Skip to content

Add console.Print* stderr wrappers and migrate high-volume MCP/secrets callsites#47108

Draft
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/deep-report-add-console-print-wrappers
Draft

Add console.Print* stderr wrappers and migrate high-volume MCP/secrets callsites#47108
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/deep-report-add-console-print-wrappers

Conversation

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

pkg/console exposed Format* helpers but no direct stderr print API, which led to widespread two-step fmt.Fprintln(os.Stderr, console.Format*(...)) patterns and inconsistent output routing ergonomics. This change introduces thin Print* wrappers and migrates the two largest offenders in CLI code.

  • Console output API consolidation

    • Added new stderr-oriented wrappers in pkg/console/print.go that mirror existing Format* helpers and centralize newline + destination handling (os.Stderr).
    • Includes wrappers for success/info/warn/error/command/progress/prompt/verbose/section/list/error-chain and related stderr-specific formatters.
  • Targeted migration in highest-volume files

    • Replaced two-step formatted stderr output in:
      • pkg/cli/mcp_inspect_mcp.go
      • pkg/cli/engine_secrets.go
    • Converted both direct Fprintln(..., console.Format*) and newline-wrapped Fprintf("\n%s\n", console.Format*) patterns to console.Print* while preserving message structure.
  • Docs + usage guidance alignment

    • Updated console package docs (pkg/console/doc.go, pkg/console/README.md) to prefer Print* for diagnostic stderr output.
  • Focused wrapper coverage

    • Added pkg/console/print_test.go to assert that new Print* wrappers emit expected formatted output to stderr.
// before
fmt.Fprintln(os.Stderr, console.FormatWarningMessage("No resources available"))

// after
_, _ = console.PrintWarningMessage("No resources available")

Copilot AI and others added 2 commits July 21, 2026 15:53
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] Add console.Print wrappers to reduce stderr calls Add console.Print* stderr wrappers and migrate high-volume MCP/secrets callsites Jul 21, 2026
Copilot AI requested a review from pelikhan July 21, 2026 16:14
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category feature
Risk medium
Score 45 / 100
Action batch_review
Batch pr-batch:go-code

Score breakdown: Impact 22 · Urgency 12 · Quality 11

Draft PR adding console.Print* stderr wrappers in Go + tests + README. Medium risk (new API surface). No CI data yet. Batch with other Go code changes (see #47088).

Generated by 🔧 PR Triage Agent · sonnet46 43.3 AIC · ⌖ 5.33 AIC · ⊞ 5.6K ·

@github-actions

Copy link
Copy Markdown
Contributor

This PR looks great! 🎉 The refactor consolidates stderr output ergonomics in the console package by introducing thin Print* wrappers and migrating the two highest-volume call sites (pkg/cli/mcp_inspect_mcp.go and pkg/cli/engine_secrets.go). This aligns perfectly with the project's focus on agentic development — the work is well-focused, includes comprehensive tests, and the PR body clearly explains the what and why.

Strengths:

  • Tests includedpkg/console/print_test.go provides assertions for new Print* wrappers
  • Focused changes — one goal (centralize stderr output), targeted migrations only
  • Clear documentation — PR body includes concrete before/after example and rationale
  • Agentic origin — authored by Copilot coding agent, following the project's core contribution model

This is ready for review by core team members!

Generated by ✅ Contribution Check · sonnet46 59 AIC · ⌖ 11.2 AIC · ⊞ 6.2K ·

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.

[deep-report] Add console.Print* wrappers to eliminate 1,640 two-step stderr calls

2 participants