sdtk-code-kit 0.1.0
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 +138 -0
- package/assets/manifest/toolkit-bundle.manifest.json +147 -0
- package/assets/manifest/toolkit-bundle.sha256.txt +28 -0
- package/assets/toolkit/toolkit/AGENTS.md +210 -0
- package/assets/toolkit/toolkit/install.ps1 +126 -0
- package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +78 -0
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +127 -0
- package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +62 -0
- package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +53 -0
- package/assets/toolkit/toolkit/sdtk-spec.config.json +6 -0
- package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +12 -0
- package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +56 -0
- package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +297 -0
- package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +69 -0
- package/assets/toolkit/toolkit/skills/code-discover/SKILL.md +54 -0
- package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +75 -0
- package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +206 -0
- package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +65 -0
- package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +27 -0
- package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +114 -0
- package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +62 -0
- package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +86 -0
- package/assets/toolkit/toolkit/skills/code-review/SKILL.md +80 -0
- package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +126 -0
- package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +147 -0
- package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +53 -0
- package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +379 -0
- package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +300 -0
- package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +145 -0
- package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +229 -0
- package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +112 -0
- package/bin/sdtk-code.js +14 -0
- package/package.json +44 -0
- package/src/commands/build.js +53 -0
- package/src/commands/generate.js +11 -0
- package/src/commands/help.js +169 -0
- package/src/commands/init.js +86 -0
- package/src/commands/plan.js +52 -0
- package/src/commands/runtime.js +205 -0
- package/src/commands/ship.js +54 -0
- package/src/commands/start.js +89 -0
- package/src/commands/verify.js +57 -0
- package/src/index.js +70 -0
- package/src/lib/args.js +107 -0
- package/src/lib/errors.js +41 -0
- package/src/lib/powershell.js +65 -0
- package/src/lib/scope.js +55 -0
- package/src/lib/toolkit-payload.js +72 -0
- package/src/lib/workflow-artifact.js +453 -0
- package/src/lib/workflow-build.js +127 -0
- package/src/lib/workflow-handoff.js +427 -0
- package/src/lib/workflow-intake.js +100 -0
- package/src/lib/workflow-plan.js +96 -0
- package/src/lib/workflow-ship.js +163 -0
- package/src/lib/workflow-verify.js +212 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { ValidationError } = require("./errors");
|
|
4
|
+
const { createOrUpdateWorkflowArtifact, loadWorkflowArtifactState } = require("./workflow-artifact");
|
|
5
|
+
|
|
6
|
+
const VALID_DECISIONS = ["ship", "finish"];
|
|
7
|
+
const VALID_PREFLIGHT_RESULT = ["pass", "partial", "fail"];
|
|
8
|
+
|
|
9
|
+
function normalizeEntries(entries) {
|
|
10
|
+
return (entries || []).map((entry) => entry.trim()).filter(Boolean);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function validateChoice(value, choices, flagName) {
|
|
14
|
+
if (!choices.includes(value)) {
|
|
15
|
+
throw new ValidationError(
|
|
16
|
+
`Invalid value for --${flagName}: "${value}". Must be one of: ${choices.join(", ")}`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function parsePreflightEntries(entries, featureKey) {
|
|
23
|
+
const normalized = normalizeEntries(entries);
|
|
24
|
+
if (normalized.length === 0) {
|
|
25
|
+
throw new ValidationError(
|
|
26
|
+
'Ship requires at least one "--preflight" entry in the format "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const expectedPrefix = `docs/dev/evidence/${featureKey}/`;
|
|
31
|
+
return normalized.map((entry) => {
|
|
32
|
+
const parts = entry.split("|").map((part) => part.trim());
|
|
33
|
+
if (parts.length !== 4 || parts.some((part) => !part)) {
|
|
34
|
+
throw new ValidationError(
|
|
35
|
+
'Each "--preflight" entry must use exactly four pipe-separated fields: "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const [checkName, summary, result, rawOutputRef] = parts;
|
|
40
|
+
validateChoice(result, VALID_PREFLIGHT_RESULT, "preflight");
|
|
41
|
+
|
|
42
|
+
const normalizedRef = rawOutputRef.replace(/\\/g, "/");
|
|
43
|
+
if (!normalizedRef.startsWith(expectedPrefix)) {
|
|
44
|
+
throw new ValidationError(
|
|
45
|
+
`Preflight raw-output reference must stay under "${expectedPrefix}". Received: ${rawOutputRef}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
checkName,
|
|
51
|
+
summary,
|
|
52
|
+
result,
|
|
53
|
+
rawOutputRef: normalizedRef,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function resolvePreflightStatus(entries) {
|
|
59
|
+
if (entries.some((entry) => entry.result === "fail")) {
|
|
60
|
+
return "fail";
|
|
61
|
+
}
|
|
62
|
+
if (entries.some((entry) => entry.result === "partial")) {
|
|
63
|
+
return "partial";
|
|
64
|
+
}
|
|
65
|
+
return "pass";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function validateShipState(state) {
|
|
69
|
+
if (state.intakeOutcome === "BLOCKED_MISSING_INPUTS") {
|
|
70
|
+
throw new ValidationError(
|
|
71
|
+
'Workflow artifact is blocked by missing upstream inputs. Re-run "sdtk-code start" after the handoff inputs are ready.'
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (state.currentPhase === "verify") {
|
|
76
|
+
if (state.phaseStatus !== "completed") {
|
|
77
|
+
throw new ValidationError(
|
|
78
|
+
'Workflow must complete "verify" before "ship". Run "sdtk-code verify --complete" first.'
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (state.currentPhase !== "ship") {
|
|
85
|
+
throw new ValidationError(
|
|
86
|
+
`Cannot run "ship" from current phase "${state.currentPhase}". Re-run the next legal workflow step instead.`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function resolveShipPhaseStatus(flags, state, preflightStatus) {
|
|
92
|
+
if (flags.blocked || preflightStatus === "fail") {
|
|
93
|
+
return "blocked";
|
|
94
|
+
}
|
|
95
|
+
if (preflightStatus === "pass") {
|
|
96
|
+
return "completed";
|
|
97
|
+
}
|
|
98
|
+
return "in_progress";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function getSuggestedEngineSkills(phaseStatus, decision) {
|
|
102
|
+
if (phaseStatus === "completed") {
|
|
103
|
+
return ["code-finish"];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const primary = decision === "finish" ? "code-finish" : "code-ship";
|
|
107
|
+
if (phaseStatus === "blocked") {
|
|
108
|
+
return ["code-debug", primary];
|
|
109
|
+
}
|
|
110
|
+
return [primary];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function runShip(projectPath, featureKey, flags) {
|
|
114
|
+
const state = loadWorkflowArtifactState(projectPath, featureKey);
|
|
115
|
+
validateShipState(state);
|
|
116
|
+
|
|
117
|
+
const decision = validateChoice(flags.decision, VALID_DECISIONS, "decision");
|
|
118
|
+
const preflightEntries = parsePreflightEntries(flags.preflight, featureKey);
|
|
119
|
+
const preflightStatus = resolvePreflightStatus(preflightEntries);
|
|
120
|
+
const phaseStatus = resolveShipPhaseStatus(flags, state, preflightStatus);
|
|
121
|
+
const nextPhase = "ship";
|
|
122
|
+
const blockingState =
|
|
123
|
+
phaseStatus === "blocked"
|
|
124
|
+
? "blocked_ship_issue"
|
|
125
|
+
: phaseStatus === "completed"
|
|
126
|
+
? "clear"
|
|
127
|
+
: "ship_preflight_in_progress";
|
|
128
|
+
const suggestedEngineSkills = getSuggestedEngineSkills(phaseStatus, decision);
|
|
129
|
+
|
|
130
|
+
const artifactPath = createOrUpdateWorkflowArtifact({
|
|
131
|
+
projectPath,
|
|
132
|
+
featureKey,
|
|
133
|
+
lane: state.lane,
|
|
134
|
+
currentPhase: "ship",
|
|
135
|
+
phaseStatus,
|
|
136
|
+
intakeOutcome: state.intakeOutcome,
|
|
137
|
+
nextPhase,
|
|
138
|
+
blockingState,
|
|
139
|
+
suggestedEngineSkills,
|
|
140
|
+
managedBlocks: ["METADATA", "SHIP", "STATUS"],
|
|
141
|
+
shipDecision: decision,
|
|
142
|
+
shipStatus: phaseStatus,
|
|
143
|
+
preflightEntries,
|
|
144
|
+
shipFollowUps: normalizeEntries(flags["follow-up"]),
|
|
145
|
+
shipNotes: normalizeEntries(flags.note),
|
|
146
|
+
shipDebugNotes: normalizeEntries(flags["debug-note"]),
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
artifactPath,
|
|
151
|
+
lane: state.lane,
|
|
152
|
+
decision,
|
|
153
|
+
phaseStatus,
|
|
154
|
+
nextPhase,
|
|
155
|
+
suggestedEngineSkills,
|
|
156
|
+
preflightCount: preflightEntries.length,
|
|
157
|
+
preflightStatus,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
module.exports = {
|
|
162
|
+
runShip,
|
|
163
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { ValidationError } = require("./errors");
|
|
4
|
+
const { createOrUpdateWorkflowArtifact, loadWorkflowArtifactState } = require("./workflow-artifact");
|
|
5
|
+
|
|
6
|
+
const VALID_REVIEW_STATUS = ["pending", "pass", "partial", "fail"];
|
|
7
|
+
const VALID_EVIDENCE_RESULT = ["pass", "partial", "fail"];
|
|
8
|
+
|
|
9
|
+
function normalizeEntries(entries) {
|
|
10
|
+
return (entries || []).map((entry) => entry.trim()).filter(Boolean);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function validateChoice(value, choices, flagName) {
|
|
14
|
+
if (!choices.includes(value)) {
|
|
15
|
+
throw new ValidationError(
|
|
16
|
+
`Invalid value for --${flagName}: "${value}". Must be one of: ${choices.join(", ")}`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function parseEvidenceEntries(entries, featureKey) {
|
|
23
|
+
const normalized = normalizeEntries(entries);
|
|
24
|
+
if (normalized.length === 0) {
|
|
25
|
+
throw new ValidationError(
|
|
26
|
+
'Verification requires at least one "--evidence" entry in the format "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const expectedPrefix = `docs/dev/evidence/${featureKey}/`;
|
|
31
|
+
return normalized.map((entry) => {
|
|
32
|
+
const parts = entry.split("|").map((part) => part.trim());
|
|
33
|
+
if (parts.length !== 4 || parts.some((part) => !part)) {
|
|
34
|
+
throw new ValidationError(
|
|
35
|
+
'Each "--evidence" entry must use exactly four pipe-separated fields: "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const [checkName, summary, result, rawOutputRef] = parts;
|
|
40
|
+
validateChoice(result, VALID_EVIDENCE_RESULT, "evidence");
|
|
41
|
+
|
|
42
|
+
const normalizedRef = rawOutputRef.replace(/\\/g, "/");
|
|
43
|
+
if (!normalizedRef.startsWith(expectedPrefix)) {
|
|
44
|
+
throw new ValidationError(
|
|
45
|
+
`Evidence raw-output reference must stay under "${expectedPrefix}". Received: ${rawOutputRef}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
checkName,
|
|
51
|
+
summary,
|
|
52
|
+
result,
|
|
53
|
+
rawOutputRef: normalizedRef,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function resolveEvidenceGate(evidenceEntries) {
|
|
59
|
+
if (evidenceEntries.some((entry) => entry.result === "fail")) {
|
|
60
|
+
return "fail";
|
|
61
|
+
}
|
|
62
|
+
if (evidenceEntries.some((entry) => entry.result === "partial")) {
|
|
63
|
+
return "partial";
|
|
64
|
+
}
|
|
65
|
+
return "pass";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function resolveReviewStatus(value, flagName) {
|
|
69
|
+
if (!value) {
|
|
70
|
+
return "pending";
|
|
71
|
+
}
|
|
72
|
+
return validateChoice(value, VALID_REVIEW_STATUS, flagName);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function validateVerifyState(state) {
|
|
76
|
+
if (state.intakeOutcome === "BLOCKED_MISSING_INPUTS") {
|
|
77
|
+
throw new ValidationError(
|
|
78
|
+
'Workflow artifact is blocked by missing upstream inputs. Re-run "sdtk-code start" after the handoff inputs are ready.'
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (state.currentPhase === "build") {
|
|
83
|
+
if (state.phaseStatus !== "completed") {
|
|
84
|
+
throw new ValidationError(
|
|
85
|
+
'Workflow must complete "build" before "verify". Run "sdtk-code build --complete" first.'
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (state.currentPhase !== "verify") {
|
|
92
|
+
throw new ValidationError(
|
|
93
|
+
`Cannot run "verify" from current phase "${state.currentPhase}". Re-run the next legal workflow step instead.`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function resolveVerifyPhaseStatus(flags, state, evidenceGate, specGateStatus, qualityGateStatus) {
|
|
99
|
+
if (flags.complete && flags.blocked) {
|
|
100
|
+
throw new ValidationError('Use either "--complete" or "--blocked", not both.');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (flags.complete) {
|
|
104
|
+
if (evidenceGate !== "pass" || specGateStatus !== "pass" || qualityGateStatus !== "pass") {
|
|
105
|
+
throw new ValidationError(
|
|
106
|
+
'Verify can be marked complete only when evidence, spec/compliance, and quality gates all pass.'
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return "completed";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (
|
|
113
|
+
flags.blocked ||
|
|
114
|
+
evidenceGate === "fail" ||
|
|
115
|
+
specGateStatus === "fail" ||
|
|
116
|
+
qualityGateStatus === "fail"
|
|
117
|
+
) {
|
|
118
|
+
return "blocked";
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (
|
|
122
|
+
state.currentPhase === "verify" &&
|
|
123
|
+
state.phaseStatus === "completed" &&
|
|
124
|
+
evidenceGate === "pass" &&
|
|
125
|
+
specGateStatus === "pass" &&
|
|
126
|
+
qualityGateStatus === "pass"
|
|
127
|
+
) {
|
|
128
|
+
return "completed";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return "in_progress";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function getSuggestedEngineSkills(phaseStatus, evidenceGate, specGateStatus, qualityGateStatus) {
|
|
135
|
+
if (phaseStatus === "completed") {
|
|
136
|
+
return ["code-ship", "code-finish"];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const hasFailure =
|
|
140
|
+
evidenceGate === "fail" || specGateStatus === "fail" || qualityGateStatus === "fail";
|
|
141
|
+
const skills = ["code-verify", "code-review"];
|
|
142
|
+
if (hasFailure || phaseStatus === "blocked") {
|
|
143
|
+
skills.unshift("code-debug");
|
|
144
|
+
}
|
|
145
|
+
return skills;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function runVerify(projectPath, featureKey, flags) {
|
|
149
|
+
const state = loadWorkflowArtifactState(projectPath, featureKey);
|
|
150
|
+
validateVerifyState(state);
|
|
151
|
+
|
|
152
|
+
const evidenceEntries = parseEvidenceEntries(flags.evidence, featureKey);
|
|
153
|
+
const evidenceGate = resolveEvidenceGate(evidenceEntries);
|
|
154
|
+
const specGateStatus = resolveReviewStatus(flags["spec-status"], "spec-status");
|
|
155
|
+
const qualityGateStatus = resolveReviewStatus(flags["quality-status"], "quality-status");
|
|
156
|
+
const phaseStatus = resolveVerifyPhaseStatus(
|
|
157
|
+
flags,
|
|
158
|
+
state,
|
|
159
|
+
evidenceGate,
|
|
160
|
+
specGateStatus,
|
|
161
|
+
qualityGateStatus
|
|
162
|
+
);
|
|
163
|
+
const nextPhase = phaseStatus === "completed" ? "ship" : "verify";
|
|
164
|
+
const blockingState =
|
|
165
|
+
phaseStatus === "blocked"
|
|
166
|
+
? "blocked_verify_issue"
|
|
167
|
+
: phaseStatus === "completed"
|
|
168
|
+
? "clear"
|
|
169
|
+
: "review_in_progress";
|
|
170
|
+
const suggestedEngineSkills = getSuggestedEngineSkills(
|
|
171
|
+
phaseStatus,
|
|
172
|
+
evidenceGate,
|
|
173
|
+
specGateStatus,
|
|
174
|
+
qualityGateStatus
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const artifactPath = createOrUpdateWorkflowArtifact({
|
|
178
|
+
projectPath,
|
|
179
|
+
featureKey,
|
|
180
|
+
lane: state.lane,
|
|
181
|
+
currentPhase: "verify",
|
|
182
|
+
phaseStatus,
|
|
183
|
+
intakeOutcome: state.intakeOutcome,
|
|
184
|
+
nextPhase,
|
|
185
|
+
blockingState,
|
|
186
|
+
suggestedEngineSkills,
|
|
187
|
+
managedBlocks: ["METADATA", "VERIFY", "STATUS"],
|
|
188
|
+
evidenceEntries,
|
|
189
|
+
evidenceGate,
|
|
190
|
+
specGateStatus,
|
|
191
|
+
qualityGateStatus,
|
|
192
|
+
specNotes: normalizeEntries(flags["spec-note"]),
|
|
193
|
+
qualityNotes: normalizeEntries(flags["quality-note"]),
|
|
194
|
+
verifyDebugNotes: normalizeEntries(flags["debug-note"]),
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
artifactPath,
|
|
199
|
+
lane: state.lane,
|
|
200
|
+
phaseStatus,
|
|
201
|
+
nextPhase,
|
|
202
|
+
suggestedEngineSkills,
|
|
203
|
+
evidenceCount: evidenceEntries.length,
|
|
204
|
+
evidenceGate,
|
|
205
|
+
specGateStatus,
|
|
206
|
+
qualityGateStatus,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
module.exports = {
|
|
211
|
+
runVerify,
|
|
212
|
+
};
|