@adamancyzhang/claude-orchestrator 0.2.8 → 0.3.1

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 (91) hide show
  1. package/README.md +179 -186
  2. package/dist/cli/commands.d.ts +13 -20
  3. package/dist/cli/commands.js +171 -288
  4. package/dist/cli/commands.js.map +1 -1
  5. package/dist/config.d.ts +25 -11
  6. package/dist/config.js +49 -13
  7. package/dist/config.js.map +1 -1
  8. package/dist/index.js +122 -215
  9. package/dist/index.js.map +1 -1
  10. package/dist/leader/decision-engine.d.ts +35 -0
  11. package/dist/leader/decision-engine.js +102 -0
  12. package/dist/leader/decision-engine.js.map +1 -0
  13. package/dist/leader/event-bus.d.ts +11 -0
  14. package/dist/leader/event-bus.js +21 -0
  15. package/dist/leader/event-bus.js.map +1 -0
  16. package/dist/leader/index.d.ts +7 -0
  17. package/dist/leader/index.js +96 -0
  18. package/dist/leader/index.js.map +1 -0
  19. package/dist/leader/monitor.d.ts +14 -0
  20. package/dist/leader/monitor.js +55 -0
  21. package/dist/leader/monitor.js.map +1 -0
  22. package/dist/leader/orchestrator.d.ts +14 -0
  23. package/dist/leader/orchestrator.js +83 -0
  24. package/dist/leader/orchestrator.js.map +1 -0
  25. package/dist/leader/recovery.d.ts +11 -0
  26. package/dist/leader/recovery.js +61 -0
  27. package/dist/leader/recovery.js.map +1 -0
  28. package/dist/leader/state.d.ts +24 -0
  29. package/dist/leader/state.js +122 -0
  30. package/dist/leader/state.js.map +1 -0
  31. package/dist/leader/task-generator.d.ts +34 -0
  32. package/dist/leader/task-generator.js +93 -0
  33. package/dist/leader/task-generator.js.map +1 -0
  34. package/dist/leader/tui.d.ts +5 -0
  35. package/dist/leader/tui.js +136 -0
  36. package/dist/leader/tui.js.map +1 -0
  37. package/dist/leader/watcher.d.ts +18 -0
  38. package/dist/leader/watcher.js +89 -0
  39. package/dist/leader/watcher.js.map +1 -0
  40. package/dist/models/schemas.d.ts +111 -100
  41. package/dist/models/schemas.js +54 -45
  42. package/dist/models/schemas.js.map +1 -1
  43. package/dist/modules/message-router.d.ts +2 -2
  44. package/dist/modules/message-router.js +10 -16
  45. package/dist/modules/message-router.js.map +1 -1
  46. package/dist/modules/registry.js +3 -3
  47. package/dist/modules/registry.js.map +1 -1
  48. package/dist/modules/task-queue.d.ts +4 -1
  49. package/dist/modules/task-queue.js +114 -10
  50. package/dist/modules/task-queue.js.map +1 -1
  51. package/dist/skills/CLAUDE.md +155 -0
  52. package/dist/skills/claude-code-developer/SKILL.md +325 -0
  53. package/dist/skills/claude-orchestrator/SKILL.md +180 -0
  54. package/dist/skills/task-acceptance/SKILL.md +201 -0
  55. package/dist/skills/task-execution/SKILL.md +142 -0
  56. package/dist/skills/task-planning/SKILL.md +188 -0
  57. package/dist/skills/task-review/SKILL.md +220 -0
  58. package/dist/skills/task-traceability/SKILL.md +154 -0
  59. package/dist/skills/task-verification/SKILL.md +194 -0
  60. package/dist/templates/leader-decide.md +59 -0
  61. package/dist/templates/leader-decompose.md +69 -0
  62. package/dist/templates/worker-accept.md +46 -0
  63. package/dist/templates/worker-build.md +45 -0
  64. package/dist/templates/worker-plan.md +43 -0
  65. package/dist/templates/worker-review.md +46 -0
  66. package/dist/templates/worker-verify.md +47 -0
  67. package/dist/utils/exec.d.ts +8 -0
  68. package/dist/utils/exec.js +45 -0
  69. package/dist/utils/exec.js.map +1 -0
  70. package/dist/worker/watcher.d.ts +19 -0
  71. package/dist/worker/watcher.js +152 -0
  72. package/dist/worker/watcher.js.map +1 -0
  73. package/dist/zk/client.d.ts +5 -5
  74. package/dist/zk/client.js +16 -26
  75. package/dist/zk/client.js.map +1 -1
  76. package/dist/zk/paths.d.ts +9 -9
  77. package/dist/zk/paths.js +4 -5
  78. package/dist/zk/paths.js.map +1 -1
  79. package/dist/zk/watcher.d.ts +0 -2
  80. package/dist/zk/watcher.js +0 -3
  81. package/dist/zk/watcher.js.map +1 -1
  82. package/package.json +3 -6
  83. package/dist/modules/context-store.d.ts +0 -10
  84. package/dist/modules/context-store.js +0 -25
  85. package/dist/modules/context-store.js.map +0 -1
  86. package/dist/modules/message-watcher.d.ts +0 -12
  87. package/dist/modules/message-watcher.js +0 -133
  88. package/dist/modules/message-watcher.js.map +0 -1
  89. package/dist/server.d.ts +0 -2
  90. package/dist/server.js +0 -490
  91. package/dist/server.js.map +0 -1
