From facdcf3f55c2c8c4a685685ed544e01e80f88fb4 Mon Sep 17 00:00:00 2001 From: Jesse Miller Date: Wed, 30 Sep 2026 10:18:27 -0600 Subject: [PATCH] Install Grok through mise's first-party package The npm launcher keeps an old ~/.grok/bin binary because mise skips its postinstall. Use mise's grok tool, and drop the npm tool so its shim does not stay ahead of the stub. --- bin/omarchy-default-agent | 2 +- install/user/mise.sh | 2 +- manual/17-ai.md | 6 +- migrations/1790863209.sh | 53 ++++++++++++++ test/shell.d/default-agent-test.sh | 113 ++++++++++++++++++++++++++++- 5 files changed, 169 insertions(+), 7 deletions(-) create mode 100644 migrations/1790863209.sh diff --git a/bin/omarchy-default-agent b/bin/omarchy-default-agent index 4cf77f79fcbc..684baaf23e2e 100755 --- a/bin/omarchy-default-agent +++ b/bin/omarchy-default-agent @@ -31,7 +31,7 @@ ori | openrouter) agent="ori"; name="Ori"; agent_package="github:OpenRouterLabs/ 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" ;; +grok) agent="grok"; name="Grok" ;; openclaw) agent="openclaw"; name="OpenClaw"; agent_installer="omarchy-install-openclaw-cli" ;; agy | antigravity | antigravity-cli | gemini | gemini-cli) agent="agy"; name="Antigravity"; agent_package="antigravity-cli" ;; hermes) agent="hermes"; name="Hermes"; agent_installer="omarchy-install-hermes-cli" ;; diff --git a/install/user/mise.sh b/install/user/mise.sh index 89f1cfb5852b..1d85e2b36630 100644 --- a/install/user/mise.sh +++ b/install/user/mise.sh @@ -12,7 +12,7 @@ omarchy-mise-install opencode omarchy-mise-install npm:playwright playwright omarchy-mise-install pi omarchy-mise-install github:can1357/oh-my-pi omp -omarchy-mise-install npm:@xai-official/grok grok +omarchy-mise-install grok # Cursor's own installer links the same path, so a re-provision keeps it. omarchy-cmd-missing cursor-agent && omarchy-mise-install cursor-agent omarchy-mise-install npm:@kitlangton/ghui ghui diff --git a/manual/17-ai.md b/manual/17-ai.md index 6739a612777b..e293c0c6b40f 100644 --- a/manual/17-ai.md +++ b/manual/17-ai.md @@ -10,7 +10,7 @@ Omarchy treats AI coding agents as first-class citizens, but it doesn't pick a f | `agy` | [Google Antigravity CLI](https://github.com/google-antigravity/antigravity-cli) | | `copilot` | [GitHub Copilot CLI](https://github.com/github/copilot-cli) | | `crush` | [Crush](https://github.com/charmbracelet/crush) | -| `grok` | Grok CLI from xAI | +| `grok` | [Grok Build](https://x.ai/build) from xAI | | `pi` | [Mario Zechner's Pi](https://github.com/badlogic/pi-mono) | | `omp` | [Oh My Pi](https://github.com/can1357/oh-my-pi) | | `ori` | [Ori](https://openrouter.ai/docs/guides/ori/harness), OpenRouter's harness | @@ -22,6 +22,8 @@ Omarchy treats AI coding agents as first-class citizens, but it doesn't pick a f To wrap an additional CLI the same way, run `omarchy-mise-install [command-name]`. The stubs are kept current along with everything else mise manages when you run `omarchy update` (or the `mup` alias). +`grok` is installed through mise's first-party `grok` package, the same way as `claude` and `codex`. Run `grok`, or pick it under _Setup > Defaults > Agent_. Skip the `curl | bash` installer on x.ai. That path puts a second copy in `~/.grok/bin`, prepends it on `PATH`, and overwrites Omarchy's wrapper. + ### The default agent Pick your default agent with `omarchy default agent ` or under _Setup > Defaults > Agent_ in the Omarchy Menu (`Super + Space`). If the agent isn't installed yet, picking it installs it first. A fresh Omarchy will invite you to make this choice with a one-time notification. @@ -50,7 +52,7 @@ Crashes can also be silenced one program at a time, which is what the diagnosis ### Desktop apps -The _Install > AI_ menu also carries a few graphical AI apps: the ChatGPT desktop app, the Claude desktop app (Anthropic's Linux beta, with Chat, Cowork, and Claude Code tabs), Grok Bot for chatting with xAI's models, Hermes Desktop, OpenClaw, and the Perplexity desktop app. +The _Install > AI_ menu also carries a few graphical AI apps: the ChatGPT desktop app, the Claude desktop app (Anthropic's Linux beta, with Chat, Cowork, and Claude Code tabs), Grok Bot for chatting with xAI's models, Hermes Desktop, OpenClaw, and the Perplexity desktop app. Grok Bot is the desktop chat app. The coding agent is the `grok` command. Hermes Desktop is the one to know about, because a machine has one Hermes, and it is the app's: Hermes is only ever installed through the app, and the `hermes` command the default agent runs is the app's. Choosing Hermes as the default agent installs the same thing the _Install > AI_ entry does: the package, and a Hermes runtime under `~/.hermes` set up by Hermes' own installer, which takes a few minutes the first time. That runtime is the one Hermes the terminal `hermes` command, the default agent and the app all use, and it updates itself with `hermes update` rather than waiting on an Omarchy release. Installing it also hands Hermes the Omarchy theme as a skin named `omarchy`, which every Hermes surface follows as you switch themes; pick another under Hermes' Appearance settings or with `/skin` if you'd rather it didn't, and Omarchy leaves that choice alone. Removing the app under _Remove > AI_ closes Hermes first, gateway included, takes that runtime with it, and keeps your chats, memories, and the skills Hermes wrote for itself unless you tell it otherwise: it asks, defaulting to no, whether that data and your connection settings should go too. diff --git a/migrations/1790863209.sh b/migrations/1790863209.sh new file mode 100644 index 000000000000..3e65d971a3ef --- /dev/null +++ b/migrations/1790863209.sh @@ -0,0 +1,53 @@ +echo "Install Grok through mise's first-party package" + +# The npm package launches whatever is already in ~/.grok/bin, and mise does not +# run its postinstall, so a newer package keeps running the old binary. mise's +# grok tool is the binary. Drop the npm tool or its shim stays ahead of the stub. + +npm_grok="npm:@xai-official/grok" +wrapper="$HOME/.local/bin/grok" +npm_stub=false + +# Anchored to the package the old installer wrote. A script the user wrote that +# calls mise use -g for something else is left alone. +if [[ -f $wrapper && ! -L $wrapper ]] && grep -Fq "$npm_grok" "$wrapper"; then + npm_stub=true +fi + +drop_npm_grok() { + omarchy-cmd-present mise || return 0 + if [[ -n $(mise ls -g "$npm_grok") ]]; then + mise unuse -g "$npm_grok" + fi + if [[ -n $(mise ls -i "$npm_grok") ]]; then + mise uninstall -y --all "$npm_grok" + fi +} + +if [[ ! -f $HOME/.local/state/omarchy/preinstalls-removed ]]; then + # The shim is ahead of ~/.local/bin, so drop the npm tool before looking for + # grok. A removed wrapper still looks installed until the tool is gone. + drop_npm_grok + if [[ $npm_stub == true ]] || omarchy-cmd-missing grok; then + omarchy-mise-install grok + fi +elif [[ $npm_stub == true ]]; then + # After an opt-out, only a wrapper Omarchy wrote proves the tool is ours. + rm -f "$wrapper" + drop_npm_grok +fi + +# The x.ai installer links ~/.local/bin/agent at its copy under ~/.grok. +# realpath -m resolves a relative or dangling target without requiring it to exist. +if [[ -L $HOME/.local/bin/agent ]]; then + agent_target=$(readlink "$HOME/.local/bin/agent" || true) + agent_resolved="" + if [[ $agent_target == /* ]]; then + agent_resolved=$(realpath -m "$agent_target") + elif [[ -n $agent_target ]]; then + agent_resolved=$(realpath -m "$HOME/.local/bin/$agent_target") + fi + if [[ $agent_resolved == "$HOME/.grok" || $agent_resolved == "$HOME/.grok/"* ]]; then + rm -f "$HOME/.local/bin/agent" + fi +fi diff --git a/test/shell.d/default-agent-test.sh b/test/shell.d/default-agent-test.sh index 60e630d34c52..471a7da4b0b5 100644 --- a/test/shell.d/default-agent-test.sh +++ b/test/shell.d/default-agent-test.sh @@ -71,6 +71,11 @@ if [[ $1 == "where" ]]; then exit fi +if [[ $1 == "ls" && -n ${OMARCHY_TEST_MISE_HAS_NPM_GROK:-} ]]; then + printf '%s\n' "npm:@xai-official/grok 1.0.44" + exit 0 +fi + [[ ${OMARCHY_TEST_MISE_FAIL:-false} != "true" ]] SH @@ -120,7 +125,8 @@ export OMARCHY_TEST_AGENT_MENU_LOG="$menu_log" export OMARCHY_TEST_MUSE_LOGIN_LOG="$muse_login_log" export OMARCHY_PATH="$ROOT" -grok_package="npm:@xai-official/grok" +grok_package="grok" +legacy_grok_package="npm:@xai-official/grok" omp_package="github:can1357/oh-my-pi" crush_package="crush" agy_package="antigravity-cli" @@ -151,7 +157,7 @@ pass "custom agent lazy stubs preserve their mise packages" OMARCHY_TEST_MISSING_COMMAND=cursor-agent source "$ROOT/install/user/mise.sh" grep -Fx "$agy_package agy" "$stub_log" >/dev/null || fail "user setup creates the Antigravity lazy stub" -grep -Fx "$grok_package grok" "$stub_log" >/dev/null || fail "user setup creates the Grok lazy stub" +grep -Fx "$grok_package" "$stub_log" >/dev/null || fail "user setup creates the Grok lazy stub" grep -Fx "$cursor_agent_package" "$stub_log" >/dev/null || fail "user setup creates the Cursor CLI 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" @@ -202,7 +208,7 @@ pass "Cursor CLI migration preserves an existing Cursor CLI install" : >"$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 "$legacy_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" : >"$stub_log" @@ -302,8 +308,109 @@ source "$ROOT/migrations/1785846769.sh" >/dev/null fail "agent migration keeps a wrapper built on $omp_package" rm -f "$test_home/.local/bin/omp" +printf '#!/bin/bash\nexport MISE_MINIMUM_RELEASE_AGE=0\nmise use -g --quiet "%s" || exit 1\nexec mise x "%s" -- "grok" "$@"\n' \ + "$legacy_grok_package" "$legacy_grok_package" >"$test_home/.local/bin/grok" +chmod +x "$test_home/.local/bin/grok" +mkdir -p "$test_home/.grok/bin" +ln -s "$test_home/.grok/bin/agent" "$test_home/.local/bin/agent" +: >"$stub_log" +: >"$mise_history" +OMARCHY_TEST_MISE_HAS_NPM_GROK=1 source "$ROOT/migrations/1790863209.sh" >/dev/null +unset OMARCHY_TEST_MISE_HAS_NPM_GROK +[[ ! -s $stub_log ]] || fail "Grok registry migration respects the preinstall opt-out" +[[ ! -e $test_home/.local/bin/grok ]] || fail "Grok registry migration removes the npm wrapper after opt-out" +[[ ! -e $test_home/.local/bin/agent ]] || fail "Grok registry migration removes the curl-installer agent symlink" +grep -Fx "unuse -g $legacy_grok_package" "$mise_history" >/dev/null || + fail "Grok registry migration drops the npm tool after opt-out" +grep -Fx "uninstall -y --all $legacy_grok_package" "$mise_history" >/dev/null || + fail "Grok registry migration uninstalls the npm tool after opt-out" + +ln -s "../../.grok/bin/agent" "$test_home/.local/bin/agent" +source "$ROOT/migrations/1790863209.sh" >/dev/null +[[ ! -e $test_home/.local/bin/agent ]] || + fail "Grok registry migration removes a relative dangling agent symlink" + +ln -s /usr/bin/true "$test_home/.local/bin/agent" +source "$ROOT/migrations/1790863209.sh" >/dev/null +[[ -L $test_home/.local/bin/agent ]] || + fail "Grok registry migration keeps an agent symlink that is not Grok's" +rm -f "$test_home/.local/bin/agent" + +rm -f "$test_home/.local/bin/grok" +: >"$stub_log" +: >"$mise_history" +OMARCHY_TEST_MISE_HAS_NPM_GROK=1 source "$ROOT/migrations/1790863209.sh" >/dev/null +unset OMARCHY_TEST_MISE_HAS_NPM_GROK +[[ ! -s $stub_log ]] || fail "Grok registry migration does not reinstall after the preinstall opt-out" +grep -Fx "unuse -g $legacy_grok_package" "$mise_history" >/dev/null && + fail "Grok registry migration leaves a user-installed npm tool after the preinstall opt-out" + rm "$test_home/.local/state/omarchy/preinstalls-removed" rm -f "$agent_file" + +printf '#!/bin/bash\nexport MISE_MINIMUM_RELEASE_AGE=0\nmise use -g --quiet "%s" || exit 1\nexec mise x "%s" -- "grok" "$@"\n' \ + "$legacy_grok_package" "$legacy_grok_package" >"$test_home/.local/bin/grok" +chmod +x "$test_home/.local/bin/grok" +: >"$stub_log" +: >"$mise_history" +OMARCHY_TEST_MISE_HAS_NPM_GROK=1 source "$ROOT/migrations/1790863209.sh" >/dev/null +unset OMARCHY_TEST_MISE_HAS_NPM_GROK +grep -Fx "$grok_package" "$stub_log" >/dev/null || + fail "Grok registry migration rewrites the npm wrapper" +grep -Fx "unuse -g $legacy_grok_package" "$mise_history" >/dev/null || + fail "Grok registry migration drops the npm tool" +rm -f "$test_home/.local/bin/grok" + +printf '#!/bin/bash\necho user-grok\n' >"$test_home/.local/bin/grok" +chmod +x "$test_home/.local/bin/grok" +: >"$stub_log" +: >"$mise_history" +OMARCHY_TEST_MISE_HAS_NPM_GROK=1 source "$ROOT/migrations/1790863209.sh" >/dev/null +unset OMARCHY_TEST_MISE_HAS_NPM_GROK +[[ $("$test_home/.local/bin/grok") == "user-grok" ]] || + fail "Grok registry migration keeps a user-managed grok" +[[ ! -s $stub_log ]] || fail "Grok registry migration does not replace a user-managed grok" +grep -Fx "unuse -g $legacy_grok_package" "$mise_history" >/dev/null || + fail "Grok registry migration drops the npm tool beside a user-managed grok" + +cat >"$test_home/.local/bin/grok" <<'SH' +#!/bin/bash +mise use -g --quiet "grok" || exit 1 +echo user-mise-grok +SH +chmod +x "$test_home/.local/bin/grok" +cp "$test_home/.local/bin/grok" "$test_tmp/user-mise-grok" +: >"$stub_log" +: >"$mise_history" +OMARCHY_TEST_MISE_HAS_NPM_GROK=1 source "$ROOT/migrations/1790863209.sh" >/dev/null +unset OMARCHY_TEST_MISE_HAS_NPM_GROK +cmp -s "$test_home/.local/bin/grok" "$test_tmp/user-mise-grok" || + fail "Grok registry migration keeps a user script that calls mise" +[[ ! -s $stub_log ]] || fail "Grok registry migration does not replace a user script that calls mise" +grep -Fx "unuse -g $legacy_grok_package" "$mise_history" >/dev/null || + fail "Grok registry migration drops the npm tool beside a user script" +rm -f "$test_home/.local/bin/grok" + +rm -f "$test_home/.local/bin/grok" +: >"$stub_log" +: >"$mise_history" +OMARCHY_TEST_MISSING_COMMAND=grok source "$ROOT/migrations/1790863209.sh" >/dev/null +unset OMARCHY_TEST_MISSING_COMMAND +grep -Fx "$grok_package" "$stub_log" >/dev/null || + fail "Grok registry migration installs the stub when grok is missing" +grep -Fx "unuse -g $legacy_grok_package" "$mise_history" >/dev/null && + fail "Grok registry migration does not drop the npm tool when it is not installed" + +rm -f "$test_home/.local/bin/grok" +: >"$stub_log" +: >"$mise_history" +OMARCHY_TEST_MISE_HAS_NPM_GROK=1 OMARCHY_TEST_MISSING_COMMAND=grok \ + source "$ROOT/migrations/1790863209.sh" >/dev/null +unset OMARCHY_TEST_MISE_HAS_NPM_GROK OMARCHY_TEST_MISSING_COMMAND +grep -Fx "$grok_package" "$stub_log" >/dev/null || + fail "Grok registry migration installs the stub after dropping a leftover npm tool" +grep -Fx "unuse -g $legacy_grok_package" "$mise_history" >/dev/null || + fail "Grok registry migration drops a leftover npm tool when the wrapper is gone" pass "agent migrations install working wrappers without overriding the preinstall opt-out" "$ROOT/bin/omarchy-mise-install" "$muse_package" muse