cc-devflow 2.4.6 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/.claude/CLAUDE.md +1065 -48
  2. package/.claude/agents/dev-implementer.md +195 -0
  3. package/.claude/commands/{flow-archive.md → flow/archive.md} +46 -11
  4. package/.claude/commands/flow/context.md +150 -0
  5. package/.claude/commands/flow/delta.md +245 -0
  6. package/.claude/commands/{flow-dev.md → flow/dev.md} +112 -11
  7. package/.claude/commands/flow/init.md +45 -0
  8. package/.claude/commands/flow/quality.md +159 -0
  9. package/.claude/commands/flow/spec.md +186 -0
  10. package/.claude/commands/flow/workspace.md +146 -0
  11. package/.claude/commands/{cancel-ralph.md → util/cancel-ralph.md} +1 -0
  12. package/.claude/config/quality-gates.yml +305 -0
  13. package/.claude/docs/guides/TEAM_MODE_GUIDE.md +313 -0
  14. package/.claude/docs/templates/DELTA_SPEC_TEMPLATE.md +91 -0
  15. package/.claude/docs/templates/DESIGN_DECISIONS_TEMPLATE.md +151 -0
  16. package/.claude/docs/templates/JOURNAL_TEMPLATE.md +75 -0
  17. package/.claude/docs/templates/_shared/CLAUDE.md +36 -0
  18. package/.claude/docs/templates/_shared/CONSTITUTION_CHECK.md +125 -0
  19. package/.claude/docs/templates/_shared/VALIDATION_CHECKLIST.md +187 -0
  20. package/.claude/docs/templates/_shared/YAML_FRONTMATTER.md +164 -0
  21. package/.claude/docs/templates/context/dev.jsonl.template +6 -0
  22. package/.claude/docs/templates/context/epic.jsonl.template +5 -0
  23. package/.claude/docs/templates/context/prd.jsonl.template +4 -0
  24. package/.claude/docs/templates/context/research.jsonl.template +4 -0
  25. package/.claude/docs/templates/context/review.jsonl.template +5 -0
  26. package/.claude/docs/templates/context/tech.jsonl.template +5 -0
  27. package/.claude/hooks/CLAUDE.md +342 -0
  28. package/.claude/hooks/inject-agent-context.ts +480 -0
  29. package/.claude/hooks/inject-skill-context.ts +359 -0
  30. package/.claude/hooks/ralph-loop.ts +931 -0
  31. package/.claude/hooks/task-completed-hook.ts +593 -0
  32. package/.claude/hooks/teammate-idle-hook.ts +690 -0
  33. package/.claude/hooks/types/team-types.d.ts +238 -0
  34. package/.claude/rules/devflow-conventions.md +82 -9
  35. package/.claude/scripts/archive-requirement.sh +44 -1
  36. package/.claude/scripts/common.sh +670 -3
  37. package/.claude/scripts/delta-parser.ts +527 -0
  38. package/.claude/scripts/detect-file-conflicts.sh +151 -0
  39. package/.claude/scripts/flow-context-add.sh +134 -0
  40. package/.claude/scripts/flow-context-init.sh +133 -0
  41. package/.claude/scripts/flow-context-validate.sh +144 -0
  42. package/.claude/scripts/flow-delta-apply.sh +297 -0
  43. package/.claude/scripts/flow-delta-archive.sh +71 -0
  44. package/.claude/scripts/flow-delta-create.sh +202 -0
  45. package/.claude/scripts/flow-delta-list.sh +142 -0
  46. package/.claude/scripts/flow-delta-status.sh +235 -0
  47. package/.claude/scripts/flow-quality-full.sh +184 -0
  48. package/.claude/scripts/flow-quality-quick.sh +64 -0
  49. package/.claude/scripts/flow-workspace-init.sh +117 -0
  50. package/.claude/scripts/flow-workspace-record.sh +164 -0
  51. package/.claude/scripts/flow-workspace-start.sh +88 -0
  52. package/.claude/scripts/get-workflow-status.sh +415 -0
  53. package/.claude/scripts/parse-task-dependencies.js +334 -0
  54. package/.claude/scripts/record-quality-error.sh +165 -0
  55. package/.claude/scripts/run-quality-gates.sh +242 -0
  56. package/.claude/scripts/team-dev-init.sh +319 -0
  57. package/.claude/scripts/team-state-recovery.sh +229 -0
  58. package/.claude/scripts/workflow-status.ts +433 -0
  59. package/.claude/settings.json +19 -0
  60. package/.claude/skills/cc-devflow-orchestrator/SKILL.md +85 -200
  61. package/.claude/skills/domain/using-git-worktrees/SKILL.md +252 -0
  62. package/.claude/skills/domain/using-git-worktrees/assets/SHELL_ALIASES.md +133 -0
  63. package/.claude/skills/domain/using-git-worktrees/context.jsonl +4 -0
  64. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-cleanup.sh +218 -0
  65. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-create.sh +232 -0
  66. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-list.sh +130 -0
  67. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-status.sh +140 -0
  68. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-switch.sh +70 -0
  69. package/.claude/skills/skill-rules.json +72 -1
  70. package/.claude/skills/utility/journey-checker/SKILL.md +199 -0
  71. package/.claude/skills/utility/journey-checker/pressure-scenarios.md +164 -0
  72. package/.claude/skills/utility/skill-creator/LICENSE.txt +202 -0
  73. package/.claude/skills/utility/skill-creator/SKILL.md +356 -0
  74. package/.claude/skills/utility/skill-creator/references/output-patterns.md +82 -0
  75. package/.claude/skills/utility/skill-creator/references/workflows.md +28 -0
  76. package/.claude/skills/utility/skill-creator/scripts/init_skill.py +303 -0
  77. package/.claude/skills/utility/skill-creator/scripts/package_skill.py +110 -0
  78. package/.claude/skills/utility/skill-creator/scripts/quick_validate.py +95 -0
  79. package/.claude/skills/workflow/flow-dev/CLAUDE.md +78 -0
  80. package/.claude/skills/workflow/flow-dev/SKILL.md +96 -0
  81. package/.claude/skills/workflow/flow-dev/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +71 -0
  82. package/.claude/skills/workflow/flow-dev/context.jsonl +8 -0
  83. package/.claude/skills/workflow/flow-dev/dev-implementer.jsonl +8 -0
  84. package/.claude/skills/workflow/flow-dev/scripts/entry-gate.sh +116 -0
  85. package/.claude/skills/workflow/flow-dev/scripts/exit-gate.sh +101 -0
  86. package/.claude/skills/workflow/flow-dev/scripts/task-orchestrator.sh +106 -0
  87. package/.claude/skills/workflow/flow-fix/SKILL.md +105 -0
  88. package/.claude/skills/workflow/flow-fix/context.jsonl +6 -0
  89. package/.claude/skills/workflow/flow-fix/references/bug-analyzer.md +381 -0
  90. package/.claude/skills/workflow/flow-init/SKILL.md +211 -0
  91. package/.claude/skills/workflow/flow-init/assets/BRAINSTORM_TEMPLATE.md +148 -0
  92. package/.claude/skills/workflow/flow-init/assets/INIT_FLOW_TEMPLATE.md +198 -0
  93. package/.claude/skills/workflow/flow-init/assets/RESEARCH_TEMPLATE.md +276 -0
  94. package/.claude/skills/workflow/flow-init/context.jsonl +5 -0
  95. package/.claude/skills/workflow/flow-init/references/flow-researcher.md +132 -0
  96. package/.claude/skills/workflow/flow-init/scripts/check-prerequisites.sh +232 -0
  97. package/.claude/skills/workflow/flow-init/scripts/consolidate-research.sh +182 -0
  98. package/.claude/skills/workflow/flow-init/scripts/create-requirement.sh +515 -0
  99. package/.claude/skills/workflow/flow-init/scripts/generate-research-tasks.sh +157 -0
  100. package/.claude/skills/workflow/flow-init/scripts/populate-research-tasks.sh +284 -0
  101. package/.claude/skills/workflow/flow-init/scripts/validate-research.sh +332 -0
  102. package/.claude/skills/workflow/flow-quality/SKILL.md +94 -0
  103. package/.claude/skills/workflow/flow-quality/context.jsonl +6 -0
  104. package/.claude/skills/workflow/flow-quality/references/code-quality-reviewer.md +205 -0
  105. package/.claude/skills/workflow/flow-quality/references/qa-tester.md +313 -0
  106. package/.claude/skills/workflow/flow-quality/references/security-reviewer.md +314 -0
  107. package/.claude/skills/workflow/flow-quality/references/spec-reviewer.md +221 -0
  108. package/.claude/skills/workflow/flow-release/SKILL.md +126 -0
  109. package/.claude/skills/workflow/flow-release/context.jsonl +7 -0
  110. package/.claude/skills/workflow/flow-release/references/release-manager.md +295 -0
  111. package/.claude/skills/workflow/flow-spec/CLAUDE.md +103 -0
  112. package/.claude/skills/workflow/flow-spec/SKILL.md +545 -0
  113. package/.claude/skills/workflow/flow-spec/context.jsonl +7 -0
  114. package/.claude/skills/workflow/flow-spec/scripts/entry-gate.sh +194 -0
  115. package/.claude/skills/workflow/flow-spec/scripts/exit-gate.sh +244 -0
  116. package/.claude/skills/workflow/flow-spec/scripts/parallel-orchestrator.sh +205 -0
  117. package/.claude/skills/workflow/flow-spec/scripts/team-communication.sh +353 -0
  118. package/.claude/skills/workflow/flow-spec/scripts/team-init.sh +195 -0
  119. package/.claude/skills/workflow/flow-spec/scripts/test-team-mode.sh +496 -0
  120. package/.claude/skills/workflow/flow-spec/team-config.json +165 -0
  121. package/.claude/skills/workflow.yaml +417 -0
  122. package/CHANGELOG.md +254 -0
  123. package/README.md +193 -33
  124. package/README.zh-CN.md +206 -46
  125. package/lib/compiler/CLAUDE.md +77 -46
  126. package/lib/compiler/__tests__/multi-module-emitters.test.js +508 -0
  127. package/lib/compiler/context-expander.js +179 -0
  128. package/lib/compiler/emitters/antigravity-emitter.js +195 -5
  129. package/lib/compiler/emitters/base-emitter.js +217 -2
  130. package/lib/compiler/emitters/codex-emitter.js +200 -4
  131. package/lib/compiler/emitters/cursor-emitter.js +307 -3
  132. package/lib/compiler/emitters/qwen-emitter.js +196 -4
  133. package/lib/compiler/index.js +197 -2
  134. package/lib/compiler/platforms.js +270 -21
  135. package/package.json +1 -1
  136. package/.claude/commands/flow-epic.md +0 -183
  137. package/.claude/commands/flow-init.md +0 -370
  138. package/.claude/commands/flow-prd.md +0 -144
  139. package/.claude/commands/flow-qa.md +0 -93
  140. package/.claude/commands/flow-review.md +0 -257
  141. package/.claude/commands/flow-tech.md +0 -142
  142. package/.claude/commands/flow-ui.md +0 -189
  143. package/.claude/skills/file-header-guardian/SKILL.md +0 -56
  144. package/.claude/skills/skill-developer/ADVANCED.md +0 -197
  145. package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +0 -306
  146. package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +0 -152
  147. package/.claude/skills/skill-developer/SKILL.md +0 -426
  148. package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +0 -315
  149. package/.claude/skills/skill-developer/TRIGGER_TYPES.md +0 -305
  150. package/.claude/skills/skill-developer/TROUBLESHOOTING.md +0 -514
  151. package/.claude/skills/writing-skills/SKILL.md +0 -655
  152. package/.claude/skills/writing-skills/anthropic-best-practices.md +0 -1150
  153. package/.claude/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
  154. package/.claude/skills/writing-skills/graphviz-conventions.dot +0 -172
  155. package/.claude/skills/writing-skills/persuasion-principles.md +0 -187
  156. package/.claude/skills/writing-skills/render-graphs.js +0 -168
  157. package/.claude/skills/writing-skills/testing-skills-with-subagents.md +0 -384
  158. package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +0 -1
  159. package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +0 -1
  160. /package/.claude/commands/{core-architecture.md → core/architecture.md} +0 -0
  161. /package/.claude/commands/{core-guidelines.md → core/guidelines.md} +0 -0
  162. /package/.claude/commands/{core-roadmap.md → core/roadmap.md} +0 -0
  163. /package/.claude/commands/{core-style.md → core/style.md} +0 -0
  164. /package/.claude/commands/{flow-checklist.md → flow/checklist.md} +0 -0
  165. /package/.claude/commands/{flow-clarify.md → flow/clarify.md} +0 -0
  166. /package/.claude/commands/{flow-constitution.md → flow/constitution.md} +0 -0
  167. /package/.claude/commands/{flow-fix.md → flow/fix.md} +0 -0
  168. /package/.claude/commands/{flow-ideate.md → flow/ideate.md} +0 -0
  169. /package/.claude/commands/{flow-new.md → flow/new.md} +0 -0
  170. /package/.claude/commands/{flow-release.md → flow/release.md} +0 -0
  171. /package/.claude/commands/{flow-restart.md → flow/restart.md} +0 -0
  172. /package/.claude/commands/{flow-status.md → flow/status.md} +0 -0
  173. /package/.claude/commands/{flow-update.md → flow/update.md} +0 -0
  174. /package/.claude/commands/{flow-upgrade.md → flow/upgrade.md} +0 -0
  175. /package/.claude/commands/{flow-verify.md → flow/verify.md} +0 -0
  176. /package/.claude/commands/{code-review-high.md → util/code-review.md} +0 -0
  177. /package/.claude/commands/{git-commit.md → util/git-commit.md} +0 -0
  178. /package/.claude/commands/{problem-analyzer.md → util/problem-analyzer.md} +0 -0
  179. /package/.claude/skills/{flow-attention-refresh → domain/attention-refresh}/SKILL.md +0 -0
  180. /package/.claude/skills/{flow-brainstorming → domain/brainstorming}/SKILL.md +0 -0
  181. /package/.claude/skills/{flow-debugging → domain/debugging}/SKILL.md +0 -0
  182. /package/.claude/skills/{flow-finishing-branch → domain/finishing-branch}/SKILL.md +0 -0
  183. /package/.claude/skills/{flow-receiving-review → domain/receiving-review}/SKILL.md +0 -0
  184. /package/.claude/skills/{flow-tdd → domain/tdd}/SKILL.md +0 -0
  185. /package/.claude/skills/{verification-before-completion → domain/verification}/SKILL.md +0 -0
  186. /package/.claude/skills/{constitution-guardian → guardrail/constitution-guardian}/SKILL.md +0 -0
  187. /package/.claude/skills/{devflow-tdd-enforcer → guardrail/tdd-enforcer}/SKILL.md +0 -0
  188. /package/.claude/skills/{devflow-constitution-quick-ref → utility/constitution-quick-ref}/SKILL.md +0 -0
  189. /package/.claude/skills/{devflow-file-standards → utility/file-standards}/SKILL.md +0 -0
  190. /package/.claude/skills/{fractal-docs-generator → utility/fractal-docs}/SKILL.md +0 -0
  191. /package/.claude/skills/{npm-release → utility/npm-release}/SKILL.md +0 -0
