Repository navigation
[terminal-stylist] Terminal output consistency audit for Go CLI code #73156
Closed
Replies: 1 comment
|
This discussion was automatically closed because it expired on 2026-10-31T08:49:50.575Z.
|
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
A static AST scan covered all 1,818 non-test Go files, including 1,798 files under
pkg/. The review focused on directfmt.Print*output,pkg/console, Lipgloss, Huh, error presentation, TTY behavior, and accessibility. Serena semantic analysis was active; diagnostics for the central console, prompt-form, and Huh-theme files were clean.The overall foundation is strong: terminal styling is centralized, adaptive light/dark colors are defined once, ANSI color output is gated by TTY and color-profile handling, and Huh forms consistently inherit theme and accessibility settings. The main opportunities are in several large renderers that mix structured console helpers with raw
fmt.Fprintfoutput.Key metrics
pkg/console.*call expressions underpkg/pkg/pkg/fmt.Fprint*calls to stdout/stderr underpkg/console.*formatterThe remaining raw calls are not automatically defects. Many intentionally emit JSON, generated snippets, tables, reports, or subprocess output. They identify where future consistency work has the highest leverage.
What is working well
pkg/console/console.gochecks stdout/stderr independently and degrades Lipgloss output through the color-profile writer, honoringNO_COLOR,COLORTERM, andTERM.pkg/styles/theme.gosupplies semantic light/dark colors and reusable styles for errors, warnings, success, tables, borders, commands, and calendar intensity.pkg/console/prompt_form.goappliesstyles.HuhTheme, enables Huh accessible mode, requires stdin and stderr TTYs, and avoids cursor-clearing behavior in accessible mode.pkg/cli/interactive.gogroups related fields into configuration, capabilities, security, and instructions pages. Required free-text fields use validation.pkg/cli/compile_schedule_calendar.gosuppresses styled cells outside terminals and in accessible mode.pkg/console/prompt_form.goandpkg/console/terminal.go, where Lipgloss has no equivalent, and are protected by TTY checks.console.RenderTable,console.RenderStruct, section headers, message formatters, spinners, confirms, and list selection already cover most CLI needs.Priority findings
Do not embed terminal styling in returned errors.
pkg/cli/env_command.go:215constructs an error witherrors.New(console.FormatErrorMessage(err.Error())).FormatErrorMessageonly at the final output boundary.Standardize the dependency report renderer.
pkg/cli/deps_report.go:104-180mixes formatted headings with manual box-drawing separators, raw labels, and hard-coded status emoji.FormatSectionHeader,RenderStruct, andRenderTable; route recommendations through warning/error/success helpers. This will improve redirected output, alignment, and visual consistency.Avoid Markdown syntax in terminal-only output.
pkg/cli/mcp_inspect_mcp.go:519-591prints literal**Name:**labels and fenced code blocks to stderr. Standard terminals do not render Markdown, so users see the asterisks and backticks.RenderStructor a two-column table and print schemas with an indented plain-text block. Reserve Markdown for file/report output modes.Avoid duplicate semantic icons.
console.FormatSuccessMessagealready adds✓, while several MCP inspection calls pass messages beginning with✅.RenderErrorBox/error formatters similarly receive messages beginning with❌.Consolidate mixed print APIs in large renderers.
pkg/cli/audit_diff_render.go,pkg/cli/audit_report_render.go,pkg/cli/mcp_inspect_mcp.go,pkg/cli/experiments_analyze_statistics.go, andpkg/cli/audit_cross_run_render.go.console.Print*,fmt.Fprintln, manual spacing, and manual column construction.strings.Builder,RenderTable, orRenderStruct, then write it once through a destination-aware console API. This reduces partial lines and makes stdout/stderr policy easier to review.Lipgloss assessment
Detailed Lipgloss findings
pkg/stylesinstead of being recreated throughout commands.lipgloss.LightDarkper render..Width()are safe in redirected output because they do not add color escapes.console.RenderTableshould remain the preferred table path instead of introducing directlipgloss/tableusage in command packages.Huh assessment
Detailed Huh findings
console.NewFormor its input/select/confirm wrappers, providing one accessibility and theme policy.console.IsCancelledhelper.Suggested implementation order
pkg/cli/env_command.go.pkg/cli/mcp_inspect_mcp.goto terminal-native labels and schema blocks, and remove duplicate icons.pkg/cli/deps_report.goto existing section/table/struct renderers.errors.New(console.Format...)and duplicate semantic icon prefixes.References:
All reactions