|
| 1 | +# agent-ci reference |
| 2 | + |
| 3 | +## Contents |
| 4 | + |
| 5 | +- Machine-readable output (`--json`) |
| 6 | +- The exit-77 pause contract |
| 7 | +- Requirements rationale (Docker, install) |
| 8 | +- When to use agent-ci vs. remote CI |
| 9 | +- Command summary |
| 10 | + |
| 11 | +## Machine-readable output (`--json`) |
| 12 | + |
| 13 | +Add `--json` (or set `AGENT_CI_JSON=1`) to emit an NDJSON event stream on stdout — one JSON object per line. Use it for programmatic monitoring instead of grepping plaintext. |
| 14 | + |
| 15 | +Events: |
| 16 | + |
| 17 | +- `run.start` — carries `schemaVersion: 1` and `runId`. |
| 18 | +- `job.start`, `job.finish` — `status: passed | failed`. |
| 19 | +- `step.start`, `step.finish` — `status: passed | failed | skipped`. |
| 20 | +- `run.paused` — carries `runner` and `retry_cmd` (the exact command to resume). |
| 21 | +- `run.finish` — `status: passed | failed`. |
| 22 | +- `diagnostic` — non-fatal notices. |
| 23 | + |
| 24 | +`--json` is independent of `--quiet`. The diff renderer is auto-suppressed under `--json` so ANSI escapes don't collide with the stream. |
| 25 | + |
| 26 | +The robust agent loop: parse the stream, react to `run.paused` (fix the failure named in `runner`), then run the `retry_cmd` it carries. No plaintext parsing required. |
| 27 | + |
| 28 | +## The exit-77 pause contract |
| 29 | + |
| 30 | +When stdout is not a TTY (piped, redirected, captured by a parent process), the launcher detaches the run. The foreground process exits **77** the instant a step pauses. This frees the pipe — `| tee`, `> log.txt`, command substitution — while the container stays paused in the background, ready for `retry`. Exit 77 means "paused, awaiting retry," not "failed." |
| 31 | + |
| 32 | +## Requirements rationale |
| 33 | + |
| 34 | +- **Docker.** agent-ci executes each workflow job inside a container, the same way GitHub's runners do. Without a running Docker daemon the run cannot start. There is no degraded mode; use `greening-ci` (push and watch remote CI) instead. |
| 35 | +- **Install.** `@redwoodjs/agent-ci` is a fleet devDependency declared as `catalog:` in every repo's `package.json`, pinned in the wheelhouse `pnpm-workspace.yaml` catalog. `pnpm install` provisions it. The published package is a self-contained Node CLI (`dist/cli.js`) — it has no platform-binary dependencies and its `ssh2` native build scripts are declined in the fleet's `allowBuilds`/`allowScripts` (the CLI runs without them). |
| 36 | + |
| 37 | +## When to use agent-ci vs. remote CI |
| 38 | + |
| 39 | +| Situation | Use | |
| 40 | +| --- | --- | |
| 41 | +| Edited a workflow YAML (`.github/workflows/*.yml`) | agent-ci first — a malformed workflow fails the same locally and remotely, skipping the push/wait loop. | |
| 42 | +| Code change that only needs lint / typecheck / unit tests | `pnpm run check --all` — faster than spinning up containers for the pure-Node gates. | |
| 43 | +| Workflow does something the local scripts don't (matrix, container steps, action wiring, secrets-shaped env) | agent-ci. | |
| 44 | +| No Docker, or the failure needs an off-machine action (a deploy, a remote service) | push and use `greening-ci`. | |
| 45 | + |
| 46 | +## Command summary |
| 47 | + |
| 48 | +| Command | Purpose | |
| 49 | +| --- | --- | |
| 50 | +| `pnpm exec agent-ci run --all --pause-on-failure` | Run the branch's PR/push workflows; pause on first failure. | |
| 51 | +| `pnpm exec agent-ci run --workflow <path>` | Run a single workflow file. | |
| 52 | +| `pnpm exec agent-ci retry --name <runner>` | Resume a paused runner after a fix. | |
| 53 | +| `pnpm exec agent-ci retry --name <runner> --from-step <N>` | Resume from an earlier step. | |
| 54 | + |
| 55 | +Add `--quiet` to suppress the live renderer, `--json` for the NDJSON stream. |
0 commit comments