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]
format_check_result 2 str
Format a CheckResult for rich terminal display.
def format_check_result(result: CheckResult, *, color: bool | None = None) -> 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
Returns
str