cc-devflow 4.2.0 → 4.3.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 (119) hide show
  1. package/.claude/commands/flow/CLAUDE.md +0 -4
  2. package/.claude/docs/examples/design-inspiration-pool.md +59 -0
  3. package/.claude/docs/examples/ui-prototype-constitution-checklist.md +75 -0
  4. package/.claude/docs/implementation-summary-v7.md +449 -0
  5. package/.claude/docs/spec-format-guide.md +349 -0
  6. package/.claude/docs/state-consolidation-design.md +323 -0
  7. package/.claude/docs/templates/ARCHITECTURE_TEMPLATE.md +85 -386
  8. package/.claude/docs/templates/DESIGN_TEMPLATE.md +157 -0
  9. package/.claude/docs/templates/PROPOSAL_TEMPLATE.md +91 -0
  10. package/.claude/docs/templates/SPEC_TEMPLATE_DELTA.md +139 -0
  11. package/.claude/docs/templates/SPEC_TEMPLATE_PROJECT.md +93 -0
  12. package/.claude/docs/templates/STYLE_TEMPLATE.md +114 -901
  13. package/.claude/docs/templates/UI_PROTOTYPE_TEMPLATE.md +143 -1205
  14. package/.claude/hooks/inject-agent-context.ts +9 -9
  15. package/.claude/scripts/.claude/commands/flow/export-openspec.md +221 -0
  16. package/.claude/scripts/.claude/commands/flow/import-openspec.md +171 -0
  17. package/.claude/scripts/__tests__/openspec.test.js +212 -0
  18. package/.claude/scripts/delta-parser.ts +112 -2
  19. package/.claude/scripts/export-openspec.js +222 -0
  20. package/.claude/scripts/import-openspec.js +272 -0
  21. package/.claude/scripts/validate-scope.sh +200 -0
  22. package/.claude/skills/{workflow/flow-init → flow-init}/SKILL.md +25 -4
  23. package/.claude/skills/{workflow/flow-release → flow-release}/SKILL.md +14 -3
  24. package/.claude/skills/{workflow/flow-spec → flow-spec}/SKILL.md +30 -2
  25. package/.claude/skills/utility/npm-release/CLAUDE.md +55 -0
  26. package/.claude/skills/utility/npm-release/SKILL.md +111 -46
  27. package/.claude/skills/utility/npm-release/references/version-decision-guide.md +134 -0
  28. package/.claude/skills/utility/npm-release/scripts/atomic-version-bump.sh +95 -0
  29. package/.claude/skills/utility/npm-release/scripts/validate-version-sync.sh +82 -0
  30. package/.claude/skills/utility/npm-release/scripts/version-decision-tree.sh +44 -0
  31. package/.claude/tsc-cache/70d2fc6d-2936-429b-b529-429f1aae8c88/affected-repos.txt +1 -0
  32. package/.claude/tsc-cache/70d2fc6d-2936-429b-b529-429f1aae8c88/edited-files.log +2 -0
  33. package/CHANGELOG.md +40 -0
  34. package/README.md +2 -1
  35. package/README.zh-CN.md +2 -1
  36. package/docs/v4.3.0-migration-guide.md +276 -0
  37. package/lib/harness/CLAUDE.md +5 -4
  38. package/lib/harness/__tests__/planner.tdd.test.js +125 -0
  39. package/lib/harness/index.js +4 -2
  40. package/lib/harness/operations/dispatch.js +13 -0
  41. package/lib/harness/operations/plan.js +55 -1
  42. package/lib/harness/operations/release.js +87 -0
  43. package/lib/harness/operations/verify.js +14 -0
  44. package/lib/harness/planner.js +131 -0
  45. package/lib/harness/query.js +126 -0
  46. package/lib/harness/schemas.js +22 -1
  47. package/package.json +1 -1
  48. package/.claude/commands/flow/checklist.md +0 -18
  49. package/.claude/commands/flow/clarify.md +0 -18
  50. package/.claude/commands/flow/new.md +0 -23
  51. package/.claude/commands/flow/quality.md +0 -21
  52. package/.claude/docs/templates/EPIC_TEMPLATE.md +0 -805
  53. package/.claude/docs/templates/PRD_TEMPLATE.md +0 -562
  54. package/.claude/docs/templates/TASKS_TEMPLATE.md +0 -523
  55. package/.claude/docs/templates/TECH_DESIGN_TEMPLATE.md +0 -1019
  56. package/.claude/skills/workflow/CLAUDE.md +0 -24
  57. /package/.claude/skills/{domain/attention-refresh → attention-refresh}/SKILL.md +0 -0
  58. /package/.claude/skills/{domain/brainstorming → brainstorming}/SKILL.md +0 -0
  59. /package/.claude/skills/{guardrail/constitution-guardian → constitution-guardian}/SKILL.md +0 -0
  60. /package/.claude/skills/{utility/constitution-quick-ref → constitution-quick-ref}/SKILL.md +0 -0
  61. /package/.claude/skills/{domain/debugging → debugging}/SKILL.md +0 -0
  62. /package/.claude/skills/{utility/file-standards → file-standards}/SKILL.md +0 -0
  63. /package/.claude/skills/{domain/finishing-branch → finishing-branch}/SKILL.md +0 -0
  64. /package/.claude/skills/{workflow/flow-dev → flow-dev}/CLAUDE.md +0 -0
  65. /package/.claude/skills/{workflow/flow-dev → flow-dev}/SKILL.md +0 -0
  66. /package/.claude/skills/{workflow/flow-dev → flow-dev}/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +0 -0
  67. /package/.claude/skills/{workflow/flow-dev → flow-dev}/context.jsonl +0 -0
  68. /package/.claude/skills/{workflow/flow-dev → flow-dev}/dev-implementer.jsonl +0 -0
  69. /package/.claude/skills/{workflow/flow-dev → flow-dev}/scripts/entry-gate.sh +0 -0
  70. /package/.claude/skills/{workflow/flow-dev → flow-dev}/scripts/exit-gate.sh +0 -0
  71. /package/.claude/skills/{workflow/flow-dev → flow-dev}/scripts/task-orchestrator.sh +0 -0
  72. /package/.claude/skills/{workflow/flow-fix → flow-fix}/SKILL.md +0 -0
  73. /package/.claude/skills/{workflow/flow-fix → flow-fix}/context.jsonl +0 -0
  74. /package/.claude/skills/{workflow/flow-fix → flow-fix}/references/bug-analyzer.md +0 -0
  75. /package/.claude/skills/{workflow/flow-init → flow-init}/assets/BRAINSTORM_TEMPLATE.md +0 -0
  76. /package/.claude/skills/{workflow/flow-init → flow-init}/assets/INIT_FLOW_TEMPLATE.md +0 -0
  77. /package/.claude/skills/{workflow/flow-init → flow-init}/assets/RESEARCH_TEMPLATE.md +0 -0
  78. /package/.claude/skills/{workflow/flow-init → flow-init}/context.jsonl +0 -0
  79. /package/.claude/skills/{workflow/flow-init → flow-init}/references/flow-researcher.md +0 -0
  80. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/check-prerequisites.sh +0 -0
  81. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/consolidate-research.sh +0 -0
  82. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/create-requirement.sh +0 -0
  83. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/generate-research-tasks.sh +0 -0
  84. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/populate-research-tasks.sh +0 -0
  85. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/validate-research.sh +0 -0
  86. /package/.claude/skills/{workflow/flow-quality → flow-quality}/SKILL.md +0 -0
  87. /package/.claude/skills/{workflow/flow-quality → flow-quality}/context.jsonl +0 -0
  88. /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/code-quality-reviewer.md +0 -0
  89. /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/qa-tester.md +0 -0
  90. /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/security-reviewer.md +0 -0
  91. /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/spec-reviewer.md +0 -0
  92. /package/.claude/skills/{workflow/flow-release → flow-release}/context.jsonl +0 -0
  93. /package/.claude/skills/{workflow/flow-release → flow-release}/references/release-manager.md +0 -0
  94. /package/.claude/skills/{workflow/flow-spec → flow-spec}/CLAUDE.md +0 -0
  95. /package/.claude/skills/{workflow/flow-spec → flow-spec}/context.jsonl +0 -0
  96. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/entry-gate.sh +0 -0
  97. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/exit-gate.sh +0 -0
  98. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/parallel-orchestrator.sh +0 -0
  99. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/team-communication.sh +0 -0
  100. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/team-init.sh +0 -0
  101. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/test-team-mode.sh +0 -0
  102. /package/.claude/skills/{workflow/flow-spec → flow-spec}/team-config.json +0 -0
  103. /package/.claude/skills/{workflow/flow-verify → flow-verify}/CLAUDE.md +0 -0
  104. /package/.claude/skills/{workflow/flow-verify → flow-verify}/SKILL.md +0 -0
  105. /package/.claude/skills/{workflow/flow-verify → flow-verify}/context.jsonl +0 -0
  106. /package/.claude/skills/{utility/fractal-docs → fractal-docs}/SKILL.md +0 -0
  107. /package/.claude/skills/{utility/journey-checker → journey-checker}/SKILL.md +0 -0
  108. /package/.claude/skills/{utility/journey-checker → journey-checker}/pressure-scenarios.md +0 -0
  109. /package/.claude/skills/{domain/receiving-review → receiving-review}/SKILL.md +0 -0
  110. /package/.claude/skills/{utility/skill-creator → skill-creator}/LICENSE.txt +0 -0
  111. /package/.claude/skills/{utility/skill-creator → skill-creator}/SKILL.md +0 -0
  112. /package/.claude/skills/{utility/skill-creator → skill-creator}/references/output-patterns.md +0 -0
  113. /package/.claude/skills/{utility/skill-creator → skill-creator}/references/workflows.md +0 -0
  114. /package/.claude/skills/{utility/skill-creator → skill-creator}/scripts/init_skill.py +0 -0
  115. /package/.claude/skills/{utility/skill-creator → skill-creator}/scripts/package_skill.py +0 -0
  116. /package/.claude/skills/{utility/skill-creator → skill-creator}/scripts/quick_validate.py +0 -0
  117. /package/.claude/skills/{domain/tdd → tdd}/SKILL.md +0 -0
  118. /package/.claude/skills/{guardrail/tdd-enforcer → tdd-enforcer}/SKILL.md +0 -0
  119. /package/.claude/skills/{domain/verification → verification}/SKILL.md +0 -0
