sdtk-ops-kit 0.2.3 → 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.
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.2.3",
3
- "sourceCommit": "5b21b7376fcf11a9138f486921de5e07e0c88ac7",
2
+ "version": "0.2.4",
3
+ "sourceCommit": "fdd187d89b2749677696e024600d94270a2fd8e2",
4
4
  "fileCount": 36,
5
5
  "files": [
6
6
  {
@@ -10,8 +10,8 @@
10
10
  },
11
11
  {
12
12
  "path": "toolkit/install.ps1",
13
- "sha256": "ac041e80d0771b13fc1dc94c6a572debaddba223ff4d029695a6953f35ebaa92",
14
- "size": 3015
13
+ "sha256": "e0a0550001385ca68854d2c33d404f0702832d34f8ae29823f0012c39bdba7ce",
14
+ "size": 4386
15
15
  },
16
16
  {
17
17
  "path": "toolkit/scripts/install-claude-skills.ps1",
@@ -1,5 +1,5 @@
1
1
  a1a8d03564680cde44ef34e1878f3c8fb6ad7ce79e79b7ba7274fdb072321f30 toolkit/AGENTS.md
2
- ac041e80d0771b13fc1dc94c6a572debaddba223ff4d029695a6953f35ebaa92 toolkit/install.ps1
2
+ e0a0550001385ca68854d2c33d404f0702832d34f8ae29823f0012c39bdba7ce toolkit/install.ps1
3
3
  5eae77f4d14b81d56c3c109f563fefafd1967d85093ff1b192293fe438aeabe5 toolkit/scripts/install-claude-skills.ps1
4
4
  68eb662bc9b8906882d32f6cd1247238f6ae663137a489f18054a75724cd1e81 toolkit/scripts/install-codex-skills.ps1
5
5
  2c629d8316b205c6a7cd0d95959b80801b281ef62e205c10a92e3a2568eb8b41 toolkit/scripts/uninstall-claude-skills.ps1
@@ -1,131 +1,168 @@
1
- param(
2
- [Parameter(Mandatory = $true)]
3
- [ValidateSet('codex', 'claude')]
4
- [string]$Runtime,
5
-
6
- [string]$ProjectPath,
7
-
8
- [ValidateSet('project', 'user', '')]
9
- [string]$Scope = '',
10
-
11
- [switch]$Force,
12
- [switch]$SkipRuntimeAssets,
13
- [switch]$SkipSkills,
14
- [switch]$Quiet
15
- )
16
-
17
- $ErrorActionPreference = 'Stop'
18
- Set-StrictMode -Version Latest
19
-
20
- function Copy-File {
21
- param(
22
- [Parameter(Mandatory = $true)][string]$SourcePath,
23
- [Parameter(Mandatory = $true)][string]$DestinationPath,
24
- [Parameter(Mandatory = $true)][bool]$Overwrite
25
- )
26
-
27
- if (-not (Test-Path -LiteralPath $SourcePath)) {
28
- throw "Missing source file: $SourcePath"
29
- }
30
-
31
- if ((Test-Path -LiteralPath $DestinationPath) -and -not $Overwrite) {
32
- if (-not $Quiet) {
33
- Write-Warning "Already exists (skipping). Use -Force to overwrite: $DestinationPath"
34
- }
35
- return
36
- }
37
-
38
- $parent = Split-Path -Parent $DestinationPath
39
- if ($parent -and -not (Test-Path -LiteralPath $parent)) {
40
- New-Item -ItemType Directory -Force -Path $parent | Out-Null
41
- }
42
-
43
- Copy-Item -LiteralPath $SourcePath -Destination $DestinationPath -Force
44
- }
45
-
46
- function Resolve-OrCreateDirectory {
47
- param(
48
- [Parameter(Mandatory = $true)][string]$Path
49
- )
50
-
51
- if (-not (Test-Path -LiteralPath $Path)) {
52
- New-Item -ItemType Directory -Force -Path $Path | Out-Null
53
- }
54
-
55
- return (Resolve-Path -LiteralPath $Path).Path
56
- }
57
-
58
- $toolkitRoot = (Resolve-Path -LiteralPath $PSScriptRoot).Path
59
- if (-not $ProjectPath) {
60
- $ProjectPath = (Get-Location).Path
61
- }
62
- $projectRoot = Resolve-OrCreateDirectory -Path $ProjectPath
63
-
64
- if (-not $Scope) {
65
- $Scope = if ($Runtime -eq 'claude') { 'project' } else { 'user' }
66
- }
67
-
68
- if ($SkipSkills) {
69
- if (-not $Quiet) {
70
- Write-Warning "-SkipSkills is deprecated. Use -SkipRuntimeAssets instead."
71
- }
72
- $SkipRuntimeAssets = $true
73
- }
74
-
75
- if (-not $Quiet) {
76
- Write-Host "SDTK-OPS installer"
77
- Write-Host " Runtime: $Runtime"
78
- Write-Host " Scope: $Scope"
79
- Write-Host " Project: $projectRoot"
80
- Write-Host ""
81
- }
82
-
83
- $sharedFiles = @(
84
- 'AGENTS.md',
85
- 'sdtk-spec.config.json',
86
- 'sdtk-spec.config.profiles.example.json'
87
- )
88
-
89
- foreach ($fileName in $sharedFiles) {
90
- Copy-File `
91
- -SourcePath (Join-Path $toolkitRoot $fileName) `
92
- -DestinationPath (Join-Path $projectRoot $fileName) `
93
- -Overwrite ([bool]$Force)
94
-
95
- if (-not $Quiet) {
96
- Write-Host " [OK] $fileName"
97
- }
98
- }
99
-
100
- if (-not $SkipRuntimeAssets) {
101
- $scriptPath = if ($Runtime -eq 'claude') {
102
- Join-Path $toolkitRoot 'scripts/install-claude-skills.ps1'
103
- } else {
104
- Join-Path $toolkitRoot 'scripts/install-codex-skills.ps1'
105
- }
106
-
107
- if (-not (Test-Path -LiteralPath $scriptPath)) {
108
- throw "Missing runtime installer: $scriptPath"
109
- }
110
-
111
- if (-not $Quiet) {
112
- Write-Host ""
113
- Write-Host "Installing $Runtime runtime assets..."
114
- }
115
-
116
- $params = @{
117
- Scope = $Scope
118
- ProjectPath = $projectRoot
119
- Quiet = [bool]$Quiet
120
- }
121
- if ($Force) {
122
- $params.Force = $true
123
- }
124
-
125
- & $scriptPath @params
126
- }
127
-
128
- if (-not $Quiet) {
129
- Write-Host ""
130
- Write-Host "SDTK-OPS installation complete."
131
- }
1
+ param(
2
+ [Parameter(Mandatory = $true)]
3
+ [ValidateSet('codex', 'claude')]
4
+ [string]$Runtime,
5
+
6
+ [string]$ProjectPath,
7
+
8
+ [ValidateSet('project', 'user', '')]
9
+ [string]$Scope = '',
10
+
11
+ [switch]$Force,
12
+ [switch]$SkipRuntimeAssets,
13
+ [switch]$SkipSkills,
14
+ [switch]$Quiet
15
+ )
16
+
17
+ $ErrorActionPreference = 'Stop'
18
+ Set-StrictMode -Version Latest
19
+
20
+ function Copy-File {
21
+ param(
22
+ [Parameter(Mandatory = $true)][string]$SourcePath,
23
+ [Parameter(Mandatory = $true)][string]$DestinationPath,
24
+ [Parameter(Mandatory = $true)][bool]$Overwrite
25
+ )
26
+
27
+ if (-not (Test-Path -LiteralPath $SourcePath)) {
28
+ throw "Missing source file: $SourcePath"
29
+ }
30
+
31
+ if ((Test-Path -LiteralPath $DestinationPath) -and -not $Overwrite) {
32
+ if (-not $Quiet) {
33
+ Write-Warning "Already exists (skipping). Use -Force to overwrite: $DestinationPath"
34
+ }
35
+ return
36
+ }
37
+
38
+ $parent = Split-Path -Parent $DestinationPath
39
+ if ($parent -and -not (Test-Path -LiteralPath $parent)) {
40
+ New-Item -ItemType Directory -Force -Path $parent | Out-Null
41
+ }
42
+
43
+ Copy-Item -LiteralPath $SourcePath -Destination $DestinationPath -Force
44
+ }
45
+
46
+ function Test-IsMaintainerRoot {
47
+ param(
48
+ [Parameter(Mandatory = $true)][string]$ProjectRoot,
49
+ [Parameter(Mandatory = $true)][string[]]$Markers
50
+ )
51
+
52
+ foreach ($marker in $Markers) {
53
+ if (-not (Test-Path -LiteralPath (Join-Path $ProjectRoot $marker))) {
54
+ return $false
55
+ }
56
+ }
57
+
58
+ return $true
59
+ }
60
+
61
+ function Get-MaintainerRootInstallMessage {
62
+ param(
63
+ [Parameter(Mandatory = $true)][string]$ProjectRoot
64
+ )
65
+
66
+ return @(
67
+ "Refusing to install managed project files into the SDTK maintainer repo root: $ProjectRoot"
68
+ "This install flow would overwrite repo-owned files such as AGENTS.md, CODEX.md, CLAUDE.md, sdtk-spec.config.json, sdtk-spec.config.profiles.example.json."
69
+ "Target a consumer project path instead of the SDTK maintainer monorepo root."
70
+ "If you only need runtime assets, install them into a separate consumer project path rather than the maintainer repo root."
71
+ ) -join "`n"
72
+ }
73
+
74
+ function Resolve-OrCreateDirectory {
75
+ param(
76
+ [Parameter(Mandatory = $true)][string]$Path
77
+ )
78
+
79
+ if (-not (Test-Path -LiteralPath $Path)) {
80
+ New-Item -ItemType Directory -Force -Path $Path | Out-Null
81
+ }
82
+
83
+ return (Resolve-Path -LiteralPath $Path).Path
84
+ }
85
+
86
+ $toolkitRoot = (Resolve-Path -LiteralPath $PSScriptRoot).Path
87
+ if (-not $ProjectPath) {
88
+ $ProjectPath = (Get-Location).Path
89
+ }
90
+ $projectRoot = Resolve-OrCreateDirectory -Path $ProjectPath
91
+
92
+ $maintainerRootMarkers = @(
93
+ 'governance/ai/core/IMPROVEMENT_BACKLOG.md',
94
+ 'products/sdtk-ops/toolkit/install.ps1'
95
+ )
96
+
97
+ if (Test-IsMaintainerRoot -ProjectRoot $projectRoot -Markers $maintainerRootMarkers) {
98
+ throw (Get-MaintainerRootInstallMessage -ProjectRoot $projectRoot)
99
+ }
100
+
101
+ if (-not $Scope) {
102
+ $Scope = if ($Runtime -eq 'claude') { 'project' } else { 'user' }
103
+ }
104
+
105
+ if ($SkipSkills) {
106
+ if (-not $Quiet) {
107
+ Write-Warning "-SkipSkills is deprecated. Use -SkipRuntimeAssets instead."
108
+ }
109
+ $SkipRuntimeAssets = $true
110
+ }
111
+
112
+ if (-not $Quiet) {
113
+ Write-Host "SDTK-OPS installer"
114
+ Write-Host " Runtime: $Runtime"
115
+ Write-Host " Scope: $Scope"
116
+ Write-Host " Project: $projectRoot"
117
+ Write-Host ""
118
+ }
119
+
120
+ $sharedFiles = @(
121
+ 'AGENTS.md',
122
+ 'sdtk-spec.config.json',
123
+ 'sdtk-spec.config.profiles.example.json'
124
+ )
125
+
126
+ foreach ($fileName in $sharedFiles) {
127
+ Copy-File `
128
+ -SourcePath (Join-Path $toolkitRoot $fileName) `
129
+ -DestinationPath (Join-Path $projectRoot $fileName) `
130
+ -Overwrite ([bool]$Force)
131
+
132
+ if (-not $Quiet) {
133
+ Write-Host " [OK] $fileName"
134
+ }
135
+ }
136
+
137
+ if (-not $SkipRuntimeAssets) {
138
+ $scriptPath = if ($Runtime -eq 'claude') {
139
+ Join-Path $toolkitRoot 'scripts/install-claude-skills.ps1'
140
+ } else {
141
+ Join-Path $toolkitRoot 'scripts/install-codex-skills.ps1'
142
+ }
143
+
144
+ if (-not (Test-Path -LiteralPath $scriptPath)) {
145
+ throw "Missing runtime installer: $scriptPath"
146
+ }
147
+
148
+ if (-not $Quiet) {
149
+ Write-Host ""
150
+ Write-Host "Installing $Runtime runtime assets..."
151
+ }
152
+
153
+ $params = @{
154
+ Scope = $Scope
155
+ ProjectPath = $projectRoot
156
+ Quiet = [bool]$Quiet
157
+ }
158
+ if ($Force) {
159
+ $params.Force = $true
160
+ }
161
+
162
+ & $scriptPath @params
163
+ }
164
+
165
+ if (-not $Quiet) {
166
+ Write-Host ""
167
+ Write-Host "SDTK-OPS installation complete."
168
+ }
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "name": "sdtk-ops-kit",
3
- "version": "0.2.3",
4
- "description": "Skill-driven operations toolkit for deployment, verification, monitoring, incident response, backup, security, compliance, and cost discipline.",
5
- "bin": {
6
- "sdtk-ops": "./bin/sdtk-ops.js"
7
- },
8
- "main": "src/index.js",
9
- "type": "commonjs",
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/codexsdtk/sdtk-toolkit.git",
13
- "directory": "products/sdtk-ops/distribution/sdtk-ops-kit"
14
- },
15
- "homepage": "https://github.com/codexsdtk/sdtk-toolkit/tree/main/products/sdtk-ops/distribution/sdtk-ops-kit",
16
- "bugs": {
17
- "url": "https://github.com/codexsdtk/sdtk-toolkit/issues"
18
- },
19
- "files": [
20
- "bin/",
21
- "src/",
22
- "assets/"
23
- ],
24
- "scripts": {
25
- "test": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; Set-Location '..\\..\\..\\..'; python -m unittest -v tests.test_sdtk_ops_cli\"",
26
- "build:payload": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; & 'scripts/sync-toolkit-assets.ps1'; & 'scripts/build-toolkit-manifest.ps1'\"",
27
- "verify:payload": "node -e \"require('./src/lib/toolkit-payload').verify()\"",
28
- "pack:smoke": "powershell -ExecutionPolicy Bypass -File scripts/pack-smoke.ps1",
29
- "prepublishOnly": "npm run build:payload && npm run verify:payload"
30
- },
31
- "engines": {
32
- "node": ">=18.13.0"
33
- },
34
- "keywords": [
35
- "sdtk-ops",
36
- "cli",
37
- "toolkit",
38
- "operations",
39
- "claude",
40
- "codex"
41
- ],
42
- "license": "MIT",
43
- "publishConfig": {
44
- "access": "public"
45
- }
46
- }
1
+ {
2
+ "name": "sdtk-ops-kit",
3
+ "version": "0.2.4",
4
+ "description": "Skill-driven operations toolkit for deployment, verification, monitoring, incident response, backup, security, compliance, and cost discipline.",
5
+ "bin": {
6
+ "sdtk-ops": "./bin/sdtk-ops.js"
7
+ },
8
+ "main": "src/index.js",
9
+ "type": "commonjs",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/codexsdtk/sdtk-toolkit.git",
13
+ "directory": "products/sdtk-ops/distribution/sdtk-ops-kit"
14
+ },
15
+ "homepage": "https://github.com/codexsdtk/sdtk-toolkit/tree/main/products/sdtk-ops/distribution/sdtk-ops-kit",
16
+ "bugs": {
17
+ "url": "https://github.com/codexsdtk/sdtk-toolkit/issues"
18
+ },
19
+ "files": [
20
+ "bin/",
21
+ "src/",
22
+ "assets/"
23
+ ],
24
+ "scripts": {
25
+ "test": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; Set-Location '..\\..\\..\\..'; python -m unittest -v tests.test_sdtk_ops_cli\"",
26
+ "build:payload": "powershell -ExecutionPolicy Bypass -Command \"$ErrorActionPreference = 'Stop'; & 'scripts/sync-toolkit-assets.ps1'; & 'scripts/build-toolkit-manifest.ps1'\"",
27
+ "verify:payload": "node -e \"require('./src/lib/toolkit-payload').verify()\"",
28
+ "pack:smoke": "powershell -ExecutionPolicy Bypass -File scripts/pack-smoke.ps1",
29
+ "prepublishOnly": "npm run build:payload && npm run verify:payload"
30
+ },
31
+ "engines": {
32
+ "node": ">=18.13.0"
33
+ },
34
+ "keywords": [
35
+ "sdtk-ops",
36
+ "cli",
37
+ "toolkit",
38
+ "operations",
39
+ "claude",
40
+ "codex"
41
+ ],
42
+ "license": "MIT",
43
+ "publishConfig": {
44
+ "access": "public"
45
+ }
46
+ }
@@ -51,6 +51,8 @@ function cmdHelp() {
51
51
  " --skip-project-files Skip sdtk-ops init --force during update",
52
52
  " --skip-runtime-assets Skip sdtk-ops runtime install --force during update",
53
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.",
54
56
  "",
55
57
  "Uninstall behavior:",
56
58
  " runtime uninstall removes only SDTK-OPS-managed skill folders for the selected runtime/scope.",
@@ -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
- 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
- `${runtime} does not support project-local runtime assets. 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-OPS workspace...");
62
- console.log(` Runtime: ${runtime}`);
63
- console.log(` Scope: ${scope}`);
64
- console.log(` Project: ${projectPath}`);
65
- if (runtime === "codex" && scope === "project") {
66
- console.log(` Codex home contract: ${path.join(projectPath, ".codex")}`);
67
- console.log(" Note: Launch Codex with CODEX_HOME=<project>/.codex to use project-local skills.");
68
- console.log(" Note: This CLI does not claim native .codex/skills auto-discovery.");
69
- }
70
- console.log("");
71
-
72
- const result = await runScript(installScript, params, { silent: !flags.verbose });
73
- if (result.exitCode !== 0) {
74
- if (result.stderr) {
75
- console.error(result.stderr);
76
- }
77
- throw new ValidationError(`Initialization failed (exit code ${result.exitCode}).`);
78
- }
79
-
80
- console.log("");
81
- console.log("SDTK-OPS workspace initialized successfully.");
82
- if (runtime === "codex" && scope === "project") {
83
- console.log(`Project-local Codex skills were installed into ${path.join(projectPath, ".codex", "skills")}.`);
84
- console.log("Launch Codex with CODEX_HOME=<project>/.codex to activate that local runtime home.");
85
- }
86
- console.log("");
87
- console.log("Next steps:");
88
- console.log(" 1. Review and customize sdtk-spec.config.json for your operations environment.");
89
- console.log(" 2. Use the installed ops-* skill set for deployment, monitoring, incident, and recovery workflows.");
90
- return 0;
91
- }
92
-
93
- module.exports = {
94
- cmdInit,
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
+ };
@@ -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
+
package/src/lib/update.js CHANGED
@@ -5,6 +5,7 @@ const { spawn } = require("child_process");
5
5
  const { parseFlags, validateChoice } = require("./args");
6
6
  const { CliError, DependencyError, ValidationError } = require("./errors");
7
7
  const { VALID_SCOPES, defaultScope, isProjectScopeSupported } = require("./scope");
8
+ const { assertProjectRefreshTargetAllowed } = require("./project-target-guard");
8
9
 
9
10
  const PACKAGE_NAME = "sdtk-ops-kit";
10
11
  const CLI_NAME = "sdtk-ops";
@@ -233,11 +234,17 @@ function parseUpdateOptions(args) {
233
234
  }
234
235
  }
235
236
 
237
+ const projectPath = path.resolve(flags["project-path"] || process.cwd());
238
+
239
+ if (runtime && !flags["skip-project-files"]) {
240
+ assertProjectRefreshTargetAllowed("sdtk-ops", "update", projectPath);
241
+ }
242
+
236
243
  return {
237
244
  requestedVersion,
238
245
  runtime,
239
246
  scope,
240
- projectPath: path.resolve(flags["project-path"] || process.cwd()),
247
+ projectPath,
241
248
  checkOnly: flags["check-only"],
242
249
  skipProjectFiles: flags["skip-project-files"],
243
250
  skipRuntimeAssets: flags["skip-runtime-assets"],