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
+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.