sdtk-code-kit 0.2.0 → 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.
Files changed (75) hide show
  1. package/README.md +201 -201
  2. package/assets/manifest/toolkit-bundle.manifest.json +147 -147
  3. package/assets/manifest/toolkit-bundle.sha256.txt +28 -28
  4. package/assets/toolkit/toolkit/AGENTS.md +219 -219
  5. package/assets/toolkit/toolkit/install.ps1 +156 -156
  6. package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +78 -78
  7. package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +150 -150
  8. package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +62 -62
  9. package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +82 -82
  10. package/assets/toolkit/toolkit/sdtk-spec.config.json +6 -6
  11. package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +12 -12
  12. package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +55 -55
  13. package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +296 -296
  14. package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +68 -68
  15. package/assets/toolkit/toolkit/skills/code-discover/SKILL.md +54 -54
  16. package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +74 -74
  17. package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +205 -205
  18. package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +64 -64
  19. package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +26 -26
  20. package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +113 -113
  21. package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +61 -61
  22. package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +85 -85
  23. package/assets/toolkit/toolkit/skills/code-review/SKILL.md +79 -79
  24. package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +125 -125
  25. package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +146 -146
  26. package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +52 -52
  27. package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +378 -378
  28. package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +299 -299
  29. package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +144 -144
  30. package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +228 -228
  31. package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +140 -140
  32. package/bin/sdtk-code.js +14 -14
  33. package/package.json +44 -44
  34. package/src/commands/build.js +53 -53
  35. package/src/commands/doctor.js +51 -51
  36. package/src/commands/generate.js +11 -11
  37. package/src/commands/guardrails.js +215 -123
  38. package/src/commands/help.js +244 -244
  39. package/src/commands/init.js +98 -98
  40. package/src/commands/plan.js +53 -53
  41. package/src/commands/readiness.js +77 -77
  42. package/src/commands/resume.js +61 -61
  43. package/src/commands/runtime.js +224 -224
  44. package/src/commands/ship.js +59 -59
  45. package/src/commands/sleep.js +132 -0
  46. package/src/commands/start.js +89 -89
  47. package/src/commands/status.js +77 -77
  48. package/src/commands/update.js +11 -11
  49. package/src/commands/verify.js +71 -71
  50. package/src/index.js +108 -104
  51. package/src/lib/args.js +107 -107
  52. package/src/lib/errors.js +41 -41
  53. package/src/lib/powershell.js +65 -65
  54. package/src/lib/project-target-guard.js +53 -53
  55. package/src/lib/scope.js +72 -72
  56. package/src/lib/ship-readiness.js +281 -281
  57. package/src/lib/sleep-plan.js +175 -0
  58. package/src/lib/sleep-report.js +229 -0
  59. package/src/lib/toolkit-payload.js +72 -72
  60. package/src/lib/trust-events.js +166 -166
  61. package/src/lib/trust-file-scope.js +154 -154
  62. package/src/lib/trust-policy.js +212 -212
  63. package/src/lib/trust-redact.js +35 -35
  64. package/src/lib/trust-trace.js +179 -179
  65. package/src/lib/update.js +344 -344
  66. package/src/lib/workflow-artifact.js +503 -503
  67. package/src/lib/workflow-build.js +127 -127
  68. package/src/lib/workflow-doctor.js +83 -83
  69. package/src/lib/workflow-handoff.js +1029 -1029
  70. package/src/lib/workflow-intake.js +101 -101
  71. package/src/lib/workflow-plan.js +193 -193
  72. package/src/lib/workflow-review-packet.js +650 -650
  73. package/src/lib/workflow-ship.js +213 -213
  74. package/src/lib/workflow-state.js +438 -438
  75. package/src/lib/workflow-verify.js +393 -393
@@ -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
+ };