Fix default agent setup edge cases

This commit is contained in:
David Heinemeier Hansson
2026-08-01 19:52:04 -07:00
parent 6009e8a73b
commit 7b4fb0ad6b
6 changed files with 69 additions and 9 deletions
+6 -2
View File
@@ -17,7 +17,7 @@ fi
case "$1" in
pi) agent="pi"; name="Pi" ;;
omp | oh-my-pi) agent="omp"; name="Oh My Pi"; agent_package="oh-my-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" ;;
@@ -40,7 +40,11 @@ if ! mise where "$agent_package" &>/dev/null; then
fi
if ! mise use -g "$agent_package"; then
[[ $installing == "true" ]] && omarchy-notification-send -g 󰚩 "Could not install $name with mise"
if [[ $installing == "true" ]]; then
omarchy-notification-send -g 󰚩 "Could not install $name with mise"
else
omarchy-notification-send -g 󰚩 "Could not set $name as the default coding agent"
fi
exit 1
fi
+1 -1
View File
@@ -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 \
+1 -1
View File
@@ -7,7 +7,7 @@ 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
+3 -1
View File
@@ -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
+8 -3
View File
@@ -1,4 +1,9 @@
echo "Install Grok and Crush via mise wrappers"
echo "Install default coding agent mise wrappers"
omarchy-mise-install npm:@xai-official/grok grok
omarchy-mise-install crush
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
+50 -1
View File
@@ -51,6 +51,15 @@ 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"
@@ -63,7 +72,7 @@ export OMARCHY_TEST_MISE_HISTORY="$mise_history"
export OMARCHY_TEST_STUB_LOG="$stub_log"
grok_package="npm:@xai-official/grok"
omp_package="oh-my-pi"
omp_package="github:can1357/oh-my-pi"
crush_package="crush"
assert_lazy_stub() {
@@ -90,6 +99,33 @@ grep -Fx "$omp_package omp" "$stub_log" >/dev/null || fail "user setup creates t
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/1785633225.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/1785633225.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"
@@ -170,6 +206,19 @@ mapfile -d '' -t notification_args <"$notification_log"
fail "default agent reports a failed mise installation"
pass "default agent changes selection only after mise installs the provider"
: >"$notification_history"
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"
mapfile -d '' -t notification_args <"$notification_log"
[[ ${notification_args[2]} == "Could not set Codex as the default coding agent" ]] ||
fail "default agent reports a failed activation for an installed provider"
mapfile -d '' -t notification_history_args <"$notification_history"
[[ ${#notification_history_args[@]} == 3 ]] ||
fail "failed activation sends only the selection failure notification"
pass "default agent reports mise failures for installed providers"
assert_launch() {
local agent=$1
shift