Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

The codebase had 46 instances of raw fmt.Println() mixing diagnostic messages with structured output, breaking Unix piping conventions. Users couldn't cleanly redirect JSON/hash output without filtering diagnostic noise.

Changes

Diagnostic output → stderr (21 instances)

  • Workflow compiler messages (stop-after resolution, skip-if configuration, cache warnings, MCP errors)
  • Engine firewall warnings
  • Claude log parser debug info
  • Version command output

Preserved stdout (11 instances)

  • JSON output (health, status, list-workflows, compile, deps-report, trial)
  • Hash output (hash command)
  • Mermaid graphs (tool-graph command)

Example

// Before: Diagnostic mixes with data
fmt.Println(console.FormatInfoMessage("Processing..."))
fmt.Println(string(jsonBytes))  // Can't cleanly pipe

// After: Separated streams
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Processing..."))
fmt.Println(string(jsonBytes))  // Clean piping: gh aw status --json | jq

Documentation: Updated AGENTS.md with output routing rules and examples.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Standardize output routing: Replace raw fmt.Println with explicit stderr routing</issue_title>
<issue_description>## Description

The codebase contains 46 instances of raw fmt.Println() calls that should be replaced with explicit fmt.Fprintln(os.Stderr, ...) for consistent output routing. Following Unix conventions, diagnostic output should go to stderr, reserving stdout for structured data (JSON).

Current Issues

  1. Inconsistent output routing - Some diagnostic messages go to stdout, others to stderr
  2. Breaks Unix conventions - Data and diagnostics are mixed
  3. Complicates piping - Users can't easily separate data from diagnostics
  4. No linter enforcement - New instances can be introduced

Files Affected

The following files contain raw fmt.Println() calls that need conversion:

  • pkg/workflow/stop_after.go - 10 instances
  • pkg/workflow/mcp_config_custom.go - 1 instance
  • pkg/workflow/engine_firewall_support.go - 3 instances
  • pkg/campaign/command.go - 3 instances (JSON output exception)
  • pkg/cli/tool_graph.go - 1 instance
  • Additional files - ~28 instances

Suggested Changes

Pattern to Replace

// ❌ Current (wrong)
fmt.Println(console.FormatWarningMessage("Warning message"))
fmt.Printf("Status: %s\n", status)

// ✅ Correct
fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Warning message"))
fmt.Fprintf(os.Stderr, "Status: %s\n", status)

Exception: JSON Output

// ✅ JSON output should go to stdout (not stderr)
fmt.Println(string(jsonBytes))  // Keep this for JSON output

Implementation Steps

  1. Identify all fmt.Println() and fmt.Printf() calls
  2. For each instance:
    • If JSON output → Keep as fmt.Println() to stdout
    • If diagnostic output → Change to fmt.Fprintln(os.Stderr, ...)
  3. Run full test suite to verify no breakage
  4. Update AGENTS.md with output routing guidelines

Success Criteria

  • All non-JSON fmt.Println() calls replaced with fmt.Fprintln(os.Stderr, ...)
  • All non-JSON fmt.Printf() calls replaced with fmt.Fprintf(os.Stderr, ...)
  • JSON output continues to go to stdout
  • All tests pass
  • AGENTS.md updated with output routing convention
  • Consider adding linter rule to prevent new instances

Priority

High - Affects consistency across entire CLI, impacts user experience when piping/redirecting output

Source

Extracted from Terminal Stylist Analysis discussion githubnext/gh-aw#12488

The analysis identified 46 instances of raw fmt.Print* calls that should be standardized for consistent output routing following Unix conventions.

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 12, 2026, 1:27 PM UTC

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…utput

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Standardize output routing by replacing fmt.Println with fmt.Fprintln Route diagnostic output to stderr, preserve structured data on stdout Jan 30, 2026
Copilot AI requested a review from pelikhan January 30, 2026 09:34
@pelikhan pelikhan marked this pull request as ready for review January 30, 2026 13:53
Copilot AI added a commit that referenced this pull request Jan 30, 2026
The version command was changed to output to stderr instead of stdout
in PR #12704, but the test was still using cmd.Output() which only
captures stdout. Changed to cmd.CombinedOutput() to capture both
stdout and stderr, fixing the test failure.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan merged commit 455b6cf into main Jan 30, 2026
50 checks passed
@pelikhan pelikhan deleted the copilot/standardize-output-routing branch January 30, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Standardize output routing: Replace raw fmt.Println with explicit stderr routing

2 participants