diff --git a/bin/omarchy-default-agent b/bin/omarchy-default-agent new file mode 100755 index 00000000..493522b5 --- /dev/null +++ b/bin/omarchy-default-agent @@ -0,0 +1,63 @@ +#!/bin/bash + +# omarchy:summary=Set and launch the default coding agent +# omarchy:args=[pi|omp|opencode|claude|codex|grok|gemini|copilot|crush] +# omarchy:examples=omarchy default agent | omarchy default agent codex | omarchy default agent claude + +installing=false +if [[ ${1:-} == "--install" ]]; then + installing=true + shift +fi + +agent_file="$HOME/.config/omarchy/defaults/agent" + +if (($# == 0)); then + if [[ -f $agent_file ]]; then + read -r agent <"$agent_file" + fi + + [[ -n $agent ]] && echo "$agent" || echo "opencode" + exit 0 +fi + +case "$1" in +pi) agent="pi"; name="Pi" ;; +omp | oh-my-pi) agent="omp"; name="Oh My Pi"; agent_package="github:can1357/oh-my-pi" ;; +opencode | open-code) agent="opencode"; name="OpenCode" ;; +claude | claude-code) agent="claude"; name="Claude Code" ;; +codex) agent="codex"; name="Codex" ;; +crush) agent="crush"; name="Crush" ;; +grok) agent="grok"; name="Grok"; agent_package="npm:@xai-official/grok" ;; +gemini | gemini-cli) agent="gemini"; name="Gemini" ;; +copilot | github-copilot) agent="copilot"; name="GitHub Copilot" ;; +*) + echo "Usage: omarchy-default-agent " + exit 1 + ;; +esac + +agent_package=${agent_package:-$agent} + +if [[ $installing == "false" ]] && ! mise where "$agent_package" &>/dev/null; then + exec omarchy-launch-floating-terminal-with-presentation omarchy-default-agent --install "$agent" +fi + +if ! mise use -g "$agent_package"; then + if [[ $installing == "true" ]]; then + echo "Could not install $name with mise" >&2 + else + echo "Could not set $name as the default coding agent" >&2 + fi + exit 1 +fi + +mkdir -p "$(dirname "$agent_file")" +printf '%s\n' "$agent" >"$agent_file" + +if [[ $installing == "true" ]]; then + printf '\033[2J\033[3J\033[H' + exec omarchy-launch-agent --inline +else + exec omarchy-launch-agent +fi diff --git a/bin/omarchy-launch-agent b/bin/omarchy-launch-agent new file mode 100755 index 00000000..b86a7bc0 --- /dev/null +++ b/bin/omarchy-launch-agent @@ -0,0 +1,68 @@ +#!/bin/bash + +# omarchy:summary=Launch the default coding agent in a terminal +# 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=$(omarchy-default-agent) + +if omarchy-cmd-missing "$agent"; then + echo "$agent is not installed. Choose an installed agent with: omarchy default agent " >&2 + exit 1 +fi + +if (($# > 0)); then + prompt="$*" +fi + +case "$agent" in +opencode) + if [[ -n ${prompt:-} ]]; then + command=(opencode --prompt "$prompt") + else + command=(opencode) + fi + ;; +gemini) + if [[ -n ${prompt:-} ]]; then + command=(gemini --prompt-interactive "$prompt") + else + command=(gemini) + fi + ;; +copilot) + if [[ -n ${prompt:-} ]]; then + command=(copilot --interactive "$prompt") + else + command=(copilot) + fi + ;; +crush) + if [[ -n ${prompt:-} ]]; then + command=(crush run "$prompt") + else + command=(crush) + fi + ;; +pi | omp | claude | codex | grok) + command=("$agent") + [[ -n ${prompt:-} ]] && command+=(-- "$prompt") + ;; +*) + echo "Unsupported default agent: $agent" >&2 + exit 1 + ;; +esac + +if [[ $inline == "true" ]]; then + exec "${command[@]}" +else + exec omarchy-launch-tui "${command[@]}" +fi diff --git a/bin/omarchy-remove-preinstalls b/bin/omarchy-remove-preinstalls index 262b1560..e3c9c908 100755 --- a/bin/omarchy-remove-preinstalls +++ b/bin/omarchy-remove-preinstalls @@ -15,7 +15,7 @@ if gum confirm "Are you sure you want to remove all preinstalled web apps, TUI w # Remove mise stubs rm -f ~/.local/bin/codex ~/.local/bin/claude ~/.local/bin/gemini ~/.local/bin/copilot \ ~/.local/bin/gh ~/.local/bin/opencode ~/.local/bin/playwright ~/.local/bin/playwright-cli ~/.local/bin/pi \ - ~/.local/bin/ghui ~/.local/bin/hunk + ~/.local/bin/omp ~/.local/bin/grok ~/.local/bin/crush ~/.local/bin/ghui ~/.local/bin/hunk omarchy-pkg-drop \ aether \ 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/fonts/omarchy/README.md b/default/fonts/omarchy/README.md new file mode 100644 index 00000000..8eb3c441 --- /dev/null +++ b/default/fonts/omarchy/README.md @@ -0,0 +1,13 @@ +# Omarchy icon font + +The private-use glyphs in `omarchy.ttf` are: + +- `U+E900` — Omarchy +- `U+E901` — Pi, from +- `U+E902` — OpenCode, from +- `U+E903` — omp, from +- `U+E904` — Grok, from +- `U+E905` — Codex, from the OpenAI mark on + +The agent marks are monochrome so the menu can render them using the active +theme's foreground and selection colors. diff --git a/default/fonts/omarchy/omarchy.ttf b/default/fonts/omarchy/omarchy.ttf index 273256d0..a548aec1 100644 Binary files a/default/fonts/omarchy/omarchy.ttf and b/default/fonts/omarchy/omarchy.ttf differ 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/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index ddc30ef0..2806fe12 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -131,6 +131,16 @@ "setup.network.qr": {"icon":"󰐲","label":"QR Code","aliases":["wifi-qr"],"when":"[[ $(omarchy-network-status) == wifi* ]]","action":"omarchy-shell omarchy.network showQr"}, "setup.network.speedtest": {"icon":"󰓅","label":"Speed Test","aliases":["speedtest","speed-test"],"action":"omarchy-shell omarchy.network speedTest"}, "setup.default": {"icon":"","label":"Defaults","aliases":["default","defaults"]}, + "setup.default.agent": {"icon":"󰚩","label":"Agent"}, + "setup.default.agent.claude": {"icon":"󰛄","label":"Claude","checked":"[[ \"$(omarchy-default-agent)\" == \"claude\" ]]","action":"omarchy-default-agent claude"}, + "setup.default.agent.codex": {"icon":"","iconFont":"omarchy","label":"Codex","checked":"[[ \"$(omarchy-default-agent)\" == \"codex\" ]]","action":"omarchy-default-agent codex"}, + "setup.default.agent.copilot": {"icon":"","label":"Copilot","checked":"[[ \"$(omarchy-default-agent)\" == \"copilot\" ]]","action":"omarchy-default-agent copilot"}, + "setup.default.agent.crush": {"icon":"󰋑","label":"Crush","checked":"[[ \"$(omarchy-default-agent)\" == \"crush\" ]]","action":"omarchy-default-agent crush"}, + "setup.default.agent.gemini": {"icon":"󰫢","label":"Gemini","checked":"[[ \"$(omarchy-default-agent)\" == \"gemini\" ]]","action":"omarchy-default-agent gemini"}, + "setup.default.agent.grok": {"icon":"","iconFont":"omarchy","label":"Grok","checked":"[[ \"$(omarchy-default-agent)\" == \"grok\" ]]","action":"omarchy-default-agent grok"}, + "setup.default.agent.omp": {"icon":"","iconFont":"omarchy","label":"omp","checked":"[[ \"$(omarchy-default-agent)\" == \"omp\" ]]","action":"omarchy-default-agent omp"}, + "setup.default.agent.opencode": {"icon":"","iconFont":"omarchy","label":"OpenCode","checked":"[[ \"$(omarchy-default-agent)\" == \"opencode\" ]]","action":"omarchy-default-agent opencode"}, + "setup.default.agent.pi": {"icon":"","iconFont":"omarchy","label":"Pi","checked":"[[ \"$(omarchy-default-agent)\" == \"pi\" ]]","action":"omarchy-default-agent pi"}, "setup.default.browser": {"icon":"","label":"Browser"}, "setup.default.browser.chromium": {"icon":"","label":"Chromium","when":"omarchy-cmd-present chromium","checked":"[[ \"$(omarchy-default-browser)\" == \"chromium\" ]]","action":"omarchy-default-browser chromium"}, "setup.default.browser.chrome": {"icon":"󰊯","label":"Chrome","when":"omarchy-cmd-present google-chrome-stable","checked":"[[ \"$(omarchy-default-browser)\" == \"chrome\" ]]","action":"omarchy-default-browser chrome"}, @@ -214,7 +224,6 @@ "install.ai.dictation": {"icon":"","label":"Dictation","when":"! omarchy-pkg-present voxtype-bin","action":"omarchy-launch-floating-terminal-with-presentation omarchy-voxtype-install"}, "install.ai.lm-studio": {"icon":"󱚤","label":"LM Studio","when":"! omarchy-pkg-present lmstudio-bin","action":"omarchy-install-app 'LM Studio' lmstudio-bin"}, "install.ai.ollama": {"icon":"󱚤","label":"Ollama","when":"! omarchy-cmd-present ollama","action":"if omarchy-cmd-present nvidia-smi; then ollama_pkg=ollama-cuda; elif omarchy-cmd-present rocminfo; then ollama_pkg=ollama-rocm; else ollama_pkg=ollama; fi; omarchy-install-app Ollama \"$ollama_pkg\""}, - "install.ai.crush": {"icon":"󱚤","label":"Crush","when":"! omarchy-pkg-present crush-bin","action":"omarchy-install-app Crush crush-bin"}, "install.gaming.steam": {"icon":"","label":"Steam","when":"! omarchy-pkg-present steam","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-gaming-steam"}, "install.gaming.retroarch": {"icon":"󰯉","label":"RetroArch","when":"! omarchy-pkg-present retroarch","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-gaming-retroarch"}, "install.gaming.minecraft": {"icon":"󰍳","label":"Minecraft","when":"! omarchy-pkg-present minecraft-launcher","action":"omarchy-install-and-launch Minecraft minecraft-launcher minecraft-launcher"}, diff --git a/install/user/mise.sh b/install/user/mise.sh index 87c16ac1..a800393d 100644 --- a/install/user/mise.sh +++ b/install/user/mise.sh @@ -1,11 +1,13 @@ omarchy-mise-install codex omarchy-mise-install claude +omarchy-mise-install crush omarchy-mise-install gemini omarchy-mise-install gh omarchy-mise-install copilot omarchy-mise-install opencode omarchy-mise-install npm:playwright playwright omarchy-mise-install pi -omarchy-mise-install oh-my-pi omp +omarchy-mise-install github:can1357/oh-my-pi omp +omarchy-mise-install npm:@xai-official/grok grok omarchy-mise-install npm:@kitlangton/ghui ghui omarchy-mise-install aqua:modem-dev/hunk hunk diff --git a/migrations/1785617047.sh b/migrations/1785617047.sh index 89054cad..b9dd386d 100644 --- a/migrations/1785617047.sh +++ b/migrations/1785617047.sh @@ -1,3 +1,5 @@ echo "Install oh-my-pi (omp) via mise wrapper" -omarchy-mise-install oh-my-pi omp +if [[ ! -f $HOME/.local/state/omarchy/preinstalls-removed ]]; then + omarchy-mise-install github:can1357/oh-my-pi omp +fi diff --git a/migrations/1785846769.sh b/migrations/1785846769.sh new file mode 100644 index 00000000..f3f5aab9 --- /dev/null +++ b/migrations/1785846769.sh @@ -0,0 +1,9 @@ +echo "Install default coding agent mise wrappers" + +if [[ ! -f $HOME/.local/state/omarchy/preinstalls-removed ]]; then + omarchy-mise-install github:can1357/oh-my-pi omp + omarchy-mise-install npm:@xai-official/grok grok + omarchy-mise-install crush +elif [[ -f $HOME/.local/bin/omp ]] && grep -Fq 'mise use -g "oh-my-pi"' "$HOME/.local/bin/omp"; then + rm -f "$HOME/.local/bin/omp" +fi diff --git a/test/shell.d/default-agent-test.sh b/test/shell.d/default-agent-test.sh new file mode 100644 index 00000000..9ffeb63e --- /dev/null +++ b/test/shell.d/default-agent-test.sh @@ -0,0 +1,341 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +mock_bin="$test_tmp/bin" +test_home="$test_tmp/home" +agent_file="$test_home/.config/omarchy/defaults/agent" +notification_history="$test_tmp/notification-history" +agent_open_log="$test_tmp/agent-open" +launch_log="$test_tmp/launch" +inline_log="$test_tmp/inline" +mise_log="$test_tmp/mise" +mise_history="$test_tmp/mise-history" +stub_log="$test_tmp/stubs" +terminal_log="$test_tmp/terminal" +mkdir -p "$mock_bin" "$test_home" + +cat >"$mock_bin/omarchy-notification-send" <<'SH' +#!/bin/bash +printf '%s\0' "$@" >>"$OMARCHY_TEST_NOTIFICATION_HISTORY" +SH + +cat >"$mock_bin/omarchy-cmd-missing" <<'SH' +#!/bin/bash +[[ $1 == ${OMARCHY_TEST_MISSING_COMMAND:-} ]] +SH + +cat >"$mock_bin/omarchy-launch-tui" <<'SH' +#!/bin/bash +printf '%s\0' "$@" >"$OMARCHY_TEST_AGENT_LAUNCH_LOG" +SH + +cat >"$mock_bin/omarchy-launch-floating-terminal-with-presentation" <<'SH' +#!/bin/bash +printf '%s\0' "$@" >"$OMARCHY_TEST_AGENT_TERMINAL_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" +SH + +cat >"$mock_bin/mise" <<'SH' +#!/bin/bash +printf '%s\0' "$@" >"$OMARCHY_TEST_MISE_LOG" +printf '%s\n' "$*" >>"$OMARCHY_TEST_MISE_HISTORY" + +if [[ $1 == "where" ]]; then + [[ ${OMARCHY_TEST_AGENT_INSTALLED:-false} == "true" ]] + exit +fi + +[[ ${OMARCHY_TEST_MISE_FAIL:-false} != "true" ]] +SH + +cat >"$mock_bin/omarchy-test-noop" <<'SH' +#!/bin/bash +exit 0 +SH + +for command in gum hyprctl omarchy-webapp-remove-all omarchy-tui-remove-all omarchy-pkg-drop; do + ln -s omarchy-test-noop "$mock_bin/$command" +done + +chmod +x "$mock_bin"/* + +export HOME="$test_home" +export PATH="$mock_bin:$ROOT/bin:$PATH" +export OMARCHY_TEST_NOTIFICATION_HISTORY="$notification_history" +export OMARCHY_TEST_AGENT_OPEN_LOG="$agent_open_log" +export OMARCHY_TEST_AGENT_LAUNCH_LOG="$launch_log" +export OMARCHY_TEST_AGENT_INLINE_LOG="$inline_log" +export OMARCHY_TEST_MISE_LOG="$mise_log" +export OMARCHY_TEST_MISE_HISTORY="$mise_history" +export OMARCHY_TEST_STUB_LOG="$stub_log" +export OMARCHY_TEST_AGENT_TERMINAL_LOG="$terminal_log" + +grok_package="npm:@xai-official/grok" +omp_package="github:can1357/oh-my-pi" +crush_package="crush" + +assert_lazy_stub() { + local package=$1 + local command=$2 + + : >"$mise_history" + "$ROOT/bin/omarchy-mise-install" "$package" "$command" + "$test_home/.local/bin/$command" --version + mapfile -t mise_calls <"$mise_history" + + [[ ${mise_calls[0]} == "use -g $package" && ${mise_calls[1]} == "x $package -- $command --version" ]] || + fail "$command lazy stub preserves its mise package" +} + +assert_lazy_stub "$grok_package" grok +assert_lazy_stub "$omp_package" omp +assert_lazy_stub "$crush_package" crush +pass "custom agent lazy stubs preserve their mise packages" + +source "$ROOT/install/user/mise.sh" +grep -Fx "$grok_package grok" "$stub_log" >/dev/null || fail "user setup creates the Grok lazy stub" +grep -Fx "$omp_package omp" "$stub_log" >/dev/null || fail "user setup creates the Oh My Pi lazy stub" +grep -Fx "$crush_package" "$stub_log" >/dev/null || fail "user setup creates the Crush lazy stub" +pass "user setup creates the custom agent lazy stubs" + +: >"$stub_log" +source "$ROOT/migrations/1785617047.sh" >/dev/null +grep -Fx "$omp_package omp" "$stub_log" >/dev/null || fail "Oh My Pi migration creates a working lazy stub" + +: >"$stub_log" +source "$ROOT/migrations/1785846769.sh" >/dev/null +grep -Fx "$omp_package omp" "$stub_log" >/dev/null || fail "agent migration repairs the Oh My Pi lazy stub" +grep -Fx "$grok_package grok" "$stub_log" >/dev/null || fail "agent migration creates the Grok lazy stub" +grep -Fx "$crush_package" "$stub_log" >/dev/null || fail "agent migration creates the Crush lazy stub" + +mkdir -p "$test_home/.local/state/omarchy" +touch "$test_home/.local/state/omarchy/preinstalls-removed" +"$ROOT/bin/omarchy-mise-install" oh-my-pi omp +: >"$stub_log" +source "$ROOT/migrations/1785617047.sh" >/dev/null +source "$ROOT/migrations/1785846769.sh" >/dev/null +[[ ! -s $stub_log ]] || fail "agent migrations respect the preinstall opt-out" +[[ ! -e $test_home/.local/bin/omp ]] || fail "agent migration removes the obsolete Oh My Pi wrapper after opt-out" +rm "$test_home/.local/state/omarchy/preinstalls-removed" +pass "agent migrations install working wrappers without overriding the preinstall opt-out" + +omarchy-remove-preinstalls >/dev/null +for command in omp grok crush; do + [[ ! -e $test_home/.local/bin/$command ]] || fail "Remove Preinstalls deletes the $command lazy stub" +done +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 launch_args <"$launch_log" +[[ ${#launch_args[@]} == 1 && ${launch_args[0]} == "opencode" ]] || + fail "agent launcher falls back to OpenCode before a default is selected" +pass "agent launcher falls back to OpenCode 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" + +cat >"$mock_bin/omarchy-launch-agent" <<'SH' +#!/bin/bash +printf '%s\0' omarchy-launch-agent "$@" >"$OMARCHY_TEST_AGENT_OPEN_LOG" +SH +chmod +x "$mock_bin/omarchy-launch-agent" +hash -r + +declare -A expected_agents=( + [pi]="pi" + [omp]="omp" + [oh-my-pi]="omp" + [opencode]="opencode" + [open-code]="opencode" + [claude]="claude" + [claude-code]="claude" + [codex]="codex" + [crush]="crush" + [grok]="grok" + [gemini]="gemini" + [gemini-cli]="gemini" + [copilot]="copilot" + [github-copilot]="copilot" +) + +declare -A expected_packages=( + [pi]="pi" + [omp]="$omp_package" + [opencode]="opencode" + [claude]="claude" + [codex]="codex" + [crush]="$crush_package" + [grok]="$grok_package" + [gemini]="gemini" + [copilot]="copilot" +) + +for selection in "${!expected_agents[@]}"; do + expected=${expected_agents[$selection]} + : >"$agent_open_log" + OMARCHY_TEST_AGENT_INSTALLED=true omarchy-default-agent "$selection" + [[ $(omarchy-default-agent) == $expected ]] || fail "default agent canonicalizes $selection" + + mapfile -d '' -t mise_args <"$mise_log" + [[ ${mise_args[0]} == "use" && ${mise_args[1]} == "-g" && ${mise_args[2]} == ${expected_packages[$expected]} ]] || + fail "default agent installs $selection globally through mise" + + mapfile -d '' -t agent_open_args <"$agent_open_log" + [[ ${#agent_open_args[@]} == 1 && ${agent_open_args[0]} == "omarchy-launch-agent" ]] || + fail "default agent opens $selection after selecting it" +done +pass "default agent selects and opens every supported provider and alias" +[[ -f $agent_file && ! -e $test_home/.local/state/omarchy/defaults/agent ]] || + fail "default agent stores its selection in Omarchy user config" +pass "default agent stores its selection in Omarchy user config" + +OMARCHY_TEST_AGENT_INSTALLED=true omarchy-default-agent pi +: >"$notification_history" +: >"$agent_open_log" +: >"$terminal_log" +omarchy-default-agent github-copilot +mapfile -d '' -t terminal_args <"$terminal_log" +[[ ${terminal_args[0]} == "omarchy-default-agent" && ${terminal_args[1]} == "--install" && ${terminal_args[2]} == "copilot" ]] || + fail "missing agent installation opens in a terminal" +[[ ! -s $notification_history ]] || fail "missing agent installation skips notifications" +[[ ! -s $agent_open_log ]] || fail "missing agent installation waits to open the agent" +[[ $(omarchy-default-agent) == "pi" ]] || fail "missing agent installation waits to change the selection" + +omarchy-default-agent --install github-copilot >"$test_tmp/install-output" +mapfile -d '' -t mise_args <"$mise_log" +[[ ${mise_args[0]} == "use" && ${mise_args[1]} == "-g" && ${mise_args[2]} == "copilot" ]] || + fail "visible agent installation activates the provider globally through mise" +[[ $(omarchy-default-agent) == "copilot" ]] || fail "visible agent installation changes the selection after mise succeeds" +[[ ! -s $notification_history ]] || fail "visible agent installation leaves progress to the terminal" +[[ $(<"$test_tmp/install-output") == $'\033[2J\033[3J\033[H' ]] || + fail "visible agent installation clears its terminal before opening the agent" +mapfile -d '' -t agent_open_args <"$agent_open_log" +[[ ${#agent_open_args[@]} == 2 && ${agent_open_args[0]} == "omarchy-launch-agent" && ${agent_open_args[1]} == "--inline" ]] || + fail "newly installed agent opens in the installation terminal" +pass "missing agents install visibly and open in the same terminal" + +: >"$notification_history" +: >"$agent_open_log" +: >"$terminal_log" +OMARCHY_TEST_AGENT_INSTALLED=true omarchy-default-agent github-copilot +[[ ! -s $terminal_log ]] || fail "installed agent selection skips the terminal" +[[ ! -s $notification_history ]] || fail "installed agent selection skips notifications" +mapfile -d '' -t mise_args <"$mise_log" +[[ ${mise_args[0]} == "use" && ${mise_args[1]} == "-g" && ${mise_args[2]} == "copilot" ]] || + fail "default agent still activates an installed provider globally through mise" +mapfile -d '' -t agent_open_args <"$agent_open_log" +[[ ${#agent_open_args[@]} == 1 && ${agent_open_args[0]} == "omarchy-launch-agent" ]] || + fail "installed agent opens in a new terminal after selection" +pass "installed agents select and open without notifications" + +: >"$agent_open_log" +if omarchy-default-agent unsupported >"$test_tmp/invalid-output" 2>&1; then + fail "default agent rejects unsupported providers" +fi +grep -F "Usage: omarchy-default-agent" "$test_tmp/invalid-output" >/dev/null || + fail "default agent explains supported providers" +[[ $(omarchy-default-agent) == "copilot" ]] || fail "invalid selection preserves the current default agent" +[[ ! -s $agent_open_log ]] || fail "invalid selection does not open an agent" +pass "default agent rejects unsupported providers without changing the selection" + +: >"$notification_history" +: >"$agent_open_log" +if OMARCHY_TEST_MISE_FAIL=true omarchy-default-agent --install codex >"$test_tmp/install-failure-output" 2>&1; then + fail "default agent rejects a failed mise installation" +fi +[[ $(omarchy-default-agent) == "copilot" ]] || fail "failed installation preserves the current default agent" +grep -F "Could not install Codex with mise" "$test_tmp/install-failure-output" >/dev/null || + fail "default agent reports a failed mise installation in the terminal" +[[ ! -s $notification_history ]] || fail "failed visible agent installation skips notifications" +[[ ! -s $agent_open_log ]] || fail "failed installation does not open an agent" +pass "default agent opens only after mise installs the provider" + +: >"$notification_history" +: >"$agent_open_log" +if OMARCHY_TEST_AGENT_INSTALLED=true OMARCHY_TEST_MISE_FAIL=true omarchy-default-agent codex >"$test_tmp/setup-failure-output" 2>&1; then + fail "default agent rejects a failed mise activation" +fi +[[ $(omarchy-default-agent) == "copilot" ]] || fail "failed activation preserves the current default agent" +grep -F "Could not set Codex as the default coding agent" "$test_tmp/setup-failure-output" >/dev/null || + fail "default agent reports a failed activation for an installed provider" +[[ ! -s $notification_history ]] || fail "failed activation skips notifications" +[[ ! -s $agent_open_log ]] || fail "failed activation does not open an agent" +pass "default agent reports mise failures without notifications" + +rm "$mock_bin/omarchy-launch-agent" +hash -r + +assert_launch() { + local agent=$1 + shift + local expected=("$@") + + printf '%s\n' "$agent" >"$agent_file" + omarchy-launch-agent "Review this" project + mapfile -d '' -t actual <"$launch_log" + + (( ${#actual[@]} == ${#expected[@]} )) || + fail "$agent launch has the expected argument count" "expected: ${expected[*]}\nactual: ${actual[*]}" + + for ((index = 0; index < ${#expected[@]}; index++)); do + [[ ${actual[$index]} == ${expected[$index]} ]] || + fail "$agent launch forwards the interactive prompt" "expected: ${expected[*]}\nactual: ${actual[*]}" + done +} + +assert_launch pi pi -- "Review this project" +assert_launch omp omp -- "Review this project" +assert_launch opencode opencode --prompt "Review this project" +assert_launch claude claude -- "Review this project" +assert_launch codex codex -- "Review this project" +assert_launch crush crush run "Review this project" +assert_launch grok grok -- "Review this project" +assert_launch gemini gemini --prompt-interactive "Review this project" +assert_launch copilot copilot --interactive "Review this project" +pass "agent launcher adapts initial prompts for every supported agent" + +printf '%s\n' "opencode" >"$agent_file" +omarchy-launch-agent +mapfile -d '' -t launch_args <"$launch_log" +[[ ${#launch_args[@]} == 1 && ${launch_args[0]} == "opencode" ]] || + 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" >"$agent_file" +if OMARCHY_TEST_MISSING_COMMAND=missing omarchy-launch-agent >"$test_tmp/missing-output" 2>&1; then + fail "agent launcher rejects a missing default command" +fi +grep -F "missing is not installed" "$test_tmp/missing-output" >/dev/null || + fail "agent launcher explains when the default command is missing" +pass "agent launcher reports a missing default command" diff --git a/test/shell.d/menu-test.sh b/test/shell.d/menu-test.sh index 6ff4f015..ccb8ce7f 100644 --- a/test/shell.d/menu-test.sh +++ b/test/shell.d/menu-test.sh @@ -167,6 +167,38 @@ assertEqual( defaultItems.findIndex(item => item.id === 'setup.input') + 1, 'menu lists Direct Boot immediately below Input' ) +const expectedAgents = { + pi: { icon: '\ue901', iconFont: 'omarchy', label: 'Pi' }, + omp: { icon: '\ue903', iconFont: 'omarchy', label: 'omp' }, + opencode: { icon: '\ue902', iconFont: 'omarchy', label: 'OpenCode' }, + claude: { icon: '󰛄', label: 'Claude' }, + codex: { icon: '\ue905', iconFont: 'omarchy', label: 'Codex' }, + grok: { icon: '\ue904', iconFont: 'omarchy', label: 'Grok' }, + gemini: { icon: '󰫢', label: 'Gemini' }, + copilot: { icon: '', label: 'Copilot' }, + crush: { icon: '󰋑', label: 'Crush' }, +} +assert( + Object.entries(expectedAgents).every(([agent, expected]) => { + const entry = defaultById[`setup.default.agent.${agent}`] + return entry + && entry.icon === expected.icon + && entry.iconFont === (expected.iconFont || '') + && entry.label === expected.label + && entry.action === `omarchy-default-agent ${agent}` + && !entry.when + && entry.checked.includes(`== \"${agent}\"`) + }), + 'menu exposes every mise-installable coding agent with its own glyph under Defaults > Agent' +) +assertDeepEqual( + defaultItems + .filter(item => item.parent === 'setup.default.agent') + .map(item => item.label), + ['Claude', 'Codex', 'Copilot', 'Crush', 'Gemini', 'Grok', 'omp', 'OpenCode', 'Pi'], + 'menu sorts coding agents alphabetically' +) +assert(!defaultById['install.ai.crush'], 'menu removes Crush from Install > AI') assert( defaultById['setup.security.passwordless-sudo'].action.includes('omarchy-sudo-passwordless'), 'menu places Passwordless Sudo under Setup > Security' @@ -452,3 +484,7 @@ assert( 'mouse activation carries pointer intent into subordinate menus' ) JS + +font_charset=$(fc-query --format='%{charset}' "$ROOT/default/fonts/omarchy/omarchy.ttf") +[[ $font_charset == *"e900-e905"* ]] || fail "Omarchy icon font includes every custom menu glyph" +pass "Omarchy icon font includes the official agent marks"