@@ -0,0 +1,238 @@
1
+ /**
2
+ * [INPUT]: 无外部依赖
3
+ * [OUTPUT]: 对外提供 Claude Team 集成的 TypeScript 类型定义
4
+ * [POS]: hooks/types/ 的 Team 状态类型,被 teammate-idle-hook.ts 和 task-completed-hook.ts 消费
5
+ * [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
6
+ */
7
+
8
+ // =============================================================================
9
+ // Teammate 状态类型
10
+ // =============================================================================
11
+
12
+ export type TeammateStatus = 'idle' | 'working' | 'blocked' | 'completed' | 'error';
13
+
14
+ export interface TeammateState {
15
+ /** Teammate 唯一标识 (e.g., "dev-analyst", "spec-analyst") */
16
+ id: string;
17
+
18
+ /** Teammate 角色 (e.g., "developer", "analyst", "reviewer") */
19
+ role: string;
20
+
21
+ /** 当前状态 */
22
+ status: TeammateStatus;
23
+
24
+ /** 当前正在执行的任务 ID (e.g., "T001") */
25
+ currentTask: string | null;
26
+
27
+ /** 已完成的任务 ID 列表 */
28
+ completedTasks: string[];
29
+
30
+ /** 最后活跃时间 (ISO 8601) */
31
+ lastActiveAt: string;
32
+
33
+ /** 错误信息 (仅当 status === 'error') */
34
+ errorMessage?: string;
35
+ }
36
+
37
+ // =============================================================================
38
+ // Team 状态类型
39
+ // =============================================================================
40
+
41
+ export type TeamMode = 'sequential' | 'parallel';
42
+
43
+ export interface TeamState {
44
+ /** Team 执行模式 */
45
+ mode: TeamMode;
46
+
47
+ /** Team Lead 标识 */
48
+ lead: string;
49
+
50
+ /** 所有 Teammates 状态 */
51
+ teammates: TeammateState[];
52
+
53
+ /** 任务分配映射 (taskId -> teammateId) */
54
+ taskAssignments: Record<string, string>;
55
+
56
+ /** Team 创建时间 */
57
+ createdAt: string;
58
+
59
+ /** Team 最后更新时间 */
60
+ updatedAt: string;
61
+ }
62
+
63
+ // =============================================================================
64
+ // Ralph Loop Team 模式类型
65
+ // =============================================================================
66
+
67
+ export interface TeammateRalphState {
68
+ /** 当前迭代次数 */
69
+ iteration: number;
70
+
71
+ /** 最后验证结果 */
72
+ lastVerifyResult: 'passed' | 'failed' | 'skipped';
73
+
74
+ /** 最后验证时间 */
75
+ lastVerifyAt?: string;
76
+
77
+ /** 最后失败记录 */
78
+ lastFailures?: FailureRecord[];
79
+ }
80
+
81
+ export interface FailureRecord {
82
+ command: string;
83
+ output: string;
84
+ timestamp: string;
85
+ }
86
+
87
+ export interface RalphLoopTeamState {
88
+ /** 是否启用 Ralph Loop */
89
+ enabled: boolean;
90
+
91
+ /** 每个 Teammate 的 Ralph 状态 */
92
+ teammates: Record<string, TeammateRalphState>;
93
+
94
+ /** 全局迭代次数 */
95
+ globalIteration: number;
96
+
97
+ /** 最大迭代次数 */
98
+ maxIterations: number;
99
+
100
+ /** 开始时间 */
101
+ startedAt: string;
102
+ }
103
+
104
+ // =============================================================================
105
+ // 扩展的 orchestration_status.json 类型
106
+ // =============================================================================
107
+
108
+ export interface OrchestrationStatus {
109
+ /** 需求 ID */
110
+ reqId: string;
111
+
112
+ /** 需求标题 */
113
+ title?: string;
114
+
115
+ /** 当前状态 */
116
+ status: string;
117
+
118
+ /** 当前阶段 */
119
+ phase: string;
120
+
121
+ /** 已完成的步骤 */
122
+ completedSteps?: string[];
123
+
124
+ /** Git 分支名 */
125
+ branch?: string;
126
+
127
+ /** 创建时间 */
128
+ createdAt: string;
129
+
130
+ /** 更新时间 */
131
+ updatedAt: string;
132
+
133
+ // =========================================================================
134
+ // v4.7 新增: Team 状态
135
+ // =========================================================================
136
+
137
+ /** Team 状态 (仅在 Team 模式下存在) */
138
+ team?: TeamState;
139
+
140
+ /** Ralph Loop 状态 (支持多 Teammate) */
141
+ ralphLoop?: RalphLoopTeamState;
142
+
143
+ // =========================================================================
144
+ // 归档相关字段
145
+ // =========================================================================
146
+
147
+ /** 归档原因 */
148
+ archivedReason?: string;
149
+
150
+ /** 归档时间 */
151
+ archivedAt?: string;
152
+
153
+ /** 归档位置 */
154
+ archiveLocation?: string;
155
+
156
+ /** 归档前状态 */
157
+ statusBeforeArchive?: string;
158
+
159
+ /** Delta 数量 */
160
+ deltaCount?: number;
161
+ }
162
+
163
+ // =============================================================================
164
+ // Hook 输入/输出类型
165
+ // =============================================================================
166
+
167
+ export interface TeammateIdleInput {
168
+ hook_event_name: 'TeammateIdle';
169
+ teammate_id: string;
170
+ teammate_role: string;
171
+ last_task_id?: string;
172
+ idle_reason: 'task_complete' | 'waiting_dependency' | 'no_tasks' | 'error';
173
+ cwd: string;
174
+ session_id: string;
175
+ }
176
+
177
+ export interface TeammateIdleOutput {
178
+ action: 'assign_task' | 'wait' | 'shutdown';
179
+ task_id?: string;
180
+ message?: string;
181
+ }
182
+
183
+ export interface TaskCompletedInput {
184
+ hook_event_name: 'TaskCompleted';
185
+ task_id: string;
186
+ task_subject: string;
187
+ completed_by: string;
188
+ completion_time: string;
189
+ cwd: string;
190
+ session_id: string;
191
+ }
192
+
193
+ export interface TaskCompletedOutput {
194
+ decision: 'accept' | 'reject';
195
+ reason: string;
196
+ next_actions?: string[];
197
+ }
198
+
199
+ // =============================================================================
200
+ // quality-gates.yml Team 模式配置类型
201
+ // =============================================================================
202
+
203
+ export interface TeammateIdleConfig {
204
+ idle_checks?: VerifyCommand[];
205
+ assignment_strategy?: 'priority_first' | 'round_robin' | 'skill_match';
206
+ idle_timeout?: number;
207
+ }
208
+
209
+ export interface TaskCompletedConfig {
210
+ verify?: VerifyCommand[];
211
+ block_on_failure?: boolean;
212
+ max_retries?: number;
213
+ }
214
+
215
+ export interface RalphLoopTeamConfig {
216
+ enabled?: boolean;
217
+ scope?: 'teammate' | 'global';
218
+ teammate_verify?: Record<string, string[]>;
219
+ global_verify?: string[];
220
+ max_iterations_per_teammate?: number;
221
+ max_global_iterations?: number;
222
+ }
223
+
224
+ export interface VerifyCommand {
225
+ name?: string;
226
+ command: string;
227
+ required?: boolean;
228
+ }
229
+
230
+ export interface QualityGatesTeamConfig {
231
+ teammate_idle?: TeammateIdleConfig;
232
+ task_completed?: TaskCompletedConfig;
233
+ ralph_loop?: {
234
+ team_mode?: RalphLoopTeamConfig;
235
+ max_iterations?: number;
236
+ timeout_minutes?: number;
237
+ };
238
+ }
@@ -61,9 +61,79 @@ devflow/requirements/${reqId}/
61
61
 
