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.
Files changed (38) hide show
  1. package/README.md +138 -130
  2. package/assets/manifest/toolkit-bundle.manifest.json +47 -47
  3. package/assets/manifest/toolkit-bundle.sha256.txt +23 -23
  4. package/assets/toolkit/toolkit/AGENTS.md +8 -1
  5. package/assets/toolkit/toolkit/install.ps1 +1 -8
  6. package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +30 -7
  7. package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +31 -2
  8. package/assets/toolkit/toolkit/sdtk-spec.config.json +1 -1
  9. package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +0 -1
  10. package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +1 -2
  11. package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +0 -1
  12. package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +0 -1
  13. package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +0 -1
  14. package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +0 -1
  15. package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +0 -1
  16. package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +0 -1
  17. package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +0 -1
  18. package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +0 -1
  19. package/assets/toolkit/toolkit/skills/code-review/SKILL.md +0 -1
  20. package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +0 -1
  21. package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +0 -1
  22. package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +0 -1
  23. package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +1 -2
  24. package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +0 -1
  25. package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +0 -1
  26. package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +13 -14
  27. package/package.json +1 -1
  28. package/src/commands/help.js +163 -145
  29. package/src/commands/init.js +10 -1
  30. package/src/commands/plan.js +1 -0
  31. package/src/commands/runtime.js +27 -8
  32. package/src/commands/ship.js +5 -0
  33. package/src/lib/scope.js +19 -2
  34. package/src/lib/workflow-artifact.js +51 -14
  35. package/src/lib/workflow-handoff.js +510 -0
  36. package/src/lib/workflow-intake.js +2 -1
  37. package/src/lib/workflow-plan.js +102 -5
  38. package/src/lib/workflow-ship.js +53 -3
@@ -1,12 +1,66 @@
1
1
  "use strict";
2
2
 
3
3
  const { ValidationError } = require("./errors");
4
- const { createOrUpdateWorkflowArtifact, loadWorkflowArtifactState } = require("./workflow-artifact");
4
+ const {
5
+ createOrUpdateWorkflowArtifact,
6
+ extractManagedBlock,
7
+ loadWorkflowArtifactState,
8
+ } = require("./workflow-artifact");
5
9
 
6
10
  function normalizeEntries(entries) {
7
11
  return (entries || []).map((entry) => entry.trim()).filter(Boolean);
8
12
  }
9
13
 
