UAT: format_output() color format returns plain text without ANSI codes — spec requires colored output #1827

Open
opened 2026-04-02 23:55:58 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/cli-format-output-color-ansi-codes
  • Commit Message: fix(cli): wire color format in format_output() to ColorMaterializer for ANSI output
  • Milestone: v3.5.0
  • Parent Epic: #936

Bug Report

Feature Area: CLI output formatting — color format mode

Severity: High

Parent Epic: #936 (Output Rendering Pipeline Integration)

Summary

The format_output() function in src/cleveragents/cli/formatting.py renders the color format as plain text (identical to plain format) instead of applying ANSI color codes as required by the specification.

Steps to Reproduce

from cleveragents.cli.formatting import format_output

data = {'name': 'test', 'status': 'active', 'count': 42}
result = format_output(data, 'color')
print(repr(result))
# Output: 'name: test\nstatus: active\ncount: 42'
# Expected: ANSI-colored output with bold cyan headers, bold blue keys, etc.

Or via CLI:

agents project show local/api-service --format color
# Actual: plain text, no color
# Expected: ANSI-colored output

Actual Behavior

format_output(data, 'color') returns plain text with no ANSI escape codes, identical to format_output(data, 'plain').

name: test
status: active
count: 42

Expected Behavior

Per the specification (§Output Rendering Framework / color — Colored Plain Text):

Philosophy: Same structural layout as plain, but with ANSI color codes applied to improve readability.

Rendering rules:

  • Headers/titles: Bold cyan.
  • Keys: Bold blue.
  • Values: Default color, with semantic coloring (success=green, warnings=yellow, errors=red).
  • Status prefixes: [OK] in green, [WARN] in yellow, [ERROR] in red, [INFO] in blue.

Expected output (with ANSI codes):

