cc-devflow 4.1.5 → 4.2.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 (112) hide show
  1. package/.claude/CLAUDE.md +87 -1091
  2. package/.claude/commands/core/architecture.md +32 -2
  3. package/.claude/commands/core/guidelines.md +27 -2
  4. package/.claude/commands/core/roadmap.md +33 -4
  5. package/.claude/commands/core/style.md +53 -263
  6. package/.claude/commands/flow/CLAUDE.md +28 -0
  7. package/.claude/commands/flow/archive.md +2 -2
  8. package/.claude/commands/flow/checklist.md +9 -251
  9. package/.claude/commands/flow/clarify.md +9 -127
  10. package/.claude/commands/flow/constitution.md +1 -1
  11. package/.claude/commands/flow/context.md +1 -1
  12. package/.claude/commands/flow/dev.md +19 -395
  13. package/.claude/commands/flow/ideate.md +13 -13
  14. package/.claude/commands/flow/init.md +19 -30
  15. package/.claude/commands/flow/new.md +12 -268
  16. package/.claude/commands/flow/quality.md +10 -153
  17. package/.claude/commands/flow/release.md +18 -81
  18. package/.claude/commands/flow/restart.md +15 -16
  19. package/.claude/commands/flow/spec.md +14 -164
  20. package/.claude/commands/flow/status.md +12 -12
  21. package/.claude/commands/flow/update.md +4 -4
  22. package/.claude/commands/flow/upgrade.md +6 -6
  23. package/.claude/commands/flow/verify.md +19 -78
  24. package/.claude/commands/flow/workspace.md +1 -1
  25. package/.claude/docs/guides/INIT_TROUBLESHOOTING.md +7 -7
  26. package/.claude/docs/guides/NEW_TROUBLESHOOTING.md +44 -96
  27. package/.claude/docs/guides/ROADMAP_TROUBLESHOOTING.md +1 -1
  28. package/.claude/docs/guides/TASK_COMPLETION_MARKING.md +5 -5
  29. package/.claude/docs/templates/ATTEMPT_TEMPLATE.md +1 -1
  30. package/.claude/docs/templates/BACKLOG_TEMPLATE.md +3 -3
  31. package/.claude/docs/templates/CLARIFICATION_REPORT_TEMPLATE.md +5 -5
  32. package/.claude/docs/templates/ERROR_LOG_TEMPLATE.md +2 -2
  33. package/.claude/docs/templates/INIT_FLOW_TEMPLATE.md +3 -3
  34. package/.claude/docs/templates/NEW_ORCHESTRATION_TEMPLATE.md +33 -64
  35. package/.claude/docs/templates/RESEARCH_TEMPLATE.md +3 -3
  36. package/.claude/docs/templates/ROADMAP_DIALOGUE_TEMPLATE.md +2 -2
  37. package/.claude/docs/templates/ROADMAP_TEMPLATE.md +2 -2
  38. package/.claude/docs/templates/STYLE_TEMPLATE.md +3 -3
  39. package/.claude/docs/templates/UI_PROTOTYPE_TEMPLATE.md +8 -9
  40. package/.claude/guides/workflow-guides/flow-orchestrator.md +31 -265
  41. package/.claude/hooks/CLAUDE.md +1 -1
  42. package/.claude/hooks/checklist-gate.js +4 -4
  43. package/.claude/hooks/inject-agent-context.ts +2 -2
  44. package/.claude/scripts/calculate-checklist-completion.sh +2 -2
  45. package/.claude/scripts/check-prerequisites.sh +2 -2
  46. package/.claude/scripts/checklist-errors.sh +4 -4
  47. package/.claude/scripts/flow-quality-full.sh +5 -5
  48. package/.claude/scripts/flow-quality-quick.sh +4 -4
  49. package/.claude/scripts/flow-workspace-init.sh +2 -2
  50. package/.claude/scripts/generate-clarification-report.sh +4 -4
  51. package/.claude/scripts/recover-workflow.sh +70 -73
  52. package/.claude/scripts/run-quality-gates.sh +1 -1
  53. package/.claude/scripts/setup-epic.sh +2 -2
  54. package/.claude/scripts/setup-ralph-loop.sh +2 -2
  55. package/.claude/scripts/validate-research.sh +1 -1
  56. package/.claude/scripts/verify-setup.sh +1 -1
  57. package/.claude/skills/cc-devflow-orchestrator/SKILL.md +113 -108
  58. package/.claude/skills/workflow/CLAUDE.md +24 -0
  59. package/.claude/skills/workflow/flow-dev/CLAUDE.md +14 -76
  60. package/.claude/skills/workflow/flow-dev/SKILL.md +58 -60
  61. package/.claude/skills/workflow/flow-dev/context.jsonl +4 -8
  62. package/.claude/skills/workflow/flow-init/SKILL.md +46 -144
  63. package/.claude/skills/workflow/flow-init/assets/RESEARCH_TEMPLATE.md +1 -1
  64. package/.claude/skills/workflow/flow-init/context.jsonl +3 -3
  65. package/.claude/skills/workflow/flow-init/scripts/check-prerequisites.sh +1 -1
  66. package/.claude/skills/workflow/flow-init/scripts/validate-research.sh +1 -1
  67. package/.claude/skills/workflow/flow-release/SKILL.md +23 -56
  68. package/.claude/skills/workflow/flow-release/context.jsonl +5 -7
  69. package/.claude/skills/workflow/flow-spec/CLAUDE.md +15 -101
  70. package/.claude/skills/workflow/flow-spec/SKILL.md +40 -511
  71. package/.claude/skills/workflow/flow-spec/context.jsonl +5 -7
  72. package/.claude/skills/workflow/flow-verify/CLAUDE.md +10 -0
  73. package/.claude/skills/workflow/flow-verify/SKILL.md +53 -0
  74. package/.claude/skills/workflow/flow-verify/context.jsonl +5 -0
  75. package/.claude/skills/workflow.yaml +72 -267
  76. package/CHANGELOG.md +72 -0
  77. package/README.md +96 -69
  78. package/README.zh-CN.md +95 -67
  79. package/bin/cc-devflow-cli.js +154 -0
  80. package/bin/harness.js +22 -0
  81. package/docs/commands/README.md +34 -38
  82. package/docs/commands/README.zh-CN.md +34 -36
  83. package/docs/commands/core-roadmap.md +2 -2
  84. package/docs/commands/core-roadmap.zh-CN.md +2 -2
  85. package/docs/commands/core-style.md +29 -381
  86. package/docs/commands/core-style.zh-CN.md +29 -381
  87. package/docs/commands/flow-init.md +10 -10
  88. package/docs/commands/flow-init.zh-CN.md +11 -11
  89. package/docs/commands/flow-new.md +25 -260
  90. package/docs/commands/flow-new.zh-CN.md +26 -257
  91. package/docs/guides/getting-started.md +16 -15
  92. package/docs/guides/getting-started.zh-CN.md +10 -12
  93. package/lib/compiler/__tests__/manifest.test.js +156 -0
  94. package/lib/compiler/__tests__/parser.test.js +21 -0
  95. package/lib/compiler/index.js +17 -1
  96. package/lib/compiler/manifest.js +68 -6
  97. package/lib/compiler/parser.js +5 -0
  98. package/lib/harness/CLAUDE.md +21 -0
  99. package/lib/harness/cli.js +208 -0
  100. package/lib/harness/index.js +16 -0
  101. package/lib/harness/operations/dispatch.js +285 -0
  102. package/lib/harness/operations/init.js +48 -0
  103. package/lib/harness/operations/janitor.js +74 -0
  104. package/lib/harness/operations/pack.js +100 -0
  105. package/lib/harness/operations/plan.js +29 -0
  106. package/lib/harness/operations/release.js +83 -0
  107. package/lib/harness/operations/resume.js +44 -0
  108. package/lib/harness/operations/verify.js +163 -0
  109. package/lib/harness/planner.js +141 -0
  110. package/lib/harness/schemas.js +108 -0
  111. package/lib/harness/store.js +240 -0
  112. package/package.json +9 -1
