Repository navigation
feat: add Cursor CLI crew harness - #2238
Merged
Merged
Conversation
# Conflicts: # bin/fm-spawn.sh
cursor-agent renders its idle composer placeholder dim (SGR 2) but paints the cell under the terminal cursor in reverse video (SGR 0;7). Reverse video is neither dim nor a dark truecolor foreground, so the shared ghost stripper keeps that one character and an idle composer reduces to a lone `P`. Judged on its own, that remnant reads `pending` on a genuinely idle pane, which defers away-mode escalation indefinitely on the styled cursorless backends. Teach the ONE fleet-wide classifier the shape instead of adding an adapter-local copy: register `→` as an agent prompt glyph so the composer row is structurally findable at all (without it the bottom-most shape is a stale shell prompt echo in the scrollback), add both verified placeholders to the idle set, and consult the styling-independent plain row when the styled row is only a remnant. The plain-row branch demands the remnant be a proper, strictly shorter substring of a plain row matching a fully anchored placeholder. Real typed text is uniformly bright, so stripping leaves it equal to the plain row and it stays `pending` - verified live against a pane where the typed text was exactly the placeholder string. Verified live on cursor-agent 2026.08.11-e8db854; the regression pins the real captured bytes and asserts the remnant survives stripping, so the case cannot go vacuous if the stripper later learns SGR 7. Co-authored-by: Amplify Logic AI <[email protected]>
…DECODE Cursor ships two executable names - `cursor-agent` and the legacy alias `agent` - and runs as a bundled node script, so tmux reports the pane command as a bare `node`. Neither `agent` nor `node` can be trusted by name, so identity gets one owner in bin/fm-cursor-lib.sh that demands cursor's own name or install tree in the path or argv[0], from the structural signal only. Probing an arbitrary pid's executable during a liveness poll would execute a stranger's binary, which is the hazard that rule exists to close. Two consequences wired up: Detection. cursor-agent does NOT clear an inherited CLAUDECODE, so a cursor worker launched under a claude primary carries both markers and whichever is tested first wins. The cursor markers are ordered ahead of the CLAUDECODE check; fm-spawn additionally clears foreign markers at the launch boundary. Both are kept deliberately - launch sanitization only covers sessions fm-spawn started, while the ordering also covers a cursor session started by hand. Verified live that CURSOR_INVOKED_AS is set on the agent process and CURSOR_AGENT=1 on the child/tool processes fm-harness.sh actually runs as. Pane liveness. A cursor pane now classifies `agent`. An unrelated node or agent stays `other`, which the liveness callers already fold into `ambiguous` rather than `dead`, so a stranger's node pane is never reported agent-free. Resolution prints the STABLE launcher rather than the canonical target: identity is proven through canonicalization, but cursor's canonical path carries a version its own auto-update replaces, and pinning that would strand a task on a version that can vanish. The regression drives the two identity signals apart - a cursor-named executable outside any cursor tree, and a non-cursor-named alias inside one - and asserts each carries a verdict alone, so no single vendor string is load-bearing. Its negative controls are real spawned processes, not fixtures. Verified live on cursor-agent 2026.08.11-e8db854. Co-authored-by: Ville Penttinen <[email protected]>
Cursor shipped as "unknown cursor-unverified" on the premise that it exposes no semantic turn lifecycle, only a rendered "Working" footer. That premise is wrong: cursor-agent persists an append-only JSONL transcript per conversation and brackets every submitted turn with a role:user open and a typed turn_ended close. Verified live on 2026.08.11-e8db854, including the interrupt path, where Escape closes the turn with status "aborted" - so this source covers manual interruption, which Claude's Stop hook does not. That makes it a genuine pull source in the muse mould rather than the rendered text the redesign forbids: no writer, no arm, no gen, nothing seeded that could never be cleared. Cursor's `ctrl+c to stop` footer stays out of the verdict, and herdr's narrower native streaming state cannot stand in for it either. Binding deliberately does not reconstruct cursor's workspace-slug directory name. That slug collapses path separators, so rebuilding it would be a guess that could bind the wrong pane; cursor records the exact absolute workspace path in each project's .workspace-trusted, and the binding matches on that. A conversation recorded as prior at spawn is excluded, so a relaunch in a reused worktree folds its own turn rather than its predecessor's. Requiring a unique remaining conversation keeps zero and several both unknown, because neither proves anything about the current turn. The regression pins the fold with real transcript files and asserts the dangerous direction stays closed: an unresolvable binding, a record-free file, an unclaimed workspace, and a workspace-path PREFIX all read unknown, never idle. The prefix case uses an opaque fixture slug so a slug-rebuilding implementation cannot pass it. Co-authored-by: Ville Penttinen <[email protected]>
…ontrol Five gaps that together kept a cursor crewmate from being drivable end to end. Launch. The template invoked `cursor agent`, but `cursor` is not the CLI - the installed names are `cursor-agent` and the legacy alias `agent` - so the command could not run at all on a machine with a normal cursor install. It now resolves through the verified owner, which also refuses a spawn loudly instead of leaving a pane that dies with command-not-found and reads as a wedged worker. Session binding. fm-spawn writes state/<id>.cursor-session so the busy fold can find this pane's transcript, and teardown removes it. Lifecycle control. No cursor PR touched fm-control-lib.sh, so `fm-control <id> interrupt|exit|relaunch` could not drive a cursor worker at all. Verified live: interrupt is a single Escape, exit is /exit, and cursor does NOT repollute its composer with the cancelled prompt, so unlike muse it needs no clear key. Secondmate is refused, matching the spawn refusal. Submit acknowledgement. cursor parks its terminal cursor outside its composer, so the composer verdict on tmux is always `unknown` and a submit could never be acknowledged from the composer alone. The submit core's existing idle-to-busy transition covers that case, but only if the pane's busy footer is recognised, so cursor's `ctrl+c to stop` joins the harness-less default union the submit cores read. The TOKEN is matched rather than the spinner verb: the same version rendered both `Working` and `Running` in consecutive turns. Bootstrap. A configured cursor crew harness with no cursor executable is now a loud MISSING diagnostic rather than a first-spawn failure, and it accepts either installed name. Interrupt cancellation is deliberately left unconfirmed. The transcript does type an aborted close, but its post-interrupt write latency measured as variable - sometimes seconds, sometimes not within twenty - so a claim built on it would be unreliable. Normal turn completion is prompt, which is what the busy fold actually depends on. Two inherited tests are corrected rather than deleted: the busy test asserted cursor could have no semantic source, and the launch test pinned the literal `cursor agent` string. Both now pin the verified behaviour, including that the launch never allocates a second worktree. Co-authored-by: ABHISHAKE KUMAR BOJJA <[email protected]> Co-authored-by: Ville Penttinen <[email protected]>
… guard The inherited cursor entry was written against 2026.08.04-aaa8809 and several of its claims no longer hold: it named `cursor agent` as the binary (not the CLI name), listed six Grok model ids of which the live catalog now returns two, and recorded busy state, exit, interrupt, and skill invocation as unverified. Replaced with what was measured against 2026.08.11-e8db854, including the two facts most likely to be rediscovered painfully: cursor runs as a bundled node script so its pane title is a bare `node`, and it parks its terminal cursor outside its composer, which makes the tmux composer verdict permanently `unknown` by design rather than a defect to chase. Model ids now route to `--list-models` for the account instead of a fixed list, since that list is exactly what drifted. The live drift guard covers cursor, resolving it through the same verified owner fm-spawn uses and passing --trust so the probe cannot hang on the workspace prompt. Run against every installed harness: 8 checked, all alive, with cursor reporting title='node' foreground=[.../cursor-agent] - the drift shape this guard exists to catch. Co-authored-by: Ville Penttinen <[email protected]>
The state/ layout section is the inventory every session reads; a busy-source binding that fm-spawn writes and teardown removes belongs in it alongside muse's.
The per-harness rendered busy footers lived in bin/fm-tmux-lib.sh under FM_TMUX_* names, so cursor's `ctrl+c to stop` signature - and every other harness's - was reachable only from tmux. That placement was wrong on its own terms: herdr, zellij, cmux, and orca run the same harnesses and face the same question these footers answer, which is whether a submitted Enter actually landed. Nothing about the signature is tmux-specific. Moved verbatim into bin/fm-composer-lib.sh, the shared composer/delivery owner every backend already sources, and renamed to FM_DELIVERY_* so the names stop claiming a scope they never had. All five adapters now reach cursor's signature; verified per adapter rather than assumed. The boundary the move must not blur is stated where it now lives: this is a DELIVERY guard, never a worker-state source. Confirming a keystroke landed is a different question from asking what a worker is doing, and bin/fm-busy-lib.sh remains the semantic owner that forbids classifying a harness from rendered text. Cursor still classifies only from its transcript fold, which is already backend-agnostic because it folds a file rather than reading a pane - the same verdict on all six backends. The old FM_TMUX_* aliases are dropped rather than kept as dead shims: nothing outside the moved block referenced them except fm-busy-lib.sh's grok fallback, which now reads the new name. The documented operator override, FM_BUSY_REGEX, is untouched. Also removes a dead duplicate CURSOR_INVOKED_AS check in bin/fm-harness.sh, unreachable behind the marker check above it.
A live cursor crewmate on herdr classified its IDLE composer as `pending`, and fm-send consequently exited 1 with "delivery unconfirmed" on a message that had actually landed. The cause is not cursor-specific. Herdr draws a composer's top and bottom rules with the half-block glyphs U+2584 and U+2580 rather than the box-drawing family. fm_composer_row_has_edge knew only the box-drawing set, so no box was detected; the composer was found as a BARE row, and its wrap region - which extends while rows are non-blank and carry no structural edge - walked straight through the composer's own closing rule and swallowed the model and path footer below it. That footer is real text, so the region classified pending on a genuinely idle pane. Teaching the shared edge detector the half-block glyphs bounds the region at the closing rule. Measured on the captured bytes of a real herdr cursor pane: the same capture that read `pending` now reads `empty`. This is a shared shape-path change, so it is deliberately narrow - it adds glyphs to the edge vocabulary and changes no verdict logic - and the whole composer and backend suite is green, including the other harnesses' herdr fixtures. The regression pins the real captured shape and asserts the footer content is genuinely present, so the case cannot pass vacuously if the region were ever bounded for some unrelated reason.
Herdr's composer-shape fix made an idle cursor pane classify `empty`, but `fm-send` still exited 1 with "delivery unconfirmed" on messages that had actually landed. Live measurement found the second, independent cause. Herdr reports a cursor pane `agent_status=blocked` in EVERY state - idle, mid-turn, and after - so the submit path's idle-baseline native confirmation is structurally unreachable for cursor and every send falls into the composer branch. That branch reads cursor's mid-turn composer row, which renders its own `Add a follow-up` placeholder beside a right-aligned `ctrl+c to stop`. That token is composer content, so the verdict is `pending` on a composer holding no user text at all, and the Enter-retry budget then reports pending. The escape is the same semantic signal the native path uses, read from the pane's verified busy footer instead of native agent-state, and it is the rendered-footer twin of the tmux submit core's turn-started confirmation: an idle-to-busy transition ACROSS our Enter proves the harness accepted the submission. The baseline is taken before the first Enter and only when the native baseline was not legibly idle, so the idle-baseline path still never reads pane content and a pane already mid-turn before we typed keeps reporting `pending` rather than borrowing another turn as proof of this delivery. The composer verdict is deliberately NOT relaxed. A right-aligned status token on the composer row stays content for every other caller, including the away-mode pre-injection guard, and the shared cursorless submit core is left untouched so zellij, cmux, and Orca keep the behavior their own follow-up owns. Verified live on herdr 0.8.0 and cursor-agent 2026.08.11-e8db854 in an isolated lab session: `fm-send` now exits 0 and the steer executes, interrupt cancels a running turn, `/exit` stops the agent, and teardown clears the record. All seven panes of the running default session classify identically before and after the shape fix, so no other harness regressed.
kunchenguid
force-pushed
the
fm/fm-cursor-crew-harness-build-r1
branch
from
August 13, 2026 02:20
d7240fe to
f52dc1e
Compare
Intent
BUILD Cursor CLI (cursor-agent) as a firstmate CREW harness - crewmate/scout ONLY, never a primary harness. firstmate SHARED, TRACKED material. This is a CONTINUATION run on the same branch and PR (#2238). Two further captain-directed commits are folded into the same ship. Do NOT rebase, do NOT reset, do NOT rewrite existing commit history.
ORIGINAL SCOPE (validated in earlier runs, unchanged): consolidate a crew-scope cursor adapter from 15 open contributor PRs rather than merging any one whole, because none was complete for crew scope, several reached into primary-session territory the captain did not ask for, and CLI drift had invalidated parts of each. Primary-only surface (turn-end guard, session-start nudge, watcher protocol, subagent guard, worker-server reaping) is deliberately excluded.
CREDIT PRESERVATION is a hard captain requirement and is DELIBERATE, not an oversight: PR #1814 (abojja9) is cherry-picked verbatim so original git authorship is preserved, and #1726 (vipentti) and #787 (Amplify-Logic) are credited with Co-authored-by trailers because their diffs could not be cherry-picked (16 and 13 conflicts; #787 predates the shared composer classifier). The captain has EXPLICITLY reviewed and APPROVED the trailer 'Co-authored-by: Amplify Logic AI [email protected]' and instructed it be kept VERBATIM: it is the real human contributor's own git identity from #787's commits, and the no-AI-co-author rule targets the assistant itself, not a human whose account name contains 'AI'. Do not flag, remove, reword, or rewrite that trailer.
THE TWO NEW COMMITS IN THIS RUN close a captain-directed gap: the captain required cursor to be E2E LIVE-VALIDATED on the HERDR backend too, not just tmux, and when that live run found a real defect the captain chose "fix it" (Option A) over "document it and ship tmux-only". Both commits are herdr-scoped defect fixes proven against a real signed cursor-agent 2026.08.11-e8db854 worker on herdr 0.8.0 in an isolated lab session.
COMMIT 1 (composer): herdr draws a composer's top and bottom rules with the half-block glyphs U+2584 and U+2580 rather than the box-drawing family. fm_composer_row_has_edge knew only the box-drawing set, so no box was detected, the composer was found as a BARE row, and its wrap region walked straight through its own closing rule and swallowed the model and path footer below it - real text, which forced
pendingon a genuinely idle pane. Teaching the shared edge detector those glyphs bounds the region at the closing rule. This is a GENERAL herdr bare-composer bug, not cursor-specific. Measured as an A/B on the SAME live pane: the pre-fix classifier returns pending, the current one returns empty.COMMIT 2 (herdr submit): the idle fix alone did NOT make delivery confirm, and this is the second, independent cause found by live measurement. A 60-sample probe across a full turn showed herdr reports a cursor pane agent_status=blocked in EVERY state - idle, mid-turn, and after - so the submit path's idle-baseline native confirmation is structurally unreachable for cursor and every send falls into the composer branch. That branch reads cursor's MID-TURN composer row, which renders its own placeholder beside a right-aligned
ctrl+c to stop; that token is composer content, so the verdict ispendingon a composer holding no user text, and fm-send exited 1 with "delivery unconfirmed" on messages that had actually landed. The fix confirms the submit from a RENDERED-FOOTER idle-to-busy transition across our Enter - the same semantic signal the native path uses and the same one the tmux submit core already reads - with the footer baseline taken before the first Enter and only when the native baseline was not legibly idle.DELIBERATE DESIGN BOUNDARIES, do not flag as missing work:
pending, so the delivery confirmation can only be coming from the footer transition and never from a softened verdict.pending.REQUIRED, EXPLICIT LIMITATION STATEMENT (captain instruction, must not be silently omitted): cursor delivery confirmation is verified on tmux and herdr ONLY. On zellij, cmux, and orca a cursor steer LANDS but fm-send reports delivery unconfirmed and exits non-zero, because those three share a submit core that never consults the busy footer. That is documented in .agents/skills/harness-adapters/SKILL.md and docs/verification/runtime-backends.md, and follow-up task fm-cursor-shared-submit-busy-transition-a2 owns the shared change and its own live validation.
CAPTAIN DECISIONS already made on this branch, do not re-litigate: cursor is NOT gated to tmux (every harness on every session backend; no backend gate may be added); model ids validate against the live cursor-agent --list-models catalog rather than a hardcoded list, failing open when the catalog cannot be reached; the tmux composer verdict for cursor is permanently 'unknown' BY DESIGN because cursor-agent parks its terminal cursor outside its composer; and cursor's recorded worker state comes only from its transcript fold, never rendered text or native state.
LIVE VALIDATION EVIDENCE for this run is dated 2026-08-12 in docs/verification/runtime-backends.md, section "Cursor Agent CLI" -> "Herdr backend". A real cursor scout was spawned on herdr through bin/fm-spawn.sh and driven end to end: brief executed, transcript fold read busy mid-turn and idle after, fm-send exited 0 with the steer executing in the pane, fm-control interrupt cancelled a running turn, fm-control exit stopped the agent, and fm-teardown refused until the decision gate was satisfied then cleared the record. All seven panes of the running default herdr session - one Pi, four Claude, two plain shells - classify identically before and after the shape fix, so no other harness regressed. All herdr lab work ran through bin/fm-herdr-lab.sh in an isolated fm-lab- session with the live default session's pane count checked before, during, and after; it never changed.
Delivery: mode=no-mistakes, yolo OFF - the captain merges. Homes need a self-update after merge. Escalate any ask-user finding rather than deciding it.
What Changed
fm-sendreports unconfirmed delivery and exits non-zero.Risk Assessment
✅ Low: The Cursor crew adapter is bounded away from primary harness use, required backend limitations are documented, and the Herdr fix now prevents a positively working pre-Enter baseline from using footer confirmation.
Testing
Inspected the targeted changes, verified the installed Herdr 0.8.0 and cursor-agent 2026.08.11-e8db854 versions, exercised focused composer, Herdr, Cursor, spawn, secondmate, control, relaunch, and busy-state tests, and captured a public fm-send transcript showing blocked-state Cursor delivery confirmed through the rendered-footer transition; all checks succeeded and the worktree remained clean.
Evidence: Cursor-on-Herdr fm-send delivery-confirmation transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/backends/herdr.sh:2776- Contradicts the required invariant: “A pane already mid-turn before the text was typed must NOT confirm from that same busy footer.” A native pre-Enterworkingstatus is collapsed tobusy, but the footer fallback remains enabled. If the initial footer capture occurs before the existing turn renders its token, then that same turn renders it after Enter while the composer remainspending, lines 2785–2787 falsely confirm delivery. Preserve the raw status and allow this fallback for Cursor'sblocked/unreadable baseline only, never a positivelyworkingbaseline.🔧 Fix: Prevent working Herdr baselines from falsely confirming delivery
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
git diff --stat b91016f2c60fe753b2f7f728f2ed3b7dd61ad34a..590da2a415bd95002e4a131eb353afa52b886aedand focused commit/diff inspectionbash tests/fm-composer-lib.test.shbash tests/fm-backend-herdr.test.shbash tests/fm-cursor-harness.test.shbash tests/fm-spawn-dispatch-profile.test.shbash tests/fm-secondmate-harness.test.shbash tests/fm-control-relaunch.test.shbash tests/fm-control.test.shbash tests/fm-busy-state.test.shChecked installedherdr --versionandcursor-agent --versioncompatibilityExecuted publicbin/fm-send.sh default:w1:p2 'hello captain'against a deterministic Herdr protocol simulation reproducing blocked native state and an idle-to-busy rendered-footer transition; it exited 0 after one Entergit status --shortconfirmed testing left the worktree clean✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.