Skip to content

SPEC-007: CLI

  • Status: Implemented
  • Milestone: M2 (doctor extended M5)
  • Owners: lead maintainer

1. Purpose

Commands users run: play, check, env list, doctor (and --runs N in M5). Errors name the file, field and next step.

2. Terms

  • Exit code: 0 success (the run ended and its log was written, whatever the result), 1 run problem (world_error or aborted), 2 usage or scenario error, 3 environment problem.

3. Requirements

  • CLI-001 The command MUST be agentplaykit (also python -m agentplaykit); --version prints the version.
  • CLI-002 agentplaykit play <scenario> [--seed N] [--out PATH] [--max-steps N] [--max-cost USD] [--runs N] MUST run the scenario and write the log. With no arguments it runs a built-in demo needing no API key.
  • CLI-003 agentplaykit check <scenario> MUST validate the scenario and report all problems (not just the first), without importing plugin code and without network access.
  • CLI-004 agentplaykit env list MUST list registered worlds with source and description (REG-007).
  • CLI-005 agentplaykit doctor MUST check Python version, dependencies and optional extras, API key variables set (never printing values), write access to the log directory, and print a pass/fail line with the fix for each.
  • CLI-006 Exit codes MUST follow the Terms above and be documented in --help.
  • CLI-007 An error MUST print on stderr as error: <what> (<file>:<field>) -> <fix>; stack traces appear only with --debug.
  • CLI-008 Flags MUST override scenario values and the log MUST record the effective values.
  • CLI-009 agentplaykit test <plugin.py> [--world NAME] [--seeds N] SHOULD check every public Environment and Agent subclass in the file without changing it: worlds against the SPEC-001 rules, determinism under seeds and log validity; agents for reply shape, capabilities and determinism while playing --world (default blank). It prints one line per check, ok or FAIL, with the requirement ID, and exits 0 only if every check passes.
  • CLI-011 With --runs N (N > 1), --out MUST name a directory for the logs and summary (default runs/), and play MUST print the summary table (EVL-007, EVL-014).
  • CLI-012 When its output is piped into a program that stops reading early (for example head), a command MUST exit with code 1 and no traceback.
  • CLI-013 agentplaykit view <log.jsonl | summary.json> [--out PATH] [--no-open] [--live] MUST behave as SPEC-012 VWR-001 to VWR-003 and VWR-019; agentplaykit play MUST accept --live and --no-open (VWR-019, VWR-022).
  • CLI-014 agentplaykit report <path>... [--out DIR] [--no-open] [--no-pages] MUST behave as SPEC-013 RPT-008, RPT-009 and RPT-019; agentplaykit play on a tournament scenario MUST behave as RPT-004 to RPT-007.
  • CLI-015 agentplaykit sandbox prune MUST behave as SPEC-014 SBX-018, and doctor MUST report the container runtime as SBX-017 describes, without failing when there is none (sandbox worlds are optional).
  • CLI-010 Output MUST work without color or TTY; color is optional.

4. Acceptance criteria

Requirement Test ID Notes
CLI-001..004 CLI-001..CLI-004
CLI-005..008 CLI-005..CLI-008 error messages pinned by stored text
CLI-009..010 CLI-009, CLI-010

5. Examples

error: unknown world "tic-tac-tow" (scenario.yaml:world.use) -> did you mean "tic-tac-toe"? run `agentplaykit env list`

6. Change log

  • 2026-11-30: Initial draft.
  • 2026-11-30: Accepted by the lead maintainer.
  • 2026-11-30: Clarified that forfeits and limit stops exit 0, since the run completed.
  • 2026-11-30: CLI-009 detailed (--world, --seeds, output); added CLI-011 (--runs output).
  • 2026-11-30: Implemented in v0.1.0; every requirement has a test (PRO-004, PRO-011).
  • 2026-11-30: Added CLI-012 (closed output pipe), from v0.1.0 testing.
  • 2026-11-30: The reference world ox is renamed tic-tac-toe (ADR-0006); no alias.
  • 2026-12-01: Added CLI-013 (view, --live, --no-open), with SPEC-012.
  • 2026-12-01: Added CLI-014 (report, tournaments), with SPEC-013.
  • 2026-12-01: Added CLI-015 (sandbox prune, doctor runtime lines), with SPEC-014.