Skip to content

feat(subagents): add herdr terminal multiplexer support#57

Open
0xRichardH wants to merge 1 commit into
HazAT:mainfrom
0xRichardH:feat/herdr-mux-backend
Open

feat(subagents): add herdr terminal multiplexer support#57
0xRichardH wants to merge 1 commit into
HazAT:mainfrom
0xRichardH:feat/herdr-mux-backend

Conversation

@0xRichardH

Copy link
Copy Markdown

What

Adds herdr as a first-class mux backend alongside cmux/tmux/zellij/wezterm.

How

  • New file: pi-extension/subagents/herdr.ts — all herdr-specific CLI integration, extracted into its own module per SRP.

    • Runtime detection (HERDR_ENV=1 + herdr in PATH)
    • Surface creation: new tab per subagent (herdr tab create --no-focus) so parallel spawns get full tabs instead of ever-narrower splits
    • Command delivery: herdr pane run (atomic text + Enter in one socket request)
    • Screen reading: herdr pane read --source visible (reliable for freshly-created panes)
    • Escape, close, tab/workspace rename
    • Env-var-first current pane info (HERDR_PANE_ID/HERDR_TAB_ID/HERDR_WORKSPACE_ID) with subprocess fallback
  • pi-extension/subagents/cmux.ts — adds "herdr" to MuxBackend, getMuxBackend(), muxSetupHint(), and dispatches to herdr.ts in all mux operations. No herdr logic leaks into the dispatcher.

  • test/integration/harness.ts — probes herdr in getAvailableBackends(), implements focusSurface/getFocusedSurface/getSurfacePane for herdr.

  • test/integration/mux-surface.test.ts — skips the focus-preservation test for herdr/wezterm (neither exposes absolute pane focusing via CLI).

  • test/test.ts — herdr detection and JSON response parsing unit tests in a dedicated describe("herdr.ts") block.

  • README.md — documents herdr as a supported multiplexer.

Bug found and fixed during development

hasCommand in herdr.ts initially used execFileSync("command", ["-v", ...]) which fails because command is a shell builtin, not a binary — Node's execFileSync doesn't invoke a shell. This silently broke herdr detection (returned false even inside a live herdr session). Fixed to use execSync(\command -v ...`)(shell form) matchingcmux.ts`.

Test results

npm test:                        133 pass / 0 fail
npm run test:integration (herdr):  8/8 mux-surface pass

Verified end-to-end in a live herdr 0.7.1 session: create → send → read → close, rename tab/workspace, escape delivery.

Extract herdr into its own backend module (herdr.ts) and wire it into
the mux dispatcher (cmux.ts). Herdr surfaces are created as new tabs
with --no-focus so parallel subagent spawns get full tabs instead of
ever-narrower splits, and focus stays on the parent pane.

herdr.ts owns all herdr-specific CLI integration:
- Runtime detection (HERDR_ENV + herdr in PATH)
- Surface creation (tab create / pane split)
- Command delivery (pane run — atomic text + Enter)
- Screen reading (pane read --source visible)
- Escape delivery, pane close, tab/workspace rename
- Env-var-first current pane info with subprocess fallback

cmux.ts adds herdr to MuxBackend, getMuxBackend(), muxSetupHint(),
and dispatches to herdr.ts in createSurface, createSurfaceSplit,
sendCommand, sendEscape, readScreen, readScreenAsync, closeSurface,
renameCurrentTab, and renameWorkspace.

Integration harness probes herdr and implements focus/focused-surface
helpers. The focus-preservation test is skipped for herdr/wezterm
because neither exposes absolute pane focusing via CLI.

README documents herdr as a supported multiplexer.

Tested: 133 unit tests pass, 8/8 herdr mux-surface integration tests
pass in a live herdr session.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant