zswarm 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,173 +1,14 @@
1
- # zSwarm
1
+ # zswarm
2
2
 
3
- 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).
3
+ Meta-package for a global install. Puts `zswarm` (CLI) and `zswarm-mcp` (MCP server) on your PATH.
4
4
 
5
- ```text
6
- you ──▶ any agent ──┐
7
- │ zswarm({op:"send", to:"reviewer"})
8
- ▼
9
- every pane can call zswarm ──▶ ┌─────────┐
10
- so agents drive each other │ zswarm │
11
- │ cli/mcp │
12
- └────┬────┘
13
- paste + Enter ┌────┴────┐ read screen / pushed state
14
- ▼ ▼
15
- ══ this machine ══════════════════════════════╗ ══ ssh user@build-01 ═════════╗
16
- zellij "crew" ║ zellij "ci" ║
17
- ║ ║
18
- ┌────────────┐ send ┌────────────┐ ║ ┌────────────┐ ║
19
- │ codex │────────▶│ claude │───────╫──▶│ opencode │ ║
20
- │ builder │◀────────│ reviewer │ send ║ │ test-runner│ ║
21
- │ wt:feat-a │ signal │ wt:rev-a │ ║ │ wt:feat-a │ ║
22
- └────────────┘ └────────────┘ ║ └──────┬─────┘ ║
23
- ┌────────────┐ ┌────────────┐ ║ ┌──────▼─────┐ ║
24
- │ cursor │ │ agy │ ║ │ pi │ ║
25
- │ refactor │ │ docs │ ║ │ deploy │ ║
26
- │ wt:feat-b │ │ wt:docs │ ║ │ cwd:/srv │ ║
27
- └────────────┘ └────────────┘ ║ └────────────┘ ║
28
- ═══════════════════════════════════════════════╝ ══════════════════════════════╝
29
- one pane = one agent + one role + optionally its own worktree
30
- any pane can drive any other, on this machine or across the ssh boundary
31
- ```
32
-
33
- ---
34
-
35
- ## ⚡ Quick Start
36
-
37
- ### Requirements
38
- - **Zellij** ≥ 0.42 on `PATH` (or set `ZSWARM_BIN` / `ZSWARM_PATH`)
39
- - **Node.js** ≥ 20
40
-
41
- ### Installation
42
5
  ```bash
43
6
  npm i -g zswarm
44
7
  zswarm list
45
8
  ```
46
9
 
