sdtk-code-kit 0.1.3 → 0.2.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.
Files changed (64) hide show
  1. package/README.md +202 -185
  2. package/assets/manifest/toolkit-bundle.manifest.json +49 -49
  3. package/assets/manifest/toolkit-bundle.sha256.txt +24 -24
  4. package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +78 -78
  5. package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +150 -150
  6. package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +62 -62
  7. package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +82 -82
  8. package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +12 -12
  9. package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +55 -55
  10. package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +1 -1
  11. package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +68 -68
  12. package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +74 -74
  13. package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +205 -205
  14. package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +64 -64
  15. package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +26 -26
  16. package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +113 -113
  17. package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +61 -61
  18. package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +85 -85
  19. package/assets/toolkit/toolkit/skills/code-review/SKILL.md +79 -79
  20. package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +125 -125
  21. package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +146 -146
  22. package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +52 -52
  23. package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +1 -1
  24. package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +299 -299
  25. package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +144 -144
  26. package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +13 -13
  27. package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +140 -112
  28. package/bin/sdtk-code.js +14 -14
  29. package/package.json +4 -4
  30. package/src/commands/build.js +53 -53
  31. package/src/commands/doctor.js +52 -0
  32. package/src/commands/generate.js +11 -11
  33. package/src/commands/guardrails.js +123 -0
  34. package/src/commands/help.js +28 -4
  35. package/src/commands/plan.js +53 -53
  36. package/src/commands/readiness.js +77 -0
  37. package/src/commands/resume.js +62 -0
  38. package/src/commands/runtime.js +224 -224
  39. package/src/commands/ship.js +59 -59
  40. package/src/commands/start.js +89 -89
  41. package/src/commands/status.js +78 -0
  42. package/src/commands/verify.js +71 -66
  43. package/src/index.js +32 -1
  44. package/src/lib/args.js +107 -107
  45. package/src/lib/errors.js +41 -41
  46. package/src/lib/powershell.js +65 -65
  47. package/src/lib/scope.js +72 -72
  48. package/src/lib/ship-readiness.js +281 -0
  49. package/src/lib/toolkit-payload.js +72 -72
  50. package/src/lib/trust-events.js +166 -0
  51. package/src/lib/trust-file-scope.js +154 -0
  52. package/src/lib/trust-policy.js +212 -0
  53. package/src/lib/trust-redact.js +35 -0
  54. package/src/lib/trust-trace.js +179 -0
  55. package/src/lib/workflow-artifact.js +503 -496
  56. package/src/lib/workflow-build.js +127 -127
  57. package/src/lib/workflow-doctor.js +84 -0
  58. package/src/lib/workflow-handoff.js +1029 -937
  59. package/src/lib/workflow-intake.js +101 -101
  60. package/src/lib/workflow-plan.js +193 -193
  61. package/src/lib/workflow-review-packet.js +89 -0
  62. package/src/lib/workflow-ship.js +213 -213
  63. package/src/lib/workflow-state.js +439 -0
  64. package/src/lib/workflow-verify.js +43 -6
@@ -225,6 +225,84 @@ function buildLinkedContractRefs(codeHandoffContext) {
225
225
  );
226
226
  }
227
227
 