\033[1;36mProject Details\033[0m
  \033[1;34mName:\033[0m test
  \033[1;34mStatus:\033[0m active

Root Cause

In src/cleveragents/cli/formatting.py (line ~215):

if fmt == OutputFormat.COLOR.value:
    return _format_plain(safe_data)  # BUG: should use color renderer

The color format branch calls _format_plain() instead of a color-aware renderer. The ColorMaterializer in cleveragents.cli.output.materializers correctly renders with ANSI codes, but format_output() does not use it.

Impact

All CLI commands that use format_output() with --format color produce plain text output, making the color format indistinguishable from plain. Users who rely on --format color for readable terminal output receive no benefit over --format plain.

Code Location

  • src/cleveragents/cli/formatting.py, line ~215: _format_plain called for color format
  • src/cleveragents/cli/output/_color_renderers.py: correct color renderer exists but is not used by format_output()

Subtasks

  • Investigate format_output() in src/cleveragents/cli/formatting.py and confirm the color branch incorrectly calls _format_plain()
  • Wire the color format branch in format_output() to use ColorMaterializer (or the appropriate color renderer from cleveragents.cli.output.materializers)
  • Ensure ANSI codes are applied per spec: bold cyan headers, bold blue keys, semantic value coloring (green/yellow/red), status prefix coloring
  • Write Behave scenario: format_output(data, 'color') returns output containing ANSI escape codes
  • Write Behave scenario: format_output(data, 'color') applies bold cyan to headers/titles
  • Write Behave scenario: format_output(data, 'color') applies bold blue to keys
  • Write Behave scenario: format_output(data, 'color') applies semantic coloring to status values
  • Write Behave scenario: format_output(data, 'plain') is unaffected and still returns plain text (regression guard)
  • Run nox -s typecheck — verify Pyright passes with no # type: ignore suppressions
  • Run nox -s unit_tests — verify all Behave scenarios pass
  • Run nox -s coverage_report — verify coverage ≥ 97%
  • Run nox (all default sessions), fix any errors

Definition of Done

  • All subtasks above are completed and checked off.
  • format_output(data, 'color') produces ANSI-colored output matching the spec rendering rules.
  • format_output(data, 'plain') is unaffected (no regression).
  • No # type: ignore or type-suppression comments introduced.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage >= 97%.

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/cli-format-output-color-ansi-codes` - **Commit Message**: `fix(cli): wire color format in format_output() to ColorMaterializer for ANSI output` - **Milestone**: v3.5.0 - **Parent Epic**: #936 ## Bug Report **Feature Area:** CLI output formatting — `color` format mode **Severity:** High **Parent Epic:** #936 (Output Rendering Pipeline Integration) ### Summary The `format_output()` function in `src/cleveragents/cli/formatting.py` renders the `color` format as plain text (identical to `plain` format) instead of applying ANSI color codes as required by the specification. ### Steps to Reproduce ```python from cleveragents.cli.formatting import format_output data = {'name': 'test', 'status': 'active', 'count': 42} result = format_output(data, 'color') print(repr(result)) # Output: 'name: test\nstatus: active\ncount: 42' # Expected: ANSI-colored output with bold cyan headers, bold blue keys, etc. ``` Or via CLI: ```bash agents project show local/api-service --format color # Actual: plain text, no color # Expected: ANSI-colored output ``` ### Actual Behavior `format_output(data, 'color')` returns plain text with no ANSI escape codes, identical to `format_output(data, 'plain')`. ``` name: test status: active count: 42 ``` ### Expected Behavior Per the specification (§Output Rendering Framework / `color` — Colored Plain Text): > **Philosophy**: Same structural layout as `plain`, but with ANSI color codes applied to improve readability. > > **Rendering rules**: > - **Headers/titles**: Bold cyan. > - **Keys**: Bold blue. > - **Values**: Default color, with semantic coloring (success=green, warnings=yellow, errors=red). > - **Status prefixes**: `[OK]` in green, `[WARN]` in yellow, `[ERROR]` in red, `[INFO]` in blue. Expected output (with ANSI codes): ``` \033[1;36mProject Details\033[0m \033[1;34mName:\033[0m test \033[1;34mStatus:\033[0m active ``` ### Root Cause In `src/cleveragents/cli/formatting.py` (line ~215): ```python if fmt == OutputFormat.COLOR.value: return _format_plain(safe_data) # BUG: should use color renderer ``` The `color` format branch calls `_format_plain()` instead of a color-aware renderer. The `ColorMaterializer` in `cleveragents.cli.output.materializers` correctly renders with ANSI codes, but `format_output()` does not use it. ### Impact All CLI commands that use `format_output()` with `--format color` produce plain text output, making the `color` format indistinguishable from `plain`. Users who rely on `--format color` for readable terminal output receive no benefit over `--format plain`. ### Code Location - `src/cleveragents/cli/formatting.py`, line ~215: `_format_plain` called for `color` format - `src/cleveragents/cli/output/_color_renderers.py`: correct color renderer exists but is not used by `format_output()` ## Subtasks - [ ] Investigate `format_output()` in `src/cleveragents/cli/formatting.py` and confirm the `color` branch incorrectly calls `_format_plain()` - [ ] Wire the `color` format branch in `format_output()` to use `ColorMaterializer` (or the appropriate color renderer from `cleveragents.cli.output.materializers`) - [ ] Ensure ANSI codes are applied per spec: bold cyan headers, bold blue keys, semantic value coloring (green/yellow/red), status prefix coloring - [ ] Write Behave scenario: `format_output(data, 'color')` returns output containing ANSI escape codes - [ ] Write Behave scenario: `format_output(data, 'color')` applies bold cyan to headers/titles - [ ] Write Behave scenario: `format_output(data, 'color')` applies bold blue to keys - [ ] Write Behave scenario: `format_output(data, 'color')` applies semantic coloring to status values - [ ] Write Behave scenario: `format_output(data, 'plain')` is unaffected and still returns plain text (regression guard) - [ ] Run `nox -s typecheck` — verify Pyright passes with no `# type: ignore` suppressions - [ ] Run `nox -s unit_tests` — verify all Behave scenarios pass - [ ] Run `nox -s coverage_report` — verify coverage ≥ 97% - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done - [ ] All subtasks above are completed and checked off. - [ ] `format_output(data, 'color')` produces ANSI-colored output matching the spec rendering rules. - [ ] `format_output(data, 'plain')` is unaffected (no regression). - [ ] No `# type: ignore` or type-suppression comments introduced. - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - [ ] All nox stages pass. - [ ] Coverage >= 97%. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.5.0 milestone 2026-04-02 23:56:24 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Should Have — bug or spec compliance issue.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Should Have — bug or spec compliance issue. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Should Have — bug or error handling improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Should Have — bug or error handling improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#1827
No description provided.