[terminal-stylist] Terminal Stylist Report: Console Output Analysis #36213
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #36431. |
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.
-
Summary
This report analyzes console output patterns across 871 Go source files in the
pkg/directory, focusing on consistency, Lipgloss styling, and Huh form usage.pkg/consoleformattersfmt.Fprintln(os.Stderr, "...")pkg/cli/Overall health: The project has a solid foundation — a well-designed
pkg/consoleformatting package, an adaptive Lipgloss theme (pkg/styles), and a consistent Huh theme (styles.HuhTheme). The main gap is 398 rawfmt.Fprintln(os.Stderr, "...")calls in 55 CLI files that bypass the console formatting layer.✅ What's Working Well
Lipgloss Integration
pkg/styles/theme.gois a well-structured, fully adaptive color system usingcompat.AdaptiveColorwith both Light and Dark hex variants (Dracula-inspired for dark mode)pkg/tty—applyStyle()inconsole.gois gated ontty.IsStdoutTerminal()RoundedBorder,NormalBorder,ThickBorder) are centralizedError,Warning,Success,Info,FilePath,Progress,Command,ListHeader,TableHeader, etc.colorprofile.Detect(os.Stderr, os.Environ())— correct for terminal capability detectionConsole Formatting Package
pkg/consoleprovides a comprehensive set of format helpers:FormatSuccessMessage,FormatInfoMessage,FormatWarningMessage,FormatErrorMessage,FormatCommandMessage,FormatProgressMessage,FormatPromptMessage,FormatVerboseMessageFormatErrorwithrenderContext)RenderComposedSections,RenderTitleBox,RenderErrorBox,RenderInfoSection) for consistent layoutFormatErrorChain) for wrapped errorsHuh Form Integration
huh.NewForm(...)call sites use.WithTheme(styles.HuhTheme).WithAccessible(console.IsAccessibleMode())— 100% consistentstyles.HuhThemeis a properhuh.ThemeFuncmapping the full palette to focused/blurred statesconsole.IsAccessibleMode()) is consistently appliedconsole.ConfirmAction,console.PromptSecretInput, andconsole.listare well-encapsulated wrappershuh.NewConfirm,huh.NewSelect,huh.NewInput(withEchoModePasswordfor secrets),huh.NewMultiSelectPromptSecretInputbefore showing interactive forms is correct1. Raw
fmt.Fprintln(os.Stderr, "...")Calls Bypassing Console FormattingThe most widespread issue: 398 raw string messages written directly to stderr in 55 CLI files, bypassing all styling and TTY detection.
Top 15 files by raw stderr message count
pkg/cli/mcp_inspect_mcp.gopkg/cli/audit_report_render.gopkg/cli/fix_command.gopkg/cli/compile_stats.gopkg/cli/audit_cross_run_render.gopkg/cli/add_interactive_workflow.gopkg/cli/copilot_setup.gopkg/cli/actionlint.gopkg/cli/preconditions.gopkg/cli/experiments_analyze_statistics.gopkg/cli/engine_secrets.gopkg/cli/enable.gopkg/cli/deps_report.gopkg/cli/outcomes_command.gopkg/cli/experiments_command.goExample pattern to fix (
pkg/cli/preconditions.go):Example from
pkg/cli/add_interactive_workflow.go:2. Manual Separator Lines Instead of Console Borders
pkg/cli/add_interactive_orchestrator.go(and others) use hardcoded Unicode separators:3. Files Using Raw
fmt.Fprintln(os.Stderr)WithoutconsoleImportSix files write to stderr without importing the console package at all:
pkg/cli/add_interactive_secrets.gopkg/cli/copilot_setup.gopkg/cli/devcontainer.gopkg/cli/mcp_config_file.gopkg/cli/observability_insights.gopkg/cli/vscode_config.goThese need both the import and updated message calls.
4.
isTTY()inconsole.goChecksstdoutInstead ofstderrThe
applyStyle()helper gates styling ontty.IsStdoutTerminal(), but all diagnostic output goes to stderr. Messages styled withapplyStyle()may lose their styling when stdout is redirected but stderr remains a terminal (the common CI case).Note:
RenderComposedSections,RenderTitleBoxand related functions already correctly usetty.IsStderrTerminal()— the inconsistency is only inapplyStyle().5.
audit_report_render.go— Mixed Raw/Styled Output PatternThis file (32 raw calls) uses
fmt.Fprintln(os.Stderr, line)to print pre-built styled strings (e.g.,compLine,metricsLine). While the content is styled, the pattern is fragile — consider refactoring to route all rendering throughconsole.RenderComposedSections.Recommendations (Priority Order)
🔴 Fix
isTTY()inconsole.go— changeIsStdoutTerminal()toIsStderrTerminal(). This is a small change with significant correctness impact for CI environments.🟠 Migrate top 5 raw-stderr files —
mcp_inspect_mcp.go(57),audit_report_render.go(32),fix_command.go(24),compile_stats.go(18),audit_cross_run_render.go(18) account for 149 of the 398 raw calls (~37%). Converting these would dramatically improve consistency.🟡 Add
consoleimport to the 6 files that write raw strings to stderr without it.🟢 Replace hardcoded separators (
━━━...) withconsole.FormatSectionHeader()orconsole.RenderTitleBox().🟢 Lipgloss table usage —
pkg/cli/compile_schedule_calendar.goandpkg/cli/gateway_logs_timeline_render.gouse Lipgloss tables directly. These are well-implemented; ensure they're usingstyles.TableBorder,styles.TableHeader, andstyles.ColorTableAltRowfor zebra striping consistency.References: §26749137896
Beta Was this translation helpful? Give feedback.
All reactions