# beorn/termless architecture

> Architecture diagram of the GitHub repository beorn/termless, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/beorn/termless
- Repository: https://github.com/beorn/termless
- Video tour (about a minute): https://gitdiagram.com/beorn/termless/video

## Overview

Termless is a headless terminal testing and recording toolkit. Its main workflow creates a terminal with a selectable emulator backend, feeds it output or runs a real process, inspects structured terminal state, and asserts on that state. Separate capabilities record and replay sessions, compare backends, and render screenshots or recordings. The graph preserves these product branches; links for capabilities documented in the README but not shown in source excerpts use README evidence, and unsampled implementation details are not inferred.

Main entry points: [`src/terminal/terminal.ts`](https://github.com/beorn/termless/blob/main/src/terminal/terminal.ts) (Terminal API), [`packages/cli/src`](https://github.com/beorn/termless/tree/main/packages/cli/src) (CLI and MCP), [`src/recording/recording.ts`](https://github.com/beorn/termless/blob/main/src/recording/recording.ts) (Recording model), [`src/assertions.ts`](https://github.com/beorn/termless/blob/main/src/assertions.ts) (Assertions and matchers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terminal["Terminal testing"]
  node_terminal_api["Terminal API<br/>[terminal.ts]"]
  node_terminal_state["Terminal state<br/>[types.ts]"]
  node_region_views["Region selectors<br/>[views.ts]"]
  node_matchers["Assertions and matchers<br/>[assertions.ts]"]
  node_vitest_matchers["Vitest matchers<br/>[matchers.ts]"]
  node_pty["PTY processes<br/>[pty.ts]"]
  node_io_contracts["Session and event contracts<br/>[session.ts]"]
end

subgraph group_engines["Emulator backends"]
  node_backend_api["Backend selection<br/>[backends.ts]"]
  node_backend_adapters["Emulator backends"]
end

subgraph group_media["Rendering and views"]
  node_svg_renderer["SVG renderer<br/>[svg.ts]"]
  node_rasterizer["Rasterizer<br/>[rasterizer.ts]"]
  node_fonts["Bundled fonts<br/>[fonts.ts]"]
  node_viewer["Recording viewer<br/>[viewer.ts]"]
  node_animation["Animation outputs<br/>[animation.ts]"]
end

subgraph group_recording["Recording and playback"]
  node_recording_model["Recording model<br/>[recording.ts]"]
  node_frame_trace["Frame tracing<br/>[frame-trace.ts]"]
  node_frame_recording["Trace conversion"]
  node_tty_format["TTY recording format<br/>[tty-format.ts]"]
  node_tape_parser["Tape parser<br/>[parser.ts]"]
end

subgraph group_interfaces["User interfaces"]
  node_cli["CLI and MCP"]
  node_web_player["Web playback<br/>[player.ts]"]
  node_conformance["Conformance corpus"]
end

node_user(("Test author"))

node_user -->|"creates terminal"| node_terminal_api
node_terminal_api -->|"uses backend"| node_backend_api
node_backend_api -.->|"resolves backend"| node_backend_adapters
node_terminal_api -->|"exposes state"| node_terminal_state
node_terminal_api -->|"creates views"| node_region_views
node_terminal_api -->|"spawns process"| node_pty
node_user -->|"asserts state"| node_matchers
node_matchers -->|"checks state"| node_terminal_state
node_vitest_matchers -->|"adapts assertions"| node_matchers
node_terminal_api -->|"renders screenshot"| node_svg_renderer
node_terminal_api -->|"selects rasterizer"| node_rasterizer
node_svg_renderer -->|"loads fonts"| node_fonts
node_user -->|"records or plays"| node_cli
node_cli -->|"creates sessions"| node_terminal_api
node_cli -.->|"records sessions"| node_recording_model
node_cli -.->|"plays tape"| node_tape_parser
node_cli -.->|"compares backends"| node_backend_api
node_terminal_api -.->|"captures frames"| node_frame_trace
node_frame_trace -->|"converts trace"| node_frame_recording
node_recording_model -->|"encodes recording"| node_tty_format
node_recording_model -->|"presents recording"| node_viewer
node_recording_model -->|"builds animations"| node_animation
node_user -.->|"views playback"| node_web_player
node_user -->|"grades backend"| node_conformance

click node_terminal_api "https://github.com/beorn/termless/blob/main/src/terminal/terminal.ts"
click node_terminal_state "https://github.com/beorn/termless/blob/main/src/terminal/types.ts"
click node_region_views "https://github.com/beorn/termless/blob/main/src/terminal/views.ts"
click node_matchers "https://github.com/beorn/termless/blob/main/src/assertions.ts"
click node_vitest_matchers "https://github.com/beorn/termless/blob/main/packages/viterm/src/matchers.ts"
click node_pty "https://github.com/beorn/termless/blob/main/src/terminal/pty.ts"
click node_backend_api "https://github.com/beorn/termless/blob/main/src/backend/backends.ts"
click node_backend_adapters "https://github.com/beorn/termless/tree/main/packages"
click node_io_contracts "https://github.com/beorn/termless/blob/main/src/io/session.ts"
click node_svg_renderer "https://github.com/beorn/termless/blob/main/src/render/svg.ts"
click node_rasterizer "https://github.com/beorn/termless/blob/main/src/view/rasterizer.ts"
click node_fonts "https://github.com/beorn/termless/blob/main/src/render/fonts.ts"
click node_recording_model "https://github.com/beorn/termless/blob/main/src/recording/recording.ts"
click node_frame_trace "https://github.com/beorn/termless/blob/main/src/recording/frame-trace.ts"
click node_frame_recording "https://github.com/beorn/termless/blob/main/src/recording/frame-trace-recording.ts"
click node_tty_format "https://github.com/beorn/termless/blob/main/src/recording/native/tty-format.ts"
click node_tape_parser "https://github.com/beorn/termless/blob/main/src/recording/tape/parser.ts"
click node_viewer "https://github.com/beorn/termless/blob/main/src/view/viewer.ts"
click node_animation "https://github.com/beorn/termless/blob/main/src/view/animation.ts"
click node_cli "https://github.com/beorn/termless/tree/main/packages/cli/src"
click node_web_player "https://github.com/beorn/termless/blob/main/packages/web-player/src/player.ts"
click node_conformance "https://github.com/beorn/termless/tree/main/corpus"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_terminal_api,node_terminal_state,node_region_views,node_matchers,node_vitest_matchers,node_pty,node_io_contracts toneBlue
class node_backend_api,node_backend_adapters toneAmber
class node_svg_renderer,node_rasterizer,node_fonts,node_viewer,node_animation toneMint
class node_recording_model,node_frame_trace,node_frame_recording,node_tty_format,node_tape_parser toneRose
class node_cli,node_web_player,node_conformance,node_user toneIndigo
```

## Components

### Terminal testing

- [Terminal API](https://github.com/beorn/termless/blob/main/src/terminal/terminal.ts): `src/terminal/terminal.ts`
- [Terminal state](https://github.com/beorn/termless/blob/main/src/terminal/types.ts): `src/terminal/types.ts`
- [Region selectors](https://github.com/beorn/termless/blob/main/src/terminal/views.ts): `src/terminal/views.ts`
- [Assertions and matchers](https://github.com/beorn/termless/blob/main/src/assertions.ts): `src/assertions.ts`
- [Vitest matchers](https://github.com/beorn/termless/blob/main/packages/viterm/src/matchers.ts): `packages/viterm/src/matchers.ts`
- [PTY processes](https://github.com/beorn/termless/blob/main/src/terminal/pty.ts): `src/terminal/pty.ts`
- [Session and event contracts](https://github.com/beorn/termless/blob/main/src/io/session.ts): `src/io/session.ts`

### Emulator backends

- [Backend selection](https://github.com/beorn/termless/blob/main/src/backend/backends.ts): `src/backend/backends.ts`
- [Emulator backends](https://github.com/beorn/termless/tree/main/packages): `packages`

### Rendering and views

- [SVG renderer](https://github.com/beorn/termless/blob/main/src/render/svg.ts): `src/render/svg.ts`
- [Rasterizer](https://github.com/beorn/termless/blob/main/src/view/rasterizer.ts): `src/view/rasterizer.ts`
- [Bundled fonts](https://github.com/beorn/termless/blob/main/src/render/fonts.ts): `src/render/fonts.ts`
- [Recording viewer](https://github.com/beorn/termless/blob/main/src/view/viewer.ts): `src/view/viewer.ts`
- [Animation outputs](https://github.com/beorn/termless/blob/main/src/view/animation.ts): `src/view/animation.ts`

### Recording and playback

- [Recording model](https://github.com/beorn/termless/blob/main/src/recording/recording.ts): `src/recording/recording.ts`
- [Frame tracing](https://github.com/beorn/termless/blob/main/src/recording/frame-trace.ts): `src/recording/frame-trace.ts`
- [Trace conversion](https://github.com/beorn/termless/blob/main/src/recording/frame-trace-recording.ts): `src/recording/frame-trace-recording.ts`
- [TTY recording format](https://github.com/beorn/termless/blob/main/src/recording/native/tty-format.ts): `src/recording/native/tty-format.ts`
- [Tape parser](https://github.com/beorn/termless/blob/main/src/recording/tape/parser.ts): `src/recording/tape/parser.ts`

### User interfaces

- [CLI and MCP](https://github.com/beorn/termless/tree/main/packages/cli/src): `packages/cli/src`
- [Web playback](https://github.com/beorn/termless/blob/main/packages/web-player/src/player.ts): `packages/web-player/src/player.ts`
- [Conformance corpus](https://github.com/beorn/termless/tree/main/corpus): `corpus`

### Other components

- **Test author**

## Connections

- Test author → Terminal API: creates terminal (evidence: `README.md`)
- Terminal API → Backend selection: uses backend (evidence: `src/backend/backends.ts`)
- Backend selection → Emulator backends: resolves backend
- Terminal API → Terminal state: exposes state (evidence: `src/terminal/terminal.ts`)
- Terminal API → Region selectors: creates views (evidence: `src/terminal/terminal.ts`)
- Terminal API → PTY processes: spawns process (evidence: `src/terminal/terminal.ts`)
- Test author → Assertions and matchers: asserts state (evidence: `README.md`)
- Assertions and matchers → Terminal state: checks state (evidence: `src/assertions.ts`)
- Vitest matchers → Assertions and matchers: adapts assertions (evidence: `packages/viterm/src/matchers.ts`)
- Terminal API → SVG renderer: renders screenshot (evidence: `src/terminal/terminal.ts`)
- Terminal API → Rasterizer: selects rasterizer (evidence: `src/terminal/terminal.ts`)
- SVG renderer → Bundled fonts: loads fonts (evidence: `src/render/svg.ts`)
- Test author → CLI and MCP: records or plays (evidence: `README.md`)
- CLI and MCP → Terminal API: creates sessions (evidence: `packages/cli/src/session.ts`)
- CLI and MCP → Recording model: records sessions
- CLI and MCP → Tape parser: plays tape
- CLI and MCP → Backend selection: compares backends
- Terminal API → Frame tracing: captures frames
- Frame tracing → Trace conversion: converts trace (evidence: `src/index.ts`)
- Recording model → TTY recording format: encodes recording (evidence: `src/index.ts`)
- Recording model → Recording viewer: presents recording (evidence: `src/view/viewer.ts`)
- Recording model → Animation outputs: builds animations
- Test author → Web playback: views playback
- Test author → Conformance corpus: grades backend (evidence: `README.md`)