228
+ function parseProvenanceContext(workflowText) {
229
+ const match = String(workflowText || "").match(/## Provenance\r?\n([\s\S]*?)(?=\r?\n##\s|$)/);
230
+ if (!match) {
231
+ return {
232
+ sectionPresent: false,
233
+ mode: "missing",
234
+ sourceRefs: [],
235
+ body: "",
236
+ };
237
+ }
238
+
239
+ const body = String(match[1] || "").trim();
240
+ const sourceRefMatches = [...body.matchAll(/\|\s*\d+\s*\|\s*([^|]+)\|\s*([^|]+)\|\s*([^|]+)\|\s*([^|]+)\|/g)];
241
+ const sourceRefs = sourceRefMatches
242
+ .map((item) => ({
243
+ source: item[1].trim(),
244
+ location: item[2].trim(),
245
+ consultedDate: item[3].trim(),
246
+ purpose: item[4].trim(),
247
+ }))
248
+ .filter(
249
+ (entry) =>
250
+ ![entry.source, entry.location, entry.consultedDate, entry.purpose].some((value) =>
251
+ /^<.+>$/.test(String(value))
252
+ )
253
+ );
254
+
255
+ const hasNoReferenceDeclaration = /no external source references were consulted for this batch\./i.test(body);
256
+ const hasExternalRefs = sourceRefs.length > 0;
257
+
258
+ return {
259
+ sectionPresent: true,
260
+ mode: hasExternalRefs ? "external" : hasNoReferenceDeclaration ? "no_reference" : "missing",
261
+ sourceRefs,
262
+ body,
263
+ };
264
+ }
265
+
266
+ function buildReferenceDisclosure(provenanceContext) {
267
+ if (!provenanceContext.sectionPresent) {
268
+ return {
269
+ mode: "missing",
270
+ lines: [
271
+ "- Warning: workflow plan is missing the required `## Provenance` section.",
272
+ "- Expected no-reference declaration: `No external source references were consulted for this batch.`",
273
+ ],
274
+ };
275
+ }
276
+
277
+ if (provenanceContext.mode === "external") {
278
+ return {
279
+ mode: "external",
280
+ lines: [
281
+ "- External references were consulted for this batch.",
282
+ "- Source references:",
283
+ ...provenanceContext.sourceRefs.map(
284
+ (entry, index) =>
285
+ ` - ${index + 1}. ${entry.source} | ${entry.location} | ${entry.consultedDate} | ${entry.purpose}`
286
+ ),
287
+ ],
288
+ };
289
+ }
290
+
291
+ if (provenanceContext.mode === "no_reference") {
292
+ return {
293
+ mode: "no_reference",
294
+ lines: ["- No external references were consulted for this batch."],
295
+ };
296
+ }
297
+
298
+ return {
299
+ mode: "missing",
300
+ lines: [
301
+ "- Warning: unable to classify provenance mode from the workflow plan.",
302
+ "- Provide either a complete provenance log or the no-reference declaration.",
303
+ ],
304
+ };
305
+ }
228
306
  function buildChangedFileRows(changedFiles) {
229
307
  return changedFiles.map((entry, index) => [
230
308
  String(index + 1),
@@ -433,6 +511,8 @@ function createReviewPacket({
433
511
  codeHandoffContext
434
512
  );
435
513
  const linkedContractRefs = buildLinkedContractRefs(codeHandoffContext);
514
+ const provenanceContext = parseProvenanceContext(workflowText);
515
+ const referenceDisclosure = buildReferenceDisclosure(provenanceContext);
436
516
  const guidance = buildReviewerGuidance(
437
517
  reviewerGuidance,
438
518
  truthSyncTargets,
@@ -545,6 +625,12 @@ function createReviewPacket({
545
625
  "No additional reviewer guidance was recorded during verify."
546
626
  ),
547
627
  "",
628
+ "## 11. Reference Disclosure",
629
+ renderBulletList(
630
+ referenceDisclosure.lines,
631
+ "Reference disclosure details were not generated."
632
+ ),
633
+ "",
548
634
  ].join("\n");
549
635
 
550
636
  fs.mkdirSync(path.dirname(reviewPacketPath), { recursive: true });
@@ -552,6 +638,9 @@ function createReviewPacket({
552
638
 
553
639
  return {
554
640
  reviewPacketPath,
641
+ hasReferenceDisclosure: content.includes("## 11. Reference Disclosure"),
642
+ provenanceMode: provenanceContext.mode,
643
+ referenceDisclosureMode: referenceDisclosure.mode,
555
644
  };
556
645
  }
557
646
 
@@ -1,213 +1,213 @@
1
- "use strict";
2
-
3
- const { ValidationError } = require("./errors");
4
- const { createOrUpdateWorkflowArtifact, loadWorkflowArtifactState } = require("./workflow-artifact");
5
- const { emitOpsHandoffForCompletedCloseout } = require("./workflow-handoff");
6
-
7
- const VALID_DECISIONS = ["ship", "finish"];
8
- const VALID_PREFLIGHT_RESULT = ["pass", "partial", "fail"];
9
-
10
- function normalizeEntries(entries) {
11
- return (entries || []).map((entry) => entry.trim()).filter(Boolean);
12
- }
13
-
14
- function validateChoice(value, choices, flagName) {
15
- if (!choices.includes(value)) {
16
- throw new ValidationError(
17
- `Invalid value for --${flagName}: "${value}". Must be one of: ${choices.join(", ")}`
18
- );
19
- }
20
- return value;
21
- }
22
-
23
- function parsePreflightEntries(entries, featureKey) {
24
- const normalized = normalizeEntries(entries);
25
- if (normalized.length === 0) {
26
- throw new ValidationError(
27
- 'Ship requires at least one "--preflight" entry in the format "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
28
- );
29
- }
30
-
31
- const expectedPrefix = `docs/dev/evidence/${featureKey}/`;
32
- return normalized.map((entry) => {
33
- const parts = entry.split("|").map((part) => part.trim());
34
- if (parts.length !== 4 || parts.some((part) => !part)) {
35
- throw new ValidationError(
36
- 'Each "--preflight" entry must use exactly four pipe-separated fields: "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
37
- );
38
- }
39
-
40
- const [checkName, summary, result, rawOutputRef] = parts;
41
- validateChoice(result, VALID_PREFLIGHT_RESULT, "preflight");
42
-
43
- const normalizedRef = rawOutputRef.replace(/\\/g, "/");
44
- if (!normalizedRef.startsWith(expectedPrefix)) {
45
- throw new ValidationError(
46
- `Preflight raw-output reference must stay under "${expectedPrefix}". Received: ${rawOutputRef}`
47
- );
48
- }
49
-
50
- return {
51
- checkName,
52
- summary,
53
- result,
54
- rawOutputRef: normalizedRef,
55
- };
56
- });
57
- }
58
-
59
- function resolvePreflightStatus(entries) {
60
- if (entries.some((entry) => entry.result === "fail")) {
61
- return "fail";
62
- }
63
- if (entries.some((entry) => entry.result === "partial")) {
64
- return "partial";
65
- }
66
- return "pass";
67
- }
68
-
69
- function validateShipState(state) {
70
- if (state.intakeOutcome === "BLOCKED_MISSING_INPUTS") {
71
- throw new ValidationError(
72
- 'Workflow artifact is blocked by missing upstream inputs. Re-run "sdtk-code start" after the handoff inputs are ready.'
73
- );
74
- }
75
-
76
- if (state.currentPhase === "verify") {
77
- if (state.phaseStatus !== "completed") {
78
- throw new ValidationError(
79
- 'Workflow must complete "verify" before "ship". Run "sdtk-code verify --complete" first.'
80
- );
81
- }
82
- return;
83
- }
84
-
85
- if (state.currentPhase !== "ship") {
86
- throw new ValidationError(
87
- `Cannot run "ship" from current phase "${state.currentPhase}". Re-run the next legal workflow step instead.`
88
- );
89
- }
90
- }
91
-
92
- function resolveShipPhaseStatus(flags, state, preflightStatus) {
93
- if (flags.blocked || preflightStatus === "fail") {
94
- return "blocked";
95
- }
96
- if (preflightStatus === "pass") {
97
- return "completed";
98
- }
99
- return "in_progress";
100
- }
101
-
102
- function getSuggestedEngineSkills(phaseStatus, decision) {
103
- if (phaseStatus === "completed") {
104
- return ["code-finish"];
105
- }
106
-
107
- const primary = decision === "finish" ? "code-finish" : "code-ship";
108
- if (phaseStatus === "blocked") {
109
- return ["code-debug", primary];
110
- }
111
- return [primary];
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
-
142
- function runShip(projectPath, featureKey, flags) {
143
- const state = loadWorkflowArtifactState(projectPath, featureKey);
144
- validateShipState(state);
145
-
146
- const decision = validateChoice(flags.decision, VALID_DECISIONS, "decision");
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);
152
- const preflightStatus = resolvePreflightStatus(preflightEntries);
153
- const phaseStatus = resolveShipPhaseStatus(flags, state, preflightStatus);
154
- const nextPhase = phaseStatus === "completed" ? "none" : "ship";
155
- const blockingState =
156
- phaseStatus === "blocked"
157
- ? "blocked_ship_issue"
158
- : phaseStatus === "completed"
159
- ? "clear"
160
- : "ship_preflight_in_progress";
161
- const suggestedEngineSkills = getSuggestedEngineSkills(phaseStatus, decision);
162
-
163
- const artifactPath = createOrUpdateWorkflowArtifact({
164
- projectPath,
165
- featureKey,
166
- lane: state.lane,
167
- currentPhase: "ship",
168
- phaseStatus,
169
- intakeOutcome: state.intakeOutcome,
170
- nextPhase,
171
- blockingState,
172
- suggestedEngineSkills,
173
- managedBlocks: ["METADATA", "SHIP", "STATUS"],
174
- shipDecision: decision,
175
- shipStatus: phaseStatus,
176
- preflightEntries,
177
- shipFollowUps,
178
- shipNotes,
179
- shipDebugNotes: normalizeEntries(flags["debug-note"]),
180
- });
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
-
198
- return {
199
- artifactPath,
200
- lane: state.lane,
201
- decision,
202
- phaseStatus,
203
- nextPhase,
204
- suggestedEngineSkills,
205
- preflightCount: preflightEntries.length,
206
- preflightStatus,
207
- opsHandoff: opsHandoffResult,
208
- };
209
- }
210
-
211
- module.exports = {
212
- runShip,
213
- };
1
+ "use strict";
2
+
3
+ const { ValidationError } = require("./errors");
4
+ const { createOrUpdateWorkflowArtifact, loadWorkflowArtifactState } = require("./workflow-artifact");
5
+ const { emitOpsHandoffForCompletedCloseout } = require("./workflow-handoff");
6
+
7
+ const VALID_DECISIONS = ["ship", "finish"];
8
+ const VALID_PREFLIGHT_RESULT = ["pass", "partial", "fail"];
9
+
10
+ function normalizeEntries(entries) {
11
+ return (entries || []).map((entry) => entry.trim()).filter(Boolean);
12
+ }
13
+
14
+ function validateChoice(value, choices, flagName) {
15
+ if (!choices.includes(value)) {
16
+ throw new ValidationError(
17
+ `Invalid value for --${flagName}: "${value}". Must be one of: ${choices.join(", ")}`
18
+ );
19
+ }
20
+ return value;
21
+ }
22
+
23
+ function parsePreflightEntries(entries, featureKey) {
24
+ const normalized = normalizeEntries(entries);
25
+ if (normalized.length === 0) {
26
+ throw new ValidationError(
27
+ 'Ship requires at least one "--preflight" entry in the format "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
28
+ );
29
+ }
30
+
31
+ const expectedPrefix = `docs/dev/evidence/${featureKey}/`;
32
+ return normalized.map((entry) => {
33
+ const parts = entry.split("|").map((part) => part.trim());
34
+ if (parts.length !== 4 || parts.some((part) => !part)) {
35
+ throw new ValidationError(
36
+ 'Each "--preflight" entry must use exactly four pipe-separated fields: "check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt".'
37
+ );
38
+ }
39
+
40
+ const [checkName, summary, result, rawOutputRef] = parts;
41
+ validateChoice(result, VALID_PREFLIGHT_RESULT, "preflight");
42
+
43
+ const normalizedRef = rawOutputRef.replace(/\\/g, "/");
44
+ if (!normalizedRef.startsWith(expectedPrefix)) {
45
+ throw new ValidationError(
46
+ `Preflight raw-output reference must stay under "${expectedPrefix}". Received: ${rawOutputRef}`
47
+ );
48
+ }
49
+
50
+ return {
51
+ checkName,
52
+ summary,
53
+ result,
54
+ rawOutputRef: normalizedRef,
55
+ };
56
+ });
57
+ }
58
+
59
+ function resolvePreflightStatus(entries) {
60
+ if (entries.some((entry) => entry.result === "fail")) {
61
+ return "fail";
62
+ }
63
+ if (entries.some((entry) => entry.result === "partial")) {
64
+ return "partial";
65
+ }
66
+ return "pass";
67
+ }
68
+
69
+ function validateShipState(state) {
70
+ if (state.intakeOutcome === "BLOCKED_MISSING_INPUTS") {
71
+ throw new ValidationError(
72
+ 'Workflow artifact is blocked by missing upstream inputs. Re-run "sdtk-code start" after the handoff inputs are ready.'
73
+ );
74
+ }
75
+
76
+ if (state.currentPhase === "verify") {
77
+ if (state.phaseStatus !== "completed") {
78
+ throw new ValidationError(
79
+ 'Workflow must complete "verify" before "ship". Run "sdtk-code verify --complete" first.'
80
+ );
81
+ }
82
+ return;
83
+ }
84
+
85
+ if (state.currentPhase !== "ship") {
86
+ throw new ValidationError(
87
+ `Cannot run "ship" from current phase "${state.currentPhase}". Re-run the next legal workflow step instead.`
88
+ );
89
+ }
90
+ }
91
+
92
+ function resolveShipPhaseStatus(flags, state, preflightStatus) {
93
+ if (flags.blocked || preflightStatus === "fail") {
94
+ return "blocked";
95
+ }
96
+ if (preflightStatus === "pass") {
97
+ return "completed";
98
+ }
99
+ return "in_progress";
100
+ }
101
+
102
+ function getSuggestedEngineSkills(phaseStatus, decision) {
103
+ if (phaseStatus === "completed") {
104
+ return ["code-finish"];
105
+ }
106
+
107
+ const primary = decision === "finish" ? "code-finish" : "code-ship";
108
+ if (phaseStatus === "blocked") {
109
+ return ["code-debug", primary];
110
+ }
111
+ return [primary];
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
+
142
+ function runShip(projectPath, featureKey, flags) {
143
+ const state = loadWorkflowArtifactState(projectPath, featureKey);
144
+ validateShipState(state);
145
+
146
+ const decision = validateChoice(flags.decision, VALID_DECISIONS, "decision");
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);
152
+ const preflightStatus = resolvePreflightStatus(preflightEntries);
153
+ const phaseStatus = resolveShipPhaseStatus(flags, state, preflightStatus);
154
+ const nextPhase = phaseStatus === "completed" ? "none" : "ship";
155
+ const blockingState =
156
+ phaseStatus === "blocked"
157
+ ? "blocked_ship_issue"
158
+ : phaseStatus === "completed"
159
+ ? "clear"
160
+ : "ship_preflight_in_progress";
161
+ const suggestedEngineSkills = getSuggestedEngineSkills(phaseStatus, decision);
162
+
163
+ const artifactPath = createOrUpdateWorkflowArtifact({
164
+ projectPath,
165
+ featureKey,
166
+ lane: state.lane,
167
+ currentPhase: "ship",
168
+ phaseStatus,
169
+ intakeOutcome: state.intakeOutcome,
170
+ nextPhase,
171
+ blockingState,
172
+ suggestedEngineSkills,
173
+ managedBlocks: ["METADATA", "SHIP", "STATUS"],
174
+ shipDecision: decision,
175
+ shipStatus: phaseStatus,
176
+ preflightEntries,
177
+ shipFollowUps,
178
+ shipNotes,
179
+ shipDebugNotes: normalizeEntries(flags["debug-note"]),
180
+ });
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
+
198
+ return {
199
+ artifactPath,
200
+ lane: state.lane,
201
+ decision,
202
+ phaseStatus,
203
+ nextPhase,
204
+ suggestedEngineSkills,
205
+ preflightCount: preflightEntries.length,
206
+ preflightStatus,
207
+ opsHandoff: opsHandoffResult,
208
+ };
209
+ }
210
+
211
+ module.exports = {
212
+ runShip,
213
+ };