package/.claude/CLAUDE.md CHANGED
@@ -1,1129 +1,125 @@
1
1
  # CC-DevFlow .claude Directory Architecture
2
2
 
3
3
  ## Purpose
4
- This directory contains Claude Code CLI extensions for the CC-DevFlow development workflow system.
4
+ `.claude/` CC-DevFlow 的执行控制层:定义命令入口、Skill 依赖、运行时脚本、Hook 策略与模板约束。
5
5
 
6
- ## Directory Structure (v4.3 Skills-First Architecture)
6
+ ## Directory Structure (v6.0 Harness-First)
7
7
 
8
- ```
8
+ ```text
9
9
  .claude/
10
- ├── skills/ # Skills 目录 (核心)
11
- │ ├── workflow.yaml # 工作流依赖图定义 [NEW: v4.0]
12
-
13
- │ ├── workflow/ # 工作流 Skills [NEW: v4.0]
14
- │ │ ├── flow-init/ # 需求初始化
15
- │ │ ├── SKILL.md # 核心指令 (<500 行)
16
- │ │ ├── context.jsonl # 上下文定义 (借鉴 Trellis)
17
- │ │ ├── scripts/ # 内嵌脚本
18
- │ │ ├── references/ # Agent 指令
19
- │ │ └── assets/ # 模板
20
- ├── flow-spec/ # 统一规格阶段 [NEW: v4.1] ⭐
21
- ├── flow-prd/ # PRD 生成 (deprecated, use flow-spec)
22
- │ ├── flow-tech/ # 技术设计 (deprecated, use flow-spec)
23
- │ │ ├── flow-ui/ # UI 原型 (deprecated, use flow-spec)
24
- ├── flow-epic/ # Epic/Tasks (deprecated, use flow-spec)
25
- ├── flow-dev/ # 开发执行
26
- └── flow-release/ # 发布管理
27
- │ │
28
- ├── domain/ # 领域 Skills
29
- │ │ ├── tdd/ # TDD Iron Law
30
- │ │ ├── debugging/ # 系统化调试
31
- │ │ └── brainstorming/ # 头脑风暴
32
- │ │
33
- │ ├── guardrail/ # 守护 Skills
34
- │ │ ├── constitution-guardian/
35
- │ │ └── tdd-enforcer/
36
- │ │
37
- │ └── utility/ # 工具 Skills
38
- │ ├── git-commit/
39
- │ └── npm-release/
40
-
41
- ├── commands/ # 命令目录 (v4.2 命名空间重构)
42
- │ ├── flow/ # 工作流命令 (20个) → /flow:xxx
43
- │ ├── core/ # 核心命令 (4个) → /core:xxx
44
- │ └── util/ # 工具命令 (4个) → /util:xxx
45
- ├── agents/ # Agent 指令 (迁移到 skills/*/references/)
46
- ├── hooks/ # 钩子脚本
47
- │ ├── inject-skill-context.ts # 上下文注入钩子 [NEW: v4.0]
48
- │ ├── ralph-loop.ts # Ralph Loop 程序化验证 [NEW: v4.4]
49
- │ ├── teammate-idle-hook.ts # Team 任务调度器 [NEW: v4.7] ⭐
50
- │ ├── task-completed-hook.ts # 任务完成验证器 [NEW: v4.7] ⭐
51
- │ └── types/
52
- │ └── team-types.d.ts # Team 状态类型定义 [NEW: v4.7]
53
- ├── scripts/ # 共享脚本
54
- │ ├── CLAUDE.md # scripts 子目录地图(成员清单与职责边界)
55
- │ └── common.sh # 通用函数
56
- └── docs/templates/ # 共享模板
57
- └── _shared/ # 共享模板组件 [NEW: v4.1]
58
- ├── CONSTITUTION_CHECK.md
59
- ├── VALIDATION_CHECKLIST.md
60
- └── YAML_FRONTMATTER.md
61
-
62
- devflow/
63
- ├── spec/ # 分层规范库 [NEW: v4.0]
64
- │ ├── frontend/index.md # 前端规范
65
- │ ├── backend/index.md # 后端规范
66
- │ └── shared/index.md # 共享规范
67
- └── requirements/ # 需求目录
68
- ```
69
-
70
- ## v4.0 Skills-First Architecture
71
-
72
- ### 核心创新 (借鉴 Trellis + OpenSpec)
73
-
74
- | 来源 | 创新点 | 应用方式 |
75
- |------|--------|----------|
76
- | **Trellis** | JSONL 上下文注入 | 每个 Skill 有 `context.jsonl` |
77
- | **Trellis** | 分层规范库 | `devflow/spec/{frontend,backend}/` |
78
- | **OpenSpec** | Schema 驱动工作流 | `workflow.yaml` 定义依赖图 |
79
- | **OpenSpec** | 文件存在性状态检测 | 通过 generates 判断完成状态 |
80
-
81
- ### Skill 结构规范
82
-
83
- ```
84
- skill-name/
85
- ├── SKILL.md # 核心指令 (<500 行)
86
- ├── context.jsonl # 上下文定义
87
- ├── scripts/ # 内嵌脚本
88
- ├── references/ # Agent 指令
89
- └── assets/ # 模板
10
+ ├── skills/
11
+ │ ├── workflow.yaml
12
+ ├── workflow/
13
+ ├── flow-init/
14
+ │ │ ├── flow-spec/
15
+ │ │ ├── flow-dev/
16
+ │ │ ├── flow-verify/
17
+ │ │ ├── flow-release/
18
+ │ │ ├── flow-fix/
19
+ │ │ └── flow-quality/ # 兼容保留
20
+ │ ├── domain/
21
+ │ ├── guardrail/
22
+ └── utility/
23
+ ├── commands/
24
+ │ ├── flow/ # /flow:*
25
+ │ ├── core/ # /core:*
26
+ │ └── util/ # /util:*
27
+ ├── hooks/
28
+ ├── scripts/
29
+ └── docs/templates/
90
30
  ```
91
31
 
92
- ### context.jsonl 格式
32
+ ## Current Canonical Flow (Default)
93
33
 
94
- ```jsonl
95
- {"file": "devflow/requirements/{REQ}/BRAINSTORM.md", "reason": "Original intent"}
96
- {"file": "devflow/spec/frontend/index.md", "reason": "Frontend conventions", "optional": true}
34
+ ```text
35
+ /flow:init -> /flow:spec -> /flow:dev -> /flow:verify -> /flow:release
97
36
  ```
98
37
 
99
- ---
38
+ ### Runtime Mapping
100
39
 
101
- ## v4.2.0 Module: Commands Namespace Restructure
40
+ | Command | Runtime Ops | Core Output |
41
+ |---------|-------------|-------------|
42
+ | `/flow:init` | `harness:init` + `harness:pack` | `context-package.md`, `harness-state.json` |
43
+ | `/flow:spec` | `harness:plan` | `task-manifest.json` |
44
+ | `/flow:dev` | `harness:dispatch` / `harness:resume` | `runtime-events.jsonl` |
45
+ | `/flow:verify` | `harness:verify` | `report-card.json` |
46
+ | `/flow:release` | `harness:release` + `harness:janitor` | `release-note.md` |
102
47
 
103
- ### Purpose
48
+ ## Command Namespace
104
49
 
