@adamancyzhang/claude-orchestrator 0.3.2 → 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 (78) hide show
  1. package/README.md +198 -280
  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 +6 -1
  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.md +1 -1
  39. package/dist/skills/claude-orchestrator/SKILL.md +75 -217
  40. package/dist/templates/agents/worker-accept.md +48 -0
  41. package/dist/templates/agents/worker-build.md +38 -0
  42. package/dist/templates/agents/worker-decompose.md +40 -0
  43. package/dist/templates/agents/worker-evaluate.md +49 -0
  44. package/dist/templates/agents/worker-plan.md +36 -0
  45. package/dist/templates/agents/worker-review.md +42 -0
  46. package/dist/templates/agents/worker-verify.md +44 -0
  47. package/dist/templates/claude-memory/personal-claude-accepter.md +17 -0
  48. package/dist/templates/claude-memory/personal-claude-builder.md +24 -0
  49. package/dist/templates/claude-memory/personal-claude-planner.md +22 -0
  50. package/dist/templates/claude-memory/personal-claude-reviewer.md +25 -0
  51. package/dist/templates/claude-memory/personal-claude-verifier.md +24 -0
  52. package/dist/templates/claude-memory/team-claude.md +61 -0
  53. package/dist/utils/logger.d.ts +1 -0
  54. package/dist/utils/logger.js +3 -0
  55. package/dist/utils/logger.js.map +1 -1
  56. package/dist/worker/child-runner.d.ts +12 -0
  57. package/dist/worker/child-runner.js +99 -0
  58. package/dist/worker/child-runner.js.map +1 -0
  59. package/dist/worker/child.d.ts +2 -0
  60. package/dist/worker/child.js +8 -0
  61. package/dist/worker/child.js.map +1 -0
  62. package/dist/worker/commit-checker.d.ts +20 -0
  63. package/dist/worker/commit-checker.js +87 -0
  64. package/dist/worker/commit-checker.js.map +1 -0
  65. package/dist/worker/watcher.d.ts +5 -1
  66. package/dist/worker/watcher.js +41 -4
  67. package/dist/worker/watcher.js.map +1 -1
  68. package/dist/worker/worktree-initializer.d.ts +10 -0
  69. package/dist/worker/worktree-initializer.js +235 -0
  70. package/dist/worker/worktree-initializer.js.map +1 -0
  71. package/package.json +2 -2
  72. package/dist/templates/worker-accept.md +0 -46
  73. package/dist/templates/worker-build.md +0 -45
  74. package/dist/templates/worker-decompose.md +0 -67
  75. package/dist/templates/worker-evaluate.md +0 -41
  76. package/dist/templates/worker-plan.md +0 -43
  77. package/dist/templates/worker-review.md +0 -46
  78. package/dist/templates/worker-verify.md +0 -47