62
62
  ---
63
63
 
64
- ## 🌿 Git 分支约定
64
+ ## 🌿 Git Worktree 约定 (v4.3)
65
+
66
+ ### Worktree vs Branch 模式
67
+
68
+ | 模式 | 命令 | 适用场景 |
69
+ |------|------|----------|
70
+ | **Worktree (默认)** | `/flow-init "REQ-123\|Title"` | 多需求并行、需要隔离环境 |
71
+ | **Branch** | `/flow-init "REQ-123\|Title" --branch-only` | 单需求开发、简单修改 |
72
+
73
+ ### Worktree 目录布局
74
+
75
+ ```
76
+ ~/projects/
77
+ ├── cc-devflow/ # 主仓库 (main 分支)
78
+ ├── cc-devflow-REQ-001/ # REQ-001 worktree
79
+ ├── cc-devflow-REQ-002/ # REQ-002 worktree
80
+ ├── cc-devflow-analysis/ # 只读分析 worktree (可选)
81
+ └── cc-devflow-hotfix/ # 紧急修复 worktree (可选)
82
+ ```
83
+
84
+ ### 命名规范
85
+
86
+ ```bash
87
+ # Worktree 目录
88
+ {repo-name}-{REQ_ID}
89
+ # 示例: cc-devflow-REQ-123
90
+
91
+ # 对应分支 (不变)
92
+ feature/${reqId}-${slug(BRANCH_TITLE_EN)}
93
+ # 示例: feature/REQ-123-user-order-support
94
+ ```
95
+
96
+ ### Worktree 操作流程
97
+
98
+ 1. **创建** (flow-init 自动执行)
99
+ ```bash
100
+ git worktree add -b feature/REQ-123-title ../cc-devflow-REQ-123
101
+ ```
102
+
103
+ 2. **切换**
104
+ ```bash
105
+ cd ../cc-devflow-REQ-123
106
+ # 或使用 shell 别名
107
+ zw REQ-123
108
+ ```
109
+
110
+ 3. **开发**
111
+ - 每个 worktree 独立的 Claude Code 会话
112
+ - 互不干扰,保持上下文
113
+
114
+ 4. **清理** (flow-release 自动执行)
115
+ ```bash
116
+ git worktree remove ../cc-devflow-REQ-123
117
+ git branch -d feature/REQ-123-title
118
+ ```
119
+
120
+ ### Shell 别名推荐
121
+
122
+ ```bash
123
+ # 添加到 ~/.zshrc 或 ~/.bashrc
124
+ alias za='cd $(git rev-parse --show-toplevel 2>/dev/null || echo .)'
125
+ alias zl='git worktree list'
126
+ alias zm='cd ~/projects/cc-devflow'
127
+
128
+ zw() {
129
+ local req_id="${1:-}"
130
+ local repo_name=$(basename $(git rev-parse --show-toplevel 2>/dev/null))
131
+ cd ~/projects/${repo_name}-${req_id}
132
+ }
133
+ ```
134
+
135
+ ### 分支命名 (保持不变)
65
136
 