105
- 28 个扁平命令文件重组为 3 个分类目录,采用 Trellis 风格的命名空间调用。
50
+ ### Active Namespaces
106
51
 
107
- ### New Structure
52
+ | Namespace | Scope | Example |
53
+ |-----------|-------|---------|
54
+ | `flow` | Requirement delivery | `/flow:spec "REQ-123"` |
55
+ | `core` | Project-level governance | `/core:roadmap` |
56
+ | `util` | Engineering utilities | `/util:code-review` |
108
57
 
109
- ```
110
- commands/
111
- ├── flow/ # 工作流命令 (20个)
112
- │ ├── init.md # /flow:init
113
- │ ├── spec.md # /flow:spec
114
- │ ├── dev.md # /flow:dev
115
- │ ├── quality.md # /flow:quality
116
- │ ├── release.md # /flow:release
117
- │ ├── fix.md # /flow:fix
118
- │ ├── new.md # /flow:new
119
- │ ├── ideate.md # /flow:ideate
120
- │ ├── clarify.md # /flow:clarify
121
- │ ├── restart.md # /flow:restart
122
- │ ├── status.md # /flow:status
123
- │ ├── update.md # /flow:update
124
- │ ├── upgrade.md # /flow:upgrade
125
- │ ├── verify.md # /flow:verify
126
- │ ├── archive.md # /flow:archive
127
- │ ├── checklist.md # /flow:checklist
128
- │ ├── context.md # /flow:context
129
- │ ├── delta.md # /flow:delta
130
- │ ├── workspace.md # /flow:workspace
131
- │ └── constitution.md # /flow:constitution
132
-
133
- ├── core/ # 核心命令 (4个)
134
- │ ├── architecture.md # /core:architecture
135
- │ ├── guidelines.md # /core:guidelines
136
- │ ├── roadmap.md # /core:roadmap
137
- │ └── style.md # /core:style
138
-
139
- └── util/ # 工具命令 (4个)
140
- ├── git-commit.md # /util:git-commit
141
- ├── code-review.md # /util:code-review
142
- ├── problem-analyzer.md # /util:problem-analyzer
143
- └── cancel-ralph.md # /util:cancel-ralph
144
- ```
58
+ ### Migration (Legacy -> Current)
145
59
 
146
- ### Command Migration
147
-
148
- | 旧命令 | 新命令 |
149
- |--------|--------|
60
+ | Legacy | Current |
61
+ |--------|---------|
150
62
  | `/flow-init` | `/flow:init` |
151
63
  | `/flow-spec` | `/flow:spec` |
152
64
  | `/flow-dev` | `/flow:dev` |
65
+ | `/flow-restart` | `/flow:restart` |
66
+ | `/flow-status` | `/flow:status` |
153
67
  | `/core-architecture` | `/core:architecture` |
154
68
  | `/git-commit` | `/util:git-commit` |
155
- | `/code-review-high` | `/util:code-review` |
156
-
157
- ### Benefits
158
-
159
- 1. **清晰分类**: 28 个命令分为 3 组,一目了然
160
- 2. **命名空间**: 避免命令名冲突
161
- 3. **可扩展**: 新命令按类别添加
162
- 4. **对齐 Trellis**: 统一风格,便于跨项目协作
163
-
164
- ---
165
-
166
- **Last Updated**: 2026-02-07
167
- **v4.2.0 Module**: Commands Namespace Restructure
168
-
169
- ---
170
-
171
- ## Legacy Structure (保留兼容)
172
-
173
- ```
174
- .claude/
175
- ├── agents/ # Agent instruction files (迁移中)
176
- ├── commands/ # Slash command definitions (已重构为命名空间)
177
- ├── hooks/ # JavaScript hooks
178
- ├── scripts/ # Bash utility scripts
179
- └── docs/templates/ # Templates
180
- ```
181
-
182
- ## REQ-002 Module: /flow-checklist
183
-
184
- ### Purpose
185
- "Unit Tests for English" - Quality validation for requirement documents before task planning.
186
-
187
- ### Components
188
-
189
- | Component | File | Lines | Purpose |
190
- |-----------|------|-------|---------|
191
- | Command | `commands/flow-checklist.md` | 256 | Command definition and flow |
192
- | Agent | `agents/checklist-agent.md` | 176 | Generation logic with Anti-Example rules |
193
- | Gate Hook | `hooks/checklist-gate.js` | 320 | Epic entry gate validation |
194
- | Calculator | `scripts/calculate-checklist-completion.sh` | 244 | Completion percentage |
195
- | Errors | `scripts/checklist-errors.sh` | 132 | Error codes and validation |
196
- | Template | `docs/templates/CHECKLIST_TEMPLATE.md` | 53 | Output format |
197
-
198
- ### Integration Points
199
-
200
- 1. **Entry**: After `/flow-prd`, before `/flow-epic`
201
- 2. **Gate**: Integrated into `/flow-epic` Entry Gate (Step 5)
202
- 3. **Config**: `config/quality-rules.yml` (80% threshold)
203
- 4. **Output**: `devflow/requirements/{REQ}/checklists/*.md`
204
-
205
- ### Quality Dimensions
206
- - Completeness
207
- - Clarity
208
- - Consistency
209
- - Measurability
210
- - Coverage
211
-
212
- ---
213
-
214
- **Last Updated**: 2025-12-15
215
- **REQ-002 Version**: 1.0.0
216
-
217
- ---
218
-
219
- ## v2.3.0 Module: Ralph × Manus Integration
220
-
221
- ### Purpose
222
- Combine Ralph-Wiggum's autonomous iteration loop with Manus-style Planning-with-Files for memory-enhanced continuous development.
223
-
224
- ### Core Concepts
225
-
226
- **Ralph Loop**: Autonomous iteration until completion (持续迭代直到完成,永不放弃)
227
- - Prompt stays constant, file state changes
228
- - Claude learns from its own previous work
229
- - Auto-retry on errors, no manual intervention
230
-
231
- **Manus 6 Principles**:
232
- 1. 文件系统作外部记忆 - Filesystem as external memory
233
- 2. 注意力操纵 - Attention manipulation (read goal files at key moments)
234
- 3. 保留失败痕迹 - Keep failure traces (ERROR_LOG.md, research/attempts/)
235
- 4. 避免少样本过拟合 - Avoid few-shot overfitting
236
- 5. 稳定前缀优化缓存 - Stable prefix for KV-cache optimization
237
- 6. 只追加上下文 - Append-only context
238
-
239
- **Why They're a Perfect Match**:
240
- - Ralph: "监督把活干完" (supervise task completion)
241
- - Manus: "认真把进度记下来" (carefully record progress)
242
- - Together: 有记忆的持续迭代系统 (memory-enhanced continuous iteration)
243
-
244
- ### Components
245
-
246
- | Component | File | Purpose |
247
- |-----------|------|---------|
248
- | **Command** | `commands/flow-dev.md` | Autonomous iteration loop (Default) |
249
- | **Attention Skill** | `skills/flow-attention-refresh/SKILL.md` | 4 attention refresh protocols |
250
- | **TDD Skill** | `skills/flow-tdd/SKILL.md` | Error recording integration |
251
- | **Error Template** | `docs/templates/ERROR_LOG_TEMPLATE.md` | Execution error log format |
252
- | **Attempt Template** | `docs/templates/ATTEMPT_TEMPLATE.md` | Research attempt log format |
253
-
254
- **Modified Files**:
255
- - `commands/flow-dev.md` - Merged Ralph Loop (Autonomous by default)
256
- - `commands/flow-init.md` - Research made mandatory via `flow-researcher` subagent (context-isolated)
257
- - `skills/cc-devflow-orchestrator/SKILL.md` - Updated routing for autonomous flow
258
-
259
- ### Attention Refresh Protocols
260
-
261
- | Protocol | Trigger Point | Reads | Purpose |
262
- |----------|---------------|-------|---------|
263
- | Protocol 1 | Every flow-* Entry Gate | BRAINSTORM.md | Align with original intent |
264
- | Protocol 2 | flow-dev task start | TASKS.md T### + DoD | Clarify task goal |
265
- | Protocol 3 | Ralph iteration start | TASKS.md + ERROR_LOG.md | Next action + avoid errors |
266
- | Protocol 4 | After error | ERROR_LOG.md | Root cause analysis |
267
-
268
- ### ERROR_LOG.md Structure
269
-
270
- ```markdown
271
- ## [TIMESTAMP] E###: TITLE
272
-
273
- **Phase**: flow-dev / T###
274
- **Error Type**: Test Failure | Build Error | Runtime Error
275
- **Error Message**: [full error]
276
- **Root Cause**: [after analysis]
277
- **Resolution**: [after fix]
278
- **Prevention**: [optional]
279
- ```
280
-
281
- ### research/attempts/ Structure
282
-
283
- ```markdown
284
- # Attempt: [方案名]
285
-
286
- **Date**: YYYY-MM-DD
287
- **Context**: 解决 [什么问题]
288
-
289
- ## Approach / Result / Reason / Learning / References
290
- ```
291
-
292
- ### Integration Points
293
-
294
- 1. **Entry**: After `/flow-epic`, execute `/flow-dev`
295
- 2. **Trigger**: `status: "epic_complete"` → `/flow-dev` (Autonomous by default)
296
- 3. **Output**:
297
- - `ERROR_LOG.md` (execution errors)
298
- - `research/attempts/` (research phase failures)
299
- - All tasks completed with TDD
300
-
301
- ### Modes: Autonomous (Default) vs Manual
302
-
303
- | | /flow-dev (Default) | /flow-dev --manual |
304
- |--|-----------|-------------|
305
- | 退出条件 | 迭代直到完成或上限 | 任务失败可停止 |
306
- | 错误处理 | 自动重试 | 提示用户修复 |
307
- | 注意力刷新 | 每迭代刷新(含错误学习) | 每任务一次 |
308
- | 适用场景 | 可无人值守 | 需要人工监督 |
309
- | ERROR_LOG | 强制记录 | 可选记录 |
310
-
311
- ### Success Metrics (Target)
312
-
313
- | 指标 | 目标 |
314
- |------|------|
315
- | 任务完成率 (无人工干预) | ≥85% |
316
- | 测试失败后自动恢复率 | ≥70% |
317
- | 上下文遗忘导致的返工 | ≤0.5 次/需求 |
318
- | 错误重复发生率 | ≤10% |
319
-
320
- ---
321
-
322
- **Last Updated**: 2026-02-06
323
- **v2.3.0 Module**: Ralph × Manus Integration
324
69
 
