@exorcist-98/cli 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +8 -8
  2. package/dist/index.mjs +145 -109
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@ Needs Node 20 or newer.
11
11
  ## Scan a project
12
12
 
13
13
  ```sh
14
- npx -y @exorcist-98/cli@0.3.3 scan .
14
+ npx -y @exorcist-98/cli@0.3.5 scan .
15
15
  ```
16
16
 
17
17
  Every finding shows the file, line, the exact text, how serious it is and how
@@ -39,7 +39,7 @@ request.
39
39
  ## Map the haunted house
40
40
 
41
41
  ```sh
42
- npx -y @exorcist-98/cli@0.3.3 map .
42
+ npx -y @exorcist-98/cli@0.3.5 map .
43
43
  ```
44
44
 
45
45
  For every MCP config in the folder, lists which servers sit in the three rooms
@@ -52,8 +52,8 @@ data. The rules are in `definitions/capabilities.yaml`.
52
52
  ## Disinfect (exorcise)
53
53
 
54
54
  ```sh
55
- npx -y @exorcist-98/cli@0.3.3 exorcise . # dry run: prints a unified diff
56
- npx -y @exorcist-98/cli@0.3.3 exorcise . --write # apply, with a vault backup first
55
+ npx -y @exorcist-98/cli@0.3.5 exorcise . # dry run: prints a unified diff
56
+ npx -y @exorcist-98/cli@0.3.5 exorcise . --write # apply, with a vault backup first
57
57
  ```
58
58
 
59
59
  Only threats with one safe, mechanical fix are repaired: hidden characters
@@ -67,7 +67,7 @@ human"), and `exorcist vault restore <id>` puts every file back byte for byte.
67
67
  ## Protect your MCP servers
68
68
 
69
69
  ```sh
70
- npx -y @exorcist-98/cli@0.3.3 wrap .kiro/settings/mcp.json
70
+ npx -y @exorcist-98/cli@0.3.5 wrap .kiro/settings/mcp.json
71
71
  ```
72
72
 
73
73
  `wrap` puts every server in the file, local or remote, behind the Real-Time
@@ -79,9 +79,9 @@ instruct your agent. `unwrap` restores the file exactly. See
79
79
  ## Share approved tools with your team: exorcist.lock
80
80
 
81
81
  ```sh
82
- npx -y @exorcist-98/cli@0.3.3 lock # write exorcist.lock, then commit it
83
- npx -y @exorcist-98/cli@0.3.3 lock --check # exit 1 if any tool or program changed
84
- npx -y @exorcist-98/cli@0.3.3 lock --check --static # starts nothing: names, programs, URLs only
82
+ npx -y @exorcist-98/cli@0.3.5 lock # write exorcist.lock, then commit it
83
+ npx -y @exorcist-98/cli@0.3.5 lock --check # exit 1 if any tool or program changed
84
+ npx -y @exorcist-98/cli@0.3.5 lock --check --static # starts nothing: names, programs, URLs only
85
85
  ```
86
86
 
87
87
  `exorcist.lock` records the fingerprint of every tool your MCP servers list,
package/dist/index.mjs CHANGED
@@ -21762,7 +21762,7 @@ function checkPathSegment(name) {
21762
21762
  }
21763
21763
 
21764
21764
  // ../core/src/lifecycle-scripts.ts
