sdtk-code-kit 0.1.3 → 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.
- package/README.md +17 -0
- package/assets/manifest/toolkit-bundle.manifest.json +147 -147
- package/assets/manifest/toolkit-bundle.sha256.txt +10 -10
- package/assets/toolkit/toolkit/AGENTS.md +219 -219
- package/assets/toolkit/toolkit/install.ps1 +156 -156
- package/assets/toolkit/toolkit/sdtk-spec.config.json +6 -6
- package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +295 -295
- package/assets/toolkit/toolkit/skills/code-discover/SKILL.md +54 -54
- package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +377 -377
- package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +215 -215
- package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +28 -0
- package/package.json +44 -44
- package/src/commands/doctor.js +52 -0
- package/src/commands/guardrails.js +215 -0
- package/src/commands/help.js +244 -220
- package/src/commands/init.js +98 -98
- package/src/commands/readiness.js +77 -0
- package/src/commands/resume.js +62 -0
- package/src/commands/sleep.js +132 -0
- package/src/commands/status.js +78 -0
- package/src/commands/update.js +11 -11
- package/src/commands/verify.js +5 -0
- package/src/index.js +108 -73
- package/src/lib/project-target-guard.js +53 -53
- package/src/lib/ship-readiness.js +281 -0
- package/src/lib/sleep-plan.js +175 -0
- package/src/lib/sleep-report.js +229 -0
- package/src/lib/trust-events.js +166 -0
- package/src/lib/trust-file-scope.js +154 -0
- package/src/lib/trust-policy.js +212 -0
- package/src/lib/trust-redact.js +35 -0
- package/src/lib/trust-trace.js +179 -0
- package/src/lib/update.js +344 -344
- package/src/lib/workflow-artifact.js +9 -2
- package/src/lib/workflow-doctor.js +84 -0
- package/src/lib/workflow-handoff.js +111 -19
- package/src/lib/workflow-review-packet.js +650 -561
- package/src/lib/workflow-state.js +439 -0
- package/src/lib/workflow-verify.js +393 -356
|
@@ -264,7 +264,6 @@ function renderShipBlock(data) {
|
|
|
264
264
|
function renderManagedBlocks(data) {
|
|
265
265
|
const currentPhase = data.currentPhase || "start";
|
|
266
266
|
const isClosedWorkflow = data.nextPhase === "none";
|
|
267
|
-
const nextPhaseLabel = isClosedWorkflow ? "none (workflow closed)" : data.nextPhase;
|
|
268
267
|
const suggestedEngine =
|
|
269
268
|
isClosedWorkflow || !Array.isArray(data.suggestedEngineSkills) || data.suggestedEngineSkills.length === 0
|
|
270
269
|
? "none (workflow closed)"
|
|
@@ -310,7 +309,7 @@ function renderManagedBlocks(data) {
|
|
|
310
309
|
"<!-- SDTK-CODE:STATUS:START -->",
|
|
311
310
|
"## 5. Status Checklist",
|
|
312
311
|
`- Current phase: \`${currentPhase}\``,
|
|
313
|
-
`- Next recommended phase: \`${
|
|
312
|
+
`- Next recommended phase: \`${data.nextPhase}\``,
|
|
314
313
|
`- Suggested engine entrypoints: ${suggestedEngine}`,
|
|
315
314
|
`- Blocking state: \`${data.blockingState}\``,
|
|
316
315
|
"<!-- SDTK-CODE:STATUS:END -->",
|
|
@@ -388,6 +387,13 @@ function parseMetadataField(metadataBlock, label) {
|
|
|
388
387
|
return match ? match[1] : null;
|
|
389
388
|
}
|
|
390
389
|
|
|
390
|
+
function parseManagedField(blockText, label) {
|
|
391
|
+
if (!blockText) {
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
return parseMetadataField(blockText, label);
|
|
395
|
+
}
|
|
396
|
+
|
|
391
397
|
function loadWorkflowArtifactState(projectPath, featureKey) {
|
|
392
398
|
const artifactPath = getWorkflowArtifactPath(projectPath, featureKey);
|
|
393
399
|
if (!fs.existsSync(artifactPath)) {
|
|
@@ -492,5 +498,6 @@ module.exports = {
|
|
|
492
498
|
extractManagedBlock,
|
|
493
499
|
getWorkflowArtifactPath,
|
|
494
500
|
loadWorkflowArtifactState,
|
|
501
|
+
parseManagedField,
|
|
495
502
|
resolveWorkflowTemplatePath,
|
|
496
503
|
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { loadWorkflowState } = require("./workflow-state");
|
|
4
|
+
|
|
5
|
+
function pushIfMissing(issues, value, message) {
|
|
6
|
+
if (!value) {
|
|
7
|
+
issues.push(message);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function runWorkflowDoctor(projectPath, featureKey) {
|
|
12
|
+
const state = loadWorkflowState(projectPath, featureKey);
|
|
13
|
+
const issues = [];
|
|
14
|
+
|
|
15
|
+
if (!state.exists) {
|
|
16
|
+
issues.push("Workflow artifact is missing. Run start before workflow recovery commands.");
|
|
17
|
+
} else {
|
|
18
|
+
pushIfMissing(issues, state.blocks.METADATA, "Workflow artifact is missing required managed block METADATA.");
|
|
19
|
+
pushIfMissing(issues, state.blocks.STATUS, "Workflow artifact is missing required managed block STATUS.");
|
|
20
|
+
|
|
21
|
+
if (state.currentPhase === "verify" || state.currentPhase === "ship" || state.nextPhase === "ship") {
|
|
22
|
+
pushIfMissing(
|
|
23
|
+
issues,
|
|
24
|
+
state.blocks.VERIFY,
|
|
25
|
+
"Workflow state requires VERIFY surface, but the VERIFY managed block is missing."
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (state.currentPhase === "ship") {
|
|
30
|
+
pushIfMissing(
|
|
31
|
+
issues,
|
|
32
|
+
state.blocks.SHIP,
|
|
33
|
+
"Workflow state requires SHIP surface, but the SHIP managed block is missing."
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (state.blocks.METADATA) {
|
|
38
|
+
if (!state.lane || state.lane === "unknown") {
|
|
39
|
+
issues.push("METADATA lane is missing or unreadable.");
|
|
40
|
+
}
|
|
41
|
+
if (!state.currentPhase || state.currentPhase === "unknown") {
|
|
42
|
+
issues.push("METADATA current phase is missing or unreadable.");
|
|
43
|
+
}
|
|
44
|
+
if (!state.phaseStatus || state.phaseStatus === "unknown") {
|
|
45
|
+
issues.push("METADATA phase status is missing or unreadable.");
|
|
46
|
+
}
|
|
47
|
+
if (!state.intakeOutcome || state.intakeOutcome === "unknown") {
|
|
48
|
+
issues.push("METADATA intake outcome is missing or unreadable.");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (state.blocks.STATUS) {
|
|
53
|
+
if (!state.nextPhase || state.nextPhase === "unknown") {
|
|
54
|
+
issues.push("STATUS next recommended phase is missing or unreadable.");
|
|
55
|
+
}
|
|
56
|
+
if (!state.blockingState || state.blockingState === "unknown") {
|
|
57
|
+
issues.push("STATUS blocking state is missing or unreadable.");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (
|
|
62
|
+
state.currentPhase === "verify" &&
|
|
63
|
+
state.phaseStatus === "completed" &&
|
|
64
|
+
Array.isArray(state.evidenceEntries) &&
|
|
65
|
+
state.evidenceEntries.length === 0
|
|
66
|
+
) {
|
|
67
|
+
issues.push("Workflow claims verify completed, but no evidence entries are recorded in VERIFY.");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
issues.push(...state.contradictions);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const uniqueIssues = [...new Set(issues)];
|
|
74
|
+
return {
|
|
75
|
+
state,
|
|
76
|
+
issues: uniqueIssues,
|
|
77
|
+
healthy: uniqueIssues.length === 0,
|
|
78
|
+
result: uniqueIssues.length === 0 ? "healthy" : "invalid",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = {
|
|
83
|
+
runWorkflowDoctor,
|
|
84
|
+
};
|
|
@@ -4,7 +4,8 @@ const fs = require("fs");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const { extractManagedBlock, getWorkflowArtifactPath } = require("./workflow-artifact");
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const LATEST_HANDOFF_SCHEMA_VERSION = "0.2";
|
|
8
|
+
const ACCEPTED_HANDOFF_SCHEMA_VERSIONS = new Set(["0.1", "0.2"]);
|
|
8
9
|
const HANDOFF_STATUSES = new Set(["READY_FOR_SDTK_CODE", "BLOCKED_FOR_SDTK_CODE"]);
|
|
9
10
|
const HANDOFF_LANES = new Set(["feature", "bugfix"]);
|
|
10
11
|
const OPS_HANDOFF_SCHEMA_VERSION = "0.1";
|
|
@@ -168,6 +169,12 @@ function requireArray(payload, key) {
|
|
|
168
169
|
function collectSoftWarnings(payload) {
|
|
169
170
|
const warnings = [];
|
|
170
171
|
|
|
172
|
+
if (payload.schema_version === "0.1") {
|
|
173
|
+
warnings.push(
|
|
174
|
+
'Formal handoff compatibility warning: schema_version "0.1" is still accepted, but richer BK-057 planning context is unavailable.'
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
171
178
|
if (payload.generated_by !== "sdtk-dev") {
|
|
172
179
|
warnings.push(
|
|
173
180
|
`Formal handoff compatibility warning: generated_by is ${JSON.stringify(
|
|
@@ -183,7 +190,69 @@ function collectSoftWarnings(payload) {
|
|
|
183
190
|
return warnings;
|
|
184
191
|
}
|
|
185
192
|
|
|
186
|
-
function
|
|
193
|
+
function normalizeStringArray(entries, label) {
|
|
194
|
+
if (!Array.isArray(entries)) {
|
|
195
|
+
throw new Error(`${label} must be an array.`);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return entries.map((entry) => String(entry).trim()).filter(Boolean);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function normalizeOptionalStringArray(entries, label) {
|
|
202
|
+
if (entries == null) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return normalizeStringArray(entries, label);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function normalizeImpactMap(impactMap) {
|
|
210
|
+
if (impactMap == null) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
if (!impactMap || typeof impactMap !== "object" || Array.isArray(impactMap)) {
|
|
214
|
+
throw new Error("impact_map must be an object.");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
api_refs: normalizeStringArray(requireArray(impactMap, "api_refs"), "impact_map.api_refs").map((entry, index) =>
|
|
219
|
+
normalizeRelativePath(entry, `impact_map.api_refs[${index}]`)
|
|
220
|
+
),
|
|
221
|
+
database_refs: normalizeStringArray(requireArray(impactMap, "database_refs"), "impact_map.database_refs").map(
|
|
222
|
+
(entry, index) => normalizeRelativePath(entry, `impact_map.database_refs[${index}]`)
|
|
223
|
+
),
|
|
224
|
+
ui_refs: normalizeStringArray(requireArray(impactMap, "ui_refs"), "impact_map.ui_refs").map((entry, index) =>
|
|
225
|
+
normalizeRelativePath(entry, `impact_map.ui_refs[${index}]`)
|
|
226
|
+
),
|
|
227
|
+
flow_refs: normalizeStringArray(requireArray(impactMap, "flow_refs"), "impact_map.flow_refs").map((entry, index) =>
|
|
228
|
+
normalizeRelativePath(entry, `impact_map.flow_refs[${index}]`)
|
|
229
|
+
),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function buildImpactPlanningNotes(impactMap) {
|
|
234
|
+
if (!impactMap) {
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const categoryLabels = {
|
|
239
|
+
api_refs: "API refs",
|
|
240
|
+
database_refs: "Database refs",
|
|
241
|
+
ui_refs: "UI refs",
|
|
242
|
+
flow_refs: "Flow refs",
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
return Object.entries(categoryLabels)
|
|
246
|
+
.filter(([key]) => Array.isArray(impactMap[key]) && impactMap[key].length > 0)
|
|
247
|
+
.map(([key, label]) => `Seeded impact ${label}: ${impactMap[key].join(", ")}`);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function buildCandidatePlanningSeed(
|
|
251
|
+
lane,
|
|
252
|
+
implementationSlices,
|
|
253
|
+
testObligations,
|
|
254
|
+
{ schemaVersion, impactMap = null, recoveryNotes = [] } = {}
|
|
255
|
+
) {
|
|
187
256
|
if (lane !== "feature") {
|
|
188
257
|
return {
|
|
189
258
|
candidateSlices: [],
|
|
@@ -195,12 +264,25 @@ function buildCandidatePlanningSeed(lane, implementationSlices, testObligations)
|
|
|
195
264
|
"Seeded from the formal SDTK-SPEC handoff. Confirm or refine these candidate slices during `sdtk-code plan`.",
|
|
196
265
|
];
|
|
197
266
|
|
|
267
|
+
if (schemaVersion === "0.2") {
|
|
268
|
+
candidatePlanningNotes.push(
|
|
269
|
+
"Seeded build order: implementation_slices order from the formal SDTK-SPEC handoff is the recommended downstream sequence."
|
|
270
|
+
);
|
|
271
|
+
candidatePlanningNotes.push(...buildImpactPlanningNotes(impactMap));
|
|
272
|
+
}
|
|
273
|
+
|
|
198
274
|
if (testObligations.length > 0) {
|
|
199
275
|
candidatePlanningNotes.push(
|
|
200
276
|
...testObligations.map((entry) => `Seeded test obligation: ${entry}`)
|
|
201
277
|
);
|
|
202
278
|
}
|
|
203
279
|
|
|
280
|
+
if (schemaVersion === "0.2" && recoveryNotes.length > 0) {
|
|
281
|
+
candidatePlanningNotes.push(
|
|
282
|
+
...recoveryNotes.map((entry) => `Seeded recovery note: ${entry}`)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
204
286
|
return {
|
|
205
287
|
candidateSlices: implementationSlices,
|
|
206
288
|
candidatePlanningNotes,
|
|
@@ -562,8 +644,8 @@ function loadFormalCodeHandoffForOps(projectPath, featureKey, lane) {
|
|
|
562
644
|
|
|
563
645
|
const payload = readJsonObject(handoffPath, "CODE_HANDOFF");
|
|
564
646
|
|
|
565
|
-
if (payload.schema_version
|
|
566
|
-
throw new Error(`CODE_HANDOFF schema_version must be
|
|
647
|
+
if (!ACCEPTED_HANDOFF_SCHEMA_VERSIONS.has(payload.schema_version)) {
|
|
648
|
+
throw new Error(`CODE_HANDOFF schema_version must be one of: ${[...ACCEPTED_HANDOFF_SCHEMA_VERSIONS].join(", ")}.`);
|
|
567
649
|
}
|
|
568
650
|
if (payload.feature_key !== featureKey) {
|
|
569
651
|
throw new Error(`CODE_HANDOFF feature_key must match ${featureKey}.`);
|
|
@@ -785,7 +867,7 @@ function resolveFormalHandoffIntake(projectPath, featureKey, lane) {
|
|
|
785
867
|
});
|
|
786
868
|
}
|
|
787
869
|
|
|
788
|
-
|
|
870
|
+
let compatibilityWarnings = collectSoftWarnings(payload);
|
|
789
871
|
const { requiredInputs, optionalInputs } = buildInputEntries(projectPath, payload, featureKey, handoffPath);
|
|
790
872
|
|
|
791
873
|
try {
|
|
@@ -793,10 +875,12 @@ function resolveFormalHandoffIntake(projectPath, featureKey, lane) {
|
|
|
793
875
|
throw new Error("Formal handoff root value must be a JSON object.");
|
|
794
876
|
}
|
|
795
877
|
|
|
796
|
-
if (payload.schema_version
|
|
797
|
-
throw new Error(`schema_version must be
|
|
878
|
+
if (!ACCEPTED_HANDOFF_SCHEMA_VERSIONS.has(payload.schema_version)) {
|
|
879
|
+
throw new Error(`schema_version must be one of: ${[...ACCEPTED_HANDOFF_SCHEMA_VERSIONS].join(", ")}.`);
|
|
798
880
|
}
|
|
799
881
|
|
|
882
|
+
const schemaVersion = payload.schema_version;
|
|
883
|
+
|
|
800
884
|
if (!isNonEmptyString(payload.feature_key)) {
|
|
801
885
|
throw new Error("feature_key must be a non-empty string.");
|
|
802
886
|
}
|
|
@@ -838,13 +922,21 @@ function resolveFormalHandoffIntake(projectPath, featureKey, lane) {
|
|
|
838
922
|
const optionalRefs = requireArray(payload, "optional_refs").map((entry, index) =>
|
|
839
923
|
normalizeRelativePath(entry, `optional_refs[${index}]`)
|
|
840
924
|
);
|
|
841
|
-
const openBlockers = requireArray(payload, "open_blockers")
|
|
842
|
-
const implementationSlices =
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
925
|
+
const openBlockers = normalizeStringArray(requireArray(payload, "open_blockers"), "open_blockers");
|
|
926
|
+
const implementationSlices = normalizeStringArray(
|
|
927
|
+
requireArray(payload, "implementation_slices"),
|
|
928
|
+
"implementation_slices"
|
|
929
|
+
);
|
|
930
|
+
const testObligations = normalizeStringArray(requireArray(payload, "test_obligations"), "test_obligations");
|
|
931
|
+
const impactMap = schemaVersion === "0.2" ? normalizeImpactMap(payload.impact_map) : null;
|
|
932
|
+
const recoveryNotes = schemaVersion === "0.2" ? normalizeOptionalStringArray(payload.recovery_notes, "recovery_notes") : [];
|
|
933
|
+
|
|
934
|
+
if (schemaVersion === "0.2" && !impactMap) {
|
|
935
|
+
compatibilityWarnings = [
|
|
936
|
+
...compatibilityWarnings,
|
|
937
|
+
'Formal handoff compatibility warning: schema_version "0.2" is present without impact_map; richer impact seeding is unavailable.',
|
|
938
|
+
];
|
|
939
|
+
}
|
|
848
940
|
|
|
849
941
|
validateRequiredRefCoverage(requiredRefs, implementationSlices, featureKey);
|
|
850
942
|
|
|
@@ -892,11 +984,11 @@ function resolveFormalHandoffIntake(projectPath, featureKey, lane) {
|
|
|
892
984
|
});
|
|
893
985
|
}
|
|
894
986
|
|
|
895
|
-
const candidatePlanningSeed = buildCandidatePlanningSeed(
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
);
|
|
987
|
+
const candidatePlanningSeed = buildCandidatePlanningSeed(lane, implementationSlices, testObligations, {
|
|
988
|
+
schemaVersion,
|
|
989
|
+
impactMap,
|
|
990
|
+
recoveryNotes,
|
|
991
|
+
});
|
|
900
992
|
|
|
901
993
|
return createIntakeResult({
|
|
902
994
|
projectPath,
|