325
- ---
326
-
327
- ## v3.0.0 Module: OpenSpec × Trellis Integration
328
-
329
- ### Purpose
330
-
331
- Borrow design concepts from OpenSpec (Delta Specs + Archive) and Trellis (Context Injection + Ralph Loop) to solve 5 major pain points:
332
-
333
- 1. **Context Bloat** → Staged Context Injection (RM-015)
334
- 2. **Weak Quality Gates** → Programmatic Verification (RM-016)
335
- 3. **No Incremental Tracking** → Delta Specs Engine (RM-017)
336
- 4. **No Session Persistence** → Workspace System (RM-018)
337
- 5. **Scattered Guidelines** → Unified Spec Directory (RM-019)
338
- 6. **Workflow Redundancy** → Flow Simplification (RM-020)
339
-
340
- ### New Directory Structure
341
-
342
- ```
343
- devflow/
344
- ├── specs/ # SSOT for specifications [NEW: RM-017]
345
- │ └── modules/ # Module-level specs
346
- ├── workspace/ # Developer workspaces [NEW: RM-018]
347
- │ └── {developer}/ # Per-developer journals
348
- ├── spec/ # Unified project specs [NEW: RM-019]
349
- │ ├── frontend/ # Frontend specifications
350
- │ ├── backend/ # Backend specifications
351
- │ └── shared/ # Cross-cutting specs
352
- ├── QUICK_REFERENCE.md # v3.0 workflow quick reference [NEW]
353
- └── MIGRATION_v3.0.md # Migration guide [NEW]
354
-
355
- .claude/
356
- ├── config/
357
- │ └── quality-gates.yml # Programmatic verification rules [NEW: RM-016]
358
- ├── hooks/
359
- │ ├── inject-agent-context.ts # Context injection hook [NEW: RM-015]
360
- │ ├── types/
361
- │ │ └── context-injection.d.ts # TypeScript types [NEW]
362
- │ └── utils/
363
- │ └── jsonl-parser.ts # JSONL parsing utilities [NEW]
364
- ├── commands/
365
- │ ├── flow-context.md # Context management [NEW: RM-015]
366
- │ ├── flow-delta.md # Delta specs management [NEW: RM-017]
367
- │ ├── flow-workspace.md # Workspace management [NEW: RM-018]
368
- │ └── flow-quality.md # Combined quality verification [NEW: RM-020]
369
- ├── scripts/
370
- │ ├── flow-context-*.sh # Context scripts [NEW]
371
- │ ├── flow-delta-*.sh # Delta scripts [NEW]
372
- │ ├── flow-workspace-*.sh # Workspace scripts [NEW]
373
- │ ├── flow-quality-*.sh # Quality scripts [NEW]
374
- │ ├── run-quality-gates.sh # Gate execution [NEW: RM-016]
375
- │ └── record-quality-error.sh # Error recording [NEW]
376
- └── docs/templates/
377
- ├── context/ # Context JSONL templates [NEW: RM-015]
378
- │ ├── dev.jsonl.template
379
- │ ├── epic.jsonl.template
380
- │ └── ...
381
- ├── DELTA_SPEC_TEMPLATE.md # Delta spec format [NEW: RM-017]
382
- └── JOURNAL_TEMPLATE.md # Journal format [NEW: RM-018]
383
- ```
384
-
385
- ### New Commands
386
-
387
- | Command | Purpose | Module |
388
- |---------|---------|--------|
389
- | `/flow-context` | Manage staged context injection | RM-015 |
390
- | `/flow-delta` | Manage delta specs | RM-017 |
391
- | `/flow-workspace` | Manage developer workspace | RM-018 |
392
- | `/flow-quality` | Combined quality verification | RM-020 |
393
-
394
- ### Simplified Workflows
395
-
396
- ```
397
- 【精简流程】(5 步, 适合小需求)
398
- /flow-init --quick → /flow-prd --quick → /flow-epic → /flow-dev → /flow-release
399
-
400
- 【标准流程】(6 步, 适合中等需求)
401
- /flow-init → /flow-prd → /flow-epic → /flow-dev → /flow-quality → /flow-release
402
-
403
- 【完整流程】(8 步, 适合大需求)
404
- /flow-init → /flow-clarify → /flow-prd → /flow-tech → /flow-ui
405
- → /flow-epic → /flow-dev → /flow-quality --full → /flow-release
406
- ```
407
-
408
- ### Deprecations
409
-
410
- | Old Command | Replacement | Status |
411
- |-------------|-------------|--------|
412
- | `/flow-review` | `/flow-quality --full` | Deprecated (warning) |
413
- | `/flow-qa` | `/flow-quality --full` | Deprecated (warning) |
414
-
415
- ### Expected Improvements
416
-
417
- | Metric | Before | After | Improvement |
418
- |--------|--------|-------|-------------|
419
- | Agent context size | 10000+ tokens | 3000 tokens | -70% |
420
- | Single command time | 2-3 min | 1-1.5 min | -50% |
421
- | Full workflow time | 30-45 min | 15-20 min | -50% |
422
- | Rework rate | ~30% | ~10% | -67% |
423
-
424
- ---
425
-
426
- **Last Updated**: 2026-02-07
427
- **v3.0.0 Module**: OpenSpec × Trellis Integration
428
-
429
- ---
430
-
431
- ## v4.1.0 Module: Unified Specification Phase
432
-
433
- ### Purpose
434
-
435
- 合并 flow-prd/flow-tech/flow-ui/flow-epic 为统一的 `/flow-spec` 命令,减少命令调用次数,利用 Agent 并行执行潜力。
70
+ ## Deprecated Entry Points (Compatibility Kept)
436
71
 
