[terminal-stylist] Terminal Stylist: Console Output Analysis (Lipgloss/Huh consistency) #54768
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #55050. |
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.
Summary
Scanned all non-test
.gofiles underpkg/for console output patterns (fmt.Print*,console.*, Lipgloss, Huh). Overall the codebase shows strong, consistent adoption of the Charmbracelet ecosystem via a well-designed internal abstraction layer.Architecture found
pkg/styles— centralizes all color/style definitions usingcharm.land/lipgloss/v2, with adaptive colors (lipgloss.AdaptiveColor-style Light/Dark pairs) for every semantic color (Error, Warning, Success, Info, Purple, Yellow, Comment, Foreground, Background, Border). Well documented with usage examples and design rationale (Dracula-inspired dark theme, WCAG-minded light theme).pkg/console— the single source of truth for terminal I/O (257 files reference it). Provides:FormatInfoMessage/FormatErrorMessage/FormatWarningMessage/FormatSuccessMessage,RenderStruct(table rendering vialipgloss/table),NewSpinner(Bubble Tea + lipgloss, TTY-aware),confirm.go/input.go/list.go/prompt_form.go(Huh-based forms), and WASM no-op stubs (*_wasm.go) for browser builds.console.IsAccessibleMode()centrally checksACCESSIBLE,TERM=dumb, andNO_COLOR, and is respected by spinners/animations — a solid, DRY accessibility gate.pkg/cli/add_interactive_*.go,run_interactive.go,engine_secrets.go,bootstrap_profile_*.gofor structured multi-field prompts, themed viapkg/styles/huh_theme.go.fmt.Print* usage (24 hits, non-test)
Nearly all are legitimate:
pkg/linters/.../testdata/) intentionally demonstrating bad patterns for lint tests — out of scope, not real output code.pkg/cli/status_command.go:295,pkg/cli/view_command.go:168) callfmt.Print(console.RenderStruct(...))/fmt.Print(output)to emit a string that was already fully rendered by the console package (table/timeline). This is an accepted, minimal pattern — no direct styling bypass.fmt.Println("some message")calls were found bypassingconsole.Format*Messagein production code.Raw ANSI / manual escape sequences
Only two intentional occurrences, both are the correct abstraction boundary rather than ad-hoc misuse:
pkg/console/terminal.go— low-level terminal capability code (expected).pkg/stringutil/ansi.go— ANSI stripping/sanitization utility (expected, not styling).No files were found manually embedding
\x1b[...]codes for coloring in place of Lipgloss.TTY detection
TTY/
IsTerminalchecks are correctly centralized inpkg/styles/theme.go,pkg/tty/tty.go, plus targeted checks inpkg/workflow/mcp_scripts_generator.goandpkg/cli/compile_update_check.go— no evidence of missing TTY guards causing raw ANSI in piped output.Table rendering
lipgloss/tableusage is centralized inpkg/console/console.go(RenderStruct), so all tabular CLI output (e.g.status_command.go) goes through one code path — good consistency, no duplicated manual column-alignment logic found elsewhere.Recommendations
docs/code-comment note inpkg/console/README.md(if not already present) explicitly stating "always useconsole.Format*Message, never rawfmt.Print*, for user-facing output" to make the convention discoverable for new contributors.pkg/linters/, consistent with existing custom analyzers) to flag newfmt.Println/fmt.Printcalls inpkg/cli/**.gooutside the two accepted "already-rendered string" call sites, to keep this consistency automatically enforced going forward.No code changes were made; this is an analysis-only report.
All reactions