@@ -0,0 +1,181 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { fork } from "node:child_process";
4
+ import { fileURLToPath } from "node:url";
5
+ import { loadConfig, loadGlobalConfig, saveInstanceConfig } from "../config.js";
6
+ import { Logger } from "../utils/logger.js";
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ const logger = new Logger("Orchestrator");
9
+ let shuttingDown = false;
10
+ export async function runOrchestrator(config) {
11
+ // Phase 1: Environment self-check + config
12
+ await ensureEnvironment();
13
+ // Phase 2: Role assignment & worktree initialization
14
+ const { initializeWorktrees } = await import("../worker/worktree-initializer.js");
15
+ const worktreeConfigs = await initializeWorktrees(process.cwd(), config.workerCount);
16
+ logger.info(`Worktrees ready: ${worktreeConfigs.map(w => `${w.name}(${w.role})`).join(", ")}`);
17
+ // Phase 3: Start Leader TUI
18
+ const { startLeader } = await import("../leader/index.js");
19
+ const leaderReady = new Promise((resolve) => {
20
+ // Give leader a tick to start, then resolve
21
+ setTimeout(resolve, 500);
22
+ });
23
+ startLeader({
24
+ zkHosts: config.zkHosts,
25
+ name: config.name,
26
+ debug: config.debug ?? false,
27
+ worktreeConfigs,
28
+ }).catch((err) => {
29
+ logger.error("Leader failed", err);
30
+ process.exit(1);
31
+ });
32
+ await leaderReady;
33
+ // Phase 4: Start Worker child processes
34
+ const children = await startAllWorkers({
35
+ zkHosts: config.zkHosts,
36
+ configs: worktreeConfigs,
37
+ debug: config.debug ?? false,
38
+ });
39
+ // Phase 5: Wait for shutdown
40
+ await handleShutdown(children);
41
+ }
42
+ async function ensureEnvironment() {
43
+ // 1. Ensure global config ~/.claude-orchestrator/config.json
44
+ const existingGlobal = loadGlobalConfig();
45
+ if (!existingGlobal.commands?.["claude-cli"] || !existingGlobal.cache_dir) {
46
+ const prevCommands = existingGlobal.commands;
47
+ const prevHooks = existingGlobal.hooks;
48
+ saveInstanceConfig({
49
+ commands: {
50
+ "claude-cli": prevCommands?.["claude-cli"] || "claude --dangerously-skip-permissions --permission-mode dontAsk",
51
+ },
52
+ hooks: prevHooks || {
53
+ leader_message_start: null,
54
+ leader_message_end: null,
55
+ worker_message_start: null,
56
+ worker_message_end: null,
57
+ },
58
+ cache_dir: existingGlobal.cache_dir || "~/.claude-orchestrator/sessions",
59
+ zookeeper: existingGlobal.zookeeper || {
60
+ url: "127.0.0.1:2181",
61
+ root_path: "/claude-orchestrator",
62
+ auth: null,
63
+ },
64
+ }, true);
65
+ }
66
+ // 2. Copy templates to .claude-orchestrator/agents/
67
+ const templateDir = path.join(__dirname, "..", "templates");
68
+ const agentsDir = path.join(process.cwd(), ".claude-orchestrator", "agents");
69
+ const templates = {
70
+ "worker-decompose.md": path.join(templateDir, "agents", "worker-decompose.md"),
71
+ "worker-evaluate.md": path.join(templateDir, "agents", "worker-evaluate.md"),
72
+ "worker-plan.md": path.join(templateDir, "agents", "worker-plan.md"),
73
+ "worker-build.md": path.join(templateDir, "agents", "worker-build.md"),
74
+ "worker-verify.md": path.join(templateDir, "agents", "worker-verify.md"),
75
+ "worker-review.md": path.join(templateDir, "agents", "worker-review.md"),
76
+ "worker-accept.md": path.join(templateDir, "agents", "worker-accept.md"),
77
+ };
78
+ for (const [filename, srcPath] of Object.entries(templates)) {
79
+ const destPath = path.join(agentsDir, filename);
80
+ if (!fs.existsSync(destPath)) {
81
+ fs.mkdirSync(agentsDir, { recursive: true });
82
+ fs.copyFileSync(srcPath, destPath);
83
+ }
84
+ }
85
+ // Copy team-level CLAUDE.md to project root (if not exists)
86
+ const teamClaudeSrc = path.join(templateDir, "claude-memory", "team-claude.md");
87
+ const teamClaudeDest = path.join(process.cwd(), "CLAUDE.md");
88
+ if (fs.existsSync(teamClaudeSrc) && !fs.existsSync(teamClaudeDest)) {
89
+ fs.copyFileSync(teamClaudeSrc, teamClaudeDest);
90
+ }
91
+ // 3. Copy skills to .claude/skills/
92
+ const skillsSrcDir = path.join(__dirname, "..", "skills");
93
+ const skillsDstDir = path.join(process.cwd(), ".claude", "skills");
94
+ const SKILLS_TO_COPY = [
95
+ "task-planning",
96
+ "task-execution",
97
+ "task-verification",
98
+ "task-review",
99
+ "task-acceptance",
100
+ "task-traceability",
101
+ "claude-orchestrator",
102
+ ];
103
+ if (fs.existsSync(skillsSrcDir)) {
104
+ for (const skillName of SKILLS_TO_COPY) {
105
+ const srcSkillPath = path.join(skillsSrcDir, skillName, "SKILL.md");
106
+ const dstSkillDir = path.join(skillsDstDir, skillName);
107
+ const dstSkillPath = path.join(dstSkillDir, "SKILL.md");
108
+ if (!fs.existsSync(srcSkillPath))
109
+ continue;
110
+ if (fs.existsSync(dstSkillDir)) {
111
+ fs.rmSync(dstSkillDir, { recursive: true, force: true });
112
+ }
113
+ fs.mkdirSync(dstSkillDir, { recursive: true });
114
+ fs.copyFileSync(srcSkillPath, dstSkillPath);
115
+ }
116
+ }
117
+ }
118
+ async function startAllWorkers(opts) {
119
+ const resolvedConfig = loadConfig({ zookeeper: opts.zkHosts });
120
+ const children = [];
121
+ const restartCount = new Map();
122
+ function spawnChild(cfg) {
123
+ const child = fork(path.join(__dirname, "..", "worker", "child.js"), [JSON.stringify({
124
+ worktreePath: cfg.worktreePath,
125
+ name: cfg.name,
126
+ role: cfg.role,
127
+ instanceId: cfg.instanceId,
128
+ branch: cfg.branch,
129
+ zkHosts: opts.zkHosts,
130
+ debug: opts.debug,
131
+ cliCommand: resolvedConfig.cliCommand,
132
+ cacheDir: resolvedConfig.cacheDir,
133
+ })], { stdio: "inherit" });
134
+ child.on("exit", (code, signal) => {
135
+ if (shuttingDown)
136
+ return;
137
+ const retries = restartCount.get(cfg.name) ?? 0;
138
+ if (code !== 0 && code !== null && retries < 3) {
139
+ logger.warn(`Worker ${cfg.name} exited (code=${code}), restart ${retries + 1}/3`);
140
+ restartCount.set(cfg.name, retries + 1);
141
+ const newChild = spawnChild(cfg);
142
+ const idx = children.indexOf(child);
143
+ if (idx !== -1)
144
+ children[idx] = newChild;
145
+ }
146
+ else if (code !== 0 && code !== null) {
147
+ logger.error(`Worker ${cfg.name} max retries exceeded, giving up`);
148
+ }
149
+ });
150
+ return child;
151
+ }
152
+ for (const cfg of opts.configs) {
153
+ children.push(spawnChild(cfg));
154
+ }
155
+ return children;
156
+ }
157
+ async function handleShutdown(children) {
158
+ return new Promise((resolve) => {
159
+ const cleanup = () => {
160
+ shuttingDown = true;
161
+ for (const child of children) {
162
+ try {
163
+ child.kill("SIGTERM");
164
+ }
165
+ catch { /* already dead */ }
166
+ }
167
+ resolve();
168
+ };
169
+ process.once("SIGINT", cleanup);
170
+ process.once("SIGTERM", cleanup);
171
+ process.on("exit", () => {
172
+ for (const child of children) {
173
+ try {
174
+ child.kill("SIGTERM");
175
+ }
176
+ catch { /* already dead */ }
177
+ }
178
+ });
179
+ });
180
+ }
181
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/orchestrator/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAqB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAsB,MAAM,cAAc,CAAC;AACpG,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;AAE1C,IAAI,YAAY,GAAG,KAAK,CAAC;AAEzB,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAKrC;IACC,2CAA2C;IAC3C,MAAM,iBAAiB,EAAE,CAAC;IAE1B,qDAAqD;IACrD,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM,CAAC,m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CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -38,7 +38,7 @@ Leader (协调层)
38
38
  Multi-agent orchestration CLI backed by ZooKeeper。所有角色都使用它来完成基础设施操作:注册实例、认领任务、发送消息、读写共享上下文。
39
39
 
40
40
  - **入口**: `claude-orchestrator <command>`
41
- - **关键命令**: `register`, `claim-task`, `complete-task`, `push-task`, `send-message`, `set-context`, `get-context`
41
+ - **关键命令**: `register`, `claim-task`, `complete-task`, `push-task`, `send-message`
42
42
  - **适用角色**: 所有角色
43
43
 
44
44
  ### task-planning
@@ -1,244 +1,102 @@
1
1
  ---
2
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.
3
+ description: Multi-agent orchestration system reference for Workers. Covers the v0.4 unified run command, worktree isolation, directory memory (CLAUDE.md), responsibility chain (Plan→Build→Verify→Review→Accept), output standards, and common pitfalls. Use this skill whenever a Worker executes any link in the responsibility chain read it at session start and whenever you are unsure about process, output paths, or role boundaries.
4
4
  ---
5
5
 
6
- # Claude Orchestrator
6
+ # Claude Orchestrator — Worker Reference
7
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.
8
+ You are a Worker in a multi-agent orchestration system. Your work is coordinated through ZooKeeper. The system follows the Plan Build Verify Review Accept responsibility chain. This reference helps you stay on track.
9
9
 
10
- ## Architecture
10
+ ## Quick Orientation
11
11
 
12
- ```
13
- Claude Code ──CLI──> ZooKeeper
14
- (instance A) (service discovery, task queue, messages, context)
12
+ When you start working, locate these files:
15
13
 
16
- Claude Code ──CLI──> ZooKeeper
17
- (instance B)
18
- ```
14
+ | File | Purpose | Read When |
15
+ |------|---------|-----------|
16
+ | `CLAUDE.md` (worktree root) | Team rules, directory structure, chain overview | Every session start |
17
+ | `.claude-orchestrator/docs/{your_name}/CLAUDE.md` | Your role-specific rules and output standards | Every session start |
18
+ | `.claude-orchestrator/docs/{your_name}/YYYY-MM-DD/CLAUDE.md` | Today's session memory | Every session start (create if missing) |
19
+ | `.claude/skills/task-traceability/SKILL.md` | Foundation: Trace → Execute → Map → Evidence → Record | Every task |
20
+ | `.claude/skills/{your_link_skill}/SKILL.md` | Your link-specific process | When starting your link |
19
21
 
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.
22
+ ## Directory Memory Rules (Non-Negotiable)
21
23
 
22
- ## Setup
24
+ 1. **All your output goes under** `.claude-orchestrator/docs/{your_name}/YYYY-MM-DD/` (use today's date)
25
+ 2. **Every daily directory must have a `CLAUDE.md`** — update it after each completed sub-task
26
+ 3. **Read upstream artifacts from their docs directories** before starting your link
27
+ 4. **Write your artifact to the docs directory** so the next Worker can find it
23
28
 
24
- ```bash
25
- npm install -g @adamancyzhang/claude-orchestrator
26
- docker-compose up -d # start ZooKeeper
27
- ```
29
+ ### Artifact Names by Link
28
30
 
29
- Initialize environment:
31
+ | Your Link | Your Output File | Who Reads It |
32
+ |-----------|-----------------|--------------|
33
+ | plan | `blueprint.md` | Builder, Verifier, Reviewer, Accepter |
34
+ | build | `traceability-map.md` + `evidence/` | Verifier, Reviewer, Accepter |
35
+ | verify | `verification-map.md` + `evidence/` | Reviewer, Accepter |
36
+ | review | `review-judgment.md` | Accepter |
37
+ | accept | `acceptance-report.md` | (chain closes) |
30
38
 
31
- ```bash
32
- # Leader (team coordinator):
33
- claude-orchestrator setup --leader --name Tom
39
+ ## Responsibility Chain Rules
34
40
 
35
- # Worker (the doers):
36
- claude-orchestrator setup --name Jerry --role builder
37
- ```
41
+ ### Every Link Must
38
42
 
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)
43
+ 1. **Trace** — Read upstream artifacts before starting. If missing → BLOCKED, report to Leader.
44
+ 2. **Execute**Follow the standard process in your skill file.
45
+ 3. **Map**Link every output to a specific upstream requirement.
46
+ 4. **Evidence** Provide verifiable proof (not claims) for every output.
47
+ 5. **Record** Write to BOTH `{{result_path}}` (for Leader) AND `.claude-orchestrator/docs/{your_name}/YYYY-MM-DD/{artifact}.md` (for downstream).
44
48
 
