sdtk-code-kit 0.2.1 → 0.3.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 (50) 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 +174 -0
  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 +257 -244
  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 -108
  24. package/src/lib/agent-team-export.js +409 -0
  25. package/src/lib/agent-team-plan.js +514 -0
  26. package/src/lib/args.js +107 -107
  27. package/src/lib/errors.js +41 -41
  28. package/src/lib/powershell.js +65 -65
  29. package/src/lib/project-target-guard.js +53 -53
  30. package/src/lib/scope.js +72 -72
  31. package/src/lib/ship-readiness.js +281 -281
  32. package/src/lib/sleep-plan.js +175 -175
  33. package/src/lib/sleep-report.js +229 -229
  34. package/src/lib/toolkit-payload.js +72 -72
  35. package/src/lib/trust-events.js +185 -166
  36. package/src/lib/trust-file-scope.js +154 -154
  37. package/src/lib/trust-policy.js +212 -212
  38. package/src/lib/trust-redact.js +35 -35
  39. package/src/lib/trust-trace.js +179 -179
  40. package/src/lib/update.js +344 -344
  41. package/src/lib/workflow-artifact.js +503 -503
  42. package/src/lib/workflow-build.js +127 -127
  43. package/src/lib/workflow-doctor.js +83 -83
  44. package/src/lib/workflow-handoff.js +1029 -1029
  45. package/src/lib/workflow-intake.js +101 -101
  46. package/src/lib/workflow-plan.js +193 -193
  47. package/src/lib/workflow-review-packet.js +650 -650
  48. package/src/lib/workflow-ship.js +213 -213
  49. package/src/lib/workflow-state.js +438 -438
  50. package/src/lib/workflow-verify.js +393 -393
