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,154 +1,154 @@
1
- "use strict";
2
-
3
- const childProcess = require("child_process");
4
- const fs = require("fs");
5
- const path = require("path");
6
-
7
- function normalizePatterns(value) {
8
- if (!Array.isArray(value)) {
9
- return [];
10
- }
11
- return value.filter((entry) => typeof entry === "string" && entry.length > 0);
12
- }
13
-
14
- function loadScopes(projectPath, featureKey, opts = {}) {
15
- const optAllowed = normalizePatterns(opts.allowed);
16
- const optBlocked = normalizePatterns(opts.blocked);
17
- if (Array.isArray(opts.allowed) || Array.isArray(opts.blocked)) {
18
- return {
19
- allowed: optAllowed,
20
- blocked: optBlocked,
21
- declared: optAllowed.length > 0 || optBlocked.length > 0,
22
- source: "opts",
23
- };
24
- }
25
-
26
- const handoffPath = path.join(
27
- path.resolve(projectPath || "."),
28
- "docs",
29
- "dev",
30
- `CODE_HANDOFF_${featureKey}.json`,
31
- );
32
-
33
- try {
34
- const payload = JSON.parse(fs.readFileSync(handoffPath, "utf8"));
35
- const allowed = normalizePatterns(payload.allowed_file_scopes);
36
- const blocked = normalizePatterns(payload.blocked_file_scopes);
37
- if (Array.isArray(payload.allowed_file_scopes) || Array.isArray(payload.blocked_file_scopes)) {
38
- return {
39
- allowed,
40
- blocked,
41
- declared: allowed.length > 0 || blocked.length > 0,
42
- source: "handoff",
43
- };
44
- }
45
- } catch (_error) {
46
- // Missing or invalid optional forward-compat handoff fields fall back cleanly.
47
- }
48
-
49
- return { allowed: [], blocked: [], declared: false, source: "none" };
50
- }
51
-
52
- function escapeRegexChar(char) {
53
- return /[\\^$+?.()|[\]{}]/.test(char) ? `\\${char}` : char;
54
- }
55
-
56
- function globToRegex(pattern) {
57
- let source = "";
58
- for (let index = 0; index < pattern.length; index += 1) {
59
- const char = pattern[index];
60
- const next = pattern[index + 1];
61
- if (char === "*") {
62
- if (next === "*") {
63
- source += ".*";
64
- index += 1;
65
- } else {
66
- source += "[^/]*";
67
- }
68
- } else if (char === "?") {
69
- source += "[^/]";
70
- } else {
71
- source += escapeRegexChar(char);
72
- }
73
- }
74
- return new RegExp(`^${source}$`);
75
- }
76
-
77
- function normalizePathForMatch(file) {
78
- return String(file || "").replace(/\\/g, "/");
79
- }
80
-
81
- function matchOne(file, pattern) {
82
- if (typeof pattern !== "string" || pattern.length === 0) {
83
- return false;
84
- }
85
- const normalizedFile = normalizePathForMatch(file);
86
- if (pattern.startsWith("re:")) {
87
- return new RegExp(`^${pattern.slice(3)}$`).test(normalizedFile);
88
- }
89
- return globToRegex(normalizePathForMatch(pattern)).test(normalizedFile);
90
- }
91
-
92
- function matchScope(file, patterns) {
93
- return normalizePatterns(patterns).some((pattern) => matchOne(file, pattern));
94
- }
95
-
96
- function checkFiles(scopes, changedFiles) {
97
- const allowed = normalizePatterns(scopes && scopes.allowed);
98
- const blocked = normalizePatterns(scopes && scopes.blocked);
99
- const declared = Boolean(scopes && scopes.declared);
100
- const files = Array.isArray(changedFiles)
101
- ? changedFiles.filter((entry) => typeof entry === "string" && entry.length > 0)
102
- : [];
103
-
104
- if (!declared && allowed.length === 0 && blocked.length === 0) {
105
- return {
106
- inScope: [],
107
- outOfScope: [],
108
- blockedHits: [],
109
- verdict: "needs_human",
110
- declared: false,
111
- };
112
- }
113
-
114
- const inScope = [];
115
- const outOfScope = [];
116
- const blockedHits = [];
117
- const hasAllowed = allowed.length > 0;
118
-
119
- for (const file of files) {
120
- if (matchScope(file, blocked)) {
121
- blockedHits.push(file);
122
- continue;
123
- }
124
- if (!hasAllowed || matchScope(file, allowed)) {
125
- inScope.push(file);
126
- } else {
127
- outOfScope.push(file);
128
- }
129
- }
130
-
131
- const verdict = blockedHits.length > 0 || outOfScope.length > 0 ? "fail" : "pass";
132
- return { inScope, outOfScope, blockedHits, verdict, declared: true };
133
- }
134
-
135
- function getChangedFiles(projectPath, baseRef = "HEAD") {
136
- const result = childProcess.spawnSync(
137
- "git",
138
- ["diff", "--name-only", baseRef],
139
- {
140
- cwd: path.resolve(projectPath || "."),
141
- encoding: "utf8",
142
- errors: "replace",
143
- },
144
- );
145
- if (result.error) {
146
- throw result.error;
147
- }
148
- if (result.status !== 0) {
149
- throw new Error((result.stderr || "git diff --name-only failed").trim());
150
- }
151
- return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
152
- }
153
-
154
- module.exports = { loadScopes, matchScope, checkFiles, getChangedFiles };
1
+ "use strict";
2
+
3
+ const childProcess = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+
7
+ function normalizePatterns(value) {
8
+ if (!Array.isArray(value)) {
9
+ return [];
10
+ }
11
+ return value.filter((entry) => typeof entry === "string" && entry.length > 0);
12
+ }
13
+
14
+ function loadScopes(projectPath, featureKey, opts = {}) {
15
+ const optAllowed = normalizePatterns(opts.allowed);
16
+ const optBlocked = normalizePatterns(opts.blocked);
17
+ if (Array.isArray(opts.allowed) || Array.isArray(opts.blocked)) {
18
+ return {
19
+ allowed: optAllowed,
20
+ blocked: optBlocked,
21
+ declared: optAllowed.length > 0 || optBlocked.length > 0,
22
+ source: "opts",
23
+ };
24
+ }
25
+
26
+ const handoffPath = path.join(
27
+ path.resolve(projectPath || "."),
28
+ "docs",
29
+ "dev",
30
+ `CODE_HANDOFF_${featureKey}.json`,
31
+ );
32
+
33
+ try {
34
+ const payload = JSON.parse(fs.readFileSync(handoffPath, "utf8"));
35
+ const allowed = normalizePatterns(payload.allowed_file_scopes);
36
+ const blocked = normalizePatterns(payload.blocked_file_scopes);
37
+ if (Array.isArray(payload.allowed_file_scopes) || Array.isArray(payload.blocked_file_scopes)) {
38
+ return {
39
+ allowed,
40
+ blocked,
41
+ declared: allowed.length > 0 || blocked.length > 0,
42
+ source: "handoff",
43
+ };
44
+ }
45
+ } catch (_error) {
46
+ // Missing or invalid optional forward-compat handoff fields fall back cleanly.
47
+ }
48
+
49
+ return { allowed: [], blocked: [], declared: false, source: "none" };
50
+ }
51
+
52
+ function escapeRegexChar(char) {
53
+ return /[\\^$+?.()|[\]{}]/.test(char) ? `\\${char}` : char;
54
+ }
55
+
56
+ function globToRegex(pattern) {
57
+ let source = "";
58
+ for (let index = 0; index < pattern.length; index += 1) {
59
+ const char = pattern[index];
60
+ const next = pattern[index + 1];
61
+ if (char === "*") {
62
+ if (next === "*") {
63
+ source += ".*";
64
+ index += 1;
65
+ } else {
66
+ source += "[^/]*";
67
+ }
68
+ } else if (char === "?") {
69
+ source += "[^/]";
70
+ } else {
71
+ source += escapeRegexChar(char);
72
+ }
73
+ }
74
+ return new RegExp(`^${source}$`);
75
+ }
76
+
77
+ function normalizePathForMatch(file) {
78
+ return String(file || "").replace(/\\/g, "/");
79
+ }
80
+
81
+ function matchOne(file, pattern) {
82
+ if (typeof pattern !== "string" || pattern.length === 0) {
83
+ return false;
84
+ }
85
+ const normalizedFile = normalizePathForMatch(file);
86
+ if (pattern.startsWith("re:")) {
87
+ return new RegExp(`^${pattern.slice(3)}$`).test(normalizedFile);
88
+ }
89
+ return globToRegex(normalizePathForMatch(pattern)).test(normalizedFile);
90
+ }
91
+
92
+ function matchScope(file, patterns) {
93
+ return normalizePatterns(patterns).some((pattern) => matchOne(file, pattern));
94
+ }
95
+
96
+ function checkFiles(scopes, changedFiles) {
97
+ const allowed = normalizePatterns(scopes && scopes.allowed);
98
+ const blocked = normalizePatterns(scopes && scopes.blocked);
99
+ const declared = Boolean(scopes && scopes.declared);
100
+ const files = Array.isArray(changedFiles)
101
+ ? changedFiles.filter((entry) => typeof entry === "string" && entry.length > 0)
102
+ : [];
103
+
104
+ if (!declared && allowed.length === 0 && blocked.length === 0) {
105
+ return {
106
+ inScope: [],
107
+ outOfScope: [],
108
+ blockedHits: [],
109
+ verdict: "needs_human",
110
+ declared: false,
111
+ };
112
+ }
113
+
114
+ const inScope = [];
115
+ const outOfScope = [];
116
+ const blockedHits = [];
117
+ const hasAllowed = allowed.length > 0;
118
+
119
+ for (const file of files) {
120
+ if (matchScope(file, blocked)) {
121
+ blockedHits.push(file);
122
+ continue;
123
+ }
124
+ if (!hasAllowed || matchScope(file, allowed)) {
125
+ inScope.push(file);
126
+ } else {
127
+ outOfScope.push(file);
128
+ }
129
+ }
130
+
131
+ const verdict = blockedHits.length > 0 || outOfScope.length > 0 ? "fail" : "pass";
132
+ return { inScope, outOfScope, blockedHits, verdict, declared: true };
133
+ }
134
+
135
+ function getChangedFiles(projectPath, baseRef = "HEAD") {
136
+ const result = childProcess.spawnSync(
137
+ "git",
138
+ ["diff", "--name-only", baseRef],
139
+ {
140
+ cwd: path.resolve(projectPath || "."),
141
+ encoding: "utf8",
142
+ errors: "replace",
143
+ },
144
+ );
145
+ if (result.error) {
146
+ throw result.error;
147
+ }
148
+ if (result.status !== 0) {
149
+ throw new Error((result.stderr || "git diff --name-only failed").trim());
150
+ }
151
+ return result.stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
152
+ }
153
+
154
+ module.exports = { loadScopes, matchScope, checkFiles, getChangedFiles };