sdtk-code-kit 0.1.0 → 0.1.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.
- package/README.md +140 -91
- package/assets/manifest/toolkit-bundle.manifest.json +47 -47
- package/assets/manifest/toolkit-bundle.sha256.txt +23 -23
- package/assets/toolkit/toolkit/AGENTS.md +219 -210
- package/assets/toolkit/toolkit/install.ps1 +1 -8
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +30 -7
- package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +31 -2
- package/assets/toolkit/toolkit/sdtk-spec.config.json +1 -1
- package/assets/toolkit/toolkit/skills/code-brainstorm/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-debug/SKILL.md +1 -2
- package/assets/toolkit/toolkit/skills/code-debug/references/root-cause-tracing.md +0 -1
- package/assets/toolkit/toolkit/skills/code-execute/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-finish/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-parallel/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-parallel/references/code-quality-reviewer-prompt.md +0 -1
- package/assets/toolkit/toolkit/skills/code-parallel/references/implementer-prompt.md +0 -1
- package/assets/toolkit/toolkit/skills/code-parallel/references/spec-reviewer-prompt.md +0 -1
- package/assets/toolkit/toolkit/skills/code-plan/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-review/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-review/references/checklist.md +0 -1
- package/assets/toolkit/toolkit/skills/code-review/references/code-reviewer.md +0 -1
- package/assets/toolkit/toolkit/skills/code-ship/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-tdd/SKILL.md +1 -2
- package/assets/toolkit/toolkit/skills/code-tdd/references/testing-anti-patterns.md +0 -1
- package/assets/toolkit/toolkit/skills/code-verify/SKILL.md +0 -1
- package/assets/toolkit/toolkit/skills/code-worktree/SKILL.md +13 -14
- package/package.json +34 -34
- package/src/commands/help.js +218 -169
- package/src/commands/init.js +10 -1
- package/src/commands/plan.js +1 -0
- package/src/commands/runtime.js +27 -8
- package/src/commands/ship.js +5 -0
- package/src/commands/update.js +11 -0
- package/src/commands/verify.js +9 -0
- package/src/index.js +73 -70
- package/src/lib/scope.js +19 -2
- package/src/lib/update.js +337 -0
- package/src/lib/workflow-artifact.js +57 -14
- package/src/lib/workflow-handoff.js +510 -0
- package/src/lib/workflow-intake.js +2 -1
- package/src/lib/workflow-plan.js +102 -5
- package/src/lib/workflow-review-packet.js +561 -0
- package/src/lib/workflow-ship.js +53 -3
- package/src/lib/workflow-verify.js +356 -212
package/src/index.js
CHANGED
|
@@ -1,70 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { cmdBuild } = require("./commands/build");
|
|
4
|
-
const { cmdHelp } = require("./commands/help");
|
|
5
|
-
const { cmdInit } = require("./commands/init");
|
|
6
|
-
const { cmdPlan } = require("./commands/plan");
|
|
7
|
-
const { cmdRuntime } = require("./commands/runtime");
|
|
8
|
-
const { cmdShip } = require("./commands/ship");
|
|
9
|
-
const { cmdStart } = require("./commands/start");
|
|
10
|
-
const {
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { cmdBuild } = require("./commands/build");
|
|
4
|
+
const { cmdHelp } = require("./commands/help");
|
|
5
|
+
const { cmdInit } = require("./commands/init");
|
|
6
|
+
const { cmdPlan } = require("./commands/plan");
|
|
7
|
+
const { cmdRuntime } = require("./commands/runtime");
|
|
8
|
+
const { cmdShip } = require("./commands/ship");
|
|
9
|
+
const { cmdStart } = require("./commands/start");
|
|
10
|
+
const { cmdUpdate } = require("./commands/update");
|
|
11
|
+
const { cmdVerify } = require("./commands/verify");
|
|
12
|
+
const { ValidationError } = require("./lib/errors");
|
|
13
|
+
|
|
14
|
+
function getVersion() {
|
|
15
|
+
const pkg = require("../package.json");
|
|
16
|
+
return pkg.version;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function parseCommand(argv) {
|
|
20
|
+
if (!argv || argv.length === 0) {
|
|
21
|
+
return { command: "help", args: [] };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const [first, ...rest] = argv;
|
|
25
|
+
if (first === "-h" || first === "--help") {
|
|
26
|
+
return { command: "help", args: [] };
|
|
27
|
+
}
|
|
28
|
+
if (first === "-v" || first === "--version") {
|
|
29
|
+
return { command: "version", args: [] };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return { command: first, args: rest };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const COMMANDS = new Set(["help", "version", "init", "runtime", "start", "plan", "build", "verify", "ship", "update"]);
|
|
36
|
+
|
|
37
|
+
async function run(argv) {
|
|
38
|
+
const { command, args } = parseCommand(argv);
|
|
39
|
+
|
|
40
|
+
if (!COMMANDS.has(command)) {
|
|
41
|
+
throw new ValidationError(
|
|
42
|
+
`Unknown command: "${command}". Run "sdtk-code --help" for available commands.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
switch (command) {
|
|
47
|
+
case "help":
|
|
48
|
+
return cmdHelp();
|
|
49
|
+
case "version":
|
|
50
|
+
console.log(`sdtk-code-kit ${getVersion()}`);
|
|
51
|
+
return 0;
|
|
52
|
+
case "init":
|
|
53
|
+
return cmdInit(args);
|
|
54
|
+
case "runtime":
|
|
55
|
+
return cmdRuntime(args);
|
|
56
|
+
case "start":
|
|
57
|
+
return cmdStart(args);
|
|
58
|
+
case "plan":
|
|
59
|
+
return cmdPlan(args);
|
|
60
|
+
case "build":
|
|
61
|
+
return cmdBuild(args);
|
|
62
|
+
case "verify":
|
|
63
|
+
return cmdVerify(args);
|
|
64
|
+
case "ship":
|
|
65
|
+
return cmdShip(args);
|
|
66
|
+
case "update":
|
|
67
|
+
return cmdUpdate(args);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = {
|
|
72
|
+
run,
|
|
73
|
+
};
|
package/src/lib/scope.js
CHANGED
|
@@ -10,7 +10,21 @@ function defaultScope(runtime) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function isProjectScopeSupported(runtime) {
|
|
13
|
-
return runtime === "claude";
|
|
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();
|
|
14
28
|
}
|
|
15
29
|
|
|
16
30
|
function resolveSkillsDir(runtime, scope, projectPath) {
|
|
@@ -21,7 +35,7 @@ function resolveSkillsDir(runtime, scope, projectPath) {
|
|
|
21
35
|
return path.join(projectPath || process.cwd(), ".claude", "skills");
|
|
22
36
|
}
|
|
23
37
|
|
|
24
|
-
const codexHome =
|
|
38
|
+
const codexHome = resolveCodexHome(scope, projectPath);
|
|
25
39
|
return path.join(codexHome, "skills");
|
|
26
40
|
}
|
|
27
41
|
|
|
@@ -50,6 +64,9 @@ module.exports = {
|
|
|
50
64
|
VALID_SCOPES,
|
|
51
65
|
defaultScope,
|
|
52
66
|
isProjectScopeSupported,
|
|
67
|
+
resolveCodexHome,
|
|
68
|
+
resolveCodexProjectHome,
|
|
69
|
+
resolveCodexUserHome,
|
|
53
70
|
resolveSkillsDir,
|
|
54
71
|
managedSkillNames,
|
|
55
72
|
};
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { spawn } = require("child_process");
|
|
5
|
+
const { parseFlags, validateChoice } = require("./args");
|
|
6
|
+
const { CliError, DependencyError, ValidationError } = require("./errors");
|
|
7
|
+
const { VALID_SCOPES, defaultScope, isProjectScopeSupported } = require("./scope");
|
|
8
|
+
|
|
9
|
+
const PACKAGE_NAME = "sdtk-code-kit";
|
|
10
|
+
const CLI_NAME = "sdtk-code";
|
|
11
|
+
const CLI_BIN = path.resolve(__dirname, "..", "..", "bin", "sdtk-code.js");
|
|
12
|
+
const NPM_BIN = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
13
|
+
const NPM_DISPLAY = "npm";
|
|
14
|
+
const NPM_VIEW_ARGS = ["view", PACKAGE_NAME, "version"];
|
|
15
|
+
const VALID_RUNTIMES = ["codex", "claude"];
|
|
16
|
+
const VERSION_PATTERN = /^\d+\.\d+\.\d+$/;
|
|
17
|
+
const FLAG_DEFS = {
|
|
18
|
+
version: { type: "string" },
|
|
19
|
+
runtime: { type: "string" },
|
|
20
|
+
scope: { type: "string" },
|
|
21
|
+
"project-path": { type: "string" },
|
|
22
|
+
"check-only": { type: "boolean" },
|
|
23
|
+
"skip-project-files": { type: "boolean" },
|
|
24
|
+
"skip-runtime-assets": { type: "boolean" },
|
|
25
|
+
verbose: { type: "boolean" },
|
|
26
|
+
};
|
|
27
|
+
const pkg = require("../../package.json");
|
|
28
|
+
|
|
29
|
+
let commandExecutor = defaultCommandExecutor;
|
|
30
|
+
|
|
31
|
+
function defaultCommandExecutor(command, args, options = {}) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const child = spawn(command, args, {
|
|
34
|
+
cwd: options.cwd || process.cwd(),
|
|
35
|
+
env: options.env || process.env,
|
|
36
|
+
shell: options.shell || false,
|
|
37
|
+
windowsHide: true,
|
|
38
|
+
});
|
|
39
|
+
let stdout = "";
|
|
40
|
+
let stderr = "";
|
|
41
|
+
|
|
42
|
+
child.stdout.on("data", (chunk) => {
|
|
43
|
+
const text = chunk.toString();
|
|
44
|
+
stdout += text;
|
|
45
|
+
if (options.verbose) {
|
|
46
|
+
process.stdout.write(text);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
child.stderr.on("data", (chunk) => {
|
|
50
|
+
const text = chunk.toString();
|
|
51
|
+
stderr += text;
|
|
52
|
+
if (options.verbose) {
|
|
53
|
+
process.stderr.write(text);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
child.on("error", (error) => {
|
|
57
|
+
if (error && error.code === "ENOENT") {
|
|
58
|
+
reject(new DependencyError(`Required command not found in PATH: ${command}`));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
reject(error);
|
|
62
|
+
});
|
|
63
|
+
child.on("close", (exitCode) => {
|
|
64
|
+
resolve({
|
|
65
|
+
exitCode: typeof exitCode === "number" ? exitCode : 1,
|
|
66
|
+
stdout,
|
|
67
|
+
stderr,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function setCommandExecutorForTests(executor) {
|
|
74
|
+
commandExecutor = executor || defaultCommandExecutor;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function resetCommandExecutorForTests() {
|
|
78
|
+
commandExecutor = defaultCommandExecutor;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function quote(value) {
|
|
82
|
+
const text = String(value);
|
|
83
|
+
return /[\s"]/u.test(text) ? JSON.stringify(text) : text;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function formatCommand(command, args) {
|
|
87
|
+
return [command, ...args].map((value) => quote(value)).join(" ");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function validateVersion(targetVersion) {
|
|
91
|
+
if (targetVersion !== "latest" && !VERSION_PATTERN.test(targetVersion)) {
|
|
92
|
+
throw new ValidationError(
|
|
93
|
+
`Invalid value for --version: "${targetVersion}". Must be "latest" or x.y.z.`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function extractResolvedVersion(stdout) {
|
|
99
|
+
const lines = String(stdout || "")
|
|
100
|
+
.split(/\r?\n/u)
|
|
101
|
+
.map((line) => line.trim())
|
|
102
|
+
.filter(Boolean);
|
|
103
|
+
const candidate = (lines[lines.length - 1] || "").replace(/^['"]|['"]$/gu, "");
|
|
104
|
+
if (!VERSION_PATTERN.test(candidate)) {
|
|
105
|
+
throw new CliError(
|
|
106
|
+
`npm registry lookup returned an invalid version for ${PACKAGE_NAME}: "${candidate || "<empty>"}"`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return candidate;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function resolveTargetVersion(options) {
|
|
113
|
+
if (options.requestedVersion !== "latest") {
|
|
114
|
+
return options.requestedVersion;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let result;
|
|
118
|
+
try {
|
|
119
|
+
result = await commandExecutor(NPM_BIN, NPM_VIEW_ARGS, {
|
|
120
|
+
verbose: options.verbose,
|
|
121
|
+
shell: process.platform === "win32",
|
|
122
|
+
});
|
|
123
|
+
} catch (error) {
|
|
124
|
+
throw new CliError(
|
|
125
|
+
`npm registry lookup failed for ${PACKAGE_NAME} while resolving --version latest.\n${error.message}`,
|
|
126
|
+
error.exitCode || 4
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (result.exitCode !== 0) {
|
|
131
|
+
const detail = (result.stderr || result.stdout || "").trim();
|
|
132
|
+
throw new CliError(
|
|
133
|
+
`npm registry lookup failed for ${PACKAGE_NAME} while resolving --version latest (exit code ${result.exitCode}).${detail ? `\n${detail}` : ""}`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
return extractResolvedVersion(result.stdout);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
throw new CliError(
|
|
141
|
+
`npm registry lookup failed for ${PACKAGE_NAME} while resolving --version latest.\n${error.message}`,
|
|
142
|
+
error.exitCode || 4
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function buildPlan(options) {
|
|
148
|
+
const npmArgs = ["install", "-g", `${PACKAGE_NAME}@${options.targetVersion}`];
|
|
149
|
+
const plan = {
|
|
150
|
+
installedVersion: pkg.version,
|
|
151
|
+
requestedVersion: options.requestedVersion,
|
|
152
|
+
targetVersion: options.targetVersion,
|
|
153
|
+
updateNeeded: pkg.version !== options.targetVersion,
|
|
154
|
+
npmArgs,
|
|
155
|
+
npmCommand: formatCommand(NPM_DISPLAY, npmArgs),
|
|
156
|
+
runtime: options.runtime,
|
|
157
|
+
scope: options.scope,
|
|
158
|
+
projectPath: options.projectPath,
|
|
159
|
+
checkOnly: options.checkOnly,
|
|
160
|
+
projectRefreshArgs: null,
|
|
161
|
+
runtimeRefreshArgs: null,
|
|
162
|
+
projectRefreshCommand: "skipped (no --runtime provided)",
|
|
163
|
+
runtimeRefreshCommand: "skipped (no --runtime provided)",
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (!options.runtime) {
|
|
167
|
+
return plan;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (options.skipProjectFiles) {
|
|
171
|
+
plan.projectRefreshCommand = "skipped (--skip-project-files)";
|
|
172
|
+
} else {
|
|
173
|
+
const initArgs = [
|
|
174
|
+
"init",
|
|
175
|
+
"--runtime",
|
|
176
|
+
options.runtime,
|
|
177
|
+
"--runtime-scope",
|
|
178
|
+
options.scope,
|
|
179
|
+
"--project-path",
|
|
180
|
+
options.projectPath,
|
|
181
|
+
"--force",
|
|
182
|
+
"--skip-runtime-assets",
|
|
183
|
+
];
|
|
184
|
+
if (options.verbose) {
|
|
185
|
+
initArgs.push("--verbose");
|
|
186
|
+
}
|
|
187
|
+
plan.projectRefreshArgs = initArgs;
|
|
188
|
+
plan.projectRefreshCommand = formatCommand(CLI_NAME, initArgs);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (options.skipRuntimeAssets) {
|
|
192
|
+
plan.runtimeRefreshCommand = "skipped (--skip-runtime-assets)";
|
|
193
|
+
} else {
|
|
194
|
+
const runtimeArgs = ["runtime", "install", "--runtime", options.runtime, "--scope", options.scope, "--force"];
|
|
195
|
+
if (options.scope === "project") {
|
|
196
|
+
runtimeArgs.push("--project-path", options.projectPath);
|
|
197
|
+
}
|
|
198
|
+
if (options.verbose) {
|
|
199
|
+
runtimeArgs.push("--verbose");
|
|
200
|
+
}
|
|
201
|
+
plan.runtimeRefreshArgs = runtimeArgs;
|
|
202
|
+
plan.runtimeRefreshCommand = formatCommand(CLI_NAME, runtimeArgs);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return plan;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function parseUpdateOptions(args) {
|
|
209
|
+
const { flags, positional } = parseFlags(args, FLAG_DEFS);
|
|
210
|
+
|
|
211
|
+
if (positional.length > 0) {
|
|
212
|
+
throw new ValidationError(`Unexpected arguments: ${positional.join(" ")}`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const requestedVersion = flags.version || "latest";
|
|
216
|
+
validateVersion(requestedVersion);
|
|
217
|
+
|
|
218
|
+
const runtime = flags.runtime;
|
|
219
|
+
if (runtime) {
|
|
220
|
+
validateChoice(runtime, VALID_RUNTIMES, "runtime");
|
|
221
|
+
}
|
|
222
|
+
if (flags.scope && !runtime) {
|
|
223
|
+
throw new ValidationError("--scope requires --runtime.");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const scope = runtime ? (flags.scope || defaultScope(runtime)) : undefined;
|
|
227
|
+
if (scope) {
|
|
228
|
+
validateChoice(scope, VALID_SCOPES, "scope");
|
|
229
|
+
if (scope === "project" && !isProjectScopeSupported(runtime)) {
|
|
230
|
+
throw new ValidationError(
|
|
231
|
+
`${runtime} does not support project-local runtime assets. Use --scope user instead.`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
requestedVersion,
|
|
238
|
+
runtime,
|
|
239
|
+
scope,
|
|
240
|
+
projectPath: path.resolve(flags["project-path"] || process.cwd()),
|
|
241
|
+
checkOnly: flags["check-only"],
|
|
242
|
+
skipProjectFiles: flags["skip-project-files"],
|
|
243
|
+
skipRuntimeAssets: flags["skip-runtime-assets"],
|
|
244
|
+
verbose: flags.verbose,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function printPlan(plan) {
|
|
249
|
+
console.log("SDTK-CODE update plan");
|
|
250
|
+
console.log(` Installed package version: ${plan.installedVersion}`);
|
|
251
|
+
console.log(` Requested package version: ${plan.requestedVersion}`);
|
|
252
|
+
console.log(` Target package version: ${plan.targetVersion}`);
|
|
253
|
+
console.log(
|
|
254
|
+
` Package update needed: ${plan.updateNeeded ? "yes" : `no (already installed: ${plan.installedVersion})`}`
|
|
255
|
+
);
|
|
256
|
+
console.log(` Package refresh command: ${plan.npmCommand}`);
|
|
257
|
+
if (plan.runtime) {
|
|
258
|
+
console.log(` Runtime: ${plan.runtime}`);
|
|
259
|
+
console.log(` Scope: ${plan.scope}`);
|
|
260
|
+
console.log(` Project path: ${plan.projectPath}`);
|
|
261
|
+
}
|
|
262
|
+
console.log(` Project file refresh: ${plan.projectRefreshCommand}`);
|
|
263
|
+
console.log(` Runtime asset refresh: ${plan.runtimeRefreshCommand}`);
|
|
264
|
+
console.log(
|
|
265
|
+
` Mode: ${plan.checkOnly ? "check-only (no changes applied)" : "apply"}`
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async function runCommand(label, command, args, options) {
|
|
270
|
+
const result = await commandExecutor(command, args, options);
|
|
271
|
+
if (result.exitCode !== 0) {
|
|
272
|
+
const detail = (result.stderr || result.stdout || "").trim();
|
|
273
|
+
throw new CliError(
|
|
274
|
+
`${label} failed (exit code ${result.exitCode}).${detail ? `\n${detail}` : ""}`
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async function applyPlan(plan, options) {
|
|
281
|
+
console.log("");
|
|
282
|
+
console.log("Applying SDTK-CODE update...");
|
|
283
|
+
if (plan.updateNeeded) {
|
|
284
|
+
console.log(` npm refresh: ${plan.npmCommand}`);
|
|
285
|
+
await runCommand("npm package refresh", NPM_BIN, plan.npmArgs, {
|
|
286
|
+
verbose: options.verbose,
|
|
287
|
+
shell: process.platform === "win32",
|
|
288
|
+
});
|
|
289
|
+
} else {
|
|
290
|
+
console.log(` npm refresh: skipped (installed package already matches ${plan.targetVersion})`);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (plan.projectRefreshArgs) {
|
|
294
|
+
console.log(` project refresh: ${plan.projectRefreshCommand}`);
|
|
295
|
+
await runCommand("project file refresh", process.execPath, [CLI_BIN, ...plan.projectRefreshArgs], {
|
|
296
|
+
verbose: options.verbose,
|
|
297
|
+
});
|
|
298
|
+
} else {
|
|
299
|
+
console.log(` project refresh: ${plan.projectRefreshCommand}`);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (plan.runtimeRefreshArgs) {
|
|
303
|
+
console.log(` runtime refresh: ${plan.runtimeRefreshCommand}`);
|
|
304
|
+
await runCommand("runtime asset refresh", process.execPath, [CLI_BIN, ...plan.runtimeRefreshArgs], {
|
|
305
|
+
verbose: options.verbose,
|
|
306
|
+
});
|
|
307
|
+
} else {
|
|
308
|
+
console.log(` runtime refresh: ${plan.runtimeRefreshCommand}`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
console.log("");
|
|
312
|
+
console.log("SDTK-CODE update completed successfully.");
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
async function executeUpdate(args) {
|
|
316
|
+
const options = parseUpdateOptions(args);
|
|
317
|
+
const targetVersion = await resolveTargetVersion(options);
|
|
318
|
+
const plan = buildPlan({ ...options, targetVersion });
|
|
319
|
+
printPlan(plan);
|
|
320
|
+
|
|
321
|
+
if (options.checkOnly) {
|
|
322
|
+
return 0;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
await applyPlan(plan, options);
|
|
326
|
+
return 0;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
module.exports = {
|
|
330
|
+
buildPlan,
|
|
331
|
+
executeUpdate,
|
|
332
|
+
formatCommand,
|
|
333
|
+
parseUpdateOptions,
|
|
334
|
+
resetCommandExecutorForTests,
|
|
335
|
+
resolveTargetVersion,
|
|
336
|
+
setCommandExecutorForTests,
|
|
337
|
+
};
|
|
@@ -97,8 +97,21 @@ function renderPlanBlock(data) {
|
|
|
97
97
|
if (Array.isArray(data.planNotes) && data.planNotes.length > 0) {
|
|
98
98
|
planningNotes.push(...data.planNotes);
|
|
99
99
|
}
|
|
100
|
+
const candidateSlices = Array.isArray(data.candidateSlices) ? data.candidateSlices : [];
|
|
101
|
+
const candidatePlanningNotes = Array.isArray(data.candidatePlanningNotes)
|
|
102
|
+
? data.candidatePlanningNotes
|
|
103
|
+
: [];
|
|
104
|
+
const shouldRenderSeededCandidates =
|
|
105
|
+
data.currentPhase === "start" &&
|
|
106
|
+
data.lane === "feature" &&
|
|
107
|
+
data.slices.length === 0 &&
|
|
108
|
+
candidateSlices.length > 0;
|
|
109
|
+
|
|
110
|
+
if (shouldRenderSeededCandidates) {
|
|
111
|
+
planningNotes.unshift(...candidatePlanningNotes);
|
|
112
|
+
}
|
|
100
113
|
|
|
101
|
-
|
|
114
|
+
const lines = [
|
|
102
115
|
"<!-- SDTK-CODE:PLAN:START -->",
|
|
103
116
|
"## 3. Scope Lock",
|
|
104
117
|
"### In Scope",
|
|
@@ -114,17 +127,36 @@ function renderPlanBlock(data) {
|
|
|
114
127
|
renderBulletList(data.risks, "No explicit planning risks recorded."),
|
|
115
128
|
"",
|
|
116
129
|
"## 4. Plan / Slices",
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
if (shouldRenderSeededCandidates) {
|
|
133
|
+
lines.push(
|
|
134
|
+
"### Seeded Candidate Slices From Formal Handoff",
|
|
135
|
+
renderBulletList(candidateSlices, "No candidate slices seeded from the formal handoff."),
|
|
136
|
+
"",
|
|
137
|
+
"### Finalized Slices After `plan`",
|
|
138
|
+
renderBulletList(data.slices, "Pending confirmation during workflow planning."),
|
|
139
|
+
""
|
|
140
|
+
);
|
|
141
|
+
} else {
|
|
142
|
+
lines.push(
|
|
143
|
+
renderBulletList(
|
|
144
|
+
data.slices,
|
|
145
|
+
data.lane === "bugfix"
|
|
146
|
+
? "Lightweight bugfix planning not recorded yet."
|
|
147
|
+
: "Pending lane-specific planning or build guidance."
|
|
148
|
+
),
|
|
149
|
+
""
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
lines.push(
|
|
124
154
|
"### Planning Notes",
|
|
125
155
|
renderBulletList(planningNotes, "No additional planning notes recorded."),
|
|
126
|
-
"<!-- SDTK-CODE:PLAN:END -->"
|
|
127
|
-
|
|
156
|
+
"<!-- SDTK-CODE:PLAN:END -->"
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
return lines.join("\n");
|
|
128
160
|
}
|
|
129
161
|
|
|
130
162
|
function renderBuildBlock(data) {
|
|
@@ -178,6 +210,11 @@ function renderVerifyBlock(data) {
|
|
|
178
210
|
return [
|
|
179
211
|
"<!-- SDTK-CODE:VERIFY:START -->",
|
|
180
212
|
"## 6. Evidence And Review Notes",
|
|
213
|
+
"### Review Packet",
|
|
214
|
+
data.reviewPacketPath
|
|
215
|
+
? `- Review packet: \`${data.reviewPacketPath}\``
|
|
216
|
+
: "- Review packet not generated yet.",
|
|
217
|
+
"",
|
|
181
218
|
"### Evidence Summary",
|
|
182
219
|
renderEvidenceList(data.evidenceEntries),
|
|
183
220
|
"",
|
|
@@ -225,10 +262,13 @@ function renderShipBlock(data) {
|
|
|
225
262
|
}
|
|
226
263
|
|
|
227
264
|
function renderManagedBlocks(data) {
|
|
228
|
-
const suggestedEngine = data.suggestedEngineSkills
|
|
229
|
-
.map((value) => `\`${value}\``)
|
|
230
|
-
.join(", ");
|
|
231
265
|
const currentPhase = data.currentPhase || "start";
|
|
266
|
+
const isClosedWorkflow = data.nextPhase === "none";
|
|
267
|
+
const nextPhaseLabel = isClosedWorkflow ? "none (workflow closed)" : data.nextPhase;
|
|
268
|
+
const suggestedEngine =
|
|
269
|
+
isClosedWorkflow || !Array.isArray(data.suggestedEngineSkills) || data.suggestedEngineSkills.length === 0
|
|
270
|
+
? "none (workflow closed)"
|
|
271
|
+
: data.suggestedEngineSkills.map((value) => `\`${value}\``).join(", ");
|
|
232
272
|
|
|
233
273
|
return {
|
|
234
274
|
METADATA: [
|
|
@@ -270,7 +310,7 @@ function renderManagedBlocks(data) {
|
|
|
270
310
|
"<!-- SDTK-CODE:STATUS:START -->",
|
|
271
311
|
"## 5. Status Checklist",
|
|
272
312
|
`- Current phase: \`${currentPhase}\``,
|
|
273
|
-
`- Next recommended phase: \`${
|
|
313
|
+
`- Next recommended phase: \`${nextPhaseLabel}\``,
|
|
274
314
|
`- Suggested engine entrypoints: ${suggestedEngine}`,
|
|
275
315
|
`- Blocking state: \`${data.blockingState}\``,
|
|
276
316
|
"<!-- SDTK-CODE:STATUS:END -->",
|
|
@@ -405,6 +445,8 @@ function createOrUpdateWorkflowArtifact(options) {
|
|
|
405
445
|
risks: options.risks || [],
|
|
406
446
|
slices: options.slices || [],
|
|
407
447
|
planNotes: options.planNotes || [],
|
|
448
|
+
candidateSlices: options.candidateSlices || [],
|
|
449
|
+
candidatePlanningNotes: options.candidatePlanningNotes || [],
|
|
408
450
|
activeSlices: options.activeSlices || [],
|
|
409
451
|
buildNotes: options.buildNotes || [],
|
|
410
452
|
debugNotes: options.debugNotes || [],
|
|
@@ -422,6 +464,7 @@ function createOrUpdateWorkflowArtifact(options) {
|
|
|
422
464
|
shipFollowUps: options.shipFollowUps || [],
|
|
423
465
|
shipNotes: options.shipNotes || [],
|
|
424
466
|
shipDebugNotes: options.shipDebugNotes || [],
|
|
467
|
+
reviewPacketPath: options.reviewPacketPath || null,
|
|
425
468
|
intakeSource: options.intakeSource || "legacy_compatibility",
|
|
426
469
|
handoffStatus: options.handoffStatus || "missing",
|
|
427
470
|
compatibilityWarnings: options.compatibilityWarnings || [],
|