[OneDev #13] research: tui-use — let AI agents control interactive terminal programs #19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from OneDev issue #13 (id 35279)
Original project: internal-joseph
Original state: Closed
Original submitterId: 5
Original submitDate: 2026-04-10T17:07:19.174+00:00
Original lastActivity: {'date': '2026-04-24T21:24:32.242+00:00', 'description': "changed state to 'Closed'", 'userId': 5}
Original fields:
Idea
Evaluate tui-use (https://github.com/onesuper/tui-use) as a foundation for AI-driven interactive terminal control. It lets agents operate TUI programs (ncurses, prompts, menus) that normally block automation — think expect, but designed for AI agents.
Why
Directly complements internal-joseph#11 (interactive terminal driver app). Could be the ready-made substrate for that idea rather than building from scratch. Also useful for automating installer wizards, interactive CLI tools, and legacy TUI apps on managed endpoints.
Open questions
Imported from OneDev comment id 242 on issue #13
Original userId: 5
Original date: 2026-04-10T17:34:13.965+00:00
Research findings — tui-use
What it is
tui-use is a Node.js/TypeScript CLI tool (
npm install -g tui-use, v0.1.17) that wraps any command in a PTY session managed by a background daemon. An AI agent drives the program via shell subcommands (start,type,press,wait,snapshot), reading back a plain-text screen rendered by a headless xterm emulator. Self-described as "like BrowserUse, but for the terminal." The key insight:waitblocks until the screen stabilizes (debounce) rather than requiring sleep guesses, andhighlightsexposes inverse-video spans so agents can detect selected menu items without parsing ANSI codes.Interface & API
Pure CLI — no MCP server, no Python API. Agent calls shell subcommands:
Session model: background daemon holds PTY sessions across CLI invocations. Sessions identified by random
adjective-nounID (e.g.calm-otter). On Linux: Unix socket. On Windows: TCP port 7654.Snapshot JSON:
lines[](plain text per row),cursor {x,y},highlights[](inverse-video spans = selection indicator),status,is_fullscreen,title.Ships a Claude Code plugin (
.claude-plugin/dir, marketplace install via/plugin marketplace add onesuper/tui-use). Also an OpenAI Codex plugin.ANSI / terminfo coverage
Uses
@xterm/headless(xterm.js 6.x — same engine as VS Code terminal). Full VT100/VT220/xterm support. By default snapshot returns plain text (colors stripped).--colorflag (just merged 2026-04-10) re-encodes cell buffer as ANSI for the agent. Inverse-video is extracted intohighlights[]automatically.Key gaps: No F11/F12, no alt+key combos (alt+f/b for readline word nav), no shift+arrows, no mouse support, cursor-only moves not detected by
wait(open issue #4).License
MIT.
Maturity signals
Limitations
wait(issue #4 open)type/press— onlywaithas timeout logicAlternatives comparison
tui-use's rendered-screen snapshot model is fundamentally better for AI agents than pexpect's raw byte stream. The gap it fills in PCT: interactive programs (wizard installers, fzf pickers, pdb sessions) on Linux LXC containers where sshubble handles non-interactive commands fine.
Recommendation: BENCH
The design is correct. The snapshot model + debounce wait + inverse-video highlights is the right abstraction for AI agents. The Claude Code plugin packaging is a direct fit.
However: 3 days old, one real maintainer, test suite is mostly stubs, API visibly in flux, Windows ConPTY support just landed. Too early to put on a production path.
ADOPT conditions: revisit ~2026-04-24. Check: stars trend, npm version stabilization, issue #4 (cursor detection) closed, second real contributor merging a feature PR.
Suggested next steps (if watching)
git rebase -iinside a Linux LXC container via Claude Code on localinf — tests debounce/highlight flow without blocking any production pathnpm install -g tui-use, drive a PowerShell interactive installer, verify TCP 7654 isn't firewalledtui-use/SKILL.mdand add to meta/skills for shared availability on localinf and joseph-desktopImported from OneDev comment id 377 on issue #13
Original userId: 5
Original date: 2026-04-18T12:52:52.880+00:00
Expanding scope of this issue to cover the full PTY control evaluation, not just tui-use in isolation.
Expanded scope: ghst vs tui-use eval
PCT already has ghst — a self-built PTY session tool used daily for subagent dispatch. The original "self-implement" recommendation was pragmatic, not ideological. This issue now tracks a head-to-head eval to determine one of three outcomes:
wait --text, xterm-headless rendering)Eval rubric dimensions (proposed)
wait --text "..."vs polling)"Significantly better" must clear the migration cost bar — a narrow win still means keep ghst.
tui-use current status (as of 2026-04-18)
193 stars, v0.1.18, MIT, TypeScript, last commit April 11 2026, CI passing, ConPTY/Windows tests present. CLI daemon via
@xterm/headlessv6.0.0. Integrates with Claude Code via plugin. Supports vim, lazygit, htop, fzf, Python/Node REPLs.Also in scope: #11 and #14 closed and folded here.
Imported from OneDev comment id 378 on issue #13
Original userId: 5
Original date: 2026-04-18T13:08:07.566+00:00
Eval Plan — ghst vs tui-use
Test case: interactive diagnostic menu
Drive a shell script that presents a numbered menu (select a site, confirm action, read result) — realistic shape of PCT onboarding/diagnostic runbooks. Both tools must complete the same task: launch the script, read the menu, send a selection, read the result.
Setup
eval-target.shinC:/Users/Joseph/git/lab/tui-eval/— a bash script with aselectmenu and a confirmation promptRubric (each dimension 1–5)
Verdict thresholds
Session handoff
npm install -g tui-usetui-eval/eval-target.sh(select menu + confirm prompt)Imported from OneDev comment id 382 on issue #13
Original userId: 5
Original date: 2026-04-18T13:36:18.754+00:00
Eval Results — ghst vs tui-use
Test:
eval-target.sh— bashselectmenu (4 options), site selection, confirmation prompt, result output. Both tools completed the full flow successfully.Setup notes
--sessionflag removed; must usetui-use use <id>to set current session.wsl bash→ ran script directly.Rubric scores (1–5)
wait --textgenuinely blocks until pattern matches — zero polling. ghst relies on 400ms settle heuristic (works for fast programs, fragile for slow-starting ones).readreturns only recent lines — cleaner.sendreturns buffer in one call with 400ms settle. tui-use requires separatewait+snapshotsubprocess calls per step. Total tui-use run: ~6.4s.Verdict: Keep ghst as-is
tui-use wins by −4 (ghst wins). Rubric threshold for "borrow features" was +4–7 for tui-use. Does not meet bar.
One genuine tui-use advantage:
wait --textsemantic blocking is the right abstraction. ghst's settle heuristic is fragile for programs with variable startup time. Worth adding await_for_texthelper to the ghst skill (pollmcp__ghst__readuntil pattern matches, with timeout) — that closes the gap without migration.Hard blocker confirmed: tui-use cannot install on Node 20.11 without either upgrading system Node or using WSL. Until PCT migrates to Node 22+ as default, tui-use is not deployable on the primary Windows dev environment.
Closing recommendation
Close this issue as won't adopt. Open a separate small issue if we want to add a
wait_for_texthelper to the ghst skill.Imported from OneDev comment id 452 on issue #13
Original userId: 5
Original date: 2026-04-24T21:24:31.242+00:00
Eval complete, verdict is keep-ghst-as-is (ghst 20 / tui-use 16, details in 2026-04-18 comment). Closing as won't-adopt. File a separate narrow issue if we want the
wait_for_texthelper ported into the ghst skill.