Launch the default coding agent without permission prompts (#6729)
Every supported agent spells it differently, so map each one to its own bypass flag instead of leaving the launcher at each agent's default. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
2fa490dc96
commit
d6b21f8075
+24
-18
@@ -26,37 +26,43 @@ if (($# > 0)); then
|
|||||||
prompt="$*"
|
prompt="$*"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Agents launched from the keybinding or menu run unattended, so each one starts
|
||||||
|
# with its own spelling of "don't stop to ask". Pi has no approval prompts.
|
||||||
case "$agent" in
|
case "$agent" in
|
||||||
opencode)
|
opencode)
|
||||||
if [[ -n ${prompt:-} ]]; then
|
command=(opencode --auto)
|
||||||
command=(opencode --prompt "$prompt")
|
[[ -n ${prompt:-} ]] && command+=(--prompt "$prompt")
|
||||||
else
|
|
||||||
command=(opencode)
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
gemini)
|
gemini)
|
||||||
if [[ -n ${prompt:-} ]]; then
|
command=(gemini --yolo)
|
||||||
command=(gemini --prompt-interactive "$prompt")
|
[[ -n ${prompt:-} ]] && command+=(--prompt-interactive "$prompt")
|
||||||
else
|
|
||||||
command=(gemini)
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
copilot)
|
copilot)
|
||||||
if [[ -n ${prompt:-} ]]; then
|
command=(copilot --allow-all)
|
||||||
command=(copilot --interactive "$prompt")
|
[[ -n ${prompt:-} ]] && command+=(--interactive "$prompt")
|
||||||
else
|
|
||||||
command=(copilot)
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
crush)
|
crush)
|
||||||
|
# --yolo belongs to the interactive command only; `crush run` never prompts.
|
||||||
if [[ -n ${prompt:-} ]]; then
|
if [[ -n ${prompt:-} ]]; then
|
||||||
command=(crush run "$prompt")
|
command=(crush run "$prompt")
|
||||||
else
|
else
|
||||||
command=(crush)
|
command=(crush --yolo)
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
pi | omp | claude | codex | grok)
|
claude | grok)
|
||||||
command=("$agent")
|
command=("$agent" --permission-mode bypassPermissions)
|
||||||
|
[[ -n ${prompt:-} ]] && command+=(-- "$prompt")
|
||||||
|
;;
|
||||||
|
codex)
|
||||||
|
command=(codex --dangerously-bypass-approvals-and-sandbox)
|
||||||
|
[[ -n ${prompt:-} ]] && command+=(-- "$prompt")
|
||||||
|
;;
|
||||||
|
omp)
|
||||||
|
command=(omp --auto-approve)
|
||||||
|
[[ -n ${prompt:-} ]] && command+=(-- "$prompt")
|
||||||
|
;;
|
||||||
|
pi)
|
||||||
|
command=(pi)
|
||||||
[[ -n ${prompt:-} ]] && command+=(-- "$prompt")
|
[[ -n ${prompt:-} ]] && command+=(-- "$prompt")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ pass "default agent falls back to OpenCode"
|
|||||||
|
|
||||||
omarchy-launch-agent
|
omarchy-launch-agent
|
||||||
mapfile -d '' -t launch_args <"$launch_log"
|
mapfile -d '' -t launch_args <"$launch_log"
|
||||||
[[ ${#launch_args[@]} == 1 && ${launch_args[0]} == "opencode" ]] ||
|
[[ ${launch_args[*]} == "opencode --auto" ]] ||
|
||||||
fail "agent launcher falls back to OpenCode before a default is selected"
|
fail "agent launcher falls back to OpenCode before a default is selected"
|
||||||
pass "agent launcher falls back to OpenCode before a default is selected"
|
pass "agent launcher falls back to OpenCode before a default is selected"
|
||||||
|
|
||||||
@@ -290,45 +290,73 @@ pass "default agent reports mise failures without notifications"
|
|||||||
rm "$mock_bin/omarchy-launch-agent"
|
rm "$mock_bin/omarchy-launch-agent"
|
||||||
hash -r
|
hash -r
|
||||||
|
|
||||||
assert_launch() {
|
assert_launched() {
|
||||||
local agent=$1
|
local agent=$1
|
||||||
shift
|
local description=$2
|
||||||
|
shift 2
|
||||||
local expected=("$@")
|
local expected=("$@")
|
||||||
|
|
||||||
printf '%s\n' "$agent" >"$agent_file"
|
|
||||||
omarchy-launch-agent "Review this" project
|
|
||||||
mapfile -d '' -t actual <"$launch_log"
|
mapfile -d '' -t actual <"$launch_log"
|
||||||
|
|
||||||
(( ${#actual[@]} == ${#expected[@]} )) ||
|
(( ${#actual[@]} == ${#expected[@]} )) ||
|
||||||
fail "$agent launch has the expected argument count" "expected: ${expected[*]}\nactual: ${actual[*]}"
|
fail "$agent launch $description" "expected: ${expected[*]}\nactual: ${actual[*]}"
|
||||||
|
|
||||||
for ((index = 0; index < ${#expected[@]}; index++)); do
|
for ((index = 0; index < ${#expected[@]}; index++)); do
|
||||||
[[ ${actual[$index]} == ${expected[$index]} ]] ||
|
[[ ${actual[$index]} == ${expected[$index]} ]] ||
|
||||||
fail "$agent launch forwards the interactive prompt" "expected: ${expected[*]}\nactual: ${actual[*]}"
|
fail "$agent launch $description" "expected: ${expected[*]}\nactual: ${actual[*]}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_launch() {
|
||||||
|
local agent=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
printf '%s\n' "$agent" >"$agent_file"
|
||||||
|
omarchy-launch-agent "Review this" project
|
||||||
|
assert_launched "$agent" "forwards the interactive prompt" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_bypass() {
|
||||||
|
local agent=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
printf '%s\n' "$agent" >"$agent_file"
|
||||||
|
omarchy-launch-agent
|
||||||
|
assert_launched "$agent" "skips permission prompts" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
assert_launch pi pi -- "Review this project"
|
assert_launch pi pi -- "Review this project"
|
||||||
assert_launch omp omp -- "Review this project"
|
assert_launch omp omp --auto-approve -- "Review this project"
|
||||||
assert_launch opencode opencode --prompt "Review this project"
|
assert_launch opencode opencode --auto --prompt "Review this project"
|
||||||
assert_launch claude claude -- "Review this project"
|
assert_launch claude claude --permission-mode bypassPermissions -- "Review this project"
|
||||||
assert_launch codex codex -- "Review this project"
|
assert_launch codex codex --dangerously-bypass-approvals-and-sandbox -- "Review this project"
|
||||||
assert_launch crush crush run "Review this project"
|
assert_launch crush crush run "Review this project"
|
||||||
assert_launch grok grok -- "Review this project"
|
assert_launch grok grok --permission-mode bypassPermissions -- "Review this project"
|
||||||
assert_launch gemini gemini --prompt-interactive "Review this project"
|
assert_launch gemini gemini --yolo --prompt-interactive "Review this project"
|
||||||
assert_launch copilot copilot --interactive "Review this project"
|
assert_launch copilot copilot --allow-all --interactive "Review this project"
|
||||||
pass "agent launcher adapts initial prompts for every supported agent"
|
pass "agent launcher adapts initial prompts for every supported agent"
|
||||||
|
|
||||||
|
assert_bypass pi pi
|
||||||
|
assert_bypass omp omp --auto-approve
|
||||||
|
assert_bypass opencode opencode --auto
|
||||||
|
assert_bypass claude claude --permission-mode bypassPermissions
|
||||||
|
assert_bypass codex codex --dangerously-bypass-approvals-and-sandbox
|
||||||
|
assert_bypass crush crush --yolo
|
||||||
|
assert_bypass grok grok --permission-mode bypassPermissions
|
||||||
|
assert_bypass gemini gemini --yolo
|
||||||
|
assert_bypass copilot copilot --allow-all
|
||||||
|
pass "agent launcher skips permission prompts for every supported agent"
|
||||||
|
|
||||||
printf '%s\n' "opencode" >"$agent_file"
|
printf '%s\n' "opencode" >"$agent_file"
|
||||||
omarchy-launch-agent
|
omarchy-launch-agent
|
||||||
mapfile -d '' -t launch_args <"$launch_log"
|
mapfile -d '' -t launch_args <"$launch_log"
|
||||||
[[ ${#launch_args[@]} == 1 && ${launch_args[0]} == "opencode" ]] ||
|
[[ ${launch_args[*]} == "opencode --auto" ]] ||
|
||||||
fail "agent launcher starts the selected agent without an initial prompt"
|
fail "agent launcher starts the selected agent without an initial prompt"
|
||||||
pass "agent launcher starts the selected agent without an initial prompt"
|
pass "agent launcher starts the selected agent without an initial prompt"
|
||||||
|
|
||||||
omarchy-launch-agent --inline "Review this project"
|
omarchy-launch-agent --inline "Review this project"
|
||||||
mapfile -d '' -t inline_args <"$inline_log"
|
mapfile -d '' -t inline_args <"$inline_log"
|
||||||
[[ ${inline_args[0]} == "opencode" && ${inline_args[1]} == "--prompt" && ${inline_args[2]} == "Review this project" ]] ||
|
[[ ${inline_args[*]} == "opencode --auto --prompt Review this project" ]] ||
|
||||||
fail "inline agent launcher runs in the current terminal"
|
fail "inline agent launcher runs in the current terminal"
|
||||||
pass "inline agent launcher runs in the current terminal"
|
pass "inline agent launcher runs in the current terminal"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user