45
- Verify:
49
+ ### Role Boundaries
46
50
 
47
- ```bash
48
- claude-orchestrator config
49
- # Shows current configuration
50
- ```
51
+ | Role | You DO | You DO NOT |
52
+ |------|--------|------------|
53
+ | **Planner** | Define blueprints with verifiable criteria | Implement code (Builder's job) |
54
+ | **Builder** | Implement per blueprint, produce evidence | Make architectural decisions (Planner's job) |
55
+ | **Verifier** | Check Builder output against Plan | Judge architecture (Reviewer's job) |
56
+ | **Reviewer** | Judge full chain quality | Re-verify or re-implement |
57
+ | **Accepter** | Validate against business criteria | Re-verify, re-review, or conditional-pass |
51
58
 
52
- ## Global Options
59
+ ### Self-Evaluation
53
60
 
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 |
61
+ After completing your link, self-evaluate:
62
+ - Criteria fully met AND artifacts in place → `activate_next`
63
+ - Anything missing `feedback` with specifics
64
+ - Accept link passes `close_chain`
58
65
 
59
- ## Commands
66
+ ## Common Pitfalls (Avoid These)
60
67
 
61
- ### Leader
68
+ 1. **Writing output to the wrong directory** — Always use `.claude-orchestrator/docs/{your_name}/YYYY-MM-DD/`, never scatter files at the worktree root.
69
+ 2. **Skipping upstream artifact read** — For build/verify/review/accept, you MUST find and read the previous Worker's output from their docs directory. If you skip this, the responsibility chain is broken.
70
+ 3. **Vague completion criteria** — "Works correctly" is not verifiable. Use specific commands and expected outputs (e.g., "curl -X POST /api/login returns 201 with a valid JWT in the response body").
71
+ 4. **"Code level already implemented"** — This phrase is banned. Every claim needs evidence: actual command output, test results, file contents.
72
+ 5. **Conditional pass (Accept link)** — There is no conditional GO. Zero issues for GO. If any criterion fails → NO-GO.
73
+ 6. **Not updating daily CLAUDE.md** — If your session is interrupted, your progress is lost. Update `CLAUDE.md` after each sub-task.
74
+ 7. **Overstepping your role** — Verifiers should not re-architect. Reviewers should not re-implement. Trust upstream, verify independently, stay in your lane.
75
+ 8. **Forgetting the dual-write** — You must write output to BOTH `{{result_path}}` AND `.claude-orchestrator/docs/{your_name}/YYYY-MM-DD/`. The first is for the Leader's evaluation, the second is for the next Worker to read.
62
76
 
63
- ```bash
64
- claude-orchestrator leader --name Tom
65
- # Launches read-only TUI: team panel, task board, event log
66
- ```
77
+ ## Startup Checklist (Every Session)
67
78
 
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.
79
+ - [ ] Read `CLAUDE.md` at worktree root
80
+ - [ ] Read `.claude-orchestrator/docs/{your_name}/CLAUDE.md`
81
+ - [ ] Read or create `.claude-orchestrator/docs/{your_name}/YYYY-MM-DD/CLAUDE.md`
82
+ - [ ] Identify your current link and read the corresponding skill
83
+ - [ ] For build/verify/review/accept: find upstream artifact paths in `docs/`
69
84
 
70
- ### Registration
85
+ ## Shutdown Checklist (Every Session)
71
86
 
72
- **Setup** one-time initialization:
87
+ - [ ] Confirm today's artifact is in `.claude-orchestrator/docs/{your_name}/YYYY-MM-DD/`
88
+ - [ ] Confirm evidence files are saved
89
+ - [ ] Update daily CLAUDE.md with completion status and artifact paths
90
+ - [ ] If build link: confirm code is committed with your name signature
91
+ - [ ] Record any blockers or unfinished items for the next session
73
92
 
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
- ```
93
+ ## Skills Reference
80
94
 
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.
95
+ | Skill File | When to Read |
96
+ |------------|-------------|
97
+ | `.claude/skills/task-traceability/SKILL.md` | Every link foundation |
98
+ | `.claude/skills/task-planning/SKILL.md` | Plan link only |
99
+ | `.claude/skills/task-execution/SKILL.md` | Build link only |
100
+ | `.claude/skills/task-verification/SKILL.md` | Verify link only |
101
+ | `.claude/skills/task-review/SKILL.md` | Review link only |
102
+ | `.claude/skills/task-acceptance/SKILL.md` | Accept link only |
@@ -0,0 +1,48 @@
1
+ Your link in the responsibility chain is **Accept** — the final gate. Validate the complete deliverable against business acceptance criteria. Make the Go/No-Go decision. No conditional pass.
2
+
3
+ ## Step 0: Restore Directory Memory
4
+
5
+ Read `.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/CLAUDE.md` to restore session context (create the directory and seed it if new). Read your personal CLAUDE.md at `.claude-orchestrator/docs/{{name}}/CLAUDE.md`.
6
+
7
+ ## Task
8
+
9
+ - **Title**: {{task_title}}
10
+ - **Description**: {{task_description}}
11
+ - **Criteria**: {{task_criteria}}
12
+ - **Spec**: {{task_doc_path}}
13
+
14
+ ## Process
15
+
16
+ Use the **task-acceptance** skill (read `.claude/skills/task-acceptance/SKILL.md`).
17
+
18
+ **Read all four upstream artifacts (required)**:
19
+ 1. `.claude-orchestrator/docs/{planner_name}/YYYY-MM-DD/blueprint.md`
20
+ 2. `.claude-orchestrator/docs/{builder_name}/YYYY-MM-DD/traceability-map.md`
21
+ 3. `.claude-orchestrator/docs/{verifier_name}/YYYY-MM-DD/verification-map.md`
22
+ 4. `.claude-orchestrator/docs/{reviewer_name}/YYYY-MM-DD/review-judgment.md`
23
+ Fallback: `{{task_doc_path}}`. If any is missing → cannot accept, report to Leader.
24
+
25
+ For each acceptance criterion: does the deliverable exist? Are Verifier FAILUREs resolved? Are Reviewer CONCERNs addressed? Is evidence independently verifiable?
26
+
27
+ - **GO**: All criteria met. Zero issues.
28
+ - **NO-GO**: Any criterion unmet. Specify what's missing and which link must address it.
29
+
30
+ ## Outputs
31
+
32
+ 1. Write acceptance report to **{{result_path}}** (for Leader)
33
+ 2. Write identical copy to **.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/acceptance-report.md**
34
+
35
+ ## Completion Report
36
+
37
+ ```
38
+ Link: accept
39
+ Status: completed
40
+ Decision: GO | NO-GO
41
+ Criteria Checked: <count> | Passed: <count> | Failed: <count>
42
+ Upstream Issues: Verifier FAILUREs <resolved>/<total>, Reviewer CONCERNs <addressed>/<total>
43
+ Failed Criteria (NO-GO): <list each with responsible link>
44
+ Acceptance Report: .claude-orchestrator/docs/{{name}}/YYYY-MM-DD/acceptance-report.md
45
+ Upstream Artifacts Read: <list all four paths>
46
+ ```
47
+
48
+ Update `.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/CLAUDE.md`.
@@ -0,0 +1,38 @@
1
+ Your link in the responsibility chain is **Build** — produce verifiable results according to the Planner's blueprint.
2
+
3
+ ## Step 0: Restore Directory Memory
4
+
5
+ Read `.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/CLAUDE.md` to restore session context (create the directory and seed it if new). Read your personal CLAUDE.md at `.claude-orchestrator/docs/{{name}}/CLAUDE.md`.
6
+
7
+ ## Task
8
+
9
+ - **Title**: {{task_title}}
10
+ - **Description**: {{task_description}}
11
+ - **Criteria**: {{task_criteria}}
12
+ - **Spec**: {{task_doc_path}}
13
+
14
+ ## Process
15
+
16
+ Use the **task-execution** skill (read `.claude/skills/task-execution/SKILL.md`). Use **task-traceability** (`.claude/skills/task-traceability/SKILL.md`) as the foundational layer. Follow Trace → Execute → Map → Evidence → Record.
17
+
18
+ **Trace**: Read the Planner's blueprint from `.claude-orchestrator/docs/{planner_name}/YYYY-MM-DD/blueprint.md`. Fallback: `{{task_doc_path}}`. Extract every implementable requirement as a checklist.
19
+
20
+ ## Outputs
21
+
22
+ 1. Write traceability map to **{{result_path}}** (for Leader evaluation)
23
+ 2. Write identical copy to **.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/traceability-map.md** (for Verifier)
24
+ 3. Save evidence files to **.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/evidence/**
25
+
26
+ ## Completion Report
27
+
28
+ ```
29
+ Link: build
30
+ Status: completed
31
+ Implemented: <count> items
32
+ Deviations: <count> items (list each with reason)
33
+ Evidence: .claude-orchestrator/docs/{{name}}/YYYY-MM-DD/evidence/
34
+ Traceability Map: .claude-orchestrator/docs/{{name}}/YYYY-MM-DD/traceability-map.md
35
+ Next Link Ready: yes
36
+ ```
37
+
38
+ Update `.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/CLAUDE.md`. Git commit with your name signature.
@@ -0,0 +1,40 @@
1
+ Break down the requirement below into a chain of tasks following the Plan → Build → Verify → Review → Accept responsibility chain.
2
+
3
+ ## Step 0: Restore Directory Memory
4
+
5
+ Read `.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/CLAUDE.md` (use today's date) to restore session context. If it doesn't exist, create the directory and seed it with today's date, your name and role. Read your personal CLAUDE.md at `.claude-orchestrator/docs/{{name}}/CLAUDE.md` for role-specific rules.
6
+
7
+ ## Requirement
8
+
9
+ {{task_description}}
10
+
11
+ ## Instructions
12
+
13
+ 1. Analyze the requirement. Identify how many independent delivery chains are needed.
14
+ 2. For each chain, define five link tasks. Plan is optional (set to null when the requirement is clear enough to build directly). Build, Verify, Review, and Accept are mandatory.
15
+ 3. For each task, specify objectively verifiable completion criteria — use concrete commands and expected outputs, not vague descriptions.
16
+ 4. Assign priority: 0 (urgent), 1 (high), 2 (normal).
17
+
18
+ ## Output
19
+
20
+ Write the result to {{result_path}}. Also save a copy to `.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/chain-def.json`.
21
+
22
+ ```json
23
+ {
24
+ "chain_id": "chain-<seq>",
25
+ "chain_title": "<short summary>",
26
+ "tasks": {
27
+ "plan": {"title": "<title>", "description": "<desc>", "criteria": "<verifiable criteria>", "priority": 1} | null,
28
+ "build": {"title": "<title>", "description": "<desc>", "criteria": "<verifiable criteria>", "priority": 1},
29
+ "verify": {"title": "<title>", "description": "<what and how to verify>", "criteria": "<verifiable criteria>", "priority": 1},
30
+ "review": {"title": "<title>", "description": "<what to review>", "criteria": "<verifiable criteria>", "priority": 1},
31
+ "accept": {"title": "<title>", "description": "<what to validate>", "criteria": "<verifiable criteria>", "priority": 1}
32
+ }
33
+ }
34
+ ```
35
+
36
+ Output ONLY the JSON. No explanation.
37
+
38
+ ## Record
39
+
40
+ After completion, update `.claude-orchestrator/docs/{{name}}/YYYY-MM-DD/CLAUDE.md` with the chain_id and chain_title.