437
- ### Key Changes
72
+ | Deprecated | Migration |
73
+ |------------|-----------|
74
+ | `/flow:new` | use canonical 5-stage flow |
75
+ | `/flow:clarify` | merged into `/flow:spec` |
76
+ | `/flow:checklist` | merged into `/flow:verify --strict` |
77
+ | `/flow:quality` | merged into `/flow:verify` |
78
+ | `/flow-prd` + `/flow-tech` + `/flow-ui` + `/flow-epic` | unified as `/flow:spec` |
438
79
 
439
- | Before (v4.0) | After (v4.1) | Improvement |
440
- |---------------|--------------|-------------|
441
- | 4 个独立命令 | 1 个统一命令 | -75% 命令数 |
442
- | 串行执行 | Tech + UI 并行 | -35% 时间 |
443
- | 重复 Entry/Exit Gate | 统一 Gate | -280 行代码 |
80
+ ## Key Compatibility Modules
444
81
 
445
- ### New Command: /flow-spec
82
+ | Module | Status | Note |
83
+ |--------|--------|------|
84
+ | `/flow:delta` | active | incremental spec evolution |
85
+ | `/flow:archive` | active | archive + restore |
86
+ | `/flow:workspace` | active | developer workspace/journal |
87
+ | `flow-quality` skill directory | compatibility | historical quality path retained |
446
88
 
447
- ```bash
448
- # Full Mode (默认)
449
- /flow-spec "REQ-123"
89
+ ## Hooks and Scripts (Execution Spine)
450
90
 
451
- # Quick Mode (小需求)
452
- /flow-spec "REQ-123" --skip-tech --skip-ui
91
+ - Hooks enforce lifecycle checks and context injection (`inject-*`, `ralph-loop`, teammate hooks).
92
+ - Scripts implement deterministic stage operations (`run-quality-gates.sh`, `recover-workflow.sh`, `verify-gate.sh`).
93
+ - `scripts/common.sh` is the shared contract for REQ detection and state helpers.
453
94
 
454
- # Backend Only
455
- /flow-spec "REQ-123" --skip-ui
95
+ ## Historical Modules (Archived Summary)
456
96
 
457
- # Frontend Only
458
- /flow-spec "REQ-123" --skip-tech
459
- ```
460
-
461
- ### Execution Flow
462
-
463
- ```
464
- PRD (sequential) → Tech + UI (parallel) → Epic (sequential)
465
-
466
- Time ────────────────────────────────────────────►
467
-
468
- T0 ┌─────────────┐
469
- │ prd-writer │ (必须先完成)
470
- └──────┬──────┘
471
-
472
- T1 ├────────────────────┐
473
- │ │
474
- ┌──────▼──────┐ ┌──────▼──────┐
475
- │tech-architect│ │ ui-designer │ (并行)
476
- └──────┬──────┘ └──────┬──────┘
477
- │ │
478
- T2 └─────────┬──────────┘
479
-
480
- ┌──────▼──────┐
481
- │ planner │ (等待两者完成)
482
- └─────────────┘
483
- ```
484
-
485
- ### New Files
486
-
487
- | File | Purpose |
488
- |------|---------|
489
- | `.claude/skills/workflow/flow-spec/SKILL.md` | 主指令 (~250 行) |
490
- | `.claude/skills/workflow/flow-spec/context.jsonl` | 上下文定义 |
491
- | `.claude/skills/workflow/flow-spec/scripts/entry-gate.sh` | 统一入口检查 |
492
- | `.claude/skills/workflow/flow-spec/scripts/parallel-orchestrator.sh` | 并行调度逻辑 |
493
- | `.claude/skills/workflow/flow-spec/scripts/exit-gate.sh` | 统一出口检查 |
494
- | `.claude/docs/templates/_shared/CONSTITUTION_CHECK.md` | 共享 Constitution 检查 |
495
- | `.claude/docs/templates/_shared/VALIDATION_CHECKLIST.md` | 共享验证清单 |
496
- | `.claude/docs/templates/_shared/YAML_FRONTMATTER.md` | 共享 YAML 头部 |
497
-
498
- ### Deprecations
499
-
500
- | Old Command | Replacement | Status |
501
- |-------------|-------------|--------|
502
- | `/flow-prd` | `/flow-spec` | Deprecated (warning) |
503
- | `/flow-tech` | `/flow-spec` | Deprecated (warning) |
504
- | `/flow-ui` | `/flow-spec` | Deprecated (warning) |
505
- | `/flow-epic` | `/flow-spec` | Deprecated (warning) |
506
-
507
- ### Simplified Workflows (v4.1)
508
-
509
- ```
510
- 【精简流程】(3 步, 适合小需求)
511
- /flow-init --quick → /flow-spec --skip-tech --skip-ui → /flow-dev → /flow-release
512
-
513
- 【标准流程】(4 步, 适合中等需求)
514
- /flow-init → /flow-spec → /flow-dev → /flow-quality → /flow-release
515
-
516
- 【完整流程】(5 步, 适合大需求)
517
- /flow-init → /flow-clarify → /flow-spec → /flow-dev → /flow-quality --full → /flow-release
518
- ```
519
-
520
- ### Expected Improvements
97
+ 以下内容是 v2.3 - v4.7 的历史演进摘要,仅用于理解设计来源,不作为当前执行标准。
521
98
 
522
- | Metric | Before (v4.0) | After (v4.1) | Improvement |
523
- |--------|---------------|--------------|-------------|
524
- | 命令调用次数 | 4 | 1 | -75% |
525
- | 设计阶段时间 | 8-12 min | 5-8 min | -35% |
526
- | Entry/Exit Gate 代码 | ~280 | ~100 | -64% |
99
+ | Version | Theme | Key Outcome | Current Status |
100
+ |---------|-------|-------------|----------------|
101
+ | v2.3.0 | Ralph × Manus | 引入自主迭代 + 外部记忆(ERROR_LOG / attempts) | 已并入 `/flow:dev` |
102
+ | v3.0.0 | OpenSpec × Trellis | Skills-first + JSONL 上下文注入 + workflow 图 | 已演进到 v6 harness 主线 |
103
+ | v4.1.0 | Unified Spec | PRD/Tech/UI/Epic 合并为统一 spec 阶段 | 保留为 `/flow:spec` 能力基础 |
104
+ | v4.4.0 | Programmatic Ralph Loop | Hook 级别迭代控制与可验证退出 | 已融入现有 hooks/runtime |
105
+ | v4.5.0 | Delta Specs | 需求增量变更与 apply 流程 | 兼容保留(`/flow:delta`) |
106
+ | v4.6.0 | Archive Enhancement | 归档元数据与可恢复能力 | 兼容保留(`/flow:archive`) |
107
+ | v4.7.0 | Claude Team | 多 Agent 并行调度与任务依赖管理 | 能力保留,非默认路径 |
527
108
 
