CLI for agents: non-TTY safe run/confirmations, compact inspect, wait hints and exit codes

- Without a terminal, run behaves as --json, tui refuses and confirmations
  fail fast naming --yes instead of prompting.
- inspect prints a compact summary by default; --step N, --transcripts and
  --json give detail.
- wait names a failed run's stage and first diagnostic line, prints how to
  answer a run waiting on a person, and exits 2 when any run failed,
  was canceled or interrupted (1 stays for client errors).
- help describes the current # outcome / # handoff format.
- Task starter's Land stage drops edit to match format.md; skill docs
  document run --json --yes, retry --yes --json and the new behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 00:27:14 +00:00
parent accb9970b6
commit 2bde6b6344
16 changed files with 658 additions and 56 deletions
+22 -9
View File
@@ -12,25 +12,38 @@ task with the least ceremony, and keep work small enough to verify.
## Using it
`pipelines list` shows the registered workflows; `pipelines runs` shows history.
Start a run with `pipelines run <name> "<task>"`, and inspect it with
`pipelines inspect <id>`.
From an agent's shell always pass `--yes` and `--json`; without a terminal the
CLI never opens a full-screen view or prompts, and a missing `--yes` fails at once.
Start a run with `pipelines run <name> "<task>" --json --yes` (prints the run id),
and inspect it with `pipelines inspect <id>`: a compact summary (one line per
step with status, outcome, duration and first diagnostic line, plus the final
handoff). `--step N` shows one step in full, `--transcripts` adds transcripts,
and `--json` is the full record.
After starting a run, always follow it with `pipelines wait <id>` until it
finishes; never start a run and move on without waiting. Run the wait as a
background command (one per run, or one loop over several ids) so the session is
notified the moment the run ends, then read its result with
`pipelines inspect <id> --json` and act on it: land, retry, or fix and report.
`pipelines inspect <id>` and act on it: land, retry, or fix and report.
`wait` prints one line per run, naming a failed run's stage and first diagnostic
line, and exits 0 when every run succeeded, 2 when any failed, was canceled or
interrupted, and 1 for a client error (unknown id, connection, `--timeout`).
Do not poll with repeated `pipelines runs` calls, and do not tell the user a run
is done, or will be reported, without a wait covering it. `wait` keeps blocking
while a run is `waiting` on a human stage (`pipelines decide`, user's choice only).
while a run is `waiting` on a human stage and prints how to answer it
(`pipelines decide <id> --option KEY`, the user's choice only).
A run started from a repository's main checkout runs in its own worktree
(`<repo>-runs/...`, branch `pipelines/run-...`); a failed run keeps that tree and
its commits. Read `pipelines inspect <id> --json` before deciding: resume the
failed stage (`pipelines retry <id>`; `--stage`/`--visit`, `--input-file`,
`--mode=restart` from entry), fix directly, or continue from the preserved
branch. Only `failed` runs can be retried; `interrupted` (server stopped
mid-run) and `canceled` runs need a new run or direct work on their branch.
its commits. Read `pipelines inspect <id>` before deciding: resume the
failed stage (`pipelines retry <id> --yes --json`; `--stage`/`--visit`,
`--input-file`, `--mode=restart` from entry), fix directly, or continue from the
preserved branch. `failed` and `interrupted` (server stopped mid-run) runs can be
retried: resume reruns the failed or interrupted stage, or starts the next stage
after the last completed one. `canceled` runs need a new run or direct work on
their branch. A retried stage's `input.md` carries a `# Previous attempt` section
(why the last attempt failed) and, with `--input-file`, a `# Operator correction`
section holding only the overridden keys.
## Use an existing pipeline
+10 -7
View File
@@ -1,6 +1,6 @@
# Recover a failed run
1. Read `pipelines inspect ID --json`, the failed stage's actual input/result,
1. Read `pipelines inspect ID` (then `--step N` or `--json`), the failed stage's actual input/result,
retained tool evidence, artifacts and Git diff. A timeout is not proof of lost work.
2. Separate code failure, environment/setup failure and result-format failure.
Missing evidence is not a passing check; a failed result does not erase edits.
@@ -10,12 +10,15 @@
4. Verify the repair with a focused regression; run broader checks once relevant
inputs settle. Do not raise retry/time budgets to hide a reproducible defect.
`pipelines retry ID` resumes the failed stage; `--stage KEY [--visit N]` picks a
recorded stage, `--input-file FILE|-` merges a bounded JSON correction,
`--version N` a published version of the same pipeline, `--mode=restart` starts
at entry (say so). Only `failed` runs retry; an `interrupted` run (server stopped
mid-stage) or a `canceled` one needs a new run or direct work on its preserved
branch. Verify the retry's actual stage input, not merely its admission.
`pipelines retry ID --yes --json` resumes the failed stage; `--stage KEY [--visit N]` picks a
recorded stage, `--input-file FILE|-` merges a bounded JSON correction (shown to
the stage as `# Operator correction`), `--version N` a published version of the
same pipeline, `--mode=restart` starts at entry (say so). `failed` and
`interrupted` runs retry (an interrupted run resumes its unfinished stage or the
stage after the last completed one); a `canceled` one needs a new run or direct
work on its preserved branch. The retried stage sees a `# Previous attempt`
section with the failing stage and diagnostic. Verify the retry's actual stage
input, not merely its admission.
A clean preparation stage succeeds without an empty commit. A `land` stage with a
delivery gate succeeds with a clean checked candidate; the server lands afterward.
+21 -2
View File
@@ -91,6 +91,12 @@ Use the authoritative `CLI_PREFIX` from the prompt:
distinguishable; `CLI_PREFIX title RUN_ID "..."` renames a run after the fact
without changing its input or steps. The stored prompt is unchanged, and
listing/renaming never calls a model.
- `CLI_PREFIX inspect RUN_ID`: compact summary — a header (status, outcome,
duration, diagnostic), one line per step (stage, status, outcome, duration,
first diagnostic line), how to answer a `waiting` run and the final `# handoff`
(bounded). `--step N` prints one step in full without its transcript (add
`--transcripts` for it), `--transcripts` alone appends every transcript, and
`--json` (with `--step N`, just that step) is the complete record below.
- `CLI_PREFIX inspect RUN_ID --json`: selected run, visits and retained evidence.
Each model step carries the usage its harness reported (`usage.tokens_total`,
`tokens_in`/`tokens_out` only when `split_known`, `cost_usd` only when
@@ -105,6 +111,17 @@ Use the authoritative `CLI_PREFIX` from the prompt:
complete tool history.
- `CLI_PREFIX decide RUN_ID [STAGE] --option KEY [--feedback TEXT] [--json]`: answer
a run `waiting` on a `type=human` stage (`references/format.md`).
- Without a terminal on stdin/stdout (an agent's shell, a pipe, CI) `run` behaves
as `--json` and never opens the full-screen view, `tui` refuses, and every
confirmation fails at once naming `--yes` instead of prompting: pass
`run NAME "TASK" --json --yes` and `retry RUN_ID --yes --json`.
- `CLI_PREFIX wait RUN_ID ...`: one line per run as it finishes (a failed run's
stage and first diagnostic line); while a run waits on a human it prints
`waiting at STAGE — answer with: pipelines decide ID --option KEY` once (stderr
under `--json`). Exit status: 0 every run succeeded, 2 a run failed, was
canceled or interrupted, 1 a client error (unknown id, connection, `--timeout`
reached; the run is untouched). `run --wait` and `retry --wait` also exit 2
for an unsuccessful run.
- `CLI_PREFIX run ... --json --wait --wait-timeout DURATION`: `--wait` polls until
terminal and `--wait-timeout` bounds only the client wait after admission,
independent of per-request `--timeout`. A reached wait limit leaves the admitted run
@@ -267,8 +284,10 @@ assistant message with the same bounded readback as the final result, so a small
final result is visible behind large prior tool content. Inspect the retained
session itself when a preview is bounded or omitted; never assume a complete tool
history from a preview.
Retry is allowed only for a `failed` run after cleanup stops (`interrupted` and
`canceled` runs need a new run). It creates a new linked run with the original
Retry is allowed for a `failed` or `interrupted` run after cleanup stops
(`canceled` runs need a new run); an interrupted run resumes its unfinished
stage, or the stage after its last completed one, and refuses resume (pointing
to `--mode=restart`) when neither is safe. It creates a new linked run with the original
input, directory, pinned version, edit scope and overrides. The default `resume`
mode restarts the failed stage (or `--stage`/`--visit`) with the completed
prefix's handoff and `public/` files; `--mode=restart` starts at entry;
@@ -39,7 +39,7 @@ and costs as agreed.
## Recovery and landing
Inspect `pipelines inspect ID --json` and actual files after failure. Preserve
Read `pipelines inspect ID` (`--step N`/`--json` for detail) and actual files after failure. Preserve
partial changes. Prefer resuming the original stage with corrected input or fixing
and merging directly; do not repeat completed work or add a merger pipeline.
For delivery=true, return a clean checked candidate and let the server land it.