package/src/lib/args.js CHANGED
@@ -1,107 +1,107 @@
1
- "use strict";
2
-
3
- const { ValidationError } = require("./errors");
4
-
5
- function parseFlags(argv, defs) {
6
- const flags = {};
7
- const positional = [];
8
- const aliasMap = {};
9
-
10
- for (const [name, def] of Object.entries(defs)) {
11
- if (def.alias) {
12
- aliasMap[def.alias] = name;
13
- }
14
- if (def.type === "boolean") {
15
- flags[name] = false;
16
- } else if (def.multiple) {
17
- flags[name] = [];
18
- } else {
19
- flags[name] = undefined;
20
- }
21
- }
22
-
23
- let i = 0;
24
- while (i < argv.length) {
25
- const arg = argv[i];
26
-
27
- if (!arg.startsWith("-")) {
28
- positional.push(arg);
29
- i++;
30
- continue;
31
- }
32
-
33
- let key;
34
- let inlineValue;
35
- if (arg.includes("=")) {
36
- const eqIdx = arg.indexOf("=");
37
- key = arg.slice(0, eqIdx);
38
- inlineValue = arg.slice(eqIdx + 1);
39
- } else {
40
- key = arg;
41
- }
42
-
43
- const stripped = key.replace(/^-{1,2}/, "");
44
- const resolved = aliasMap[stripped] || stripped;
45
- if (!(resolved in defs)) {
46
- throw new ValidationError(`Unknown flag: ${key}`);
47
- }
48
-
49
- const def = defs[resolved];
50
- if (def.type === "boolean") {
51
- flags[resolved] = true;
52
- i++;
53
- continue;
54
- }
55
-
56
- let value = inlineValue;
57
- if (value === undefined) {
58
- i++;
59
- if (i >= argv.length) {
60
- throw new ValidationError(`Flag ${key} requires a value.`);
61
- }
62
- value = argv[i];
63
- }
64
-
65
- if (def.multiple) {
66
- flags[resolved].push(value);
67
- } else {
68
- flags[resolved] = value;
69
- }
70
- i++;
71
- }
72
-
73
- return { flags, positional };
74
- }
75
-
76
- function requireFlag(flags, name, label) {
77
- const value = flags[name];
78
- if (value === undefined || value === null || value === "") {
79
- throw new ValidationError(`Missing required flag: --${label || name}`);
80
- }
81
- return value;
82
- }
83
-
84
- function validateChoice(value, choices, label) {
85
- if (!choices.includes(value)) {
86
- throw new ValidationError(
87
- `Invalid value for --${label}: "${value}". Must be one of: ${choices.join(", ")}`
88
- );
89
- }
90
- return value;
91
- }
92
-
93
- function validatePattern(value, regex, label, hint) {
94
- if (!regex.test(value)) {
95
- throw new ValidationError(
96
- `Invalid value for --${label}: "${value}". ${hint || `Must match ${regex}`}`
97
- );
98
- }
99
- return value;
100
- }
101
-
102
- module.exports = {
103
- parseFlags,
104
- requireFlag,
105
- validateChoice,
106
- validatePattern,
107
- };
1
+ "use strict";
2
+
3
+ const { ValidationError } = require("./errors");
4
+
5
+ function parseFlags(argv, defs) {
6
+ const flags = {};
7
+ const positional = [];
8
+ const aliasMap = {};
9
+
10
+ for (const [name, def] of Object.entries(defs)) {
11
+ if (def.alias) {
12
+ aliasMap[def.alias] = name;
13
+ }
14
+ if (def.type === "boolean") {
15
+ flags[name] = false;
16
+ } else if (def.multiple) {
17
+ flags[name] = [];
18
+ } else {
19
+ flags[name] = undefined;
20
+ }
21
+ }
22
+
23
+ let i = 0;
24
+ while (i < argv.length) {
25
+ const arg = argv[i];
26
+
27
+ if (!arg.startsWith("-")) {
28
+ positional.push(arg);
29
+ i++;
30
+ continue;
31
+ }
32
+
33
+ let key;
34
+ let inlineValue;
35
+ if (arg.includes("=")) {
36
+ const eqIdx = arg.indexOf("=");
37
+ key = arg.slice(0, eqIdx);
38
+ inlineValue = arg.slice(eqIdx + 1);
39
+ } else {
40
+ key = arg;
41
+ }
42
+
43
+ const stripped = key.replace(/^-{1,2}/, "");
44
+ const resolved = aliasMap[stripped] || stripped;
45
+ if (!(resolved in defs)) {
46
+ throw new ValidationError(`Unknown flag: ${key}`);
47
+ }
48
+
49
+ const def = defs[resolved];
50
+ if (def.type === "boolean") {
51
+ flags[resolved] = true;
52
+ i++;
53
+ continue;
54
+ }
55
+
56
+ let value = inlineValue;
57
+ if (value === undefined) {
58
+ i++;
59
+ if (i >= argv.length) {
60
+ throw new ValidationError(`Flag ${key} requires a value.`);
61
+ }
62
+ value = argv[i];
63
+ }
64
+
65
+ if (def.multiple) {
66
+ flags[resolved].push(value);
67
+ } else {
68
+ flags[resolved] = value;
69
+ }
70
+ i++;
71
+ }
72
+
73
+ return { flags, positional };
74
+ }
75
+
76
+ function requireFlag(flags, name, label) {
77
+ const value = flags[name];
78
+ if (value === undefined || value === null || value === "") {
79
+ throw new ValidationError(`Missing required flag: --${label || name}`);
80
+ }
81
+ return value;
82
+ }
83
+
84
+ function validateChoice(value, choices, label) {
85
+ if (!choices.includes(value)) {
86
+ throw new ValidationError(
87
+ `Invalid value for --${label}: "${value}". Must be one of: ${choices.join(", ")}`
88
+ );
89
+ }
90
+ return value;
91
+ }
92
+
93
+ function validatePattern(value, regex, label, hint) {
94
+ if (!regex.test(value)) {
95
+ throw new ValidationError(
96
+ `Invalid value for --${label}: "${value}". ${hint || `Must match ${regex}`}`
97
+ );
98
+ }
99
+ return value;
100
+ }
101
+
102
+ module.exports = {
103
+ parseFlags,
104
+ requireFlag,
105
+ validateChoice,
106
+ validatePattern,
107
+ };
package/src/lib/errors.js CHANGED
@@ -1,41 +1,41 @@
1
- "use strict";
2
-
3
- class CliError extends Error {
4
- constructor(message, exitCode = 4) {
5
- super(message);
6
- this.name = this.constructor.name;
7
- this.exitCode = exitCode;
8
- }
9
- }
10
-
11
- class ValidationError extends CliError {
12
- constructor(message) {
13
- super(message, 1);
14
- }
15
- }
16
-
17
- class DependencyError extends CliError {
18
- constructor(message) {
19
- super(message, 2);
20
- }
21
- }
22
-
23
- class IntegrityError extends CliError {
24
- constructor(message) {
25
- super(message, 3);
26
- }
27
- }
28
-
29
- class InternalError extends CliError {
30
- constructor(message) {
31
- super(message, 4);
32
- }
33
- }
34
-
35
- module.exports = {
36
- CliError,
37
- ValidationError,
38
- DependencyError,
39
- IntegrityError,
40
- InternalError,
41
- };
1
+ "use strict";
2
+
3
+ class CliError extends Error {
4
+ constructor(message, exitCode = 4) {
5
+ super(message);
6
+ this.name = this.constructor.name;
7
+ this.exitCode = exitCode;
8
+ }
9
+ }
10
+
11
+ class ValidationError extends CliError {
12
+ constructor(message) {
13
+ super(message, 1);
14
+ }
15
+ }
16
+
17
+ class DependencyError extends CliError {
18
+ constructor(message) {
19
+ super(message, 2);
20
+ }
21
+ }
22
+
23
+ class IntegrityError extends CliError {
24
+ constructor(message) {
25
+ super(message, 3);
26
+ }
27
+ }
28
+
29
+ class InternalError extends CliError {
30
+ constructor(message) {
31
+ super(message, 4);
32
+ }
33
+ }
34
+
35
+ module.exports = {
36
+ CliError,
37
+ ValidationError,
38
+ DependencyError,
39
+ IntegrityError,
40
+ InternalError,
41
+ };
@@ -1,65 +1,65 @@
1
- "use strict";
2
-
3
- const { execFile } = require("child_process");
4
- const { DependencyError } = require("./errors");
5
-
6
- function findPowerShell() {
7
- if (process.platform === "win32") {
8
- return "powershell.exe";
9
- }
10
- return "pwsh";
11
- }
12
-
13
- function runScript(scriptPath, params = {}, options = {}) {
14
- return new Promise((resolve, reject) => {
15
- const psExe = findPowerShell();
16
- const args = [
17
- "-ExecutionPolicy",
18
- "Bypass",
19
- "-NoProfile",
20
- "-NonInteractive",
21
- "-File",
22
- scriptPath,
23
- ];
24
-
25
- for (const [key, value] of Object.entries(params)) {
26
- if (value === true) {
27
- args.push(`-${key}`);
28
- } else if (value === false || value === undefined || value === null) {
29
- continue;
30
- } else {
31
- args.push(`-${key}`);
32
- args.push(String(value));
33
- }
34
- }
35
-
36
- execFile(psExe, args, { maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
37
- if (error && error.code === "ENOENT") {
38
- reject(
39
- new DependencyError(
40
- `PowerShell not found. Ensure PowerShell is installed and available in PATH.\nTried: ${psExe}`
41
- )
42
- );
43
- return;
44
- }
45
-
46
- const exitCode = error ? error.code || 1 : 0;
47
- const result = {
48
- exitCode: typeof exitCode === "number" ? exitCode : 1,
49
- stdout: stdout || "",
50
- stderr: stderr || "",
51
- };
52
-
53
- if (!options.silent && result.stdout) {
54
- process.stdout.write(result.stdout);
55
- }
56
-
57
- resolve(result);
58
- });
59
- });
60
- }
61
-
62
- module.exports = {
63
- findPowerShell,
64
- runScript,
65
- };
1
+ "use strict";
2
+
3
+ const { execFile } = require("child_process");
4
+ const { DependencyError } = require("./errors");
5
+
6
+ function findPowerShell() {
7
+ if (process.platform === "win32") {
8
+ return "powershell.exe";
9
+ }
10
+ return "pwsh";
11
+ }
12
+
13
+ function runScript(scriptPath, params = {}, options = {}) {
14
+ return new Promise((resolve, reject) => {
15
+ const psExe = findPowerShell();
16
+ const args = [
17
+ "-ExecutionPolicy",
18
+ "Bypass",
19
+ "-NoProfile",
20
+ "-NonInteractive",
21
+ "-File",
22
+ scriptPath,
23
+ ];
24
+
25
+ for (const [key, value] of Object.entries(params)) {
26
+ if (value === true) {
27
+ args.push(`-${key}`);
28
+ } else if (value === false || value === undefined || value === null) {
29
+ continue;
30
+ } else {
31
+ args.push(`-${key}`);
32
+ args.push(String(value));
33
+ }
34
+ }
35
+
36
+ execFile(psExe, args, { maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
37
+ if (error && error.code === "ENOENT") {
38
+ reject(
39
+ new DependencyError(
40
+ `PowerShell not found. Ensure PowerShell is installed and available in PATH.\nTried: ${psExe}`
41
+ )
42
+ );
43
+ return;
44
+ }
45
+
46
+ const exitCode = error ? error.code || 1 : 0;
47
+ const result = {
48
+ exitCode: typeof exitCode === "number" ? exitCode : 1,
49
+ stdout: stdout || "",
50
+ stderr: stderr || "",
51
+ };
52
+
53
+ if (!options.silent && result.stdout) {
54
+ process.stdout.write(result.stdout);
55
+ }
56
+
57
+ resolve(result);
58
+ });
59
+ });
60
+ }
61
+
62
+ module.exports = {
63
+ findPowerShell,
64
+ runScript,
65
+ };
@@ -1,53 +1,53 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { ValidationError } = require("./errors");
6
-
7
- const MAINTAINER_ROOT_MARKERS = [
8
- "governance/ai/core/IMPROVEMENT_BACKLOG.md",
9
- "products/sdtk-code/toolkit/install.ps1",
10
- ];
11
- const PROTECTED_FILES = [
12
- "AGENTS.md",
13
- "CODEX.md",
14
- "CLAUDE.md",
15
- "sdtk-spec.config.json",
16
- "sdtk-spec.config.profiles.example.json"
17
- ];
18
-
19
- function isMaintainerRoot(projectPath) {
20
- const resolved = path.resolve(projectPath);
21
- return MAINTAINER_ROOT_MARKERS.every((marker) => fs.existsSync(path.join(resolved, marker)));
22
- }
23
-
24
- function buildMaintainerRootMessage(cliName, action, projectPath) {
25
- const lines = [
26
- `Refusing to refresh managed project files into the SDTK maintainer repo root: ${projectPath}`,
27
- `The ${action} flow would overwrite repo-owned files such as ${PROTECTED_FILES.join(", ")}.`,
28
- "Target a consumer project path instead of the SDTK maintainer monorepo root.",
29
- ];
30
-
31
- if (action === "update") {
32
- lines.push(`If you only need package/runtime refresh, rerun ${cliName} update with --skip-project-files.`);
33
- } else {
34
- lines.push(`If you only need runtime assets, use ${cliName} runtime install against the desired consumer project path instead of ${cliName} init.`);
35
- }
36
-
37
- return lines.join("\n");
38
- }
39
-
40
- function assertProjectRefreshTargetAllowed(cliName, action, projectPath) {
41
- if (!isMaintainerRoot(projectPath)) {
42
- return;
43
- }
44
-
45
- throw new ValidationError(buildMaintainerRootMessage(cliName, action, projectPath));
46
- }
47
-
48
- module.exports = {
49
- assertProjectRefreshTargetAllowed,
50
- buildMaintainerRootMessage,
51
- isMaintainerRoot,
52
- };
53
-
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { ValidationError } = require("./errors");
6
+
7
+ const MAINTAINER_ROOT_MARKERS = [
8
+ "governance/ai/core/IMPROVEMENT_BACKLOG.md",
9
+ "products/sdtk-code/toolkit/install.ps1",
10
+ ];
11
+ const PROTECTED_FILES = [
12
+ "AGENTS.md",
13
+ "CODEX.md",
14
+ "CLAUDE.md",
15
+ "sdtk-spec.config.json",
16
+ "sdtk-spec.config.profiles.example.json"
17
+ ];
18
+
19
+ function isMaintainerRoot(projectPath) {
20
+ const resolved = path.resolve(projectPath);
21
+ return MAINTAINER_ROOT_MARKERS.every((marker) => fs.existsSync(path.join(resolved, marker)));
22
+ }
23
+
24
+ function buildMaintainerRootMessage(cliName, action, projectPath) {
25
+ const lines = [
26
+ `Refusing to refresh managed project files into the SDTK maintainer repo root: ${projectPath}`,
27
+ `The ${action} flow would overwrite repo-owned files such as ${PROTECTED_FILES.join(", ")}.`,
28
+ "Target a consumer project path instead of the SDTK maintainer monorepo root.",
29
+ ];
30
+
31
+ if (action === "update") {
32
+ lines.push(`If you only need package/runtime refresh, rerun ${cliName} update with --skip-project-files.`);
33
+ } else {
34
+ lines.push(`If you only need runtime assets, use ${cliName} runtime install against the desired consumer project path instead of ${cliName} init.`);
35
+ }
36
+
37
+ return lines.join("\n");
38
+ }
39
+
40
+ function assertProjectRefreshTargetAllowed(cliName, action, projectPath) {
41
+ if (!isMaintainerRoot(projectPath)) {
42
+ return;
43
+ }
44
+
45
+ throw new ValidationError(buildMaintainerRootMessage(cliName, action, projectPath));
46
+ }
47
+
48
+ module.exports = {
49
+ assertProjectRefreshTargetAllowed,
50
+ buildMaintainerRootMessage,
51
+ isMaintainerRoot,
52
+ };
53
+
package/src/lib/scope.js CHANGED
@@ -1,72 +1,72 @@
1
- "use strict";
2
-
3
- const os = require("os");
4
- const path = require("path");
5
-
6
- const VALID_SCOPES = ["project", "user"];
7
-
8
- function defaultScope(runtime) {
9
- return runtime === "claude" ? "project" : "user";
10
- }
11
-
12
- function isProjectScopeSupported(runtime) {
13
- return runtime === "claude" || runtime === "codex";
14
- }
15
-
16
- function resolveCodexProjectHome(projectPath) {
17
- return path.join(projectPath || process.cwd(), ".codex");
18
- }
19
-
20
- function resolveCodexUserHome() {
21
- return process.env.CODEX_HOME || path.join(os.homedir(), ".codex");
22
- }
23
-
24
- function resolveCodexHome(scope, projectPath) {
25
- return scope === "project"
26
- ? resolveCodexProjectHome(projectPath)
27
- : resolveCodexUserHome();
28
- }
29
-
30
- function resolveSkillsDir(runtime, scope, projectPath) {
31
- if (runtime === "claude") {
32
- if (scope === "user") {
33
- return path.join(os.homedir(), ".claude", "skills");
34
- }
35
- return path.join(projectPath || process.cwd(), ".claude", "skills");
36
- }
37
-
38
- const codexHome = resolveCodexHome(scope, projectPath);
39
- return path.join(codexHome, "skills");
40
- }
41
-
42
- const MANAGED_CLAUDE_SKILLS = [
43
- "code-brainstorm",
44
- "code-debug",
45
- "code-discover",
46
- "code-execute",
47
- "code-finish",
48
- "code-parallel",
49
- "code-plan",
50
- "code-review",
51
- "code-ship",
52
- "code-tdd",
53
- "code-verify",
54
- "code-worktree",
55
- ];
56
-
57
- const MANAGED_CODEX_SKILLS = MANAGED_CLAUDE_SKILLS.map((name) => `sdtk-${name}`);
58
-
59
- function managedSkillNames(runtime) {
60
- return runtime === "claude" ? MANAGED_CLAUDE_SKILLS : MANAGED_CODEX_SKILLS;
61
- }
62
-
63
- module.exports = {
64
- VALID_SCOPES,
65
- defaultScope,
66
- isProjectScopeSupported,
67
- resolveCodexHome,
68
- resolveCodexProjectHome,
69
- resolveCodexUserHome,
70
- resolveSkillsDir,
71
- managedSkillNames,
72
- };
1
+ "use strict";
2
+
3
+ const os = require("os");
4
+ const path = require("path");
5
+
6
+ const VALID_SCOPES = ["project", "user"];
7
+
8
+ function defaultScope(runtime) {
9
+ return runtime === "claude" ? "project" : "user";
10
+ }
11
+
12
+ function isProjectScopeSupported(runtime) {
13
+ return runtime === "claude" || runtime === "codex";
14
+ }
15
+
16
+ function resolveCodexProjectHome(projectPath) {
17
+ return path.join(projectPath || process.cwd(), ".codex");
18
+ }
19
+
20
+ function resolveCodexUserHome() {
21
+ return process.env.CODEX_HOME || path.join(os.homedir(), ".codex");
22
+ }
23
+
24
+ function resolveCodexHome(scope, projectPath) {
25
+ return scope === "project"
26
+ ? resolveCodexProjectHome(projectPath)
27
+ : resolveCodexUserHome();
28
+ }
29
+
30
+ function resolveSkillsDir(runtime, scope, projectPath) {
31
+ if (runtime === "claude") {
32
+ if (scope === "user") {
33
+ return path.join(os.homedir(), ".claude", "skills");
34
+ }
35
+ return path.join(projectPath || process.cwd(), ".claude", "skills");
36
+ }
37
+
38
+ const codexHome = resolveCodexHome(scope, projectPath);
39
+ return path.join(codexHome, "skills");
40
+ }
41
+
42
+ const MANAGED_CLAUDE_SKILLS = [
43
+ "code-brainstorm",
44
+ "code-debug",
45
+ "code-discover",
46
+ "code-execute",
47
+ "code-finish",
48
+ "code-parallel",
49
+ "code-plan",
50
+ "code-review",
51
+ "code-ship",
52
+ "code-tdd",
53
+ "code-verify",
54
+ "code-worktree",
55
+ ];
56
+
57
+ const MANAGED_CODEX_SKILLS = MANAGED_CLAUDE_SKILLS.map((name) => `sdtk-${name}`);
58
+
59
+ function managedSkillNames(runtime) {
60
+ return runtime === "claude" ? MANAGED_CLAUDE_SKILLS : MANAGED_CODEX_SKILLS;
61
+ }
62
+
63
+ module.exports = {
64
+ VALID_SCOPES,
65
+ defaultScope,
66
+ isProjectScopeSupported,
67
+ resolveCodexHome,
68
+ resolveCodexProjectHome,
69
+ resolveCodexUserHome,
70
+ resolveSkillsDir,
71
+ managedSkillNames,
72
+ };