47
- Enable the optional Zellij event-bus plugin once per machine for zero-polling state updates:
48
- ```bash
49
- zswarm bus --install
50
- ```
51
-
52
- ### MCP Server Setup
53
- Configure `zswarm-mcp` (stdio MCP server bundled with the package) in your MCP host:
54
-
55
- ```json
56
- {
57
- "mcpServers": {
58
- "zswarm": {
59
- "command": "/absolute/path/to/zswarm-mcp",
60
- "env": {
61
- "ZSWARM_SESSION": "my-zellij-session"
62
- }
63
- }
64
- }
65
- }
66
- ```
67
- > **Note:** Use the absolute path to `zswarm-mcp` and specify `ZSWARM_SESSION` to prevent ambiguous session errors when multiple Zellij sessions run.
68
-
69
- ---
70
-
71
- ## Usage & Quick Syntax
72
-
73
- Every operation is supported both via **CLI** (`zswarm <op> [flags]`) and **MCP** (`zswarm({ op: "<op>", ... })`).
74
-
75
- ### Essential Examples
76
-
77
- ```bash
78
- # 1. Inspect Panes & Status
79
- zswarm list # List active panes
80
- zswarm status # Check status: busy | waiting | idle | exited
81
-
82
- # 2. Spawn Panes & Worktrees
83
- zswarm spawn --command "claude" --name reviewer # Spawn agent pane
84
- zswarm spawn --command "codex" --worktree feature-auth --name auth-dev # Isolated git worktree pane
85
-
86
- # 3. Pass Prompts & Input
87
- zswarm send --to reviewer --body "Review changes in src/" --submit auto
88
- zswarm keys --to reviewer --key "Ctrl c" # Send special keys / interrupts
89
-
90
- # 4. Read Outputs & Wait
91
- zswarm dump --to reviewer --max 4000 # Read recent screen tail
92
- zswarm tail --to reviewer # Incremental read since last check
93
- zswarm wait --to reviewer --match "DONE" # Block until pattern matched or pane idle
94
-
95
- # 5. Coordinate Crew & Sync Signals
96
- zswarm broadcast --all --group builder --body "Run test suite" # group matches pane title or command
97
- zswarm signal --channel tests --payload ok # Send signal to durable channel
98
- zswarm await --channel tests --count 3 # Wait for 3 worker signals
99
- ```
100
-
101
- ---
102
-
103
- ## 📋 Operations Reference
104
-
105
- | Operation | Purpose | Key Parameters / Flags |
106
- |---|---|---|
107
- | `list` / `sessions` | List panes or live Zellij sessions | `verbose` |
108
- | `status` | Panes classified by state (`idle`, `busy`, `waiting`, `exited`) | `to`, `sampleMs`, `since-last` |
109
- | `spawn` | Launch command in new pane, tab, or git worktree | `command`, `name`, `cwd`, `worktree`, `tab`, `newTab` |
110
- | `send` | Send text / prompt into a pane | `to`, `body`, `submit` (`auto`\|`double-enter`\|`none`), `expect` |
111
- | `dump` | Read screen content (screen tail) | `to`, `max` (default 8000) |
112
- | `tail` | Incremental screen read since last cursor | `to`, `reset` |
113
- | `wait` | Block until quiet, pattern match, or idle | `to`, `match`, `for` (`idle`), `idleMs`, `timeoutMs` |
114
- | `broadcast` | Send one prompt to multiple panes | `to`, `tab`, `all`, `group`, `body` |
115
- | `keys` / `interrupt` | Send key combos (`Ctrl c`, `Esc`) or raw chars | `to`, `keys`, `chars`, `enter`, `hard` |
116
- | `close` | Close a pane | `to`, `force` |
117
- | `signal` / `signals` / `await` | Durable message channels & barrier sync | `channel`, `payload`, `count` |
118
- | `worktrees` / `unworktree` | List or remove managed git worktrees | `cwd`, `branch`, `path`, `force` |
119
- | `diff` / `checkpoint` | Inspect peer worktree patch or autocommit WIP | `branch`, `path`, `stat`, `message` |
120
- | `rename` / `focus` | Retitle pane/tab or focus pane | `to`, `tab`, `name` |
121
- | `tabs` / `layout` / `stack` | Inspect tabs, layout KDL, or stack panes | `to`, `max` |
122
- | `bus` / `log` | Event bus plugin management & delivery log | `install`, `clear`, `failed`, `limit` |
123
-
124
- ---
125
-
126
- ## 🛡️ Safety & Policy Guards
127
-
128
- - **Self-Target Guard:** Operations refuse to modify zSwarm's own pane (`allowSelf: true` to override).
129
- - **Execution & Exited Guards:** Prevents writing to exited panes (`force: true` to override).
130
- - **Prompt Safety (`expect`):** `send --expect <text>` ensures target pane screen contains `<text>` before writing (prevents accidental shell execution).
131
- - **Submission Verification (`submit`):** `auto` verifies text submission into TUI composers and retries Enter if unsubmitted.
132
-
133
- ### Environment Security Controls
134
-
135
- | Env Variable | Effect |
136
- |---|---|
137
- | `ZSWARM_READONLY=1` | Disable all write ops (`send`, `spawn`, `close`, etc.) |
138
- | `ZSWARM_ALLOW_PANES` / `ZSWARM_DENY_PANES` | Comma-separated list/patterns of allowed/denied pane titles |
139
- | `ZSWARM_ALLOW_SPAWN=0` | Disable spawning new panes |
140
- | `ZSWARM_ALLOW_CLOSE=0` | Disable closing panes |
141
- | `ZSWARM_ALLOW_WORKTREE_REMOVE=0` | Disable removing git worktrees |
142
-
143
- ---
144
-
145
- ## ⚙️ Environment Variables
146
-
147
- | Variable | Description |
148
- |---|---|
149
- | `ZSWARM_BIN` / `ZSWARM_PATH` | Path to `zellij` executable |
150
- | `ZSWARM_SESSION` | Default Zellij session name |
151
- | `ZELLIJ_SESSION_NAME` | Active Zellij session (set automatically inside Zellij panes) |
152
- | `ZSWARM_WORKTREE_ROOT` | Directory for linked worktrees (default: `<repo>-worktrees`) |
153
- | `ZSWARM_STATE_DIR` | State storage directory for logs, signals, and cursors (default: `~/.zswarm`) |
154
- | `ZSWARM_SSH` | `user@host` — Route Zellij commands across SSH |
155
-
156
- ---
157
-
158
- ## 📦 Monorepo Structure
159
-
160
- | Package | Purpose |
161
- |---|---|
162
- | `zswarm` | Main meta-package (`npm i -g zswarm`) |
163
- | `@zswarm/core` | Core Zellij client and shared dispatch engine |
164
- | `@zswarm/cli` | `zswarm` command line interface |
165
- | `@zswarm/mcp` | Stdio MCP server (`zswarm-mcp`) |
166
- | `@zswarm/wasm` | Precompiled Rust event-bus WASM plugin |
167
- | `@zswarm/pi` | Extension bridge for harnesses without native MCP support |
168
-
169
- ---
10
+ Ops, env, MCP setup, and the event bus: the [repo README](../../README.md).
170
11
 
