A Pi extension for the Herdr CLI — control workspaces, tabs, panes, and coding agents through a typed tool that calls the local herdr CLI directly.
Pi can already shell out to the herdr CLI via bash, but a bare skill describing CLI flags is easy to misuse: the model runs bare herdr (launching the TUI), forgets to check HERDR_ENV, or runs herdr server stop by accident. This extension packages the CLI behind a typed tool with:
- a
subcommand+argsmap that serializes to the CLI's--flag valueformat (booleans → bare flags, no shell quoting needed) HERDR_ENV=1precondition — the tool refuses to run outside a Herdr-managed pane and returns actionable guidance instead of failing opaquely- bare-
herdrrejection — empty subcommand throws with a warning that bareherdrlaunches the TUI - prompt guidance injected when a prompt mentions herdr / pane / workspace / tab / agents
- a live skill generated from
herdr --skillat session start (always matches the installed herdr version; falls back to a bundled static copy outside Herdr) - safety guards — refuses
server stopunlessforceDangerous: true - output truncation consistent with Pi's built-in tools
- The
herdrCLI on yourPATH - Running inside a Herdr-managed pane (
HERDR_ENV=1) — the tool is a no-op otherwise and returns guidance
pi install npm:@sfroment/pi-herdrOr pin a version:
pi install npm:@sfroment/pi-herdr@0.1.0Then /reload in Pi.
pi install git:github.com:sfroment/pi-herdr@v0.1.0Copy or symlink this directory into ~/.pi/agent/extensions/herdr/, then /reload.
The herdr tool takes:
| param | type | description |
|---|---|---|
subcommand |
string (required) | CLI subcommand, e.g. agent list, pane split, workspace create. Split on spaces into the command path. |
args |
object | Key/value flags. Booleans become bare flags ({"no-focus": true} → --no-focus). Strings/numbers become --flag value pairs. Arrays become repeated --flag value pairs. |
timeoutSeconds |
int | Default 30, max 120. |
forceDangerous |
bool | Opt-in for destructive commands (server stop). Requires explicit user confirmation. |
git clone git@github.com:sfroment/pi-herdr.git
cd pi-herdr
bun install
bun testThe tests mock only the system boundary (pi.exec) via dependency injection — runHerdr(params, exec) takes the exec function as a parameter, so tests pass a fake that records argv and returns canned results. Internal helpers (buildArgv, assertSafeCommand, formatOutput) are pure and tested directly.
The pretest script (scripts/link-pi-deps.sh) symlinks the pi runtime packages (@earendil-works/pi-coding-agent, @earendil-works/pi-ai, typebox) into node_modules/ so Bun can resolve the extension's imports during tests.
Licensed under the GNU General Public License v3.0.