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,123 +1,215 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { parseFlags, requireFlag } = require("../lib/args");
6
- const { ValidationError } = require("../lib/errors");
7
- const { DEFAULT_POLICY, loadPolicy, classifyCommand, policyFile } = require("../lib/trust-policy");
8
- const { appendEvent } = require("../lib/trust-events");
9
-
10
- const CHECK_FLAG_DEFS = {
11
- command: { type: "string" },
12
- "project-path": { type: "string" },
13
- "action-count": { type: "string" },
14
- };
15
-
16
- const INIT_FLAG_DEFS = {
17
- "project-path": { type: "string" },
18
- force: { type: "boolean" },
19
- };
20
-
21
- // allow/ask are advisory observations (info); deny is recorded as blocked.
22
- function statusForVerdict(verdict) {
23
- return verdict === "deny" ? "blocked" : "info";
24
- }
25
-
26
- function resolveProjectPath(flags) {
27
- return flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
28
- }
29
-
30
- function parseActionCount(raw) {
31
- if (raw === undefined || raw === null || raw === "") {
32
- return undefined;
33
- }
34
- const value = Number(raw);
35
- if (!Number.isInteger(value) || value < 0) {
36
- throw new ValidationError(
37
- `Invalid value for --action-count: "${raw}". Must be a non-negative integer.`
38
- );
39
- }
40
- return value;
41
- }
42
-
43
- function runCheck(args) {
44
- const { flags, positional } = parseFlags(args, CHECK_FLAG_DEFS);
45
- if (positional.length > 0) {
46
- throw new ValidationError('Unexpected positional arguments for "guardrails check".');
47
- }
48
-
49
- const command = requireFlag(flags, "command", "command");
50
- const projectPath = resolveProjectPath(flags);
51
- const actionCount = parseActionCount(flags["action-count"]);
52
-
53
- const policy = loadPolicy(projectPath);
54
- const result = classifyCommand(policy, command, { actionCount });
55
-
56
- // Record a redacted trust event (BK-239 buildEvent redacts the command).
57
- appendEvent(projectPath, {
58
- toolkit: "sdtk-code",
59
- event_type: "guardrail_check",
60
- command,
61
- status: statusForVerdict(result.verdict),
62
- });
63
-
64
- console.log("SDTK-CODE guardrails check");
65
- console.log(` Verdict: ${result.verdict}`);
66
- console.log(` Reason: ${result.reason}`);
67
- console.log(
68
- ` Matched: ${result.matchedRule ? `${result.matchedRule.bucket}:${result.matchedRule.pattern}` : "none"}`
69
- );
70
- // Advisory classifier: deny is reported in stdout, not enforced via exit code.
71
- return 0;
72
- }
73
-
74
- function runInit(args) {
75
- const { flags, positional } = parseFlags(args, INIT_FLAG_DEFS);
76
- if (positional.length > 0) {
77
- throw new ValidationError('Unexpected positional arguments for "guardrails init".');
78
- }
79
-
80
- const projectPath = resolveProjectPath(flags);
81
- const target = policyFile(projectPath);
82
-
83
- if (fs.existsSync(target) && !flags.force) {
84
- throw new ValidationError(
85
- [
86
- `Refusing to overwrite existing trust policy: ${target}`,
87
- "Re-run with --force to replace it with the default policy pack.",
88
- ].join("\n")
89
- );
90
- }
91
-
92
- fs.mkdirSync(path.dirname(target), { recursive: true });
93
- fs.writeFileSync(target, `${JSON.stringify(DEFAULT_POLICY, null, 2)}\n`, "utf8");
94
-
95
- console.log("SDTK-CODE guardrails init");
96
- console.log(` Policy: ${target}`);
97
- console.log(` Rules: deny=${DEFAULT_POLICY.deny.length}, ask=${DEFAULT_POLICY.ask.length}, allow=${DEFAULT_POLICY.allow.length}`);
98
- return 0;
99
- }
100
-
101
- function cmdGuardrails(args) {
102
- const list = Array.isArray(args) ? args : [];
103
- const subcommand = list[0];
104
- if (!subcommand || subcommand.startsWith("-")) {
105
- throw new ValidationError('Missing guardrails subcommand. Use one of: check, init.');
106
- }
107
-
108
- const rest = list.slice(1);
109
- switch (subcommand) {
110
- case "check":
111
- return runCheck(rest);
112
- case "init":
113
- return runInit(rest);
114
- default:
115
- throw new ValidationError(
116
- `Unknown guardrails subcommand: "${subcommand}". Use one of: check, init.`
117
- );
118
- }
119
- }
120
-
121
- module.exports = {
122
- cmdGuardrails,
123
- };
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { parseFlags, requireFlag } = require("../lib/args");
6
+ const { ValidationError } = require("../lib/errors");
7
+ const { DEFAULT_POLICY, loadPolicy, classifyCommand, policyFile } = require("../lib/trust-policy");
8
+ const { appendEvent } = require("../lib/trust-events");
9
+ const { loadScopes, getChangedFiles, checkFiles } = require("../lib/trust-file-scope");
10
+ const { writeTraceReport } = require("../lib/trust-trace");
11
+
12
+ const CHECK_FLAG_DEFS = {
13
+ command: { type: "string" },
14
+ "project-path": { type: "string" },
15
+ "action-count": { type: "string" },
16
+ };
17
+
18
+ const INIT_FLAG_DEFS = {
19
+ "project-path": { type: "string" },
20
+ force: { type: "boolean" },
21
+ };
22
+
23
+ const SCOPE_FLAG_DEFS = {
24
+ "feature-key": { type: "string" },
25
+ "project-path": { type: "string" },
26
+ base: { type: "string" },
27
+ changed: { type: "string", multiple: true },
28
+ };
29
+
30
+ const TRACE_FLAG_DEFS = {
31
+ "feature-key": { type: "string" },
32
+ "project-path": { type: "string" },
33
+ };
34
+
35
+ // allow/ask are advisory observations (info); deny is recorded as blocked.
36
+ function statusForVerdict(verdict) {
37
+ return verdict === "deny" ? "blocked" : "info";
38
+ }
39
+
40
+ function resolveProjectPath(flags) {
41
+ return flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
42
+ }
43
+
44
+ function parseActionCount(raw) {
45
+ if (raw === undefined || raw === null || raw === "") {
46
+ return undefined;
47
+ }
48
+ const value = Number(raw);
49
+ if (!Number.isInteger(value) || value < 0) {
50
+ throw new ValidationError(
51
+ `Invalid value for --action-count: "${raw}". Must be a non-negative integer.`
52
+ );
53
+ }
54
+ return value;
55
+ }
56
+
57
+ function runCheck(args) {
58
+ const { flags, positional } = parseFlags(args, CHECK_FLAG_DEFS);
59
+ if (positional.length > 0) {
60
+ throw new ValidationError('Unexpected positional arguments for "guardrails check".');
61
+ }
62
+
63
+ const command = requireFlag(flags, "command", "command");
64
+ const projectPath = resolveProjectPath(flags);
65
+ const actionCount = parseActionCount(flags["action-count"]);
66
+
67
+ const policy = loadPolicy(projectPath);
68
+ const result = classifyCommand(policy, command, { actionCount });
69
+
70
+ // Record a redacted trust event (BK-239 buildEvent redacts the command).
71
+ appendEvent(projectPath, {
72
+ toolkit: "sdtk-code",
73
+ event_type: "guardrail_check",
74
+ command,
75
+ status: statusForVerdict(result.verdict),
76
+ });
77
+
78
+ console.log("SDTK-CODE guardrails check");
79
+ console.log(` Verdict: ${result.verdict}`);
80
+ console.log(` Reason: ${result.reason}`);
81
+ console.log(
82
+ ` Matched: ${result.matchedRule ? `${result.matchedRule.bucket}:${result.matchedRule.pattern}` : "none"}`
83
+ );
84
+ // Advisory classifier: deny is reported in stdout, not enforced via exit code.
85
+ return 0;
86
+ }
87
+
88
+ function runInit(args) {
89
+ const { flags, positional } = parseFlags(args, INIT_FLAG_DEFS);
90
+ if (positional.length > 0) {
91
+ throw new ValidationError('Unexpected positional arguments for "guardrails init".');
92
+ }
93
+
94
+ const projectPath = resolveProjectPath(flags);
95
+ const target = policyFile(projectPath);
96
+
97
+ if (fs.existsSync(target) && !flags.force) {
98
+ throw new ValidationError(
99
+ [
100
+ `Refusing to overwrite existing trust policy: ${target}`,
101
+ "Re-run with --force to replace it with the default policy pack.",
102
+ ].join("\n")
103
+ );
104
+ }
105
+
106
+ fs.mkdirSync(path.dirname(target), { recursive: true });
107
+ fs.writeFileSync(target, `${JSON.stringify(DEFAULT_POLICY, null, 2)}\n`, "utf8");
108
+
109
+ console.log("SDTK-CODE guardrails init");
110
+ console.log(` Policy: ${target}`);
111
+ console.log(` Rules: deny=${DEFAULT_POLICY.deny.length}, ask=${DEFAULT_POLICY.ask.length}, allow=${DEFAULT_POLICY.allow.length}`);
112
+ return 0;
113
+ }
114
+
115
+ // file-scope verdict -> trust event status. fail is a blocking observation.
116
+ function statusForScope(verdict) {
117
+ return verdict === "fail" ? "blocked" : "info";
118
+ }
119
+
120
+ function runScope(args) {
121
+ const { flags, positional } = parseFlags(args, SCOPE_FLAG_DEFS);
122
+ if (positional.length > 0) {
123
+ throw new ValidationError('Unexpected positional arguments for "guardrails scope".');
124
+ }
125
+
126
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
127
+ const projectPath = resolveProjectPath(flags);
128
+ const scopes = loadScopes(projectPath, featureKey);
129
+
130
+ // Explicit --changed entries take precedence; otherwise diff against base via git.
131
+ let changed = Array.isArray(flags.changed) ? flags.changed.filter(Boolean) : [];
132
+ if (changed.length === 0) {
133
+ try {
134
+ changed = getChangedFiles(projectPath, flags.base || "HEAD");
135
+ } catch (error) {
136
+ throw new ValidationError(
137
+ `Could not determine changed files (git): ${error.message}. ` +
138
+ "Run inside a git repo, or pass --changed <file> entries explicitly."
139
+ );
140
+ }
141
+ }
142
+
143
+ const result = checkFiles(scopes, changed);
144
+
145
+ appendEvent(projectPath, {
146
+ toolkit: "sdtk-code",
147
+ event_type: "file_scope_check",
148
+ phase: "verify",
149
+ status: statusForScope(result.verdict),
150
+ files: result.outOfScope.concat(result.blockedHits),
151
+ });
152
+
153
+ console.log("SDTK-CODE guardrails scope");
154
+ console.log(` Feature key: ${featureKey}`);
155
+ console.log(` Scope source: ${scopes.source}${scopes.declared ? "" : " (no scope declared)"}`);
156
+ console.log(` Verdict: ${result.verdict}`);
157
+ console.log(` In scope: ${result.inScope.length}`);
158
+ if (result.outOfScope.length > 0) {
159
+ console.log(` Out of scope: ${result.outOfScope.join(", ")}`);
160
+ }
161
+ if (result.blockedHits.length > 0) {
162
+ console.log(` Blocked: ${result.blockedHits.join(", ")}`);
163
+ }
164
+ // Advisory gate: verdict is reported in stdout, not enforced via exit code.
165
+ return 0;
166
+ }
167
+
168
+ function runTrace(args) {
169
+ const { flags, positional } = parseFlags(args, TRACE_FLAG_DEFS);
170
+ if (positional.length > 0) {
171
+ throw new ValidationError('Unexpected positional arguments for "guardrails trace".');
172
+ }
173
+
174
+ const featureKey = requireFlag(flags, "feature-key", "feature-key");
175
+ const projectPath = resolveProjectPath(flags);
176
+ const result = writeTraceReport(projectPath, featureKey);
177
+ const totals = result.trace.totals;
178
+
179
+ console.log("SDTK-CODE guardrails trace");
180
+ console.log(` Feature key: ${featureKey}`);
181
+ console.log(` Report: ${result.path}`);
182
+ console.log(` Events: ${totals.events}`);
183
+ console.log(` Failures: ${totals.failures}`);
184
+ console.log(` Blocked: ${totals.blocked}`);
185
+ console.log(` Decision gates: ${totals.decisionGates}`);
186
+ return 0;
187
+ }
188
+
189
+ function cmdGuardrails(args) {
190
+ const list = Array.isArray(args) ? args : [];
191
+ const subcommand = list[0];
192
+ if (!subcommand || subcommand.startsWith("-")) {
193
+ throw new ValidationError('Missing guardrails subcommand. Use one of: check, init, scope, trace.');
194
+ }
195
+
196
+ const rest = list.slice(1);
197
+ switch (subcommand) {
198
+ case "check":
199
+ return runCheck(rest);
200
+ case "init":
201
+ return runInit(rest);
202
+ case "scope":
203
+ return runScope(rest);
204
+ case "trace":
205
+ return runTrace(rest);
206
+ default:
207
+ throw new ValidationError(
208
+ `Unknown guardrails subcommand: "${subcommand}". Use one of: check, init, scope, trace.`
209
+ );
210
+ }
211
+ }
212
+
213
+ module.exports = {
214
+ cmdGuardrails,
215
+ };