diff --git a/home/bin/oc2 b/home/bin/oc2 index efde972..1ef0dc6 100755 --- a/home/bin/oc2 +++ b/home/bin/oc2 @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Launch OpenCode 2 with an isolated config so it cannot rewrite -# ~/.config/opencode/opencode.json (OpenCode 1 / firstmate). +# Launch OpenCode with an isolated config so it cannot rewrite +# ~/.config/opencode/opencode.json (firstmate). set -euo pipefail bin="${OPENCODE2_BIN:-/opt/homebrew/opt/opencode/bin/opencode}" @@ -8,7 +8,7 @@ cfg="${OPENCODE_CONFIG:-$HOME/.config/opencode2/opencode.json}" if [ ! -x "$bin" ]; then echo "oc2: stable opencode not installed. Rebuild, or run:" >&2 - echo " brew install opencode && brew unlink opencode" >&2 + echo " brew install opencode" >&2 exit 1 fi if [ ! -e "$cfg" ]; then diff --git a/rebuild.sh b/rebuild.sh index 43cb66e..7cf7a17 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -33,6 +33,17 @@ if [ -x "$NPM" ] && npm_root="$("$NPM" root -g 2>/dev/null)"; then fi done fi +# `opencode` links without --overwrite, so any npm shim left in the Homebrew +# prefix aborts the switch's brew bundle link step. Drop the retired packages' +# shims directly, which also covers a failed uninstall and a missing npm. +for link in /opt/homebrew/bin/*; do + case "$(readlink "$link" 2>/dev/null || true)" in + */node_modules/@opencode-ai/cli/* | */node_modules/opencode-ai/*) + rm -f "$link" + echo "==> Removed stale OpenCode npm shim $link" + ;; + esac +done echo "==> Updating no-mistakes..." NO_MISTAKES_BIN="$HOME/.no-mistakes/bin/no-mistakes"