Skip to content

Add tmux shim for Claude Code agent teams#286

Draft
srid wants to merge 5 commits intomasterfrom
feat/tmux-shim
Draft

Add tmux shim for Claude Code agent teams#286
srid wants to merge 5 commits intomasterfrom
feat/tmux-shim

Conversation

@srid
Copy link
Copy Markdown
Member

@srid srid commented Apr 1, 2026

A kolu-tmux CLI shim that translates tmux commands into Kolu RPC calls, letting Claude Code's teammate/swarm feature work inside Kolu terminals with zero user configuration.

Claude Code detects tmux via $TMUX and the tmux binary on PATH, then uses ~10 subcommands (split-window, send-keys, kill-pane, capture-pane, list-panes, display-message, has-session, -V) to manage agent panes. The shim intercepts these and maps them to Kolu's existing terminal RPC — terminal.create, terminal.sendInput, terminal.kill, terminal.screenText, etc. No-ops for layout/styling commands that have no Kolu equivalent (select-layout, set-option).

The server injects $TMUX and $TMUX_PANE into PTY shells and creates a temp wrapper script on $PATH as tmux at startup, so Claude Code auto-detects multiplexer support. Each terminal gets a unique monotonic pane index (%0, %1, ...) for multi-instance isolation — Claude Code reads $TMUX_PANE at startup to scope its teammate operations.

Format string evaluation (#{pane_id}, #{window_index}, etc.) and target resolution (%N, session:window.pane) follow the same patterns as cmux's tmux compat layer, which was studied during implementation. send-keys special key handling (case-insensitive, space-joining) also matches cmux/tmux behavior.

Closes #185


  • sync
  • understand
  • hickey
  • branch
  • implement
  • e2e
  • fmt
  • commit
  • police
  • test
  • ci
  • update-pr
  • done

srid added 5 commits April 1, 2026 19:33
Implement a kolu-tmux CLI shim that translates tmux commands into Kolu
HTTP RPC calls, enabling Claude Code's teammate/swarm feature to work
inside Kolu terminals with zero user configuration.

The shim handles the ~10 tmux subcommands Claude Code actually uses:
split-window, send-keys, kill-pane, capture-pane, list-panes,
display-message, has-session, list-windows, list-sessions, and -V.
No-ops for layout/styling commands (select-layout, set-option).

Server changes:
- Inject $TMUX, $TMUX_PANE, and the shim binary into PTY shell env
- Add /api/terminals non-streaming endpoint for shim to query
- Create temp tmux wrapper at startup, clean up on shutdown
- Allocate unique pane indices per terminal (monotonic counter)

Closes #185
- Fix mutating sort in buildPaneMap (use [...all].sort())
- Remove non-null assertions on .find() (use type-narrowing filter)
- Remove unused variables (printFlag, created)
- Remove stale KOLU_TMUX_IDS doc comment
- Move imports to top of file
- Extract VALUED_FLAGS to module-level constant
- Hoist buildPaneMap outside loop in cmdListPanes
- Remove async from resolveTarget (no awaits)
- Use DEFAULT_PORT from config instead of hardcoded "7681"
- Remove inaccurate fallback to pane 0 when TMUX_PANE unset
- Use absolute tsx path in wrapper script (PTY shells may not have tsx
  on PATH after NixOS shell init rebuilds PATH)
- Store tmuxPaneIndex on TerminalProcess and expose via /api/terminals
  so the shim maps %N pane IDs correctly across test scenarios
- Remove -p and -l from VALUED_FLAGS (both are boolean in supported cmds)
- Simplify e2e tests: split round-trip into separate split + capture
  scenarios, use direct API for capture verification
@srid srid mentioned this pull request Apr 2, 2026
14 tasks
srid added a commit that referenced this pull request Apr 2, 2026
The `/workflow do` DAG runs end-to-end but never checks whether
documentation still matches the code after structural changes. PR #286
(tmux shim) shipped new server modules without updating the README
architecture section — exactly the kind of drift CLAUDE.md warns about.

This adds a `docs` check-then-fix loop between `update-pr` and `done`,
mirroring the existing police/police-fix and ci/ci-fix patterns. The
node reads README.md's Architecture section, compares against `git diff
master...HEAD`, and updates any stale sections before completing.

Also strengthens `workflow.md` with a "never stop between nodes" rule to
prevent the orchestrator from pausing after skill nodes return.

- [x] sync
- [x] understand
- [x] hickey
- [x] branch
- [x] implement
- [x] e2e
- [x] fmt
- [x] commit
- [x] police
- [x] test
- [ ] ci
- [x] update-pr
- [x] docs
- [ ] done
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.

tmux compatibility shim for AI tool integration

1 participant