원클릭으로
terminal-vt-core
改动 PTY 会话、libghostty-vt 桥接、终端输入、OSC/HTML 适配时使用。覆盖终端状态唯一真相源、会话协议、输出合并与输入路径。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
改动 PTY 会话、libghostty-vt 桥接、终端输入、OSC/HTML 适配时使用。覆盖终端状态唯一真相源、会话协议、输出合并与输入路径。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
做渲染/滚动/输出性能优化,或需要判断"正确性 vs 流畅 vs 可读性"取舍时使用。覆盖脏行渲染、缓存层、合并、render loop 禁忌。
改动 ProGhostty 渲染层(Metal 直渲 / cell-grid 回退 / 滚动 / 脏行)时使用。覆盖三层降级梯、不可变快照契约、像素滚动路径与渲染边界。
改动工作区、分屏树、pane 生命周期、App 层协调 (AppModel)、或 App↔Core 分层时使用。覆盖唯一 owner、值类型分屏树与分层边界。
SOC 직업 분류 기준
| name | terminal-vt-core |
| description | 改动 PTY 会话、libghostty-vt 桥接、终端输入、OSC/HTML 适配时使用。覆盖终端状态唯一真相源、会话协议、输出合并与输入路径。 |
改任何 TerminalCore/PTY/、TerminalCore/LibGhostty/、或输入/OSC 相关代码前读本文件。
libghostty-vt 是终端状态唯一真相源:光标、屏幕缓冲、scrollback、终端状态、ANSI/VT 解析全归它。libghostty-vt 之外解析 ANSI/VT。 Swift 侧不重新解析终端字节。SIGWINCH。zsh/vim/ssh/... → PTY(进程 + 字节)→ libghostty-vt(VT 引擎,真相源)
→ GhosttyVTBridge(唯一适配边界)→ Swift 值快照 → Renderer
产品代码只能依赖 TerminalSessionManager / TerminalSurfaceRegistry / 会话 ID / 值类型,不得依赖 GhosttyVTBridge、C/Zig 头文件、GhosttyKit 类型。
PTYTerminalEngine(PTY/PTYTerminalEngine.swift:199)— 同时实现 TerminalSessionManager + TerminalSurfaceRegistry,是 PTY I/O 与会话生命周期的 owner。PTYTerminalSessionManager(同文件:302)— 会话管理具体实现。TerminalSessionManager(协议,TerminalModels.swift:57):createSession / closeSession / resizeSession / writeInput / writePaste / workingDirectory / controlToken / hasForegroundProcess / events。MockTerminalEngine(Mock/)— UI/数据层可脱离真实 PTY 开发;保持它可用。PTYTerminalSurfaceRegistry — 把会话映射到 NSView / 渲染表面。GhosttyVTBridge(LibGhostty/GhosttyVTBridge.swift)— 唯一 libghostty-vt 适配边界。write 喂字节;frame() / scrollFrame(overscanTop:overscanBottom:) / scrollbar 出快照;scrollViewport 移动权威视口。它拥有 VT 交互,别在别处调 C API。GhosttyHTMLAttributedAdapter — 把 VT HTML 输出转 NSAttributedString(文本回退用)。HTMLPaletteNormalizer(纯字符串/正则,无 AppKit)— 把 var(--vt-palette-N) + <style> 改写成具体 rgb(...),幂等。放在 VT 层而非 AppKit 适配层。PTY 字节 → TerminalOutputBatchCoordinator(合并原始字节)→ TerminalOutputCoordinator(合并 render 快照)→ 渲染。两级共分一个 8ms 预算(各 4ms,pipelineStageDelayNanoseconds),交互回显走 .immediate 绕过两级。改输出延迟/合并时保持这个预算划分,别让字节→像素最坏延迟翻倍。
TerminalInputStateMachine(TerminalCore/)— 输入状态机(纯逻辑,不该 import AppKit)。TerminalSurfaceRegistry.set*Handler(...) 注入。TerminalInputRouter、LibGhosttyTerminalEngine。老文档提到它们即过期。PTY 字节
→ PTYTerminalEngine 读出
→ GhosttyVTBridge.write → libghostty-vt(解析 + 维护全部终端状态)
→ PTYTerminalSurfaceRegistry.render → GhosttyVTBridge.frame/scrollFrame
→ GhosttyTerminalFrame / TerminalRenderFrame(不可变值)
→ 渲染后端
事件(output/osc/bell/cwd/title)→ TerminalEvent(AsyncStream)→ App 层
$/%/❯)猜命令边界(用 OSC 133/7 语义事件)。TerminalSessionManager 直接碰 PTY。GhosttyVTBridge)。TerminalInputStateMachine 引 AppKit。CLAUDE.md(产品方向与核心原则)、docs/architecture/ownership-map.md(职责归属)、docs/libghostty-vt.md(vendored 构建)、docs/architecture/ghostty-html-compatibility.md。测试:GhosttyVTBridgeTests、OscParserTests、PTYLaunchTests、TerminalInputStateMachineTests、GhosttyHTMLAttributedAdapterTests。