Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bin/omarchy-default-agent
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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
Expand Down
47 changes: 47 additions & 0 deletions bin/omarchy-hw-cpu-sse4_2
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 19 additions & 0 deletions bin/omarchy-mise-install-bun
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# omarchy:summary=Install a Bun linux-x64 agent when the CPU can run it.
# omarchy:args=<package> [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 <package> [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
4 changes: 2 additions & 2 deletions default/omarchy/omarchy-menu.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -147,7 +147,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"},
Expand Down
4 changes: 2 additions & 2 deletions install/user/mise.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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.
Expand Down
170 changes: 170 additions & 0 deletions test/shell.d/bun-agent-cpu-test.sh
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 4 additions & 3 deletions test/shell.d/menu-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -238,7 +239,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 mise-installable coding agent with its own glyph under Defaults > Agent'
Expand Down