Module

server.terminal_checks

Rich terminal formatting for hypermedia surface checks.

Produces structured, colored output for contract validation results that appear at startup in debug mode. Respects TTY detection — no ANSI codes when piped or redirected.

Matches the visual language of pounce's startup banner (->arrows, clean indentation) and chirp's terminal error formatting (dash banners, compact diagnostics).

Example output (with color)::

── chirp check ─────────────────────────────────────────────

  5 routes · 3 templates · 12 targets · 8 hx-target selectors

  ▲  hx-target="#main" — no element with id="main" found
     in pokedex.html
     Did you mean "#mainn"?

  ✓  No errors · 1 warning

─────────────────────────────────────────────────────────────

Classes

_Palette 1
ANSI escape sequences — empty strings when color is disabled.

ANSI escape sequences — empty strings when color is disabled.

Methods

Internal Methods 1
__init__ 1
def __init__(self, *, enabled: bool) -> None
Parameters
Name Type Description
enabled

Functions

_use_color 1 bool
True if the output stream supports ANSI color.
def _use_color(stream: object | None = None) -> bool
Parameters
Name Type Description
stream object | None Default:None
Returns
bool
_severity_icon 2 str
Colored icon for an issue severity.
def _severity_icon(severity: Severity, c: _Palette) -> str
Parameters
Name Type Description
severity Severity
c _Palette
Returns
str
_format_issue 2 list[str]
Format a single issue as indented lines.
def _format_issue(issue: ContractIssue, c: _Palette) -> list[str]
Parameters
Name Type Description
issue ContractIssue
c _Palette
Returns
list[str]
_concern_for_category 1 str
Return the terminal output group for a contract category.
def _concern_for_category(category: str) -> str
Parameters
Name Type Description
category str
Returns
str
_format_fragment_registry 2 list[str]
Render the fragment target registry grouped by contract. Returns a list of lin…
def _format_fragment_registry(registry: FragmentTargetRegistry, c: _Palette) -> list[str]

Render the fragment target registry grouped by contract.

Returns a list of lines or an empty list when the registry has no registered targets.

Parameters
Name Type Description
registry FragmentTargetRegistry
c _Palette
Returns
list[str]
_format_coverage 2 list[str]
Render high-level contract coverage counters.
def _format_coverage(result: CheckResult, c: _Palette) -> list[str]
Parameters
Name Type Description
result CheckResult
c _Palette
Returns
list[str]
format_check_result 5 str
Format a CheckResult for rich terminal display.
def format_check_result(result: CheckResult, *, color: bool | None = None, fragment_target_registry: FragmentTargetRegistry | None = None, verbose_registry: bool = False, show_coverage: bool = False) -> str
Parameters
Name Type Description
result CheckResult

The check result to format.

color bool | None

Force color on/off.Noneauto-detects from stderr.

Default:None
fragment_target_registry FragmentTargetRegistry | None

If provided and non-empty, a summary of registered fragment targets is included — one stats entry for contract count, and (whenverbose_registryis True) a full dump grouped by contract before the summary line.

Default:None
verbose_registry bool

When True, render the full registry dump. Gated by the caller onconfig.debug.

Default:False
show_coverage bool

When True, render route/template coverage counters that make form, mounted-page, shell, and OOB contract coverage visible.

Default:False
Returns
str