Terminal Stylist Report: Console Output Analysis #23875
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #24088. |
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 622 Go source files in the
pkg/directory, evaluating consistency, Lipgloss usage, Huh form implementations, and output routing.Summary
compat.AdaptiveColorArchitecture Overview
The codebase uses a well-structured layered approach to terminal output:
Lipgloss version strategy:
charm.land/lipgloss/v2withcharm.land/lipgloss/v2/compatfor adaptive colorsgithub.com/charmbracelet/lipgloss(v1) isolated topkg/styles/huh_theme.go(required by huh's type system)✅ What's Working Well
1. Adaptive Color System
pkg/styles/theme.godefines 10 semanticcompat.AdaptiveColorpairs covering all CLI use cases:Light mode uses saturated/darker colors; dark mode uses Dracula theme bright colors. This ensures readability across both terminal themes.
2. TTY-Aware Styling
The
applyStyle()guard inconsole.gois consistently applied to all styled output:RenderTable,RenderTitleBox,RenderErrorBox, andRenderInfoSectionall checkisTTY()/IsStderrTerminal()before applying Lipgloss layout.3. Console Message Formatting Usage
The
console.*functions are widely used — 553 calls toconsole.FormatInfoMessagealone:FormatInfoMessageFormatWarningMessageFormatSuccessMessageFormatVerboseMessageFormatErrorMessageLogVerboseFormatSectionHeaderRenderTableFormatCommandMessageFormatProgressMessageRenderStruct4. Correct Output Routing
All 14 files using
fmt.Println/fmt.Printfto stdout are printing structured data (not diagnostics):compile_pipeline.go,status_command.go,health_command.go,run_workflow_execution.go,domains_command.go,list_workflows_command.go,deps_report.go,trial_command.gohash_command.gotool_graph.goaudit_cross_run_render.go,audit_diff_render.gologs_report.go,status_command.go(viaconsole.RenderStruct)This correctly allows piping and redirection without mixing diagnostic noise.
5. Huh Forms — Consistent Configuration
All 10+ Huh form usages apply the same configuration pattern:
IsAccessibleMode()checksACCESSIBLE,TERM=dumb, andNO_COLORenvironment variables, ensuring the forms degrade gracefully in CI/screen-reader environments.PromptSecretInputandadd_interactive_auth.gocorrectly usehuh.EchoModePasswordand.Validate()for secure inputs.6. Error Rendering
FormatError()implements Rust-inspired error rendering with:^pointer underlining the error tokenFormatErrorChain()intelligently unwrapsfmt.Errorf("%w", ...)chains, displaying each level with proper indentation.Issue 1: API Gap Between WASM and Non-WASM Console
Three functions exist in
pkg/console/console_wasm.gobut are absent frompkg/console/console.go:FormatLocationMessageFormatCountMessageFormatListHeaderThese functions are currently unused so there is no runtime issue, but the API asymmetry is a latent inconsistency. If a caller ever uses these on a non-WASM build (e.g., referencing
console.FormatLocationMessagein CLI code), it will fail to compile.Recommendation: Add the missing implementations to
console.go:Note:
styles.Location(bold orange) already exists inpkg/styles/theme.go.styles.Countandstyles.ListHeaderalso already exist.Issue 2: Plain
fmt.Fprintffor Inline Diagnostics inaudit_report_render.goLine 936:
This mixes the
console.FormatNumberhelper with rawfmt.Fprintf, bypassing the bullet/icon formatting that other diagnostic lines in the same file use. Nearby lines all usefmt.Fprintln(os.Stderr, console.FormatXMessage(...)).Recommendation: Use a consistent pattern:
Issue 3:
audit_cross_run_render.goandaudit_diff_render.go— Raw Markdown Tables to StdoutThese two render files output GitHub Flavored Markdown to stdout for piping into issues/PRs. They use raw
fmt.Printfto construct pipe-delimited tables:This is intentionally correct for their primary use case (piped Markdown). However, when consumed interactively in a terminal, the raw Markdown is unrendered.
Opportunity: Consider adding a TTY-aware rendering path using
console.RenderTable():This would match the pattern already used by
RenderTitleBoxandRenderErrorBoxinconsole.go.Issue 4: Optional — Huh Form Validation Coverage
Most interactive wizard forms (
add_interactive_engine.go,add_interactive_git.go,add_interactive_orchestrator.go,add_interactive_schedule.go) do not use.Validate()on their input fields. Theauthform andengine_secrets.goforms do use validation.For user-facing forms collecting structured data (engine names, repository paths, schedule expressions), adding
.Validate()would prevent silent failures downstream.Example pattern (from
add_interactive_auth.go):Files Summary
Files with excellent console formatting compliance (sample)
These files consistently use
console.*formatters for all diagnostic output:pkg/cli/add_command.gopkg/cli/compile_file_operations.gopkg/cli/compile_orchestrator.gopkg/cli/compile_post_processing.gopkg/cli/mcp_list.gopkg/cli/mcp_inspect_list.gopkg/cli/audit_report_render.go(mostly, see Issue 2)pkg/cli/deps_outdated.gopkg/cli/pr_command.goFiles outputting structured data to stdout (correct pattern)
These files output structured data (JSON/hash/graph) to stdout per Unix conventions:
pkg/cli/audit_cross_run_render.go— Markdown reportpkg/cli/audit_diff_render.go— Markdown diffpkg/cli/compile_pipeline.go— JSON outputpkg/cli/deps_report.go— JSON outputpkg/cli/domains_command.go— JSON outputpkg/cli/hash_command.go— Hash outputpkg/cli/health_command.go— JSON outputpkg/cli/list_workflows_command.go— JSON outputpkg/cli/logs_report.go— Struct renderingpkg/cli/run_workflow_execution.go— JSON outputpkg/cli/status_command.go— JSON + struct renderingpkg/cli/tool_graph.go— Mermaid graphpkg/cli/trial_command.go— JSON outputRecommendations Priority
FormatLocationMessage,FormatCountMessage,FormatListHeadertoconsole.goto close WASM/non-WASM API gapaudit_report_render.go:936inlinefmt.Fprintfto use console formattingaudit_cross_run_render.goandaudit_diff_render.go.Validate()to wizard form inputs for better UXReferences:
Beta Was this translation helpful? Give feedback.
All reactions