@xenonbyte/da-vinci-workflow 0.1.26 → 0.2.1

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 (40) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +17 -65
  3. package/README.zh-CN.md +17 -65
  4. package/commands/claude/dv/continue.md +5 -0
  5. package/commands/codex/prompts/dv-continue.md +6 -1
  6. package/commands/gemini/dv/continue.toml +5 -0
  7. package/commands/templates/dv-continue.shared.md +33 -0
  8. package/docs/dv-command-reference.md +31 -0
  9. package/docs/execution-chain-migration.md +46 -0
  10. package/docs/execution-chain-plan.md +125 -0
  11. package/docs/prompt-entrypoints.md +6 -0
  12. package/docs/workflow-examples.md +10 -0
  13. package/docs/workflow-overview.md +25 -0
  14. package/docs/zh-CN/dv-command-reference.md +31 -0
  15. package/docs/zh-CN/execution-chain-migration.md +46 -0
  16. package/docs/zh-CN/prompt-entrypoints.md +6 -0
  17. package/docs/zh-CN/workflow-examples.md +10 -0
  18. package/docs/zh-CN/workflow-overview.md +25 -0
  19. package/lib/artifact-parsers.js +120 -0
  20. package/lib/audit.js +61 -0
  21. package/lib/cli.js +328 -13
  22. package/lib/diff-spec.js +242 -0
  23. package/lib/execution-signals.js +136 -0
  24. package/lib/lint-bindings.js +143 -0
  25. package/lib/lint-spec.js +408 -0
  26. package/lib/lint-tasks.js +176 -0
  27. package/lib/planning-parsers.js +567 -0
  28. package/lib/scaffold.js +193 -0
  29. package/lib/scope-check.js +603 -0
  30. package/lib/sidecars.js +369 -0
  31. package/lib/supervisor-review.js +28 -3
  32. package/lib/utils.js +10 -2
  33. package/lib/verify.js +652 -0
  34. package/lib/workflow-contract.js +107 -0
  35. package/lib/workflow-persisted-state.js +297 -0
  36. package/lib/workflow-state.js +785 -0
  37. package/package.json +10 -2
  38. package/references/artifact-templates.md +26 -0
  39. package/references/checkpoints.md +14 -0
  40. package/references/modes.md +10 -0
