@adamancyzhang/claude-orchestrator 0.3.3 → 0.4.0

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.
Files changed (77) hide show
  1. package/README.md +197 -269
  2. package/dist/cli/commands.d.ts +0 -10
  3. package/dist/cli/commands.js +1 -184
  4. package/dist/cli/commands.js.map +1 -1
  5. package/dist/config.d.ts +22 -0
  6. package/dist/config.js +23 -0
  7. package/dist/config.js.map +1 -1
  8. package/dist/executor/template.js +21 -3
  9. package/dist/executor/template.js.map +1 -1
  10. package/dist/index.js +9 -34
  11. package/dist/index.js.map +1 -1
  12. package/dist/leader/chain-router.d.ts +5 -1
  13. package/dist/leader/chain-router.js +90 -2
  14. package/dist/leader/chain-router.js.map +1 -1
  15. package/dist/leader/event-bus.d.ts +1 -1
  16. package/dist/leader/event-bus.js +1 -1
  17. package/dist/leader/event-bus.js.map +1 -1
  18. package/dist/leader/index.d.ts +7 -0
  19. package/dist/leader/index.js +5 -2
  20. package/dist/leader/index.js.map +1 -1
  21. package/dist/leader/merge-validator.d.ts +24 -0
  22. package/dist/leader/merge-validator.js +112 -0
  23. package/dist/leader/merge-validator.js.map +1 -0
  24. package/dist/leader/state.d.ts +17 -0
  25. package/dist/leader/state.js +48 -2
  26. package/dist/leader/state.js.map +1 -1
  27. package/dist/leader/tui.d.ts +2 -0
  28. package/dist/leader/tui.js +140 -16
  29. package/dist/leader/tui.js.map +1 -1
  30. package/dist/leader/watcher.js +12 -0
  31. package/dist/leader/watcher.js.map +1 -1
  32. package/dist/models/schemas.d.ts +15 -0
  33. package/dist/models/schemas.js +5 -0
  34. package/dist/models/schemas.js.map +1 -1
  35. package/dist/orchestrator/run.d.ts +6 -0
  36. package/dist/orchestrator/run.js +181 -0
  37. package/dist/orchestrator/run.js.map +1 -0
  38. package/dist/skills/claude-orchestrator/SKILL.md +75 -217
  39. package/dist/templates/agents/worker-accept.md +48 -0
  40. package/dist/templates/agents/worker-build.md +38 -0
  41. package/dist/templates/agents/worker-decompose.md +40 -0
  42. package/dist/templates/agents/worker-evaluate.md +49 -0
  43. package/dist/templates/agents/worker-plan.md +36 -0
  44. package/dist/templates/agents/worker-review.md +42 -0
  45. package/dist/templates/agents/worker-verify.md +44 -0
  46. package/dist/templates/claude-memory/personal-claude-accepter.md +17 -0
  47. package/dist/templates/claude-memory/personal-claude-builder.md +24 -0
  48. package/dist/templates/claude-memory/personal-claude-planner.md +22 -0
  49. package/dist/templates/claude-memory/personal-claude-reviewer.md +25 -0
  50. package/dist/templates/claude-memory/personal-claude-verifier.md +24 -0
  51. package/dist/templates/claude-memory/team-claude.md +61 -0
  52. package/dist/utils/logger.d.ts +1 -0
  53. package/dist/utils/logger.js +3 -0
  54. package/dist/utils/logger.js.map +1 -1
  55. package/dist/worker/child-runner.d.ts +12 -0
  56. package/dist/worker/child-runner.js +99 -0
  57. package/dist/worker/child-runner.js.map +1 -0
  58. package/dist/worker/child.d.ts +2 -0
  59. package/dist/worker/child.js +8 -0
  60. package/dist/worker/child.js.map +1 -0
  61. package/dist/worker/commit-checker.d.ts +20 -0
  62. package/dist/worker/commit-checker.js +87 -0
  63. package/dist/worker/commit-checker.js.map +1 -0
  64. package/dist/worker/watcher.d.ts +5 -1
  65. package/dist/worker/watcher.js +41 -4
  66. package/dist/worker/watcher.js.map +1 -1
  67. package/dist/worker/worktree-initializer.d.ts +10 -0
  68. package/dist/worker/worktree-initializer.js +235 -0
  69. package/dist/worker/worktree-initializer.js.map +1 -0
  70. package/package.json +2 -2
  71. package/dist/templates/worker-accept.md +0 -46
  72. package/dist/templates/worker-build.md +0 -45
  73. package/dist/templates/worker-decompose.md +0 -67
  74. package/dist/templates/worker-evaluate.md +0 -41
  75. package/dist/templates/worker-plan.md +0 -43
  76. package/dist/templates/worker-review.md +0 -46
  77. package/dist/templates/worker-verify.md +0 -47
package/README.md CHANGED
@@ -18,29 +18,22 @@
18
18
 
19
19
  ## What is this?
20
20
 
