// src/lib/crossSpawn.ts
import crossSpawn from "cross-spawn";
function spawn(command, args, options) {
  return crossSpawn(command, args, options);
}

// src/actions/skills/passthrough.ts
var NPX_SKILLS_PATTERN = /(?<=\[[\d;]*m|\W|^)npx(?:\s+-y)?\s+skills(?=\W|$)/g;
var rewriteSkillsRefs = (text) => text.replaceAll(NPX_SKILLS_PATTERN, "xy skills");
var runSkills = (subcommand, args, options = {}) => {
  const stdio = options.interactive ? "inherit" : ["inherit", "pipe", "pipe"];
  return new Promise((resolve) => {
    const child = spawn("npx", ["-y", "skills", subcommand, ...args], {
      env: { FORCE_COLOR: "3", ...process.env },
      stdio
    });
    if (!options.interactive) {
      child.stdout?.setEncoding("utf8");
      child.stderr?.setEncoding("utf8");
      child.stdout?.on("data", (chunk) => {
        process.stdout.write(rewriteSkillsRefs(chunk));
      });
      child.stderr?.on("data", (chunk) => {
        process.stderr.write(rewriteSkillsRefs(chunk));
      });
    }
    child.on("error", () => resolve(1));
    child.on("close", (code) => resolve(code ?? 1));
  });
};

// src/actions/skills/updo.ts
var SCOPE_FLAGS = /* @__PURE__ */ new Set(["-g", "--global", "-p", "--project"]);
var hasSkillsScopeFlag = (args) => args.some((a) => SCOPE_FLAGS.has(a));
var skillsUpdo = (args) => {
  const finalArgs = hasSkillsScopeFlag(args) ? args : ["-p", ...args];
  return runSkills("update", finalArgs);
};
export {
  hasSkillsScopeFlag,
  skillsUpdo
};
//# sourceMappingURL=updo.mjs.map
