cc-devflow 2.5.0 → 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 (190) hide show
  1. package/.claude/CLAUDE.md +1065 -53
  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/utility/skill-creator/LICENSE.txt +202 -0
  70. package/.claude/skills/utility/skill-creator/SKILL.md +356 -0
  71. package/.claude/skills/utility/skill-creator/references/output-patterns.md +82 -0
  72. package/.claude/skills/utility/skill-creator/references/workflows.md +28 -0
  73. package/.claude/skills/utility/skill-creator/scripts/init_skill.py +303 -0
  74. package/.claude/skills/utility/skill-creator/scripts/package_skill.py +110 -0
  75. package/.claude/skills/utility/skill-creator/scripts/quick_validate.py +95 -0
  76. package/.claude/skills/workflow/flow-dev/CLAUDE.md +78 -0
  77. package/.claude/skills/workflow/flow-dev/SKILL.md +96 -0
  78. package/.claude/skills/workflow/flow-dev/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +71 -0
  79. package/.claude/skills/workflow/flow-dev/context.jsonl +8 -0
  80. package/.claude/skills/workflow/flow-dev/dev-implementer.jsonl +8 -0
  81. package/.claude/skills/workflow/flow-dev/scripts/entry-gate.sh +116 -0
  82. package/.claude/skills/workflow/flow-dev/scripts/exit-gate.sh +101 -0
  83. package/.claude/skills/workflow/flow-dev/scripts/task-orchestrator.sh +106 -0
  84. package/.claude/skills/workflow/flow-fix/SKILL.md +105 -0
  85. package/.claude/skills/workflow/flow-fix/context.jsonl +6 -0
  86. package/.claude/skills/workflow/flow-fix/references/bug-analyzer.md +381 -0
  87. package/.claude/skills/workflow/flow-init/SKILL.md +211 -0
  88. package/.claude/skills/workflow/flow-init/assets/BRAINSTORM_TEMPLATE.md +148 -0
  89. package/.claude/skills/workflow/flow-init/assets/INIT_FLOW_TEMPLATE.md +198 -0
  90. package/.claude/skills/workflow/flow-init/assets/RESEARCH_TEMPLATE.md +276 -0
  91. package/.claude/skills/workflow/flow-init/context.jsonl +5 -0
  92. package/.claude/skills/workflow/flow-init/references/flow-researcher.md +132 -0
  93. package/.claude/skills/workflow/flow-init/scripts/check-prerequisites.sh +232 -0
  94. package/.claude/skills/workflow/flow-init/scripts/consolidate-research.sh +182 -0
  95. package/.claude/skills/workflow/flow-init/scripts/create-requirement.sh +515 -0
  96. package/.claude/skills/workflow/flow-init/scripts/generate-research-tasks.sh +157 -0
  97. package/.claude/skills/workflow/flow-init/scripts/populate-research-tasks.sh +284 -0
  98. package/.claude/skills/workflow/flow-init/scripts/validate-research.sh +332 -0
  99. package/.claude/skills/workflow/flow-quality/SKILL.md +94 -0
  100. package/.claude/skills/workflow/flow-quality/context.jsonl +6 -0
  101. package/.claude/skills/workflow/flow-quality/references/code-quality-reviewer.md +205 -0
  102. package/.claude/skills/workflow/flow-quality/references/qa-tester.md +313 -0
  103. package/.claude/skills/workflow/flow-quality/references/security-reviewer.md +314 -0
  104. package/.claude/skills/workflow/flow-quality/references/spec-reviewer.md +221 -0
  105. package/.claude/skills/workflow/flow-release/SKILL.md +126 -0
  106. package/.claude/skills/workflow/flow-release/context.jsonl +7 -0
  107. package/.claude/skills/workflow/flow-release/references/release-manager.md +295 -0
  108. package/.claude/skills/workflow/flow-spec/CLAUDE.md +103 -0
  109. package/.claude/skills/workflow/flow-spec/SKILL.md +545 -0
  110. package/.claude/skills/workflow/flow-spec/context.jsonl +7 -0
  111. package/.claude/skills/workflow/flow-spec/scripts/entry-gate.sh +194 -0
  112. package/.claude/skills/workflow/flow-spec/scripts/exit-gate.sh +244 -0
  113. package/.claude/skills/workflow/flow-spec/scripts/parallel-orchestrator.sh +205 -0
  114. package/.claude/skills/workflow/flow-spec/scripts/team-communication.sh +353 -0
  115. package/.claude/skills/workflow/flow-spec/scripts/team-init.sh +195 -0
  116. package/.claude/skills/workflow/flow-spec/scripts/test-team-mode.sh +496 -0
  117. package/.claude/skills/workflow/flow-spec/team-config.json +165 -0
  118. package/.claude/skills/workflow.yaml +417 -0
  119. package/CHANGELOG.md +233 -0
  120. package/README.md +193 -33
  121. package/README.zh-CN.md +206 -46
  122. package/lib/compiler/CLAUDE.md +77 -46
  123. package/lib/compiler/__tests__/multi-module-emitters.test.js +508 -0
  124. package/lib/compiler/context-expander.js +179 -0
  125. package/lib/compiler/emitters/antigravity-emitter.js +195 -5
  126. package/lib/compiler/emitters/base-emitter.js +217 -2
  127. package/lib/compiler/emitters/codex-emitter.js +200 -4
  128. package/lib/compiler/emitters/cursor-emitter.js +307 -3
  129. package/lib/compiler/emitters/qwen-emitter.js +196 -4
  130. package/lib/compiler/index.js +197 -2
  131. package/lib/compiler/platforms.js +270 -21
  132. package/package.json +2 -2
  133. package/.claude/commands/flow-epic.md +0 -183
  134. package/.claude/commands/flow-init.md +0 -370
  135. package/.claude/commands/flow-prd.md +0 -144
  136. package/.claude/commands/flow-qa.md +0 -93
  137. package/.claude/commands/flow-review.md +0 -257
  138. package/.claude/commands/flow-tech.md +0 -142
  139. package/.claude/commands/flow-ui.md +0 -189
  140. package/.claude/skills/file-header-guardian/SKILL.md +0 -56
  141. package/.claude/skills/skill-developer/ADVANCED.md +0 -197
  142. package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +0 -306
  143. package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +0 -152
  144. package/.claude/skills/skill-developer/SKILL.md +0 -426
  145. package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +0 -315
  146. package/.claude/skills/skill-developer/TRIGGER_TYPES.md +0 -305
  147. package/.claude/skills/skill-developer/TROUBLESHOOTING.md +0 -514
  148. package/.claude/skills/writing-skills/SKILL.md +0 -655
  149. package/.claude/skills/writing-skills/anthropic-best-practices.md +0 -1150
  150. package/.claude/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
  151. package/.claude/skills/writing-skills/graphviz-conventions.dot +0 -172
  152. package/.claude/skills/writing-skills/persuasion-principles.md +0 -187
  153. package/.claude/skills/writing-skills/render-graphs.js +0 -168
  154. package/.claude/skills/writing-skills/testing-skills-with-subagents.md +0 -384
  155. package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +0 -1
  156. package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +0 -1
  157. /package/.claude/commands/{core-architecture.md → core/architecture.md} +0 -0
  158. /package/.claude/commands/{core-guidelines.md → core/guidelines.md} +0 -0
  159. /package/.claude/commands/{core-roadmap.md → core/roadmap.md} +0 -0
  160. /package/.claude/commands/{core-style.md → core/style.md} +0 -0
  161. /package/.claude/commands/{flow-checklist.md → flow/checklist.md} +0 -0
  162. /package/.claude/commands/{flow-clarify.md → flow/clarify.md} +0 -0
  163. /package/.claude/commands/{flow-constitution.md → flow/constitution.md} +0 -0
  164. /package/.claude/commands/{flow-fix.md → flow/fix.md} +0 -0
  165. /package/.claude/commands/{flow-ideate.md → flow/ideate.md} +0 -0
  166. /package/.claude/commands/{flow-new.md → flow/new.md} +0 -0
  167. /package/.claude/commands/{flow-release.md → flow/release.md} +0 -0
  168. /package/.claude/commands/{flow-restart.md → flow/restart.md} +0 -0
  169. /package/.claude/commands/{flow-status.md → flow/status.md} +0 -0
  170. /package/.claude/commands/{flow-update.md → flow/update.md} +0 -0
  171. /package/.claude/commands/{flow-upgrade.md → flow/upgrade.md} +0 -0
  172. /package/.claude/commands/{flow-verify.md → flow/verify.md} +0 -0
  173. /package/.claude/commands/{code-review-high.md → util/code-review.md} +0 -0
  174. /package/.claude/commands/{git-commit.md → util/git-commit.md} +0 -0
  175. /package/.claude/commands/{problem-analyzer.md → util/problem-analyzer.md} +0 -0
  176. /package/.claude/skills/{flow-attention-refresh → domain/attention-refresh}/SKILL.md +0 -0
  177. /package/.claude/skills/{flow-brainstorming → domain/brainstorming}/SKILL.md +0 -0
  178. /package/.claude/skills/{flow-debugging → domain/debugging}/SKILL.md +0 -0
  179. /package/.claude/skills/{flow-finishing-branch → domain/finishing-branch}/SKILL.md +0 -0
  180. /package/.claude/skills/{flow-receiving-review → domain/receiving-review}/SKILL.md +0 -0
  181. /package/.claude/skills/{flow-tdd → domain/tdd}/SKILL.md +0 -0
  182. /package/.claude/skills/{verification-before-completion → domain/verification}/SKILL.md +0 -0
  183. /package/.claude/skills/{constitution-guardian → guardrail/constitution-guardian}/SKILL.md +0 -0
  184. /package/.claude/skills/{devflow-tdd-enforcer → guardrail/tdd-enforcer}/SKILL.md +0 -0
  185. /package/.claude/skills/{devflow-constitution-quick-ref → utility/constitution-quick-ref}/SKILL.md +0 -0
  186. /package/.claude/skills/{devflow-file-standards → utility/file-standards}/SKILL.md +0 -0
  187. /package/.claude/skills/{fractal-docs-generator → utility/fractal-docs}/SKILL.md +0 -0
  188. /package/.claude/skills/{journey-coherence-checker → utility/journey-checker}/SKILL.md +0 -0
  189. /package/.claude/skills/{journey-coherence-checker → utility/journey-checker}/pressure-scenarios.md +0 -0
  190. /package/.claude/skills/{npm-release → utility/npm-release}/SKILL.md +0 -0
