Skip to content

spec: add terminfo & capability layer specification - #130

Open
natemoo-re wants to merge 1 commit into
mainfrom
spec/terminfo-layer
Open

natemoo-re wants to merge 1 commit into
mainfrom
spec/terminfo-layer

Conversation

@natemoo-re

@natemoo-re natemoo-re commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Part 1/4 of the terminfo foundation stack (supersedes the mixed-history #106, which will be closed once this stack lands). Tracks the spec only — implementation PRs are stacked as drafts and must not merge before this spec is approved, per the spec-driven workflow.

What this adds

  • specs/terminfo-spec.md (new, normative): the capability layer — Capabilities, Detection, the CapabilityEvent union, the probe model (query batch + DA1 completion fence, sans-IO), compiled terminfo binary parsing (legacy + extended), the baseline capability set, and the progressive-enhancement evidence model.
  • specs/renderer-spec.md: §7.7 update transaction generalized to resize or capability updates; §7.8 defines capability consumption as deliberately deferred — no renderer output changes in this stack; §8.6 specifies the term.update() public API.
  • specs/input-spec.md: §6 probe-response recognition (how query responses are recognized byte-by-byte and surfaced as events).
  • specs/transitions-spec.md: removes a stale cross-reference note.

Review guidance

The spec is the reviewable artifact here; the stacked implementation PRs (#131, #132, #133) conform to it mechanically. Renderer byte output is unchanged across the entire stack — the first gated consumer (color encoding, #60) is a follow-up and deliberately out of scope (§7.8).

Follow-up protocol work is tracked in #129.

@bombshell-cooper

Copy link
Copy Markdown

No changeset needed

This pull request is classified as no_release_impact: no published package

@natemoo-re
natemoo-re added this pull request to stack #134 September 19, 2026 04:29
@pkg-pr-new

pkg-pr-new Bot commented Sep 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/tty@130

commit: 3998114

Comment thread specs/terminfo-spec.md
Comment on lines +257 to +264
| `foreground-color` | OSC 10 | [`osc-10-fg-color-query`](https://terminfo.dev) |
| `background-color` | OSC 11 | [`osc-11-bg-color-query`](https://terminfo.dev) |
| `cursor-color` | OSC 12 or OSC 21 | [`osc-12-cursor-color`](https://terminfo.dev) |
| `colordepth` | XTGETTCAP `RGB`/`Tc` | [`24-bit-truecolor`](https://terminfo.dev) |
| `sync-output` | DECRPM mode 2026 | [`decset-2026-synchronized-output`](https://terminfo.dev) |
| `kitty-keyboard` | `CSI ? u` | [`kitty-keyboard-protocol`](https://terminfo.dev) |
| `kitty-graphics` | APC `_G…` | [`kitty-graphics-protocol`](https://terminfo.dev) |
| `pointer-shape` | OSC 22 | [`osc-22-pointer-shape`](https://terminfo.dev) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these urls are incomplete? they only appear to reference the base domain?

Comment thread specs/terminfo-spec.md
Comment on lines +349 to +350
`terminfo_parse(bytes, len, out)` accepts a compiled terminfo entry and
populates a `Capabilities`-shaped struct.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a C function? how are errors represented?

Comment thread specs/terminfo-spec.md
Comment on lines +488 to +505
### 10.4 `applyUpdate`

```ts
function applyUpdate(
current: RuntimeCapabilities,
change: Update,
): { readonly next: RuntimeCapabilities; readonly bytes: Uint8Array };

type Update =
| { width: number; height: number }
| CapabilityEvent;
```

`applyUpdate` is a pure function. Given the current `RuntimeCapabilities` and
one `Update`, it returns the next `RuntimeCapabilities` and any bytes defined by
the consuming feature. The foundation returns an empty byte array;
`term.update()` is a loop over `applyUpdate`. Exporting the reducer allows tests
to assert `(next, bytes)` against literal values without a live `Term`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth externalizing this logic in the specs just to be able to write internal unit tests? Isn't creating a term pretty lightweight given that it does not actually do any I/O (aside from loading the WASM once?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants