zswarm
Health Gecti
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 26 GitHub stars
Code Uyari
- process.env — Environment variable access in bin/launch-mcp.mjs
- fs module — File system access in package.json
- process.env — Environment variable access in packages/cli/src/cli.ts
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
Coordinate CLI agent crews in Zellij panes — CLI + MCP
zSwarm
Coordinate CLI AI crews across Zellij terminal panes. Control agents, pass prompts between panes, manage git worktrees, inspect outputs, and sync crew tasks via CLI or Model Context Protocol (MCP).
you ──▶ any agent ──┐
│ zswarm({op:"send", to:"claude"})
▼
every pane can call zswarm ──▶ ┌─────────┐
so agents drive each other │ zswarm │
│ cli/mcp │
└────┬────┘
paste + Enter ┌────┴────┐ read screen / pushed state
▼ ▼
══ this machine ═══════════════╗ ══ ssh user@worker-01 ════════════════════╗ ══ ssh user@build-01 ═════════╗
zellij "crew" (orchestrators)║ zellij "workers" (workers/subworkers) ║ zellij "ci" (runner/deploy) ║
║ ║ ║
┌────────────┐ ║ ┌────────────┐ send ┌────────────┐ ║ ┌────────────┐ ║
│ codex │───────────────╫──▶│ cursor │────────▶│ opencode │───╫──▶│ test-runner│ ║
│ orchestrat.│ plan/send ║ │ worker │◀────────│ subworker │ ║ │ ci runner │ ║
│ planner │ ║ │ wt:feat-a │ signal │ wt:tests │ ║ │ wt:tests │ ║
└─────┬──────┘ ║ └─────┬──────┘ └─────┬──────┘ ║ └──────┬─────┘ ║
signal │ send ║ │ send │ send ║ │ pass / done ║
┌─────▼──────┐ ║ ┌─────▼──────┐ send ┌─────▼──────┐ ║ ┌──────▼─────┐ ║
│ claude │───────────────╫──▶│ agy │────────▶│ opencode │ ║ │ pi │ ║
│ orchestrat.│ review/send ║ │ subworker │◀────────│ subworker │ ║ │ deploy │ ║
│ lead │ ║ │ wt:docs │ signal │ wt:api │ ║ │ cwd:/srv │ ║
└────────────┘ ║ └────────────┘ └────────────┘ ║ └────────────┘ ║
═══════════════════════════════╝ ══════════════════════════════════════════╝ ══════════════════════════════╝
one pane = one agent + one role + optionally its own worktree
any pane can drive any other, on this machine or across the ssh boundary
⚡ Quick Start
Requirements
- Zellij ≥ 0.42 on
PATH(or setZSWARM_BIN/ZSWARM_PATH) - Node.js ≥ 20
Installation
npm i -g zswarm
zswarm list
Enable the optional Zellij event-bus plugin once per Zellij session for zero-polling state updates:
zswarm bus --install
Keep the floating pane open. --force closes orphan bus panes and reloads; do not use it as a retry.
MCP Server Setup
Configure zswarm-mcp (stdio MCP server bundled with the package) in your MCP host:
{
"mcpServers": {
"zswarm": {
"command": "/absolute/path/to/zswarm-mcp",
"env": {
"ZSWARM_SESSION": "my-zellij-session"
}
}
}
}
Note: Use the absolute path to
zswarm-mcpand specifyZSWARM_SESSIONto prevent ambiguous session errors when multiple Zellij sessions run.
Each harness registers the server and the skill (skills/zswarm) itself; the repo ships no plugin manifests. With npm i -g zswarm, the skill is installed at $(npm root -g)/zswarm/skills/zswarm (or from a clone: skills/zswarm):
- Claude Code:
claude mcp add --scope user zswarm -- "$(command -v zswarm-mcp)", then copy$(npm root -g)/zswarm/skills/zswarm(orskills/zswarmfrom a checkout) to~/.claude/skills/zswarm. - Codex: add to
~/.codex/config.toml
(Codex passes only the variables listed in[mcp_servers.zswarm] command = "/absolute/path/to/zswarm-mcp" env_vars = ["ZELLIJ_PANE_ID", "ZELLIJ_SESSION_NAME", "ZSWARM_SESSION", "ZSWARM_SELF_PANE", "ZSWARM_FROM", "ZSWARM_SERVE", "ZSWARM_SERVE_TOKEN", "ZSWARM_SSH"]env_vars; add any otherZSWARM_*you use), then copy$(npm root -g)/zswarm/skills/zswarm(orskills/zswarmfrom a checkout) to~/.codex/skills/zswarm. - Cursor: add the JSON above to
~/.cursor/mcp.json, and copy$(npm root -g)/zswarm/skills/zswarm(orskills/zswarmfrom a checkout) to~/.cursor/skills/zswarm. - Other hosts: any stdio MCP client runs
zswarm-mcp; a host that must execnodedirectly can usenode bin/launch-mcp.mjsfrom a checkout (requires a build first:pnpm run build, ornpm i -g zswarm).
Usage & Quick Syntax
Every operation is supported both via CLI (zswarm <op> [flags]) and MCP (zswarm({ op: "<op>", ... })).
Essential Examples
# 1. Inspect Panes & Status
zswarm list # List active panes
zswarm status # Check status: busy | waiting | idle | exited | running | unknown
# 2. Spawn Panes & Worktrees
zswarm spawn --command "claude" --name reviewer # Spawn agent pane
zswarm spawn --command "codex" --worktree feature-auth --name auth-dev # Isolated git worktree pane
# 3. Pass Prompts & Input
zswarm send --to reviewer --body "Review changes in src/" --submit auto
zswarm keys --to reviewer --key "Ctrl c" # Send special keys / interrupts
# 4. Read Outputs & Wait
zswarm dump --to reviewer --max 4000 # Read recent screen tail
zswarm tail --to reviewer # Incremental read since last check
zswarm wait --to reviewer --match "DONE" # Block until pattern matched (or add --for either to stop on idle too)
# 5. Coordinate Crew & Sync Signals
zswarm broadcast --all --group builder --body "Run test suite" # group matches pane title or command
zswarm signal --channel tests --payload ok # Send signal to durable channel
zswarm await --channel tests --count 3 # Wait for 3 worker signals
# 6. Agent host commands (see docs/hosts.md)
zswarm host install --ssh root@build-host # Node.js, zswarm, Zellij on a Linux/macOS host
zswarm crew up crew --layout crew.kdl # Keep a session running from its layout
zswarm serve --install --session crew # Serve as a systemd/launchd service (token in ~/.zswarm/serve/)
zswarm relay --serve 'ssh://crew1@build-host?servePort=9419' --to worker-a --body-file task.md --done 'TASK-DONE' --reply-to me
zswarm relay --wait <id> # Pull path: block until that relay has its message
zswarm slot -- cargo test # Run inside one of the host's build slots
zswarm host doctor --ssh crew1@build-host --serve 'ssh://crew1@build-host?servePort=9419' --session crew
📋 Operations Reference
| Operation | Purpose | Key Parameters / Flags |
|---|---|---|
list / sessions |
List panes or live Zellij sessions | verbose |
status |
Panes classified by state (idle, busy, waiting, exited, running, unknown) |
to, sampleMs, since-last |
spawn |
Launch command in new pane, tab, or git worktree | command, name, cwd, worktree, tab, newTab |
send |
Send text / prompt into a pane | to, body, submit (auto|double-enter|none), expect |
dump |
Read screen content (screen tail) | to, max (default 8000) |
tail |
Incremental screen read since last cursor | to, reset |
wait |
Block until quiet, pattern match, or idle | to, match, for (idle|match|either), idleMs, timeoutMs |
broadcast |
Send one prompt to multiple panes | to, tab, all, group, body |
keys / interrupt |
Send key combos (Ctrl c, Esc) or raw chars |
to, keys, chars, enter, hard |
close |
Close a pane | to |
signal / signals / await |
Durable message channels & barrier sync | channel, payload, count |
worktrees / unworktree |
List or remove managed git worktrees | cwd, branch, path, force |
diff / checkpoint |
Inspect peer worktree patch or autocommit WIP | branch, path, stat, message |
rename / focus |
Retitle pane/tab or focus pane | to, tab, name |
tabs / layout / stack |
Inspect tabs, layout KDL, or stack panes | to, max |
bus / log |
Event bus plugin management & delivery log | install, clear, failed, limit |
doctor |
Inspect-only route/SSH/serve/Zellij/bus diagnostics | session, timeoutMs (default 10000) |
🛡️ Safety & Policy Guards
- Self-Target Guard: Operations refuse to modify zSwarm's own pane (
allowSelf: trueto override). - Execution & Exited Guards: Prevents writing to exited panes (
force: trueto override). - Prompt Safety (
expect):send --expect <text>ensures target pane screen contains<text>before writing (prevents accidental shell execution). - Submission Verification (
submit):autoverifies text submission into TUI composers and retries Enter if unsubmitted.
Environment Security Controls
| Env Variable | Effect |
|---|---|
ZSWARM_READONLY=1 |
Disable all write ops (send, spawn, close, etc.) |
ZSWARM_ALLOW_PANES / ZSWARM_DENY_PANES |
Comma-separated pane IDs or case-insensitive title substrings |
ZSWARM_ALLOW_SPAWN=0 |
Disable spawning new panes |
ZSWARM_ALLOW_CLOSE=0 |
Disable closing panes |
ZSWARM_ALLOW_WORKTREE_REMOVE=0 |
Disable removing git worktrees |
⚙️ Environment Variables
| Variable | Description |
|---|---|
ZSWARM_BIN / ZSWARM_PATH / ZELLIJ_BIN |
Path to zellij executable |
ZSWARM_SESSION |
Default Zellij session name |
ZELLIJ_SESSION_NAME |
Active Zellij session (set automatically inside Zellij panes) |
ZELLIJ_PANE_ID / ZSWARM_SELF_PANE |
Sending pane id (Zellij sets the first inside a pane). Used to refuse self-target and to default from to that pane's title |
ZSWARM_FROM |
Sender label when from is omitted (overrides the pane title) |
ZSWARM_WORKTREE_ROOT |
Directory for linked worktrees (default: <repo>-worktrees) |
ZSWARM_STATE_DIR |
State storage directory for logs, signals, and cursors (default: ~/.zswarm) |
ZSWARM_BUS |
1 / 0 — Enable or disable Zellij event-bus plugin integration |
ZSWARM_BUS_PLUGIN |
Custom path to zswarm event-bus WASM plugin (.wasm) |
ZSWARM_SSH |
user@host — Route Zellij commands across SSH |
ZSWARM_SSH_BIN |
Custom ssh executable path (default: ssh) |
ZSWARM_SSH_OPTS |
Additional command-line options passed to OpenSSH |
ZSWARM_REMOTE_BIN |
Remote zellij binary (zellij.exe on Windows) |
ZSWARM_TMP |
Remote IPC temp directory, or auto to parse live zellij --server paths |
ZSWARM_SSH_MODE |
interactive — Windows only: run each CLI call in the desktop session (scheduled task, same idea as schtasks /IT) |
ZSWARM_REMOTE_SHELL |
cmd or sh — override remote quoting (inferred from .exe / Windows tmp / interactive) |
ZSWARM_SERVE |
127.0.0.1:9419, tcp://127.0.0.1:9419, or ssh://user@host[:sshPort]?servePort=9419 — Forward ops to zswarm serve. ssh:// opens a process-owned SSH LocalForward to remote loopback (desktop serve must already be running). Omit sshPort to keep an SSH alias's configured Port |
ZSWARM_SERVE_TOKEN |
Shared secret for zswarm serve. Required even on loopback (another local OS user can connect to 127.0.0.1); send the same value on the client |
ZSWARM_CACHE_TTL_MS |
In-process metadata cache TTL in milliseconds (default: 500; 0 disables) |
ZSWARM_TAILSCALE_BIN |
Custom tailscale binary path (default: tailscale) |
ZSWARM_SLOT_POLL |
Build slot polling interval in seconds (default: 1) |
Remote crews
Linux/macOS SSH works when it is the same user and $TMPDIR. Windows OpenSSH is session 0; live Zellij is usually the interactive desktop session. ZSWARM_TMP=auto points at that TEMP (enough to list sessions). Pane attach on Windows uses named pipes in the desktop session, so use ZSWARM_SSH_MODE=interactive for occasional commands or, for the default Tailscale crew, zswarm serve --install on the logged-in desktop plus OpenSSH over Tailscale from the controller.
# Linux/macOS, same user:
ZSWARM_SSH=user@host zswarm list
# Point SSH at the interactive TEMP (auto reads zellij --server …)
ZSWARM_SSH=user@host ZSWARM_TMP=auto zswarm sessions
# Windows: run the CLI inside the desktop session. Discovers TEMP unless ZSWARM_TMP is set.
ZSWARM_SSH=user@host ZSWARM_SSH_MODE=interactive zswarm list
# Linux/macOS host: keep a session and its serve running as services (docs/hosts.md)
zswarm crew up crew --layout crew.kdl
zswarm serve --install --listen 127.0.0.1:9419 --session crew
# Tailscale crew (native Windows desktop + controller). Full recipe: docs/tailscale.md
# Host (logged-in desktop, token already in this process) — default loopback:
zswarm serve --install --listen 127.0.0.1:9419 --session crew --timeout-ms 30000
# Optional: bind a verified local Tailscale IP instead (see docs/tailscale.md):
# zswarm serve --install --listen "$(tailscale ip -4):9419" --session crew --timeout-ms 30000
# Controller (same private token; ssh:// authority port is SSH, servePort is remote loopback):
zswarm --serve 'ssh://user@crew-host?servePort=9419' doctor --session crew --timeout-ms 10000
zswarm --serve 'ssh://user@crew-host?servePort=9419' status --session crew
# Direct endpoint when the host bound its Tailscale IP:
# zswarm --serve '<host-tailscale-ip>:9419' status --session crew
# Private TCP Tailscale Serve frontend (backend stays 127.0.0.1:9419):
# zswarm --serve 'tcp://crew-host:19419' doctor --session crew --timeout-ms 10000
file: plugin URLs stay on the machine that owns Zellij. A client with ZSWARM_SERVE never sends a local wasm path across the tunnel.
{
"mcpServers": {
"zswarm": {
"command": "/absolute/path/to/zswarm-mcp",
"env": {
"ZSWARM_SERVE": "ssh://host?servePort=9419",
"ZSWARM_SERVE_TOKEN": "secret"
}
}
}
}
Note: The server picks its own session (pinned via
zswarm serve --session <session>or the host environment); client-sideZSWARM_SESSIONis not forwarded to serve. Explicitsessionarguments on individual tool calls still select that session on the server.
📦 Monorepo Structure
| Package | Purpose |
|---|---|
zswarm |
Main meta-package (npm i -g zswarm) |
@zswarm/core |
Core Zellij client and shared dispatch engine |
@zswarm/cli |
zswarm command line interface |
@zswarm/mcp |
Stdio MCP server (zswarm-mcp) |
@zswarm/wasm |
Precompiled Rust event-bus WASM plugin |
@zswarm/pi |
Extension bridge for harnesses without native MCP support |
For spawn lifecycle fields, file/stdin handoffs, guarded menu input, tab summaries, and routing diagnostics, see Reliable crew operations.
For the Windows + Tailscale crew recipe (serve --install, OpenSSH over Tailscale, optional verified Tailscale-IP bind, private TCP Tailscale Serve, token, doctor/status), see Tailscale crew.
For layered inspect-only diagnostics (zswarm doctor), see Doctor.
For agent hosts (zswarm host install|doctor to set a Linux/macOS machine up, zswarm crew up to keep a session running from a layout, serve --install as a systemd or launchd service, zswarm relay to hand a remote pane work and be told when it is done, zswarm slot to share build capacity), see Agent hosts.
For repeated status calls, see polling performance and serve/tunnel setup.
📜 License
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi