cc-devflow 2.4.6 → 4.1.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 (191) hide show
  1. package/.claude/CLAUDE.md +1065 -48
  2. package/.claude/agents/dev-implementer.md +195 -0
  3. package/.claude/commands/{flow-archive.md → flow/archive.md} +46 -11
  4. package/.claude/commands/flow/context.md +150 -0
  5. package/.claude/commands/flow/delta.md +245 -0
  6. package/.claude/commands/{flow-dev.md → flow/dev.md} +112 -11
  7. package/.claude/commands/flow/init.md +45 -0
  8. package/.claude/commands/flow/quality.md +159 -0
  9. package/.claude/commands/flow/spec.md +186 -0
  10. package/.claude/commands/flow/workspace.md +146 -0
  11. package/.claude/commands/{cancel-ralph.md → util/cancel-ralph.md} +1 -0
  12. package/.claude/config/quality-gates.yml +305 -0
  13. package/.claude/docs/guides/TEAM_MODE_GUIDE.md +313 -0
  14. package/.claude/docs/templates/DELTA_SPEC_TEMPLATE.md +91 -0
  15. package/.claude/docs/templates/DESIGN_DECISIONS_TEMPLATE.md +151 -0
  16. package/.claude/docs/templates/JOURNAL_TEMPLATE.md +75 -0
  17. package/.claude/docs/templates/_shared/CLAUDE.md +36 -0
  18. package/.claude/docs/templates/_shared/CONSTITUTION_CHECK.md +125 -0
  19. package/.claude/docs/templates/_shared/VALIDATION_CHECKLIST.md +187 -0
  20. package/.claude/docs/templates/_shared/YAML_FRONTMATTER.md +164 -0
  21. package/.claude/docs/templates/context/dev.jsonl.template +6 -0
  22. package/.claude/docs/templates/context/epic.jsonl.template +5 -0
  23. package/.claude/docs/templates/context/prd.jsonl.template +4 -0
  24. package/.claude/docs/templates/context/research.jsonl.template +4 -0
  25. package/.claude/docs/templates/context/review.jsonl.template +5 -0
  26. package/.claude/docs/templates/context/tech.jsonl.template +5 -0
  27. package/.claude/hooks/CLAUDE.md +342 -0
  28. package/.claude/hooks/inject-agent-context.ts +480 -0
  29. package/.claude/hooks/inject-skill-context.ts +359 -0
  30. package/.claude/hooks/ralph-loop.ts +931 -0
  31. package/.claude/hooks/task-completed-hook.ts +593 -0
  32. package/.claude/hooks/teammate-idle-hook.ts +690 -0
  33. package/.claude/hooks/types/team-types.d.ts +238 -0
  34. package/.claude/rules/devflow-conventions.md +82 -9
  35. package/.claude/scripts/archive-requirement.sh +44 -1
  36. package/.claude/scripts/common.sh +670 -3
  37. package/.claude/scripts/delta-parser.ts +527 -0
  38. package/.claude/scripts/detect-file-conflicts.sh +151 -0
  39. package/.claude/scripts/flow-context-add.sh +134 -0
  40. package/.claude/scripts/flow-context-init.sh +133 -0
  41. package/.claude/scripts/flow-context-validate.sh +144 -0
  42. package/.claude/scripts/flow-delta-apply.sh +297 -0
  43. package/.claude/scripts/flow-delta-archive.sh +71 -0
  44. package/.claude/scripts/flow-delta-create.sh +202 -0
  45. package/.claude/scripts/flow-delta-list.sh +142 -0
  46. package/.claude/scripts/flow-delta-status.sh +235 -0
  47. package/.claude/scripts/flow-quality-full.sh +184 -0
  48. package/.claude/scripts/flow-quality-quick.sh +64 -0
  49. package/.claude/scripts/flow-workspace-init.sh +117 -0
  50. package/.claude/scripts/flow-workspace-record.sh +164 -0
  51. package/.claude/scripts/flow-workspace-start.sh +88 -0
  52. package/.claude/scripts/get-workflow-status.sh +415 -0
  53. package/.claude/scripts/parse-task-dependencies.js +334 -0
  54. package/.claude/scripts/record-quality-error.sh +165 -0
  55. package/.claude/scripts/run-quality-gates.sh +242 -0
  56. package/.claude/scripts/team-dev-init.sh +319 -0
  57. package/.claude/scripts/team-state-recovery.sh +229 -0
  58. package/.claude/scripts/workflow-status.ts +433 -0
  59. package/.claude/settings.json +19 -0
  60. package/.claude/skills/cc-devflow-orchestrator/SKILL.md +85 -200
  61. package/.claude/skills/domain/using-git-worktrees/SKILL.md +252 -0
  62. package/.claude/skills/domain/using-git-worktrees/assets/SHELL_ALIASES.md +133 -0
  63. package/.claude/skills/domain/using-git-worktrees/context.jsonl +4 -0
  64. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-cleanup.sh +218 -0
  65. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-create.sh +232 -0
  66. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-list.sh +130 -0
  67. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-status.sh +140 -0
  68. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-switch.sh +70 -0
  69. package/.claude/skills/skill-rules.json +72 -1
  70. package/.claude/skills/utility/journey-checker/SKILL.md +199 -0
  71. package/.claude/skills/utility/journey-checker/pressure-scenarios.md +164 -0
  72. package/.claude/skills/utility/skill-creator/LICENSE.txt +202 -0
  73. package/.claude/skills/utility/skill-creator/SKILL.md +356 -0
  74. package/.claude/skills/utility/skill-creator/references/output-patterns.md +82 -0
  75. package/.claude/skills/utility/skill-creator/references/workflows.md +28 -0
  76. package/.claude/skills/utility/skill-creator/scripts/init_skill.py +303 -0
  77. package/.claude/skills/utility/skill-creator/scripts/package_skill.py +110 -0
  78. package/.claude/skills/utility/skill-creator/scripts/quick_validate.py +95 -0
  79. package/.claude/skills/workflow/flow-dev/CLAUDE.md +78 -0
  80. package/.claude/skills/workflow/flow-dev/SKILL.md +96 -0
  81. package/.claude/skills/workflow/flow-dev/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +71 -0
  82. package/.claude/skills/workflow/flow-dev/context.jsonl +8 -0
  83. package/.claude/skills/workflow/flow-dev/dev-implementer.jsonl +8 -0
  84. package/.claude/skills/workflow/flow-dev/scripts/entry-gate.sh +116 -0
  85. package/.claude/skills/workflow/flow-dev/scripts/exit-gate.sh +101 -0
  86. package/.claude/skills/workflow/flow-dev/scripts/task-orchestrator.sh +106 -0
  87. package/.claude/skills/workflow/flow-fix/SKILL.md +105 -0
  88. package/.claude/skills/workflow/flow-fix/context.jsonl +6 -0
  89. package/.claude/skills/workflow/flow-fix/references/bug-analyzer.md +381 -0
  90. package/.claude/skills/workflow/flow-init/SKILL.md +211 -0
  91. package/.claude/skills/workflow/flow-init/assets/BRAINSTORM_TEMPLATE.md +148 -0
  92. package/.claude/skills/workflow/flow-init/assets/INIT_FLOW_TEMPLATE.md +198 -0
  93. package/.claude/skills/workflow/flow-init/assets/RESEARCH_TEMPLATE.md +276 -0
  94. package/.claude/skills/workflow/flow-init/context.jsonl +5 -0
  95. package/.claude/skills/workflow/flow-init/references/flow-researcher.md +132 -0
  96. package/.claude/skills/workflow/flow-init/scripts/check-prerequisites.sh +232 -0
  97. package/.claude/skills/workflow/flow-init/scripts/consolidate-research.sh +182 -0
  98. package/.claude/skills/workflow/flow-init/scripts/create-requirement.sh +515 -0
  99. package/.claude/skills/workflow/flow-init/scripts/generate-research-tasks.sh +157 -0
  100. package/.claude/skills/workflow/flow-init/scripts/populate-research-tasks.sh +284 -0
  101. package/.claude/skills/workflow/flow-init/scripts/validate-research.sh +332 -0
  102. package/.claude/skills/workflow/flow-quality/SKILL.md +94 -0
  103. package/.claude/skills/workflow/flow-quality/context.jsonl +6 -0
  104. package/.claude/skills/workflow/flow-quality/references/code-quality-reviewer.md +205 -0
  105. package/.claude/skills/workflow/flow-quality/references/qa-tester.md +313 -0
  106. package/.claude/skills/workflow/flow-quality/references/security-reviewer.md +314 -0
  107. package/.claude/skills/workflow/flow-quality/references/spec-reviewer.md +221 -0
  108. package/.claude/skills/workflow/flow-release/SKILL.md +126 -0
  109. package/.claude/skills/workflow/flow-release/context.jsonl +7 -0
  110. package/.claude/skills/workflow/flow-release/references/release-manager.md +295 -0
  111. package/.claude/skills/workflow/flow-spec/CLAUDE.md +103 -0
  112. package/.claude/skills/workflow/flow-spec/SKILL.md +545 -0
  113. package/.claude/skills/workflow/flow-spec/context.jsonl +7 -0
  114. package/.claude/skills/workflow/flow-spec/scripts/entry-gate.sh +194 -0
  115. package/.claude/skills/workflow/flow-spec/scripts/exit-gate.sh +244 -0
  116. package/.claude/skills/workflow/flow-spec/scripts/parallel-orchestrator.sh +205 -0
  117. package/.claude/skills/workflow/flow-spec/scripts/team-communication.sh +353 -0
  118. package/.claude/skills/workflow/flow-spec/scripts/team-init.sh +195 -0
  119. package/.claude/skills/workflow/flow-spec/scripts/test-team-mode.sh +496 -0
  120. package/.claude/skills/workflow/flow-spec/team-config.json +165 -0
  121. package/.claude/skills/workflow.yaml +417 -0
  122. package/CHANGELOG.md +254 -0
  123. package/README.md +193 -33
  124. package/README.zh-CN.md +206 -46
  125. package/lib/compiler/CLAUDE.md +77 -46
  126. package/lib/compiler/__tests__/multi-module-emitters.test.js +508 -0
  127. package/lib/compiler/context-expander.js +179 -0
  128. package/lib/compiler/emitters/antigravity-emitter.js +195 -5
  129. package/lib/compiler/emitters/base-emitter.js +217 -2
  130. package/lib/compiler/emitters/codex-emitter.js +200 -4
  131. package/lib/compiler/emitters/cursor-emitter.js +307 -3
  132. package/lib/compiler/emitters/qwen-emitter.js +196 -4
  133. package/lib/compiler/index.js +197 -2
  134. package/lib/compiler/platforms.js +270 -21
  135. package/package.json +1 -1
  136. package/.claude/commands/flow-epic.md +0 -183
  137. package/.claude/commands/flow-init.md +0 -370
  138. package/.claude/commands/flow-prd.md +0 -144
  139. package/.claude/commands/flow-qa.md +0 -93
  140. package/.claude/commands/flow-review.md +0 -257
  141. package/.claude/commands/flow-tech.md +0 -142
  142. package/.claude/commands/flow-ui.md +0 -189
  143. package/.claude/skills/file-header-guardian/SKILL.md +0 -56
  144. package/.claude/skills/skill-developer/ADVANCED.md +0 -197
  145. package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +0 -306
  146. package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +0 -152
  147. package/.claude/skills/skill-developer/SKILL.md +0 -426
  148. package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +0 -315
  149. package/.claude/skills/skill-developer/TRIGGER_TYPES.md +0 -305
  150. package/.claude/skills/skill-developer/TROUBLESHOOTING.md +0 -514
  151. package/.claude/skills/writing-skills/SKILL.md +0 -655
  152. package/.claude/skills/writing-skills/anthropic-best-practices.md +0 -1150
  153. package/.claude/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
  154. package/.claude/skills/writing-skills/graphviz-conventions.dot +0 -172
  155. package/.claude/skills/writing-skills/persuasion-principles.md +0 -187
  156. package/.claude/skills/writing-skills/render-graphs.js +0 -168
  157. package/.claude/skills/writing-skills/testing-skills-with-subagents.md +0 -384
  158. package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +0 -1
  159. package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +0 -1
  160. /package/.claude/commands/{core-architecture.md → core/architecture.md} +0 -0
  161. /package/.claude/commands/{core-guidelines.md → core/guidelines.md} +0 -0
  162. /package/.claude/commands/{core-roadmap.md → core/roadmap.md} +0 -0
  163. /package/.claude/commands/{core-style.md → core/style.md} +0 -0
  164. /package/.claude/commands/{flow-checklist.md → flow/checklist.md} +0 -0
  165. /package/.claude/commands/{flow-clarify.md → flow/clarify.md} +0 -0
  166. /package/.claude/commands/{flow-constitution.md → flow/constitution.md} +0 -0
  167. /package/.claude/commands/{flow-fix.md → flow/fix.md} +0 -0
  168. /package/.claude/commands/{flow-ideate.md → flow/ideate.md} +0 -0
  169. /package/.claude/commands/{flow-new.md → flow/new.md} +0 -0
  170. /package/.claude/commands/{flow-release.md → flow/release.md} +0 -0
  171. /package/.claude/commands/{flow-restart.md → flow/restart.md} +0 -0
  172. /package/.claude/commands/{flow-status.md → flow/status.md} +0 -0
  173. /package/.claude/commands/{flow-update.md → flow/update.md} +0 -0
  174. /package/.claude/commands/{flow-upgrade.md → flow/upgrade.md} +0 -0
  175. /package/.claude/commands/{flow-verify.md → flow/verify.md} +0 -0
  176. /package/.claude/commands/{code-review-high.md → util/code-review.md} +0 -0
  177. /package/.claude/commands/{git-commit.md → util/git-commit.md} +0 -0
  178. /package/.claude/commands/{problem-analyzer.md → util/problem-analyzer.md} +0 -0
  179. /package/.claude/skills/{flow-attention-refresh → domain/attention-refresh}/SKILL.md +0 -0
  180. /package/.claude/skills/{flow-brainstorming → domain/brainstorming}/SKILL.md +0 -0
  181. /package/.claude/skills/{flow-debugging → domain/debugging}/SKILL.md +0 -0
  182. /package/.claude/skills/{flow-finishing-branch → domain/finishing-branch}/SKILL.md +0 -0
  183. /package/.claude/skills/{flow-receiving-review → domain/receiving-review}/SKILL.md +0 -0
  184. /package/.claude/skills/{flow-tdd → domain/tdd}/SKILL.md +0 -0
  185. /package/.claude/skills/{verification-before-completion → domain/verification}/SKILL.md +0 -0
  186. /package/.claude/skills/{constitution-guardian → guardrail/constitution-guardian}/SKILL.md +0 -0
  187. /package/.claude/skills/{devflow-tdd-enforcer → guardrail/tdd-enforcer}/SKILL.md +0 -0
  188. /package/.claude/skills/{devflow-constitution-quick-ref → utility/constitution-quick-ref}/SKILL.md +0 -0
  189. /package/.claude/skills/{devflow-file-standards → utility/file-standards}/SKILL.md +0 -0
  190. /package/.claude/skills/{fractal-docs-generator → utility/fractal-docs}/SKILL.md +0 -0
  191. /package/.claude/skills/{npm-release → utility/npm-release}/SKILL.md +0 -0