@@ -0,0 +1,349 @@
1
+ # CC-DevFlow spec.md Format Guide
2
+
3
+ > **Version**: v4.3.0
4
+ > **Purpose**: 定义项目级和需求级 spec.md 的格式规范
5
+
6
+ ---
7
+
8
+ ## 核心设计原则
9
+
10
+ **OpenSpec 复刻**:
11
+ - 项目级 `devflow/specs/` = 不可变源代码真相(描述当前系统状态)
12
+ - 需求级 `requirements/{REQ}/specs/` = Delta(ADDED/MODIFIED/REMOVED/RENAMED)
13
+ - 归档时自动合并 Delta 到项目级
14
+
15
+ **关键区别**:
16
+ - ❌ 错误理解:每个需求有自己的 spec.md
17
+ - ✅ 正确理解:项目有统一的 specs/,需求通过 Delta 修改它
18
+
19
+ ---
20
+
21
+ ## 项目级 spec.md 格式
22
+
23
+ ### YAML Frontmatter
24
+
25
+ ```yaml
26
+ ---
27
+ module: "auth" # 模块名称
28
+ created_at: "2026-01-01T10:00:00Z" # 创建时间
29
+ updated_at: "2026-03-12T15:30:00Z" # 最后更新时间
30
+ version: "2.1.0" # 语义化版本号
31
+ ---
32
+ ```
33
+
34
+ ### 文档结构
35
+
36
+ ```markdown
37
+ # {Module Name}
38
+
39
+ ## Purpose
40
+ {高层描述:这个模块是干什么的}
41
+
42
+ ## Requirements
43
+
44
+ ### Requirement: {Requirement Name}
45
+ The system {SHALL|MUST|SHOULD|MAY} {behavior description}.
46
+
47
+ #### Scenario: {Scenario Name}
48
+ - GIVEN {precondition}
49
+ - WHEN {action}
50
+ - THEN {expected result}
51
+ - AND {additional assertion}
52
+
53
+ ### Requirement: {Another Requirement}
54
+ ...
55
+
56
+ ## Implementation
57
+
58
+ ### API Endpoints
59
+ - POST /api/auth/login
60
+ - GET /api/auth/verify
61
+
62
+ ### Data Model
63
+ ```sql
64
+ CREATE TABLE users (
65
+ id UUID PRIMARY KEY,
66
+ email VARCHAR(255) UNIQUE NOT NULL
67
+ );
68
+ ```
69
+
70
+ ### Files
71
+ - `src/api/auth/login.ts`
72
+ - `src/middleware/jwt.ts`
73
+ ```
74
+
75
+ ### RFC 2119 关键字
76
+
77
+ | 关键字 | 含义 | 用法 |
78
+ |--------|------|------|
79
+ | SHALL | 必须实现 | 核心功能 |
80
+ | MUST | 强制要求 | 安全/合规 |
81
+ | SHOULD | 推荐实现 | 最佳实践 |
82
+ | MAY | 可选实现 | 增强功能 |
83
+
84
+ ### BDD Scenario 格式
85
+
86
+ ```markdown
87
+ #### Scenario: {场景名称}
88
+ - GIVEN {前置条件}
89
+ - WHEN {触发动作}
90
+ - THEN {预期结果}
91
+ - AND {额外断言}
92
+ ```
93
+
94
+ **示例**:
95
+ ```markdown
96
+ #### Scenario: Valid credentials
97
+ - GIVEN a registered user
98
+ - WHEN the user submits valid email and password
99
+ - THEN a JWT token is issued
100
+ - AND the user is redirected to dashboard
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 需求级 Delta spec.md 格式
106
+
107
+ ### YAML Frontmatter
108
+
109
+ ```yaml
110
+ ---
111
+ delta_id: "REQ-123" # 需求 ID
112
+ module: "auth" # 目标模块
113
+ title: "添加 2FA 支持" # 变更标题
114
+ created_at: "2026-03-12T10:00:00Z" # 创建时间
115
+ status: "draft" # draft | approved | applied
116
+ ---
117
+ ```
118
+
119
+ ### 文档结构
120
+
121
+ ```markdown
122
+ # Delta: {变更标题}
123
+
124
+ ## Summary
125
+ {为什么需要这个变更?简短说明}
126
+
127
+ ## ADDED Requirements
128
+
129
+ ### Requirement: {New Requirement Name}
130
+ The system SHALL {new behavior}.
131
+
132
+ #### Scenario: {New Scenario}
133
+ - GIVEN ...
134
+ - WHEN ...
135
+ - THEN ...
136
+
137
+ ## MODIFIED Requirements
138
+
139
+ ### Requirement: {Existing Requirement Name}
140
+ The system SHALL {modified behavior}.
141
+ (Previously: {old behavior})
142
+
143
+ ## REMOVED Requirements
144
+
145
+ ### Requirement: {Removed Requirement Name}
146
+ {说明为什么移除}
147
+
148
+ ## RENAMED Requirements
149
+
150
+ ### Requirement: {Old Name} → {New Name}
151
+ {说明为什么重命名}
152
+ ```
153
+
154
+ ### Delta 操作类型
155
+
156
+ | 操作 | 含义 | 示例 |
157
+ |------|------|------|
158
+ | ADDED | 新增需求 | 添加 2FA 功能 |
159
+ | MODIFIED | 修改现有需求 | 会话超时从 60 分钟改为 30 分钟 |
160
+ | REMOVED | 删除需求 | 移除已废弃的 OAuth 1.0 支持 |
161
+ | RENAMED | 重命名需求 | "User Authentication" → "Multi-Factor Authentication" |
162
+
163
+ ---
164
+
165
+ ## 完整示例
166
+
167
+ ### 项目级 spec.md
168
+
169
+ ```markdown
170
+ ---
171
+ module: "auth"
172
+ created_at: "2026-01-01T10:00:00Z"
173
+ updated_at: "2026-03-12T15:30:00Z"
174
+ version: "2.1.0"
175
+ ---
176
+
177
+ # Authentication Module
178
+
179
+ ## Purpose
180
+ Provides secure authentication and session management for the application.
181
+
182
+ ## Requirements
183
+
184
+ ### Requirement: User Login
185
+ The system SHALL allow users to log in with email and password.
186
+
187
+ #### Scenario: Valid credentials
188
+ - GIVEN a registered user
189
+ - WHEN the user submits valid email and password
190
+ - THEN a JWT token is issued
191
+ - AND the user is redirected to dashboard
192
+
193
+ #### Scenario: Invalid credentials
194
+ - GIVEN a registered user
195
+ - WHEN the user submits invalid password
196
+ - THEN an error message is displayed
197
+ - AND no token is issued
198
+
199
+ ### Requirement: Session Management
200
+ The system MUST expire sessions after 30 minutes of inactivity.
201
+
202
+ #### Scenario: Idle timeout
203
+ - GIVEN an authenticated session
204
+ - WHEN 30 minutes pass without activity
205
+ - THEN the session is invalidated
206
+ - AND the user must re-authenticate
207
+
208
+ ## Implementation
209
+
210
+ ### API Endpoints
211
+ - POST /api/auth/login
212
+ - POST /api/auth/logout
213
+ - GET /api/auth/verify
214
+
215
+ ### Data Model
216
+ ```sql
217
+ CREATE TABLE users (
218
+ id UUID PRIMARY KEY,
219
+ email VARCHAR(255) UNIQUE NOT NULL,
220
+ password_hash VARCHAR(255) NOT NULL,
221
+ created_at TIMESTAMP DEFAULT NOW()
222
+ );
223
+ ```
224
+
225
+ ### Files
226
+ - `src/api/auth/login.ts`
227
+ - `src/api/auth/logout.ts`
228
+ - `src/middleware/jwt.ts`
229
+ ```
230
+
231
+ ### 需求级 Delta spec.md
232
+
233
+ ```markdown
234
+ ---
235
+ delta_id: "REQ-123"
236
+ module: "auth"
237
+ title: "添加 2FA 支持"
238
+ created_at: "2026-03-12T10:00:00Z"
239
+ status: "draft"
240
+ ---
241
+
242
+ # Delta: 添加 2FA 支持
243
+
244
+ ## Summary
245
+ 为提高安全性,添加两因素认证支持。用户可选择启用 2FA,登录时需要输入 OTP 验证码。
246
+
247
+ ## ADDED Requirements
248
+
249
+ ### Requirement: Two-Factor Authentication
250
+ The system MUST require a second factor during login for users with 2FA enabled.
251
+
252
+ #### Scenario: OTP required
253
+ - GIVEN a user with 2FA enabled
254
+ - WHEN the user submits valid credentials
255
+ - THEN an OTP challenge is presented
256
+ - AND the user must enter a valid OTP code
257
+
258
+ #### Scenario: OTP validation
259
+ - GIVEN a user has entered valid credentials
260
+ - WHEN the user submits a valid OTP code
261
+ - THEN a JWT token is issued
262
+ - AND the user is redirected to dashboard
263
+
264
+ #### Scenario: Invalid OTP
265
+ - GIVEN a user has entered valid credentials
266
+ - WHEN the user submits an invalid OTP code
267
+ - THEN an error message is displayed
268
+ - AND the user remains on the OTP challenge page
269
+
270
+ ## MODIFIED Requirements
271
+
272
+ ### Requirement: Session Management
273
+ The system SHALL expire sessions after 30 minutes of inactivity.
274
+ (Previously: 60 minutes)
275
+
276
+ **Rationale**: 缩短超时时间以提高安全性,配合 2FA 使用。
277
+
278
+ ## REMOVED Requirements
279
+
280
+ None
281
+
282
+ ## RENAMED Requirements
283
+
284
+ None
285
+ ```
286
+
287
+ ---
288
+
289
+ ## 合并逻辑
290
+
291
+ 归档时,`delta-parser.ts` 自动执行以下操作:
292
+
293
+ 1. **ADDED**: 追加到项目级 spec.md 的 Requirements 章节
294
+ 2. **MODIFIED**: 替换项目级 spec.md 中对应的 Requirement
295
+ 3. **REMOVED**: 从项目级 spec.md 中删除对应的 Requirement
296
+ 4. **RENAMED**: 重命名项目级 spec.md 中的 Requirement 标题
297
+ 5. **Version Bump**: 更新项目级 spec.md 的 version 字段
298
+
299
+ ---
300
+
301
+ ## 最佳实践
302
+
303
+ ### 1. 保持 Delta 最小化
304
+ - 只包含本次需求的变更
305
+ - 不要在 Delta 中重复现有内容
306
+
307
+ ### 2. 使用清晰的 Scenario
308
+ - 每个 Scenario 测试一个具体行为
309
+ - 使用 Given-When-Then 格式
310
+ - 避免模糊的描述
311
+
312
+ ### 3. 记录变更原因
313
+ - MODIFIED 时说明为什么修改
314
+ - REMOVED 时说明为什么移除
315
+ - RENAMED 时说明为什么重命名
316
+
317
+ ### 4. 版本号规范
318
+ - ADDED 新功能 → MINOR 版本号 +1
319
+ - MODIFIED 现有功能 → PATCH 版本号 +1
320
+ - REMOVED 功能 → MAJOR 版本号 +1(破坏性变更)
321
+
322
+ ---
323
+
324
+ ## 工具支持
325
+
326
+ ### 生成 Delta
327
+ ```bash
328
+ /flow:spec "REQ-123"
329
+ → 生成 devflow/requirements/REQ-123/specs/{module}/spec.md
330
+ ```
331
+
332
+ ### 验证 Delta
333
+ ```bash
334
+ /flow:validate-scope "REQ-123"
335
+ → 检测需求偏移,生成 scope-creep-report.md
336
+ ```
337
+
338
+ ### 合并 Delta
339
+ ```bash
340
+ /flow:release "REQ-123"
341
+ → 自动合并 Delta 到 devflow/specs/{module}/spec.md
342
+ → 更新版本号
343
+ → 归档需求
344
+ ```
345
+
346
+ ---
347
+
348
+ **Last Updated**: 2026-03-12
349
+ **Version**: v4.3.0
@@ -0,0 +1,323 @@
1
+ # State Consolidation Design (Task #10 重新设计)
2
+
3
+ > **Version**: 1.0.0
4
+ > **Date**: 2026-03-12
5
+ > **Status**: Design Proposal
6
+
7
+ ---
8
+
9
+ ## 问题诊断
10
+
11
+ ### 现象层
12
+ Task #10 原始设计要求创建统一的 `.harness/state.json`,合并:
13
+ - `orchestration_status.json`
14
+ - `session-checklist.json`
15
+ - `session-progress.md`
16
+ - `session-handoff.md`
17
+
18
+ ### 本质层
19
+ 这个设计与 v6.0 Harness-First 架构冲突:
20
+ - v6.0 已经实现了**关注点分离**
21
+ - 将所有状态塞入一个文件违反了单一职责原则
22
+ - 真正的问题是**旧文件未被废弃**,而非需要新的统一文件
23
+
24
+ ### 哲学层
25
+ **单一真相源 ≠ 单一文件**
26
+
27
+ 正确的架构:
28
+ ```
29
+ harness-state.json → 生命周期状态 (initialized/released)
30
+ task-manifest.json → 任务定义与进度 (tasks[].status)
31
+ checkpoint.json → 会话恢复点 (per task)
32
+ report-card.json → 质量验证结果
33
+ ```
34
+
35
+ ---
36
+
37
+ ## v6.0 当前架构分析
38
+
39
+ ### 1. harness-state.json (核心生命周期)
40
+ ```json
41
+ {
42
+ "changeId": "REQ-123",
43
+ "goal": "Deliver REQ-123 safely",
44
+ "status": "initialized|released",
45
+ "initializedAt": "2026-03-12T10:00:00Z",
46
+ "releasedAt": "2026-03-12T15:00:00Z",
47
+ "updatedAt": "2026-03-12T15:00:00Z"
48
+ }
49
+ ```
50
+
51
+ **职责**:
52
+ - 需求的生命周期状态
53
+ - 初始化和发布时间戳
54
+ - 不包含任务细节
55
+
56
+ ### 2. task-manifest.json (任务定义与进度)
57
+ ```json
58
+ {
59
+ "changeId": "REQ-123",
60
+ "goal": "...",
61
+ "createdAt": "...",
62
+ "updatedAt": "...",
63
+ "tasks": [
64
+ {
65
+ "id": "T001",
66
+ "title": "...",
67
+ "status": "pending|running|passed|failed",
68
+ "attempts": 0,
69
+ "maxRetries": 1,
70
+ "dependsOn": [],
71
+ "touches": [],
72
+ "run": [],
73
+ "checks": []
74
+ }
75
+ ],
76
+ "metadata": {
77
+ "source": "TASKS.md",
78
+ "generatedBy": "harness:plan"
79
+ }
80
+ }
81
+ ```
82
+
83
+ **职责**:
84
+ - 任务定义(依赖、文件、命令)
85
+ - 任务执行状态(pending/running/passed/failed)
86
+ - 重试次数和错误信息
87
+ - **已经包含了 progress 信息**(completedTasks = tasks.filter(t => t.status === 'passed').length)
88
+
89
+ ### 3. checkpoint.json (会话恢复)
90
+ ```json
91
+ {
92
+ "changeId": "REQ-123",
93
+ "taskId": "T001",
94
+ "sessionId": "session-abc123",
95
+ "status": "passed",
96
+ "summary": "Task completed successfully",
97
+ "timestamp": "2026-03-12T10:30:00Z",
98
+ "attempt": 0
99
+ }
100
+ ```
101
+
102
+ **职责**:
103
+ - 每个任务的检查点
104
+ - 会话恢复信息
105
+ - 任务执行摘要
106
+
107
+ ### 4. report-card.json (质量验证)
108
+ ```json
109
+ {
110
+ "changeId": "REQ-123",
111
+ "overall": "pass|fail",
112
+ "quickGates": [...],
113
+ "strictGates": [...],
114
+ "review": {...},
115
+ "blockingFindings": [],
116
+ "timestamp": "..."
117
+ }
118
+ ```
119
+
120
+ **职责**:
121
+ - 质量门禁结果
122
+ - 阻塞性问题列表
123
+
124
+ ---
125
+
126
+ ## 旧文件映射分析
127
+
128
+ ### orchestration_status.json → 已被替代
129
+ ```json
130
+ {
131
+ "reqId": "REQ-006",
132
+ "status": "release_complete", // → harness-state.json: status
133
+ "phase": "release", // → harness-state.json: status
134
+ "completedSteps": [...], // → task-manifest.json: tasks[].status
135
+ "documents": {...}, // → 文件系统本身就是真相源
136
+ "research": {...}, // → 文件系统
137
+ "createdAt": "...", // → harness-state.json: initializedAt
138
+ "updatedAt": "...", // → harness-state.json: updatedAt
139
+ "prUrl": "..." // → 不属于 harness 职责
140
+ }
141
+ ```
142
+
143
+ **结论**:orchestration_status.json 是冗余的,所有信息已在新架构中表达。
144
+
145
+ ### session-checklist.json → 已被替代
146
+ ```json
147
+ {
148
+ "flow:init": { "passes": true },
149
+ "flow:spec": { "passes": false }
150
+ }
151
+ ```
152
+
153
+ **映射**:
154
+ - `flow:init.passes` → harness-state.json: status === 'initialized'
155
+ - `flow:spec.passes` → task-manifest.json 存在且有效
156
+
157
+ **结论**:session-checklist.json 是冗余的。
158
+
159
+ ### session-progress.md → 可生成
160
+ ```markdown
161
+ ## Progress
162
+ - Total Tasks: 6
163
+ - Completed: 2
164
+ - Failed: 0
165
+ ```
166
+
167
+ **映射**:
168
+ ```javascript
169
+ const manifest = readJson('task-manifest.json');
170
+ const totalTasks = manifest.tasks.length;
171
+ const completedTasks = manifest.tasks.filter(t => t.status === 'passed').length;
172
+ const failedTasks = manifest.tasks.filter(t => t.status === 'failed').length;
173
+ ```
174
+
175
+ **结论**:session-progress.md 可从 task-manifest.json 实时生成,无需存储。
176
+
177
+ ### session-handoff.md → 可生成
178
+ ```markdown
179
+ ## Next Steps
180
+ - Continue from Task T003
181
+ - Review checkpoint at ...
182
+ ```
183
+
184
+ **映射**:
185
+ ```javascript
186
+ const manifest = readJson('task-manifest.json');
187
+ const nextTask = manifest.tasks.find(t => t.status === 'pending');
188
+ const lastCheckpoint = readJson(`checkpoint-${lastTaskId}.json`);
189
+ ```
190
+
191
+ **结论**:session-handoff.md 可从 task-manifest.json + checkpoint.json 生成。
192
+
193
+ ---
194
+
195
+ ## 正确的实现策略
196
+
197
+ ### Phase 1: 废弃旧文件(不破坏兼容性)
198
+
199
+ 1. **标记为 deprecated**:
200
+ - 在 flow-init/flow-spec skills 中移除对 session-* 文件的引用
201
+ - 添加迁移警告:检测到旧文件时输出 deprecation warning
202
+
203
+ 2. **迁移脚本**(可选):
204
+ ```bash
205
+ # .claude/scripts/migrate-legacy-state.sh
206
+ # 将 orchestration_status.json 转换为 harness-state.json
207
+ ```
208
+
209
+ ### Phase 2: 增强 harness-state.json(最小化扩展)
210
+
211
+ 当前 harness-state.json 已经足够简洁,只需添加一个可选字段:
212
+
213
+ ```json
214
+ {
215
+ "changeId": "REQ-123",
216
+ "goal": "...",
217
+ "status": "initialized|planned|in_progress|verified|released",
218
+ "initializedAt": "...",
219
+ "plannedAt": "...", // 新增:plan 完成时间
220
+ "verifiedAt": "...", // 新增:verify 完成时间
221
+ "releasedAt": "...",
222
+ "updatedAt": "..."
223
+ }
224
+ ```
225
+
226
+ **新增状态**:
227
+ - `planned` - harness:plan 完成后
228
+ - `in_progress` - harness:dispatch 开始后
229
+ - `verified` - harness:verify 通过后
230
+
231
+ ### Phase 3: 提供查询工具
232
+
233
+ 创建辅助函数从分散的文件中聚合信息:
234
+
235
+ ```javascript
236
+ // lib/harness/query.js
237
+
238
+ async function getProgress(repoRoot, changeId) {
239
+ const manifest = await readJson(getTaskManifestPath(repoRoot, changeId));
240
+ return {
241
+ totalTasks: manifest.tasks.length,
242
+ completedTasks: manifest.tasks.filter(t => t.status === 'passed').length,
243
+ failedTasks: manifest.tasks.filter(t => t.status === 'failed').length,
244
+ pendingTasks: manifest.tasks.filter(t => t.status === 'pending').length
245
+ };
246
+ }
247
+
248
+ async function getNextTask(repoRoot, changeId) {
249
+ const manifest = await readJson(getTaskManifestPath(repoRoot, changeId));
250
+ return manifest.tasks.find(t => t.status === 'pending');
251
+ }
252
+
253
+ async function getFullState(repoRoot, changeId) {
254
+ const state = await readJson(getHarnessStatePath(repoRoot, changeId));
255
+ const manifest = await readJson(getTaskManifestPath(repoRoot, changeId));
256
+ const report = await readJson(getReportCardPath(repoRoot, changeId), null);
257
+
258
+ return {
259
+ lifecycle: state,
260
+ progress: await getProgress(repoRoot, changeId),
261
+ nextTask: await getNextTask(repoRoot, changeId),
262
+ quality: report
263
+ };
264
+ }
265
+ ```
266
+
267
+ ---
268
+
269
+ ## 实施计划
270
+
271
+ ### Task #10 重新定义
272
+
273
+ **目标**:废弃旧状态文件,增强 harness-state.json,提供查询工具
274
+
275
+ **步骤**:
276
+
277
+ 1. **更新 harness-state.json schema**:
278
+ - 添加 `plannedAt`, `verifiedAt` 字段
279
+ - 扩展 status 枚举:`initialized|planned|in_progress|verified|released`
280
+
281
+ 2. **更新 operations**:
282
+ - `plan.js`: 写入 `plannedAt`
283
+ - `dispatch.js`: 写入 `status: 'in_progress'`
284
+ - `verify.js`: 写入 `verifiedAt`
285
+
286
+ 3. **创建查询工具**:
287
+ - `lib/harness/query.js`: getProgress, getNextTask, getFullState
288
+
289
+ 4. **废弃旧文件引用**:
290
+ - 更新 flow-init/flow-spec skills
291
+ - 移除 session-* 文件的生成逻辑
292
+ - 添加 deprecation warnings
293
+
294
+ 5. **文档更新**:
295
+ - 更新 CLAUDE.md 说明新架构
296
+ - 添加迁移指南
297
+
298
+ ---
299
+
300
+ ## 验证标准
301
+
302
+ - [ ] harness-state.json 包含完整生命周期状态
303
+ - [ ] task-manifest.json 包含任务进度
304
+ - [ ] query.js 可以聚合所有状态信息
305
+ - [ ] flow-init/flow-spec 不再引用 session-* 文件
306
+ - [ ] 旧需求(REQ-004/005/006)可以继续工作(向后兼容)
307
+
308
+ ---
309
+
310
+ ## 总结
311
+
312
+ **核心原则**:
313
+ 1. 不创建新的臃肿文件
314
+ 2. 保持 v6.0 的关注点分离
315
+ 3. 通过查询工具聚合信息
316
+ 4. 优雅地废弃旧文件
317
+
318
+ **哲学**:
319
+ > 单一真相源通过**职责分离 + 查询聚合**实现,而非将所有数据塞入一个文件。
320
+
321
+ ---
322
+
323
+ **[PROTOCOL]**: 变更时更新此头部,然后检查 CLAUDE.md