14
+ function uniqueEntries(entries) {
15
+ const seen = new Set();
16
+ const results = [];
17
+ for (const entry of entries) {
18
+ if (!entry || seen.has(entry)) {
19
+ continue;
20
+ }
21
+ seen.add(entry);
22
+ results.push(entry);
23
+ }
24
+ return results;
25
+ }
26
+
27
+ function escapeRegExp(value) {
28
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
29
+ }
30
+
31
+ function parseBulletSection(planBlock, heading) {
32
+ if (!planBlock) {
33
+ return [];
34
+ }
35
+
36
+ const regex = new RegExp(`### ${escapeRegExp(heading)}\\r?\\n([\\s\\S]*?)(?=\\r?\\n### |$)`);
37
+ const match = planBlock.match(regex);
38
+ if (!match) {
39
+ return [];
40
+ }
41
+
42
+ return match[1]
43
+ .split(/\r?\n/)
44
+ .map((line) => line.trim())
45
+ .filter((line) => line.startsWith("- "))
46
+ .map((line) => line.slice(2).trim())
47
+ .filter(Boolean);
48
+ }
49
+
50
+ function getSeededPlanContext(state) {
51
+ const planBlock = extractManagedBlock(state.text, "PLAN");
52
+ const candidateSlices = parseBulletSection(planBlock, "Seeded Candidate Slices From Formal Handoff")
53
+ .filter((entry) => entry !== "No candidate slices seeded from the formal handoff.");
54
+ const candidatePlanningNotes = parseBulletSection(planBlock, "Planning Notes").filter(
55
+ (entry) => entry !== "No additional planning notes recorded."
56
+ );
57
+
58
+ return {
59
+ candidateSlices,
60
+ candidatePlanningNotes,
61
+ };
62
+ }
63
+
10
64
  function getBuildEngineSkills(lane) {
11
65
  if (lane === "bugfix") {
12
66
  return ["code-debug (if failure reproduction is needed)", "code-tdd", "code-execute"];
@@ -40,7 +94,9 @@ function validatePlanState(state) {
40
94
  }
41
95
  }
42
96
 
43
- function buildPlanPayload(flags, lane) {
97
+ function buildPlanPayload(flags, state) {
98
+ const lane = state.lane;
99
+ const useSeededCandidates = Boolean(flags["use-seeded-candidates"]);
44
100
  const payload = {
45
101
  inScope: normalizeEntries(flags["in-scope"]),
46
102
  outScope: normalizeEntries(flags["out-scope"]),
@@ -51,8 +107,49 @@ function buildPlanPayload(flags, lane) {
51
107
  planningMode: lane === "bugfix" ? "bugfix-light" : "feature-standard",
52
108
  };
53
109
 
54
- if (lane === "feature" && payload.slices.length === 0) {
55
- throw new ValidationError('Feature-lane planning requires at least one "--slice" entry.');
110
+ if (lane !== "feature" && useSeededCandidates) {
111
+ throw new ValidationError('"--use-seeded-candidates" is only valid for feature-lane planning.');
112
+ }
113
+
114
+ if (lane === "feature") {
115
+ const seededContext = getSeededPlanContext(state);
116
+
117
+ if (useSeededCandidates && state.currentPhase !== "start") {
118
+ throw new ValidationError(
119
+ '"--use-seeded-candidates" can only be used while confirming seeded handoff slices from the "start" phase.'
120
+ );
121
+ }
122
+
123
+ if (useSeededCandidates && payload.slices.length > 0) {
124
+ throw new ValidationError(
125
+ 'Feature-lane planning must choose exactly one slice-confirmation path: explicit "--slice" entries or "--use-seeded-candidates".'
126
+ );
127
+ }
128
+
129
+ if (useSeededCandidates) {
130
+ if (seededContext.candidateSlices.length === 0) {
131
+ throw new ValidationError(
132
+ 'No seeded candidate slices are available in the workflow artifact. Re-run "sdtk-code start" from a formal SDTK-SPEC handoff or use explicit "--slice" entries.'
133
+ );
134
+ }
135
+
136
+ payload.slices = seededContext.candidateSlices;
137
+ payload.planNotes = uniqueEntries([
138
+ "Confirmed seeded candidate slices from the formal SDTK-SPEC handoff via `--use-seeded-candidates`.",
139
+ ...payload.planNotes,
140
+ ...seededContext.candidatePlanningNotes,
141
+ ]);
142
+ payload.planningMode = "feature-seeded-confirmed";
143
+ }
144
+
145
+ if (payload.slices.length === 0) {
146
+ if (seededContext.candidateSlices.length > 0) {
147
+ throw new ValidationError(
148
+ 'Feature-lane planning requires explicit "--slice" entries or "--use-seeded-candidates" to confirm the seeded handoff slice set.'
149
+ );
150
+ }
151
+ throw new ValidationError('Feature-lane planning requires at least one "--slice" entry.');
152
+ }
56
153
  }
57
154
 
58
155
  if (lane === "bugfix" && payload.slices.length === 0) {
@@ -66,7 +163,7 @@ function runPlan(projectPath, featureKey, flags) {
66
163
  const state = loadWorkflowArtifactState(projectPath, featureKey);
67
164
  validatePlanState(state);
68
165
 
69
- const planPayload = buildPlanPayload(flags, state.lane);
166
+ const planPayload = buildPlanPayload(flags, state);
70
167
  const artifactPath = createOrUpdateWorkflowArtifact({
71
168
  projectPath,
72
169
  featureKey,
@@ -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: normalizeEntries(flags["follow-up"]),
145
- shipNotes: normalizeEntries(flags.note),
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