21
- **Claude Orchestrator** lets you run multiple Claude Code instances that talk to each other assign tasks, send messages, share context, and collaborate on real work. Think of it as giving each Claude Code instance a walkie-talkie and a shared kanban board, then watching them build together.
21
+ **Claude Orchestrator** runs multiple Claude Code instances as an AI team. Each Worker gets an isolated git worktree with humanized names (Tom, Jerry, Lucy...), auto-processes assigned tasks via `claude -p`, self-evaluates output, and sends structured decisions back to the Leader. The Leader runs a read-only TUI and mechanically routes tasks through the Plan Build → Verify → Review → Accept responsibility chain.
22
22
 
23
- Behind the scenes, ZooKeeper acts as the coordination backbone: ephemeral nodes for instance heartbeat, sequential nodes for FIFO task ordering, and watches for real-time change notification.
24
-
25
- v0.3.1 delivers a **Leader-Worker CLI-native architecture**: no MCP server, no HTTP. The Leader runs a read-only TUI and acts as a pure message/task router — it never calls `claude -p`. Workers connect directly to ZooKeeper, process messages via `claude -p`, self-evaluate their output, and send structured decisions back to the Leader. All AI intelligence lives in Workers; the Leader only handles mechanical forwarding, task distribution, and recovery. Built-in Claude Code skills (task-planning, task-execution, task-verification, task-review, task-acceptance, task-traceability) enforce a standardized responsibility chain for every task.
23
+ Under the hood, ZooKeeper handles coordination: ephemeral nodes for heartbeat, sequential nodes for FIFO task ordering, and watches for real-time notification. Zero external database — all state lives in ZooKeeper.
26
24
 
27
25
  ```
28
- ┌─────────────────────────────────────────────────┐
29
- ZooKeeper
30
- /leader /instances /tasks /messages│
31
- └──────┬──────────────┬──────────────┬────────────┘
32
-
33
- ┌────┴────┐ ┌────┴────┐ ┌────┴────┐
34
- │ Leader │ │ Worker │ │ Worker │
35
- │ (TUI) │ (CLI) (CLI)
36
- Tom Jerry │ Bob
37
- │architect│developer tester
38
- └─────────┘ └─────────┘ └─────────┘
39
- │ │ │
40
- └──────────────┼──────────────┘
41
-
42
- claude-orchestrator CLI
43
- (send-message, push-task, …)
26
+ ┌──────────────────────────────────────────────────────┐
27
+ ZooKeeper
28
+ /leader /instances /tasks /messages
29
+ └────────┬────────────────┬────────────────┬────────────┘
30
+
31
+ ┌────┴────┐ ┌────┴────┐ ┌────┴────┐
32
+ │ Leader │ │ Worker │ │ Worker │
33
+ │ (TUI) │ │(worktree)│ │(worktree)│
34
+ Tom │Jerry │ Lucy
35
+ planner builder │verifier │
36
+ └─────────┘ └─────────┘ └─────────┘
44
37
  ```
45
38
 
46
39
  ---
@@ -59,187 +52,175 @@ npm install -g @adamancyzhang/claude-orchestrator
59
52
  docker-compose up -d
60
53
  ```
61
54
 
62
- ### 3. Initialize your environment
55
+ ### 3. Launch Everything
63
56
 
64
57
  ```bash
65
- # For the Leader (the team coordinator):
66
- claude-orchestrator setup --leader --name Tom
67
-
68
- # For each Worker (the doers):
69
- claude-orchestrator setup --name Jerry --role builder
58
+ claude-orchestrator run --worker 5
70
59
  ```
71
60
 
72
- This creates `.claude-orchestrator/agents/` with message templates, `.claude/skills/` with responsibility-chain skills, and writes project + global config.
61
+ One command. It:
62
+ - Creates isolated git worktrees for each Worker (`.claude-orchestrator/worktree/{name}/`)
63
+ - Assigns humanized names (Tom, Jerry, Lucy, Thomas, Jack...) and roles (planner, builder, verifier, reviewer, accepter)
64
+ - Copies agent templates and skills into each worktree
65
+ - Starts the Leader TUI
66
+ - Forks Worker child processes (each in its own worktree)
73
67
 
74
- ### 4. Start the Leader
68
+ ### 4. Use It
69
+
70
+ Type a requirement in the TUI input line and press Enter. The Leader forwards it to a Planner Worker, which decomposes it into a responsibility chain. Each Worker processes its link, self-evaluates, and the Leader routes the next link.
75
71
 
76
72
  ```bash