package/.claude/CLAUDE.md CHANGED
@@ -3,65 +3,180 @@
3
3
  ## Purpose
4
4
  This directory contains Claude Code CLI extensions for the CC-DevFlow development workflow system.
5
5
 
6
- ## Directory Structure
6
+ ## Directory Structure (v4.3 Skills-First Architecture)
7
7
 
8
8
  ```
9
9
  .claude/
10
- ├── agents/ # Agent instruction files (research-type, invoked by commands)
11
- │ ├── checklist-agent.md # Checklist generation logic [NEW: REQ-002]
12
- ├── clarify-analyst.md # Requirements clarification
13
- │ ├── flow-researcher.md # /flow-init mandatory research runner (subagent; file-based memory)
14
- │ ├── prd-writer.md # PRD generation
15
- │ ├── tech-architect.md # Technical design
16
- │ ├── planner.md # EPIC/TASKS planning
17
- │ ├── code-reviewer.md # Code review
18
- │ ├── qa-tester.md # QA testing
19
- │ └── ... # Other agents
10
+ ├── skills/ # Skills 目录 (核心)
11
+ │ ├── workflow.yaml # 工作流依赖图定义 [NEW: v4.0]
12
+
13
+ │ ├── workflow/ # 工作流 Skills [NEW: v4.0]
14
+ ├── flow-init/ # 需求初始化 (支持 worktree)
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/ # 发布管理 (支持 worktree 清理)
27
+ │ │
28
+ │ ├── domain/ # 领域 Skills
29
+ │ │ ├── tdd/ # TDD Iron Law
30
+ │ │ ├── debugging/ # 系统化调试
31
+ │ │ ├── brainstorming/ # 头脑风暴
32
+ │ │ └── using-git-worktrees/ # Git Worktree 管理 [NEW: v4.3] ⭐
33
+ │ │
34
+ │ ├── guardrail/ # 守护 Skills
35
+ │ │ ├── constitution-guardian/
36
+ │ │ └── tdd-enforcer/
37
+ │ │
38
+ │ └── utility/ # 工具 Skills
39
+ │ ├── git-commit/
40
+ │ └── npm-release/
20
41
 
21
- ├── commands/ # Slash command definitions
22
- │ ├── flow-checklist.md # /flow-checklist command [NEW: REQ-002]
23
- │ ├── flow-init.md # /flow-init (modified: research delegated to flow-researcher subagent)
24
- ├── flow-clarify.md # /flow-clarify
25
- ├── flow-prd.md # /flow-prd
26
- ├── flow-tech.md # /flow-tech
27
- │ ├── flow-epic.md # /flow-epic (modified: Checklist Gate)
28
- │ ├── flow-dev.md # /flow-dev (Autonomous by default, /w --manual opt)
29
- └── ... # Other commands
42
+ ├── commands/ # 命令目录 (v4.2 命名空间重构)
43
+ │ ├── flow/ # 工作流命令 (20个) → /flow:xxx
44
+ │ ├── core/ # 核心命令 (4个) /core:xxx
45
+ └── util/ # 工具命令 (4个) → /util:xxx
46
+ ├── agents/ # Agent 指令 (迁移到 skills/*/references/)
47
+ ├── hooks/ # 钩子脚本
48
+ │ ├── inject-skill-context.ts # 上下文注入钩子 [NEW: v4.0]
49
+ │ ├── ralph-loop.ts # Ralph Loop 程序化验证 [NEW: v4.4]
50
+ ├── teammate-idle-hook.ts # Team 任务调度器 [NEW: v4.7] ⭐
51
+ │ ├── task-completed-hook.ts # 任务完成验证器 [NEW: v4.7] ⭐
52
+ │ └── types/
53
+ │ └── team-types.d.ts # Team 状态类型定义 [NEW: v4.7]
54
+ ├── scripts/ # 共享脚本
55
+ │ └── common.sh # 通用函数 (含 worktree 辅助函数)
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/ # 模板
90
+ ```
91
+
92
+ ### context.jsonl 格式
93
+
94
+ ```jsonl
95
+ {"file": "devflow/requirements/{REQ}/BRAINSTORM.md", "reason": "Original intent"}
96
+ {"file": "devflow/spec/frontend/index.md", "reason": "Frontend conventions", "optional": true}
97
+ ```
98
+
99
+ ---
100
+
101
+ ## v4.2.0 Module: Commands Namespace Restructure
102
+
103
+ ### Purpose
104
+
105
+ 将 28 个扁平命令文件重组为 3 个分类目录,采用 Trellis 风格的命名空间调用。
106
+
107
+ ### New Structure
108
+
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
30
132
 
