Cover the list branches in _format_rich() and _format_color() that were
left untested, causing the coverage gate to drop below the 97% threshold.
Add two new @when steps (list+rich, list+color), two @then steps for list
panel assertions, and two new feature scenarios exercising those paths.
ISSUES CLOSED: #2921
Issue #4364 is now resolved by the envelope pattern introduced on master.
The scenario "Format output handles all format types for dict" passes
correctly — the TDD inversion was flipping it to a failure.
ISSUES CLOSED: #4364
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