The format_output() function in src/cleveragents/cli/formatting.py had two
routing bugs that caused incorrect output for the 'rich' and 'color' formats:
1. The 'rich' format had no explicit dispatch branch and silently fell through
to the final JSON fallback, returning raw JSON instead of styled terminal
output. Since 'rich' is the default CLI format (per ADR-021), this meant
all commands using format_output() (version, info, diagnostics) produced
JSON by default.
2. The 'color' format was incorrectly routed to _format_plain() instead of a
color-aware renderer, producing plain text with no ANSI color codes.
Fix:
- Added _format_rich() helper that delegates to RichMaterializer via
OutputSession, producing ANSI-styled terminal output consistent with
format_output_session().
- Added _format_color() helper that delegates to ColorMaterializer via
OutputSession, producing ANSI-colored terminal output.
- Added explicit OutputFormat.RICH dispatch in format_output() routing.
- Fixed OutputFormat.COLOR dispatch to use _format_color() instead of
_format_plain().
Tests:
- Updated existing BDD scenario that was validating the buggy behavior
(expected JSON for rich format) to now assert correct styled output.
- Added new BDD scenarios: 'rich format produces styled terminal output not
JSON' and 'color format produces ANSI-colored output not plain text'.
- Added Robot Framework integration tests in cli_formats.robot and
helper_cli_formats.py verifying end-to-end styled output for both formats.
All nox sessions pass: lint, typecheck, unit_tests, security_scan.
ISSUES CLOSED: #2921
Add `fmt: OutputFormat` parameter to `main_callback()` in
`src/cleveragents/cli/main.py` and store the selected format in
`ctx.obj["format"]` so all subcommands can read it without needing
their own per-command `--format` flag.
Remove per-command `--format` / `fmt` parameters from `version()`,
`info()`, and `diagnostics()` commands. These commands now read the
format from `ctx.obj.get("format", OutputFormat.RICH.value)`.
The specification states: "The framework supports six distinct output
formats, selectable via the global `--format` flag." This change
aligns the implementation with the spec by making `--format` a global
option on the root `agents` command (via the Typer callback).
All six formats (json, yaml, plain, rich, table, color) are supported
via the global flag and the `-f` shorthand.
Add Behave BDD scenarios covering global `--format` flag propagation
to subcommands for all six formats. Update Robot Framework integration
tests to exercise the global `--format` flag. Update existing tests
that used per-command `--format` for version/info/diagnostics to use
the global flag instead.
ISSUES CLOSED: #2908
Renames `plan lifecycle-list` to `plan list` and `plan lifecycle-apply` to `plan apply` to align with the specification's canonical command names. Removes legacy V2 plan commands that occupied those names.
- Renamed CLI command registrations from lifecycle-list/lifecycle-apply to list/apply
- Removed legacy V2 apply and list commands (~200 lines)
- Updated apply shortcut in main.py to delegate to v3 lifecycle
- Added defensive null check for plan existence in apply command
- Updated 63+ test, doc, and benchmark files for consistency
Closes#881
Co-authored-by: Jeffrey Phillips Freeman <the@jeffreyfreeman.me>
Co-committed-by: Jeffrey Phillips Freeman <the@jeffreyfreeman.me>