66
- ### 分支命名
67
137
  ```bash
68
138
  # 标准格式
69
139
  feature/${reqId}-${slug(BRANCH_TITLE_EN)}
@@ -75,13 +145,16 @@ feature/REQ-124-permission-management
75
145
 
76
146
  > BRANCH_TITLE_EN 为 TITLE 的英文意译 (语义为准,非拼音,使用模型意译)
77
147
 
78
- ### 分支操作流程
79
- 1. 检查当前在 main 分支且状态干净
80
- 2. 创建特性分支
81
- 3. 实施开发 (TDD方式)
82
- 4. 质量闸检查
83
- 5. 创建 PR
84
- 6. 合并后清理分支
148
+ ### 分支操作流程 (Worktree 模式)
149
+
150
+ 1. 确保主仓库在 main 分支且状态干净
151
+ 2. 执行 `/flow-init` 创建 worktree + 分支
152
+ 3. 切换到 worktree 目录
153
+ 4. 启动新的 Claude Code 会话
154
+ 5. 实施开发 (TDD方式)
155
+ 6. 质量闸检查
156
+ 7. 创建 PR
157
+ 8. 合并后清理 worktree 和分支
85
158
 
86
159
  ---
87
160
 
@@ -1,8 +1,13 @@
1
1
  #!/usr/bin/env bash
2
2
  # =============================================================================
3
- # archive-requirement.sh - 需求归档脚本
3
+ # archive-requirement.sh - 需求归档脚本 (v4.5 增强版)
4
4
  # 将已完成或废弃的需求移动到归档目录
5
+ # 支持 Delta Specs 集成
5
6
  # =============================================================================
7
+ # [INPUT]: 依赖 common.sh, orchestration_status.json
8
+ # [OUTPUT]: 移动需求到 devflow/archive/{YYYY-MM}/
9
+ # [POS]: scripts 的归档脚本,被 /flow:archive 调用
10
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
6
11
 
7
12
  set -euo pipefail
8
13
 
@@ -276,12 +281,43 @@ archive_month=$(TZ='Asia/Shanghai' date '+%Y-%m')
276
281
  archive_dir=$(get_archive_dir "$REPO_ROOT" "$archive_month")
277
282
  target_dir="$archive_dir/$REQ_ID"
278
283
 
284
+ # 检查 Delta Specs
285
+ delta_count=$(get_delta_count "$source_dir")
286
+ has_unapplied_deltas=false
287
+ if [[ "$delta_count" -gt 0 ]]; then
288
+ # 检查是否有未应用的 deltas
289
+ for delta_dir in "$source_dir/deltas"/*/; do
290
+ [[ -d "$delta_dir" ]] || continue
291
+ delta_file="$delta_dir/delta.md"
292
+ if [[ -f "$delta_file" ]]; then
293
+ status=$(grep -E '^status:' "$delta_file" | head -1 | sed 's/status:[[:space:]]*"\?\([^"]*\)"\?/\1/')
294
+ if [[ "$status" != "applied" ]]; then
295
+ has_unapplied_deltas=true
296
+ break
297
+ fi
298
+ fi
299
+ done
300
+ fi
301
+
279
302
  if [[ "$DRY_RUN" == "true" ]]; then
280
303
  echo "[DRY-RUN] 将移动: $source_dir → $target_dir"
281
304
  echo "[DRY-RUN] 归档原因: $REASON"
305
+ if [[ "$delta_count" -gt 0 ]]; then
306
+ echo "[DRY-RUN] Delta Specs: $delta_count 个"
307
+ if [[ "$has_unapplied_deltas" == "true" ]]; then
308
+ echo "[DRY-RUN] ⚠️ 警告: 存在未应用的 Delta Specs"
309
+ fi
310
+ fi
282
311
  exit 0
283
312
  fi
284
313
 
314
+ # 警告未应用的 deltas
315
+ if [[ "$has_unapplied_deltas" == "true" ]]; then
316
+ echo "⚠️ 警告: 存在未应用的 Delta Specs"
317
+ echo " 建议先运行: /flow:delta apply $REQ_ID --all"
318
+ echo ""
319
+ fi
320
+
285
321
  # 创建归档目录
286
322
  mkdir -p "$archive_dir"
287
323
 
@@ -303,11 +339,13 @@ if [[ -f "$status_file" ]]; then
303
339
  --arg location "$target_dir" \
304
340
  --arg prev_status "$current_status" \
305
341
  --arg updated "$(get_beijing_time_iso)" \
342
+ --argjson delta_count "$delta_count" \
306
343
  '.status = "archived" |
307
344
  .archivedReason = $reason |
308
345
  .archivedAt = $archived_at |
309
346
  .archiveLocation = $location |
310
347
  .statusBeforeArchive = $prev_status |
348
+ .deltaCount = $delta_count |
311
349
  .updatedAt = $updated' \
312
350
  "$status_file" > "${status_file}.tmp" && mv "${status_file}.tmp" "$status_file"
313
351
  fi
@@ -322,6 +360,7 @@ if [[ -f "$log_file" ]]; then
322
360
  - 归档原因: $REASON
323
361
  - 归档位置: $target_dir
324
362
  - 归档前状态: $current_status
363
+ - Delta Specs: $delta_count 个
325
364
  EOF
326
365
  fi
327
366
 
@@ -335,6 +374,7 @@ if [[ "$JSON_MODE" == "true" ]]; then
335
374
  "to": "$target_dir",
336
375
  "reason": "$REASON",
337
376
  "previousStatus": "$current_status",
377
+ "deltaCount": $delta_count,
338
378
  "archivedAt": "$(get_beijing_time_iso)",
339
379
  "status": "success"
340
380
  }
@@ -347,5 +387,8 @@ else
347
387
  echo " 新位置: $target_dir"
348
388
  echo " 归档原因: $REASON"
349
389
  echo " 归档前状态: $current_status"
390
+ if [[ "$delta_count" -gt 0 ]]; then
391
+ echo " Delta Specs: $delta_count 个"
392
+ fi
350
393
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
351
394
  fi