sdtk-code-kit 0.1.0 → 0.1.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 +138 -130
- package/assets/manifest/toolkit-bundle.manifest.json +47 -47
- package/assets/manifest/toolkit-bundle.sha256.txt +23 -23
- package/assets/toolkit/toolkit/AGENTS.md +8 -1
- 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 +1 -1
- package/src/commands/help.js +163 -145
- 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/lib/scope.js +19 -2
- package/src/lib/workflow-artifact.js +51 -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-ship.js +53 -3
|
@@ -2,15 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const { extractManagedBlock, getWorkflowArtifactPath } = require("./workflow-artifact");
|
|
5
6
|
|
|
6
7
|
const HANDOFF_SCHEMA_VERSION = "0.1";
|
|
7
8
|
const HANDOFF_STATUSES = new Set(["READY_FOR_SDTK_CODE", "BLOCKED_FOR_SDTK_CODE"]);
|
|
8
9
|
const HANDOFF_LANES = new Set(["feature", "bugfix"]);
|
|
10
|
+
const OPS_HANDOFF_SCHEMA_VERSION = "0.1";
|
|
11
|
+
const OPS_HANDOFF_READY_STATUS = "READY_FOR_SDTK_OPS";
|
|
9
12
|
|
|
10
13
|
function normalizePathForDoc(projectPath, targetPath) {
|
|
11
14
|
return path.relative(projectPath, targetPath).split(path.sep).join("/");
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
function getCodeHandoffPath(projectPath, featureKey) {
|
|
18
|
+
return path.join(projectPath, "docs", "dev", `CODE_HANDOFF_${featureKey}.json`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getOpsHandoffPath(projectPath, featureKey) {
|
|
22
|
+
return path.join(projectPath, "docs", "dev", `OPS_HANDOFF_${featureKey}.json`);
|
|
23
|
+
}
|
|
24
|
+
|
|
14
25
|
function buildPathEntry(key, projectPath, relativePath) {
|
|
15
26
|
const normalized = relativePath.split("/").join(path.sep);
|
|
16
27
|
const fullPath = path.join(projectPath, normalized);
|
|
@@ -64,6 +75,8 @@ function createIntakeResult({
|
|
|
64
75
|
compatibilityWarnings = [],
|
|
65
76
|
blockingMessage,
|
|
66
77
|
blockingDetails = [],
|
|
78
|
+
candidateSlices = [],
|
|
79
|
+
candidatePlanningNotes = [],
|
|
67
80
|
}) {
|
|
68
81
|
return {
|
|
69
82
|
requiredInputs: uniquePathEntries(requiredInputs || []),
|
|
@@ -83,6 +96,8 @@ function createIntakeResult({
|
|
|
83
96
|
blockingDetails,
|
|
84
97
|
featureKey,
|
|
85
98
|
lane,
|
|
99
|
+
candidateSlices,
|
|
100
|
+
candidatePlanningNotes,
|
|
86
101
|
};
|
|
87
102
|
}
|
|
88
103
|
|
|
@@ -168,6 +183,492 @@ function collectSoftWarnings(payload) {
|
|
|
168
183
|
return warnings;
|
|
169
184
|
}
|
|
170
185
|
|
|
186
|
+
function buildCandidatePlanningSeed(lane, implementationSlices, testObligations) {
|
|
187
|
+
if (lane !== "feature") {
|
|
188
|
+
return {
|
|
189
|
+
candidateSlices: [],
|
|
190
|
+
candidatePlanningNotes: [],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const candidatePlanningNotes = [
|
|
195
|
+
"Seeded from the formal SDTK-SPEC handoff. Confirm or refine these candidate slices during `sdtk-code plan`.",
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
if (testObligations.length > 0) {
|
|
199
|
+
candidatePlanningNotes.push(
|
|
200
|
+
...testObligations.map((entry) => `Seeded test obligation: ${entry}`)
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
candidateSlices: implementationSlices,
|
|
206
|
+
candidatePlanningNotes,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function humanizeFeatureKey(featureKey) {
|
|
211
|
+
return String(featureKey)
|
|
212
|
+
.split("_")
|
|
213
|
+
.filter(Boolean)
|
|
214
|
+
.map((token) => token.charAt(0) + token.slice(1).toLowerCase())
|
|
215
|
+
.join(" ");
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function uniqueStrings(entries) {
|
|
219
|
+
return [...new Set((entries || []).map((entry) => String(entry).trim()).filter(Boolean))];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function uniqueObjects(entries, keyBuilder) {
|
|
223
|
+
const seen = new Set();
|
|
224
|
+
const results = [];
|
|
225
|
+
for (const entry of entries || []) {
|
|
226
|
+
const key = keyBuilder(entry);
|
|
227
|
+
if (!key || seen.has(key)) {
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
seen.add(key);
|
|
231
|
+
results.push(entry);
|
|
232
|
+
}
|
|
233
|
+
return results;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function parseBulletEntries(sectionText) {
|
|
237
|
+
if (!sectionText) {
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return sectionText
|
|
242
|
+
.split(/\r?\n/)
|
|
243
|
+
.map((line) => line.trim())
|
|
244
|
+
.filter((line) => line.startsWith("- "))
|
|
245
|
+
.map((line) => line.slice(2).trim())
|
|
246
|
+
.filter(Boolean);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function parseBlockSection(blockText, heading) {
|
|
250
|
+
if (!blockText) {
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const escapedHeading = heading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
255
|
+
const match = blockText.match(new RegExp(`### ${escapedHeading}\\r?\\n([\\s\\S]*?)(?=\\r?\\n### |$)`));
|
|
256
|
+
return match ? parseBulletEntries(match[1]) : [];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function parseInlineSliceSection(planBlock) {
|
|
260
|
+
if (!planBlock) {
|
|
261
|
+
return [];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const match = planBlock.match(/## 4\. Plan \/ Slices\r?\n([\s\S]*?)(?=\r?\n### Planning Notes)/);
|
|
265
|
+
return match ? parseBulletEntries(match[1]) : [];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function isPlaceholderSlice(value) {
|
|
269
|
+
return [
|
|
270
|
+
"Pending confirmation during workflow planning.",
|
|
271
|
+
"Pending lane-specific planning or build guidance.",
|
|
272
|
+
"Lightweight bugfix planning not recorded yet.",
|
|
273
|
+
"No active build slices recorded yet.",
|
|
274
|
+
"Pending build-phase execution.",
|
|
275
|
+
].includes(value);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function cleanSliceEntries(entries) {
|
|
279
|
+
return uniqueStrings(entries).filter((entry) => !isPlaceholderSlice(entry));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function deriveScopeSliceId(title, index) {
|
|
283
|
+
const prefixed = title.match(/^([A-Z]\d+(?:-[A-Za-z0-9]+)?)\s*:/);
|
|
284
|
+
if (prefixed) {
|
|
285
|
+
return prefixed[1];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const tokenized = title.match(/^([A-Z]\d+(?:-[A-Za-z0-9]+)?)\b/);
|
|
289
|
+
if (tokenized) {
|
|
290
|
+
return tokenized[1];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return `S${index + 1}`;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function deriveOpsImpactSummary(title) {
|
|
297
|
+
const lower = title.toLowerCase();
|
|
298
|
+
|
|
299
|
+
if (/\b(database|migration|schema|sql|table|db)\b/.test(lower)) {
|
|
300
|
+
return "Requires rollout sequencing plus migration and recovery safety checks.";
|
|
301
|
+
}
|
|
302
|
+
if (/\b(api|service|endpoint|backend|auth)\b/.test(lower)) {
|
|
303
|
+
return "Requires runtime service deployment plus API smoke validation.";
|
|
304
|
+
}
|
|
305
|
+
if (/\b(ui|screen|frontend|page|form|layout)\b/.test(lower)) {
|
|
306
|
+
return "Requires user-facing rollout validation for the updated UI surface.";
|
|
307
|
+
}
|
|
308
|
+
if (/\b(flow|interaction|integration|dispatch)\b/.test(lower)) {
|
|
309
|
+
return "Requires end-to-end runtime validation across the affected interaction path.";
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return "Requires bounded runtime rollout and post-deploy validation for the scoped slice.";
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function parseWorkflowScopeSlices(workflowText, handoffPayload) {
|
|
316
|
+
const planBlock = extractManagedBlock(workflowText, "PLAN");
|
|
317
|
+
const buildBlock = extractManagedBlock(workflowText, "BUILD");
|
|
318
|
+
|
|
319
|
+
let sliceTitles = cleanSliceEntries(parseBlockSection(planBlock, "Finalized Slices After `plan`"));
|
|
320
|
+
if (sliceTitles.length === 0) {
|
|
321
|
+
sliceTitles = cleanSliceEntries(parseInlineSliceSection(planBlock));
|
|
322
|
+
}
|
|
323
|
+
if (sliceTitles.length === 0) {
|
|
324
|
+
sliceTitles = cleanSliceEntries(parseBlockSection(buildBlock, "Active Slices"));
|
|
325
|
+
}
|
|
326
|
+
if (sliceTitles.length === 0) {
|
|
327
|
+
sliceTitles = uniqueStrings(handoffPayload.implementation_slices || []);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return sliceTitles.map((title, index) => ({
|
|
331
|
+
slice_id: deriveScopeSliceId(title, index),
|
|
332
|
+
title,
|
|
333
|
+
ops_impact_summary: deriveOpsImpactSummary(title),
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function inferEvidenceKind(checkName, refPath) {
|
|
338
|
+
const combined = `${checkName} ${refPath}`.toLowerCase();
|
|
339
|
+
if (/\b(review|checklist|approval|captain)\b/.test(combined)) {
|
|
340
|
+
return "review";
|
|
341
|
+
}
|
|
342
|
+
if (/\b(pack|build|bundle|artifact)\b/.test(combined)) {
|
|
343
|
+
return "build";
|
|
344
|
+
}
|
|
345
|
+
if (/\b(pytest|npm test|test|regression|smoke|verify)\b/.test(combined)) {
|
|
346
|
+
return "test";
|
|
347
|
+
}
|
|
348
|
+
return "artifact";
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function parseEvidenceEntriesFromWorkflow(workflowText) {
|
|
352
|
+
const entries = [];
|
|
353
|
+
const regex = /^- `([^`]+)` \| `([^`]+)` \| ([^\r\n]+?) \| Raw output: `([^`]+)`$/gm;
|
|
354
|
+
let match;
|
|
355
|
+
while ((match = regex.exec(workflowText)) !== null) {
|
|
356
|
+
entries.push({
|
|
357
|
+
checkName: match[1],
|
|
358
|
+
result: match[2],
|
|
359
|
+
summary: match[3].trim(),
|
|
360
|
+
rawOutputRef: match[4],
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
return entries;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function buildCodeEvidenceRefs(projectPath, featureKey, workflowText) {
|
|
367
|
+
const workflowPath = getWorkflowArtifactPath(projectPath, featureKey);
|
|
368
|
+
const refs = [
|
|
369
|
+
{
|
|
370
|
+
label: `${humanizeFeatureKey(featureKey)} code workflow artifact`,
|
|
371
|
+
path: normalizePathForDoc(projectPath, workflowPath),
|
|
372
|
+
kind: "workflow",
|
|
373
|
+
},
|
|
374
|
+
];
|
|
375
|
+
|
|
376
|
+
for (const entry of parseEvidenceEntriesFromWorkflow(workflowText)) {
|
|
377
|
+
refs.push({
|
|
378
|
+
label: `${entry.checkName} evidence`,
|
|
379
|
+
path: entry.rawOutputRef,
|
|
380
|
+
kind: inferEvidenceKind(entry.checkName, entry.rawOutputRef),
|
|
381
|
+
notes: entry.summary,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return uniqueObjects(refs, (entry) => `${entry.kind}::${entry.path}`);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function hasRequiredRef(payload, prefix) {
|
|
389
|
+
return Array.isArray(payload.required_refs)
|
|
390
|
+
? payload.required_refs.some((entry) => String(entry).startsWith(prefix))
|
|
391
|
+
: false;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function buildDeploymentPrerequisites(preflightEntries) {
|
|
395
|
+
return uniqueStrings(
|
|
396
|
+
preflightEntries.map((entry) => `${entry.checkName}: ${entry.summary}`)
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function buildEnvironmentAssumptions(handoffPayload, decision) {
|
|
401
|
+
const assumptions = [
|
|
402
|
+
"OPS intake remains anchored to the current formal CODE_HANDOFF and repo config contract.",
|
|
403
|
+
`DEV-Run should use ${handoffPayload.repo_config_ref} as the current repo command/config reference.`,
|
|
404
|
+
];
|
|
405
|
+
|
|
406
|
+
if (decision === "finish") {
|
|
407
|
+
assumptions.push(
|
|
408
|
+
'The CODE closeout used "finish", so remaining hardening or deployment work stays explicit during DEV-Run intake.'
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (hasRequiredRef(handoffPayload, "docs/api/")) {
|
|
413
|
+
assumptions.push("Runtime execution can reach the service or API surfaces referenced by the scoped slices.");
|
|
414
|
+
}
|
|
415
|
+
if (hasRequiredRef(handoffPayload, "docs/database/")) {
|
|
416
|
+
assumptions.push("Runtime rollout preserves compatible database state for the scoped slices.");
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return uniqueStrings(assumptions);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function buildInfraRuntimeDependencies(handoffPayload) {
|
|
423
|
+
const dependencies = [
|
|
424
|
+
{
|
|
425
|
+
dependency: "sdtk-spec.config.json",
|
|
426
|
+
requirement: "Use the repo command and environment contract from sdtk-spec.config.json during DEV-Run execution.",
|
|
427
|
+
},
|
|
428
|
+
];
|
|
429
|
+
|
|
430
|
+
if (hasRequiredRef(handoffPayload, "docs/api/")) {
|
|
431
|
+
dependencies.push({
|
|
432
|
+
dependency: "Application service runtime",
|
|
433
|
+
requirement: "Deploy and validate the API or service surfaces referenced by the scoped slices.",
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
if (hasRequiredRef(handoffPayload, "docs/database/")) {
|
|
437
|
+
dependencies.push({
|
|
438
|
+
dependency: "Database / schema state",
|
|
439
|
+
requirement: "Provision compatible database state, migration handling, and recovery safety for the scoped slices.",
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
if (hasRequiredRef(handoffPayload, "docs/design/")) {
|
|
443
|
+
dependencies.push({
|
|
444
|
+
dependency: "Frontend or admin delivery surface",
|
|
445
|
+
requirement: "Expose the updated UI surface and verify that the scoped routes remain reachable after rollout.",
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return uniqueObjects(dependencies, (entry) => entry.dependency);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function buildObservabilityRequirements(handoffPayload) {
|
|
453
|
+
const requirements = [
|
|
454
|
+
"DEV-Run must capture deployment and post-deploy validation evidence for the scoped slices.",
|
|
455
|
+
];
|
|
456
|
+
|
|
457
|
+
if (hasRequiredRef(handoffPayload, "docs/api/")) {
|
|
458
|
+
requirements.push("API or service health plus bounded smoke results must be observable during OPS rollout.");
|
|
459
|
+
}
|
|
460
|
+
if (hasRequiredRef(handoffPayload, "docs/database/")) {
|
|
461
|
+
requirements.push("Migration and persistence outcomes must be observable through logs, health checks, or equivalent evidence.");
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return uniqueStrings(requirements);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function buildRollbackRecoveryExpectations(handoffPayload, decision) {
|
|
468
|
+
const expectations = [
|
|
469
|
+
"Rollback or recovery steps must be explicit before runtime rollout begins.",
|
|
470
|
+
];
|
|
471
|
+
|
|
472
|
+
if (hasRequiredRef(handoffPayload, "docs/database/")) {
|
|
473
|
+
expectations.push("Database-affecting slices require rollback-safe migrations or documented restore steps.");
|
|
474
|
+
}
|
|
475
|
+
if (decision === "finish") {
|
|
476
|
+
expectations.push("Remaining hardening items carried from CODE closeout must stay explicit if rollback readiness is incomplete.");
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return uniqueStrings(expectations);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function buildSuggestedNextOpsPath(lane, decision) {
|
|
483
|
+
const suggestedChain =
|
|
484
|
+
lane === "bugfix"
|
|
485
|
+
? ["ops-plan", "ops-deploy"]
|
|
486
|
+
: ["ops-plan", "ops-deploy", "ops-monitor"];
|
|
487
|
+
|
|
488
|
+
return {
|
|
489
|
+
start_with: suggestedChain[0],
|
|
490
|
+
suggested_chain: suggestedChain,
|
|
491
|
+
close_with: "ops-verify",
|
|
492
|
+
why:
|
|
493
|
+
decision === "finish"
|
|
494
|
+
? "CODE closed a bounded implementation pass and DEV-Run should carry the explicit hardening or deployment follow-up into the OPS path."
|
|
495
|
+
: "CODE closed the scoped implementation with the stronger closeout bundle and DEV-Run can continue with the normal OPS path.",
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function buildOptionalReferenceEntries(handoffPayload) {
|
|
500
|
+
const refs = [];
|
|
501
|
+
|
|
502
|
+
if (isNonEmptyString(handoffPayload.feature_impl_plan_path)) {
|
|
503
|
+
refs.push({
|
|
504
|
+
label: "Upstream feature implementation plan",
|
|
505
|
+
path: handoffPayload.feature_impl_plan_path.trim(),
|
|
506
|
+
kind: "artifact",
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
if (Array.isArray(handoffPayload.optional_refs)) {
|
|
511
|
+
handoffPayload.optional_refs.forEach((entry, index) => {
|
|
512
|
+
if (isNonEmptyString(entry)) {
|
|
513
|
+
refs.push({
|
|
514
|
+
label: `Optional upstream ref ${index + 1}`,
|
|
515
|
+
path: entry.trim(),
|
|
516
|
+
kind: "artifact",
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return uniqueObjects(refs, (entry) => entry.path);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
function buildOptionalOpsNotes(decision, followUps, shipNotes) {
|
|
526
|
+
const notes = [];
|
|
527
|
+
|
|
528
|
+
if (decision === "finish") {
|
|
529
|
+
notes.push('CODE closeout used "finish", so remaining hardening or deployment work stays explicit for DEV-Run.');
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
notes.push(...normalizeOptionalNotes(shipNotes));
|
|
533
|
+
notes.push(...normalizeOptionalNotes((followUps || []).map((entry) => `Follow-up: ${entry}`)));
|
|
534
|
+
|
|
535
|
+
return uniqueStrings(notes);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function normalizeOptionalNotes(entries) {
|
|
539
|
+
return (entries || []).map((entry) => String(entry).trim()).filter(Boolean);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function readJsonObject(jsonPath, label) {
|
|
543
|
+
let payload;
|
|
544
|
+
try {
|
|
545
|
+
payload = JSON.parse(fs.readFileSync(jsonPath, "utf-8"));
|
|
546
|
+
} catch (error) {
|
|
547
|
+
throw new Error(`${label} is invalid JSON: ${error.message}`);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
551
|
+
throw new Error(`${label} must be a JSON object.`);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return payload;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function loadFormalCodeHandoffForOps(projectPath, featureKey, lane) {
|
|
558
|
+
const handoffPath = getCodeHandoffPath(projectPath, featureKey);
|
|
559
|
+
if (!fs.existsSync(handoffPath)) {
|
|
560
|
+
return null;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
const payload = readJsonObject(handoffPath, "CODE_HANDOFF");
|
|
564
|
+
|
|
565
|
+
if (payload.schema_version !== HANDOFF_SCHEMA_VERSION) {
|
|
566
|
+
throw new Error(`CODE_HANDOFF schema_version must be "${HANDOFF_SCHEMA_VERSION}".`);
|
|
567
|
+
}
|
|
568
|
+
if (payload.feature_key !== featureKey) {
|
|
569
|
+
throw new Error(`CODE_HANDOFF feature_key must match ${featureKey}.`);
|
|
570
|
+
}
|
|
571
|
+
if (!HANDOFF_LANES.has(payload.recommended_lane) || payload.recommended_lane !== lane) {
|
|
572
|
+
throw new Error(`CODE_HANDOFF recommended_lane must match the current lane "${lane}".`);
|
|
573
|
+
}
|
|
574
|
+
if (!HANDOFF_STATUSES.has(payload.handoff_status) || payload.handoff_status !== "READY_FOR_SDTK_CODE") {
|
|
575
|
+
throw new Error('CODE_HANDOFF must remain "READY_FOR_SDTK_CODE" for canonical OPS emission.');
|
|
576
|
+
}
|
|
577
|
+
if (payload.repo_config_ref !== "sdtk-spec.config.json") {
|
|
578
|
+
throw new Error('CODE_HANDOFF repo_config_ref must remain "sdtk-spec.config.json".');
|
|
579
|
+
}
|
|
580
|
+
if (!Array.isArray(payload.implementation_slices) || payload.implementation_slices.length === 0) {
|
|
581
|
+
throw new Error("CODE_HANDOFF must keep at least one implementation_slices entry.");
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
return {
|
|
585
|
+
handoffPath,
|
|
586
|
+
payload,
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function emitOpsHandoffForCompletedCloseout({
|
|
591
|
+
projectPath,
|
|
592
|
+
featureKey,
|
|
593
|
+
lane,
|
|
594
|
+
decision,
|
|
595
|
+
preflightEntries,
|
|
596
|
+
shipFollowUps,
|
|
597
|
+
shipNotes,
|
|
598
|
+
}) {
|
|
599
|
+
let formalCodeHandoff;
|
|
600
|
+
try {
|
|
601
|
+
formalCodeHandoff = loadFormalCodeHandoffForOps(projectPath, featureKey, lane);
|
|
602
|
+
} catch (error) {
|
|
603
|
+
return {
|
|
604
|
+
emitted: false,
|
|
605
|
+
reason: `skipped because the current formal CODE_HANDOFF is invalid (${error.message})`,
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
if (!formalCodeHandoff) {
|
|
610
|
+
return {
|
|
611
|
+
emitted: false,
|
|
612
|
+
reason:
|
|
613
|
+
"skipped because compatibility fallback workflows do not emit the canonical CODE -> OPS bridge without docs/dev/CODE_HANDOFF_[FEATURE_KEY].json",
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const workflowPath = getWorkflowArtifactPath(projectPath, featureKey);
|
|
618
|
+
const workflowText = fs.readFileSync(workflowPath, "utf-8");
|
|
619
|
+
const scopeSlices = parseWorkflowScopeSlices(workflowText, formalCodeHandoff.payload);
|
|
620
|
+
const codeEvidenceRefs = buildCodeEvidenceRefs(projectPath, featureKey, workflowText);
|
|
621
|
+
const opsHandoffPath = getOpsHandoffPath(projectPath, featureKey);
|
|
622
|
+
const relativeWorkflowPath = normalizePathForDoc(projectPath, workflowPath);
|
|
623
|
+
const relativeCodeHandoffPath = normalizePathForDoc(projectPath, formalCodeHandoff.handoffPath);
|
|
624
|
+
const optionalRefs = buildOptionalReferenceEntries(formalCodeHandoff.payload);
|
|
625
|
+
const notes = buildOptionalOpsNotes(decision, shipFollowUps, shipNotes);
|
|
626
|
+
|
|
627
|
+
const payload = {
|
|
628
|
+
schema_version: OPS_HANDOFF_SCHEMA_VERSION,
|
|
629
|
+
feature_key: featureKey,
|
|
630
|
+
feature_name: humanizeFeatureKey(featureKey),
|
|
631
|
+
delivery_lane: lane,
|
|
632
|
+
generated_by: "sdtk-code",
|
|
633
|
+
generated_at: new Date().toISOString(),
|
|
634
|
+
handoff_status: OPS_HANDOFF_READY_STATUS,
|
|
635
|
+
producer_owner: "DEV-Code",
|
|
636
|
+
consumer_owner: "DEV-Run",
|
|
637
|
+
code_workflow_path: relativeWorkflowPath,
|
|
638
|
+
code_handoff_path: relativeCodeHandoffPath,
|
|
639
|
+
repo_config_ref: formalCodeHandoff.payload.repo_config_ref,
|
|
640
|
+
scope_slices: scopeSlices,
|
|
641
|
+
code_evidence_refs: codeEvidenceRefs,
|
|
642
|
+
deployment_prerequisites: buildDeploymentPrerequisites(preflightEntries),
|
|
643
|
+
environment_assumptions: buildEnvironmentAssumptions(formalCodeHandoff.payload, decision),
|
|
644
|
+
infra_runtime_dependencies: buildInfraRuntimeDependencies(formalCodeHandoff.payload),
|
|
645
|
+
observability_requirements: buildObservabilityRequirements(formalCodeHandoff.payload),
|
|
646
|
+
rollback_recovery_expectations: buildRollbackRecoveryExpectations(
|
|
647
|
+
formalCodeHandoff.payload,
|
|
648
|
+
decision
|
|
649
|
+
),
|
|
650
|
+
open_blockers: [],
|
|
651
|
+
suggested_next_ops_path: buildSuggestedNextOpsPath(lane, decision),
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
if (optionalRefs.length > 0) {
|
|
655
|
+
payload.optional_refs = optionalRefs;
|
|
656
|
+
}
|
|
657
|
+
if (notes.length > 0) {
|
|
658
|
+
payload.notes = notes;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
fs.writeFileSync(opsHandoffPath, JSON.stringify(payload, null, 2) + "\n", "utf-8");
|
|
662
|
+
|
|
663
|
+
return {
|
|
664
|
+
emitted: true,
|
|
665
|
+
opsHandoffPath,
|
|
666
|
+
handoffStatus: OPS_HANDOFF_READY_STATUS,
|
|
667
|
+
scopeSliceCount: scopeSlices.length,
|
|
668
|
+
evidenceRefCount: codeEvidenceRefs.length,
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
|
|
171
672
|
function validateRequiredRefCoverage(requiredRefs, implementationSlices, featureKey) {
|
|
172
673
|
const archPath = `docs/architecture/ARCH_DESIGN_${featureKey}.md`;
|
|
173
674
|
const backlogPath = `docs/product/BACKLOG_${featureKey}.md`;
|
|
@@ -391,6 +892,12 @@ function resolveFormalHandoffIntake(projectPath, featureKey, lane) {
|
|
|
391
892
|
});
|
|
392
893
|
}
|
|
393
894
|
|
|
895
|
+
const candidatePlanningSeed = buildCandidatePlanningSeed(
|
|
896
|
+
lane,
|
|
897
|
+
implementationSlices,
|
|
898
|
+
testObligations
|
|
899
|
+
);
|
|
900
|
+
|
|
394
901
|
return createIntakeResult({
|
|
395
902
|
projectPath,
|
|
396
903
|
featureKey,
|
|
@@ -406,6 +913,7 @@ function resolveFormalHandoffIntake(projectPath, featureKey, lane) {
|
|
|
406
913
|
intakeSource: "formal_handoff",
|
|
407
914
|
handoffStatus: payload.handoff_status,
|
|
408
915
|
compatibilityWarnings,
|
|
916
|
+
...candidatePlanningSeed,
|
|
409
917
|
});
|
|
410
918
|
} catch (error) {
|
|
411
919
|
return createBlockedFormalIntake({
|
|
@@ -423,5 +931,7 @@ function resolveFormalHandoffIntake(projectPath, featureKey, lane) {
|
|
|
423
931
|
}
|
|
424
932
|
|
|
425
933
|
module.exports = {
|
|
934
|
+
emitOpsHandoffForCompletedCloseout,
|
|
935
|
+
getOpsHandoffPath,
|
|
426
936
|
resolveFormalHandoffIntake,
|
|
427
937
|
};
|
|
@@ -53,7 +53,8 @@ function getSuggestedEngineSkills(lane, blocked) {
|
|
|
53
53
|
|
|
54
54
|
function buildLegacyCompatibilityWarnings(featureKey, lane) {
|
|
55
55
|
const warnings = [
|
|
56
|
-
"Formal SDTK-SPEC handoff missing. Using
|
|
56
|
+
"Formal SDTK-SPEC handoff missing. Using bounded compatibility intake from FEATURE_IMPL_PLAN + sdtk-spec.config.json.",
|
|
57
|
+
"Upstream SDTK-SPEC /dev still owns implementation-readiness planning and formal CODE_HANDOFF scope.",
|
|
57
58
|
];
|
|
58
59
|
if (lane === "feature") {
|
|
59
60
|
warnings.push(
|