77
- claude-orchestrator leader --name Tom
78
- # TUI launches: team panel, task board, event log, footer
73
+ # CLI commands (from any terminal)
74
+ claude-orchestrator push-task --title "Implement login endpoint" --priority 0
75
+ claude-orchestrator send-message --to-name Jerry --content "Starting on the auth module?"
76
+ claude-orchestrator list-tasks --status pending
79
77
  ```
80
78
 
81
- The Leader TUI shows who's online, what tasks are pending, and a scrolling event log. It also has a keyboard input line — typed text is sent as a message for processing. All other actions are triggered by CLI commands or Worker registrations.
79
+ ---
82
80
 
83
- ### 5. Register a Worker
81
+ ## Architecture
84
82
 
85
- ```bash
86
- # Reads name/role from .claude-orchestrator/config.json (set during setup).
87
- # Starts Worker Watcher — listens for messages and auto-processes via claude -p:
88
- claude-orchestrator register
89
- # Press Ctrl+C to stop and unregister
90
- ```
83
+ ### Leader-Worker Model (v0.4)
91
84
 
92
- ### 6. Go
85
+ | Component | What it does | ZK magic |
86
+ |-----------|-------------|----------|
87
+ | **Leader** | Read-only TUI, mechanical message/task routing, merge validation, orphan recovery. No AI calls. | `/leader` EPHEMERAL — exactly one Leader |
88
+ | **Worker** | Isolated git worktree, ZK watch loop, auto-processes messages via `claude -p`, self-evaluates output, auto-commits changes | EPHEMERAL nodes → auto-cleanup on disconnect |
89
+ | **Task Queue** | Push → Claim → Complete (or Block/Fail/Retry). Role-link priority sorting. | Sequential nodes for FIFO, ephemeral claims for atomic locks |
90
+ | **Message Router** | Point-to-point messaging via ZK watches | Persistent-sequential nodes, push notification |
93
91
 
94
- Now the Leader TUI shows Jerry online. You can push tasks, send messages, and manage the full lifecycle — all from any terminal.
92
+ ### Worktree Isolation
95
93
 
96
- ```bash
97
- claude-orchestrator push-task --title "Implement login endpoint" --priority 0
98
- claude-orchestrator send-message --content "Starting on the auth module?"
99
- claude-orchestrator poll-task
100
- ```
94
+ Each Worker runs in its own `git worktree` under `.claude-orchestrator/worktree/{name}/`. This gives every Worker:
95
+ - **Independent working directory** no file conflicts
96
+ - **Dedicated git branch** `claude-orchestrator/{name}-workspace`
97
+ - **Personal CLAUDE.md** — role-specific rules at `.claude-orchestrator/docs/{name}/CLAUDE.md`
98
+ - **Daily directory memory** — `.claude-orchestrator/docs/{name}/YYYY-MM-DD/CLAUDE.md` preserves session context across restarts
101
99
 
102
- ---
100
+ ### CLI-Native — Zero MCP Server
103
101
 
104
- ## How It Works
102
+ Leader and Workers each connect directly to ZooKeeper. The Leader is a pure router: forwards requirements, creates tasks from ChainDef JSON, mechanically executes EvalDecision JSON. All AI intelligence runs exclusively on Workers via `claude -p`. No HTTP, no SSE, no MCP protocol.
105
103
 
106
- ### Leader-Worker Model
104
+ ### Responsibility Chain
107
105
 
108
- | Component | What it does | ZK magic |
109
- |-----------|-------------|----------|
110
- | **Leader** | TUI with keyboard input, mechanical message/task router, recovers orphaned tasks. No AI calls. | `/leader` EPHEMERAL — only one Leader at a time |
111
- | **Worker** | Persistent ZK connection, auto-processes messages via `claude -p`, self-evaluates output | Ephemeral nodes → auto-cleanup on disconnect |
112
- | **Task Queue** | Push → Claim → Complete (or Block/Fail/Retry) | Sequential nodes for FIFO, ephemeral claims for atomic locks |
113
- | **Message Router** | Point-to-point messaging via ZK watches | Persistent-sequential nodes, ZK watches for push |
106
+ ```
107
+ Plan → Build → Verify → Review → Accept
108
+ ```
114
109
 
115
- ### CLI-NativeNo MCP Server
110
+ Each link is a dedicated role. One Worker produces, the next Worker verifies forming a **closed-loop responsibility chain**. Every output is written to `.claude-orchestrator/docs/{name}/YYYY-MM-DD/` and the next link reads from there. Built-in self-evaluation after every link ensures quality at each step.
116
111
 
117
- v0.3.x removes the centralized MCP Server entirely. Leader and Workers each connect directly to ZooKeeper. The Leader is a pure router: it forwards requirements to Planner Workers, creates tasks from structured definitions, and mechanically executes EvalDecision JSON from Workers. AI intelligence (task decomposition, self-evaluation) runs exclusively on Workers via `claude -p`. This eliminates 3 layers of indirection (MCP protocol, SSE, HTTP) and makes every node self-contained.
112
+ ---
118
113
 
119
- ### CLI Commands
114
+ ## CLI Commands
120
115
 
121
- | Command | What it does |
116
+ | Command | Description |
122
117
  |---------|-------------|
123
- | `leader` | Start Leader node with TUI (keyboard input for sending messages) |
124
- | `setup` | Initialize environment: templates, skills, config |
125
- | `register` | Join the swarm. Reads name/role from `.claude-orchestrator/config.json`, registers and listens in cwd |
118
+ | `run --worker <n>` | Start full orchestration: Leader TUI + N Workers with worktree isolation |
126
119
  | `unregister` | Explicitly unregister an instance |
127
120
  | `push-task` | Create a task (optionally assign to someone) |
128
121
  | `claim-task` | Grab the next task — atomic, no two instances can claim the same one |
129
122
  | `complete-task` | Mark a task done with results |
130
- | `poll-task` | Check your claimed tasks |
123
+ | `list-tasks` | List tasks by status |
131
124
  | `task-block` | Mark a claimed task as blocked (with reason) |
132
125
  | `task-fail` | Mark a claimed task as failed (with reason) |
133
- | `task-retry` | Re-queue a failed task for retry (retry_count + 1, max 3) |
134
- | `send-message` | Send a message to the Leader instance |
126
+ | `task-retry` | Re-queue a failed task (retry_count + 1, max 3) |
127
+ | `send-message` | Send a message to a specific instance |
135
128
  | `poll-message` | Check your inbox |
136
129
  | `delete-message` | Delete a message from your inbox |
137
130
  | `config` | Show current configuration |
138
131
 
139
- All CLI commands return JSON. Every command supports `--zookeeper` / `-z` (or `ZK_HOSTS` env var) for pointing at a remote ZooKeeper.
140
-
141
132
  ---
142
133
 
143
- ## Example Session
134
+ ## Directory Memory (CLAUDE.md)
144
135
 
145
- Here's a real flow with a Leader (Tom) and two Workers (Jerry, Bob):
136
+ Claude Orchestrator uses a three-layer **CLAUDE.md** system as directory memory:
146
137
 
147
- **Tom starts the Leader:**
148
- ```
149
- claude-orchestrator leader --name Tom
150
- TUI shows: [TEAM] Tom (leader), [PENDING] empty, [EVENT LOG] Leader started
151
- ```
138
+ | Layer | Location | Content |
139
+ |-------|----------|---------|
140
+ | **Team** | Worktree root `CLAUDE.md` | Team roles, directory structure, responsibility chain, git rules |
141
+ | **Personal** | `.claude-orchestrator/docs/{name}/CLAUDE.md` | Role-specific process, output standards, communication rules, prohibited behaviors |
142
+ | **Daily** | `.claude-orchestrator/docs/{name}/YYYY-MM-DD/CLAUDE.md` | Session context, task progress, decisions, blockers |
152
143
 
153
- **Jerry registers as a Worker:**
154
- ```bash
155
- claude-orchestrator register
156
- ```
157
- ```
158
- TUI updates:
159
- [TEAM] Jerry joined (builder)
160
- [EVENT] 9:15:03 PM Jerry joined (builder)
161
- ```
144
+ Layers 1 and 2 are seeded from templates during worktree creation. Layer 3 is created and maintained by Workers themselves during task execution — guided by prompt templates that instruct Claude to manage its own daily memory.
162
145
 
163
- **Tom assigns work (from another terminal):**
164
- ```bash
165
- claude-orchestrator push-task --title "Implement POST /api/auth/login" \
166
- --description "Email+password login, return JWT." --priority 0
167
- ```
146
+ ---
168
147
 
169
- **Jerry claims it:**
170
- ```bash
171
- claude-orchestrator claim-task
172
- # → { "id": "task-0000000000", "status": "claimed", ... }
173
- ```
148
+ ## Template Structure
174
149
 
175
- **Jerry gets blocked:**
176
- ```bash
177
- claude-orchestrator task-block --task-id task-0000000000 --reason "Waiting for API key"
178
150
  ```
179
-
180
- **Tom sees the block in the TUI and sends the key:**
181
- ```bash
182
- claude-orchestrator send-message --content "API key is in 1Password: auth/third-party/google-oauth"
151
+ templates/
152
+ ├── agents/ ← Worker prompt templates
153
+ │ ├── worker-decompose.md # Requirement → chain decomposition
154
+ │ ├── worker-plan.md # Planner: blueprint design
155
+ │ ├── worker-build.md # Builder: traceable implementation
156
+ │ ├── worker-verify.md # Verifier: cross-check Plan vs Build
157
+ │ ├── worker-review.md # Reviewer: chain-level quality gate
158
+ │ ├── worker-accept.md # Accepter: final Go/No-Go decision
159
+ │ └── worker-evaluate.md # Self-evaluation after each link
160
+ └── claude-memory/ ← Directory memory templates
161
+ ├── team-claude.md # Workspace-level CLAUDE.md
162
+ ├── personal-claude-planner.md # Planner role rules
163
+ ├── personal-claude-builder.md # Builder role rules
164
+ ├── personal-claude-verifier.md # Verifier role rules
165
+ ├── personal-claude-reviewer.md # Reviewer role rules
166
+ └── personal-claude-accepter.md # Accepter role rules
183
167
  ```
184
168
 
185
- **Jerry finishes:**
186
- ```bash
187
- claude-orchestrator complete-task --task-id task-0000000000 --result "PR #42 — login endpoint with tests"
188
- ```
169
+ Worker templates are lean — they provide task context and key instructions, then guide Workers to read the corresponding skill file (`.claude/skills/{skill}/SKILL.md`) for detailed process. This keeps prompts focused and prevents LLM attention dispersion.
189
170
 
190
- **Bob fails a task (test env down):**
191
- ```bash
192
- claude-orchestrator task-fail --task-id task-0000000001 --reason "Test environment unavailable"
193
- claude-orchestrator task-retry --task-id task-0000000001
194
- # Re-queued as task-0000000002 with retry_count: 1
195
- ```
171
+ ---
172
+
173
+ ## Skills
174
+
175
+ | Skill | Role | Description |
176
+ |-------|------|-------------|
177
+ | `task-planning` | Planner | Analyze requirements, define blueprints, break down tasks |
178
+ | `task-execution` | Builder | Claim tasks, implement against blueprints, commit with traceability |
179
+ | `task-verification` | Verifier | Independently verify Builder output against Plan criteria |
180
+ | `task-review` | Reviewer | Review full chain (Plan→Build→Verify) for design consistency |
181
+ | `task-acceptance` | Accepter | Validate final deliverable against business criteria, sign Go/No-Go |
182
+ | `task-traceability` | Foundation | Trace → Execute → Map → Evidence → Record — all roles |
196
183
 
197
184
  ---
198
185
 
199
- ## ZooKeeper Schema (v0.3.0)
186
+ ## ZooKeeper Node Tree
200
187
 
201
188
  ```