21765
- import { closeSync, existsSync, lstatSync, openSync, readdirSync, readSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
21765
+ import { closeSync, existsSync as existsSync2, lstatSync, openSync, readdirSync, readSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
21766
21766
  import { isAbsolute as isAbsolute5, join as join7, posix as posix2, relative as relative5, resolve as resolve5, sep } from "node:path";
21767
21767
 
21768
21768
  // ../core/src/install-hooks.ts
@@ -22592,7 +22592,7 @@ function parseShell(command, sub = false) {
22592
22592
 
22593
22593
  // ../core/src/dev-tools.ts
22594
22594
  init_zod();
22595
- import { readFileSync as readFileSync3, statSync } from "node:fs";
22595
+ import { existsSync, readFileSync as readFileSync3, statSync } from "node:fs";
22596
22596
  import { homedir as homedir2 } from "node:os";
22597
22597
  import { isAbsolute as isAbsolute4, join as join6, normalize as normalize2, relative as relative4, resolve as resolve3 } from "node:path";
22598
22598
 
@@ -22905,12 +22905,42 @@ function envFamilyOwners(name) {
22905
22905
  for (const [re2, owners] of ENV_FAMILIES) if (re2.test(name)) return owners;
22906
22906
  return null;
22907
22907
  }
22908
- function envAssignRisk(name, value, cwd, dynamic = false, known) {
22908
+ var PATH_VAR = /(?:CONFIG|_FILES?|_DIR|_HOME|_PATH|_PLUGINS?|CACHEDIR|_CERT\w*|_CA\w*)$/;
22909
+ var PROGRAM_VAR = /(?:EDITOR|PAGER|BROWSER|_CMD|_COMMAND|_HELPER|_PROGRAM|_EXEC|_SHELL|_ARGS(?:_\w+)?)$/u;
22910
+ var ENDPOINT_VAR = /(?:_HOST|_URL|_ENDPOINT|_SERVER)$/;
22911
+ function unlockedValueRisk(name, value, cwd, dynamic) {
22912
+ const runtime = dynamic || /[$`]/.test(value);
22913
+ const say = `${name} is set to a path inside the project, or to a value built at run time, and a tool config can name a program to run or a daemon to reach`;
22914
+ if (runtime) return say;
22915
+ if (PATH_VAR.test(name) && anyInside(value, cwd)) return say;
22916
+ const parts2 = value.split(/[\s:,;=]+/u).filter((x) => x !== "");
22917
+ if (PROGRAM_VAR.test(name)) {
22918
+ const only = parts2.length === 1 && value.trim() === parts2[0] ? parts2[0] : void 0;
22919
+ const ok2 = only !== void 0 && (isAbsolute4(only) ? !insideProject(only, cwd) : !/[/\\~]/u.test(only) && cwd !== void 0 && !existsSync(resolve3(cwd, only)));
22920
+ if (!ok2) return `${name} names a program or arguments for the tool, and only one word is allowed: an absolute path outside the project, or a program name that is not a file in the project`;
22921
+ }
22922
+ for (const part of parts2) {
22923
+ if (/^[./~]/u.test(part) || part.includes("/")) {
22924
+ if (insideProject(part, cwd)) return say;
22925
+ } else {
22926
+ const bare = part.replace(/^-+/u, "");
22927
+ if (bare !== "" && (cwd === void 0 || existsSync(resolve3(cwd, bare)))) return say;
22928
+ }
22929
+ }
22930
+ if (ENDPOINT_VAR.test(name)) {
22931
+ const m = /^(?:unix|npipe|file):\/\/(.*)$/.exec(value);
22932
+ const target = m === null ? value : m[1];
22933
+ if ((m !== null || /^[./~]/.test(target)) && insideProject(target, cwd)) return say;
22934
+ }
22935
+ return null;
22936
+ }
22937
+ function envAssignRisk(name, value, cwd, dynamic = false, known, prog) {
22909
22938
  const owners = envFamilyOwners(name);
22910
22939
  if (owners !== null) {
22911
22940
  if (name === "HELM_PLUGINS") return "HELM_PLUGINS names a folder of helm plugins, which are programs, and the guard always refuses it. The person can run it in their own terminal";
22912
22941
  const list2 = known ?? userKnownPrograms();
22913
- if (owners.some((o) => list2.has(o))) return null;
22942
+ const unlocked = prog === void 0 ? owners.some((o) => list2.has(o)) : owners.includes(prog) && list2.has(prog);
22943
+ if (unlocked) return unlockedValueRisk(name, value, cwd, dynamic);
22914
22944
  return `${name} belongs to the environment of ${owners[0]}, and its variables change what the tool runs or trusts (config files, plugins, endpoints, certificates, helpers). The guard refuses them whatever the value. To allow it, add "${owners[0]}" to the list of programs in your own user config, ${KNOWN_PROGRAMS_HINT} (a list inside a repository is never read)`;
22915
22945
  }
22916
22946
  if (!RISK_ENV.test(name)) return null;
@@ -23082,7 +23112,7 @@ function route(tool, args, c) {
23082
23112
  const bad = entry.check?.(parsed.pos, parsed.opts, c) ?? null;
23083
23113
  if (bad !== null) return blocked(n, `${n} ${key}`, bad);
23084
23114
  if (entry.stop !== void 0) {
23085
- const ep = parsed.opts.find((o) => o.name === "--entrypoint")?.value;
23115
+ const ep = parsed.opts.filter((o) => o.name === "--entrypoint").pop()?.value;
23086
23116
  const inner = [...ep === void 0 ? [] : [ep], ...parsed.rest ?? []];
23087
23117
  return inner.length === 0 ? plain : { kind: "follow", words: inner };
23088
23118
  }
@@ -23163,8 +23193,8 @@ var KUBE_NEVER = /* @__PURE__ */ new Map([
23163
23193
  ["--server", "was given a server address, and the request would carry your credentials to it"]
23164
23194
  ]);
23165
23195
  var tableOutputOnly = (_pos, opts) => {
23166
- const o = opts.find((x) => x.name === "-o" || x.name === "--output");
23167
- return o === void 0 || o.value !== void 0 && ["wide", "name"].includes(t(o.value)) ? null : "was asked for an output format other than the plain table (wide or name), and yaml, json and templates return secret values";
23196
+ const outs = opts.filter((x) => x.name === "-o" || x.name === "--output");
23197
+ return outs.every((o) => o.value !== void 0 && ["wide", "name"].includes(t(o.value).replace(/^=/, ""))) ? null : "was asked for an output format other than the plain table (wide or name), and yaml, json and templates return secret values";
23168
23198
  };
23169
23199
  var KUBECTL_TOOL = {
23170
23200
  name: "kubectl",
@@ -23310,11 +23340,11 @@ var TOOLS = {
23310
23340
  };
23311
23341
  function devToolPlan(prog, args, ctx = {}) {
23312
23342
  const c = { env: ctx.env ?? {}, known: ctx.known ?? userKnownPrograms(), ...ctx.cwd === void 0 ? {} : { cwd: ctx.cwd } };
23313
- if (c.known.has(prog)) return plain;
23314
23343
  for (const [k, v] of Object.entries(c.env)) {
23315
- const risk = envAssignRisk(k, v, c.cwd, false, c.known);
23344
+ const risk = envAssignRisk(k, v, c.cwd, false, c.known, prog);
23316
23345
  if (risk !== null) return blocked(prog, prog, `was given ${risk}`);
23317
23346
  }
23347
+ if (c.known.has(prog)) return plain;
23318
23348
  const unreadable = args.find((w) => w.dynamic || w.glob);
23319
23349
  if (unreadable !== void 0) return blocked(prog, prog, "was given a word built at run time (a variable, a substitution or a pattern), and the guard cannot read what it will be");
23320
23350
  switch (prog) {
@@ -23856,7 +23886,8 @@ function resolveWords(words2, f, ctx) {
23856
23886
  const env = { ...f.env };
23857
23887
  let i = skipFlags(words2, 1, WRAP_SPECS[prog], prog, prog === "env" || prog === "sudo" || prog === "doas" ? env : void 0);
23858
23888
  if (prog === "env" || prog === "sudo" || prog === "doas") {
23859
- for (const [k, v] of Object.entries(env)) if (f.env[k] !== v) checkAssign(ctx, k, v, /[$`]/.test(v));
23889
+ const inner = words2[i] !== void 0 && !words2[i]?.dynamic && !words2[i]?.glob ? progName(words2[i].text) : void 0;
23890
+ for (const [k, v] of Object.entries(env)) if (f.env[k] !== v) checkAssign(ctx, k, v, /[$`]/.test(v), inner);
23860
23891
  }
23861
23892
  if (prog === "timeout") {
23862
23893
  if (words2[i] === void 0 || words2[i]?.dynamic) reject("timeout has no fixed duration");
@@ -24031,9 +24062,14 @@ function producedText(e) {
24031
24062
  }
24032
24063
  var ENV_DECLARERS = /* @__PURE__ */ new Set(["export", "declare", "typeset", "readonly", "local"]);
24033
24064
  var ASSIGN_WORD = /^([A-Za-z_][A-Za-z0-9_]*)=([\s\S]*)$/;
24034
- function checkAssign(ctx, name, value, dynamic) {
24065
+ function literalProg(words2) {
24066
+ const w = words2[0];
24067
+ if (w === void 0 || w.dynamic || w.glob || ENV_DECLARERS.has(w.text)) return void 0;
24068
+ return progName(w.text);
24069
+ }
24070
+ function checkAssign(ctx, name, value, dynamic, prog) {
24035
24071
  if (ctx.mode !== "agent") return;
24036
- const why = envAssignRisk(name, value, ctx.cwd, dynamic);
24072
+ const why = envAssignRisk(name, value, ctx.cwd, dynamic, void 0, prog);
24037
24073
  if (why !== null) reject(`${why}. If you trust it, the person can run it in their own terminal`, FIX_SIMPLE);
24038
24074
  }
24039
24075
  function resolveCommands(commands, ctx, via, baseEnv) {
@@ -24043,7 +24079,7 @@ function resolveCommands(commands, ctx, via, baseEnv) {
24043
24079
  for (const c of commands) {
24044
24080
  const env = { ...persist };
24045
24081
  for (const a of c.assigns) {
24046
- checkAssign(ctx, a.name, a.value.text, a.value.dynamic);
24082
+ checkAssign(ctx, a.name, a.value.text, a.value.dynamic, literalProg(c.words));
24047
24083
  env[a.name] = a.value.text;
24048
24084
  }
24049
24085
  let stdinText = null;
@@ -24794,7 +24830,7 @@ function readLocalText(pkgDir, rel) {
24794
24830
  const r = relative5(root, p);
24795
24831
  return r !== "" && !r.startsWith("..") && !isAbsolute5(r) && !r.split(sep).includes("..");
24796
24832
  };
24797
- if (!within(pkgDir, abs) || !existsSync(abs)) return null;
24833
+ if (!within(pkgDir, abs) || !existsSync2(abs)) return null;
24798
24834
  const real = realpathSync2(abs);
24799
24835
  if (!within(realpathSync2(pkgDir), real)) return null;
24800
24836
  const st = statSync2(real);
@@ -25753,7 +25789,7 @@ async function* scanRepo(root, options) {
25753
25789
  init_zod();
25754
25790
 
25755
25791
  // ../core/src/version.ts
25756
- var SCANNER_VERSION = "0.3.3";
25792
+ var SCANNER_VERSION = "0.3.5";
25757
25793
 
25758
25794
  // ../core/src/reporters/json-reporter.ts
25759
25795
  var ScanStatsSchema = external_exports.object({
@@ -27119,7 +27155,7 @@ import { isAbsolute as isAbsolute7, join as join12, relative as relative6, resol
27119
27155
 
27120
27156
  // ../core/src/repo-config-guard.ts
27121
27157
  import { execFile } from "node:child_process";
27122
- import { existsSync as existsSync2, readFileSync as readFileSync5, realpathSync as realpathSync3, statSync as statSync4 } from "node:fs";
27158
+ import { existsSync as existsSync3, readFileSync as readFileSync5, realpathSync as realpathSync3, statSync as statSync4 } from "node:fs";
27123
27159
  import { tmpdir } from "node:os";
27124
27160
  import { dirname as dirname3, isAbsolute as isAbsolute6, join as join11, resolve as resolve7 } from "node:path";
27125
27161
  function stripComment(s) {
@@ -27207,7 +27243,7 @@ function locateRepo(start) {
27207
27243
  }
27208
27244
  for (; ; ) {
27209
27245
  const dotGit = join11(dir, ".git");
27210
- if (existsSync2(dotGit)) {
27246
+ if (existsSync3(dotGit)) {
27211
27247
  let gitDir = null;
27212
27248
  try {
27213
27249
  if (statSync4(dotGit).isDirectory()) gitDir = dotGit;
@@ -27218,14 +27254,14 @@ function locateRepo(start) {
27218
27254
  } catch {
27219
27255
  return null;
27220
27256
  }
27221
- if (!gitDir || !existsSync2(gitDir)) return null;
27257
+ if (!gitDir || !existsSync3(gitDir)) return null;
27222
27258
  let commonDir = gitDir;
27223
27259
  const commonFile = join11(gitDir, "commondir");
27224
- if (existsSync2(commonFile)) {
27260
+ if (existsSync3(commonFile)) {
27225
27261
  const c = readFileSync5(commonFile, "utf8").trim();
27226
27262
  commonDir = isAbsolute6(c) ? c : resolve7(gitDir, c);
27227
27263
  }
27228
- const configFiles = [join11(commonDir, "config"), join11(gitDir, "config.worktree")].filter((f, i, all) => all.indexOf(f) === i && existsSync2(f));
27264
+ const configFiles = [join11(commonDir, "config"), join11(gitDir, "config.worktree")].filter((f, i, all) => all.indexOf(f) === i && existsSync3(f));
27229
27265
  return { workTree: dir, gitDir, configFiles };
27230
27266
  }
27231
27267
  const up = dirname3(dir);
@@ -27652,7 +27688,7 @@ function buildTimeline(traced) {
27652
27688
  // ../core/src/hook-guard.ts
27653
27689
  init_secrets_check();
27654
27690
  init_canary();
27655
- import { existsSync as existsSync3, readFileSync as readFileSync6, statSync as statSync5 } from "node:fs";
27691
+ import { existsSync as existsSync4, readFileSync as readFileSync6, statSync as statSync5 } from "node:fs";
27656
27692
  import { homedir as homedir4 } from "node:os";
27657
27693
  import { dirname as dirname4, join as join13, resolve as resolve9 } from "node:path";
27658
27694
  function strings3(value, out = [], depth = 0) {
@@ -27683,7 +27719,7 @@ function readAliases(cwd, home) {
27683
27719
  const files = [join13(home, ".gitconfig"), join13(home, ".config", "git", "config")];
27684
27720
  let d = resolve9(cwd);
27685
27721
  for (let i = 0; i < 40; i++) {
27686
- if (existsSync3(join13(d, ".git"))) {
27722
+ if (existsSync4(join13(d, ".git"))) {
27687
27723
  files.push(join13(d, ".git", "config"));
27688
27724
  break;
27689
27725
  }
@@ -27792,14 +27828,14 @@ A trap token has been copied out of its trap. Find what copied it, remove the co
27792
27828
  }
27793
27829
 
27794
27830
  // ../core/src/on-access.ts
27795
- import { closeSync as closeSync2, existsSync as existsSync6, openSync as openSync2, readdirSync as readdirSync3, readFileSync as readFileSync8, readSync as readSync2, realpathSync as realpathSync5, statSync as statSync7 } from "node:fs";
27831
+ import { closeSync as closeSync2, existsSync as existsSync7, openSync as openSync2, readdirSync as readdirSync3, readFileSync as readFileSync8, readSync as readSync2, realpathSync as realpathSync5, statSync as statSync7 } from "node:fs";
27796
27832
  import { createHash as createHash3 } from "node:crypto";
27797
27833
  import { basename as basename5, isAbsolute as isAbsolute11, relative as relative8, resolve as resolve13 } from "node:path";
27798
27834
 
27799
27835
  // ../core/src/allowed-reads.ts
27800
27836
  init_zod();
27801
27837
  import { createHash as createHash2 } from "node:crypto";
27802
- import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync7, realpathSync as realpathSync4, renameSync, statSync as statSync6, writeFileSync } from "node:fs";
27838
+ import { existsSync as existsSync5, mkdirSync, readFileSync as readFileSync7, realpathSync as realpathSync4, renameSync, statSync as statSync6, writeFileSync } from "node:fs";
27803
27839
  import { homedir as homedir5 } from "node:os";
27804
27840
  import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute8, join as join14, parse, relative as relative7, resolve as resolve10 } from "node:path";
27805
27841
  var Hash = external_exports.string().regex(/^[0-9a-f]{64}$/);
@@ -27811,7 +27847,7 @@ function sha256Bytes(data) {
27811
27847
  }
27812
27848
  function sha256File(file) {
27813
27849
  try {
27814
- if (!existsSync4(file) || !statSync6(file).isFile()) return null;
27850
+ if (!existsSync5(file) || !statSync6(file).isFile()) return null;
27815
27851
  return sha256Bytes(readFileSync7(file));
27816
27852
  } catch {
27817
27853
  return null;
@@ -27833,7 +27869,7 @@ function findProjectRoot(cwd) {
27833
27869
  const start = realPath(cwd);
27834
27870
  const { root } = parse(start);
27835
27871
  for (let dir = start; ; dir = dirname5(dir)) {
27836
- if (PROJECT_MARKERS.some((m) => existsSync4(join14(dir, m)))) return dir;
27872
+ if (PROJECT_MARKERS.some((m) => existsSync5(join14(dir, m)))) return dir;
27837
27873
  if (dir === root || dirname5(dir) === dir) break;
27838
27874
  }
27839
27875
  return start;
@@ -27857,7 +27893,7 @@ function allowKey(realAbsPath, sha2564) {
27857
27893
  }
27858
27894
  function readAllowedReads(cwd, env = process.env) {
27859
27895
  const loc = allowedReadsLocation(cwd, env);
27860
- if (!loc.ok || !existsSync4(loc.file)) return /* @__PURE__ */ new Set();
27896
+ if (!loc.ok || !existsSync5(loc.file)) return /* @__PURE__ */ new Set();
27861
27897
  try {
27862
27898
  if (isInside2(loc.file, loc.project)) return /* @__PURE__ */ new Set();
27863
27899
  const result = AllowedReadsSchema.safeParse(JSON.parse(readFileSync7(loc.file, "utf8")));
@@ -27875,7 +27911,7 @@ function addAllowedRead(cwd, file, env = process.env, expected) {
27875
27911
  const loc = allowedReadsLocation(cwd, env);
27876
27912
  if (!loc.ok) return loc;
27877
27913
  let entries = [];
27878
- if (existsSync4(loc.file)) {
27914
+ if (existsSync5(loc.file)) {
27879
27915
  try {
27880
27916
  const parsed = AllowedReadsSchema.safeParse(JSON.parse(readFileSync7(loc.file, "utf8")));
27881
27917
  if (parsed.success && parsed.data.project === loc.project) entries = parsed.data.entries;
@@ -27892,7 +27928,7 @@ function addAllowedRead(cwd, file, env = process.env, expected) {
27892
27928
  }
27893
27929
 
27894
27930
  // ../core/src/fs-expand.ts
27895
- import { existsSync as existsSync5, lstatSync as lstatSync2, readdirSync as readdirSync2 } from "node:fs";
27931
+ import { existsSync as existsSync6, lstatSync as lstatSync2, readdirSync as readdirSync2 } from "node:fs";
27896
27932
  import { isAbsolute as isAbsolute9, resolve as resolve11 } from "node:path";
27897
27933
  var MAX_TARGETS = 100;
27898
27934
  var MAX_RECURSIVE_FILES = 500;
@@ -27971,7 +28007,7 @@ function expandGlob(word, dir) {
27971
28007
  level = next;
27972
28008
  }
27973
28009
  for (const p of level) {
27974
- if (!existsSync5(p)) continue;
28010
+ if (!existsSync6(p)) continue;
27975
28011
  out.push(p);
27976
28012
  if (out.length >= cap3) return out;
27977
28013
  }
@@ -28431,7 +28467,7 @@ function decideRead(event, defs, opts = {}) {
28431
28467
  let text;
28432
28468
  let bytes;
28433
28469
  try {
28434
- if (!existsSync6(abs)) continue;
28470
+ if (!existsSync7(abs)) continue;
28435
28471
  const stat4 = statSync7(abs);
28436
28472
  if (!stat4.isFile()) continue;
28437
28473
  if (stat4.size > MAX_SCAN_BYTES) {
@@ -29124,7 +29160,7 @@ function webFetchBlockMessage(d) {
29124
29160
  init_zod();
29125
29161
 
29126
29162
  // ../core/src/gitignore.ts
29127
- import { existsSync as existsSync7, readFileSync as readFileSync10, statSync as statSync9 } from "node:fs";
29163
+ import { existsSync as existsSync8, readFileSync as readFileSync10, statSync as statSync9 } from "node:fs";
29128
29164
  import { dirname as dirname7, join as join16, relative as relative9, resolve as resolve15, sep as sep3 } from "node:path";
29129
29165
  var MAX_IGNORE_BYTES = 256 * 1024;
29130
29166
  function globToRe(glob) {
@@ -29186,7 +29222,7 @@ function parseGitignore(text) {
29186
29222
  }
29187
29223
  function readIgnore(path) {
29188
29224
  try {
29189
- if (!existsSync7(path) || statSync9(path).size > MAX_IGNORE_BYTES) return [];
29225
+ if (!existsSync8(path) || statSync9(path).size > MAX_IGNORE_BYTES) return [];
29190
29226
  return parseGitignore(readFileSync10(path, "utf8"));
29191
29227
  } catch {
29192
29228
  return [];
@@ -29195,7 +29231,7 @@ function readIgnore(path) {
29195
29231
  function repoRootOf(from) {
29196
29232
  let d = resolve15(from);
29197
29233
  for (let i = 0; i < 40; i++) {
29198
- if (existsSync7(join16(d, ".git"))) return d;
29234
+ if (existsSync8(join16(d, ".git"))) return d;
29199
29235
  const up = dirname7(d);
29200
29236
  if (up === d) return null;
29201
29237
  d = up;
@@ -30349,7 +30385,7 @@ var SessionJsonSchema = external_exports.object({
30349
30385
  }).passthrough();
30350
30386
 
30351
30387
  // ../core/src/run-scripts-guard.ts
30352
- import { existsSync as existsSync8, readFileSync as readFileSync13, realpathSync as realpathSync7, statSync as statSync11 } from "node:fs";
30388
+ import { existsSync as existsSync9, readFileSync as readFileSync13, realpathSync as realpathSync7, statSync as statSync11 } from "node:fs";
30353
30389
  import { isAbsolute as isAbsolute14, join as join19, relative as relative11, resolve as resolve18, sep as sep4 } from "node:path";
30354
30390
  var MAX_PKG_BYTES = 1048576;
30355
30391
  var MAX_WORKSPACE_PACKAGES = 300;
@@ -30371,7 +30407,7 @@ var insideOf = (root, p) => {
30371
30407
  function readPackage(dir) {
30372
30408
  try {
30373
30409
  const p = join19(dir, "package.json");
30374
- if (!existsSync8(p) || statSync11(p).size > MAX_PKG_BYTES) return null;
30410
+ if (!existsSync9(p) || statSync11(p).size > MAX_PKG_BYTES) return null;
30375
30411
  return readFileSync13(p, "utf8");
30376
30412
  } catch {
30377
30413
  return null;
@@ -30432,7 +30468,7 @@ function expandGlob2(root, pattern) {
30432
30468
  } else if (/[*?]/.test(seg)) {
30433
30469
  const re2 = new RegExp(`^${seg.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]")}$`);
30434
30470
  for (const e of listLocal(base, ".") ?? []) if (e.endsWith("/") && re2.test(e.slice(0, -1)) && e !== "node_modules/") next.push(join19(base, e.slice(0, -1)));
30435
- } else if (existsSync8(join19(base, seg))) next.push(join19(base, seg));
30471
+ } else if (existsSync9(join19(base, seg))) next.push(join19(base, seg));
30436
30472
  }
30437
30473
  level = next;
30438
30474
  if (level.length > MAX_WORKSPACE_PACKAGES) break;
@@ -30445,13 +30481,13 @@ function workspacePackages(root) {
30445
30481
  const include = globs.filter((g) => !g.startsWith("!"));
30446
30482
  const exclude = globs.filter((g) => g.startsWith("!")).flatMap((g) => expandGlob2(root, g.slice(1)));
30447
30483
  const dirs = /* @__PURE__ */ new Set();
30448
- for (const g of include) for (const d of expandGlob2(root, g)) if (!exclude.includes(d) && existsSync8(join19(d, "package.json"))) dirs.add(d);
30484
+ for (const g of include) for (const d of expandGlob2(root, g)) if (!exclude.includes(d) && existsSync9(join19(d, "package.json"))) dirs.add(d);
30449
30485
  return [...dirs].slice(0, MAX_WORKSPACE_PACKAGES).map((dir) => ({ dir, name: packageInfo(dir).name }));
30450
30486
  }
30451
30487
  function nearestPackageDir(from) {
30452
30488
  let d = from;
30453
30489
  for (let i = 0; i < 10; i++) {
30454
- if (existsSync8(join19(d, "package.json"))) return d;
30490
+ if (existsSync9(join19(d, "package.json"))) return d;
30455
30491
  const up = resolve18(d, "..");
30456
30492
  if (up === d) break;
30457
30493
  d = up;
@@ -30462,7 +30498,7 @@ function findWorkspaceRoot(from) {
30462
30498
  let d = from;
30463
30499
  let best = null;
30464
30500
  for (let i = 0; i < 10; i++) {
30465
- if (existsSync8(join19(d, "pnpm-workspace.yaml")) || packageInfo(d).workspaces.length > 0) best = d;
30501
+ if (existsSync9(join19(d, "pnpm-workspace.yaml")) || packageInfo(d).workspaces.length > 0) best = d;
30466
30502
  const up = resolve18(d, "..");
30467
30503
  if (up === d) break;
30468
30504
  d = up;
@@ -30523,7 +30559,7 @@ function checkReadable(dir, rels, label) {
30523
30559
  const abs = resolve18(dir, rel);
30524
30560
  let isFile = false;
30525
30561
  try {
30526
- isFile = existsSync8(abs) && statSync11(abs).isFile();
30562
+ isFile = existsSync9(abs) && statSync11(abs).isFile();
30527
30563
  } catch {
30528
30564
  isFile = false;
30529
30565
  }
@@ -30543,7 +30579,7 @@ function findLocalBin(dir, bin) {
30543
30579
  let d = dir;
30544
30580
  for (let i = 0; i < 8; i++) {
30545
30581
  const link = join19(d, "node_modules", ".bin", bin);
30546
- if (existsSync8(link)) return link;
30582
+ if (existsSync9(link)) return link;
30547
30583
  const up = resolve18(d, "..");
30548
30584
  if (up === d) break;
30549
30585
  d = up;
@@ -30574,7 +30610,7 @@ function runExec(e, dirs, ctx) {
30574
30610
  for (const dir of dirs) {
30575
30611
  if (e.localPath !== null) {
30576
30612
  const abs = resolve18(dir, e.localPath);
30577
- if (existsSync8(abs)) {
30613
+ if (existsSync9(abs)) {
30578
30614
  checkReadable(dir, [e.localPath], e.localPath);
30579
30615
  const v = evaluateTargets(targetsOfExec(e), fsFor(dir), true);
30580
30616
  if (v) blockHit(e.rawProg, e.rawProg, v, dir);
@@ -30621,7 +30657,7 @@ function runAction(a, e, dir, dirs, ctx) {
30621
30657
  });
30622
30658
  const hit = hits[0];
30623
30659
  if (hit) throw new Stop({ block: true, hit, dir: pkgDir });
30624
- if (a.serverJs && existsSync8(join19(pkgDir, "server.js"))) {
30660
+ if (a.serverJs && existsSync9(join19(pkgDir, "server.js"))) {
30625
30661
  const v = evaluateTargets({ files: ["server.js"], inline: [], scripts: [], runners: [], dotenv: false, unclear: [] }, fsFor(pkgDir), true);
30626
30662
  if (v) blockHit("npm start (server.js)", "node server.js", v, pkgDir);
30627
30663
  }
@@ -31146,7 +31182,7 @@ function decideShellRead(event, defs, opts = {}, fallbackCwd = process.cwd()) {
31146
31182
  }
31147
31183
 
31148
31184
  // src/commands/approve.ts
31149
- import { existsSync as existsSync18, readFileSync as readFileSync27 } from "node:fs";
31185
+ import { existsSync as existsSync19, readFileSync as readFileSync27 } from "node:fs";
31150
31186
 
31151
31187
  // ../shield/src/hash.ts
31152
31188
  import { createHash as createHash7 } from "node:crypto";
@@ -31252,7 +31288,7 @@ var LineSplitter = class {
31252
31288
 
31253
31289
  // ../shield/src/policy.ts
31254
31290
  init_zod();
31255
- import { existsSync as existsSync9, lstatSync as lstatSync6, readFileSync as readFileSync15, writeFileSync as writeFileSync3 } from "node:fs";
31291
+ import { existsSync as existsSync10, lstatSync as lstatSync6, readFileSync as readFileSync15, writeFileSync as writeFileSync3 } from "node:fs";
31256
31292
  import { join as join21 } from "node:path";
31257
31293
 
31258
31294
  // ../shield/src/userkey.ts
@@ -31513,7 +31549,7 @@ function loadPolicy(path) {
31513
31549
  const user = loadUserPolicy(notes);
31514
31550
  if (!user.ok) return user;
31515
31551
  let merged = { ...user.raw };
31516
- if (existsSync9(path)) {
31552
+ if (existsSync10(path)) {
31517
31553
  let text;
31518
31554
  try {
31519
31555
  text = readFileSync15(path, "utf8");
@@ -32504,7 +32540,7 @@ function defaultOsAuth(o = {}) {
32504
32540
 
32505
32541
  // ../shield/src/state.ts
32506
32542
  init_zod();
32507
- import { appendFileSync, existsSync as existsSync10, mkdirSync as mkdirSync5, readFileSync as readFileSync19, renameSync as renameSync6, writeFileSync as writeFileSync5 } from "node:fs";
32543
+ import { appendFileSync, existsSync as existsSync11, mkdirSync as mkdirSync5, readFileSync as readFileSync19, renameSync as renameSync6, writeFileSync as writeFileSync5 } from "node:fs";
32508
32544
  import { dirname as dirname9, join as join26 } from "node:path";
32509
32545
  var Sha256 = external_exports.string().regex(/^[0-9a-f]{64}$/);
32510
32546
  var PinSchema = external_exports.object({
@@ -32563,7 +32599,7 @@ function pinsText(raw) {
32563
32599
  return canonicalJson({ version: raw.version, servers: raw.servers });
32564
32600
  }
32565
32601
  function loadState(path) {
32566
- if (!existsSync10(path)) return { ok: true, state: emptyState() };
32602
+ if (!existsSync11(path)) return { ok: true, state: emptyState() };
32567
32603
  let json2;
32568
32604
  try {
32569
32605
  json2 = JSON.parse(readFileSync19(path, "utf8"));
@@ -33248,7 +33284,7 @@ function throttle(o = {}) {
33248
33284
  }
33249
33285
 
33250
33286
  // ../shield/src/canary.ts
33251
- import { existsSync as existsSync11, lstatSync as lstatSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync20, readdirSync as readdirSync9, realpathSync as realpathSync8, rmdirSync, rmSync as rmSync3, writeFileSync as writeFileSync6 } from "node:fs";
33287
+ import { existsSync as existsSync12, lstatSync as lstatSync10, mkdirSync as mkdirSync6, readFileSync as readFileSync20, readdirSync as readdirSync9, realpathSync as realpathSync8, rmdirSync, rmSync as rmSync3, writeFileSync as writeFileSync6 } from "node:fs";
33252
33288
  import { dirname as dirname10, isAbsolute as isAbsolute17, join as join27, resolve as resolve21 } from "node:path";
33253
33289
  var TRAPS = [
33254
33290
  {
@@ -33293,18 +33329,18 @@ function plantCanaries(root, o = {}) {
33293
33329
  }
33294
33330
  for (const d of [".exorcist", CANARY_TRAP_DIR]) {
33295
33331
  const path = join27(root, d);
33296
- if (existsSync11(path) || isSymlink(path)) {
33332
+ if (existsSync12(path) || isSymlink(path)) {
33297
33333
  if (!isRealDir(path)) return { ok: false, error: `${path} is not a real folder (a symlink or a file); no traps were planted.` };
33298
33334
  }
33299
33335
  }
33300
33336
  const traps = TRAPS.slice(0, count);
33301
33337
  for (const t2 of traps) {
33302
33338
  const path = join27(root, CANARY_TRAP_DIR, t2.name);
33303
- if (existsSync11(path)) return { ok: false, error: `${path} already exists; it was not overwritten.` };
33339
+ if (existsSync12(path)) return { ok: false, error: `${path} already exists; it was not overwritten.` };
33304
33340
  }
33305
33341
  const created = (o.now ? o.now() : /* @__PURE__ */ new Date()).toISOString();
33306
33342
  const records = [];
33307
- const madeDirs = [".exorcist", CANARY_TRAP_DIR].filter((d) => !existsSync11(join27(root, d)));
33343
+ const madeDirs = [".exorcist", CANARY_TRAP_DIR].filter((d) => !existsSync12(join27(root, d)));
33308
33344
  try {
33309
33345
  mkdirSync6(join27(root, CANARY_TRAP_DIR), { recursive: true });
33310
33346
  for (const t2 of traps) {
@@ -33431,7 +33467,7 @@ function removeCanaries(root, o = {}) {
33431
33467
  }
33432
33468
  function readPolicyObject(stateDir2) {
33433
33469
  const path = policyPath(stateDir2);
33434
- if (!existsSync11(path)) return { ok: true, obj: {} };
33470
+ if (!existsSync12(path)) return { ok: true, obj: {} };
33435
33471
  try {
33436
33472
  const json2 = JSON.parse(readFileSync20(path, "utf8"));
33437
33473
  if (!json2 || typeof json2 !== "object" || Array.isArray(json2)) return { ok: false, error: `${path} is not a JSON object.` };
@@ -33446,7 +33482,7 @@ function setPolicyCanaries(stateDir2, recordsFile) {
33446
33482
  try {
33447
33483
  mkdirSync6(stateDir2, { recursive: true });
33448
33484
  const file = policyPath(stateDir2);
33449
- const sign = !existsSync11(file) || policyIsSigned(file);
33485
+ const sign = !existsSync12(file) || policyIsSigned(file);
33450
33486
  writeFileSync6(file, `${JSON.stringify({ ...p.obj, canaries: resolve21(recordsFile) }, null, 2)}
33451
33487
  `);
33452
33488
  if (sign) signPolicyFile(file);
@@ -34744,11 +34780,11 @@ var ShieldEngine = class {
34744
34780
 
34745
34781
  // ../shield/src/proxy.ts
34746
34782
  import { spawn as spawn3 } from "node:child_process";
34747
- import { existsSync as existsSync15, mkdirSync as mkdirSync9, readFileSync as readFileSync26, statSync as statSync15 } from "node:fs";
34783
+ import { existsSync as existsSync16, mkdirSync as mkdirSync9, readFileSync as readFileSync26, statSync as statSync15 } from "node:fs";
34748
34784
  import { dirname as dirname14 } from "node:path";
34749
34785
 
34750
34786
  // ../shield/src/lockfile.ts
34751
- import { existsSync as existsSync12 } from "node:fs";
34787
+ import { existsSync as existsSync13 } from "node:fs";
34752
34788
  import { dirname as dirname11, join as join28, parse as parsePath, resolve as resolve22 } from "node:path";
34753
34789
  init_zod();
34754
34790
  var Sha2562 = external_exports.string().regex(/^[0-9a-f]{64}$/);
@@ -34925,8 +34961,8 @@ function findLockFile(starts) {
34925
34961
  const { root } = parsePath(resolve22(start));
34926
34962
  for (let dir = resolve22(start); ; dir = dirname11(dir)) {
34927
34963
  const candidate = join28(dir, LOCK_FILE);
34928
- if (existsSync12(candidate)) return candidate;
34929
- if (PROJECT_MARKERS2.some((m) => existsSync12(join28(dir, m)))) break;
34964
+ if (existsSync13(candidate)) return candidate;
34965
+ if (PROJECT_MARKERS2.some((m) => existsSync13(join28(dir, m)))) break;
34930
34966
  if (dir === root || dirname11(dir) === dir) break;
34931
34967
  }
34932
34968
  }
@@ -34935,7 +34971,7 @@ function findLockFile(starts) {
34935
34971
 
34936
34972
  // ../shield/src/vault.ts
34937
34973
  import { createHash as createHash11, randomBytes as randomBytes7 } from "node:crypto";
34938
- import { closeSync as closeSync7, constants as constants6, copyFileSync, existsSync as existsSync13, fstatSync as fstatSync3, lstatSync as lstatSync11, mkdirSync as mkdirSync7, openSync as openSync7, readFileSync as readFileSync21, readdirSync as readdirSync10, realpathSync as realpathSync9, rmSync as rmSync4, statSync as statSync13, writeFileSync as writeFileSync7, writeSync as writeSync4 } from "node:fs";
34974
+ import { closeSync as closeSync7, constants as constants6, copyFileSync, existsSync as existsSync14, fstatSync as fstatSync3, lstatSync as lstatSync11, mkdirSync as mkdirSync7, openSync as openSync7, readFileSync as readFileSync21, readdirSync as readdirSync10, realpathSync as realpathSync9, rmSync as rmSync4, statSync as statSync13, writeFileSync as writeFileSync7, writeSync as writeSync4 } from "node:fs";
34939
34975
  import { basename as basename8, dirname as dirname12, isAbsolute as isAbsolute18, join as join29, resolve as resolve23, sep as sep6 } from "node:path";
34940
34976
  init_zod();
34941
34977
  var SafeRel = external_exports.string().min(1).max(1024).refine(
@@ -35021,7 +35057,7 @@ function targetProblem(e) {
35021
35057
  const dir = e.kind === "exorcise" ? e.target : dirname12(e.target);
35022
35058
  let real;
35023
35059
  try {
35024
- real = realpathSync9(existsSync13(dir) ? dir : dirname12(dir));
35060
+ real = realpathSync9(existsSync14(dir) ? dir : dirname12(dir));
35025
35061
  } catch {
35026
35062
  return `${e.target} cannot be resolved.`;
35027
35063
  }
@@ -35053,12 +35089,12 @@ function writeManifest(vaultDir, e) {
35053
35089
  `);
35054
35090
  }
35055
35091
  function listEntries(vaultDir) {
35056
- if (!existsSync13(vaultDir)) return [];
35092
+ if (!existsSync14(vaultDir)) return [];
35057
35093
  const key = getUserKey();
35058
35094
  const out = [];
35059
35095
  for (const name of readdirSync10(vaultDir)) {
35060
35096
  const file = join29(vaultDir, name, "manifest.json");
35061
- if (!existsSync13(file)) continue;
35097
+ if (!existsSync14(file)) continue;
35062
35098
  try {
35063
35099
  const st = lstatSync11(file);
35064
35100
  if (!st.isFile()) continue;
@@ -35133,7 +35169,7 @@ function quarantineServer(o) {
35133
35169
  }
35134
35170
  function quarantineFile(o) {
35135
35171
  const target = resolve23(o.filePath);
35136
- if (!existsSync13(target) || !statSync13(target).isFile()) return fail3(`${target} is not a file.`);
35172
+ if (!existsSync14(target) || !statSync13(target).isFile()) return fail3(`${target} is not a file.`);
35137
35173
  if (activeFor(o.vaultDir, target)) return fail3(`${target} is already in the vault.`);
35138
35174
  const safe2 = ensureSafeVault(o.vaultDir);
35139
35175
  if (safe2 !== null) return fail3(safe2);
@@ -35161,7 +35197,7 @@ function backupAndRewrite(o) {
35161
35197
  for (const f of o.files) {
35162
35198
  if (!SafeRel.safeParse(f.rel).success) return fail3(`Refusing to write outside ${root}: ${f.rel}`);
35163
35199
  const path = join29(root, f.rel);
35164
- if (!existsSync13(path)) return fail3(`${f.rel} is gone; nothing was changed.`);
35200
+ if (!existsSync14(path)) return fail3(`${f.rel} is gone; nothing was changed.`);
35165
35201
  if (sha2562(readFileSync21(path)) !== sha2562(Buffer.from(f.before, "utf8"))) {
35166
35202
  return fail3(`${f.rel} changed since it was scanned; nothing was changed. Run exorcise again.`);
35167
35203
  }
@@ -35205,7 +35241,7 @@ function restoreExorcised(vaultDir, e, force) {
35205
35241
  const files = e.files ?? [];
35206
35242
  const blocked2 = files.filter((f) => {
35207
35243
  const path = join29(e.target, f.rel);
35208
- if (!existsSync13(path)) return false;
35244
+ if (!existsSync14(path)) return false;
35209
35245
  const now = sha2562(readFileSync21(path));
35210
35246
  return now !== f.after && now !== f.sha256;
35211
35247
  });
@@ -35233,7 +35269,7 @@ function diffEntry(vaultDir, id) {
35233
35269
  const parts2 = (e.files ?? []).map((f) => {
35234
35270
  const path = join29(e.target, f.rel);
35235
35271
  const before2 = readFileSync21(join29(entryDir(vaultDir, e.id), "files", f.rel), "utf8");
35236
- const after2 = existsSync13(path) ? readFileSync21(path, "utf8") : "";
35272
+ const after2 = existsSync14(path) ? readFileSync21(path, "utf8") : "";
35237
35273
  return createTwoFilesPatch(`${f.rel} (backup)`, `${f.rel} (now)`, before2, after2, "", "", { context: 3 });
35238
35274
  });
35239
35275
  return { ok: true, value: parts2.join("") };
@@ -35245,7 +35281,7 @@ function diffEntry(vaultDir, id) {
35245
35281
  const now = cfg.ok ? cfg.value.mcpServers?.[e.serverName ?? ""] : void 0;
35246
35282
  after = now ? `${JSON.stringify(now, null, 2)}
35247
35283
  ` : "";
35248
- } else if (existsSync13(e.target)) {
35284
+ } else if (existsSync14(e.target)) {
35249
35285
  after = readFileSync21(e.target, "utf8");
35250
35286
  }
35251
35287
  const label = e.kind === "mcp-server" ? `${e.serverName} in ${basename8(e.target)}` : basename8(e.target);
@@ -35282,7 +35318,7 @@ function restoreEntry(vaultDir, id, opts = {}) {
35282
35318
  writeConfig(e.target, cfg.value);
35283
35319
  } else {
35284
35320
  const stored = backupFile(vaultDir, e);
35285
- if (existsSync13(e.target) && sha2562(readFileSync21(e.target)) !== e.sha256 && !opts.force) {
35321
+ if (existsSync14(e.target) && sha2562(readFileSync21(e.target)) !== e.sha256 && !opts.force) {
35286
35322
  return fail3(`${e.target} exists and is different from the quarantined file. Use --force to overwrite it.`);
35287
35323
  }
35288
35324
  mkdirSync7(resolve23(e.target, ".."), { recursive: true });
@@ -36204,7 +36240,7 @@ var EventTail = class {
36204
36240
 
36205
36241
  // ../shield/src/launch.ts
36206
36242
  import { createHash as createHash13 } from "node:crypto";
36207
- import { existsSync as existsSync14, readFileSync as readFileSync25, statSync as statSync14 } from "node:fs";
36243
+ import { existsSync as existsSync15, readFileSync as readFileSync25, statSync as statSync14 } from "node:fs";
36208
36244
  import { dirname as dirname13, isAbsolute as isAbsolute19, join as join32, parse as parsePath2, relative as relative13, resolve as resolve24, sep as sep7 } from "node:path";
36209
36245
  var sha2563 = (b) => createHash13("sha256").update(b).digest("hex");
36210
36246
  var MAX_HASHED_BYTES = 64 * 1024 * 1024;
@@ -36282,7 +36318,7 @@ function configLabel(configPath) {
36282
36318
  const abs = resolve24(configPath);
36283
36319
  const { root } = parsePath2(abs);
36284
36320
  for (let dir = dirname13(abs); ; dir = dirname13(dir)) {
36285
- if (PROJECT_MARKERS3.some((m) => existsSync14(join32(dir, m)))) return relative13(dir, abs).split(sep7).join("/");
36321
+ if (PROJECT_MARKERS3.some((m) => existsSync15(join32(dir, m)))) return relative13(dir, abs).split(sep7).join("/");
36286
36322
  if (dir === root || dirname13(dir) === dir) return abs;
36287
36323
  }
36288
36324
  }
@@ -36463,13 +36499,13 @@ async function prepareShield(o) {
36463
36499
  log(canariesFile.error);
36464
36500
  return FAIL_CLOSED_EXIT;
36465
36501
  }
36466
- if (policy.policy.canaries && !existsSync15(canariesAt)) log(`The policy names canary records at ${canariesAt}, but there is no such file; no canary traps are active.`);
36502
+ if (policy.policy.canaries && !existsSync16(canariesAt)) log(`The policy names canary records at ${canariesAt}, but there is no such file; no canary traps are active.`);
36467
36503
  const canaries = canariesFile.canaries.map((r) => ({ token: r.token, file: r.file }));
36468
36504
  if (canaries.length > 0) log(`Watching for ${canaries.length} canary token${canaries.length === 1 ? "" : "s"} (EX-022).`);
36469
36505
  let lockExpected;
36470
36506
  let lockLaunch;
36471
36507
  const lockFile = o.lockPath === void 0 ? findLockFile([...o.configPath ? [dirname14(o.configPath)] : [], process.cwd()]) : o.lockPath;
36472
- if (lockFile && existsSync15(lockFile)) {
36508
+ if (lockFile && existsSync16(lockFile)) {
36473
36509
  let text;
36474
36510
  try {
36475
36511
  text = readFileSync26(lockFile, "utf8");
@@ -37043,7 +37079,7 @@ async function runRemoteProxy(o) {
37043
37079
  }
37044
37080
 
37045
37081
  // ../shield/src/locate.ts
37046
- import { existsSync as existsSync16, readdirSync as readdirSync11, statSync as statSync16 } from "node:fs";
37082
+ import { existsSync as existsSync17, readdirSync as readdirSync11, statSync as statSync16 } from "node:fs";
37047
37083
  import { dirname as dirname15, isAbsolute as isAbsolute20, join as join33, parse as parse2, resolve as resolve25 } from "node:path";
37048
37084
  import { fileURLToPath } from "node:url";
37049
37085
  function hasDefinitions(dir) {
@@ -37074,7 +37110,7 @@ function findStateDir(o = {}) {
37074
37110
  if (fromEnv) return isAbsolute20(fromEnv) ? fromEnv : resolve25(cwd, fromEnv);
37075
37111
  const { root } = parse2(cwd);
37076
37112
  for (let dir = cwd; ; dir = dirname15(dir)) {
37077
- if (PROJECT_MARKERS4.some((m) => existsSync16(join33(dir, m)))) return join33(dir, ".exorcist");
37113
+ if (PROJECT_MARKERS4.some((m) => existsSync17(join33(dir, m)))) return join33(dir, ".exorcist");
37078
37114
  if (dir === root || dirname15(dir) === dir) break;
37079
37115
  }
37080
37116
  return join33(cwd, ".exorcist");
@@ -37260,7 +37296,7 @@ var DEFAULT_DIR = "the project's .exorcist folder (or EXORCIST_DIR)";
37260
37296
  // src/commands/on-access.ts
37261
37297
  import { randomBytes as randomBytes10 } from "node:crypto";
37262
37298
  import { execFile as execFile3 } from "node:child_process";
37263
- import { existsSync as existsSync17, statSync as statSync17 } from "node:fs";
37299
+ import { existsSync as existsSync18, statSync as statSync17 } from "node:fs";
37264
37300
  import { resolve as resolve26 } from "node:path";
37265
37301
  import { createInterface } from "node:readline";
37266
37302
  var ALLOW_READ_HELP = `Usage: exorcist allow-read <file>
@@ -37454,7 +37490,7 @@ ${ALLOW_READ_HELP}`);
37454
37490
  return 1;
37455
37491
  }
37456
37492
  const file = resolve26(target);
37457
- if (!existsSync17(file) || !statSync17(file).isFile()) {
37493
+ if (!existsSync18(file) || !statSync17(file).isFile()) {
37458
37494
  io.err(`Not a readable file: ${shownName(target)}`);
37459
37495
  return 1;
37460
37496
  }
@@ -37561,7 +37597,7 @@ ${APPROVE_HELP}`);
37561
37597
  return 1;
37562
37598
  }
37563
37599
  const file = policyPath(stateDir(str4(p.values["dir"])));
37564
- if (!existsSync18(file)) {
37600
+ if (!existsSync19(file)) {
37565
37601
  io.err(`There is no policy file at ${file}.`);
37566
37602
  return 1;
37567
37603
  }
@@ -37622,7 +37658,7 @@ async function alertsCommand(argv, io) {
37622
37658
  if (!h.ok) io.out(`Event log head: unreadable (${h.error.replace(/[^\x20-\x7e]/g, "?")}).`);
37623
37659
  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})`);
37624
37660
  };
37625
- if (!existsSync18(file)) {
37661
+ if (!existsSync19(file)) {
37626
37662
  io.out("No alerts.");
37627
37663
  printHead();
37628
37664
  return 0;
@@ -37645,12 +37681,12 @@ import { statSync as statSync20, writeFileSync as writeFileSync9 } from "node:fs
37645
37681
  import { join as join36, resolve as resolve29 } from "node:path";
37646
37682
 
37647
37683
  // src/commands/scan.ts
37648
- import { existsSync as existsSync20, readFileSync as readFileSync29, realpathSync as realpathSync10, statSync as statSync19, writeFileSync as writeFileSync8 } from "node:fs";
37684
+ import { existsSync as existsSync21, readFileSync as readFileSync29, realpathSync as realpathSync10, statSync as statSync19, writeFileSync as writeFileSync8 } from "node:fs";
37649
37685
  import { basename as basename10, dirname as dirname16, isAbsolute as isAbsolute21, join as join35, relative as relative14, resolve as resolve28 } from "node:path";
37650
37686
  init_bedrock();
37651
37687
 
37652
37688
  // src/commands/detonate.ts
37653
- import { existsSync as existsSync19, readFileSync as readFileSync28, statSync as statSync18 } from "node:fs";
37689
+ import { existsSync as existsSync20, readFileSync as readFileSync28, statSync as statSync18 } from "node:fs";
37654
37690
  import { basename as basename9, join as join34, resolve as resolve27 } from "node:path";
37655
37691
  init_bedrock();
37656
37692
  var DEFAULT_DETONATE_MAX = 10;
@@ -37794,7 +37830,7 @@ ${DETONATE_HELP}`);
37794
37830
  return 2;
37795
37831
  }
37796
37832
  const abs = resolve27(target);
37797
- if (!existsSync19(abs) || !statSync18(abs).isFile()) {
37833
+ if (!existsSync20(abs) || !statSync18(abs).isFile()) {
37798
37834
  io.err(`File not found: ${target}`);
37799
37835
  return 2;
37800
37836
  }
@@ -37878,7 +37914,7 @@ function readIgnoreFile(root) {
37878
37914
  return readIgnoreEntries(join35(root, ".exorcistignore"));
37879
37915
  }
37880
37916
  function readIgnoreEntries(file) {
37881
- if (!existsSync20(file)) return [];
37917
+ if (!existsSync21(file)) return [];
37882
37918
  return readFileSync29(file, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
37883
37919
  }
37884
37920
  function isIgnored(rel, prefixes) {
@@ -37984,7 +38020,7 @@ async function makeAiClient(rawMax, io, real) {
37984
38020
  }
37985
38021
  async function runScan(opts, io) {
37986
38022
  const abs = resolve28(opts.target);
37987
- if (!existsSync20(abs)) {
38023
+ if (!existsSync21(abs)) {
37988
38024
  io.err(`Path not found: ${opts.target}`);
37989
38025
  return { ok: false, code: 2 };
37990
38026
  }
@@ -38141,7 +38177,7 @@ ${SCAN_HELP}`);
38141
38177
  const ignoreFilePath = str4(p.values["ignore-file"]);
38142
38178
  let userIgnore = [];
38143
38179
  if (ignoreFilePath !== void 0) {
38144
- if (!existsSync20(resolve28(ignoreFilePath))) {
38180
+ if (!existsSync21(resolve28(ignoreFilePath))) {
38145
38181
  io.err(`Could not read the ignore file ${ignoreFilePath}. Check the path.`);
38146
38182
  return 2;
38147
38183
  }
@@ -38392,7 +38428,7 @@ function remove(io, dir, state) {
38392
38428
 
38393
38429
  // src/commands/config.ts
38394
38430
  import { createHash as createHash14 } from "node:crypto";
38395
- import { existsSync as existsSync21, mkdirSync as mkdirSync10, readFileSync as readFileSync30, rmSync as rmSync5, writeFileSync as writeFileSync10 } from "node:fs";
38431
+ import { existsSync as existsSync22, mkdirSync as mkdirSync10, readFileSync as readFileSync30, rmSync as rmSync5, writeFileSync as writeFileSync10 } from "node:fs";
38396
38432
  import { join as join37, resolve as resolve31 } from "node:path";
38397
38433
  var WRAP_HELP = `Usage: exorcist wrap <mcp.json> [options]
38398
38434
  exorcist unwrap <mcp.json>
@@ -38404,7 +38440,7 @@ unwrap Put the original file back byte for byte, if it was not edited since
38404
38440
 
38405
38441
  Options (wrap):
38406
38442
  --bin <command> Command that runs the shield (default: exorcist)
38407
- --bin-arg <arg> Argument before "shield" (repeatable), e.g. --bin npx --bin-arg -y --bin-arg @exorcist-98/cli@0.3.3
38443
+ --bin-arg <arg> Argument before "shield" (repeatable), e.g. --bin npx --bin-arg -y --bin-arg @exorcist-98/cli@0.3.5
38408
38444
  --dir <folder> State folder (default: ${DEFAULT_DIR})
38409
38445
  --dry-run Show the result without writing the file
38410
38446
  `;
@@ -38431,7 +38467,7 @@ function dirsInConfig(cfg) {
38431
38467
  return out;
38432
38468
  }
38433
38469
  function readConfig2(path, io) {
38434
- if (!existsSync21(path)) {
38470
+ if (!existsSync22(path)) {
38435
38471
  io.err(`File not found: ${path}`);
38436
38472
  return null;
38437
38473
  }
@@ -39724,7 +39760,7 @@ ${CONSOLE_HELP}`);
39724
39760
  }
39725
39761
 
39726
39762
  // src/commands/exorcise.ts
39727
- import { existsSync as existsSync22, readFileSync as readFileSync31, statSync as statSync21 } from "node:fs";
39763
+ import { existsSync as existsSync23, readFileSync as readFileSync31, statSync as statSync21 } from "node:fs";
39728
39764
  import { basename as basename11, dirname as dirname17, isAbsolute as isAbsolute22, relative as relative15, resolve as resolve32 } from "node:path";
39729
39765
  var EXORCISE_HELP = `Usage: exorcist exorcise [path] [options]
39730
39766
 
@@ -39810,7 +39846,7 @@ ${EXORCISE_HELP}`);
39810
39846
  }
39811
39847
  const target = p.positionals[0] ?? ".";
39812
39848
  const abs = resolve32(target);
39813
- if (!existsSync22(abs)) {
39849
+ if (!existsSync23(abs)) {
39814
39850
  io.err(`Path not found: ${target}`);
39815
39851
  return 2;
39816
39852
  }
@@ -39902,7 +39938,7 @@ ${EXORCISE_HELP}`);
39902
39938
  }
39903
39939
 
39904
39940
  // src/commands/gate.ts
39905
- import { existsSync as existsSync23 } from "node:fs";
39941
+ import { existsSync as existsSync24 } from "node:fs";
39906
39942
  import { lstat as lstat2, readFile as readFile6 } from "node:fs/promises";
39907
39943
  import { resolve as resolve33 } from "node:path";
39908
39944
  var GATE_HELP = `Usage: exorcist gate [dir] [--fail-on <critical|high|medium|low>] [--dir <state folder>]
@@ -39989,7 +40025,7 @@ ${GATE_HELP}`);
39989
40025
  return 2;
39990
40026
  }
39991
40027
  const start = resolve33(p.positionals[0] ?? ".");
39992
- if (!existsSync23(start)) return nothingChecked(io, "that folder does not exist");
40028
+ if (!existsSync24(start)) return nothingChecked(io, "that folder does not exist");
39993
40029
  const top = await gitRepoRoot(start);
39994
40030
  if (!top) return nothingChecked(io, "this folder is not a git repository, or git is not available");
39995
40031
  const repo = { root: top };
@@ -40332,7 +40368,7 @@ async function guardShellReadCommand(stdin, io) {
40332
40368
  }
40333
40369
 
40334
40370
  // src/commands/hook-scan.ts
40335
- import { existsSync as existsSync24, statSync as statSync22 } from "node:fs";
40371
+ import { existsSync as existsSync25, statSync as statSync22 } from "node:fs";
40336
40372
  import { resolve as resolve34 } from "node:path";
40337
40373
  async function hookScanCommand(stdin, io) {
40338
40374
  let event;
@@ -40344,12 +40380,12 @@ async function hookScanCommand(stdin, io) {
40344
40380
  if (typeof event.file_path !== "string" || event.file_path === "") return 0;
40345
40381
  const base = typeof event.cwd === "string" && event.cwd ? event.cwd : process.cwd();
40346
40382
  const file = resolve34(base, event.file_path);
40347
- if (!existsSync24(file) || !statSync22(file).isFile()) return 0;
40383
+ if (!existsSync25(file) || !statSync22(file).isFile()) return 0;
40348
40384
  return await scanCommand([file, "--fail-on", "high"], { out: io.err, err: io.err });
40349
40385
  }
40350
40386
 
40351
40387
  // src/commands/init.ts
40352
- import { chmodSync, existsSync as existsSync25, lstatSync as lstatSync15, mkdirSync as mkdirSync11, readFileSync as readFileSync33, writeFileSync as writeFileSync12 } from "node:fs";
40388
+ import { chmodSync, existsSync as existsSync26, lstatSync as lstatSync15, mkdirSync as mkdirSync11, readFileSync as readFileSync33, writeFileSync as writeFileSync12 } from "node:fs";
40353
40389
  import { dirname as dirname18, join as join39, resolve as resolve35 } from "node:path";
40354
40390
 
40355
40391
  // src/kiro-hook-script.ts
@@ -40478,8 +40514,8 @@ function reviewerAgentForProject(mcpCommand) {
40478
40514
  }
40479
40515
 
40480
40516
  // src/commands/init.ts
40481
- var DEFAULT_BIN = "npx -y @exorcist-98/cli@0.3.3";
40482
- var DEFAULT_MCP_BIN = "npx -y @exorcist-98/mcp-server@0.3.3";
40517
+ var DEFAULT_BIN = "npx -y @exorcist-98/cli@0.3.5";
40518
+ var DEFAULT_MCP_BIN = "npx -y @exorcist-98/mcp-server@0.3.5";
40483
40519
  var MISSING_FROM_DEFAULT_BIN = /* @__PURE__ */ new Set();
40484
40520
  var INIT_HELP = `Usage: exorcist init [folder] [--kiro] [--shield] [--sandbox] [--no-agent] [--force]
40485
40521
  [--bin <command>] [--mcp-bin <command>]
@@ -40592,7 +40628,7 @@ function splitCommand(s) {
40592
40628
  }
40593
40629
  var MAX_NAME = 60;
40594
40630
  function describeMcpConfig(path) {
40595
- if (!existsSync25(path)) return { exists: false, warnings: [], line: "no .kiro/settings/mcp.json yet (the mcp-scan hook scans it once you add one)" };
40631
+ if (!existsSync26(path)) return { exists: false, warnings: [], line: "no .kiro/settings/mcp.json yet (the mcp-scan hook scans it once you add one)" };
40596
40632
  try {
40597
40633
  const cfg = JSON.parse(readFileSync33(path, "utf8"));
40598
40634
  const entries = Object.entries(cfg.mcpServers ?? {});
@@ -40777,7 +40813,7 @@ ${INIT_HELP}`);
40777
40813
  const done = [];
40778
40814
  for (const f of files) {
40779
40815
  const path = join39(root, f.rel);
40780
- if (existsSync25(path) && !force) {
40816
+ if (existsSync26(path) && !force) {
40781
40817
  io.err(`Kept existing ${f.rel} (use --force to replace it).`);
40782
40818
  done.push({ f, wrote: false });
40783
40819
  continue;
@@ -40848,7 +40884,7 @@ ${INIT_HELP}`);
40848
40884
  "then reconnect MCP servers in the MCP panel so they start through the Shield."
40849
40885
  ];
40850
40886
  if (isDefaultBin) {
40851
- lines.push("Commands run through npx (@exorcist-98/cli@0.3.3). If Kiro cannot start a wrapped server or a hook cannot find npx,");
40887
+ lines.push("Commands run through npx (@exorcist-98/cli@0.3.5). If Kiro cannot start a wrapped server or a hook cannot find npx,");
40852
40888
  lines.push('rerun with --bin "<absolute path to node> <absolute path to the exorcist CLI>" and --force.');
40853
40889
  }
40854
40890
  io.out(lines.join("\n"));
@@ -40857,7 +40893,7 @@ ${INIT_HELP}`);
40857
40893
  }
40858
40894
 
40859
40895
  // src/commands/lock.ts
40860
- import { existsSync as existsSync26, readFileSync as readFileSync34, writeFileSync as writeFileSync13 } from "node:fs";
40896
+ import { existsSync as existsSync27, readFileSync as readFileSync34, writeFileSync as writeFileSync13 } from "node:fs";
40861
40897
  import { isAbsolute as isAbsolute27, join as join40, resolve as resolve36 } from "node:path";
40862
40898
 
40863
40899
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/core/core.js
@@ -48231,7 +48267,7 @@ var RawToolsPage = external_exports.object({ tools: external_exports.array(exter
48231
48267
  var firstLine2 = (err) => (err instanceof Error ? err.message : String(err)).split("\n")[0]?.slice(0, 300) ?? "unknown error";
48232
48268
  async function listTools(o) {
48233
48269
  const transport = new StdioClientTransport({ command: o.command, args: o.args, env: o.env, cwd: o.cwd, stderr: "ignore" });
48234
- const client = new Client({ name: "exorcist-lock", version: "0.3.3" }, { capabilities: {} });
48270
+ const client = new Client({ name: "exorcist-lock", version: "0.3.5" }, { capabilities: {} });
48235
48271
  let timer;
48236
48272
  const timedOut = new Promise((res) => {
48237
48273
  timer = setTimeout(() => res({ ok: false, error: `it did not list its tools within ${o.timeoutMs} ms.` }), o.timeoutMs);
@@ -48396,7 +48432,7 @@ ${LOCK_HELP}`);
48396
48432
  return 2;
48397
48433
  }
48398
48434
  let previous;
48399
- if (existsSync26(lockPath2)) {
48435
+ if (existsSync27(lockPath2)) {
48400
48436
  let text2;
48401
48437
  try {
48402
48438
  text2 = readFileSync34(lockPath2, "utf8");
@@ -48425,7 +48461,7 @@ ${LOCK_HELP}`);
48425
48461
  current = pinsToLock(st.state);
48426
48462
  } else {
48427
48463
  const configPath = resolve36(str4(p.values["config"]) ?? DEFAULT_CONFIG);
48428
- if (!existsSync26(configPath)) {
48464
+ if (!existsSync27(configPath)) {
48429
48465
  io.err(`MCP config not found: ${configPath}. Pass --config <file>, or --from-shield.`);
48430
48466
  return 2;
48431
48467
  }
@@ -48473,7 +48509,7 @@ ${LOCK_HELP}`);
48473
48509
  }
48474
48510
 
48475
48511
  // src/commands/map.ts
48476
- import { existsSync as existsSync27, statSync as statSync23 } from "node:fs";
48512
+ import { existsSync as existsSync28, statSync as statSync23 } from "node:fs";
48477
48513
  import { resolve as resolve37 } from "node:path";
48478
48514
  var MAP_HELP = `Usage: exorcist map [dir] [options]
48479
48515
 
@@ -48570,7 +48606,7 @@ ${MAP_HELP}`);
48570
48606
  }
48571
48607
  const target = p.positionals[0] ?? ".";
48572
48608
  const root = resolve37(target);
48573
- if (!existsSync27(root) || !statSync23(root).isDirectory()) {
48609
+ if (!existsSync28(root) || !statSync23(root).isDirectory()) {
48574
48610
  io.err(`Folder not found: ${target}`);
48575
48611
  return 2;
48576
48612
  }
@@ -48592,7 +48628,7 @@ ${MAP_HELP}`);
48592
48628
  }
48593
48629
 
48594
48630
  // src/commands/origin.ts
48595
- import { existsSync as existsSync28, realpathSync as realpathSync11, statSync as statSync24 } from "node:fs";
48631
+ import { existsSync as existsSync29, realpathSync as realpathSync11, statSync as statSync24 } from "node:fs";
48596
48632
  import { posix as posix3, relative as relative16, resolve as resolve38, sep as sep8 } from "node:path";
48597
48633
  var ORIGIN_HELP = `Usage: exorcist origin [dir] [options]
48598
48634
 
@@ -48716,7 +48752,7 @@ ${ORIGIN_HELP}`);
48716
48752
  return 2;
48717
48753
  }
48718
48754
  const target = resolve38(p.positionals[0] ?? ".");
48719
- if (!existsSync28(target) || !statSync24(target).isDirectory()) {
48755
+ if (!existsSync29(target) || !statSync24(target).isDirectory()) {
48720
48756
  io.err(`Not a directory: ${target}`);
48721
48757
  return 2;
48722
48758
  }
@@ -49129,7 +49165,7 @@ ${VAULT_HELP}`);
49129
49165
  }
49130
49166
 
49131
49167
  // src/index.ts
49132
- var VERSION = "0.3.3";
49168
+ var VERSION = "0.3.5";
49133
49169
  var HELP = `Exorcist 98 ${VERSION}: antivirus for AI coding agents
49134
49170
 
49135
49171
  Usage: exorcist <command> [options]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exorcist-98/cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Exorcist 98: antivirus for AI coding agents. Scan repos, shield MCP servers, quarantine threats.",