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,212 +1,212 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { ValidationError } = require("./errors");
6
-
7
- // Default allow/ask/deny pack (BK-240 §5), derived from the reference harness
8
- // settings.json command classes. Patterns starting with "^" are treated as
9
- // anchored regular expressions; all other patterns are case-sensitive
10
- // substring matches against the command string. NO shell execution: this is
11
- // advisory classification only.
12
- const DEFAULT_POLICY = {
13
- deny: [
14
- "^rm -rf",
15
- "^rm -fr",
16
- "^sudo ",
17
- "git reset --hard",
18
- "git push --force",
19
- "git push -f",
20
- "mkfs",
21
- "^dd ",
22
- ".env",
23
- ".pem",
24
- "secrets/",
25
- "^psql",
26
- "^mysql",
27
- "^mongod",
28
- ],
29
- ask: [
30
- "npm install",
31
- "npm publish",
32
- "npm exec",
33
- "npx",
34
- "git merge",
35
- "git rebase",
36
- "git clean -fd",
37
- "git clean -fx",
38
- "git clean -fdx",
39
- ],
40
- allow: [
41
- "git status",
42
- "git diff",
43
- "git log",
44
- "git branch",
45
- "git show",
46
- "npm test",
47
- "npm run test",
48
- "npm run lint",
49
- "npm run build",
50
- "pytest",
51
- "python -m unittest",
52
- "rg ",
53
- "ls ",
54
- "node --check",
55
- ],
56
- // limits.max_actions is omitted by default; callers may add it (and supply
57
- // --action-count) to enable the action-count cap.
58
- limits: {},
59
- };
60
-
61
- function assertPatternArray(value, label) {
62
- if (!Array.isArray(value)) {
63
- throw new ValidationError(
64
- `Invalid trust policy: "${label}" must be an array of string patterns.`
65
- );
66
- }
67
- value.forEach((entry, index) => {
68
- if (typeof entry !== "string") {
69
- throw new ValidationError(
70
- `Invalid trust policy: "${label}[${index}]" must be a string pattern.`
71
- );
72
- }
73
- });
74
- }
75
-
76
- function validatePolicy(obj) {
77
- if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
78
- throw new ValidationError("Invalid trust policy: expected a JSON object.");
79
- }
80
- assertPatternArray(obj.deny, "deny");
81
- assertPatternArray(obj.ask, "ask");
82
- assertPatternArray(obj.allow, "allow");
83
-
84
- if (obj.limits !== undefined && obj.limits !== null) {
85
- if (typeof obj.limits !== "object" || Array.isArray(obj.limits)) {
86
- throw new ValidationError('Invalid trust policy: "limits" must be an object.');
87
- }
88
- if (
89
- obj.limits.max_actions !== undefined &&
90
- typeof obj.limits.max_actions !== "number"
91
- ) {
92
- throw new ValidationError(
93
- 'Invalid trust policy: "limits.max_actions" must be a number.'
94
- );
95
- }
96
- }
97
- return obj;
98
- }
99
-
100
- function policyFile(projectPath) {
101
- return path.join(path.resolve(projectPath || "."), ".sdtk", "trust", "policy.json");
102
- }
103
-
104
- function loadPolicy(projectPath) {
105
- const file = policyFile(projectPath);
106
- if (!fs.existsSync(file)) {
107
- return DEFAULT_POLICY;
108
- }
109
- let parsed;
110
- try {
111
- parsed = JSON.parse(fs.readFileSync(file, "utf8"));
112
- } catch (error) {
113
- throw new ValidationError(
114
- `Invalid trust policy: ${file} is not valid JSON (${error.message}).`
115
- );
116
- }
117
- return validatePolicy(parsed);
118
- }
119
-
120
- // Match a single pattern against the command string. "^"-prefixed patterns are
121
- // anchored regexes; everything else is a case-sensitive substring match. A
122
- // malformed regex pattern is treated as a non-match so classify never crashes.
123
- function matchesPattern(pattern, command) {
124
- if (typeof pattern !== "string" || pattern.length === 0) {
125
- return false;
126
- }
127
- if (pattern.startsWith("^")) {
128
- try {
129
- return new RegExp(pattern).test(command);
130
- } catch (_error) {
131
- return false;
132
- }
133
- }
134
- return command.includes(pattern);
135
- }
136
-
137
- function firstMatch(patterns, command) {
138
- if (!Array.isArray(patterns)) {
139
- return null;
140
- }
141
- for (const pattern of patterns) {
142
- if (matchesPattern(pattern, command)) {
143
- return pattern;
144
- }
145
- }
146
- return null;
147
- }
148
-
149
- // Classify a command as allow/ask/deny against a policy. Most-restrictive-wins,
150
- // deterministic. Stateless: the caller supplies opts.actionCount; trust-policy
151
- // performs no session counting. Never executes the command.
152
- function classifyCommand(policy, command, opts) {
153
- const cmd = typeof command === "string" ? command : "";
154
- const options = opts && typeof opts === "object" ? opts : {};
155
- const limits = policy && policy.limits && typeof policy.limits === "object" ? policy.limits : {};
156
-
157
- // 1. action-count cap.
158
- if (
159
- typeof options.actionCount === "number" &&
160
- typeof limits.max_actions === "number" &&
161
- options.actionCount >= limits.max_actions
162
- ) {
163
- return {
164
- verdict: "deny",
165
- reason: `action-count cap reached (${options.actionCount}/${limits.max_actions})`,
166
- matchedRule: { bucket: "limit", pattern: "limits.max_actions" },
167
- };
168
- }
169
-
170
- // 2. deny → 3. ask → 4. allow (first match wins per bucket).
171
- const denyHit = firstMatch(policy && policy.deny, cmd);
172
- if (denyHit) {
173
- return {
174
- verdict: "deny",
175
- reason: `denied by policy rule: ${denyHit}`,
176
- matchedRule: { bucket: "deny", pattern: denyHit },
177
- };
178
- }
179
-
180
- const askHit = firstMatch(policy && policy.ask, cmd);
181
- if (askHit) {
182
- return {
183
- verdict: "ask",
184
- reason: `requires confirmation by policy rule: ${askHit}`,
185
- matchedRule: { bucket: "ask", pattern: askHit },
186
- };
187
- }
188
-
189
- const allowHit = firstMatch(policy && policy.allow, cmd);
190
- if (allowHit) {
191
- return {
192
- verdict: "allow",
193
- reason: `allowed by policy rule: ${allowHit}`,
194
- matchedRule: { bucket: "allow", pattern: allowHit },
195
- };
196
- }
197
-
198
- // 5. no match → conservative ask.
199
- return {
200
- verdict: "ask",
201
- reason: "no matching allow rule; defaulting to ask (conservative)",
202
- matchedRule: null,
203
- };
204
- }
205
-
206
- module.exports = {
207
- DEFAULT_POLICY,
208
- loadPolicy,
209
- classifyCommand,
210
- validatePolicy,
211
- policyFile,
212
- };
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { ValidationError } = require("./errors");
6
+
7
+ // Default allow/ask/deny pack (BK-240 §5), derived from the reference harness
8
+ // settings.json command classes. Patterns starting with "^" are treated as
9
+ // anchored regular expressions; all other patterns are case-sensitive
10
+ // substring matches against the command string. NO shell execution: this is
11
+ // advisory classification only.
12
+ const DEFAULT_POLICY = {
13
+ deny: [
14
+ "^rm -rf",
15
+ "^rm -fr",
16
+ "^sudo ",
17
+ "git reset --hard",
18
+ "git push --force",
19
+ "git push -f",
20
+ "mkfs",
21
+ "^dd ",
22
+ ".env",
23
+ ".pem",
24
+ "secrets/",
25
+ "^psql",
26
+ "^mysql",
27
+ "^mongod",
28
+ ],
29
+ ask: [
30
+ "npm install",
31
+ "npm publish",
32
+ "npm exec",
33
+ "npx",
34
+ "git merge",
35
+ "git rebase",
36
+ "git clean -fd",
37
+ "git clean -fx",
38
+ "git clean -fdx",
39
+ ],
40
+ allow: [
41
+ "git status",
42
+ "git diff",
43
+ "git log",
44
+ "git branch",
45
+ "git show",
46
+ "npm test",
47
+ "npm run test",
48
+ "npm run lint",
49
+ "npm run build",
50
+ "pytest",
51
+ "python -m unittest",
52
+ "rg ",
53
+ "ls ",
54
+ "node --check",
55
+ ],
56
+ // limits.max_actions is omitted by default; callers may add it (and supply
57
+ // --action-count) to enable the action-count cap.
58
+ limits: {},
59
+ };
60
+
61
+ function assertPatternArray(value, label) {
62
+ if (!Array.isArray(value)) {
63
+ throw new ValidationError(
64
+ `Invalid trust policy: "${label}" must be an array of string patterns.`
65
+ );
66
+ }
67
+ value.forEach((entry, index) => {
68
+ if (typeof entry !== "string") {
69
+ throw new ValidationError(
70
+ `Invalid trust policy: "${label}[${index}]" must be a string pattern.`
71
+ );
72
+ }
73
+ });
74
+ }
75
+
76
+ function validatePolicy(obj) {
77
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) {
78
+ throw new ValidationError("Invalid trust policy: expected a JSON object.");
79
+ }
80
+ assertPatternArray(obj.deny, "deny");
81
+ assertPatternArray(obj.ask, "ask");
82
+ assertPatternArray(obj.allow, "allow");
83
+
84
+ if (obj.limits !== undefined && obj.limits !== null) {
85
+ if (typeof obj.limits !== "object" || Array.isArray(obj.limits)) {
86
+ throw new ValidationError('Invalid trust policy: "limits" must be an object.');
87
+ }
88
+ if (
89
+ obj.limits.max_actions !== undefined &&
90
+ typeof obj.limits.max_actions !== "number"
91
+ ) {
92
+ throw new ValidationError(
93
+ 'Invalid trust policy: "limits.max_actions" must be a number.'
94
+ );
95
+ }
96
+ }
97
+ return obj;
98
+ }
99
+
100
+ function policyFile(projectPath) {
101
+ return path.join(path.resolve(projectPath || "."), ".sdtk", "trust", "policy.json");
102
+ }
103
+
104
+ function loadPolicy(projectPath) {
105
+ const file = policyFile(projectPath);
106
+ if (!fs.existsSync(file)) {
107
+ return DEFAULT_POLICY;
108
+ }
109
+ let parsed;
110
+ try {
111
+ parsed = JSON.parse(fs.readFileSync(file, "utf8"));
112
+ } catch (error) {
113
+ throw new ValidationError(
114
+ `Invalid trust policy: ${file} is not valid JSON (${error.message}).`
115
+ );
116
+ }
117
+ return validatePolicy(parsed);
118
+ }
119
+
120
+ // Match a single pattern against the command string. "^"-prefixed patterns are
121
+ // anchored regexes; everything else is a case-sensitive substring match. A
122
+ // malformed regex pattern is treated as a non-match so classify never crashes.
123
+ function matchesPattern(pattern, command) {
124
+ if (typeof pattern !== "string" || pattern.length === 0) {
125
+ return false;
126
+ }
127
+ if (pattern.startsWith("^")) {
128
+ try {
129
+ return new RegExp(pattern).test(command);
130
+ } catch (_error) {
131
+ return false;
132
+ }
133
+ }
134
+ return command.includes(pattern);
135
+ }
136
+
137
+ function firstMatch(patterns, command) {
138
+ if (!Array.isArray(patterns)) {
139
+ return null;
140
+ }
141
+ for (const pattern of patterns) {
142
+ if (matchesPattern(pattern, command)) {
143
+ return pattern;
144
+ }
145
+ }
146
+ return null;
147
+ }
148
+
149
+ // Classify a command as allow/ask/deny against a policy. Most-restrictive-wins,
150
+ // deterministic. Stateless: the caller supplies opts.actionCount; trust-policy
151
+ // performs no session counting. Never executes the command.
152
+ function classifyCommand(policy, command, opts) {
153
+ const cmd = typeof command === "string" ? command : "";
154
+ const options = opts && typeof opts === "object" ? opts : {};
155
+ const limits = policy && policy.limits && typeof policy.limits === "object" ? policy.limits : {};
156
+
157
+ // 1. action-count cap.
158
+ if (
159
+ typeof options.actionCount === "number" &&
160
+ typeof limits.max_actions === "number" &&
161
+ options.actionCount >= limits.max_actions
162
+ ) {
163
+ return {
164
+ verdict: "deny",
165
+ reason: `action-count cap reached (${options.actionCount}/${limits.max_actions})`,
166
+ matchedRule: { bucket: "limit", pattern: "limits.max_actions" },
167
+ };
168
+ }
169
+
170
+ // 2. deny → 3. ask → 4. allow (first match wins per bucket).
171
+ const denyHit = firstMatch(policy && policy.deny, cmd);
172
+ if (denyHit) {
173
+ return {
174
+ verdict: "deny",
175
+ reason: `denied by policy rule: ${denyHit}`,
176
+ matchedRule: { bucket: "deny", pattern: denyHit },
177
+ };
178
+ }
179
+
180
+ const askHit = firstMatch(policy && policy.ask, cmd);
181
+ if (askHit) {
182
+ return {
183
+ verdict: "ask",
184
+ reason: `requires confirmation by policy rule: ${askHit}`,
185
+ matchedRule: { bucket: "ask", pattern: askHit },
186
+ };
187
+ }
188
+
189
+ const allowHit = firstMatch(policy && policy.allow, cmd);
190
+ if (allowHit) {
191
+ return {
192
+ verdict: "allow",
193
+ reason: `allowed by policy rule: ${allowHit}`,
194
+ matchedRule: { bucket: "allow", pattern: allowHit },
195
+ };
196
+ }
197
+
198
+ // 5. no match → conservative ask.
199
+ return {
200
+ verdict: "ask",
201
+ reason: "no matching allow rule; defaulting to ask (conservative)",
202
+ matchedRule: null,
203
+ };
204
+ }
205
+
206
+ module.exports = {
207
+ DEFAULT_POLICY,
208
+ loadPolicy,
209
+ classifyCommand,
210
+ validatePolicy,
211
+ policyFile,
212
+ };
@@ -1,35 +1,35 @@
1
- "use strict";
2
-
3
- const PRIVATE_TAG_PATTERN = /<private>[\s\S]*?<\/private>/gi;
4
-
5
- const SECRET_PATTERNS = [
6
- /(?:api[_-]?key|secret|token|password|credential|auth)[\s]*[=:]\s*["']?[A-Za-z0-9_\-/.+]{20,}["']?/gi,
7
- /Bearer\s+[A-Za-z0-9._\-+/=]{20,}/gi,
8
- /sk-proj-[A-Za-z0-9\-_]{20,}/g,
9
- /(?:sk|pk|rk|ak)-[A-Za-z0-9][A-Za-z0-9\-_]{19,}/g,
10
- /sk-ant-[A-Za-z0-9\-_]{20,}/g,
11
- /gh[pus]_[A-Za-z0-9]{36,}/g,
12
- /github_pat_[A-Za-z0-9_]{22,}/g,
13
- /xoxb-[A-Za-z0-9\-]+/g,
14
- /AKIA[0-9A-Z]{16}/g,
15
- /AIza[A-Za-z0-9\-_]{35}/g,
16
- /eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
17
- /npm_[A-Za-z0-9]{36}/g,
18
- /glpat-[A-Za-z0-9\-_]{20,}/g,
19
- /dop_v1_[A-Za-z0-9]{64}/g,
20
- ];
21
-
22
- function redact(input) {
23
- if (typeof input !== "string") {
24
- return "";
25
- }
26
-
27
- let result = input.replace(PRIVATE_TAG_PATTERN, "[REDACTED]");
28
- for (const source of SECRET_PATTERNS) {
29
- const pattern = new RegExp(source.source, source.flags);
30
- result = result.replace(pattern, "[REDACTED_SECRET]");
31
- }
32
- return result;
33
- }
34
-
35
- module.exports = { redact, SECRET_PATTERNS };
1
+ "use strict";
2
+
3
+ const PRIVATE_TAG_PATTERN = /<private>[\s\S]*?<\/private>/gi;
4
+
5
+ const SECRET_PATTERNS = [
6
+ /(?:api[_-]?key|secret|token|password|credential|auth)[\s]*[=:]\s*["']?[A-Za-z0-9_\-/.+]{20,}["']?/gi,
7
+ /Bearer\s+[A-Za-z0-9._\-+/=]{20,}/gi,
8
+ /sk-proj-[A-Za-z0-9\-_]{20,}/g,
9
+ /(?:sk|pk|rk|ak)-[A-Za-z0-9][A-Za-z0-9\-_]{19,}/g,
10
+ /sk-ant-[A-Za-z0-9\-_]{20,}/g,
11
+ /gh[pus]_[A-Za-z0-9]{36,}/g,
12
+ /github_pat_[A-Za-z0-9_]{22,}/g,
13
+ /xoxb-[A-Za-z0-9\-]+/g,
14
+ /AKIA[0-9A-Z]{16}/g,
15
+ /AIza[A-Za-z0-9\-_]{35}/g,
16
+ /eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
17
+ /npm_[A-Za-z0-9]{36}/g,
18
+ /glpat-[A-Za-z0-9\-_]{20,}/g,
19
+ /dop_v1_[A-Za-z0-9]{64}/g,
20
+ ];
21
+
22
+ function redact(input) {
23
+ if (typeof input !== "string") {
24
+ return "";
25
+ }
26
+
27
+ let result = input.replace(PRIVATE_TAG_PATTERN, "[REDACTED]");
28
+ for (const source of SECRET_PATTERNS) {
29
+ const pattern = new RegExp(source.source, source.flags);
30
+ result = result.replace(pattern, "[REDACTED_SECRET]");
31
+ }
32
+ return result;
33
+ }
34
+
35
+ module.exports = { redact, SECRET_PATTERNS };