Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion .agents/skills/harness-adapters/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: harness-adapters
description: Agent-only reference for firstmate harness operations. Use before spawning or recovering a crewmate or secondmate, handling a trust dialog, sending a harness-specific skill invocation, interrupting or exiting an agent, resuming an exited agent, or verifying a new harness adapter. Contains verified facts for claude, codex, opencode, pi, and grok.
description: Agent-only reference for firstmate harness operations. Use before spawning or recovering a crewmate or secondmate, handling a trust dialog, sending a harness-specific skill invocation, interrupting or exiting an agent, resuming an exited agent, or verifying a new harness adapter. Contains verified facts for claude, codex, opencode, pi, grok, and cursor.
user-invocable: false
---

Expand Down Expand Up @@ -55,6 +55,7 @@ The supported launch-profile flags below were verified locally on 2026-06-30 wit
| grok | `--model <model>` | `--reasoning-effort <low\|medium\|high\|xhigh>` | Verified on grok 0.2.73. `--effort` parses too, but firstmate's profile axis is reasoning effort. `--reasoning-effort max` is rejected, so `max` is omitted. |
| pi | `--model <model>` | `--thinking <low\|medium\|high\|xhigh>` | Verified on pi 0.80.2. `max` prints an invalid-thinking warning, so firstmate omits Pi effort when the requested effort is `max`. |
| opencode | `--model <provider/model>` | none for firstmate's interactive launch | Verified on opencode 1.17.6. `opencode run` has `--variant`, but firstmate launches the interactive `opencode --prompt` path, which has no verified effort flag. |
| cursor | `--model <id>` | none — encoded in model id | Verified on cursor-agent 2026.07.01-41b2de7. No separate effort flag; effort folds into the model id (suffix `-low/-medium/-high/-xhigh/-max`, or bracket `'id[effort=high]'`). `fm-spawn` records the requested effort in meta but emits no effort flag. |

When a requested effort value is outside the harness-specific accepted set, `fm-spawn` records the requested `effort=` in meta but emits no effort flag for that harness.
This preserves launch success instead of passing a known-bad value.
Expand All @@ -69,6 +70,7 @@ Natural language is acceptable if uncertain.
- opencode: no separate verified skill invocation beyond normal slash-command behavior; use natural language if the exact skill command is uncertain.
- pi: no separate verified skill invocation beyond normal command behavior; use natural language if the exact skill command is uncertain.
- grok: `/<skill>`, for example `/no-mistakes` (same form as claude). Verified end to end: grok discovers the user-level `no-mistakes` skill, `/no-mistakes` invokes it, and grok drives a real `no-mistakes axi run`. Like codex's `$`/`/` popups, typing `/<skill>` opens grok's slash-autocomplete, so a too-fast Enter selects the popup entry instead of sending; `fm_tmux_submit_core`'s retried Enter (used by `fm-send`) lands it.
- cursor: `/<skill>`, for example `/no-mistakes` (same form as claude/grok). cursor auto-discovers the workspace's `.agents/skills/` as `/`-commands (verified cursor-agent 2026.07.01). Note: the user-level `no-mistakes` skill was NOT present in `~/.cursor/skills/` at probe time, so confirm `/no-mistakes` resolves on cursor (cursor may need it symlinked into `~/.cursor/skills/`); natural language is the fallback.

## claude (VERIFIED)

Expand Down Expand Up @@ -177,3 +179,36 @@ The hook reads `$GROK_WORKSPACE_ROOT`, which is always set for hooks and equals
This keeps the hook outside the worktree, needs no trust grant, and writes only firstmate-owned files.
`fm-teardown` removes the worktree pointer before returning a pooled worktree.
Secondmate spawns skip the pointer (idle panes are healthy, no stale-pane detection for them).

## cursor (VERIFIED 2026-07-02, cursor-agent 2026.07.01-41b2de7)

`cursor-agent` (Cursor CLI). Launch with a positional prompt: `cursor-agent --yolo "$(cat <brief>)"`.

