sdtk-ops-kit 0.2.3 → 0.2.5

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.
@@ -1,88 +1,90 @@
1
- "use strict";
2
-
3
- function cmdHelp() {
4
- const text = [
5
- "SDTK-OPS CLI -- skill-driven operations discipline toolkit",
6
- "",
7
- "Usage:",
8
- " sdtk-ops <command> [options]",
9
- "",
10
- "Commands:",
11
- " init Initialize SDTK-OPS files in a project",
12
- " runtime Manage runtime asset installation (install, uninstall, status)",
13
- " update Refresh the npm package and optionally re-apply managed project/runtime assets",
14
- " help Show this help message",
15
- "",
16
- "Current supported surface:",
17
- " Supported now: help, init, runtime install|status|uninstall",
18
- " Not supported: generate",
19
- " Package scope: public npm package",
20
- "",
21
- "DEV-Run intake:",
22
- " Canonical intake artifact: docs/dev/OPS_HANDOFF_[FEATURE_KEY].json",
23
- " READY_FOR_SDTK_OPS: start from suggested_next_ops_path or confirm it with ops-discover.",
24
- " BLOCKED_FOR_SDTK_OPS: inspect blockers and evidence refs, but do not treat it as normal ready-path execution.",
25
- " SDTK-OPS consumes the frozen handoff contract and does not redefine the schema.",
26
- "",
27
- "Workflow entry:",
28
- " After init, choose a journey directly if the goal is clear.",
29
- " Canonical journeys: deployment, incident, monitoring, backup/recovery.",
30
- " If the correct path is unclear, start with the ops-discover skill.",
31
- " ops-parallel remains valid only for independent slices; if collab/subagent dispatch is unavailable in the active runtime, keep the same split but execute sequentially.",
32
- " Close every journey with ops-verify before declaring work complete.",
33
- "",
34
- "Runtime support:",
35
- " Claude: project + user scope",
36
- " Codex: default user scope plus bounded project scope via <project>/.codex",
37
- " Codex project scope requires the explicit local CODEX_HOME=<project>/.codex contract",
38
- " Native .codex/skills auto-discovery is not claimed",
39
- "",
40
- "Runtime commands:",
41
- " sdtk-ops runtime install --runtime <codex|claude> [--scope <project|user>] [--project-path <path>]",
42
- " sdtk-ops runtime uninstall --runtime <codex|claude> [--scope <project|user>] [--all] [--project-path <path>]",
43
- " sdtk-ops runtime status --runtime <codex|claude> [--project-path <path>]",
44
- "",
45
- "Update options:",
46
- " --version <latest|x.y.z> Target published npm package version (default: latest)",
47
- " --runtime <codex|claude> Optional runtime refresh target after npm update",
48
- " --scope <project|user> Runtime asset scope when --runtime is provided",
49
- " --project-path <path> Target project directory for managed file refresh (default: cwd)",
50
- " --check-only Print the planned npm/init/runtime refresh steps without making changes",
51
- " --skip-project-files Skip sdtk-ops init --force during update",
52
- " --skip-runtime-assets Skip sdtk-ops runtime install --force during update",
53
- " --verbose Show detailed command output",
54
- "",
55
- "Uninstall behavior:",
56
- " runtime uninstall removes only SDTK-OPS-managed skill folders for the selected runtime/scope.",
57
- " It does not delete parent runtime roots such as .claude/, .claude/skills/, $CODEX_HOME/, or $CODEX_HOME/skills/.",
58
- " npm uninstall -g sdtk-ops-kit removes the CLI package only. Runtime assets remain until runtime uninstall or manual cleanup.",
59
- "",
60
- "Global options:",
61
- " -h, --help Show this help",
62
- " -v, --version Show version",
63
- "",
64
- "Examples:",
65
- " sdtk-ops --help",
66
- " sdtk-ops --version",
67
- " sdtk-ops init --runtime claude --project-path ./my-project",
68
- " sdtk-ops update --check-only",
69
- " sdtk-ops update --runtime claude --project-path ./my-project",
70
- " sdtk-ops update --version 1.2.3 --runtime codex --scope user --skip-project-files",
71
- " sdtk-ops init --runtime codex --runtime-scope project --project-path ./my-project",
72
- " sdtk-ops runtime install --runtime claude --scope project --project-path ./my-project",
73
- " sdtk-ops runtime install --runtime codex --scope project --project-path ./my-project",
74
- " # Journey routing after init:",
75
- " # deployment -> ops-plan -> ops-infra-plan -> ops-container -> ops-ci-cd -> ops-deploy -> ops-monitor -> ops-verify",
76
- " # incident -> ops-incident -> ops-debug -> ops-monitor -> ops-verify",
77
- " # monitoring -> ops-plan -> ops-monitor -> ops-verify",
78
- " # recovery -> ops-plan -> ops-backup -> ops-verify",
79
- " sdtk-ops runtime status --runtime codex",
80
- " sdtk-ops runtime uninstall --runtime codex --scope user",
81
- " npm uninstall -g sdtk-ops-kit",
82
- ];
83
-
84
- console.log(text.join("\n"));
85
- return 0;
86
- }
87
-
88
- module.exports = { cmdHelp };
1
+ "use strict";
2
+
3
+ function cmdHelp() {
4
+ const text = [
5
+ "SDTK-OPS CLI -- skill-driven operations discipline toolkit",
6
+ "",
7
+ "Usage:",
8
+ " sdtk-ops <command> [options]",
9
+ "",
10
+ "Commands:",
11
+ " init Initialize SDTK-OPS files in a project",
12
+ " runtime Manage runtime asset installation (install, uninstall, status)",
13
+ " update Refresh the npm package and optionally re-apply managed project/runtime assets",
14
+ " help Show this help message",
15
+ "",
16
+ "Current supported surface:",
17
+ " Supported now: help, init, runtime install|status|uninstall",
18
+ " Not supported: generate",
19
+ " Package scope: public npm package",
20
+ "",
21
+ "DEV-Run intake:",
22
+ " Canonical intake artifact: docs/dev/OPS_HANDOFF_[FEATURE_KEY].json",
23
+ " READY_FOR_SDTK_OPS: start from suggested_next_ops_path or confirm it with ops-discover.",
24
+ " BLOCKED_FOR_SDTK_OPS: inspect blockers and evidence refs, but do not treat it as normal ready-path execution.",
25
+ " SDTK-OPS consumes the frozen handoff contract and does not redefine the schema.",
26
+ "",
27
+ "Workflow entry:",
28
+ " After init, choose a journey directly if the goal is clear.",
29
+ " Canonical journeys: deployment, incident, monitoring, backup/recovery.",
30
+ " If the correct path is unclear, start with the ops-discover skill.",
31
+ " ops-parallel remains valid only for independent slices; if collab/subagent dispatch is unavailable in the active runtime, keep the same split but execute sequentially.",
32
+ " Close every journey with ops-verify before declaring work complete.",
33
+ "",
34
+ "Runtime support:",
35
+ " Claude: project + user scope",
36
+ " Codex: default user scope plus bounded project scope via <project>/.codex",
37
+ " Codex project scope requires the explicit local CODEX_HOME=<project>/.codex contract",
38
+ " Native .codex/skills auto-discovery is not claimed",
39
+ "",
40
+ "Runtime commands:",
41
+ " sdtk-ops runtime install --runtime <codex|claude> [--scope <project|user>] [--project-path <path>]",
42
+ " sdtk-ops runtime uninstall --runtime <codex|claude> [--scope <project|user>] [--all] [--project-path <path>]",
43
+ " sdtk-ops runtime status --runtime <codex|claude> [--project-path <path>]",
44
+ "",
45
+ "Update options:",
46
+ " --version <latest|x.y.z> Target published npm package version (default: latest)",
47
+ " --runtime <codex|claude> Optional runtime refresh target after npm update",
48
+ " --scope <project|user> Runtime asset scope when --runtime is provided",
49
+ " --project-path <path> Target project directory for managed file refresh (default: cwd)",
50
+ " --check-only Print the planned npm/init/runtime refresh steps without making changes",
51
+ " --skip-project-files Skip sdtk-ops init --force during update",
52
+ " --skip-runtime-assets Skip sdtk-ops runtime install --force during update",
53
+ " --verbose Show detailed command output",
54
+ " Maintainer-root guard: init/update refuse the SDTK maintainer monorepo root as a managed project target.",
55
+ " Use a consumer project path, or use --skip-project-files when update should avoid project-file refresh.",
56
+ "",
57
+ "Uninstall behavior:",
58
+ " runtime uninstall removes only SDTK-OPS-managed skill folders for the selected runtime/scope.",
59
+ " It does not delete parent runtime roots such as .claude/, .claude/skills/, $CODEX_HOME/, or $CODEX_HOME/skills/.",
60
+ " npm uninstall -g sdtk-ops-kit removes the CLI package only. Runtime assets remain until runtime uninstall or manual cleanup.",
61
+ "",
62
+ "Global options:",
63
+ " -h, --help Show this help",
64
+ " -v, --version Show version",
65
+ "",
66
+ "Examples:",
67
+ " sdtk-ops --help",
68
+ " sdtk-ops --version",
69
+ " sdtk-ops init --runtime claude --project-path ./my-project",
70
+ " sdtk-ops update --check-only",
71
+ " sdtk-ops update --runtime claude --project-path ./my-project",
72
+ " sdtk-ops update --version 1.2.3 --runtime codex --scope user --skip-project-files",
73
+ " sdtk-ops init --runtime codex --runtime-scope project --project-path ./my-project",
74
+ " sdtk-ops runtime install --runtime claude --scope project --project-path ./my-project",
75
+ " sdtk-ops runtime install --runtime codex --scope project --project-path ./my-project",
76
+ " # Journey routing after init:",
77
+ " # deployment -> ops-plan -> ops-infra-plan -> ops-container -> ops-ci-cd -> ops-deploy -> ops-monitor -> ops-verify",
78
+ " # incident -> ops-incident -> ops-debug -> ops-monitor -> ops-verify",
79
+ " # monitoring -> ops-plan -> ops-monitor -> ops-verify",
80
+ " # recovery -> ops-plan -> ops-backup -> ops-verify",
81
+ " sdtk-ops runtime status --runtime codex",
82
+ " sdtk-ops runtime uninstall --runtime codex --scope user",
83
+ " npm uninstall -g sdtk-ops-kit",
84
+ ];
85
+
86
+ console.log(text.join("\n"));
87
+ return 0;
88
+ }
89
+
90
+ module.exports = { cmdHelp };
@@ -6,6 +6,7 @@ const { verify, resolvePayloadFile } = require("../lib/toolkit-payload");
6
6
  const { runScript } = require("../lib/powershell");