528
- ---
529
-
530
- **Last Updated**: 2026-02-07
531
- **v4.1.0 Module**: Unified Specification Phase
532
-
533
-
534
- ---
535
-
536
- ## v4.4.0 Module: Ralph Loop Programmatic Verification
537
-
538
- ### Purpose
539
-
540
- 实现 SubagentStop Hook 拦截验证机制,在子 Agent 尝试停止时执行程序化验证,确保代码质量。借鉴 Trellis 的 Ralph Loop 设计。
541
-
542
- ### Key Changes
543
-
544
- | Before (v4.3) | After (v4.4) | Improvement |
545
- |---------------|--------------|-------------|
546
- | 无自动验证 | SubagentStop 拦截 | 质量保证 |
547
- | 手动检查 | 程序化验证 | 自动化 |
548
- | 无迭代控制 | 最大迭代限制 | 防止无限循环 |
549
-
550
- ### New Files
551
-
552
- | File | Purpose |
553
- |------|---------|
554
- | `.claude/hooks/ralph-loop.ts` | SubagentStop Hook 主逻辑 (~350 行) |
555
- | `.ralph-state.json` | 运行时状态文件 (自动生成) |
556
-
557
- ### Configuration
558
-
559
- `quality-gates.yml` 新增配置:
560
-
561
- ```yaml
562
- # 顶级 verify 命令 (SubagentStop 时执行)
563
- verify:
564
- - npm run lint --if-present
565
- - npm run typecheck --if-present
566
- - npm test -- --passWithNoTests
567
-
568
- ralph_loop:
569
- max_iterations: 5 # 最大迭代次数
570
- timeout_minutes: 30 # 超时时间
571
- ```
109
+ ## Design Invariants
572
110
 
