Terminal Stylist Analysis: Console Output Patterns in gh-aw #23683
Closed
Replies: 2 comments 1 reply
-
|
/plan |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #23875. |
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.
-
This report analyzes console output patterns across all Go source files in the
pkg/andcmd/directories ofgithub/gh-aw, evaluated against Charmbracelet ecosystem best practices.Summary
console.*formatter usagesfmt.Fprintln/fprintf(os.Stderr, …)usagesfmt.Println/Printfto stdoutOverall, the codebase demonstrates strong discipline in terminal output formatting. The vast majority of diagnostic output correctly uses
os.Stderrwith console formatting helpers, and structured data is correctly routed toos.Stdout.✅ What the Codebase Does Well
Lipgloss Integration
The
pkg/console/console.gofile is a well-designed Lipgloss v2 integration layer:applyStyle(style, text)helper that checkstty.IsStdoutTerminal()before applying styles. Raw text is returned for non-TTY environments (pipes, CI, scripts).pkg/styles/theme.go): All colors usecompat.AdaptiveColor{Light: ..., Dark: ...}pairs, automatically adapting to the user's terminal background. The palette is Dracula-inspired for dark mode and high-contrast for light mode.lipgloss/tablefor structured data:RenderTable()inconsole.gouses thecharm.land/lipgloss/v2/tablepackage with astyleFuncthat applies alternating row colors, distinct header/total row styles, and padding — all TTY-gated.RenderTitleBox,RenderErrorBox,RenderInfoSection, andRenderComposedSectionsuselipgloss.JoinVerticaland border styles with fallbacks for non-TTY output. Double-border title boxes and rounded-border error boxes provide rich visual hierarchy in terminals.FormatError()rendersCompilerErrorstructs with IDE-parseablefile:line:col: type: messageformat, source context highlighting, and^pointer underlines — styled with Lipgloss and gracefully degraded for non-TTY.pkg/cli/: All CLI commands access styling exclusively through theconsoleandstylespackages, achieving clean separation of concerns.Huh Form Implementation
The Huh integration is consistently well-structured across all 11 files using it directly:
huh.NewForm(...)call includes.WithTheme(styles.HuhTheme()).WithAccessible(console.IsAccessibleMode())— no exceptions found. This ensures visual consistency and screen-reader support.HuhTheme()inpkg/styles/huh_theme.go: Maps the shared Dracula palette to Huh's theming API usinglipgloss.AdaptiveColor. Covers focused/blurred states, select/multi-select indicators, button styles, and text input cursors.pkg/console/confirm.goandpkg/console/input.goprovide wrapper functions (ConfirmAction,PromptSecretInput) that abstract single-field forms behind clean APIs.PromptSecretInput: Correctly checkstty.IsStderrTerminal()before attempting interactive input, returning a clear error when not in a terminal.console.IsAccessibleMode()reads theACCESSIBLEenvironment variable, passed consistently to all forms.Output Routing
The codebase correctly separates:
os.Stderrwith console formatting (FormatSuccessMessage,FormatErrorMessage, etc.)os.Stdoutviafmt.Println/Printf1. Markdown Report Renderers Using Raw
fmt.Printfto Stdoutaudit_cross_run_render.go(66 calls) andaudit_diff_render.go(35 calls) render markdown tables entirely with rawfmt.Printf/fmt.Println. While routing to stdout is correct for pipeable markdown output, these files could benefit from a shared markdown table builder utility to reduce repetition and eliminate typo-prone format strings.Example pattern (audit_cross_run_render.go)
2. Two-Library Lipgloss Split (Architectural Note)
Huh v0.8.0 depends on
github.com/charmbracelet/lipgloss(v1), while the rest of the codebase usescharm.land/lipgloss/v2. Thehuh_theme.gofile already calls this out with a comment. This is a known constraint of the ecosystem and is handled cleanly by isolating the v1 import topkg/styles/huh_theme.go. No action needed, but worth tracking for when Huh upgrades to Lipgloss v2.3.
mcp_list_tools.goandmcp_inspect_mcp.go:fmt.Print(table)to StdoutThese files render pre-formatted text tables using
fmt.Print(table)to stdout. Since these are formatted as structured output (not diagnostic messages), routing to stdout is acceptable. However, the table variable (table string) is built manually rather than usingconsole.RenderTable()orconsole.RenderStruct(). Migrating to the shared console table renderer would provide consistent styling and TTY detection.4. Bubble Tea List in
pkg/console/list.goThe
list.gofile implements a full Bubble Tea interactive list picker (charm.land/bubbles/v2/list). This is the only direct Bubble Tea model implementation outside of huh. It includes proper TTY detection (falls back to non-interactive text list when not in a terminal). This is a good pattern but could benefit from a note in the console package README about when to prefer Bubble Tea list vs. HuhSelect.📋 Specific Recommendations
audit_cross_run_render.go,audit_diff_render.gofmt.Printfmarkdown table callsmarkdownTable(headers []string, rows [][]string)helpermcp_list_tools.go,mcp_inspect_mcp.gofmt.Print(table)console.RenderTable()with TTY fallbackpkg/styles/huh_theme.gopkg/console/list.go🏆 Best-Practice Examples in the Codebase
Lipgloss adaptive color system (pkg/styles/theme.go):
TTY-safe styling (pkg/console/console.go):
Consistent Huh form pattern (pkg/cli/interactive.go):
Correct output routing (pkg/cli/tool_graph.go):
References:
Beta Was this translation helpful? Give feedback.
All reactions