@@ -0,0 +1,342 @@
1
+ # hooks/ - Claude Code Hooks
2
+
3
+ > L2 | 父级: `.claude/CLAUDE.md`
4
+
5
+ ## Purpose
6
+
7
+ Claude Code CLI 钩子脚本,在工具调用前后执行自定义逻辑。
8
+
9
+ ## Members
10
+
11
+ | File | Purpose | Trigger |
12
+ |------|---------|---------|
13
+ | `inject-agent-context.ts` | Task 工具上下文注入 [v4.4] | PreToolUse(Task) |
14
+ | `inject-skill-context.ts` | Skill 上下文注入 | PreToolUse(Skill) |
15
+ | `pre-tool-use-guardrail.sh` | Edit/Write 前置检查 | PreToolUse(Edit\|Write) |
16
+ | `post-tool-use-tracker.sh` | 文件修改追踪 | PostToolUse(Edit\|Write) |
17
+ | `skill-activation-prompt.sh` | Skill 激活提示 | UserPromptSubmit |
18
+ | `error-handling-reminder.sh` | 错误处理提醒 | Stop |
19
+ | `ralph-loop.ts` | Ralph Loop 程序化验证 [v4.7 Team 模式] | SubagentStop |
20
+ | `teammate-idle-hook.ts` | Team 任务调度器 [v4.7] | TeammateIdle |
21
+ | `task-completed-hook.ts` | 任务完成验证器 [v4.7] | TaskCompleted |
22
+ | `checklist-gate.js` | Checklist 质量门 | Custom |
23
+ | `types/team-types.d.ts` | Team 状态 TypeScript 类型定义 [v4.7] | N/A |
24
+
25
+ ## Hook Registration (settings.json)
26
+
27
+ ```json
28
+ {
29
+ "hooks": {
30
+ "PreToolUse": [
31
+ {"matcher": "Edit|Write", "command": "pre-tool-use-guardrail.sh"},
32
+ {"matcher": "Task", "command": "inject-agent-context.ts"}
33
+ ],
34
+ "PostToolUse": [
35
+ {"matcher": "Edit|Write", "command": "post-tool-use-tracker.sh"}
36
+ ],
37
+ "SubagentStop": [
38
+ {"command": "ralph-loop.ts"}
39
+ ],
40
+ "TeammateIdle": [
41
+ {"command": "teammate-idle-hook.ts"}
42
+ ],
43
+ "TaskCompleted": [
44
+ {"command": "task-completed-hook.ts"}
45
+ ]
46
+ }
47
+ }
48
+ ```
49
+
50
+ ## inject-agent-context.ts (v4.4)
51
+
52
+ 借鉴 Trellis 的 `inject-subagent-context.py` 实现。
53
+
54
+ ### 工作流程
55
+
56
+ ```
57
+ Task(subagent_type="dev-implementer", prompt="...")
58
+
59
+ Hook 检测到 Task 工具调用
60
+
61
+ 获取 REQ-ID (环境变量 > .current-task > 分支名)
62
+
63
+ 查找 JSONL 文件:
64
+ 1. devflow/requirements/{REQ}/context/dev-implementer.jsonl
65
+ 2. .claude/skills/workflow/flow-dev/dev-implementer.jsonl
66
+ 3. .claude/skills/workflow/flow-dev/context.jsonl
67
+
68
+ 解析 JSONL,读取文件内容
69
+
70
+ 注入到 prompt 参数中
71
+ ```
72
+
73
+ ### JSONL 格式 (Trellis 风格)
74
+
75
+ ```jsonl
76
+ {"file": "devflow/requirements/{REQ}/TASKS.md", "reason": "Task list"}
77
+ {"file": "devflow/spec/frontend/index.md", "reason": "Frontend conventions", "optional": true}
78
+ {"file": "src/components/", "type": "directory", "reason": "Existing patterns"}
79
+ ```
80
+
81
+ ### Agent 映射
82
+
83
+ | subagent_type | Skill Directory | JSONL File |
84
+ |---------------|-----------------|------------|
85
+ | dev-implementer | flow-dev | dev-implementer.jsonl |
86
+ | prd-writer | flow-spec | prd-writer.jsonl |
87
+ | tech-architect | flow-spec | tech-architect.jsonl |
88
+ | planner | flow-spec | planner.jsonl |
89
+ | qa-tester | flow-quality | qa-tester.jsonl |
90
+
91
+ ## ralph-loop.ts (v4.7 Team 模式)
92
+
93
+ SubagentStop 钩子,支持单 Agent 和多 Teammate 两种模式。
94
+
95
+ ### 单 Agent 模式 (原有逻辑)
96
+
97
+ ```
98
+ SubagentStop Event
99
+
100
+ 加载 .ralph-state.json
101
+
102
+ 检查超时/最大迭代
103
+
104
+ 执行 verify 命令
105
+
106
+ 通过 → allow | 失败 → block
107
+ ```
108
+
109
+ ### Team 模式 (v4.7 新增)
110
+
111
+ ```
112
+ SubagentStop Event (with teammate_id)
113
+
114
+ 加载 orchestration_status.json
115
+
116
+ 检查 Team 模式是否启用
117
+
118
+ 检查 Teammate 迭代次数 / 全局迭代次数
119
+
120
+ 执行 Teammate 级别验证 (teammate_verify)
121
+
122
+ 验证失败 → block (更新 ralphLoop.teammates[id])
123
+ 验证通过 → 检查是否最后一个活跃 Teammate
124
+
125
+ 是最后一个 → 执行全局验证 (global_verify)
126
+
127
+ 全局通过 → allow | 全局失败 → block
128
+ 不是最后一个 → allow
129
+ ```
130
+
131
+ ### 输入格式 (Team 模式扩展)
132
+
133
+ ```typescript
134
+ interface HookInput {
135
+ hook_event_name: 'SubagentStop';
136
+ cwd: string;
137
+ session_id: string;
138
+ // Team 模式扩展
139
+ teammate_id?: string;
140
+ teammate_role?: string;
141
+ }
142
+ ```
143
+
144
+ ### 配置 (quality-gates.yml)
145
+
146
+ ```yaml
147
+ ralph_loop:
148
+ max_iterations: 5
149
+ timeout_minutes: 30
150
+
151
+ team_mode:
152
+ enabled: true
153
+ scope: teammate
154
+
155
+ teammate_verify:
156
+ dev-frontend:
157
+ - npm run lint -- --files-changed
158
+ - npm run typecheck --if-present
159
+ dev-backend:
160
+ - npm run lint -- --files-changed
161
+ - npm test -- --changed
162
+
163
+ global_verify:
164
+ - npm run lint
165
+ - npm run typecheck --if-present
166
+ - npm test -- --passWithNoTests
167
+
168
+ max_iterations_per_teammate: 3
169
+ max_global_iterations: 10
170
+ ```
171
+
172
+ ### 状态存储
173
+
174
+ **单 Agent 模式**: `.ralph-state.json`
175
+ ```json
176
+ {
177
+ "agent_id": "session-xxx",
178
+ "iteration": 2,
179
+ "last_failures": [...],
180
+ "started_at": "2026-02-07T10:00:00Z"
181
+ }
182
+ ```
183
+
184
+ **Team 模式**: `orchestration_status.json` 中的 `ralphLoop` 字段
185
+ ```json
186
+ {
187
+ "ralphLoop": {
188
+ "enabled": true,
189
+ "teammates": {
190
+ "dev-frontend": {
191
+ "iteration": 2,
192
+ "lastVerifyResult": "passed",
193
+ "lastVerifyAt": "2026-02-07T10:00:00Z"
194
+ }
195
+ },
196
+ "globalIteration": 5,
197
+ "maxIterations": 10,
198
+ "startedAt": "2026-02-07T09:00:00Z"
199
+ }
200
+ }
201
+ ```
202
+
203
+ ## teammate-idle-hook.ts (v4.7)
204
+
205
+ Team 模式下的任务调度器,在 Teammate 空闲时触发。
206
+
207
+ ### 工作流程
208
+
209
+ ```
210
+ TeammateIdle Event
211
+
212
+ 验证 hook_event_name === 'TeammateIdle'
213
+
214
+ 如果有 last_task_id,执行 idle_checks 验证
215
+
216
+ 验证失败 → 返回 assign_task (继续修复)
217
+ 验证通过 → 标记任务完成
218
+
219
+ 查找下一个未分配任务
220
+
221
+ 有任务 → 返回 assign_task
222
+ 无任务 + 所有 Teammate 空闲 → 返回 shutdown
223
+ 无任务 + 有 Teammate 工作中 → 返回 wait
224
+ ```
225
+
226
+ ### 输入格式 (TeammateIdleInput)
227
+
228
+ ```typescript
229
+ {
230
+ hook_event_name: 'TeammateIdle',
231
+ teammate_id: string,
232
+ teammate_role: string,
233
+ last_task_id?: string,
234
+ idle_reason: 'task_complete' | 'waiting_dependency' | 'no_tasks' | 'error',
235
+ cwd: string,
236
+ session_id: string
237
+ }
238
+ ```
239
+
240
+ ### 输出格式 (TeammateIdleOutput)
241
+
242
+ ```typescript
243
+ {
244
+ action: 'assign_task' | 'wait' | 'shutdown',
245
+ task_id?: string,
246
+ message?: string
247
+ }
248
+ ```
249
+
250
+ ### 配置 (quality-gates.yml)
251
+
252
+ ```yaml
253
+ teammate_idle:
254
+ idle_checks:
255
+ - npm run lint --if-present
256
+ - npm run typecheck --if-present
257
+ - npm test -- --passWithNoTests
258
+ assignment_strategy: priority_first
259
+ ```
260
+
261
+ ## task-completed-hook.ts (v4.7)
262
+
263
+ 任务完成时的质量验证钩子。
264
+
265
+ ### 工作流程
266
+
267
+ ```
268
+ TaskCompleted Event
269
+
270
+ 验证 hook_event_name === 'TaskCompleted'
271
+
272
+ 加载 quality-gates.yml 配置
273
+
274
+ 执行 task_completed.verify 命令
275
+
276
+ ├── 通过 → accept + 更新 Team 状态
277
+ └── 失败 → block_on_failure?
278
+ ├── true → reject
279
+ └── false → accept (with warning)
280
+
281
+ 记录失败到 ERROR_LOG.md
282
+
283
+ 检查阶段转换
284
+ ```
285
+
286
+ ### 配置 (quality-gates.yml)
287
+
288
+ ```yaml
289
+ task_completed:
290
+ verify:
291
+ - npm run lint --if-present
292
+ - npm run typecheck --if-present
293
+ - npm test -- --passWithNoTests
294
+ block_on_failure: true
295
+ max_retries: 3
296
+ ```
297
+
298
+ ### 输入格式
299
+
300
+ ```typescript
301
+ interface TaskCompletedInput {
302
+ hook_event_name: 'TaskCompleted';
303
+ task_id: string;
304
+ task_subject: string;
305
+ completed_by: string;
306
+ completion_time: string;
307
+ cwd: string;
308
+ session_id: string;
309
+ }
310
+ ```
311
+
312
+ ### 输出格式
313
+
314
+ ```typescript
315
+ interface TaskCompletedOutput {
316
+ decision: 'accept' | 'reject';
317
+ reason: string;
318
+ next_actions?: string[];
319
+ }
320
+ ```
321
+
322
+ ## types/ - TypeScript 类型定义 (v4.7)
323
+
324
+ ### team-types.d.ts
325
+
326
+ Team 集成的核心类型定义,被 teammate-idle-hook.ts 和 task-completed-hook.ts 消费。
327
+
328
+ **主要类型**:
329
+
330
+ | Type | Purpose |
331
+ |------|---------|
332
+ | `TeammateState` | Teammate 状态 (id, role, status, currentTask, completedTasks) |
333
+ | `TeamState` | Team 状态 (mode, lead, teammates, taskAssignments) |
334
+ | `RalphLoopTeamState` | Ralph Loop Team 模式状态 |
335
+ | `OrchestrationStatus` | 扩展的 orchestration_status.json 类型 |
336
+ | `TeammateIdleInput/Output` | TeammateIdle Hook 输入/输出 |
337
+ | `TaskCompletedInput/Output` | TaskCompleted Hook 输入/输出 |
338
+ | `QualityGatesTeamConfig` | quality-gates.yml Team 配置 |
339
+
340
+ ---
341
+
342
+ [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md