202
189
  /claude-orchestrator
203
190
  ├── leader [EPHEMERAL] Leader metadata
204
- ├── instances/
205
- │ ├── a1b2c3d4... [EPHEMERAL] Tom (leader)
206
- │ ├── f6e5d4c3... [EPHEMERAL] Jerry (developer)
207
- │ └── e7f8a9b0... [EPHEMERAL] Bob (tester)
191
+ ├── instances/{id} [EPHEMERAL] Instance metadata
208
192
  ├── tasks/
209
- │ ├── pending/
210
- ├── task-0000000000 [PERSISTENT_SEQUENTIAL]
211
- └── task-0000000001 [PERSISTENT_SEQUENTIAL]
212
- │ ├── claimed/
213
- │ │ └── f6e5d4c3-task-0000000000 [EPHEMERAL] ← atomic lock!
214
- │ └── completed/
215
- │ └── task-0000000000 [PERSISTENT]
216
- ├── messages/
217
- │ ├── a1b2c3d4.../
218
- │ │ └── msg-0000000000 [PERSISTENT_SEQUENTIAL]
219
- │ └── f6e5d4c3.../
220
- │ └── msg-0000000000 [PERSISTENT_SEQUENTIAL]
193
+ │ ├── pending/task-NNNNN [PERSISTENT_SEQUENTIAL]
194
+ │ ├── claimed/{insId}-task-NNNNN [EPHEMERAL] ← atomic lock
195
+ │ └── completed/task-NNNNN [PERSISTENT]
196
+ └── messages/{instanceId}/msg-NNNNN [PERSISTENT_SEQUENTIAL]
221
197
  ```
222
198
 
223
- **Key insight:** Ephemeral nodes mean crashed instances auto-unregister. Ephemeral claim nodes mean abandoned tasks auto-release. The Leader monitors `/instances` and recovers orphaned tasks when a Worker disconnects (max 3 retries, then archived as failed).
224
-
225
199
  ---
226
200
 
227
- ## Task State Machine (v0.3.0)
201
+ ## Why ZooKeeper?
228
202
 
229
- ```
230
- pending → claimed → completed
231
- blockedpending (retry)
232
- failed pending (retry, max 3)
233
- claimed pending (Worker disconnect, Leader recovers orphan)
234
- ```
203
+ | Concern | ZooKeeper answer |
204
+ |---------|-----------------|
205
+ | Instance lifecycle | Ephemeral nodes auto-cleanup on crash |
206
+ | Task ordering | Sequential nodes guaranteed FIFO |
207
+ | Claim atomicity | `create(path, ephemeral=true)` is atomic — only one winner |
208
+ | Leader election | `/leader` EPHEMERAL → exactly one Leader |
209
+ | Change notification | Built-in watches → push, not poll |
210
+ | Dependencies | One dependency (ZK). No database, no HTTP server. |
235
211
 
236
- | State | Meaning | Trigger |
237
- |-------|---------|---------|
238
- | `pending` | Waiting for claim | `push_task` |
239
- | `claimed` | Claimed, not started | `claim_task` |
240
- | `completed` | Done | `complete_task` |
241
- | `blocked` | Blocked, waiting unblock | `task-block` |
242
- | `failed` | Failed, can retry | `task-fail` |
212
+ ---
213
+
214
+ ## Roles
215
+
216
+ | Role | Value | Typical behavior |
217
+ |------|-------|-----------------|
218
+ | Leader | `leader` | Runs TUI, mechanical routing, merge validation, orphan recovery |
219
+ | Planner | `planner` | Decomposes requirements, defines blueprints |
220
+ | Builder | `builder` | Implements per blueprint, produces traceability evidence |
221
+ | Verifier | `verifier` | Cross-checks Builder output against Plan |
222
+ | Reviewer | `reviewer` | Quality gate for design consistency across full chain |
223
+ | Accepter | `accepter` | Final Go/No-Go validation against business criteria |
243
224
 
244
225
  ---
245
226
 
@@ -257,160 +238,107 @@ claimed → pending (Worker disconnect, Leader recovers orphan)
257
238
  git clone https://github.com/adamancyzhang/claude-orchestrator-server.git
258
239
  cd claude-orchestrator-server
259
240
 
260
- # Install dependencies
261
241
  npm install
262
-
263
- # Start ZooKeeper
264
242
  docker-compose up -d
265
-
266
- # Build TypeScript
267
243
  npm run build
268
244
 
269
- # Start the Leader
270
- claude-orchestrator leader
271
-
272
- # Or use the CLI directly
273
- claude-orchestrator config
245
+ # Start with 3 Workers
246
+ node dist/index.js run --worker 3
274
247
  ```
