@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.
- package/README.md +197 -269
- package/dist/cli/commands.d.ts +0 -10
- package/dist/cli/commands.js +1 -184
- package/dist/cli/commands.js.map +1 -1
- package/dist/config.d.ts +22 -0
- package/dist/config.js +23 -0
- package/dist/config.js.map +1 -1
- package/dist/executor/template.js +21 -3
- package/dist/executor/template.js.map +1 -1
- package/dist/index.js +9 -34
- package/dist/index.js.map +1 -1
- package/dist/leader/chain-router.d.ts +5 -1
- package/dist/leader/chain-router.js +90 -2
- package/dist/leader/chain-router.js.map +1 -1
- package/dist/leader/event-bus.d.ts +1 -1
- package/dist/leader/event-bus.js +1 -1
- package/dist/leader/event-bus.js.map +1 -1
- package/dist/leader/index.d.ts +7 -0
- package/dist/leader/index.js +5 -2
- package/dist/leader/index.js.map +1 -1
- package/dist/leader/merge-validator.d.ts +24 -0
- package/dist/leader/merge-validator.js +112 -0
- package/dist/leader/merge-validator.js.map +1 -0
- package/dist/leader/state.d.ts +17 -0
- package/dist/leader/state.js +48 -2
- package/dist/leader/state.js.map +1 -1
- package/dist/leader/tui.d.ts +2 -0
- package/dist/leader/tui.js +140 -16
- package/dist/leader/tui.js.map +1 -1
- package/dist/leader/watcher.js +12 -0
- package/dist/leader/watcher.js.map +1 -1
- package/dist/models/schemas.d.ts +15 -0
- package/dist/models/schemas.js +5 -0
- package/dist/models/schemas.js.map +1 -1
- package/dist/orchestrator/run.d.ts +6 -0
- package/dist/orchestrator/run.js +181 -0
- package/dist/orchestrator/run.js.map +1 -0
- package/dist/skills/claude-orchestrator/SKILL.md +75 -217
- package/dist/templates/agents/worker-accept.md +48 -0
- package/dist/templates/agents/worker-build.md +38 -0
- package/dist/templates/agents/worker-decompose.md +40 -0
- package/dist/templates/agents/worker-evaluate.md +49 -0
- package/dist/templates/agents/worker-plan.md +36 -0
- package/dist/templates/agents/worker-review.md +42 -0
- package/dist/templates/agents/worker-verify.md +44 -0
- package/dist/templates/claude-memory/personal-claude-accepter.md +17 -0
- package/dist/templates/claude-memory/personal-claude-builder.md +24 -0
- package/dist/templates/claude-memory/personal-claude-planner.md +22 -0
- package/dist/templates/claude-memory/personal-claude-reviewer.md +25 -0
- package/dist/templates/claude-memory/personal-claude-verifier.md +24 -0
- package/dist/templates/claude-memory/team-claude.md +61 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.js +3 -0
- package/dist/utils/logger.js.map +1 -1
- package/dist/worker/child-runner.d.ts +12 -0
- package/dist/worker/child-runner.js +99 -0
- package/dist/worker/child-runner.js.map +1 -0
- package/dist/worker/child.d.ts +2 -0
- package/dist/worker/child.js +8 -0
- package/dist/worker/child.js.map +1 -0
- package/dist/worker/commit-checker.d.ts +20 -0
- package/dist/worker/commit-checker.js +87 -0
- package/dist/worker/commit-checker.js.map +1 -0
- package/dist/worker/watcher.d.ts +5 -1
- package/dist/worker/watcher.js +41 -4
- package/dist/worker/watcher.js.map +1 -1
- package/dist/worker/worktree-initializer.d.ts +10 -0
- package/dist/worker/worktree-initializer.js +235 -0
- package/dist/worker/worktree-initializer.js.map +1 -0
- package/package.json +2 -2
- package/dist/templates/worker-accept.md +0 -46
- package/dist/templates/worker-build.md +0 -45
- package/dist/templates/worker-decompose.md +0 -67
- package/dist/templates/worker-evaluate.md +0 -41
- package/dist/templates/worker-plan.md +0 -43
- package/dist/templates/worker-review.md +0 -46
- 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**
|
|
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
|
-
|
|
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
|
-
│
|
|
30
|
-
│
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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.
|
|
55
|
+
### 3. Launch Everything
|
|
63
56
|
|
|
64
57
|
```bash
|
|
65
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
78
|
-
|
|
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
|
-
|
|
79
|
+
---
|
|
82
80
|
|
|
83
|
-
|
|
81
|
+
## Architecture
|
|
84
82
|
|
|
85
|
-
|
|
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
|
-
|
|
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
|
-
|
|
92
|
+
### Worktree Isolation
|
|
95
93
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
claude-orchestrator
|
|
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
|
-
|
|
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
|
-
###
|
|
104
|
+
### Responsibility Chain
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
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
|
-
|
|
112
|
+
---
|
|
118
113
|
|
|
119
|
-
|
|
114
|
+
## CLI Commands
|
|
120
115
|
|
|
121
|
-
| Command |
|
|
116
|
+
| Command | Description |
|
|
122
117
|
|---------|-------------|
|
|
123
|
-
| `
|
|
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
|
-
| `
|
|
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
|
|
134
|
-
| `send-message` | Send a message to
|
|
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
|
-
##
|
|
134
|
+
## Directory Memory (CLAUDE.md)
|
|
144
135
|
|
|
145
|
-
|
|
136
|
+
Claude Orchestrator uses a three-layer **CLAUDE.md** system as directory memory:
|
|
146
137
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
|
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
|
-
│
|
|
211
|
-
│
|
|
212
|
-
|
|
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
|
-
##
|
|
201
|
+
## Why ZooKeeper?
|
|
228
202
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
|
241
|
-
|
|
242
|
-
| `
|
|
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
|
|
270
|
-
|
|
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
|
|
343
|
-
│ ├── config.ts
|
|
344
|
-
│ ├──
|
|
345
|
-
│ │ └──
|
|
346
|
-
│ ├── leader/
|
|
347
|
-
│ │ ├── index.ts
|
|
348
|
-
│ │ ├── tui.ts
|
|
349
|
-
│ │ ├── event-bus.ts
|
|
350
|
-
│ │ ├── state.ts
|
|
351
|
-
│ │ ├── monitor.ts
|
|
352
|
-
│ │ ├── orchestrator.ts
|
|
353
|
-
│ │ ├── recovery.ts
|
|
354
|
-
│ │ ├── watcher.ts
|
|
355
|
-
│ │
|
|
356
|
-
│
|
|
357
|
-
│
|
|
358
|
-
│ │
|
|
359
|
-
│ ├──
|
|
360
|
-
│ │ ├──
|
|
361
|
-
│ │
|
|
362
|
-
│ ├──
|
|
363
|
-
│ │
|
|
364
|
-
│
|
|
365
|
-
│ │ ├──
|
|
366
|
-
│ │
|
|
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 # WorkerWatcher — ZK 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
|
|
372
|
-
│ │ └── paths.ts
|
|
289
|
+
│ │ ├── client.ts # ZooKeeper connection management
|
|
290
|
+
│ │ └── paths.ts # ZK path constants
|
|
373
291
|
│ ├── modules/
|
|
374
|
-
│ │ ├── registry.ts
|
|
375
|
-
│ │ ├── task-queue.ts
|
|
376
|
-
│ │
|
|
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
|
|
296
|
+
│ │ └── schemas.ts # Zod schemas (Instance, Task, Message, ChainDef, EvalDecision)
|
|
379
297
|
│ └── utils/
|
|
380
|
-
│ ├── exec.ts
|
|
381
|
-
│
|
|
382
|
-
|
|
383
|
-
├──
|
|
384
|
-
│ └── claude-
|
|
385
|
-
├──
|
|
386
|
-
│ ├──
|
|
387
|
-
│ ├──
|
|
388
|
-
│ ├──
|
|
389
|
-
│ ├──
|
|
390
|
-
│
|
|
391
|
-
├──
|
|
392
|
-
│ ├──
|
|
393
|
-
│
|
|
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.
|
|
400
|
-
│ ├── v0.
|
|
401
|
-
│
|
|
402
|
-
│
|
|
403
|
-
│ └──
|
|
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
|
-
│ └──
|
|
407
|
-
|
|
408
|
-
├──
|
|
409
|
-
|
|
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.
|
package/dist/cli/commands.d.ts
CHANGED
|
@@ -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>;
|