Skip to content

feat(pi): simplify primary session launch - #386

Merged
kunchenguid merged 6 commits into
mainfrom
fm/fm-readme-grok-qs-r1
Jul 9, 2026
Merged

kunchenguid merged 6 commits into
mainfrom
fm/fm-readme-grok-qs-r1

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Jul 9, 2026 •

Copy link
Copy Markdown
Owner

Intent

Update README.md Quick Start so Claude Code, Grok, and Pi are three equal co-primary recommendations for running the primary firstmate session, and make Pi's launch genuinely as simple as the other two. Previously Pi's primary watcher extension was generated at session start into a gitignored state/fm-primary-pi-watch.ts file, requiring a dual -e launch flag (pi -e .pi/extensions/fm-primary-turnend-guard.ts -e state/fm-primary-pi-watch.ts) that is harder to use than Claude Code's plain 'claude' or Grok's 'grok --trust'. This commit tracks the watcher extension as .pi/extensions/fm-primary-pi-watch.ts (committed, self-hashing its own version via createHash/readFileSync exactly like the existing turn-end guard extension), removes bin/fm-pi-watch-extension.sh entirely since nothing needs to generate it anymore, updates fm-session-start.sh and fm-supervision-instructions.sh to resolve the extension from FM_ROOT instead of state/, updates fm-spawn.sh's Pi secondmate launch to point at the tracked extension in the secondmate home's own worktree instead of generating a state/ copy, and updates the session-start diagnostic to tell the user to restart plain 'pi' after approving Pi's one-time project trust (with -e as a documented fallback for untrusted folders). README Quick Start's Pi launch block is now just 'pi' plus a one-line trust note, matching Grok's 'grok --trust' note. Tests (fm-pi-watch-extension.test.sh, fm-session-start.test.sh, fm-supervision-instructions.test.sh) and docs (docs/scripts.md, docs/configuration.md, docs/supervision-protocols/pi.md, harness-adapters skill) were updated to match; unrelated OpenCode tests colocated in fm-pi-watch-extension.test.sh were left untouched. Scope stays within README.md and the Pi watcher-extension plumbing; no other harness behavior changed.

What Changed

  • Track Pi’s primary watcher extension in .pi/extensions and remove the generated state-file helper so trusted projects can launch with plain pi.
  • Update session startup, supervision guidance, and Pi secondmate launch paths to use the tracked extension, while retaining an extension-flag fallback for untrusted folders.
  • Rework Quick Start to present Claude Code, Grok, and Pi as equal primary-session options, with matching Pi documentation and tests.

Risk Assessment

🚨 High: The change range was not accessible for inspection in this environment, so no evidence-based merge assessment is possible.

Testing

