cc-devflow 4.5.8 → 4.5.10
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.
- package/.claude/skills/cc-act/CHANGELOG.md +33 -0
- package/.claude/skills/cc-act/PLAYBOOK.md +9 -4
- package/.claude/skills/cc-act/SKILL.md +73 -12
- package/.claude/skills/cc-act/assets/PROJECT_POSTMORTEM_INDEX_TEMPLATE.md +30 -0
- package/.claude/skills/cc-act/assets/PROJECT_POSTMORTEM_PRINCIPLES_TEMPLATE.md +29 -0
- package/.claude/skills/cc-act/assets/PROJECT_POSTMORTEM_TEMPLATE.md +103 -0
- package/.claude/skills/cc-act/assets/PR_BRIEF_TEMPLATE.md +61 -5
- package/.claude/skills/cc-act/references/closure-contract.md +4 -1
- package/.claude/skills/cc-act/references/git-commit-guidelines.md +342 -37
- package/.claude/skills/cc-act/scripts/cc-act-common.sh +29 -1
- package/.claude/skills/cc-act/scripts/render-pr-brief.sh +164 -0
- package/.claude/skills/cc-act/scripts/sync-act-docs.sh +1 -1
- package/.claude/skills/cc-check/CHANGELOG.md +17 -0
- package/.claude/skills/cc-check/PLAYBOOK.md +1 -0
- package/.claude/skills/cc-check/SKILL.md +9 -5
- package/.claude/skills/cc-check/references/review-contract.md +7 -0
- package/.claude/skills/cc-check/scripts/render-report-card.js +6 -1
- package/.claude/skills/cc-dev/CHANGELOG.md +5 -0
- package/.claude/skills/cc-dev/SKILL.md +26 -1
- package/.claude/skills/cc-do/CHANGELOG.md +23 -0
- package/.claude/skills/cc-do/PLAYBOOK.md +7 -7
- package/.claude/skills/cc-do/SKILL.md +49 -45
- package/.claude/skills/cc-do/references/execution-recovery.md +18 -13
- package/.claude/skills/cc-do/scripts/build-task-context.sh +13 -22
- package/.claude/skills/cc-do/scripts/mark-task-complete.sh +0 -6
- package/.claude/skills/cc-do/scripts/record-review-decision.sh +4 -5
- package/.claude/skills/cc-do/scripts/recover-workflow.sh +9 -11
- package/.claude/skills/cc-do/scripts/verify-task-gates.sh +12 -10
- package/.claude/skills/cc-do/scripts/write-task-checkpoint.sh +7 -29
- package/.claude/skills/cc-investigate/CHANGELOG.md +34 -0
- package/.claude/skills/cc-investigate/PLAYBOOK.md +21 -5
- package/.claude/skills/cc-investigate/SKILL.md +97 -40
- package/.claude/skills/cc-investigate/assets/TASKS_TEMPLATE.md +66 -4
- package/.claude/skills/cc-investigate/assets/TASK_MANIFEST_TEMPLATE.json +30 -59
- package/.claude/skills/cc-investigate/assets/{ANALYSIS_TEMPLATE.md → legacy/ANALYSIS_TEMPLATE.md} +48 -0
- package/.claude/skills/cc-investigate/references/investigation-contract.md +16 -2
- package/.claude/skills/cc-investigate/scripts/bootstrap-analysis.sh +1 -1
- package/.claude/skills/cc-next/CHANGELOG.md +6 -0
- package/.claude/skills/cc-next/PLAYBOOK.md +26 -4
- package/.claude/skills/cc-next/SKILL.md +39 -4
- package/.claude/skills/cc-plan/CHANGELOG.md +38 -0
- package/.claude/skills/cc-plan/PLAYBOOK.md +60 -53
- package/.claude/skills/cc-plan/SKILL.md +164 -87
- package/.claude/skills/cc-plan/assets/TASKS_TEMPLATE.md +101 -9
- package/.claude/skills/cc-plan/assets/TASK_MANIFEST_TEMPLATE.json +58 -229
- package/.claude/skills/cc-plan/assets/{DESIGN_TEMPLATE.md → legacy/DESIGN_TEMPLATE.md} +68 -0
- package/.claude/skills/cc-plan/assets/{TINY_DESIGN_TEMPLATE.md → legacy/TINY_DESIGN_TEMPLATE.md} +47 -1
- package/.claude/skills/cc-plan/references/planning-contract.md +48 -33
- package/.claude/skills/cc-review/CHANGELOG.md +6 -0
- package/.claude/skills/cc-review/PLAYBOOK.md +9 -11
- package/.claude/skills/cc-review/SKILL.md +37 -61
- package/.claude/skills/cc-review/references/e2e-and-plugin-verification.md +1 -1
- package/.claude/skills/cc-review/references/implementation-review-branch.md +5 -5
- package/.claude/skills/cc-review/references/plan-review-branch.md +1 -1
- package/.claude/skills/cc-review/references/review-methods.md +4 -4
- package/.claude/skills/cc-review/scripts/collect-review-context.sh +14 -7
- package/.claude/skills/cc-roadmap/CHANGELOG.md +6 -0
- package/.claude/skills/cc-roadmap/PLAYBOOK.md +30 -0
- package/.claude/skills/cc-roadmap/SKILL.md +45 -8
- package/.claude/skills/cc-roadmap/assets/BACKLOG_TEMPLATE.md +8 -0
- package/.claude/skills/cc-roadmap/assets/ROADMAP_TEMPLATE.md +22 -0
- package/.claude/skills/cc-roadmap/assets/TRACKING_TEMPLATE.json +32 -1
- package/.claude/skills/cc-roadmap/references/roadmap-dialogue.md +14 -14
- package/CHANGELOG.md +28 -0
- package/CONTRIBUTING.md +40 -4
- package/CONTRIBUTING.zh-CN.md +40 -4
- package/README.md +57 -43
- package/README.zh-CN.md +57 -43
- package/bin/cc-devflow-cli.js +293 -36
- package/docs/examples/START-HERE.md +5 -4
- package/docs/examples/example-bindings.json +10 -10
- package/docs/examples/full-design-blocked/BACKLOG.md +1 -1
- package/docs/examples/full-design-blocked/README.md +2 -2
- package/docs/examples/full-design-blocked/ROADMAP.md +1 -1
- package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/planning/design.md +2 -1
- package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/planning/task-manifest.json +29 -312
- package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/planning/tasks.md +11 -8
- package/docs/examples/full-design-blocked/changes/REQ-002-bulk-invite-import/review/report-card.json +4 -4
- package/docs/examples/full-design-blocked/roadmap.json +1 -1
- package/docs/examples/local-handoff/BACKLOG.md +1 -1
- package/docs/examples/local-handoff/README.md +2 -2
- package/docs/examples/local-handoff/ROADMAP.md +1 -1
- package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/planning/design.md +2 -1
- package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/planning/task-manifest.json +27 -210
- package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/planning/tasks.md +9 -6
- package/docs/examples/local-handoff/changes/REQ-003-audit-log-export/review/report-card.json +1 -1
- package/docs/examples/local-handoff/roadmap.json +1 -1
- package/docs/examples/pdca-loop/BACKLOG.md +1 -1
- package/docs/examples/pdca-loop/README.md +2 -2
- package/docs/examples/pdca-loop/ROADMAP.md +1 -1
- package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/handoff/pr-brief.md +65 -1
- package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/planning/design.md +2 -1
- package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/planning/task-manifest.json +26 -228
- package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/planning/tasks.md +9 -6
- package/docs/examples/pdca-loop/changes/REQ-001-copy-invite-link/review/report-card.json +1 -1
- package/docs/examples/pdca-loop/roadmap.json +1 -1
- package/docs/examples/scripts/check-example-bindings.sh +11 -5
- package/docs/get-shit-done-strategy-audit.md +22 -22
- package/docs/guides/artifact-contract.md +44 -0
- package/docs/guides/getting-started.md +10 -8
- package/docs/guides/getting-started.zh-CN.md +10 -8
- package/docs/guides/minimize-artifacts.md +123 -0
- package/docs/guides/project-postmortem.md +78 -0
- package/lib/compiler/__tests__/skills-registry.test.js +2 -2
- package/lib/skill-runtime/CLAUDE.md +1 -1
- package/lib/skill-runtime/__tests__/autopilot.test.js +42 -6
- package/lib/skill-runtime/__tests__/benchmark-artifacts.test.js +165 -0
- package/lib/skill-runtime/__tests__/cli-bootstrap.integration.test.js +2 -2
- package/lib/skill-runtime/__tests__/dispatch.test.js +8 -38
- package/lib/skill-runtime/__tests__/intent.test.js +4 -20
- package/lib/skill-runtime/__tests__/lifecycle.test.js +1 -1
- package/lib/skill-runtime/__tests__/paths.test.js +7 -1
- package/lib/skill-runtime/__tests__/planner.tdd.test.js +63 -2
- package/lib/skill-runtime/__tests__/prepare-pr.test.js +3 -16
- package/lib/skill-runtime/__tests__/query.test.js +388 -7
- package/lib/skill-runtime/__tests__/review-check-integration.test.js +148 -0
- package/lib/skill-runtime/__tests__/review-records.test.js +619 -0
- package/lib/skill-runtime/__tests__/runtime.integration.test.js +64 -23
- package/lib/skill-runtime/__tests__/schemas.test.js +76 -2
- package/lib/skill-runtime/__tests__/task-contract-migrate.test.js +137 -0
- package/lib/skill-runtime/__tests__/task-contract.test.js +783 -0
- package/lib/skill-runtime/__tests__/verify-artifacts.test.js +203 -0
- package/lib/skill-runtime/__tests__/worker-run.test.js +4 -11
- package/lib/skill-runtime/__tests__/workflow-context-legacy-fallback.test.js +31 -0
- package/lib/skill-runtime/__tests__/workflow-context.test.js +98 -0
- package/lib/skill-runtime/artifacts.js +0 -5
- package/lib/skill-runtime/context-index.js +545 -0
- package/lib/skill-runtime/intent.js +9 -33
- package/lib/skill-runtime/lifecycle.js +1 -1
- package/lib/skill-runtime/operations/CLAUDE.md +2 -2
- package/lib/skill-runtime/operations/dispatch.js +4 -42
- package/lib/skill-runtime/operations/init.js +2 -6
- package/lib/skill-runtime/operations/janitor.js +2 -18
- package/lib/skill-runtime/operations/resume.js +21 -38
- package/lib/skill-runtime/operations/review-records.js +265 -0
- package/lib/skill-runtime/operations/snapshot.js +1 -1
- package/lib/skill-runtime/operations/task-contract.js +524 -0
- package/lib/skill-runtime/operations/worker-run.js +2 -30
- package/lib/skill-runtime/paths.js +4 -4
- package/lib/skill-runtime/planner.js +25 -13
- package/lib/skill-runtime/query-registry.js +2 -2
- package/lib/skill-runtime/query.js +16 -3
- package/lib/skill-runtime/review-records.js +123 -0
- package/lib/skill-runtime/review.js +246 -11
- package/lib/skill-runtime/schemas.js +179 -15
- package/lib/skill-runtime/store.js +0 -10
- package/lib/skill-runtime/task-contract.js +187 -0
- package/lib/skill-runtime/workflow-context.js +748 -0
- package/package.json +7 -4
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [INPUT]: workflow-context 的源 artifact 路径、manifest、当前 task、report。
|
|
3
|
+
* [OUTPUT]: 生成 context index 所需的 source hash、must-not-forget、open refs 与 digest。
|
|
4
|
+
* [POS]: skill runtime 的上下文索引构造层;只做只读索引,不决定 workflow 路由。
|
|
5
|
+
* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const crypto = require('crypto');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
function dedupe(values) {
|
|
13
|
+
return [...new Set((values || []).filter(Boolean))];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function stableStringify(value) {
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return `[${value.map(stableStringify).join(',')}]`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (value && typeof value === 'object') {
|
|
22
|
+
return `{${Object.keys(value).sort().map((key) => (
|
|
23
|
+
`${JSON.stringify(key)}:${stableStringify(value[key])}`
|
|
24
|
+
)).join(',')}}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return JSON.stringify(value);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function digestValue(value) {
|
|
31
|
+
if (value === null || value === undefined) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return crypto
|
|
36
|
+
.createHash('sha256')
|
|
37
|
+
.update(stableStringify(value))
|
|
38
|
+
.digest('hex')
|
|
39
|
+
.slice(0, 16);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function fileExists(filePath) {
|
|
43
|
+
if (!filePath) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
await fs.promises.access(filePath);
|
|
49
|
+
return true;
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function hashFile(filePath) {
|
|
56
|
+
if (!(await fileExists(filePath))) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const bytes = await fs.promises.readFile(filePath);
|
|
61
|
+
return `sha256:${crypto
|
|
62
|
+
.createHash('sha256')
|
|
63
|
+
.update(bytes)
|
|
64
|
+
.digest('hex')}`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function digestFile(filePath) {
|
|
68
|
+
const hash = await hashFile(filePath);
|
|
69
|
+
return hash ? hash.replace(/^sha256:/, '').slice(0, 16) : null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function withFragment(filePath, fragment) {
|
|
73
|
+
return filePath && fragment ? `${filePath}#${fragment}` : filePath;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function splitRef(ref) {
|
|
77
|
+
const [filePath, fragment = ''] = String(ref || '').split('#');
|
|
78
|
+
return { filePath, fragment };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function limitList(values, limit = 6) {
|
|
82
|
+
return dedupe(values)
|
|
83
|
+
.map((value) => String(value || '').trim())
|
|
84
|
+
.filter(Boolean)
|
|
85
|
+
.slice(0, limit);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function stripMarkdownBullet(line) {
|
|
89
|
+
return String(line || '')
|
|
90
|
+
.replace(/^\s*[-*]\s+/, '')
|
|
91
|
+
.replace(/`/g, '')
|
|
92
|
+
.trim();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function readTextIfExists(filePath) {
|
|
96
|
+
if (!(await fileExists(filePath))) {
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return fs.promises.readFile(filePath, 'utf8');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function extractHeadingSection(markdown, headingPattern) {
|
|
104
|
+
const lines = String(markdown || '').split('\n');
|
|
105
|
+
const start = lines.findIndex((line) => headingPattern.test(line));
|
|
106
|
+
if (start === -1) {
|
|
107
|
+
return '';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const level = (lines[start].match(/^#+/) || [''])[0].length;
|
|
111
|
+
const end = lines.findIndex((line, index) => (
|
|
112
|
+
index > start
|
|
113
|
+
&& /^#+\s/.test(line)
|
|
114
|
+
&& (line.match(/^#+/) || [''])[0].length <= level
|
|
115
|
+
));
|
|
116
|
+
|
|
117
|
+
return lines.slice(start, end === -1 ? lines.length : end).join('\n');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function extractBulletsFromSections(markdown, headingPatterns, limit = 6) {
|
|
121
|
+
const bullets = [];
|
|
122
|
+
for (const pattern of headingPatterns) {
|
|
123
|
+
const section = extractHeadingSection(markdown, pattern);
|
|
124
|
+
if (!section) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (const line of section.split('\n')) {
|
|
129
|
+
if (/^\s*[-*]\s+/.test(line)) {
|
|
130
|
+
bullets.push(stripMarkdownBullet(line));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return limitList(bullets, limit);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function extractNestedBulletsAfterMarker(markdown, markerPattern, limit = 6) {
|
|
139
|
+
const lines = String(markdown || '').split('\n');
|
|
140
|
+
const markerIndex = lines.findIndex((line) => markerPattern.test(line));
|
|
141
|
+
if (markerIndex === -1) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const bullets = [];
|
|
146
|
+
for (let index = markerIndex + 1; index < lines.length; index += 1) {
|
|
147
|
+
const line = lines[index];
|
|
148
|
+
if (/^#+\s/.test(line)) {
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
if (!/^\s*[-*]\s+/.test(line)) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (/^\s{2,}[-*]\s+/.test(line)) {
|
|
155
|
+
bullets.push(stripMarkdownBullet(line));
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (bullets.length > 0) {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return limitList(bullets, limit);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function sourceHashForRef(source, ref) {
|
|
167
|
+
const { filePath } = splitRef(ref);
|
|
168
|
+
const match = Object.values(source || {}).find((entry) => entry?.path === filePath);
|
|
169
|
+
return match?.hash || null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function openRef(ref, reason, source) {
|
|
173
|
+
if (!ref) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
ref,
|
|
179
|
+
reason,
|
|
180
|
+
sourceHash: sourceHashForRef(source, ref)
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function slugifyHeading(value) {
|
|
185
|
+
return String(value || '')
|
|
186
|
+
.trim()
|
|
187
|
+
.toLowerCase()
|
|
188
|
+
.replace(/`/g, '')
|
|
189
|
+
.replace(/[^\p{L}\p{N}\s-]/gu, '')
|
|
190
|
+
.replace(/\s+/g, '-');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function markdownHeadings(markdown) {
|
|
194
|
+
return String(markdown || '')
|
|
195
|
+
.split('\n')
|
|
196
|
+
.map((line) => {
|
|
197
|
+
const match = line.match(/^#+\s+(.+?)\s*$/);
|
|
198
|
+
return match ? match[1].trim() : null;
|
|
199
|
+
})
|
|
200
|
+
.filter(Boolean);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function jsonPointerExists(value, pointer) {
|
|
204
|
+
if (!pointer) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (pointer === '/summary') {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (pointer.startsWith('/tasks/')) {
|
|
213
|
+
const taskId = pointer.slice('/tasks/'.length);
|
|
214
|
+
return Array.isArray(value?.tasks) && value.tasks.some((task) => task.id === taskId);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return pointer
|
|
218
|
+
.split('/')
|
|
219
|
+
.filter(Boolean)
|
|
220
|
+
.reduce((current, segment) => {
|
|
221
|
+
if (current === undefined || current === null) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const key = segment.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
226
|
+
return current[key];
|
|
227
|
+
}, value) !== undefined;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function fallbackMarkdownRef(relativePath, headings) {
|
|
231
|
+
const preferred = [
|
|
232
|
+
'Progressive Disclosure Index',
|
|
233
|
+
'Frozen Design Card',
|
|
234
|
+
'Approved Direction',
|
|
235
|
+
'Requirement Snapshot',
|
|
236
|
+
'Validation',
|
|
237
|
+
'Main Risk'
|
|
238
|
+
];
|
|
239
|
+
const heading = preferred.find((candidate) => (
|
|
240
|
+
headings.some((actual) => slugifyHeading(actual) === slugifyHeading(candidate))
|
|
241
|
+
)) || headings[0];
|
|
242
|
+
|
|
243
|
+
return heading ? withFragment(relativePath, slugifyHeading(heading)) : relativePath;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function validateRef(entry, repoRoot) {
|
|
247
|
+
if (!entry?.ref || entry.ref.includes('<change-key>')) {
|
|
248
|
+
return entry;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const { filePath, fragment } = splitRef(entry.ref);
|
|
252
|
+
const absolutePath = path.join(repoRoot, filePath);
|
|
253
|
+
if (!(await fileExists(absolutePath))) {
|
|
254
|
+
return {
|
|
255
|
+
...entry,
|
|
256
|
+
exists: false,
|
|
257
|
+
manifestIssue: `missing referenced artifact: ${filePath}`
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (!fragment) {
|
|
262
|
+
return { ...entry, exists: true };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (filePath.endsWith('.json')) {
|
|
266
|
+
try {
|
|
267
|
+
const value = JSON.parse(await fs.promises.readFile(absolutePath, 'utf8'));
|
|
268
|
+
const exists = jsonPointerExists(value, fragment);
|
|
269
|
+
return exists ? { ...entry, exists: true } : {
|
|
270
|
+
...entry,
|
|
271
|
+
exists: false,
|
|
272
|
+
fallbackRef: filePath,
|
|
273
|
+
manifestIssue: `missing JSON pointer ${fragment} in ${filePath}`
|
|
274
|
+
};
|
|
275
|
+
} catch {
|
|
276
|
+
return {
|
|
277
|
+
...entry,
|
|
278
|
+
exists: false,
|
|
279
|
+
fallbackRef: filePath,
|
|
280
|
+
manifestIssue: `invalid JSON while validating ${entry.ref}`
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (filePath.endsWith('.md')) {
|
|
286
|
+
const text = await fs.promises.readFile(absolutePath, 'utf8');
|
|
287
|
+
const headings = markdownHeadings(text);
|
|
288
|
+
const exists = headings.some((heading) => slugifyHeading(heading) === slugifyHeading(fragment));
|
|
289
|
+
return exists ? { ...entry, exists: true } : {
|
|
290
|
+
...entry,
|
|
291
|
+
exists: false,
|
|
292
|
+
fallbackRef: fallbackMarkdownRef(filePath, headings),
|
|
293
|
+
manifestIssue: `missing markdown section ${fragment} in ${filePath}`
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return { ...entry, exists: true };
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function validateOpenRefs(entries, { repoRoot }) {
|
|
301
|
+
return Promise.all((entries || []).map((entry) => validateRef(entry, repoRoot)));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function validateDeepOpenGroups(groups, { repoRoot }) {
|
|
305
|
+
return Promise.all((groups || []).map(async (group) => ({
|
|
306
|
+
...group,
|
|
307
|
+
refs: await validateOpenRefs(group.refs, { repoRoot })
|
|
308
|
+
})));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function dedupeOpenRefs(entries) {
|
|
312
|
+
const seen = new Set();
|
|
313
|
+
return (entries || []).filter((entry) => {
|
|
314
|
+
if (!entry?.ref || seen.has(entry.ref)) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
seen.add(entry.ref);
|
|
318
|
+
return true;
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function buildDefaultOpenRefs({ nextTask, refs, source }) {
|
|
323
|
+
const taskId = nextTask?.id || null;
|
|
324
|
+
return dedupeOpenRefs([
|
|
325
|
+
openRef(
|
|
326
|
+
refs.relativePrimaryContractRef,
|
|
327
|
+
'primary task contract',
|
|
328
|
+
source
|
|
329
|
+
),
|
|
330
|
+
openRef(
|
|
331
|
+
taskId ? withFragment(refs.relativeManifestPath, `/tasks/${taskId}`) : withFragment(refs.relativeManifestPath, '/summary'),
|
|
332
|
+
taskId ? 'current task source of truth' : 'task graph summary source of truth',
|
|
333
|
+
source
|
|
334
|
+
),
|
|
335
|
+
openRef(
|
|
336
|
+
refs.relativeContractIndexRef
|
|
337
|
+
|| (refs.relativeContractPath ? withFragment(refs.relativeContractPath, 'progressive-disclosure-index') : null),
|
|
338
|
+
'contract index for non-negotiable design constraints',
|
|
339
|
+
source
|
|
340
|
+
),
|
|
341
|
+
openRef(
|
|
342
|
+
refs.relativeChangeMetaPath ? withFragment(refs.relativeChangeMetaPath, '/spec') : null,
|
|
343
|
+
'scope and spec-sync status',
|
|
344
|
+
source
|
|
345
|
+
),
|
|
346
|
+
openRef(
|
|
347
|
+
refs.relativeReportPath ? withFragment(refs.relativeReportPath, '/verdict') : null,
|
|
348
|
+
'latest verification verdict',
|
|
349
|
+
source
|
|
350
|
+
)
|
|
351
|
+
]);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function deepOpenGroup({ when, conditions, refs: openRefs, source, command }) {
|
|
355
|
+
const group = {
|
|
356
|
+
when,
|
|
357
|
+
conditions,
|
|
358
|
+
refs: dedupeOpenRefs(openRefs.map((entry) => (
|
|
359
|
+
typeof entry === 'string'
|
|
360
|
+
? openRef(entry, when, source)
|
|
361
|
+
: openRef(entry.ref, entry.reason || when, source)
|
|
362
|
+
)))
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
if (command) {
|
|
366
|
+
group.command = command;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return group;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function summarizeManifestForDigest(manifest) {
|
|
373
|
+
return {
|
|
374
|
+
changeId: manifest.changeId || null,
|
|
375
|
+
currentTaskId: manifest.currentTaskId || null,
|
|
376
|
+
tasks: (manifest.tasks || []).map((task) => ({
|
|
377
|
+
id: task.id,
|
|
378
|
+
status: task.status || 'pending',
|
|
379
|
+
phase: task.phase || 0,
|
|
380
|
+
dependsOn: task.dependsOn || [],
|
|
381
|
+
files: task.files || [],
|
|
382
|
+
verification: task.verification || []
|
|
383
|
+
}))
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function summarizeEvidenceForDigest({ nextTask, report }) {
|
|
388
|
+
return {
|
|
389
|
+
currentTaskEvidence: nextTask?.evidence || [],
|
|
390
|
+
report: report ? {
|
|
391
|
+
overall: report.overall || null,
|
|
392
|
+
verdict: report.verdict || null,
|
|
393
|
+
reroute: report.reroute || null,
|
|
394
|
+
specSyncReady: report.specSyncReady === true,
|
|
395
|
+
blockingFindings: report.blockingFindings || [],
|
|
396
|
+
gaps: report.gaps || []
|
|
397
|
+
} : null
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
async function buildPacketOnly({
|
|
402
|
+
canonicalContractPath,
|
|
403
|
+
manifest,
|
|
404
|
+
currentTaskSummary,
|
|
405
|
+
nextTask,
|
|
406
|
+
report,
|
|
407
|
+
mustNotForget
|
|
408
|
+
}) {
|
|
409
|
+
return {
|
|
410
|
+
contractDigest: await digestFile(canonicalContractPath),
|
|
411
|
+
manifestDigest: digestValue(summarizeManifestForDigest(manifest)),
|
|
412
|
+
currentTaskDigest: digestValue(currentTaskSummary),
|
|
413
|
+
evidenceDigest: digestValue(summarizeEvidenceForDigest({ nextTask, report })),
|
|
414
|
+
mustNotForgetDigest: digestValue(mustNotForget)
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
async function buildSourceIndex({
|
|
419
|
+
manifestPath,
|
|
420
|
+
canonicalContractPath,
|
|
421
|
+
tasksPath,
|
|
422
|
+
changeMetaPath,
|
|
423
|
+
reportPath,
|
|
424
|
+
refs
|
|
425
|
+
}) {
|
|
426
|
+
const entries = {
|
|
427
|
+
manifest: {
|
|
428
|
+
path: refs.relativeManifestPath,
|
|
429
|
+
hash: await hashFile(manifestPath)
|
|
430
|
+
},
|
|
431
|
+
contract: refs.relativeContractPath ? {
|
|
432
|
+
path: refs.relativeContractPath,
|
|
433
|
+
hash: await hashFile(canonicalContractPath)
|
|
434
|
+
} : null,
|
|
435
|
+
tasks: refs.relativeTasksPath ? {
|
|
436
|
+
path: refs.relativeTasksPath,
|
|
437
|
+
hash: await hashFile(tasksPath)
|
|
438
|
+
} : null,
|
|
439
|
+
changeMeta: refs.relativeChangeMetaPath ? {
|
|
440
|
+
path: refs.relativeChangeMetaPath,
|
|
441
|
+
hash: await hashFile(changeMetaPath)
|
|
442
|
+
} : null,
|
|
443
|
+
reportCard: refs.relativeReportPath ? {
|
|
444
|
+
path: refs.relativeReportPath,
|
|
445
|
+
hash: await hashFile(reportPath)
|
|
446
|
+
} : null
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
return Object.fromEntries(Object.entries(entries).filter(([, value]) => value));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function buildSourceHashes(source) {
|
|
453
|
+
return Object.fromEntries(
|
|
454
|
+
Object.values(source || {})
|
|
455
|
+
.filter((entry) => entry?.path && entry.hash)
|
|
456
|
+
.map((entry) => [entry.path, entry.hash])
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function sourcePointer(ref, source) {
|
|
461
|
+
return {
|
|
462
|
+
ref,
|
|
463
|
+
hash: sourceHashForRef(source, ref)
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function sourcedValue(value, ref, source) {
|
|
468
|
+
return {
|
|
469
|
+
value,
|
|
470
|
+
source: sourcePointer(ref, source)
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
async function buildMustNotForget({
|
|
475
|
+
manifest,
|
|
476
|
+
nextTask,
|
|
477
|
+
report,
|
|
478
|
+
source,
|
|
479
|
+
refs,
|
|
480
|
+
canonicalContractPath,
|
|
481
|
+
missingVerificationCommands
|
|
482
|
+
}) {
|
|
483
|
+
const contractText = await readTextIfExists(canonicalContractPath);
|
|
484
|
+
const taskRef = nextTask
|
|
485
|
+
? withFragment(refs.relativeManifestPath, `/tasks/${nextTask.id}`)
|
|
486
|
+
: withFragment(refs.relativeManifestPath, '/summary');
|
|
487
|
+
const contractRef = refs.relativeContractPath
|
|
488
|
+
? (refs.relativeContractRef || withFragment(refs.relativeContractPath, 'contract-index'))
|
|
489
|
+
: taskRef;
|
|
490
|
+
const goal = manifest.goal || 'Deliver planned requirement changes safely.';
|
|
491
|
+
const taskContract = nextTask?.contract || {};
|
|
492
|
+
const taskNotes = nextTask?.context?.notes || [];
|
|
493
|
+
const designDecisions = [
|
|
494
|
+
...extractNestedBulletsAfterMarker(contractText, /must not re-decide|Frozen decisions/i),
|
|
495
|
+
...extractBulletsFromSections(contractText, [/^##\s+Approved Direction/i, /^##\s+Frozen Design Card/i], 6)
|
|
496
|
+
];
|
|
497
|
+
const risks = [
|
|
498
|
+
...extractBulletsFromSections(contractText, [/^##\s+Main Risk/i, /^##\s+Success Criteria/i], 6),
|
|
499
|
+
...(report?.blockingFindings || []),
|
|
500
|
+
...(report?.gaps || [])
|
|
501
|
+
];
|
|
502
|
+
const nonNegotiables = limitList([
|
|
503
|
+
'workflow-context is read-only and must not mutate source artifacts',
|
|
504
|
+
'source-of-truth artifacts remain authoritative; chat memory never replaces them',
|
|
505
|
+
'ship-readiness remains the source of truth for cc-act routing',
|
|
506
|
+
'current task state comes from task-manifest.json, not the ready queue alone',
|
|
507
|
+
missingVerificationCommands ? 'verification commands are required before execution can continue' : null,
|
|
508
|
+
...taskNotes.filter((note) => /do not|must|keep|only|without/i.test(note))
|
|
509
|
+
]);
|
|
510
|
+
const doNotRedecide = limitList([
|
|
511
|
+
...(taskContract.doNotRedecide || []),
|
|
512
|
+
...designDecisions
|
|
513
|
+
]);
|
|
514
|
+
const acceptanceGates = limitList([
|
|
515
|
+
...(nextTask?.acceptance || []),
|
|
516
|
+
...(nextTask?.verification || []),
|
|
517
|
+
nextTask?.testSeam?.publicVerificationPath || null
|
|
518
|
+
]);
|
|
519
|
+
const knownRisks = limitList([
|
|
520
|
+
...risks,
|
|
521
|
+
'if scope, task ownership, or source hashes are uncertain, open the source artifact before acting'
|
|
522
|
+
]);
|
|
523
|
+
|
|
524
|
+
return {
|
|
525
|
+
goal: sourcedValue(goal, withFragment(refs.relativeManifestPath, '/goal'), source),
|
|
526
|
+
nonNegotiables: nonNegotiables.map((value) => sourcedValue(value, contractRef, source)),
|
|
527
|
+
doNotRedecide: doNotRedecide.map((value) => sourcedValue(value, contractRef, source)),
|
|
528
|
+
acceptanceGates: acceptanceGates.map((value) => sourcedValue(value, taskRef, source)),
|
|
529
|
+
knownRisks: knownRisks.map((value) => sourcedValue(value, contractRef, source))
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
module.exports = {
|
|
534
|
+
buildDefaultOpenRefs,
|
|
535
|
+
buildMustNotForget,
|
|
536
|
+
buildPacketOnly,
|
|
537
|
+
buildSourceHashes,
|
|
538
|
+
buildSourceIndex,
|
|
539
|
+
dedupeOpenRefs,
|
|
540
|
+
deepOpenGroup,
|
|
541
|
+
openRef,
|
|
542
|
+
validateDeepOpenGroups,
|
|
543
|
+
validateOpenRefs,
|
|
544
|
+
withFragment
|
|
545
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* [INPUT]: 依赖 store 的路径与文件读写能力,依赖 change-state/task-manifest/report-card
|
|
2
|
+
* [INPUT]: 依赖 store 的路径与文件读写能力,依赖 change-state/task-manifest/report-card 作为 durable truth。
|
|
3
3
|
* [OUTPUT]: 对外提供 handoff 级工件生成与 legacy artifact 清理能力。
|
|
4
4
|
* [POS]: skill runtime 的薄 handoff 层,只保留终态交付文件,不再投影中间态 Markdown。
|
|
5
5
|
* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
|
|
@@ -14,7 +14,6 @@ const {
|
|
|
14
14
|
getRuntimeStatePath,
|
|
15
15
|
getTaskManifestPath,
|
|
16
16
|
getReportCardPath,
|
|
17
|
-
getCheckpointPath,
|
|
18
17
|
getReleaseNotePath
|
|
19
18
|
} = require('./store');
|
|
20
19
|
const {
|
|
@@ -68,28 +67,6 @@ function summarizeGateSection(gates = []) {
|
|
|
68
67
|
});
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
async function readLatestCheckpoints(repoRoot, changeId, tasks = [], options = {}) {
|
|
72
|
-
const checkpoints = [];
|
|
73
|
-
|
|
74
|
-
for (const task of tasks) {
|
|
75
|
-
const checkpoint = await readJson(getCheckpointPath(repoRoot, changeId, task.id, options), null);
|
|
76
|
-
if (!checkpoint) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
checkpoints.push({
|
|
81
|
-
taskId: task.id,
|
|
82
|
-
title: task.title,
|
|
83
|
-
status: checkpoint.status,
|
|
84
|
-
timestamp: checkpoint.timestamp,
|
|
85
|
-
summary: checkpoint.summary
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
checkpoints.sort((left, right) => right.timestamp.localeCompare(left.timestamp));
|
|
90
|
-
return checkpoints;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
70
|
async function cleanupLegacyArtifacts(repoRoot, changeId, manifest, options = {}) {
|
|
94
71
|
const taskIds = (manifest?.tasks || []).map((task) => task.id);
|
|
95
72
|
const change = getChangePaths(repoRoot, changeId, options);
|
|
@@ -111,8 +88,7 @@ async function clearHandoffArtifacts(repoRoot, changeId, keep = null, options =
|
|
|
111
88
|
async function writeResumeIndex(repoRoot, changeId, state, manifest, report, options = {}) {
|
|
112
89
|
await ensureIntentScaffold(repoRoot, changeId, options);
|
|
113
90
|
|
|
114
|
-
const
|
|
115
|
-
const lastGoodCheckpoint = checkpoints.find((checkpoint) => checkpoint.status === 'passed') || checkpoints[0] || null;
|
|
91
|
+
const lastGoodTask = [...(manifest?.tasks || [])].reverse().find((task) => task.status === 'passed') || null;
|
|
116
92
|
const blockers = [
|
|
117
93
|
...(manifest?.tasks || [])
|
|
118
94
|
.filter((task) => task.status === 'failed')
|
|
@@ -144,11 +120,11 @@ async function writeResumeIndex(repoRoot, changeId, state, manifest, report, opt
|
|
|
144
120
|
`- Plan Version: ${manifest?.metadata?.planVersion || 1}`,
|
|
145
121
|
`- Updated At: ${nowIso()}`,
|
|
146
122
|
'',
|
|
147
|
-
'## Last Good
|
|
123
|
+
'## Last Good Task',
|
|
148
124
|
'',
|
|
149
|
-
|
|
150
|
-
? `- \`${
|
|
151
|
-
: '- No
|
|
125
|
+
lastGoodTask
|
|
126
|
+
? `- \`${lastGoodTask.id}\` ${lastGoodTask.status} - ${lastGoodTask.title || 'untitled task'}`
|
|
127
|
+
: '- No completed task yet',
|
|
152
128
|
'',
|
|
153
129
|
'## Blockers',
|
|
154
130
|
'',
|
|
@@ -203,9 +179,9 @@ async function syncIntentPrBrief(repoRoot, changeId) {
|
|
|
203
179
|
const summary = summarizeTaskStates(manifest.tasks || []);
|
|
204
180
|
const touchedFiles = [...new Set((manifest.tasks || []).flatMap((task) => task.touches || []))];
|
|
205
181
|
const skippedTasks = (manifest.tasks || []).filter((task) => task.status === 'skipped');
|
|
206
|
-
const
|
|
182
|
+
const taskStatusRefs = (manifest.tasks || [])
|
|
207
183
|
.filter((task) => isTaskSettledStatus(task.status))
|
|
208
|
-
.map((task) => `\`${task.id}\` ${task.title} -> \`
|
|
184
|
+
.map((task) => `\`${task.id}\` ${task.title} -> \`planning/tasks.md\` + \`planning/task-manifest.json\``);
|
|
209
185
|
|
|
210
186
|
const risks = [
|
|
211
187
|
...((report.review?.status === 'skipped' || report.review?.status === 'blocked')
|
|
@@ -275,7 +251,7 @@ async function syncIntentPrBrief(repoRoot, changeId) {
|
|
|
275
251
|
`\`devflow/changes/<change>/meta/change-state.json\``,
|
|
276
252
|
`\`devflow/changes/<change>/planning/task-manifest.json\``,
|
|
277
253
|
`\`devflow/changes/<change>/review/report-card.json\``,
|
|
278
|
-
...
|
|
254
|
+
...taskStatusRefs
|
|
279
255
|
]),
|
|
280
256
|
''
|
|
281
257
|
].join('\n');
|
|
@@ -205,7 +205,7 @@ function deriveLifecycleStage({ state, manifest, report, hasPrBrief = false }) {
|
|
|
205
205
|
|
|
206
206
|
function describeExecutionNextAction({ failedTaskIds, runningTaskIds, pendingTaskIds, report }) {
|
|
207
207
|
if (failedTaskIds.length > 0) {
|
|
208
|
-
return `优先修复失败任务 ${failedTaskIds.join(', ')}
|
|
208
|
+
return `优先修复失败任务 ${failedTaskIds.join(', ')},然后从 task-manifest 的最近稳定状态恢复。`;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
if (runningTaskIds.length > 0) {
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
阶段分组
|
|
5
5
|
初始化与快照: `init.js` 创建 runtime 骨架,`snapshot.js` 采集 discover 阶段需要的只读事实。
|
|
6
6
|
计划与批准: `plan.js` 生成 `task-manifest.json`,`approve.js` 锁定批准版本与执行模式。
|
|
7
|
-
执行主链: `dispatch.js` 推进当前任务前沿,`resume.js`
|
|
7
|
+
执行主链: `dispatch.js` 推进当前任务前沿,`resume.js` 从 `task-manifest.json` 的稳定状态恢复,`verify.js` 和 `release.js` 负责质量门与发布收口。
|
|
8
8
|
交接与工人: `prepare-pr.js` 生成唯一 PR brief,`worker.js`/`worker-run.js` 负责本地或 provider worker handoff 与回写。
|
|
9
9
|
自动驾驶: `autopilot-shared.js`、`autopilot-core.js`、`autopilot-execution.js`、`autopilot.js` 拆开共享语义、阶段判定和执行循环,避免单文件失控。
|
|
10
|
-
维护类: `janitor.js` 清理过期 runtime
|
|
10
|
+
维护类: `janitor.js` 清理过期 runtime 工件,但不改变 manifest / tasks 的真相源。
|
|
11
11
|
|
|
12
12
|
更新规则
|
|
13
13
|
这里只记录阶段入口和职责边界,不维护逐文件穷举说明。
|