Retire OpenCode 1.x so Homebrew OpenCode 2 is the only install

Link the Homebrew opencode formula at /opt/homebrew/bin/opencode, drop the npm 1.x install from rebuild.sh, and remove leftover npm packages. Update the agent notes and home.nix comments to match.
This commit is contained in:
Lap Tran committed 2026-11-08 18:06:38 -05:00
1 parent b03d71dc81
commit 3c7d2662a4
4 files changed
+26 -44

No files matched your search

+17 -31
View File
@@ -1,9 +1,8 @@
#!/usr/bin/env bash
# Rebuild nix-darwin + home-manager. Rotates stale home-manager *.backup files
# so a second switch never fails with "would be clobbered".
# Also updates flake inputs, upgrades grok-build, installs OpenCode 1.x
# (stable CLI for free-tier), removes the retired OpenCode 2 npm beta, updates
# no-mistakes, and updates pi extensions.
# Also updates flake inputs, upgrades grok-build, removes retired npm OpenCode
# packages, updates no-mistakes, and updates pi extensions.
set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
ln -sfn "$DIR" ~/.dotfiles
@@ -17,35 +16,22 @@ else
echo "==> WARNING: grok-build upgrade failed (network issue). Skipping."
fi
# Install OpenCode 1.x (stable CLI, binary "opencode") if absent.
# Required for free-tier models; OpenCode 2 is the separate stable `oc2` build.
# Uses Homebrew's npm (not Nix's npm) to avoid EACCES on the store.
# Skip if npm is unavailable (e.g., network issues preventing fetch).
OPENCODE_BIN=/opt/homebrew/bin/opencode
if [ ! -x "$OPENCODE_BIN" ]; then
echo "==> Installing OpenCode 1.x (stable) via Homebrew npm..."
if /opt/homebrew/bin/npm install -g --allow-scripts=opencode-ai opencode-ai@1.18 2>&1; then
echo "==> OpenCode 1.x installed successfully"
else
echo "==> WARNING: OpenCode 1.x installation failed (network issue). Skipping."
fi
else
echo "==> OpenCode 1.x already installed: $(${OPENCODE_BIN} --version)"
fi
# Remove the retired OpenCode 2 beta (@opencode-ai/cli, binary "opencode2") if
# an older rebuild installed it. The stable Homebrew `opencode` formula declared
# in configuration.nix is now the only OpenCode 2 install. Local check only, so
# an offline rebuild skips this instead of failing.
# Remove retired npm OpenCode installs if an older rebuild installed them:
# the OpenCode 2 beta (@opencode-ai/cli) and the OpenCode 1.x CLI (opencode-ai).
# The stable Homebrew `opencode` formula declared in configuration.nix is now
# the only OpenCode install. Local check only, so an offline rebuild skips this
# instead of failing.
NPM=/opt/homebrew/bin/npm
if [ -x "$NPM" ] && beta_root="$("$NPM" root -g 2>/dev/null)" && [ -d "$beta_root/@opencode-ai/cli" ]; then
echo "==> Removing retired OpenCode 2 beta (@opencode-ai/cli)..."
if "$NPM" uninstall -g @opencode-ai/cli 2>&1; then
echo "==> OpenCode 2 beta removed"
else
echo "==> WARNING: OpenCode 2 beta removal failed. Remove it manually:"
echo " $NPM uninstall -g @opencode-ai/cli"
fi
if [ -x "$NPM" ] && npm_root="$("$NPM" root -g 2>/dev/null)"; then
for pkg in @opencode-ai/cli opencode-ai; do
if [ -d "$npm_root/$pkg" ]; then
if "$NPM" uninstall -g "$pkg" >/dev/null 2>&1; then
echo "==> Removed retired npm package $pkg"
else
echo "==> WARNING: $pkg removal failed. Remove it manually: $NPM uninstall -g $pkg"
fi
fi
done
fi
echo "==> Updating no-mistakes..."