[terminal-stylist] Console Output Style Analysis — pkg/ Codebase #37792
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #38079. |
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 analyzes console output patterns across 891 non-test Go source files in
pkg/, with focus on thepkg/cli/layer (315 files). The codebase uses the Charmbracelet v2 ecosystem:lipgloss/v2,huh/v2,bubbletea/v2, andbubbles/v2.Overall verdict: The foundational architecture (
pkg/console,pkg/styles) is well-designed and comprehensive. Adoption inconsistencies inpkg/cli/are the primary area for improvement — 145 of 315 cli files (46%) emit rawfmt.Fprintf(os.Stderr, ...)calls that bypass the console styling layer.Key Metrics
.gosource files inpkg/pkg/cli/pkg/cli/files importingpkg/consolefmt.Fprintf/Fprintlnto stderr (cli)Lipgloss Usage Analysis
✅ Strengths
pkg/styles/theme.godefines a complete Dracula-inspired palette withcompat.AdaptiveColorfor automatic light/dark adaptation. All 11 semantic colors (ColorError,ColorWarning,ColorSuccess,ColorInfo,ColorPurple,ColorYellow,ColorComment,ColorForeground,ColorBackground,ColorBorder,ColorTableAltRow) use the proper{Light: ..., Dark: ...}form.TTY detection is centralized:
console.go::applyStyle()gates all styling behindisTTY()(backed bytty.IsStdoutTerminal()), which prevents ANSI codes from leaking into redirected output.Table rendering (
console.RenderTable) useslipgloss/tablewith a per-cellstyleFuncthat returnslipgloss.NewStyle()(no styling) in non-TTY mode — correct pattern.Rich layout components in
console.go:RenderTitleBox,RenderErrorBox,RenderInfoSection, andRenderComposedSectionsall have TTY-aware fallbacks to plain-text alternatives.mcp_inspect.gocorrectly usescharm.land/lipgloss/v2/tree(the Lipgloss tree component) for hierarchical tool/resource output.compile_schedule_calendar.gousesintensityStyle()creating custom styles withstyles.Color*constants — no hardcoded hex values, proper delegation to the styles package.ANSI escape sequences in
terminal.goANSI sequences used for spinner/cursor management are properly isolated in named constants:
These are only used internally by
spinner.goandterminal.go— not scattered across the codebase. ✅compile_schedule_calendar.go::intensityStyle()creates a newlipgloss.NewStyle()on every call. Consider caching these as package-level vars inpkg/styles— e.g.,styles.IntensityLow,styles.IntensityMedium, etc.console.go::RenderTitleBoxandRenderErrorBoxcreate anonymous inlinelipgloss.NewStyle()calls.styles.ErrorBoxalready exists inpkg/stylesand could be referenced for DRY consistency.Huh Form Usage Analysis
✅ Strengths — Excellent Consistency
All 14+ huh form instances across the codebase apply the same consistent pattern:
Files following this pattern:
add_interactive_auth.go,add_interactive_engine.go,add_interactive_git.go,add_interactive_orchestrator.go,add_interactive_schedule.go,add_interactive_workflow.go,run_interactive.go,engine_secrets.go,interactive.go,console/confirm.go,console/input.go,console/list.go.IsAccessibleMode()checksACCESSIBLE,TERM=dumb, andNO_COLOR— solid multi-signal accessibility detection.HuhThemeinpkg/styles/huh_theme.gouseslipgloss.LightDark(isDark)(Lipgloss v2 API) to map the pkg/styles Dracula palette to all huh field states (focused/blurred, selected/unselected, error, navigation indicators, text cursor).Field type variety
huh.NewConfirm()console/confirm.go,add_interactive_workflow.gohuh.NewSelect[T]()add_interactive_schedule.go,add_interactive_git.go,run_interactive.go,console/list.gohuh.NewInput()withEchoModePasswordconsole/input.gohuh.NewInput()(text)add_interactive_git.gorun_interactive.go(dynamic[]*huh.Groupslice)Password masking (
EchoMode(huh.EchoModePassword)) is used inconsole/input.gofor secret entry — correct security practice. ✅console/confirm.godoes not check TTY before creating the huh form, unlikeconsole/list.gowhich guards withtty.IsStderrTerminal(). A non-TTY environment callingConfirmActionwill attempt interactive rendering.run_interactive.gobuilds dynamic[]*huh.Groupslices for multi-step workflows. Consider adding field-level validation where inputs have clear constraints.Console Package Coverage Analysis
✅ Well-Designed Abstraction
pkg/consoleprovides a comprehensive set of format helpers covering all common message types (error chain, success, info, warning, command, progress, verbose, list, section header, table, struct reflection, title/error/info boxes).❌ Raw Output Bypassing Console (145 of 315 cli files)
579 raw
fmt.Fprintf(os.Stderr, ...)/fmt.Fprintln(os.Stderr, ...)calls inpkg/clido not use the console package. Key patterns:Pattern 1 — Unstyled user-facing messages (most impactful)
Better expressed as
console.FormatProgressMessage/console.FormatVerboseMessage/console.LogVerbose.Pattern 2 — Manual list formatting (
fix_command.go: 35 raw calls alongside 21 console calls)console.FormatListItem(codemodName)already exists for this purpose.Pattern 3 — Manual separators (
actionlint.go)console.FormatSectionHeader()orconsole.RenderTitleBox()exist for this pattern.Pattern 4 — Instruction text without styling (
trial_confirmation.go,add_interactive_auth.go)console.RenderInfoSection()provides the proper left-border callout styling for instructional blocks.Files with highest raw fmt stderr usage
fix_command.goadd_interactive_git.goadd_interactive_workflow.goupdate_container_pins.goupdate_actions.goactionlint.gotrial_confirmation.goRecommendations
High Impact
Replace unstyled progress/status messages in
add_interactive_workflow.gowithconsole.FormatProgressMessage/console.LogVerbose(verbose, ...)— improves visual consistency for the most user-visible interactive flow.Replace manual bullet points in
fix_command.gowithconsole.FormatListItem()— the function exists and is already used elsewhere in the same file.Replace manual separators in
actionlint.gowithconsole.FormatSectionHeader()orconsole.RenderTitleBox()— eliminates the hardcodedstrings.Repeat("━", 60).Medium Impact
Add TTY guard to
console/confirm.gomatching the pattern inconsole/list.go— prevents huh from attempting interactive rendering in non-TTY environments.Replace plain instruction text blocks in
trial_confirmation.goandadd_interactive_auth.gowithconsole.RenderInfoSection()for consistent left-border callout styling.vscode_config.go:fmt.Fprintf(os.Stderr, "Settings file already exists at %s\n", settingsPath)→console.FormatInfoMessage().Low Impact / Cleanup
Cache
intensityStyle()variants inpkg/stylesas pre-configured vars to avoid style allocation on every calendar render call.RenderTitleBox/RenderErrorBoxinconsole.gocreate inline lipgloss styles — reference the existingstyles.ErrorBoxvar for DRY consistency.References: §27130449179
Beta Was this translation helpful? Give feedback.
All reactions