[terminal-stylist] Terminal Stylist: Console Output Analysis Report #39530
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-06-17T10:28:51.686Z.
|
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
Terminal Stylist analysis of
pkg/console output patterns across 917 Go source files (excl._test.go). The codebase uses a well-structured, layered approach:pkg/styles/→pkg/console/→pkg/cli/. Library stack: Lipgloss v2.0.3 and Huh v2.0.3 (charm.land custom forks).Key Metrics
fmt.Print*usageconsole.Format*calls inpkg/cli/huh.NewForm()instances inpkg/cli/WithTheme/WithAccessiblelipgloss.Color()outsidepkg/styles/pkg/console/terminal.go✅ Strengths
Adaptive Color System
pkg/styles/theme.gousescompat.AdaptiveColorfor every color constant, with explicit Light/Dark hex variants. Color profile detection viacolorprofile.Detectis wired at init, respectingNO_COLOR,TERM, and terminal capability bits.TTY-Aware Rendering
pkg/console/console.gocentralises TTY detection inapplyStyle()— styles are only rendered whentty.IsStdoutTerminal()/tty.IsStderrTerminal()returns true, preventing ANSI codes in pipes or redirects.Consistent Huh Theming
All 17
huh.NewForm()calls inpkg/cli/append.WithTheme(styles.HuhTheme).WithAccessible(console.IsAccessibleMode()). Thepkg/console/wrappers (confirm.go,input.go,list.go) do the same. Zero exceptions found.Rich Console API
pkg/console/exposes 20+ typed format functions (FormatSuccessMessage,FormatWarningMessage,FormatInfoMessage,FormatErrorMessage,FormatCommandMessage,FormatProgressMessage,FormatListItem,FormatSectionHeader, etc.) plus structured rendering (RenderStruct,RenderTable,RenderTitleBox,RenderInfoSection).Accessibility Mode
IsAccessibleMode()checksACCESSIBLE,TERM=dumb, andNO_COLOR, and is propagated to every interactive Huh form to disable animations and simplify output.No Colour Leakage
Zero
lipgloss.Color()literals found outsidepkg/styles/andpkg/console/. All colour constants are defined once inpkg/styles/theme.goand consumed via named style objects.1. Raw
fmt.Fprintf(os.Stderr, ...)inpkg/cli/compile_stats.go(14 occurrences)compile_stats.gousesconsole.FormatErrorMessage/FormatSuccessMessagefor summary lines but falls back to rawfmt.Fprintffor the detailed error-report body and summary statistics. This breaks visual consistency — unstyled lines appear alongside styled ones in the same output block.Affected lines (representative):
Recommendation: Wrap list items with
console.FormatListItem(), applystyles.Error.Render()consistently to failure markers, and useconsole.FormatInfoMessage()for stats lines — matching the pattern already used incompile_stats.golines 158 and 220.Additionally, lines 301–302 use
styles.Error.Render()directly (bypassingconsole.*) while line 158 usesconsole.FormatErrorMessage(). Normalise toconsole.FormatErrorMessage()or a dedicated compile-error format function.2. Unstyled sub-bullets in
pkg/cli/trial_confirmation.goLines 182–183 and 199–200 emit plain execution-step sub-items directly, while the surrounding step numbers use
console.FormatInfoMessage():Lines 220 and 222 emit blank separator lines as
fmt.Fprintln(os.Stderr, ""), and there are no visual separators between execution phase sections.Recommendation: Style sub-items with
console.FormatListItem()or an indented variant. Extract the blank-line separator into a small local helper (e.g.,printBlank()) to reduce repetition.3. Unformatted messages in
vscode_config.goandmcp_config_file.govscode_config.goline 82:This is a warning-level condition;
console.FormatWarningMessage()should be used.mcp_config_file.golines 64, 108–109:These are informational user instructions that would benefit from
console.FormatInfoMessage()andconsole.FormatCommandMessage()styling to visually separate them from the JSON snippet that follows.4. Inline Lipgloss style creation in
pkg/cli/compile_schedule_calendar.gointensityStyle()at line 200 createslipgloss.Style{}andlipgloss.NewStyle()variants inline, bypassing the centralisedpkg/styles/palette:While the TTY check is correct, the colours used here should be defined as named constants in
pkg/styles/(e.g.,ColorCalendarLow,ColorCalendarMedium) so they participate in the light/dark adaptive system.5. Blank-line separator repetition
fmt.Fprintln(os.Stderr)is used as a blank-line visual separator in 20+ locations acrosscompile_stats.go,mcp_config_file.go,mcp_inspect.go,compile_schedule_calendar.go, and others. While functional, this pattern is verbose and easy to forget.pkg/console/could expose aPrintBlankLine()helper (analogous toPrintBanner()) to make intent explicit and allow future behaviour changes (e.g., suppressing blanks in non-TTY mode) without touching every call site.Lipgloss-Specific Recommendations
compat.AdaptiveColor)pkg/styles/applyStyle()colorprofile.Detectat initlipgloss.Color()outside stylesRenderTableuseslipgloss/tablewith style funccompile_schedule_calendar.gopkg/styles/with named constantsDoubleBorder,NormalBorderused inconsole.goHuh-Specific Recommendations
WithTheme(styles.HuhTheme)on all formspkg/cli/, 3/3 inpkg/console/WithAccessible(console.IsAccessibleMode())Suggestions()on text inputsinteractive.gointeractive.gohuh.Notefor long instructionsfmt.FprintfNext Actions
compile_stats.go— Replace 14 rawfmt.Fprintf(os.Stderr, ...)withconsole.FormatListItem(),console.FormatInfoMessage(), and consistentstyles.Error.Render()usage.vscode_config.go/mcp_config_file.go— Replace 3 unformatted info/warning messages withconsole.FormatWarningMessage()/console.FormatInfoMessage().compile_schedule_calendar.go— Move calendar intensity colours intopkg/styles/as adaptive colour constants.pkg/console/— Consider adding aPrintBlankLine()helper to reducefmt.Fprintln(os.Stderr)boilerplate.References:
Beta Was this translation helpful? Give feedback.
All reactions