Usage Guide and Coexistence with Original Herdr
Zero-conflict coexistence strategy with original Herdr, environment variable isolation, daily workflows, and configuration reference.
Herdr2 is an AI coding workbench and multi-agent orchestration runtime built on a hybrid dual-plane architecture (“real workspace terminals + headless background ACP sub-agents”), consisting of:
h2/herdr2(Core daemon & CLI): Manages both interactive human workspace terminals (t1,t2, …) and background headless ACP sub-agents (a1,a2, …).Herdr2(herdr2/herdr2-appdesktop client): A native multi-Space, Tab, and Split-pane desktop client powered by GPUI andlibghostty-vt.
1. What Problem Herdr2 Solves: Hybrid Architecture Design
Section titled “1. What Problem Herdr2 Solves: Hybrid Architecture Design”Original Herdr placed both human workspaces and spawned sub-agents inside PTY/ConPTY sessions: whenever a primary agent fanned out sub-agents, it either flooded the UI with extra terminal panes or had to scrape terminal screen characters heuristically to guess sub-agent progress, permission blocks, and completion.
Herdr2’s solution splits responsibilities into two orthogonal planes:
| Dimension | Human Workspace Terminal (t1, t2, …) |
Background Sub-Agent (a1, a2, …) |
|---|---|---|
| Launch mechanism | Herdr2 UI (New space / New tab / Split / + menu Terminal or CLI tools), terminal.run |
h2 run, built-in MCP tool h2_run, RPC agent.run |
| Underlying transport | Local PTY / Windows ConPTY + holder daemon + libghostty-vt |
Pure headless ACP (stdio JSON-RPC 2.0 / NDJSON) |
| Child environment | Full terminal environment (TERM=xterm-256color, COLORTERM=truecolor, TERM_PROGRAM=ghostty, H2_TERMINAL_ID) |
Terminal-free environment (ClientCapabilities { fs: false, terminal: false }, strips TERM* and H2_TERMINAL_*, injects H2_AGENT_ID) |
| Desktop presentation | Displayed directly as Space / Tab / Split panes with full interactive input and shortcuts | Never opens a terminal pane on desktop and never appears in terminal.list |
| Orchestration & collaboration | Humans work directly in shells or CLIs (such as claude, codex); CLIs use $H2_TERMINAL_ID to spawn/wait on sub-agents via h2 |
Serial inbox queue + --steer preemption + Core permission arbitration (approve-reads) + structured transcript (h2 read) |
Core collaboration loop:
- You open a standard shell or interactive coding CLI in a
Herdr2desktop window (running inside a real Ghostty/PTY panet1). - When the coding CLI needs parallel research or sub-task execution, it invokes
h2 runor the built-inh2_runMCP tool to spawn sub-agentsa1,a2, … - Sub-agents execute purely in headless ACP mode in the background;
h2automatically bindsparentto the originating terminal (t1), keeping your workspace free of unwanted popups, while status updates and permission blocks flow back to the parent viah2 wait/notes. - Closing desktop pane
t1automatically cleans up its spawned sub-agents under the defaultdie_with_parentpolicy (use--outlive-parentto keep them alive).
2. Zero-Conflict Coexistence Layout with Original Herdr
Section titled “2. Zero-Conflict Coexistence Layout with Original Herdr”Herdr2 and original Herdr (herdr-app + hc) use completely isolated executable names, config directories, state paths, sockets/pipes, environment variables, and Start Menu entries so both can run side by side indefinitely:
| Component | Platform | Original Herdr | Herdr2 (This Project) |
|---|---|---|---|
| Core runtime CLI | Linux / WSL2 | ~/.local/bin/hc (herdr-core) |
~/.local/bin/h2 (herdr2) |
| Core runtime CLI | Windows | %LOCALAPPDATA%\Programs\herdr-core\hc.exe |
%LOCALAPPDATA%\Programs\h2\h2.exe (with herdr2-core.exe & conpty/) |
| Core state directory | Linux / Windows | ~/.local/state/herdr-core/ |
~/.local/state/herdr2/ / %LOCALAPPDATA%\herdr2\ |
| Core config & templates | Linux / Windows | ~/.config/herdr/ |
~/.config/herdr2/ |
| Core env var prefix | All platforms | HC_* (HC_AGENT_ID / HC_TERMINAL_ID) |
H2_* (H2_AGENT_ID / H2_TERMINAL_ID / H2_SESSION / H2_SOCKET) |
| Desktop binary | Windows / Linux | herdr-app.exe / herdr-app |
herdr2.exe (with herdr2-app.exe) / herdr2 |
| Desktop install directory | Windows | %LOCALAPPDATA%\Programs\herdr-app\ |
%LOCALAPPDATA%\Programs\herdr2\ |
| Desktop config home | Linux / Windows | ~/.config/herdr-app (HERDR_APP_HOME) |
~/.config/herdr2-app (HERDR2_APP_HOME) |
| Control socket / doc key | All platforms | herdr-app.sock / "herdr-app" |
herdr2-app.sock / "herdr2-app" |
| Windows title & shortcut | Windows | "Herdr" / Herdr.lnk |
"Herdr2" / Herdr2.lnk |
3. Desktop Workbench (Herdr2 GUI & Control CLI)
Section titled “3. Desktop Workbench (Herdr2 GUI & Control CLI)”3.1 Opening Terminals and Interactive Agents
Section titled “3.1 Opening Terminals and Interactive Agents”Launch herdr2 (or click Herdr2 in the Windows Start Menu):
- New Space / New Tab / Split Pane: Immediately starts your local shell in a real PTY/ConPTY (default interactive shell on Linux/macOS,
powershell.exeon Windows), rendered bylibghostty-vtand managed byholder. The top tab bar supports horizontal drag reordering (with spring animations for neighboring tabs) and scroll-wheel tab switching. Closing the desktop window leaves terminals running in the background; reopening reattaches seamlessly. +Menu (new-menu):Terminal: Opens a new real terminal tab in the current Space.Start an agent: Lists detected local coding tools (fromdefaults/programs.json, including Claude Code, Codex, OpenCode, Cursor, Copilot, Amp, Antigravity, Kimi, Kiro, Hermes, Qoder, Crush, Gemini, ZCode, etc.) and launches them inside a real terminal tab with full-permission flags (e.g.,claude --dangerously-skip-permissions,codex --no-daemon --dangerously-bypass-approvals-and-sandbox,agent --yolo --trust,opencode --auto,gemini --yolo,zcode --mode yolo; on Windows, automatically wraps withpowershell.exe -ExecutionPolicy Bypassso.ps1/.cmdshims launch reliably). Individual entries can be overridden in~/.config/herdr2-app/programs.json.New space/New worktree…/Open worktree…: Creates a workspace or manages Git worktree spaces.
- Bottom-Left
AgentsStatus Panel (Dual-Channel Live Awareness & Quick Controls):- Interactive CLI Agents (
t*): Even without GhosttyOSC 7501, supported coding CLIs running inside workspace terminals (includingnode .../@anthropic-ai/claude-code/cli.js, versioned binaries, PowerShell-wrapped launches, and returning to the shell on exit) are automatically detected and tracked acrossworking/Needs you(blocked) /done/idle. When a program emitsOSC 7501,OSC 7501still takes top priority. - ZCode CLI (
zcode): Detected whether started from the menu or typed manually in a workspace terminal (process namezcode-cli). On first launch from Herdr2, checkpoint hooks are idempotently written to ZCode’s runtime config~/.zcode/cli/config.jsonandhooks.enabledis turned on (a shared switch across ZCode sessions; outside Herdr2 terminals the hooks immediately return{}with no side effects). Each turn then records a checkpoint (h2 checkpoint ls tN). Rolling back to turn k restores workspace files, restarts the session withzcode --resume <session>, and injects a rollback note into the next prompt—because ZCode stores conversation history in its own database rather than truncatable files and does not persist a readable transcript, transcript-based content reading and handoff context are unavailable for ZCode. - Headless ACP Agents (
a*/wsl/a*): Displays both sub-agents spawned by workspace panes (nested under their parent terminal with upward urgent-status aggregation) and standalone or cross-machine root ACP agents (taggedACP). - Click and Remove: Clicking a pane agent focuses its pane; clicking a headless ACP row opens the T3 Code-style conversation overlay (ACP Peek) showing unwrapped
<h2 ...>user message bubbles (with source badges and timestamps), collapsible reasoning and tool-execution timelines (Thought / Tool Calls / Plan), rich Markdown rendering (tables, lists, code-block cards with language headers and one-clickCopy, full-turn copy, and diagnosticstderrdrawer), inline permission approval bars (Approve/Deny), and an auto-expanding multiline composer (Enterto send,Shift+Enterfor newline,Steerpreemption, and queue count). Hovering any parent or child row reveals an✕remove button (closing the pane or terminating the ACP session cleanly). Closing a Space (space.close) automatically terminates and cleans up headless ACP sessions belonging to that workspace directory. - Manual Status Override (
Idle/Working/Needs you/Done/Auto detect): If terminal state inference misfires or you want to mark status explicitly, click the status dot/badge on the left of any agent or sub-agent row, right-click any agent row, open the Command Palette (Ctrl+Shift+P→Set agent status), or runherdr2 do agent.status. Overrides persist across clients via theherdr.statuslabel and revert to automatic detection when a new turn begins or you selectAuto detect.
- Interactive CLI Agents (
- Every terminal child process inside the window automatically receives
H2_TERMINAL_ID(e.g.,t1) andH2_TERMINAL_SOCKET, so runningh2commands directly inside any terminal automatically knows its parent terminal address.
3.2 herdr2 Window Control CLI
Section titled “3.2 herdr2 Window Control CLI”Script or remotely control an open Herdr2 desktop window using the herdr2 CLI:
herdr2 ls # List spaces, tabs, panes (t*), and headless_agents (a*) in the windowherdr2 status # Show current focus, layout, zoom level, and mod load errorsherdr2 commands # List all window commands (works without a running window)herdr2 --skill # Print the desktop control manual for AI agents
# Drive window actions remotelyherdr2 do space.new --name api --folder ~/repo/apiherdr2 do tab.new --name "shell"herdr2 do tab.new --name "Claude Code" --argv '["claude", "--dangerously-skip-permissions"]'herdr2 do pane.split --direction rightherdr2 do terminal.peek --terminal wsl/a6 # Open the interactive ACP conversation & approval panelherdr2 do agent.status --terminal wsl/t13 --status idle # Manually override agent status (--status auto restores auto-detect)herdr2 do app.language --language zh-CN # Switch UI language live ("en" / "zh-CN")herdr2 do terminal.scroll --lines -20herdr2 shot /tmp/herdr2.png # Capture a screenshot of the current GPUI window frame3.3 Interface Language Settings (English / 简体中文)
Section titled “3.3 Interface Language Settings (English / 简体中文)”The desktop client supports live switching between English and Simplified Chinese:
- Settings Panel: Open bottom-left Settings → Look → Interface language and choose
Englishor简体中文(all sidebars, tabs, modals, and context menus update immediately with no restart). - Command Palette / Context Menu / CLI: Press
Ctrl+Shift+Pand searchLanguage: 简体中文orLanguage: English, right-click empty desktop space, or runherdr2 do app.language --language zh-CN.
4. Core h2 CLI Workflows (Headless ACP Sub-Agents & Hybrid Terminal Control)
Section titled “4. Core h2 CLI Workflows (Headless ACP Sub-Agents & Hybrid Terminal Control)”flowchart LR T["Workspace Terminal (t1)<br/>Holds H2_TERMINAL_ID=t1"] -->|"1. Spawn headless sub-agent<br/>h2 run --bg --name worker --agent claude"| A["ACP Agent (a1)<br/>No PTY / stdio NDJSON"] A -->|"2. Wait for status or read output<br/>h2 wait a1 / h2 read a1"| T A -->|"On write/exec permission request<br/>status == blocked"| B{"Permission Arbitration"} B -->|"h2 approve a1 / h2 deny a1"| A T -->|"3. Follow up / steer / terminate<br/>h2 send a1 --steer / h2 kill a1"| A4.1 Checking the Daemon and Runtime State
Section titled “4.1 Checking the Daemon and Runtime State”h2 --versionh2 server statush2 server restart # Preserves kept terminal holders and --keep ACP sessions across restarts
h2 ls # Hybrid tree view showing live ACP Agents (a*) and Terminals (t*)h2 ls --all --json # JSON output including finished entries and remote machine statesh2 events # Follow lifecycle and structured transcript/status events in real time (NDJSON)4.2 Spawning Headless ACP Sub-Agents (h2 run)
Section titled “4.2 Spawning Headless ACP Sub-Agents (h2 run)”Built-in --agent presets include 13 preset names covering 12 ACP adapters (both cursor and cursor-agent map to cursor-agent acp):
claude(claude-agent-acp)codex(codex-acp)gemini(gemini --acp)opencode(opencode acp)copilot(copilot --acp --stdio)cursor/cursor-agent(cursor-agent acp)kimi(kimi acp)qwen(qwen --acp)pi(pi-acp)hermes(hermes-acp)glm(glm-acp-agent)zcode(zcode-acp-server)
# 1) Run in foreground and wait for the first turn (opens no terminal pane)h2 run --agent claude --cwd /path/to/repo --prompt "Analyze Cargo.toml dependency issues without editing files"
# 2) Start in the background (recommended for multi-agent orchestration)h2 run --bg --name reviewer --cwd /path/to/repo --agent codex \ --prompt "Review error handling in src/main.rs and return a summary"
# 3) Run a custom terminal-free ACP adapter commandh2 run --bg --name custom -- python3 ./my_acp_agent.py
# 4) Launch from ~/.config/herdr2/templates/*.md templatesh2 templatesh2 run --bg --name audit security-review "Focus on the auth module"Common run flags:
--model <MODEL>: Selects the model viasession/set_config_option(falling back tosession/set_model).--mode <MODE>: Switches the ACP session mode (e.g., read-only, plan, execute).--system-prompt <TEXT>: Appends a system-level prompt.--permissions <approve-all|approve-reads|deny-all|ask|dangerously-skip-permissions>: Overrides the session permission policy (dangerously-skip-permissions/bypassPermissionsis equivalent toapprove-all).--dangerously-skip-permissions: Sets the policy toapprove-alland automatically switches to ACPbypassPermissionsmode when supported (displayed in Claude ACP dialogs asdangerously-skip-permissions).--no-mcp: Disables automatic injection of the built-inherdr2MCP server (h2 mcp).--keep: Marks the agent as persistent so Core attempts ACPsession/loadrecovery after daemon restarts or crashes.--outlive-parent: Prevents automatic cleanup when the parent node exits.--rm: Automatically removes the record once the agent finishes.--on <machine>: Runs the agent on a paired remote machine.
4.3 Queued Sending, Preemptive Steering (--steer), and Permission Approvals
Section titled “4.3 Queued Sending, Preemptive Steering (--steer), and Permission Approvals”# Queue a follow-up prompt at the tail of the serial inbox (runs after the active turn finishes)h2 send reviewer "Also check whether tests/ is missing assertions"
# Preemptive steer (--steer): sends ACP session/cancel to stop the active turn and delivers nexth2 send reviewer --steer "Stop! Requirements changed—keep backwards compatibility with the legacy API"
# Inspect transcript and detailed statush2 read reviewer # Full structured conversation transcripth2 read reviewer --last # Only the final assistant reply from the latest turnh2 read reviewer --lines 50 # Last 50 rendered linesh2 get reviewer # Status, turn count, queued_count, and pending_permission
# Permission arbitration (when status == blocked)h2 approve reviewerh2 approve reviewer --option allow_onceh2 deny reviewer
# Interrupt, persist, live-configure, and clean uph2 interrupt reviewerh2 config reviewer --id model --value gpt-5.4 # Switch model or custom model ID liveh2 config reviewer --id reasoning_effort --value high # Adjust reasoning effort (thought_level)h2 config reviewer --id fast-mode --bool true # Toggle Fast modeh2 config reviewer --id mode --value dangerously-skip-permissions # Switch Claude ACP to bypass mode and release pending requesth2 keep reviewerh2 label reviewer role=backendh2 kill reviewerh2 rm reviewerThe desktop UI (clicking a headless ACP agent in the Agents sidebar or driving it via herdr2 do) also supports two extended controls:
- Bottom Model Capability Strip: Directly beneath the composer input, switch Model (with search filtering and custom model ID entry), Reasoning (effort level), Fast (toggle), Mode (permission/preset mode), and
Collaboration mode, all dispatched live viaagent.config. - Mount as Workspace Tab / Split Left-Right or Top-Bottom / Detach to Background:
- Click
↗ Open as Tabin the top-right corner of the overlay (or runherdr2 do terminal.keep --terminal wsl/a6 --place tab) to mount the ACP agent as a standalone workspace tab. ClickSplit right, use theAgentsrow context menu, or runherdr2 do terminal.keep --terminal wsl/a6 --place right/--place downto split the ACP agent alongside panes in the current tab (mounted ACP panes can also split and rearrange alongside regular terminals). - When mounted in a tab or split, only a single unified lightweight pane bar is shown at the top (icon, name,
ACPbadge, path, status, activeStop, and hover split/zoom/background buttons), avoiding duplicate title bars. Clickingxon a mounted ACP tab or pane detaches it back to the background by default without killing the process (to terminate explicitly, use the context menu’sKillorh2 kill). - If a mounted ACP session terminates externally (for example, after a parent agent finishes and runs
h2 kill), its tab stays open in a read-onlyEndedstate preserving the full conversation for reading and copying until you close the tab manually with×.
- Click
4.4 Controlling Workspace PTY Terminals (t*) from the CLI
Section titled “4.4 Controlling Workspace PTY Terminals (t*) from the CLI”In addition to the GUI, the h2 CLI can read, send input to, attach to, or clean up real PTY terminals:
h2 read t1 --lines 40 # Read plaintext screen and scrollback history of t1h2 send t1 "cargo test --locked" # Paste text into t1 and press Enter after a quiet window (editor/shell safe)h2 keys t1 ctrl+c # Send named key sequences (enter / esc / ctrl+c, etc.) to t1h2 attach t1 # Attach live to t1 in your shell (Ctrl-\ then d to detach)h2 interrupt t1 # Send terminal interrupt controlh2 put t1 ./artifact.png # Stage a local file next to the target and print the remote pathh2 kill t1 && h2 rm t1 # Terminate and remove a finished terminal record5. Built-In MCP Self-Orchestration and Cross-Machine Federation
Section titled “5. Built-In MCP Self-Orchestration and Cross-Machine Federation”5.1 Auto-Injected h2 mcp Toolset
Section titled “5.1 Auto-Injected h2 mcp Toolset”By default (inject_mcp = true), h2 injects its stdio MCP server (command: <herdr2>, args: ["mcp"], carrying H2_AGENT_ID and H2_AGENT_SOCKET) into every ACP session. When an interactive coding CLI running inside workspace terminal t* registers h2 mcp explicitly as an MCP server, h2 mcp automatically detects the parent terminal via H2_TERMINAL_ID (client::agent_id().or_else(client::terminal_id)).
Exposed 7 MCP tools:
| MCP Tool Name | Purpose | Equivalent CLI |
|---|---|---|
h2_run |
Spawn a headless ACP sub-agent (supports agent / prompt / cwd / name / wait / permissions / model, etc.) |
h2 run |
h2_send |
Send a message to a target agent or terminal (agent targets support steer preemption) |
h2 send |
h2_wait |
Wait for a target agent/terminal or children of the current node (children: "any" | "all") |
h2 wait |
h2_read |
Read structured agent output (last: true) or terminal screen text |
h2 read |
h2_ls |
List active/finished Agents and Terminals | h2 ls |
h2_approve |
Approve a pending permission request on a blocked sub-agent |
h2 approve |
h2_deny |
Deny a pending permission request on a blocked sub-agent |
h2 deny |
When notes is enabled:
- Inter-agent messages are automatically wrapped in
<h2 from="...">...</h2>envelopes to prevent identity confusion. - When a child transitions to
blocked,error, or exits, Core asynchronously delivers a notification to the parent agent’s inbox (or pastes it into the parent PTY terminal after the quiet period). - If the parent terminal has an active input draft or a pending approval block,
notes_quiet/draft_waitbackoff prevents interrupting user typing.
5.2 Non-Agent Utilities and Cross-Machine SSH Federation
Section titled “5.2 Non-Agent Utilities and Cross-Machine SSH Federation”# 1) Run a one-shot non-agent command directly (captures exact stdout/stderr and exit code)h2 exec --cwd /repo -- cargo test --locked
# 2) Atomic file read, write, and exact text replacementh2 file read src/main.rs --offset 1 --limit 80echo "hello" | h2 file write /tmp/note.txth2 file edit src/config.toml --old 'ask' --new 'approve-reads'
# 3) Cross-machine SSH federation (e.g., Windows Herdr2 connecting to local WSL or remote Linux)h2 machine add zzh@gpu-server --name gpuh2 run --on gpu --bg --name trainer --agent claude --prompt "Run a baseline evaluation"h2 ls # Unified view showing wsl/t1, gpu/trainer, etc.h2 send gpu/trainer "Check GPU memory usage"6. Configuration File Reference
Section titled “6. Configuration File Reference”6.1 Core Runtime Config ~/.config/herdr2/config.toml
Section titled “6.1 Core Runtime Config ~/.config/herdr2/config.toml”# Default permission policy for ACP sub-agents: approve-reads (default) | approve-all | deny-all | askdefault_permissions = "approve-reads"
# Automatically inject the built-in `h2 mcp` server into ACP sessions (default: true)inject_mcp = true
# Enable parent-child status notifications and <h2> envelopes (default: true)notes = true
# Quiet delay before pasting into a parent PTY (default: 3s) and draft backoff (default: 60s)notes_quiet = 3.0draft_wait = 60.0
# Default single check-in timeout for `h2 wait` in seconds (default: 180)wait_timeout = 180.0
# Custom `h2` daemon socket path (defaults to $XDG_RUNTIME_DIR/herdr2/)# socket = "/custom/path/herdr2.sock"
# Override the default shell for interactive workspace terminals# shell = ["/bin/zsh"]
# Override or add custom ACP agent preset commands[agents]claude = ["claude-agent-acp"]my-local-agent = ["python3", "/opt/agents/my_acp.py", "--stdio"]6.2 Desktop Client Config ~/.config/herdr2-app/settings.json
Section titled “6.2 Desktop Client Config ~/.config/herdr2-app/settings.json”Herdr2 desktop settings are kept in sync between the UI and config file (changes hot-reload automatically):
{ "language": "zh-CN", "zoom": 1.2, "font_ligatures": false, "terminal_line_height": 1.0, "terminal_cell_width": 1.0, "terminal_scroll_speed": 1.0, "minimum_contrast": 1.0, "telemetry": false, "sounds": { "enabled": true }}