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
@@ -1,127 +1,127 @@
1
- "use strict";
2
-
3
- const { ValidationError } = require("./errors");
4
- const { createOrUpdateWorkflowArtifact, loadWorkflowArtifactState } = require("./workflow-artifact");
5
-
6
- function normalizeEntries(entries) {
7
- return (entries || []).map((entry) => entry.trim()).filter(Boolean);
8
- }
9
-
10
- function resolveBuildStatus(flags, state) {
11
- if (flags.complete && flags.blocked) {
12
- throw new ValidationError('Use either "--complete" or "--blocked", not both.');
13
- }
14
- if (flags.complete) {
15
- return "completed";
16
- }
17
- if (flags.blocked) {
18
- return "blocked";
19
- }
20
- if (state.currentPhase === "build" && state.phaseStatus === "completed") {
21
- return state.phaseStatus;
22
- }
23
- return "in_progress";
24
- }
25
-
26
- function getSuggestedEngineSkills(lane, flags, phaseStatus) {
27
- if (lane === "bugfix") {
28
- const skills = ["code-debug (if failure reproduction is needed)", "code-tdd", "code-execute"];
29
- if (phaseStatus === "blocked" && !skills.includes("code-debug")) {
30
- skills.unshift("code-debug");
31
- }
32
- return skills;
33
- }
34
-
35
- const skills = ["code-worktree", "code-tdd", "code-execute"];
36
- if (flags["parallel-reason"]) {
37
- skills.push("code-parallel");
38
- }
39
- if (phaseStatus === "blocked") {
40
- skills.push("code-debug");
41
- }
42
- return skills;
43
- }
44
-
45
- function validateBuildState(state) {
46
- if (state.intakeOutcome === "BLOCKED_MISSING_INPUTS") {
47
- throw new ValidationError(
48
- "Workflow artifact is blocked by missing upstream inputs. Re-run \"sdtk-code start\" after the handoff inputs are ready."
49
- );
50
- }
51
-
52
- if (state.lane === "feature") {
53
- if (state.currentPhase === "start") {
54
- throw new ValidationError(
55
- 'Feature-lane workflow must complete "plan" before "build". Run "sdtk-code plan" first.'
56
- );
57
- }
58
- if (state.currentPhase !== "plan" && state.currentPhase !== "build") {
59
- throw new ValidationError(
60
- `Cannot run "build" from current phase "${state.currentPhase}". Re-run the next legal workflow step instead.`
61
- );
62
- }
63
- if (state.intakeOutcome !== "READY_FOR_PLAN") {
64
- throw new ValidationError(
65
- `Feature-lane workflow is not ready for "build". Current intake outcome: ${state.intakeOutcome}.`
66
- );
67
- }
68
- return;
69
- }
70
-
71
- if (state.currentPhase !== "start" && state.currentPhase !== "plan" && state.currentPhase !== "build") {
72
- throw new ValidationError(
73
- `Cannot run "build" from current phase "${state.currentPhase}". Re-run the next legal workflow step instead.`
74
- );
75
- }
76
-
77
- if (state.intakeOutcome !== "READY_FOR_BUILD_BUGFIX") {
78
- throw new ValidationError(
79
- `Bugfix-lane workflow is not ready for "build". Current intake outcome: ${state.intakeOutcome}.`
80
- );
81
- }
82
- }
83
-
84
- function runBuild(projectPath, featureKey, flags) {
85
- const state = loadWorkflowArtifactState(projectPath, featureKey);
86
- validateBuildState(state);
87
-
88
- if (state.lane === "bugfix" && flags["parallel-reason"]) {
89
- throw new ValidationError('Bugfix-lane build does not support "--parallel-reason" in v1.');
90
- }
91
-
92
- const phaseStatus = resolveBuildStatus(flags, state);
93
- const suggestedEngineSkills = getSuggestedEngineSkills(state.lane, flags, phaseStatus);
94
- const nextPhase = phaseStatus === "completed" ? "verify" : "build";
95
- const blockingState = phaseStatus === "blocked" ? "blocked_build_issue" : "clear";
96
-
97
- const artifactPath = createOrUpdateWorkflowArtifact({
98
- projectPath,
99
- featureKey,
100
- lane: state.lane,
101
- currentPhase: "build",
102
- phaseStatus,
103
- intakeOutcome: state.intakeOutcome,
104
- nextPhase,
105
- blockingState,
106
- suggestedEngineSkills,
107
- managedBlocks: ["METADATA", "BUILD", "STATUS"],
108
- activeSlices: normalizeEntries(flags["active-slice"]),
109
- buildNotes: normalizeEntries(flags.note),
110
- debugNotes: normalizeEntries(flags["debug-note"]),
111
- parallelReason: flags["parallel-reason"] || null,
112
- });
113
-
114
- return {
115
- artifactPath,
116
- lane: state.lane,
117
- phaseStatus,
118
- nextPhase,
119
- suggestedEngineSkills,
120
- executionMode: flags["parallel-reason"] ? "parallel" : "sequential",
121
- activeSliceCount: normalizeEntries(flags["active-slice"]).length,
122
- };
123
- }
124
-
125
- module.exports = {
126
- runBuild,
127
- };
1
+ "use strict";
2
+
3
+ const { ValidationError } = require("./errors");
4
+ const { createOrUpdateWorkflowArtifact, loadWorkflowArtifactState } = require("./workflow-artifact");
5
+
6
+ function normalizeEntries(entries) {
7
+ return (entries || []).map((entry) => entry.trim()).filter(Boolean);
8
+ }
9
+
10
+ function resolveBuildStatus(flags, state) {
11
+ if (flags.complete && flags.blocked) {
12
+ throw new ValidationError('Use either "--complete" or "--blocked", not both.');
13
+ }
14
+ if (flags.complete) {
15
+ return "completed";
16
+ }
17
+ if (flags.blocked) {
18
+ return "blocked";
19
+ }
20
+ if (state.currentPhase === "build" && state.phaseStatus === "completed") {
21
+ return state.phaseStatus;
22
+ }
23
+ return "in_progress";
24
+ }
25
+
26
+ function getSuggestedEngineSkills(lane, flags, phaseStatus) {
27
+ if (lane === "bugfix") {
28
+ const skills = ["code-debug (if failure reproduction is needed)", "code-tdd", "code-execute"];
29
+ if (phaseStatus === "blocked" && !skills.includes("code-debug")) {
30
+ skills.unshift("code-debug");
31
+ }
32
+ return skills;
33
+ }
34
+
35
+ const skills = ["code-worktree", "code-tdd", "code-execute"];
36
+ if (flags["parallel-reason"]) {
37
+ skills.push("code-parallel");
38
+ }
39
+ if (phaseStatus === "blocked") {
40
+ skills.push("code-debug");
41
+ }
42
+ return skills;
43
+ }
44
+
45
+ function validateBuildState(state) {
46
+ if (state.intakeOutcome === "BLOCKED_MISSING_INPUTS") {
47
+ throw new ValidationError(
48
+ "Workflow artifact is blocked by missing upstream inputs. Re-run \"sdtk-code start\" after the handoff inputs are ready."
49
+ );
50
+ }
51
+
52
+ if (state.lane === "feature") {
53
+ if (state.currentPhase === "start") {
54
+ throw new ValidationError(
55
+ 'Feature-lane workflow must complete "plan" before "build". Run "sdtk-code plan" first.'
56
+ );
57
+ }
58
+ if (state.currentPhase !== "plan" && state.currentPhase !== "build") {
59
+ throw new ValidationError(
60
+ `Cannot run "build" from current phase "${state.currentPhase}". Re-run the next legal workflow step instead.`
61
+ );
62
+ }
63
+ if (state.intakeOutcome !== "READY_FOR_PLAN") {
64
+ throw new ValidationError(
65
+ `Feature-lane workflow is not ready for "build". Current intake outcome: ${state.intakeOutcome}.`
66
+ );
67
+ }
68
+ return;
69
+ }
70
+
71
+ if (state.currentPhase !== "start" && state.currentPhase !== "plan" && state.currentPhase !== "build") {
72
+ throw new ValidationError(
73
+ `Cannot run "build" from current phase "${state.currentPhase}". Re-run the next legal workflow step instead.`
74
+ );
75
+ }
76
+
77
+ if (state.intakeOutcome !== "READY_FOR_BUILD_BUGFIX") {
78
+ throw new ValidationError(
79
+ `Bugfix-lane workflow is not ready for "build". Current intake outcome: ${state.intakeOutcome}.`
80
+ );
81
+ }
82
+ }
83
+
84
+ function runBuild(projectPath, featureKey, flags) {
85
+ const state = loadWorkflowArtifactState(projectPath, featureKey);
86
+ validateBuildState(state);
87
+
88
+ if (state.lane === "bugfix" && flags["parallel-reason"]) {
89
+ throw new ValidationError('Bugfix-lane build does not support "--parallel-reason" in v1.');
90
+ }
91
+
92
+ const phaseStatus = resolveBuildStatus(flags, state);
93
+ const suggestedEngineSkills = getSuggestedEngineSkills(state.lane, flags, phaseStatus);
94
+ const nextPhase = phaseStatus === "completed" ? "verify" : "build";
95
+ const blockingState = phaseStatus === "blocked" ? "blocked_build_issue" : "clear";
96
+
97
+ const artifactPath = createOrUpdateWorkflowArtifact({
98
+ projectPath,
99
+ featureKey,
100
+ lane: state.lane,
101
+ currentPhase: "build",
102
+ phaseStatus,
103
+ intakeOutcome: state.intakeOutcome,
104
+ nextPhase,
105
+ blockingState,
106
+ suggestedEngineSkills,
107
+ managedBlocks: ["METADATA", "BUILD", "STATUS"],
108
+ activeSlices: normalizeEntries(flags["active-slice"]),
109
+ buildNotes: normalizeEntries(flags.note),
110
+ debugNotes: normalizeEntries(flags["debug-note"]),
111
+ parallelReason: flags["parallel-reason"] || null,
112
+ });
113
+
114
+ return {
115
+ artifactPath,
116
+ lane: state.lane,
117
+ phaseStatus,
118
+ nextPhase,
119
+ suggestedEngineSkills,
120
+ executionMode: flags["parallel-reason"] ? "parallel" : "sequential",
121
+ activeSliceCount: normalizeEntries(flags["active-slice"]).length,
122
+ };
123
+ }
124
+
125
+ module.exports = {
126
+ runBuild,
127
+ };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ const { loadWorkflowState } = require("./workflow-state");
4
+
5
+ function pushIfMissing(issues, value, message) {
6
+ if (!value) {
7
+ issues.push(message);
8
+ }
9
+ }
10
+
11
+ function runWorkflowDoctor(projectPath, featureKey) {
12
+ const state = loadWorkflowState(projectPath, featureKey);
13
+ const issues = [];
14
+
15
+ if (!state.exists) {
16
+ issues.push("Workflow artifact is missing. Run start before workflow recovery commands.");
17
+ } else {
18
+ pushIfMissing(issues, state.blocks.METADATA, "Workflow artifact is missing required managed block METADATA.");
19
+ pushIfMissing(issues, state.blocks.STATUS, "Workflow artifact is missing required managed block STATUS.");
20
+
21
+ if (state.currentPhase === "verify" || state.currentPhase === "ship" || state.nextPhase === "ship") {
22
+ pushIfMissing(
23
+ issues,
24
+ state.blocks.VERIFY,
25
+ "Workflow state requires VERIFY surface, but the VERIFY managed block is missing."
26
+ );
27
+ }
28
+
29
+ if (state.currentPhase === "ship") {
30
+ pushIfMissing(
31
+ issues,
32
+ state.blocks.SHIP,
33
+ "Workflow state requires SHIP surface, but the SHIP managed block is missing."
34
+ );
35
+ }
36
+
37
+ if (state.blocks.METADATA) {
38
+ if (!state.lane || state.lane === "unknown") {
39
+ issues.push("METADATA lane is missing or unreadable.");
40
+ }
41
+ if (!state.currentPhase || state.currentPhase === "unknown") {
42
+ issues.push("METADATA current phase is missing or unreadable.");
43
+ }
44
+ if (!state.phaseStatus || state.phaseStatus === "unknown") {
45
+ issues.push("METADATA phase status is missing or unreadable.");
46
+ }
47
+ if (!state.intakeOutcome || state.intakeOutcome === "unknown") {
48
+ issues.push("METADATA intake outcome is missing or unreadable.");
49
+ }
50
+ }
51
+
52
+ if (state.blocks.STATUS) {
53
+ if (!state.nextPhase || state.nextPhase === "unknown") {
54
+ issues.push("STATUS next recommended phase is missing or unreadable.");
55
+ }
56
+ if (!state.blockingState || state.blockingState === "unknown") {
57
+ issues.push("STATUS blocking state is missing or unreadable.");
58
+ }
59
+ }
60
+
61
+ if (
62
+ state.currentPhase === "verify" &&
63
+ state.phaseStatus === "completed" &&
64
+ Array.isArray(state.evidenceEntries) &&
65
+ state.evidenceEntries.length === 0
66
+ ) {
67
+ issues.push("Workflow claims verify completed, but no evidence entries are recorded in VERIFY.");
68
+ }
69
+
70
+ issues.push(...state.contradictions);
71
+ }
72
+
73
+ const uniqueIssues = [...new Set(issues)];
74
+ return {
75
+ state,
76
+ issues: uniqueIssues,
77
+ healthy: uniqueIssues.length === 0,
78
+ result: uniqueIssues.length === 0 ? "healthy" : "invalid",
79
+ };
80
+ }
81
+
82
+ module.exports = {
83
+ runWorkflowDoctor,
84
+ };