cc-devflow 4.5.11 → 4.5.12

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 (185) hide show
  1. package/.claude/skills/cc-act/CHANGELOG.md +18 -0
  2. package/.claude/skills/cc-act/PLAYBOOK.md +17 -269
  3. package/.claude/skills/cc-act/SKILL.md +38 -425
  4. package/.claude/skills/cc-act/assets/PROJECT_POSTMORTEM_INDEX_TEMPLATE.md +2 -13
  5. package/.claude/skills/cc-act/assets/PROJECT_POSTMORTEM_TEMPLATE.md +1 -9
  6. package/.claude/skills/cc-act/assets/PR_BRIEF_TEMPLATE.md +21 -177
  7. package/.claude/skills/cc-act/references/closure-contract.md +12 -63
  8. package/.claude/skills/cc-act/references/git-commit-guidelines.md +5 -5
  9. package/.claude/skills/cc-act/scripts/cc-act-common.sh +5 -322
  10. package/.claude/skills/cc-act/scripts/detect-ship-target.sh +11 -2
  11. package/.claude/skills/cc-act/scripts/inspect-git-index.sh +58 -0
  12. package/.claude/skills/cc-act/scripts/render-pr-brief.sh +40 -440
  13. package/.claude/skills/cc-act/scripts/verify-act-gate.sh +10 -50
  14. package/.claude/skills/cc-check/CHANGELOG.md +18 -0
  15. package/.claude/skills/cc-check/PLAYBOOK.md +19 -273
  16. package/.claude/skills/cc-check/SKILL.md +33 -456
  17. package/.claude/skills/cc-check/references/review-contract.md +12 -147
  18. package/.claude/skills/cc-dev/CHANGELOG.md +15 -0
  19. package/.claude/skills/cc-dev/PLAYBOOK.md +1 -1
  20. package/.claude/skills/cc-dev/SKILL.md +52 -137
  21. package/.claude/skills/cc-dev/scripts/resolve-cc-devflow.sh +181 -0
  22. package/.claude/skills/cc-do/CHANGELOG.md +11 -0
  23. package/.claude/skills/cc-do/PLAYBOOK.md +19 -113
  24. package/.claude/skills/cc-do/SKILL.md +39 -245
  25. package/.claude/skills/cc-do/references/execution-recovery.md +15 -109
  26. package/.claude/skills/cc-do/scripts/cc-do-common.sh +5 -57
  27. package/.claude/skills/cc-do/scripts/check-task-status.sh +35 -65
  28. package/.claude/skills/cc-do/scripts/mark-task-complete.sh +9 -46
  29. package/.claude/skills/cc-do/scripts/select-ready-tasks.sh +29 -97
  30. package/.claude/skills/cc-investigate/CHANGELOG.md +16 -0
  31. package/.claude/skills/cc-investigate/PLAYBOOK.md +20 -180
  32. package/.claude/skills/cc-investigate/SKILL.md +64 -246
  33. package/.claude/skills/cc-investigate/assets/TASKS_TEMPLATE.md +48 -98
  34. package/.claude/skills/cc-investigate/references/investigation-contract.md +14 -218
  35. package/.claude/skills/cc-next/CHANGELOG.md +6 -0
  36. package/.claude/skills/cc-next/PLAYBOOK.md +12 -8
  37. package/.claude/skills/cc-next/SKILL.md +34 -140
  38. package/.claude/skills/cc-plan/CHANGELOG.md +16 -0
  39. package/.claude/skills/cc-plan/PLAYBOOK.md +22 -161
  40. package/.claude/skills/cc-plan/SKILL.md +45 -295
  41. package/.claude/skills/cc-plan/assets/TASKS_TEMPLATE.md +30 -228
  42. package/.claude/skills/cc-plan/references/planning-contract.md +24 -161
  43. package/.claude/skills/cc-plan/scripts/next-change-key.sh +8 -44
  44. package/.claude/skills/cc-plan/scripts/parse-task-dependencies.js +2 -2
  45. package/.claude/skills/cc-plan/scripts/validate-scope.sh +1 -1
  46. package/.claude/skills/cc-pr-land/SKILL.md +14 -114
  47. package/.claude/skills/cc-pr-review/CHANGELOG.md +4 -0
  48. package/.claude/skills/cc-pr-review/SKILL.md +20 -103
  49. package/.claude/skills/cc-review/CHANGELOG.md +17 -0
  50. package/.claude/skills/cc-review/PLAYBOOK.md +13 -86
  51. package/.claude/skills/cc-review/SKILL.md +53 -241
  52. package/.claude/skills/cc-review/references/e2e-and-plugin-verification.md +2 -2
  53. package/.claude/skills/cc-review/references/implementation-review-branch.md +7 -147
  54. package/.claude/skills/cc-review/references/plan-review-branch.md +5 -147
  55. package/.claude/skills/cc-review/references/review-methods.md +10 -218
  56. package/.claude/skills/cc-review/scripts/collect-review-context.sh +4 -63
  57. package/.claude/skills/cc-roadmap/PLAYBOOK.md +1 -1
  58. package/.claude/skills/cc-roadmap/SKILL.md +3 -3
  59. package/.claude/skills/cc-simplify/CHANGELOG.md +7 -0
  60. package/.claude/skills/cc-simplify/SKILL.md +26 -21
  61. package/.claude/skills/cc-spec-init/PLAYBOOK.md +12 -48
  62. package/.claude/skills/cc-spec-init/SKILL.md +29 -132
  63. package/.claude/skills/cc-spec-init/references/spec-contract.md +8 -17
  64. package/CHANGELOG.md +13 -0
  65. package/bin/cc-devflow-cli.js +20 -260
  66. package/bin/cc-devflow.js +44 -7
  67. package/docs/commands/README.md +1 -1
  68. package/docs/commands/README.zh-CN.md +1 -1
  69. package/docs/examples/README.md +1 -1
  70. package/docs/examples/START-HERE.md +14 -15
  71. package/docs/examples/example-bindings.json +11 -11
  72. package/docs/examples/full-design-blocked/README.md +4 -6
  73. package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/{planning/tasks.md → task.md} +20 -15
  74. package/docs/examples/local-handoff/README.md +8 -11
  75. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/handoff/pr-brief.md +31 -0
  76. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/{planning/tasks.md → task.md} +18 -13
  77. package/docs/examples/pdca-loop/README.md +6 -9
  78. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/handoff/pr-brief.md +9 -11
  79. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/{planning/tasks.md → task.md} +18 -13
  80. package/docs/examples/scripts/check-example-bindings.sh +11 -62
  81. package/docs/guides/artifact-contract.md +10 -40
  82. package/docs/guides/getting-started.md +8 -8
  83. package/docs/guides/getting-started.zh-CN.md +8 -8
  84. package/docs/guides/minimize-artifacts.md +16 -130
  85. package/docs/guides/project-postmortem.md +14 -71
  86. package/lib/compiler/__tests__/skills-registry.test.js +9 -8
  87. package/lib/compiler/resource-copier.js +29 -0
  88. package/lib/skill-runtime/__tests__/archive-change.test.js +2 -2
  89. package/lib/skill-runtime/__tests__/benchmark-skills.test.js +3 -3
  90. package/lib/skill-runtime/__tests__/cli-bootstrap.integration.test.js +14 -4
  91. package/lib/skill-runtime/errors.js +3 -3
  92. package/lib/skill-runtime/index.js +5 -23
  93. package/lib/skill-runtime/paths.js +5 -52
  94. package/lib/skill-runtime/query-registry.js +4 -4
  95. package/lib/skill-runtime/query.js +89 -201
  96. package/lib/skill-runtime/store.js +4 -40
  97. package/lib/skill-runtime/trace.js +2 -2
  98. package/package.json +2 -5
  99. package/.claude/skills/cc-act/assets/PROJECT_POSTMORTEM_PRINCIPLES_TEMPLATE.md +0 -29
  100. package/.claude/skills/cc-act/assets/RELEASE_NOTE_TEMPLATE.md +0 -54
  101. package/.claude/skills/cc-act/scripts/generate-status-report.sh +0 -92
  102. package/.claude/skills/cc-act/scripts/sync-act-docs.sh +0 -355
  103. package/.claude/skills/cc-check/assets/REPORT_CARD_TEMPLATE.json +0 -234
  104. package/.claude/skills/cc-check/scripts/render-report-card.js +0 -438
  105. package/.claude/skills/cc-check/scripts/verify-gate.sh +0 -85
  106. package/.claude/skills/cc-do/scripts/build-task-context.sh +0 -175
  107. package/.claude/skills/cc-do/scripts/record-review-decision.sh +0 -88
  108. package/.claude/skills/cc-do/scripts/recover-workflow.sh +0 -82
  109. package/.claude/skills/cc-do/scripts/run-problem-analysis.sh +0 -70
  110. package/.claude/skills/cc-do/scripts/verify-task-gates.sh +0 -109
  111. package/.claude/skills/cc-do/scripts/write-task-checkpoint.sh +0 -92
  112. package/.claude/skills/cc-investigate/assets/TASK_MANIFEST_TEMPLATE.json +0 -224
  113. package/.claude/skills/cc-plan/assets/TASK_MANIFEST_TEMPLATE.json +0 -178
  114. package/.claude/skills/cc-spec-init/assets/CHANGE_META_TEMPLATE.json +0 -28
  115. package/.claude/skills/cc-spec-init/scripts/validate-spec-links.sh +0 -45
  116. package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/planning/design.md +0 -234
  117. package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/planning/task-manifest.json +0 -488
  118. package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/review/report-card.json +0 -189
  119. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/handoff/resume-index.md +0 -39
  120. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/handoff/status.md +0 -29
  121. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/planning/design.md +0 -123
  122. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/planning/task-manifest.json +0 -292
  123. package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/review/report-card.json +0 -136
  124. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/handoff/status.md +0 -29
  125. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/planning/design.md +0 -124
  126. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/planning/task-manifest.json +0 -292
  127. package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/review/report-card.json +0 -136
  128. package/docs/get-shit-done-strategy-audit.md +0 -518
  129. package/docs/skill-runtime-migration.md +0 -46
  130. package/lib/skill-runtime/__tests__/approve.test.js +0 -92
  131. package/lib/skill-runtime/__tests__/autopilot.test.js +0 -253
  132. package/lib/skill-runtime/__tests__/benchmark-artifacts.test.js +0 -165
  133. package/lib/skill-runtime/__tests__/delegation.test.js +0 -97
  134. package/lib/skill-runtime/__tests__/dispatch.test.js +0 -237
  135. package/lib/skill-runtime/__tests__/intent.test.js +0 -203
  136. package/lib/skill-runtime/__tests__/lifecycle.test.js +0 -169
  137. package/lib/skill-runtime/__tests__/planner.tdd.test.js +0 -331
  138. package/lib/skill-runtime/__tests__/prepare-pr.test.js +0 -126
  139. package/lib/skill-runtime/__tests__/query.test.js +0 -860
  140. package/lib/skill-runtime/__tests__/readiness.test.js +0 -53
  141. package/lib/skill-runtime/__tests__/release.test.js +0 -85
  142. package/lib/skill-runtime/__tests__/review-check-integration.test.js +0 -148
  143. package/lib/skill-runtime/__tests__/review-records.test.js +0 -619
  144. package/lib/skill-runtime/__tests__/runtime.integration.test.js +0 -351
  145. package/lib/skill-runtime/__tests__/schemas.test.js +0 -337
  146. package/lib/skill-runtime/__tests__/task-contract-migrate.test.js +0 -137
  147. package/lib/skill-runtime/__tests__/task-contract.test.js +0 -874
  148. package/lib/skill-runtime/__tests__/team-state.test.js +0 -51
  149. package/lib/skill-runtime/__tests__/verify-artifacts.test.js +0 -203
  150. package/lib/skill-runtime/__tests__/worker-run.test.js +0 -275
  151. package/lib/skill-runtime/__tests__/worker.test.js +0 -56
  152. package/lib/skill-runtime/__tests__/workflow-context-legacy-fallback.test.js +0 -31
  153. package/lib/skill-runtime/__tests__/workflow-context.test.js +0 -98
  154. package/lib/skill-runtime/artifacts.js +0 -88
  155. package/lib/skill-runtime/context-index.js +0 -545
  156. package/lib/skill-runtime/delegation.js +0 -533
  157. package/lib/skill-runtime/intent.js +0 -309
  158. package/lib/skill-runtime/lifecycle.js +0 -294
  159. package/lib/skill-runtime/operations/CLAUDE.md +0 -19
  160. package/lib/skill-runtime/operations/approve.js +0 -81
  161. package/lib/skill-runtime/operations/autopilot-core.js +0 -337
  162. package/lib/skill-runtime/operations/autopilot-execution.js +0 -307
  163. package/lib/skill-runtime/operations/autopilot-shared.js +0 -48
  164. package/lib/skill-runtime/operations/autopilot.js +0 -163
  165. package/lib/skill-runtime/operations/dispatch.js +0 -416
  166. package/lib/skill-runtime/operations/init.js +0 -60
  167. package/lib/skill-runtime/operations/janitor.js +0 -61
  168. package/lib/skill-runtime/operations/plan.js +0 -59
  169. package/lib/skill-runtime/operations/prepare-pr.js +0 -25
  170. package/lib/skill-runtime/operations/release.js +0 -99
  171. package/lib/skill-runtime/operations/resume.js +0 -126
  172. package/lib/skill-runtime/operations/review-records.js +0 -265
  173. package/lib/skill-runtime/operations/snapshot.js +0 -45
  174. package/lib/skill-runtime/operations/task-contract.js +0 -593
  175. package/lib/skill-runtime/operations/verify.js +0 -170
  176. package/lib/skill-runtime/operations/worker-run.js +0 -531
  177. package/lib/skill-runtime/operations/worker.js +0 -33
  178. package/lib/skill-runtime/planner.js +0 -539
  179. package/lib/skill-runtime/readiness.js +0 -84
  180. package/lib/skill-runtime/review-records.js +0 -123
  181. package/lib/skill-runtime/review.js +0 -855
  182. package/lib/skill-runtime/schemas.js +0 -746
  183. package/lib/skill-runtime/task-contract.js +0 -188
  184. package/lib/skill-runtime/team-state.js +0 -122
  185. package/lib/skill-runtime/workflow-context.js +0 -748
@@ -1,309 +0,0 @@
1
- /**
2
- * [INPUT]: 依赖 store 的路径与文件读写能力,依赖 change-state/task-manifest/report-card 作为 durable truth。
3
- * [OUTPUT]: 对外提供 handoff 级工件生成与 legacy artifact 清理能力。
4
- * [POS]: skill runtime 的薄 handoff 层,只保留终态交付文件,不再投影中间态 Markdown。
5
- * [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
6
- */
7
-
8
- const {
9
- nowIso,
10
- exists,
11
- readJson,
12
- writeText,
13
- removePath,
14
- getRuntimeStatePath,
15
- getTaskManifestPath,
16
- getReportCardPath,
17
- getReleaseNotePath
18
- } = require('./store');
19
- const {
20
- deriveLifecycleStage,
21
- summarizeTaskStates,
22
- getApprovalState,
23
- deriveLifecycleNextAction,
24
- isTaskSettledStatus
25
- } = require('./lifecycle');
26
- const {
27
- getChangePaths
28
- } = require('./paths');
29
- const {
30
- getIntentResumeIndexPath,
31
- getIntentPrBriefPath,
32
- getIntentHandoffArtifactPaths,
33
- getLegacyIntentProjectionPaths,
34
- ensureIntentScaffold
35
- } = require('./artifacts');
36
-
37
- function formatList(items, empty = '- None') {
38
- if (!items || items.length === 0) {
39
- return empty;
40
- }
41
-
42
- return items.map((item) => `- ${item}`).join('\n');
43
- }
44
-
45
- function truncateLine(value, max = 120) {
46
- const normalized = String(value || '').replace(/\s+/g, ' ').trim();
47
- if (normalized.length <= max) {
48
- return normalized;
49
- }
50
-
51
- return `${normalized.slice(0, max - 3).trimEnd()}...`;
52
- }
53
-
54
- function suggestPrTitle(changeId, goal) {
55
- const prefix = changeId.startsWith('FIX-') ? 'fix' : 'feat';
56
- return `${prefix}(${changeId.toLowerCase()}): ${truncateLine(goal || changeId, 72)}`;
57
- }
58
-
59
- function summarizeGateSection(gates = []) {
60
- if (!gates.length) {
61
- return ['- None'];
62
- }
63
-
64
- return gates.map((gate) => {
65
- const duration = typeof gate.durationMs === 'number' ? `${gate.durationMs}ms` : 'n/a';
66
- return `- ${gate.name}: ${gate.status} (${duration}) via \`${gate.command}\``;
67
- });
68
- }
69
-
70
- async function cleanupLegacyArtifacts(repoRoot, changeId, manifest, options = {}) {
71
- const taskIds = (manifest?.tasks || []).map((task) => task.id);
72
- const change = getChangePaths(repoRoot, changeId, options);
73
-
74
- await Promise.all(
75
- getLegacyIntentProjectionPaths(repoRoot, changeId, taskIds, options).map((target) => removePath(target))
76
- );
77
- await removePath(change.workersDir);
78
- }
79
-
80
- async function clearHandoffArtifacts(repoRoot, changeId, keep = null, options = {}) {
81
- await Promise.all(
82
- getIntentHandoffArtifactPaths(repoRoot, changeId, options)
83
- .filter((target) => target !== keep)
84
- .map((target) => removePath(target))
85
- );
86
- }
87
-
88
- async function writeResumeIndex(repoRoot, changeId, state, manifest, report, options = {}) {
89
- await ensureIntentScaffold(repoRoot, changeId, options);
90
-
91
- const lastGoodTask = [...(manifest?.tasks || [])].reverse().find((task) => task.status === 'passed') || null;
92
- const blockers = [
93
- ...(manifest?.tasks || [])
94
- .filter((task) => task.status === 'failed')
95
- .map((task) => `${task.id}: ${task.lastError || 'Task failed'}`),
96
- ...(report?.blockingFindings || [])
97
- ];
98
- const hasPrBrief = await exists(getIntentPrBriefPath(repoRoot, changeId, options));
99
- const hasReleaseNote = await exists(getReleaseNotePath(repoRoot, changeId, options));
100
- const stage = deriveLifecycleStage({ state, manifest, report, hasPrBrief });
101
- const approval = getApprovalState(state, manifest);
102
- const goal = manifest?.goal || state?.goal || changeId;
103
- const nextAction = deriveLifecycleNextAction({
104
- state,
105
- manifest,
106
- report,
107
- hasPrBrief,
108
- hasReleaseNote
109
- });
110
- const resumePath = getIntentResumeIndexPath(repoRoot, changeId, options);
111
-
112
- const content = [
113
- `# Resume Index: ${changeId}`,
114
- '',
115
- `- Goal: ${goal}`,
116
- `- Stage: \`${stage}\``,
117
- `- Lifecycle: \`${state?.status || 'unknown'}\``,
118
- `- Approval: \`${approval.status}\``,
119
- `- Execution Mode: \`${approval.executionMode}\``,
120
- `- Plan Version: ${manifest?.metadata?.planVersion || 1}`,
121
- `- Updated At: ${nowIso()}`,
122
- '',
123
- '## Last Good Task',
124
- '',
125
- lastGoodTask
126
- ? `- \`${lastGoodTask.id}\` ${lastGoodTask.status} - ${lastGoodTask.title || 'untitled task'}`
127
- : '- No completed task yet',
128
- '',
129
- '## Blockers',
130
- '',
131
- formatList(blockers, '- None'),
132
- '',
133
- '## Next Action',
134
- '',
135
- nextAction,
136
- '',
137
- '## Durable Truth',
138
- '',
139
- formatList([
140
- `\`devflow/changes/<change>/meta/change-state.json\``,
141
- `\`devflow/changes/<change>/planning/task-manifest.json\``,
142
- `\`devflow/changes/<change>/review/report-card.json\``
143
- ])
144
- ].join('\n');
145
-
146
- await clearHandoffArtifacts(repoRoot, changeId, resumePath, options);
147
- await writeText(resumePath, `${content}\n`);
148
-
149
- return {
150
- goalId: changeId,
151
- resumePath
152
- };
153
- }
154
-
155
- async function syncIntentPrBrief(repoRoot, changeId) {
156
- await ensureIntentScaffold(repoRoot, changeId);
157
-
158
- const [state, manifest, report] = await Promise.all([
159
- readJson(getRuntimeStatePath(repoRoot, changeId), null),
160
- readJson(getTaskManifestPath(repoRoot, changeId), null),
161
- readJson(getReportCardPath(repoRoot, changeId), null)
162
- ]);
163
-
164
- if (!manifest) {
165
- throw new Error(`Cannot prepare PR brief for ${changeId}: task-manifest.json is missing`);
166
- }
167
-
168
- if (!report) {
169
- throw new Error(`Cannot prepare PR brief for ${changeId}: report-card.json is missing`);
170
- }
171
-
172
- if (report.overall !== 'pass') {
173
- throw new Error(`Cannot prepare PR brief for ${changeId}: verification has not passed`);
174
- }
175
-
176
- await cleanupLegacyArtifacts(repoRoot, changeId, manifest);
177
-
178
- const goal = manifest.goal || state?.goal || changeId;
179
- const summary = summarizeTaskStates(manifest.tasks || []);
180
- const touchedFiles = [...new Set((manifest.tasks || []).flatMap((task) => task.touches || []))];
181
- const skippedTasks = (manifest.tasks || []).filter((task) => task.status === 'skipped');
182
- const taskStatusRefs = (manifest.tasks || [])
183
- .filter((task) => isTaskSettledStatus(task.status))
184
- .map((task) => `\`${task.id}\` ${task.title} -> \`planning/tasks.md\` + \`planning/task-manifest.json\``);
185
-
186
- const risks = [
187
- ...((report.review?.status === 'skipped' || report.review?.status === 'blocked')
188
- ? ['评审门未完全闭环,合并前需要补齐 review 证据。']
189
- : []),
190
- ...(skippedTasks.length > 0
191
- ? [`存在 ${skippedTasks.length} 个 skipped 任务,需要确认是否可接受:${skippedTasks.map((task) => task.id).join(', ')}`]
192
- : []),
193
- ...(summary.failed > 0
194
- ? [`manifest 中仍有 ${summary.failed} 个 failed 任务,PR 前需要重新确认状态一致性。`]
195
- : []),
196
- ...(report.blockingFindings || [])
197
- ];
198
-
199
- const content = [
200
- `# PR Brief: ${changeId}`,
201
- '',
202
- `- Suggested Title: ${suggestPrTitle(changeId, goal)}`,
203
- `- Goal: ${goal}`,
204
- `- Lifecycle: \`${state?.status || 'verified'}\``,
205
- `- Prepared At: ${nowIso()}`,
206
- '',
207
- '## Summary',
208
- '',
209
- formatList(
210
- (manifest.tasks || [])
211
- .filter((task) => task.status === 'passed')
212
- .map((task) => `\`${task.id}\` ${task.title}`),
213
- '- No passed tasks'
214
- ),
215
- '',
216
- '## Verification',
217
- '',
218
- `- Verdict: \`${report.verdict || (report.overall === 'pass' ? 'pass' : 'fail')}\``,
219
- `- Overall: \`${report.overall}\``,
220
- `- Review: \`${report.review?.status || 'skipped'}\``,
221
- `- Blocking Findings: ${(report.blockingFindings || []).length}`,
222
- '',
223
- '### Quick Gates',
224
- '',
225
- ...summarizeGateSection(report.quickGates),
226
- '',
227
- '### Strict Gates',
228
- '',
229
- ...summarizeGateSection(report.strictGates),
230
- '',
231
- '### Review Summary',
232
- '',
233
- report.review?.summary || '- None',
234
- '',
235
- '## Risks',
236
- '',
237
- formatList(risks, '- None captured by verify; remaining risk is merge timing and manual product acceptance.'),
238
- '',
239
- '## Rollback',
240
- '',
241
- formatList([
242
- '回滚该变更分支或最终提交栈,然后重新执行 cc-check 的验证命令。',
243
- touchedFiles.length > 0
244
- ? `优先检查这些触达文件:${touchedFiles.slice(0, 8).map((file) => `\`${file}\``).join(', ')}${touchedFiles.length > 8 ? ' ...' : ''}`
245
- : '当前 manifest 未记录触达文件,回滚时以最终 diff 为准。'
246
- ]),
247
- '',
248
- '## Key Artifacts',
249
- '',
250
- formatList([
251
- `\`devflow/changes/<change>/meta/change-state.json\``,
252
- `\`devflow/changes/<change>/planning/task-manifest.json\``,
253
- `\`devflow/changes/<change>/review/report-card.json\``,
254
- ...taskStatusRefs
255
- ]),
256
- ''
257
- ].join('\n');
258
-
259
- const prBriefPath = getIntentPrBriefPath(repoRoot, changeId);
260
- await clearHandoffArtifacts(repoRoot, changeId, prBriefPath);
261
- await writeText(prBriefPath, `${content}\n`);
262
-
263
- return {
264
- goalId: changeId,
265
- prBriefPath,
266
- suggestedTitle: suggestPrTitle(changeId, goal)
267
- };
268
- }
269
-
270
- async function syncIntentMemory(repoRoot, changeId, options = {}) {
271
- await ensureIntentScaffold(repoRoot, changeId);
272
-
273
- const [state, manifest, report] = await Promise.all([
274
- readJson(getRuntimeStatePath(repoRoot, changeId), null),
275
- readJson(getTaskManifestPath(repoRoot, changeId), null),
276
- readJson(getReportCardPath(repoRoot, changeId), null)
277
- ]);
278
-
279
- await cleanupLegacyArtifacts(repoRoot, changeId, manifest);
280
-
281
- if (options.handoff === 'resume') {
282
- return writeResumeIndex(repoRoot, changeId, state, manifest, report);
283
- }
284
-
285
- const prBriefPath = getIntentPrBriefPath(repoRoot, changeId);
286
- const releaseNotePath = getReleaseNotePath(repoRoot, changeId);
287
- const hasPrBrief = await exists(prBriefPath);
288
- const hasReleaseNote = await exists(releaseNotePath);
289
- const stage = deriveLifecycleStage({ state, manifest, report, hasPrBrief });
290
-
291
- if (hasReleaseNote) {
292
- await clearHandoffArtifacts(repoRoot, changeId, releaseNotePath);
293
- } else if (hasPrBrief) {
294
- await clearHandoffArtifacts(repoRoot, changeId, prBriefPath);
295
- } else {
296
- await clearHandoffArtifacts(repoRoot, changeId, null);
297
- }
298
-
299
- return {
300
- goalId: changeId,
301
- stage,
302
- resumePath: hasPrBrief || hasReleaseNote ? null : getIntentResumeIndexPath(repoRoot, changeId)
303
- };
304
- }
305
-
306
- module.exports = {
307
- syncIntentPrBrief,
308
- syncIntentMemory
309
- };
@@ -1,294 +0,0 @@
1
- /**
2
- * [INPUT]: 依赖 harness-state/task-manifest/report-card 的内存对象,接收 stage 名与任务元数据。
3
- * [OUTPUT]: 对外提供 lifecycle 阶段判定、approval 解析、下一步动作建议、执行模式归一化与 direct/delegate/team 路由决策。
4
- * [POS]: skill runtime 的共享生命周期语义层,让 query/intent/autopilot/dispatch 使用同一套运行时词汇与阶段建议。
5
- * [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
6
- */
7
-
8
- const STAGE_ORDER = [
9
- 'discover',
10
- 'converge',
11
- 'approve',
12
- 'delegate',
13
- 'execute',
14
- 'verify',
15
- 'document',
16
- 'prepare-pr',
17
- 'released'
18
- ];
19
-
20
- function normalizeStage(stage) {
21
- if (!stage) {
22
- return null;
23
- }
24
-
25
- const aliases = {
26
- init: 'discover',
27
- snapshot: 'discover',
28
- plan: 'converge',
29
- approval: 'approve',
30
- approved: 'approve',
31
- 'awaiting-approval': 'approve',
32
- awaiting_approval: 'approve',
33
- spec: 'converge',
34
- dispatch: 'execute',
35
- resume: 'execute',
36
- release: 'prepare-pr'
37
- };
38
-
39
- return aliases[stage] || stage;
40
- }
41
-
42
- function stageIndex(stage) {
43
- const normalized = normalizeStage(stage);
44
- if (!normalized) {
45
- return 0;
46
- }
47
-
48
- const index = STAGE_ORDER.indexOf(normalized);
49
- if (index === -1) {
50
- throw new Error(`Unknown autopilot stage: ${stage}`);
51
- }
52
-
53
- return index;
54
- }
55
-
56
- function normalizeExecutionMode(mode) {
57
- if (['direct', 'delegate', 'team'].includes(mode)) {
58
- return mode;
59
- }
60
-
61
- return 'delegate';
62
- }
63
-
64
- function normalizeTaskStatus(status) {
65
- const aliases = {
66
- completed: 'passed',
67
- done: 'passed',
68
- verified: 'passed'
69
- };
70
-
71
- return aliases[status] || status || 'pending';
72
- }
73
-
74
- function isTaskCompletedStatus(status) {
75
- return normalizeTaskStatus(status) === 'passed';
76
- }
77
-
78
- function isTaskSettledStatus(status) {
79
- return isTaskCompletedStatus(status) || status === 'skipped';
80
- }
81
-
82
- function summarizeTaskStates(tasks = []) {
83
- return tasks.reduce(
84
- (acc, task) => {
85
- const normalizedStatus = normalizeTaskStatus(task.status);
86
- acc[normalizedStatus] = (acc[normalizedStatus] || 0) + 1;
87
- return acc;
88
- },
89
- { pending: 0, running: 0, passed: 0, failed: 0, skipped: 0 }
90
- );
91
- }
92
-
93
- function deriveTaskProgress(tasks = []) {
94
- const summary = summarizeTaskStates(tasks);
95
-
96
- return {
97
- totalTasks: tasks.length,
98
- completedTasks: summary.passed,
99
- failedTasks: summary.failed,
100
- pendingTasks: summary.pending,
101
- runningTasks: summary.running,
102
- skippedTasks: summary.skipped
103
- };
104
- }
105
-
106
- function listTaskIdsByStatus(tasks = [], status) {
107
- return tasks
108
- .filter((task) => task.status === status)
109
- .map((task) => task.id);
110
- }
111
-
112
- function getApprovalState(state, manifest = null) {
113
- const currentPlanVersion = manifest?.metadata?.planVersion || state?.approval?.planVersion || null;
114
- const executionMode = normalizeExecutionMode(state?.approval?.executionMode);
115
- const approvedPlanVersion = state?.approval?.planVersion || null;
116
- const approved = Boolean(
117
- currentPlanVersion &&
118
- state?.approval?.status === 'approved' &&
119
- approvedPlanVersion === currentPlanVersion
120
- );
121
-
122
- return {
123
- status: approved ? 'approved' : 'pending',
124
- executionMode,
125
- planVersion: currentPlanVersion,
126
- approvedPlanVersion,
127
- approvedAt: approved ? state?.approval?.approvedAt || null : null
128
- };
129
- }
130
-
131
- function isExecutionApproved(state, manifest) {
132
- return getApprovalState(state, manifest).status === 'approved';
133
- }
134
-
135
- function classifyDelegationMode(task, options = {}) {
136
- const commandCount = (task.run || []).length + (task.checks || []).length;
137
- const executionMode = normalizeExecutionMode(
138
- options.executionMode || options.approval?.executionMode || options.state?.approval?.executionMode
139
- );
140
- const teamCandidate = (task.touches || []).length >= 4 || (task.dependsOn || []).length >= 3;
141
-
142
- if (executionMode === 'direct') {
143
- return 'direct';
144
- }
145
-
146
- if (executionMode === 'team' && teamCandidate) {
147
- return 'team';
148
- }
149
-
150
- if (
151
- commandCount > 1 ||
152
- (task.touches || []).length > 1 ||
153
- (task.dependsOn || []).length > 0 ||
154
- teamCandidate
155
- ) {
156
- return 'delegate';
157
- }
158
-
159
- return 'direct';
160
- }
161
-
162
- function deriveLifecycleStage({ state, manifest, report, hasPrBrief = false }) {
163
- const approval = getApprovalState(state, manifest);
164
-
165
- if (state?.status === 'released') {
166
- return 'released';
167
- }
168
-
169
- if (report?.overall === 'pass' && hasPrBrief) {
170
- return 'prepare-pr';
171
- }
172
-
173
- if (report?.overall === 'pass') {
174
- return 'document';
175
- }
176
-
177
- if (report?.overall === 'fail') {
178
- return 'verify';
179
- }
180
-
181
- if (manifest && approval.status !== 'approved') {
182
- return 'approve';
183
- }
184
-
185
- if (manifest) {
186
- const summary = summarizeTaskStates(manifest.tasks);
187
- if (summary.running > 0 || summary.failed > 0 || summary.pending > 0) {
188
- return state?.status === 'planned' ? 'delegate' : 'execute';
189
- }
190
- if (summary.passed > 0 || summary.skipped > 0) {
191
- return 'verify';
192
- }
193
- }
194
-
195
- if (state?.status === 'planned') {
196
- return 'delegate';
197
- }
198
-
199
- if (state?.status === 'initialized') {
200
- return 'discover';
201
- }
202
-
203
- return 'converge';
204
- }
205
-
206
- function describeExecutionNextAction({ failedTaskIds, runningTaskIds, pendingTaskIds, report }) {
207
- if (failedTaskIds.length > 0) {
208
- return `优先修复失败任务 ${failedTaskIds.join(', ')},然后从 task-manifest 的最近稳定状态恢复。`;
209
- }
210
-
211
- if (runningTaskIds.length > 0) {
212
- return `检查运行中任务 ${runningTaskIds.join(', ')}。`;
213
- }
214
-
215
- if (pendingTaskIds.length > 0) {
216
- return `继续执行待处理任务 ${pendingTaskIds.join(', ')}。`;
217
- }
218
-
219
- if (!report) {
220
- return '所有任务已完成,进入 cc-check 并同步验证证据。';
221
- }
222
-
223
- if (report.overall === 'fail') {
224
- return '修复 blocking findings 后重新进入 cc-check。';
225
- }
226
-
227
- return '验证已通过,按实际路由生成唯一 handoff 文件。';
228
- }
229
-
230
- const DEFAULT_NEXT_ACTION = '生成或刷新 task-manifest,然后回到批准闸。';
231
-
232
- const NEXT_ACTION_RESOLVERS = {
233
- discover: () => DEFAULT_NEXT_ACTION,
234
- converge: () => DEFAULT_NEXT_ACTION,
235
- approve: ({ approval }) => `先批准当前计划版本 ${approval.planVersion || 1},再进入执行。`,
236
- delegate: describeExecutionNextAction,
237
- execute: describeExecutionNextAction,
238
- verify: describeExecutionNextAction,
239
- document: ({ hasReleaseNote }) => (
240
- hasReleaseNote
241
- ? '发布材料已经生成,可归档或启动下一轮增量。'
242
- : '验证已通过,按实际路由生成唯一 handoff 文件。'
243
- ),
244
- 'prepare-pr': ({ hasPrBrief, hasReleaseNote }) => {
245
- if (hasReleaseNote) {
246
- return '发布材料已经生成,可归档或启动下一轮增量。';
247
- }
248
-
249
- if (hasPrBrief) {
250
- return 'PR brief 已生成,可直接整理提交并创建 PR。';
251
- }
252
-
253
- return '验证已通过,按实际路由生成唯一 handoff 文件。';
254
- },
255
- released: () => '发布材料已经生成,可归档或启动下一轮增量。'
256
- };
257
-
258
- function deriveLifecycleNextAction({
259
- state,
260
- manifest,
261
- report,
262
- hasPrBrief = false,
263
- hasReleaseNote = false
264
- }) {
265
- const stage = deriveLifecycleStage({ state, manifest, report, hasPrBrief });
266
- const resolver = NEXT_ACTION_RESOLVERS[stage] || NEXT_ACTION_RESOLVERS.converge;
267
-
268
- return resolver({
269
- approval: getApprovalState(state, manifest),
270
- report,
271
- hasPrBrief,
272
- hasReleaseNote,
273
- failedTaskIds: listTaskIdsByStatus(manifest?.tasks, 'failed'),
274
- runningTaskIds: listTaskIdsByStatus(manifest?.tasks, 'running'),
275
- pendingTaskIds: listTaskIdsByStatus(manifest?.tasks, 'pending')
276
- });
277
- }
278
-
279
- module.exports = {
280
- STAGE_ORDER,
281
- normalizeStage,
282
- stageIndex,
283
- normalizeExecutionMode,
284
- normalizeTaskStatus,
285
- isTaskCompletedStatus,
286
- isTaskSettledStatus,
287
- summarizeTaskStates,
288
- deriveTaskProgress,
289
- getApprovalState,
290
- isExecutionApproved,
291
- classifyDelegationMode,
292
- deriveLifecycleStage,
293
- deriveLifecycleNextAction
294
- };
@@ -1,19 +0,0 @@
1
- # operations/
2
- > L2 | 父级: ../CLAUDE.md
3
-
4
- 阶段分组
5
- 初始化与快照: `init.js` 创建 runtime 骨架,`snapshot.js` 采集 discover 阶段需要的只读事实。
6
- 计划与批准: `plan.js` 生成 `task-manifest.json`,`approve.js` 锁定批准版本与执行模式。
7
- 执行主链: `dispatch.js` 推进当前任务前沿,`resume.js` 从 `task-manifest.json` 的稳定状态恢复,`verify.js` 和 `release.js` 负责质量门与发布收口。
8
- 交接与工人: `prepare-pr.js` 生成唯一 PR brief,`worker.js`/`worker-run.js` 负责本地或 provider worker handoff 与回写。
9
- 自动驾驶: `autopilot-shared.js`、`autopilot-core.js`、`autopilot-execution.js`、`autopilot.js` 拆开共享语义、阶段判定和执行循环,避免单文件失控。
10
- 维护类: `janitor.js` 清理过期 runtime 工件,但不改变 manifest / tasks 的真相源。
11
-
12
- 更新规则
13
- 这里只记录阶段入口和职责边界,不维护逐文件穷举说明。
14
- 新增 operation 如果只是归入已有阶段,不改此文档;只有出现新阶段或边界迁移时才更新。
15
- 阶段入口只保留当前真相源,不为历史别名单独占坑。
16
-
17
- 法则: 阶段先于文件名·边界先于清单·父级链接稳定
18
-
19
- [PROTOCOL]: 变更阶段边界或入口约定时更新此头部,然后检查 CLAUDE.md
@@ -1,81 +0,0 @@
1
- /**
2
- * [INPUT]: 依赖 change-state/task-manifest 与 handoff memory,同步接收 changeId 与 executionMode。
3
- * [OUTPUT]: 为当前 plan_version 写入唯一 approval 真相,并返回批准摘要。
4
- * [POS]: skill runtime 的显式批准入口,专门负责把计划从 converge 推进到可执行态。
5
- * [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
6
- */
7
-
8
- const {
9
- nowIso,
10
- readJson,
11
- writeJson,
12
- getRuntimeStatePath,
13
- getTaskManifestPath
14
- } = require('../store');
15
- const { parseRuntimeState, parseManifest } = require('../schemas');
16
- const { syncIntentMemory } = require('../intent');
17
- const { normalizeExecutionMode } = require('../lifecycle');
18
- const { namedError } = require('../errors');
19
-
20
- async function runApprove({ repoRoot, changeId, executionMode }) {
21
- const statePath = getRuntimeStatePath(repoRoot, changeId);
22
- const manifestPath = getTaskManifestPath(repoRoot, changeId);
23
- const rawState = await readJson(statePath, null);
24
- const rawManifest = await readJson(manifestPath, null);
25
-
26
- if (!rawState) {
27
- throw namedError(
28
- 'MissingChangeStateError',
29
- `Cannot approve ${changeId}: change-state.json is missing`,
30
- {
31
- artifactRefs: [statePath],
32
- rescueAction: 'run cc-roadmap or cc-plan init before approving execution'
33
- }
34
- );
35
- }
36
-
37
- if (!rawManifest) {
38
- throw namedError(
39
- 'MissingTaskManifestError',
40
- `Cannot approve ${changeId}: task-manifest.json is missing`,
41
- {
42
- artifactRefs: [manifestPath],
43
- rescueAction: 'run cc-plan to create planning/task-manifest.json before approving execution'
44
- }
45
- );
46
- }
47
-
48
- const state = parseRuntimeState(rawState);
49
- const manifest = parseManifest(rawManifest);
50
- const approvedAt = nowIso();
51
- const nextExecutionMode = normalizeExecutionMode(executionMode || state.approval?.executionMode);
52
-
53
- await writeJson(statePath, {
54
- ...state,
55
- approval: {
56
- status: 'approved',
57
- executionMode: nextExecutionMode,
58
- planVersion: manifest.metadata?.planVersion || 1,
59
- approvedAt
60
- },
61
- updatedAt: approvedAt
62
- });
63
-
64
- await syncIntentMemory(repoRoot, changeId, {
65
- event: 'approval_granted',
66
- reason: `Plan version ${manifest.metadata?.planVersion || 1} approved for ${nextExecutionMode} execution`
67
- });
68
-
69
- return {
70
- changeId,
71
- statePath,
72
- status: 'approved',
73
- executionMode: nextExecutionMode,
74
- planVersion: manifest.metadata?.planVersion || 1,
75
- approvedAt
76
- };
77
- }
78
-
79
- module.exports = {
80
- runApprove
81
- };