@@ -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,180 @@
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
+ pip install -e .
26
+ docker-compose up -d # start ZooKeeper
27
+ ```
28
+
29
+ Verify:
30
+
31
+ ```bash
32
+ claude-orchestrator status
33
+ # {"status": "healthy", "zookeeper": "connected", "instances_online": 0}
34
+ ```
35
+
36
+ ## Global Options
37
+
38
+ | Option | Env var | Default | Description |
39
+ |--------|---------|---------|-------------|
40
+ | `--zk-hosts` | `ZK_HOSTS` | `127.0.0.1:2181` | ZooKeeper connection string |
41
+ | `--instance-id` | — | auto (from config) | Override stored instance ID |
42
+
43
+ ## Commands
44
+
45
+ ### Registration
46
+
47
+ **Register** this instance:
48
+
49
+ ```bash
50
+ claude-orchestrator register --name Jerry-Dev --role developer
51
+ # {"id": "a1b2c3d4...", "name": "Jerry-Dev", "role": "developer", "status": "idle", ...}
52
+ ```
53
+
54
+ The returned `id` is saved to `~/.claude-orchestrator/config.json`. Pass `--instance-id` on re-registration to reuse the same identity.
55
+
56
+ **Heartbeat** — keep registration alive, optionally declare current task:
57
+
58
+ ```bash
59
+ claude-orchestrator heartbeat
60
+ claude-orchestrator heartbeat --current-task "fix-login-bug"
61
+ ```
62
+
63
+ ZK session timeout is 30s. Call heartbeat regularly (every 30-60s) while working.
64
+
65
+ **List instances:**
66
+
67
+ ```bash
68
+ claude-orchestrator list-instances
69
+ # [{"id": "...", "name": "Jerry-Dev", "role": "developer", "status": "busy", ...}, ...]
70
+ ```
71
+
72
+ ### Tasks
73
+
74
+ **Push a task** to the queue:
75
+
76
+ ```bash
77
+ claude-orchestrator push-task --title "Fix login bug" --description "..." --priority 0
78
+ claude-orchestrator push-task --title "Review PR #42" --assignee <instance-id>
79
+ ```
80
+
81
+ Priority: `0` = HIGH, `1` = MEDIUM (default), `2` = LOW.
82
+
83
+ **Claim a task** — FIFO, higher priority first, assigned-to-you tasks jump the queue:
84
+
85
+ ```bash
86
+ claude-orchestrator claim-task
87
+ # {"id": "task-0000000001", "title": "Fix login bug", ...} ← claimed
88
+ # {"status": "no_tasks", "message": "No pending tasks available."} ← empty queue
89
+ ```
90
+
91
+ **Complete a task:**
92
+
93
+ ```bash
94
+ claude-orchestrator complete-task --task-id task-0000000001 --result "Fixed auth middleware, added tests"
95
+ ```
96
+
97
+ **List tasks:**
98
+
99
+ ```bash
100
+ claude-orchestrator list-tasks
101
+ claude-orchestrator list-tasks --status pending
102
+ claude-orchestrator list-tasks --status claimed
103
+ claude-orchestrator list-tasks --status completed
104
+ ```
105
+
106
+ ### Messages
107
+
108
+ **Send a direct message:**
109
+
110
+ ```bash
111
+ claude-orchestrator send-message --to <instance-id> --content "Can you review my PR?"
112
+ ```
113
+
114
+ **Broadcast to all:**
115
+
116
+ ```bash
117
+ claude-orchestrator send-message --broadcast --content "CI is down, don't push"
118
+ ```
119
+
120
+ **Poll messages:**
121
+
122
+ ```bash
123
+ claude-orchestrator poll-messages
124
+ # [{"id": "msg-...", "type": "direct", "from_name": "Lucy-Test", "content": "...", "read": true}]
125
+ ```
126
+
127
+ **Request help** (broadcasts to all):
128
+
129
+ ```bash
130
+ claude-orchestrator request-help --question "How do I test the auth flow?" --context "stack trace..."
131
+ ```
132
+
133
+ ### Shared Context
134
+
135
+ **Set:**
136
+
137
+ ```bash
138
+ claude-orchestrator set-context --key ci_status --value "failing: auth tests"
139
+ ```
140
+
141
+ **Get:**
142
+
143
+ ```bash
144
+ claude-orchestrator get-context --key ci_status
145
+ # {"key": "ci_status", "value": "failing: auth tests"}
146
+ ```
147
+
148
+ ### Status
149
+
150
+ ```bash
151
+ claude-orchestrator status
152
+ # {"status": "healthy", "zookeeper": "connected", "instances_online": 3}
153
+ ```
154
+
155
+ ## Workflow
156
+
157
+ A typical agent session:
158
+
159
+ ```bash
160
+ # 1. Join the team
161
+ claude-orchestrator register --name Jerry-Dev --role developer
162
+
163
+ # 2. Check who's online
164
+ claude-orchestrator list-instances
165
+
166
+ # 3. Work loop
167
+ while true; do
168
+ claude-orchestrator poll-messages # check for messages
169
+ task=$(claude-orchestrator claim-task) # grab work
170
+ if [ "$task" = "no_tasks" ]; then break; fi
171
+ # ... execute the task ...
172
+ claude-orchestrator complete-task --task-id <id> --result "Done: ..."
173
+ done
174
+ ```
175
+
176
+ ## Error recovery
177
+
178
+ - **ZooKeeper not connected**: check `docker-compose ps`, retry. ZK client auto-reconnects.
179
+ - **"No instance_id found"**: register first, or pass `--instance-id`
180
+ - **Registration expired**: ephemeral nodes cleaned up on disconnect. Re-register with same `--instance-id` to restore identity.
@@ -0,0 +1,201 @@
1
+ ---
2
+ name: task-acceptance
3
+ description: PM task-level acceptance verification with full traceability. Use when the PM needs to verify completed work from team members, run acceptance on daily work assignments, or confirm deliverables before signing off — every acceptance decision must be traceable to specific criteria and verified deliverables. Triggers on keywords like "确认并验收", "验收一下", "verify and accept", "检查完成情况", "task acceptance", "任务验收". Covers per-task-assignment verification workflow with cross-worktree git checks, commit signature validation, and report data cross-validation.
4
+ ---
5
+
6
+ # Task Acceptance
7
+
8
+ > 验收不是读报告,是逐项验证代码、测试、git commit 的真实存在。本技能与 [[task-traceability]] 协作,确保每次验收不走形式、不漏步骤、可追溯——每个 Go/No-Go 决策都可追溯到具体的验收标准和经过验证的交付物。
9
+
10
+ ---
11
+
12
+ ## 何时触发
13
+
14
+ - 用户说"确认并验收"、"验收一下"、"检查一下完成情况"
15
+ - 团队成员报告任务完成,PM 需要核实
16
+ - daily work assignment 文档中所有任务标记为已完成
17
+ - PM 准备签阶段验收报告
18
+
19
+ ---
20
+
21
+ ## 验收八步法
22
+
23
+ 按顺序执行,每一步通过才进入下一步。任一步不通过 → 记录问题,最终 No-Go。
24
+
25
+ ### 1. 读取工作分配文档
26
+
27
+ 找到对应的任务分配文档(如 `docs/pm/YYYY-MM-DD/daily-work-assignment.md`),提取:
28
+ - 每个成员的任务清单和验收标准
29
+ - 预期的产出物路径
30
+ - 依赖链(谁依赖谁先完成)
31
+
32
+ ### 2. 检查产出物是否存在
33
+
34
+ 对每个成员,检查指定的产出目录下是否有对应的产出文件。
35
+
36
+ ```bash
37
+ ls -la docs/{member}/YYYY-MM-DD/
38
+ ```
39
+
40
+ 如果报告引用了产出物但文件不存在 → P1 问题。
41
+
42
+ ### 3. 验证代码变更真实存在
43
+
44
+ **不要轻信报告中的描述。** 对每项声称的代码修改,直接 grep 验证:
45
+
46
+ ```bash
47
+ # 示例:验证某组件是否真的引入了某个依赖
48
+ grep -n "<key-symbol>" <source-file-path>
49
+
50
+ # 示例:验证是否替换了特定常量
51
+ grep -n "<new-value>" <spec-file-path>
52
+
53
+ # 验证旧引用已清除
54
+ grep "<old-value>" <spec-file-path> # 应无结果
55
+ ```
56
+
57
+ 如果代码变更不存在但报告声称已完成 → P0 问题(虚假报告)。
58
+
59
+ ### 4. 运行测试验证数字
60
+
61
+ 报告中的测试数字必须可复现:
62
+
63
+ ```bash
64
+ # 运行单元测试
65
+ <project-test-command> 2>&1 | tail -20
66
+
67
+ # 统计测试文件中的实际测试数量
68
+ for f in <test-glob-pattern>; do
69
+ count=$(grep -c "test(" "$f")
70
+ echo "$f: $count tests"
71
+ done
72
+ ```
73
+
74
+ 将实际测试数与报告中的数字对比。不一致 → P2 问题(报告错误)。
75
+
76
+ ### 5. 验证 git commit 真实存在
77
+
78
+ **关键**:如项目使用多个独立 git worktree 或子模块,必须在对应目录下检查 commit。
79
+
80
+ ```bash
81
+ # 检查各仓库的 git log
82
+ cd <subdir> && git log --oneline -10
83
+ ```
84
+
85
+ 对报告中引用的每个 commit hash:
86
+
87
+ ```bash
88
+ cd <subdir> && git log --all --oneline | grep "^<commit-hash>"
89
+ ```
90
+
91
+ 如果 commit hash 不存在 → P0 问题(commits 未生成或引用了虚构 hash)。
92
+
93
+ 同时检查**工作区是否干净**(`git status`)—— 如果有未提交的变更,成果可能未真正落盘。
94
+
95
+ ### 6. 验证 commit message 格式
96
+
97
+ 根据项目 CLAUDE.md 中的 Git Commit Rules 检查 commit message 格式:
98
+
99
+ ```bash
100
+ # 检查每个相关 commit 的完整 message
101
+ cd <subdir> && git log --format="%B" <commit-hash> -1
102
+ ```
103
+
104
+ 格式不符合项目规范 → P1 问题(规范违规)。
105
+
106
+ > **amend 边界**:如果 commit 未 push 到 remote,可 amend 修复;已 push 则必须新建 commit。
107
+
108
+ ### 7. 交叉验证报告数据
109
+
110
+ 报告中的数字必须自洽:
111
+
112
+ - 分项测试数相加是否等于合计?
113
+ - 表格是否有重复行?
114
+ - 截图数量是否与声称一致?
115
+ - 引用文件路径是否真实存在?
116
+
117
+ ```bash
118
+ # 检查截图文件是否存在
119
+ ls -la docs/{member}/YYYY-MM-DD/*.png
120
+ ```
121
+
122
+ 不一致 → P2 问题。
123
+
124
+ ### 8. 产出验收报告
125
+
126
+ 写入 PM 的验收报告文件(如 `docs/pm/YYYY-MM-DD/acceptance-report.md`),使用以下模板:
127
+
128
+ ```markdown
129
+ # 验收报告
130
+
131
+ > PM | YYYY-MM-DD | 验收范围:成员 A / 成员 B / ... 交付物
132
+
133
+ ## 验收结论:Go / No-Go
134
+
135
+ (一句话结论 + 原因)
136
+
137
+ ---
138
+
139
+ ## 逐项验收
140
+
141
+ ### 成员 A — 任务名称
142
+
143
+ | 检查项 | 预期 | 实际 | 结果 |
144
+ |--------|------|------|------|
145
+ | ... | ... | ... | ✅/❌/⚠️ |
146
+
147
+ ### 成员 B — 任务名称
148
+
149
+ ...
150
+
151
+ ---
152
+
153
+ ## 问题清单
154
+
155
+ | # | 严重度 | 问题 | 责任人 | 修复方案 |
156
+ |---|--------|------|--------|---------|
157
+ | 1 | P0/P1/P2 | 描述 | @name | 具体操作 |
158
+
159
+ ---
160
+
161
+ ## 验收完成标准重检
162
+
163
+ - [ ] 标准 1 ✅/❌
164
+ - [ ] 标准 2 ✅/❌
165
+ ...
166
+
167
+ ---
168
+
169
+ *PM — YYYY-MM-DD*
170
+ ```
171
+
172
+ ---
173
+
174
+ ## 问题严重度分级
175
+
176
+ | 级别 | 定义 | 示例 |
177
+ |------|------|------|
178
+ | P0 | 虚假报告、代码变更不存在、commit 不存在 | 引用不存在的 commit hash |
179
+ | P1 | 规范违规、产出物缺失、签名格式错误 | commit 格式不符合项目要求 |
180
+ | P2 | 报告数据错误、表格笔误 | 测试数分项与合计不对应 |
181
+
182
+ 验收标准:**零问题才能签 Go**。不做"条件通过"。
183
+
184
+ ---
185
+
186
+ ## 与其他技能的协作
187
+
188
+ - **[[task-traceability]]**:基础层。Accepter 严格遵循追溯 → 执行 → 映射 → 举证 → 记录的五步法。追溯全链产出和验收标准(Trace),逐项核实验收标准(Execute),映射交付物到验收标准(Map),提供代码检查、测试运行、git log 等证据(Evidence),签署验收报告并记录 Go/No-Go(Record)。零问题才能签 Go——不做条件通过。
189
+ - **[[task-planning]]**:Accepter 以 Planner 蓝图中的验收标准为核实基准。
190
+ - **[[task-execution]]**:Accepter 核验 Builder 的代码变更和 commit hash 是否真实存在。
191
+ - **[[task-verification]]**:Accepter 引用 Verifier 的报告,但不替代自己的独立核实。
192
+ - **[[task-review]]**:Accepter 依赖 Reviewer 的 Pass 结论。Review 不通过无须进入 Accept。
193
+
194
+ ---
195
+
196
+ ## 特别注意
197
+
198
+ - **外部阻塞不是缺陷**:如外部依赖未就绪导致某些验收项无法执行,在报告中标注为外部阻塞,不计入问题清单,但须明确放行条件。
199
+ - **worktree / 多仓库**:如项目使用多个独立 git worktree 或子模块,git 操作必须 `cd` 到对应子目录执行。根目录的 `git log` 看不到子目录的 commit。
200
+ - **报告 ≠ 真相**:报告中的 claim 必须可独立验证。如果某项验收标准无法复现(如需要外部系统产出),标记为 ⏸ Blocked,不打 ☑。
201
+ - **commit 后验收**:团队成员应在验收前完成 commit。如果发现未 commit,退回要求先 commit 再验收。