@exorcist-98/cli 0.3.0 → 0.3.2

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/dist/index.mjs CHANGED
@@ -4566,8 +4566,8 @@ var init_prompts = __esm({
4566
4566
 
4567
4567
  // ../core/src/secrets-check.ts
4568
4568
  import { execFileSync as execFileSync2 } from "node:child_process";
4569
- import { readFileSync as readFileSync3, statSync } from "node:fs";
4570
- import { resolve as resolve2 } from "node:path";
4569
+ import { readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
4570
+ import { resolve as resolve3 } from "node:path";
4571
4571
  function placeholderRanges(text) {
4572
4572
  const ranges = [];
4573
4573
  PLACEHOLDER_RE.lastIndex = 0;
@@ -4623,10 +4623,10 @@ function findStagedSecrets(cwd = process.cwd()) {
4623
4623
  const hits = [];
4624
4624
  let filesChecked = 0;
4625
4625
  for (const name of names) {
4626
- const full = resolve2(root, name);
4626
+ const full = resolve3(root, name);
4627
4627
  let text;
4628
4628
  try {
4629
- if (statSync(full).size > MAX_BYTES2) continue;
4629
+ if (statSync2(full).size > MAX_BYTES2) continue;
4630
4630
  const buf = readFileSync3(full);
4631
4631
  if (buf.subarray(0, 512).includes(0)) continue;
4632
4632
  text = buf.toString("utf8");
@@ -8539,7 +8539,7 @@ var require_compile = __commonJS({
8539
8539
  const schOrFunc = root.refs[ref];
8540
8540
  if (schOrFunc)
8541
8541
  return schOrFunc;
8542
- let _sch = resolve28.call(this, root, ref);
8542
+ let _sch = resolve31.call(this, root, ref);
8543
8543
  if (_sch === void 0) {
8544
8544
  const schema2 = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
8545
8545
  const { schemaId } = this.opts;
@@ -8566,7 +8566,7 @@ var require_compile = __commonJS({
8566
8566
  function sameSchemaEnv(s1, s2) {
8567
8567
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
8568
8568
  }
8569
- function resolve28(root, ref) {
8569
+ function resolve31(root, ref) {
8570
8570
  let sch;
8571
8571
  while (typeof (sch = this.refs[ref]) == "string")
8572
8572
  ref = sch;
@@ -9430,7 +9430,7 @@ var require_fast_uri = __commonJS({
9430
9430
  }
9431
9431
  return uri;
9432
9432
  }
9433
- function resolve28(baseURI, relativeURI, options) {
9433
+ function resolve31(baseURI, relativeURI, options) {
9434
9434
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
9435
9435
  const {
9436
9436
  parsed: baseParsed,
@@ -9466,50 +9466,50 @@ var require_fast_uri = __commonJS({
9466
9466
  schemelessOptions.skipEscape = true;
9467
9467
  return serialize(resolved, schemelessOptions);
9468
9468
  }
9469
- function resolveComponent(base, relative10, options, skipNormalization) {
9469
+ function resolveComponent(base, relative13, options, skipNormalization) {
9470
9470
  const target = {};
9471
9471
  if (!skipNormalization) {
9472
9472
  base = parse6(serialize(base, options), options);
9473
- relative10 = parse6(serialize(relative10, options), options);
9473
+ relative13 = parse6(serialize(relative13, options), options);
9474
9474
  }
9475
9475
  options = options || {};
9476
- if (!options.tolerant && relative10.scheme) {
9477
- target.scheme = relative10.scheme;
9478
- target.userinfo = relative10.userinfo;
9479
- target.host = relative10.host;
9480
- target.port = relative10.port;
9481
- target.path = removeDotSegments(relative10.path || "");
9482
- target.query = relative10.query;
9476
+ if (!options.tolerant && relative13.scheme) {
9477
+ target.scheme = relative13.scheme;
9478
+ target.userinfo = relative13.userinfo;
9479
+ target.host = relative13.host;
9480
+ target.port = relative13.port;
9481
+ target.path = removeDotSegments(relative13.path || "");
9482
+ target.query = relative13.query;
9483
9483
  } else {
9484
- if (relative10.userinfo !== void 0 || relative10.host !== void 0 || relative10.port !== void 0) {
9485
- target.userinfo = relative10.userinfo;
9486
- target.host = relative10.host;
9487
- target.port = relative10.port;
9488
- target.path = removeDotSegments(relative10.path || "");
9489
- target.query = relative10.query;
9484
+ if (relative13.userinfo !== void 0 || relative13.host !== void 0 || relative13.port !== void 0) {
9485
+ target.userinfo = relative13.userinfo;
9486
+ target.host = relative13.host;
9487
+ target.port = relative13.port;
9488
+ target.path = removeDotSegments(relative13.path || "");
9489
+ target.query = relative13.query;
9490
9490
  } else {
9491
- if (!relative10.path) {
9491
+ if (!relative13.path) {
9492
9492
  target.path = base.path;
9493
- if (relative10.query !== void 0) {
9494
- target.query = relative10.query;
9493
+ if (relative13.query !== void 0) {
9494
+ target.query = relative13.query;
9495
9495
  } else {
9496
9496
  target.query = base.query;
9497
9497
  }
9498
9498
  } else {
9499
- if (relative10.path[0] === "/") {
9500
- target.path = removeDotSegments(relative10.path);
9499
+ if (relative13.path[0] === "/") {
9500
+ target.path = removeDotSegments(relative13.path);
9501
9501
  } else {
9502
9502
  const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
9503
9503
  if (baseHasAuthority && !base.path) {
9504
- target.path = "/" + relative10.path;
9504
+ target.path = "/" + relative13.path;
9505
9505
  } else if (!base.path) {
9506
- target.path = relative10.path;
9506
+ target.path = relative13.path;
9507
9507
  } else {
9508
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative10.path;
9508
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative13.path;
9509
9509
  }
9510
9510
  target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
9511
9511
  }
9512
- target.query = relative10.query;
9512
+ target.query = relative13.query;
9513
9513
  }
9514
9514
  target.userinfo = base.userinfo;
9515
9515
  target.host = base.host;
@@ -9517,7 +9517,7 @@ var require_fast_uri = __commonJS({
9517
9517
  }
9518
9518
  target.scheme = base.scheme;
9519
9519
  }
9520
- target.fragment = relative10.fragment;
9520
+ target.fragment = relative13.fragment;
9521
9521
  return target;
9522
9522
  }
9523
9523
  function equal(uriA, uriB, options) {
@@ -9821,7 +9821,7 @@ var require_fast_uri = __commonJS({
9821
9821
  var fastUri = {
9822
9822
  SCHEMES,
9823
9823
  normalize: normalize2,
9824
- resolve: resolve28,
9824
+ resolve: resolve31,
9825
9825
  resolveComponent,
9826
9826
  equal,
9827
9827
  serialize,
@@ -12904,12 +12904,12 @@ var require_isexe = __commonJS({
12904
12904
  if (typeof Promise !== "function") {
12905
12905
  throw new TypeError("callback not provided");
12906
12906
  }
12907
- return new Promise(function(resolve28, reject) {
12907
+ return new Promise(function(resolve31, reject) {
12908
12908
  isexe(path, options || {}, function(er, is) {
12909
12909
  if (er) {
12910
12910
  reject(er);
12911
12911
  } else {
12912
- resolve28(is);
12912
+ resolve31(is);
12913
12913
  }
12914
12914
  });
12915
12915
  });
@@ -12975,27 +12975,27 @@ var require_which = __commonJS({
12975
12975
  opt = {};
12976
12976
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
12977
12977
  const found = [];
12978
- const step = (i) => new Promise((resolve28, reject) => {
12978
+ const step = (i) => new Promise((resolve31, reject) => {
12979
12979
  if (i === pathEnv.length)
12980
- return opt.all && found.length ? resolve28(found) : reject(getNotFoundError(cmd));
12980
+ return opt.all && found.length ? resolve31(found) : reject(getNotFoundError(cmd));
12981
12981
  const ppRaw = pathEnv[i];
12982
12982
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
12983
12983
  const pCmd = path.join(pathPart, cmd);
12984
12984
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
12985
- resolve28(subStep(p, i, 0));
12985
+ resolve31(subStep(p, i, 0));
12986
12986
  });
12987
- const subStep = (p, i, ii) => new Promise((resolve28, reject) => {
12987
+ const subStep = (p, i, ii) => new Promise((resolve31, reject) => {
12988
12988
  if (ii === pathExt.length)
12989
- return resolve28(step(i + 1));
12989
+ return resolve31(step(i + 1));
12990
12990
  const ext = pathExt[ii];
12991
12991
  isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
12992
12992
  if (!er && is) {
12993
12993
  if (opt.all)
12994
12994
  found.push(p + ext);
12995
12995
  else
12996
- return resolve28(p + ext);
12996
+ return resolve31(p + ext);
12997
12997
  }
12998
- return resolve28(subStep(p, i, ii + 1));
12998
+ return resolve31(subStep(p, i, ii + 1));
12999
12999
  });
13000
13000
  });
13001
13001
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -16452,7 +16452,8 @@ var MatchSchema = external_exports.object({
16452
16452
  // `detonation` is the Detonation Chamber (EX-024, m5-detonation): a
16453
16453
  // sandboxed model run, only with `--detonate`.
16454
16454
  // `path-names` checks the names of every walked path (EX-029, path-names.ts).
16455
- analysis: external_exports.enum(["trifecta", "detonation", "path-names"]).optional(),
16455
+ // `lifecycle-scripts` follows a package.json lifecycle script into the local file it runs (EX-036, lifecycle-scripts.ts).
16456
+ analysis: external_exports.enum(["trifecta", "detonation", "path-names", "lifecycle-scripts"]).optional(),
16456
16457
  // Text an element hides from a person by its style (EX-028, hidden-text.ts):
16457
16458
  // reported only when the hidden text addresses the AI or asks for actions.
16458
16459
  hidden_text: external_exports.boolean().optional(),
@@ -18558,7 +18559,7 @@ function skipArgument(text, p, lang, limit) {
18558
18559
  }
18559
18560
  return -1;
18560
18561
  }
18561
- function findKeyString(text, open3, lang, limit, sep3) {
18562
+ function findKeyString(text, open3, lang, limit, sep6) {
18562
18563
  let depth = 0;
18563
18564
  let i = open3;
18564
18565
  let lit = null;
@@ -18568,7 +18569,7 @@ function findKeyString(text, open3, lang, limit, sep3) {
18568
18569
  };
18569
18570
  const sepAt = (p) => {
18570
18571
  const j = skipTrivia(text, p, lang, limit);
18571
- if (text[j] !== sep3 || sep3 === "=" && text[j + 1] === "=") return -1;
18572
+ if (text[j] !== sep6 || sep6 === "=" && text[j + 1] === "=") return -1;
18572
18573
  return j + 1;
18573
18574
  };
18574
18575
  while (i < limit) {
@@ -18926,12 +18927,360 @@ function checkPathSegment(name) {
18926
18927
  return null;
18927
18928
  }
18928
18929
 
18930
+ // ../core/src/lifecycle-scripts.ts
18931
+ import { closeSync, existsSync, openSync, readSync, realpathSync, statSync } from "node:fs";
18932
+ import { isAbsolute as isAbsolute2, join as join5, relative as relative3, resolve as resolve2, sep } from "node:path";
18933
+
18934
+ // ../core/src/shell-words.ts
18935
+ var MAX_COMMAND_CHARS = 65536;
18936
+ var REDIRECT = /^\d*[<>]+&?\d*-?$/;
18937
+ var REDIRECT_WITH_TARGET = /^\d*[<>]+&?[^\s<>]/;
18938
+ function splitShell(command) {
18939
+ if (command.length > MAX_COMMAND_CHARS) return { ok: false };
18940
+ const segments = [];
18941
+ let words3 = [];
18942
+ let cur = "";
18943
+ let started = false;
18944
+ let quote = null;
18945
+ const endWord = () => {
18946
+ if (started) words3.push(cur);
18947
+ cur = "";
18948
+ started = false;
18949
+ };
18950
+ const endSegment = () => {
18951
+ endWord();
18952
+ const kept = [];
18953
+ for (let i = 0; i < words3.length; i++) {
18954
+ const w = words3[i] ?? "";
18955
+ if (REDIRECT.test(w)) {
18956
+ i += 1;
18957
+ continue;
18958
+ }
18959
+ if (REDIRECT_WITH_TARGET.test(w)) continue;
18960
+ kept.push(w);
18961
+ }
18962
+ if (kept.length > 0) segments.push(kept);
18963
+ words3 = [];
18964
+ };
18965
+ for (let i = 0; i < command.length; i++) {
18966
+ const c = command[i] ?? "";
18967
+ if (quote === "'") {
18968
+ if (c === "'") quote = null;
18969
+ else cur += c;
18970
+ continue;
18971
+ }
18972
+ if (quote === '"') {
18973
+ if (c === '"') quote = null;
18974
+ else if (c === "\\" && i + 1 < command.length && /["\\$`]/.test(command[i + 1] ?? "")) {
18975
+ cur += command[i + 1] ?? "";
18976
+ i += 1;
18977
+ } else cur += c;
18978
+ continue;
18979
+ }
18980
+ if (c === "\\") {
18981
+ if (i + 1 >= command.length) return { ok: false };
18982
+ cur += command[i + 1] ?? "";
18983
+ started = true;
18984
+ i += 1;
18985
+ } else if (c === "'" || c === '"') {
18986
+ quote = c;
18987
+ started = true;
18988
+ } else if (c === " " || c === " ") {
18989
+ endWord();
18990
+ } else if (c === ";" || c === "\n" || c === "|" || c === "&" || c === "(" || c === ")") {
18991
+ if (c === "&" && (/[<>]$/.test(cur) || command[i + 1] === ">")) {
18992
+ cur += c;
18993
+ started = true;
18994
+ continue;
18995
+ }
18996
+ endSegment();
18997
+ } else {
18998
+ cur += c;
18999
+ started = true;
19000
+ }
19001
+ }
19002
+ if (quote !== null) return { ok: false };
19003
+ endSegment();
19004
+ return { ok: true, segments };
19005
+ }
19006
+ function isPlainWord(word) {
19007
+ return word !== "" && !/[$`*?[\]{}]/.test(word) && !word.startsWith("~") && !word.includes("\0");
19008
+ }
19009
+ function stripPrefixes(words3) {
19010
+ let i = 0;
19011
+ for (; ; ) {
19012
+ const w = words3[i];
19013
+ if (w === void 0) break;
19014
+ if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(w)) {
19015
+ i += 1;
19016
+ continue;
19017
+ }
19018
+ if (w === "env" || w === "sudo" || w === "time" || w === "nohup" || w === "command" || w === "exec") {
19019
+ i += 1;
19020
+ continue;
19021
+ }
19022
+ if (w === "cross-env") {
19023
+ i += 1;
19024
+ continue;
19025
+ }
19026
+ break;
19027
+ }
19028
+ return words3.slice(i);
19029
+ }
19030
+
19031
+ // ../core/src/lifecycle-scripts.ts
19032
+ var INSTALL_HOOKS = [
19033
+ "preinstall",
19034
+ "install",
19035
+ "postinstall",
19036
+ "prepublish",
19037
+ "preprepare",
19038
+ "prepare",
19039
+ "postprepare",
19040
+ "prepublishOnly",
19041
+ "prepack",
19042
+ "postpack"
19043
+ ];
19044
+ var HOOK_BASES = /* @__PURE__ */ new Set(["test", "start", "stop", "restart", "build", "install", "publish", "version", "pack", "uninstall", "shrinkwrap"]);
19045
+ var MAX_FOLLOW_DEPTH = 3;
19046
+ var MAX_SOURCE_BYTES = 1048576;
19047
+ var MAX_SCRIPTS = 500;
19048
+ function parseScripts(pkgText) {
19049
+ try {
19050
+ const parsed = JSON.parse(pkgText);
19051
+ if (typeof parsed !== "object" || parsed === null) return {};
19052
+ const s = parsed["scripts"];
19053
+ if (typeof s !== "object" || s === null || Array.isArray(s)) return {};
19054
+ const out = {};
19055
+ for (const [k, v] of Object.entries(s).slice(0, MAX_SCRIPTS)) if (typeof v === "string") out[k] = v;
19056
+ return out;
19057
+ } catch {
19058
+ return {};
19059
+ }
19060
+ }
19061
+ function isAutoScript(name, scripts) {
19062
+ if (INSTALL_HOOKS.includes(name)) return true;
19063
+ const m = /^(pre|post)(.+)$/.exec(name);
19064
+ if (!m) return false;
19065
+ const base = m[2] ?? "";
19066
+ return Object.prototype.hasOwnProperty.call(scripts, base) || HOOK_BASES.has(base);
19067
+ }
19068
+ function autoScriptNames(scripts) {
19069
+ return Object.keys(scripts).filter((n) => isAutoScript(n, scripts));
19070
+ }
19071
+ var INTERPRETERS = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno", "sh", "bash", "zsh", "dash", "python", "python3", "ruby", "perl", "php"]);
19072
+ var INLINE_FLAGS = /* @__PURE__ */ new Set(["-e", "-c", "-p", "--eval", "--print"]);
19073
+ var VALUE_FLAGS = /* @__PURE__ */ new Set(["-r", "--require", "--import", "--loader", "--experimental-loader", "-C", "-W", "-X", "-m"]);
19074
+ var RUN_WORDS = /* @__PURE__ */ new Set(["run", "run-script", "rum", "urn"]);
19075
+ function cleanRel(p) {
19076
+ if (!isPlainWord(p) || /^[a-z][a-z0-9+.-]*:/i.test(p) || isAbsolute2(p) || p.length > 300) return null;
19077
+ const rel = p.replace(/^(?:\.\/)+/, "");
19078
+ return rel === "" ? null : rel;
19079
+ }
19080
+ function scriptTargets(name, scripts, depth = 0, seen = /* @__PURE__ */ new Set()) {
19081
+ const out = { files: [], inline: [], scripts: [] };
19082
+ const text = scripts[name];
19083
+ if (text === void 0 || seen.has(name) || depth > MAX_FOLLOW_DEPTH) return out;
19084
+ seen.add(name);
19085
+ out.inline.push(text);
19086
+ collectSegments(text, scripts, depth, seen, out);
19087
+ return out;
19088
+ }
19089
+ var SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash"]);
19090
+ var MODULE_FLAGS = /* @__PURE__ */ new Set(["-r", "--require", "--import", "--loader", "--experimental-loader"]);
19091
+ var MODULE_FLAG_EQ = /^(--require|--import|--loader|--experimental-loader)=([\s\S]+)$/;
19092
+ var PYTHON_MODULE = /^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/;
19093
+ function pythonModuleFiles(mod) {
19094
+ if (!PYTHON_MODULE.test(mod) || mod.length > 200) return [];
19095
+ const path = mod.split(".").join("/");
19096
+ return [`${path}.py`, `${path}/__main__.py`, `${path}/__init__.py`];
19097
+ }
19098
+ function collectSegments(text, scripts, depth, seen, out) {
19099
+ const split = splitShell(text);
19100
+ if (!split.ok) return;
19101
+ for (const raw of split.segments) {
19102
+ const words3 = stripPrefixes(raw);
19103
+ const head = words3[0];
19104
+ if (head === void 0) continue;
19105
+ const base = head.split("/").pop() ?? head;
19106
+ if ((base === "npm" || base === "pnpm" || base === "yarn") && depth < MAX_FOLLOW_DEPTH) {
19107
+ const sub = words3[1] === "run" || RUN_WORDS.has(words3[1] ?? "") ? words3[2] : base === "yarn" || base === "pnpm" ? words3[1] : void 0;
19108
+ if (sub !== void 0 && Object.prototype.hasOwnProperty.call(scripts, sub)) {
19109
+ out.scripts.push(sub);
19110
+ const inner = scriptTargets(sub, scripts, depth + 1, seen);
19111
+ out.files.push(...inner.files);
19112
+ out.inline.push(...inner.inline);
19113
+ out.scripts.push(...inner.scripts);
19114
+ }
19115
+ continue;
19116
+ }
19117
+ const interp = /^python[0-9.]*$/.test(base) ? "python" : base;
19118
+ if (INTERPRETERS.has(interp)) {
19119
+ const isShell = SHELLS.has(interp);
19120
+ for (let i = 1; i < words3.length; i++) {
19121
+ const w = words3[i] ?? "";
19122
+ if (INLINE_FLAGS.has(w) || isShell && /^-[A-Za-z]*c[A-Za-z]*$/.test(w)) {
19123
+ const inner = words3[i + 1] ?? "";
19124
+ out.inline.push(inner);
19125
+ if (isShell && depth < MAX_FOLLOW_DEPTH) collectSegments(inner, scripts, depth + 1, seen, out);
19126
+ break;
19127
+ }
19128
+ const eq = MODULE_FLAG_EQ.exec(w);
19129
+ if (eq) {
19130
+ const rel2 = cleanRel(eq[2] ?? "");
19131
+ if (rel2 !== null) out.files.push(rel2);
19132
+ continue;
19133
+ }
19134
+ if (MODULE_FLAGS.has(w)) {
19135
+ const rel2 = cleanRel(words3[i + 1] ?? "");
19136
+ if (rel2 !== null) out.files.push(rel2);
19137
+ i += 1;
19138
+ continue;
19139
+ }
19140
+ if (w === "-m" && interp === "python") {
19141
+ out.files.push(...pythonModuleFiles(words3[i + 1] ?? ""));
19142
+ break;
19143
+ }
19144
+ if (VALUE_FLAGS.has(w)) {
19145
+ i += 1;
19146
+ continue;
19147
+ }
19148
+ if (w.startsWith("-")) continue;
19149
+ if (interp === "deno" && (w === "run" || w === "task")) continue;
19150
+ const rel = cleanRel(w);
19151
+ if (rel !== null) out.files.push(rel);
19152
+ break;
19153
+ }
19154
+ continue;
19155
+ }
19156
+ if (head.startsWith("./") || head.startsWith("scripts/") || head.includes("/") && !head.startsWith("-") && !head.includes(":")) {
19157
+ const rel = cleanRel(head);
19158
+ if (rel !== null) out.files.push(rel);
19159
+ }
19160
+ }
19161
+ }
19162
+ var SECRET_PATTERNS = [
19163
+ [/(?<![\w])\.env(?!\.(?:example|sample|template|dist))(?:\.[A-Za-z]+)?(?![\w-])/, ".env"],
19164
+ [/(?<![\w])\.npmrc\b/, ".npmrc"],
19165
+ [/(?<![\w])\.aws(?![\w-])/, "~/.aws"],
19166
+ [/(?<![\w])\.ssh(?![\w-])/, "~/.ssh"],
19167
+ [/\bid_(?:rsa|ed25519|ecdsa)\b/, "a private key file"],
19168
+ [/(?<![\w])\.(?:netrc|git-credentials|pypirc)\b/, "a credentials file"],
19169
+ [/JSON\.stringify\(\s*process\.env\s*[,)]/, "the whole of process.env"],
19170
+ [/Object\.(?:entries|keys|values|fromEntries|assign)\(\s*(?:\{\}\s*,\s*)?process\.env\s*\)/, "the whole of process.env"],
19171
+ [/\{\s*\.\.\.\s*process\.env\s*\}/, "the whole of process.env"],
19172
+ [/\bdict\(\s*os\.environ\s*\)|\bos\.environ\.(?:items|copy)\(\)|json\.dumps\(\s*os\.environ/, "the whole of os.environ"],
19173
+ [/(?:^|[;&|]\s*|\$\(\s*)(?:printenv|env)\s*(?:$|[|>)]|\s*\|)/, "the whole environment"]
19174
+ ];
19175
+ var SEND_PATTERNS = [
19176
+ [/\bhttps?\.(?:request|get)\s*\(/, "an http request"],
19177
+ [/\bfetch\s*\(/, "fetch"],
19178
+ [/\baxios(?:\.\w+)?\s*\(|\bgot(?:\.(?:post|get|put))?\s*\(\s*['"`]/, "an http client call"],
19179
+ [/new\s+XMLHttpRequest\b|new\s+WebSocket\s*\(/, "a browser-style request"],
19180
+ [/\bnet\.(?:connect|createConnection|Socket)\b/, "a socket"],
19181
+ [/require\(\s*['"](?:node:)?dgram['"]\s*\)|from\s+['"](?:node:)?dgram['"]/, "a datagram socket"],
19182
+ [/\b(?:curl|wget)\s+(?:-\S+\s+)*\S/, "curl or wget"],
19183
+ [/\/dev\/tcp\//, "/dev/tcp"],
19184
+ [/\bnc\s+\S+\s+\d+/, "netcat"],
19185
+ [/\burlopen\s*\(|\brequests\.(?:get|post|put)\s*\(|\bhttp\.client\b|\bsocket\.(?:socket|create_connection)\b|\bsmtplib\b/, "a python network call"]
19186
+ ];
19187
+ var lineHit = (lines, patterns) => {
19188
+ for (let i = 0; i < lines.length; i++) {
19189
+ const line = lines[i] ?? "";
19190
+ if (line.length > 4e3) continue;
19191
+ for (const [re2, label] of patterns) if (re2.test(line)) return { line: i + 1, label };
19192
+ }
19193
+ return null;
19194
+ };
19195
+ function analyzeSource(text) {
19196
+ const lines = text.split(/\r?\n/);
19197
+ return { secret: lineHit(lines, SECRET_PATTERNS), send: lineHit(lines, SEND_PATTERNS) };
19198
+ }
19199
+ function locateScript(pkgText, name) {
19200
+ const start = pkgText.search(/"scripts"\s*:/);
19201
+ const esc3 = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
19202
+ const re2 = new RegExp(`"${esc3}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`, "g");
19203
+ re2.lastIndex = Math.max(0, start);
19204
+ const m = re2.exec(pkgText);
19205
+ if (!m) return { line: 1, col: 1, span: name.slice(0, 120) };
19206
+ const valueIndex = m.index + m[0].indexOf('"', m[0].indexOf(":")) + 1;
19207
+ const before = pkgText.slice(0, valueIndex);
19208
+ const line = before.split("\n").length;
19209
+ const col = valueIndex - (before.lastIndexOf("\n") + 1) + 1;
19210
+ return { line, col, span: (m[1] ?? "").slice(0, 120) };
19211
+ }
19212
+ function lifecycleFindings(input) {
19213
+ const scripts = parseScripts(input.pkgText);
19214
+ const names = (input.names ?? autoScriptNames(scripts)).filter((n) => Object.prototype.hasOwnProperty.call(scripts, n));
19215
+ const hits = [];
19216
+ for (const name of names) {
19217
+ let found = null;
19218
+ try {
19219
+ const targets = scriptTargets(name, scripts);
19220
+ const where2 = locateScript(input.pkgText, name);
19221
+ const base = { script: name, scriptText: scripts[name] ?? "", ...where2 };
19222
+ for (const rel of [...new Set(targets.files)]) {
19223
+ const text = input.readLocal(rel);
19224
+ if (text === null) continue;
19225
+ const a = analyzeSource(text);
19226
+ if (a.secret && a.send) {
19227
+ found = { ...base, file: rel, secret: a.secret, send: a.send };
19228
+ break;
19229
+ }
19230
+ }
19231
+ if (!found) {
19232
+ for (const inline of targets.inline) {
19233
+ const a = analyzeSource(inline);
19234
+ if (a.secret && a.send) {
19235
+ found = { ...base, file: null, secret: a.secret, send: a.send };
19236
+ break;
19237
+ }
19238
+ }
19239
+ }
19240
+ } catch {
19241
+ found = null;
19242
+ }
19243
+ if (found) hits.push(found);
19244
+ }
19245
+ return hits;
19246
+ }
19247
+ function describeHit(h) {
19248
+ const where2 = h.file === null ? `The script text itself reads ${h.secret.label} and sends data out (${h.send.label}).` : `It runs ${h.file}, which reads ${h.secret.label} (line ${h.secret.line}) and sends data out through ${h.send.label} (line ${h.send.line}).`;
19249
+ return `The "${h.script}" script of package.json runs by itself when a package manager installs or tests this project. ${where2}`;
19250
+ }
19251
+ function readLocalText(pkgDir, rel) {
19252
+ try {
19253
+ const abs = resolve2(pkgDir, rel);
19254
+ const within = (root, p) => {
19255
+ const r = relative3(root, p);
19256
+ return r !== "" && !r.startsWith("..") && !isAbsolute2(r) && !r.split(sep).includes("..");
19257
+ };
19258
+ if (!within(pkgDir, abs) || !existsSync(abs)) return null;
19259
+ const real = realpathSync(abs);
19260
+ if (!within(realpathSync(pkgDir), real)) return null;
19261
+ const st = statSync(real);
19262
+ if (!st.isFile() || st.size > MAX_SOURCE_BYTES) return null;
19263
+ const buf = Buffer.alloc(st.size);
19264
+ const fd = openSync(real, "r");
19265
+ try {
19266
+ readSync(fd, buf, 0, st.size, 0);
19267
+ } finally {
19268
+ closeSync(fd);
19269
+ }
19270
+ if (buf.includes(0)) return null;
19271
+ return buf.toString("utf8");
19272
+ } catch {
19273
+ return null;
19274
+ }
19275
+ }
19276
+
18929
19277
  // ../core/src/scanner/orchestrator.ts
19278
+ import { dirname } from "node:path";
18930
19279
  init_heuristic_engine();
18931
19280
 
18932
19281
  // ../core/src/capabilities.ts
18933
19282
  import { readFile as readFile2 } from "node:fs/promises";
18934
- import { join as join5 } from "node:path";
19283
+ import { join as join6 } from "node:path";
18935
19284
  init_zod();
18936
19285
  var CAPABILITIES = ["private-data", "untrusted-input", "exfiltration"];
18937
19286
  var CAPABILITIES_FILE = "capabilities.yaml";
@@ -19004,7 +19353,7 @@ function parseCapabilityRules(data) {
19004
19353
  async function loadCapabilityRules(definitionsDir) {
19005
19354
  let raw;
19006
19355
  try {
19007
- raw = await readFile2(join5(definitionsDir, CAPABILITIES_FILE), "utf8");
19356
+ raw = await readFile2(join6(definitionsDir, CAPABILITIES_FILE), "utf8");
19008
19357
  } catch {
19009
19358
  return { ok: false, missing: true, error: `${CAPABILITIES_FILE} was not found in ${definitionsDir}` };
19010
19359
  }
@@ -19019,8 +19368,8 @@ async function loadCapabilityRules(definitionsDir) {
19019
19368
  var PACKAGE_RUNNERS = /* @__PURE__ */ new Set(["npx", "bunx", "pnpx", "uvx"]);
19020
19369
  var SCRIPT_RUNNERS = /* @__PURE__ */ new Set(["node", "nodejs", "python", "python3", "py", "bun", "deno", "tsx", "ts-node"]);
19021
19370
  var CONTAINERS = /* @__PURE__ */ new Set(["docker", "podman"]);
19022
- var SHELLS = /* @__PURE__ */ new Set(["bash", "sh", "zsh", "cmd", "powershell", "pwsh"]);
19023
- var LAUNCHERS = /* @__PURE__ */ new Set([...PACKAGE_RUNNERS, ...SCRIPT_RUNNERS, ...CONTAINERS, ...SHELLS, "npm", "pnpm", "yarn", "uv", "pipx", "env", "exorcist"]);
19371
+ var SHELLS2 = /* @__PURE__ */ new Set(["bash", "sh", "zsh", "cmd", "powershell", "pwsh"]);
19372
+ var LAUNCHERS = /* @__PURE__ */ new Set([...PACKAGE_RUNNERS, ...SCRIPT_RUNNERS, ...CONTAINERS, ...SHELLS2, "npm", "pnpm", "yarn", "uv", "pipx", "env", "exorcist"]);
19024
19373
  var DOCKER_VALUE_FLAGS = /* @__PURE__ */ new Set([
19025
19374
  "-e",
19026
19375
  "--env",
@@ -19090,7 +19439,7 @@ function unwrapLaunch(command, args, depth = 0) {
19090
19439
  if (u !== -1 && args[u + 1] !== void 0) return { command: "", args: [], url: args[u + 1] };
19091
19440
  }
19092
19441
  const base = basenameOf(command);
19093
- if (depth < 3 && SHELLS.has(base)) {
19442
+ if (depth < 3 && SHELLS2.has(base)) {
19094
19443
  const c = args.findIndex((a) => /^(?:-c|\/c|-command)$/i.test(a));
19095
19444
  const inner = c === -1 ? void 0 : args[c + 1];
19096
19445
  if (inner !== void 0) {
@@ -19286,7 +19635,7 @@ function classifyCapabilities(server, rules) {
19286
19635
  init_zod();
19287
19636
  import { constants } from "node:fs";
19288
19637
  import { lstat, open as open2 } from "node:fs/promises";
19289
- import { join as join6 } from "node:path";
19638
+ import { join as join7 } from "node:path";
19290
19639
  init_severity_paths();
19291
19640
  init_walker();
19292
19641
  var TRIFECTA_RULE_ID = "EX-023";
@@ -19425,7 +19774,7 @@ function parsePins(json2) {
19425
19774
  return out;
19426
19775
  }
19427
19776
  async function readPins(root, maxBytes = MAX_PINS_BYTES) {
19428
- const path = join6(root, ".exorcist", "pins.json");
19777
+ const path = join7(root, ".exorcist", "pins.json");
19429
19778
  const none = (note) => ({ pins: /* @__PURE__ */ new Map(), note });
19430
19779
  let info;
19431
19780
  try {
@@ -19585,6 +19934,21 @@ async function* pathNameFindings(root, def) {
19585
19934
  } catch {
19586
19935
  }
19587
19936
  }
19937
+ function lifecycleScanFindings(text, absPath, rel, def) {
19938
+ const dir = dirname(absPath);
19939
+ return lifecycleFindings({ pkgText: text, readLocal: (r) => readLocalText(dir, r) }).map((h) => ({
19940
+ source: "signature",
19941
+ ruleId: def.id,
19942
+ title: def.title,
19943
+ severity: def.severity,
19944
+ file: rel,
19945
+ line: h.line,
19946
+ col: h.col,
19947
+ span: h.span,
19948
+ owasp: def.owasp,
19949
+ fix: `${describeHit(h)} ${def.fix}`
19950
+ }));
19951
+ }
19588
19952
  async function mapRepo(root, options) {
19589
19953
  const rules = await loadCapabilityRules(options.definitionsDir);
19590
19954
  if (!rules.ok) return { ok: false, error: rules.error };
@@ -19620,6 +19984,7 @@ async function* scanRepo(root, options) {
19620
19984
  let filesSkipped = 0;
19621
19985
  let findingsTotal = 0;
19622
19986
  const ex026 = defs.find((d) => d.id === "EX-026");
19987
+ const ex036 = defs.find((d) => d.id === "EX-036" && d.enabled !== false && d.match.analysis === "lifecycle-scripts");
19623
19988
  for await (const file of walkRepo(root, options.maxFileSizeBytes)) {
19624
19989
  yield { type: "file", file };
19625
19990
  if (file.tooLarge) {
@@ -19655,7 +20020,8 @@ async function* scanRepo(root, options) {
19655
20020
  const heurs = options.bedrockClient ? await runHeuristics(file, norm2, sigs, options.bedrockClient) : [];
19656
20021
  const traps = canaryFindings(text, file.rel, records, ex022);
19657
20022
  const sourceTools = (file.role === "code" || file.role === "unknown") && languageOf(file.rel) !== null ? scanSourceTools(file, text, defs) : [];
19658
- let deduped = deduplicate([...sigs, ...heurs, ...traps, ...sandboxFindings(text, file.rel), ...sourceTools]);
20023
+ const lifecycle = ex036 && file.role === "manifest" && file.rel.split("/").pop() === "package.json" ? lifecycleScanFindings(text, file.path, file.rel, ex036) : [];
20024
+ let deduped = deduplicate([...sigs, ...heurs, ...traps, ...sandboxFindings(text, file.rel), ...sourceTools, ...lifecycle]);
19659
20025
  if (checkVault && deduped.length > 0 && file.rel.includes(".exorcist/vault/")) {
19660
20026
  const backup = checkVault(file.rel, await readFile3(file.path));
19661
20027
  if (backup) deduped = deduped.map((f) => asBackupFinding(f, backup));
@@ -19705,7 +20071,7 @@ async function* scanRepo(root, options) {
19705
20071
  init_zod();
19706
20072
 
19707
20073
  // ../core/src/version.ts
19708
- var SCANNER_VERSION = "0.3.0";
20074
+ var SCANNER_VERSION = "0.3.2";
19709
20075
 
19710
20076
  // ../core/src/redact-secrets.ts
19711
20077
  var MIN_LENGTH_FOR_PREFIX = 16;
@@ -19995,6 +20361,14 @@ var ENTRIES = {
19995
20361
  headline: "This project file switches off the sandbox around your AI tool servers",
19996
20362
  attack: "A committed Kiro sandbox file turns MCP sandboxing, or the whole command sandbox, off, so local tool servers run without the operating-system boundary. This is only information: a project file can only tighten your global sandbox policy, so your global setting may still apply."
19997
20363
  },
20364
+ "EX-036": {
20365
+ headline: "A script that runs by itself sends your secrets out",
20366
+ attack: 'This package has a script that npm, pnpm or yarn runs on its own (on install, or before or after "npm test"), and the file it runs reads your .env or other credentials and sends data to another computer. Your AI agent only has to run the tests or install the project; it does not have to obey anything.'
20367
+ },
20368
+ "EX-037": {
20369
+ headline: "This text tells your AI to do something and not to tell you",
20370
+ attack: 'A file gives the agent a job (create a file, skip a test, edit a settings file, send something out) and then tells it to keep that from you: "do not tell the user", "do not mention it", "without telling the user". Plain wording like this has no trick words, but the request to hide the job is what gives it away. The same text can sit in a steering file, a README, a CONTRIBUTING note or a comment in source code.'
20371
+ },
19998
20372
  "EX-027": {
19999
20373
  headline: "Your AI read untrusted text and private data, and now wants to send something out",
20000
20374
  attack: "Earlier in this session your AI read text anyone can write (a web page, an issue, a message) and then private data (a secrets file, a key). Each step looked harmless. Sending data out now is exactly how a prompt injection steals it, so the Shield holds the call until you say yes."
@@ -20115,7 +20489,7 @@ function toBadgeSvg(findings) {
20115
20489
 
20116
20490
  // ../core/src/exorcise.ts
20117
20491
  import { readFile as readFile4 } from "node:fs/promises";
20118
- import { join as join7 } from "node:path";
20492
+ import { join as join8 } from "node:path";
20119
20493
 
20120
20494
  // ../../node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/base.js
20121
20495
  var Diff = class {
@@ -20973,7 +21347,7 @@ async function exorciseRepo(root, findings, opts = {}) {
20973
21347
  for (const [file, list2] of [...byFile.entries()].sort(([a], [b]) => a.localeCompare(b))) {
20974
21348
  let bytes;
20975
21349
  try {
20976
- bytes = await readFile4(join7(root, file));
21350
+ bytes = await readFile4(join8(root, file));
20977
21351
  } catch {
20978
21352
  continue;
20979
21353
  }
@@ -21047,13 +21421,13 @@ var DEFAULT_TAR_LIMITS = {
21047
21421
  // ../core/src/origin.ts
21048
21422
  import { execFile as execFile2 } from "node:child_process";
21049
21423
  import { readFile as readFile5, realpath, stat as stat2 } from "node:fs/promises";
21050
- import { isAbsolute as isAbsolute3, join as join9, relative as relative3, resolve as resolve4 } from "node:path";
21424
+ import { isAbsolute as isAbsolute4, join as join10, relative as relative4, resolve as resolve5 } from "node:path";
21051
21425
 
21052
21426
  // ../core/src/repo-config-guard.ts
21053
21427
  import { execFile } from "node:child_process";
21054
- import { existsSync, readFileSync as readFileSync4, realpathSync, statSync as statSync2 } from "node:fs";
21428
+ import { existsSync as existsSync2, readFileSync as readFileSync4, realpathSync as realpathSync2, statSync as statSync3 } from "node:fs";
21055
21429
  import { tmpdir } from "node:os";
21056
- import { dirname, isAbsolute as isAbsolute2, join as join8, resolve as resolve3 } from "node:path";
21430
+ import { dirname as dirname2, isAbsolute as isAbsolute3, join as join9, resolve as resolve4 } from "node:path";
21057
21431
  function stripComment(s) {
21058
21432
  let inQuote = false;
21059
21433
  for (let i = 0; i < s.length; i++) {
@@ -21133,34 +21507,34 @@ function dangerousKey(e) {
21133
21507
  function locateRepo(start) {
21134
21508
  let dir;
21135
21509
  try {
21136
- dir = realpathSync(start);
21510
+ dir = realpathSync2(start);
21137
21511
  } catch {
21138
21512
  return null;
21139
21513
  }
21140
21514
  for (; ; ) {
21141
- const dotGit = join8(dir, ".git");
21142
- if (existsSync(dotGit)) {
21515
+ const dotGit = join9(dir, ".git");
21516
+ if (existsSync2(dotGit)) {
21143
21517
  let gitDir = null;
21144
21518
  try {
21145
- if (statSync2(dotGit).isDirectory()) gitDir = dotGit;
21519
+ if (statSync3(dotGit).isDirectory()) gitDir = dotGit;
21146
21520
  else {
21147
21521
  const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync4(dotGit, "utf8"));
21148
- if (m?.[1]) gitDir = isAbsolute2(m[1]) ? m[1] : resolve3(dir, m[1]);
21522
+ if (m?.[1]) gitDir = isAbsolute3(m[1]) ? m[1] : resolve4(dir, m[1]);
21149
21523
  }
21150
21524
  } catch {
21151
21525
  return null;
21152
21526
  }
21153
- if (!gitDir || !existsSync(gitDir)) return null;
21527
+ if (!gitDir || !existsSync2(gitDir)) return null;
21154
21528
  let commonDir = gitDir;
21155
- const commonFile = join8(gitDir, "commondir");
21156
- if (existsSync(commonFile)) {
21529
+ const commonFile = join9(gitDir, "commondir");
21530
+ if (existsSync2(commonFile)) {
21157
21531
  const c = readFileSync4(commonFile, "utf8").trim();
21158
- commonDir = isAbsolute2(c) ? c : resolve3(gitDir, c);
21532
+ commonDir = isAbsolute3(c) ? c : resolve4(gitDir, c);
21159
21533
  }
21160
- const configFiles = [join8(commonDir, "config"), join8(gitDir, "config.worktree")].filter((f, i, all) => all.indexOf(f) === i && existsSync(f));
21534
+ const configFiles = [join9(commonDir, "config"), join9(gitDir, "config.worktree")].filter((f, i, all) => all.indexOf(f) === i && existsSync2(f));
21161
21535
  return { workTree: dir, gitDir, configFiles };
21162
21536
  }
21163
- const up = dirname(dir);
21537
+ const up = dirname2(dir);
21164
21538
  if (up === dir) return null;
21165
21539
  dir = up;
21166
21540
  }
@@ -21209,7 +21583,7 @@ async function guardRepoConfig(target) {
21209
21583
  for (const file of repo.configFiles) {
21210
21584
  let text;
21211
21585
  try {
21212
- if (statSync2(file).size > MAX_CONFIG_BYTES) return { ok: false, kind: "unreadable-config", message: `${file} is too large to check. ${advice}`, keys: [] };
21586
+ if (statSync3(file).size > MAX_CONFIG_BYTES) return { ok: false, kind: "unreadable-config", message: `${file} is too large to check. ${advice}`, keys: [] };
21213
21587
  text = readFileSync4(file, "utf8");
21214
21588
  } catch {
21215
21589
  return { ok: false, kind: "unreadable-config", message: `${file} could not be read. ${advice}`, keys: [] };
@@ -21352,7 +21726,7 @@ function runGit(cwd, args, timeoutMs) {
21352
21726
  async function gitRepoRoot(cwd) {
21353
21727
  const r = await runGit(cwd, ["rev-parse", "--show-toplevel"], 5e3);
21354
21728
  const root = r.ok ? r.stdout.replace(/\n$/, "") : "";
21355
- return root !== "" && isAbsolute3(root) ? root : null;
21729
+ return root !== "" && isAbsolute4(root) ? root : null;
21356
21730
  }
21357
21731
  async function openRepo(target) {
21358
21732
  const guard = await guardRepoConfig(target);
@@ -21379,7 +21753,7 @@ async function shallowBoundaries(repoRoot) {
21379
21753
  const r = await runGit(repoRoot, ["rev-parse", "--git-path", "shallow"], 5e3);
21380
21754
  if (!r.ok) return /* @__PURE__ */ new Set();
21381
21755
  const rel = r.stdout.replace(/\n$/, "");
21382
- const file = isAbsolute3(rel) ? rel : join9(repoRoot, rel);
21756
+ const file = isAbsolute4(rel) ? rel : join10(repoRoot, rel);
21383
21757
  try {
21384
21758
  const text = await readFile5(file, "utf8");
21385
21759
  return new Set(text.split("\n").map((l) => l.trim()).filter((l) => OBJECT_ID.test(l)));
@@ -21439,9 +21813,9 @@ function mapLineToHead(workText, headText, line) {
21439
21813
  }
21440
21814
  var MAX_FILE_BYTES = 8 * 1024 * 1024;
21441
21815
  async function readWorkTree(repoRoot, relFile) {
21442
- const abs = resolve4(repoRoot, relFile);
21443
- const rel = relative3(repoRoot, abs);
21444
- if (rel === "" || rel.startsWith("..") || isAbsolute3(rel)) return null;
21816
+ const abs = resolve5(repoRoot, relFile);
21817
+ const rel = relative4(repoRoot, abs);
21818
+ if (rel === "" || rel.startsWith("..") || isAbsolute4(rel)) return null;
21445
21819
  try {
21446
21820
  if ((await stat2(abs)).size > MAX_FILE_BYTES) return null;
21447
21821
  return await readFile5(abs, "utf8");
@@ -21629,16 +22003,16 @@ A trap token has been copied out of its trap. Find what copied it, remove the co
21629
22003
  }
21630
22004
 
21631
22005
  // ../core/src/on-access.ts
21632
- import { closeSync, existsSync as existsSync3, openSync, readFileSync as readFileSync6, readSync, statSync as statSync4 } from "node:fs";
22006
+ import { closeSync as closeSync2, existsSync as existsSync4, openSync as openSync2, readFileSync as readFileSync6, readSync as readSync2, statSync as statSync5 } from "node:fs";
21633
22007
  import { createHash as createHash3 } from "node:crypto";
21634
- import { basename as basename4, relative as relative5, resolve as resolve6 } from "node:path";
22008
+ import { basename as basename4, relative as relative6, resolve as resolve7 } from "node:path";
21635
22009
 
21636
22010
  // ../core/src/allowed-reads.ts
21637
22011
  init_zod();
21638
22012
  import { createHash as createHash2 } from "node:crypto";
21639
- import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync5, realpathSync as realpathSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
22013
+ import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync5, realpathSync as realpathSync3, renameSync, statSync as statSync4, writeFileSync } from "node:fs";
21640
22014
  import { homedir } from "node:os";
21641
- import { basename as basename3, dirname as dirname2, isAbsolute as isAbsolute4, join as join10, parse, relative as relative4, resolve as resolve5 } from "node:path";
22015
+ import { basename as basename3, dirname as dirname3, isAbsolute as isAbsolute5, join as join11, parse, relative as relative5, resolve as resolve6 } from "node:path";
21642
22016
  var Hash = external_exports.string().regex(/^[0-9a-f]{64}$/);
21643
22017
  var Entry = external_exports.object({ path: external_exports.string().min(1), sha256: Hash });
21644
22018
  var AllowedReadsSchema = external_exports.object({ version: external_exports.literal(2), project: external_exports.string(), entries: external_exports.array(Entry) });
@@ -21648,20 +22022,20 @@ function sha256Bytes(data) {
21648
22022
  }
21649
22023
  function sha256File(file) {
21650
22024
  try {
21651
- if (!existsSync2(file) || !statSync3(file).isFile()) return null;
22025
+ if (!existsSync3(file) || !statSync4(file).isFile()) return null;
21652
22026
  return sha256Bytes(readFileSync5(file));
21653
22027
  } catch {
21654
22028
  return null;
21655
22029
  }
21656
22030
  }
21657
22031
  function realPath(p) {
21658
- const abs = resolve5(p);
22032
+ const abs = resolve6(p);
21659
22033
  const rest = [];
21660
- for (let dir = abs; ; dir = dirname2(dir)) {
22034
+ for (let dir = abs; ; dir = dirname3(dir)) {
21661
22035
  try {
21662
- return join10(realpathSync2(dir), ...rest.reverse());
22036
+ return join11(realpathSync3(dir), ...rest.reverse());
21663
22037
  } catch {
21664
- if (dirname2(dir) === dir) return abs;
22038
+ if (dirname3(dir) === dir) return abs;
21665
22039
  rest.push(basename3(dir));
21666
22040
  }
21667
22041
  }
@@ -21669,21 +22043,21 @@ function realPath(p) {
21669
22043
  function findProjectRoot(cwd) {
21670
22044
  const start = realPath(cwd);
21671
22045
  const { root } = parse(start);
21672
- for (let dir = start; ; dir = dirname2(dir)) {
21673
- if (PROJECT_MARKERS.some((m) => existsSync2(join10(dir, m)))) return dir;
21674
- if (dir === root || dirname2(dir) === dir) break;
22046
+ for (let dir = start; ; dir = dirname3(dir)) {
22047
+ if (PROJECT_MARKERS.some((m) => existsSync3(join11(dir, m)))) return dir;
22048
+ if (dir === root || dirname3(dir) === dir) break;
21675
22049
  }
21676
22050
  return start;
21677
22051
  }
21678
22052
  function isInside(p, dir) {
21679
- const rel = relative4(realPath(dir), realPath(p));
21680
- return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
22053
+ const rel = relative5(realPath(dir), realPath(p));
22054
+ return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
21681
22055
  }
21682
22056
  function allowedReadsLocation(cwd, env = process.env) {
21683
22057
  const project = findProjectRoot(cwd);
21684
22058
  const fromEnv = env["EXORCIST_DIR"];
21685
- const base = fromEnv ? resolve5(project, fromEnv) : join10(homedir(), ".exorcist");
21686
- const file = join10(base, "allowed-reads", `${sha256Bytes(Buffer.from(project, "utf8"))}.json`);
22059
+ const base = fromEnv ? resolve6(project, fromEnv) : join11(homedir(), ".exorcist");
22060
+ const file = join11(base, "allowed-reads", `${sha256Bytes(Buffer.from(project, "utf8"))}.json`);
21687
22061
  if (isInside(file, project)) {
21688
22062
  return { ok: false, error: `Allowances cannot be kept inside the project (${file}): the project itself could plant them. Set EXORCIST_DIR to a folder outside ${project}.` };
21689
22063
  }
@@ -21694,7 +22068,7 @@ function allowKey(realAbsPath, sha2564) {
21694
22068
  }
21695
22069
  function readAllowedReads(cwd, env = process.env) {
21696
22070
  const loc = allowedReadsLocation(cwd, env);
21697
- if (!loc.ok || !existsSync2(loc.file)) return /* @__PURE__ */ new Set();
22071
+ if (!loc.ok || !existsSync3(loc.file)) return /* @__PURE__ */ new Set();
21698
22072
  try {
21699
22073
  if (isInside(loc.file, loc.project)) return /* @__PURE__ */ new Set();
21700
22074
  const result = AllowedReadsSchema.safeParse(JSON.parse(readFileSync5(loc.file, "utf8")));
@@ -21705,14 +22079,14 @@ function readAllowedReads(cwd, env = process.env) {
21705
22079
  }
21706
22080
  }
21707
22081
  function addAllowedRead(cwd, file, env = process.env, expected) {
21708
- const abs = realPath(resolve5(cwd, file));
22082
+ const abs = realPath(resolve6(cwd, file));
21709
22083
  const hash = sha256File(abs);
21710
22084
  if (hash === null) return { ok: false, error: "Cannot read the file, so it cannot be allowed." };
21711
22085
  if (expected !== void 0 && hash !== expected) return { ok: false, error: "The file changed while you were confirming. Nothing was allowed; run allow-read again." };
21712
22086
  const loc = allowedReadsLocation(cwd, env);
21713
22087
  if (!loc.ok) return loc;
21714
22088
  let entries = [];
21715
- if (existsSync2(loc.file)) {
22089
+ if (existsSync3(loc.file)) {
21716
22090
  try {
21717
22091
  const parsed = AllowedReadsSchema.safeParse(JSON.parse(readFileSync5(loc.file, "utf8")));
21718
22092
  if (parsed.success && parsed.data.project === loc.project) entries = parsed.data.entries;
@@ -21720,7 +22094,7 @@ function addAllowedRead(cwd, file, env = process.env, expected) {
21720
22094
  }
21721
22095
  }
21722
22096
  entries = [...entries.filter((e) => e.path !== abs), { path: abs, sha256: hash }];
21723
- mkdirSync(dirname2(loc.file), { recursive: true });
22097
+ mkdirSync(dirname3(loc.file), { recursive: true });
21724
22098
  const tmp = `${loc.file}.tmp-${process.pid}`;
21725
22099
  writeFileSync(tmp, `${JSON.stringify({ version: 2, project: loc.project, entries }, null, 2)}
21726
22100
  `, "utf8");
@@ -21766,11 +22140,11 @@ function regexJobs(defs, role) {
21766
22140
  function sha256FileChunked(file) {
21767
22141
  const h = createHash3("sha256");
21768
22142
  const buf = Buffer.alloc(1048576);
21769
- const fd = openSync(file, "r");
22143
+ const fd = openSync2(file, "r");
21770
22144
  try {
21771
- for (let n = readSync(fd, buf); n > 0; n = readSync(fd, buf)) h.update(buf.subarray(0, n));
22145
+ for (let n = readSync2(fd, buf); n > 0; n = readSync2(fd, buf)) h.update(buf.subarray(0, n));
21772
22146
  } finally {
21773
- closeSync(fd);
22147
+ closeSync2(fd);
21774
22148
  }
21775
22149
  return h.digest("hex");
21776
22150
  }
@@ -21820,7 +22194,7 @@ function extractReadPaths(toolInput, cwd) {
21820
22194
  const resolved = [];
21821
22195
  const seen = /* @__PURE__ */ new Set();
21822
22196
  for (const p of raw) {
21823
- const abs = resolve6(cwd, p);
22197
+ const abs = resolve7(cwd, p);
21824
22198
  if (!seen.has(abs)) {
21825
22199
  seen.add(abs);
21826
22200
  resolved.push(abs);
@@ -21850,7 +22224,7 @@ function allowAdvice(names) {
21850
22224
  ];
21851
22225
  }
21852
22226
  function relLabel(abs, cwd) {
21853
- const rel = relative5(cwd, abs);
22227
+ const rel = relative6(cwd, abs);
21854
22228
  return rel === "" || rel.startsWith("..") ? basename4(abs) : rel;
21855
22229
  }
21856
22230
  function timedOutSerious(f, defs) {
@@ -21889,8 +22263,8 @@ function decideRead(event, defs, opts = {}) {
21889
22263
  let text;
21890
22264
  let bytes;
21891
22265
  try {
21892
- if (!existsSync3(abs)) continue;
21893
- const stat4 = statSync4(abs);
22266
+ if (!existsSync4(abs)) continue;
22267
+ const stat4 = statSync5(abs);
21894
22268
  if (!stat4.isFile()) continue;
21895
22269
  if (stat4.size > MAX_SCAN_BYTES) {
21896
22270
  const big = relLabel(abs, cwd);
@@ -21981,8 +22355,8 @@ function decideRead(event, defs, opts = {}) {
21981
22355
  }
21982
22356
 
21983
22357
  // ../core/src/mcp-write-guard.ts
21984
- import { readFileSync as readFileSync7, statSync as statSync5 } from "node:fs";
21985
- import { isAbsolute as isAbsolute5, join as join11, resolve as resolve7 } from "node:path";
22358
+ import { readFileSync as readFileSync7, statSync as statSync6 } from "node:fs";
22359
+ import { isAbsolute as isAbsolute6, join as join12, resolve as resolve8 } from "node:path";
21986
22360
  var PATH_KEYS = ["path", "file_path", "filePath", "target", "destination", "file"];
21987
22361
  var COMMAND_KEYS = /* @__PURE__ */ new Set(["command", "cmd", "script", "commands"]);
21988
22362
  var MAX_PATH_LEN = 1024;
@@ -22001,9 +22375,9 @@ function expand(raw, home, cwd) {
22001
22375
  }
22002
22376
  }
22003
22377
  if (s === "~") s = home;
22004
- else if (s.startsWith("~/") || s.startsWith("~\\")) s = join11(home, s.slice(2));
22378
+ else if (s.startsWith("~/") || s.startsWith("~\\")) s = join12(home, s.slice(2));
22005
22379
  s = s.replace(/^\$\{HOME\}|^\$HOME(?![A-Za-z0-9_])/, home);
22006
- return isAbsolute5(s) ? resolve7(s) : resolve7(cwd, s);
22380
+ return isAbsolute6(s) ? resolve8(s) : resolve8(cwd, s);
22007
22381
  }
22008
22382
  function isMcpConfigPath(real) {
22009
22383
  const parts = real.split(/[\\/]+/).slice(-3).map((p) => p.toLowerCase());
@@ -22097,11 +22471,11 @@ function writeTargets(seg) {
22097
22471
  const t = args.findIndex((a) => a === "-t" || a === "--target-directory");
22098
22472
  if (t >= 0 && args[t + 1] !== void 0) {
22099
22473
  const dir = args[t + 1];
22100
- out.push(dir, ...operands.filter((a) => a !== dir).map((a) => join11(dir, a.split("/").pop() ?? a)));
22474
+ out.push(dir, ...operands.filter((a) => a !== dir).map((a) => join12(dir, a.split("/").pop() ?? a)));
22101
22475
  } else if (operands.length >= 2) out.push(operands[operands.length - 1]);
22102
22476
  if (operands.length >= 2) {
22103
22477
  const last = operands[operands.length - 1];
22104
- if (/[\\/]$/.test(last)) out.push(join11(last, operands[0].split("/").pop() ?? ""));
22478
+ if (/[\\/]$/.test(last)) out.push(join12(last, operands[0].split("/").pop() ?? ""));
22105
22479
  }
22106
22480
  }
22107
22481
  return out;
@@ -22134,7 +22508,7 @@ var MOVERS = /* @__PURE__ */ new Set(["cp", "mv", "install", "ln"]);
22134
22508
  var REMOVERS = /* @__PURE__ */ new Set(["rm", "rmdir", "unlink", "shred", "touch", "truncate", "mkdir"]);
22135
22509
  function prepare(event, cwd) {
22136
22510
  if (!isRecord(event) || !isRecord(event["tool_input"])) return null;
22137
- const base = typeof event["cwd"] === "string" && event["cwd"] !== "" ? resolve7(cwd, event["cwd"]) : resolve7(cwd);
22511
+ const base = typeof event["cwd"] === "string" && event["cwd"] !== "" ? resolve8(cwd, event["cwd"]) : resolve8(cwd);
22138
22512
  const toolName = typeof event["tool_name"] === "string" ? event["tool_name"] : "";
22139
22513
  const shellTool = /shell|bash|exec|command|terminal/i.test(toolName);
22140
22514
  const input = event["tool_input"];
@@ -22257,7 +22631,7 @@ function readString(text, start) {
22257
22631
  }
22258
22632
  function readDisk(path) {
22259
22633
  try {
22260
- if (statSync5(path).size > MAX_READ_BYTES) return void 0;
22634
+ if (statSync6(path).size > MAX_READ_BYTES) return void 0;
22261
22635
  return readFileSync7(path, "utf8");
22262
22636
  } catch {
22263
22637
  return void 0;
@@ -22310,7 +22684,7 @@ function isGuardFileWrite(event, home, cwd) {
22310
22684
  }
22311
22685
  function decideMcpWrite(event, home, cwd) {
22312
22686
  if (!isRecord(event) || !isRecord(event["tool_input"])) return { target: "other" };
22313
- const base = typeof event["cwd"] === "string" && event["cwd"] !== "" ? resolve7(cwd, event["cwd"]) : resolve7(cwd);
22687
+ const base = typeof event["cwd"] === "string" && event["cwd"] !== "" ? resolve8(cwd, event["cwd"]) : resolve8(cwd);
22314
22688
  const toolName = typeof event["tool_name"] === "string" ? event["tool_name"] : "";
22315
22689
  const shellTool = /shell|bash|exec|command|terminal/i.test(toolName);
22316
22690
  const paths2 = [];
@@ -22505,7 +22879,7 @@ function envWriteBlockMessage(d, envValues = []) {
22505
22879
 
22506
22880
  // ../core/src/env-values.ts
22507
22881
  import { lstatSync, readdirSync, readFileSync as readFileSync8 } from "node:fs";
22508
- import { join as join12 } from "node:path";
22882
+ import { join as join13 } from "node:path";
22509
22883
  var MIN_ENV_VALUE_LENGTH = 8;
22510
22884
  var MAX_ENV_FILE_BYTES = 256 * 1024;
22511
22885
  var COMMON_WORDS = /* @__PURE__ */ new Set([
@@ -22575,7 +22949,7 @@ function loadEnvValues(cwd) {
22575
22949
  const seen = /* @__PURE__ */ new Set();
22576
22950
  for (const name of names) {
22577
22951
  try {
22578
- const path = join12(cwd, name);
22952
+ const path = join13(cwd, name);
22579
22953
  const st = lstatSync(path);
22580
22954
  if (!st.isFile() || st.size > MAX_ENV_FILE_BYTES) continue;
22581
22955
  for (const v of parseEnvValues(readFileSync8(path, "utf8"))) {
@@ -22676,9 +23050,9 @@ var BUNDLED_DEFINITIONS_DATE = "2026-11-24";
22676
23050
  // ../core/src/liveupdate.ts
22677
23051
  init_zod();
22678
23052
  import { createHash as createHash4, createPrivateKey, createPublicKey, generateKeyPairSync, randomBytes as randomBytes2, sign as edSign, verify as edVerify } from "node:crypto";
22679
- import { closeSync as closeSync2, fstatSync, lstatSync as lstatSync2, mkdirSync as mkdirSync2, openSync as openSync2, readFileSync as readFileSync9, readSync as readSync2, readdirSync as readdirSync2, renameSync as renameSync2, rmSync, statSync as statSync6, writeFileSync as writeFileSync2 } from "node:fs";
23053
+ import { closeSync as closeSync3, fstatSync, lstatSync as lstatSync2, mkdirSync as mkdirSync2, openSync as openSync3, readFileSync as readFileSync9, readSync as readSync3, readdirSync as readdirSync2, renameSync as renameSync2, rmSync, statSync as statSync7, writeFileSync as writeFileSync2 } from "node:fs";
22680
23054
  import { homedir as homedir2 } from "node:os";
22681
- import { basename as basename5, join as join13, resolve as resolve8 } from "node:path";
23055
+ import { basename as basename5, join as join14, resolve as resolve9 } from "node:path";
22682
23056
  var DEFINITIONS_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
22683
23057
  MCowBQYDK2VwAyEAn4o+dmOJXIzsygT2CF/3go/1E/bk9Ub16r4hGtJJjhM=
22684
23058
  -----END PUBLIC KEY-----
@@ -22862,19 +23236,19 @@ function checkBundle(tar, o = {}) {
22862
23236
  }
22863
23237
  function installedDefinitionsRoot(env = process.env) {
22864
23238
  const fromEnv = env["EXORCIST_DEFINITIONS_HOME"];
22865
- if (fromEnv) return resolve8(fromEnv);
22866
- return join13(env["HOME"] || env["USERPROFILE"] || homedir2(), ".exorcist", "definitions");
23239
+ if (fromEnv) return resolve9(fromEnv);
23240
+ return join14(env["HOME"] || env["USERPROFILE"] || homedir2(), ".exorcist", "definitions");
22867
23241
  }
22868
23242
  function verifySetFolder(dir, expectedVersion, publicKeyPem) {
22869
23243
  try {
22870
23244
  if (!lstatSync2(dir).isDirectory()) return fail("not a real folder (a symlink or a file)");
22871
- const defsDir = join13(dir, "definitions");
22872
- for (const [p, kind] of [[join13(dir, MANIFEST_NAME), "file"], [join13(dir, SIGNATURE_NAME), "file"], [defsDir, "dir"]]) {
23245
+ const defsDir = join14(dir, "definitions");
23246
+ for (const [p, kind] of [[join14(dir, MANIFEST_NAME), "file"], [join14(dir, SIGNATURE_NAME), "file"], [defsDir, "dir"]]) {
22873
23247
  const st = lstatSync2(p);
22874
23248
  if (kind === "file" ? !st.isFile() : !st.isDirectory()) return fail(`${basename5(p)} is not a plain ${kind === "file" ? "file" : "folder"}`);
22875
23249
  }
22876
- const manifestBytes = readFileSync9(join13(dir, MANIFEST_NAME));
22877
- const bad = verifySignature(manifestBytes, readFileSync9(join13(dir, SIGNATURE_NAME)), publicKeyPem);
23250
+ const manifestBytes = readFileSync9(join14(dir, MANIFEST_NAME));
23251
+ const bad = verifySignature(manifestBytes, readFileSync9(join14(dir, SIGNATURE_NAME)), publicKeyPem);
22878
23252
  if (bad) return fail("the manifest signature does not verify");
22879
23253
  const m = parseManifest(manifestBytes);
22880
23254
  if (!m.ok) return m;
@@ -22884,7 +23258,7 @@ function verifySetFolder(dir, expectedVersion, publicKeyPem) {
22884
23258
  const extra = onDisk.filter((n) => !listed.includes(n));
22885
23259
  if (extra.length > 0) return fail(`definitions/ holds files the manifest does not list: ${extra.map((n) => printable(n)).join(", ")}`);
22886
23260
  for (const name of listed) {
22887
- const p = join13(defsDir, name);
23261
+ const p = join14(defsDir, name);
22888
23262
  let st;
22889
23263
  try {
22890
23264
  st = lstatSync2(p);
@@ -22911,7 +23285,7 @@ function inspectInstalledSets(root, publicKeyPem = DEFINITIONS_PUBLIC_KEY) {
22911
23285
  } catch {
22912
23286
  return [];
22913
23287
  }
22914
- return names.filter(isValidVersion).sort((a, b) => compareVersions(b, a)).map((name) => ({ name, dir: join13(root, name), ...verifyInstalledSet(join13(root, name), publicKeyPem) }));
23288
+ return names.filter(isValidVersion).sort((a, b) => compareVersions(b, a)).map((name) => ({ name, dir: join14(root, name), ...verifyInstalledSet(join14(root, name), publicKeyPem) }));
22915
23289
  }
22916
23290
  function findActiveInstalledSet(o = {}) {
22917
23291
  const root = o.root ?? installedDefinitionsRoot(o.env);
@@ -22924,7 +23298,7 @@ function findActiveInstalledSet(o = {}) {
22924
23298
  }
22925
23299
  const newer = names.filter((n) => isValidVersion(n) && compareVersions(n, BUNDLED_DEFINITIONS_VERSION) > 0).sort((a, b) => compareVersions(b, a));
22926
23300
  for (const name of newer) {
22927
- const r = verifyInstalledSet(join13(root, name), pem);
23301
+ const r = verifyInstalledSet(join14(root, name), pem);
22928
23302
  if (r.ok) return r.set;
22929
23303
  }
22930
23304
  return null;
@@ -22943,7 +23317,7 @@ function installBundle(tar, o) {
22943
23317
  if (compareVersions(version2, o.currentVersion) <= 0) {
22944
23318
  return fail(`The bundle is version ${version2}, which is not newer than the definitions in use (${o.currentVersion}).`);
22945
23319
  }
22946
- const final = join13(o.root, version2);
23320
+ const final = join14(o.root, version2);
22947
23321
  let exists = true;
22948
23322
  try {
22949
23323
  lstatSync2(final);
@@ -22951,14 +23325,14 @@ function installBundle(tar, o) {
22951
23325
  exists = false;
22952
23326
  }
22953
23327
  if (exists) return fail(`${final} already exists. Remove it to install version ${version2} again.`);
22954
- const staging = join13(o.root, `.staging-${randomBytes2(6).toString("hex")}`);
23328
+ const staging = join14(o.root, `.staging-${randomBytes2(6).toString("hex")}`);
22955
23329
  try {
22956
23330
  mkdirSync2(o.root, { recursive: true, mode: 448 });
22957
23331
  mkdirSync2(staging, { mode: 448 });
22958
- mkdirSync2(join13(staging, "definitions"));
22959
- for (const f of b.files) writeFileSync2(join13(staging, f.path), f.data, { flag: "wx", mode: 420 });
22960
- writeFileSync2(join13(staging, MANIFEST_NAME), b.manifestBytes, { flag: "wx", mode: 420 });
22961
- writeFileSync2(join13(staging, SIGNATURE_NAME), b.sig, { flag: "wx", mode: 420 });
23332
+ mkdirSync2(join14(staging, "definitions"));
23333
+ for (const f of b.files) writeFileSync2(join14(staging, f.path), f.data, { flag: "wx", mode: 420 });
23334
+ writeFileSync2(join14(staging, MANIFEST_NAME), b.manifestBytes, { flag: "wx", mode: 420 });
23335
+ writeFileSync2(join14(staging, SIGNATURE_NAME), b.sig, { flag: "wx", mode: 420 });
22962
23336
  const check3 = verifySetFolder(staging, version2, pem);
22963
23337
  if (!check3.ok) return fail(`The staged copy did not verify (${check3.error}).`);
22964
23338
  renameSync2(staging, final);
@@ -23046,15 +23420,15 @@ async function downloadBundle(url, o = {}) {
23046
23420
  function readBundleFile(path, limitBytes = DOWNLOAD_LIMIT_BYTES) {
23047
23421
  let fd = null;
23048
23422
  try {
23049
- if (!statSync6(path).isFile()) return fail(`${path} is not a regular file.`);
23050
- fd = openSync2(path, "r");
23423
+ if (!statSync7(path).isFile()) return fail(`${path} is not a regular file.`);
23424
+ fd = openSync3(path, "r");
23051
23425
  const st = fstatSync(fd);
23052
23426
  if (!st.isFile()) return fail(`${path} is not a regular file.`);
23053
23427
  if (st.size > limitBytes) return fail(`The bundle is larger than the ${limitBytes / 1048576} MB limit.`);
23054
23428
  const buf = Buffer.alloc(limitBytes + 1);
23055
23429
  let n = 0;
23056
23430
  for (; ; ) {
23057
- const r = readSync2(fd, buf, n, buf.length - n, null);
23431
+ const r = readSync3(fd, buf, n, buf.length - n, null);
23058
23432
  if (r === 0) break;
23059
23433
  n += r;
23060
23434
  if (n > limitBytes) return fail(`The bundle is larger than the ${limitBytes / 1048576} MB limit.`);
@@ -23064,7 +23438,7 @@ function readBundleFile(path, limitBytes = DOWNLOAD_LIMIT_BYTES) {
23064
23438
  } catch (e) {
23065
23439
  return fail(`Could not read ${path} (${e.code ?? "error"}).`);
23066
23440
  } finally {
23067
- if (fd !== null) closeSync2(fd);
23441
+ if (fd !== null) closeSync3(fd);
23068
23442
  }
23069
23443
  }
23070
23444
  async function loadBundleSource(from, o = {}) {
@@ -23072,7 +23446,7 @@ async function loadBundleSource(from, o = {}) {
23072
23446
  if (!/^https:\/\//i.test(from)) return fail("The update source must be an https:// URL or a local file.");
23073
23447
  return downloadBundle(from, { ...o.fetchImpl ? { fetchImpl: o.fetchImpl } : {}, ...o.timeoutMs ? { timeoutMs: o.timeoutMs } : {} });
23074
23448
  }
23075
- return readBundleFile(resolve8(o.cwd ?? process.cwd(), from));
23449
+ return readBundleFile(resolve9(o.cwd ?? process.cwd(), from));
23076
23450
  }
23077
23451
  async function runLiveUpdate(o) {
23078
23452
  const lookup = { root: o.root, ...o.publicKeyPem ? { publicKeyPem: o.publicKeyPem } : {} };
@@ -23319,8 +23693,314 @@ var SessionJsonSchema = external_exports.object({
23319
23693
  approveForMe: external_exports.boolean().optional()
23320
23694
  }).passthrough();
23321
23695
 
23696
+ // ../core/src/run-scripts-guard.ts
23697
+ import { existsSync as existsSync5, realpathSync as realpathSync4, statSync as statSync8 } from "node:fs";
23698
+ import { isAbsolute as isAbsolute7, join as join15, relative as relative7, resolve as resolve10, sep as sep2 } from "node:path";
23699
+ import { readFileSync as readFileSync10 } from "node:fs";
23700
+ var MAX_PKG_BYTES = 1048576;
23701
+ var PM = /* @__PURE__ */ new Set(["npm", "pnpm", "yarn", "npx", "pnpx"]);
23702
+ var VALUE_FLAGS2 = /* @__PURE__ */ new Set(["--prefix", "-C", "--cwd", "--workspace", "-w", "--filter", "-F", "--package", "-p", "--loglevel", "--registry", "--userconfig"]);
23703
+ var DIR_FLAGS = /* @__PURE__ */ new Set(["--prefix", "-C", "--cwd"]);
23704
+ var INSTALL_SET = [...INSTALL_HOOKS];
23705
+ var withHooks = (n) => [`pre${n}`, n, `post${n}`];
23706
+ function namesFor(pm, sub, arg, scripts) {
23707
+ const s = sub ?? "";
23708
+ if (pm === "npm" || pm === "pnpm" || pm === "yarn") {
23709
+ if (["test", "t", "tst"].includes(s)) return withHooks("test");
23710
+ if (["start", "stop", "restart"].includes(s)) return withHooks(s);
23711
+ if (["run", "run-script", "rum", "urn"].includes(s)) return arg === void 0 ? [] : withHooks(arg);
23712
+ if (["install", "i", "add", "ci", "install-test", "it", "cit", "isntall"].includes(s)) return [...INSTALL_SET, ...s === "it" || s === "install-test" || s === "cit" ? withHooks("test") : []];
23713
+ if (pm === "yarn" && sub === void 0) return INSTALL_SET;
23714
+ if (["publish", "pack", "version"].includes(s)) return [...withHooks(s), "prepare", "prepublishOnly", "prepack", "postpack"];
23715
+ if ((pm === "pnpm" || pm === "yarn") && scripts.has(s)) return withHooks(s);
23716
+ }
23717
+ return [];
23718
+ }
23719
+ function afterFlags(words3, from) {
23720
+ const rest = [];
23721
+ let dir = null;
23722
+ for (let i = from; i < words3.length; i++) {
23723
+ const w = words3[i] ?? "";
23724
+ if (w === "--") {
23725
+ rest.push(...words3.slice(i + 1));
23726
+ break;
23727
+ }
23728
+ if (w.startsWith("-")) {
23729
+ const eq = w.indexOf("=");
23730
+ const flag = eq > 0 ? w.slice(0, eq) : w;
23731
+ if (eq > 0) {
23732
+ if (DIR_FLAGS.has(flag)) dir = w.slice(eq + 1);
23733
+ continue;
23734
+ }
23735
+ if (VALUE_FLAGS2.has(flag)) {
23736
+ if (DIR_FLAGS.has(flag)) dir = words3[i + 1] ?? null;
23737
+ i += 1;
23738
+ }
23739
+ continue;
23740
+ }
23741
+ rest.push(w);
23742
+ }
23743
+ return { rest, dir };
23744
+ }
23745
+ function plansForCommand(command, cwd, scriptsOf) {
23746
+ const split = splitShell(command);
23747
+ if (!split.ok) return null;
23748
+ const plans = [];
23749
+ let dir = cwd;
23750
+ for (const raw of split.segments) {
23751
+ const words3 = stripPrefixes(raw);
23752
+ const head = words3[0];
23753
+ if (head === void 0) continue;
23754
+ const base = head.split("/").pop() ?? head;
23755
+ if (base === "cd" || base === "pushd") {
23756
+ const target = words3[1];
23757
+ if (target !== void 0 && isPlainWord(target) && !target.startsWith("-")) dir = resolve10(dir, target);
23758
+ continue;
23759
+ }
23760
+ if (!PM.has(base)) continue;
23761
+ const { rest, dir: flagDir } = afterFlags(words3, 1);
23762
+ const where2 = flagDir !== null && isPlainWord(flagDir) ? resolve10(dir, flagDir) : dir;
23763
+ const sub = rest[0];
23764
+ if (base === "npx" || base === "pnpx" || base === "npm" && (sub === "exec" || sub === "x") || base === "pnpm" && sub === "exec") {
23765
+ const bin = base === "npx" || base === "pnpx" ? rest[0] : rest[1];
23766
+ if (bin !== void 0 && isPlainWord(bin)) plans.push({ dir: where2, names: [], bin });
23767
+ continue;
23768
+ }
23769
+ const names = namesFor(base, sub, rest[1], scriptsOf(where2));
23770
+ if (names.length > 0) plans.push({ dir: where2, names });
23771
+ }
23772
+ return plans;
23773
+ }
23774
+ function readPackage(dir) {
23775
+ try {
23776
+ const p = join15(dir, "package.json");
23777
+ if (!existsSync5(p) || statSync8(p).size > MAX_PKG_BYTES) return null;
23778
+ return readFileSync10(p, "utf8");
23779
+ } catch {
23780
+ return null;
23781
+ }
23782
+ }
23783
+ function scriptNamesOf(dir) {
23784
+ const text = readPackage(dir);
23785
+ if (text === null) return /* @__PURE__ */ new Set();
23786
+ try {
23787
+ const s = JSON.parse(text).scripts;
23788
+ return new Set(typeof s === "object" && s !== null ? Object.keys(s) : []);
23789
+ } catch {
23790
+ return /* @__PURE__ */ new Set();
23791
+ }
23792
+ }
23793
+ var inside2 = (root, p) => {
23794
+ const r = relative7(root, p);
23795
+ return r !== "" && !r.startsWith("..") && !isAbsolute7(r) && !r.split(sep2).includes("..");
23796
+ };
23797
+ function localBinHit(dir, workspace, bin) {
23798
+ try {
23799
+ const link = join15(dir, "node_modules", ".bin", bin);
23800
+ if (bin.includes("/") || !existsSync5(link)) return null;
23801
+ const real = realpathSync4(link);
23802
+ const ws = realpathSync4(workspace);
23803
+ if (!inside2(ws, real) || real.split(sep2).includes("node_modules")) return null;
23804
+ const text = readLocalText(ws, relative7(ws, real));
23805
+ if (text === null) return null;
23806
+ const a = analyzeSource(text);
23807
+ if (!a.secret || !a.send) return null;
23808
+ const file = relative7(ws, real);
23809
+ return { script: `npx ${bin}`, scriptText: bin, line: 1, col: 1, span: bin, file, secret: a.secret, send: a.send };
23810
+ } catch {
23811
+ return null;
23812
+ }
23813
+ }
23814
+ var isShellTool = (tool) => tool === void 0 || typeof tool === "string" && /shell|bash|command|exec/i.test(tool);
23815
+ function eventCommand(event) {
23816
+ if (typeof event !== "object" || event === null) return null;
23817
+ const e = event;
23818
+ if (!isShellTool(e["tool_name"])) return null;
23819
+ const input = e["tool_input"];
23820
+ if (typeof input !== "object" || input === null) return null;
23821
+ const c = input["command"] ?? input["cmd"];
23822
+ return typeof c === "string" && c !== "" ? c : null;
23823
+ }
23824
+ function eventCwd(event, fallback) {
23825
+ const c = typeof event === "object" && event !== null ? event["cwd"] : void 0;
23826
+ return typeof c === "string" && isAbsolute7(c) ? c : fallback;
23827
+ }
23828
+ function decideRunScripts(event, fallbackCwd) {
23829
+ try {
23830
+ const command = eventCommand(event);
23831
+ if (command === null) return { block: false };
23832
+ const cwd = eventCwd(event, fallbackCwd);
23833
+ const plans = plansForCommand(command, cwd, scriptNamesOf);
23834
+ if (plans === null) return { block: false, parseFailed: true };
23835
+ for (const plan of plans) {
23836
+ if (plan.bin !== void 0) {
23837
+ const hit2 = localBinHit(plan.dir, cwd, plan.bin);
23838
+ if (hit2) return { block: true, hit: hit2, dir: plan.dir };
23839
+ continue;
23840
+ }
23841
+ const pkgText = readPackage(plan.dir);
23842
+ if (pkgText === null) continue;
23843
+ const hits = lifecycleFindings({ pkgText, readLocal: (rel) => readLocalText(plan.dir, rel), names: plan.names });
23844
+ const hit = hits[0];
23845
+ if (hit) return { block: true, hit, dir: plan.dir };
23846
+ }
23847
+ return { block: false };
23848
+ } catch {
23849
+ return { block: false };
23850
+ }
23851
+ }
23852
+ function runScriptsBlockMessage(hit) {
23853
+ const file = hit.file === null ? "its own text" : shownName(hit.file);
23854
+ return [
23855
+ "Exorcist 98 blocked this command: a package script it would run reads secrets and sends them out. Nothing was run.",
23856
+ ` script ${shownName(hit.script)} in package.json, which uses ${file}`,
23857
+ hit.file === null ? ` The script text reads ${hit.secret.label} and sends data out (${hit.send.label}).` : ` The file reads ${hit.secret.label} (line ${hit.secret.line}) and sends data out through ${hit.send.label} (line ${hit.send.line}).`,
23858
+ "Do not look for a way around this block (running the file by hand, editing the script, using another package manager).",
23859
+ "Tell the user what was blocked. They can read the file and run `exorcist scan` on the project before deciding."
23860
+ ].join("\n");
23861
+ }
23862
+
23863
+ // ../core/src/shell-read-guard.ts
23864
+ import { readdirSync as readdirSync3, statSync as statSync9 } from "node:fs";
23865
+ import { basename as basename6, dirname as dirname4, isAbsolute as isAbsolute8, relative as relative8, resolve as resolve11, sep as sep3 } from "node:path";
23866
+ var MAX_TARGETS = 100;
23867
+ var MAX_TOTAL_BYTES = 32 * 1024 * 1024;
23868
+ var VALUE_FLAGS3 = {
23869
+ cat: /* @__PURE__ */ new Set(),
23870
+ head: /* @__PURE__ */ new Set(["-n", "-c", "--lines", "--bytes"]),
23871
+ tail: /* @__PURE__ */ new Set(["-n", "-c", "--lines", "--bytes", "-s", "--sleep-interval"]),
23872
+ less: /* @__PURE__ */ new Set(["-b", "-h", "-j", "-p", "-P", "-t", "-T", "-x", "-y", "-z"]),
23873
+ more: /* @__PURE__ */ new Set(["-n", "-p"]),
23874
+ bat: /* @__PURE__ */ new Set(["-l", "--language", "-r", "--line-range", "--theme", "--style", "--tabs", "--wrap"]),
23875
+ batcat: /* @__PURE__ */ new Set(["-l", "--language", "-r", "--line-range", "--theme", "--style", "--tabs", "--wrap"]),
23876
+ nl: /* @__PURE__ */ new Set(["-b", "-d", "-f", "-h", "-i", "-l", "-n", "-s", "-v", "-w"]),
23877
+ sed: /* @__PURE__ */ new Set(["-e", "-f", "--expression", "--file", "-l", "-E", "-s"]),
23878
+ awk: /* @__PURE__ */ new Set(["-F", "-v", "-f", "--file", "-e", "--source"]),
23879
+ gawk: /* @__PURE__ */ new Set(["-F", "-v", "-f", "--file", "-e", "--source"]),
23880
+ grep: /* @__PURE__ */ new Set(["-e", "-f", "-m", "-A", "-B", "-C", "--include", "--exclude", "--exclude-dir", "--regexp", "--file", "--max-count", "--label", "--color", "-d", "-D"])
23881
+ };
23882
+ VALUE_FLAGS3["egrep"] = VALUE_FLAGS3["grep"] ?? /* @__PURE__ */ new Set();
23883
+ VALUE_FLAGS3["fgrep"] = VALUE_FLAGS3["grep"] ?? /* @__PURE__ */ new Set();
23884
+ var FILE_PROGRAMS = new Set(Object.keys(VALUE_FLAGS3));
23885
+ var FIRST_IS_PROGRAM = /* @__PURE__ */ new Set(["sed", "awk", "gawk", "grep", "egrep", "fgrep"]);
23886
+ var GIVES_PROGRAM = /* @__PURE__ */ new Set(["-e", "-f", "--expression", "--file", "--regexp", "--source"]);
23887
+ function readTargets(words3) {
23888
+ const w = stripPrefixes(words3);
23889
+ const head = w[0];
23890
+ if (head === void 0) return [];
23891
+ const prog = head.split("/").pop() ?? head;
23892
+ if (!FILE_PROGRAMS.has(prog)) return [];
23893
+ if (prog === "sed" && !w.some((x) => /^-[A-Za-z]*n[A-Za-z]*$/.test(x) || x === "--quiet" || x === "--silent")) return [];
23894
+ const valueFlags = VALUE_FLAGS3[prog] ?? /* @__PURE__ */ new Set();
23895
+ const files = [];
23896
+ let programGiven = !FIRST_IS_PROGRAM.has(prog);
23897
+ let afterDashes = false;
23898
+ for (let i = 1; i < w.length; i++) {
23899
+ const a = w[i] ?? "";
23900
+ if (!afterDashes && a === "--") {
23901
+ afterDashes = true;
23902
+ continue;
23903
+ }
23904
+ if (!afterDashes && a.startsWith("-") && a !== "-") {
23905
+ if (GIVES_PROGRAM.has(a)) programGiven = true;
23906
+ if (valueFlags.has(a)) {
23907
+ if ((a === "-f" || a === "--file") && prog !== "grep" && prog !== "egrep" && prog !== "fgrep") {
23908
+ const v = w[i + 1];
23909
+ if (v !== void 0) files.push(v);
23910
+ }
23911
+ i += 1;
23912
+ }
23913
+ continue;
23914
+ }
23915
+ if (!programGiven) {
23916
+ programGiven = true;
23917
+ continue;
23918
+ }
23919
+ files.push(a);
23920
+ }
23921
+ return files;
23922
+ }
23923
+ function isSimpleGlob(word) {
23924
+ if (/[$`[\]{}~]/.test(word) || word.includes("\0") || !/[*?]/.test(word) || word.includes("**")) return false;
23925
+ const dir = dirname4(word);
23926
+ return !/[*?]/.test(dir) && !/[*?]/.test(word.slice(0, word.length - basename6(word).length));
23927
+ }
23928
+ function expandSimpleGlob(word, dir) {
23929
+ try {
23930
+ const base = basename6(word);
23931
+ const re2 = new RegExp(`^${base.replace(/[.+^${}()|\\[\]]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".")}$`);
23932
+ const folder = resolve11(dir, dirname4(word));
23933
+ return readdirSync3(folder).filter((n) => re2.test(n) && (!n.startsWith(".") || base.startsWith("."))).sort().slice(0, MAX_TARGETS + 1).map((n) => resolve11(folder, n));
23934
+ } catch {
23935
+ return [];
23936
+ }
23937
+ }
23938
+ function sizeOf(p) {
23939
+ try {
23940
+ return statSync9(p).size;
23941
+ } catch {
23942
+ return 0;
23943
+ }
23944
+ }
23945
+ function shellReadPlan(command, cwd, workspace) {
23946
+ const split = splitShell(command);
23947
+ if (!split.ok) return null;
23948
+ const out = [];
23949
+ let tooMany = false;
23950
+ let dir = cwd;
23951
+ for (const raw of split.segments) {
23952
+ const words3 = stripPrefixes(raw);
23953
+ const base = (words3[0] ?? "").split("/").pop();
23954
+ if (base === "cd" || base === "pushd") {
23955
+ const t = words3[1];
23956
+ if (t !== void 0 && isPlainWord(t) && !t.startsWith("-")) dir = resolve11(dir, t);
23957
+ continue;
23958
+ }
23959
+ for (const f of readTargets(words3)) {
23960
+ const candidates = isPlainWord(f) ? [resolve11(dir, f)] : isSimpleGlob(f) ? expandSimpleGlob(f, dir) : [];
23961
+ for (const abs of candidates) {
23962
+ const rel = relative8(workspace, abs);
23963
+ if (rel === "" || rel.startsWith("..") || isAbsolute8(rel) || rel.split(sep3).includes("..")) continue;
23964
+ if (!out.includes(abs)) out.push(abs);
23965
+ if (out.length > MAX_TARGETS) return { paths: out.slice(0, MAX_TARGETS), tooMany: true };
23966
+ }
23967
+ }
23968
+ }
23969
+ let total = 0;
23970
+ for (const p of out) {
23971
+ total += sizeOf(p);
23972
+ if (total > MAX_TOTAL_BYTES) {
23973
+ tooMany = true;
23974
+ break;
23975
+ }
23976
+ }
23977
+ return { paths: out, tooMany };
23978
+ }
23979
+ function tooManyFilesMessage() {
23980
+ return `Exorcist 98 blocked this command, which reads files through the shell: it names too many files to check (more than ${MAX_TARGETS} files, or more than ${MAX_TOTAL_BYTES / (1024 * 1024)} MB in all). A part of the list was not scanned, so none of it is let through. Read fewer files at a time, for example one folder or one file per command. Do not look for a way around this block.`;
23981
+ }
23982
+ function decideShellRead(event, defs, opts = {}, fallbackCwd = process.cwd()) {
23983
+ try {
23984
+ const command = eventCommand(event);
23985
+ if (command === null) return { exitCode: 0, message: "" };
23986
+ const cwd = eventCwd(event, opts.cwd ?? fallbackCwd);
23987
+ const plan = shellReadPlan(command, cwd, cwd);
23988
+ if (plan === null) return { exitCode: 0, message: "" };
23989
+ if (plan.tooMany) return { exitCode: 2, message: tooManyFilesMessage() };
23990
+ const paths2 = plan.paths;
23991
+ if (paths2.length === 0) return { exitCode: 0, message: "" };
23992
+ const d = decideRead({ tool_name: "read", cwd, tool_input: { paths: paths2 } }, defs, { ...opts, cwd });
23993
+ if (d.exitCode === 2) {
23994
+ return { exitCode: 2, message: d.message.replace("Exorcist 98 blocked this read:", "Exorcist 98 blocked this command, which reads a file through the shell:") };
23995
+ }
23996
+ return d;
23997
+ } catch {
23998
+ return { exitCode: 0, message: "" };
23999
+ }
24000
+ }
24001
+
23322
24002
  // src/commands/approve.ts
23323
- import { existsSync as existsSync13, readFileSync as readFileSync18 } from "node:fs";
24003
+ import { existsSync as existsSync15, readFileSync as readFileSync19 } from "node:fs";
23324
24004
 
23325
24005
  // ../shield/src/hash.ts
23326
24006
  import { createHash as createHash6 } from "node:crypto";
@@ -23398,7 +24078,7 @@ var LineSplitter = class {
23398
24078
 
23399
24079
  // ../shield/src/policy.ts
23400
24080
  init_zod();
23401
- import { existsSync as existsSync4, readFileSync as readFileSync10 } from "node:fs";
24081
+ import { existsSync as existsSync6, readFileSync as readFileSync11 } from "node:fs";
23402
24082
  var PolicySchema = external_exports.object({
23403
24083
  allowedHosts: external_exports.array(external_exports.string().min(1)).default([]),
23404
24084
  mode: external_exports.enum(["enforce", "monitor"]).default("enforce"),
@@ -23466,10 +24146,10 @@ var PolicySchema = external_exports.object({
23466
24146
  }).strict();
23467
24147
  var DEFAULT_POLICY = { allowedHosts: [], mode: "enforce", autoQuarantine: false, firstUse: "pin", notify: true, verifyCalls: true, launchPin: "block", aiReview: false, sessionGuard: "hold" };
23468
24148
  function loadPolicy(path) {
23469
- if (!existsSync4(path)) return { ok: true, policy: DEFAULT_POLICY };
24149
+ if (!existsSync6(path)) return { ok: true, policy: DEFAULT_POLICY };
23470
24150
  let json2;
23471
24151
  try {
23472
- json2 = JSON.parse(readFileSync10(path, "utf8"));
24152
+ json2 = JSON.parse(readFileSync11(path, "utf8"));
23473
24153
  } catch {
23474
24154
  return { ok: false, error: `The policy file ${path} is not valid JSON.` };
23475
24155
  }
@@ -23493,8 +24173,8 @@ function hostAllowed(host, allowed) {
23493
24173
 
23494
24174
  // ../shield/src/state.ts
23495
24175
  init_zod();
23496
- import { appendFileSync, existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync11, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
23497
- import { dirname as dirname3, join as join14 } from "node:path";
24176
+ import { appendFileSync, existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync12, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
24177
+ import { dirname as dirname5, join as join16 } from "node:path";
23498
24178
  var Sha256 = external_exports.string().regex(/^[0-9a-f]{64}$/);
23499
24179
  var PinSchema = external_exports.object({
23500
24180
  hash: Sha256,
@@ -23538,15 +24218,15 @@ var StateSchema = external_exports.object({
23538
24218
  servers: external_exports.record(ServerStateSchema).default({})
23539
24219
  });
23540
24220
  var emptyState = () => ({ version: 1, servers: {} });
23541
- var statePath = (dir) => join14(dir, "pins.json");
23542
- var policyPath = (dir) => join14(dir, "policy.json");
23543
- var alertsPath = (dir) => join14(dir, "alerts.jsonl");
23544
- var vaultPath = (dir) => join14(dir, "vault");
24221
+ var statePath = (dir) => join16(dir, "pins.json");
24222
+ var policyPath = (dir) => join16(dir, "policy.json");
24223
+ var alertsPath = (dir) => join16(dir, "alerts.jsonl");
24224
+ var vaultPath = (dir) => join16(dir, "vault");
23545
24225
  function loadState(path) {
23546
- if (!existsSync5(path)) return { ok: true, state: emptyState() };
24226
+ if (!existsSync7(path)) return { ok: true, state: emptyState() };
23547
24227
  let json2;
23548
24228
  try {
23549
- json2 = JSON.parse(readFileSync11(path, "utf8"));
24229
+ json2 = JSON.parse(readFileSync12(path, "utf8"));
23550
24230
  } catch {
23551
24231
  return { ok: false, error: `The pin file ${path} is not valid JSON. Fix or delete it; the shield will not run without it.` };
23552
24232
  }
@@ -23557,7 +24237,7 @@ function loadState(path) {
23557
24237
  return { ok: true, state: parsed.data };
23558
24238
  }
23559
24239
  function saveState(path, state) {
23560
- mkdirSync3(dirname3(path), { recursive: true });
24240
+ mkdirSync3(dirname5(path), { recursive: true });
23561
24241
  const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
23562
24242
  writeFileSync3(tmp, `${JSON.stringify(state, null, 2)}
23563
24243
  `, "utf8");
@@ -23572,7 +24252,7 @@ function serverState(state, name) {
23572
24252
  return s;
23573
24253
  }
23574
24254
  function appendAlert(path, alert) {
23575
- mkdirSync3(dirname3(path), { recursive: true });
24255
+ mkdirSync3(dirname5(path), { recursive: true });
23576
24256
  appendFileSync(path, `${JSON.stringify(alert)}
23577
24257
  `, "utf8");
23578
24258
  }
@@ -24184,8 +24864,8 @@ function throttle(o = {}) {
24184
24864
  }
24185
24865
 
24186
24866
  // ../shield/src/canary.ts
24187
- import { existsSync as existsSync6, lstatSync as lstatSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync12, readdirSync as readdirSync3, realpathSync as realpathSync3, rmdirSync, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "node:fs";
24188
- import { dirname as dirname4, isAbsolute as isAbsolute6, join as join15, resolve as resolve9 } from "node:path";
24867
+ import { existsSync as existsSync8, lstatSync as lstatSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync13, readdirSync as readdirSync4, realpathSync as realpathSync5, rmdirSync, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "node:fs";
24868
+ import { dirname as dirname6, isAbsolute as isAbsolute9, join as join17, resolve as resolve12 } from "node:path";
24189
24869
  var TRAPS = [
24190
24870
  {
24191
24871
  name: ".env.canary",
@@ -24228,36 +24908,36 @@ function plantCanaries(root, o = {}) {
24228
24908
  return { ok: false, error: `Canary traps are already planted in ${root}. To replace them, run "exorcist canary --remove" first.` };
24229
24909
  }
24230
24910
  for (const d of [".exorcist", CANARY_TRAP_DIR]) {
24231
- const path = join15(root, d);
24232
- if (existsSync6(path) || isSymlink(path)) {
24911
+ const path = join17(root, d);
24912
+ if (existsSync8(path) || isSymlink(path)) {
24233
24913
  if (!isRealDir(path)) return { ok: false, error: `${path} is not a real folder (a symlink or a file); no traps were planted.` };
24234
24914
  }
24235
24915
  }
24236
24916
  const traps = TRAPS.slice(0, count);
24237
24917
  for (const t of traps) {
24238
- const path = join15(root, CANARY_TRAP_DIR, t.name);
24239
- if (existsSync6(path)) return { ok: false, error: `${path} already exists; it was not overwritten.` };
24918
+ const path = join17(root, CANARY_TRAP_DIR, t.name);
24919
+ if (existsSync8(path)) return { ok: false, error: `${path} already exists; it was not overwritten.` };
24240
24920
  }
24241
24921
  const created = (o.now ? o.now() : /* @__PURE__ */ new Date()).toISOString();
24242
24922
  const records = [];
24243
- const madeDirs = [".exorcist", CANARY_TRAP_DIR].filter((d) => !existsSync6(join15(root, d)));
24923
+ const madeDirs = [".exorcist", CANARY_TRAP_DIR].filter((d) => !existsSync8(join17(root, d)));
24244
24924
  try {
24245
- mkdirSync4(join15(root, CANARY_TRAP_DIR), { recursive: true });
24925
+ mkdirSync4(join17(root, CANARY_TRAP_DIR), { recursive: true });
24246
24926
  for (const t of traps) {
24247
24927
  const token = newToken();
24248
24928
  const file = `${CANARY_TRAP_DIR}/${t.name}`;
24249
- writeFileSync4(join15(root, file), t.body(token), { flag: "wx" });
24929
+ writeFileSync4(join17(root, file), t.body(token), { flag: "wx" });
24250
24930
  records.push({ token, file, created });
24251
24931
  }
24252
24932
  writeFileSync4(recordsFile, `${JSON.stringify({ version: 1, canaries: records, ...madeDirs.length > 0 ? { madeDirs } : {} }, null, 2)}
24253
24933
  `);
24254
24934
  } catch (err) {
24255
- for (const r of records) rmSync2(join15(root, r.file), { force: true });
24256
- for (const d of [...madeDirs].reverse()) rmdirIfEmpty(join15(root, d));
24935
+ for (const r of records) rmSync2(join17(root, r.file), { force: true });
24936
+ for (const d of [...madeDirs].reverse()) rmdirIfEmpty(join17(root, d));
24257
24937
  return { ok: false, error: `Could not plant the canary traps: ${firstLine(err)}` };
24258
24938
  }
24259
24939
  const result = { ok: true, records, recordsFile };
24260
- if (o.stateDir && resolve9(o.stateDir) !== resolve9(root, ".exorcist")) {
24940
+ if (o.stateDir && resolve12(o.stateDir) !== resolve12(root, ".exorcist")) {
24261
24941
  const told = setPolicyCanaries(o.stateDir, recordsFile);
24262
24942
  if (!told.ok) return { ok: false, error: `Planted the traps, but could not tell the Shield where they are: ${told.error}` };
24263
24943
  result.policyUpdated = policyPath(o.stateDir);
@@ -24270,7 +24950,7 @@ function loadCanaries(root) {
24270
24950
  }
24271
24951
  function rmdirIfEmpty(path) {
24272
24952
  try {
24273
- if (lstatSync3(path).isDirectory() && readdirSync3(path).length === 0) rmdirSync(path);
24953
+ if (lstatSync3(path).isDirectory() && readdirSync4(path).length === 0) rmdirSync(path);
24274
24954
  } catch {
24275
24955
  }
24276
24956
  }
@@ -24295,18 +24975,18 @@ function removeCanaries(root, o = {}) {
24295
24975
  if (!existing.ok) return existing;
24296
24976
  const removed = [];
24297
24977
  const warnings = [];
24298
- const stateFolder = join15(root, ".exorcist");
24299
- const trapFolder = join15(root, CANARY_TRAP_DIR);
24978
+ const stateFolder = join17(root, ".exorcist");
24979
+ const trapFolder = join17(root, CANARY_TRAP_DIR);
24300
24980
  const foldersReal = isRealDir(stateFolder) && isRealDir(trapFolder);
24301
24981
  let trapReal = null;
24302
24982
  try {
24303
- trapReal = foldersReal ? realpathSync3(trapFolder) : null;
24983
+ trapReal = foldersReal ? realpathSync5(trapFolder) : null;
24304
24984
  } catch {
24305
24985
  trapReal = null;
24306
24986
  }
24307
24987
  let left = 0;
24308
24988
  for (const r of existing.canaries) {
24309
- const full = join15(root, r.file);
24989
+ const full = join17(root, r.file);
24310
24990
  const name = r.file.slice(`${CANARY_TRAP_DIR}/`.length);
24311
24991
  const leave = (why) => {
24312
24992
  left++;
@@ -24331,11 +25011,11 @@ function removeCanaries(root, o = {}) {
24331
25011
  continue;
24332
25012
  }
24333
25013
  try {
24334
- if (realpathSync3(dirname4(full)) !== trapReal) {
25014
+ if (realpathSync5(dirname6(full)) !== trapReal) {
24335
25015
  leave("it is not inside the trap folder.");
24336
25016
  continue;
24337
25017
  }
24338
- if (!readFileSync12(full, "utf8").includes(r.token)) {
25018
+ if (!readFileSync13(full, "utf8").includes(r.token)) {
24339
25019
  leave("it no longer holds the token it was planted with, so it may not be the trap any more.");
24340
25020
  continue;
24341
25021
  }
@@ -24362,14 +25042,14 @@ function removeCanaries(root, o = {}) {
24362
25042
  }
24363
25043
  if (existing.madeDirs.includes(CANARY_TRAP_DIR)) rmdirIfEmpty(trapFolder);
24364
25044
  if (existing.madeDirs.includes(".exorcist")) rmdirIfEmpty(stateFolder);
24365
- if (o.stateDir && resolve9(o.stateDir) !== resolve9(root, ".exorcist")) clearPolicyCanaries(o.stateDir, recordsFile);
25045
+ if (o.stateDir && resolve12(o.stateDir) !== resolve12(root, ".exorcist")) clearPolicyCanaries(o.stateDir, recordsFile);
24366
25046
  return { ok: true, removed, warnings };
24367
25047
  }
24368
25048
  function readPolicyObject(stateDir2) {
24369
25049
  const path = policyPath(stateDir2);
24370
- if (!existsSync6(path)) return { ok: true, obj: {} };
25050
+ if (!existsSync8(path)) return { ok: true, obj: {} };
24371
25051
  try {
24372
- const json2 = JSON.parse(readFileSync12(path, "utf8"));
25052
+ const json2 = JSON.parse(readFileSync13(path, "utf8"));
24373
25053
  if (!json2 || typeof json2 !== "object" || Array.isArray(json2)) return { ok: false, error: `${path} is not a JSON object.` };
24374
25054
  return { ok: true, obj: json2 };
24375
25055
  } catch (err) {
@@ -24381,7 +25061,7 @@ function setPolicyCanaries(stateDir2, recordsFile) {
24381
25061
  if (!p.ok) return p;
24382
25062
  try {
24383
25063
  mkdirSync4(stateDir2, { recursive: true });
24384
- writeFileSync4(policyPath(stateDir2), `${JSON.stringify({ ...p.obj, canaries: resolve9(recordsFile) }, null, 2)}
25064
+ writeFileSync4(policyPath(stateDir2), `${JSON.stringify({ ...p.obj, canaries: resolve12(recordsFile) }, null, 2)}
24385
25065
  `);
24386
25066
  return { ok: true };
24387
25067
  } catch (err) {
@@ -24390,7 +25070,7 @@ function setPolicyCanaries(stateDir2, recordsFile) {
24390
25070
  }
24391
25071
  function clearPolicyCanaries(stateDir2, recordsFile) {
24392
25072
  const p = readPolicyObject(stateDir2);
24393
- if (!p.ok || p.obj["canaries"] !== resolve9(recordsFile)) return;
25073
+ if (!p.ok || p.obj["canaries"] !== resolve12(recordsFile)) return;
24394
25074
  const { canaries: _gone, ...rest } = p.obj;
24395
25075
  try {
24396
25076
  if (Object.keys(rest).length === 0) rmSync2(policyPath(stateDir2));
@@ -24400,8 +25080,8 @@ function clearPolicyCanaries(stateDir2, recordsFile) {
24400
25080
  }
24401
25081
  }
24402
25082
  function canariesFileFor(stateDir2, policyCanaries) {
24403
- if (!policyCanaries) return join15(stateDir2, "canaries.json");
24404
- return isAbsolute6(policyCanaries) ? policyCanaries : resolve9(stateDir2, policyCanaries);
25083
+ if (!policyCanaries) return join17(stateDir2, "canaries.json");
25084
+ return isAbsolute9(policyCanaries) ? policyCanaries : resolve12(stateDir2, policyCanaries);
24405
25085
  }
24406
25086
  function allStrings(value) {
24407
25087
  const out = [];
@@ -24436,8 +25116,8 @@ function findCanary(value, canaries) {
24436
25116
  init_zod();
24437
25117
  import { createHash as createHash7, randomBytes as randomBytes3 } from "node:crypto";
24438
25118
  import { spawnSync } from "node:child_process";
24439
- import { lstatSync as lstatSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync13, readdirSync as readdirSync4, renameSync as renameSync4, rmSync as rmSync3, unlinkSync, writeFileSync as writeFileSync5 } from "node:fs";
24440
- import { join as join16 } from "node:path";
25119
+ import { lstatSync as lstatSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync14, readdirSync as readdirSync5, renameSync as renameSync4, rmSync as rmSync3, unlinkSync, writeFileSync as writeFileSync5 } from "node:fs";
25120
+ import { join as join18 } from "node:path";
24441
25121
  var SESSION_RULE_ID = "EX-027";
24442
25122
  var SESSION_TTL_MS = 2 * 60 * 60 * 1e3;
24443
25123
  var MAX_FACTS = 32;
@@ -24620,14 +25300,14 @@ var TMP_RE = /\.tmp$/;
24620
25300
  function code(err) {
24621
25301
  return err && typeof err === "object" && "code" in err ? String(err.code) : "error";
24622
25302
  }
24623
- var sessionsPath = (stateDir2) => join16(stateDir2, "sessions");
25303
+ var sessionsPath = (stateDir2) => join18(stateDir2, "sessions");
24624
25304
  var FileSessionStore = class {
24625
25305
  constructor(stateDir2, key, ttlMs = SESSION_TTL_MS) {
24626
25306
  this.key = key;
24627
25307
  this.ttlMs = ttlMs;
24628
25308
  if (!isSessionKey(key)) throw new Error(`Invalid session key "${key}".`);
24629
25309
  this.root = sessionsPath(stateDir2);
24630
- this.dir = join16(this.root, key);
25310
+ this.dir = join18(this.root, key);
24631
25311
  }
24632
25312
  dir;
24633
25313
  root;
@@ -24637,7 +25317,7 @@ var FileSessionStore = class {
24637
25317
  const problems = [];
24638
25318
  let names;
24639
25319
  try {
24640
- names = readdirSync4(this.dir);
25320
+ names = readdirSync5(this.dir);
24641
25321
  } catch (err) {
24642
25322
  if (code(err) === "ENOENT") return { records, problems };
24643
25323
  return { records, problems: [`the session folder ${this.dir} could not be read (${code(err)})`] };
@@ -24649,7 +25329,7 @@ var FileSessionStore = class {
24649
25329
  problems.push(`${name} in ${this.dir} is not a session record`);
24650
25330
  continue;
24651
25331
  }
24652
- const path = join16(this.dir, name);
25332
+ const path = join18(this.dir, name);
24653
25333
  let st;
24654
25334
  try {
24655
25335
  st = lstatSync4(path);
@@ -24668,7 +25348,7 @@ var FileSessionStore = class {
24668
25348
  }
24669
25349
  let json2;
24670
25350
  try {
24671
- json2 = JSON.parse(readFileSync13(path, "utf8"));
25351
+ json2 = JSON.parse(readFileSync14(path, "utf8"));
24672
25352
  } catch (err) {
24673
25353
  if (code(err) !== "ENOENT") problems.push(`${name} is not valid JSON`);
24674
25354
  continue;
@@ -24683,7 +25363,7 @@ var FileSessionStore = class {
24683
25363
  return { records, problems };
24684
25364
  }
24685
25365
  write(record3) {
24686
- const path = join16(this.dir, `${record3.writer}.json`);
25366
+ const path = join18(this.dir, `${record3.writer}.json`);
24687
25367
  const tmp = `${path}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
24688
25368
  try {
24689
25369
  mkdirSync5(this.dir, { recursive: true, mode: 448 });
@@ -24707,24 +25387,24 @@ var FileSessionStore = class {
24707
25387
  this.lastPrune = t;
24708
25388
  const old = (st, age) => t - st.mtimeMs > age;
24709
25389
  try {
24710
- for (const name of readdirSync4(this.dir)) {
25390
+ for (const name of readdirSync5(this.dir)) {
24711
25391
  if (name === `${own}.json`) continue;
24712
- const p = join16(this.dir, name);
25392
+ const p = join18(this.dir, name);
24713
25393
  const st = lstatSync4(p);
24714
25394
  if (st.isFile() && old(st, TMP_RE.test(name) ? 6e4 : this.ttlMs)) unlinkSync(p);
24715
25395
  }
24716
25396
  } catch {
24717
25397
  }
24718
25398
  try {
24719
- for (const name of readdirSync4(this.root).slice(0, MAX_SESSION_DIRS)) {
25399
+ for (const name of readdirSync5(this.root).slice(0, MAX_SESSION_DIRS)) {
24720
25400
  if (name === this.key || !KEY_RE.test(name)) continue;
24721
- const p = join16(this.root, name);
25401
+ const p = join18(this.root, name);
24722
25402
  const st = lstatSync4(p);
24723
25403
  if (!st.isDirectory()) continue;
24724
- const entries = readdirSync4(p);
25404
+ const entries = readdirSync5(p);
24725
25405
  const newest = entries.reduce((m, e) => {
24726
25406
  try {
24727
- return Math.max(m, lstatSync4(join16(p, e)).mtimeMs);
25407
+ return Math.max(m, lstatSync4(join18(p, e)).mtimeMs);
24728
25408
  } catch {
24729
25409
  return m;
24730
25410
  }
@@ -24739,7 +25419,7 @@ function liveSessions(stateDir2, now = /* @__PURE__ */ new Date(), ttlMs = SESSI
24739
25419
  const root = sessionsPath(stateDir2);
24740
25420
  let names;
24741
25421
  try {
24742
- names = readdirSync4(root);
25422
+ names = readdirSync5(root);
24743
25423
  } catch {
24744
25424
  return [];
24745
25425
  }
@@ -24899,7 +25579,7 @@ function macOsAuth(o = {}) {
24899
25579
  } catch {
24900
25580
  return { kind: "fail" };
24901
25581
  }
24902
- return new Promise((resolve28) => {
25582
+ return new Promise((resolve31) => {
24903
25583
  let settled = false;
24904
25584
  let timer;
24905
25585
  let child;
@@ -24907,7 +25587,7 @@ function macOsAuth(o = {}) {
24907
25587
  if (settled) return;
24908
25588
  settled = true;
24909
25589
  if (timer !== void 0) clearTimeout(timer);
24910
- resolve28(r);
25590
+ resolve31(r);
24911
25591
  };
24912
25592
  try {
24913
25593
  const base = o.env ?? process.env;
@@ -25884,12 +26564,12 @@ var ShieldEngine = class {
25884
26564
 
25885
26565
  // ../shield/src/proxy.ts
25886
26566
  import { spawn } from "node:child_process";
25887
- import { existsSync as existsSync10, mkdirSync as mkdirSync8, readFileSync as readFileSync17, statSync as statSync9 } from "node:fs";
25888
- import { dirname as dirname8 } from "node:path";
26567
+ import { existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync18, statSync as statSync12 } from "node:fs";
26568
+ import { dirname as dirname10 } from "node:path";
25889
26569
 
25890
26570
  // ../shield/src/lockfile.ts
25891
- import { existsSync as existsSync7 } from "node:fs";
25892
- import { dirname as dirname5, join as join17, parse as parsePath, resolve as resolve10 } from "node:path";
26571
+ import { existsSync as existsSync9 } from "node:fs";
26572
+ import { dirname as dirname7, join as join19, parse as parsePath, resolve as resolve13 } from "node:path";
25893
26573
  init_zod();
25894
26574
  var Sha2562 = external_exports.string().regex(/^[0-9a-f]{64}$/);
25895
26575
  var LockToolSchema = external_exports.object({
@@ -26062,12 +26742,12 @@ function seedFromLock(s, ls, report, o) {
26062
26742
  var PROJECT_MARKERS2 = [".git", ".kiro", ".exorcist"];
26063
26743
  function findLockFile(starts) {
26064
26744
  for (const start of starts) {
26065
- const { root } = parsePath(resolve10(start));
26066
- for (let dir = resolve10(start); ; dir = dirname5(dir)) {
26067
- const candidate = join17(dir, LOCK_FILE);
26068
- if (existsSync7(candidate)) return candidate;
26069
- if (PROJECT_MARKERS2.some((m) => existsSync7(join17(dir, m)))) break;
26070
- if (dir === root || dirname5(dir) === dir) break;
26745
+ const { root } = parsePath(resolve13(start));
26746
+ for (let dir = resolve13(start); ; dir = dirname7(dir)) {
26747
+ const candidate = join19(dir, LOCK_FILE);
26748
+ if (existsSync9(candidate)) return candidate;
26749
+ if (PROJECT_MARKERS2.some((m) => existsSync9(join19(dir, m)))) break;
26750
+ if (dir === root || dirname7(dir) === dir) break;
26071
26751
  }
26072
26752
  }
26073
26753
  return null;
@@ -26075,11 +26755,11 @@ function findLockFile(starts) {
26075
26755
 
26076
26756
  // ../shield/src/vault.ts
26077
26757
  import { createHash as createHash8, randomBytes as randomBytes4 } from "node:crypto";
26078
- import { copyFileSync, existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync14, readdirSync as readdirSync5, rmSync as rmSync4, statSync as statSync7, writeFileSync as writeFileSync6 } from "node:fs";
26079
- import { basename as basename6, dirname as dirname6, isAbsolute as isAbsolute7, join as join18, resolve as resolve11 } from "node:path";
26758
+ import { copyFileSync, existsSync as existsSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync15, readdirSync as readdirSync6, rmSync as rmSync4, statSync as statSync10, writeFileSync as writeFileSync6 } from "node:fs";
26759
+ import { basename as basename7, dirname as dirname8, isAbsolute as isAbsolute10, join as join20, resolve as resolve14 } from "node:path";
26080
26760
  init_zod();
26081
26761
  var SafeRel = external_exports.string().min(1).max(1024).refine(
26082
- (p) => !isAbsolute7(p) && !p.includes("\\") && !p.includes("\0") && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== ".."),
26762
+ (p) => !isAbsolute10(p) && !p.includes("\\") && !p.includes("\0") && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== ".."),
26083
26763
  "unsafe path"
26084
26764
  );
26085
26765
  var EditedFileSchema = external_exports.object({
@@ -26109,20 +26789,20 @@ function newId(label, now) {
26109
26789
  return `${stamp}-${slug}-${randomBytes4(2).toString("hex")}`;
26110
26790
  }
26111
26791
  function entryDir(vaultDir, id) {
26112
- return join18(vaultDir, id);
26792
+ return join20(vaultDir, id);
26113
26793
  }
26114
26794
  function writeManifest(vaultDir, e) {
26115
- writeFileSync6(join18(entryDir(vaultDir, e.id), "manifest.json"), `${JSON.stringify(e, null, 2)}
26795
+ writeFileSync6(join20(entryDir(vaultDir, e.id), "manifest.json"), `${JSON.stringify(e, null, 2)}
26116
26796
  `, "utf8");
26117
26797
  }
26118
26798
  function listEntries(vaultDir) {
26119
- if (!existsSync8(vaultDir)) return [];
26799
+ if (!existsSync10(vaultDir)) return [];
26120
26800
  const out = [];
26121
- for (const name of readdirSync5(vaultDir)) {
26122
- const file = join18(vaultDir, name, "manifest.json");
26123
- if (!existsSync8(file)) continue;
26801
+ for (const name of readdirSync6(vaultDir)) {
26802
+ const file = join20(vaultDir, name, "manifest.json");
26803
+ if (!existsSync10(file)) continue;
26124
26804
  try {
26125
- const parsed = EntrySchema.safeParse(JSON.parse(readFileSync14(file, "utf8")));
26805
+ const parsed = EntrySchema.safeParse(JSON.parse(readFileSync15(file, "utf8")));
26126
26806
  if (parsed.success) out.push(parsed.data);
26127
26807
  } catch {
26128
26808
  }
@@ -26140,7 +26820,7 @@ function activeFor(vaultDir, target, serverName) {
26140
26820
  function readConfig(path) {
26141
26821
  let text;
26142
26822
  try {
26143
- text = readFileSync14(path, "utf8");
26823
+ text = readFileSync15(path, "utf8");
26144
26824
  } catch {
26145
26825
  return fail2(`Could not read ${path}.`);
26146
26826
  }
@@ -26155,7 +26835,7 @@ function readConfig(path) {
26155
26835
  var writeConfig = (path, cfg) => writeFileSync6(path, `${JSON.stringify(cfg, null, 2)}
26156
26836
  `, "utf8");
26157
26837
  function quarantineServer(o) {
26158
- const configPath = resolve11(o.configPath);
26838
+ const configPath = resolve14(o.configPath);
26159
26839
  const cfg = readConfig(configPath);
26160
26840
  if (!cfg.ok) return cfg;
26161
26841
  const entry = cfg.value.mcpServers?.[o.serverName];
@@ -26169,7 +26849,7 @@ function quarantineServer(o) {
26169
26849
  mkdirSync6(dir, { recursive: true });
26170
26850
  const backup = `${JSON.stringify(entry, null, 2)}
26171
26851
  `;
26172
- writeFileSync6(join18(dir, "entry.json"), backup, "utf8");
26852
+ writeFileSync6(join20(dir, "entry.json"), backup, "utf8");
26173
26853
  const e = {
26174
26854
  id,
26175
26855
  kind: "mcp-server",
@@ -26186,17 +26866,17 @@ function quarantineServer(o) {
26186
26866
  return { ok: true, value: e };
26187
26867
  }
26188
26868
  function quarantineFile(o) {
26189
- const target = resolve11(o.filePath);
26190
- if (!existsSync8(target) || !statSync7(target).isFile()) return fail2(`${target} is not a file.`);
26869
+ const target = resolve14(o.filePath);
26870
+ if (!existsSync10(target) || !statSync10(target).isFile()) return fail2(`${target} is not a file.`);
26191
26871
  if (activeFor(o.vaultDir, target)) return fail2(`${target} is already in the vault.`);
26192
26872
  const now = o.now ?? /* @__PURE__ */ new Date();
26193
- const id = newId(basename6(target), now);
26873
+ const id = newId(basename7(target), now);
26194
26874
  const dir = entryDir(o.vaultDir, id);
26195
- mkdirSync6(join18(dir, "files"), { recursive: true });
26196
- const stored = join18(dir, "files", basename6(target));
26875
+ mkdirSync6(join20(dir, "files"), { recursive: true });
26876
+ const stored = join20(dir, "files", basename7(target));
26197
26877
  copyFileSync(target, stored);
26198
- const digest = sha2562(readFileSync14(stored));
26199
- if (digest !== sha2562(readFileSync14(target))) {
26878
+ const digest = sha2562(readFileSync15(stored));
26879
+ if (digest !== sha2562(readFileSync15(target))) {
26200
26880
  rmSync4(dir, { recursive: true, force: true });
26201
26881
  return fail2("The backup did not match the original, so nothing was moved.");
26202
26882
  }
@@ -26206,27 +26886,27 @@ function quarantineFile(o) {
26206
26886
  return { ok: true, value: e };
26207
26887
  }
26208
26888
  function backupAndRewrite(o) {
26209
- const root = resolve11(o.root);
26889
+ const root = resolve14(o.root);
26210
26890
  if (o.files.length === 0) return fail2("There are no files to change.");
26211
26891
  for (const f of o.files) {
26212
26892
  if (!SafeRel.safeParse(f.rel).success) return fail2(`Refusing to write outside ${root}: ${f.rel}`);
26213
- const path = join18(root, f.rel);
26214
- if (!existsSync8(path)) return fail2(`${f.rel} is gone; nothing was changed.`);
26215
- if (sha2562(readFileSync14(path)) !== sha2562(Buffer.from(f.before, "utf8"))) {
26893
+ const path = join20(root, f.rel);
26894
+ if (!existsSync10(path)) return fail2(`${f.rel} is gone; nothing was changed.`);
26895
+ if (sha2562(readFileSync15(path)) !== sha2562(Buffer.from(f.before, "utf8"))) {
26216
26896
  return fail2(`${f.rel} changed since it was scanned; nothing was changed. Run exorcise again.`);
26217
26897
  }
26218
26898
  }
26219
26899
  const now = o.now ?? /* @__PURE__ */ new Date();
26220
- const id = newId(`exorcise-${basename6(root)}`, now);
26900
+ const id = newId(`exorcise-${basename7(root)}`, now);
26221
26901
  const dir = entryDir(o.vaultDir, id);
26222
26902
  const files = [];
26223
26903
  try {
26224
26904
  for (const f of o.files) {
26225
- const stored = join18(dir, "files", f.rel);
26226
- mkdirSync6(dirname6(stored), { recursive: true });
26227
- copyFileSync(join18(root, f.rel), stored);
26228
- const digest = sha2562(readFileSync14(stored));
26229
- if (digest !== sha2562(readFileSync14(join18(root, f.rel)))) throw new Error("mismatch");
26905
+ const stored = join20(dir, "files", f.rel);
26906
+ mkdirSync6(dirname8(stored), { recursive: true });
26907
+ copyFileSync(join20(root, f.rel), stored);
26908
+ const digest = sha2562(readFileSync15(stored));
26909
+ if (digest !== sha2562(readFileSync15(join20(root, f.rel)))) throw new Error("mismatch");
26230
26910
  files.push({ rel: f.rel, sha256: digest, after: sha2562(Buffer.from(f.after, "utf8")) });
26231
26911
  }
26232
26912
  } catch {
@@ -26244,57 +26924,57 @@ function backupAndRewrite(o) {
26244
26924
  status: "quarantined"
26245
26925
  };
26246
26926
  writeManifest(o.vaultDir, e);
26247
- for (const f of o.files) writeFileSync6(join18(root, f.rel), f.after, "utf8");
26927
+ for (const f of o.files) writeFileSync6(join20(root, f.rel), f.after, "utf8");
26248
26928
  return { ok: true, value: e };
26249
26929
  }
26250
26930
  function restoreExorcised(vaultDir, e, force) {
26251
26931
  const files = e.files ?? [];
26252
26932
  const blocked = files.filter((f) => {
26253
- const path = join18(e.target, f.rel);
26254
- if (!existsSync8(path)) return false;
26255
- const now = sha2562(readFileSync14(path));
26933
+ const path = join20(e.target, f.rel);
26934
+ if (!existsSync10(path)) return false;
26935
+ const now = sha2562(readFileSync15(path));
26256
26936
  return now !== f.after && now !== f.sha256;
26257
26937
  });
26258
26938
  if (blocked.length > 0 && !force) {
26259
26939
  return fail2(`${blocked.map((f) => f.rel).join(", ")} changed after the exorcism. Use --force to overwrite ${blocked.length === 1 ? "it" : "them"} with the backup.`);
26260
26940
  }
26261
26941
  for (const f of files) {
26262
- const stored = join18(entryDir(vaultDir, e.id), "files", f.rel);
26263
- if (sha2562(readFileSync14(stored)) !== f.sha256) return fail2(`The backup of ${f.rel} is damaged (sha256 does not match); nothing was restored.`);
26942
+ const stored = join20(entryDir(vaultDir, e.id), "files", f.rel);
26943
+ if (sha2562(readFileSync15(stored)) !== f.sha256) return fail2(`The backup of ${f.rel} is damaged (sha256 does not match); nothing was restored.`);
26264
26944
  }
26265
26945
  for (const f of files) {
26266
- const path = join18(e.target, f.rel);
26267
- mkdirSync6(dirname6(path), { recursive: true });
26268
- copyFileSync(join18(entryDir(vaultDir, e.id), "files", f.rel), path);
26946
+ const path = join20(e.target, f.rel);
26947
+ mkdirSync6(dirname8(path), { recursive: true });
26948
+ copyFileSync(join20(entryDir(vaultDir, e.id), "files", f.rel), path);
26269
26949
  }
26270
26950
  return { ok: true, value: null };
26271
26951
  }
26272
26952
  function backupFile(vaultDir, e) {
26273
- return e.kind === "mcp-server" ? join18(entryDir(vaultDir, e.id), "entry.json") : join18(entryDir(vaultDir, e.id), "files", basename6(e.target));
26953
+ return e.kind === "mcp-server" ? join20(entryDir(vaultDir, e.id), "entry.json") : join20(entryDir(vaultDir, e.id), "files", basename7(e.target));
26274
26954
  }
26275
26955
  function diffEntry(vaultDir, id) {
26276
26956
  const e = getEntry(vaultDir, id);
26277
26957
  if (!e) return fail2(`There is no vault entry "${id}".`);
26278
26958
  if (e.kind === "exorcise") {
26279
26959
  const parts = (e.files ?? []).map((f) => {
26280
- const path = join18(e.target, f.rel);
26281
- const before2 = readFileSync14(join18(entryDir(vaultDir, e.id), "files", f.rel), "utf8");
26282
- const after2 = existsSync8(path) ? readFileSync14(path, "utf8") : "";
26960
+ const path = join20(e.target, f.rel);
26961
+ const before2 = readFileSync15(join20(entryDir(vaultDir, e.id), "files", f.rel), "utf8");
26962
+ const after2 = existsSync10(path) ? readFileSync15(path, "utf8") : "";
26283
26963
  return createTwoFilesPatch(`${f.rel} (backup)`, `${f.rel} (now)`, before2, after2, "", "", { context: 3 });
26284
26964
  });
26285
26965
  return { ok: true, value: parts.join("") };
26286
26966
  }
26287
- const before = readFileSync14(backupFile(vaultDir, e), "utf8");
26967
+ const before = readFileSync15(backupFile(vaultDir, e), "utf8");
26288
26968
  let after = "";
26289
26969
  if (e.kind === "mcp-server") {
26290
26970
  const cfg = readConfig(e.target);
26291
26971
  const now = cfg.ok ? cfg.value.mcpServers?.[e.serverName ?? ""] : void 0;
26292
26972
  after = now ? `${JSON.stringify(now, null, 2)}
26293
26973
  ` : "";
26294
- } else if (existsSync8(e.target)) {
26295
- after = readFileSync14(e.target, "utf8");
26974
+ } else if (existsSync10(e.target)) {
26975
+ after = readFileSync15(e.target, "utf8");
26296
26976
  }
26297
- const label = e.kind === "mcp-server" ? `${e.serverName} in ${basename6(e.target)}` : basename6(e.target);
26977
+ const label = e.kind === "mcp-server" ? `${e.serverName} in ${basename7(e.target)}` : basename7(e.target);
26298
26978
  return { ok: true, value: createTwoFilesPatch(`${label} (backup)`, `${label} (now)`, before, after, "", "", { context: 3 }) };
26299
26979
  }
26300
26980
  function restoreEntry(vaultDir, id, opts = {}) {
@@ -26307,7 +26987,7 @@ function restoreEntry(vaultDir, id, opts = {}) {
26307
26987
  } else if (e.kind === "mcp-server") {
26308
26988
  const cfg = readConfig(e.target);
26309
26989
  if (!cfg.ok) return cfg;
26310
- const original = JSON.parse(readFileSync14(backupFile(vaultDir, e), "utf8"));
26990
+ const original = JSON.parse(readFileSync15(backupFile(vaultDir, e), "utf8"));
26311
26991
  const servers = cfg.value.mcpServers ??= {};
26312
26992
  const current = servers[e.serverName ?? ""];
26313
26993
  if (!current) {
@@ -26320,10 +27000,10 @@ function restoreEntry(vaultDir, id, opts = {}) {
26320
27000
  writeConfig(e.target, cfg.value);
26321
27001
  } else {
26322
27002
  const stored = backupFile(vaultDir, e);
26323
- if (existsSync8(e.target) && sha2562(readFileSync14(e.target)) !== e.sha256 && !opts.force) {
27003
+ if (existsSync10(e.target) && sha2562(readFileSync15(e.target)) !== e.sha256 && !opts.force) {
26324
27004
  return fail2(`${e.target} exists and is different from the quarantined file. Use --force to overwrite it.`);
26325
27005
  }
26326
- mkdirSync6(resolve11(e.target, ".."), { recursive: true });
27006
+ mkdirSync6(resolve14(e.target, ".."), { recursive: true });
26327
27007
  copyFileSync(stored, e.target);
26328
27008
  }
26329
27009
  const done = { ...e, status: "restored" };
@@ -26333,14 +27013,14 @@ function restoreEntry(vaultDir, id, opts = {}) {
26333
27013
 
26334
27014
  // ../shield/src/events.ts
26335
27015
  init_zod();
26336
- import { closeSync as closeSync4, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync6, mkdirSync as mkdirSync7, openSync as openSync4, readSync as readSync4, renameSync as renameSync6, rmdirSync as rmdirSync2, writeSync as writeSync2 } from "node:fs";
26337
- import { join as join20 } from "node:path";
27016
+ import { closeSync as closeSync5, constants as constants3, fstatSync as fstatSync3, lstatSync as lstatSync6, mkdirSync as mkdirSync7, openSync as openSync5, readSync as readSync5, renameSync as renameSync6, rmdirSync as rmdirSync2, writeSync as writeSync2 } from "node:fs";
27017
+ import { join as join22 } from "node:path";
26338
27018
 
26339
27019
  // ../shield/src/chain.ts
26340
27020
  init_zod();
26341
27021
  import { createHash as createHash9, randomBytes as randomBytes5 } from "node:crypto";
26342
- import { closeSync as closeSync3, constants as constants2, fstatSync as fstatSync2, lstatSync as lstatSync5, openSync as openSync3, readFileSync as readFileSync15, readSync as readSync3, renameSync as renameSync5, unlinkSync as unlinkSync2, writeSync } from "node:fs";
26343
- import { join as join19 } from "node:path";
27022
+ import { closeSync as closeSync4, constants as constants2, fstatSync as fstatSync2, lstatSync as lstatSync5, openSync as openSync4, readFileSync as readFileSync16, readSync as readSync4, renameSync as renameSync5, unlinkSync as unlinkSync2, writeSync } from "node:fs";
27023
+ import { join as join21 } from "node:path";
26344
27024
 
26345
27025
  // ../shield/src/chain-core.ts
26346
27026
  init_zod();
@@ -26546,8 +27226,8 @@ function verifyChain(lines, head, genesis, opts) {
26546
27226
  // ../shield/src/chain.ts
26547
27227
  var ok = (value) => ({ ok: true, value });
26548
27228
  var fail3 = (error2) => ({ ok: false, error: error2 });
26549
- var headPath = (dir) => join19(dir, "events.head.json");
26550
- var genesisPath = (dir) => join19(dir, "events.genesis.json");
27229
+ var headPath = (dir) => join21(dir, "events.head.json");
27230
+ var genesisPath = (dir) => join21(dir, "events.genesis.json");
26551
27231
  var GenesisFileSchema = external_exports.object({ v: external_exports.literal(1), genesis: external_exports.string().regex(HEX64) }).strict();
26552
27232
  var MAX_FILE_BYTES4 = 4096;
26553
27233
  function errCode(e) {
@@ -26559,15 +27239,15 @@ function readSmall(path) {
26559
27239
  const st = lstatSync5(path, { throwIfNoEntry: false });
26560
27240
  if (st === void 0) return ok(null);
26561
27241
  if (!st.isFile()) return fail3("not a regular file");
26562
- fd = openSync3(path, constants2.O_RDONLY | constants2.O_NOFOLLOW);
27242
+ fd = openSync4(path, constants2.O_RDONLY | constants2.O_NOFOLLOW);
26563
27243
  if (fstatSync2(fd).size > MAX_FILE_BYTES4) return fail3("file is too large");
26564
- return ok(readFileSync15(fd, "utf8"));
27244
+ return ok(readFileSync16(fd, "utf8"));
26565
27245
  } catch (e) {
26566
27246
  return errCode(e) === "ENOENT" ? ok(null) : fail3(`could not read (${errCode(e)})`);
26567
27247
  } finally {
26568
27248
  if (fd !== null) {
26569
27249
  try {
26570
- closeSync3(fd);
27250
+ closeSync4(fd);
26571
27251
  } catch {
26572
27252
  }
26573
27253
  }
@@ -26593,7 +27273,7 @@ function readGenesis(dir) {
26593
27273
  function writeNew(path, text) {
26594
27274
  let fd = null;
26595
27275
  try {
26596
- fd = openSync3(path, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | constants2.O_NOFOLLOW, 384);
27276
+ fd = openSync4(path, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | constants2.O_NOFOLLOW, 384);
26597
27277
  writeSync(fd, text);
26598
27278
  return ok(void 0);
26599
27279
  } catch (e) {
@@ -26601,7 +27281,7 @@ function writeNew(path, text) {
26601
27281
  } finally {
26602
27282
  if (fd !== null) {
26603
27283
  try {
26604
- closeSync3(fd);
27284
+ closeSync4(fd);
26605
27285
  } catch {
26606
27286
  }
26607
27287
  }
@@ -26632,7 +27312,7 @@ function readHead(dir) {
26632
27312
  function writeHeadAtomic(dir, head) {
26633
27313
  const parsed = HeadRecordSchema.safeParse(head);
26634
27314
  if (!parsed.success) return fail3("head file: record is not valid");
26635
- const tmp = join19(dir, `events.head.json.${process.pid}.${randomBytes5(4).toString("hex")}.tmp`);
27315
+ const tmp = join21(dir, `events.head.json.${process.pid}.${randomBytes5(4).toString("hex")}.tmp`);
26636
27316
  const w = writeNew(tmp, `${JSON.stringify(parsed.data)}
26637
27317
  `);
26638
27318
  if (!w.ok) return fail3(`head file: could not write (${w.error})`);
@@ -26654,7 +27334,7 @@ function readEventsInto(path, out) {
26654
27334
  const st = lstatSync5(path, { throwIfNoEntry: false });
26655
27335
  if (st === void 0) return ok(null);
26656
27336
  if (!st.isFile()) return fail3("not a regular file");
26657
- fd = openSync3(path, constants2.O_RDONLY | constants2.O_NOFOLLOW);
27337
+ fd = openSync4(path, constants2.O_RDONLY | constants2.O_NOFOLLOW);
26658
27338
  const buf = Buffer.alloc(CHUNK);
26659
27339
  let carry = Buffer.alloc(0);
26660
27340
  const take = (raw) => {
@@ -26671,7 +27351,7 @@ function readEventsInto(path, out) {
26671
27351
  if (r.success) out.push(r.data);
26672
27352
  };
26673
27353
  for (; ; ) {
26674
- const n = readSync3(fd, buf, 0, CHUNK, null);
27354
+ const n = readSync4(fd, buf, 0, CHUNK, null);
26675
27355
  if (n === 0) break;
26676
27356
  let from = 0;
26677
27357
  for (; ; ) {
@@ -26693,7 +27373,7 @@ function readEventsInto(path, out) {
26693
27373
  } finally {
26694
27374
  if (fd !== null) {
26695
27375
  try {
26696
- closeSync3(fd);
27376
+ closeSync4(fd);
26697
27377
  } catch {
26698
27378
  }
26699
27379
  }
@@ -26723,9 +27403,9 @@ function verifyLogDir(dir, opts) {
26723
27403
  }
26724
27404
 
26725
27405
  // ../shield/src/events.ts
26726
- var eventsPath = (dir) => join20(dir, "events.jsonl");
26727
- var oldEventsPath = (dir) => join20(dir, "events.1.jsonl");
26728
- var lockPath = (dir) => join20(dir, "events.lock");
27406
+ var eventsPath = (dir) => join22(dir, "events.jsonl");
27407
+ var oldEventsPath = (dir) => join22(dir, "events.1.jsonl");
27408
+ var lockPath = (dir) => join22(dir, "events.lock");
26729
27409
  var MAX_EVENT_BYTES = 1024 * 1024;
26730
27410
  var MAX_LINE_BYTES = 8 * 1024;
26731
27411
  var STALE_LOCK_MS = 1e4;
@@ -26933,7 +27613,7 @@ var EventLog = class {
26933
27613
  }
26934
27614
  }
26935
27615
  const flags = constants3.O_WRONLY | constants3.O_APPEND | constants3.O_CREAT | (constants3.O_NOFOLLOW ?? 0);
26936
- const fd = openSync4(this.path, flags, 384);
27616
+ const fd = openSync5(this.path, flags, 384);
26937
27617
  try {
26938
27618
  if (!fstatSync3(fd).isFile()) {
26939
27619
  this.fail(`${this.path} is not a regular file`);
@@ -26941,7 +27621,7 @@ var EventLog = class {
26941
27621
  }
26942
27622
  writeSync2(fd, line);
26943
27623
  } finally {
26944
- closeSync4(fd);
27624
+ closeSync5(fd);
26945
27625
  }
26946
27626
  return true;
26947
27627
  }
@@ -27015,7 +27695,7 @@ function parseEventLines(text) {
27015
27695
  function readFrom(path, from) {
27016
27696
  let fd;
27017
27697
  try {
27018
- fd = openSync4(path, constants3.O_RDONLY | (constants3.O_NOFOLLOW ?? 0));
27698
+ fd = openSync5(path, constants3.O_RDONLY | (constants3.O_NOFOLLOW ?? 0));
27019
27699
  } catch {
27020
27700
  return null;
27021
27701
  }
@@ -27032,7 +27712,7 @@ function readFrom(path, from) {
27032
27712
  const buf = Buffer.alloc(len);
27033
27713
  let got = 0;
27034
27714
  while (got < len) {
27035
- const n = readSync4(fd, buf, got, len - got, start + got);
27715
+ const n = readSync5(fd, buf, got, len - got, start + got);
27036
27716
  if (n === 0) break;
27037
27717
  got += n;
27038
27718
  }
@@ -27042,7 +27722,7 @@ function readFrom(path, from) {
27042
27722
  if (dropFirst) text = text.slice(text.indexOf("\n") + 1);
27043
27723
  return { text, end: start + lastNl + 1, st };
27044
27724
  } finally {
27045
- closeSync4(fd);
27725
+ closeSync5(fd);
27046
27726
  }
27047
27727
  }
27048
27728
  var EventTail = class {
@@ -27103,15 +27783,15 @@ var EventTail = class {
27103
27783
 
27104
27784
  // ../shield/src/launch.ts
27105
27785
  import { createHash as createHash10 } from "node:crypto";
27106
- import { existsSync as existsSync9, readFileSync as readFileSync16, statSync as statSync8 } from "node:fs";
27107
- import { dirname as dirname7, isAbsolute as isAbsolute8, join as join21, parse as parsePath2, relative as relative6, resolve as resolve12, sep } from "node:path";
27786
+ import { existsSync as existsSync11, readFileSync as readFileSync17, statSync as statSync11 } from "node:fs";
27787
+ import { dirname as dirname9, isAbsolute as isAbsolute11, join as join23, parse as parsePath2, relative as relative9, resolve as resolve15, sep as sep4 } from "node:path";
27108
27788
  var sha2563 = (b) => createHash10("sha256").update(b).digest("hex");
27109
27789
  var MAX_HASHED_BYTES = 64 * 1024 * 1024;
27110
27790
  var fsReader = (path) => {
27111
27791
  try {
27112
- const st = statSync8(path);
27792
+ const st = statSync11(path);
27113
27793
  if (!st.isFile()) return { kind: "other" };
27114
- return { kind: "file", size: st.size, mtimeMs: st.mtimeMs, read: () => readFileSync16(path) };
27794
+ return { kind: "file", size: st.size, mtimeMs: st.mtimeMs, read: () => readFileSync17(path) };
27115
27795
  } catch {
27116
27796
  return { kind: "other" };
27117
27797
  }
@@ -27127,7 +27807,7 @@ var RUNNERS2 = {
27127
27807
  bun: ["x"],
27128
27808
  pipx: ["run"]
27129
27809
  };
27130
- var INTERPRETERS = /^(node|nodejs|deno|bun|python\d*(\.\d+)?|pythonw|uv|uvx|npx|pnpx|bunx|pnpm|npm|yarn|pipx|java|ruby|php|dotnet|docker|podman|sh|bash|zsh|cmd|powershell|pwsh)$/i;
27810
+ var INTERPRETERS2 = /^(node|nodejs|deno|bun|python\d*(\.\d+)?|pythonw|uv|uvx|npx|pnpx|bunx|pnpm|npm|yarn|pipx|java|ruby|php|dotnet|docker|podman|sh|bash|zsh|cmd|powershell|pwsh)$/i;
27131
27811
  var baseName3 = (c) => c.split(/[\\/]/).pop()?.replace(/\.(cmd|exe)$/i, "") ?? c;
27132
27812
  function packageSpec(command, args) {
27133
27813
  const sub = RUNNERS2[baseName3(command)];
@@ -27178,17 +27858,17 @@ function launchEntryOf(entry) {
27178
27858
  }
27179
27859
  var PROJECT_MARKERS3 = [".git", ".kiro"];
27180
27860
  function configLabel(configPath) {
27181
- const abs = resolve12(configPath);
27861
+ const abs = resolve15(configPath);
27182
27862
  const { root } = parsePath2(abs);
27183
- for (let dir = dirname7(abs); ; dir = dirname7(dir)) {
27184
- if (PROJECT_MARKERS3.some((m) => existsSync9(join21(dir, m)))) return relative6(dir, abs).split(sep).join("/");
27185
- if (dir === root || dirname7(dir) === dir) return abs;
27863
+ for (let dir = dirname9(abs); ; dir = dirname9(dir)) {
27864
+ if (PROJECT_MARKERS3.some((m) => existsSync11(join23(dir, m)))) return relative9(dir, abs).split(sep4).join("/");
27865
+ if (dir === root || dirname9(dir) === dir) return abs;
27186
27866
  }
27187
27867
  }
27188
27868
  function launchFingerprint(command, args, cwd, reader = fsReader, entry = {}) {
27189
27869
  const fileLine = (label, value) => {
27190
27870
  if (value.length === 0 || value.length > 4096) return void 0;
27191
- const path = isAbsolute8(value) ? value : resolve12(cwd, value);
27871
+ const path = isAbsolute11(value) ? value : resolve15(cwd, value);
27192
27872
  const f = reader(path);
27193
27873
  if (f.kind !== "file") return void 0;
27194
27874
  const content = f.size <= MAX_HASHED_BYTES ? `sha256:${sha2563(f.read())}` : `size:${f.size} mtime:${Math.round(f.mtimeMs)}`;
@@ -27196,7 +27876,7 @@ function launchFingerprint(command, args, cwd, reader = fsReader, entry = {}) {
27196
27876
  };
27197
27877
  const parts = [];
27198
27878
  const commandIsPath = /[\\/]/.test(command);
27199
- const own = commandIsPath && !INTERPRETERS.test(baseName3(command)) ? fileLine("command", command) : void 0;
27879
+ const own = commandIsPath && !INTERPRETERS2.test(baseName3(command)) ? fileLine("command", command) : void 0;
27200
27880
  parts.push(own ?? `command ${command}`);
27201
27881
  const spec = packageSpec(command, args);
27202
27882
  if (spec) parts.push(`package ${spec}`);
@@ -27238,11 +27918,11 @@ function checkLaunch(s, pin, now = /* @__PURE__ */ new Date()) {
27238
27918
  // ../shield/src/ai-review.ts
27239
27919
  var NONE = { block: [], warn: [] };
27240
27920
  function withTimeout(p, ms) {
27241
- return new Promise((resolve28, reject) => {
27921
+ return new Promise((resolve31, reject) => {
27242
27922
  const t = setTimeout(() => reject(new Error(`no answer within ${ms} ms`)), ms);
27243
27923
  p.then((v) => {
27244
27924
  clearTimeout(t);
27245
- resolve28(v);
27925
+ resolve31(v);
27246
27926
  }, (e) => {
27247
27927
  clearTimeout(t);
27248
27928
  reject(e instanceof Error ? e : new Error(String(e)));
@@ -27356,16 +28036,16 @@ async function prepareShield(o) {
27356
28036
  log(canariesFile.error);
27357
28037
  return FAIL_CLOSED_EXIT;
27358
28038
  }
27359
- if (policy.policy.canaries && !existsSync10(canariesAt)) log(`The policy names canary records at ${canariesAt}, but there is no such file; no canary traps are active.`);
28039
+ if (policy.policy.canaries && !existsSync12(canariesAt)) log(`The policy names canary records at ${canariesAt}, but there is no such file; no canary traps are active.`);
27360
28040
  const canaries = canariesFile.canaries.map((r) => ({ token: r.token, file: r.file }));
27361
28041
  if (canaries.length > 0) log(`Watching for ${canaries.length} canary token${canaries.length === 1 ? "" : "s"} (EX-022).`);
27362
28042
  let lockExpected;
27363
28043
  let lockLaunch;
27364
- const lockFile = o.lockPath === void 0 ? findLockFile([...o.configPath ? [dirname8(o.configPath)] : [], process.cwd()]) : o.lockPath;
27365
- if (lockFile && existsSync10(lockFile)) {
28044
+ const lockFile = o.lockPath === void 0 ? findLockFile([...o.configPath ? [dirname10(o.configPath)] : [], process.cwd()]) : o.lockPath;
28045
+ if (lockFile && existsSync12(lockFile)) {
27366
28046
  let text;
27367
28047
  try {
27368
- text = readFileSync17(lockFile, "utf8");
28048
+ text = readFileSync18(lockFile, "utf8");
27369
28049
  } catch {
27370
28050
  log(`Could not read ${lockFile}; running with the local pins only.`);
27371
28051
  }
@@ -27463,7 +28143,7 @@ async function prepareShield(o) {
27463
28143
  let dirty = false;
27464
28144
  const readMtime = () => {
27465
28145
  try {
27466
- return statSync9(statePath(o.dir)).mtimeMs;
28146
+ return statSync12(statePath(o.dir)).mtimeMs;
27467
28147
  } catch {
27468
28148
  return 0;
27469
28149
  }
@@ -27594,7 +28274,7 @@ async function prepareShield(o) {
27594
28274
  function readConfigEntry(configPath, server) {
27595
28275
  let json2;
27596
28276
  try {
27597
- json2 = JSON.parse(readFileSync17(configPath, "utf8"));
28277
+ json2 = JSON.parse(readFileSync18(configPath, "utf8"));
27598
28278
  } catch {
27599
28279
  return { ok: false, error: "the MCP config could not be read as JSON" };
27600
28280
  }
@@ -27677,16 +28357,16 @@ async function runProxy(o) {
27677
28357
  });
27678
28358
  prepared.attach(run2);
27679
28359
  const stopWatch = prepared.watch(run2);
27680
- return await new Promise((resolve28) => {
28360
+ return await new Promise((resolve31) => {
27681
28361
  child.on("error", (err) => {
27682
28362
  stopWatch();
27683
28363
  log(`Could not start "${o.command}": ${err.message}`);
27684
- resolve28(127);
28364
+ resolve31(127);
27685
28365
  });
27686
28366
  child.on("close", (code3) => {
27687
28367
  stopWatch();
27688
28368
  for (const l of fromServer.flush()) fromServerLine(l);
27689
- void serverQueue.then(() => resolve28(code3 ?? 1));
28369
+ void serverQueue.then(() => resolve31(code3 ?? 1));
27690
28370
  });
27691
28371
  });
27692
28372
  }
@@ -27718,9 +28398,9 @@ var SseParser = class {
27718
28398
  const out = [];
27719
28399
  let nl = this.buf.search(/\r\n|\n|\r/);
27720
28400
  while (nl !== -1) {
27721
- const sep3 = this.buf.startsWith("\r\n", nl) ? 2 : 1;
28401
+ const sep6 = this.buf.startsWith("\r\n", nl) ? 2 : 1;
27722
28402
  const line = this.buf.slice(0, nl);
27723
- this.buf = this.buf.slice(nl + sep3);
28403
+ this.buf = this.buf.slice(nl + sep6);
27724
28404
  if (line === "") {
27725
28405
  if (this.data.length > 0) out.push(this.data.join("\n"));
27726
28406
  this.data = [];
@@ -27891,7 +28571,7 @@ async function runRemoteProxy(o) {
27891
28571
  const fromClient = new LineSplitter();
27892
28572
  prepared.attach(deliver);
27893
28573
  const stopWatch = prepared.watch(deliver);
27894
- return await new Promise((resolve28) => {
28574
+ return await new Promise((resolve31) => {
27895
28575
  stdin.on("data", (chunk) => {
27896
28576
  for (const l of fromClient.push(chunk)) deliver(engine.onClientLine(l));
27897
28577
  });
@@ -27911,19 +28591,19 @@ async function runRemoteProxy(o) {
27911
28591
  } catch {
27912
28592
  }
27913
28593
  }
27914
- resolve28(0);
28594
+ resolve31(0);
27915
28595
  })();
27916
28596
  });
27917
28597
  });
27918
28598
  }
27919
28599
 
27920
28600
  // ../shield/src/locate.ts
27921
- import { existsSync as existsSync11, readdirSync as readdirSync6, statSync as statSync10 } from "node:fs";
27922
- import { dirname as dirname9, isAbsolute as isAbsolute9, join as join22, parse as parse2, resolve as resolve13 } from "node:path";
28601
+ import { existsSync as existsSync13, readdirSync as readdirSync7, statSync as statSync13 } from "node:fs";
28602
+ import { dirname as dirname11, isAbsolute as isAbsolute12, join as join24, parse as parse2, resolve as resolve16 } from "node:path";
27923
28603
  import { fileURLToPath } from "node:url";
27924
28604
  function hasDefinitions(dir) {
27925
28605
  try {
27926
- return statSync10(dir).isDirectory() && readdirSync6(dir).some((f) => /^EX-\d{3}.*\.yaml$/.test(f));
28606
+ return statSync13(dir).isDirectory() && readdirSync7(dir).some((f) => /^EX-\d{3}.*\.yaml$/.test(f));
27927
28607
  } catch {
27928
28608
  return false;
27929
28609
  }
@@ -27931,28 +28611,28 @@ function hasDefinitions(dir) {
27931
28611
  function findDefinitionsDir(o) {
27932
28612
  const env = o.env ?? process.env;
27933
28613
  const cwd = o.cwd ?? process.cwd();
27934
- if (o.explicit) return resolve13(cwd, o.explicit);
28614
+ if (o.explicit) return resolve16(cwd, o.explicit);
27935
28615
  const fromEnv = env["EXORCIST_DEFINITIONS"];
27936
- if (fromEnv) return resolve13(cwd, fromEnv);
28616
+ if (fromEnv) return resolve16(cwd, fromEnv);
27937
28617
  const installed = findActiveInstalledSet({ env, ...o.publicKeyPem ? { publicKeyPem: o.publicKeyPem } : {} });
27938
28618
  if (installed && hasDefinitions(installed.definitionsDir)) return installed.definitionsDir;
27939
- const here = dirname9(fileURLToPath(o.callerUrl));
27940
- const candidates = [join22(here, "..", "definitions"), join22(here, "..", "..", "..", "definitions"), join22(cwd, "definitions")];
28619
+ const here = dirname11(fileURLToPath(o.callerUrl));
28620
+ const candidates = [join24(here, "..", "definitions"), join24(here, "..", "..", "..", "definitions"), join24(cwd, "definitions")];
27941
28621
  return candidates.find(hasDefinitions) ?? null;
27942
28622
  }
27943
28623
  var PROJECT_MARKERS4 = [".exorcist", ".kiro", ".git"];
27944
28624
  function findStateDir(o = {}) {
27945
28625
  const env = o.env ?? process.env;
27946
- const cwd = resolve13(o.cwd ?? process.cwd());
27947
- if (o.explicit) return resolve13(cwd, o.explicit);
28626
+ const cwd = resolve16(o.cwd ?? process.cwd());
28627
+ if (o.explicit) return resolve16(cwd, o.explicit);
27948
28628
  const fromEnv = env["EXORCIST_DIR"];
27949
- if (fromEnv) return isAbsolute9(fromEnv) ? fromEnv : resolve13(cwd, fromEnv);
28629
+ if (fromEnv) return isAbsolute12(fromEnv) ? fromEnv : resolve16(cwd, fromEnv);
27950
28630
  const { root } = parse2(cwd);
27951
- for (let dir = cwd; ; dir = dirname9(dir)) {
27952
- if (PROJECT_MARKERS4.some((m) => existsSync11(join22(dir, m)))) return join22(dir, ".exorcist");
27953
- if (dir === root || dirname9(dir) === dir) break;
28631
+ for (let dir = cwd; ; dir = dirname11(dir)) {
28632
+ if (PROJECT_MARKERS4.some((m) => existsSync13(join24(dir, m)))) return join24(dir, ".exorcist");
28633
+ if (dir === root || dirname11(dir) === dir) break;
27954
28634
  }
27955
- return join22(cwd, ".exorcist");
28635
+ return join24(cwd, ".exorcist");
27956
28636
  }
27957
28637
 
27958
28638
  // ../shield/src/wrap.ts
@@ -28094,11 +28774,11 @@ function unwrapConfig(config2) {
28094
28774
  unwrapped.push(name);
28095
28775
  continue;
28096
28776
  }
28097
- const sep3 = separatorIndex(args);
28098
- const original = args[sep3 + 1];
28099
- if (sep3 === -1 || original === void 0) continue;
28777
+ const sep6 = separatorIndex(args);
28778
+ const original = args[sep6 + 1];
28779
+ if (sep6 === -1 || original === void 0) continue;
28100
28780
  entry["command"] = original;
28101
- const rest = args.slice(sep3 + 2);
28781
+ const rest = args.slice(sep6 + 2);
28102
28782
  if (rest.length > 0) entry["args"] = rest;
28103
28783
  else delete entry["args"];
28104
28784
  unwrapped.push(name);
@@ -28135,8 +28815,8 @@ var DEFAULT_DIR = "the project's .exorcist folder (or EXORCIST_DIR)";
28135
28815
  // src/commands/on-access.ts
28136
28816
  import { randomBytes as randomBytes7 } from "node:crypto";
28137
28817
  import { execFile as execFile4 } from "node:child_process";
28138
- import { existsSync as existsSync12, statSync as statSync11 } from "node:fs";
28139
- import { resolve as resolve14 } from "node:path";
28818
+ import { existsSync as existsSync14, statSync as statSync14 } from "node:fs";
28819
+ import { resolve as resolve17 } from "node:path";
28140
28820
  import { createInterface } from "node:readline";
28141
28821
  var ALLOW_READ_HELP = `Usage: exorcist allow-read <file>
28142
28822
 
@@ -28220,7 +28900,7 @@ function recordApproval(audit, outcome, now) {
28220
28900
  return false;
28221
28901
  }
28222
28902
  }
28223
- function eventCwd(stdin) {
28903
+ function eventCwd2(stdin) {
28224
28904
  try {
28225
28905
  const parsed = JSON.parse(stdin);
28226
28906
  if (typeof parsed?.cwd === "string" && parsed.cwd) return parsed.cwd;
@@ -28229,7 +28909,7 @@ function eventCwd(stdin) {
28229
28909
  return process.cwd();
28230
28910
  }
28231
28911
  async function onAccessCommand(stdin, io) {
28232
- const cwd = eventCwd(stdin);
28912
+ const cwd = eventCwd2(stdin);
28233
28913
  let defs = [];
28234
28914
  const defsDir = findDefinitionsDir2();
28235
28915
  if (defsDir) {
@@ -28328,8 +29008,8 @@ ${ALLOW_READ_HELP}`);
28328
29008
  io.err("exorcist allow-read only runs in an interactive terminal: the user must review the file and run it themselves. Nothing was allowed.");
28329
29009
  return 1;
28330
29010
  }
28331
- const file = resolve14(target);
28332
- if (!existsSync12(file) || !statSync11(file).isFile()) {
29011
+ const file = resolve17(target);
29012
+ if (!existsSync14(file) || !statSync14(file).isFile()) {
28333
29013
  io.err(`Not a readable file: ${shownName(target)}`);
28334
29014
  return 1;
28335
29015
  }
@@ -28475,13 +29155,13 @@ async function alertsCommand(argv, io) {
28475
29155
  if (!h.ok) io.out(`Event log head: unreadable (${h.error.replace(/[^\x20-\x7e]/g, "?")}).`);
28476
29156
  else io.out(h.value === null ? "Event log head: none yet (nothing has been logged in this folder)." : `Event log head: ${h.value.hash} (event ${h.value.seq})`);
28477
29157
  };
28478
- if (!existsSync13(file)) {
29158
+ if (!existsSync15(file)) {
28479
29159
  io.out("No alerts.");
28480
29160
  printHead();
28481
29161
  return 0;
28482
29162
  }
28483
29163
  const n = Math.max(1, Number.parseInt(str4(p.values["last"]) ?? "20", 10) || 20);
28484
- const lines = readFileSync18(file, "utf8").split("\n").filter(Boolean).slice(-n);
29164
+ const lines = readFileSync19(file, "utf8").split("\n").filter(Boolean).slice(-n);
28485
29165
  for (const l of lines) {
28486
29166
  try {
28487
29167
  const a = JSON.parse(l);
@@ -28494,17 +29174,17 @@ async function alertsCommand(argv, io) {
28494
29174
  }
28495
29175
 
28496
29176
  // src/commands/baseline.ts
28497
- import { statSync as statSync14, writeFileSync as writeFileSync8 } from "node:fs";
28498
- import { join as join25, resolve as resolve17 } from "node:path";
29177
+ import { statSync as statSync17, writeFileSync as writeFileSync8 } from "node:fs";
29178
+ import { join as join27, resolve as resolve20 } from "node:path";
28499
29179
 
28500
29180
  // src/commands/scan.ts
28501
- import { existsSync as existsSync15, readFileSync as readFileSync20, realpathSync as realpathSync4, statSync as statSync13, writeFileSync as writeFileSync7 } from "node:fs";
28502
- import { basename as basename8, dirname as dirname10, isAbsolute as isAbsolute10, join as join24, relative as relative7, resolve as resolve16 } from "node:path";
29181
+ import { existsSync as existsSync17, readFileSync as readFileSync21, realpathSync as realpathSync6, statSync as statSync16, writeFileSync as writeFileSync7 } from "node:fs";
29182
+ import { basename as basename9, dirname as dirname12, isAbsolute as isAbsolute13, join as join26, relative as relative10, resolve as resolve19 } from "node:path";
28503
29183
  init_bedrock();
28504
29184
 
28505
29185
  // src/commands/detonate.ts
28506
- import { existsSync as existsSync14, readFileSync as readFileSync19, statSync as statSync12 } from "node:fs";
28507
- import { basename as basename7, join as join23, resolve as resolve15 } from "node:path";
29186
+ import { existsSync as existsSync16, readFileSync as readFileSync20, statSync as statSync15 } from "node:fs";
29187
+ import { basename as basename8, join as join25, resolve as resolve18 } from "node:path";
28508
29188
  init_bedrock();
28509
29189
  var DEFAULT_DETONATE_MAX = 10;
28510
29190
  var EX024 = "EX-024";
@@ -28583,12 +29263,12 @@ async function runDetonations(root, findings, client, max, def) {
28583
29263
  for (const t of targets) {
28584
29264
  let text;
28585
29265
  try {
28586
- text = readFileSync19(join23(root, t.file), "utf8");
29266
+ text = readFileSync20(join25(root, t.file), "utf8");
28587
29267
  } catch {
28588
29268
  tally.inconclusive++;
28589
29269
  continue;
28590
29270
  }
28591
- const r = await detonate(text, "file", client, { fileName: basename7(t.file) });
29271
+ const r = await detonate(text, "file", client, { fileName: basename8(t.file) });
28592
29272
  calls += r.modelCalls;
28593
29273
  tally[r.verdict]++;
28594
29274
  reports.push({ file: t.file, report: r });
@@ -28646,18 +29326,18 @@ ${DETONATE_HELP}`);
28646
29326
  io.err(`Unknown format "${format}". Use text or json.`);
28647
29327
  return 2;
28648
29328
  }
28649
- const abs = resolve15(target);
28650
- if (!existsSync14(abs) || !statSync12(abs).isFile()) {
29329
+ const abs = resolve18(target);
29330
+ if (!existsSync16(abs) || !statSync15(abs).isFile()) {
28651
29331
  io.err(`File not found: ${target}`);
28652
29332
  return 2;
28653
29333
  }
28654
- if (statSync12(abs).size > MAX_FILE_BYTES5) {
29334
+ if (statSync15(abs).size > MAX_FILE_BYTES5) {
28655
29335
  io.err(`${target} is larger than 1 MB; detonate a smaller part of it.`);
28656
29336
  return 2;
28657
29337
  }
28658
29338
  const client = await makeChamberClient(io, "exorcist detonate", deps.client);
28659
29339
  if (client === false) return 2;
28660
- const report = await detonate(readFileSync19(abs, "utf8"), placement, client, { fileName: basename7(abs) });
29340
+ const report = await detonate(readFileSync20(abs, "utf8"), placement, client, { fileName: basename8(abs) });
28661
29341
  if (format === "json") io.out(`${JSON.stringify({ file: target, model: modelIdFor("haiku"), ...report }, null, 2)}
28662
29342
  `);
28663
29343
  else io.out(renderTranscript(target, report));
@@ -28721,9 +29401,9 @@ Openers: // # <!-- /* -- ; A reason is required. Hidden characters (EX-00
28721
29401
  secrets (EX-011) cannot be silenced this way. The comment's own text is still scanned.
28722
29402
  `;
28723
29403
  function readIgnoreFile(root) {
28724
- const file = join24(root, ".exorcistignore");
28725
- if (!existsSync15(file)) return [];
28726
- return readFileSync20(file, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
29404
+ const file = join26(root, ".exorcistignore");
29405
+ if (!existsSync17(file)) return [];
29406
+ return readFileSync21(file, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
28727
29407
  }
28728
29408
  function isIgnored(rel, prefixes) {
28729
29409
  return prefixes.some((p) => {
@@ -28817,14 +29497,14 @@ async function makeAiClient(rawMax, io, real) {
28817
29497
  };
28818
29498
  }
28819
29499
  async function runScan(opts, io) {
28820
- const abs = resolve16(opts.target);
28821
- if (!existsSync15(abs)) {
29500
+ const abs = resolve19(opts.target);
29501
+ if (!existsSync17(abs)) {
28822
29502
  io.err(`Path not found: ${opts.target}`);
28823
29503
  return { ok: false, code: 2 };
28824
29504
  }
28825
- const isFile = statSync13(abs).isFile();
28826
- const root = isFile ? dirname10(abs) : abs;
28827
- const only = isFile ? basename8(abs) : null;
29505
+ const isFile = statSync16(abs).isFile();
29506
+ const root = isFile ? dirname12(abs) : abs;
29507
+ const only = isFile ? basename9(abs) : null;
28828
29508
  const defsDir = findDefinitionsDir2(opts.definitions);
28829
29509
  if (!defsDir) {
28830
29510
  io.err("Could not find the virus definitions. Pass --definitions <dir> or set EXORCIST_DEFINITIONS.");
@@ -28868,17 +29548,17 @@ async function runScan(opts, io) {
28868
29548
  function makeRootReader(root) {
28869
29549
  let realRoot;
28870
29550
  try {
28871
- realRoot = realpathSync4(root);
29551
+ realRoot = realpathSync6(root);
28872
29552
  } catch {
28873
29553
  return () => null;
28874
29554
  }
28875
29555
  return (file) => {
28876
29556
  try {
28877
- const real = realpathSync4(resolve16(realRoot, file));
28878
- const rel = relative7(realRoot, real);
28879
- if (rel === "" || rel.startsWith("..") || isAbsolute10(rel)) return null;
28880
- if (statSync13(real).size > MAX_DIRECTIVE_FILE_BYTES) return null;
28881
- return readFileSync20(real, "utf8");
29557
+ const real = realpathSync6(resolve19(realRoot, file));
29558
+ const rel = relative10(realRoot, real);
29559
+ if (rel === "" || rel.startsWith("..") || isAbsolute13(rel)) return null;
29560
+ if (statSync16(real).size > MAX_DIRECTIVE_FILE_BYTES) return null;
29561
+ return readFileSync21(real, "utf8");
28882
29562
  } catch {
28883
29563
  return null;
28884
29564
  }
@@ -28936,7 +29616,7 @@ ${SCAN_HELP}`);
28936
29616
  if (baselinePath !== void 0) {
28937
29617
  let text;
28938
29618
  try {
28939
- text = readFileSync20(resolve16(baselinePath), "utf8");
29619
+ text = readFileSync21(resolve19(baselinePath), "utf8");
28940
29620
  } catch {
28941
29621
  io.err(`Could not read the baseline file ${baselinePath}. Check the path, or create one with: exorcist baseline <folder>`);
28942
29622
  return 2;
@@ -29049,7 +29729,7 @@ ${BASELINE_HELP}`);
29049
29729
  }
29050
29730
  const target = p.positionals[0] ?? ".";
29051
29731
  try {
29052
- if (!statSync14(resolve17(target)).isDirectory()) {
29732
+ if (!statSync17(resolve20(target)).isDirectory()) {
29053
29733
  io.err(`${target} is a file. Give a folder to baseline.`);
29054
29734
  return 2;
29055
29735
  }
@@ -29062,7 +29742,7 @@ ${BASELINE_HELP}`);
29062
29742
  const { findings, root } = result.run;
29063
29743
  const { active } = applyInline(findings, makeRootReader(root));
29064
29744
  const baseline = buildBaseline(active);
29065
- const out = str4(p.values["output"]) ?? join25(root, BASELINE_FILE);
29745
+ const out = str4(p.values["output"]) ?? join27(root, BASELINE_FILE);
29066
29746
  try {
29067
29747
  writeFileSync8(out, `${JSON.stringify(baseline, null, 2)}
29068
29748
  `, "utf8");
@@ -29075,7 +29755,7 @@ ${BASELINE_HELP}`);
29075
29755
  }
29076
29756
 
29077
29757
  // src/commands/canary.ts
29078
- import { resolve as resolve18 } from "node:path";
29758
+ import { resolve as resolve21 } from "node:path";
29079
29759
  var CANARY_HELP = `Usage: exorcist canary plant [dir] Plant canary traps in a project (3 by default)
29080
29760
  exorcist canary --list [dir] Show the planted traps
29081
29761
  exorcist canary --remove [dir] Remove the trap files and their records
@@ -29123,7 +29803,7 @@ ${CANARY_HELP}`);
29123
29803
  ${CANARY_HELP}`);
29124
29804
  return 2;
29125
29805
  }
29126
- const dir = resolve18(positionals[0] ?? ".");
29806
+ const dir = resolve21(positionals[0] ?? ".");
29127
29807
  const wantList = p.values["list"] === true || sub === "list";
29128
29808
  const wantRemove = p.values["remove"] === true || sub === "remove";
29129
29809
  const wantPlant = sub === "plant";
@@ -29189,8 +29869,8 @@ function remove(io, dir, state) {
29189
29869
 
29190
29870
  // src/commands/config.ts
29191
29871
  import { createHash as createHash11 } from "node:crypto";
29192
- import { existsSync as existsSync16, mkdirSync as mkdirSync9, readFileSync as readFileSync21, rmSync as rmSync5, writeFileSync as writeFileSync9 } from "node:fs";
29193
- import { join as join26, resolve as resolve19 } from "node:path";
29872
+ import { existsSync as existsSync18, mkdirSync as mkdirSync9, readFileSync as readFileSync22, rmSync as rmSync5, writeFileSync as writeFileSync9 } from "node:fs";
29873
+ import { join as join28, resolve as resolve22 } from "node:path";
29194
29874
  var WRAP_HELP = `Usage: exorcist wrap <mcp.json> [options]
29195
29875
  exorcist unwrap <mcp.json>
29196
29876
 
@@ -29201,16 +29881,16 @@ unwrap Put the original file back byte for byte, if it was not edited since
29201
29881
 
29202
29882
  Options (wrap):
29203
29883
  --bin <command> Command that runs the shield (default: exorcist)
29204
- --bin-arg <arg> Argument before "shield" (repeatable), e.g. --bin npx --bin-arg -y --bin-arg @exorcist-98/cli@0.3.0
29884
+ --bin-arg <arg> Argument before "shield" (repeatable), e.g. --bin npx --bin-arg -y --bin-arg @exorcist-98/cli@0.3.2
29205
29885
  --dir <folder> State folder (default: ${DEFAULT_DIR})
29206
29886
  --dry-run Show the result without writing the file
29207
29887
  `;
29208
29888
  function backupPath(dir, configPath) {
29209
- return join26(dir, "wrap-backups", `${createHash11("sha256").update(configPath).digest("hex").slice(0, 32)}.json`);
29889
+ return join28(dir, "wrap-backups", `${createHash11("sha256").update(configPath).digest("hex").slice(0, 32)}.json`);
29210
29890
  }
29211
29891
  function readBackup(file) {
29212
29892
  try {
29213
- const b = JSON.parse(readFileSync21(file, "utf8"));
29893
+ const b = JSON.parse(readFileSync22(file, "utf8"));
29214
29894
  return typeof b.original === "string" && typeof b.wrapped === "string" && typeof b.path === "string" ? b : null;
29215
29895
  } catch {
29216
29896
  return null;
@@ -29228,12 +29908,12 @@ function dirsInConfig(cfg) {
29228
29908
  return out;
29229
29909
  }
29230
29910
  function readConfig2(path, io) {
29231
- if (!existsSync16(path)) {
29911
+ if (!existsSync18(path)) {
29232
29912
  io.err(`File not found: ${path}`);
29233
29913
  return null;
29234
29914
  }
29235
29915
  try {
29236
- const json2 = JSON.parse(readFileSync21(path, "utf8"));
29916
+ const json2 = JSON.parse(readFileSync22(path, "utf8"));
29237
29917
  if (!json2 || typeof json2 !== "object" || Array.isArray(json2)) throw new Error("not an object");
29238
29918
  return json2;
29239
29919
  } catch {
@@ -29266,10 +29946,10 @@ ${WRAP_HELP}`);
29266
29946
  ${WRAP_HELP}`);
29267
29947
  return 2;
29268
29948
  }
29269
- const path = resolve19(file);
29949
+ const path = resolve22(file);
29270
29950
  const cfg = readConfig2(path, io);
29271
29951
  if (!cfg) return 2;
29272
- const text = readFileSync21(path, "utf8");
29952
+ const text = readFileSync22(path, "utf8");
29273
29953
  let next;
29274
29954
  let names;
29275
29955
  if (mode === "wrap") {
@@ -29295,7 +29975,7 @@ ${WRAP_HELP}`);
29295
29975
  writeFileSync9(path, out, "utf8");
29296
29976
  const b = backupPath(stateDir(str4(p.values["dir"])), path);
29297
29977
  try {
29298
- mkdirSync9(join26(b, ".."), { recursive: true, mode: 448 });
29978
+ mkdirSync9(join28(b, ".."), { recursive: true, mode: 448 });
29299
29979
  writeFileSync9(b, JSON.stringify({ path, original: text, wrapped: out }), { mode: 384 });
29300
29980
  } catch {
29301
29981
  io.err("Could not save a copy of the original file; unwrap will still restore the original commands.");
@@ -29354,7 +30034,7 @@ import { randomBytes as randomBytes8, timingSafeEqual } from "node:crypto";
29354
30034
  import { createServer } from "node:http";
29355
30035
 
29356
30036
  // src/console/model.ts
29357
- import { lstatSync as lstatSync7, readdirSync as readdirSync7 } from "node:fs";
30037
+ import { lstatSync as lstatSync7, readdirSync as readdirSync8 } from "node:fs";
29358
30038
  var BACKLOG = 400;
29359
30039
  var MAX_SHIELDS = 64;
29360
30040
  var MAX_SESSIONS = 16;
@@ -29479,7 +30159,7 @@ var ConsoleModel = class {
29479
30159
  const root = sessionsPath(this.dir);
29480
30160
  let names = [];
29481
30161
  try {
29482
- names = readdirSync7(root).filter((k) => isSessionKey(k));
30162
+ names = readdirSync8(root).filter((k) => isSessionKey(k));
29483
30163
  } catch {
29484
30164
  names = [];
29485
30165
  }
@@ -30271,11 +30951,11 @@ data: ${data}
30271
30951
  });
30272
30952
  server.headersTimeout = 1e4;
30273
30953
  server.requestTimeout = 0;
30274
- await new Promise((resolve28, reject) => {
30954
+ await new Promise((resolve31, reject) => {
30275
30955
  server.once("error", reject);
30276
30956
  server.listen(o.port ?? 0, "127.0.0.1", () => {
30277
30957
  server.off("error", reject);
30278
- resolve28();
30958
+ resolve31();
30279
30959
  });
30280
30960
  });
30281
30961
  port = server.address().port;
@@ -30323,11 +31003,11 @@ function openCommand(platform, url) {
30323
31003
  if (platform === "win32") return { file: "rundll32", args: ["url.dll,FileProtocolHandler", url] };
30324
31004
  return { file: "xdg-open", args: [url] };
30325
31005
  }
30326
- var untilSignal = () => new Promise((resolve28) => {
31006
+ var untilSignal = () => new Promise((resolve31) => {
30327
31007
  const stop = () => {
30328
31008
  process.off("SIGINT", stop);
30329
31009
  process.off("SIGTERM", stop);
30330
- resolve28();
31010
+ resolve31();
30331
31011
  };
30332
31012
  process.on("SIGINT", stop);
30333
31013
  process.on("SIGTERM", stop);
@@ -30382,8 +31062,8 @@ ${CONSOLE_HELP}`);
30382
31062
  }
30383
31063
 
30384
31064
  // src/commands/exorcise.ts
30385
- import { existsSync as existsSync17, readFileSync as readFileSync22, statSync as statSync15 } from "node:fs";
30386
- import { basename as basename9, dirname as dirname11, isAbsolute as isAbsolute11, relative as relative8, resolve as resolve20 } from "node:path";
31065
+ import { existsSync as existsSync19, readFileSync as readFileSync23, statSync as statSync18 } from "node:fs";
31066
+ import { basename as basename10, dirname as dirname13, isAbsolute as isAbsolute14, relative as relative11, resolve as resolve23 } from "node:path";
30387
31067
  var EXORCISE_HELP = `Usage: exorcist exorcise [path] [options]
30388
31068
 
30389
31069
  Disinfect: repair the threats that have one safe, mechanical fix, and report
@@ -30467,14 +31147,14 @@ ${EXORCISE_HELP}`);
30467
31147
  return 2;
30468
31148
  }
30469
31149
  const target = p.positionals[0] ?? ".";
30470
- const abs = resolve20(target);
30471
- if (!existsSync17(abs)) {
31150
+ const abs = resolve23(target);
31151
+ if (!existsSync19(abs)) {
30472
31152
  io.err(`Path not found: ${target}`);
30473
31153
  return 2;
30474
31154
  }
30475
- const isFile = statSync15(abs).isFile();
30476
- const root = isFile ? dirname11(abs) : abs;
30477
- const single = isFile ? basename9(abs) : null;
31155
+ const isFile = statSync18(abs).isFile();
31156
+ const root = isFile ? dirname13(abs) : abs;
31157
+ const single = isFile ? basename10(abs) : null;
30478
31158
  const defsDir = findDefinitionsDir2(str4(p.values["definitions"]));
30479
31159
  if (!defsDir) {
30480
31160
  io.err("Could not find the virus definitions. Pass --definitions <dir> or set EXORCIST_DEFINITIONS.");
@@ -30492,10 +31172,10 @@ ${EXORCISE_HELP}`);
30492
31172
  return 2;
30493
31173
  }
30494
31174
  const vault = vaultPath(stateDir(str4(p.values["dir"])));
30495
- const state = relative8(root, resolve20(vault, ".."));
31175
+ const state = relative11(root, resolve23(vault, ".."));
30496
31176
  const ignore = [...strs(p.values["ignore"]), ...readIgnoreFile(root)];
30497
31177
  if (state === "") ignore.push("vault");
30498
- else if (!state.startsWith("..") && !isAbsolute11(state)) ignore.push(state.replace(/\\/g, "/"));
31178
+ else if (!state.startsWith("..") && !isAbsolute14(state)) ignore.push(state.replace(/\\/g, "/"));
30499
31179
  const keep = (rel) => (single === null || rel === single) && !isIgnored(rel, ignore);
30500
31180
  const findings = [];
30501
31181
  try {
@@ -30541,7 +31221,7 @@ ${EXORCISE_HELP}`);
30541
31221
  return 1;
30542
31222
  }
30543
31223
  const changedSet = new Set(changed.map((r) => r.file));
30544
- const now = changed.map((r) => ({ file: r.file, text: readFileSync22(resolve20(root, r.file), "utf8") }));
31224
+ const now = changed.map((r) => ({ file: r.file, text: readFileSync23(resolve23(root, r.file), "utf8") }));
30545
31225
  const after = [...findings.filter((f) => !changedSet.has(f.file)), ...rescanTexts(now, defs).filter((f) => keep(f.file))];
30546
31226
  const removed = Math.max(0, findings.length - after.length);
30547
31227
  const dirFlag = str4(p.values["dir"]) ? ` --dir ${str4(p.values["dir"])}` : "";
@@ -30560,9 +31240,9 @@ ${EXORCISE_HELP}`);
30560
31240
  }
30561
31241
 
30562
31242
  // src/commands/gate.ts
30563
- import { existsSync as existsSync18 } from "node:fs";
31243
+ import { existsSync as existsSync20 } from "node:fs";
30564
31244
  import { lstat as lstat2, readFile as readFile6 } from "node:fs/promises";
30565
- import { resolve as resolve21 } from "node:path";
31245
+ import { resolve as resolve24 } from "node:path";
30566
31246
  var GATE_HELP = `Usage: exorcist gate [dir] [--fail-on <critical|high|medium|low>] [--dir <state folder>]
30567
31247
  The gate for the end of an agent's turn. It looks only at the files an AI agent
30568
31248
  obeys (steering, specs, hooks, custom agents, MCP configs, AGENTS.md and the
@@ -30646,8 +31326,8 @@ ${GATE_HELP}`);
30646
31326
  ${GATE_HELP}`);
30647
31327
  return 2;
30648
31328
  }
30649
- const start = resolve21(p.positionals[0] ?? ".");
30650
- if (!existsSync18(start)) return nothingChecked(io, "that folder does not exist");
31329
+ const start = resolve24(p.positionals[0] ?? ".");
31330
+ if (!existsSync20(start)) return nothingChecked(io, "that folder does not exist");
30651
31331
  const top = await gitRepoRoot(start);
30652
31332
  if (!top) return nothingChecked(io, "this folder is not a git repository, or git is not available");
30653
31333
  const repo = { root: top };
@@ -30664,7 +31344,7 @@ ${GATE_HELP}`);
30664
31344
  const onDisk = [];
30665
31345
  const sizes = /* @__PURE__ */ new Map();
30666
31346
  for (const rel of changed.files) {
30667
- const info = await lstat2(resolve21(repo.root, rel)).catch(() => null);
31347
+ const info = await lstat2(resolve24(repo.root, rel)).catch(() => null);
30668
31348
  if (!info || !info.isFile()) continue;
30669
31349
  onDisk.push(rel);
30670
31350
  sizes.set(rel, info.size);
@@ -30681,7 +31361,7 @@ ${GATE_HELP}`);
30681
31361
  if (f) added.push(f);
30682
31362
  continue;
30683
31363
  }
30684
- const after = await readFile6(resolve21(repo.root, rel), "utf8").catch(() => null);
31364
+ const after = await readFile6(resolve24(repo.root, rel), "utf8").catch(() => null);
30685
31365
  if (after === null) continue;
30686
31366
  const before = then.has(rel) ? await committed(repo.root, rel) : null;
30687
31367
  added.push(...gateFindings(rel, before, after, defs));
@@ -30699,7 +31379,7 @@ ${head}`);
30699
31379
 
30700
31380
  // src/commands/guard-mcp-write.ts
30701
31381
  import { randomBytes as randomBytes9 } from "node:crypto";
30702
- import { createReadStream, createWriteStream, openSync as openSync5, writeSync as writeSync3 } from "node:fs";
31382
+ import { createReadStream, createWriteStream, openSync as openSync6, writeSync as writeSync3 } from "node:fs";
30703
31383
  import { homedir as homedir3 } from "node:os";
30704
31384
  import { createInterface as createInterface2 } from "node:readline";
30705
31385
  var GUARD_MCP_WRITE_HELP = `Usage: exorcist guard-mcp-write (Kiro hook helper)
@@ -30719,7 +31399,7 @@ var PROMPT_TIMEOUT_MS = 125e3;
30719
31399
  function hookDeps() {
30720
31400
  let fd = null;
30721
31401
  try {
30722
- fd = openSync5("/dev/tty", "r+");
31402
+ fd = openSync6("/dev/tty", "r+");
30723
31403
  } catch {
30724
31404
  fd = null;
30725
31405
  }
@@ -30814,7 +31494,7 @@ async function guardMcpWriteCommand(stdin, io, deps = hookDeps()) {
30814
31494
  }
30815
31495
 
30816
31496
  // src/commands/guard-env-write.ts
30817
- import { isAbsolute as isAbsolute12 } from "node:path";
31497
+ import { isAbsolute as isAbsolute15 } from "node:path";
30818
31498
  var GUARD_ENV_WRITE_HELP = `Usage: exorcist guard-env-write (Kiro hook helper)
30819
31499
  Reads a Kiro PreToolUse hook event for a file write (fs_write, str_replace) from
30820
31500
  stdin. When the text to be written holds a value from a .env file of this project
@@ -30826,7 +31506,7 @@ understand, is allowed: the hook must never stop the agent from working.
30826
31506
  `;
30827
31507
  function projectDir(event) {
30828
31508
  const cwd = typeof event === "object" && event !== null ? event["cwd"] : void 0;
30829
- return typeof cwd === "string" && cwd !== "" && isAbsolute12(cwd) ? cwd : process.cwd();
31509
+ return typeof cwd === "string" && cwd !== "" && isAbsolute15(cwd) ? cwd : process.cwd();
30830
31510
  }
30831
31511
  function guardEnvWriteCommand(stdin, io) {
30832
31512
  let event;
@@ -30843,7 +31523,7 @@ function guardEnvWriteCommand(stdin, io) {
30843
31523
  }
30844
31524
 
30845
31525
  // src/commands/guard-web-fetch.ts
30846
- import { isAbsolute as isAbsolute13 } from "node:path";
31526
+ import { isAbsolute as isAbsolute16 } from "node:path";
30847
31527
  var GUARD_WEB_FETCH_HELP = `Usage: exorcist guard-web-fetch (Kiro hook helper)
30848
31528
  Reads a Kiro PreToolUse hook event for the web_fetch tool from stdin. When the
30849
31529
  address holds a secret (a key or token), a canary token, or a value from a .env
@@ -30855,7 +31535,7 @@ understand, is allowed: the hook must never stop the agent from working.
30855
31535
  `;
30856
31536
  function projectDir2(event) {
30857
31537
  const cwd = typeof event === "object" && event !== null ? event["cwd"] : void 0;
30858
- return typeof cwd === "string" && cwd !== "" && isAbsolute13(cwd) ? cwd : process.cwd();
31538
+ return typeof cwd === "string" && cwd !== "" && isAbsolute16(cwd) ? cwd : process.cwd();
30859
31539
  }
30860
31540
  function guardWebFetchCommand(stdin, io) {
30861
31541
  let event;
@@ -30875,9 +31555,101 @@ function guardWebFetchCommand(stdin, io) {
30875
31555
  return 2;
30876
31556
  }
30877
31557
 
31558
+ // src/commands/guard-run-scripts.ts
31559
+ import { appendFileSync as appendFileSync2, existsSync as existsSync21 } from "node:fs";
31560
+ import { isAbsolute as isAbsolute17, join as join29 } from "node:path";
31561
+ var GUARD_RUN_SCRIPTS_HELP = `Usage: exorcist guard-run-scripts (Kiro hook helper)
31562
+ Reads a Kiro PreToolUse hook event for a shell tool from stdin. When the command
31563
+ would run a package script (npm test, npm run x, npm install, pnpm, yarn, npx of a
31564
+ local bin) whose file reads a secret (.env, .npmrc, ~/.aws, ~/.ssh, the whole
31565
+ environment) and sends data out, the command is blocked. Nothing is ever run.
31566
+ Exit codes: 0 allow, 2 block (the script and the file on stderr, never file text).
31567
+ Anything it cannot work out is allowed: the hook must never stop the agent from
31568
+ working. A command it cannot parse is allowed and noted in .exorcist/kiro-hooks.log.
31569
+ `;
31570
+ var cwdOf = (event) => {
31571
+ const c = typeof event === "object" && event !== null ? event["cwd"] : void 0;
31572
+ return typeof c === "string" && isAbsolute17(c) ? c : process.cwd();
31573
+ };
31574
+ function logParseFailure(cwd) {
31575
+ try {
31576
+ const dir = join29(cwd, ".exorcist");
31577
+ if (!existsSync21(dir)) return;
31578
+ appendFileSync2(join29(dir, "kiro-hooks.log"), `${(/* @__PURE__ */ new Date()).toISOString()} guard-run-scripts: the command could not be parsed, so it was allowed exit=0
31579
+ `);
31580
+ } catch {
31581
+ }
31582
+ }
31583
+ function guardRunScriptsCommand(stdin, io) {
31584
+ let event;
31585
+ try {
31586
+ event = JSON.parse(stdin);
31587
+ } catch {
31588
+ return 0;
31589
+ }
31590
+ const cwd = cwdOf(event);
31591
+ const d = decideRunScripts(event, cwd);
31592
+ if (d.block) {
31593
+ io.err(runScriptsBlockMessage(d.hit));
31594
+ return 2;
31595
+ }
31596
+ if (d.parseFailed) logParseFailure(cwd);
31597
+ return 0;
31598
+ }
31599
+
31600
+ // src/commands/guard-shell-read.ts
31601
+ import { isAbsolute as isAbsolute18 } from "node:path";
31602
+ var GUARD_SHELL_READ_HELP = `Usage: exorcist guard-shell-read (Kiro hook helper)
31603
+ Reads a Kiro PreToolUse hook event for a shell tool from stdin. When the command
31604
+ reads a file in this project with cat, head, tail, less, more, sed -n, awk, bat, nl
31605
+ or grep, the file is scanned the way "exorcist on-access" scans it, and the command
31606
+ is blocked when a high or critical rule fires. Globs and words with $, backticks or
31607
+ ~ are skipped, files outside the project are not scanned, and the command is never run.
31608
+ Exit codes: 0 allow, 2 block (the file name and the rule on stderr, never file text).
31609
+ Anything it cannot read or understand is allowed.
31610
+ `;
31611
+ var cwdOf2 = (stdin) => {
31612
+ try {
31613
+ const c = JSON.parse(stdin).cwd;
31614
+ if (typeof c === "string" && isAbsolute18(c)) return c;
31615
+ } catch {
31616
+ }
31617
+ return process.cwd();
31618
+ };
31619
+ async function guardShellReadCommand(stdin, io) {
31620
+ let event;
31621
+ try {
31622
+ event = JSON.parse(stdin);
31623
+ } catch {
31624
+ return 0;
31625
+ }
31626
+ const cwd = cwdOf2(stdin);
31627
+ const defsDir = findDefinitionsDir2();
31628
+ if (!defsDir) {
31629
+ io.err("Exorcist 98 guard-shell-read: no virus definitions were found, so the command was allowed.");
31630
+ return 0;
31631
+ }
31632
+ let defs;
31633
+ try {
31634
+ defs = await loadDefinitions(defsDir);
31635
+ } catch {
31636
+ io.err("Exorcist 98 guard-shell-read: the virus definitions could not be loaded, so the command was allowed.");
31637
+ return 0;
31638
+ }
31639
+ let allowed = /* @__PURE__ */ new Set();
31640
+ try {
31641
+ allowed = readAllowedReads(cwd);
31642
+ } catch {
31643
+ allowed = /* @__PURE__ */ new Set();
31644
+ }
31645
+ const d = decideShellRead(event, defs, { cwd, allowed }, cwd);
31646
+ if (d.message) io.err(d.message);
31647
+ return d.exitCode;
31648
+ }
31649
+
30878
31650
  // src/commands/hook-scan.ts
30879
- import { existsSync as existsSync19, statSync as statSync16 } from "node:fs";
30880
- import { resolve as resolve22 } from "node:path";
31651
+ import { existsSync as existsSync22, statSync as statSync19 } from "node:fs";
31652
+ import { resolve as resolve25 } from "node:path";
30881
31653
  async function hookScanCommand(stdin, io) {
30882
31654
  let event;
30883
31655
  try {
@@ -30887,14 +31659,14 @@ async function hookScanCommand(stdin, io) {
30887
31659
  }
30888
31660
  if (typeof event.file_path !== "string" || event.file_path === "") return 0;
30889
31661
  const base = typeof event.cwd === "string" && event.cwd ? event.cwd : process.cwd();
30890
- const file = resolve22(base, event.file_path);
30891
- if (!existsSync19(file) || !statSync16(file).isFile()) return 0;
31662
+ const file = resolve25(base, event.file_path);
31663
+ if (!existsSync22(file) || !statSync19(file).isFile()) return 0;
30892
31664
  return await scanCommand([file, "--fail-on", "high"], { out: io.err, err: io.err });
30893
31665
  }
30894
31666
 
30895
31667
  // src/commands/init.ts
30896
- import { chmodSync, existsSync as existsSync20, lstatSync as lstatSync8, mkdirSync as mkdirSync10, readFileSync as readFileSync23, writeFileSync as writeFileSync10 } from "node:fs";
30897
- import { dirname as dirname12, join as join27, resolve as resolve23 } from "node:path";
31668
+ import { chmodSync, existsSync as existsSync23, lstatSync as lstatSync8, mkdirSync as mkdirSync10, readFileSync as readFileSync24, writeFileSync as writeFileSync10 } from "node:fs";
31669
+ import { dirname as dirname14, join as join30, resolve as resolve26 } from "node:path";
30898
31670
 
30899
31671
  // src/kiro-hook-script.ts
30900
31672
  var KIRO_HOOK_SCRIPT = [
@@ -31012,8 +31784,8 @@ function reviewerAgentForProject(mcpCommand) {
31012
31784
  }
31013
31785
 
31014
31786
  // src/commands/init.ts
31015
- var DEFAULT_BIN = "npx -y @exorcist-98/cli@0.3.0";
31016
- var DEFAULT_MCP_BIN = "npx -y @exorcist-98/mcp-server@0.3.0";
31787
+ var DEFAULT_BIN = "npx -y @exorcist-98/cli@0.3.2";
31788
+ var DEFAULT_MCP_BIN = "npx -y @exorcist-98/mcp-server@0.3.2";
31017
31789
  var MISSING_FROM_DEFAULT_BIN = /* @__PURE__ */ new Set();
31018
31790
  var INIT_HELP = `Usage: exorcist init [folder] [--kiro] [--shield] [--sandbox] [--no-agent] [--force]
31019
31791
  [--bin <command>] [--mcp-bin <command>]
@@ -31027,6 +31799,8 @@ Add Exorcist 98 to a Kiro project:
31027
31799
  .kiro/hooks/exorcist-mcp-write-guard.json a person must confirm any agent write to an MCP config (Kiro hook)
31028
31800
  .kiro/hooks/exorcist-guard-web-fetch.json block a web fetch whose address holds a secret, canary or .env value (Kiro hook)
31029
31801
  .kiro/hooks/exorcist-guard-env-write.json block writing a .env value into any other file (Kiro hook)
31802
+ .kiro/hooks/exorcist-guard-run-scripts.json block a package script (npm test, install ...) that reads secrets and sends them out (Kiro hook)
31803
+ .kiro/hooks/exorcist-guard-shell-read.json scan a file before a shell command (cat, head, grep ...) reads it (Kiro hook)
31030
31804
  .kiro/steering/exorcist.md tell the agent how to treat tool output
31031
31805
  .exorcist/kiro-hook.sh puts Node on PATH for the Kiro hooks (Kiro's hook PATH has none)
31032
31806
  .exorcist/.gitignore keeps the hook log out of git
@@ -31050,7 +31824,7 @@ Existing files are never overwritten unless you pass --force.
31050
31824
  var SANDBOX_REL = ".kiro/settings/sandbox.json";
31051
31825
  var SANDBOX_SETTINGS = { enabled: true, networkAccess: "DEFAULT_BLOCKED", mcpSandboxing: true };
31052
31826
  function writeSandboxFile(root, io) {
31053
- const path = join27(root, SANDBOX_REL);
31827
+ const path = join30(root, SANDBOX_REL);
31054
31828
  let present = false;
31055
31829
  try {
31056
31830
  lstatSync8(path);
@@ -31058,7 +31832,7 @@ function writeSandboxFile(root, io) {
31058
31832
  } catch {
31059
31833
  }
31060
31834
  if (!present) {
31061
- mkdirSync10(dirname12(path), { recursive: true });
31835
+ mkdirSync10(dirname14(path), { recursive: true });
31062
31836
  try {
31063
31837
  writeFileSync10(path, `${JSON.stringify(SANDBOX_SETTINGS, null, 2)}
31064
31838
  `, { encoding: "utf8", flag: "wx" });
@@ -31124,9 +31898,9 @@ function splitCommand(s) {
31124
31898
  }
31125
31899
  var MAX_NAME = 60;
31126
31900
  function describeMcpConfig(path) {
31127
- if (!existsSync20(path)) return { exists: false, warnings: [], line: "no .kiro/settings/mcp.json yet (the mcp-scan hook scans it once you add one)" };
31901
+ if (!existsSync23(path)) return { exists: false, warnings: [], line: "no .kiro/settings/mcp.json yet (the mcp-scan hook scans it once you add one)" };
31128
31902
  try {
31129
- const cfg = JSON.parse(readFileSync23(path, "utf8"));
31903
+ const cfg = JSON.parse(readFileSync24(path, "utf8"));
31130
31904
  const entries = Object.entries(cfg.mcpServers ?? {});
31131
31905
  const shielded = entries.filter(([, e]) => isWrapped(e)).map(([n]) => n);
31132
31906
  const warnings = entries.filter(([, e]) => Array.isArray(e.autoApprove) && e.autoApprove.includes("*")).map(([n]) => `WARNING: server "${displayMessage(n.slice(0, MAX_NAME).replace(/[\t\n\r]/g, " "))}${n.length > MAX_NAME ? "..." : ""}" has autoApprove "*": your agent can run every tool of it without asking you. List only the tools you trust, or remove autoApprove.`);
@@ -31162,7 +31936,7 @@ ${INIT_HELP}`);
31162
31936
  ${INIT_HELP}`);
31163
31937
  return 2;
31164
31938
  }
31165
- const root = resolve23(p.positionals[0] ?? ".");
31939
+ const root = resolve26(p.positionals[0] ?? ".");
31166
31940
  const bin = str4(p.values["bin"]) ?? DEFAULT_BIN;
31167
31941
  const mcpBin = str4(p.values["mcp-bin"]) ?? DEFAULT_MCP_BIN;
31168
31942
  const force = p.values["force"] === true;
@@ -31194,6 +31968,8 @@ ${INIT_HELP}`);
31194
31968
  const mcpWriteOff = isDefaultBin && MISSING_FROM_DEFAULT_BIN.has("guard-mcp-write");
31195
31969
  const webFetchOff = isDefaultBin && MISSING_FROM_DEFAULT_BIN.has("guard-web-fetch");
31196
31970
  const envWriteOff = isDefaultBin && MISSING_FROM_DEFAULT_BIN.has("guard-env-write");
31971
+ const runScriptsOff = isDefaultBin && MISSING_FROM_DEFAULT_BIN.has("guard-run-scripts");
31972
+ const shellReadOff = isDefaultBin && MISSING_FROM_DEFAULT_BIN.has("guard-shell-read");
31197
31973
  const files = [
31198
31974
  {
31199
31975
  rel: ".kiro/hooks/exorcist-secrets.json",
@@ -31269,6 +32045,28 @@ ${INIT_HELP}`);
31269
32045
  ...envWriteOff ? { enabled: false } : {}
31270
32046
  })
31271
32047
  },
32048
+ {
32049
+ rel: ".kiro/hooks/exorcist-guard-run-scripts.json",
32050
+ summary: runScriptsOff ? 'PreToolUse on shell tools: WRITTEN DISABLED, because the published version in the default command has no guard-run-scripts command (pass --bin with a newer build, then set "enabled": true)' : "PreToolUse on shell tools: blocks npm test, npm install and similar when a script they run reads secrets and sends them out",
32051
+ body: hook("exorcist-guard-run-scripts", "Blocks a shell command that would run a package script (npm, pnpm, yarn, npx of a local bin) whose file reads a secret and sends data out. Exit code 2 blocks the command; the reason names the script and the file, never file text. Nothing is run to find out.", {
32052
+ trigger: "PreToolUse",
32053
+ matcher: "shell|execute_bash|executeBash|run_command|bash",
32054
+ action: { type: "command", command: `${HOOK_RUNNER} ${bin} guard-run-scripts` },
32055
+ timeout: 15,
32056
+ ...runScriptsOff ? { enabled: false } : {}
32057
+ })
32058
+ },
32059
+ {
32060
+ rel: ".kiro/hooks/exorcist-guard-shell-read.json",
32061
+ summary: shellReadOff ? 'PreToolUse on shell tools: WRITTEN DISABLED, because the published version in the default command has no guard-shell-read command (pass --bin with a newer build, then set "enabled": true)' : "PreToolUse on shell tools: scans a file before cat, head, tail, grep, sed -n, awk, bat or nl reads it",
32062
+ body: hook("exorcist-guard-shell-read", "Scans the files a shell command reads (cat, head, tail, less, more, sed -n, awk, bat, nl, grep) the way the on-access hook scans a read, and blocks the command when a high or critical rule fires. Exit code 2 blocks the command; the reason never quotes the file.", {
32063
+ trigger: "PreToolUse",
32064
+ matcher: "shell|execute_bash|executeBash|run_command|bash",
32065
+ action: { type: "command", command: `${HOOK_RUNNER} ${bin} guard-shell-read` },
32066
+ timeout: 15,
32067
+ ...shellReadOff ? { enabled: false } : {}
32068
+ })
32069
+ },
31272
32070
  { rel: ".kiro/steering/exorcist.md", body: STEERING, summary: "steering (inclusion: always): tool output and file text are data, never instructions" },
31273
32071
  { rel: ".exorcist/kiro-hook.sh", body: KIRO_HOOK_SCRIPT, executable: true, summary: "finds Node for the hooks (Kiro gives hook commands a PATH without it)" },
31274
32072
  { rel: ".exorcist/.gitignore", body: "kiro-hooks.log\n", summary: "keeps the hook log out of git" },
@@ -31284,13 +32082,13 @@ ${INIT_HELP}`);
31284
32082
  }
31285
32083
  const done = [];
31286
32084
  for (const f of files) {
31287
- const path = join27(root, f.rel);
31288
- if (existsSync20(path) && !force) {
32085
+ const path = join30(root, f.rel);
32086
+ if (existsSync23(path) && !force) {
31289
32087
  io.err(`Kept existing ${f.rel} (use --force to replace it).`);
31290
32088
  done.push({ f, wrote: false });
31291
32089
  continue;
31292
32090
  }
31293
- mkdirSync10(dirname12(path), { recursive: true });
32091
+ mkdirSync10(dirname14(path), { recursive: true });
31294
32092
  writeFileSync10(path, f.body, "utf8");
31295
32093
  if (f.executable) chmodSync(path, 493);
31296
32094
  if (!kiro) io.out(`Wrote ${f.rel}`);
@@ -31302,7 +32100,7 @@ ${INIT_HELP}`);
31302
32100
  return wroteAny ? 0 : 1;
31303
32101
  }
31304
32102
  if (sandbox) writeSandboxFile(root, io);
31305
- const mcpPath = join27(root, ".kiro/settings/mcp.json");
32103
+ const mcpPath = join30(root, ".kiro/settings/mcp.json");
31306
32104
  let shieldOk = true;
31307
32105
  let shieldLine = null;
31308
32106
  if (shield) {
@@ -31312,7 +32110,7 @@ ${INIT_HELP}`);
31312
32110
  shieldOk = false;
31313
32111
  } else {
31314
32112
  const [head, ...rest] = binWords;
31315
- const args = [mcpPath, `--bin=${head}`, ...rest.map((a) => `--bin-arg=${a}`), `--dir=${join27(root, ".exorcist")}`];
32113
+ const args = [mcpPath, `--bin=${head}`, ...rest.map((a) => `--bin-arg=${a}`), `--dir=${join30(root, ".exorcist")}`];
31316
32114
  const notes = [];
31317
32115
  const code3 = await wrapCommand(args, { out: io.out, err: (s) => notes.push(s) }, "wrap");
31318
32116
  for (const n of notes) io.err(n);
@@ -31356,7 +32154,7 @@ ${INIT_HELP}`);
31356
32154
  "then reconnect MCP servers in the MCP panel so they start through the Shield."
31357
32155
  ];
31358
32156
  if (isDefaultBin) {
31359
- lines.push("Commands run through npx (@exorcist-98/cli@0.3.0). If Kiro cannot start a wrapped server or a hook cannot find npx,");
32157
+ lines.push("Commands run through npx (@exorcist-98/cli@0.3.2). If Kiro cannot start a wrapped server or a hook cannot find npx,");
31360
32158
  lines.push('rerun with --bin "<absolute path to node> <absolute path to the exorcist CLI>" and --force.');
31361
32159
  }
31362
32160
  io.out(lines.join("\n"));
@@ -31365,8 +32163,8 @@ ${INIT_HELP}`);
31365
32163
  }
31366
32164
 
31367
32165
  // src/commands/lock.ts
31368
- import { existsSync as existsSync21, readFileSync as readFileSync24, writeFileSync as writeFileSync11 } from "node:fs";
31369
- import { isAbsolute as isAbsolute14, join as join28, resolve as resolve24 } from "node:path";
32166
+ import { existsSync as existsSync24, readFileSync as readFileSync25, writeFileSync as writeFileSync11 } from "node:fs";
32167
+ import { isAbsolute as isAbsolute19, join as join31, resolve as resolve27 } from "node:path";
31370
32168
 
31371
32169
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js
31372
32170
  var NEVER2 = Object.freeze({
@@ -37236,7 +38034,7 @@ var Protocol = class {
37236
38034
  return;
37237
38035
  }
37238
38036
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
37239
- await new Promise((resolve28) => setTimeout(resolve28, pollInterval));
38037
+ await new Promise((resolve31) => setTimeout(resolve31, pollInterval));
37240
38038
  options?.signal?.throwIfAborted();
37241
38039
  }
37242
38040
  } catch (error2) {
@@ -37253,7 +38051,7 @@ var Protocol = class {
37253
38051
  */
37254
38052
  request(request, resultSchema, options) {
37255
38053
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
37256
- return new Promise((resolve28, reject) => {
38054
+ return new Promise((resolve31, reject) => {
37257
38055
  const earlyReject = (error2) => {
37258
38056
  reject(error2);
37259
38057
  };
@@ -37331,7 +38129,7 @@ var Protocol = class {
37331
38129
  if (!parseResult.success) {
37332
38130
  reject(parseResult.error);
37333
38131
  } else {
37334
- resolve28(parseResult.data);
38132
+ resolve31(parseResult.data);
37335
38133
  }
37336
38134
  } catch (error2) {
37337
38135
  reject(error2);
@@ -37593,12 +38391,12 @@ var Protocol = class {
37593
38391
  }
37594
38392
  } catch {
37595
38393
  }
37596
- return new Promise((resolve28, reject) => {
38394
+ return new Promise((resolve31, reject) => {
37597
38395
  if (signal.aborted) {
37598
38396
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
37599
38397
  return;
37600
38398
  }
37601
- const timeoutId = setTimeout(resolve28, interval);
38399
+ const timeoutId = setTimeout(resolve31, interval);
37602
38400
  signal.addEventListener("abort", () => {
37603
38401
  clearTimeout(timeoutId);
37604
38402
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -38549,7 +39347,7 @@ var StdioClientTransport = class {
38549
39347
  if (this._process) {
38550
39348
  throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
38551
39349
  }
38552
- return new Promise((resolve28, reject) => {
39350
+ return new Promise((resolve31, reject) => {
38553
39351
  this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
38554
39352
  // merge default env with server env because mcp server needs some env vars
38555
39353
  env: {
@@ -38566,7 +39364,7 @@ var StdioClientTransport = class {
38566
39364
  this.onerror?.(error2);
38567
39365
  });
38568
39366
  this._process.on("spawn", () => {
38569
- resolve28();
39367
+ resolve31();
38570
39368
  });
38571
39369
  this._process.on("close", (_code) => {
38572
39370
  this._process = void 0;
@@ -38631,22 +39429,22 @@ var StdioClientTransport = class {
38631
39429
  if (this._process) {
38632
39430
  const processToClose = this._process;
38633
39431
  this._process = void 0;
38634
- const closePromise = new Promise((resolve28) => {
39432
+ const closePromise = new Promise((resolve31) => {
38635
39433
  processToClose.once("close", () => {
38636
- resolve28();
39434
+ resolve31();
38637
39435
  });
38638
39436
  });
38639
39437
  try {
38640
39438
  processToClose.stdin?.end();
38641
39439
  } catch {
38642
39440
  }
38643
- await Promise.race([closePromise, new Promise((resolve28) => setTimeout(resolve28, 2e3).unref())]);
39441
+ await Promise.race([closePromise, new Promise((resolve31) => setTimeout(resolve31, 2e3).unref())]);
38644
39442
  if (processToClose.exitCode === null) {
38645
39443
  try {
38646
39444
  processToClose.kill("SIGTERM");
38647
39445
  } catch {
38648
39446
  }
38649
- await Promise.race([closePromise, new Promise((resolve28) => setTimeout(resolve28, 2e3).unref())]);
39447
+ await Promise.race([closePromise, new Promise((resolve31) => setTimeout(resolve31, 2e3).unref())]);
38650
39448
  }
38651
39449
  if (processToClose.exitCode === null) {
38652
39450
  try {
@@ -38658,15 +39456,15 @@ var StdioClientTransport = class {
38658
39456
  this._readBuffer.clear();
38659
39457
  }
38660
39458
  send(message) {
38661
- return new Promise((resolve28) => {
39459
+ return new Promise((resolve31) => {
38662
39460
  if (!this._process?.stdin) {
38663
39461
  throw new Error("Not connected");
38664
39462
  }
38665
39463
  const json2 = serializeMessage(message);
38666
39464
  if (this._process.stdin.write(json2)) {
38667
- resolve28();
39465
+ resolve31();
38668
39466
  } else {
38669
- this._process.stdin.once("drain", resolve28);
39467
+ this._process.stdin.once("drain", resolve31);
38670
39468
  }
38671
39469
  });
38672
39470
  }
@@ -38675,7 +39473,7 @@ var StdioClientTransport = class {
38675
39473
  // src/commands/lock.ts
38676
39474
  init_zod();
38677
39475
  var DEFAULT_LOCK_TIMEOUT_MS = 2e4;
38678
- var DEFAULT_CONFIG = join28(".kiro", "settings", "mcp.json");
39476
+ var DEFAULT_CONFIG = join31(".kiro", "settings", "mcp.json");
38679
39477
  var MAX_PAGES = 100;
38680
39478
  var LOCK_HELP = `Usage: exorcist lock [options]
38681
39479
  exorcist lock --check [options]
@@ -38726,7 +39524,7 @@ var EntrySchema2 = external_exports.object({
38726
39524
  function readConfig3(path) {
38727
39525
  let json2;
38728
39526
  try {
38729
- json2 = JSON.parse(readFileSync24(path, "utf8"));
39527
+ json2 = JSON.parse(readFileSync25(path, "utf8"));
38730
39528
  } catch {
38731
39529
  return { ok: false, error: `${path} is not valid JSON.` };
38732
39530
  }
@@ -38739,7 +39537,7 @@ var RawToolsPage = external_exports.object({ tools: external_exports.array(exter
38739
39537
  var firstLine2 = (err) => (err instanceof Error ? err.message : String(err)).split("\n")[0]?.slice(0, 300) ?? "unknown error";
38740
39538
  async function listTools(o) {
38741
39539
  const transport = new StdioClientTransport({ command: o.command, args: o.args, env: o.env, cwd: o.cwd, stderr: "ignore" });
38742
- const client = new Client({ name: "exorcist-lock", version: "0.3.0" }, { capabilities: {} });
39540
+ const client = new Client({ name: "exorcist-lock", version: "0.3.2" }, { capabilities: {} });
38743
39541
  let timer;
38744
39542
  const timedOut = new Promise((res) => {
38745
39543
  timer = setTimeout(() => res({ ok: false, error: `it did not list its tools within ${o.timeoutMs} ms.` }), o.timeoutMs);
@@ -38822,7 +39620,7 @@ async function collectListings(config2, o) {
38822
39620
  if (loaders.length > 0) {
38823
39621
  warnings.push(`HIGH EX-025: "${name}" sets ${loaders.join(", ")} in its env, which changes how its program loads (for example NODE_OPTIONS=--require runs extra code first). Make sure you know why it is there.`);
38824
39622
  }
38825
- const cwd = entry.cwd === void 0 ? o.cwd : isAbsolute14(entry.cwd) ? entry.cwd : resolve24(o.cwd, entry.cwd);
39623
+ const cwd = entry.cwd === void 0 ? o.cwd : isAbsolute19(entry.cwd) ? entry.cwd : resolve27(o.cwd, entry.cwd);
38826
39624
  if (o.static) {
38827
39625
  const old = o.previous && Object.hasOwn(o.previous.servers, name) ? o.previous.servers[name] : void 0;
38828
39626
  kept.push([name, { launch: launchFingerprint(command, entry.args, cwd, void 0, pinEntry).hash, tools: old?.tools ?? {} }]);
@@ -38891,7 +39689,7 @@ ${LOCK_HELP}`);
38891
39689
  io.err("--timeout must be a positive whole number of milliseconds.");
38892
39690
  return 2;
38893
39691
  }
38894
- const lockPath2 = resolve24(str4(p.values["lock"]) ?? LOCK_FILE);
39692
+ const lockPath2 = resolve27(str4(p.values["lock"]) ?? LOCK_FILE);
38895
39693
  const checking = p.values["check"] === true;
38896
39694
  const fromShield = p.values["from-shield"] === true;
38897
39695
  const isStatic = p.values["static"] === true;
@@ -38904,10 +39702,10 @@ ${LOCK_HELP}`);
38904
39702
  return 2;
38905
39703
  }
38906
39704
  let previous;
38907
- if (existsSync21(lockPath2)) {
39705
+ if (existsSync24(lockPath2)) {
38908
39706
  let text2;
38909
39707
  try {
38910
- text2 = readFileSync24(lockPath2, "utf8");
39708
+ text2 = readFileSync25(lockPath2, "utf8");
38911
39709
  } catch (err) {
38912
39710
  io.err(`Could not read ${lockPath2}: ${firstLine2(err)}`);
38913
39711
  return 2;
@@ -38932,8 +39730,8 @@ ${LOCK_HELP}`);
38932
39730
  }
38933
39731
  current = pinsToLock(st.state);
38934
39732
  } else {
38935
- const configPath = resolve24(str4(p.values["config"]) ?? DEFAULT_CONFIG);
38936
- if (!existsSync21(configPath)) {
39733
+ const configPath = resolve27(str4(p.values["config"]) ?? DEFAULT_CONFIG);
39734
+ if (!existsSync24(configPath)) {
38937
39735
  io.err(`MCP config not found: ${configPath}. Pass --config <file>, or --from-shield.`);
38938
39736
  return 2;
38939
39737
  }
@@ -38981,8 +39779,8 @@ ${LOCK_HELP}`);
38981
39779
  }
38982
39780
 
38983
39781
  // src/commands/map.ts
38984
- import { existsSync as existsSync22, statSync as statSync17 } from "node:fs";
38985
- import { resolve as resolve25 } from "node:path";
39782
+ import { existsSync as existsSync25, statSync as statSync20 } from "node:fs";
39783
+ import { resolve as resolve28 } from "node:path";
38986
39784
  var MAP_HELP = `Usage: exorcist map [dir] [options]
38987
39785
 
38988
39786
  The Haunted House Map: for every MCP config in a folder (default: the current
@@ -39077,8 +39875,8 @@ ${MAP_HELP}`);
39077
39875
  return 2;
39078
39876
  }
39079
39877
  const target = p.positionals[0] ?? ".";
39080
- const root = resolve25(target);
39081
- if (!existsSync22(root) || !statSync17(root).isDirectory()) {
39878
+ const root = resolve28(target);
39879
+ if (!existsSync25(root) || !statSync20(root).isDirectory()) {
39082
39880
  io.err(`Folder not found: ${target}`);
39083
39881
  return 2;
39084
39882
  }
@@ -39100,8 +39898,8 @@ ${MAP_HELP}`);
39100
39898
  }
39101
39899
 
39102
39900
  // src/commands/origin.ts
39103
- import { existsSync as existsSync23, realpathSync as realpathSync5, statSync as statSync18 } from "node:fs";
39104
- import { posix, relative as relative9, resolve as resolve26, sep as sep2 } from "node:path";
39901
+ import { existsSync as existsSync26, realpathSync as realpathSync7, statSync as statSync21 } from "node:fs";
39902
+ import { posix, relative as relative12, resolve as resolve29, sep as sep5 } from "node:path";
39105
39903
  var ORIGIN_HELP = `Usage: exorcist origin [dir] [options]
39106
39904
 
39107
39905
  Scan a git repository, then walk its history to find the commit that
@@ -39223,8 +40021,8 @@ ${ORIGIN_HELP}`);
39223
40021
  ${ORIGIN_HELP}`);
39224
40022
  return 2;
39225
40023
  }
39226
- const target = resolve26(p.positionals[0] ?? ".");
39227
- if (!existsSync23(target) || !statSync18(target).isDirectory()) {
40024
+ const target = resolve29(p.positionals[0] ?? ".");
40025
+ if (!existsSync26(target) || !statSync21(target).isDirectory()) {
39228
40026
  io.err(`Not a directory: ${target}`);
39229
40027
  return 2;
39230
40028
  }
@@ -39238,8 +40036,8 @@ ${ORIGIN_HELP}`);
39238
40036
  return 2;
39239
40037
  }
39240
40038
  const { root: repoRoot, shallow, boundaries } = repo;
39241
- const scanRoot = realpathSync5(target);
39242
- const prefix = relative9(realpathSync5(repoRoot), scanRoot).split(sep2).join("/");
40039
+ const scanRoot = realpathSync7(target);
40040
+ const prefix = relative12(realpathSync7(repoRoot), scanRoot).split(sep5).join("/");
39243
40041
  if (prefix.startsWith("..")) {
39244
40042
  io.err(`The folder is outside the git repository git reported (${repoRoot}).`);
39245
40043
  return 2;
@@ -39311,7 +40109,7 @@ ${ORIGIN_HELP}`);
39311
40109
  }
39312
40110
 
39313
40111
  // src/commands/shield.ts
39314
- import { resolve as resolve27 } from "node:path";
40112
+ import { resolve as resolve30 } from "node:path";
39315
40113
  var SHIELD_HELP = `Usage: exorcist shield --server <name> [options] -- <command> [args...]
39316
40114
  exorcist shield --server <name> --url <https://...> [options]
39317
40115
 
@@ -39362,9 +40160,9 @@ function parseHeaders(literal2, fromEnv, env) {
39362
40160
  return { ok: true, headers };
39363
40161
  }
39364
40162
  async function shieldCommand(argv, io) {
39365
- const sep3 = argv.indexOf("--");
39366
- const flags = sep3 === -1 ? argv : argv.slice(0, sep3);
39367
- const rest = sep3 === -1 ? [] : argv.slice(sep3 + 1);
40163
+ const sep6 = argv.indexOf("--");
40164
+ const flags = sep6 === -1 ? argv : argv.slice(0, sep6);
40165
+ const rest = sep6 === -1 ? [] : argv.slice(sep6 + 1);
39368
40166
  const p = parse3(flags, {
39369
40167
  server: { type: "string" },
39370
40168
  config: { type: "string" },
@@ -39416,7 +40214,7 @@ ${SHIELD_HELP}`);
39416
40214
  server,
39417
40215
  dir: stateDir(str4(p.values["dir"])),
39418
40216
  definitionsDir: defs,
39419
- ...config2 ? { configPath: resolve27(config2) } : {},
40217
+ ...config2 ? { configPath: resolve30(config2) } : {},
39420
40218
  // Desktop notifications for critical and high alerts; EXORCIST_NOTIFY=0 or policy notify:false turns them off.
39421
40219
  ...process.env["EXORCIST_NOTIFY"] === "0" ? {} : { notify: desktopNotifier() }
39422
40220
  };
@@ -39736,7 +40534,7 @@ ${VERIFY_LOG_HELP}`);
39736
40534
  }
39737
40535
 
39738
40536
  // src/index.ts
39739
- var VERSION = "0.3.0";
40537
+ var VERSION = "0.3.2";
39740
40538
  var HELP = `Exorcist 98 ${VERSION}: antivirus for AI coding agents
39741
40539
 
39742
40540
  Usage: exorcist <command> [options]
@@ -39774,6 +40572,8 @@ Commands:
39774
40572
  finding (read-only; run by the Kiro Stop hook)
39775
40573
  guard-mcp-write Hook helper: a person must confirm any agent write to an MCP config
39776
40574
  guard-web-fetch Hook helper: block a web fetch whose address holds a secret, canary or .env value
40575
+ guard-run-scripts Hook helper: block a package script (npm test, install ...) that reads secrets and sends them out
40576
+ guard-shell-read Hook helper: scan a file before a shell command (cat, head, grep ...) reads it
39777
40577
  guard-env-write Hook helper: block writing a .env value into any other file
39778
40578
  guard-commit Hook helper: block git commit while secrets are staged
39779
40579
  hook-scan Hook helper: scan the file named in a Kiro "file saved" event
@@ -39855,6 +40655,18 @@ async function main(argv) {
39855
40655
  return 0;
39856
40656
  }
39857
40657
  return guardWebFetchCommand(await readStdin(), stdio);
40658
+ case "guard-run-scripts":
40659
+ if (rest.includes("--help") || rest.includes("-h")) {
40660
+ stdio.out(GUARD_RUN_SCRIPTS_HELP);
40661
+ return 0;
40662
+ }
40663
+ return guardRunScriptsCommand(await readStdin(), stdio);
40664
+ case "guard-shell-read":
40665
+ if (rest.includes("--help") || rest.includes("-h")) {
40666
+ stdio.out(GUARD_SHELL_READ_HELP);
40667
+ return 0;
40668
+ }
40669
+ return await guardShellReadCommand(await readStdin(), stdio);
39858
40670
  case "guard-env-write":
39859
40671
  if (rest.includes("--help") || rest.includes("-h")) {
39860
40672
  stdio.out(GUARD_ENV_WRITE_HELP);