Repository navigation
feat: support Cursor Agent CLI as a primary harness - #2305
Merged
Merged
Conversation
kunchenguid
force-pushed
the
fm/fm-cursor-primary-build-r1
branch
from
August 13, 2026 17:37
c0a206a to
ecbdaef
Compare
…nd session start Register a tracked project-scope .cursor/hooks.json for Cursor's stop, sessionStart, preCompact, and preToolUse steps. bin/fm-turnend-guard-cursor.sh owns Cursor's turn boundary as a park: it foregrounds the watcher arm, holds the boundary open until an actionable close, and returns that wake as one follow-up. Exit 2 is a silent no-op on Cursor's stop step, so the adapter never uses it. The follow-up loop is bounded twice, by Cursor's own loop_limit and by the payload's loop_count. bin/fm-sessionstart-cursor.sh delivers the digest as additional_context at sessionStart, and stages it for the next turn boundary at preCompact, which cannot inject context. Cursor also loads the tracked Claude settings, so bin/fm-hook-host-lib.sh lets each tracked Claude-shaped entrypoint stand down on a Cursor-delivered payload rather than running every covered event twice. bin/fm-tmux-lib.sh reclassifies a Cursor pane's composer cursorlessly, because Cursor parks its terminal cursor outside the composer, which restores a genuine composer-empty proof and unblocks away-mode escalation delivery.
Resolve Cursor in the session-lock ancestry through bin/fm-cursor-lib.sh, which a Cursor primary needs before it can hold its own home lock, and classify its stop-hook park under the autoarm supervision model so the mid-turn pull guard stops reporting a healthy between-turns watcher as down. Read a Cursor pane's composer cursorlessly on tmux, gated on Cursor's own structural process identity, which restores a genuine composer-empty proof and lets away-mode escalations reach a Cursor primary with no daemon change. Lift the secondmate refusals in bin/fm-spawn.sh and bin/fm-control-lib.sh now that the supervision protocol exists and is recorded. Cover the whole surface with a portable regression over real processes, an opt-in live guard against the installed cursor-agent, and dated per-harness evidence.
…urfaces Update the turn-end guard, session-start, arm-seatbelt, cd-guard, watcher continuity, architecture, configuration, README, and harness-adapters owners, and add dated live evidence to the supervision and runtime-backend verification records. Correct the recorded Cursor tmux composer verdict: the cursor-anchored read is still blind, but the composite reader is no longer unknown. Lift the remaining remote-secondmate refusal missed in the previous commit, and add the new libs to the existing fixtures that copy a fixed dependency list.
…auses Also record that Cursor's preCompact firing itself is not yet live-verified, while the static evidence that it cannot inject context, and the staging path that follows from it, both are.
The cd-guard fixture copies a fixed dependency list and now needs the shared hook-host predicate. Both pretool suites also asserted cleanliness with a bare shellcheck call, a second and weaker copy of the lint definition that bin/fm-lint.sh owns: it omits --external-sources, so it failed the moment these checkers sourced a shared library. They now delegate to that owner.
…fusal A cursor secondmate now launches, so the suite asserts what its park actually needs: --trust so the home's project hooks load at all, its own home pinned as the workspace, and the autoarm supervision model inherited across the launch.
Carrying a compaction digest across two concurrently running stop hooks kept producing races that could deliver it twice or strand it indefinitely, and closing them kept enlarging a critical section inside a hook Cursor awaits at the turn boundary. Native preCompact firing was never observed either, so the surface has no empirical basis yet. Remove the adapter, its registration, its staged path in the park, and its tests, and record the surface as deferred and uncovered alongside the Codex interactive TUI. A regression now asserts preCompact stays unregistered so it cannot return without its own design and evidence. This change ships the proven core only: the turn-end follow-up park, the run-tier session start, and away-mode delivery.
kunchenguid
force-pushed
the
fm/fm-cursor-primary-build-r1
branch
from
August 13, 2026 17:39
ecbdaef to
937c228
Compare
tiago-peixoto
added a commit
to tiago-peixoto/firstmate
that referenced
this pull request
Aug 14, 2026
Intent
Make Cursor Agent CLI usable as a firstmate PRIMARY harness, not just a crewmate/scout adapter. This is firstmate SHARED, TRACKED material touching the core supervision surface: the turn-end guard, the watcher/supervision protocol, session start, and the away-mode daemon.
The authoritative spec was a completed feasibility scout report (data/fm-cursor-primary-feasibility-s1/report.md) that had already located every primitive with file:line references, live evidence, exact bundle offsets, the config schema, and a gap list G1-G9. The instruction was to IMPLEMENT that report rather than re-investigate or redesign it, and to escalate rather than silently diverge if the report turned out to be wrong about a concrete fact.
Captain-ordered sequence, done in this order:
Also add cursor to the primary-tier tables and adapter facts so the always-loaded contract records that cursor now HAS a hooks system and can be a primary; the report explicitly framed this as an ADDITION rather than a correction, since no existing line was factually wrong (they were all scoped to "has been verified").
Binding constraints accepted for this work: firstmate's coding guidelines apply (one-owner rule for contracts, one sentence per line in tracked Markdown, plain dash never an em dash, shellcheck-clean bin scripts via bin/fm-lint.sh, no agent co-author on commits). Tests must exercise behavior through an executable interface and must never assert implementation source bytes. The cursor stop and sessionStart hooks are HARNESS-DEPENDENT checks, so they required BOTH a portable tests/ regression using real processes with no harness installed AND a live-harness-optin guard in the bin/fm-test-run.sh family that is env-gated, self-skipping, and fails naming the harness and version - proven against the REAL cursor-agent, never a stub - plus dated per-harness evidence in docs/verification/supervision.md and docs/verification/runtime-backends.md. All live validation had to run in an isolated throwaway firstmate home on a separate tmux server, never against the live home or the fleet's default tmux/herdr session, and hooks were never to be installed at user or global scope because a global hook fires inside every live cursor crew agent in the fleet.
SUPERSEDED SCOPE - READ THIS BEFORE FLAGGING ANYTHING AS MISSING. The preCompact staged-digest feature has been REMOVED from this change by an explicit, current decision of the repository owner, and deferred to a clean follow-up. This is an accepted exclusion, not an omission, not an oversight, and not a regression. Do NOT re-implement it, do NOT restore bin/fm-precompact-cursor.sh or any equivalent adapter, do NOT re-register preCompact in .cursor/hooks.json, and do NOT reintroduce any staged-context path in bin/fm-turnend-guard-cursor.sh. A regression in tests/fm-cursor-primary.test.sh deliberately asserts that preCompact stays UNREGISTERED; that assertion encodes the intended contract and must not be weakened or deleted.
Why it was cut: an earlier review of this same branch surfaced two ask-user concurrency findings in that path - a superseded park could still deliver a duplicate follow-up, and an in-flight staged claim could strand the required post-compaction digest indefinitely. Each attempt to close them enlarged a critical section inside a hook that Cursor AWAITS at the turn boundary, where blocking is the most dangerous failure available. Native preCompact firing was also never observed, because a real compaction could not be forced in the isolated session, so the surface had no empirical basis to justify that risk. The owner therefore directed shipping the proven core only.
The shipping scope of this change is exactly three things, all live-verified against the real cursor-agent: the turn-end follow-up park, the run-tier session start, and away-mode escalation delivery. Cursor's compaction surface is recorded as DEFERRED and uncovered, in the same sense as the Codex interactive TUI, with the static reason stated: preCompact can return only user_message and is absent from Cursor's additional_context step set, so it cannot inject a digest and needs its own design. A cursor primary therefore does not re-emit its digest after a compaction, and that is the intended, documented behavior of this change.
Decisions and findings made while doing the work that a reviewer reading only the diff would not know:
Delivery: mode=no-mistakes with yolo OFF, so the captain merges. Any ask-user finding must be escalated rather than answered here. The PR must state that homes need a self-update after merge because this changes the running primary supervision surface, and must state explicitly that cursor primary away-mode support is COMPLETE rather than partial.
What Changed
Risk Assessment
Testing
The focused process-level regressions and manual protocol probe validated Cursor turn-end parking, loop bounds and supersession, session-start context, composer/away-mode classification, session locking, and secondmate launch behavior. The credentialed real-Cursor guard self-skipped as designed; it was not opted in because it documents Cursor user-data writes outside the permitted worktree boundary. No baseline test commands were supplied, and the worktree remained clean.
Evidence: Cursor primary executable protocol transcript
Evidence: Targeted Cursor primary regression transcript
Evidence: Environment-gated live Cursor guard self-skip
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-turnend-guard-cursor.sh:304- The required claim that a captain-interrupted park “stands down without emitting” remains false until the captain's new turn ends. The old park checks only whether a newer stop has claimed PARK_SEQ, but the new stop is created after the captain turn finishes. If the watcher closes actionably during that turn, the old park remains owner and emits its stale follow-up at lines 345-350. Invalidate the park at the earliest supported Cursor state transition that observes the captain's new turn, before committing any follow-up; if no such primitive exists, escalate that concrete limitation rather than claiming complete supersession.🔧 Fix: Correct Cursor park supersession documentation
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-cursor-primary.test.sh tests/fm-tmux-agent-liveness.test.sh tests/fm-session-lock-ancestry.test.sh tests/fm-secondmate-harness.test.sh tests/fm-turnend-guard.test.shManual executable protocol probe using real hook processes and fake Cursor ancestry: verified stop exits 0 with a watcherfollowup_message, sessionStart emitsadditional_context, and preCompact remains unregistered.tests/fm-cursor-primary-live-e2e.test.shwithout opt-in: verified the live guard self-skips with the required environment-gated instruction.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.