---
id: TASK-28
title: Fix normal-verbosity error coloring leaking into subprocess output
status: Done
assignee:
  - codex
created_date: '2026-03-04 07:09'
updated_date: '2026-03-04 21:06'
labels: []
dependencies: []
references:
  - src/core/exec.rs
  - src/core/log.rs
  - src/core/cmd.rs
  - src/main.rs
  - src/core/cli.rs
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
In normal verbosity (default), when a command fails, kaze prints its own error line in red as expected, but it also colors the underlying command’s stdout/stderr output red. The subprocess output should retain its original coloring (including any ANSI colors) and should not be recolored by kaze. Quiet (-v) and very verbose (-vvv) currently behave correctly and must remain unchanged. Repro: run a failing build (e.g., `kaze build` in a Zephyr project) and observe subprocess output is red when failure occurs.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 In normal verbosity (default, verbose=2), on a failing command, kaze’s own error line is red, but the subprocess stdout/stderr is not recolored by kaze and preserves any original ANSI coloring.
- [x] #2 Quiet verbosity (-v, verbose=1) remains unchanged (no subprocess output, same behavior as before).
- [x] #3 Very verbose (-vvv, verbose>=3) remains unchanged (subprocess output preserves its original coloring).
- [x] #4 Add/adjust tests to cover the normal-verbosity failure path so that subprocess output is not forced to red when kaze reports an error.
- [x] #5 If this is considered a user-facing behavior change, update `CHANGELOG.md` accordingly.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1) Inspect normal-verbosity (verbose=2) failure path in src/core/exec.rs to locate where subprocess output is captured/printed and where red color spec is applied.
2) Review src/core/log.rs and shared output helpers for color reset behavior that might leak red state into subsequent writes.
3) Change the failure reporting path so only kaze’s own error line is colored red; ensure subprocess stdout/stderr is written without forcing red and with a color reset before/after as needed.
4) Add/adjust tests in src/core/exec.rs for verbose=2 failure output so subprocess output is not forced to red, while quiet/very-verbose behaviors stay unchanged.
5) Update CHANGELOG.md if the behavior change is considered user-facing.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Updated verbose=2 failure path to write raw stdout/stderr bytes (no forced red); removed write_red_bytes helper and added write_raw_bytes test. Added Unreleased changelog entry. Tests not run in this session.

Ran `just check -- -D warnings` (passes).

Ran `just check -- -D warnings` (passes) after fixing clippy pattern_type_mismatch in cmd workspace helpers.
<!-- SECTION:NOTES:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Changed the verbose=2 failure path to write subprocess stdout/stderr as raw bytes so kaze no longer forces red coloring, while keeping the red kaze error line. Removed the red-bytes helper, added a write_raw_bytes unit test, and recorded the behavior fix in the Unreleased changelog. Tests: `just check -- -D warnings`.
<!-- SECTION:FINAL_SUMMARY:END -->
