| name | implementation-terminal-engine |
| description | Implement the retained-mode terminal renderer and interactive input stack, including layout, frame diffing, ANSI lifecycle, keyboard and mouse parsing, focus, selection, prompt editing, keybindings, Vim mode, paste handling, and durable prompt history. Use for terminal rendering, editor behavior, shortcut resolution, input protocol, or history implementation. |
Implementation Terminal Engine
Objective
Build a responsive terminal substrate whose rendering and input behavior are independent of the agent session policy. The engine receives a presentation tree and terminal events; it emits bounded terminal updates and normalized UI events.
See the terminal architecture diagram for the rendering, input, editor, and persistence boundaries, the flex-layout diagram for dirty propagation, generation-aware caching, measure/layout branching, flex redistribution, absolute positioning, and pixel rounding, and the component and integration lifecycle diagram for alternate-screen symmetry, scroll ownership, shared-clock wakeups, recording, export, and terminal-preference recovery.
Load references by task
- Read rendering-pipeline.md to implement layout, frame production, screen diffing, cursor control, resize, fullscreen, synchronized output, and rendering acceptance tests.
- Read flex-layout-engine.md to implement the retained flex tree, units and edge precedence, measurement, wrapping, flex distribution, absolute layout, caching, rounding, and explicit compatibility gaps.
- Read text-layout-and-capabilities.md to implement grapheme width, wrapping, truncation, ANSI styling, hyperlinks, bidirectional text, tab stops, and response-driven terminal capability discovery.
- Read input-events.md to implement byte tokenization, key/mouse/paste/terminal-response decoding, propagation, focus, scrolling, and selection.