171
- ## 📜 License
12
+ ## License
172
13
 
173
- [MIT](LICENSE)
14
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zswarm",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Coordinate CLI agent crews in Zellij panes",
6
6
  "engines": {
@@ -22,17 +22,11 @@
22
22
  "README.md"
23
23
  ],
24
24
  "dependencies": {
25
- "@zswarm/cli": "0.1.0",
26
- "@zswarm/mcp": "0.1.0"
25
+ "@zswarm/mcp": "0.1.1",
26
+ "@zswarm/cli": "0.1.1"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "scripts": {
32
- "build": "pnpm -r run build",
33
- "build:plugin": "cd plugin/zswarm-events && cargo build --release --target wasm32-wasip1 && node -e \"require('node:fs').copyFileSync('target/wasm32-wasip1/release/zswarm-events.wasm','../../packages/wasm/zswarm-bus-v3.wasm')\"",
34
- "test": "pnpm --dir packages/core test",
35
- "cli": "pnpm --dir packages/cli exec node dist/cli.js",
36
- "mcp": "pnpm --dir packages/mcp exec node dist/mcp-server.js"
37
- }
31
+ "scripts": {}
38
32
  }
@@ -1,85 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Cross-host MCP launcher for zSwarm (Cursor / Codex / Claude).
4
- * Windows-safe: hosts must exec `node` + this file.
5
- */
6
- import { spawn } from "node:child_process";
7
- import { existsSync, statSync } from "node:fs";
8
- import { homedir } from "node:os";
9
- import { dirname, join } from "node:path";
10
- import { fileURLToPath } from "node:url";
11
-
12
- const home = process.env.USERPROFILE || process.env.HOME || homedir();
13
- const thisFile = fileURLToPath(import.meta.url);
14
- const pluginRoot = join(dirname(thisFile), "..");
15
-
16
- function isFile(p) {
17
- try {
18
- return statSync(p).isFile();
19
- } catch {
20
- return false;
21
- }
22
- }
23
-
24
- function enrichPath(env) {
25
- const sep = process.platform === "win32" ? ";" : ":";
26
- const extras = [
27
- process.platform === "win32"
28
- ? join(env.LOCALAPPDATA || join(home, "AppData", "Local"), "Zellij")
29
- : "",
30
- join(home, ".local", "bin"),
31
- join(home, ".cargo", "bin"),
32
- ].filter(Boolean);
33
- const current = env.PATH || env.Path || "";
34
- const merged = [...extras, ...current.split(sep).filter(Boolean)];
35
- const seen = new Set();
36
- const path = merged
37
- .filter((p) => {
38
- const key = p.toLowerCase();
39
- if (seen.has(key)) return false;
40
- seen.add(key);
41
- return true;
42
- })
43
- .join(sep);
44
- return { ...env, PATH: path, Path: path };
45
- }
46
-
47
- const script = join(pluginRoot, "packages", "mcp", "dist", "mcp-server.js");
48
- if (!isFile(script)) {
49
- console.error(
50
- "zswarm: missing packages/mcp/dist/mcp-server.js — run: pnpm install && pnpm run build",
51
- );
52
- process.exit(127);
53
- }
54
-
55
- const env = enrichPath(process.env);
56
-
57
- function expandHome(p) {
58
- if (typeof p !== "string") return p;
59
- const t = p.trim();
60
- if (!t.startsWith("~/") && !t.startsWith("~\\")) return p;
61
- return join(home, t.slice(2));
62
- }
63
- if (env.ZSWARM_BIN) env.ZSWARM_BIN = expandHome(env.ZSWARM_BIN);
64
- if (env.ZSWARM_PATH) env.ZSWARM_PATH = expandHome(env.ZSWARM_PATH);
65
-
66
- const zellijExe = join(
67
- env.LOCALAPPDATA || join(home, "AppData", "Local"),
68
- "Zellij",
69
- "zellij.exe",
70
- );
71
- if (!env.ZSWARM_BIN && !env.ZSWARM_PATH && isFile(zellijExe)) {
72
- env.ZSWARM_BIN = zellijExe;
73
- }
74
-
75
- const child = spawn(process.execPath, [script, ...process.argv.slice(2)], {
76
- stdio: "inherit",
77
- env,
78
- windowsHide: true,
79
- shell: false,
80
- });
81
- child.on("exit", (code) => process.exit(code ?? 1));
82
- child.on("error", (error) => {
83
- console.error(error.message);
84
- process.exit(1);
85
- });