Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
138a9d0
feat(bin): encode project AGENTS.md authoring bar with canonical self…
kunchenguid Jul 7, 2026
463cb51
feat(skills): add captain-invocable bearings status-report skill (#300)
Ballestar Jul 7, 2026
49ffe5d
fix(watcher): make PID identity locale-invariant (#285)
pchuri Jul 7, 2026
0a7cb88
docs: document codex app backend contract (#222)
Jul 7, 2026
a790a20
docs: add Codex Desktop coordination skill (#275)
Jul 7, 2026
f5e89b9
fix(afk): stop herdr escalation redelivery loop (#317)
kunchenguid Jul 7, 2026
01dca33
fix(backends): confirm Herdr submits with native agent state (#323)
kunchenguid Jul 7, 2026
7a42707
feat: add quota-balanced crew dispatch selection (#327)
kunchenguid Jul 8, 2026
121b902
fix(session-start): respawn dead secondmate agents conservatively
kunchenguid Jul 8, 2026
28a3b0e
fix: emit stable secondmate nudge selectors (#331)
kunchenguid Jul 8, 2026
c9e5ba3
feat: require bootstrap detection for AXI tools (#332)
kunchenguid Jul 8, 2026
2061c37
bearings: delete today's report before recreating (#333)
kunchenguid Jul 8, 2026
228963d
feat: guard primary turn ends across harnesses (#339)
kunchenguid Jul 8, 2026
a894c3a
fix: resolve backend selectors by exact task id first (#342)
kunchenguid Jul 8, 2026
091384b
fix: scale bootstrap fleet-sync timeout (#341)
kunchenguid Jul 8, 2026
0f9b7cc
feat: add fleet snapshot and view commands (#343)
kunchenguid Jul 8, 2026
d8a2ff1
fix(fm-send): fail loudly on unresolvable send targets (#254)
mielyemitchell Jul 8, 2026
95dd1a0
fix: deliver AFK escalations through herdr supervisors (#353)
kunchenguid Jul 8, 2026
090483e
feat: add harness-aware supervision (#367)
kunchenguid Jul 8, 2026
4790bc5
fix: split X-mode replies by platform (#369)
kunchenguid Jul 8, 2026
af5361e
fix: make stow memory writes inspect before update (#372)
kunchenguid Jul 9, 2026
7302a95
fix(watcher): wait when arm attaches to a healthy watcher (#375)
kunchenguid Jul 9, 2026
1b5a9f5
feat(pi): simplify primary session launch (#386)
kunchenguid Jul 9, 2026
766f772
feat(supervision): prevent unsafe watcher-arm commands (#387)
kunchenguid Jul 9, 2026
80ecc8d
fix(pi): restore primary watcher supervision lifecycle (#397)
kunchenguid Jul 10, 2026
e627524
Merge upstream/main into fork main
nmkataoka Jul 10, 2026
b77079e
no-mistakes(review): fix herdr liveness dead-gate and restart signale…
nmkataoka Jul 10, 2026
44253b7
no-mistakes(test): skip Pi TS extension tests when node lacks type st…
nmkataoka Jul 10, 2026
5e6e48b
no-mistakes(document): sync test index, doc links, and seatbelt gap docs
nmkataoka Jul 10, 2026
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
51 changes: 25 additions & 26 deletions .agents/skills/afk/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ batched digest rather than per-wake injections.
This file survives a firstmate restart: recovery re-enters afk if the
flag is present.

2. **Ensure the sub-supervisor daemon is running.** Check the pid file; start
the daemon only if it is dead or absent:
2. **Ensure the sub-supervisor daemon is running.** Start the helper as its own
tracked background terminal/session:
```sh
if [ -f state/.supervise-daemon.pid ] && kill -0 "$(cat state/.supervise-daemon.pid)" 2>/dev/null; then
: # daemon already alive - it picks up the flag on its next cycle
else
nohup bin/fm-supervise-daemon.sh >/dev/null 2>&1 &
fi
bin/fm-afk-start.sh
```
The helper sets or refreshes `state/.afk`, exits immediately if the identity-backed daemon lock already names a live process, and otherwise execs `bin/fm-supervise-daemon.sh` in the foreground.
Do not wrap this in `nohup ... &`.
Codex/herdr can reap fire-and-forget shell children after a tool call
returns; a tracked background terminal/session keeps the daemon attached to
the harness lifecycle and survived the real incident reproduction.
The daemon is **presence-gated**: it injects escalations only while
`state/.afk` exists, and stays quiet otherwise.

Expand All @@ -46,12 +47,8 @@ batched digest rather than per-wake injections.

No `/back` is needed. The first genuine message is the return signal:

- A message **without** the sentinel marker and **not** starting with `/afk`
-> the captain is back. Clear `state/.afk`, stop the daemon, flush one
distilled "while you were out" catch-up (drain `state/.wake-queue`, summarize
any pending escalations from `state/.subsuper-escalations` and any
`state/.subsuper-inject-wedged` marker), and resume full per-wake
responsiveness (arm `bin/fm-watch-arm.sh`).
- A message **without** the sentinel marker and **not** starting with `/afk` -> the captain is back.
Clear `state/.afk`, stop the daemon, flush one distilled "while you were out" catch-up (drain `state/.wake-queue`, summarize any pending escalations from `state/.subsuper-escalations` and any `state/.subsuper-inject-wedged` marker), and resume full per-wake responsiveness through the emitted primary-harness supervision protocol from session start.
- A message **with** the sentinel marker (`FM_INJECT_MARK`, ASCII 0x1f) -> it
is a daemon escalation; stay afk and process it.
- Re-invoking `/afk` while already away -> stay afk (refresh the flag); this
Expand Down Expand Up @@ -90,8 +87,8 @@ backend (tmux or herdr; see "Auto-discovered supervisor pane" below):
correctly read as empty, not pending. Without this, every idle claude pane
looked like pending input and the daemon deferred 100% of escalations
(incident afk-invx-i5). `FM_COMPOSER_IDLE_RE` still overrides empty-composer
matching after border stripping. On herdr, the equivalent structural
border-row classifier (`fm_backend_herdr_composer_state`,
matching after border stripping. On herdr, the equivalent ANSI-aware
structural classifier (`fm_backend_herdr_composer_state`,
docs/herdr-backend.md) plays the same role.

Either condition defers the injection; the buffered escalation survives in
Expand All @@ -113,12 +110,13 @@ So a guard false-positive becomes a visible stall, never an unbounded silent no-

The digest is typed **once** (`send-keys -l` on tmux, `pane send-text` on
herdr - both literal, non-submitting sends), then submitted with Enter and
**verified**: Enter is retried (Enter only, never a retype) until the composer
clears.
A submit "landed" only when the composer is confirmed empty afterward, using
the same corrected, border-aware detector as the composer guard.
A bordered-empty claude composer is recognized as submitted rather than
mistaken for a swallowed Enter.
**verified** through the selected backend's submit primitive.
Enter is retried (Enter only, never a retype) until the backend confirms the
submit landed.
For tmux that confirmation is a cleared composer, using the same corrected,
border-aware detector as the composer guard.
For herdr, normal idle-baseline submits are confirmed by native agent-state showing a real turn started; the ANSI-aware composer classifier remains the pre-injection guard and conservative fallback for non-idle or unreadable baselines.
A bordered-empty or ghost-only composer is recognized as empty where that backend uses composer confirmation, rather than mistaken for a swallowed Enter.
`fm-send.sh` uses the same primitive and exits non-zero
when a steer's Enter is positively swallowed, so firstmate learns an instruction
did not land instead of leaving it unsubmitted.
Expand Down Expand Up @@ -191,11 +189,12 @@ the marker lets firstmate distinguish it from a real captain message.
no-op.
- **Verified type-once submit model** - the digest is typed once (`send-keys -l`
on tmux, `pane send-text` on herdr), then submitted with Enter and verified.
Enter is retried, Enter only and never a retype, until the composer is
confirmed empty. That empty composer is the acknowledgement that the submit
landed, using the same dim-ghost-aware and border-aware detector (tmux) or
structural border-row classifier (herdr) so a ghost-only or bordered-empty
claude composer counts as submitted rather than a false swallowed Enter.
Enter is retried, Enter only and never a retype, until the backend submit
primitive reports `empty` as its caller-facing success verdict.
For tmux that verdict means the dim-ghost-aware and border-aware composer
cleared.
For herdr's normal idle-baseline path it means native agent-state observed a real turn start; herdr uses the ANSI-aware structural classifier for the pre-injection composer guard and fallback paths.
This lets ghost-only or bordered-empty composers count as empty where a composer read is the active confirmation signal.
- **Marker strip** - `strip_injection_marker` removes the sentinel prefix before
classification or relay, so the digest text firstmate sees is clean.
- **Portable singleton lock** - the daemon uses the repo's portable lock helper
Expand Down
59 changes: 59 additions & 0 deletions .agents/skills/bearings/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: bearings
description: Generate a "pick up where I left off" status report from firstmate's live fleet state. Use when the captain invokes /bearings or asks for a bearings report, morning brief, status report, catch-up, "where did I leave off", or "what's in the works". Reads live fleet state cheaply (backlog, per-task crew state, open PRs, scout reports, pending decisions, date-gated queued work), composes a scannable dated report to data/status-report-<YYYY-MM-DD>.md, and surfaces a concise version in chat; it is read-mostly and must not tear down, merge, or mutate task state as a side effect of producing the brief.
user-invocable: true
metadata:
internal: true
---

# bearings

Generate a "pick up where I left off" report from the fleet's live state, so the captain can resume in one read after a break, a night, or a context reset.
The deliverable is a dated markdown file plus a concise chat summary; this is the reusable version of the worked example at `data/status-report-2026-07-06.md` when that file is present in this home.
This skill is read-mostly.
It reads fleet state and writes exactly one report file.
It never tears down a task, merges a PR, dispatches new work, or mutates any task state as a side effect of producing the brief - those belong to the captain's explicit word and the normal task lifecycle.

## What it does

1. **Gather live fleet state, cheaply and in this order.**
Read each source once and do not re-derive what a script already reports.
- `bin/fm-fleet-snapshot.sh --json` - the deterministic fleet source for backlog rows, task metadata, current state, endpoint facts, PR/report pointers, scout report paths, status-event hints, and secondmate return-channel guidance.
Its schema is owned by the script header; consume those structured fields before rereading raw fleet files.
- If the snapshot command is unavailable or its JSON is invalid, fall back to `data/backlog.md`, each `state/<id>.meta`, and each task's live state via `bin/fm-crew-state.sh <id>`.
Never infer current state from a raw `tail` of `state/<id>.status`: that log is an append-only wake-event history and its last line goes stale the moment a resolved gate lets a run resume, while `bin/fm-crew-state.sh` reconciles the authoritative run-step over the stale log line - which is exactly what a catch-up report needs.
- Open PRs awaiting the captain's merge, via `gh-axi` per repo touched by in-flight or recent tasks.
A PR-based ship task records `pr=` in `state/<id>.meta`; collect those repos, list their open PRs, and cross-reference each task's recorded PR.
- Recent scout deliverables at `data/<id>/report.md` and any planning docs the captain should pick up from.
- Pending human decisions (needs-decision findings), needed credentials or logins (such as an SSO re-auth), and date-gated queued items.
A queued item only becomes "next work" when its blocker is gone and its time/date gate has arrived; until then it stays queued with the reason.

2. **Compose the report with these sections, matching the worked example's structure, tone, and level of detail.**
The exemplar is `data/status-report-2026-07-06.md` in this home's `data/` when present; match its scannability, not a raw state dump.
- **Title** - `# Bearings - <day> <YYYY-MM-DD>` (the exemplar used "Morning status" for a morning brief; use that phrasing when the captain specifically asks for a morning brief).
- **TL;DR** - two or three sentences framing where things stand.
- **Check first** - anything likely waiting on the captain: a PR to merge, a needed credential or login, or anything blocking pickup, each PR with the full `https://...` URL, never a bare `#number`.
- **Landed** since the captain last worked - merged PRs, completed scouts, and finished local-only work, drawn from the Done section and recent merges.
- **In flight** now - each live direct report with its current state in one line; if nothing is in flight, say so plainly rather than omitting the section.
- **Plans / main pickup points** - pointers to the relevant `data/<id>/report.md` files and any Lavish boards (`.lavish/*.html`) the captain should reopen.
- **Decisions pending** from the captain - relayed verbatim from needs-decision findings, with options where the crewmate offered them.
- **Date-gated / queued** next work - queued items whose blocker is gone and whose gate has arrived, plus anything still blocked with the reason.

3. **Write the report to a dated file so it persists, and surface a concise version in chat.**
- Write the full report to `data/status-report-<YYYY-MM-DD>.md` using today's date.
This is the required artifact; it lives in gitignored `data/` alongside the worked example.
If today's file already exists, delete it first, then create a new file from scratch.
- Surface a concise version to the captain in chat - the TL;DR plus the "Check first" list - and point to the file for the full picture.
- For a richer review surface, optionally offer a Lavish board with `lavish-axi` when the report has enough structure to deserve one, but the markdown file is the required artifact and the chat summary is the required minimum.

## Tone and content rules

- This report is a private, captain-facing internal artifact that lives in gitignored `data/`, so unlike normal captain chat it MAY reference task ids, PR URLs, and repo names - the captain works with these directly and needs them to resume; keep it organized and scannable, not a raw dump.
- Every PR reference is a full `https://...` URL, never a bare `#number`; a shorthand `#number` is fine only as a back-reference after the full URL has already appeared in the same report.
- Never include PHI or secret values; the report is an operational artifact, but it is still subject to the same security and compliance rules that govern everything else in this fleet.

## Supervision discipline

This skill is read-mostly and changes no fleet state.
Do not tear down a task, merge a PR, dispatch queued work, or mutate any `state/` or `data/` file other than the single report file as a side effect of generating the brief.
If the state you read suggests an action - a PR ready to merge, a queued item whose gate has arrived, a needs-decision finding - name it in the report under "Check first" or "Date-gated / queued" and let the captain decide, rather than taking the action from inside this skill.
108 changes: 108 additions & 0 deletions .agents/skills/firstmate-codexapp/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
name: firstmate-codexapp
description: >-
Agent-only playbook for coordinating visible Codex Desktop threads alongside Firstmate without pretending they are a selectable shell backend.
Use before creating, reading, steering, archiving, debugging, or reviewing a Codex App visible thread for Firstmate work, and before responding to requests to make Codex App native to Firstmate.
user-invocable: false
metadata:
internal: true
---

# firstmate-codexapp

## Overview

Use this playbook when Firstmate work needs a visible Codex Desktop thread.
The current supported shape is Desktop host-tool choreography plus an explicit status-file return-channel check, not a `codex-app` value in `FM_BACKEND`.

## Boundary

Codex Desktop visible threads are companion host-tool workflows, not a selectable Firstmate backend.
Read `docs/codex-app-backend.md` when it exists in this checkout; that document owns the acceptance contract, bridge requirement, status-return requirement, and staged rollout.

If local helper scripts exist for Codex App work, use only helpers explicitly provided by the operator or maintained by Firstmate.
For helpers outside `bin/`, inspect the source or header before running `--help`.

## Preflight

1. Confirm this session is running inside Codex Desktop and that the host tools are exposed.
Search exact names when needed: `create_thread`, `list_threads`, `read_thread`, `send_message_to_thread`, `archive`, and `set_thread_archived`.
2. Confirm the target repository is already saved as a Codex Desktop project.
No host tool currently creates Codex App projects for an agent, so the human must add the project in Desktop before a created thread can reliably land there.
3. Do not create projectless threads for repo work.
If the project is absent, stop and ask for the project to be added or use a normal Firstmate backend instead.
4. Decide whether this is a real Firstmate-managed task or a visible companion thread.
A real task needs a task id, an isolated worktree or Desktop-owned cwd, a branch plan, and a writable `state/<id>.status` path.

## Create And Send

When creating a visible thread, use the Desktop host tool, not shell imitation.
Target the saved project and ask the worker to start by reporting:

```text
pwd
git rev-parse --show-toplevel
git branch --show-current
git log --oneline --max-count=3
```

For writable repo work, instruct the worker to use the Codex-created current directory.
Do not tell it to `cd` into the saved project checkout for edits, commits, no-mistakes, pushes, or PR work.

When sending follow-up instructions, use `send_message_to_thread`.
If the user types directly into the visible thread, treat that as authoritative and reconcile from `read_thread` instead of undoing it.

## Status Return Channel

A Desktop-owned Codex thread can append to Firstmate status files only when the prompt gives an absolute path and the Desktop permission context can write that checkout.
That makes status writes a verified return-channel requirement, not a fact to assume.

For a Firstmate-managed task, include an explicit status instruction:

```text
Append supervisor-visible status lines to <absolute-firstmate-home>/state/<task-id>.status.
Use only these prefixes for supervisor-actionable changes: working:, needs-decision:, blocked:, done:, failed:.
Before doing substantive work, append "working: Codex Desktop thread started".
```

Verify the return channel before treating the thread as supervised:

- `read_thread` shows the worker attempted the status write.
- The local `state/<task-id>.status` file contains the expected line.
- If available, the transcript includes a file-change entry for that status file.

If the thread cannot write the status file, keep it as a visible companion thread only.
Do not claim it is a complete Firstmate backend.

## Observe And Reconcile

Use `read_thread` for thread truth.
Use `list_threads` only to find or recover a visible thread id, not as a replacement for reading the transcript.

For Firstmate reconciliation, prefer concrete evidence:

- thread id and project
- current Desktop-owned cwd
- branch name
- last meaningful thread state
- latest status file line
- PR URL when one exists

Avoid repeating long transcripts into Firstmate docs or PR bodies.
Summarize only the host-tool calls, the status-file result, and the archive result.

## Archive

Archive through the Desktop host tool: `archive` when that is the exposed primitive, or `set_thread_archived(threadId=<id>, archived=true)` when that is the exposed tool name.
Archiving can remove the thread from normal sidebar/project views, but it should not erase the transcript or landed work.

For companion threads, archive the thread and report where the durable work landed.
If there is a real Firstmate task record, leave teardown decisions to the normal Firstmate task flow instead of this skill.

## Failure Signals

- Missing Desktop project: ask the human to add the target project in Codex Desktop, or use a normal backend.
- Missing host tools: do not simulate them with shell files; use a terminal backend instead.
- Status file not updated: treat the thread as unsupervised until the return channel is proven.
- Worker editing the saved project checkout instead of its Desktop cwd: stop and decide whether to salvage the branch before continuing.
- Production `codex-app` backend request: read `docs/codex-app-backend.md` and do not invent a local adapter.
4 changes: 4 additions & 0 deletions .agents/skills/firstmate-codexapp/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface:
display_name: "Firstmate Codex App"
short_description: "Operate visible Codex Desktop threads"
default_prompt: "Use $firstmate-codexapp to coordinate visible Codex Desktop threads without pretending they are a shell backend."
2 changes: 1 addition & 1 deletion .agents/skills/firstmate-orca/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Do not manually patch metadata to make an externally-created Orca terminal look
## Supervision

Use `bin/fm-peek.sh`, `bin/fm-send.sh`, `bin/fm-crew-state.sh`, and `bin/fm-teardown.sh` for routine operation.
For steer messages, send short lines through `bin/fm-send.sh fm-<id> '...'`.
For steer messages, send short lines through `bin/fm-send.sh <id> '...'`; the stable `fm-<id>` alias also works.
Put long instructions in the task brief or a temporary file and point the crewmate at that file.

When supervising, treat `state/<id>.meta` as the routing record and Orca's own ids as backend implementation details.
Expand Down
Loading