@xenonbyte/da-vinci-workflow 0.2.4 → 0.2.6
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/CHANGELOG.md +35 -0
- package/README.md +15 -9
- package/README.zh-CN.md +16 -9
- package/SKILL.md +45 -704
- package/docs/dv-command-reference.md +33 -5
- package/docs/execution-chain-migration.md +14 -3
- package/docs/maintainer-bootstrap.md +102 -0
- package/docs/pencil-rendering-workflow.md +1 -1
- package/docs/prompt-entrypoints.md +1 -0
- package/docs/skill-contract-maintenance.md +14 -0
- package/docs/skill-usage.md +31 -0
- package/docs/workflow-overview.md +40 -5
- package/docs/zh-CN/dv-command-reference.md +31 -5
- package/docs/zh-CN/maintainer-bootstrap.md +101 -0
- package/docs/zh-CN/pencil-rendering-workflow.md +1 -1
- package/docs/zh-CN/prompt-entrypoints.md +1 -0
- package/docs/zh-CN/skill-usage.md +30 -0
- package/docs/zh-CN/workflow-overview.md +38 -5
- package/lib/audit.js +19 -0
- package/lib/cli/helpers.js +104 -0
- package/lib/cli/lint-family.js +56 -0
- package/lib/cli/verify-family.js +79 -0
- package/lib/cli.js +143 -172
- package/lib/gate-utils.js +56 -0
- package/lib/install.js +134 -6
- package/lib/lint-bindings.js +41 -28
- package/lib/lint-spec.js +403 -109
- package/lib/lint-tasks.js +571 -21
- package/lib/maintainer-readiness.js +317 -0
- package/lib/planning-parsers.js +198 -2
- package/lib/planning-quality-utils.js +81 -0
- package/lib/planning-signal-freshness.js +205 -0
- package/lib/scaffold.js +454 -23
- package/lib/scope-check.js +751 -82
- package/lib/sidecars.js +396 -1
- package/lib/task-review.js +2 -1
- package/lib/utils.js +34 -0
- package/lib/verify.js +1160 -88
- package/lib/workflow-persisted-state.js +52 -32
- package/lib/workflow-state.js +1187 -249
- package/package.json +1 -1
- package/references/skill-workflow-detail.md +66 -0
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
|
+
const crypto = require("crypto");
|
|
3
4
|
const { writeFileAtomic, pathExists, readTextIfExists } = require("./utils");
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
// Route snapshot schema version; task-group metadata keeps its own version in workflow-state.js.
|
|
7
|
+
const WORKFLOW_STATE_VERSION = 3;
|
|
8
|
+
const SUPPORTED_WORKFLOW_STATE_VERSIONS = new Set([2, WORKFLOW_STATE_VERSION]);
|
|
6
9
|
const DEFAULT_STALE_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
7
10
|
const PERSISTED_NOTE_EXCLUDE_PATTERNS = [
|
|
8
11
|
/^No persisted workflow state found for this change; deriving from artifacts\.$/i,
|
|
@@ -19,16 +22,29 @@ function resolveTaskGroupMetadataPath(projectRoot, changeId) {
|
|
|
19
22
|
return path.join(projectRoot, ".da-vinci", "state", "task-groups", `${changeId}.json`);
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
function hashContent(value) {
|
|
26
|
+
return crypto.createHash("sha256").update(value).digest("hex");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function digestForPath(targetPath) {
|
|
30
|
+
if (!pathExists(targetPath)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
return hashContent(fs.readFileSync(targetPath));
|
|
35
|
+
} catch (_error) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
22
40
|
function fingerprintForPath(targetPath) {
|
|
23
41
|
if (!pathExists(targetPath)) {
|
|
24
42
|
return null;
|
|
25
43
|
}
|
|
26
44
|
try {
|
|
27
|
-
const stat = fs.statSync(targetPath);
|
|
28
45
|
return {
|
|
29
46
|
path: targetPath,
|
|
30
|
-
|
|
31
|
-
size: stat.size
|
|
47
|
+
digest: digestForPath(targetPath)
|
|
32
48
|
};
|
|
33
49
|
} catch (_error) {
|
|
34
50
|
return null;
|
|
@@ -46,8 +62,7 @@ function buildWorkflowFingerprint(projectRoot, changeId) {
|
|
|
46
62
|
path.join(changeRoot, "pencil-design.md"),
|
|
47
63
|
path.join(changeRoot, "pencil-bindings.md"),
|
|
48
64
|
path.join(changeRoot, "tasks.md"),
|
|
49
|
-
path.join(changeRoot, "verification.md")
|
|
50
|
-
path.join(changeRoot, "workflow.json")
|
|
65
|
+
path.join(changeRoot, "verification.md")
|
|
51
66
|
];
|
|
52
67
|
|
|
53
68
|
const specRoot = path.join(changeRoot, "specs");
|
|
@@ -96,8 +111,7 @@ function stableFingerprintHash(fingerprint) {
|
|
|
96
111
|
return JSON.stringify(
|
|
97
112
|
(fingerprint || []).map((entry) => ({
|
|
98
113
|
path: entry.path,
|
|
99
|
-
|
|
100
|
-
size: entry.size
|
|
114
|
+
digest: entry.digest
|
|
101
115
|
}))
|
|
102
116
|
);
|
|
103
117
|
}
|
|
@@ -163,7 +177,7 @@ function selectPersistedStateForChange(projectRoot, changeId, options = {}) {
|
|
|
163
177
|
};
|
|
164
178
|
}
|
|
165
179
|
|
|
166
|
-
if (loaded.state.version
|
|
180
|
+
if (!SUPPORTED_WORKFLOW_STATE_VERSIONS.has(Number(loaded.state.version))) {
|
|
167
181
|
return {
|
|
168
182
|
usable: false,
|
|
169
183
|
reason: "version-mismatch",
|
|
@@ -183,25 +197,6 @@ function selectPersistedStateForChange(projectRoot, changeId, options = {}) {
|
|
|
183
197
|
};
|
|
184
198
|
}
|
|
185
199
|
|
|
186
|
-
const persistedAt = Date.parse(String(changeRecord.persistedAt || ""));
|
|
187
|
-
if (!Number.isFinite(persistedAt)) {
|
|
188
|
-
return {
|
|
189
|
-
usable: false,
|
|
190
|
-
reason: "invalid-timestamp",
|
|
191
|
-
statePath: loaded.statePath,
|
|
192
|
-
persisted: loaded.state
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (Date.now() - persistedAt > staleWindowMs) {
|
|
197
|
-
return {
|
|
198
|
-
usable: false,
|
|
199
|
-
reason: "time-stale",
|
|
200
|
-
statePath: loaded.statePath,
|
|
201
|
-
persisted: loaded.state
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
200
|
const currentFingerprint = buildWorkflowFingerprint(projectRoot, changeId);
|
|
206
201
|
const currentHash = stableFingerprintHash(currentFingerprint);
|
|
207
202
|
const persistedHash = String(changeRecord.fingerprintHash || "");
|
|
@@ -219,7 +214,20 @@ function selectPersistedStateForChange(projectRoot, changeId, options = {}) {
|
|
|
219
214
|
reason: null,
|
|
220
215
|
statePath: loaded.statePath,
|
|
221
216
|
persisted: loaded.state,
|
|
222
|
-
changeRecord
|
|
217
|
+
changeRecord,
|
|
218
|
+
advisoryNotes:
|
|
219
|
+
(() => {
|
|
220
|
+
const persistedAt = Date.parse(String(changeRecord.persistedAt || ""));
|
|
221
|
+
if (!Number.isFinite(persistedAt)) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
if (Date.now() - persistedAt > staleWindowMs) {
|
|
225
|
+
return [
|
|
226
|
+
"Persisted workflow state is older than the historical stale-time threshold but remains usable because artifact content digests still match."
|
|
227
|
+
];
|
|
228
|
+
}
|
|
229
|
+
return [];
|
|
230
|
+
})()
|
|
223
231
|
};
|
|
224
232
|
}
|
|
225
233
|
|
|
@@ -234,6 +242,14 @@ function persistDerivedWorkflowResult(projectRoot, changeId, workflowResult, opt
|
|
|
234
242
|
}
|
|
235
243
|
|
|
236
244
|
const fingerprint = buildWorkflowFingerprint(projectRoot, changeId);
|
|
245
|
+
const metadataRefsNormalized =
|
|
246
|
+
metadataRefs && typeof metadataRefs === "object"
|
|
247
|
+
? {
|
|
248
|
+
...metadataRefs,
|
|
249
|
+
taskGroupsPath: metadataRefs.taskGroupsPath || null,
|
|
250
|
+
taskGroupsDigest: metadataRefs.taskGroupsDigest || null
|
|
251
|
+
}
|
|
252
|
+
: {};
|
|
237
253
|
changes[changeId] = {
|
|
238
254
|
stage: workflowResult.stage,
|
|
239
255
|
checkpointState: workflowResult.checkpointState,
|
|
@@ -243,8 +259,7 @@ function persistDerivedWorkflowResult(projectRoot, changeId, workflowResult, opt
|
|
|
243
259
|
failures: workflowResult.failures,
|
|
244
260
|
warnings: workflowResult.warnings,
|
|
245
261
|
notes: sanitizePersistedNotes(workflowResult.notes),
|
|
246
|
-
|
|
247
|
-
metadataRefs,
|
|
262
|
+
metadataRefs: metadataRefsNormalized,
|
|
248
263
|
fingerprintHash: stableFingerprintHash(fingerprint),
|
|
249
264
|
persistedAt: new Date().toISOString()
|
|
250
265
|
};
|
|
@@ -264,7 +279,10 @@ function writeTaskGroupMetadata(projectRoot, changeId, metadataPayload) {
|
|
|
264
279
|
const targetPath = resolveTaskGroupMetadataPath(projectRoot, changeId);
|
|
265
280
|
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
266
281
|
writeFileAtomic(targetPath, `${JSON.stringify(metadataPayload, null, 2)}\n`);
|
|
267
|
-
return
|
|
282
|
+
return {
|
|
283
|
+
path: targetPath,
|
|
284
|
+
digest: digestForPath(targetPath)
|
|
285
|
+
};
|
|
268
286
|
}
|
|
269
287
|
|
|
270
288
|
function readTaskGroupMetadata(projectRoot, changeId) {
|
|
@@ -284,11 +302,13 @@ function readTaskGroupMetadata(projectRoot, changeId) {
|
|
|
284
302
|
|
|
285
303
|
module.exports = {
|
|
286
304
|
WORKFLOW_STATE_VERSION,
|
|
305
|
+
SUPPORTED_WORKFLOW_STATE_VERSIONS,
|
|
287
306
|
DEFAULT_STALE_WINDOW_MS,
|
|
288
307
|
resolveWorkflowStatePath,
|
|
289
308
|
resolveTaskGroupMetadataPath,
|
|
290
309
|
buildWorkflowFingerprint,
|
|
291
310
|
stableFingerprintHash,
|
|
311
|
+
digestForPath,
|
|
292
312
|
sanitizePersistedNotes,
|
|
293
313
|
readPersistedWorkflowState,
|
|
294
314
|
writePersistedWorkflowState,
|