From 1fda5c09b787e30c3ccbf874f8e2a610f7391680 Mon Sep 17 00:00:00 2001 From: Lap Tran Date: Sun, 8 Nov 2026 12:15:22 -0500 Subject: [PATCH] Run OpenCode 2 from the stable Homebrew formula Declare the opencode formula with link = false so it never replaces the npm-installed OpenCode 1.x CLI at /opt/homebrew/bin/opencode. Drop the npm beta install from home.activation.opencode2, point home/bin/oc2 at the keg binary, and correct the related notes. --- AGENTS.md | 2 +- configuration.nix | 7 ++++++- home.nix | 27 +++++++-------------------- home/bin/oc2 | 6 +++--- rebuild.sh | 2 +- 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 3251244..2f7719b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,7 +9,7 @@ Deliberate decisions in this repo - do NOT silently revert them: - herdr stores runtime state beside its config, so `~/.config/herdr` stays a real directory and only `config.toml` is symlinked; `home.activation.herdrConfigDir` migrates the old whole-directory symlink and clears leaked artifacts. Do not symlink the whole directory - rationale and artifact list are in `home.nix`. - Codex runs on the OpenCode Go subscription. The ChatGPT app owns and rewrites the live `~/.codex/config.toml`, so it is NOT symlinked; `home.activation.codexOpenCodeGo` merges the repo fragment `home/.codex/config.toml` into it on every rebuild, and the app's own sections (`[desktop]`, `[plugins]`, `[mcp_servers]`, ...) survive. Auth is command-backed via `~/.local/bin/opencode-go-token` (prints the key from the opencode store), so `~/.codex/auth.json` stays in ChatGPT mode and ChatGPT sign-in coexists with Go. Only Go models that speak the Responses API work (`deepseek-v4.1-flash`, `gpt-6-luna`, `gpt-5.6-luna`, `grok-4.7/4.6`); GLM/Kimi/MiMo/LongCat are chat-completions-only and need a proxy. Desktop Codex is now the `chatgpt` cask - do not use the deprecated `codex-app` cask. - firstmate lives at `~/Documents/firstmate` as a mutable git clone (not in the Nix store). `home.activation.firstmate` clones it if missing and seeds `config/backend=herdr` + `config/crew-harness=opencode` only when those files are absent. Crew routing is `home/.config/firstmate/crew-dispatch.json` (symlinked in): per the captain's order 2026-10-21, coding crewmates and scouts use `opencode` + `opencode-go/deepseek-v4.1-flash` through the OpenCode CLI. Design, architecture, and design-review tasks are the exception: the file's first rule sends them to Pi with `openai-codex/gpt-6.1-sol` at `xhigh`, and implementation tasks re-resolve their profile instead of keeping that model. The free `deepseek-v4.1-flash-free` order of 2026-10-20 resumes when that lane resets. The validation pipeline stays on Pi with `opencode-go/deepseek-v4.1-flash` steps and the `opencode-go/glm-5.3-flash` reviewer. Avoid the `muse-spark-*-contributor` models, which train on prompts, and the `exo-free`, `mimo-*-free`, and `nemotron-*-free` models, whose data may be used to improve the model. `cat-jam-free` retains for 30 days. Crews inherit the primary's OpenCode login through the spawn-owned symlink (the isolated worker data root links the primary `/opencode/auth.json`; no `~/.pi/agent/auth.json` reliance). Launch with shell alias `fm` (`cd` + `pi` with the two firstmate primary extensions); the primary runs Pi on the OpenCode Go subscription, while crews run on the opencode harness unless a dispatch rule selects another harness. `oc2` remains the isolated OpenCode 2 fallback. Self-update via `/updatefirstmate`, not rebuild. -- OpenCode 2 is the isolated OpenCode harness behind `oc2`, not the firstmate primary. It is not a Homebrew formula: install `@opencode-ai/cli@beta` with Homebrew's npm (`home.activation.opencode2`). Launch through `home/bin/oc2` so `OPENCODE_CONFIG` stays at `home/.config/opencode2/opencode.json` and cannot rewrite OpenCode 1.x's `~/.config/opencode`. Do not add a brew `opencode` / `opencode2` formula; `zap` would fight the npm install. firstmate harness detection matches `*opencode*`, so the `opencode2` process name still classifies as OpenCode. +- OpenCode 2 is the isolated OpenCode harness behind `oc2`, not the firstmate primary. It is the stable Homebrew `opencode` formula, installed with `link = false` so the OpenCode 1.x CLI keeps `/opt/homebrew/bin/opencode`, and launched only through `home/bin/oc2` so `OPENCODE_CONFIG` stays at `home/.config/opencode2/opencode.json` and cannot rewrite OpenCode 1.x's `~/.config/opencode`. Switching between builds needs `opencode service restart`, because the client refuses a background service left over from the other build with `Background service uses an incompatible health protocol`. firstmate harness detection matches `*opencode*`, so it still classifies as OpenCode. - Shell aliases: `cc` (Claude skip-permissions), `co` (Codex full-auto), `gb` (Grok --yolo), `fm` (firstmate via Pi), `oc2` (OpenCode 2, isolated). They are intentional high-agency shortcuts. - OpenSuperWhisper is installed by the `opensuperwhisper` cask, and `home.activation.openSuperWhisper` downloads its Whisper model (`ggml-large-v3-turbo.bin` under the app's Application Support directory, never the Nix store) and seeds the model selection only when it is missing or dangling. All other app settings (trigger, language, paste behavior) belong to the app and must not be rewritten by a rebuild, so `modifierOnlyHotkey = rightOption` on this machine stays the effective trigger. Microphone/Accessibility/Input Monitoring grants stay manual because macOS TCC cannot be declarative; do not kill a running app to apply defaults. The model is local-only. diff --git a/configuration.nix b/configuration.nix index d7bb46d..e5a11b4 100644 --- a/configuration.nix +++ b/configuration.nix @@ -54,7 +54,12 @@ # resolves on the normal PATH. No server, service, database, or # connection is configured. { name = "libpq"; link = true; } - "node" # required: opencode2 is an npm global, not a Homebrew formula + "node" # required: backpass and acpx are npm globals, not formulae + # OpenCode 2 stable. Installed unlinked so it never replaces the + # npm-installed OpenCode 1.x CLI at /opt/homebrew/bin/opencode (the crew + # harness); home/bin/oc2 runs this keg binary directly. `link = false` + # makes brew bundle unlink after install, which is deterministic. + { name = "opencode"; link = false; } "pi-coding-agent" "tea" # Gitea CLI - PRs for firstmate crewmates on unraid.local:3003 "tmux" diff --git a/home.nix b/home.nix index ab5ce60..507a39c 100644 --- a/home.nix +++ b/home.nix @@ -369,23 +369,10 @@ in "$HOME/.codex/config.toml" ''; - # OpenCode 2 is not on Homebrew (beta). Install via Homebrew's npm, never - # Nix's npm (EACCES on the store). Skip when already present so a rebuild - # does not pull a new beta under a live TUI. Activation blocks are inlined - # into one flat script, so never `exit 0` here: that would skip every later - # block (securityAuditSkill, setupLaunchAgents, syncMusic). - home.activation.opencode2 = lib.hm.dag.entryAfter [ "writeBoundary" ] '' - set -euo pipefail - npm=/opt/homebrew/bin/npm - bin=/opt/homebrew/bin/opencode2 - if [ ! -x "$bin" ]; then - if [ ! -x "$npm" ]; then - echo "opencode2: /opt/homebrew/bin/npm missing (declare node in homebrew.brews)" >&2 - exit 1 - fi - "$npm" install -g --allow-scripts=@opencode-ai/cli @opencode-ai/cli@beta - fi - ''; + # OpenCode 2 is the stable Homebrew `opencode` formula declared in + # configuration.nix. It is installed unlinked so the OpenCode 1.x CLI keeps + # /opt/homebrew/bin/opencode; home/bin/oc2 runs the keg binary directly. + # Nothing to install here. # backpass (kunchenguid/backpass) - gradient descent for agent memory: reads # the transcript stores of the harnesses this config already declares @@ -394,8 +381,8 @@ in # to a harness you already authenticated, so acpx is a hard runtime dep and # must be on PATH. Homebrew node v26 satisfies backpass (>= 22.5) and acpx # (>= 22.13). Neither is a Homebrew formula: install via Homebrew's npm, - # never Nix's npm (EACCES on the store). Skip-if-present like opencode2 so a - # rebuild never pulls a new version mid-session; refresh manually with + # never Nix's npm (EACCES on the store). Skip-if-present so a rebuild never + # pulls a new version mid-session; refresh manually with # /opt/homebrew/bin/npm update -g backpass acpx home.activation.backpass = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail @@ -468,7 +455,7 @@ in # ~/.config/opencode/skills: home-manager owns that path with force = true and # mkOutOfStoreSymlink into the mutable dotfiles checkout, so a rebuild would # clobber the CLI's link and CLI writes would land in the git checkout. Skip - # when installed, like opencode2/backpass, so a rebuild never pulls a new skill + # when installed, like backpass, so a rebuild never pulls a new skill # version mid-session. The skill's own README still requires an OS-enforced # sandbox before it may run target-controlled builds, tests, browsers, or # fuzzers. That sandbox is home/bin/security-audit-sandbox; without it, those diff --git a/home/bin/oc2 b/home/bin/oc2 index fe88aa2..2fed2d5 100755 --- a/home/bin/oc2 +++ b/home/bin/oc2 @@ -3,12 +3,12 @@ # ~/.config/opencode/opencode.json (OpenCode 1 / firstmate). set -euo pipefail -bin="${OPENCODE2_BIN:-/opt/homebrew/bin/opencode2}" +bin="${OPENCODE2_BIN:-/opt/homebrew/opt/opencode/bin/opencode}" cfg="${OPENCODE_CONFIG:-$HOME/.config/opencode2/opencode.json}" if [ ! -x "$bin" ]; then - echo "oc2: opencode2 not installed. Rebuild, or run:" >&2 - echo " /opt/homebrew/bin/npm install -g --allow-scripts=@opencode-ai/cli @opencode-ai/cli@beta" >&2 + echo "oc2: stable opencode not installed. Rebuild, or run:" >&2 + echo " brew install opencode" >&2 exit 1 fi if [ ! -e "$cfg" ]; then diff --git a/rebuild.sh b/rebuild.sh index b62dc02..d24b115 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -17,7 +17,7 @@ else fi # Install OpenCode 1.x (stable CLI, binary "opencode") if absent. -# Required for free-tier models; opencode2 beta returns HTTP 426 on those endpoints. +# 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