[terminal-stylist] Terminal Stylist Audit — Console Output Analysis #28712
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Terminal Stylist. A newer discussion is available at Discussion #28934. |
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
The gh-aw codebase demonstrates mature, well-structured terminal output with a well-established console formatting layer, modern Charmbracelet ecosystem usage (
charm.land/lipgloss/v2andcharm.land/huh/v2), and strong adherence to the stderr/stdout routing conventions.Run: §24994209506
Summary Statistics
pkg/consoleconsole.Format*helpersfmt.Fprintf/fmt.Fprintln(stderr)fmt.Println/fmt.Printf(stdout structured data)pkg/console/,pkg/styles/)✅ Strengths
Console Formatting Package
pkg/console/console.goprovides a rich, well-documented API:FormatSuccessMessage,FormatInfoMessage,FormatWarningMessage,FormatErrorMessage,FormatCommandMessage,FormatProgressMessage,FormatPromptMessage,FormatVerboseMessage,FormatListItemRenderTable,RenderTitleBox,RenderErrorBox,RenderInfoSection,RenderComposedSections,FormatSectionHeaderFormatErrorwith file:line:col positions, context lines, and hintsapplyStyleconditionally applies Lipgloss styling — styles are silently stripped in pipes/redirectsLipgloss v2 (charm.land/lipgloss/v2)
pkg/styles/theme.goandpkg/console/console.gouse Lipgloss v2 correctly:compat.AdaptiveColorwith explicitLight/Darkhex variants for each semantic color (Error, Warning, Success, Info, Purple, Yellow, Comment, Foreground, Background, Border, TableAltRow)applyStyle(style, text)returns plain text when not in a TTYcharm.land/lipgloss/v2/tablefor structured table outputHuh v2 (charm.land/huh/v2 — charm.land fork)
13 files use Huh v2, with excellent integration:
pkg/styles/huh_theme.go):HuhThememaps the pkg/styles Dracula palette to every Huh component — focused/blurred borders, selectors, options, buttons, text input cursor/placeholder/prompt — usinglipgloss.LightDark()for adaptive colors.WithAccessible(IsAccessibleMode())for screen-reader-friendly fallbackpkg/console/list.gofalls back to a numbered text list withfmt.Fprintf(os.Stderr, ...)for non-TTY environmentspkg/console/confirm.go,pkg/console/list.go,pkg/console/input.goabstracthuh.NewFormbehind named helpers (ConfirmAction,ShowInteractiveList,PromptSecretInput) so call sites get consistent theme and accessibility settings automaticallyConfirm,Select,Input(withEchoModePasswordfor secrets) are all usedStdout / Stderr Routing
All 14 files using
fmt.Println/fmt.Printfto stdout output structured data (JSON bytes, Mermaid graphs, Markdown audit reports, hash strings, state strings) — consistent with the documented Unix convention of routing structured data to stdout for piping/redirection.1. Render files use bare fmt.Print* for Markdown/structured output (expected, but undocumented)
pkg/cli/audit_cross_run_render.goandpkg/cli/audit_diff_render.gousefmt.Println/fmt.Printffor Markdown table rows. This is intentional (Markdown output for human-readable reports) and aligns with the "structured output → stdout" convention, but neither file has a comment explaining the choice. A brief header comment would improve maintainability.2. styles/theme.go usage examples use fmt.Println (comment-only, not runtime)
Lines 39–46 of
pkg/styles/theme.goshowfmt.Println(styles.Error.Render(...))in doc comments. These are illustrative examples — not actual runtime calls. However, callers following these examples may send styled output to stdout instead of stderr. Consider updating the doc examples to usefmt.Fprintln(os.Stderr, ...).3. No huh.Text (multi-line) or huh.FilePicker usage found
The current interactive forms cover
Confirm,Select, andInputfields. Workflows that prompt for multi-line content (e.g., workflow descriptions) currently use sequentialInputfields.huh.NewText()would provide a better UX for multi-line text entry. This is an enhancement opportunity, not a defect.4. console.go isTTY() checks stdout, not stderr
isTTY()inpkg/console/console.gocallstty.IsStdoutTerminal(), but all formatted messages are written toos.Stderr. Callers usefmt.Fprintln(os.Stderr, console.FormatXxx(...)). Styling based on stdout TTY state is technically correct for most terminals (stdout and stderr share the same TTY), but an explicittty.IsStderrTerminal()check would be more semantically accurate for messages written to stderr.Recommendations
audit_cross_run_render.go/audit_diff_render.goexplaining stdout Markdown outputstyles/theme.godoc example to usefmt.Fprintln(os.Stderr, ...)huh.NewText()for multi-line workflow description promptsisTTY()in console.go to check stderr terminal stateConclusion
The codebase is in excellent shape for terminal output consistency. The console formatting layer is comprehensive and widely adopted, Lipgloss v2 adaptive colors are used correctly, Huh v2 forms have a consistent custom theme with accessibility support, and the stdout/stderr routing convention is followed throughout. The observations above are minor polish items — no systemic issues were found.
References:
Beta Was this translation helpful? Give feedback.
All reactions