feat(0.2): internal/uitokens/ design system foundation (Track 10.1)#136
Open
feat(0.2): internal/uitokens/ design system foundation (Track 10.1)#136
Conversation
Foundational deliverable for Track 10 (Visual & design system). Every
user-visible renderer in 0.2.0 — terminal output, HTML report,
PR-comment markdown, SARIF tags — consumes from this package. Ad-hoc
styling outside `internal/uitokens/` becomes a parity-gate violation
on the V1 (visual consistency) axis; Track 10.2 migrates existing
renderers to the tokens.
What's in the package:
Color tokens
Six semantic colors (muted / accent / ok / warn / alert / bold).
Names describe ROLES not specific shades, so the underlying ANSI
codes can change without rewriting callers. Wrappers (Muted, Ok,
Warn, Alert, Bold) emit only when ColorEnabled is true; empty-
input wraps are no-ops to avoid stray escape sequences.
TTY / NO_COLOR detection
ColorEnabled initialized once via stdout TTY check + NO_COLOR
env var (https://no-color.org/) + TERM=dumb fallback. Pipes /
file redirects automatically suppress color. Tests can flip the
flag to assert plain-text output.
Symbol vocabulary
SymOK / SymFail / SymWarn / SymInfo / SymArrow / SymBullet /
SymDash / SymDot / SymRule / SymSubrule. One vocabulary used
across every command — the V2 (information rhythm) axis depends
on this consistency.
Severity model + badges
SeverityCritical / High / Medium / Low / Info ladder with
SeverityBadge() rendering. CRITICAL and HIGH bold so blocking
findings stand out at a glance.
Verdict badges
VerdictBadge("PASS"|"WARN"|"FAIL") returns the canonical glyph +
label combo used by the parity-gate matrix, AI risk review hero
block, and policy check.
Spacing & rules
SectionWidth = 60 — every renderer uses this width for section
rules so headings line up across commands. Heading() / Subheading()
return ready-to-print two-line blocks.
ASCII bar renderer
BarChar / BarEmpty constants; Bar() with auto-coloring by
proportion (≥80% alert, ≥40% warn, < muted); BarPlain() for
callers that want inverse-polarity coloring (e.g. coverage,
where high is good).
Text helpers
Truncate / PadRight / PadLeft — rune-aware, unicode-safe. Used
by every table layout in the codebase once Track 10.2 migrates.
Tests (15 total, ~280 lines):
- Color wrappers respect ColorEnabled in both directions
- Color wrappers no-op on empty strings (avoid escape-sequence
noise around "")
- Severity badges produce the right labels
- Severity badges bold ≥ HIGH
- Verdict badges canonicalize case + whitespace
- Bar rendering covers full / empty / half / overflow / negative /
zero-max / zero-width
- Bar coloring threshold transitions at 0.4 and 0.8
- Truncate / PadRight / PadLeft handle unicode correctly
- Rule and SubRule render at SectionWidth
- Heading is two lines (title + rule)
- Color composition (Bold(Alert(...))) preserves both escapes
Zero dependencies. Stateless. Tested at 100% coverage of public API.
Track 10.2 (renderer audit + migration) is the follow-on PR that
moves existing internal/reporting/* code paths to consume from here.
A vet rule that flags raw ANSI codes outside this package is also
on the Track 10.2 list.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
[RISK] Terrain — Merge blocked
Coverage gaps in changed code
Pre-existing issues (2)
Recommended tests1 test(s) with exact coverage of 19 impacted unit(s). 3 impacted unit(s) have no covering tests in the selected set.
Owners: PMCLSF Limitations
Generated by Terrain · Targeted Test ResultsTerrain selected 1 test(s) instead of the full suite.
|
Terrain AI Risk Review
Decision: PASS — AI surfaces are covered. |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Foundational deliverable for Track 10 (Visual & design system) from the 0.2.0 parity-gated release plan. `internal/uitokens/` is the design-system shim every user-visible renderer in 0.2.0 will consume from — terminal output, HTML report, PR-comment markdown, SARIF tags.
After this lands, ad-hoc styling outside the package becomes a parity-gate violation on the V1 (visual consistency) axis. Track 10.2 follows: migrate existing renderers + add a vet rule that flags raw ANSI codes outside `internal/uitokens/`.
What's in the package
Zero dependencies. Stateless. ~310 lines of code + ~280 lines of tests.
Tests (15 total, all passing)
Test plan
Plan link
`/Users/pzachary/.claude/plans/kind-mapping-turing.md` (Track 10.1).
Next: Track 10.2
Renderer audit + migration. Existing `internal/reporting/` / `internal/changescope/render.go` / etc. switch to consuming from this package; a static check flags any `\x1b[` outside `internal/uitokens/`. Separate PR.
🤖 Generated with Claude Code