[terminal-stylist] Terminal Stylist Audit: Console Output Analysis #24720
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #24874. |
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 non-test Go source files in
pkg/andcmd/, covering Lipgloss styling, Huh interactive forms, andpkg/consoleformatting consistency.Workflow Run: §24000899337
Overall Assessment
The codebase demonstrates excellent adoption of the Charmbracelet ecosystem. The architecture is clean and well-structured with clear separation of concerns between
pkg/styles(palette),pkg/console(formatting), and CLI command code.✅ Strengths
Lipgloss v2 — Adaptive Color System
pkg/styles/theme.goimplements a complete, well-documented adaptive palette:compat.AdaptiveColorfromcharm.land/lipgloss/v2/compat— automatically selects light/dark color based on terminal backgroundError,Warning,Success,Info,FilePath,LineNumber,ContextLine,Highlight,Command,Progress,Prompt,Count,Verbose,ListHeader,ListItem,TableHeader,TableCell,TableTotal,TableTitle,TableBorder,ServerName,ServerType,ErrorBox,Header,TreeEnumerator,TreeNodeRoundedBorder,NormalBorder,ThickBorder) for centralized border managementTTY Detection
applyStyle()inconsole.gowraps all styling with a TTY check, ensuring ANSI codes never appear in piped/redirected output:The
ttypackage usesgolang.org/x/termfor detection.console.RenderComposedSections,RenderTitleBox, andRenderErrorBoxseparately checktty.IsStderrTerminal()for stderr output — correct since those are diagnostic messages.Huh v2 — Interactive Forms
All 15+ form instantiations across the codebase consistently apply:
styles.HuhThememaps thepkg/stylesDracula palette to every visual element of Huh forms (title, description, option, button, cursor, border). Accessibility mode is properly triggered byACCESSIBLE,TERM=dumb, orNO_COLORenvironment variables.Form field types used:
Input,Select,MultiSelect,Confirm,Text(multi-line) — full coverage of the use cases.Non-TTY fallback for
ShowInteractiveListdegrades gracefully to a numbered text list viafmt.Scanf.Console Package Architecture
pkg/console/is comprehensive and well-organized:FormatSuccessMessage✓+ styled messageFormatInfoMessageℹ+ styled messageFormatWarningMessage⚠+ styled messageFormatErrorMessage✗+ styled messageFormatCommandMessage⚡+ styled commandFormatProgressMessage🔨+ styled progressFormatPromptMessage❓+ styled promptFormatVerboseMessage🔍+ muted debug textFormatErrorChainFormatErrorWithSuggestionsRenderTableRenderStructRenderTitleBoxRenderErrorBoxRenderInfoSectionWasm stubs in
console_wasm.gomirror all functions as plain-text equivalents.Audit Report Multi-Mode Rendering
audit_cross_run_render.goandaudit_diff_render.goimplement a clean three-mode output system:console.Format*functions)This correctly follows the Unix convention of diagnostic output → stderr, structured data → stdout.
1. Missing Functions: Native Console vs. Wasm Stub Asymmetry
Three functions exist in
console_wasm.gostubs but are absent fromconsole.go(native builds):console.goFormatLocationMessage"📁 " + messageFormatCountMessage"📊 " + messageFormatListHeaderreturn headerThese functions would cause compilation errors if called from non-wasm CLI code. They are currently unused in native code, but the gap breaks the symmetry contract and makes the API confusing.
Conversely,
FormatErrorChain(defined inconsole.go) is absent fromconsole_wasm.go. It is used inpkg/cli/add_command.goandcmd/gh-aw/main.go, but those are non-wasm targets so there is no current build failure. However, it would fail if called in wasm code.Recommendation: Add the missing functions to
console.gowith appropriate Lipgloss styling:And add
FormatErrorChainstub toconsole_wasm.go.2.
logs_report.go—fmt.PrintInstead offmt.Fprint(os.Stdout, ...)While functionally equivalent (
fmt.Printwrites to stdout), the explicitfmt.Fprint(os.Stdout, ...)orfmt.Fprintln(os.Stdout, ...)form is more idiomatic and consistent with the rest of the codebase. Per the AGENTS.md guidelines, structured output goes to stdout — this is correct routing, just a minor style inconsistency.💡 Opportunities
1.
renderCrossRunReportPrettyCould Useconsole.RenderTableThe pretty renderer currently uses manually aligned
fmt.Fprintfstrings:These could be expressed as
console.RenderTablecalls for consistent visual styling (zebra striping, borders, bold headers) when in TTY mode. The existingconsole.RenderTablewithTableConfigalready supports this pattern as demonstrated inpkg/cli/mcp_list.go,pkg/cli/gateway_logs.go, andpkg/cli/deps_outdated.go.2.
RenderTreeMissing Native ImplementationRenderTreeis defined only inconsole_wasm.go(plain-text fallback). The nativeconsole.gohas no Lipgloss tree implementation despitepkg/stylesdefiningTreeEnumeratorandTreeNodestyles. These style definitions are unused. Adding a nativeRenderTreeusing Lipgloss list rendering would enable visually-rich hierarchical output.3. Extend
FormatErrorContext Rendering with Lipgloss Inline EmphasisThe current
FormatErrorcontext rendering (Rust-style with^carets) is good. A future enhancement could uselipgloss.NewStyle().Underline(true)for the highlighted word on terminals that support it, reducing the need for a separate caret line.File Coverage Summary
Files Using Console Formatters Correctly (selected examples)
pkg/cli/audit_cross_run_render.go— pretty renderer usesconsole.FormatInfoMessagepkg/cli/audit_diff_render.go— usesconsole.RenderTablefor comparison tables,console.FormatWarningMessagepkg/cli/mcp_list.go— usesconsole.RenderTablefor MCP server tablespkg/cli/gateway_logs.go— usesconsole.RenderTablefor firewall statspkg/cli/health_command.go— usesconsole.RenderStructfor status displaypkg/cli/list_workflows_command.go— usesconsole.RenderStructin non-JSON modepkg/cli/deps_outdated.go— usesconsole.RenderTablefor dependency tablespkg/cli/logs_download.go— consistently usesconsole.FormatVerboseMessageto stderrpkg/console/list.go,confirm.go,input.go— use Huh withstyles.HuhThemeandIsAccessibleMode()Files Using Markdown/Structured stdout Output (intentional pattern)
These files correctly use raw
fmt.Print*to stdout for structured output (markdown tables, JSON, hashes):pkg/cli/audit_cross_run_render.go—renderCrossRunReportMarkdown()(markdown to stdout)pkg/cli/audit_diff_render.go—renderAuditDiffMarkdown()(markdown to stdout)pkg/cli/tool_graph.go— Mermaid graph to stdoutpkg/cli/deps_report.go— JSON to stdoutpkg/cli/hash_command.go— hash to stdoutpkg/cli/compile_pipeline.go— JSON to stdoutpkg/cli/health_command.go,status_command.go,domains_command.go— JSON to stdoutStatistics
fmt.Print*to stdout (structured output)fmt.Fprintln/Fprintfto stderrWithTheme+WithAccessiblepkg/stylesReferences:
Beta Was this translation helpful? Give feedback.
All reactions