[terminal-stylist] Terminal Stylist Audit — Console Output Consistency Analysis #28253
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #28446. |
Beta Was this translation helpful? Give feedback.
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
This report covers a systematic analysis of console output patterns across all non-test Go source files in
pkg/andcmd/. The codebase has a well-designed console infrastructure built on the Charmbracelet ecosystem (Lipgloss v2 + Huh v2), and the majority of CLI output follows the established conventions. A small number of files contain rawfmt.Print*calls that bypass theconsoleformatting package.Summary
pkg/cli/diagnostic outputpkg/workflow/outputStrengths
Lipgloss Usage
pkg/styles/theme.godefines a centralized Dracula-inspired palette usingcompat.AdaptiveColor— both light and dark variants for every semantic color (error, warning, success, info, purple, yellow, comment, foreground). This is a textbook Lipgloss best practice.pkg/console/console.gowraps everylipgloss.Style.Render()call behindapplyStyle(), which short-circuits styling when stdout is not a TTY. This ensures ANSI codes don't pollute piped output.pkg/console/spinner.gocorrectly checkstty.IsStderrTerminal()before starting the spinner animation.Huh Forms
pkg/console/confirm.go,pkg/console/list.go,pkg/console/input.goall usehuh.NewForm()withstyles.HuhThemeand.WithAccessible(IsAccessibleMode())— proper accessible mode support.pkg/console/list.goimplements a graceful non-TTY fallback (showTextList) for use in CI/pipe contexts.pkg/cli/engine_secrets.gouseshuh.NewForm()for secret entry withEchoModePasswordmasking — good security practice.HuhThemeinpkg/styles/huh_theme.gomaps the Dracula palette intohuh.ThemeBase(), providing consistent visual identity across interactive prompts.Console Package API
Rich set of formatters all returning styled strings for use with
fmt.Fprintln(os.Stderr, ...):FormatSuccessMessage,FormatInfoMessage,FormatWarningMessage,FormatErrorMessageFormatCommandMessage,FormatProgressMessage,FormatPromptMessage,FormatVerboseMessageFormatListItem,FormatSectionHeader,FormatLocationMessage,FormatCountMessageFormatError(Rust-like compiler error with context lines)NewSpinnerwith TTY detectionIssues Found
🔴 3 files with missing console formatting (click to expand)
pkg/cli/compile_file_operations.go(lines 113, 213)Recommended fix:
pkg/cli/deps_security.go(lines 97–128)Security advisory output is rendered with raw
fmt.Fprintf/fmt.Fprintlncalls that manually format severity headers and content. The header at line 109 builds its ownicon + severityprefix inline, bypassing the console package entirely.Recommended fix: Use
console.FormatWarningMessage()/console.FormatErrorMessage()for the header based on severity, andconsole.FormatListItem()orconsole.FormatVerboseMessage()for advisory detail lines.pkg/cli/copilot_setup.go(lines 269–292)Introductory instruction text is output with raw
fmt.Fprintln(os.Stderr, ...)withoutconsole.FormatInfoMessage:Note: The YAML snippet lines (
- name: ...,uses: ...,run: |) should remain unformatted for copy-paste fidelity. Only the instructional prose needs styling.Recommended fix: Wrap the two prose lines with
console.FormatInfoMessage().🟡 Minor: Empty-line blank writes (low priority)
Several files (
deps_outdated.go,update_container_pins.go,audit_cross_run_render.go) usefmt.Fprintln(os.Stderr, "")orfmt.Fprintln(os.Stderr)to emit blank lines for visual spacing. These work correctly and don't require console formatting — blank lines have no semantic content. However, they could optionally be replaced with a sharedconsole.PrintBlankLine()helper if consistent vertical rhythm becomes a priority.Correctly Handled Patterns
Structured output to stdout ✅
pkg/cli/audit_cross_run_render.goandpkg/cli/audit_diff_render.gousefmt.Println/fmt.Printfto write markdown report content to stdout. This is intentional and correct per Unix conventions — structured data (markdown reports, JSON, hashes) goes to stdout for piping/redirection. No console formatting should be applied here.pkg/workflow/compiler messages ✅pkg/workflow/compiler.go,compiler_validators.go, andagent_validation.gouse a localformatCompilerMessage()function that produces IDE-parseablefile:line:col: type: messageoutput, consistent with the Rust-like rendering inpkg/console/console.go'sFormatError(). This is appropriate and separate from CLI diagnostic output.pkg/cli/hash_command.go✅fmt.Println(hash)correctly writes a hash value to stdout for piping — no console formatting needed.Recommendations
High Priority
compile_file_operations.go— Applyconsole.FormatErrorMessage()andconsole.FormatInfoMessage()to the two raw stderr calls (easy win, high visibility).deps_security.go— Replace the manual severity header construction withconsole.FormatWarningMessage()/console.FormatErrorMessage(), and useconsole.FormatListItem()for advisory detail lines. This is the most visible gap.copilot_setup.go— Wrap the two prose instruction lines withconsole.FormatInfoMessage().Low Priority / Optional
console.PrintBlankLine()helper to unify vertical spacing across files using emptyfmt.Fprintln(os.Stderr).pkg/console/terminal.gowelcome banner (lines 43–45) uses rawfmt.Fprintln(os.Stderr, ...)without console formatting — consider usingFormatSectionHeaderandFormatInfoMessagefor the welcome text.Charmbracelet Ecosystem Assessment
The codebase makes excellent use of the Charmbracelet ecosystem. The three small issues above are the only notable gaps in an otherwise well-structured console output system.
References: §24888400961
Beta Was this translation helpful? Give feedback.
All reactions