7
7
  const { ValidationError } = require("../lib/errors");
8
8
  const { VALID_SCOPES, defaultScope, isProjectScopeSupported } = require("../lib/scope");
9
+ const { assertProjectRefreshTargetAllowed } = require("../lib/project-target-guard");
9
10
 
10
11
  const FLAG_DEFS = {
11
12
  runtime: { type: "string" },
@@ -40,6 +41,8 @@ async function cmdInit(args) {
40
41
 
41
42
  const projectPath = flags["project-path"] ? path.resolve(flags["project-path"]) : process.cwd();
42
43
 
44
+ assertProjectRefreshTargetAllowed("sdtk-ops", "init", projectPath);
45
+
43
46
  verify();
44
47
 
45
48
  const installScript = resolvePayloadFile("toolkit/install.ps1");
@@ -1,11 +1,11 @@
1
- "use strict";
2
-
3
- const { executeUpdate } = require("../lib/update");
4
-
5
- async function cmdUpdate(args) {
6
- return executeUpdate(args);
7
- }
8
-
9
- module.exports = {
10
- cmdUpdate,
11
- };
1
+ "use strict";
2
+
3
+ const { executeUpdate } = require("../lib/update");
4
+
5
+ async function cmdUpdate(args) {
6
+ return executeUpdate(args);
7
+ }
8
+
9
+ module.exports = {
10
+ cmdUpdate,
11
+ };
package/src/index.js CHANGED
@@ -1,68 +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 { 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
- };
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
+