275
248
 
276
249
  ### Run Tests
277
250
 
278
251
  ```bash
279
- npm test
252
+ npm test # All unit tests (110+)
253
+ npm run test:watch # Watch mode
254
+ npx vitest run tests/unit/worker-prompt-rendering.test.ts # Prompt rendering verification
280
255
  ```
281
256
 
282
257
  ---
283
258
 
284
- ## Skills for Claude Code
285
-
286
- The repo includes Claude Code skills that enforce a standardized **responsibility chain**: Plan → Build → Verify → Review → Accept. Each link has a dedicated skill, grounded on the `task-traceability` foundation layer. The `setup` command installs the 6 responsibility-chain skills into `.claude/skills/`.
287
-
288
- | Skill | Role | What it does |
289
- |-------|------|-------------|
290
- | `task-planning` | Planner | Analyze requirements, define blueprints, break down tasks, push to queue |
291
- | `task-execution` | Builder | Claim tasks, implement against blueprints, commit code with traceability |
292
- | `task-verification` | Verifier | Independently verify Builder output against Plan criteria |
293
- | `task-review` | Reviewer | Review full chain (Plan→Build→Verify) for design consistency |
294
- | `task-acceptance` | Accepter | Validate final deliverable against business criteria, sign Go/No-Go |
295
- | `task-traceability` | Foundation | Trace → Execute → Map → Evidence → Record — all roles |
296
-
297
- ---
298
-
299
- ## Why ZooKeeper?
300
-
301
- | Concern | ZooKeeper answer |
302
- |---------|-----------------|
303
- | Instance lifecycle | Ephemeral nodes → auto-cleanup. No heartbeat polling needed. |
304
- | Task ordering | Sequential nodes → guaranteed FIFO. No race conditions. |
305
- | Claim atomicity | `create(path, ephemeral=true)` is atomic at the ZK level. Only one winner. |
306
- | Leader election | `/leader` EPHEMERAL → exactly one Leader. Auto-released on crash. |
307
- | Change notification | Built-in watches → push, not poll. |
308
- | Dependencies | One dependency (ZK). No external database, no HTTP server. |
309
-
310
- Zero external database. All state lives in ZooKeeper.
311
-
312
- ---
313
-
314
- ## Roles
315
-
316
- | Role | Value | Typical behavior |
317
- |------|-------|-----------------|
318
- | Leader | `leader` | Runs TUI, mechanical message/task routing, recovers orphaned tasks |
319
- | Planner | `planner` | Decomposes requirements into task chains, defines blueprints |
320
- | Builder | `builder` | Claims build tasks, writes code, submits PRs |
321
- | Verifier | `verifier` | Claims verify tasks, checks Builder output against Plan |
322
- | Reviewer | `reviewer` | Claims review tasks, quality gate for design consistency |
323
- | Accepter | `accepter` | Claims accept tasks, final Go/No-Go validation |
324
-
325
- ---
326
-
327
- ## Configuration Reference
328
-
329
- | Config | Where | Default |
330
- |--------|-------|---------|
331
- | ZK hosts | `-z, --zookeeper` flag or `ZK_HOSTS` env | `127.0.0.1:2181` |
332
- | Instance ID | `-i, --instance-id` flag or `.claude-orchestrator/config.json` (project) / `~/.claude-orchestrator/config.json` (global) | auto-saved after `register` |
333
- | Claude command | `--command` flag or `config.json` → `commands.claude-cli` | `claude --dangerously-skip-permissions --permission-mode dontAsk` |
334
- | Cache directory | `--cache-dir` flag or `config.json` → `cache_dir` | `~/.claude-orchestrator/sessions` |
335
-
336
- ---
337
-
338
259
  ## Project Structure
