From a4373b0c5d4b2aef2adf4dc2e086925f8c2c1e48 Mon Sep 17 00:00:00 2001 From: Lucas Bebber Date: Wed, 17 Jun 2026 21:19:40 -0300 Subject: [PATCH 1/2] Pass --global or --project to postinstall skills install based on npm context Use npm_config_global to detect whether the package was installed globally (npm i -g) or as a project dependency, and pass the matching scope flag to cio skills install. --- .npm/postinstall.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.npm/postinstall.js b/.npm/postinstall.js index 812eb36..7c2aae6 100644 --- a/.npm/postinstall.js +++ b/.npm/postinstall.js @@ -43,8 +43,9 @@ if (!existsSync(binPath)) { process.exit(0); } -console.log("[cio postinstall] Running: cio skills install"); -const child = spawn(binPath, ["skills", "install"], { +const scopeFlag = process.env.npm_config_global === "true" ? "--global" : "--project"; +console.log(`[cio postinstall] Running: cio skills install ${scopeFlag}`); +const child = spawn(binPath, ["skills", "install", scopeFlag], { stdio: "inherit", }); From cf011adc1002f0e1a3cd2aaa6a2c0f71d704bc5c Mon Sep 17 00:00:00 2001 From: Lucas Bebber Date: Wed, 17 Jun 2026 21:33:26 -0300 Subject: [PATCH 2/2] Use INIT_CWD for project-scoped postinstall skills install npm runs postinstall with cwd inside node_modules, not the project root. Use INIT_CWD (set by npm to the original working directory) so --project installs skills into the actual project directory. --- .npm/postinstall.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.npm/postinstall.js b/.npm/postinstall.js index 7c2aae6..abff2e3 100644 --- a/.npm/postinstall.js +++ b/.npm/postinstall.js @@ -43,11 +43,18 @@ if (!existsSync(binPath)) { process.exit(0); } -const scopeFlag = process.env.npm_config_global === "true" ? "--global" : "--project"; +const isGlobal = process.env.npm_config_global === "true"; +const scopeFlag = isGlobal ? "--global" : "--project"; +const spawnOpts = { stdio: "inherit" }; + +// For project installs, npm runs postinstall with cwd inside node_modules. +// INIT_CWD is the directory where the user ran npm install (the project root). +if (!isGlobal && process.env.INIT_CWD) { + spawnOpts.cwd = process.env.INIT_CWD; +} + console.log(`[cio postinstall] Running: cio skills install ${scopeFlag}`); -const child = spawn(binPath, ["skills", "install", scopeFlag], { - stdio: "inherit", -}); +const child = spawn(binPath, ["skills", "install", scopeFlag], spawnOpts); child.on("error", (err) => { console.log("[cio postinstall] Failed to run cio skills install:", err.message);