diff --git a/bin/omarchy-launch-agent b/bin/omarchy-launch-agent index aef81821..9e5a5ddc 100755 --- a/bin/omarchy-launch-agent +++ b/bin/omarchy-launch-agent @@ -1,9 +1,22 @@ #!/bin/bash # omarchy:summary=Launch the default coding agent in a terminal -# omarchy:args=[prompt...] +# omarchy:args=[--inline] [prompt...] # omarchy:examples=omarchy launch agent | omarchy launch agent "Review this project" +if [[ ${1:-} == "--inline" ]]; then + inline=true + shift +else + inline=false +fi + +agent_file="$HOME/.local/state/omarchy/defaults/agent" + +if [[ ! -s $agent_file ]]; then + exec omarchy-menu summon setup.default.agent +fi + agent=$(omarchy-default-agent) if omarchy-cmd-missing "$agent"; then @@ -58,4 +71,8 @@ pi | omp | claude | codex | grok) ;; esac -exec omarchy-launch-tui "${command[@]}" +if [[ $inline == "true" ]]; then + exec "${command[@]}" +else + exec omarchy-launch-tui "${command[@]}" +fi diff --git a/default/bash/aliases b/default/bash/aliases index 7433541e..bc44e0bf 100644 --- a/default/bash/aliases +++ b/default/bash/aliases @@ -43,6 +43,7 @@ alias ...='cd ../..' alias ....='cd ../../..' # Tools +alias a='omarchy-launch-agent --inline' alias c='opencode --auto' alias cx='printf "\033[2J\033[3J\033[H" && claude --permission-mode bypassPermissions' alias cy='codex -s danger-full-access -a never' diff --git a/default/hypr/bindings/utilities.lua b/default/hypr/bindings/utilities.lua index 6be42a7a..48b9c519 100644 --- a/default/hypr/bindings/utilities.lua +++ b/default/hypr/bindings/utilities.lua @@ -74,6 +74,7 @@ o.bind("SUPER + CTRL + ALT + T", "Show time", "omarchy-notification-time") o.bind("SUPER + CTRL + ALT + B", "Show battery remaining", "omarchy-notification-battery") o.bind("SUPER + CTRL + ALT + W", "Toggle weather", "omarchy-notification-weather") +o.bind("SUPER + SHIFT + CTRL + A", "Agent", "omarchy-launch-agent") o.bind("SUPER + CTRL + A", "Audio", "omarchy-shell shell toggle omarchy.audio") o.bind("SUPER + CTRL + B", "Bluetooth", "omarchy-shell shell toggle omarchy.bluetooth") o.bind("SUPER + CTRL + D", "Display", "omarchy-shell shell toggle omarchy.monitor") diff --git a/test/shell.d/default-agent-test.sh b/test/shell.d/default-agent-test.sh index 895bedf4..1c284867 100644 --- a/test/shell.d/default-agent-test.sh +++ b/test/shell.d/default-agent-test.sh @@ -12,8 +12,10 @@ test_home="$test_tmp/home" notification_log="$test_tmp/notifications" notification_history="$test_tmp/notification-history" launch_log="$test_tmp/launch" +inline_log="$test_tmp/inline" mise_log="$test_tmp/mise" mise_history="$test_tmp/mise-history" +picker_log="$test_tmp/picker" stub_log="$test_tmp/stubs" mkdir -p "$mock_bin" "$test_home" @@ -33,6 +35,16 @@ cat >"$mock_bin/omarchy-launch-tui" <<'SH' printf '%s\0' "$@" >"$OMARCHY_TEST_AGENT_LAUNCH_LOG" SH +cat >"$mock_bin/omarchy-menu" <<'SH' +#!/bin/bash +printf '%s\0' "$@" >"$OMARCHY_TEST_AGENT_PICKER_LOG" +SH + +cat >"$mock_bin/opencode" <<'SH' +#!/bin/bash +printf '%s\0' opencode "$@" >"$OMARCHY_TEST_AGENT_INLINE_LOG" +SH + cat >"$mock_bin/omarchy-mise-install" <<'SH' #!/bin/bash printf '%s\n' "$*" >>"$OMARCHY_TEST_STUB_LOG" @@ -67,6 +79,8 @@ export PATH="$mock_bin:$ROOT/bin:$PATH" export OMARCHY_TEST_NOTIFICATION_LOG="$notification_log" export OMARCHY_TEST_NOTIFICATION_HISTORY="$notification_history" export OMARCHY_TEST_AGENT_LAUNCH_LOG="$launch_log" +export OMARCHY_TEST_AGENT_INLINE_LOG="$inline_log" +export OMARCHY_TEST_AGENT_PICKER_LOG="$picker_log" export OMARCHY_TEST_MISE_LOG="$mise_log" export OMARCHY_TEST_MISE_HISTORY="$mise_history" export OMARCHY_TEST_STUB_LOG="$stub_log" @@ -129,6 +143,22 @@ pass "Remove Preinstalls deletes every optional agent lazy stub" [[ $(omarchy-default-agent) == "opencode" ]] || fail "default agent falls back to OpenCode" pass "default agent falls back to OpenCode" +omarchy-launch-agent +mapfile -d '' -t picker_args <"$picker_log" +[[ ${picker_args[0]} == "summon" && ${picker_args[1]} == "setup.default.agent" ]] || + fail "agent launcher opens the picker before a default is selected" +pass "agent launcher opens the picker before a default is selected" + +source "$ROOT/default/bash/aliases" +[[ $(alias a) == "alias a='omarchy-launch-agent --inline'" ]] || + fail "terminal alias launches the default agent inline" +pass "terminal alias launches the default agent inline" + +grep -Fq 'o.bind("SUPER + SHIFT + CTRL + A", "Agent", "omarchy-launch-agent")' \ + "$ROOT/default/hypr/bindings/utilities.lua" || + fail "agent launcher has a keyboard shortcut" +pass "agent launcher has a keyboard shortcut" + declare -A expected_agents=( [pi]="pi" [omp]="omp" @@ -265,6 +295,12 @@ mapfile -d '' -t launch_args <"$launch_log" fail "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" +mapfile -d '' -t inline_args <"$inline_log" +[[ ${inline_args[0]} == "opencode" && ${inline_args[1]} == "--prompt" && ${inline_args[2]} == "Review this project" ]] || + fail "inline agent launcher runs in the current terminal" +pass "inline agent launcher runs in the current terminal" + printf '%s\n' "missing" >"$test_home/.local/state/omarchy/defaults/agent" if OMARCHY_TEST_MISSING_COMMAND=missing omarchy-launch-agent >"$test_tmp/missing-output" 2>&1; then fail "agent launcher rejects a missing default command"