339
260
 
340
261
  ```
341
262
  ├── src/
342
- │ ├── index.ts # CLI entry point (commander, 15 commands)
343
- │ ├── config.ts # Configuration handling
344
- │ ├── cli/
345
- │ │ └── commands.ts # CLI subcommand implementations
346
- │ ├── leader/ # Leader node (v0.3.1)
347
- │ │ ├── index.ts # startup / shutdown orchestration
348
- │ │ ├── tui.ts # ANSI-based read-only TUI
349
- │ │ ├── event-bus.ts # typed EventEmitter (14 events)
350
- │ │ ├── state.ts # centralized LeaderState
351
- │ │ ├── monitor.ts # WorkerMonitor — join/leave detection
352
- │ │ ├── orchestrator.ts # TaskOrchestrator — lifecycle tracking
353
- │ │ ├── recovery.ts # TaskRecovery — orphan recovery (max 3 retries)
354
- │ │ ├── watcher.ts # LeaderWatcher — message processing
355
- │ │ └── chain-router.ts # ChainRouter — mechanical routing (no AI)
356
- ├── worker/ # Worker node (v0.3.1)
357
- ├── watcher.ts # WorkerWatcher ZK watch loop + orchestration
358
- │ │ └── evaluator.ts # SelfEvaluator built-in self-evaluation
359
- │ ├── executor/ # Template execution engine
360
- │ │ ├── template.ts # TemplateEngine loading + rendering
361
- │ │ └── runner.ts # ClaudeRunnerCLI execution wrapper
362
- │ ├── templates/ # Built-in agent templates
363
- │ │ ├── worker-decompose.md # Planner decompose prompt
364
- ├── worker-evaluate.md # Worker self-evaluation prompt
365
- │ │ ├── worker-plan.md # Planner template (task-traceability + task-acceptance)
366
- │ │ ├── worker-build.md # Builder template (task-traceability)
367
- │ │ ├── worker-verify.md # Verifier template (task-traceability)
368
- │ │ ├── worker-review.md # Reviewer template (task-traceability)
369
- │ │ └── worker-accept.md # Accepter template (task-traceability + task-acceptance)
263
+ │ ├── index.ts # CLI entry point (commander)
264
+ │ ├── config.ts # Configuration layering (global + project)
265
+ │ ├── orchestrator/
266
+ │ │ └── run.ts # Unified run orchestrator (5-phase startup)
267
+ │ ├── leader/ # Leader node
268
+ │ │ ├── index.ts # Startup / shutdown orchestration
269
+ │ │ ├── tui.ts # ANSI TUI with Worker Messages panel
270
+ │ │ ├── event-bus.ts # Typed EventEmitter (15 events)
271
+ │ │ ├── state.ts # Centralized LeaderState
272
+ │ │ ├── monitor.ts # WorkerMonitor — join/leave detection
273
+ │ │ ├── orchestrator.ts # TaskOrchestrator — lifecycle tracking
274
+ │ │ ├── recovery.ts # TaskRecovery — orphan recovery (max 3 retries)
275
+ │ │ ├── watcher.ts # LeaderWatcher — message processing
276
+ │ │ ├── chain-router.ts # ChainRouter — mechanical routing (no AI)
277
+ │ └── merge-validator.ts # Cross-verify + merge worker branches
278
+ │ ├── worker/ # Worker node
279
+ │ │ ├── worktree-initializer.ts# Name generation, worktree creation, role assignment
280
+ ├── child.ts # Child process entry point
281
+ │ │ ├── child-runner.ts # Child process core (chdir → ZK → Watcher)
282
+ │ │ ├── watcher.ts # WorkerWatcherZK watch loop + orchestration
283
+ ├── evaluator.ts # SelfEvaluator — built-in self-evaluation (max 3 retries)
284
+ │ │ └── commit-checker.ts # Auto-commit after task completion
285
+ │ ├── executor/ # Template execution engine
286
+ │ │ ├── template.ts # TemplateEngine loading + identity card + rendering
287
+ │ │ └── runner.ts # ClaudeRunner CLI execution wrapper
370
288
  │ ├── zk/
371
- │ │ ├── client.ts # ZooKeeper connection management
372
- │ │ └── paths.ts # ZK path constants
289
+ │ │ ├── client.ts # ZooKeeper connection management
290
+ │ │ └── paths.ts # ZK path constants
373
291
  │ ├── modules/
374
- │ │ ├── registry.ts # Instance registry
375
- │ │ ├── task-queue.ts # Task queue (6-state: push/claim/block/fail/retry)
376
- │ │ ├── message-router.ts # Message routing + template rendering + long-poll
292
+ │ │ ├── registry.ts # Instance registry
293
+ │ │ ├── task-queue.ts # Task queue (push/claim/complete/block/fail/retry)
294
+ │ │ └── message-router.ts # Message routing + template rendering
377
295
  │ ├── models/
378
- │ │ └── schemas.ts # Zod schemas and inferred types
296
+ │ │ └── schemas.ts # Zod schemas (Instance, Task, Message, ChainDef, EvalDecision)
379
297
  │ └── utils/
380
- │ ├── exec.ts # Shell execution (execWithTee)
381
- ├── output.ts # CLI output formatting
382
- │ └── logger.ts # Tagged logger for contextual output
383
- ├── bin/
384
- │ └── claude-orchestrator # npm CLI entry (Node.js)
385
- ├── scripts/
386
- │ ├── start-zk.sh # Docker ZK launcher
387
- │ ├── start-leader.sh # Leader launcher
388
- │ ├── start-worker.sh # Worker launcher
389
- │ ├── stop-all.sh # Tear down
390
- └── publish.sh # npm publish pipeline
391
- ├── skills/ # Claude Code skills (6 responsibility-chain + 2 infrastructure)
392
- │ ├── task-planning/ # Planner skill
393
- ├── task-execution/ # Builder skill
394
- │ ├── task-verification/ # Verifier skill
395
- │ ├── task-review/ # Reviewer skill
396
- │ ├── task-acceptance/ # Accepter skill
397
- │ └── task-traceability/ # Foundation layer skill
298
+ │ ├── exec.ts # Shell execution (execWithTee)
299
+ └── logger.ts # Tagged logger (+ --debug mode)
300
+ ├── templates/ # Prompt and memory templates (v0.4)
301
+ ├── agents/ # 7 Worker prompt templates
302
+ │ └── claude-memory/ # 6 CLAUDE.md directory memory templates
303
+ ├── skills/ # Claude Code skills (8 total)
304
+ │ ├── task-traceability/ # Foundation layer
305
+ │ ├── task-planning/ # Planner skill
306
+ │ ├── task-execution/ # Builder skill
307
+ │ ├── task-verification/ # Verifier skill
308
+ ├── task-review/ # Reviewer skill
309
+ ├── task-acceptance/ # Accepter skill
310
+ │ ├── claude-orchestrator/ # CLI reference
311
+ └── claude-code-developer/ # Claude Code developer reference
398
312
  ├── docs/
399
- │ ├── v0.1.0/ # Archived Python v0.1.0 docs
400
- │ ├── v0.2.0/ # Archived MCP-based v0.2.x docs
401
- └── v0.3.0/ # Current v0.3.0 docs
402
- ├── prd/ # Full spec + architecture + ZK schema
403
- │ └── migration-guide.md # v0.2.0 v0.3.0 migration
313
+ │ ├── v0.4/
314
+ ├── design.md # v0.4 full design document
315
+ │ ├── CLAUDE.md # v0.4 changelog summary
316
+ │ └── worker-init/
317
+ └── design.md # Worker initialization + directory memory design
318
+ │ └── v0.3/ # Archived v0.3 docs
404
319
  ├── tests/
405
- │ ├── unit/
406
- │ └── integration/
407
- ├── docker-compose.yml # ZooKeeper
408
- ├── package.json # npm package definition
409
- └── tsconfig.json # TypeScript configuration
320
+ │ ├── unit/ # 11 test files, 110+ tests
321
+ └── worker-prompt-rendering.test.ts # Prompt variable substitution verification
322
+ │ └── integration/ # Leader-Worker integration tests
323
+ ├── examples-workspace/ # Reference implementation of multi-agent patterns
324
+ ├── docker-compose.yml # ZooKeeper
325
+ ├── package.json
326
+ └── tsconfig.json
410
327
  ```
