From 208e6741f3ce7df9e7facb8b1e8705cabaddb471 Mon Sep 17 00:00:00 2001 From: Lap Tran Date: Mon, 16 Nov 2026 09:21:44 -0500 Subject: [PATCH 1/2] feat(firstmate): add explicit fm-oc2 launcher alias and test all three aliases fm and fm-oc2 both run oc2 from the firstmate home. fm-pi stays the explicit Pi fallback. The launcher check now sources the generated zshrc, runs each alias against spies, and asserts the working directory and that fm and fm-oc2 launch identically. The readme records that the aliases share one firstmate home and its task records but keep separate chat histories, so the running primary must be quit before starting the other. --- home.nix | 4 +- readme.md | 12 ++-- tests/fm-launcher.sh | 146 ++++++++++++++++++++++++++++--------------- 3 files changed, 104 insertions(+), 58 deletions(-) diff --git a/home.nix b/home.nix index a4efedc..a883203 100644 --- a/home.nix +++ b/home.nix @@ -83,8 +83,10 @@ in # firstmate primary session in OpenCode 2 on the OpenCode Go subscription, # launched through the isolated-config oc2 wrapper; crewmates = OpenCode by # default. Permanent since 2026-11-15: fm-pi stays only as the explicit Pi - # fallback, never as the default launcher. + # fallback, never as the default launcher. fm-oc2 is the explicit + # OpenCode 2 name and stays byte-identical to fm. fm = "cd ${firstmateHome} && exec ${home}/.local/bin/oc2"; + fm-oc2 = "cd ${firstmateHome} && exec ${home}/.local/bin/oc2"; fm-pi = "cd ${firstmateHome} && exec pi"; oc2 = "${home}/.local/bin/oc2"; # Sync ~/Music into the beets library on Unraid (requires NAS mounted). diff --git a/readme.md b/readme.md index 45a8e5f..a772df2 100644 --- a/readme.md +++ b/readme.md @@ -13,13 +13,15 @@ The firstmate crew dispatch + Gitea PR helper are wired by `darwin-rebuild`, but cd ~/Documents/investor-flow git remote set-url origin http://unraid.local:3003/transnet/investor-flow -Verify: `fm` launches OpenCode 2 as the first mate and `fm-pi` is the explicit Pi fallback; `oc2 --version` prints the Homebrew opencode version; `pi --list-models mimo` shows `opencode-go/mimo-v2.5-pro`; `tea pulls list --repo transnet/investor-flow` works. +Verify: `fm` and `fm-oc2` launch OpenCode 2 as the first mate and `fm-pi` is the explicit Pi fallback; `oc2 --version` prints the Homebrew opencode version; `pi --list-models mimo` shows `opencode-go/mimo-v2.5-pro`; `tea pulls list --repo transnet/investor-flow` works. ## firstmate launcher and crew model routing -`fm` is the permanent firstmate launcher. It changes to `~/Documents/firstmate` and executes `~/.local/bin/oc2`, which runs the Homebrew OpenCode build with the isolated `~/.config/opencode2/opencode.json` config. `fm-pi` remains only as an explicit Pi fallback. Never make Pi the default launcher. +`fm` is the permanent firstmate launcher. `fm-oc2` is the same launcher under its explicit OpenCode 2 name, so both aliases expand to the same command. They change to `~/Documents/firstmate` and execute `~/.local/bin/oc2`, which runs the Homebrew OpenCode build with the isolated `~/.config/opencode2/opencode.json` config. `fm-pi` starts Pi instead and remains only an explicit fallback. Never make Pi the default launcher. -`home.nix` owns both aliases, so a rebuild regenerates them. The installed `~/.zshrc` changes only at the next activation. +The three aliases share one firstmate home. They read the same task records, inbox, and state. Each tool keeps its own chat history, so a conversation in OpenCode 2 does not appear in Pi, and the reverse. Quit the running primary before you start the other one. A single firstmate home serves one primary at a time. + +`home.nix` owns all three aliases, so a rebuild regenerates them. The installed `~/.zshrc` changes only at the next activation. Worker routing lives in `home/.config/firstmate/crew-dispatch.json`, which is symlinked to `~/Documents/firstmate/config/crew-dispatch.json`: @@ -55,7 +57,7 @@ The captain confirmed the split on 2026-11-15. Leave it unchanged: ./tests/run.sh # all checks ``` -The launcher check sources the real generated zshrc in an interactive zsh. A `pi` spy on PATH and an `OPENCODE2_BIN` spy capture the launch, so no firstmate session starts. +The launcher check sources the real generated zshrc in an interactive zsh. A `pi` spy on PATH and an `OPENCODE2_BIN` spy capture the launch of `fm`, `fm-oc2`, and `fm-pi`, record the working directory, and exit at once, so no firstmate session starts. ### Install after merge @@ -65,7 +67,7 @@ The Nix sources in this repository are the durable record. The live files are ge 2. Confirm `readlink ~/.dotfiles` names the checkout that holds the merged commit. 3. Run `./rebuild.sh` from that checkout. 4. Run `./tests/fm-launcher.sh --live` and `./tests/crew-dispatch.sh`. -5. Open a fresh shell and run `alias fm`. It must show `exec /Users/laptran/.local/bin/oc2`. +5. Open a fresh shell and run `alias fm fm-oc2 fm-pi`. `fm` and `fm-oc2` must show `exec /Users/laptran/.local/bin/oc2`, and `fm-pi` must show `exec pi`. ### Checkout topology and safe installation diff --git a/tests/fm-launcher.sh b/tests/fm-launcher.sh index 3b5a7b4..8e894a9 100755 --- a/tests/fm-launcher.sh +++ b/tests/fm-launcher.sh @@ -1,15 +1,21 @@ #!/usr/bin/env bash -# Behavior check: a fresh interactive zsh runs `fm` and the permanent launcher -# starts OpenCode 2 through ~/.local/bin/oc2, never Pi. +# Behavior check: a fresh interactive zsh runs the firstmate launchers and each +# one starts the tool its name promises, from the firstmate home directory. +# +# fm -> OpenCode 2 through ~/.local/bin/oc2 +# fm-oc2 -> OpenCode 2 through ~/.local/bin/oc2, identical to fm +# fm-pi -> Pi # # The check reads the zshrc that the real home-manager configuration generates # (the same file a rebuild installs), sources it in an interactive zsh, and runs -# `fm` with two harmless spies: +# each launcher with three harmless spies: # - a `pi` spy first on PATH, which catches a Pi launch; # - a spy named by OPENCODE2_BIN, which the real ~/.local/bin/oc2 wrapper -# execs instead of the OpenCode binary. -# Nothing here launches a real firstmate primary, Pi, or OpenCode, so no -# session lock is taken. +# execs instead of the OpenCode binary; +# - the spies record their working directory, so a launcher that forgets the +# `cd` into the firstmate home fails here. +# Nothing here launches a real firstmate primary, Pi, or OpenCode, and the spies +# exit at once, so no session lock is taken and the primary stays alive. # # Usage: # tests/fm-launcher.sh # check the configuration source (default) @@ -20,6 +26,8 @@ set -euo pipefail ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P) MODE=source ZSHRC='' +LAUNCHERS='fm:oc2 fm-oc2:oc2 fm-pi:pi' +FM_HOME=${FM_HOME:-"$HOME/Documents/firstmate"} while [ $# -gt 0 ]; do case "$1" in @@ -41,14 +49,14 @@ trap cleanup EXIT mkdir -p "$TMP/bin" cat > "$TMP/bin/pi" <<'SH' #!/usr/bin/env bash -printf 'pi' >> "$FM_TEST_SPY_LOG" +printf 'pi|%s' "$PWD" >> "$FM_TEST_SPY_LOG" for arg in "$@"; do printf '|%s' "$arg" >> "$FM_TEST_SPY_LOG"; done printf '\n' >> "$FM_TEST_SPY_LOG" exit 0 SH cat > "$TMP/bin/opencode2-spy" <<'SH' #!/usr/bin/env bash -printf 'oc2' >> "$FM_TEST_SPY_LOG" +printf 'oc2|%s' "$PWD" >> "$FM_TEST_SPY_LOG" for arg in "$@"; do printf '|%s' "$arg" >> "$FM_TEST_SPY_LOG"; done printf '\n' >> "$FM_TEST_SPY_LOG" exit 0 @@ -77,53 +85,87 @@ esac [ -r "$ZSHRC" ] || { echo "fm-launcher: cannot read $ZSHRC" >&2; exit 2; } -: > "$TMP/spy.log" -: > "$TMP/stderr" +# Run one launcher in a fresh interactive zsh and print what the spies saw. +launch() { + local launcher=$1 + : > "$TMP/spy.log" + : > "$TMP/stderr" -set +e -# shellcheck disable=SC2016 # the snippet expands inside the interactive zsh -FM_TEST_ZSHRC="$ZSHRC" \ -FM_TEST_SPY_LOG="$TMP/spy.log" \ -OPENCODE2_BIN="$TMP/bin/opencode2-spy" \ -OPENCODE_CONFIG="$TMP/opencode.json" \ -PATH="$TMP/bin:$PATH" \ - timeout 60 zsh -f -i -c ' - source "$FM_TEST_ZSHRC" || exit 4 - if ! alias fm >/dev/null 2>&1; then - echo "fm-launcher: no fm alias in the sourced zshrc" >&2 - exit 3 - fi - eval fm - ' >/dev/null 2>"$TMP/stderr" -status=$? -set -e + set +e + # shellcheck disable=SC2016 # the snippet expands inside the interactive zsh + FM_TEST_ZSHRC="$ZSHRC" \ + FM_TEST_LAUNCHER="$launcher" \ + FM_TEST_SPY_LOG="$TMP/spy.log" \ + OPENCODE2_BIN="$TMP/bin/opencode2-spy" \ + OPENCODE_CONFIG="$TMP/opencode.json" \ + PATH="$TMP/bin:$PATH" \ + timeout 60 zsh -f -i -c ' + source "$FM_TEST_ZSHRC" || exit 4 + if ! alias "$FM_TEST_LAUNCHER" >/dev/null 2>&1; then + echo "fm-launcher: no $FM_TEST_LAUNCHER alias in the sourced zshrc" >&2 + exit 3 + fi + eval "$FM_TEST_LAUNCHER" + ' >/dev/null 2>"$TMP/stderr" + LAUNCH_STATUS=$? + set -e +} -launched='' -[ -s "$TMP/spy.log" ] && launched=$(head -n 1 "$TMP/spy.log") +for pair in $LAUNCHERS; do + launcher=${pair%%:*} + expected=${pair##*:} -if [ "$status" -eq 3 ]; then - echo "FAIL: $LABEL does not define an fm alias" - exit 1 -fi -if [ "$status" -ne 0 ]; then - echo "FAIL: fm launch from $LABEL exited $status" - sed 's/^/ /' "$TMP/stderr" - exit 1 -fi -if [ -z "$launched" ]; then - echo "FAIL: fm from $LABEL launched nothing the spies could see" - sed 's/^/ /' "$TMP/stderr" - exit 1 -fi -if [ "${launched%%|*}" != oc2 ]; then - echo "FAIL: fm from $LABEL launched ${launched%%|*} instead of OpenCode 2 (oc2)" - echo " recorded launch: $launched" - exit 1 -fi -if grep -q '^pi' "$TMP/spy.log"; then - echo "FAIL: fm from $LABEL also launched Pi" - sed 's/^/ /' "$TMP/spy.log" + launch "$launcher" + status=$LAUNCH_STATUS + + if [ "$status" -eq 3 ]; then + echo "FAIL: $LABEL does not define a $launcher alias" + exit 1 + fi + if [ "$status" -ne 0 ]; then + echo "FAIL: $launcher from $LABEL exited $status" + sed 's/^/ /' "$TMP/stderr" + exit 1 + fi + if [ ! -s "$TMP/spy.log" ]; then + echo "FAIL: $launcher from $LABEL launched nothing the spies could see" + sed 's/^/ /' "$TMP/stderr" + exit 1 + fi + + record=$(head -n 1 "$TMP/spy.log") + tool=${record%%|*} + dir=$(printf '%s' "${record#*|}" | cut -d'|' -f1) + + if [ "$tool" != "$expected" ]; then + echo "FAIL: $launcher from $LABEL launched $tool instead of $expected" + echo " recorded launch: $record" + exit 1 + fi + if [ "$dir" != "$FM_HOME" ]; then + echo "FAIL: $launcher from $LABEL ran in $dir instead of the firstmate home $FM_HOME" + echo " recorded launch: $record" + exit 1 + fi + if [ "$expected" = oc2 ] && grep -q '^pi' "$TMP/spy.log"; then + echo "FAIL: $launcher from $LABEL also launched Pi" + sed 's/^/ /' "$TMP/spy.log" + exit 1 + fi + + case "$launcher" in + fm) fm_record=$record ;; + fm-oc2) fm_oc2_record=$record ;; + esac + + echo "PASS: $launcher from $LABEL launched $expected in $dir ($record)" +done + +if [ "$fm_record" != "$fm_oc2_record" ]; then + echo "FAIL: fm and fm-oc2 are not identical launchers" + echo " fm: $fm_record" + echo " fm-oc2: $fm_oc2_record" exit 1 fi -echo "PASS: fm from $LABEL launched OpenCode 2 via oc2 ($launched)" +echo "PASS: fm and fm-oc2 are identical launchers" -- 2.54.0 From 2e2578ead833846d1a0ea8c3be3b0bd9bb1f940f Mon Sep 17 00:00:00 2001 From: Lap Tran Date: Mon, 16 Nov 2026 09:28:25 -0500 Subject: [PATCH 2/2] no-mistakes(document): Note fm-oc2 alias in AGENTS.md and test header --- AGENTS.md | 2 +- tests/run.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index fd5c8d0..155cc2a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,7 +10,7 @@ Deliberate decisions in this repo - do NOT silently revert them: - 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` + the `oc2` wrapper, so the primary runs OpenCode 2 on the OpenCode Go subscription and loads firstmate's `.opencode/plugins` by working directory), while crews run on the opencode harness unless a dispatch rule selects another harness. `oc2` remains the isolated-config OpenCode launcher, and `fm-pi` stays only as the explicit Pi fallback now that the OpenCode 2 launcher is the confirmed default. Self-update via `/updatefirstmate`, not rebuild. - OpenCode is one install: the stable Homebrew `opencode` formula, linked so `/opt/homebrew/bin/opencode` is that build. It is both the firstmate crew harness and the `oc2` binary. `oc2` only isolates the config: `OPENCODE_CONFIG` stays at `home/.config/opencode2/opencode.json` and cannot rewrite `~/.config/opencode`, and `OPENCODE2_BIN` overrides the binary. 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 OpenCode 2), `fm-pi` (firstmate via Pi fallback), `oc2` (OpenCode with isolated config). They are intentional high-agency shortcuts. +- Shell aliases: `cc` (Claude skip-permissions), `co` (Codex full-auto), `gb` (Grok --yolo), `fm` / `fm-oc2` (firstmate via OpenCode 2), `fm-pi` (firstmate via Pi fallback), `oc2` (OpenCode with isolated config). 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. ## Maintaining this file diff --git a/tests/run.sh b/tests/run.sh index 367015f..93cce49 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -2,8 +2,9 @@ # Run the dotfiles configuration checks that need the live machine. # # The launcher check builds the zshrc from the home-manager configuration and -# runs `fm` with spies. The dispatch check reads the crew dispatch config through -# firstmate's bootstrap validator. Neither starts a real agent session. +# runs `fm`, `fm-oc2`, and `fm-pi` with spies. The dispatch check reads the crew +# dispatch config through firstmate's bootstrap validator. Neither starts a real +# agent session. set -euo pipefail ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P) -- 2.54.0