tuistory
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTuistory Driver
Tuistory Driver
The orchestrator routed you here. Use these mechanics to execute your plan.
Launch a target command in a virtual PTY with Playwright-style CLI for typing, pressing keys, waiting, snapshotting, and recording.
编排器将你引导到这里。使用这些机制来执行你的计划。
在虚拟PTY中启动目标命令,采用Playwright风格的CLI来实现输入文本、按键、等待、快照和录制功能。
When to use
适用场景
- Routine TUI automation and regression checks
- Deterministic /
waitagainst the virtual screen bufferwait-idle - Text snapshots of exactly what the user would see
- Any scenario where you do not need to prove real terminal keyboard encoding
If you need to prove what Ghostty or Kitty actually emits for a given keystroke, use true-input instead.
- 常规TUI自动化与回归检查
- 针对虚拟屏幕缓冲区的确定性/
wait操作wait-idle - 精确捕获用户所见内容的文本快照
- 任何无需验证真实终端键盘编码的场景
如果你需要验证Ghostty或Kitty针对特定按键实际输出的内容,请改用true-input。
Prerequisites
前置条件
bash
npm install -g tuistory # or: bun add -g tuistoryOptional: (scrollback flows), (recordings), ( to ).
tmuxasciinemaagg.cast.gifbash
npm install -g tuistory # or: bun add -g tuistory可选依赖:(滚动回溯流)、(录制)、(将转换为)。
tmuxasciinemaagg.cast.gifCore pattern
核心模式
bash
TCTL=${DROID_PLUGIN_ROOT}/bin/tctl
$TCTL launch "droid-dev" -s demo --backend tuistory \
--repo-root /path/to/worktree \
--cols 120 --rows 36 \
--env FORCE_COLOR=3 --env COLORTERM=truecolor
$TCTL -s demo wait ">" --timeout 15000
$TCTL -s demo type "hello"
$TCTL -s demo press enter
$TCTL -s demo snapshot --trim
$TCTL -s demo closeNote: is mandatory for launches — enforces it.
--repo-rootdroid-devtctlAlways pass when launching. The virtual PTY doesn't advertise color support, so Node.js apps (Ink/chalk) suppress all color escape codes without these.
--env FORCE_COLOR=3 --env COLORTERM=truecolorbash
TCTL=${DROID_PLUGIN_ROOT}/bin/tctl
$TCTL launch "droid-dev" -s demo --backend tuistory \
--repo-root /path/to/worktree \
--cols 120 --rows 36 \
--env FORCE_COLOR=3 --env COLORTERM=truecolor
$TCTL -s demo wait ">" --timeout 15000
$TCTL -s demo type "hello"
$TCTL -s demo press enter
$TCTL -s demo snapshot --trim
$TCTL -s demo close注意: 启动时是必填项——会强制校验这一点。
droid-dev--repo-roottctl启动时务必传入。虚拟PTY不会主动声明颜色支持,因此如果没有这些环境变量,Node.js应用(如Ink/chalk)会抑制所有颜色转义码。
--env FORCE_COLOR=3 --env COLORTERM=truecolorCommand reference (via tctl)
命令参考(通过tctl)
| Command | Purpose |
|---|---|
| Start a tuistory session |
| Send literal text |
| Send key chord (e.g., |
| Block until text or |
| Block until output stabilizes |
| Print cleaned text ( |
| Tear down session |
Launch options: , , , , .
--cols <n>--rows <n>--cwd <path>--env KEY=VALUE--record <path>| 命令 | 用途 |
|---|---|
| 启动一个tuistory会话 |
| 发送文本内容 |
| 发送组合按键(例如: |
| 阻塞直到文本或 |
| 阻塞直到输出稳定 |
| 输出清理后的文本( |
| 销毁会话 |
启动选项:、、、、。
--cols <n>--rows <n>--cwd <path>--env KEY=VALUE--record <path>Recording
录制功能
Pass at launch. wraps around the PTY, so recording must be set at launch time (raw cannot record):
--recordtctlasciinema rectuistorybash
$TCTL launch "droid-dev" -s demo --backend tuistory \
--repo-root /path/to/worktree \
--cols 120 --rows 36 --record /tmp/demo.cast \
--env FORCE_COLOR=3 --env COLORTERM=truecolor启动时传入参数。会在PTY外层包裹,因此录制功能必须在启动时设置(原生无法实现录制):
--recordtctlasciinema rectuistorybash
$TCTL launch "droid-dev" -s demo --backend tuistory \
--repo-root /path/to/worktree \
--cols 120 --rows 36 --record /tmp/demo.cast \
--env FORCE_COLOR=3 --env COLORTERM=truecolor... interact ...
... 执行交互操作 ...
$TCTL -s demo close # finalizes the .cast
Before/after comparison -- launch two sessions against different worktrees:
```bash
$TCTL launch "droid-dev" -s before --backend tuistory \
--repo-root /path/to/baseline-worktree \
--cols 120 --rows 36 --record /tmp/before.cast \
--env FORCE_COLOR=3 --env COLORTERM=truecolor
$TCTL launch "droid-dev" -s after --backend tuistory \
--repo-root /path/to/candidate-worktree \
--cols 120 --rows 36 --record /tmp/after.cast \
--env FORCE_COLOR=3 --env COLORTERM=truecolorPlayback:
asciinema play /tmp/demo.cast$TCTL -s demo close # 完成.cast文件的生成
前后对比——针对不同工作目录启动两个会话:
```bash
$TCTL launch "droid-dev" -s before --backend tuistory \
--repo-root /path/to/baseline-worktree \
--cols 120 --rows 36 --record /tmp/before.cast \
--env FORCE_COLOR=3 --env COLORTERM=truecolor
$TCTL launch "droid-dev" -s after --backend tuistory \
--repo-root /path/to/candidate-worktree \
--cols 120 --rows 36 --record /tmp/after.cast \
--env FORCE_COLOR=3 --env COLORTERM=truecolor回放:
asciinema play /tmp/demo.casttmux (scrollback flows only)
tmux(仅用于滚动回溯流)
Only needed when the demo requires terminal-emulator scrollback and the app uses the standard buffer (not alternate screen). True-input sessions rarely need tmux because the real terminal owns native scrollback.
Use at launch. wraps the command in tmux, starts tmux with , and preconfigures , , (fallback for tmux < 3.2), (via ), , and .
--tmuxtctlTERM=xterm-256colordefault-terminal=tmux-256colorterminal-features=...,xterm-256color:RGBterminal-overrides=...,xterm-256color:TcCOLORTERM=truecolorset-environmentescape-time=50mode-keys=viCopy-mode: to enter, top, bottom, / half-page, search, to exit (not ).
ctrl-b [g gshift-gctrl-uctrl-d/qescLaunch with tmux:
bash
$TCTL launch "droid-dev" -s demo --backend tuistory --tmux \
--repo-root /path/to/worktree \
--cols 120 --rows 36 --record /tmp/demo.cast \
--env FORCE_COLOR=3 --env COLORTERM=truecolorWhen recording includes tmux redraws, asciinema must wrap tmux, not the reverse.
仅当演示需要终端模拟器的滚动回溯功能,且应用使用标准缓冲区(而非交替屏幕)时才需要使用。True-input会话很少需要tmux,因为真实终端拥有原生滚动回溯功能。
启动时使用参数。会在tmux中包裹命令,启动tmux时设置,并预先配置、、(针对tmux < 3.2的兼容方案)、(通过设置)、和。
--tmuxtctlTERM=xterm-256colordefault-terminal=tmux-256colorterminal-features=...,xterm-256color:RGBterminal-overrides=...,xterm-256color:TcCOLORTERM=truecolorset-environmentescape-time=50mode-keys=vi复制模式:按进入,跳转到顶部,跳到底部,/翻半页,搜索,退出(不要用)。
ctrl-b [g gshift-gctrl-uctrl-d/qesc使用tmux启动:
bash
$TCTL launch "droid-dev" -s demo --backend tuistory --tmux \
--repo-root /path/to/worktree \
--cols 120 --rows 36 --record /tmp/demo.cast \
--env FORCE_COLOR=3 --env COLORTERM=truecolor当录制包含tmux重绘内容时,必须由asciinema包裹tmux,而不是反过来。
Known dead ends
已知误区
- Raw : Do not call
asciinema recdirectly.asciinema recwrapstctl --recordaround the PTY so that tuistory-relay still owns the session and interactive TUIs (Ink/React) receive stdin correctly. Callingasciinema recmanually bypasses this wiring — stdin forwarding breaks, typed keys echo on the outer PTY instead of reaching the child, and tuistory commands (asciinema rec,wait,snapshot) cannot find the session.close - Raw with tctl flags:
tuistory launchhas notuistory,--record,--backend, or--repo-rootflags. Passing them crashes--env. Usetuistory-relayfor all launches.tctl
- 直接使用:不要直接调用
asciinema rec。asciinema rec会在PTY外层包裹tctl --record,这样tuistory-relay仍能控制会话,且交互式TUI(如Ink/React)能正确接收标准输入。手动调用asciinema rec会绕过该机制——标准输入转发失效,输入的按键会在外部PTY回显而非传递给子进程,且tuistory命令(asciinema rec、wait、snapshot)无法找到会话。close - 在原生中使用tctl参数:
tuistory launch没有tuistory、--record、--backend或--repo-root参数。传入这些参数会导致--env崩溃。所有启动操作请使用tuistory-relay。tctl
Recovery
恢复操作
bash
$TCTL -s demo press esc # bail out of a stuck dialog
$TCTL -s demo snapshot --trim # check visible state
$TCTL -s demo close # hard resetbash
$TCTL -s demo press esc # 退出卡住的对话框
$TCTL -s demo snapshot --trim # 检查当前可见状态
$TCTL -s demo close # 强制重置会话Escape hatch: raw tuistory (last resort)
应急方案:原生tuistory(最后手段)
If itself is broken or unavailable, you can fall back to raw for non-recording sessions only. Raw accepts only , , and — no other flags. Do not pass , , , , or .
tctltuistorytuistory--cols--rows-s--record--backend--repo-root--env--tmuxbash
tuistory launch "my-tui-app" -s demo --cols 120 --rows 36
tuistory -s demo wait ">" --timeout 15000
tuistory -s demo snapshot --trim
tuistory -s demo close如果本身损坏或不可用,你可以退回到原生,但仅适用于非录制会话。原生仅接受、和参数——不支持其他任何参数。请勿传入、、、或。
tctltuistorytuistory--cols--rows-s--record--backend--repo-root--env--tmuxbash
tuistory launch "my-tui-app" -s demo --cols 120 --rows 36
tuistory -s demo wait ">" --timeout 15000
tuistory -s demo snapshot --trim
tuistory -s demo close