411
328
 
412
329
  ---
413
330
 
331
+ ## Configuration Reference
332
+
333
+ | Config | Where | Default |
334
+ |--------|-------|---------|
335
+ | ZK hosts | `-z, --zookeeper` flag or `ZK_HOSTS` env | `127.0.0.1:2181` |
336
+ | Instance ID | Auto-generated per Worker | saved to `.claude-orchestrator/config.json` |
337
+ | Claude command | `config.json` → `commands.claude-cli` | `claude --dangerously-skip-permissions --permission-mode dontAsk` |
338
+ | Cache directory | `config.json` → `cache_dir` | `~/.claude-orchestrator/sessions` |
339
+
340
+ ---
341
+
414
342
  ## License
415
343
 
416
344
  MIT — use it, fork it, ship it.
@@ -1,4 +1,3 @@
1
- export declare function cmdRegister(zkHosts: string, debug?: boolean): Promise<void>;
2
1
  export declare function cmdPushTask(zkHosts: string, cliInstanceId: string | undefined, title: string, description: string, priority: number, assignee?: string, link?: string, chainId?: string, dependsOn?: string[], blockedBy?: string[]): Promise<void>;
3
2
  export declare function cmdClaimTask(zkHosts: string, cliInstanceId: string | undefined): Promise<void>;
