clrun
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseclrun — The Interactive CLI for AI Agents
clrun — 面向AI Agent的交互式CLI工具
No more flags or command retries. gives you full control over interactive terminal sessions with structured YAML responses.
--yesclrun无需再使用参数或重复执行命令。让你通过结构化的YAML响应,完全掌控交互式终端会话。
--yesclrunInstall
安装
bash
npm install -g clrunbash
npm install -g clrunCore Commands
核心命令
| Action | Command |
|---|---|
| Run a command | |
| Send text + Enter | |
| Send keystrokes | |
| Toggle checkbox | |
| Accept default | |
| View output | |
| Check sessions | |
| Kill session | |
| Interrupt | |
| 操作 | 命令 |
|---|---|
| 运行命令 | |
| 发送文本并回车 | |
| 发送按键 | |
| 切换复选框 | |
| 接受默认值 | |
| 查看输出 | |
| 查看会话状态 | |
| 终止会话 | |
| 中断进程 | |
Two Input Modes
两种输入模式
Text input — sends text followed by Enter:
bash
clrun <id> "my-project-name" # Type and press Enter
clrun <id> "" # Just press EnterKeystroke input — sends raw keys for TUI navigation:
bash
clrun key <id> down down enter # Select 3rd item in list
clrun key <id> space down space enter # Toggle checkboxes 1 and 2
clrun key <id> enter # Accept defaultAvailable keys: , , , , , , , , , , , , , , , , , , , , ,
updownleftrightentertabescapespacebackspacedeletehomeendpageuppagedownctrl-cctrl-dctrl-zctrl-lctrl-actrl-eyn文本输入 — 发送文本后自动回车:
bash
clrun <id> "my-project-name" # 输入内容并按回车
clrun <id> "" # 仅按回车按键输入 — 发送原始按键用于TUI导航:
bash
clrun key <id> down down enter # 选择列表中的第3项
clrun key <id> space down space enter # 切换第1和第2个复选框
clrun key <id> enter # 接受默认值支持的按键:, , , , , , , , , , , , , , , , , , , , ,
updownleftrightentertabescapespacebackspacedeletehomeendpageuppagedownctrl-cctrl-dctrl-zctrl-lctrl-actrl-eynIdentifying Prompt Types
识别提示类型
When you a session, identify the prompt type to choose the right input:
tail| You see | Type | Action |
|---|---|---|
| Text input | |
| Single-select | |
| Multi-select | |
| Confirm | |
| Simple confirm | |
| Readline | |
当你使用查看会话时,需要识别提示类型以选择正确的输入方式:
tail| 显示内容 | 类型 | 操作 |
|---|---|---|
| 文本输入 | |
| 单选列表 | |
| 多选列表 | |
| 确认选择 | |
| 简单确认 | |
| Readline输入 | |
Select List Navigation
选择列表导航
Count items from the top. First item is highlighted by default. To select item N, send N-1 presses then .
downenter◆ Select a framework:
│ ● Vanilla ← 0 downs
│ ○ Vue ← 1 down
│ ○ React ← 2 downs
│ ○ Svelte ← 3 downsbash
clrun key <id> down down enter # Selects React从顶部开始计数选项。默认高亮第一个选项。要选择第N项,发送N-1次按键,然后按。
downenter◆ 选择框架:
│ ● Vanilla ← 0次down
│ ○ Vue ← 1次down
│ ○ React ← 2次down
│ ○ Svelte ← 3次downbash
clrun key <id> down down enter # 选择ReactMulti-Select Pattern
多选模式
Plan a sequence of (toggle) and (skip) from top to bottom, ending with :
spacedownenterbash
undefined规划从顶部到底部的(切换)和(跳过)序列,最后按确认:
spacedownenterbash
undefinedSelect items 1, 3, and 4 from a list of 5:
从5个选项中选择第1、3、4项:
clrun key <id> space down down space down space enter
clrun key <id> space down down space down space enter
item1 skip skip item3 item4 confirm
选第1项 跳过 跳过 选第3项 选第4项 确认
undefinedundefinedReading Responses
读取响应
All responses are structured YAML. Key fields:
- — store this for all subsequent calls
terminal_id - — cleaned terminal output (ANSI stripped)
output - —
status,running,suspended,exited,killeddetached - — exact commands you can run next (copy-pasteable)
hints - — detected issues with input or output
warnings
所有响应均为结构化YAML格式。关键字段:
- — 保存该ID用于后续所有调用
terminal_id - — 清理后的终端输出(已去除ANSI代码)
output - —
status(运行中)、running(已挂起)、suspended(已退出)、exited(已终止)、killed(已分离)detached - — 可直接复制粘贴的下一步执行命令
hints - — 检测到的输入或输出问题
warnings
Workflow Pattern
工作流模式
1. START → clrun <command> → get terminal_id
2. OBSERVE → clrun tail <id> → read output, identify prompt
3. INTERACT → clrun <id> "text" / clrun key → respond to prompt
4. REPEAT → steps 2-3 until done
5. CLEANUP → clrun kill <id> → if needed1. 启动 → clrun <command> → 获取terminal_id
2. 观察 → clrun tail <id> → 读取输出,识别提示类型
3. 交互 → clrun <id> "text" / clrun key → 响应提示
4. 重复 → 重复步骤2-3直至完成
5. 清理 → clrun kill <id> → 如有需要Shell Variable Quoting
Shell变量引用
Use single quotes to prevent your shell from expanding variables:
$bash
clrun <id> 'echo $MY_VAR' # Correct
clrun <id> "echo $MY_VAR" # Wrong — expanded before clrun sees it使用单引号防止shell扩展变量:
$bash
clrun <id> 'echo $MY_VAR' # 正确
clrun <id> "echo $MY_VAR" # 错误 — shell会在clrun处理前扩展变量Session Persistence
会话持久化
- Environment variables persist within a session
- Sessions auto-suspend after 5 min idle (env and cwd saved)
- Sending input to a suspended session auto-restores it
- No pre-check needed — just send input
See references/tui-patterns.md for complete real-world examples.
- 环境变量在会话内保持持久
- 会话闲置5分钟后自动挂起(环境变量和当前工作目录已保存)
- 向挂起的会话发送输入会自动恢复会话
- 无需预先检查,直接发送输入即可
完整的真实场景示例请查看references/tui-patterns.md。