Files
cleveragents-core/robot
freemo 6e47abbd63 fix(cli): fix format_output() to use rich and color renderers instead of JSON fallback
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
2026-05-30 11:09:06 -04:00
..