| Fact | Value |
|---|---|
| Busy-pane signature | `ctrl+c to stop` (right-aligned on the `→ Add a follow-up` composer input line, shown iff a turn is running; idle shows that line bare, no suffix). The spinner line is a braille glyph + `<verb>` + `N.NNk tokens` (e.g. `⠘⠤ Working`, `⠰⠳ Editing 55 tokens`); the glyph rotates so match the ASCII `ctrl+c to stop`, never the spinner. |
| Exit command | `Ctrl+D` (cleanly exits `node`→shell; `/exit`/`/quit` exist but their slash-autocomplete is menu-finicky under `tmux send-keys`). On exit prints `To resume this session: agent --resume=<chatId>`. |
| Interrupt | single `Ctrl+C` (cancels the current turn, session survives). `Esc` dismisses the `/`-command menu but does not interrupt. |
| Autonomy | `--yolo` (alias of `--force`; status bar shows `Run Everything`). Auto-approves every command unless explicitly denied. |
| Env marker | `CURSOR_AGENT=1`, set for child/tool processes (the cursor analog of claude's `CLAUDECODE`). Also sets `CURSOR_INVOKED_AS=cursor-agent`, `CURSOR_CONVERSATION_ID=<uuid>`. |
| Skill invocation | `/<skill>` (e.g. `/no-mistakes`), same as claude/grok. Workspace `.agents/skills/` is auto-discovered as `/`-commands. |
| Resume | `cursor-agent --resume=<chatId>` (id printed on exit) or `--continue`. |

Trust dialog: first launch in an untrusted workspace shows a bordered "Workspace Trust Required" dialog.
Accept with `a` (or arrow+Enter on the highlighted row); reject with `q`.
Trust persists per workspace path, so a re-launch in the same path does not re-prompt, but a fresh worktree path prompts anew.
After every spawn, peek the pane within ~20 seconds and accept with `bin/fm-send.sh <window> --key a` if the dialog is showing.
Headless `--print` mode skips the dialog entirely with `--trust` (see future fallback below).

Turn-end hook: cursor fires a `stop` hook at every turn boundary (verified: 2 turns → 2 fires), the clean equivalent of claude's Stop / grok's Stop.
But unlike grok's private `~/.grok/hooks/` tree, cursor's ONLY hook file is `~/.cursor/hooks.json`, which is SHARED with cmux and already holds cmux's own `stop`/`afterAgentResponse`/`beforeSubmitPrompt`/`beforeShellExecution`/`afterShellExecution` entries.
So `fm-spawn` `jq`-MERGES firstmate's `stop` command in additively and idempotently (back up → merge keyed by the exact firstmate command so re-runs never duplicate → never clobber cmux's entries) and gates it as a no-op for every non-firstmate cursor session with the same per-task token-pointer scheme grok uses.
The guard command fires only when the current workspace holds a `.fm-cursor-turnend` token pointer that matches the firstmate-owned registry under `~/.cursor/fm-turn-end.d/`; it resolves the workspace from `CURSOR_WORKSPACE_ROOT` (if set) or `pwd`, so it does not depend on cursor setting a workspace env var.
`fm-spawn` writes that per-task pointer (`<worktree>/.fm-cursor-turnend`, gitignored via git `info/exclude`) and a matching registry entry naming this task's `state/<id>.turn-ended`.
`fm-teardown` removes the worktree pointer and the per-task registry entry, but deliberately LEAVES the shared `~/.cursor/hooks.json` entry in place: it is idempotent and gated, so once the pointer is gone it is a safe no-op for every other cursor session (cmux's or a future firstmate task).
This keeps the hook outside the worktree, needs no trust grant, and writes only firstmate-owned files (firstmate never clobbers cmux's entries, so it never removes a shared entry wholesale either).
Secondmate spawns skip the pointer (idle panes are healthy, no stale-pane detection for them).

Future fallback (not wired today): if the interactive TUI proves too finicky under real supervision (multi-key submit / follow-up prompts via `tmux send-keys` are unreliable and the composer can wedge), cursor-agent has a verified headless mode: `cursor-agent --print --yolo --trust [--output-format json] "<prompt>"` runs one agent turn to stdout and exits 0 cleanly, with `--output-format json` giving structured per-turn output instead of pane-scraping.
firstmate's interactive TUI launch matches the other five adapters today; headless `--print` is documented here as the documented fallback path if TUI reliability becomes a blocker in real supervision.

3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ If the captain expresses a standing dispatch preference such as "use grok for ne
Crewmates default to the same harness you are running on.
The captain may override the static default at any time, typically at bootstrap: record the choice in `config/crew-harness` (a single adapter name; absent or `default` means mirror your own harness).
Resolve `default` with `bin/fm-harness.sh`; resolve the active static crewmate harness with `bin/fm-harness.sh crew`.
Verified adapter names are `claude`, `codex`, `opencode`, `pi`, and `grok`.
Verified adapter names are `claude`, `codex`, `opencode`, `pi`, `grok`, and `cursor`.

### Crew dispatch profiles

Expand Down Expand Up @@ -260,6 +260,7 @@ The verified profile axes are:
- `grok`: model via `--model <name>`, reasoning effort via `--reasoning-effort <low|medium|high|xhigh>`; `max` is not passed because Grok rejects it for `--reasoning-effort`.
- `pi`: model via `--model <name>`, effort via `--thinking <low|medium|high|xhigh>`; `max` is not passed because the installed Pi CLI warns that it is invalid.
- `opencode`: model via `--model <provider/model>`; no verified effort flag for firstmate's interactive `opencode --prompt` launch, so effort is not passed.
- `cursor`: model via `--model <id>` (cursor-specific vocabulary such as `auto`, `composer-2.5-fast`, `claude-opus-4-8-high`); no separate effort flag is passed because effort is folded into the model id (suffix `-low/-medium/-high/-xhigh/-max`, or bracket override `'id[effort=high]'`), so a requested effort is recorded in meta for traceability but not emitted as a flag (verified cursor-agent 2026.07.01-41b2de7).

If the selected profile asks for an effort value the selected harness does not accept, `fm-spawn` records the requested `effort=` in meta for traceability but omits the launch flag so the harness starts successfully.
Bootstrap reports this as a `CREW_DISPATCH` diagnostic when it can see the invalid harness/effort pair in `config/crew-dispatch.json`.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ Full detail on every feature lives in [docs/architecture.md](docs/architecture.m

## Quick Start

**Requirements:** a verified agent harness (claude, codex, opencode, pi, or grok), git with GitHub auth, and tmux for the reference session backend.
**Requirements:** a verified agent harness (claude, codex, opencode, pi, grok, or cursor), git with GitHub auth, and tmux for the reference session backend.
Experimental herdr spawns additionally require `herdr` and `jq`, checked at spawn time.
The first mate detects and offers to install everything else.

```sh
gh auth login
git clone https://github.com/kunchenguid/firstmate
cd firstmate && claude # launch your harness here; AGENTS.md takes over
cd firstmate && claude # or cursor-agent, codex, etc.; AGENTS.md takes over
```

Then just talk:
Expand Down
18 changes: 16 additions & 2 deletions bin/fm-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ crew_dispatch_validate() {
return 0
fi
err=$(jq -r '
def verified($h): ["claude","codex","opencode","pi","grok"] | index($h);
def verified($h): ["claude","codex","opencode","pi","grok","cursor"] | index($h);
def effort_ok($h; $e):
if $e == null then true
elif ($e | type) != "string" then false
elif $h == "claude" then (["low","medium","high","xhigh","max"] | index($e))
elif ($h == "codex" or $h == "grok" or $h == "pi") then (["low","medium","high","xhigh"] | index($e))
elif $h == "opencode" then false
elif ($h == "opencode" or $h == "cursor") then false
else true
end;
def bad_efforts:
Expand Down Expand Up @@ -414,6 +414,20 @@ fi
crew=
[ -f "$CONFIG/crew-harness" ] && crew=$(tr -d '[:space:]' < "$CONFIG/crew-harness" || true)
[ -n "$crew" ] && [ "$crew" != "default" ] && echo "CREW_HARNESS_OVERRIDE: $crew"

# jq is required for cursor harness (to jq-merge the stop hook into the shared
# ~/.cursor/hooks.json). Already required for X-mode and crew-dispatch (above).
if [ "$crew" = "cursor" ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect cursor defaults before jq check

Captain, this check only examines the literal config/crew-harness contents; if that file is absent or set to default while firstmate itself is running under cursor-agent, fm-harness.sh crew resolves to cursor but bootstrap will not emit MISSING: jq. This is a fresh gap beyond the earlier jq fix: cursor is selected implicitly via harness detection, so the first spawn fails in fm-spawn.sh instead of the session-start consent/install flow surfacing the prerequisite.

Useful? React with 👍 / 👎.

if ! command -v jq >/dev/null 2>&1; then
echo "MISSING: jq (install: $(install_cmd jq))"
fi
fi
sm=
[ -f "$CONFIG/secondmate-harness" ] && sm=$(head -1 "$CONFIG/secondmate-harness" 2>/dev/null | tr -d '[:space:]' | cut -d' ' -f1 || true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse secondmate harness before jq check

Captain, this secondmate jq probe removes all whitespace before taking the first field, so documented config/secondmate-harness lines like cursor auto high are parsed as cursorautohigh and skip MISSING: jq on machines without jq. This is fresh evidence beyond the prior jq thread: the added parser disagrees with fm-harness.sh's whitespace-token parser for pinned secondmate model/effort, so a cursor secondmate can pass bootstrap and then fail at spawn.

Useful? React with 👍 / 👎.

if [ "$sm" = "cursor" ] && ! command -v jq >/dev/null 2>&1; then
echo "MISSING: jq (install: $(install_cmd jq))"
fi

crew_dispatch_validate
if ! fm_backlog_backend_manual "$CONFIG"; then
if fm_tasks_axi_compatible; then
Expand Down
7 changes: 6 additions & 1 deletion bin/fm-harness.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Detect the agent harness this process tree runs on.
# Usage: fm-harness.sh print own harness: claude|codex|opencode|pi|grok|unknown
# Usage: fm-harness.sh print own harness: claude|codex|opencode|pi|grok|cursor|unknown
# fm-harness.sh crew print the effective CREWMATE harness
# (config/crew-harness; "default" resolves to own)
# fm-harness.sh secondmate print the harness the PRIMARY uses to launch
Expand Down Expand Up @@ -35,6 +35,9 @@ detect_own() {
# It does NOT set CLAUDECODE despite being Claude-Code-compatible, so this marker
# is unambiguous when firstmate runs natively on grok.
[ "${GROK_AGENT:-}" = "1" ] && { echo grok; return; }
# cursor-agent sets CURSOR_AGENT=1 for its child/tool processes (verified,
# cursor-agent 2026.07.01-41b2de7), the cursor analog of claude's CLAUDECODE.
[ "${CURSOR_AGENT:-}" = "1" ] && { echo cursor; return; }
# Layer 2: walk the parent chain and match the command name.
local pid=$$ comm args
for _ in 1 2 3 4 5 6 7 8; do
Expand All @@ -44,6 +47,7 @@ detect_own() {
*codex*) echo codex; return ;;
*opencode*) echo opencode; return ;;
*grok*) echo grok; return ;;
*cursor*) echo cursor; return ;;
pi) echo pi; return ;;
node*|python*)
# Bare interpreter: match the harness name in its script path.
Expand All @@ -53,6 +57,7 @@ detect_own() {
*codex*) echo codex; return ;;
*opencode*) echo opencode; return ;;
*grok*) echo grok; return ;;
*cursor*) echo cursor; return ;;
*" pi "*|*/pi) echo pi; return ;;
esac ;;
esac
Expand Down
2 changes: 1 addition & 1 deletion bin/fm-lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LOCK="$STATE/.lock"
mkdir -p "$STATE"

# Known harness command names; extend when a new adapter is verified.
HARNESS_RE='claude|codex|opencode|grok|^pi$'
HARNESS_RE='claude|codex|opencode|grok|cursor|^pi$'

harness_pid() {
local pid=$$ comm args
Expand Down
Loading
Loading