sdtk-code-kit 0.1.0 → 0.1.2
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/README.md +140 -91
- package/assets/manifest/toolkit-bundle.manifest.json +47 -47
- package/assets/manifest/toolkit-bundle.sha256.txt +23 -23
- package/assets/toolkit/toolkit/AGENTS.md +219 -210
- package/assets/toolkit/toolkit/install.ps1 +1 -8
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +30 -7
- package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +31 -2
- package/assets/toolkit/toolkit/sdtk-spec.config.json +1 -1
- package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +1 -2
- package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +0 -1
- package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +0 -1
- package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +0 -1
- package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +0 -1
- package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-review/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +0 -1
- package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +0 -1
- package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +1 -2
- package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +0 -1
- package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +13 -14
- package/package.json +34 -34
- package/src/commands/help.js +218 -169
- package/src/commands/init.js +10 -1
- package/src/commands/plan.js +1 -0
- package/src/commands/runtime.js +27 -8
- package/src/commands/ship.js +5 -0
- package/src/commands/update.js +11 -0
- package/src/commands/verify.js +9 -0
- package/src/index.js +73 -70
- package/src/lib/scope.js +19 -2
- package/src/lib/update.js +337 -0
- package/src/lib/workflow-artifact.js +57 -14
- package/src/lib/workflow-handoff.js +510 -0
- package/src/lib/workflow-intake.js +2 -1
- package/src/lib/workflow-plan.js +102 -5
- package/src/lib/workflow-review-packet.js +561 -0
- package/src/lib/workflow-ship.js +53 -3
- package/src/lib/workflow-verify.js +356 -212
package/src/lib/workflow-ship.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { ValidationError } = require("./errors");
|
|
4
4
|
const { createOrUpdateWorkflowArtifact, loadWorkflowArtifactState } = require("./workflow-artifact");
|
|
5
|
+
const { emitOpsHandoffForCompletedCloseout } = require("./workflow-handoff");
|
|
5
6
|
|
|
6
7
|
const VALID_DECISIONS = ["ship", "finish"];
|
|
7
8
|
const VALID_PREFLIGHT_RESULT = ["pass", "partial", "fail"];
|
|
@@ -110,15 +111,47 @@ function getSuggestedEngineSkills(phaseStatus, decision) {
|
|
|
110
111
|
return [primary];
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
function validateDecisionSpecificFinish(lane, decision, followUps, notes) {
|
|
115
|
+
if (decision !== "finish" || lane === "bugfix") {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (followUps.length > 0 && notes.length > 0) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
throw new ValidationError(
|
|
124
|
+
'Feature-lane "finish" requires at least one "--follow-up" item and at least one "--note". "finish" is for bounded closeout when remaining hardening or deployment work is still explicit; use "--decision ship" for the stronger closure decision.'
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function validateCloseoutBundleStrength(lane, decision, preflightEntries) {
|
|
129
|
+
if (decision === "ship" && preflightEntries.length < 2) {
|
|
130
|
+
throw new ValidationError(
|
|
131
|
+
'Stronger "--decision ship" closeout requires at least two "--preflight" entries. Use a multi-preflight bundle to record the fuller release boundary, or use "--decision finish" for a bounded closeout.'
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (decision === "finish" && lane === "feature" && preflightEntries.length < 2) {
|
|
136
|
+
throw new ValidationError(
|
|
137
|
+
'Feature-lane "--decision finish" requires at least two "--preflight" entries. Use a multi-preflight bundle plus explicit "--follow-up" and "--note" items so the bounded closeout remains reviewable.'
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
113
142
|
function runShip(projectPath, featureKey, flags) {
|
|
114
143
|
const state = loadWorkflowArtifactState(projectPath, featureKey);
|
|
115
144
|
validateShipState(state);
|
|
116
145
|
|
|
117
146
|
const decision = validateChoice(flags.decision, VALID_DECISIONS, "decision");
|
|
118
147
|
const preflightEntries = parsePreflightEntries(flags.preflight, featureKey);
|
|
148
|
+
const shipFollowUps = normalizeEntries(flags["follow-up"]);
|
|
149
|
+
const shipNotes = normalizeEntries(flags.note);
|
|
150
|
+
validateDecisionSpecificFinish(state.lane, decision, shipFollowUps, shipNotes);
|
|
151
|
+
validateCloseoutBundleStrength(state.lane, decision, preflightEntries);
|
|
119
152
|
const preflightStatus = resolvePreflightStatus(preflightEntries);
|
|
120
153
|
const phaseStatus = resolveShipPhaseStatus(flags, state, preflightStatus);
|
|
121
|
-
const nextPhase = "ship";
|
|
154
|
+
const nextPhase = phaseStatus === "completed" ? "none" : "ship";
|
|
122
155
|
const blockingState =
|
|
123
156
|
phaseStatus === "blocked"
|
|
124
157
|
? "blocked_ship_issue"
|
|
@@ -141,11 +174,27 @@ function runShip(projectPath, featureKey, flags) {
|
|
|
141
174
|
shipDecision: decision,
|
|
142
175
|
shipStatus: phaseStatus,
|
|
143
176
|
preflightEntries,
|
|
144
|
-
shipFollowUps
|
|
145
|
-
shipNotes
|
|
177
|
+
shipFollowUps,
|
|
178
|
+
shipNotes,
|
|
146
179
|
shipDebugNotes: normalizeEntries(flags["debug-note"]),
|
|
147
180
|
});
|
|
148
181
|
|
|
182
|
+
const opsHandoffResult =
|
|
183
|
+
phaseStatus === "completed"
|
|
184
|
+
? emitOpsHandoffForCompletedCloseout({
|
|
185
|
+
projectPath,
|
|
186
|
+
featureKey,
|
|
187
|
+
lane: state.lane,
|
|
188
|
+
decision,
|
|
189
|
+
preflightEntries,
|
|
190
|
+
shipFollowUps,
|
|
191
|
+
shipNotes,
|
|
192
|
+
})
|
|
193
|
+
: {
|
|
194
|
+
emitted: false,
|
|
195
|
+
reason: 'skipped because OPS_HANDOFF is emitted only after completed "ship" closeout.',
|
|
196
|
+
};
|
|
197
|
+
|
|
149
198
|
return {
|
|
150
199
|
artifactPath,
|
|
151
200
|
lane: state.lane,
|
|
@@ -155,6 +204,7 @@ function runShip(projectPath, featureKey, flags) {
|
|
|
155
204
|
suggestedEngineSkills,
|
|
156
205
|
preflightCount: preflightEntries.length,
|
|
157
206
|
preflightStatus,
|
|
207
|
+
opsHandoff: opsHandoffResult,
|
|
158
208
|
};
|
|
159
209
|
}
|
|
160
210
|
|
|
@@ -1,212 +1,356 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { ValidationError } = require("./errors");
|
|
6
|
+
const { createOrUpdateWorkflowArtifact, loadWorkflowArtifactState } = require("./workflow-artifact");
|
|
7
|
+
const { createReviewPacket } = require("./workflow-review-packet");
|
|
8
|
+
|
|
9
|
+
const VALID_REVIEW_STATUS = ["pending", "pass", "partial", "fail"];
|
|
10
|
+
const VALID_EVIDENCE_RESULT = ["pass", "partial", "fail"];
|
|
11
|
+
const VALID_TRUTH_SYNC_STATUS = ["touched", "untouched"];
|
|
12
|
+
const GLOB_PATTERN_RE = /[*?[\]{}]/;
|
|
13
|
+
|
|
14
|
+
function normalizeEntries(entries) {
|
|
15
|
+
return (entries || []).map((entry) => entry.trim()).filter(Boolean);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function validateChoice(value, choices, flagName) {
|
|
19
|
+
if (!choices.includes(value)) {
|
|
20
|
+
throw new ValidationError(
|
|
21
|
+
`Invalid value for --${flagName}: "${value}". Must be one of: ${choices.join(", ")}`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeRepoRelativePath(rawValue, label) {
|
|
28
|
+
if (!rawValue || !String(rawValue).trim()) {
|
|
29
|
+
throw new ValidationError(`${label} must be a non-empty repo-relative path.`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const normalized = String(rawValue).trim().replace(/\\/g, "/").replace(/^\.\//, "");
|
|
33
|
+
if (normalized.startsWith("/") || /^[A-Za-z]:/.test(normalized)) {
|
|
34
|
+
throw new ValidationError(`${label} must be repo-relative, not absolute: ${rawValue}`);
|
|
35
|
+
}
|
|
36
|
+
if (
|
|
37
|
+
normalized === "." ||
|
|
38
|
+
normalized.startsWith("../") ||
|
|
39
|
+
normalized.split("/").includes("..")
|
|
40
|
+
) {
|
|
41
|
+
throw new ValidationError(`${label} must stay within the repository boundary: ${rawValue}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return normalized;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function rejectGlobPattern(rawValue, label) {
|
|
48
|
+
if (GLOB_PATTERN_RE.test(String(rawValue))) {
|
|
49
|
+
throw new ValidationError(`${label} must be an exact repo-relative path, not a glob pattern: ${rawValue}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function parseEvidenceEntries(entries, featureKey, projectPath) {
|
|
54
|
+
const normalized = normalizeEntries(entries);
|
|
55
|
+
if (normalized.length === 0) {
|
|
56
|
+
throw new ValidationError(
|
|
57
|
+
'Verification requires at least one "--evidence" entry in the format "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const expectedPrefix = `docs/dev/evidence/${featureKey}/`;
|
|
62
|
+
return normalized.map((entry) => {
|
|
63
|
+
const parts = entry.split("|").map((part) => part.trim());
|
|
64
|
+
if (parts.length !== 4 || parts.some((part) => !part)) {
|
|
65
|
+
throw new ValidationError(
|
|
66
|
+
'Each "--evidence" entry must use exactly four pipe-separated fields: "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const [checkName, summary, result, rawOutputRef] = parts;
|
|
71
|
+
validateChoice(result, VALID_EVIDENCE_RESULT, "evidence");
|
|
72
|
+
|
|
73
|
+
const normalizedRef = rawOutputRef.replace(/\\/g, "/");
|
|
74
|
+
rejectGlobPattern(normalizedRef, "evidence raw-output reference");
|
|
75
|
+
if (!normalizedRef.startsWith(expectedPrefix)) {
|
|
76
|
+
throw new ValidationError(
|
|
77
|
+
`Evidence raw-output reference must stay under "${expectedPrefix}". Received: ${rawOutputRef}`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
if (!fs.existsSync(path.join(projectPath, normalizedRef.replace(/\//g, path.sep)))) {
|
|
81
|
+
throw new ValidationError(
|
|
82
|
+
`Evidence raw-output reference must exist before verify can claim the check ran. Missing: ${rawOutputRef}`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
checkName,
|
|
88
|
+
summary,
|
|
89
|
+
result,
|
|
90
|
+
rawOutputRef: normalizedRef,
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function parseChangedFileEntries(entries) {
|
|
96
|
+
return normalizeEntries(entries).map((entry) => {
|
|
97
|
+
const parts = entry.split("|").map((part) => part.trim());
|
|
98
|
+
if (parts.length !== 2 || parts.some((part) => !part)) {
|
|
99
|
+
throw new ValidationError(
|
|
100
|
+
'Each "--changed-file" entry must use exactly two pipe-separated fields: "repo/path|rationale".'
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const normalizedPath = normalizeRepoRelativePath(parts[0], "changed-file path");
|
|
105
|
+
rejectGlobPattern(normalizedPath, "changed-file path");
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
path: normalizedPath,
|
|
109
|
+
rationale: parts[1],
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function parseExcludeFileEntries(entries) {
|
|
115
|
+
return normalizeEntries(entries).map((entry) => {
|
|
116
|
+
const parts = entry.split("|").map((part) => part.trim());
|
|
117
|
+
if (parts.length !== 2 || parts.some((part) => !part)) {
|
|
118
|
+
throw new ValidationError(
|
|
119
|
+
'Each "--exclude-file" entry must use exactly two pipe-separated fields: "repo/path|reason".'
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const normalizedPath = normalizeRepoRelativePath(parts[0], "exclude-file path");
|
|
124
|
+
rejectGlobPattern(normalizedPath, "exclude-file path");
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
path: normalizedPath,
|
|
128
|
+
reason: parts[1],
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function parseTruthSyncTargetEntries(entries) {
|
|
134
|
+
return normalizeEntries(entries).map((entry) => {
|
|
135
|
+
const parts = entry.split("|").map((part) => part.trim());
|
|
136
|
+
if (parts.length !== 3 || parts.some((part) => !part)) {
|
|
137
|
+
throw new ValidationError(
|
|
138
|
+
'Each "--truth-sync-target" entry must use exactly three pipe-separated fields: "path-or-surface|touched|rationale".'
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const [target, status, rationale] = parts;
|
|
143
|
+
validateChoice(status, VALID_TRUTH_SYNC_STATUS, "truth-sync-target");
|
|
144
|
+
return {
|
|
145
|
+
target,
|
|
146
|
+
status,
|
|
147
|
+
rationale,
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function parseCommitBoundaryPaths(entries, flagName) {
|
|
153
|
+
return normalizeEntries(entries).map((entry) => {
|
|
154
|
+
const normalizedPath = normalizeRepoRelativePath(entry, `${flagName} path`);
|
|
155
|
+
rejectGlobPattern(normalizedPath, `${flagName} path`);
|
|
156
|
+
return normalizedPath;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function parseCaveatEntries(entries) {
|
|
161
|
+
return normalizeEntries(entries).map((entry) => {
|
|
162
|
+
const parts = entry.split("|").map((part) => part.trim());
|
|
163
|
+
if (parts.length !== 4 || parts.some((part) => !part)) {
|
|
164
|
+
throw new ValidationError(
|
|
165
|
+
'Each "--caveat" entry must use exactly four pipe-separated fields: "ID|statement|impact|owner".'
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
id: parts[0],
|
|
171
|
+
statement: parts[1],
|
|
172
|
+
impact: parts[2],
|
|
173
|
+
owner: parts[3],
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function resolveEvidenceGate(evidenceEntries) {
|
|
179
|
+
if (evidenceEntries.some((entry) => entry.result === "fail")) {
|
|
180
|
+
return "fail";
|
|
181
|
+
}
|
|
182
|
+
if (evidenceEntries.some((entry) => entry.result === "partial")) {
|
|
183
|
+
return "partial";
|
|
184
|
+
}
|
|
185
|
+
return "pass";
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function resolveReviewStatus(value, flagName) {
|
|
189
|
+
if (!value) {
|
|
190
|
+
return "pending";
|
|
191
|
+
}
|
|
192
|
+
return validateChoice(value, VALID_REVIEW_STATUS, flagName);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function validateVerifyState(state) {
|
|
196
|
+
if (state.intakeOutcome === "BLOCKED_MISSING_INPUTS") {
|
|
197
|
+
throw new ValidationError(
|
|
198
|
+
'Workflow artifact is blocked by missing upstream inputs. Re-run "sdtk-code start" after the handoff inputs are ready.'
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (state.currentPhase === "build") {
|
|
203
|
+
if (state.phaseStatus !== "completed") {
|
|
204
|
+
throw new ValidationError(
|
|
205
|
+
'Workflow must complete "build" before "verify". Run "sdtk-code build --complete" first.'
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (state.currentPhase !== "verify") {
|
|
212
|
+
throw new ValidationError(
|
|
213
|
+
`Cannot run "verify" from current phase "${state.currentPhase}". Re-run the next legal workflow step instead.`
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function resolveVerifyPhaseStatus(flags, state, evidenceGate, specGateStatus, qualityGateStatus) {
|
|
219
|
+
if (flags.complete && flags.blocked) {
|
|
220
|
+
throw new ValidationError('Use either "--complete" or "--blocked", not both.');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (flags.complete) {
|
|
224
|
+
if (evidenceGate !== "pass" || specGateStatus !== "pass" || qualityGateStatus !== "pass") {
|
|
225
|
+
throw new ValidationError(
|
|
226
|
+
'Verify can be marked complete only when evidence, spec/compliance, and quality gates all pass.'
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
return "completed";
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (
|
|
233
|
+
flags.blocked ||
|
|
234
|
+
evidenceGate === "fail" ||
|
|
235
|
+
specGateStatus === "fail" ||
|
|
236
|
+
qualityGateStatus === "fail"
|
|
237
|
+
) {
|
|
238
|
+
return "blocked";
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (
|
|
242
|
+
state.currentPhase === "verify" &&
|
|
243
|
+
state.phaseStatus === "completed" &&
|
|
244
|
+
evidenceGate === "pass" &&
|
|
245
|
+
specGateStatus === "pass" &&
|
|
246
|
+
qualityGateStatus === "pass"
|
|
247
|
+
) {
|
|
248
|
+
return "completed";
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return "in_progress";
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function getSuggestedEngineSkills(phaseStatus, evidenceGate, specGateStatus, qualityGateStatus) {
|
|
255
|
+
if (phaseStatus === "completed") {
|
|
256
|
+
return ["code-ship", "code-finish"];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const hasFailure =
|
|
260
|
+
evidenceGate === "fail" || specGateStatus === "fail" || qualityGateStatus === "fail";
|
|
261
|
+
const skills = ["code-verify", "code-review"];
|
|
262
|
+
if (hasFailure || phaseStatus === "blocked") {
|
|
263
|
+
skills.unshift("code-debug");
|
|
264
|
+
}
|
|
265
|
+
return skills;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function runVerify(projectPath, featureKey, flags) {
|
|
269
|
+
const state = loadWorkflowArtifactState(projectPath, featureKey);
|
|
270
|
+
validateVerifyState(state);
|
|
271
|
+
|
|
272
|
+
const evidenceEntries = parseEvidenceEntries(flags.evidence, featureKey, projectPath);
|
|
273
|
+
const evidenceGate = resolveEvidenceGate(evidenceEntries);
|
|
274
|
+
const specGateStatus = resolveReviewStatus(flags["spec-status"], "spec-status");
|
|
275
|
+
const qualityGateStatus = resolveReviewStatus(flags["quality-status"], "quality-status");
|
|
276
|
+
const phaseStatus = resolveVerifyPhaseStatus(
|
|
277
|
+
flags,
|
|
278
|
+
state,
|
|
279
|
+
evidenceGate,
|
|
280
|
+
specGateStatus,
|
|
281
|
+
qualityGateStatus
|
|
282
|
+
);
|
|
283
|
+
const nextPhase = phaseStatus === "completed" ? "ship" : "verify";
|
|
284
|
+
const blockingState =
|
|
285
|
+
phaseStatus === "blocked"
|
|
286
|
+
? "blocked_verify_issue"
|
|
287
|
+
: phaseStatus === "completed"
|
|
288
|
+
? "clear"
|
|
289
|
+
: "review_in_progress";
|
|
290
|
+
const suggestedEngineSkills = getSuggestedEngineSkills(
|
|
291
|
+
phaseStatus,
|
|
292
|
+
evidenceGate,
|
|
293
|
+
specGateStatus,
|
|
294
|
+
qualityGateStatus
|
|
295
|
+
);
|
|
296
|
+
const reviewPacket = createReviewPacket({
|
|
297
|
+
projectPath,
|
|
298
|
+
featureKey,
|
|
299
|
+
workflowText: state.text,
|
|
300
|
+
evidenceEntries,
|
|
301
|
+
specGateStatus,
|
|
302
|
+
qualityGateStatus,
|
|
303
|
+
specNotes: normalizeEntries(flags["spec-note"]),
|
|
304
|
+
qualityNotes: normalizeEntries(flags["quality-note"]),
|
|
305
|
+
debugNotes: normalizeEntries(flags["debug-note"]),
|
|
306
|
+
batchSummary: flags["batch-summary"] || "",
|
|
307
|
+
changedFiles: parseChangedFileEntries(flags["changed-file"]),
|
|
308
|
+
excludedFiles: parseExcludeFileEntries(flags["exclude-file"]),
|
|
309
|
+
truthSyncTargets: parseTruthSyncTargetEntries(flags["truth-sync-target"]),
|
|
310
|
+
commitInclude: parseCommitBoundaryPaths(flags["commit-include"], "commit-include"),
|
|
311
|
+
commitExclude: parseCommitBoundaryPaths(flags["commit-exclude"], "commit-exclude"),
|
|
312
|
+
caveats: parseCaveatEntries(flags.caveat),
|
|
313
|
+
reviewerGuidance: normalizeEntries(flags["reviewer-guidance"]),
|
|
314
|
+
});
|
|
315
|
+
const normalizedReviewPacketPath = path
|
|
316
|
+
.relative(projectPath, reviewPacket.reviewPacketPath)
|
|
317
|
+
.replace(/\\/g, "/");
|
|
318
|
+
|
|
319
|
+
const artifactPath = createOrUpdateWorkflowArtifact({
|
|
320
|
+
projectPath,
|
|
321
|
+
featureKey,
|
|
322
|
+
lane: state.lane,
|
|
323
|
+
currentPhase: "verify",
|
|
324
|
+
phaseStatus,
|
|
325
|
+
intakeOutcome: state.intakeOutcome,
|
|
326
|
+
nextPhase,
|
|
327
|
+
blockingState,
|
|
328
|
+
suggestedEngineSkills,
|
|
329
|
+
managedBlocks: ["METADATA", "VERIFY", "STATUS"],
|
|
330
|
+
evidenceEntries,
|
|
331
|
+
evidenceGate,
|
|
332
|
+
specGateStatus,
|
|
333
|
+
qualityGateStatus,
|
|
334
|
+
specNotes: normalizeEntries(flags["spec-note"]),
|
|
335
|
+
qualityNotes: normalizeEntries(flags["quality-note"]),
|
|
336
|
+
verifyDebugNotes: normalizeEntries(flags["debug-note"]),
|
|
337
|
+
reviewPacketPath: normalizedReviewPacketPath,
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
return {
|
|
341
|
+
artifactPath,
|
|
342
|
+
lane: state.lane,
|
|
343
|
+
phaseStatus,
|
|
344
|
+
nextPhase,
|
|
345
|
+
suggestedEngineSkills,
|
|
346
|
+
evidenceCount: evidenceEntries.length,
|
|
347
|
+
evidenceGate,
|
|
348
|
+
specGateStatus,
|
|
349
|
+
qualityGateStatus,
|
|
350
|
+
reviewPacketPath: normalizedReviewPacketPath,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
module.exports = {
|
|
355
|
+
runVerify,
|
|
356
|
+
};
|