Users and CI expect no-color.org semantics for accessibility and logs.
Console capabilities
Platform spec feature
Console capabilities
Spec standingStandard
-
Any non-empty NO_COLOR strips ANSI emission.
Context
Decision
Rule Detail NO_COLORNon-empty value must force ShouldEmitAnsi()falseReference no-color.org Consequences
Capability probes and markup render paths consult the same gate.
Verification anchors
CapabilitiesTests.bd;Console/Capabilities.bd. -
COLORTERM presence selects TrueColor when color allowed.
Context
Modern terminals advertise truecolor via COLORTERM without breaking NO_COLOR.
Decision
Rule Detail Probe COLORTERMset →TrueColorwhen color not strippedFORCE_COLORMay enable emission on non-TTY stdout Consequences
EffectiveColorModel reflects env probes before SGR downgrade (see D-CORE-TERM-0003).
Verification anchors
CapabilitiesTests.bd. -
RGB downgrades through palette ladders automatically.
Context
Callers should not manually pick CSI color modes per terminal.
Decision
Rule Detail Downgrade RGB → indexed → basic is lossy API No per-sequence model selector on public helpers Consequences
Styled output remains readable on Basic16 hosts without author branches.
Verification anchors
AnsiSgrGoldenTests.bd; capability + SGR integration.
- Contracts and edge cases MUST rules for capability probing and color stripping.
- Design model Capability record, color models, and environment-driven probing.
- Examples Checking capabilities before custom styling.
- Flow and algorithm Probe and strip algorithms for terminal capabilities.
- Verification and traceability Tests and sources for capability probing.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
what-this-feature-specifies | yes | yes |
implementation-anchors | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
What this feature specifies
Console.Capabilities and Platform.Terminal probe whether styled output is appropriate: TTY detection on fd 1, environment flags (NO_COLOR, FORCE_COLOR, COLORTERM, TERM), and the effective color model used by Ansi.Sgr downgrade logic.
Contract statement
ShouldEmitAnsi()must return false whenNO_COLORis set (non-empty value perEnvFlagSet).- When not forced, non-TTY stdout must suppress ANSI emission.
FORCE_COLORmust enable emission even when stdout is not a TTY.EffectiveColorModelmust returnBasic16when color is stripped, otherwise the probed model (Basic8,Basic16,Indexed256,TrueColor).Platform.Terminal.ForcePlainText()should align with dumb terminals (TERM=dumb) and piped stdout unlessFORCE_COLORis set.
Implementation anchors
compiler/corelib/packages/console/src/Console/Capabilities.bdcompiler/corelib/packages/console/src/Platform/Terminal.bd- Tests:
CapabilitiesTests.bd
Decisions
Section titled “Decisions”No open decisions. Closed choices are normative ADRs under adr/ (D-CORE-TERM-0020 … D-CORE-TERM-0022); use the reader ADRs tab for expandable detail.
Articles
- NO_COLOR disables colorAny non-empty NO_COLOR strips ANSI emission.
- Contracts and edge casesMUST rules for capability probing and color stripping.
- Design modelCapability record, color models, and environment-driven probing.
- ExamplesChecking capabilities before custom styling.
- Flow and algorithmProbe and strip algorithms for terminal capabilities.
- Verification and traceabilityTests and sources for capability probing.