From 4ca1fac241f040c1788d1078817a613633e5c89b Mon Sep 17 00:00:00 2001 From: Taksh Date: Sat, 12 Sep 2026 22:16:45 +0530 Subject: [PATCH 01/10] Stop forcing MISE_MINIMUM_RELEASE_AGE=0 --- bin/omarchy-mise-install | 5 ----- bin/omarchy-update-mise | 8 ++++---- default/bash/aliases | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/bin/omarchy-mise-install b/bin/omarchy-mise-install index 356c3324bf6a..ab357f47119b 100755 --- a/bin/omarchy-mise-install +++ b/bin/omarchy-mise-install @@ -44,14 +44,9 @@ case "$bin" in *) bin_arg="\"$bin\"" ;; esac -# These tools install and upgrade on first run, so mise's release cooldown would -# hold a new version back for days after it ships. Exported rather than set on -# the install line alone, so resolving the version to execute agrees with the -# one just installed. rm -f "$HOME/.local/bin/$command" cat >"$HOME/.local/bin/$command" <&2 + fi fi diff --git a/default/bash/aliases b/default/bash/aliases index 315dd230c5d5..8e64c3288874 100644 --- a/default/bash/aliases +++ b/default/bash/aliases @@ -54,7 +54,7 @@ alias h='herdr' alias ic='tdl c' alias ix='tdl cx' alias icx='tdl c cx' -alias mup='MISE_MINIMUM_RELEASE_AGE=0 mise up' +alias mup='mise up' n() { if [ "$#" -eq 0 ]; then command nvim . ; else command nvim "$@"; fi; } # Git From 5cccd3398c61603dd421f748f654e52eb031470f Mon Sep 17 00:00:00 2001 From: Taksh Date: Sat, 12 Sep 2026 22:17:38 +0530 Subject: [PATCH 02/10] Also stop forcing MISE_MINIMUM_RELEASE_AGE=0 in hermes-cli install --- bin/omarchy-install-hermes-cli | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/omarchy-install-hermes-cli b/bin/omarchy-install-hermes-cli index 4f4b99d768f1..2451e3833bde 100755 --- a/bin/omarchy-install-hermes-cli +++ b/bin/omarchy-install-hermes-cli @@ -241,7 +241,6 @@ export UV_PYTHON="$python" # Exported rather than set on the install line alone, so the version resolved # to run agrees with the one just installed. Hermes ships several times a week # and mise's cooldown would otherwise hold a new release back for days. -export MISE_MINIMUM_RELEASE_AGE=0 # mise up -- which omarchy update runs -- reinstalls without that pin, so this # asks which interpreter is actually there rather than whether anything is. From 276c2cf38f46aca52aa5d2d95475fb2d20ff67b0 Mon Sep 17 00:00:00 2001 From: Taksh Date: Tue, 15 Sep 2026 21:37:16 +0530 Subject: [PATCH 03/10] Make mise wrappers exec-only after a one-time install pin. Wrappers were calling `mise use -g` on every invocation, which rewrote global mise config and raced on shared locks when a caller timed out. Pin once in omarchy-mise-install, leave wrappers as `mise x` only, and migrate existing mutating wrappers. --- bin/omarchy-default-agent | 2 +- bin/omarchy-mise-install | 7 +- migrations/1789200000.sh | 37 ++++++++++ test/shell.d/mise-install-test.sh | 54 ++++++++------ .../mise-wrapper-quiet-migration-test.sh | 24 +++---- .../mise-wrapper-readonly-migration-test.sh | 72 +++++++++++++++++++ 6 files changed, 161 insertions(+), 35 deletions(-) create mode 100644 migrations/1789200000.sh create mode 100644 test/shell.d/mise-wrapper-readonly-migration-test.sh diff --git a/bin/omarchy-default-agent b/bin/omarchy-default-agent index af93d8635f11..d031901ffded 100755 --- a/bin/omarchy-default-agent +++ b/bin/omarchy-default-agent @@ -67,7 +67,7 @@ else # only shadow it, since the mise shims precede ~/.local/bin on PATH. user_install() { [[ -x $HOME/.local/bin/$agent ]] && - { [[ -L $HOME/.local/bin/$agent ]] || ! grep -q '^mise use -g' "$HOME/.local/bin/$agent"; } + { [[ -L $HOME/.local/bin/$agent ]] || ! grep -qE '^(mise use -g|exec mise x)' "$HOME/.local/bin/$agent"; } } agent_present() { user_install || mise where "$agent_package" &>/dev/null; } agent_install() { user_install || mise use -g "$agent_package"; } diff --git a/bin/omarchy-mise-install b/bin/omarchy-mise-install index ab357f47119b..0ab31c8d86b6 100755 --- a/bin/omarchy-mise-install +++ b/bin/omarchy-mise-install @@ -44,10 +44,15 @@ case "$bin" in *) bin_arg="\"$bin\"" ;; esac +# Install / pin once here. The generated wrapper must not rewrite global mise +# config (or disable release cooldowns) on every ordinary invocation — that is +# what left machines racing on shared mise locks when a caller timed out mid +# `mise use` (#11886). +mise use -g --quiet "$package" || exit 1 + rm -f "$HOME/.local/bin/$command" cat >"$HOME/.local/bin/$command" <"$stub_bin/mise" <<'SH' #!/bin/bash @@ -25,37 +25,51 @@ SH chmod +x "$stub_bin/mise" install_wrapper() { - HOME="$home" "$ROOT/bin/omarchy-mise-install" "$@" + HOME="$home" PATH="$stub_bin:$PATH" OMARCHY_MISE_TEST_LOG="$1" \ + "$ROOT/bin/omarchy-mise-install" "${@:2}" } # The ordinary case still works, and every call site in install/user/mise.sh -# passes names of this shape. -install_wrapper npm:playwright playwright >/dev/null +# passes names of this shape. Install pins once; the wrapper only execs. +install_log="$tmpdir/install-normal.log" +: >"$install_log" +install_wrapper "$install_log" npm:playwright playwright >/dev/null [[ -x $home/.local/bin/playwright ]] || fail "a normal install writes an executable wrapper" +grep -Fqx $'mise\tuse\t-g\t--quiet\tnpm:playwright' "$install_log" || + fail "install pins the package once" "$(cat "$install_log")" + +run_log="$tmpdir/run-normal.log" +: >"$run_log" +OMARCHY_MISE_TEST_LOG="$run_log" PATH="$stub_bin:$PATH" "$home/.local/bin/playwright" >/dev/null +grep -Fqx $'mise\tx\tnpm:playwright\t--\tplaywright' "$run_log" || + fail "the wrapper only execs the package" "$(cat "$run_log")" +if grep -q $'\tuse\t' "$run_log"; then + fail "the wrapper must not call mise use" "$(cat "$run_log")" +fi -log="$tmpdir/normal.log" -: >"$log" -OMARCHY_MISE_TEST_LOG="$log" PATH="$stub_bin:$PATH" "$home/.local/bin/playwright" >/dev/null -grep -Fqx $'mise\tuse\t-g\t--quiet\tnpm:playwright' "$log" || - fail "the wrapper asks mise for the package it was given" "$(cat "$log")" - -pass "a normal install writes a wrapper that names its package" +pass "a normal install writes an exec-only wrapper that names its package" # A package name is data. Quoted with %q it reaches mise as one argument # instead of being read as shell source when the wrapper runs. -install_wrapper 'npm:pkg$(touch '"$tmpdir"'/PWNED)end' hostile >/dev/null +install_log="$tmpdir/install-hostile.log" +: >"$install_log" +install_wrapper "$install_log" 'npm:pkg$(touch '"$tmpdir"'/PWNED)end' hostile >/dev/null -log="$tmpdir/hostile.log" -: >"$log" -OMARCHY_MISE_TEST_LOG="$log" PATH="$stub_bin:$PATH" "$home/.local/bin/hostile" >/dev/null +run_log="$tmpdir/run-hostile.log" +: >"$run_log" +OMARCHY_MISE_TEST_LOG="$run_log" PATH="$stub_bin:$PATH" "$home/.local/bin/hostile" >/dev/null [[ -e $tmpdir/PWNED ]] && fail "a package name with shell characters does not run when the wrapper does" \ "wrapper: $(cat "$home/.local/bin/hostile")" -grep -Fqx $'mise\tuse\t-g\t--quiet\tnpm:pkg$(touch '"$tmpdir"'/PWNED)end' "$log" || - fail "the package reaches mise whole" "$(cat "$log")" +grep -Fq $'mise\tx\tnpm:pkg$(touch ' "$run_log" || + fail "the package reaches mise whole" "$(cat "$run_log")" +grep -Fq $'\t--\thostile' "$run_log" || + fail "the bin reaches mise whole" "$(cat "$run_log")" +grep -Fq 'PWNED' "$run_log" || + fail "the hostile package name is preserved in the mise argv" "$(cat "$run_log")" pass "a package name with shell characters reaches mise as one argument" @@ -75,7 +89,7 @@ for (( i = 0; i < ${#refused[@]}; i += 2 )); do label=${refused[i]} name=${refused[i + 1]} - if install_wrapper somepkg "$name" >/dev/null 2>"$tmpdir/err"; then + if install_wrapper "$tmpdir/refused.log" somepkg "$name" >/dev/null 2>"$tmpdir/err"; then fail "a command name with $label is refused" fi grep -Fq 'is not usable as a command name' "$tmpdir/err" || @@ -88,7 +102,7 @@ pass "command names that are not plain file names are refused" # escaped path on its way to failing. victim="$tmpdir/victim" printf 'keep me\n' >"$victim" -if install_wrapper somepkg "../../../..$victim" >/dev/null 2>&1; then +if install_wrapper "$tmpdir/escape.log" somepkg "../../../..$victim" >/dev/null 2>&1; then fail "an escaping command name is refused" fi [[ -f $victim ]] || diff --git a/test/shell.d/mise-wrapper-quiet-migration-test.sh b/test/shell.d/mise-wrapper-quiet-migration-test.sh index ff207d0fe5e5..8d55e2d091cc 100755 --- a/test/shell.d/mise-wrapper-quiet-migration-test.sh +++ b/test/shell.d/mise-wrapper-quiet-migration-test.sh @@ -65,32 +65,30 @@ chmod +x "$bin_dir/mise-exec-era" "$bin_dir/bare-exec-era" run_migration -grep -qF 'mise use -g --quiet "claude" || exit 1' "$bin_dir/claude" || - fail "migration adds --quiet to a stale wrapper" -pass "migration adds --quiet to a stale wrapper" +grep -qF 'exec mise x "claude" -- "claude" "$@"' "$bin_dir/claude" || + fail "migration rewrites a stale wrapper through the current template" +if grep -q '^mise use -g' "$bin_dir/claude"; then + fail "current template must not call mise use on every run" +fi +pass "migration rewrites a stale wrapper through the current template" -grep -qF 'mise use -g --quiet "github:can1357/oh-my-pi" || exit 1' "$bin_dir/omp" || - fail "migration keeps a wrapper's package when the command name differs" grep -qF 'exec mise x "github:can1357/oh-my-pi" -- "omp" "$@"' "$bin_dir/omp" || - fail "migration keeps a wrapper's bin name when the command name differs" + fail "migration keeps a wrapper's package and bin when the command name differs" pass "migration preserves package and bin names" grep -qF 'exec mise x "npm:@kitlangton/ghui" -- "ghui" "$@"' "$bin_dir/ghui" || fail "migration preserves a scoped npm package name" pass "migration preserves a scoped npm package name" -grep -qF 'mise use -g --quiet "github:someone/custom-tool" || exit 1' "$bin_dir/custom-tool" || +grep -qF 'exec mise x "github:someone/custom-tool" -- "custom-tool" "$@"' "$bin_dir/custom-tool" || fail "migration rewrites a wrapper on the pre-export template" -grep -qF 'export MISE_MINIMUM_RELEASE_AGE=0' "$bin_dir/custom-tool" || - fail "migration brings a pre-export wrapper up to the current template" +if grep -q 'MISE_MINIMUM_RELEASE_AGE=0' "$bin_dir/custom-tool"; then + fail "current template must not disable release cooldowns" +fi pass "migration rewrites wrappers on the pre-export template" -grep -qF 'mise use -g --quiet "npm:some/tool" || exit 1' "$bin_dir/mise-exec-era" || - fail "migration rewrites a wrapper on the mise-exec template" grep -qF 'exec mise x "npm:some/tool" -- "tool-bin" "$@"' "$bin_dir/mise-exec-era" || fail "migration keeps the bin name from a mise-exec wrapper" -grep -qF 'mise use -g --quiet "aqua:some/other" || exit 1' "$bin_dir/bare-exec-era" || - fail "migration rewrites a wrapper on the bare-exec template" grep -qF 'exec mise x "aqua:some/other" -- "other-bin" "$@"' "$bin_dir/bare-exec-era" || fail "migration keeps the bin name from a bare-exec wrapper" pass "migration rewrites every generated form that predates --quiet" diff --git a/test/shell.d/mise-wrapper-readonly-migration-test.sh b/test/shell.d/mise-wrapper-readonly-migration-test.sh new file mode 100644 index 000000000000..818e77679511 --- /dev/null +++ b/test/shell.d/mise-wrapper-readonly-migration-test.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +set -euo pipefail + +source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh" + +migration="$ROOT/migrations/1789200000.sh" +test_dir=$(mktemp -d) +trap 'rm -rf "$test_dir"' EXIT + +home="$test_dir/home" +bin_dir="$home/.local/bin" +mkdir -p "$bin_dir" "$test_dir/bin" + +# Stub mise so omarchy-mise-install can pin during rewrite. +cat >"$test_dir/bin/mise" <<'SH' +#!/bin/bash +exit 0 +SH +chmod +x "$test_dir/bin/mise" + +run_migration() { + HOME="$home" PATH="$test_dir/bin:$ROOT/bin:$PATH" bash -euo pipefail "$migration" >/dev/null +} + +write_mutating_wrapper() { + local command=$1 package=$2 bin=$3 + cat >"$bin_dir/$command" <"$bin_dir/already-clean" <<'EOF' +#!/bin/bash +exec mise x "npm:clean" -- "clean" "$@" +EOF +chmod +x "$bin_dir/already-clean" +cp "$bin_dir/already-clean" "$test_dir/already-clean.before" + +# A large non-wrapper binary must not be rewritten. +dd if=/dev/zero of="$bin_dir/big-tool" bs=2048 count=1 status=none 2>/dev/null || + dd if=/dev/zero of="$bin_dir/big-tool" bs=2048 count=1 2>/dev/null +chmod +x "$bin_dir/big-tool" +cp "$bin_dir/big-tool" "$test_dir/big-tool.before" + +run_migration + +grep -qF 'exec mise x "claude" -- "claude" "$@"' "$bin_dir/claude" || + fail "migration rewrites a mutating wrapper to exec-only" +if grep -q '^mise use -g' "$bin_dir/claude"; then + fail "rewritten wrapper must not call mise use" +fi +pass "migration rewrites a mutating wrapper to exec-only" + +grep -qF 'exec mise x "github:can1357/oh-my-pi" -- "omp" "$@"' "$bin_dir/omp" || + fail "migration keeps package and bin names across rewrite" +pass "migration preserves package and bin names" + +cmp -s "$test_dir/already-clean.before" "$bin_dir/already-clean" || + fail "migration leaves an already exec-only wrapper alone" +pass "migration leaves an already exec-only wrapper alone" + +cmp -s "$test_dir/big-tool.before" "$bin_dir/big-tool" || + fail "migration does not rewrite a large non-wrapper binary" +pass "migration does not rewrite a large non-wrapper binary" From cf2508eafe7e35010f0f510f71a6df57e0d96532 Mon Sep 17 00:00:00 2001 From: Taksh Date: Mon, 21 Sep 2026 12:45:22 +0530 Subject: [PATCH 04/10] Skip Claude and Pi on CPUs without SSE4.2/POPCNT Folded from #8149. --- bin/omarchy-default-agent | 5 + bin/omarchy-hw-cpu-sse4_2 | 47 ++++++++ bin/omarchy-mise-install-bun | 19 ++++ default/omarchy/omarchy-menu.jsonc | 4 +- install/user/mise.sh | 4 +- test/shell.d/bun-agent-cpu-test.sh | 170 +++++++++++++++++++++++++++++ test/shell.d/menu-test.sh | 7 +- 7 files changed, 249 insertions(+), 7 deletions(-) create mode 100755 bin/omarchy-hw-cpu-sse4_2 create mode 100755 bin/omarchy-mise-install-bun create mode 100755 test/shell.d/bun-agent-cpu-test.sh diff --git a/bin/omarchy-default-agent b/bin/omarchy-default-agent index d031901ffded..fcbf6f9265d9 100755 --- a/bin/omarchy-default-agent +++ b/bin/omarchy-default-agent @@ -50,6 +50,11 @@ esac agent_package=${agent_package:-$agent} +if [[ $agent == claude || $agent == pi ]] && ! omarchy-hw-cpu-sse4_2; then + echo "Cannot install $name: this CPU lacks SSE4.2/POPCNT, which Bun's linux-x64 builds need" >&2 + exit 1 +fi + # Hermes reaches mise through its own installer rather than straight from # here: it needs its interpreter pinned, and a bare `mise use` has nowhere to # say so. See omarchy-install-hermes-cli. OpenClaw comes from its pacman diff --git a/bin/omarchy-hw-cpu-sse4_2 b/bin/omarchy-hw-cpu-sse4_2 new file mode 100755 index 000000000000..a7b75e31e1aa --- /dev/null +++ b/bin/omarchy-hw-cpu-sse4_2 @@ -0,0 +1,47 @@ +#!/bin/bash + +# omarchy:summary=Returns true when the CPU has SSE4.2 and POPCNT, or is not x86_64. + +# Bun's linux-x64 target needs SSE4.2 and POPCNT. x86-64-v1 CPUs (Core 2 Duo, +# first-gen Atom, …) install the natives then SIGILL. ARM/aarch64 — including +# Apple Silicon and Asahi — uses a different build and should still install. +# +# OMARCHY_CPUINFO and OMARCHY_ARCH override /proc/cpuinfo and uname for tests. + +cpuinfo=${OMARCHY_CPUINFO:-/proc/cpuinfo} +arch=${OMARCHY_ARCH:-} + +cpu_has_bun_x64_flags() { + local flags=$1 + + [[ " $flags " == *" sse4_2 "* && " $flags " == *" popcnt "* ]] +} + +if [[ -z $arch && -r $cpuinfo ]]; then + if grep -q '^flags[[:space:]]*:' "$cpuinfo"; then + arch=x86_64 + elif grep -qiE '^(features|cpu architecture)[[:space:]]*:' "$cpuinfo"; then + arch=aarch64 + fi +fi + +if [[ -z $arch ]]; then + arch=$(uname -m) +fi + +case $arch in +aarch64 | arm64) + exit 0 + ;; +esac + +flags="" +if [[ -r $cpuinfo ]]; then + flags=$(awk -F: '/^flags[[:space:]]*:/{print $2; exit}' "$cpuinfo") +fi + +if [[ -z $flags ]] && command -v lscpu >/dev/null; then + flags=$(lscpu 2>/dev/null | awk -F: '/^Flags:/{print $2; exit}') +fi + +cpu_has_bun_x64_flags "$flags" diff --git a/bin/omarchy-mise-install-bun b/bin/omarchy-mise-install-bun new file mode 100755 index 000000000000..9ff64c8e57a2 --- /dev/null +++ b/bin/omarchy-mise-install-bun @@ -0,0 +1,19 @@ +#!/bin/bash + +# omarchy:summary=Install a Bun linux-x64 agent when the CPU can run it. +# omarchy:args= [command-name [bin-name]] +# omarchy:hidden=true + +# Claude and Pi ship Bun linux-x64 natives that SIGILL without SSE4.2/POPCNT. +# Skip (don't install) on incompatible x86; ARM/aarch64 still installs. + +if [[ -z $1 ]]; then + echo "Usage: omarchy-mise-install-bun [command-name [bin-name]]" + exit 1 +fi + +if omarchy-hw-cpu-sse4_2; then + omarchy-mise-install "$@" +else + echo "Skipping $1: this CPU lacks SSE4.2/POPCNT, which Bun's linux-x64 builds need" +fi diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index 7583d8d8ce95..37fc21ac6433 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -136,7 +136,7 @@ "setup.default": {"icon":"","label":"Defaults","aliases":["default","defaults"]}, "setup.default.agent": {"icon":"󰚩","label":"Agent","title":"Default Agent"}, "setup.default.agent.agy": {"icon":"󰫢","label":"Antigravity","checked":"[[ \"$(omarchy-default-agent)\" == \"agy\" ]]","action":"omarchy-default-agent agy"}, - "setup.default.agent.claude": {"icon":"󰛄","label":"Claude","checked":"[[ \"$(omarchy-default-agent)\" == \"claude\" ]]","action":"omarchy-default-agent claude"}, + "setup.default.agent.claude": {"icon":"󰛄","label":"Claude","when":"omarchy-hw-cpu-sse4_2","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"}, @@ -148,7 +148,7 @@ "setup.default.agent.openclaw": {"icon":"","iconFont":"omarchy","label":"OpenClaw","checked":"[[ \"$(omarchy-default-agent)\" == \"openclaw\" ]]","action":"omarchy-default-agent openclaw"}, "setup.default.agent.opencode": {"icon":"","iconFont":"omarchy","label":"OpenCode","checked":"[[ \"$(omarchy-default-agent)\" == \"opencode\" ]]","action":"omarchy-default-agent opencode"}, "setup.default.agent.ori": {"icon":"","iconFont":"omarchy","label":"Ori","checked":"[[ \"$(omarchy-default-agent)\" == \"ori\" ]]","action":"omarchy-default-agent ori"}, - "setup.default.agent.pi": {"icon":"","iconFont":"omarchy","label":"Pi","checked":"[[ \"$(omarchy-default-agent)\" == \"pi\" ]]","action":"omarchy-default-agent pi"}, + "setup.default.agent.pi": {"icon":"","iconFont":"omarchy","label":"Pi","when":"omarchy-hw-cpu-sse4_2","checked":"[[ \"$(omarchy-default-agent)\" == \"pi\" ]]","action":"omarchy-default-agent pi"}, "setup.default.browser": {"icon":"","label":"Browser","title":"Default Browser"}, "setup.default.browser.chromium": {"icon":"","label":"Chromium","checked":"[[ \"$(omarchy-default-browser)\" == \"chromium\" ]]","action":"omarchy-default-browser chromium"}, "setup.default.browser.chrome": {"icon":"󰊯","label":"Chrome","checked":"[[ \"$(omarchy-default-browser)\" == \"chrome\" ]]","action":"omarchy-default-browser chrome"}, diff --git a/install/user/mise.sh b/install/user/mise.sh index 81e0364c69a6..e064a7d8b37e 100644 --- a/install/user/mise.sh +++ b/install/user/mise.sh @@ -3,14 +3,14 @@ mise settings set upgrade.auto_prune false omarchy-mise-install codex -omarchy-mise-install claude +omarchy-mise-install-bun claude omarchy-mise-install crush omarchy-mise-install antigravity-cli agy 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-bun pi omarchy-mise-install github:can1357/oh-my-pi omp omarchy-mise-install npm:@xai-official/grok grok # Cursor's own installer links the same path, so a re-provision keeps it. diff --git a/test/shell.d/bun-agent-cpu-test.sh b/test/shell.d/bun-agent-cpu-test.sh new file mode 100755 index 000000000000..ca9322958697 --- /dev/null +++ b/test/shell.d/bun-agent-cpu-test.sh @@ -0,0 +1,170 @@ +#!/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" +cpuinfo_dir="$test_tmp/cpuinfo" +mise_log="$test_tmp/mise" +skip_log="$test_tmp/skip" +mkdir -p "$mock_bin" "$test_home" "$cpuinfo_dir" + +cat >"$mock_bin/omarchy-mise-install" <<'SH' +#!/bin/bash +printf '%s\n' "$*" >>"$OMARCHY_TEST_MISE_LOG" +SH +chmod +x "$mock_bin/omarchy-mise-install" + +cat >"$cpuinfo_dir/core2duo" <<'EOF' +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 23 +model name : Intel(R) Core(TM)2 Duo CPU E7600 @ 3.06GHz +stepping : 10 +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc art arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm tpr_shadow vnmi flexpriority +EOF + +cat >"$cpuinfo_dir/haswell" <<'EOF' +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz +stepping : 3 +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d +EOF + +cat >"$cpuinfo_dir/aarch64" <<'EOF' +processor : 0 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x4 +CPU part : 0xd0b +CPU revision : 1 +EOF + +cat >"$cpuinfo_dir/sse4_2-only" <<'EOF' +processor : 0 +vendor_id : GenuineIntel +flags : fpu sse sse2 sse3 ssse3 sse4_1 sse4_2 +EOF + +export PATH="$mock_bin:$ROOT/bin:$PATH" +export HOME="$test_home" +export OMARCHY_PATH="$ROOT" +export OMARCHY_TEST_MISE_LOG="$mise_log" + +hw_cpu() { + "$ROOT/bin/omarchy-hw-cpu-sse4_2" +} + +assert_hw() { + local description=$1 expected=$2 + local actual=no + + hw_cpu && actual=yes + [[ $actual == "$expected" ]] || fail "$description" "expected $expected, got $actual" + pass "$description" +} + +OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" assert_hw "x86 without sse4_2 is not Bun linux-x64 compatible" no +OMARCHY_CPUINFO="$cpuinfo_dir/sse4_2-only" assert_hw "x86 with sse4_2 but no popcnt is not Bun linux-x64 compatible" no +OMARCHY_CPUINFO="$cpuinfo_dir/haswell" assert_hw "x86 with sse4_2 and popcnt is Bun linux-x64 compatible" yes +OMARCHY_CPUINFO="$cpuinfo_dir/aarch64" assert_hw "aarch64 cpuinfo is Bun linux-x64 compatible" yes +OMARCHY_ARCH=aarch64 OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" assert_hw "OMARCHY_ARCH=aarch64 still installs even with x86 cpuinfo" yes + +run_mise() { + : >"$mise_log" + OMARCHY_CPUINFO=$1 source "$ROOT/install/user/mise.sh" >"$skip_log" 2>&1 +} + +assert_skipped() { + if grep -qx 'claude' "$mise_log"; then + fail "$1 still installs claude" + fi + if grep -qx 'pi' "$mise_log"; then + fail "$1 still installs pi" + fi + grep -q 'Skipping claude:' "$skip_log" || fail "$1 does not explain skipping claude" + grep -q 'Skipping pi:' "$skip_log" || fail "$1 does not explain skipping pi" + grep -qx 'codex' "$mise_log" || fail "$1 still installs other mise tools" +} + +assert_installed() { + grep -qx 'claude' "$mise_log" || fail "$1 does not install claude" + grep -qx 'pi' "$mise_log" || fail "$1 does not install pi" + if grep -q 'Skipping' "$skip_log"; then + fail "$1 skips bun agents on a compatible CPU" + fi +} + +run_mise "$cpuinfo_dir/core2duo" +assert_skipped "missing sse4_2" +pass "user setup skips claude and pi when SSE4.2 is missing" + +run_mise "$cpuinfo_dir/haswell" +assert_installed "sse4_2+popcnt" +pass "user setup installs claude and pi when SSE4.2 and POPCNT are present" + +run_mise "$cpuinfo_dir/aarch64" +assert_installed "aarch64" +pass "user setup installs claude and pi on aarch64" + +cat >"$mock_bin/mise" <<'SH' +#!/bin/bash +printf '%s\n' "$*" >>"$OMARCHY_TEST_MISE_LOG" +if [[ $1 == "where" ]]; then + [[ ${OMARCHY_TEST_AGENT_INSTALLED:-false} == "true" ]] + exit +fi +exit 0 +SH + +cat >"$mock_bin/omarchy-launch-floating-terminal-with-presentation" <<'SH' +#!/bin/bash +printf '%s\n' "$*" >>"$OMARCHY_TEST_TERMINAL_LOG" +SH + +cat >"$mock_bin/omarchy-agent" <<'SH' +#!/bin/bash +exit 0 +SH +chmod +x "$mock_bin"/* + +terminal_log="$test_tmp/terminal" +export OMARCHY_TEST_TERMINAL_LOG="$terminal_log" + +: >"$mise_log" +: >"$terminal_log" +mkdir -p "$test_home/.config/omarchy/defaults" +if OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" omarchy-default-agent claude >"$skip_log" 2>&1; then + fail "default agent installs claude on a CPU without SSE4.2" +fi +grep -q 'SSE4.2' "$skip_log" || fail "default agent explains why claude cannot be installed" +[[ ! -s $mise_log ]] || fail "default agent does not invoke mise for an incompatible claude" +[[ ! -s $terminal_log ]] || fail "default agent does not open an install terminal for incompatible claude" +[[ ! -f $test_home/.config/omarchy/defaults/agent ]] || fail "default agent does not record an incompatible claude" +pass "default agent refuses claude on a CPU without SSE4.2" + +: >"$mise_log" +: >"$skip_log" +if OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" omarchy-default-agent pi >"$skip_log" 2>&1; then + fail "default agent installs pi on a CPU without SSE4.2" +fi +grep -q 'SSE4.2' "$skip_log" || fail "default agent explains why pi cannot be installed" +[[ ! -s $mise_log ]] || fail "default agent does not invoke mise for an incompatible pi" +pass "default agent refuses pi on a CPU without SSE4.2" + +: >"$mise_log" +OMARCHY_CPUINFO="$cpuinfo_dir/haswell" OMARCHY_TEST_AGENT_INSTALLED=true omarchy-default-agent claude >/dev/null +grep -q 'use -g claude' "$mise_log" || fail "default agent still installs claude when the CPU can run Bun" +[[ $(<"$test_home/.config/omarchy/defaults/agent") == claude ]] || fail "default agent records claude on a compatible CPU" +pass "default agent still installs claude when SSE4.2 and POPCNT are present" diff --git a/test/shell.d/menu-test.sh b/test/shell.d/menu-test.sh index a424379b1afd..6c3f9bdd2e3b 100644 --- a/test/shell.d/menu-test.sh +++ b/test/shell.d/menu-test.sh @@ -215,13 +215,14 @@ assertEqual( 'setup.reset', 'menu lists Reset Computer last under Setup' ) +const bunX64When = 'omarchy-hw-cpu-sse4_2' const expectedAgents = { agy: { icon: '󰫢', label: 'Antigravity' }, - pi: { icon: '\ue901', iconFont: 'omarchy', label: 'Pi' }, + pi: { icon: '\ue901', iconFont: 'omarchy', label: 'Pi', when: bunX64When }, omp: { icon: '\ue903', iconFont: 'omarchy', label: 'omp' }, opencode: { icon: '\ue902', iconFont: 'omarchy', label: 'OpenCode' }, ori: { icon: '\ue909', iconFont: 'omarchy', label: 'Ori' }, - claude: { icon: '󰛄', label: 'Claude' }, + claude: { icon: '󰛄', label: 'Claude', when: bunX64When }, codex: { icon: '\ue905', iconFont: 'omarchy', label: 'Codex' }, grok: { icon: '\ue904', iconFont: 'omarchy', label: 'Grok' }, hermes: { icon: '\ue90a', iconFont: 'omarchy', label: 'Hermes' }, @@ -240,7 +241,7 @@ assert( && entry.iconFont === (expected.iconFont || '') && entry.label === expected.label && entry.action === `omarchy-default-agent ${agent}` - && !entry.when + && entry.when === (expected.when || '') && entry.checked.includes(`== \"${agent}\"`) }), 'menu exposes every supported coding agent with its own glyph under Defaults > Agent' From 58daba3587ff19ecf489562f6f758cd3499809dd Mon Sep 17 00:00:00 2001 From: Taksh Date: Mon, 21 Sep 2026 12:46:36 +0530 Subject: [PATCH 05/10] Don't reinstall a stale OpenClaw package over a working CLI Folded from #11969. --- bin/omarchy-install-ai-openclaw | 8 ++- bin/omarchy-install-openclaw-cli | 18 +++---- bin/omarchy-launch-openclaw | 12 +++++ bin/omarchy-openclaw-present | 28 +++++++++++ default/omarchy/omarchy-menu.jsonc | 2 +- test/shell.d/default-agent-test.sh | 15 +++--- test/shell.d/openclaw-present-test.sh | 70 +++++++++++++++++++++++++++ 7 files changed, 135 insertions(+), 18 deletions(-) create mode 100755 bin/omarchy-openclaw-present create mode 100755 test/shell.d/openclaw-present-test.sh diff --git a/bin/omarchy-install-ai-openclaw b/bin/omarchy-install-ai-openclaw index cb79a9ad25f6..1bce3c3d8032 100755 --- a/bin/omarchy-install-ai-openclaw +++ b/bin/omarchy-install-ai-openclaw @@ -5,8 +5,12 @@ set -e -echo "Installing OpenClaw..." -omarchy-pkg-add openclaw +if omarchy-openclaw-present; then + echo "OpenClaw is already available; skipping the package install." +else + echo "Installing OpenClaw..." + omarchy-pkg-add openclaw +fi # The desktop app is OpenClaw's Control UI: a web app served by its own # gateway. The launcher entry goes through omarchy-launch-openclaw, which diff --git a/bin/omarchy-install-openclaw-cli b/bin/omarchy-install-openclaw-cli index 18e123179ff1..35dab0262efb 100755 --- a/bin/omarchy-install-openclaw-cli +++ b/bin/omarchy-install-openclaw-cli @@ -4,23 +4,23 @@ # omarchy:args=[--check|--now] # omarchy:requires-sudo=true -# OpenClaw is not a mise tool: the openclaw pacman package is the one OpenClaw -# installation on the machine — the CLI, the gateway, and the Install > AI web -# app all share it, and the fast ring keeps it current. The default-agent flow -# talks to that package through the same --check/--now contract mise-backed -# agents get from mise itself. +# OpenClaw is not a mise tool: the openclaw pacman package is the usual +# Omarchy install, but a user may already have a newer CLI on PATH. Treat any +# working openclaw (package, PATH, or gateway) as present so --check/--now +# does not reinstall a stale package ahead of it. set -euo pipefail case "${1:---now}" in --check) - omarchy-pkg-present openclaw + omarchy-openclaw-present ;; --now) - if ! omarchy-pkg-present openclaw; then - echo "Installing OpenClaw..." - omarchy-pkg-add openclaw + if omarchy-openclaw-present; then + exit 0 fi + echo "Installing OpenClaw..." + omarchy-pkg-add openclaw ;; *) echo "Usage: omarchy-install-openclaw-cli [--check|--now]" >&2 diff --git a/bin/omarchy-launch-openclaw b/bin/omarchy-launch-openclaw index 13ab6c247652..b09dca473fbe 100755 --- a/bin/omarchy-launch-openclaw +++ b/bin/omarchy-launch-openclaw @@ -5,6 +5,18 @@ set -euo pipefail +# /usr/bin usually precedes ~/.npm-global/bin. When both a packaged and a +# user-installed openclaw are on PATH, bare `openclaw` can be the older one +# and refuse a migrated state database. Surface that before we talk to it. +_openclaw_bins=() +while IFS= read -r _openclaw_bin; do + _openclaw_bins+=("$_openclaw_bin") +done < <(type -aP openclaw 2>/dev/null || true) +if ((${#_openclaw_bins[@]} > 1)); then + echo "warning: multiple openclaw binaries on PATH; using ${_openclaw_bins[0]}" >&2 + printf ' %s\n' "${_openclaw_bins[@]}" >&2 +fi + tui=false message=() if [[ ${1:-} == "--tui" ]]; then diff --git a/bin/omarchy-openclaw-present b/bin/omarchy-openclaw-present new file mode 100755 index 000000000000..3df31ef19f78 --- /dev/null +++ b/bin/omarchy-openclaw-present @@ -0,0 +1,28 @@ +#!/bin/bash + +# omarchy:summary=True when OpenClaw is already available (package, PATH, or gateway) +# omarchy:hidden=true + +# The Install > AI entry used to key only on the pacman package. A newer +# OpenClaw installed outside the package (npm, a manual build) still puts +# `openclaw` on PATH and may already be running a gateway. Re-offering the +# package in that state can put an older /usr/bin/openclaw ahead of the +# working one and break a migrated state database. + +if omarchy-pkg-present openclaw 2>/dev/null; then + exit 0 +fi + +if command -v openclaw >/dev/null 2>&1; then + exit 0 +fi + +if systemctl --user is-enabled --quiet openclaw-gateway.service 2>/dev/null; then + exit 0 +fi + +if [[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/openclaw-gateway.service ]]; then + exit 0 +fi + +exit 1 diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index 37fc21ac6433..ec045dda4248 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -247,7 +247,7 @@ "install.ai.hermes": {"icon":"","iconFont":"omarchy","label":"Hermes Desktop","disabled":"omarchy-pkg-present hermes-desktop","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-ai-hermes"}, "install.ai.lm-studio": {"icon":"","iconFont":"omarchy","label":"LM Studio","disabled":"omarchy-pkg-present lmstudio-bin","action":"omarchy-install-app 'LM Studio' lmstudio-bin"}, "install.ai.ollama": {"icon":"","iconFont":"omarchy","label":"Ollama","disabled":"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.openclaw": {"icon":"","iconFont":"omarchy","label":"OpenClaw","disabled":"omarchy-pkg-present openclaw","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-ai-openclaw"}, + "install.ai.openclaw": {"icon":"","iconFont":"omarchy","label":"OpenClaw","disabled":"omarchy-openclaw-present","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-ai-openclaw"}, "install.ai.perplexity": {"icon":"","iconFont":"omarchy","label":"Perplexity","disabled":"omarchy-pkg-present perplexity","action":"omarchy-install-and-launch Perplexity perplexity perplexity"}, "install.ai.t3-code": {"icon":"","iconFont":"omarchy","label":"T3 Code","disabled":"omarchy-pkg-present t3code-bin","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-ai-t3-code"}, "install.gaming.steam": {"icon":"","label":"Steam","disabled":"omarchy-pkg-present steam","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-gaming-steam"}, diff --git a/test/shell.d/default-agent-test.sh b/test/shell.d/default-agent-test.sh index ea65b9732dc0..054338747c8b 100644 --- a/test/shell.d/default-agent-test.sh +++ b/test/shell.d/default-agent-test.sh @@ -743,6 +743,13 @@ cat >"$mock_bin/omarchy-pkg-present" <<'SH' #!/bin/bash [[ $1 == openclaw && ${OMARCHY_TEST_OPENCLAW_INSTALLED:-false} == "true" ]] SH +# install-openclaw-cli now asks omarchy-openclaw-present (package, PATH, or +# gateway). Drive that with the same fixture flag so a leftover openclaw stub +# cannot masquerade as an install. +cat >"$mock_bin/omarchy-openclaw-present" <<'SH' +#!/bin/bash +[[ ${OMARCHY_TEST_OPENCLAW_INSTALLED:-false} == "true" ]] +SH cat >"$mock_bin/omarchy-pkg-add" <<'SH' #!/bin/bash printf '%s\n' "pkg-add $*" >>"$OMARCHY_TEST_STUB_LOG" @@ -751,12 +758,8 @@ cat >"$mock_bin/omarchy-launch-openclaw" <<'SH' #!/bin/bash printf '%s\0' omarchy-launch-openclaw "$@" >"$OMARCHY_TEST_AGENT_INLINE_LOG" SH -cat >"$mock_bin/openclaw" <<'SH' -#!/bin/bash -exit 0 -SH -chmod +x "$mock_bin/omarchy-pkg-present" "$mock_bin/omarchy-pkg-add" \ - "$mock_bin/omarchy-launch-openclaw" "$mock_bin/openclaw" +chmod +x "$mock_bin/omarchy-pkg-present" "$mock_bin/omarchy-openclaw-present" \ + "$mock_bin/omarchy-pkg-add" "$mock_bin/omarchy-launch-openclaw" : >"$launch_log" : >"$terminal_log" diff --git a/test/shell.d/openclaw-present-test.sh b/test/shell.d/openclaw-present-test.sh new file mode 100755 index 000000000000..8997f8dd9d6d --- /dev/null +++ b/test/shell.d/openclaw-present-test.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +set -euo pipefail + +source "$(dirname "$0")/base-test.sh" + +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +mkdir -p "$tmp/bin" "$tmp/home/.config/systemd/user" +export HOME="$tmp/home" +export XDG_CONFIG_HOME="$tmp/home/.config" +export PATH="$tmp/bin:$ROOT/bin:/usr/bin:/bin" +export TEST_LOG="$tmp/log" +: >"$TEST_LOG" + +cat >"$tmp/bin/omarchy-pkg-present" <<'SH' +#!/bin/bash +exit 1 +SH +chmod +x "$tmp/bin/omarchy-pkg-present" + +cat >"$tmp/bin/systemctl" <<'SH' +#!/bin/bash +exit 1 +SH +chmod +x "$tmp/bin/systemctl" + +if omarchy-openclaw-present; then + fail "absent OpenClaw should not count as present" +fi +pass "absent OpenClaw is not present" + +cat >"$tmp/bin/openclaw" <<'SH' +#!/bin/bash +exit 0 +SH +chmod +x "$tmp/bin/openclaw" + +omarchy-openclaw-present || fail "PATH openclaw should count as present" +pass "PATH openclaw counts as present" + +cat >"$tmp/bin/omarchy-pkg-add" <<'SH' +#!/bin/bash +printf 'pkg-add:%s\n' "$*" >>"$TEST_LOG" +exit 0 +SH +chmod +x "$tmp/bin/omarchy-pkg-add" + +omarchy-install-openclaw-cli --check || fail "--check should succeed for PATH openclaw" +omarchy-install-openclaw-cli --now || fail "--now should succeed without installing" +if [[ -s $TEST_LOG ]]; then + fail "--now must not reinstall over a PATH openclaw" "$(cat "$TEST_LOG")" +fi +pass "install-openclaw-cli leaves a PATH openclaw alone" + +rm -f "$tmp/bin/openclaw" +touch "$XDG_CONFIG_HOME/systemd/user/openclaw-gateway.service" +omarchy-openclaw-present || fail "gateway unit should count as present" +pass "gateway unit counts as present" + +# Shadowed PATH warning (exercise the detection the launcher uses). +rm -f "$XDG_CONFIG_HOME/systemd/user/openclaw-gateway.service" +mkdir -p "$tmp/a" "$tmp/b" +printf '#!/bin/bash\n' >"$tmp/a/openclaw" +printf '#!/bin/bash\n' >"$tmp/b/openclaw" +chmod +x "$tmp/a/openclaw" "$tmp/b/openclaw" +export PATH="$tmp/a:$tmp/b:$tmp/bin:$ROOT/bin:/usr/bin:/bin" +mapfile -t bins < <(type -aP openclaw) +(( ${#bins[@]} > 1 )) || fail "fixture should expose two openclaw binaries" +pass "multiple openclaw binaries are detectable on PATH" From 59942cf6ad44c98e828f1e0e198bfdf0f298e5b2 Mon Sep 17 00:00:00 2001 From: Taksh Date: Mon, 5 Oct 2026 15:07:56 +0530 Subject: [PATCH 06/10] Restore managed agent installs and report mise failures --- bin/omarchy-default-agent | 11 ++++++- bin/omarchy-mise-install | 1 + bin/omarchy-openclaw-present | 10 +----- bin/omarchy-update-mise | 1 + test/shell.d/mise-managed-agent-test.sh | 44 +++++++++++++++++++++++++ test/shell.d/openclaw-present-test.sh | 10 +++--- 6 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 test/shell.d/mise-managed-agent-test.sh diff --git a/bin/omarchy-default-agent b/bin/omarchy-default-agent index d758d2479aa8..a48406c7bf06 100755 --- a/bin/omarchy-default-agent +++ b/bin/omarchy-default-agent @@ -71,9 +71,18 @@ else # Anything at the wrapper's path other than the wrapper is the user's own # install, such as the symlink Cursor's installer leaves. A mise copy would # only shadow it, since the mise shims precede ~/.local/bin on PATH. + managed_wrapper() { + local wrapper="$HOME/.local/bin/$agent" + grep -Eq '^mise use -g|^# omarchy:mise-managed=true$' "$wrapper" && return 0 + # Recognize the exact two-line read-only template written before the marker + # was added, while leaving wrappers with user setup outside that template. + [[ $(head -n 1 "$wrapper") == '#!/bin/bash' ]] && + (( $(wc -l <"$wrapper") == 2 )) && + grep -Eq '^exec mise x .+ -- .+ "\$@"$' "$wrapper" + } user_install() { [[ -x $HOME/.local/bin/$agent ]] && - { [[ -L $HOME/.local/bin/$agent ]] || ! grep -q '^mise use -g' "$HOME/.local/bin/$agent"; } + { [[ -L $HOME/.local/bin/$agent ]] || ! managed_wrapper; } } agent_present() { user_install || mise where "$agent_package" &>/dev/null; } agent_install() { user_install || mise use -g "$agent_package"; } diff --git a/bin/omarchy-mise-install b/bin/omarchy-mise-install index 0ab31c8d86b6..e7853ab5c7be 100755 --- a/bin/omarchy-mise-install +++ b/bin/omarchy-mise-install @@ -53,6 +53,7 @@ mise use -g --quiet "$package" || exit 1 rm -f "$HOME/.local/bin/$command" cat >"$HOME/.local/bin/$command" < AI entry used to key only on the pacman package. A newer @@ -17,12 +17,4 @@ if command -v openclaw >/dev/null 2>&1; then exit 0 fi -if systemctl --user is-enabled --quiet openclaw-gateway.service 2>/dev/null; then - exit 0 -fi - -if [[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/openclaw-gateway.service ]]; then - exit 0 -fi - exit 1 diff --git a/bin/omarchy-update-mise b/bin/omarchy-update-mise index e8d9374296ee..2efe280b9e6e 100755 --- a/bin/omarchy-update-mise +++ b/bin/omarchy-update-mise @@ -8,5 +8,6 @@ if omarchy-cmd-present mise; then # Honor mise / npm release cooldowns. Do not force MISE_MINIMUM_RELEASE_AGE=0. if ! mise up; then echo -e "\e[33mmise up could not refresh every tool (often a release cooldown). Retry later or adjust MISE_MINIMUM_RELEASE_AGE / npm min-release-age.\e[0m" >&2 + exit 1 fi fi diff --git a/test/shell.d/mise-managed-agent-test.sh b/test/shell.d/mise-managed-agent-test.sh new file mode 100644 index 000000000000..8c5dc9e5ffa9 --- /dev/null +++ b/test/shell.d/mise-managed-agent-test.sh @@ -0,0 +1,44 @@ +#!/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 +export HOME="$test_tmp/home" +mkdir -p "$test_tmp/bin" +export TEST_LOG="$test_tmp/log" +export PATH="$test_tmp/bin:$ROOT/bin:$PATH" +cat >"$test_tmp/bin/mise" <<'STUB' +#!/bin/bash +printf '%s\n' "$*" >>"$TEST_LOG" +[[ $1 != where && ${TEST_MISE_FAIL:-0} != 1 ]] +STUB +cat >"$test_tmp/bin/omarchy-launch-floating-terminal-with-presentation" <<'STUB' +#!/bin/bash +printf 'install-terminal:%s\n' "$*" >>"$TEST_LOG" +STUB +cat >"$test_tmp/bin/omarchy-agent" <<'STUB' +#!/bin/bash +printf 'agent:%s\n' "$*" >>"$TEST_LOG" +STUB +cat >"$test_tmp/bin/omarchy-cmd-present" <<'STUB' +#!/bin/bash +exit 0 +STUB +chmod +x "$test_tmp/bin/"* +omarchy-mise-install codex +: >"$TEST_LOG" +omarchy-default-agent codex +grep -Fx 'where codex' "$TEST_LOG" >/dev/null || fail "generated wrapper must probe its mise package" +grep -F 'install-terminal:omarchy-default-agent --install codex' "$TEST_LOG" >/dev/null || fail "a missing package must start installation before selecting the agent" +[[ ! -f $HOME/.config/omarchy/defaults/agent ]] || fail "a missing agent must not become the default" +# Existing read-only wrappers from the migration predate the explicit marker. +printf '#!/bin/bash\nexec mise x "codex" -- "codex" "$@"\n' >"$HOME/.local/bin/codex" +: >"$TEST_LOG" +omarchy-default-agent codex +grep -Fx 'where codex' "$TEST_LOG" >/dev/null || fail "legacy read-only wrappers must probe their package" +omarchy-default-agent --install codex +grep -Fx 'use -g codex' "$TEST_LOG" >/dev/null || fail "managed agent selection must restore the package pin" +[[ $(cat "$HOME/.config/omarchy/defaults/agent") == codex ]] || fail "successful installation must set the default" +TEST_MISE_FAIL=1 omarchy-update-mise >"$test_tmp/update" 2>&1 && fail "mise update failures must propagate" +TEST_MISE_FAIL=0 omarchy-update-mise >/dev/null +pass "managed wrappers restore missing mise packages and update failures propagate" diff --git a/test/shell.d/openclaw-present-test.sh b/test/shell.d/openclaw-present-test.sh index 8997f8dd9d6d..c08a360376ed 100755 --- a/test/shell.d/openclaw-present-test.sh +++ b/test/shell.d/openclaw-present-test.sh @@ -46,17 +46,17 @@ exit 0 SH chmod +x "$tmp/bin/omarchy-pkg-add" -omarchy-install-openclaw-cli --check || fail "--check should succeed for PATH openclaw" -omarchy-install-openclaw-cli --now || fail "--now should succeed without installing" +if omarchy-install-openclaw-cli --check; then fail "--check must reject an incomplete managed runtime"; fi +if omarchy-install-openclaw-cli --now; then fail "--now must reject a foreign PATH install"; fi if [[ -s $TEST_LOG ]]; then fail "--now must not reinstall over a PATH openclaw" "$(cat "$TEST_LOG")" fi -pass "install-openclaw-cli leaves a PATH openclaw alone" +pass "install-openclaw-cli rejects a foreign PATH openclaw without reinstalling" rm -f "$tmp/bin/openclaw" touch "$XDG_CONFIG_HOME/systemd/user/openclaw-gateway.service" -omarchy-openclaw-present || fail "gateway unit should count as present" -pass "gateway unit counts as present" +if omarchy-openclaw-present; then fail "a gateway unit without a command must not count as installed"; fi +pass "a gateway unit without its CLI does not hide installation" # Shadowed PATH warning (exercise the detection the launcher uses). rm -f "$XDG_CONFIG_HOME/systemd/user/openclaw-gateway.service" From c763921edcee8c4a72c62c11315f13519f9071d8 Mon Sep 17 00:00:00 2001 From: Taksh Date: Mon, 5 Oct 2026 15:14:13 +0530 Subject: [PATCH 07/10] Match legacy wrappers only to the selected agent package --- bin/omarchy-default-agent | 15 ++++++++++----- test/shell.d/mise-managed-agent-test.sh | 6 ++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bin/omarchy-default-agent b/bin/omarchy-default-agent index a48406c7bf06..c88fa558d498 100755 --- a/bin/omarchy-default-agent +++ b/bin/omarchy-default-agent @@ -74,11 +74,16 @@ else managed_wrapper() { local wrapper="$HOME/.local/bin/$agent" grep -Eq '^mise use -g|^# omarchy:mise-managed=true$' "$wrapper" && return 0 - # Recognize the exact two-line read-only template written before the marker - # was added, while leaving wrappers with user setup outside that template. - [[ $(head -n 1 "$wrapper") == '#!/bin/bash' ]] && - (( $(wc -l <"$wrapper") == 2 )) && - grep -Eq '^exec mise x .+ -- .+ "\$@"$' "$wrapper" + # Recognize the exact old template only for this agent's own package and + # executable; a user's two-line wrapper can deliberately run another tool. + local package_arg bin_arg text + printf -v package_arg '%q' "$agent_package" + printf -v bin_arg '%q' "$agent" + text=$(cat "$wrapper") + (( $(wc -l <"$wrapper") == 2 )) && + { [[ $text == $'#!/bin/bash\nexec mise x '"\"$agent_package\" -- \"$agent\" \"\$@\"" ]] || + [[ $text == $'#!/bin/bash\nexec mise x '"$package_arg -- $bin_arg \"\$@\"" ]]; } + } user_install() { [[ -x $HOME/.local/bin/$agent ]] && diff --git a/test/shell.d/mise-managed-agent-test.sh b/test/shell.d/mise-managed-agent-test.sh index 8c5dc9e5ffa9..75cda64cb898 100644 --- a/test/shell.d/mise-managed-agent-test.sh +++ b/test/shell.d/mise-managed-agent-test.sh @@ -36,6 +36,12 @@ printf '#!/bin/bash\nexec mise x "codex" -- "codex" "$@"\n' >"$HOME/.local/bin/c : >"$TEST_LOG" omarchy-default-agent codex grep -Fx 'where codex' "$TEST_LOG" >/dev/null || fail "legacy read-only wrappers must probe their package" +# A user's canonical-looking wrapper for another package must stay theirs. +printf '#!/bin/bash\nexec mise x "custom-codex" -- "custom-agent" "$@"\n' >"$HOME/.local/bin/codex" +: >"$TEST_LOG" +omarchy-default-agent codex +if grep -E '^(where|use) ' "$TEST_LOG" >/dev/null; then fail "foreign two-line launchers must not trigger mise installation"; fi +printf '#!/bin/bash\nexec mise x "codex" -- "codex" "$@"\n' >"$HOME/.local/bin/codex" omarchy-default-agent --install codex grep -Fx 'use -g codex' "$TEST_LOG" >/dev/null || fail "managed agent selection must restore the package pin" [[ $(cat "$HOME/.config/omarchy/defaults/agent") == codex ]] || fail "successful installation must set the default" From 05e060dfb573401ee964ce0e497adbc2e0fa1130 Mon Sep 17 00:00:00 2001 From: Taksh Date: Tue, 10 Nov 2026 19:16:05 +0530 Subject: [PATCH 08/10] Keep optional wrappers safe for offline migrations --- bin/omarchy-mise-install | 7 +------ test/shell.d/bun-agent-cpu-test.sh | 4 ++++ test/shell.d/mise-install-test.sh | 9 +++++---- test/shell.d/mise-managed-agent-test.sh | 5 +++++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bin/omarchy-mise-install b/bin/omarchy-mise-install index e7853ab5c7be..8d5e43441ac9 100755 --- a/bin/omarchy-mise-install +++ b/bin/omarchy-mise-install @@ -44,12 +44,7 @@ case "$bin" in *) bin_arg="\"$bin\"" ;; esac -# Install / pin once here. The generated wrapper must not rewrite global mise -# config (or disable release cooldowns) on every ordinary invocation — that is -# what left machines racing on shared mise locks when a caller timed out mid -# `mise use` (#11886). -mise use -g --quiet "$package" || exit 1 - +# Historical migrations use this to write optional launchers offline. rm -f "$HOME/.local/bin/$command" cat >"$HOME/.local/bin/$command" <"$mock_bin/omarchy-agent" <<'SH' #!/bin/bash exit 0 SH +cat >"$mock_bin/omarchy-install-chromium-claude" <<'SH' +#!/bin/bash +exit 0 +SH chmod +x "$mock_bin"/* terminal_log="$test_tmp/terminal" diff --git a/test/shell.d/mise-install-test.sh b/test/shell.d/mise-install-test.sh index 888eb6c66350..2588f87f87cf 100644 --- a/test/shell.d/mise-install-test.sh +++ b/test/shell.d/mise-install-test.sh @@ -21,6 +21,7 @@ for arg in "$@"; do printf '\t%s' "$arg" >>"$OMARCHY_MISE_TEST_LOG" done printf '\n' >>"$OMARCHY_MISE_TEST_LOG" +[[ ${OMARCHY_MISE_TEST_OFFLINE:-0} != 1 ]] SH chmod +x "$stub_bin/mise" @@ -30,14 +31,14 @@ install_wrapper() { } # The ordinary case still works, and every call site in install/user/mise.sh -# passes names of this shape. Install pins once; the wrapper only execs. +# passes names of this shape. Wrapper creation also has to work offline. install_log="$tmpdir/install-normal.log" : >"$install_log" -install_wrapper "$install_log" npm:playwright playwright >/dev/null +OMARCHY_MISE_TEST_OFFLINE=1 install_wrapper "$install_log" npm:playwright playwright >/dev/null || + fail "writing an optional wrapper does not need a package download" [[ -x $home/.local/bin/playwright ]] || fail "a normal install writes an executable wrapper" -grep -Fqx $'mise\tuse\t-g\t--quiet\tnpm:playwright' "$install_log" || - fail "install pins the package once" "$(cat "$install_log")" +[[ ! -s $install_log ]] || fail "creating the wrapper does not call mise" "$(cat "$install_log")" run_log="$tmpdir/run-normal.log" : >"$run_log" diff --git a/test/shell.d/mise-managed-agent-test.sh b/test/shell.d/mise-managed-agent-test.sh index 75cda64cb898..2b5ed5132026 100644 --- a/test/shell.d/mise-managed-agent-test.sh +++ b/test/shell.d/mise-managed-agent-test.sh @@ -4,6 +4,7 @@ source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" test_tmp=$(mktemp -d) trap 'rm -rf "$test_tmp"' EXIT export HOME="$test_tmp/home" +export OMARCHY_MISE_CONFIG_PATH="$test_tmp/no-tools.toml" mkdir -p "$test_tmp/bin" export TEST_LOG="$test_tmp/log" export PATH="$test_tmp/bin:$ROOT/bin:$PATH" @@ -45,6 +46,10 @@ printf '#!/bin/bash\nexec mise x "codex" -- "codex" "$@"\n' >"$HOME/.local/bin/c omarchy-default-agent --install codex grep -Fx 'use -g codex' "$TEST_LOG" >/dev/null || fail "managed agent selection must restore the package pin" [[ $(cat "$HOME/.config/omarchy/defaults/agent") == codex ]] || fail "successful installation must set the default" +: >"$TEST_LOG" +OMARCHY_MISE_CONFIG_PATH="$ROOT/etc/mise/conf.d/omarchy-tools.toml" omarchy-default-agent --install codex +grep -Fx 'install codex' "$TEST_LOG" >/dev/null || fail "a declared agent is installed without rewriting the user pin" +if grep -E '^use ' "$TEST_LOG" >/dev/null; then fail "installing a declared agent must leave the user pin alone"; fi TEST_MISE_FAIL=1 omarchy-update-mise >"$test_tmp/update" 2>&1 && fail "mise update failures must propagate" TEST_MISE_FAIL=0 omarchy-update-mise >/dev/null pass "managed wrappers restore missing mise packages and update failures propagate" From 3a17cbe377f47834d6e94983640df08e21aca348 Mon Sep 17 00:00:00 2001 From: Taksh Date: Tue, 10 Nov 2026 19:41:51 +0530 Subject: [PATCH 09/10] Align the agent suite with offline wrapper creation --- bin/omarchy-hw-cpu-sse4_2 | 2 +- bin/omarchy-openclaw-present | 2 +- test/shell.d/default-agent-test.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/omarchy-hw-cpu-sse4_2 b/bin/omarchy-hw-cpu-sse4_2 index a7b75e31e1aa..50fc94c8fc2c 100755 --- a/bin/omarchy-hw-cpu-sse4_2 +++ b/bin/omarchy-hw-cpu-sse4_2 @@ -40,7 +40,7 @@ if [[ -r $cpuinfo ]]; then flags=$(awk -F: '/^flags[[:space:]]*:/{print $2; exit}' "$cpuinfo") fi -if [[ -z $flags ]] && command -v lscpu >/dev/null; then +if [[ -z $flags ]] && omarchy-cmd-present lscpu; then flags=$(lscpu 2>/dev/null | awk -F: '/^Flags:/{print $2; exit}') fi diff --git a/bin/omarchy-openclaw-present b/bin/omarchy-openclaw-present index c595fabd6039..8bfc7f20740d 100755 --- a/bin/omarchy-openclaw-present +++ b/bin/omarchy-openclaw-present @@ -13,7 +13,7 @@ if omarchy-pkg-present openclaw 2>/dev/null; then exit 0 fi -if command -v openclaw >/dev/null 2>&1; then +if omarchy-cmd-present openclaw; then exit 0 fi diff --git a/test/shell.d/default-agent-test.sh b/test/shell.d/default-agent-test.sh index 075ecfc0a792..f12358bf1f66 100644 --- a/test/shell.d/default-agent-test.sh +++ b/test/shell.d/default-agent-test.sh @@ -178,7 +178,7 @@ assert_lazy_stub() { "$test_home/.local/bin/$command" --version mapfile -t mise_calls <"$mise_history" - [[ ${mise_calls[0]} == "use -g --quiet $package" && ${mise_calls[1]} == "x $package -- $command --version" ]] || + [[ ${#mise_calls[@]} == 1 && ${mise_calls[0]} == "x $package -- $command --version" ]] || fail "$command lazy stub preserves its mise package" } From 6a3827d35df7db1ec31caff52574bbe2e394a5b2 Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 13 Nov 2026 15:18:20 +0530 Subject: [PATCH 10/10] Consolidate agent regressions into the existing suites --- test/shell.d/bun-agent-cpu-test.sh | 132 ------------------------ test/shell.d/default-agent-test.sh | 65 ++++++++++++ test/shell.d/mise-install-test.sh | 9 ++ test/shell.d/mise-managed-agent-test.sh | 55 ---------- test/shell.d/openclaw-cli-test.sh | 10 ++ test/shell.d/openclaw-present-test.sh | 59 ----------- 6 files changed, 84 insertions(+), 246 deletions(-) delete mode 100755 test/shell.d/bun-agent-cpu-test.sh delete mode 100644 test/shell.d/mise-managed-agent-test.sh delete mode 100755 test/shell.d/openclaw-present-test.sh diff --git a/test/shell.d/bun-agent-cpu-test.sh b/test/shell.d/bun-agent-cpu-test.sh deleted file mode 100755 index 49481c4c9026..000000000000 --- a/test/shell.d/bun-agent-cpu-test.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/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" -cpuinfo_dir="$test_tmp/cpuinfo" -mise_log="$test_tmp/mise" -skip_log="$test_tmp/skip" -mkdir -p "$mock_bin" "$test_home" "$cpuinfo_dir" - -cat >"$cpuinfo_dir/core2duo" <<'EOF' -processor : 0 -vendor_id : GenuineIntel -cpu family : 6 -model : 23 -model name : Intel(R) Core(TM)2 Duo CPU E7600 @ 3.06GHz -stepping : 10 -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc art arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm tpr_shadow vnmi flexpriority -EOF - -cat >"$cpuinfo_dir/haswell" <<'EOF' -processor : 0 -vendor_id : GenuineIntel -cpu family : 6 -model : 60 -model name : Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz -stepping : 3 -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d -EOF - -cat >"$cpuinfo_dir/aarch64" <<'EOF' -processor : 0 -BogoMIPS : 48.00 -Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop -CPU implementer : 0x41 -CPU architecture: 8 -CPU variant : 0x4 -CPU part : 0xd0b -CPU revision : 1 -EOF - -cat >"$cpuinfo_dir/sse4_2-only" <<'EOF' -processor : 0 -vendor_id : GenuineIntel -flags : fpu sse sse2 sse3 ssse3 sse4_1 sse4_2 -EOF - -export PATH="$mock_bin:$ROOT/bin:$PATH" -export HOME="$test_home" -export OMARCHY_PATH="$ROOT" -export OMARCHY_MISE_CONFIG_PATH="$ROOT/etc/mise/conf.d/omarchy-tools.toml" -export OMARCHY_TEST_MISE_LOG="$mise_log" - -hw_cpu() { - "$ROOT/bin/omarchy-hw-cpu-sse4_2" -} - -assert_hw() { - local description=$1 expected=$2 - local actual=no - - hw_cpu && actual=yes - [[ $actual == "$expected" ]] || fail "$description" "expected $expected, got $actual" - pass "$description" -} - -OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" assert_hw "x86 without sse4_2 is not Bun linux-x64 compatible" no -OMARCHY_CPUINFO="$cpuinfo_dir/sse4_2-only" assert_hw "x86 with sse4_2 but no popcnt is not Bun linux-x64 compatible" no -OMARCHY_CPUINFO="$cpuinfo_dir/haswell" assert_hw "x86 with sse4_2 and popcnt is Bun linux-x64 compatible" yes -OMARCHY_CPUINFO="$cpuinfo_dir/aarch64" assert_hw "aarch64 cpuinfo is Bun linux-x64 compatible" yes -OMARCHY_ARCH=aarch64 OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" assert_hw "OMARCHY_ARCH=aarch64 still installs even with x86 cpuinfo" yes - -cat >"$mock_bin/mise" <<'SH' -#!/bin/bash -printf '%s\n' "$*" >>"$OMARCHY_TEST_MISE_LOG" -if [[ $1 == "where" ]]; then - [[ ${OMARCHY_TEST_AGENT_INSTALLED:-false} == "true" ]] - exit -fi -exit 0 -SH - -cat >"$mock_bin/omarchy-launch-floating-terminal-with-presentation" <<'SH' -#!/bin/bash -printf '%s\n' "$*" >>"$OMARCHY_TEST_TERMINAL_LOG" -SH - -cat >"$mock_bin/omarchy-agent" <<'SH' -#!/bin/bash -exit 0 -SH -cat >"$mock_bin/omarchy-install-chromium-claude" <<'SH' -#!/bin/bash -exit 0 -SH -chmod +x "$mock_bin"/* - -terminal_log="$test_tmp/terminal" -export OMARCHY_TEST_TERMINAL_LOG="$terminal_log" - -: >"$mise_log" -: >"$terminal_log" -mkdir -p "$test_home/.config/omarchy/defaults" -if OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" omarchy-default-agent claude >"$skip_log" 2>&1; then - fail "default agent installs claude on a CPU without SSE4.2" -fi -grep -q 'SSE4.2' "$skip_log" || fail "default agent explains why claude cannot be installed" -[[ ! -s $mise_log ]] || fail "default agent does not invoke mise for an incompatible claude" -[[ ! -s $terminal_log ]] || fail "default agent does not open an install terminal for incompatible claude" -[[ ! -f $test_home/.config/omarchy/defaults/agent ]] || fail "default agent does not record an incompatible claude" -pass "default agent refuses claude on a CPU without SSE4.2" - -: >"$mise_log" -: >"$skip_log" -if OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" omarchy-default-agent pi >"$skip_log" 2>&1; then - fail "default agent installs pi on a CPU without SSE4.2" -fi -grep -q 'SSE4.2' "$skip_log" || fail "default agent explains why pi cannot be installed" -[[ ! -s $mise_log ]] || fail "default agent does not invoke mise for an incompatible pi" -pass "default agent refuses pi on a CPU without SSE4.2" - -: >"$mise_log" -OMARCHY_CPUINFO="$cpuinfo_dir/haswell" OMARCHY_TEST_AGENT_INSTALLED=true omarchy-default-agent claude >/dev/null -grep -qx 'install claude' "$mise_log" || fail "default agent installs the declared claude tool when the CPU can run Bun" -[[ $(<"$test_home/.config/omarchy/defaults/agent") == claude ]] || fail "default agent records claude on a compatible CPU" -pass "default agent still installs claude when SSE4.2 and POPCNT are present" diff --git a/test/shell.d/default-agent-test.sh b/test/shell.d/default-agent-test.sh index f12358bf1f66..ee468f3d6f4d 100644 --- a/test/shell.d/default-agent-test.sh +++ b/test/shell.d/default-agent-test.sh @@ -287,6 +287,41 @@ omarchy-remove-preinstalls >/dev/null rm "$test_home/.local/bin/muse" pass "Remove Preinstalls keeps a user-managed Muse install" +# Bun's x86 build needs both flags; ARM uses a different build. +cpuinfo_dir="$test_tmp/cpuinfo" +mkdir -p "$cpuinfo_dir" +printf 'flags : sse4_1\n' >"$cpuinfo_dir/core2duo" +printf 'flags : sse4_1 sse4_2\n' >"$cpuinfo_dir/sse4_2-only" +printf 'flags : sse4_1 sse4_2 popcnt\n' >"$cpuinfo_dir/haswell" +printf 'Features : fp asimd\n' >"$cpuinfo_dir/aarch64" +for cpu in core2duo sse4_2-only haswell aarch64; do + compatible=false + OMARCHY_ARCH='' OMARCHY_CPUINFO="$cpuinfo_dir/$cpu" "$ROOT/bin/omarchy-hw-cpu-sse4_2" && compatible=true + case $cpu in + core2duo | sse4_2-only) [[ $compatible == "false" ]] || fail "$cpu cannot run Bun's x86 build" ;; + *) [[ $compatible == "true" ]] || fail "$cpu can run its Bun build" ;; + esac +done +OMARCHY_ARCH=aarch64 OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" "$ROOT/bin/omarchy-hw-cpu-sse4_2" || + fail "the architecture override takes precedence over x86 cpuinfo" +pass "Bun CPU detection requires SSE4.2 and POPCNT only on x86" + +for agent in claude pi; do + : >"$mise_history" + : >"$terminal_log" + if OMARCHY_ARCH=x86_64 OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" omarchy-default-agent "$agent" >"$test_tmp/cpu-skip" 2>&1; then + fail "default agent refuses $agent on an incompatible CPU" + fi + grep -q 'SSE4.2' "$test_tmp/cpu-skip" || fail "default agent explains why $agent cannot run" + [[ ! -s $mise_history && ! -s $terminal_log && ! -f $agent_file ]] || + fail "an incompatible $agent is not installed, launched or selected" +done +OMARCHY_ARCH=x86_64 OMARCHY_CPUINFO="$cpuinfo_dir/haswell" OMARCHY_TEST_AGENT_INSTALLED=true \ + OMARCHY_MISE_CONFIG_PATH="$ROOT/etc/mise/conf.d/omarchy-tools.toml" omarchy-default-agent claude >/dev/null +[[ $(<"$agent_file") == "claude" ]] || fail "a compatible CPU can select Claude" +grep -Fx 'install claude' "$mise_history" >/dev/null || fail "a compatible CPU installs the declared Claude tool" +rm "$agent_file" +pass "agent selection checks CPU support before installation" [[ -z $(omarchy-default-agent) ]] || fail "default agent is unset until one is chosen" pass "default agent is unset until one is chosen" @@ -344,6 +379,36 @@ SH chmod +x "$mock_bin/omarchy-agent" hash -r +# A managed wrapper is not evidence that its package is installed. +"$ROOT/bin/omarchy-mise-install" codex +for wrapper in generated legacy; do + if [[ $wrapper == "legacy" ]]; then + printf '#!/bin/bash\nexec mise x "codex" -- "codex" "$@"\n' >"$test_home/.local/bin/codex" + fi + : >"$mise_history" + : >"$terminal_log" + omarchy-default-agent codex + grep -Fx 'where codex' "$mise_history" >/dev/null || fail "$wrapper wrappers probe their mise package" + mapfile -d '' -t terminal_args <"$terminal_log" + [[ ${terminal_args[*]} == "omarchy-default-agent --install codex" && ! -f $agent_file ]] || + fail "$wrapper wrappers install a missing package before selecting it" +done +printf '#!/bin/bash\nexec mise x "custom-codex" -- "custom-agent" "$@"\n' >"$test_home/.local/bin/codex" +: >"$mise_history" +omarchy-default-agent codex +[[ ! -s $mise_history ]] || fail "a foreign two-line launcher must not trigger mise installation" +printf '#!/bin/bash\nexec mise x "codex" -- "codex" "$@"\n' >"$test_home/.local/bin/codex" +: >"$mise_history" +omarchy-default-agent --install codex >/dev/null +grep -Fx 'use -g codex' "$mise_history" >/dev/null || fail "managed selection restores an undeclared package pin" +[[ $(<"$agent_file") == "codex" ]] || fail "a successful installation selects the managed agent" +: >"$mise_history" +OMARCHY_MISE_CONFIG_PATH="$ROOT/etc/mise/conf.d/omarchy-tools.toml" omarchy-default-agent --install codex >/dev/null +grep -Fx 'install codex' "$mise_history" >/dev/null || fail "a declared managed agent uses the system declaration" +grep -q '^use ' "$mise_history" && fail "a declared managed agent leaves the user's pin alone" +rm "$test_home/.local/bin/codex" "$agent_file" +pass "managed wrappers restore missing packages without taking over foreign launchers" + declare -A expected_agents=( [pi]="pi" [omp]="omp" diff --git a/test/shell.d/mise-install-test.sh b/test/shell.d/mise-install-test.sh index 2588f87f87cf..272ea5d8b77d 100644 --- a/test/shell.d/mise-install-test.sh +++ b/test/shell.d/mise-install-test.sh @@ -110,3 +110,12 @@ fi fail "an escaping command name removes nothing outside ~/.local/bin" pass "an escaping command name removes nothing outside ~/.local/bin" + +update_log="$tmpdir/update.log" +if HOME="$home" PATH="$stub_bin:$ROOT/bin:$PATH" OMARCHY_MISE_TEST_LOG="$update_log" OMARCHY_MISE_TEST_OFFLINE=1 \ + "$ROOT/bin/omarchy-update-mise" >"$tmpdir/update-failure" 2>&1; then + fail "mise update failures propagate" +fi +HOME="$home" PATH="$stub_bin:$ROOT/bin:$PATH" OMARCHY_MISE_TEST_LOG="$update_log" \ + "$ROOT/bin/omarchy-update-mise" >/dev/null || fail "successful mise updates succeed" +pass "mise updates propagate the tool's exit status" diff --git a/test/shell.d/mise-managed-agent-test.sh b/test/shell.d/mise-managed-agent-test.sh deleted file mode 100644 index 2b5ed5132026..000000000000 --- a/test/shell.d/mise-managed-agent-test.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/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 -export HOME="$test_tmp/home" -export OMARCHY_MISE_CONFIG_PATH="$test_tmp/no-tools.toml" -mkdir -p "$test_tmp/bin" -export TEST_LOG="$test_tmp/log" -export PATH="$test_tmp/bin:$ROOT/bin:$PATH" -cat >"$test_tmp/bin/mise" <<'STUB' -#!/bin/bash -printf '%s\n' "$*" >>"$TEST_LOG" -[[ $1 != where && ${TEST_MISE_FAIL:-0} != 1 ]] -STUB -cat >"$test_tmp/bin/omarchy-launch-floating-terminal-with-presentation" <<'STUB' -#!/bin/bash -printf 'install-terminal:%s\n' "$*" >>"$TEST_LOG" -STUB -cat >"$test_tmp/bin/omarchy-agent" <<'STUB' -#!/bin/bash -printf 'agent:%s\n' "$*" >>"$TEST_LOG" -STUB -cat >"$test_tmp/bin/omarchy-cmd-present" <<'STUB' -#!/bin/bash -exit 0 -STUB -chmod +x "$test_tmp/bin/"* -omarchy-mise-install codex -: >"$TEST_LOG" -omarchy-default-agent codex -grep -Fx 'where codex' "$TEST_LOG" >/dev/null || fail "generated wrapper must probe its mise package" -grep -F 'install-terminal:omarchy-default-agent --install codex' "$TEST_LOG" >/dev/null || fail "a missing package must start installation before selecting the agent" -[[ ! -f $HOME/.config/omarchy/defaults/agent ]] || fail "a missing agent must not become the default" -# Existing read-only wrappers from the migration predate the explicit marker. -printf '#!/bin/bash\nexec mise x "codex" -- "codex" "$@"\n' >"$HOME/.local/bin/codex" -: >"$TEST_LOG" -omarchy-default-agent codex -grep -Fx 'where codex' "$TEST_LOG" >/dev/null || fail "legacy read-only wrappers must probe their package" -# A user's canonical-looking wrapper for another package must stay theirs. -printf '#!/bin/bash\nexec mise x "custom-codex" -- "custom-agent" "$@"\n' >"$HOME/.local/bin/codex" -: >"$TEST_LOG" -omarchy-default-agent codex -if grep -E '^(where|use) ' "$TEST_LOG" >/dev/null; then fail "foreign two-line launchers must not trigger mise installation"; fi -printf '#!/bin/bash\nexec mise x "codex" -- "codex" "$@"\n' >"$HOME/.local/bin/codex" -omarchy-default-agent --install codex -grep -Fx 'use -g codex' "$TEST_LOG" >/dev/null || fail "managed agent selection must restore the package pin" -[[ $(cat "$HOME/.config/omarchy/defaults/agent") == codex ]] || fail "successful installation must set the default" -: >"$TEST_LOG" -OMARCHY_MISE_CONFIG_PATH="$ROOT/etc/mise/conf.d/omarchy-tools.toml" omarchy-default-agent --install codex -grep -Fx 'install codex' "$TEST_LOG" >/dev/null || fail "a declared agent is installed without rewriting the user pin" -if grep -E '^use ' "$TEST_LOG" >/dev/null; then fail "installing a declared agent must leave the user pin alone"; fi -TEST_MISE_FAIL=1 omarchy-update-mise >"$test_tmp/update" 2>&1 && fail "mise update failures must propagate" -TEST_MISE_FAIL=0 omarchy-update-mise >/dev/null -pass "managed wrappers restore missing mise packages and update failures propagate" diff --git a/test/shell.d/openclaw-cli-test.sh b/test/shell.d/openclaw-cli-test.sh index 53e21dea5937..f7fd36e44313 100755 --- a/test/shell.d/openclaw-cli-test.sh +++ b/test/shell.d/openclaw-cli-test.sh @@ -180,6 +180,7 @@ for script in bin/omarchy-install-openclaw-cli; do "$ROOT/$script" >"$mock_bin/${script##*/}" done chmod +x "$mock_bin/omarchy-install-openclaw-cli" +ln -s "$ROOT/bin/omarchy-cmd-present" "$mock_bin/omarchy-cmd-present" new_home() { test_home="$test_tmp/$1" @@ -209,6 +210,13 @@ run_update() { "$@" >"$test_tmp/output" 2>&1 } +new_home absent +run "$ROOT/bin/omarchy-openclaw-present" && fail "an absent OpenClaw does not count as installed" +mkdir -p "$test_home/.config/systemd/user" +touch "$test_home/.config/systemd/user/openclaw-gateway.service" +run "$ROOT/bin/omarchy-openclaw-present" && fail "a gateway unit without its CLI does not hide installation" +pass "a leftover gateway unit does not count as an installed OpenClaw" + new_home usage run omarchy-install-openclaw-cli && fail "no mode is a usage error" [[ ! -s $events ]] || fail "no mode installs nothing" "$(cat "$events")" @@ -276,7 +284,9 @@ pass "a runtime that does not run fails the install" new_home foreign printf '#!/bin/bash\necho mine\n' >"$command" chmod +x "$command" +run "$ROOT/bin/omarchy-openclaw-present" || fail "a user-installed CLI on PATH disables the installation entry" run omarchy-install-openclaw-cli --now && fail "a command that is the user's is not replaced" +[[ ! -s $events ]] || fail "a user-installed CLI is rejected before installing another package" "$(cat "$events")" grep -q "Move it aside" "$test_tmp/output" || fail "a command that is the user's is named" "$(cat "$test_tmp/output")" [[ ! -L $command ]] && grep -q mine "$command" || fail "a command that is the user's is kept" run omarchy-install-openclaw-cli --check && fail "--check calls the runtime installed while the command is somebody else's" diff --git a/test/shell.d/openclaw-present-test.sh b/test/shell.d/openclaw-present-test.sh deleted file mode 100755 index d64cc7f3c97a..000000000000 --- a/test/shell.d/openclaw-present-test.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -source "$(dirname "$0")/base-test.sh" - -tmp=$(mktemp -d) -trap 'rm -rf "$tmp"' EXIT -mkdir -p "$tmp/bin" "$tmp/home/.config/systemd/user" -export HOME="$tmp/home" -export XDG_CONFIG_HOME="$tmp/home/.config" -export PATH="$tmp/bin:$ROOT/bin:/usr/bin:/bin" -export TEST_LOG="$tmp/log" -: >"$TEST_LOG" - -cat >"$tmp/bin/omarchy-pkg-present" <<'SH' -#!/bin/bash -exit 1 -SH -chmod +x "$tmp/bin/omarchy-pkg-present" - -cat >"$tmp/bin/systemctl" <<'SH' -#!/bin/bash -exit 1 -SH -chmod +x "$tmp/bin/systemctl" - -if omarchy-openclaw-present; then - fail "absent OpenClaw should not count as present" -fi -pass "absent OpenClaw is not present" - -cat >"$tmp/bin/openclaw" <<'SH' -#!/bin/bash -exit 0 -SH -chmod +x "$tmp/bin/openclaw" - -omarchy-openclaw-present || fail "PATH openclaw should count as present" -pass "PATH openclaw counts as present" - -cat >"$tmp/bin/omarchy-pkg-add" <<'SH' -#!/bin/bash -printf 'pkg-add:%s\n' "$*" >>"$TEST_LOG" -exit 0 -SH -chmod +x "$tmp/bin/omarchy-pkg-add" - -if omarchy-install-openclaw-cli --check; then fail "--check must reject an incomplete managed runtime"; fi -if omarchy-install-openclaw-cli --now; then fail "--now must reject a foreign PATH install"; fi -if [[ -s $TEST_LOG ]]; then - fail "--now must not reinstall over a PATH openclaw" "$(cat "$TEST_LOG")" -fi -pass "install-openclaw-cli rejects a foreign PATH openclaw without reinstalling" - -rm -f "$tmp/bin/openclaw" -touch "$XDG_CONFIG_HOME/systemd/user/openclaw-gateway.service" -if omarchy-openclaw-present; then fail "a gateway unit without a command must not count as installed"; fi -pass "a gateway unit without its CLI does not hide installation"