31
- ├── hooks/ # JavaScript hooks for validation/gating
32
- └── checklist-gate.js # Epic entry gate hook [NEW: REQ-002]
133
+ ├── core/ # 核心命令 (4个)
134
+ ├── architecture.md # /core:architecture
135
+ │ ├── guidelines.md # /core:guidelines
136
+ │ ├── roadmap.md # /core:roadmap
137
+ │ └── style.md # /core:style
33
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
+ ```
145
+
146
+ ### Command Migration
147
+
148
+ | 旧命令 | 新命令 |
149
+ |--------|--------|
150
+ | `/flow-init` | `/flow:init` |
151
+ | `/flow-spec` | `/flow:spec` |
152
+ | `/flow-dev` | `/flow:dev` |
153
+ | `/core-architecture` | `/core:architecture` |
154
+ | `/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
34
178
  ├── scripts/ # Bash utility scripts
35
- │ ├── calculate-checklist-completion.sh # Completion calculation [NEW: REQ-002]
36
- │ ├── checklist-errors.sh # Error codes and validation [NEW: REQ-002]
37
- │ ├── common.sh # Shared functions
38
- │ ├── check-prerequisites.sh # Entry gate checks
39
- │ └── ... # Other scripts
40
-
41
- ├── skills/ # Reusable skill definitions
42
- │ ├── fractal-docs-generator/ # 目录级 CLAUDE.md 自动生成
43
- │ │ └── SKILL.md
44
- │ ├── file-header-guardian/ # 文件头注释 @input/@output/@pos 守护
45
- │ │ └── SKILL.md
46
- │ ├── flow-attention-refresh/ # 注意力刷新协议 [NEW: v2.3.0 Ralph × Manus]
47
- │ │ └── SKILL.md
48
- │ ├── flow-tdd/ # TDD enforcement (modified: Error Recording)
49
- │ │ └── SKILL.md
50
- │ ├── cc-devflow-orchestrator/
51
- │ │ └── SKILL.md # Workflow router (modified: /flow-checklist, /flow-dev autonomous)
52
- │ ├── journey-coherence-checker/ # 跨需求一致性检查 [NEW: v2.4.0]
53
- │ │ ├── SKILL.md # 检查协议:依赖满足、旅程完整、累积偏差
54
- │ │ └── pressure-scenarios.md # TDD 压力测试场景
55
- │ ├── npm-release/ # NPM 包发布工作流
56
- │ │ └── SKILL.md # 版本发布、Changelog 维护、原子化发布流程
57
- │ └── ...
58
-
59
- └── docs/
60
- └── templates/
61
- ├── CHECKLIST_TEMPLATE.md # Checklist output template [NEW: REQ-002]
62
- ├── ERROR_LOG_TEMPLATE.md # Error log template [NEW: v2.3.0 Ralph × Manus]
63
- ├── ATTEMPT_TEMPLATE.md # Research attempt template [NEW: v2.3.0 Ralph × Manus]
64
- └── ... # Other templates
179
+ └── docs/templates/ # Templates
65
180
  ```
66
181
 
67
182
  ## REQ-002 Module: /flow-checklist
@@ -204,5 +319,902 @@ Combine Ralph-Wiggum's autonomous iteration loop with Manus-style Planning-with-
204
319
 
205
320
  ---
206
321
 
207
- **Last Updated**: 2026-01-08
322
+ **Last Updated**: 2026-02-06
208
323
  **v2.3.0 Module**: Ralph × Manus Integration
324
+
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 并行执行潜力。
436
+
437
+ ### Key Changes
438
+
439
+ | Before (v4.0) | After (v4.1) | Improvement |
440
+ |---------------|--------------|-------------|
441
+ | 4 个独立命令 | 1 个统一命令 | -75% 命令数 |
442
+ | 串行执行 | Tech + UI 并行 | -35% 时间 |
443
+ | 重复 Entry/Exit Gate | 统一 Gate | -280 行代码 |
444
+
445
+ ### New Command: /flow-spec
446
+
447
+ ```bash
448
+ # Full Mode (默认)
449
+ /flow-spec "REQ-123"
450
+
451
+ # Quick Mode (小需求)
452
+ /flow-spec "REQ-123" --skip-tech --skip-ui
453
+
454
+ # Backend Only
455
+ /flow-spec "REQ-123" --skip-ui
456
+
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
521
+
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% |
527
+
528
+ ---
529
+
530
+ **Last Updated**: 2026-02-07
531
+ **v4.1.0 Module**: Unified Specification Phase
532
+
533
+ ---
534
+
535
+ ## v4.3.0 Module: Git Worktree Integration
536
+
537
+ ### Purpose
538
+
539
+ 将所有 Git 分支操作改为 Git Worktree 方式,支持 3-5 个并行 Claude Code 会话,借鉴官方最佳实践。
540
+
541
+ ### Key Changes
542
+
543
+ | Before (v4.2) | After (v4.3) | Improvement |
544
+ |---------------|--------------|-------------|
545
+ | 传统分支切换 | Worktree 隔离 | 并行开发 |
546
+ | stash/checkout | cd 切换 | 切换时间 -97% |
547
+ | 单一 Claude 会话 | 多会话并行 | 效率 +200% |
548
+
549
+ ### Worktree Directory Layout
550
+
551
+ ```
552
+ ~/projects/
553
+ ├── cc-devflow/ # 主仓库 (main 分支)
554
+ ├── cc-devflow-REQ-001/ # REQ-001 worktree
555
+ ├── cc-devflow-REQ-002/ # REQ-002 worktree
556
+ ├── cc-devflow-analysis/ # 只读分析 worktree (可选)
557
+ └── cc-devflow-hotfix/ # 紧急修复 worktree (可选)
558
+ ```
559
+
560
+ ### New Skill: using-git-worktrees
561
+
562
+ ```
563
+ .claude/skills/domain/using-git-worktrees/
564
+ ├── SKILL.md # 核心指令 (~200 行)
565
+ ├── context.jsonl # 上下文定义
566
+ ├── scripts/
567
+ │ ├── worktree-create.sh # 创建 worktree
568
+ │ ├── worktree-list.sh # 列出 worktree
569
+ │ ├── worktree-switch.sh # 切换 worktree
570
+ │ ├── worktree-cleanup.sh # 清理 worktree
571
+ │ └── worktree-status.sh # 状态检查
572
+ └── assets/
573
+ └── SHELL_ALIASES.md # Shell 别名模板
574
+ ```
575
+
576
+ ### Modified Commands
577
+
578
+ | Command | Change |
579
+ |---------|--------|
580
+ | `/flow-init` | 默认使用 worktree 模式,`--branch-only` 兼容旧模式 |
581
+ | `/flow-release` | 自动清理 worktree |
582
+
583
+ ### Shell Aliases (Recommended)
584
+
585
+ ```bash
586
+ alias za='cd $(git rev-parse --show-toplevel 2>/dev/null || echo .)'
587
+ alias zl='git worktree list'
588
+ alias zm='cd ~/projects/cc-devflow'
589
+
590
+ zw() {
591
+ local req_id="${1:-}"
592
+ local repo_name=$(basename $(git rev-parse --show-toplevel 2>/dev/null))
593
+ cd ~/projects/${repo_name}-${req_id}
594
+ }
595
+ ```
596
+
597
+ ### New common.sh Functions
598
+
599
+ | Function | Purpose |
600
+ |----------|---------|
601
+ | `is_in_worktree()` | 检测是否在 worktree 中 |
602
+ | `get_main_repo_path()` | 获取主仓库路径 |
603
+ | `get_worktree_path()` | 获取当前 worktree 路径 |
604
+ | `get_worktree_dir_for_req()` | 获取指定 REQ 的 worktree 目录 |
605
+ | `worktree_exists_for_req()` | 检查 worktree 是否存在 |
606
+ | `get_req_id_from_worktree()` | 从 worktree 路径提取 REQ-ID |
607
+ | `list_worktrees_with_req()` | 列出所有 worktree 及其 REQ-ID |
608
+
609
+ ### Expected Improvements
610
+
611
+ | Metric | Before | After | Improvement |
612
+ |--------|--------|-------|-------------|
613
+ | 并行需求数 | 1 | 3-5 | +400% |
614
+ | 上下文切换时间 | 30s | 1s | -97% |
615
+ | 紧急修复响应 | 需要 stash | 直接新建 | 即时 |
616
+ | Claude 会话隔离 | 无 | 完全隔离 | 100% |
617
+
618
+ ---
619
+
620
+ **Last Updated**: 2026-02-07
621
+ **v4.3.0 Module**: Git Worktree Integration
622
+
623
+ ---
624
+
625
+ ## v4.4.0 Module: Ralph Loop Programmatic Verification
626
+
627
+ ### Purpose
628
+
629
+ 实现 SubagentStop Hook 拦截验证机制,在子 Agent 尝试停止时执行程序化验证,确保代码质量。借鉴 Trellis 的 Ralph Loop 设计。
630
+
631
+ ### Key Changes
632
+
633
+ | Before (v4.3) | After (v4.4) | Improvement |
634
+ |---------------|--------------|-------------|
635
+ | 无自动验证 | SubagentStop 拦截 | 质量保证 |
636
+ | 手动检查 | 程序化验证 | 自动化 |
637
+ | 无迭代控制 | 最大迭代限制 | 防止无限循环 |
638
+
639
+ ### New Files
640
+
641
+ | File | Purpose |
642
+ |------|---------|
643
+ | `.claude/hooks/ralph-loop.ts` | SubagentStop Hook 主逻辑 (~350 行) |
644
+ | `.ralph-state.json` | 运行时状态文件 (自动生成) |
645
+
646
+ ### Configuration
647
+
648
+ `quality-gates.yml` 新增配置:
649
+
650
+ ```yaml
651
+ # 顶级 verify 命令 (SubagentStop 时执行)
652
+ verify:
653
+ - npm run lint --if-present
654
+ - npm run typecheck --if-present
655
+ - npm test -- --passWithNoTests
656
+
657
+ ralph_loop:
658
+ max_iterations: 5 # 最大迭代次数
659
+ timeout_minutes: 30 # 超时时间
660
+ ```
661
+
662
+ ### Hook Registration
663
+
664
+ `settings.json` 新增:
665
+
666
+ ```json
667
+ {
668
+ "hooks": {
669
+ "SubagentStop": [
670
+ {
671
+ "hooks": [
672
+ {
673
+ "type": "command",
674
+ "command": "npx ts-node $CLAUDE_PROJECT_DIR/.claude/hooks/ralph-loop.ts"
675
+ }
676
+ ]
677
+ }
678
+ ]
679
+ }
680
+ }
681
+ ```
682
+
683
+ ### State File Format
684
+
685
+ `.ralph-state.json`:
686
+
687
+ ```json
688
+ {
689
+ "agent_id": "session-xxx",
690
+ "iteration": 2,
691
+ "last_failures": [
692
+ {
693
+ "command": "npm run lint",
694
+ "output": "error: ...",
695
+ "timestamp": "2026-02-07T06:00:00Z"
696
+ }
697
+ ],
698
+ "started_at": "2026-02-07T06:00:00Z"
699
+ }
700
+ ```
701
+
702
+ ### Execution Flow
703
+
704
+ ```
705
+ SubagentStop Event
706
+
707
+
708
+ ┌──────────────────┐
709
+ │ Load State │
710
+ │ Check Timeout │
711
+ └────────┬─────────┘
712
+
713
+
714
+ ┌──────────────────┐
715
+ │ Check Max Iter │──── Reached ──▶ Allow Stop
716
+ └────────┬─────────┘
717
+
718
+
719
+ ┌──────────────────┐
720
+ │ Run Verify Cmds │
721
+ └────────┬─────────┘
722
+
723
+ ┌────┴────┐
724
+ │ │
725
+ Pass Fail
726
+ │ │
727
+ ▼ ▼
728
+ Allow Block
729
+ Stop Stop
730
+ (return errors)
731
+ ```
732
+
733
+ ### Expected Improvements
734
+
735
+ | Metric | Before | After | Improvement |
736
+ |--------|--------|-------|-------------|
737
+ | 代码质量保证 | 手动 | 自动 | 100% |
738
+ | 验证遗漏率 | ~20% | ~0% | -100% |
739
+ | 无限循环风险 | 存在 | 受控 | 安全 |
740
+
741
+ ---
742
+
743
+ **Last Updated**: 2026-02-07
744
+ **v4.4.0 Module**: Ralph Loop Programmatic Verification
745
+
746
+ ---
747
+
748
+ ## v4.5.0 Module: Delta Specs Enhancement
749
+
750
+ ### Purpose
751
+
752
+ 增强 Delta Specs 机制,借鉴 OpenSpec 的设计,实现完整的增量规格管理。支持 ADDED/MODIFIED/REMOVED/RENAMED 四种操作,提供 TypeScript 解析器和完整的 CLI 工具链。
753
+
754
+ ### Key Changes
755
+
756
+ | Before (v4.4) | After (v4.5) | Improvement |
757
+ |---------------|--------------|-------------|
758
+ | 简单复制 | 真正的 delta 应用 | 精确变更 |
759
+ | 3 个子命令 | 4 个子命令 | 完整功能 |
760
+ | Bash 解析 | TypeScript 解析器 | 可靠性 |
761
+ | 无状态管理 | 状态工作流 | 可追溯 |
762
+
763
+ ### New Command: /flow:delta
764
+
765
+ ```bash
766
+ # Create a new delta spec
767
+ /flow:delta create "REQ-123" "add-2fa"
768
+
769
+ # List all deltas for a requirement
770
+ /flow:delta list "REQ-123"
771
+
772
+ # Apply delta to main specs (PRD.md)
773
+ /flow:delta apply "REQ-123" "add-2fa"
774
+
775
+ # Check delta status
776
+ /flow:delta status "REQ-123" "add-2fa"
777
+ ```
778
+
779
+ ### Delta Spec Format (OpenSpec-style)
780
+
781
+ ```markdown
782
+ ---
783
+ delta_id: "2026-02-01-add-2fa"
784
+ req_id: "REQ-123"
785
+ title: "Add 2FA Support"
786
+ created_at: "2026-02-01T10:00:00Z"
787
+ status: "draft|review|approved|applied"
788
+ ---
789
+
790
+ # Delta: Add 2FA Support
791
+
792
+ ## ADDED Requirements
793
+ ### Requirement: Two-Factor Authentication
794
+ #### Scenario: Enable 2FA
795
+ - GIVEN user is logged in
796
+ - WHEN user enables 2FA
797
+ - THEN system generates QR code
798
+
799
+ ## MODIFIED Requirements
800
+ ### Requirement: User Login
801
+ (Previously: old description)
802
+
803
+ ## REMOVED Requirements
804
+ ### Requirement: Legacy Session
805
+ **Reason**: Replaced by JWT
806
+ **Migration**: Run migration script
807
+
808
+ ## RENAMED Requirements
809
+ - FROM: Old Name
810
+ - TO: New Name
811
+ ```
812
+
813
+ ### New Files
814
+
815
+ | File | Purpose |
816
+ |------|---------|
817
+ | `.claude/scripts/delta-parser.ts` | TypeScript Delta 解析器 (~400 行) |
818
+ | `.claude/scripts/flow-delta-create.sh` | 创建 delta 目录和文件 |
819
+ | `.claude/scripts/flow-delta-list.sh` | 列出所有 deltas |
820
+ | `.claude/scripts/flow-delta-apply.sh` | 应用 delta 到 PRD.md |
821
+ | `.claude/scripts/flow-delta-status.sh` | 检查 delta 状态 |
822
+ | `.claude/docs/templates/DELTA_SPEC_TEMPLATE.md` | Delta 模板 (OpenSpec 格式) |
823
+
824
+ ### Directory Structure
825
+
826
+ ```
827
+ devflow/requirements/REQ-123/
828
+ ├── PRD.md # Main specification (SSOT)
829
+ ├── deltas/ # Delta specs directory
830
+ │ ├── 2026-02-01-add-2fa/
831
+ │ │ ├── delta.md # Delta specification
832
+ │ │ └── tasks.md # Delta-specific tasks
833
+ │ └── 2026-02-05-fix-login/
834
+ │ ├── delta.md
835
+ │ └── tasks.md
836
+ └── ...
837
+
838
+ devflow/archive/
839
+ └── 2026-02/
840
+ └── REQ-123/
841
+ └── deltas/ # Archived deltas
842
+ ```
843
+
844
+ ### Status Workflow
845
+
846
+ ```
847
+ draft → review → approved → applied
848
+ │ │ │
849
+ │ │ └── /flow:delta apply
850
+ │ │
851
+ │ └── Manual review approval
852
+
853
+ └── /flow:delta create
854
+ ```
855
+
856
+ ### TypeScript Parser API
857
+
858
+ ```typescript
859
+ interface DeltaBlock {
860
+ type: 'ADDED' | 'MODIFIED' | 'REMOVED' | 'RENAMED';
861
+ name: string;
862
+ content: string;
863
+ previousContent?: string; // for MODIFIED
864
+ reason?: string; // for REMOVED
865
+ newName?: string; // for RENAMED
866
+ }
867
+
868
+ function parseDelta(content: string): DeltaBlock[];
869
+ function applyDelta(prdContent: string, delta: DeltaBlock[]): string;
870
+ ```
871
+
872
+ ### Integration Points
873
+
874
+ | Integration | Description |
875
+ |-------------|-------------|
876
+ | `/flow:spec` | 生成 delta 而非直接修改 PRD |
877
+ | `/flow:release` | 应用所有 approved deltas |
878
+ | `/flow:archive` | 归档 applied deltas |
879
+
880
+ ### Expected Improvements
881
+
882
+ | Metric | Before | After | Improvement |
883
+ |--------|--------|-------|-------------|
884
+ | 变更追溯性 | 无 | 完整 | 100% |
885
+ | 冲突检测 | 无 | 自动 | 100% |
886
+ | 回滚能力 | 手动 | 自动 | 100% |
887
+ | 审核流程 | 无 | 状态驱动 | 100% |
888
+
889
+ ---
890
+
891
+ **Last Updated**: 2026-02-07
892
+ **v4.5.0 Module**: Delta Specs Enhancement
893
+
894
+ ---
895
+
896
+ ## v4.6.0 Module: Archive System Enhancement
897
+
898
+ ### Purpose
899
+
900
+ 增强归档系统,集成 Delta Specs 支持,提供完整的需求生命周期管理。
901
+
902
+ ### Key Changes
903
+
904
+ | Before (v4.5) | After (v4.6) | Improvement |
905
+ |---------------|--------------|-------------|
906
+ | 简单移动目录 | Delta Specs 检查 | 完整性保证 |
907
+ | 无警告机制 | 未应用 delta 警告 | 防止遗漏 |
908
+ | 基础状态记录 | deltaCount 字段 | 可追溯性 |
909
+
910
+ ### New Features
911
+
912
+ #### 1. Delta Specs 检查
913
+
914
+ 归档前自动检测:
915
+ - 检查 `deltas/` 目录是否存在
916
+ - 统计 Delta Specs 数量
917
+ - 警告未应用的 Delta Specs (status != "applied")
918
+
919
+ #### 2. 增强的状态记录
920
+
921
+ ```json
922
+ {
923
+ "status": "archived",
924
+ "archivedReason": "completed",
925
+ "archivedAt": "2026-02-07T10:00:00+08:00",
926
+ "archiveLocation": "devflow/archive/2026-02/REQ-123",
927
+ "statusBeforeArchive": "release_complete",
928
+ "deltaCount": 3
929
+ }
930
+ ```
931
+
932
+ #### 3. 新增 common.sh 函数
933
+
934
+ | Function | Purpose |
935
+ |----------|---------|
936
+ | `get_archive_summary()` | 获取归档需求的 JSON 摘要 |
937
+ | `has_deltas_to_archive()` | 检查是否有 deltas 需要归档 |
938
+ | `get_delta_count()` | 获取 delta 数量 |
939
+
940
+ ### Archive Directory Structure
941
+
942
+ ```
943
+ devflow/archive/
944
+ ├── 2026-01/ # 按月组织
945
+ │ ├── REQ-001/
946
+ │ │ ├── PRD.md
947
+ │ │ ├── EPIC.md
948
+ │ │ ├── TASKS.md
949
+ │ │ ├── deltas/ # Delta Specs 完整保留
950
+ │ │ │ └── 2026-01-15-add-feature/
951
+ │ │ │ ├── delta.md
952
+ │ │ │ └── tasks.md
953
+ │ │ ├── orchestration_status.json
954
+ │ │ └── ...
955
+ │ └── REQ-002/
956
+ └── 2026-02/
957
+ └── REQ-003/
958
+ ```
959
+
960
+ ### Command Usage
961
+
962
+ ```bash
963
+ # 归档需求 (自动检测 Delta Specs)
964
+ /flow:archive "REQ-123"
965
+
966
+ # 预览归档 (显示 Delta Specs 信息)
967
+ /flow:archive "REQ-123" --dry-run
968
+
969
+ # 列出所有归档
970
+ /flow:archive --list
971
+
972
+ # 恢复归档
973
+ /flow:archive "REQ-123" --restore
974
+ ```
975
+
976
+ ### Integration Points
977
+
978
+ | Integration | Description |
979
+ |-------------|-------------|
980
+ | `/flow:release` | 发布后自动触发归档 |
981
+ | `/flow:delta` | 归档前检查未应用的 deltas |
982
+ | `/flow:status` | 显示归档状态 |
983
+
984
+ ### Expected Improvements
985
+
986
+ | Metric | Before | After | Improvement |
987
+ |--------|--------|-------|-------------|
988
+ | Delta 遗漏率 | ~15% | ~0% | -100% |
989
+ | 归档完整性 | 基础 | 完整 | 100% |
990
+ | 可追溯性 | 有限 | 完整 | 100% |
991
+
992
+ ---
993
+
994
+ **Last Updated**: 2026-02-07
995
+ **v4.6.0 Module**: Archive System Enhancement
996
+
997
+ ---
998
+
999
+ ## v4.7.0 Module: Claude Team Integration
1000
+
1001
+ ### Purpose
1002
+
1003
+ 集成 Claude Team 功能,支持多 Agent 并行协作开发。实现 TeammateIdle 和 TaskCompleted Hook,扩展状态管理支持 Team 模式。
1004
+
1005
+ ### Key Changes
1006
+
1007
+ | Before (v4.6) | After (v4.7) | Improvement |
1008
+ |---------------|--------------|-------------|
1009
+ | 单 Agent 执行 | 多 Agent 并行 | 效率 +200% |
1010
+ | 无 Team 状态 | 完整 Team 状态管理 | 可追溯 |
1011
+ | 单一 Ralph Loop | 多 Teammate Ralph Loop | 分布式验证 |
1012
+
1013
+ ### New Hooks
1014
+
1015
+ | Hook | File | Trigger | Purpose |
1016
+ |------|------|---------|---------|
1017
+ | **TeammateIdle** | `teammate-idle-hook.ts` | Teammate 空闲时 | 任务分配和调度 |
1018
+ | **TaskCompleted** | `task-completed-hook.ts` | 任务完成时 | 质量验证和状态更新 |
1019
+
1020
+ ### TeammateIdle Hook 工作流程
1021
+
1022
+ ```
1023
+ TeammateIdle Event
1024
+
1025
+ 验证 last_task_id (如有)
1026
+
1027
+ 验证失败 → 返回 assign_task (继续修复)
1028
+ 验证通过 → 标记任务完成
1029
+
1030
+ 查找下一个未分配任务
1031
+
1032
+ 有任务 → 返回 assign_task
1033
+ 无任务 + 所有 Teammate 空闲 → 返回 shutdown
1034
+ 无任务 + 有 Teammate 工作中 → 返回 wait
1035
+ ```
1036
+
1037
+ ### TaskCompleted Hook 工作流程
1038
+
1039
+ ```
1040
+ TaskCompleted Event
1041
+
1042
+ 执行 task_completed.verify 命令
1043
+
1044
+ ├── 通过 → accept + 更新 Team 状态
1045
+ └── 失败 → block_on_failure?
1046
+ ├── true → reject
1047
+ └── false → accept (with warning)
1048
+
1049
+ 记录失败到 ERROR_LOG.md
1050
+
1051
+ 检查阶段转换
1052
+ ```
1053
+
1054
+ ### orchestration_status.json 扩展
1055
+
1056
+ ```json
1057
+ {
1058
+ "reqId": "REQ-007",
1059
+ "status": "in_progress",
1060
+ "phase": "development",
1061
+
1062
+ "team": {
1063
+ "mode": "parallel",
1064
+ "lead": "team-lead",
1065
+ "teammates": [
1066
+ {
1067
+ "id": "dev-analyst",
1068
+ "role": "developer",
1069
+ "status": "working",
1070
+ "currentTask": "T001",
1071
+ "completedTasks": ["T000"],
1072
+ "lastActiveAt": "2026-02-07T10:00:00Z"
1073
+ }
1074
+ ],
1075
+ "taskAssignments": {
1076
+ "T001": "dev-analyst"
1077
+ }
1078
+ },
1079
+
1080
+ "ralphLoop": {
1081
+ "enabled": true,
1082
+ "teammates": {
1083
+ "dev-analyst": {
1084
+ "iteration": 2,
1085
+ "lastVerifyResult": "passed"
1086
+ }
1087
+ },
1088
+ "globalIteration": 3,
1089
+ "maxIterations": 10
1090
+ }
1091
+ }
1092
+ ```
1093
+
1094
+ ### New Files
1095
+
1096
+ | File | Purpose |
1097
+ |------|---------|
1098
+ | `.claude/hooks/teammate-idle-hook.ts` | TeammateIdle Hook 实现 |
1099
+ | `.claude/hooks/task-completed-hook.ts` | TaskCompleted Hook 实现 |
1100
+ | `.claude/hooks/types/team-types.d.ts` | Team 状态 TypeScript 类型 |
1101
+ | `.claude/scripts/parse-task-dependencies.js` | TASKS.md 任务依赖解析器 |
1102
+ | `.claude/scripts/detect-file-conflicts.sh` | 并行任务文件冲突检测 |
1103
+ | `.claude/scripts/team-dev-init.sh` | flow-dev Team 模式初始化 |
1104
+ | `.claude/skills/workflow/flow-spec/scripts/team-init.sh` | flow-spec Team 模式初始化 |
1105
+ | `.claude/skills/workflow/flow-spec/scripts/team-communication.sh` | Teammate 通信协议 |
1106
+ | `.claude/skills/workflow/flow-spec/team-config.json` | spec-design-team 配置 |
1107
+ | `.claude/docs/templates/DESIGN_DECISIONS_TEMPLATE.md` | 设计决策记录模板 |
1108
+
1109
+ ### common.sh 新增函数
1110
+
1111
+ | Function | Purpose |
1112
+ |----------|---------|
1113
+ | `is_team_mode_enabled()` | 检查 Team 模式是否启用 |
1114
+ | `init_team_state()` | 初始化 Team 状态 |
1115
+ | `add_teammate()` | 添加 Teammate |
1116
+ | `update_teammate_status()` | 更新 Teammate 状态 |
1117
+ | `mark_teammate_task_complete()` | 标记任务完成 |
1118
+ | `assign_task_to_teammate()` | 分配任务 |
1119
+ | `get_unassigned_tasks()` | 获取未分配任务 |
1120
+ | `update_teammate_ralph_state()` | 更新 Ralph 状态 |
1121
+ | `all_teammates_idle()` | 检查所有 Teammate 空闲 |
1122
+ | `cleanup_team_state()` | 清理 Team 状态 |
1123
+
1124
+ ### flow-dev Team 模式命令
1125
+
1126
+ ```bash
1127
+ # 启用 Team 模式 (默认 3 个 Agent)
1128
+ /flow:dev "REQ-123" --team
1129
+
1130
+ # 指定 Agent 数量 (2-5)
1131
+ /flow:dev "REQ-123" --team --agents 5
1132
+
1133
+ # Team 模式执行流程
1134
+ # 1. 解析 TASKS.md 获取任务依赖
1135
+ # 2. 检测文件冲突,分配任务给 Agent
1136
+ # 3. 并行执行无冲突任务
1137
+ # 4. 冲突任务分配给同一 Agent 串行执行
1138
+ # 5. TeammateIdle Hook 自动分配下一任务
1139
+ # 6. 所有任务完成后 shutdown
1140
+ ```
1141
+
1142
+ ### Task Dependency Parser (parse-task-dependencies.js)
1143
+
1144
+ ```bash
1145
+ # 解析 TASKS.md
1146
+ node .claude/scripts/parse-task-dependencies.js parse TASKS.md
1147
+
1148
+ # 获取并行分组
1149
+ node .claude/scripts/parse-task-dependencies.js groups TASKS.md
1150
+
1151
+ # 获取下一批可执行任务
1152
+ node .claude/scripts/parse-task-dependencies.js next TASKS.md
1153
+
1154
+ # 输出格式
1155
+ {
1156
+ "tasks": [
1157
+ {"id": "T001", "phase": 1, "parallel": true, "userStory": "US1", "filePath": "src/user.ts"}
1158
+ ],
1159
+ "parallelGroups": [["T001", "T002"], ["T003"]],
1160
+ "stats": {"total": 10, "completed": 3, "pending": 7}
1161
+ }
1162
+ ```
1163
+
1164
+ ### File Conflict Detection (detect-file-conflicts.sh)
1165
+
1166
+ ```bash
1167
+ # 检测文件冲突
1168
+ echo '{"tasks": [...]}' | .claude/scripts/detect-file-conflicts.sh
1169
+
1170
+ # 输出格式
1171
+ {
1172
+ "hasConflicts": true,
1173
+ "conflicts": [{"file": "src/user.ts", "tasks": ["T001", "T002"]}],
1174
+ "safeGroups": [{"tasks": ["T003", "T004"]}]
1175
+ }
1176
+ ```
1177
+
1178
+ ### quality-gates.yml 新增配置
1179
+
1180
+ ```yaml
1181
+ # TeammateIdle Hook 配置
1182
+ teammate_idle:
1183
+ idle_checks:
1184
+ - npm run lint --if-present
1185
+ - npm run typecheck --if-present
1186
+ assignment_strategy: priority_first
1187
+ idle_timeout: 300
1188
+
1189
+ # TaskCompleted Hook 配置
1190
+ task_completed:
1191
+ verify:
1192
+ - npm run lint --if-present
1193
+ - npm run typecheck --if-present
1194
+ - npm test -- --passWithNoTests
1195
+ block_on_failure: true
1196
+ max_retries: 3
1197
+
1198
+ # Ralph Loop Team 模式配置
1199
+ ralph_loop:
1200
+ team_mode:
1201
+ enabled: true
1202
+ scope: teammate
1203
+ max_iterations_per_teammate: 3
1204
+ max_global_iterations: 10
1205
+ ```
1206
+
1207
+ ### Expected Improvements
1208
+
1209
+ | Metric | Before | After | Improvement |
1210
+ |--------|--------|-------|-------------|
1211
+ | 并行 Agent 数 | 1 | 3-5 | +400% |
1212
+ | 需求完成时间 | 90 min | 50 min | -45% |
1213
+ | 任务调度 | 手动 | 自动 | 100% |
1214
+ | 质量验证 | 单点 | 分布式 | 100% |
1215
+
1216
+ ---
1217
+
1218
+ **Last Updated**: 2026-02-07
1219
+ **v4.7.0 Module**: Claude Team Integration
1220
+