@adamancyzhang/claude-orchestrator 0.3.0 → 0.3.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 +203 -201
- package/dist/cli/commands.d.ts +6 -17
- package/dist/cli/commands.js +133 -172
- package/dist/cli/commands.js.map +1 -1
- package/dist/config.d.ts +28 -14
- package/dist/config.js +51 -20
- package/dist/config.js.map +1 -1
- package/dist/executor/runner.d.ts +19 -0
- package/dist/executor/runner.js +59 -0
- package/dist/executor/runner.js.map +1 -0
- package/dist/executor/template.d.ts +12 -0
- package/dist/executor/template.js +42 -0
- package/dist/executor/template.js.map +1 -0
- package/dist/hooks/engine.d.ts +22 -0
- package/dist/hooks/engine.js +50 -0
- package/dist/hooks/engine.js.map +1 -0
- package/dist/index.js +115 -250
- package/dist/index.js.map +1 -1
- package/dist/leader/chain-router.d.ts +22 -0
- package/dist/leader/chain-router.js +163 -0
- package/dist/leader/chain-router.js.map +1 -0
- 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 +1 -2
- package/dist/leader/index.js +35 -13
- package/dist/leader/index.js.map +1 -1
- package/dist/leader/recovery.d.ts +2 -0
- package/dist/leader/recovery.js +37 -22
- package/dist/leader/recovery.js.map +1 -1
- package/dist/leader/state.d.ts +2 -1
- package/dist/leader/state.js +48 -2
- package/dist/leader/state.js.map +1 -1
- package/dist/leader/tui.d.ts +8 -0
- package/dist/leader/tui.js +74 -9
- package/dist/leader/tui.js.map +1 -1
- package/dist/leader/watcher.d.ts +4 -3
- package/dist/leader/watcher.js +8 -13
- package/dist/leader/watcher.js.map +1 -1
- package/dist/models/schemas.d.ts +307 -87
- package/dist/models/schemas.js +51 -43
- package/dist/models/schemas.js.map +1 -1
- package/dist/modules/message-router.d.ts +1 -3
- package/dist/modules/message-router.js +3 -26
- package/dist/modules/message-router.js.map +1 -1
- package/dist/modules/registry.js +3 -3
- package/dist/modules/registry.js.map +1 -1
- package/dist/modules/task-queue.d.ts +1 -1
- package/dist/modules/task-queue.js +28 -2
- package/dist/modules/task-queue.js.map +1 -1
- package/dist/skills/CLAUDE.md +155 -0
- package/dist/skills/claude-code-developer/SKILL.md +325 -0
- package/dist/skills/claude-orchestrator/SKILL.md +244 -0
- package/dist/skills/task-acceptance/SKILL.md +201 -0
- package/dist/skills/task-execution/SKILL.md +142 -0
- package/dist/skills/task-planning/SKILL.md +188 -0
- package/dist/skills/task-review/SKILL.md +220 -0
- package/dist/skills/task-traceability/SKILL.md +154 -0
- package/dist/skills/task-verification/SKILL.md +194 -0
- package/dist/templates/worker-accept.md +46 -0
- package/dist/templates/worker-build.md +45 -0
- package/dist/templates/worker-decompose.md +67 -0
- package/dist/templates/worker-evaluate.md +41 -0
- package/dist/templates/worker-plan.md +43 -0
- package/dist/templates/worker-review.md +46 -0
- package/dist/templates/worker-verify.md +47 -0
- package/dist/utils/exec.d.ts +5 -0
- package/dist/utils/exec.js +27 -0
- package/dist/utils/exec.js.map +1 -1
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.js +22 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/worker/evaluator.d.ts +13 -0
- package/dist/worker/evaluator.js +112 -0
- package/dist/worker/evaluator.js.map +1 -0
- package/dist/worker/watcher.d.ts +13 -4
- package/dist/worker/watcher.js +108 -24
- package/dist/worker/watcher.js.map +1 -1
- package/dist/zk/client.d.ts +0 -5
- package/dist/zk/client.js +0 -27
- package/dist/zk/client.js.map +1 -1
- package/dist/zk/paths.d.ts +8 -10
- package/dist/zk/paths.js +1 -6
- package/dist/zk/paths.js.map +1 -1
- package/dist/zk/watcher.d.ts +0 -2
- package/dist/zk/watcher.js +0 -3
- package/dist/zk/watcher.js.map +1 -1
- package/package.json +2 -2
- package/dist/modules/context-store.d.ts +0 -10
- package/dist/modules/context-store.js +0 -25
- package/dist/modules/context-store.js.map +0 -1
- package/dist/templates/leader.md +0 -10
- package/dist/templates/worker.md +0 -8
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: claude-code-developer
|
|
3
|
+
description: Reference for developing Claude Code extensions — hooks, settings, MCP, CLI, and skills. Use when building tools on Claude Code, configuring automation, debugging hooks, or understanding extension points.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Claude Code Developer Guide
|
|
7
|
+
|
|
8
|
+
Reference for building tools and automations on top of Claude Code. Covers hooks, settings, MCP integration, and CLI usage.
|
|
9
|
+
|
|
10
|
+
## Hooks
|
|
11
|
+
|
|
12
|
+
Hooks run shell commands at specific points in Claude Code's lifecycle. Configured in `settings.json` under `hooks.<EventName>`.
|
|
13
|
+
|
|
14
|
+
### Hook Event Reference
|
|
15
|
+
|
|
16
|
+
| Event | Matcher | Fires when | Use for |
|
|
17
|
+
|-------|---------|-----------|---------|
|
|
18
|
+
| `SessionStart` | — | Session starts | Auto-register, init workspace |
|
|
19
|
+
| `SessionEnd` | — | Session truly ends | Cleanup, unregister |
|
|
20
|
+
| `Stop` | — | Claude stops (clear/resume/compact too) | Logging — prefer `SessionEnd` for cleanup |
|
|
21
|
+
| `UserPromptSubmit` | — | User submits a prompt | Pre-processing, logging |
|
|
22
|
+
| `PreToolUse` | Tool name | Before a tool runs | Validation, blocking dangerous ops |
|
|
23
|
+
| `PostToolUse` | Tool name | After a tool succeeds | Formatting, logging, notifications |
|
|
24
|
+
| `PostToolUseFailure` | Tool name | After a tool fails | Error recovery |
|
|
25
|
+
| `PreCompact` | `"manual"`/`"auto"` | Before context compaction | Save state, warn user |
|
|
26
|
+
| `PostCompact` | `"manual"`/`"auto"` | After compaction | Post-processing |
|
|
27
|
+
| `Notification` | Notification type | On notifications | Custom notification handling |
|
|
28
|
+
| `PermissionRequest` | Tool name | Before permission prompt | Custom permission logic |
|
|
29
|
+
| `SubagentStart` | — | Subagent spawns | Agent lifecycle tracking |
|
|
30
|
+
| `SubagentStop` | — | Subagent exits | Agent lifecycle tracking |
|
|
31
|
+
|
|
32
|
+
### Hook Structure
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"hooks": {
|
|
37
|
+
"EVENT_NAME": [
|
|
38
|
+
{
|
|
39
|
+
"matcher": "ToolName|OtherTool",
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "your-command-here",
|
|
44
|
+
"timeout": 60
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- **matcher**: tool name (`"Bash"`, `"Write"`, `"Edit"`), pipe-separated list (`"Write|Edit"`), or `""` to match all. For non-tool events, omit or use `""`.
|
|
54
|
+
- **hooks**: array of hook objects, each with `type` and type-specific fields.
|
|
55
|
+
|
|
56
|
+
### Hook Types
|
|
57
|
+
|
|
58
|
+
**command** — Shell command:
|
|
59
|
+
```json
|
|
60
|
+
{ "type": "command", "command": "echo 'hello'", "timeout": 30 }
|
|
61
|
+
```
|
|
62
|
+
- Receives JSON on stdin with event context
|
|
63
|
+
- `timeout` in seconds (optional)
|
|
64
|
+
- `statusMessage` for spinner text (optional)
|
|
65
|
+
- `once`: auto-remove after first run (optional)
|
|
66
|
+
- `async`: run in background without blocking (optional)
|
|
67
|
+
|
|
68
|
+
**prompt** — LLM evaluation (PreToolUse/PostToolUse/PermissionRequest only):
|
|
69
|
+
```json
|
|
70
|
+
{ "type": "prompt", "prompt": "Is this safe? $ARGUMENTS" }
|
|
71
|
+
```
|
|
72
|
+
- `$ARGUMENTS` placeholder replaced with hook input JSON
|
|
73
|
+
|
|
74
|
+
**agent** — Agent with tools (PreToolUse/PostToolUse/PermissionRequest only):
|
|
75
|
+
```json
|
|
76
|
+
{ "type": "agent", "prompt": "Verify tests pass", "timeout": 60 }
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**http** — POST hook input to a URL:
|
|
80
|
+
```json
|
|
81
|
+
{ "type": "http", "url": "https://example.com/hook", "headers": {} }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**mcp_tool** — Call an MCP tool:
|
|
85
|
+
```json
|
|
86
|
+
{ "type": "mcp_tool", "server": "server-name", "tool": "tool_name", "input": {} }
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Hook stdin JSON
|
|
90
|
+
|
|
91
|
+
Hooks receive context on stdin. Key fields:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"session_id": "abc123",
|
|
96
|
+
"tool_name": "Write",
|
|
97
|
+
"tool_input": { "file_path": "/path/to/file.txt", "content": "..." },
|
|
98
|
+
"tool_response": { "success": true }
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Extract with `jq`:
|
|
103
|
+
```bash
|
|
104
|
+
jq -r '.tool_input.file_path'
|
|
105
|
+
jq -r '.tool_input.command' # for Bash
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Hook JSON Output
|
|
109
|
+
|
|
110
|
+
Commands can output JSON to control behavior:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"systemMessage": "Warning shown to user",
|
|
115
|
+
"continue": false,
|
|
116
|
+
"stopReason": "Blocked because...",
|
|
117
|
+
"decision": "block",
|
|
118
|
+
"reason": "Explanation",
|
|
119
|
+
"hookSpecificOutput": {
|
|
120
|
+
"hookEventName": "PostToolUse",
|
|
121
|
+
"additionalContext": "Injected into model context",
|
|
122
|
+
"permissionDecision": "allow",
|
|
123
|
+
"permissionDecisionReason": "Why allowed"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Common Hook Pitfalls
|
|
129
|
+
|
|
130
|
+
1. **`Stop` vs `SessionEnd`**: `Stop` fires on clear/resume/compact — use `SessionEnd` for cleanup
|
|
131
|
+
2. **Matcher is required**: each hook entry needs `"matcher"` (use `""` for all)
|
|
132
|
+
3. **Nested hooks array**: the outer `hooks` object contains arrays of `{matcher, hooks:[...]}`
|
|
133
|
+
4. **Silent failure**: invalid JSON in settings.json silently disables ALL settings from that file
|
|
134
|
+
5. **Hook command format**: `{matcher: "", hooks: [{type: "command", command: "..."}]}` — NOT flat `{matcher: "", command: "..."}`
|
|
135
|
+
|
|
136
|
+
## Settings
|
|
137
|
+
|
|
138
|
+
### File Locations
|
|
139
|
+
|
|
140
|
+
| File | Scope | Git | Use for |
|
|
141
|
+
|------|-------|-----|---------|
|
|
142
|
+
| `~/.claude/settings.json` | Global (user) | No | Personal preferences |
|
|
143
|
+
| `.claude/settings.json` | Project | Yes | Team-wide config |
|
|
144
|
+
| `.claude/settings.local.json` | Project local | Gitignore | Personal overrides |
|
|
145
|
+
|
|
146
|
+
Priority: user → project → local (later overrides earlier).
|
|
147
|
+
|
|
148
|
+
### Key Settings for Tool Developers
|
|
149
|
+
|
|
150
|
+
**Permissions** — allow/deny tool operations:
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"permissions": {
|
|
154
|
+
"allow": ["Bash(npm *)", "Bash(git *)"],
|
|
155
|
+
"deny": ["Bash(rm -rf *)"],
|
|
156
|
+
"defaultMode": "default"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**MCP Servers** — manage server approval:
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"enableAllProjectMcpServers": true,
|
|
165
|
+
"enabledMcpjsonServers": ["orchestrator"],
|
|
166
|
+
"disabledMcpjsonServers": ["blocked-server"]
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Environment Variables**:
|
|
171
|
+
```json
|
|
172
|
+
{ "env": { "DEBUG": "true", "ZK_HOSTS": "127.0.0.1:2181" } }
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Model & Agent**:
|
|
176
|
+
```json
|
|
177
|
+
{ "model": "sonnet", "agent": "agent-name" }
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Plugins**:
|
|
181
|
+
```json
|
|
182
|
+
{ "enabledPlugins": { "formatter@anthropic-tools": true } }
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Status Line** — custom terminal status bar:
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"statusLine": {
|
|
189
|
+
"type": "command",
|
|
190
|
+
"command": "echo '$(date +%H:%M)'",
|
|
191
|
+
"padding": 0
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### JSON Validation
|
|
197
|
+
|
|
198
|
+
Broken JSON in settings.json silently disables the entire file. Validate with:
|
|
199
|
+
```bash
|
|
200
|
+
jq -e '.hooks.SessionStart' .claude/settings.json
|
|
201
|
+
python3 -m json.tool .claude/settings.json > /dev/null
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## MCP Integration
|
|
205
|
+
|
|
206
|
+
### .mcp.json Format
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"mcpServers": {
|
|
211
|
+
"server-name": {
|
|
212
|
+
"type": "http",
|
|
213
|
+
"url": "http://127.0.0.1:3100/mcp",
|
|
214
|
+
"headers": {
|
|
215
|
+
"X-Instance-Name": "my-instance",
|
|
216
|
+
"X-Instance-Role": "developer"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
- `type`: `"http"` for Streamable HTTP, `"stdio"` for subprocess
|
|
224
|
+
- `headers`: custom HTTP headers sent with every request
|
|
225
|
+
- MCP tools appear as callable tools in Claude Code
|
|
226
|
+
|
|
227
|
+
### MCP Server Best Practices
|
|
228
|
+
|
|
229
|
+
1. Use Streamable HTTP transport on `127.0.0.1` for local servers
|
|
230
|
+
2. Expose a `/health` endpoint for diagnostics
|
|
231
|
+
3. Provide REST endpoints alongside MCP tools for CLI-based interaction
|
|
232
|
+
4. Use `resources/subscribe` for push notifications to Claude Code
|
|
233
|
+
5. Stateless sessions simplify scaling (set `sessionIdGenerator: undefined`)
|
|
234
|
+
|
|
235
|
+
## CLI Reference
|
|
236
|
+
|
|
237
|
+
### Key Commands
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
claude # Interactive session
|
|
241
|
+
claude -p "prompt" # One-shot, print and exit
|
|
242
|
+
claude -c # Continue last session
|
|
243
|
+
claude -r # Resume by ID or picker
|
|
244
|
+
claude --resume <id> # Resume specific session
|
|
245
|
+
claude --model sonnet # Override model
|
|
246
|
+
claude --mcp-config file.json # Additional MCP config
|
|
247
|
+
claude --settings file.json # Additional settings
|
|
248
|
+
claude --add-dir /path # Additional workspace dir
|
|
249
|
+
claude --debug # Debug mode
|
|
250
|
+
claude --debug hooks # Debug hooks specifically
|
|
251
|
+
claude --bare # Minimal mode (no hooks/LSP/plugins)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Useful Subcommands
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
claude mcp # MCP server management
|
|
258
|
+
claude auth # Auth management
|
|
259
|
+
claude doctor # Health check
|
|
260
|
+
claude update # Check for updates
|
|
261
|
+
claude agents # Background agents management
|
|
262
|
+
claude plugin # Plugin management
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Hook Testing
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
# Debug hooks
|
|
269
|
+
claude --debug hooks
|
|
270
|
+
|
|
271
|
+
# Stream hook events
|
|
272
|
+
claude --include-hook-events --output-format stream-json -p "test"
|
|
273
|
+
|
|
274
|
+
# Validate hook JSON
|
|
275
|
+
jq -e '.hooks.<event>[] | select(.matcher == "<matcher>") | .hooks[] | select(.type == "command") | .command' .claude/settings.json
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Skills
|
|
279
|
+
|
|
280
|
+
### Skill File Format
|
|
281
|
+
|
|
282
|
+
Skills live in `skills/<name>/SKILL.md`:
|
|
283
|
+
|
|
284
|
+
```markdown
|
|
285
|
+
---
|
|
286
|
+
name: skill-name
|
|
287
|
+
description: One-line description — used for trigger matching
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
# Skill Title
|
|
291
|
+
|
|
292
|
+
Skill content with instructions for the LLM.
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
- `name`: unique identifier, used for `/skill-name` invocation
|
|
296
|
+
- `description`: used by Claude Code to auto-detect when to invoke the skill
|
|
297
|
+
|
|
298
|
+
### Skill Design Guidelines
|
|
299
|
+
|
|
300
|
+
1. **Clear triggers in description** — mention keywords users will say
|
|
301
|
+
2. **Step-by-step instructions** — the LLM follows the skill literally
|
|
302
|
+
3. **Include bash commands** — for the LLM to run
|
|
303
|
+
4. **Handle edge cases** — re-registration, cleanup, verification
|
|
304
|
+
5. **Keep it concise** — skills are loaded into context
|
|
305
|
+
|
|
306
|
+
## Development Workflow
|
|
307
|
+
|
|
308
|
+
### Testing a Hook
|
|
309
|
+
|
|
310
|
+
1. Write the hook in `.claude/settings.json`
|
|
311
|
+
2. Validate JSON: `jq -e '.hooks' .claude/settings.json`
|
|
312
|
+
3. Reload config: open `/hooks` in Claude Code or restart
|
|
313
|
+
4. Test with `--debug hooks` to see execution logs
|
|
314
|
+
5. For tool hooks: trigger the tool and verify the side effect
|
|
315
|
+
6. For lifecycle hooks (`SessionStart`, `SessionEnd`, `Stop`): restart Claude Code
|
|
316
|
+
|
|
317
|
+
### Troubleshooting
|
|
318
|
+
|
|
319
|
+
| Symptom | Likely cause |
|
|
320
|
+
|---------|-------------|
|
|
321
|
+
| Hook doesn't fire | Invalid JSON, wrong event name, matcher mismatch |
|
|
322
|
+
| All settings ignored | Syntax error in settings.json |
|
|
323
|
+
| Hook fires but command fails | Command not in PATH, permission denied, timeout |
|
|
324
|
+
| `Stop` fires unexpectedly | `Stop` triggers on clear/compact too — use `SessionEnd` |
|
|
325
|
+
| MCP tools not showing | Server not running, wrong URL in mcp.json, port conflict |
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: claude-orchestrator
|
|
3
|
+
description: Multi-agent orchestration CLI backed by ZooKeeper for service discovery. Register instances, distribute tasks, send messages, and share context across Claude Code instances. Use when the user wants to register, join a team, claim tasks, send messages, check status, or any orchestrator operation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Claude Orchestrator
|
|
7
|
+
|
|
8
|
+
A CLI that provides multi-agent orchestration directly on top of ZooKeeper. Every Claude Code instance becomes a discoverable agent — register, claim tasks, communicate, and share context without a middleman server.
|
|
9
|
+
|
|
10
|
+
## Architecture
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
Claude Code ──CLI──> ZooKeeper
|
|
14
|
+
(instance A) (service discovery, task queue, messages, context)
|
|
15
|
+
|
|
16
|
+
Claude Code ──CLI──> ZooKeeper
|
|
17
|
+
(instance B)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Every CLI command talks directly to ZooKeeper. Instance discovery is via ephemeral znodes. Tasks use sequential znodes for FIFO ordering. Messages use watch-based push.
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g @adamancyzhang/claude-orchestrator
|
|
26
|
+
docker-compose up -d # start ZooKeeper
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Initialize environment:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Leader (team coordinator):
|
|
33
|
+
claude-orchestrator setup --leader --name Tom
|
|
34
|
+
|
|
35
|
+
# Worker (the doers):
|
|
36
|
+
claude-orchestrator setup --name Jerry --role builder
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This creates:
|
|
40
|
+
- `.claude-orchestrator/agents/` — message templates (7 templates for leader + 5 worker links)
|
|
41
|
+
- `.claude/skills/` — 8 Claude Code skills (responsibility chain + infrastructure)
|
|
42
|
+
- `.claude-orchestrator/config.json` — project config (name, role)
|
|
43
|
+
- `~/.claude-orchestrator/config.json` — global config (ZK hosts, CLI command, cache dir)
|
|
44
|
+
|
|
45
|
+
Verify:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
claude-orchestrator config
|
|
49
|
+
# Shows current configuration
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Global Options
|
|
53
|
+
|
|
54
|
+
| Option | Env var | Default | Description |
|
|
55
|
+
|--------|---------|---------|-------------|
|
|
56
|
+
| `--zookeeper`, `-z` | `ZK_HOSTS` | `127.0.0.1:2181` | ZooKeeper connection string |
|
|
57
|
+
| `--instance-id`, `-i` | — | auto (from config) | Override stored instance ID |
|
|
58
|
+
|
|
59
|
+
## Commands
|
|
60
|
+
|
|
61
|
+
### Leader
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
claude-orchestrator leader --name Tom
|
|
65
|
+
# Launches read-only TUI: team panel, task board, event log
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Only one Leader at a time (ZK ephemeral node). The TUI shows who's online, what tasks are in each state, and a scrolling event log.
|
|
69
|
+
|
|
70
|
+
### Registration
|
|
71
|
+
|
|
72
|
+
**Setup** — one-time initialization:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
claude-orchestrator setup --leader --name Tom # Leader
|
|
76
|
+
claude-orchestrator setup --name Jerry --role builder # Worker
|
|
77
|
+
claude-orchestrator setup --name Lucy --role verifier \
|
|
78
|
+
--cache-dir ~/shared/sessions --command "claude -p" # Custom CLI
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Setup options:
|
|
82
|
+
|
|
83
|
+
| Option | Default | Description |
|
|
84
|
+
|--------|---------|-------------|
|
|
85
|
+
| `--leader` | false | Initialize as Leader environment |
|
|
86
|
+
| `--name <name>` | — | Instance display name |
|
|
87
|
+
| `--role <role>` | builder | Role: planner, builder, verifier, reviewer, accepter |
|
|
88
|
+
| `--cache-dir <path>` | `~/.claude-orchestrator/sessions` | Shared cache directory |
|
|
89
|
+
| `--command <cmd>` | `claude --dangerously-skip-permissions --permission-mode dontAsk` | Claude CLI command |
|
|
90
|
+
| `--global` | false | Write only global config, skip project files |
|
|
91
|
+
|
|
92
|
+
**Register** — join the swarm:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Connect and listen for messages (reads name/role from .claude-orchestrator/config.json):
|
|
96
|
+
claude-orchestrator register
|
|
97
|
+
# Worker Watcher starts, listens for messages, processes via claude -p
|
|
98
|
+
# Press Ctrl+C to stop and unregister
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Registration creates an ephemeral ZK node. The instance auto-deregisters on disconnect (Ctrl+C or timeout). The Worker Watcher listens for messages on `/messages/{instance_id}` and processes them using the template that matches the message's `link` field.
|
|
102
|
+
|
|
103
|
+
**Unregister:**
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
claude-orchestrator unregister
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Tasks
|
|
110
|
+
|
|
111
|
+
**Push a task** to the queue:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
claude-orchestrator push-task --title "Implement login endpoint" --priority 0
|
|
115
|
+
claude-orchestrator push-task --title "Verify auth module" --link verify --priority 1
|
|
116
|
+
claude-orchestrator push-task --title "Review PR #42" --link review --assignee <instance-id>
|
|
117
|
+
claude-orchestrator push-task --title "Part 2" --chain-id chain-001 --depends-on task-0000000001
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Push options:
|
|
121
|
+
|
|
122
|
+
| Option | Default | Description |
|
|
123
|
+
|--------|---------|-------------|
|
|
124
|
+
| `--title <text>` | required | Task title |
|
|
125
|
+
| `--description <text>` | "" | Task description |
|
|
126
|
+
| `--priority <n>` | 1 | 0=HIGH, 1=MEDIUM, 2=LOW |
|
|
127
|
+
| `--assignee <id>` | — | Target instance ID |
|
|
128
|
+
| `--link <link>` | — | Responsibility chain link: plan, build, verify, review, accept |
|
|
129
|
+
| `--chain-id <id>` | — | Group related tasks under one chain |
|
|
130
|
+
| `--depends-on <ids>` | — | Comma-separated task IDs this task depends on |
|
|
131
|
+
| `--blocked-by <ids>` | — | Comma-separated task IDs blocking this task |
|
|
132
|
+
|
|
133
|
+
**Claim a task** — FIFO, higher priority first, assigned-to-you tasks jump the queue:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
claude-orchestrator claim-task
|
|
137
|
+
# → { "id": "task-0000000001", "title": "Implement login endpoint", "status": "claimed", ... }
|
|
138
|
+
# → { "status": "no_tasks", "message": "No pending tasks available." }
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Complete a task:**
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
claude-orchestrator complete-task --task-id task-0000000001 --result "PR #42 — login endpoint with tests"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Poll tasks:**
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
claude-orchestrator poll-task
|
|
151
|
+
claude-orchestrator poll-task --status pending
|
|
152
|
+
claude-orchestrator poll-task --status claimed
|
|
153
|
+
claude-orchestrator poll-task --status completed
|
|
154
|
+
claude-orchestrator poll-task --status blocked
|
|
155
|
+
claude-orchestrator poll-task --status failed
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Task lifecycle commands:**
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
claude-orchestrator task-block --task-id task-0000000001 --reason "Waiting for API key"
|
|
162
|
+
claude-orchestrator task-fail --task-id task-0000000001 --reason "Test environment unavailable"
|
|
163
|
+
claude-orchestrator task-retry --task-id task-0000000001
|
|
164
|
+
# → Re-queued with retry_count + 1 (max 3 retries)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Task state machine:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
pending → claimed → in_progress → completed
|
|
171
|
+
→ blocked → pending (retry)
|
|
172
|
+
→ failed → pending (retry, max 3)
|
|
173
|
+
claimed → pending (Worker disconnect, Leader recovers orphan)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Messages
|
|
177
|
+
|
|
178
|
+
**Send a direct message:**
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
claude-orchestrator send-message --to-name Jerry --content "Can you review my PR?"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Broadcast to all:**
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
claude-orchestrator send-message --broadcast --content "CI is down, don't push"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Request help** (broadcasts to all with help flag):
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
claude-orchestrator send-message --request-help --broadcast --content "How do I test the auth flow?"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Poll messages:**
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
claude-orchestrator poll-message
|
|
200
|
+
# [{ "id": "msg-...", "type": "direct", "from_name": "Tom", "content": "...", "read": true }]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Delete a message:**
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
claude-orchestrator delete-message --message-id msg-0000000000
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Config
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
claude-orchestrator config
|
|
213
|
+
# Shows global and project configuration
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Roles
|
|
217
|
+
|
|
218
|
+
| Role | Value | Typical behavior |
|
|
219
|
+
|------|-------|-----------------|
|
|
220
|
+
| Leader | `leader` | Runs TUI, monitors team, recovers orphaned tasks |
|
|
221
|
+
| Planner | `planner` | Uses `task-planning` + `task-traceability` skills |
|
|
222
|
+
| Builder | `builder` | Uses `task-execution` + `task-traceability` skills |
|
|
223
|
+
| Verifier | `verifier` | Uses `task-verification` + `task-traceability` skills |
|
|
224
|
+
| Reviewer | `reviewer` | Uses `task-review` + `task-traceability` skills |
|
|
225
|
+
| Accepter | `accepter` | Uses `task-acceptance` + `task-traceability` skills |
|
|
226
|
+
|
|
227
|
+
## Workflow
|
|
228
|
+
|
|
229
|
+
A typical agent session:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# 1. Initialize (first time only)
|
|
233
|
+
claude-orchestrator setup --name Jerry --role builder
|
|
234
|
+
|
|
235
|
+
# 2. Join the team — Worker Watcher auto-processes incoming messages via claude -p
|
|
236
|
+
claude-orchestrator register
|
|
237
|
+
# Press Ctrl+C to stop and unregister
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Error recovery
|
|
241
|
+
|
|
242
|
+
- **ZooKeeper not connected**: check `docker-compose ps`, retry. ZK client auto-reconnects.
|
|
243
|
+
- **"No instance_id found"**: run `setup` first, or check `.claude-orchestrator/config.json`
|
|
244
|
+
- **Registration expired**: ephemeral nodes cleaned up on disconnect. Re-register to restore identity.
|