herdr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHerdr
Herdr
Herdr organizes terminals into workspaces, tabs, and panes, recognizes coding agents running inside panes, and exposes the current session through the CLI.
herdrBefore issuing any control command, verify that this agent is running inside a Herdr-managed pane:
bash
test "${HERDR_ENV:-}" = 1If the check fails, say that you are not running inside Herdr and stop. Do not inspect or control the focused Herdr session from outside Herdr.
When the check passes, the binary in talks to the current session. Use it to inspect neighboring work, create terminal layout, start agents and commands, read output, and wait for state changes.
herdrPATHHerdr将终端组织为工作区、标签页和窗格,识别在窗格内运行的编码Agent,并通过 CLI暴露当前会话。
herdr在执行任何控制命令之前,请验证当前Agent是否运行在Herdr管理的窗格中:
bash
test "${HERDR_ENV:-}" = 1如果检查失败,请告知用户当前未运行在Herdr环境中并停止操作。不要从Herdr外部检查或控制已聚焦的Herdr会话。
如果检查通过,中的二进制文件会与当前会话通信。可使用它来查看相邻任务、创建终端布局、启动Agent和命令、读取输出以及等待状态变更。
PATHherdrLearn the current CLI
了解当前CLI
The installed binary is the authority for command syntax. Start with:
bash
herdr --helpThen print the relevant command group by running the group without a subcommand:
bash
herdr agent
herdr pane
herdr workspace
herdr tab
herdr worktree
herdr terminal
herdr notification
herdr integration
herdr sessionDo not run bare for discovery; it launches or attaches the TUI. Do not probe a mutating nested command by omitting arguments. Commands such as are valid with defaults and will execute.
herdrherdr workspace createMost control commands return JSON. Read identifiers and state from those responses instead of predicting them.
已安装的二进制文件是命令语法的权威来源。从以下命令开始:
bash
herdr --help然后通过不带子命令的方式运行命令组,查看相关命令组的信息:
bash
herdr agent
herdr pane
herdr workspace
herdr tab
herdr worktree
herdr terminal
herdr notification
herdr integration
herdr session不要运行裸命令来探索功能;它会启动或附加到TUI。不要通过省略参数来尝试可变嵌套命令。诸如的命令在使用默认值时是有效的,并且会直接执行。
herdrherdr workspace create大多数控制命令会返回JSON。请从这些响应中读取标识符和状态,而非自行预测。
Understand layout, panes, and agents
理解布局、窗格和Agent
Choose the primitive that matches the job:
- Workspace, tab, and pane topology organize terminal locations.
- Pane commands control raw terminals, shells, tests, servers, input, and output.
- Agent commands control the recognized coding agent currently occupying a pane.
A pane exists whether or not it contains an agent. requires an existing available shell pane and never creates, splits, or moves layout. Use pane commands for ordinary processes. Use agent commands when Herdr must validate agent identity or interpret , , , , and lifecycle states.
agent startidleworkingblockeddoneunknownAgent commands accept either a unique live agent name or the pane ID currently hosting that agent. They do not accept terminal IDs or bare agent-kind labels. Names must match and be unique among live agents. A name follows the current pane occupant and is cleared when that agent exits, is released, or is replaced.
[a-z][a-z0-9_-]{0,31}idledoneblockedunknown选择与任务匹配的基本单元:
- 工作区、标签页和窗格的拓扑结构用于组织终端位置。
- 窗格命令用于控制原始终端、Shell、测试、服务器、输入和输出。
- Agent命令用于控制当前占用窗格的已识别编码Agent。
无论窗格中是否包含Agent,窗格都存在。命令需要一个已有的可用Shell窗格,且不会创建、拆分或移动布局。对于普通进程,请使用窗格命令。当Herdr需要验证Agent身份或解释、、、和生命周期状态时,请使用Agent命令。
agent startidleworkingblockeddoneunknownAgent命令接受唯一的活跃Agent名称或当前托管该Agent的窗格ID。不接受终端ID或裸Agent类型标签。名称必须匹配格式,且在活跃Agent中唯一。名称会跟随当前窗格的占用者,当该Agent退出、被释放或被替换时,名称会被清除。
[a-z][a-z0-9_-]{0,31}idledoneidleblockedunknownUse IDs and caller context
使用ID和调用者上下文
Public IDs are opaque stable handles:
- workspace:
w1 - tab:
w1:t1 - pane:
w1:p1
Closed tab and pane IDs are not reused. A pane moved into another workspace receives a new workspace-qualified pane ID. After , continue with or the live agent name. The old value is reported as ; only the moved process's inherited caller context keeps resolving that old ID, so do not use it as a general agent target.
pane move.result.move_result.pane.pane_id.result.move_result.previous_pane_idHerdr injects the caller's context into each managed pane:
bash
printf '%s\n' "$HERDR_WORKSPACE_ID" "$HERDR_TAB_ID" "$HERDR_PANE_ID"Prefer when a pane command should target the calling pane. Omitting a target may use the UI-focused pane, which can belong to the user or another client.
--currentDiscover live state with:
bash
herdr workspace list
herdr tab list --workspace "$HERDR_WORKSPACE_ID"
herdr pane current --current
herdr pane list --workspace "$HERDR_WORKSPACE_ID"
herdr agent listCreation responses expose the IDs to use next. returns , , and . returns and . returns the new pane as .
workspace create.result.workspace.result.tab.result.root_panetab create.result.tab.result.root_panepane split.result.pane公开ID是不透明的稳定句柄:
- 工作区:
w1 - 标签页:
w1:t1 - 窗格:
w1:p1
已关闭的标签页和窗格ID不会被复用。当窗格被移动到另一个工作区时,会获得一个新的工作区限定窗格ID。执行后,请使用或活跃Agent名称继续操作。旧值会被报告为;只有被移动进程继承的调用者上下文会继续解析该旧ID,因此不要将其用作通用Agent目标。
pane move.result.move_result.pane.pane_id.result.move_result.previous_pane_idHerdr会将调用者的上下文注入每个受管理的窗格:
bash
printf '%s\n' "$HERDR_WORKSPACE_ID" "$HERDR_TAB_ID" "$HERDR_PANE_ID"当窗格命令需要定位调用者所在窗格时,优先使用参数。省略目标参数可能会使用UI聚焦的窗格,该窗格可能属于用户或其他客户端。
--current通过以下命令发现实时状态:
bash
herdr workspace list
herdr tab list --workspace "$HERDR_WORKSPACE_ID"
herdr pane current --current
herdr pane list --workspace "$HERDR_WORKSPACE_ID"
herdr agent list创建操作的响应会暴露后续要使用的ID。会返回、和。会返回和。会返回新窗格的。
workspace create.result.workspace.result.tab.result.root_panetab create.result.tab.result.root_panepane split.result.paneStart and coordinate an agent
启动并协调Agent
Default to a sibling pane in the current tab and the current working directory. Do not create a workspace, tab, worktree, or different cwd unless the user explicitly requests that topology or location.
Honor a direction requested by the user. Otherwise inspect the caller pane:
bash
herdr pane layout --pane "$HERDR_PANE_ID"Split a wide pane to the right and a narrow or tall pane down. Avoid repeated same-direction splits that create unusably narrow columns or short rows. Keep the user's focus in the calling pane and explicitly preserve the caller's working directory:
bash
herdr pane split --current --direction right --cwd "$PWD" --no-focusReplace with when appropriate. Read the new pane ID from .
rightdown.result.pane.pane_idAn available shell pane must be at its interactive prompt, with the shell itself in the foreground and no foreground command, editor, or agent running. Start a supported agent in that pane with a useful unique name:
bash
herdr agent start reviewer --kind codex --pane <returned-pane-id>Use the kind requested by the user. Run to inspect the installed kind list and options. Pass native agent arguments only after :
herdr agent--bash
herdr agent start reviewer --kind codex --pane <returned-pane-id> -- <agent-args...>agent startSubmit work through the agent surface:
bash
herdr agent prompt reviewer "Review the current diff and report only actionable findings." --wait --timeout 120000agent prompt--waitidledoneblocked--untilA prompt sent from a non-working state must produce an observed lifecycle change within five seconds. Otherwise Herdr returns instead of waiting indefinitely. This wait tracks lifecycle state, not an individual turn; if the agent is already working, completion of the active turn may satisfy it.
agent_prompt_stalledUse only for a state-specific workflow, such as waiting for an already-running agent to request input:
--untilbash
herdr agent wait reviewer --until blocked --timeout 120000Without , standalone uses the same settled-state defaults as .
--untilagent waitagent prompt --waitUse logical keys for interactive agent UI controls:
bash
herdr agent send-keys reviewer esc
herdr agent send-keys reviewer ctrl+cHerdr validates all keys before writing any bytes. Read the result through the resolved agent:
bash
herdr agent get reviewer
herdr agent read reviewer --source recent-unwrapped --lines 120If a wait fails or returns , inspect and before deciding what input to send. Use the pane surface only when raw terminal control is intentional.
blockedagent getagent read默认在当前标签页的同级窗格中启动,并使用当前工作目录。除非用户明确请求特定拓扑结构或位置,否则不要创建工作区、标签页、工作树或使用不同的工作目录。
遵循用户请求的方向。否则,请检查调用者所在的窗格:
bash
herdr pane layout --pane "$HERDR_PANE_ID"宽窗格向右拆分,窄窗格或高窗格向下拆分。避免重复同一方向的拆分,以免创建无法使用的窄列或短行。保持用户焦点在调用者所在窗格,并明确保留调用者的工作目录:
bash
herdr pane split --current --direction right --cwd "$PWD" --no-focus适当时将替换为。从中读取新窗格的ID。
rightdown.result.pane.pane_id可用的Shell窗格必须处于交互式提示符状态,Shell本身位于前台,且没有前台命令、编辑器或Agent在运行。在该窗格中使用一个有用的唯一名称启动受支持的Agent:
bash
herdr agent start reviewer --kind codex --pane <returned-pane-id>使用用户请求的Agent类型。运行查看已安装的类型列表和选项。仅在之后传递原生Agent参数:
herdr agent--bash
herdr agent start reviewer --kind codex --pane <returned-pane-id> -- <agent-args...>只有当Herdr在同一窗格中检测到预期的Agent并认为其已准备好接收交互式输入时,才会返回。它默认设置30秒的启动超时时间。
agent start通过Agent界面提交任务:
bash
herdr agent prompt reviewer "Review the current diff and report only actionable findings." --wait --timeout 120000agent prompt--waitidledoneblocked--until从未工作状态发送的提示必须在5秒内产生可观察到的生命周期变更。否则,Herdr会返回,而非无限等待。此等待跟踪的是生命周期状态,而非单个交互回合;如果Agent已经在工作,完成当前交互回合即可满足条件。
agent_prompt_stalled仅针对特定状态的工作流使用,例如等待已运行的Agent请求输入:
--untilbash
herdr agent wait reviewer --until blocked --timeout 120000如果不使用,独立的命令会使用与相同的稳定状态默认设置。
--untilagent waitagent prompt --wait使用逻辑键控制交互式Agent UI:
bash
herdr agent send-keys reviewer esc
herdr agent send-keys reviewer ctrl+cHerdr会在写入任何字节之前验证所有按键。通过已解析的Agent读取结果:
bash
herdr agent get reviewer
herdr agent read reviewer --source recent-unwrapped --lines 120如果等待失败或返回状态,请先检查和的结果,再决定发送什么输入。仅当需要原始终端控制时,才使用窗格界面。
blockedagent getagent readRun an ordinary command in another pane
在另一个窗格中运行普通命令
Create a sibling pane with the same geometry rule, preserve the caller's working directory, and keep user focus unchanged:
bash
herdr pane split --current --direction right --cwd "$PWD" --no-focusRead the new pane ID from , then run and inspect the command:
.result.pane.pane_idbash
herdr pane run <returned-pane-id> "just test"
herdr pane wait-output <returned-pane-id> --match "test result" --timeout 120000
herdr pane read <returned-pane-id> --source recent-unwrapped --lines 120pane runpane wait-output--match <text>--regex <pattern>--timeoutUse the read source that matches the task:
- : the currently rendered viewport.
visible - : recent rendered output, including soft wraps.
recent - : recent output with soft wraps joined; prefer it for logs and transcripts.
recent-unwrapped - : the plain-text bottom-buffer snapshot used for agent detection.
detection
Use when colors and terminal styling are evidence. Otherwise use text.
--format ansi--linesAfter that failed read, ask the agent to write its complete response as Markdown in a temporary directory and reply only with the file path, then read the file directly. Use this only as a fallback; do not request file output in the initial prompt.
按照相同的几何规则创建同级窗格,保留调用者的工作目录,并保持用户焦点不变:
bash
herdr pane split --current --direction right --cwd "$PWD" --no-focus从中读取新窗格的ID,然后运行并检查命令:
.result.pane.pane_idbash
herdr pane run <returned-pane-id> "just test"
herdr pane wait-output <returned-pane-id> --match "test result" --timeout 120000
herdr pane read <returned-pane-id> --source recent-unwrapped --lines 120pane runpane wait-output--match <text>--regex <pattern>--timeout选择与任务匹配的读取源:
- :当前渲染的视口。
visible - :最近渲染的输出,包括软换行。
recent - :合并软换行后的最近输出;对于日志和记录,优先使用此选项。
recent-unwrapped - :用于Agent检测的纯文本底部缓冲区快照。
detection
当颜色和终端样式作为证据时,使用。否则使用文本格式。
--format ansi--lines如果读取失败,请要求Agent将完整响应以Markdown格式写入临时目录,并仅回复文件路径,然后直接读取该文件。仅将此作为后备方案;不要在初始提示中请求文件输出。
Safety and coordination rules
安全与协调规则
- Use for background work unless the user asked to switch context.
--no-focus - Use , an explicit pane ID, or a unique agent name. Do not rely on another client's focused pane.
--current - Parse IDs from JSON responses. Do not derive them from sidebar order or examples.
- Do not close workspaces, tabs, panes, or sessions you did not create unless the user explicitly asked.
- Never run from an active session unless the user explicitly intends to stop the server and its pane processes.
herdr server stop - Never kill the main Herdr process. Use named test sessions for experiments that need an isolated server.
- CLI server errors are JSON on stderr with exit status 1. CLI syntax errors exit with status 2.
- 除非用户要求切换上下文,否则对后台任务使用。
--no-focus - 使用、明确的窗格ID或唯一的Agent名称。不要依赖其他客户端的聚焦窗格。
--current - 从JSON响应中解析ID。不要从侧边栏顺序或示例中推导ID。
- 除非用户明确要求,否则不要关闭你未创建的工作区、标签页、窗格或会话。
- 除非用户明确打算停止服务器及其窗格进程,否则不要从活动会话中运行。
herdr server stop - 永远不要终止主Herdr进程。对于需要隔离服务器的实验,请使用命名测试会话。
- CLI服务器错误会以JSON格式输出到stderr,退出状态为1。CLI语法错误的退出状态为2。