4
3
  export declare function cmdCompleteTask(zkHosts: string, cliInstanceId: string | undefined, taskId: string, result: string): Promise<void>;
@@ -7,15 +6,6 @@ export declare function cmdSendMessage(zkHosts: string, cliInstanceId: string |
7
6
  export declare function cmdPollMessage(zkHosts: string, cliInstanceId: string | undefined): Promise<void>;
8
7
  export declare function cmdDeleteMessage(zkHosts: string, cliInstanceId: string | undefined, messageId: string): Promise<void>;
9
8
  export declare function cmdUnregister(zkHosts: string, cliInstanceId: string | undefined): Promise<void>;
10
- export declare function cmdSetup(options: {
11
- leader: boolean;
12
- name?: string;
13
- role?: string;
14
- cacheDir?: string;
15
- command?: string;
16
- global: boolean;
17
- instanceId?: string;
18
- }): Promise<void>;
19
9
  export declare function cmdTaskBlock(zkHosts: string, cliInstanceId: string | undefined, taskId: string, reason: string): Promise<void>;
20
10
  export declare function cmdTaskFail(zkHosts: string, cliInstanceId: string | undefined, taskId: string, reason: string): Promise<void>;
21
11
  export declare function cmdTaskRetry(zkHosts: string, _cliInstanceId: string | undefined, taskId: string): Promise<void>;