@@ -0,0 +1,176 @@
1
+ const path = require("path");
2
+ const { STATUS } = require("./workflow-contract");
3
+ const {
4
+ normalizeText,
5
+ unique,
6
+ resolveChangeDir,
7
+ parseTasksArtifact,
8
+ parseRuntimeSpecs,
9
+ readChangeArtifacts,
10
+ readArtifactTexts
11
+ } = require("./planning-parsers");
12
+
13
+ function buildEnvelope(projectRoot, strict) {
14
+ return {
15
+ status: STATUS.PASS,
16
+ failures: [],
17
+ warnings: [],
18
+ notes: [],
19
+ projectRoot,
20
+ changeId: null,
21
+ strict,
22
+ summary: {
23
+ groups: 0,
24
+ checklistItems: 0
25
+ }
26
+ };
27
+ }
28
+
29
+ function finalize(result) {
30
+ result.failures = unique(result.failures);
31
+ result.warnings = unique(result.warnings);
32
+ result.notes = unique(result.notes);
33
+ const hasFindings = result.failures.length > 0 || result.warnings.length > 0;
34
+ if (!hasFindings) {
35
+ result.status = STATUS.PASS;
36
+ return result;
37
+ }
38
+ result.status = result.strict ? STATUS.BLOCK : STATUS.WARN;
39
+ return result;
40
+ }
41
+
42
+ function findMissingTaskGroupSequence(taskGroups) {
43
+ const numeric = taskGroups
44
+ .map((group) => Number.parseInt(String(group.id || "").split(".")[0], 10))
45
+ .filter(Number.isFinite)
46
+ .sort((a, b) => a - b);
47
+ if (numeric.length === 0) {
48
+ return [];
49
+ }
50
+ const missing = [];
51
+ for (let value = numeric[0]; value <= numeric[numeric.length - 1]; value += 1) {
52
+ if (!numeric.includes(value)) {
53
+ missing.push(value);
54
+ }
55
+ }
56
+ return missing;
57
+ }
58
+
59
+ function lintTasks(projectPathInput, options = {}) {
60
+ const projectRoot = path.resolve(projectPathInput || process.cwd());
61
+ const strict = options.strict === true;
62
+ const requestedChangeId = options.changeId ? String(options.changeId).trim() : "";
63
+ const result = buildEnvelope(projectRoot, strict);
64
+
65
+ const resolved = resolveChangeDir(projectRoot, requestedChangeId);
66
+ result.failures.push(...resolved.failures);
67
+ result.notes.push(...resolved.notes);
68
+ if (!resolved.changeDir) {
69
+ result.notes.push("lint-tasks defaults to advisory mode; pass `--strict` to block on findings.");
70
+ return finalize(result);
71
+ }
72
+ result.changeId = resolved.changeId;
73
+
74
+ const artifactPaths = readChangeArtifacts(projectRoot, resolved.changeId);
75
+ const artifacts = readArtifactTexts(artifactPaths);
76
+ if (!artifacts.tasks) {
77
+ result.failures.push("Missing `tasks.md` for lint-tasks.");
78
+ result.notes.push("lint-tasks defaults to advisory mode; pass `--strict` to block on findings.");
79
+ return finalize(result);
80
+ }
81
+
82
+ const parsedTasks = parseTasksArtifact(artifacts.tasks);
83
+ const specRecords = parseRuntimeSpecs(resolved.changeDir, projectRoot);
84
+ const taskText = normalizeText(artifacts.tasks);
85
+
86
+ result.summary.groups = parsedTasks.taskGroups.length;
87
+ result.summary.checklistItems = parsedTasks.checklistItems.length;
88
+
89
+ if (parsedTasks.taskGroups.length === 0) {
90
+ result.failures.push("`tasks.md` is missing top-level numbered task groups (for example `## 1. Setup`).");
91
+ }
92
+
93
+ const missingSequence = findMissingTaskGroupSequence(parsedTasks.taskGroups);
94
+ if (missingSequence.length > 0) {
95
+ result.warnings.push(
96
+ `Task-group numbering is non-contiguous. Missing top-level groups: ${missingSequence.join(", ")}.`
97
+ );
98
+ }
99
+
100
+ const nonNumericGroups = parsedTasks.taskGroups.filter(
101
+ (group) => !/^\d+(?:\.\d+)*$/.test(String(group.id || ""))
102
+ );
103
+ if (nonNumericGroups.length > 0) {
104
+ result.warnings.push("Some task-group headings are not numeric and may be skipped by execution metadata.");
105
+ }
106
+
107
+ if (parsedTasks.checklistItems.length === 0) {
108
+ result.failures.push("`tasks.md` has no checklist items.");
109
+ }
110
+
111
+ const hasVerificationAction =
112
+ parsedTasks.taskGroups.some((group) => /verify|verification|coverage/i.test(group.title)) ||
113
+ parsedTasks.checklistItems.some((item) => /verify|verification|coverage/i.test(item.text));
114
+ if (!hasVerificationAction) {
115
+ result.warnings.push("Missing explicit verification actions in `tasks.md`.");
116
+ }
117
+
118
+ for (const specRecord of specRecords) {
119
+ const behaviorItems = specRecord.parsed.sections.behavior.items || [];
120
+ for (const behaviorItem of behaviorItems) {
121
+ const normalizedBehavior = normalizeText(behaviorItem)
122
+ .split(" ")
123
+ .filter((token) => token.length >= 4)
124
+ .slice(0, 6);
125
+ if (normalizedBehavior.length === 0) {
126
+ continue;
127
+ }
128
+ const covered = normalizedBehavior.some((token) => taskText.includes(token));
129
+ if (!covered) {
130
+ result.warnings.push(
131
+ `Planned behavior may be uncovered in tasks: "${behaviorItem}" (${specRecord.path}).`
132
+ );
133
+ }
134
+ }
135
+ }
136
+
137
+ result.notes.push("lint-tasks defaults to advisory mode; pass `--strict` to block on findings.");
138
+ return finalize(result);
139
+ }
140
+
141
+ function formatLintTasksReport(result) {
142
+ const lines = [
143
+ "Da Vinci lint-tasks",
144
+ `Project: ${result.projectRoot}`,
145
+ `Change: ${result.changeId || "(not selected)"}`,
146
+ `Strict mode: ${result.strict ? "yes" : "no"}`,
147
+ `Status: ${result.status}`,
148
+ `Task groups: ${result.summary.groups}`,
149
+ `Checklist items: ${result.summary.checklistItems}`
150
+ ];
151
+
152
+ if (result.failures.length > 0) {
153
+ lines.push("", "Failures:");
154
+ for (const failure of result.failures) {
155
+ lines.push(`- ${failure}`);
156
+ }
157
+ }
158
+ if (result.warnings.length > 0) {
159
+ lines.push("", "Warnings:");
160
+ for (const warning of result.warnings) {
161
+ lines.push(`- ${warning}`);
162
+ }
163
+ }
164
+ if (result.notes.length > 0) {
165
+ lines.push("", "Notes:");
166
+ for (const note of result.notes) {
167
+ lines.push(`- ${note}`);
168
+ }
169
+ }
170
+ return lines.join("\n");
171
+ }
172
+
173
+ module.exports = {
174
+ lintTasks,
175
+ formatLintTasksReport
176
+ };