sdtk-code-kit 0.1.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.
- package/README.md +138 -0
- package/assets/manifest/toolkit-bundle.manifest.json +147 -0
- package/assets/manifest/toolkit-bundle.sha256.txt +28 -0
- package/assets/toolkit/toolkit/AGENTS.md +210 -0
- package/assets/toolkit/toolkit/install.ps1 +126 -0
- package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +78 -0
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +127 -0
- package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +62 -0
- package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +53 -0
- package/assets/toolkit/toolkit/sdtk-spec.config.json +6 -0
- package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +12 -0
- package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +56 -0
- package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +297 -0
- package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +69 -0
- package/assets/toolkit/toolkit/skills/code-discover/SKILL.md +54 -0
- package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +75 -0
- package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +206 -0
- package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +65 -0
- package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +27 -0
- package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +114 -0
- package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +62 -0
- package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +86 -0
- package/assets/toolkit/toolkit/skills/code-review/SKILL.md +80 -0
- package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +126 -0
- package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +147 -0
- package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +53 -0
- package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +379 -0
- package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +300 -0
- package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +145 -0
- package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +229 -0
- package/assets/toolkit/toolkit/templates/CODE_WORKFLOW_TEMPLATE.md +112 -0
- package/bin/sdtk-code.js +14 -0
- package/package.json +44 -0
- package/src/commands/build.js +53 -0
- package/src/commands/generate.js +11 -0
- package/src/commands/help.js +169 -0
- package/src/commands/init.js +86 -0
- package/src/commands/plan.js +52 -0
- package/src/commands/runtime.js +205 -0
- package/src/commands/ship.js +54 -0
- package/src/commands/start.js +89 -0
- package/src/commands/verify.js +57 -0
- package/src/index.js +70 -0
- package/src/lib/args.js +107 -0
- package/src/lib/errors.js +41 -0
- package/src/lib/powershell.js +65 -0
- package/src/lib/scope.js +55 -0
- package/src/lib/toolkit-payload.js +72 -0
- package/src/lib/workflow-artifact.js +453 -0
- package/src/lib/workflow-build.js +127 -0
- package/src/lib/workflow-handoff.js +427 -0
- package/src/lib/workflow-intake.js +100 -0
- package/src/lib/workflow-plan.js +96 -0
- package/src/lib/workflow-ship.js +163 -0
- package/src/lib/workflow-verify.js +212 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function cmdHelp() {
|
|
4
|
+
const text = [
|
|
5
|
+
"SDTK-CODE CLI -- coding process discipline toolkit",
|
|
6
|
+
"",
|
|
7
|
+
"Usage:",
|
|
8
|
+
" sdtk-code <command> [options]",
|
|
9
|
+
"",
|
|
10
|
+
"Commands:",
|
|
11
|
+
" start Create or refresh CODE_WORKFLOW from formal handoff or compatibility inputs",
|
|
12
|
+
" plan Refine workflow slices and scope from an existing CODE_WORKFLOW",
|
|
13
|
+
" build Record build progress and route the next coding engine step",
|
|
14
|
+
" verify Record summarized evidence and ordered review gate status",
|
|
15
|
+
" ship Record final ship or finish decision with preflight summary",
|
|
16
|
+
" init Initialize SDTK-CODE workspace",
|
|
17
|
+
" runtime Manage runtime asset installation (install, uninstall, status)",
|
|
18
|
+
"",
|
|
19
|
+
"Workflow status:",
|
|
20
|
+
" Implemented now: start, plan, build, verify, ship",
|
|
21
|
+
"",
|
|
22
|
+
"Package status:",
|
|
23
|
+
" First public package target: sdtk-code-kit@0.1.0",
|
|
24
|
+
" Canonical command: sdtk-code",
|
|
25
|
+
" Real workflow execution still expects upstream SDTK-SPEC artifacts",
|
|
26
|
+
" First registry publish may still be pending until the maintainer-run npm publish completes",
|
|
27
|
+
" CI/tag-publish parity is follow-up hardening, not a blocker for the first public release",
|
|
28
|
+
" Payload stays intentionally narrow and ships runtime assets plus CODE_WORKFLOW_TEMPLATE.md",
|
|
29
|
+
"",
|
|
30
|
+
"Start options:",
|
|
31
|
+
" --feature-key <KEY> Feature key in UPPER_SNAKE_CASE (required)",
|
|
32
|
+
" --lane <feature|bugfix> Explicit workflow lane (required)",
|
|
33
|
+
" --project-path <path> Target project directory (default: cwd)",
|
|
34
|
+
" --force Reinitialize an existing workflow artifact",
|
|
35
|
+
"",
|
|
36
|
+
"Start intake truth:",
|
|
37
|
+
" Prefers docs/dev/CODE_HANDOFF_[FEATURE_KEY].json when present",
|
|
38
|
+
" Falls back to FEATURE_IMPL_PLAN + sdtk-spec.config.json only when the formal handoff file is missing",
|
|
39
|
+
" Feature lane expects formal handoff by default; bugfix may use compatibility fallback when missing",
|
|
40
|
+
" Invalid or blocked formal handoff stops start and writes a blocked workflow artifact",
|
|
41
|
+
"",
|
|
42
|
+
"Plan options:",
|
|
43
|
+
" --feature-key <KEY> Feature key in UPPER_SNAKE_CASE (required)",
|
|
44
|
+
" --project-path <path> Target project directory (default: cwd)",
|
|
45
|
+
" --in-scope <text> Record an in-scope item (repeatable)",
|
|
46
|
+
" --out-scope <text> Record an out-of-scope item (repeatable)",
|
|
47
|
+
" --slice <text> Record a planning slice (repeatable; required for feature lane)",
|
|
48
|
+
" --assumption <text> Record a planning assumption (repeatable)",
|
|
49
|
+
" --risk <text> Record a planning risk (repeatable)",
|
|
50
|
+
" --note <text> Record an additional planning note (repeatable)",
|
|
51
|
+
"",
|
|
52
|
+
"Build options:",
|
|
53
|
+
" --feature-key <KEY> Feature key in UPPER_SNAKE_CASE (required)",
|
|
54
|
+
" --project-path <path> Target project directory (default: cwd)",
|
|
55
|
+
" --active-slice <text> Record an active build slice (repeatable)",
|
|
56
|
+
" --note <text> Record a build note (repeatable)",
|
|
57
|
+
" --debug-note <text> Record a reactive debug note (repeatable)",
|
|
58
|
+
" --parallel-reason <text> Explicit justification for code-parallel in feature lane",
|
|
59
|
+
" --complete Mark the current build pass complete and route to verify",
|
|
60
|
+
" --blocked Mark the current build pass blocked and keep routing on build",
|
|
61
|
+
"",
|
|
62
|
+
"Verify options:",
|
|
63
|
+
" --feature-key <KEY> Feature key in UPPER_SNAKE_CASE (required)",
|
|
64
|
+
" --project-path <path> Target project directory (default: cwd)",
|
|
65
|
+
" --evidence <text> Summarized evidence entry in the form",
|
|
66
|
+
" \"check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt\"",
|
|
67
|
+
" (repeatable; at least one required)",
|
|
68
|
+
" --spec-status <pending|pass|partial|fail>",
|
|
69
|
+
" Current spec/compliance review gate status",
|
|
70
|
+
" --spec-note <text> Record a spec/compliance review note (repeatable)",
|
|
71
|
+
" --quality-status <pending|pass|partial|fail>",
|
|
72
|
+
" Current quality review gate status",
|
|
73
|
+
" --quality-note <text> Record a quality review note (repeatable)",
|
|
74
|
+
" --debug-note <text> Record reactive debug follow-up from verification (repeatable)",
|
|
75
|
+
" --complete Mark verify complete and route to ship",
|
|
76
|
+
" --blocked Keep verify blocked and route back to verification work",
|
|
77
|
+
"",
|
|
78
|
+
"Ship options:",
|
|
79
|
+
" --feature-key <KEY> Feature key in UPPER_SNAKE_CASE (required)",
|
|
80
|
+
" --project-path <path> Target project directory (default: cwd)",
|
|
81
|
+
" --decision <ship|finish> Final decision to record (required)",
|
|
82
|
+
" --preflight <text> Preflight entry in the form",
|
|
83
|
+
" \"check|summary|pass|docs/dev/evidence/FEATURE_KEY/file.txt\"",
|
|
84
|
+
" (repeatable; at least one required)",
|
|
85
|
+
" --follow-up <text> Record a deferred follow-up item (repeatable)",
|
|
86
|
+
" --note <text> Record a ship/finalization note (repeatable)",
|
|
87
|
+
" --debug-note <text> Record reactive debug follow-up from preflight (repeatable)",
|
|
88
|
+
" --blocked Keep ship blocked and route back to code-debug/code-ship",
|
|
89
|
+
"",
|
|
90
|
+
"Init options:",
|
|
91
|
+
" --runtime <codex|claude> Runtime adapter (default: codex)",
|
|
92
|
+
" --runtime-scope <project|user> Install scope (default: project for claude, user for codex)",
|
|
93
|
+
" --project-path <path> Target project directory (default: cwd)",
|
|
94
|
+
" --force Overwrite existing files",
|
|
95
|
+
" --skip-runtime-assets Skip runtime skill installation",
|
|
96
|
+
" --skip-skills Deprecated alias for --skip-runtime-assets",
|
|
97
|
+
" --verbose Show detailed PowerShell script output",
|
|
98
|
+
"",
|
|
99
|
+
"Runtime subcommands:",
|
|
100
|
+
" sdtk-code runtime install --runtime <codex|claude> [--scope <project|user>]",
|
|
101
|
+
" sdtk-code runtime uninstall --runtime <codex|claude> [--scope <project|user>] [--all]",
|
|
102
|
+
" sdtk-code runtime status --runtime <codex|claude> [--project-path <path>]",
|
|
103
|
+
"",
|
|
104
|
+
"Runtime options:",
|
|
105
|
+
" --runtime <codex|claude> Target runtime (required)",
|
|
106
|
+
" --scope <project|user> Install scope (default: project for claude, user for codex)",
|
|
107
|
+
" --project-path <path> Target project directory (default: cwd)",
|
|
108
|
+
" --force Overwrite existing managed skills",
|
|
109
|
+
" --all Explicit alias for uninstalling all managed skills",
|
|
110
|
+
" --verbose Show detailed script output",
|
|
111
|
+
"",
|
|
112
|
+
"Scope behavior:",
|
|
113
|
+
" claude/project -> <project>/.claude/skills",
|
|
114
|
+
" claude/user -> ~/.claude/skills",
|
|
115
|
+
" codex/user -> $CODEX_HOME/skills or ~/.codex/skills",
|
|
116
|
+
" Note: Codex supports user scope only. Project scope is blocked by Gate C0.",
|
|
117
|
+
"",
|
|
118
|
+
"Skill naming:",
|
|
119
|
+
" Claude installs: code-*",
|
|
120
|
+
" Codex installs: sdtk-code-*",
|
|
121
|
+
"",
|
|
122
|
+
"Global options:",
|
|
123
|
+
" -h, --help Show this help",
|
|
124
|
+
" -v, --version Show version",
|
|
125
|
+
"",
|
|
126
|
+
"Exit codes:",
|
|
127
|
+
" 0 Success",
|
|
128
|
+
" 1 Validation or user error",
|
|
129
|
+
" 2 Dependency error",
|
|
130
|
+
" 3 Integrity error",
|
|
131
|
+
" 4 Unexpected internal error",
|
|
132
|
+
"",
|
|
133
|
+
"Examples:",
|
|
134
|
+
" sdtk-code start --feature-key ORDER_MGMT --lane feature --project-path ./my-project",
|
|
135
|
+
" sdtk-code start --feature-key LOGIN_FIX --lane bugfix --project-path ./my-project",
|
|
136
|
+
" sdtk-code plan --feature-key ORDER_MGMT --slice \"API contract updates\" --slice \"UI register flow\"",
|
|
137
|
+
" sdtk-code plan --feature-key LOGIN_FIX --note \"Bugfix planning override\"",
|
|
138
|
+
" sdtk-code build --feature-key ORDER_MGMT --active-slice \"API contract updates\" --parallel-reason \"Backend and UI are isolated\"",
|
|
139
|
+
" sdtk-code build --feature-key LOGIN_FIX --debug-note \"Failure reproduced in session timeout flow\" --complete",
|
|
140
|
+
" sdtk-code verify --feature-key ORDER_MGMT --evidence \"pytest -q|Regression suite passed|pass|docs/dev/evidence/ORDER_MGMT/pytest.txt\" --spec-status pass --quality-status partial",
|
|
141
|
+
" sdtk-code verify --feature-key LOGIN_FIX --evidence \"npm test|Bugfix regression passes|pass|docs/dev/evidence/LOGIN_FIX/regression.txt\" --spec-status pass --quality-status pass --complete",
|
|
142
|
+
" sdtk-code ship --feature-key ORDER_MGMT --decision ship --preflight \"npm pack --dry-run|Package smoke passed|pass|docs/dev/evidence/ORDER_MGMT/pack.txt\" --follow-up \"Monitor first-release support tickets\"",
|
|
143
|
+
" sdtk-code ship --feature-key LOGIN_FIX --decision finish --preflight \"git diff --check|No whitespace issues remain|pass|docs/dev/evidence/LOGIN_FIX/diff-check.txt\"",
|
|
144
|
+
" sdtk-code init",
|
|
145
|
+
" sdtk-code init --runtime claude --project-path ./my-project",
|
|
146
|
+
" sdtk-code init --runtime claude --runtime-scope user",
|
|
147
|
+
" sdtk-code runtime install --runtime claude --scope project --project-path ./my-project",
|
|
148
|
+
" sdtk-code runtime install --runtime codex --scope user",
|
|
149
|
+
" sdtk-code runtime status --runtime claude --project-path ./my-project",
|
|
150
|
+
" sdtk-code runtime uninstall --runtime codex --all",
|
|
151
|
+
"",
|
|
152
|
+
"Next steps after init:",
|
|
153
|
+
" 1. Review and customize sdtk-spec.config.json for your project.",
|
|
154
|
+
" 2. Create or refresh CODE_WORKFLOW with sdtk-code start once the upstream SDTK-SPEC handoff exists.",
|
|
155
|
+
" Preferred input: CODE_HANDOFF_[FEATURE_KEY].json; compatibility fallback is bounded to missing-handoff cases.",
|
|
156
|
+
" 3. For feature work, refine slices with sdtk-code plan before implementation.",
|
|
157
|
+
" 4. Record build progress with sdtk-code build while execution is in motion.",
|
|
158
|
+
" 5. Capture summarized evidence and review gates with sdtk-code verify before closure.",
|
|
159
|
+
" 6. Record final ship or finish decision with sdtk-code ship.",
|
|
160
|
+
" 7. Use raw code-* skills directly when you intentionally choose expert mode.",
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
console.log(text.join("\n"));
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
module.exports = {
|
|
168
|
+
cmdHelp,
|
|
169
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { parseFlags, validateChoice } = require("../lib/args");
|
|
5
|
+
const { verify, resolvePayloadFile } = require("../lib/toolkit-payload");
|
|
6
|
+
const { runScript } = require("../lib/powershell");
|
|
7
|
+
const { ValidationError } = require("../lib/errors");
|
|
8
|
+
const { VALID_SCOPES, defaultScope, isProjectScopeSupported } = require("../lib/scope");
|
|
9
|
+
|
|
10
|
+
const FLAG_DEFS = {
|
|
11
|
+
runtime: { type: "string" },
|
|
12
|
+
"project-path": { type: "string" },
|
|
13
|
+
"runtime-scope": { type: "string" },
|
|
14
|
+
force: { type: "boolean" },
|
|
15
|
+
"skip-skills": { type: "boolean" },
|
|
16
|
+
"skip-runtime-assets": { type: "boolean" },
|
|
17
|
+
verbose: { type: "boolean" },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const VALID_RUNTIMES = ["codex", "claude"];
|
|
21
|
+
|
|
22
|
+
async function cmdInit(args) {
|
|
23
|
+
const { flags } = parseFlags(args, FLAG_DEFS);
|
|
24
|
+
|
|
25
|
+
const runtime = flags.runtime || "codex";
|
|
26
|
+
validateChoice(runtime, VALID_RUNTIMES, "runtime");
|
|
27
|
+
|
|
28
|
+
const scope = flags["runtime-scope"] || defaultScope(runtime);
|
|
29
|
+
validateChoice(scope, VALID_SCOPES, "runtime-scope");
|
|
30
|
+
if (scope === "project" && !isProjectScopeSupported(runtime)) {
|
|
31
|
+
throw new ValidationError(
|
|
32
|
+
"Codex does not support project-local skills. Use --runtime-scope user instead."
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const skipAssets = flags["skip-runtime-assets"] || flags["skip-skills"];
|
|
37
|
+
if (flags["skip-skills"] && !flags["skip-runtime-assets"]) {
|
|
38
|
+
console.warn("Warning: --skip-skills is deprecated. Use --skip-runtime-assets instead.");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
42
|
+
|
|
43
|
+
verify();
|
|
44
|
+
|
|
45
|
+
const installScript = resolvePayloadFile("toolkit/install.ps1");
|
|
46
|
+
const params = {
|
|
47
|
+
ProjectPath: projectPath,
|
|
48
|
+
Runtime: runtime,
|
|
49
|
+
Scope: scope,
|
|
50
|
+
};
|
|
51
|
+
if (flags.force) {
|
|
52
|
+
params.Force = true;
|
|
53
|
+
}
|
|
54
|
+
if (skipAssets) {
|
|
55
|
+
params.SkipRuntimeAssets = true;
|
|
56
|
+
}
|
|
57
|
+
if (!flags.verbose) {
|
|
58
|
+
params.Quiet = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
console.log("Initializing SDTK-CODE workspace...");
|
|
62
|
+
console.log(` Runtime: ${runtime}`);
|
|
63
|
+
console.log(` Scope: ${scope}`);
|
|
64
|
+
console.log(` Project: ${projectPath}`);
|
|
65
|
+
console.log("");
|
|
66
|
+
|
|
67
|
+
const result = await runScript(installScript, params, { silent: !flags.verbose });
|
|
68
|
+
if (result.exitCode !== 0) {
|
|
69
|
+
if (result.stderr) {
|
|
70
|
+
console.error(result.stderr);
|
|
71
|
+
}
|
|
72
|
+
throw new ValidationError(`Initialization failed (exit code ${result.exitCode}).`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log("");
|
|
76
|
+
console.log("SDTK-CODE workspace initialized successfully.");
|
|
77
|
+
console.log("");
|
|
78
|
+
console.log("Next steps:");
|
|
79
|
+
console.log(" 1. Review and customize sdtk-spec.config.json for your project stack.");
|
|
80
|
+
console.log(" 2. Start the workflow with sdtk-code start once the upstream SDTK-SPEC handoff is ready.");
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = {
|
|
85
|
+
cmdInit,
|
|
86
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
|
|
5
|
+
const { ValidationError } = require("../lib/errors");
|
|
6
|
+
const { runPlan } = require("../lib/workflow-plan");
|
|
7
|
+
|
|
8
|
+
const FLAG_DEFS = {
|
|
9
|
+
"feature-key": { type: "string" },
|
|
10
|
+
"project-path": { type: "string" },
|
|
11
|
+
"in-scope": { type: "string", multiple: true },
|
|
12
|
+
"out-scope": { type: "string", multiple: true },
|
|
13
|
+
slice: { type: "string", multiple: true },
|
|
14
|
+
assumption: { type: "string", multiple: true },
|
|
15
|
+
risk: { type: "string", multiple: true },
|
|
16
|
+
note: { type: "string", multiple: true },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
|
|
20
|
+
|
|
21
|
+
function cmdPlan(args) {
|
|
22
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
23
|
+
if (positional.length > 0) {
|
|
24
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "plan".');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
28
|
+
validatePattern(
|
|
29
|
+
featureKey,
|
|
30
|
+
FEATURE_KEY_RE,
|
|
31
|
+
"feature-key",
|
|
32
|
+
"Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
36
|
+
const result = runPlan(projectPath, featureKey, flags);
|
|
37
|
+
|
|
38
|
+
console.log("SDTK-CODE workflow plan");
|
|
39
|
+
console.log(` Feature key: ${featureKey}`);
|
|
40
|
+
console.log(` Lane: ${result.lane}`);
|
|
41
|
+
console.log(` Mode: ${result.planningMode}`);
|
|
42
|
+
console.log(` Artifact: ${result.artifactPath}`);
|
|
43
|
+
console.log(` Slices: ${result.sliceCount}`);
|
|
44
|
+
console.log(` Next phase: ${result.nextPhase}`);
|
|
45
|
+
console.log(` Engine: ${result.suggestedEngineSkills.join(", ")}`);
|
|
46
|
+
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = {
|
|
51
|
+
cmdPlan,
|
|
52
|
+
};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { parseFlags, requireFlag, validateChoice } = require("../lib/args");
|
|
6
|
+
const { verify, resolvePayloadFile } = require("../lib/toolkit-payload");
|
|
7
|
+
const { runScript } = require("../lib/powershell");
|
|
8
|
+
const { ValidationError } = require("../lib/errors");
|
|
9
|
+
const {
|
|
10
|
+
VALID_SCOPES,
|
|
11
|
+
defaultScope,
|
|
12
|
+
isProjectScopeSupported,
|
|
13
|
+
managedSkillNames,
|
|
14
|
+
resolveSkillsDir,
|
|
15
|
+
} = require("../lib/scope");
|
|
16
|
+
|
|
17
|
+
const FLAG_DEFS = {
|
|
18
|
+
runtime: { type: "string" },
|
|
19
|
+
scope: { type: "string" },
|
|
20
|
+
"project-path": { type: "string" },
|
|
21
|
+
force: { type: "boolean" },
|
|
22
|
+
all: { type: "boolean" },
|
|
23
|
+
verbose: { type: "boolean" },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const VALID_RUNTIMES = ["codex", "claude"];
|
|
27
|
+
const SUBCOMMANDS = ["install", "uninstall", "status"];
|
|
28
|
+
|
|
29
|
+
function validateScopeForRuntime(runtime, scope, label) {
|
|
30
|
+
if (scope === "project" && !isProjectScopeSupported(runtime)) {
|
|
31
|
+
throw new ValidationError(
|
|
32
|
+
`Codex does not support project-local skills. Use --${label} user instead.`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function cmdRuntimeInstall(flags) {
|
|
38
|
+
const runtime = requireFlag(flags, "runtime", "runtime");
|
|
39
|
+
validateChoice(runtime, VALID_RUNTIMES, "runtime");
|
|
40
|
+
|
|
41
|
+
const scope = flags.scope || defaultScope(runtime);
|
|
42
|
+
validateChoice(scope, VALID_SCOPES, "scope");
|
|
43
|
+
validateScopeForRuntime(runtime, scope, "scope");
|
|
44
|
+
|
|
45
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
46
|
+
verify();
|
|
47
|
+
|
|
48
|
+
const scriptName =
|
|
49
|
+
runtime === "claude"
|
|
50
|
+
? "toolkit/scripts/install-claude-skills.ps1"
|
|
51
|
+
: "toolkit/scripts/install-codex-skills.ps1";
|
|
52
|
+
const script = resolvePayloadFile(scriptName);
|
|
53
|
+
const params = { Scope: scope };
|
|
54
|
+
if (runtime === "claude") {
|
|
55
|
+
params.ProjectPath = projectPath;
|
|
56
|
+
}
|
|
57
|
+
if (flags.force) {
|
|
58
|
+
params.Force = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
console.log(`Installing ${runtime} runtime assets...`);
|
|
62
|
+
console.log(` Runtime: ${runtime}`);
|
|
63
|
+
console.log(` Scope: ${scope}`);
|
|
64
|
+
if (runtime === "claude" && scope === "project") {
|
|
65
|
+
console.log(` Project: ${projectPath}`);
|
|
66
|
+
}
|
|
67
|
+
console.log("");
|
|
68
|
+
|
|
69
|
+
const result = await runScript(script, params, { silent: !flags.verbose });
|
|
70
|
+
if (result.exitCode !== 0) {
|
|
71
|
+
if (result.stderr) {
|
|
72
|
+
console.error(result.stderr);
|
|
73
|
+
}
|
|
74
|
+
throw new ValidationError(`Runtime install failed (exit code ${result.exitCode}).`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log("");
|
|
78
|
+
console.log(`${runtime} runtime assets installed successfully.`);
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function cmdRuntimeUninstall(flags) {
|
|
83
|
+
const runtime = requireFlag(flags, "runtime", "runtime");
|
|
84
|
+
validateChoice(runtime, VALID_RUNTIMES, "runtime");
|
|
85
|
+
|
|
86
|
+
const scope = flags.scope || defaultScope(runtime);
|
|
87
|
+
validateChoice(scope, VALID_SCOPES, "scope");
|
|
88
|
+
validateScopeForRuntime(runtime, scope, "scope");
|
|
89
|
+
|
|
90
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
91
|
+
verify();
|
|
92
|
+
|
|
93
|
+
const scriptName =
|
|
94
|
+
runtime === "claude"
|
|
95
|
+
? "toolkit/scripts/uninstall-claude-skills.ps1"
|
|
96
|
+
: "toolkit/scripts/uninstall-codex-skills.ps1";
|
|
97
|
+
const script = resolvePayloadFile(scriptName);
|
|
98
|
+
const params = { All: true };
|
|
99
|
+
if (runtime === "claude") {
|
|
100
|
+
params.Scope = scope;
|
|
101
|
+
params.ProjectPath = projectPath;
|
|
102
|
+
}
|
|
103
|
+
if (flags.all) {
|
|
104
|
+
params.All = true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.log(`Uninstalling ${runtime} runtime assets...`);
|
|
108
|
+
console.log(` Runtime: ${runtime}`);
|
|
109
|
+
console.log(` Scope: ${scope}`);
|
|
110
|
+
if (runtime === "claude" && scope === "project") {
|
|
111
|
+
console.log(` Project: ${projectPath}`);
|
|
112
|
+
}
|
|
113
|
+
console.log("");
|
|
114
|
+
|
|
115
|
+
const result = await runScript(script, params, { silent: !flags.verbose });
|
|
116
|
+
if (result.exitCode !== 0) {
|
|
117
|
+
if (result.stderr) {
|
|
118
|
+
console.error(result.stderr);
|
|
119
|
+
}
|
|
120
|
+
throw new ValidationError(`Runtime uninstall failed (exit code ${result.exitCode}).`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
console.log("");
|
|
124
|
+
console.log(`${runtime} runtime assets uninstalled successfully.`);
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function cmdRuntimeStatus(flags) {
|
|
129
|
+
const runtime = requireFlag(flags, "runtime", "runtime");
|
|
130
|
+
validateChoice(runtime, VALID_RUNTIMES, "runtime");
|
|
131
|
+
|
|
132
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
133
|
+
const scopes = runtime === "claude" ? ["project", "user"] : ["user"];
|
|
134
|
+
|
|
135
|
+
console.log(`Runtime: ${runtime}`);
|
|
136
|
+
console.log("");
|
|
137
|
+
|
|
138
|
+
for (const scope of scopes) {
|
|
139
|
+
const skillsDir = resolveSkillsDir(runtime, scope, projectPath);
|
|
140
|
+
const managed = managedSkillNames(runtime);
|
|
141
|
+
const exists = fs.existsSync(skillsDir);
|
|
142
|
+
let installedNames = [];
|
|
143
|
+
|
|
144
|
+
if (exists) {
|
|
145
|
+
try {
|
|
146
|
+
const entries = fs.readdirSync(skillsDir, { withFileTypes: true });
|
|
147
|
+
installedNames = entries
|
|
148
|
+
.filter((entry) => entry.isDirectory() && managed.includes(entry.name))
|
|
149
|
+
.map((entry) => entry.name)
|
|
150
|
+
.sort();
|
|
151
|
+
} catch {
|
|
152
|
+
installedNames = [];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const skillCount = installedNames.length;
|
|
157
|
+
const allInstalled = skillCount === managed.length;
|
|
158
|
+
const hasManagedSkills = skillCount > 0;
|
|
159
|
+
const status = !exists || !hasManagedSkills
|
|
160
|
+
? "not installed"
|
|
161
|
+
: allInstalled
|
|
162
|
+
? `installed (${skillCount}/${managed.length} SDTK-CODE skills)`
|
|
163
|
+
: `partial (${skillCount}/${managed.length} SDTK-CODE skills)`;
|
|
164
|
+
|
|
165
|
+
console.log(` Scope: ${scope}`);
|
|
166
|
+
console.log(` Path: ${skillsDir}`);
|
|
167
|
+
console.log(` Status: ${status}`);
|
|
168
|
+
if (exists && hasManagedSkills && skillCount < managed.length) {
|
|
169
|
+
const missing = managed.filter((name) => !installedNames.includes(name));
|
|
170
|
+
console.log(` Missing: ${missing.join(", ")}`);
|
|
171
|
+
}
|
|
172
|
+
console.log("");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function cmdRuntime(args) {
|
|
179
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
180
|
+
const subcommand = positional[0];
|
|
181
|
+
|
|
182
|
+
if (!subcommand) {
|
|
183
|
+
throw new ValidationError(
|
|
184
|
+
`Missing subcommand. Usage: sdtk-code runtime <${SUBCOMMANDS.join("|")}> [options]`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
if (!SUBCOMMANDS.includes(subcommand)) {
|
|
188
|
+
throw new ValidationError(
|
|
189
|
+
`Unknown subcommand: "${subcommand}". Must be one of: ${SUBCOMMANDS.join(", ")}`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
switch (subcommand) {
|
|
194
|
+
case "install":
|
|
195
|
+
return cmdRuntimeInstall(flags);
|
|
196
|
+
case "uninstall":
|
|
197
|
+
return cmdRuntimeUninstall(flags);
|
|
198
|
+
case "status":
|
|
199
|
+
return cmdRuntimeStatus(flags);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
module.exports = {
|
|
204
|
+
cmdRuntime,
|
|
205
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { parseFlags, requireFlag, validatePattern } = require("../lib/args");
|
|
5
|
+
const { ValidationError } = require("../lib/errors");
|
|
6
|
+
const { runShip } = require("../lib/workflow-ship");
|
|
7
|
+
|
|
8
|
+
const FLAG_DEFS = {
|
|
9
|
+
"feature-key": { type: "string" },
|
|
10
|
+
"project-path": { type: "string" },
|
|
11
|
+
decision: { type: "string" },
|
|
12
|
+
preflight: { type: "string", multiple: true },
|
|
13
|
+
"follow-up": { type: "string", multiple: true },
|
|
14
|
+
note: { type: "string", multiple: true },
|
|
15
|
+
"debug-note": { type: "string", multiple: true },
|
|
16
|
+
blocked: { type: "boolean" },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
|
|
20
|
+
|
|
21
|
+
function cmdShip(args) {
|
|
22
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
23
|
+
if (positional.length > 0) {
|
|
24
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "ship".');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
28
|
+
validatePattern(
|
|
29
|
+
featureKey,
|
|
30
|
+
FEATURE_KEY_RE,
|
|
31
|
+
"feature-key",
|
|
32
|
+
"Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
|
|
33
|
+
);
|
|
34
|
+
requireFlag(flags, "decision", "decision");
|
|
35
|
+
|
|
36
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
37
|
+
const result = runShip(projectPath, featureKey, flags);
|
|
38
|
+
|
|
39
|
+
console.log("SDTK-CODE workflow ship");
|
|
40
|
+
console.log(` Feature key: ${featureKey}`);
|
|
41
|
+
console.log(` Lane: ${result.lane}`);
|
|
42
|
+
console.log(` Decision: ${result.decision}`);
|
|
43
|
+
console.log(` Status: ${result.phaseStatus}`);
|
|
44
|
+
console.log(` Artifact: ${result.artifactPath}`);
|
|
45
|
+
console.log(` Preflight: ${result.preflightCount}`);
|
|
46
|
+
console.log(` Next phase: ${result.nextPhase}`);
|
|
47
|
+
console.log(` Engine: ${result.suggestedEngineSkills.join(", ")}`);
|
|
48
|
+
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
cmdShip,
|
|
54
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { parseFlags, requireFlag, validateChoice, validatePattern } = require("../lib/args");
|
|
5
|
+
const { ValidationError } = require("../lib/errors");
|
|
6
|
+
const { runIntake } = require("../lib/workflow-intake");
|
|
7
|
+
const { createOrUpdateWorkflowArtifact } = require("../lib/workflow-artifact");
|
|
8
|
+
|
|
9
|
+
const FLAG_DEFS = {
|
|
10
|
+
lane: { type: "string" },
|
|
11
|
+
"feature-key": { type: "string" },
|
|
12
|
+
"project-path": { type: "string" },
|
|
13
|
+
force: { type: "boolean" },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const VALID_LANES = ["feature", "bugfix"];
|
|
17
|
+
const FEATURE_KEY_RE = /^[A-Z0-9_]+$/;
|
|
18
|
+
|
|
19
|
+
function formatIntakeSource(intake) {
|
|
20
|
+
return intake.intakeSource === "formal_handoff"
|
|
21
|
+
? "formal SDTK-SPEC handoff"
|
|
22
|
+
: "legacy compatibility intake";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function buildBlockedIntakeMessage(intake, artifactPath) {
|
|
26
|
+
if (intake.blockingState === "blocked_upstream_handoff") {
|
|
27
|
+
const details = intake.blockingDetails.map((entry) => `- ${entry}`).join("\n");
|
|
28
|
+
return `${intake.blockingMessage}\n${details}\nArtifact written to: ${artifactPath}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (intake.blockingState === "invalid_handoff_contract") {
|
|
32
|
+
return `${intake.blockingMessage}\nArtifact written to: ${artifactPath}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const details = intake.missingInputs.map((entry) => `- ${entry.key}: ${entry.path}`).join("\n");
|
|
36
|
+
return `Workflow intake blocked. Missing required inputs:\n${details}\nArtifact written to: ${artifactPath}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function cmdStart(args) {
|
|
40
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
41
|
+
if (positional.length > 0) {
|
|
42
|
+
throw new ValidationError('Unexpected positional arguments. Use flags only for "start".');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const lane = requireFlag(flags, "lane", "lane");
|
|
46
|
+
validateChoice(lane, VALID_LANES, "lane");
|
|
47
|
+
|
|
48
|
+
const featureKey = requireFlag(flags, "feature-key", "feature-key");
|
|
49
|
+
validatePattern(
|
|
50
|
+
featureKey,
|
|
51
|
+
FEATURE_KEY_RE,
|
|
52
|
+
"feature-key",
|
|
53
|
+
"Must use UPPER_SNAKE_CASE, for example ORDER_MGMT."
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
57
|
+
const intake = runIntake(projectPath, featureKey, lane);
|
|
58
|
+
const artifactPath = createOrUpdateWorkflowArtifact({
|
|
59
|
+
featureKey,
|
|
60
|
+
lane,
|
|
61
|
+
projectPath,
|
|
62
|
+
force: flags.force,
|
|
63
|
+
managedBlocks: ["METADATA", "INPUTS", "STATUS"],
|
|
64
|
+
...intake,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
console.log("SDTK-CODE workflow start");
|
|
68
|
+
console.log(` Feature key: ${featureKey}`);
|
|
69
|
+
console.log(` Lane: ${lane}`);
|
|
70
|
+
console.log(` Intake: ${formatIntakeSource(intake)}`);
|
|
71
|
+
console.log(` Handoff: ${intake.handoffStatus}`);
|
|
72
|
+
console.log(` Outcome: ${intake.intakeOutcome}`);
|
|
73
|
+
console.log(` Artifact: ${artifactPath}`);
|
|
74
|
+
console.log(` Next phase: ${intake.nextPhase}`);
|
|
75
|
+
console.log(` Engine: ${intake.suggestedEngineSkills.join(", ")}`);
|
|
76
|
+
for (const warning of intake.compatibilityWarnings || []) {
|
|
77
|
+
console.log(` Note: ${warning}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (intake.blocked) {
|
|
81
|
+
throw new ValidationError(buildBlockedIntakeMessage(intake, artifactPath));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
cmdStart,
|
|
89
|
+
};
|