Repository navigation
[terminal-stylist] Terminal output consistency audit for Go sources #72055
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #72365. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Overview
The Go console-output audit is complete. I scanned all 1,789 non-test Go files, with 1,769 under
pkg/as the primary analysis area. Of those, 1,587 are productionpkg/files and 182 are linter fixtures undertestdata. Serena semantic analysis and gopls diagnostics were used for the core console, style, Huh, and TUI implementations; no language-server diagnostics were reported for the sampled core files.Overall, the terminal architecture is strong: user-facing status output is centralized through
pkg/console, Lipgloss styling is adaptive and TTY-aware, Huh forms share one theme/accessibility wrapper, and raw ANSI is confined to terminal-control operations. The main opportunity is finishing migration of a small set of raw warning/error and verbose diagnostic writes that bypass the console conventions.Key metrics and findings
console.*calls across 284 productionpkg/files. The dominant APIs areFormatInfoMessage(683),FormatWarningMessage(572),FormatSuccessMessage(234), andFormatVerboseMessage(80).fmt.Print,fmt.Printf, orfmt.Printlncalls were found inpkg/. The three textual matches are documentation examples inpkg/styles/theme.go.pkg/console,pkg/styles, the logger, schedule rendering, secret layout, and the work-queue TUI.console.NewFormor its single-field wrappers, so the shared theme and accessible mode are consistently applied.pkg/console/terminal.go,pkg/console/prompt_form.go, andpkg/stringutil/ansi.go. These uses are cursor/screen control or ANSI parsing rather than hand-coded color styling.fmt.F*writes toos.Stdout/os.Stderrremain across 276 files. Most are intentional structured reports, machine-readable output, spacing, or already wrapconsole.Format*; a smaller subset contains raw status diagnostics that should be standardized.Highest-value improvements
Standardize the remaining raw warning/error writes. These currently bypass semantic icons, adaptive color, NO_COLOR degradation, and consistent capitalization:
pkg/workflow/mcp_renderer.go:114— rawError generating custom MCP configuration...pkg/workflow/compiler_orchestrator_engine.go:302-308— uppercase rawWARNING:linespkg/workflow/push_to_pull_request_branch.go:127— rawWarning:linepkg/workflow/cache_steps.go:23— raw verbose warningpkg/cli/mcp_inspect_mcp.go:577,591— raw schema display errorsPrefer
console.PrintWarningMessage,console.PrintErrorMessage, or destination-explicitFormat*Stderrhelpers. For compiler diagnostics with file context, prefer the existingformatCompilerMessagepath.Route Claude parser diagnostics through the established verbose/debug layer.
pkg/workflow/claude_logs.go:144-321emits several unstyled verbose lines directly to stderr, while the same file already hasclaudeLogsLog. Use the namespace logger for developer diagnostics orconsole.FormatVerboseMessageStderrfor deliberate user-visible verbose output. In particular, avoid printing an entire invalid JSON line (:231) without truncation/redaction because log records can contain large or sensitive payloads.Reduce destination ambiguity in new code. The codebase has explicit stdout/stderr aliases, but many call sites still combine
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(...)). Prefer thePrint*helpers where no composition is needed, and use the*Stderrformatter names when composing multi-line reports. This makes stream intent reviewable and avoids accidentally selecting stdout TTY state for stderr output.Consider gating the startup background probe on terminal availability.
pkg/styles/theme.goskips Lipgloss background probing on Windows but otherwise probes during package initialization. Output rendering itself is correctly TTY-gated; adding an stdin/stderr terminal check beforelipgloss.HasDarkBackgroundwould make non-interactive startup behavior more explicit and avoid unnecessary terminal queries in CI and redirected execution.Patterns implemented well
pkg/console/console.gochecks destination-specific TTY state and degrades rendered ANSI through the color-profile writer, honoringNO_COLOR,COLORTERM, andTERM.pkg/styles/theme.goprovides a centralized semantic palette with light/dark variants for error, warning, success, info, borders, tables, and specialized UI elements.pkg/styles/huh_theme.gouseslipgloss.LightDarkand maps focus, selection, validation errors, buttons, placeholders, and group styling consistently.pkg/console/prompt_form.gocentralizes Huh theming, accessible mode, TTY requirements, cancellation handling, and form cleanup.pkg/cli/interactive.goorganizes the larger authoring flow into titled Huh groups, uses appropriate Select/MultiSelect/Text fields, and validates the workflow intent.pkg/cli/run_interactive.goadds validation for required dynamic workflow inputs.pkg/cli/engine_secrets.gouses masked Huh inputs with validation for tokens and API keys.pkg/cli/work_command_tui_view.gouses Lipgloss width/height calculations, responsive single/two-pane layouts, alternate-screen rendering, viewport limits, and ASCII borders that remain legible on basic terminals. Dynamic values are escaped throughworkQueueText.pkg/console/terminal.goandpkg/console/prompt_form.gois justified because Lipgloss does not provide cursor save/restore or screen-clearing primitives, and execution is TTY-gated.Library-specific recommendations
Lipgloss
pkg/styles; avoid adding one-off hardcoded colors in CLI packages.lipgloss.Widthrather than byte/rune counts for alignment. Existing usage in tables, secret layouts, and schedule rendering is correct.console.RenderTablewidth-budget path over manual padding.pkg/stylesand retain a no-color focus indicator.Huh
console.NewForm; no directhuh.NewFormconstruction was found outside that wrapper.WithAccessiblehandling is a strong baseline. Consider documenting whetherNO_COLORis intended to imply full Huh accessible mode, since color preference and screen-reader mode are related but not identical user choices.pkg/console/confirm.goandpkg/console/list.goare valuable. A shared fallback prompt abstraction could improve testability and make list input injectable like confirmation input already is.Error and status messages
%w; apply user-facing capitalization/icons only at the terminal boundary.Warning:,WARNING:, orError:when a semantic formatter is available.Recommended next actions
Warning:,WARNING:, andError:writes to stderr outside approved renderer/debug paths.References:
All reactions