The provided baseline command had already succeeded, but this validation run could not execute any automated or end-to-end evidence-producing check because the local command host is missing; no reviewer-visible artifact could be gathered.

  • Outcome: ⚠️ 1 error across 1 run (10m15s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⏭️ **Review** - skipped
  • 🚨 Review could not be performed: the local command runner failed before executing any command because /opt/homebrew/bin/codex-code-mode-host is missing. I could not inspect the specified history or diff.
⚠️ **Test** - 1 error
  • 🚨 Testing could not start: the execution host failed before any repository command ran because /opt/homebrew/bin/codex-code-mode-host is missing. This environment issue is outside the allowed worktree boundary, so I could not independently exercise the Pi launch flow or produce evidence.
  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • Baseline suite was reported as already successful by the task context; no additional command could be executed because the command host failed to spawn.
⏭️ **Document** - skipped
  • 🚨 Captain, the required documentation audit could not run because command execution fails before launch: the code-mode host binary is missing. No files were read or edited.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid kunchenguid changed the title docs: recommend Grok alongside Claude Code in Quick Start docs: make Claude Code, Grok, and Pi equal co-primaries in Quick Start Jul 9, 2026
Move Pi's primary watcher bridge from a generated state/ file to a
tracked .pi/extensions/fm-primary-pi-watch.ts, matching how the turn-end
guard extension already works: self-hashing version, project-local
auto-discovery after one-time Pi trust. This drops the state/-generation
step and dual -e requirement from the happy path, so Pi's Quick Start
launch becomes plain 'pi', the same friction class as 'claude' and
'grok --trust'.

- bin/fm-pi-watch-extension.sh is removed; nothing generates the
  extension anymore since it is committed.
- fm-session-start.sh and fm-supervision-instructions.sh resolve the
  watcher extension path from FM_ROOT instead of state/, and the
  session-start diagnostic now points at restarting plain pi after
  trust, with -e as a documented fallback.
- fm-spawn.sh points Pi secondmate launches at the tracked extension
  path in the secondmate home instead of generating a state/ copy.
- README Quick Start Pi block is now just 'pi' plus a trust note.
- Tests, docs, and the harness-adapters skill updated to match.
@kunchenguid kunchenguid changed the title docs: make Claude Code, Grok, and Pi equal co-primaries in Quick Start feat(pi): simplify primary session launch Jul 9, 2026
@kunchenguid
kunchenguid merged commit 1b5a9f5 into main Jul 9, 2026
4 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-readme-grok-qs-r1 branch July 9, 2026 21:13
vitalNohj added a commit to vitalNohj/firstmate that referenced this pull request Jul 10, 2026
* feat(pi): simplify primary session launch (kunchenguid#386)

* docs(readme): reformat Quick Start and recommend Grok equally with Claude Code

* no-mistakes(review): Captain: align harness launch guidance

* no-mistakes(review): Captain, clarify Pi supervised launch

* no-mistakes(review): Captain, document Pi first-launch bridge

* feat(pi): track primary watcher extension for plain-pi launch

Move Pi's primary watcher bridge from a generated state/ file to a
tracked .pi/extensions/fm-primary-pi-watch.ts, matching how the turn-end
guard extension already works: self-hashing version, project-local
auto-discovery after one-time Pi trust. This drops the state/-generation
step and dual -e requirement from the happy path, so Pi's Quick Start
launch becomes plain 'pi', the same friction class as 'claude' and
'grok --trust'.

- bin/fm-pi-watch-extension.sh is removed; nothing generates the
  extension anymore since it is committed.
- fm-session-start.sh and fm-supervision-instructions.sh resolve the
  watcher extension path from FM_ROOT instead of state/, and the
  session-start diagnostic now points at restarting plain pi after
  trust, with -e as a documented fallback.
- fm-spawn.sh points Pi secondmate launches at the tracked extension
  path in the secondmate home instead of generating a state/ copy.
- README Quick Start Pi block is now just 'pi' plus a trust note.
- Tests, docs, and the harness-adapters skill updated to match.

* fix(pi): drop backticks from session-start diagnostic to satisfy shellcheck SC2016

* feat(supervision): prevent unsafe watcher-arm commands (kunchenguid#387)

* feat(supervision): add PreToolUse seatbelt against watcher-arm anti-patterns

Adds bin/fm-arm-pretool-check.sh, a shared PreToolUse-style checker that
denies a primary shell command backgrounding, piping, or bundling the
watcher arm/checkpoint, or force-killing the watcher process broadly -
the exact shapes that silently took Grok's supervision down. Wires it
into all five verified harnesses (grok, claude, codex, opencode, pi),
each validated empirically against the real harness.

Also fixes a grok 0.2.93 regression discovered during that validation: the
existing turnend-guard Stop hook's bare root variable broke grok's own
variable pre-substitution and silently no-op'd the hook.

* no-mistakes(review): Harden watcher arm validation

* no-mistakes(review): Harden arm guard metacharacter checks

* no-mistakes(review): Harden nested shell arm guard

* fix(lint): rewrite SC2015 guards in fm-arm-pretool-check.sh as if/then

A && B || C is not if-then-else; C can run when A is true. Replace both
occurrences of the quote-state early-continue with an explicit if/then.

* fix(pi): restore primary watcher supervision lifecycle (kunchenguid#397)

* fix Pi primary supervision lifecycle

* no-mistakes(document): Synchronize Pi primary extension documentation

* Recognize Cursor Agent as a primary session harness.

Detect CURSOR_AGENT=1 and cursor-agent process args so Cursor can hold the
fleet lock and get a Codex-shaped supervision protocol. Cursor is not yet a
verified crewmate launch adapter; set config/crew-harness for crew spawns.
Also stop calling basename(1) on ps comm names so macOS -zsh ancestry no
longer breaks harness detection.

Co-authored-by: Cursor <[email protected]>

* Add Cursor Agent as a verified crewmate harness.

Empirically verified against cursor-agent 2026.07.08: launch with
agent --force, project stop hook for turn-end, busy footer ctrl+c to stop,
Ctrl+C interrupt, /exit, and one-time workspace trust. Wire spawn, teardown,
busy detection, bootstrap verified list, and harness-adapters facts.

Co-authored-by: Cursor <[email protected]>

* Ignore local Serena project config.

Co-authored-by: Cursor <[email protected]>

* no-mistakes(review): scope Cursor hook install/teardown to firstmate-owned files

* no-mistakes(test): test(fixtures): wire new cursor-hook sibling and hermetic harness detect

* no-mistakes(document): sync docs for cursor harness verification

* no-mistakes(lint): fix shellcheck SC1007 empty env assignments in cursor test

* no-mistakes(review): gate fm-lock argv harness match to interpreters and cursor-agent

* no-mistakes(document): sync remaining docs for cursor harness support

* fix(cursor): launch crewmates via cursor-agent, not ambiguous bare agent

Cursor installs both agent and cursor-agent, and Grok (or anything else)
can claim the bare agent name on PATH, so bare 'agent --force' could
silently launch the wrong CLI. Resolve the launch binary through
fm_cursor_launch_bin: always prefer cursor-agent, fall back to bare
agent only when cursor-agent is absent and agent is verified Cursor
(CURSOR_INVOKED_AS, resolved cursor-agent path, or --version
fingerprint), and abort the spawn if neither resolves. Mirrors the
cursor-agent robustness of primary detection.

* no-mistakes(review): drop ambient CURSOR_INVOKED_AS trust from cursor launch resolver

* no-mistakes(review): add cursor to secondmate positional harness allow-list

* no-mistakes(review): restore nodejs interpreter match in fm-lock harness detection

* no-mistakes(document): sync harness docs for cursor turn-end/pretool/launch gaps

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Cursor <[email protected]>
Keigyoku pushed a commit to Keigyoku/firstmate that referenced this pull request Jul 11, 2026
* docs(readme): reformat Quick Start and recommend Grok equally with Claude Code

* no-mistakes(review): Captain: align harness launch guidance

* no-mistakes(review): Captain, clarify Pi supervised launch

* no-mistakes(review): Captain, document Pi first-launch bridge

* feat(pi): track primary watcher extension for plain-pi launch

Move Pi's primary watcher bridge from a generated state/ file to a
tracked .pi/extensions/fm-primary-pi-watch.ts, matching how the turn-end
guard extension already works: self-hashing version, project-local
auto-discovery after one-time Pi trust. This drops the state/-generation
step and dual -e requirement from the happy path, so Pi's Quick Start
launch becomes plain 'pi', the same friction class as 'claude' and
'grok --trust'.

- bin/fm-pi-watch-extension.sh is removed; nothing generates the
  extension anymore since it is committed.
- fm-session-start.sh and fm-supervision-instructions.sh resolve the
  watcher extension path from FM_ROOT instead of state/, and the
  session-start diagnostic now points at restarting plain pi after
  trust, with -e as a documented fallback.
- fm-spawn.sh points Pi secondmate launches at the tracked extension
  path in the secondmate home instead of generating a state/ copy.
- README Quick Start Pi block is now just 'pi' plus a trust note.
- Tests, docs, and the harness-adapters skill updated to match.

* fix(pi): drop backticks from session-start diagnostic to satisfy shellcheck SC2016

(cherry picked from commit 1b5a9f5)
Keigyoku added a commit to Keigyoku/firstmate that referenced this pull request Jul 11, 2026
…, kunchenguid#435 deferred) (#8)

* feat: add harness-aware supervision (kunchenguid#367)

* Add harness-aware supervision

* no-mistakes(review): Captain, harden watcher supervision regressions

* no-mistakes(review): Captain, harden watcher supervision cadence

* no-mistakes(review): Harden watcher supervision ownership

* no-mistakes(review): Captain, harden Pi extension marker

* no-mistakes(review): Captain, harden Pi supervision restart checks

* no-mistakes(review): Harden watcher ownership checks

* no-mistakes(review): Captain, harden Pi supervision loading

* no-mistakes(review): Captain, require Pi guard extension loading

* no-mistakes(review): Captain, harden watcher supervision recovery

* no-mistakes(test): Fix fm-send baseline log filtering

* no-mistakes(document): Sync harness supervision docs

* no-mistakes: apply CI fixes

(cherry picked from commit 090483e)

* fix: split X-mode replies by platform (kunchenguid#369)

* fix: make x replies split by platform

* no-mistakes(review): Captain: preserve Discord recovery relink context

* no-mistakes(test): Captain: keep split markers outside fences

* no-mistakes(document): Sync X-mode reply docs

(cherry picked from commit 4790bc5)

* fix: make stow memory writes inspect before update (kunchenguid#372)

* docs: make stow inspect-then-update

* no-mistakes(review): Remove unsupported archive-body guidance

* no-mistakes(review): Clarify stow read-before-write exception

* no-mistakes(test): Require archive-body for stow task notes

* no-mistakes(document): Sync stow memory docs

* no-mistakes(lint): Silence ShellCheck source warning

(cherry picked from commit af5361e)

* fix(watcher): wait when arm attaches to a healthy watcher (kunchenguid#375)

* fix: attach-and-wait when arm finds a healthy watcher

Grok and Claude re-arm after every turn with work in flight. When a
watcher was already healthy, fm-watch-arm exited immediately with
watcher: healthy, which completed the harness background task and
injected an empty false wake.

Attach to the live identity-matched holder instead, stay until that
cycle ends, then exit 0 so notify fires for a real end-of-cycle. The
peer-startup-race path uses the same contract. --restart and the
started path are unchanged.

* no-mistakes(review): Gate restart watcher peer attach

* no-mistakes(document): Sync watcher arm docs

(cherry picked from commit 7302a95)

* feat(pi): simplify primary session launch (kunchenguid#386)

* docs(readme): reformat Quick Start and recommend Grok equally with Claude Code

* no-mistakes(review): Captain: align harness launch guidance

* no-mistakes(review): Captain, clarify Pi supervised launch

* no-mistakes(review): Captain, document Pi first-launch bridge

* feat(pi): track primary watcher extension for plain-pi launch

Move Pi's primary watcher bridge from a generated state/ file to a
tracked .pi/extensions/fm-primary-pi-watch.ts, matching how the turn-end
guard extension already works: self-hashing version, project-local
auto-discovery after one-time Pi trust. This drops the state/-generation
step and dual -e requirement from the happy path, so Pi's Quick Start
launch becomes plain 'pi', the same friction class as 'claude' and
'grok --trust'.

- bin/fm-pi-watch-extension.sh is removed; nothing generates the
  extension anymore since it is committed.
- fm-session-start.sh and fm-supervision-instructions.sh resolve the
  watcher extension path from FM_ROOT instead of state/, and the
  session-start diagnostic now points at restarting plain pi after
  trust, with -e as a documented fallback.
- fm-spawn.sh points Pi secondmate launches at the tracked extension
  path in the secondmate home instead of generating a state/ copy.
- README Quick Start Pi block is now just 'pi' plus a trust note.
- Tests, docs, and the harness-adapters skill updated to match.

* fix(pi): drop backticks from session-start diagnostic to satisfy shellcheck SC2016

(cherry picked from commit 1b5a9f5)

* feat(supervision): prevent unsafe watcher-arm commands (kunchenguid#387)

* feat(supervision): add PreToolUse seatbelt against watcher-arm anti-patterns

Adds bin/fm-arm-pretool-check.sh, a shared PreToolUse-style checker that
denies a primary shell command backgrounding, piping, or bundling the
watcher arm/checkpoint, or force-killing the watcher process broadly -
the exact shapes that silently took Grok's supervision down. Wires it
into all five verified harnesses (grok, claude, codex, opencode, pi),
each validated empirically against the real harness.

Also fixes a grok 0.2.93 regression discovered during that validation: the
existing turnend-guard Stop hook's bare root variable broke grok's own
variable pre-substitution and silently no-op'd the hook.

* no-mistakes(review): Harden watcher arm validation

* no-mistakes(review): Harden arm guard metacharacter checks

* no-mistakes(review): Harden nested shell arm guard

* fix(lint): rewrite SC2015 guards in fm-arm-pretool-check.sh as if/then

A && B || C is not if-then-else; C can run when A is true. Replace both
occurrences of the quote-state early-continue with an explicit if/then.

(cherry picked from commit 766f772)

* fix(pi): restore primary watcher supervision lifecycle (kunchenguid#397)

* fix Pi primary supervision lifecycle

* no-mistakes(document): Synchronize Pi primary extension documentation

(cherry picked from commit 80ecc8d)

* fix: keep persistent secondmates out of the main backlog (kunchenguid#398)

* fix secondmate backlog guidance

* no-mistakes(review): Require reasons for captain backlog holds

* no-mistakes(test): Document secondmate handoff skill requirement

* fix secondmate teardown reminder

* no-mistakes(document): sync teardown reminder docs to work-items-only backlog contract

(cherry picked from commit 7525a37)

* fix(backlog-handoff): move full item blocks including indented bodies (kunchenguid#401)

* fix(backlog-handoff): move full item blocks including indented bodies

fm-backlog-handoff only moved the checklist header line, so multi-line
item bodies were left orphaned in the source backlog and never reached
the secondmate. Move the full block (header plus indented body lines)
atomically, treating body membership by indentation so lines like
## Intent stay with the item, and add regression coverage.

* no-mistakes(review): Captain: preserve EOF handoff terminators

* no-mistakes(review): treat blank lines inside item bodies as movable body

* no-mistakes(document): sync backlog-handoff docs with full-block move behavior

(cherry picked from commit 600075e)

* feat(herdr): make Herdr lab lifecycle safety deterministic for briefs (kunchenguid#402)

* guard Herdr lab lifecycle in briefs

* no-mistakes(review): Fix Herdr lab helper and provisioning safety

* no-mistakes(review): Captain, harden Herdr lab lifecycle safety

* no-mistakes(review): fix Herdr lab test cleanup ordering and brief help range

* no-mistakes(review): reject leading options in Herdr lab run guard

* no-mistakes(review): strip leading non-alnum in Herdr lab name generator

* no-mistakes(document): document Herdr lab helper and --herdr-lab brief flag

* no-mistakes(lint): add shellcheck disable for deliberate SC2016 literals in fm-brief herdr-lab

* no-mistakes: apply CI fixes

(cherry picked from commit 4bc0824)

* fix(watcher): classify arm-command seatbelt by execution position (kunchenguid#403)

* fix watcher arm command policy

* no-mistakes(review): Harden watcher command policy parsing

* no-mistakes(review): Captain: harden watcher policy parsing

* no-mistakes(review): harden watcher policy for expanded paths, direct-watch, and sound prefilter

* no-mistakes(review): close prefilter and classifier locale/ANSI-C watcher-path decode gaps

* no-mistakes(review): fail closed on loop-wrapped broad watcher kills

* no-mistakes(document): sync docs for watcher-arm command-position policy

(cherry picked from commit 22b1d71)

* fix: reconcile existing AGENTS.md safely (kunchenguid#405)

* fix(agents-md): inject self-governance section into existing AGENTS.md

fm-ensure-agents-md.sh only appended the canonical "## Maintaining this
file" section on skeleton create or CLAUDE.md promotion, so an existing
AGENTS.md that lacked it exited unchanged and forced hand-copying the
wording during a rollout across existing projects. Call the already-
idempotent ensure_maintenance_section on the existing-AGENTS.md paths and
report whether the file changed; a re-run and an already-complete file stay
byte-identical.

Also fixes kunchenguid#389: refuse a case-variant real memory file (e.g. a lowercase
agents.md) instead of silently emitting a CLAUDE.md symlink whose uppercase
literal target dangles once the tree lands on a case-sensitive filesystem.

Tests extend tests/fm-ensure-agents-md.test.sh; skeleton-create and
CLAUDE.md-promotion regressions still pass. Docs updated to match.

* no-mistakes(review): Captain: preserve CRLF maintenance-section idempotency

* no-mistakes(review): Preserve CRLF during maintenance-section injection

* no-mistakes(review): Captain: harden dangling-symlink regression coverage

* no-mistakes(document): Document agent-memory injection outcomes

(cherry picked from commit 96244f4)

* feat: support project-less secondmate homes (kunchenguid#409)

* feat(secondmate): support project-less homes via --no-projects

fm-brief.sh --secondmate and fm-home-seed.sh now accept an explicit
--no-projects signal to scaffold, seed, and register a secondmate home
whose subject is the firstmate repo itself (no clones). The signal is
mutually exclusive with a project list; omitting both still fails loudly
so an accidental omission is never a silent project-less seed. The
registry line renders an empty projects: field, which spawn and the
snapshot already tolerate. Docs updated in the secondmate-provisioning
skill and both script headers.

* no-mistakes(review): Captain: document project-less secondmate flow

* no-mistakes(review): Captain: refuse project-less reseeding of populated homes

* fix(seed): fail closed on unreadable project data

* no-mistakes(review): Captain: reject stale projectful charters

* no-mistakes(review): Captain: fail closed on unsafe project paths

* no-mistakes(review): Captain: validate project-less charter clone sections

* no-mistakes(document): Document project-less secondmate seeding

(cherry picked from commit 08453f9)

* fix: delegate backlog handoffs to tasks-axi (kunchenguid#411)

* wip(handoff): record verified delegation design + tasks-axi mv blocker

No production code changed yet. tasks-axi mv (v0.2.1) cannot atomically
move a blocked-by-linked item set across backlogs (deadlocks both orders,
no batch/--force), which fm-secondmate-lifecycle-e2e requires. Parked
pending a tasks-axi connected-set mv enhancement; note captures the
verified design, semantics, test/CI/doc changes, and resume checklist.

* refactor(handoff): delegate the item move to tasks-axi mv

fm-backlog-handoff.sh's two-pass awk was a second parser of the backlog
format and the source of the PR kunchenguid#401 body-orphaning drift. Delete it and
delegate the move to `tasks-axi mv <id>... --to <dest>` (v0.2.2 atomic
multi-id), the single owner of the format: a connected set (blocker plus
dependents) moves together with blocked-by preserved, item blocks stay
byte-exact, and destination section placement holds. The helper keeps only
the fleet-level validation tasks-axi cannot know - secondmate-home
resolution, the seeded-home safety checks, the In-flight refusal, and
idempotent per-key reporting - and is atomic: on any move failure nothing
moves.

Tests: fm-backlog-handoff.test.sh keeps PR kunchenguid#401's regression matrix but now
exercises the delegated path and skips cleanly when tasks-axi is absent; the
two whole-file fixtures move to tasks-axi's canonical whitespace. The
lifecycle-e2e and safety move-cases gain the same skip guard. CI installs
tasks-axi so the delegated path is exercised. Docs state that
config/backlog-backend=manual governs firstmate's own hand-editing, not this
validated helper, which delegates fleet-wide because bootstrap requires
tasks-axi on PATH.

Remove the now-redundant WIP design note.

* no-mistakes(review): Captain: harden atomic backlog handoffs

* no-mistakes(review): Captain: enforce queued-only backlog handoffs

* no-mistakes(review): Captain: harden handoff section parsing

* no-mistakes(document): Document delegated backlog handoffs

* no-mistakes(lint): Silence ShellCheck source diagnostics

(cherry picked from commit 31afb8c)

* fix: ignore secondmate home marker during sync (kunchenguid#417)

* fix: gitignore the secondmate home marker

bin/fm-home-seed.sh writes an untracked .fm-secondmate-home marke