573
- ### Hook Registration
574
-
575
- `settings.json` 新增:
576
-
577
- ```json
578
- {
579
- "hooks": {
580
- "SubagentStop": [
581
- {
582
- "hooks": [
583
- {
584
- "type": "command",
585
- "command": "npx ts-node $CLAUDE_PROJECT_DIR/.claude/hooks/ralph-loop.ts"
586
- }
587
- ]
588
- }
589
- ]
590
- }
591
- }
592
- ```
593
-
594
- ### State File Format
595
-
596
- `.ralph-state.json`:
597
-
598
- ```json
599
- {
600
- "agent_id": "session-xxx",
601
- "iteration": 2,
602
- "last_failures": [
603
- {
604
- "command": "npm run lint",
605
- "output": "error: ...",
606
- "timestamp": "2026-02-07T06:00:00Z"
607
- }
608
- ],
609
- "started_at": "2026-02-07T06:00:00Z"
610
- }
611
- ```
612
-
613
- ### Execution Flow
614
-
615
- ```
616
- SubagentStop Event
617
-
618
-
619
- ┌──────────────────┐
620
- │ Load State │
621
- │ Check Timeout │
622
- └────────┬─────────┘
623
-
624
-
625
- ┌──────────────────┐
626
- │ Check Max Iter │──── Reached ──▶ Allow Stop
627
- └────────┬─────────┘
628
-
629
-
630
- ┌──────────────────┐
631
- │ Run Verify Cmds │
632
- └────────┬─────────┘
633
-
634
- ┌────┴────┐
635
- │ │
636
- Pass Fail
637
- │ │
638
- ▼ ▼
639
- Allow Block
640
- Stop Stop
641
- (return errors)
642
- ```
643
-
644
- ### Expected Improvements
645
-
646
- | Metric | Before | After | Improvement |
647
- |--------|--------|-------|-------------|
648
- | 代码质量保证 | 手动 | 自动 | 100% |
649
- | 验证遗漏率 | ~20% | ~0% | -100% |
650
- | 无限循环风险 | 存在 | 受控 | 安全 |
651
-
652
- ---
653
-
654
- **Last Updated**: 2026-02-07
655
- **v4.4.0 Module**: Ralph Loop Programmatic Verification
656
-
657
- ---
658
-
659
- ## v4.5.0 Module: Delta Specs Enhancement
660
-
661
- ### Purpose
662
-
663
- 增强 Delta Specs 机制,借鉴 OpenSpec 的设计,实现完整的增量规格管理。支持 ADDED/MODIFIED/REMOVED/RENAMED 四种操作,提供 TypeScript 解析器和完整的 CLI 工具链。
664
-
665
- ### Key Changes
666
-
667
- | Before (v4.4) | After (v4.5) | Improvement |
668
- |---------------|--------------|-------------|
669
- | 简单复制 | 真正的 delta 应用 | 精确变更 |
670
- | 3 个子命令 | 4 个子命令 | 完整功能 |
671
- | Bash 解析 | TypeScript 解析器 | 可靠性 |
672
- | 无状态管理 | 状态工作流 | 可追溯 |
673
-
674
- ### New Command: /flow:delta
675
-
676
- ```bash
677
- # Create a new delta spec
678
- /flow:delta create "REQ-123" "add-2fa"
679
-
680
- # List all deltas for a requirement
681
- /flow:delta list "REQ-123"
682
-
683
- # Apply delta to main specs (PRD.md)
684
- /flow:delta apply "REQ-123" "add-2fa"
685
-
686
- # Check delta status
687
- /flow:delta status "REQ-123" "add-2fa"
688
- ```
689
-
690
- ### Delta Spec Format (OpenSpec-style)
691
-
692
- ```markdown
693
- ---
694
- delta_id: "2026-02-01-add-2fa"
695
- req_id: "REQ-123"
696
- title: "Add 2FA Support"
697
- created_at: "2026-02-01T10:00:00Z"
698
- status: "draft|review|approved|applied"
699
- ---
700
-
701
- # Delta: Add 2FA Support
702
-
703
- ## ADDED Requirements
704
- ### Requirement: Two-Factor Authentication
705
- #### Scenario: Enable 2FA
706
- - GIVEN user is logged in
707
- - WHEN user enables 2FA
708
- - THEN system generates QR code
709
-
710
- ## MODIFIED Requirements
711
- ### Requirement: User Login
712
- (Previously: old description)
713
-
714
- ## REMOVED Requirements
715
- ### Requirement: Legacy Session
716
- **Reason**: Replaced by JWT
717
- **Migration**: Run migration script
718
-
719
- ## RENAMED Requirements
720
- - FROM: Old Name
721
- - TO: New Name
722
- ```
723
-
724
- ### New Files
725
-
726
- | File | Purpose |
727
- |------|---------|
728
- | `.claude/scripts/delta-parser.ts` | TypeScript Delta 解析器 (~400 行) |
729
- | `.claude/scripts/flow-delta-create.sh` | 创建 delta 目录和文件 |
730
- | `.claude/scripts/flow-delta-list.sh` | 列出所有 deltas |
731
- | `.claude/scripts/flow-delta-apply.sh` | 应用 delta 到 PRD.md |
732
- | `.claude/scripts/flow-delta-status.sh` | 检查 delta 状态 |
733
- | `.claude/docs/templates/DELTA_SPEC_TEMPLATE.md` | Delta 模板 (OpenSpec 格式) |
734
-
735
- ### Directory Structure
736
-
737
- ```
738
- devflow/requirements/REQ-123/
739
- ├── PRD.md # Main specification (SSOT)
740
- ├── deltas/ # Delta specs directory
741
- │ ├── 2026-02-01-add-2fa/
742
- │ │ ├── delta.md # Delta specification
743
- │ │ └── tasks.md # Delta-specific tasks
744
- │ └── 2026-02-05-fix-login/
745
- │ ├── delta.md
746
- │ └── tasks.md
747
- └── ...
748
-
749
- devflow/archive/
750
- └── 2026-02/
751
- └── REQ-123/
752
- └── deltas/ # Archived deltas
753
- ```
754
-
755
- ### Status Workflow
756
-
757
- ```
758
- draft → review → approved → applied
759
- │ │ │
760
- │ │ └── /flow:delta apply
761
- │ │
762
- │ └── Manual review approval
763
-
764
- └── /flow:delta create
765
- ```
766
-
767
- ### TypeScript Parser API
768
-
769
- ```typescript
770
- interface DeltaBlock {
771
- type: 'ADDED' | 'MODIFIED' | 'REMOVED' | 'RENAMED';
772
- name: string;
773
- content: string;
774
- previousContent?: string; // for MODIFIED
775
- reason?: string; // for REMOVED
776
- newName?: string; // for RENAMED
777
- }
778
-
779
- function parseDelta(content: string): DeltaBlock[];
780
- function applyDelta(prdContent: string, delta: DeltaBlock[]): string;
781
- ```
782
-
783
- ### Integration Points
784
-
785
- | Integration | Description |
786
- |-------------|-------------|
787
- | `/flow:spec` | 生成 delta 而非直接修改 PRD |
788
- | `/flow:release` | 应用所有 approved deltas |
789
- | `/flow:archive` | 归档 applied deltas |
790
-
791
- ### Expected Improvements
792
-
793
- | Metric | Before | After | Improvement |
794
- |--------|--------|-------|-------------|
795
- | 变更追溯性 | 无 | 完整 | 100% |
796
- | 冲突检测 | 无 | 自动 | 100% |
797
- | 回滚能力 | 手动 | 自动 | 100% |
798
- | 审核流程 | 无 | 状态驱动 | 100% |
799
-
800
- ---
801
-
802
- **Last Updated**: 2026-02-07
803
- **v4.5.0 Module**: Delta Specs Enhancement
804
-
805
- ---
806
-
807
- ## v4.6.0 Module: Archive System Enhancement
808
-
809
- ### Purpose
810
-
811
- 增强归档系统,集成 Delta Specs 支持,提供完整的需求生命周期管理。
812
-
813
- ### Key Changes
814
-
815
- | Before (v4.5) | After (v4.6) | Improvement |
816
- |---------------|--------------|-------------|
817
- | 简单移动目录 | Delta Specs 检查 | 完整性保证 |
818
- | 无警告机制 | 未应用 delta 警告 | 防止遗漏 |
819
- | 基础状态记录 | deltaCount 字段 | 可追溯性 |
820
-
821
- ### New Features
822
-
823
- #### 1. Delta Specs 检查
824
-
825
- 归档前自动检测:
826
- - 检查 `deltas/` 目录是否存在
827
- - 统计 Delta Specs 数量
828
- - 警告未应用的 Delta Specs (status != "applied")
829
-
830
- #### 2. 增强的状态记录
831
-
832
- ```json
833
- {
834
- "status": "archived",
835
- "archivedReason": "completed",
836
- "archivedAt": "2026-02-07T10:00:00+08:00",
837
- "archiveLocation": "devflow/archive/2026-02/REQ-123",
838
- "statusBeforeArchive": "release_complete",
839
- "deltaCount": 3
840
- }
841
- ```
842
-
843
- #### 3. 新增 common.sh 函数
844
-
845
- | Function | Purpose |
846
- |----------|---------|
847
- | `get_archive_summary()` | 获取归档需求的 JSON 摘要 |
848
- | `has_deltas_to_archive()` | 检查是否有 deltas 需要归档 |
849
- | `get_delta_count()` | 获取 delta 数量 |
850
-
851
- ### Archive Directory Structure
852
-
853
- ```
854
- devflow/archive/
855
- ├── 2026-01/ # 按月组织
856
- │ ├── REQ-001/
857
- │ │ ├── PRD.md
858
- │ │ ├── EPIC.md
859
- │ │ ├── TASKS.md
860
- │ │ ├── deltas/ # Delta Specs 完整保留
861
- │ │ │ └── 2026-01-15-add-feature/
862
- │ │ │ ├── delta.md
863
- │ │ │ └── tasks.md
864
- │ │ ├── orchestration_status.json
865
- │ │ └── ...
866
- │ └── REQ-002/
867
- └── 2026-02/
868
- └── REQ-003/
869
- ```
870
-
871
- ### Command Usage
872
-
873
- ```bash
874
- # 归档需求 (自动检测 Delta Specs)
875
- /flow:archive "REQ-123"
876
-
877
- # 预览归档 (显示 Delta Specs 信息)
878
- /flow:archive "REQ-123" --dry-run
879
-
880
- # 列出所有归档
881
- /flow:archive --list
882
-
883
- # 恢复归档
884
- /flow:archive "REQ-123" --restore
885
- ```
886
-
887
- ### Integration Points
888
-
889
- | Integration | Description |
890
- |-------------|-------------|
891
- | `/flow:release` | 发布后自动触发归档 |
892
- | `/flow:delta` | 归档前检查未应用的 deltas |
893
- | `/flow:status` | 显示归档状态 |
894
-
895
- ### Expected Improvements
896
-
897
- | Metric | Before | After | Improvement |
898
- |--------|--------|-------|-------------|
899
- | Delta 遗漏率 | ~15% | ~0% | -100% |
900
- | 归档完整性 | 基础 | 完整 | 100% |
901
- | 可追溯性 | 有限 | 完整 | 100% |
902
-
903
- ---
904
-
905
- **Last Updated**: 2026-02-07
906
- **v4.6.0 Module**: Archive System Enhancement
907
-
908
- ---
909
-
910
- ## v4.7.0 Module: Claude Team Integration
911
-
912
- ### Purpose
913
-
914
- 集成 Claude Team 功能,支持多 Agent 并行协作开发。实现 TeammateIdle 和 TaskCompleted Hook,扩展状态管理支持 Team 模式。
915
-
916
- ### Key Changes
917
-
918
- | Before (v4.6) | After (v4.7) | Improvement |
919
- |---------------|--------------|-------------|
920
- | 单 Agent 执行 | 多 Agent 并行 | 效率 +200% |
921
- | 无 Team 状态 | 完整 Team 状态管理 | 可追溯 |
922
- | 单一 Ralph Loop | 多 Teammate Ralph Loop | 分布式验证 |
923
-
924
- ### New Hooks
925
-
926
- | Hook | File | Trigger | Purpose |
927
- |------|------|---------|---------|
928
- | **TeammateIdle** | `teammate-idle-hook.ts` | Teammate 空闲时 | 任务分配和调度 |
929
- | **TaskCompleted** | `task-completed-hook.ts` | 任务完成时 | 质量验证和状态更新 |
930
-
931
- ### TeammateIdle Hook 工作流程
932
-
933
- ```
934
- TeammateIdle Event
935
-
936
- 验证 last_task_id (如有)
937
-
938
- 验证失败 → 返回 assign_task (继续修复)
939
- 验证通过 → 标记任务完成
940
-
941
- 查找下一个未分配任务
942
-
943
- 有任务 → 返回 assign_task
944
- 无任务 + 所有 Teammate 空闲 → 返回 shutdown
945
- 无任务 + 有 Teammate 工作中 → 返回 wait
946
- ```
947
-
948
- ### TaskCompleted Hook 工作流程
949
-
950
- ```
951
- TaskCompleted Event
952
-
953
- 执行 task_completed.verify 命令
954
-
955
- ├── 通过 → accept + 更新 Team 状态
956
- └── 失败 → block_on_failure?
957
- ├── true → reject
958
- └── false → accept (with warning)
959
-
960
- 记录失败到 ERROR_LOG.md
961
-
962
- 检查阶段转换
963
- ```
964
-
965
- ### orchestration_status.json 扩展
966
-
967
- ```json
968
- {
969
- "reqId": "REQ-007",
970
- "status": "in_progress",
971
- "phase": "development",
972
-
973
- "team": {
974
- "mode": "parallel",
975
- "lead": "team-lead",
976
- "teammates": [
977
- {
978
- "id": "dev-analyst",
979
- "role": "developer",
980
- "status": "working",
981
- "currentTask": "T001",
982
- "completedTasks": ["T000"],
983
- "lastActiveAt": "2026-02-07T10:00:00Z"
984
- }
985
- ],
986
- "taskAssignments": {
987
- "T001": "dev-analyst"
988
- }
989
- },
990
-
991
- "ralphLoop": {
992
- "enabled": true,
993
- "teammates": {
994
- "dev-analyst": {
995
- "iteration": 2,
996
- "lastVerifyResult": "passed"
997
- }
998
- },
999
- "globalIteration": 3,
1000
- "maxIterations": 10
1001
- }
1002
- }
1003
- ```
1004
-
1005
- ### New Files
1006
-
1007
- | File | Purpose |
1008
- |------|---------|
1009
- | `.claude/hooks/teammate-idle-hook.ts` | TeammateIdle Hook 实现 |
1010
- | `.claude/hooks/task-completed-hook.ts` | TaskCompleted Hook 实现 |
1011
- | `.claude/hooks/types/team-types.d.ts` | Team 状态 TypeScript 类型 |
1012
- | `.claude/scripts/parse-task-dependencies.js` | TASKS.md 任务依赖解析器 |
1013
- | `.claude/scripts/detect-file-conflicts.sh` | 并行任务文件冲突检测 |
1014
- | `.claude/skills/workflow/flow-spec/scripts/team-init.sh` | flow-spec Team 模式初始化 |
1015
- | `.claude/skills/workflow/flow-spec/scripts/team-communication.sh` | Teammate 通信协议 |
1016
- | `.claude/skills/workflow/flow-spec/team-config.json` | spec-design-team 配置 |
1017
- | `.claude/docs/templates/DESIGN_DECISIONS_TEMPLATE.md` | 设计决策记录模板 |
1018
-
1019
- ### common.sh 新增函数
1020
-
1021
- | Function | Purpose |
1022
- |----------|---------|
1023
- | `is_team_mode_enabled()` | 检查 Team 模式是否启用 |
1024
- | `init_team_state()` | 初始化 Team 状态 |
1025
- | `add_teammate()` | 添加 Teammate |
1026
- | `update_teammate_status()` | 更新 Teammate 状态 |
1027
- | `mark_teammate_task_complete()` | 标记任务完成 |
1028
- | `assign_task_to_teammate()` | 分配任务 |
1029
- | `get_unassigned_tasks()` | 获取未分配任务 |
1030
- | `update_teammate_ralph_state()` | 更新 Ralph 状态 |
1031
- | `all_teammates_idle()` | 检查所有 Teammate 空闲 |
1032
- | `cleanup_team_state()` | 清理 Team 状态 |
1033
-
1034
- ### flow-dev Team 模式命令
1035
-
1036
- ```bash
1037
- # 启用 Team 模式 (默认 3 个 Agent)
1038
- /flow:dev "REQ-123" --team
1039
-
1040
- # 指定 Agent 数量 (2-5)
1041
- /flow:dev "REQ-123" --team --agents 5
1042
-
1043
- # Team 模式执行流程
1044
- # 1. 解析 TASKS.md 获取任务依赖
1045
- # 2. 检测文件冲突,分配任务给 Agent
1046
- # 3. 并行执行无冲突任务
1047
- # 4. 冲突任务分配给同一 Agent 串行执行
1048
- # 5. TeammateIdle Hook 自动分配下一任务
1049
- # 6. 所有任务完成后 shutdown
1050
- ```
1051
-
1052
- ### Task Dependency Parser (parse-task-dependencies.js)
1053
-
1054
- ```bash
1055
- # 解析 TASKS.md
1056
- node .claude/scripts/parse-task-dependencies.js parse TASKS.md
1057
-
1058
- # 获取并行分组
1059
- node .claude/scripts/parse-task-dependencies.js groups TASKS.md
1060
-
1061
- # 获取下一批可执行任务
1062
- node .claude/scripts/parse-task-dependencies.js next TASKS.md
1063
-
1064
- # 输出格式
1065
- {
1066
- "tasks": [
1067
- {"id": "T001", "phase": 1, "parallel": true, "userStory": "US1", "filePath": "src/user.ts"}
1068
- ],
1069
- "parallelGroups": [["T001", "T002"], ["T003"]],
1070
- "stats": {"total": 10, "completed": 3, "pending": 7}
1071
- }
1072
- ```
1073
-
1074
- ### File Conflict Detection (detect-file-conflicts.sh)
1075
-
1076
- ```bash
1077
- # 检测文件冲突
1078
- echo '{"tasks": [...]}' | .claude/scripts/detect-file-conflicts.sh
1079
-
1080
- # 输出格式
1081
- {
1082
- "hasConflicts": true,
1083
- "conflicts": [{"file": "src/user.ts", "tasks": ["T001", "T002"]}],
1084
- "safeGroups": [{"tasks": ["T003", "T004"]}]
1085
- }
1086
- ```
1087
-
1088
- ### quality-gates.yml 新增配置
1089
-
1090
- ```yaml
1091
- # TeammateIdle Hook 配置
1092
- teammate_idle:
1093
- idle_checks:
1094
- - npm run lint --if-present
1095
- - npm run typecheck --if-present
1096
- assignment_strategy: priority_first
1097
- idle_timeout: 300
1098
-
1099
- # TaskCompleted Hook 配置
1100
- task_completed:
1101
- verify:
1102
- - npm run lint --if-present
1103
- - npm run typecheck --if-present
1104
- - npm test -- --passWithNoTests
1105
- block_on_failure: true
1106
- max_retries: 3
1107
-
1108
- # Ralph Loop Team 模式配置
1109
- ralph_loop:
1110
- team_mode:
1111
- enabled: true
1112
- scope: teammate
1113
- max_iterations_per_teammate: 3
1114
- max_global_iterations: 10
1115
- ```
111
+ 1. 阶段输出必须可审计(状态文件 + 产物 + 日志)。
112
+ 2. 质量闸必须可重跑并可追踪证据。
113
+ 3. 恢复策略优先从失败阶段继续,不做整链回滚。
114
+ 4. 默认路径保持单一主链,兼容入口仅作迁移过渡。
1116
115
 
1117
- ### Expected Improvements
116
+ ## References
1118
117
 
1119
- | Metric | Before | After | Improvement |
1120
- |--------|--------|-------|-------------|
1121
- | 并行 Agent 数 | 1 | 3-5 | +400% |
1122
- | 需求完成时间 | 90 min | 50 min | -45% |
1123
- | 任务调度 | 手动 | 自动 | 100% |
1124
- | 质量验证 | 单点 | 分布式 | 100% |
118
+ - 命令索引:`docs/commands/README.md`、`docs/commands/README.zh-CN.md`
119
+ - 版本历史:`README.md`、`README.zh-CN.md`
120
+ - 运行时实现:`bin/harness.js`、`lib/harness/*`
1125
121
 
1126
122
  ---
1127
123
 
1128
- **Last Updated**: 2026-02-07
1129
- **v4.7.0 Module**: Claude Team Integration
124
+ **Last Updated**: 2026-02-18
125
+ **PR-6.3**: Rebuilt CLAUDE L1 doc into concise canonical map + archived history summary.