sdtk-code-kit 0.3.0 → 0.3.2

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 (58) hide show
  1. package/README.md +204 -204
  2. package/assets/manifest/toolkit-bundle.manifest.json +147 -147
  3. package/assets/manifest/toolkit-bundle.sha256.txt +5 -5
  4. package/bin/sdtk-code.js +14 -14
  5. package/package.json +44 -44
  6. package/src/commands/agent-team.js +479 -174
  7. package/src/commands/build.js +53 -53
  8. package/src/commands/doctor.js +51 -51
  9. package/src/commands/generate.js +11 -11
  10. package/src/commands/guardrails.js +215 -215
  11. package/src/commands/help.js +266 -257
  12. package/src/commands/init.js +98 -98
  13. package/src/commands/plan.js +53 -53
  14. package/src/commands/readiness.js +77 -77
  15. package/src/commands/resume.js +61 -61
  16. package/src/commands/runtime.js +224 -224
  17. package/src/commands/ship.js +59 -59
  18. package/src/commands/sleep.js +132 -132
  19. package/src/commands/start.js +89 -89
  20. package/src/commands/status.js +77 -77
  21. package/src/commands/update.js +11 -11
  22. package/src/commands/verify.js +71 -71
  23. package/src/index.js +112 -112
  24. package/src/lib/agent-team-author.js +552 -0
  25. package/src/lib/agent-team-evidence.js +302 -0
  26. package/src/lib/agent-team-execute.js +892 -0
  27. package/src/lib/agent-team-export.js +411 -409
  28. package/src/lib/agent-team-plan.js +514 -514
  29. package/src/lib/agent-team-readiness.js +161 -0
  30. package/src/lib/agent-team-report.js +165 -0
  31. package/src/lib/agent-team-sleep-execute.js +524 -0
  32. package/src/lib/agent-team-sleep-session.js +278 -0
  33. package/src/lib/args.js +107 -107
  34. package/src/lib/errors.js +41 -41
  35. package/src/lib/model-provider.js +219 -0
  36. package/src/lib/powershell.js +65 -65
  37. package/src/lib/project-target-guard.js +53 -53
  38. package/src/lib/scope.js +72 -72
  39. package/src/lib/ship-readiness.js +281 -281
  40. package/src/lib/sleep-plan.js +175 -175
  41. package/src/lib/sleep-report.js +229 -229
  42. package/src/lib/toolkit-payload.js +72 -72
  43. package/src/lib/trust-events.js +264 -185
  44. package/src/lib/trust-file-scope.js +154 -154
  45. package/src/lib/trust-policy.js +212 -212
  46. package/src/lib/trust-redact.js +58 -35
  47. package/src/lib/trust-trace.js +179 -179
  48. package/src/lib/update.js +344 -344
  49. package/src/lib/workflow-artifact.js +503 -503
  50. package/src/lib/workflow-build.js +127 -127
  51. package/src/lib/workflow-doctor.js +83 -83
  52. package/src/lib/workflow-handoff.js +1029 -1029
  53. package/src/lib/workflow-intake.js +101 -101
  54. package/src/lib/workflow-plan.js +193 -193
  55. package/src/lib/workflow-review-packet.js +650 -650
  56. package/src/lib/workflow-ship.js +213 -213
  57. package/src/lib/workflow-state.js +438 -438
  58. 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
+ };