sdtk-ops-kit 0.2.2 → 0.2.4
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 +192 -160
- package/assets/manifest/toolkit-bundle.manifest.json +8 -8
- package/assets/manifest/toolkit-bundle.sha256.txt +3 -3
- package/assets/toolkit/toolkit/AGENTS.md +2 -2
- package/assets/toolkit/toolkit/SDTKOPS_TOOLKIT.md +203 -202
- package/assets/toolkit/toolkit/install.ps1 +168 -131
- package/package.json +46 -46
- package/src/commands/help.js +43 -27
- package/src/commands/init.js +98 -95
- package/src/commands/update.js +11 -0
- package/src/index.js +68 -65
- package/src/lib/project-target-guard.js +53 -0
- package/src/lib/update.js +344 -0
package/src/commands/init.js
CHANGED
|
@@ -1,95 +1,98 @@
|
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"skip-
|
|
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
|
-
if (
|
|
55
|
-
params.
|
|
56
|
-
}
|
|
57
|
-
if (
|
|
58
|
-
params.
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
console.log(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
console.log("
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
+
const { assertProjectRefreshTargetAllowed } = require("../lib/project-target-guard");
|
|
10
|
+
|
|
11
|
+
const FLAG_DEFS = {
|
|
12
|
+
runtime: { type: "string" },
|
|
13
|
+
"project-path": { type: "string" },
|
|
14
|
+
"runtime-scope": { type: "string" },
|
|
15
|
+
force: { type: "boolean" },
|
|
16
|
+
"skip-skills": { type: "boolean" },
|
|
17
|
+
"skip-runtime-assets": { type: "boolean" },
|
|
18
|
+
verbose: { type: "boolean" },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const VALID_RUNTIMES = ["codex", "claude"];
|
|
22
|
+
|
|
23
|
+
async function cmdInit(args) {
|
|
24
|
+
const { flags } = parseFlags(args, FLAG_DEFS);
|
|
25
|
+
|
|
26
|
+
const runtime = flags.runtime || "codex";
|
|
27
|
+
validateChoice(runtime, VALID_RUNTIMES, "runtime");
|
|
28
|
+
|
|
29
|
+
const scope = flags["runtime-scope"] || defaultScope(runtime);
|
|
30
|
+
validateChoice(scope, VALID_SCOPES, "runtime-scope");
|
|
31
|
+
if (scope === "project" && !isProjectScopeSupported(runtime)) {
|
|
32
|
+
throw new ValidationError(
|
|
33
|
+
`${runtime} does not support project-local runtime assets. Use --runtime-scope user instead.`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const skipAssets = flags["skip-runtime-assets"] || flags["skip-skills"];
|
|
38
|
+
if (flags["skip-skills"] && !flags["skip-runtime-assets"]) {
|
|
39
|
+
console.warn("Warning: --skip-skills is deprecated. Use --skip-runtime-assets instead.");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
|
|
43
|
+
|
|
44
|
+
assertProjectRefreshTargetAllowed("sdtk-ops", "init", projectPath);
|
|
45
|
+
|
|
46
|
+
verify();
|
|
47
|
+
|
|
48
|
+
const installScript = resolvePayloadFile("toolkit/install.ps1");
|
|
49
|
+
const params = {
|
|
50
|
+
ProjectPath: projectPath,
|
|
51
|
+
Runtime: runtime,
|
|
52
|
+
Scope: scope,
|
|
53
|
+
};
|
|
54
|
+
if (flags.force) {
|
|
55
|
+
params.Force = true;
|
|
56
|
+
}
|
|
57
|
+
if (skipAssets) {
|
|
58
|
+
params.SkipRuntimeAssets = true;
|
|
59
|
+
}
|
|
60
|
+
if (!flags.verbose) {
|
|
61
|
+
params.Quiet = true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log("Initializing SDTK-OPS workspace...");
|
|
65
|
+
console.log(` Runtime: ${runtime}`);
|
|
66
|
+
console.log(` Scope: ${scope}`);
|
|
67
|
+
console.log(` Project: ${projectPath}`);
|
|
68
|
+
if (runtime === "codex" && scope === "project") {
|
|
69
|
+
console.log(` Codex home contract: ${path.join(projectPath, ".codex")}`);
|
|
70
|
+
console.log(" Note: Launch Codex with CODEX_HOME=<project>/.codex to use project-local skills.");
|
|
71
|
+
console.log(" Note: This CLI does not claim native .codex/skills auto-discovery.");
|
|
72
|
+
}
|
|
73
|
+
console.log("");
|
|
74
|
+
|
|
75
|
+
const result = await runScript(installScript, params, { silent: !flags.verbose });
|
|
76
|
+
if (result.exitCode !== 0) {
|
|
77
|
+
if (result.stderr) {
|
|
78
|
+
console.error(result.stderr);
|
|
79
|
+
}
|
|
80
|
+
throw new ValidationError(`Initialization failed (exit code ${result.exitCode}).`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log("");
|
|
84
|
+
console.log("SDTK-OPS workspace initialized successfully.");
|
|
85
|
+
if (runtime === "codex" && scope === "project") {
|
|
86
|
+
console.log(`Project-local Codex skills were installed into ${path.join(projectPath, ".codex", "skills")}.`);
|
|
87
|
+
console.log("Launch Codex with CODEX_HOME=<project>/.codex to activate that local runtime home.");
|
|
88
|
+
}
|
|
89
|
+
console.log("");
|
|
90
|
+
console.log("Next steps:");
|
|
91
|
+
console.log(" 1. Review and customize sdtk-spec.config.json for your operations environment.");
|
|
92
|
+
console.log(" 2. Use the installed ops-* skill set for deployment, monitoring, incident, and recovery workflows.");
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
module.exports = {
|
|
97
|
+
cmdInit,
|
|
98
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,65 +1,68 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { cmdHelp } = require("./commands/help");
|
|
4
|
-
const { cmdInit } = require("./commands/init");
|
|
5
|
-
const { cmdRuntime } = require("./commands/runtime");
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { cmdHelp } = require("./commands/help");
|
|
4
|
+
const { cmdInit } = require("./commands/init");
|
|
5
|
+
const { cmdRuntime } = require("./commands/runtime");
|
|
6
|
+
const { cmdUpdate } = require("./commands/update");
|
|
7
|
+
const { ValidationError } = require("./lib/errors");
|
|
8
|
+
|
|
9
|
+
const COMMANDS = new Set(["help", "version", "init", "runtime", "update"]);
|
|
10
|
+
|
|
11
|
+
function getVersion() {
|
|
12
|
+
const pkg = require("../package.json");
|
|
13
|
+
return pkg.version;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function parseCommand(argv) {
|
|
17
|
+
if (!argv || argv.length === 0) {
|
|
18
|
+
return { command: "help", args: [] };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const [first, ...rest] = argv;
|
|
22
|
+
if (first === "-h" || first === "--help") {
|
|
23
|
+
return { command: "help", args: [] };
|
|
24
|
+
}
|
|
25
|
+
if (first === "-v" || first === "--version") {
|
|
26
|
+
return { command: "version", args: [] };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return { command: first, args: rest };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function run(argv) {
|
|
33
|
+
const { command, args } = parseCommand(argv);
|
|
34
|
+
|
|
35
|
+
if (command === "generate") {
|
|
36
|
+
throw new ValidationError(
|
|
37
|
+
'The "generate" command is not part of the supported SDTK-OPS workflow-entry surface. Supported commands: help, init, runtime. If the correct journey is unclear, start with the "ops-discover" skill.'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!COMMANDS.has(command)) {
|
|
42
|
+
throw new ValidationError(
|
|
43
|
+
`Unknown command: "${command}". Run "sdtk-ops --help" for available commands.`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
switch (command) {
|
|
48
|
+
case "help":
|
|
49
|
+
return cmdHelp();
|
|
50
|
+
case "version":
|
|
51
|
+
console.log(`sdtk-ops-kit ${getVersion()}`);
|
|
52
|
+
return 0;
|
|
53
|
+
case "init":
|
|
54
|
+
return cmdInit(args);
|
|
55
|
+
case "runtime":
|
|
56
|
+
return cmdRuntime(args);
|
|
57
|
+
case "update":
|
|
58
|
+
return cmdUpdate(args);
|
|
59
|
+
default:
|
|
60
|
+
throw new ValidationError(`Unsupported command: "${command}".`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
getVersion,
|
|
66
|
+
parseCommand,
|
|
67
|
+
run,
|
|
68
|
+
};
|
|
@@ -0,0 +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-ops/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
|
+
|