@exorcist-98/mcp-server 0.2.0 → 0.3.1

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
@@ -7083,7 +7083,7 @@ var require_compile = __commonJS({
7083
7083
  const schOrFunc = root.refs[ref];
7084
7084
  if (schOrFunc)
7085
7085
  return schOrFunc;
7086
- let _sch = resolve6.call(this, root, ref);
7086
+ let _sch = resolve7.call(this, root, ref);
7087
7087
  if (_sch === void 0) {
7088
7088
  const schema2 = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
7089
7089
  const { schemaId } = this.opts;
@@ -7110,7 +7110,7 @@ var require_compile = __commonJS({
7110
7110
  function sameSchemaEnv(s1, s2) {
7111
7111
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
7112
7112
  }
7113
- function resolve6(root, ref) {
7113
+ function resolve7(root, ref) {
7114
7114
  let sch;
7115
7115
  while (typeof (sch = this.refs[ref]) == "string")
7116
7116
  ref = sch;
@@ -7974,7 +7974,7 @@ var require_fast_uri = __commonJS({
7974
7974
  }
7975
7975
  return uri;
7976
7976
  }
7977
- function resolve6(baseURI, relativeURI, options) {
7977
+ function resolve7(baseURI, relativeURI, options) {
7978
7978
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
7979
7979
  const {
7980
7980
  parsed: baseParsed,
@@ -8010,50 +8010,50 @@ var require_fast_uri = __commonJS({
8010
8010
  schemelessOptions.skipEscape = true;
8011
8011
  return serialize(resolved, schemelessOptions);
8012
8012
  }
8013
- function resolveComponent(base, relative4, options, skipNormalization) {
8013
+ function resolveComponent(base, relative5, options, skipNormalization) {
8014
8014
  const target = {};
8015
8015
  if (!skipNormalization) {
8016
8016
  base = parse4(serialize(base, options), options);
8017
- relative4 = parse4(serialize(relative4, options), options);
8017
+ relative5 = parse4(serialize(relative5, options), options);
8018
8018
  }
8019
8019
  options = options || {};
8020
- if (!options.tolerant && relative4.scheme) {
8021
- target.scheme = relative4.scheme;
8022
- target.userinfo = relative4.userinfo;
8023
- target.host = relative4.host;
8024
- target.port = relative4.port;
8025
- target.path = removeDotSegments(relative4.path || "");
8026
- target.query = relative4.query;
8020
+ if (!options.tolerant && relative5.scheme) {
8021
+ target.scheme = relative5.scheme;
8022
+ target.userinfo = relative5.userinfo;
8023
+ target.host = relative5.host;
8024
+ target.port = relative5.port;
8025
+ target.path = removeDotSegments(relative5.path || "");
8026
+ target.query = relative5.query;
8027
8027
  } else {
8028
- if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
8029
- target.userinfo = relative4.userinfo;
8030
- target.host = relative4.host;
8031
- target.port = relative4.port;
8032
- target.path = removeDotSegments(relative4.path || "");
8033
- target.query = relative4.query;
8028
+ if (relative5.userinfo !== void 0 || relative5.host !== void 0 || relative5.port !== void 0) {
8029
+ target.userinfo = relative5.userinfo;
8030
+ target.host = relative5.host;
8031
+ target.port = relative5.port;
8032
+ target.path = removeDotSegments(relative5.path || "");
8033
+ target.query = relative5.query;
8034
8034
  } else {
8035
- if (!relative4.path) {
8035
+ if (!relative5.path) {
8036
8036
  target.path = base.path;
8037
- if (relative4.query !== void 0) {
8038
- target.query = relative4.query;
8037
+ if (relative5.query !== void 0) {
8038
+ target.query = relative5.query;
8039
8039
  } else {
8040
8040
  target.query = base.query;
8041
8041
  }
8042
8042
  } else {
8043
- if (relative4.path[0] === "/") {
8044
- target.path = removeDotSegments(relative4.path);
8043
+ if (relative5.path[0] === "/") {
8044
+ target.path = removeDotSegments(relative5.path);
8045
8045
  } else {
8046
8046
  const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
8047
8047
  if (baseHasAuthority && !base.path) {
8048
- target.path = "/" + relative4.path;
8048
+ target.path = "/" + relative5.path;
8049
8049
  } else if (!base.path) {
8050
- target.path = relative4.path;
8050
+ target.path = relative5.path;
8051
8051
  } else {
8052
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative4.path;
8052
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative5.path;
8053
8053
  }
8054
8054
  target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
8055
8055
  }
8056
- target.query = relative4.query;
8056
+ target.query = relative5.query;
8057
8057
  }
8058
8058
  target.userinfo = base.userinfo;
8059
8059
  target.host = base.host;
@@ -8061,7 +8061,7 @@ var require_fast_uri = __commonJS({
8061
8061
  }
8062
8062
  target.scheme = base.scheme;
8063
8063
  }
8064
- target.fragment = relative4.fragment;
8064
+ target.fragment = relative5.fragment;
8065
8065
  return target;
8066
8066
  }
8067
8067
  function equal(uriA, uriB, options) {
@@ -8365,7 +8365,7 @@ var require_fast_uri = __commonJS({
8365
8365
  var fastUri = {
8366
8366
  SCHEMES,
8367
8367
  normalize: normalize2,
8368
- resolve: resolve6,
8368
+ resolve: resolve7,
8369
8369
  resolveComponent,
8370
8370
  equal,
8371
8371
  serialize,
@@ -20237,7 +20237,7 @@ var Protocol = class {
20237
20237
  return;
20238
20238
  }
20239
20239
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
20240
- await new Promise((resolve6) => setTimeout(resolve6, pollInterval));
20240
+ await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
20241
20241
  options?.signal?.throwIfAborted();
20242
20242
  }
20243
20243
  } catch (error2) {
@@ -20254,7 +20254,7 @@ var Protocol = class {
20254
20254
  */
20255
20255
  request(request, resultSchema, options) {
20256
20256
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
20257
- return new Promise((resolve6, reject) => {
20257
+ return new Promise((resolve7, reject) => {
20258
20258
  const earlyReject = (error2) => {
20259
20259
  reject(error2);
20260
20260
  };
@@ -20332,7 +20332,7 @@ var Protocol = class {
20332
20332
  if (!parseResult.success) {
20333
20333
  reject(parseResult.error);
20334
20334
  } else {
20335
- resolve6(parseResult.data);
20335
+ resolve7(parseResult.data);
20336
20336
  }
20337
20337
  } catch (error2) {
20338
20338
  reject(error2);
@@ -20594,12 +20594,12 @@ var Protocol = class {
20594
20594
  }
20595
20595
  } catch {
20596
20596
  }
20597
- return new Promise((resolve6, reject) => {
20597
+ return new Promise((resolve7, reject) => {
20598
20598
  if (signal.aborted) {
20599
20599
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
20600
20600
  return;
20601
20601
  }
20602
- const timeoutId = setTimeout(resolve6, interval);
20602
+ const timeoutId = setTimeout(resolve7, interval);
20603
20603
  signal.addEventListener("abort", () => {
20604
20604
  clearTimeout(timeoutId);
20605
20605
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -21740,7 +21740,7 @@ var McpServer = class {
21740
21740
  let task = createTaskResult.task;
21741
21741
  const pollInterval = task.pollInterval ?? 5e3;
21742
21742
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
21743
- await new Promise((resolve6) => setTimeout(resolve6, pollInterval));
21743
+ await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
21744
21744
  const updatedTask = await extra.taskStore.getTask(taskId);
21745
21745
  if (!updatedTask) {
21746
21746
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -22404,12 +22404,12 @@ var StdioServerTransport = class {
22404
22404
  this.onclose?.();
22405
22405
  }
22406
22406
  send(message) {
22407
- return new Promise((resolve6) => {
22407
+ return new Promise((resolve7) => {
22408
22408
  const json2 = serializeMessage(message);
22409
22409
  if (this._stdout.write(json2)) {
22410
- resolve6();
22410
+ resolve7();
22411
22411
  } else {
22412
- this._stdout.once("drain", resolve6);
22412
+ this._stdout.once("drain", resolve7);
22413
22413
  }
22414
22414
  });
22415
22415
  }
@@ -22421,7 +22421,7 @@ import { homedir as homedir3 } from "node:os";
22421
22421
  import { delimiter } from "node:path";
22422
22422
 
22423
22423
  // src/tools.ts
22424
- import { existsSync as existsSync3, readFileSync as readFileSync5, realpathSync, statSync as statSync4 } from "node:fs";
22424
+ import { existsSync as existsSync4, readFileSync as readFileSync5, realpathSync as realpathSync2, statSync as statSync5 } from "node:fs";
22425
22425
  import { fileURLToPath as fileURLToPath2 } from "node:url";
22426
22426
 
22427
22427
  // ../shield/src/jsonrpc.ts
@@ -25694,7 +25694,8 @@ var MatchSchema = external_exports.object({
25694
25694
  // `detonation` is the Detonation Chamber (EX-024, m5-detonation): a
25695
25695
  // sandboxed model run, only with `--detonate`.
25696
25696
  // `path-names` checks the names of every walked path (EX-029, path-names.ts).
25697
- analysis: external_exports.enum(["trifecta", "detonation", "path-names"]).optional(),
25697
+ // `lifecycle-scripts` follows a package.json lifecycle script into the local file it runs (EX-036, lifecycle-scripts.ts).
25698
+ analysis: external_exports.enum(["trifecta", "detonation", "path-names", "lifecycle-scripts"]).optional(),
25698
25699
  // Text an element hides from a person by its style (EX-028, hidden-text.ts):
25699
25700
  // reported only when the hidden text addresses the AI or asks for actions.
25700
25701
  hidden_text: external_exports.boolean().optional(),
@@ -26728,7 +26729,57 @@ var OPEN_TAG = /<([a-zA-Z][a-zA-Z0-9-]*)\b([^<>]*?)\bstyle\s*=\s*(?:"([^"]*)"|'(
26728
26729
  function plainElementText(html) {
26729
26730
  return html.replace(/<[^>]*>/g, " ").replace(/&nbsp;/gi, " ").replace(/&amp;/gi, "&").replace(/\s+/g, " ").trim();
26730
26731
  }
26732
+ var AI_META_NAME = /^(?:ai|llm|assistant|gpt|chatgpt|claude|kiro|copilot|agent|ai-agent|bot-instructions)(?:[-_:.][a-z0-9_.:-]*)?$/i;
26733
+ var META_TAG = /<meta\b[^<>]*>/gi;
26734
+ var IMG_TAG = /<img\b[^<>]*>/gi;
26735
+ var MD_IMAGE = /!\[([^\]\n]{1,500})\]\(/g;
26736
+ var AI_WORD = "(?:AI|assistants?|agents?|llms?|language\\s+models?|kiro|claude|copilot|chatgpt|gemini|cursor)";
26737
+ var ALT_ADDRESS = new RegExp(
26738
+ `(?:^|[.!?]\\s+)(?:hey\\s+|dear\\s+|attention\\s+)?${AI_WORD}\\s*[,:]|\\b(?:if\\s+you\\s+are|you\\s+are\\s+an?|note\\s+to|message\\s+for|instructions?\\s+for|attention)\\b[^.\\n]{0,30}\\b${AI_WORD}\\b`,
26739
+ "i"
26740
+ );
26741
+ function attr(tag, name) {
26742
+ const m = new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`, "i").exec(tag);
26743
+ return m ? m[1] ?? m[2] ?? "" : null;
26744
+ }
26745
+ function altInstructs(alt) {
26746
+ const t = alt.replace(/\s+/g, " ").trim();
26747
+ return t.length > 0 && (ALT_ADDRESS.test(t) || OVERRIDE.test(t) || ACTION.test(t));
26748
+ }
26749
+ function metaTagFindings(text) {
26750
+ const out = [];
26751
+ META_TAG.lastIndex = 0;
26752
+ let m;
26753
+ while ((m = META_TAG.exec(text)) !== null) {
26754
+ const name = attr(m[0], "name");
26755
+ const content = attr(m[0], "content");
26756
+ if (name === null || content === null || !AI_META_NAME.test(name.trim())) continue;
26757
+ const body = content.replace(/&nbsp;/gi, " ").replace(/&amp;/gi, "&").replace(/\s+/g, " ").trim();
26758
+ if (!addressesAi(body)) continue;
26759
+ out.push({ index: m.index, length: m[0].length, method: "meta-tag", text: body });
26760
+ }
26761
+ return out;
26762
+ }
26763
+ function altTextFindings(text) {
26764
+ const out = [];
26765
+ let m;
26766
+ IMG_TAG.lastIndex = 0;
26767
+ while ((m = IMG_TAG.exec(text)) !== null) {
26768
+ const alt = attr(m[0], "alt");
26769
+ if (alt !== null && altInstructs(alt)) out.push({ index: m.index, length: m[0].length, method: "alt-text", text: alt.replace(/\s+/g, " ").trim() });
26770
+ }
26771
+ MD_IMAGE.lastIndex = 0;
26772
+ while ((m = MD_IMAGE.exec(text)) !== null) {
26773
+ const alt = m[1];
26774
+ if (altInstructs(alt)) out.push({ index: m.index, length: m[0].length, method: "alt-text", text: alt.replace(/\s+/g, " ").trim() });
26775
+ }
26776
+ return out;
26777
+ }
26731
26778
  function findHiddenText(text) {
26779
+ const all = [...findHiddenElements(text), ...metaTagFindings(text), ...altTextFindings(text)];
26780
+ return all.sort((a, b) => a.index - b.index);
26781
+ }
26782
+ function findHiddenElements(text) {
26732
26783
  const out = [];
26733
26784
  OPEN_TAG.lastIndex = 0;
26734
26785
  let lastEnd = -1;
@@ -26751,6 +26802,65 @@ function findHiddenText(text) {
26751
26802
  return out;
26752
26803
  }
26753
26804
 
26805
+ // ../core/src/json-loose.ts
26806
+ function parseJsonLoose(text) {
26807
+ try {
26808
+ return JSON.parse(text);
26809
+ } catch {
26810
+ }
26811
+ try {
26812
+ return JSON.parse(stripJsonComments(text));
26813
+ } catch {
26814
+ return void 0;
26815
+ }
26816
+ }
26817
+ function stripJsonComments(text) {
26818
+ let out = "";
26819
+ let i = text.charCodeAt(0) === 65279 ? 1 : 0;
26820
+ while (i < text.length) {
26821
+ const c = text[i];
26822
+ const next = text[i + 1];
26823
+ if (c === '"') {
26824
+ let j = i + 1;
26825
+ while (j < text.length && text[j] !== '"') j += text[j] === "\\" ? 2 : 1;
26826
+ out += text.slice(i, j + 1);
26827
+ i = j + 1;
26828
+ } else if (c === "/" && next === "/") {
26829
+ while (i < text.length && text[i] !== "\n") i++;
26830
+ } else if (c === "/" && next === "*") {
26831
+ const end = text.indexOf("*/", i + 2);
26832
+ i = end === -1 ? text.length : end + 2;
26833
+ out += " ";
26834
+ } else {
26835
+ out += c;
26836
+ i++;
26837
+ }
26838
+ }
26839
+ return dropTrailingCommas(out);
26840
+ }
26841
+ function dropTrailingCommas(text) {
26842
+ let out = "";
26843
+ let i = 0;
26844
+ while (i < text.length) {
26845
+ const c = text[i];
26846
+ if (c === '"') {
26847
+ let j = i + 1;
26848
+ while (j < text.length && text[j] !== '"') j += text[j] === "\\" ? 2 : 1;
26849
+ out += text.slice(i, j + 1);
26850
+ i = j + 1;
26851
+ } else if (c === ",") {
26852
+ let j = i + 1;
26853
+ while (j < text.length && /\s/.test(text[j])) j++;
26854
+ if (text[j] !== "}" && text[j] !== "]") out += c;
26855
+ i++;
26856
+ } else {
26857
+ out += c;
26858
+ i++;
26859
+ }
26860
+ }
26861
+ return out;
26862
+ }
26863
+
26754
26864
  // ../core/src/scanner/signature-engine.ts
26755
26865
  init_severity_paths();
26756
26866
 
@@ -27370,12 +27480,8 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
27370
27480
  }
27371
27481
  }
27372
27482
  if (match.json_path) {
27373
- let parsed;
27374
- try {
27375
- parsed = JSON.parse(norm.original);
27376
- } catch {
27377
- continue;
27378
- }
27483
+ const parsed = parseJsonLoose(norm.original);
27484
+ if (parsed === void 0) continue;
27379
27485
  if (parsed === null || typeof parsed !== "object") continue;
27380
27486
  let results2;
27381
27487
  try {
@@ -27686,7 +27792,7 @@ function skipArgument(text, p, lang, limit) {
27686
27792
  }
27687
27793
  return -1;
27688
27794
  }
27689
- function findKeyString(text, open3, lang, limit, sep2) {
27795
+ function findKeyString(text, open3, lang, limit, sep3) {
27690
27796
  let depth = 0;
27691
27797
  let i = open3;
27692
27798
  let lit = null;
@@ -27696,7 +27802,7 @@ function findKeyString(text, open3, lang, limit, sep2) {
27696
27802
  };
27697
27803
  const sepAt = (p) => {
27698
27804
  const j = skipTrivia(text, p, lang, limit);
27699
- if (text[j] !== sep2 || sep2 === "=" && text[j + 1] === "=") return -1;
27805
+ if (text[j] !== sep3 || sep3 === "=" && text[j + 1] === "=") return -1;
27700
27806
  return j + 1;
27701
27807
  };
27702
27808
  while (i < limit) {
@@ -27927,6 +28033,47 @@ function scanSourceTools(file, text, defs) {
27927
28033
  }
27928
28034
  }
27929
28035
 
28036
+ // ../core/src/sandbox-policy.ts
28037
+ init_canary();
28038
+ var SANDBOX_RULE_ID = "EX-035";
28039
+ var SANDBOX_FILE = /(?:^|\/)\.kiro\/settings\/sandbox\.json$/;
28040
+ var OWASP = ["ASI05 Unexpected Code Execution", "LLM06:2025 Excessive Agency"];
28041
+ var FIX = 'A project file can only tighten the global sandbox policy, so if your global policy turns the sandbox and MCP wrapping on, it still applies here. To be covered in every project, set "enabled": true and "mcpSandboxing": true in your global ~/.kiro/settings/sandbox.json (or in this file).';
28042
+ function indexOfFalse(text, key) {
28043
+ const re2 = new RegExp(`"${key}"\\s*:\\s*false`, "g");
28044
+ for (let m = re2.exec(text); m; m = re2.exec(text)) {
28045
+ const lineStart = text.lastIndexOf("\n", m.index) + 1;
28046
+ if (!text.slice(lineStart, m.index).includes("//")) return m.index;
28047
+ }
28048
+ return -1;
28049
+ }
28050
+ function sandboxFindings(text, rel) {
28051
+ if (!SANDBOX_FILE.test(rel.replace(/\\/g, "/"))) return [];
28052
+ const doc = parseJsonLoose(text);
28053
+ if (typeof doc !== "object" || doc === null || Array.isArray(doc)) return [];
28054
+ const obj = doc;
28055
+ const mcpOff = obj["mcpSandboxing"] === false;
28056
+ const allOff = obj["enabled"] === false;
28057
+ if (!mcpOff && !allOff) return [];
28058
+ const key = mcpOff ? "mcpSandboxing" : "enabled";
28059
+ const at = indexOfFalse(text, key);
28060
+ if (at < 0) return [];
28061
+ const m = new RegExp(`^"${key}"\\s*:\\s*false`).exec(text.slice(at));
28062
+ const { line, col } = lineColOf(text, at);
28063
+ return [{
28064
+ source: "signature",
28065
+ ruleId: SANDBOX_RULE_ID,
28066
+ title: mcpOff ? "Info: MCP sandboxing is off in this project" : "Info: the command sandbox is off in this project",
28067
+ severity: "low",
28068
+ file: rel,
28069
+ line,
28070
+ col,
28071
+ span: m ? m[0] : `"${key}": false`,
28072
+ owasp: OWASP,
28073
+ fix: FIX
28074
+ }];
28075
+ }
28076
+
27930
28077
  // ../core/src/path-names.ts
27931
28078
  var MAX_PATH_SPAN = 120;
27932
28079
  var CONTROL = /[\u0000-\u001F\u007F-\u009F]/;
@@ -28013,12 +28160,328 @@ function checkPathSegment(name) {
28013
28160
  return null;
28014
28161
  }
28015
28162
 
28163
+ // ../core/src/lifecycle-scripts.ts
28164
+ import { closeSync, existsSync, openSync, readSync, realpathSync, statSync } from "node:fs";
28165
+ import { isAbsolute as isAbsolute2, join as join5, relative as relative3, resolve as resolve2, sep } from "node:path";
28166
+
28167
+ // ../core/src/shell-words.ts
28168
+ var MAX_COMMAND_CHARS = 65536;
28169
+ var REDIRECT = /^\d*[<>]+&?\d*-?$/;
28170
+ var REDIRECT_WITH_TARGET = /^\d*[<>]+&?[^\s<>]/;
28171
+ function splitShell(command) {
28172
+ if (command.length > MAX_COMMAND_CHARS) return { ok: false };
28173
+ const segments = [];
28174
+ let words2 = [];
28175
+ let cur = "";
28176
+ let started = false;
28177
+ let quote = null;
28178
+ const endWord = () => {
28179
+ if (started) words2.push(cur);
28180
+ cur = "";
28181
+ started = false;
28182
+ };
28183
+ const endSegment = () => {
28184
+ endWord();
28185
+ const kept = [];
28186
+ for (let i = 0; i < words2.length; i++) {
28187
+ const w = words2[i] ?? "";
28188
+ if (REDIRECT.test(w)) {
28189
+ i += 1;
28190
+ continue;
28191
+ }
28192
+ if (REDIRECT_WITH_TARGET.test(w)) continue;
28193
+ kept.push(w);
28194
+ }
28195
+ if (kept.length > 0) segments.push(kept);
28196
+ words2 = [];
28197
+ };
28198
+ for (let i = 0; i < command.length; i++) {
28199
+ const c = command[i] ?? "";
28200
+ if (quote === "'") {
28201
+ if (c === "'") quote = null;
28202
+ else cur += c;
28203
+ continue;
28204
+ }
28205
+ if (quote === '"') {
28206
+ if (c === '"') quote = null;
28207
+ else if (c === "\\" && i + 1 < command.length && /["\\$`]/.test(command[i + 1] ?? "")) {
28208
+ cur += command[i + 1] ?? "";
28209
+ i += 1;
28210
+ } else cur += c;
28211
+ continue;
28212
+ }
28213
+ if (c === "\\") {
28214
+ if (i + 1 >= command.length) return { ok: false };
28215
+ cur += command[i + 1] ?? "";
28216
+ started = true;
28217
+ i += 1;
28218
+ } else if (c === "'" || c === '"') {
28219
+ quote = c;
28220
+ started = true;
28221
+ } else if (c === " " || c === " ") {
28222
+ endWord();
28223
+ } else if (c === ";" || c === "\n" || c === "|" || c === "&" || c === "(" || c === ")") {
28224
+ if (c === "&" && (/[<>]$/.test(cur) || command[i + 1] === ">")) {
28225
+ cur += c;
28226
+ started = true;
28227
+ continue;
28228
+ }
28229
+ endSegment();
28230
+ } else {
28231
+ cur += c;
28232
+ started = true;
28233
+ }
28234
+ }
28235
+ if (quote !== null) return { ok: false };
28236
+ endSegment();
28237
+ return { ok: true, segments };
28238
+ }
28239
+ function isPlainWord(word) {
28240
+ return word !== "" && !/[$`*?[\]{}]/.test(word) && !word.startsWith("~") && !word.includes("\0");
28241
+ }
28242
+ function stripPrefixes(words2) {
28243
+ let i = 0;
28244
+ for (; ; ) {
28245
+ const w = words2[i];
28246
+ if (w === void 0) break;
28247
+ if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(w)) {
28248
+ i += 1;
28249
+ continue;
28250
+ }
28251
+ if (w === "env" || w === "sudo" || w === "time" || w === "nohup" || w === "command" || w === "exec") {
28252
+ i += 1;
28253
+ continue;
28254
+ }
28255
+ if (w === "cross-env") {
28256
+ i += 1;
28257
+ continue;
28258
+ }
28259
+ break;
28260
+ }
28261
+ return words2.slice(i);
28262
+ }
28263
+
28264
+ // ../core/src/lifecycle-scripts.ts
28265
+ var INSTALL_HOOKS = [
28266
+ "preinstall",
28267
+ "install",
28268
+ "postinstall",
28269
+ "prepublish",
28270
+ "preprepare",
28271
+ "prepare",
28272
+ "postprepare",
28273
+ "prepublishOnly",
28274
+ "prepack",
28275
+ "postpack"
28276
+ ];
28277
+ var HOOK_BASES = /* @__PURE__ */ new Set(["test", "start", "stop", "restart", "build", "install", "publish", "version", "pack", "uninstall", "shrinkwrap"]);
28278
+ var MAX_FOLLOW_DEPTH = 3;
28279
+ var MAX_SOURCE_BYTES = 1048576;
28280
+ var MAX_SCRIPTS = 500;
28281
+ function parseScripts(pkgText) {
28282
+ try {
28283
+ const parsed = JSON.parse(pkgText);
28284
+ if (typeof parsed !== "object" || parsed === null) return {};
28285
+ const s = parsed["scripts"];
28286
+ if (typeof s !== "object" || s === null || Array.isArray(s)) return {};
28287
+ const out = {};
28288
+ for (const [k, v] of Object.entries(s).slice(0, MAX_SCRIPTS)) if (typeof v === "string") out[k] = v;
28289
+ return out;
28290
+ } catch {
28291
+ return {};
28292
+ }
28293
+ }
28294
+ function isAutoScript(name, scripts) {
28295
+ if (INSTALL_HOOKS.includes(name)) return true;
28296
+ const m = /^(pre|post)(.+)$/.exec(name);
28297
+ if (!m) return false;
28298
+ const base = m[2] ?? "";
28299
+ return Object.prototype.hasOwnProperty.call(scripts, base) || HOOK_BASES.has(base);
28300
+ }
28301
+ function autoScriptNames(scripts) {
28302
+ return Object.keys(scripts).filter((n) => isAutoScript(n, scripts));
28303
+ }
28304
+ var INTERPRETERS = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno", "sh", "bash", "zsh", "dash", "python", "python3", "ruby", "perl", "php"]);
28305
+ var INLINE_FLAGS = /* @__PURE__ */ new Set(["-e", "-c", "-p", "--eval", "--print"]);
28306
+ var VALUE_FLAGS = /* @__PURE__ */ new Set(["-r", "--require", "--import", "--loader", "--experimental-loader", "-C", "-W", "-X", "-m"]);
28307
+ var RUN_WORDS = /* @__PURE__ */ new Set(["run", "run-script", "rum", "urn"]);
28308
+ function cleanRel(p) {
28309
+ if (!isPlainWord(p) || /^[a-z][a-z0-9+.-]*:/i.test(p) || isAbsolute2(p) || p.length > 300) return null;
28310
+ const rel = p.replace(/^(?:\.\/)+/, "");
28311
+ return rel === "" ? null : rel;
28312
+ }
28313
+ function scriptTargets(name, scripts, depth = 0, seen = /* @__PURE__ */ new Set()) {
28314
+ const out = { files: [], inline: [], scripts: [] };
28315
+ const text = scripts[name];
28316
+ if (text === void 0 || seen.has(name) || depth > MAX_FOLLOW_DEPTH) return out;
28317
+ seen.add(name);
28318
+ out.inline.push(text);
28319
+ const split = splitShell(text);
28320
+ if (!split.ok) return out;
28321
+ for (const raw of split.segments) {
28322
+ const words2 = stripPrefixes(raw);
28323
+ const head = words2[0];
28324
+ if (head === void 0) continue;
28325
+ const base = head.split("/").pop() ?? head;
28326
+ if ((base === "npm" || base === "pnpm" || base === "yarn") && depth < MAX_FOLLOW_DEPTH) {
28327
+ const sub = words2[1] === "run" || RUN_WORDS.has(words2[1] ?? "") ? words2[2] : base === "yarn" || base === "pnpm" ? words2[1] : void 0;
28328
+ if (sub !== void 0 && Object.prototype.hasOwnProperty.call(scripts, sub)) {
28329
+ out.scripts.push(sub);
28330
+ const inner = scriptTargets(sub, scripts, depth + 1, seen);
28331
+ out.files.push(...inner.files);
28332
+ out.inline.push(...inner.inline);
28333
+ out.scripts.push(...inner.scripts);
28334
+ }
28335
+ continue;
28336
+ }
28337
+ if (INTERPRETERS.has(base)) {
28338
+ for (let i = 1; i < words2.length; i++) {
28339
+ const w = words2[i] ?? "";
28340
+ if (INLINE_FLAGS.has(w)) {
28341
+ out.inline.push(words2[i + 1] ?? "");
28342
+ break;
28343
+ }
28344
+ if (VALUE_FLAGS.has(w)) {
28345
+ i += 1;
28346
+ continue;
28347
+ }
28348
+ if (w.startsWith("-")) continue;
28349
+ if (base === "deno" && (w === "run" || w === "task")) continue;
28350
+ const rel = cleanRel(w);
28351
+ if (rel !== null) out.files.push(rel);
28352
+ break;
28353
+ }
28354
+ continue;
28355
+ }
28356
+ if (head.startsWith("./") || head.startsWith("scripts/") || head.includes("/") && !head.startsWith("-") && !head.includes(":")) {
28357
+ const rel = cleanRel(head);
28358
+ if (rel !== null) out.files.push(rel);
28359
+ }
28360
+ }
28361
+ return out;
28362
+ }
28363
+ var SECRET_PATTERNS = [
28364
+ [/(?<![\w])\.env(?!\.(?:example|sample|template|dist))(?:\.[A-Za-z]+)?(?![\w-])/, ".env"],
28365
+ [/(?<![\w])\.npmrc\b/, ".npmrc"],
28366
+ [/(?<![\w])\.aws(?![\w-])/, "~/.aws"],
28367
+ [/(?<![\w])\.ssh(?![\w-])/, "~/.ssh"],
28368
+ [/\bid_(?:rsa|ed25519|ecdsa)\b/, "a private key file"],
28369
+ [/(?<![\w])\.(?:netrc|git-credentials|pypirc)\b/, "a credentials file"],
28370
+ [/JSON\.stringify\(\s*process\.env\s*[,)]/, "the whole of process.env"],
28371
+ [/Object\.(?:entries|keys|values|fromEntries|assign)\(\s*(?:\{\}\s*,\s*)?process\.env\s*\)/, "the whole of process.env"],
28372
+ [/\{\s*\.\.\.\s*process\.env\s*\}/, "the whole of process.env"],
28373
+ [/\bdict\(\s*os\.environ\s*\)|\bos\.environ\.(?:items|copy)\(\)|json\.dumps\(\s*os\.environ/, "the whole of os.environ"],
28374
+ [/(?:^|[;&|]\s*|\$\(\s*)(?:printenv|env)\s*(?:$|[|>)]|\s*\|)/, "the whole environment"]
28375
+ ];
28376
+ var SEND_PATTERNS = [
28377
+ [/\bhttps?\.(?:request|get)\s*\(/, "an http request"],
28378
+ [/\bfetch\s*\(/, "fetch"],
28379
+ [/\baxios(?:\.\w+)?\s*\(|\bgot(?:\.(?:post|get|put))?\s*\(\s*['"`]/, "an http client call"],
28380
+ [/new\s+XMLHttpRequest\b|new\s+WebSocket\s*\(/, "a browser-style request"],
28381
+ [/\bnet\.(?:connect|createConnection|Socket)\b/, "a socket"],
28382
+ [/require\(\s*['"](?:node:)?dgram['"]\s*\)|from\s+['"](?:node:)?dgram['"]/, "a datagram socket"],
28383
+ [/\b(?:curl|wget)\s+(?:-\S+\s+)*\S/, "curl or wget"],
28384
+ [/\/dev\/tcp\//, "/dev/tcp"],
28385
+ [/\bnc\s+\S+\s+\d+/, "netcat"],
28386
+ [/\burlopen\s*\(|\brequests\.(?:get|post|put)\s*\(|\bhttp\.client\b|\bsocket\.(?:socket|create_connection)\b|\bsmtplib\b/, "a python network call"]
28387
+ ];
28388
+ var lineHit = (lines, patterns) => {
28389
+ for (let i = 0; i < lines.length; i++) {
28390
+ const line = lines[i] ?? "";
28391
+ if (line.length > 4e3) continue;
28392
+ for (const [re2, label] of patterns) if (re2.test(line)) return { line: i + 1, label };
28393
+ }
28394
+ return null;
28395
+ };
28396
+ function analyzeSource(text) {
28397
+ const lines = text.split(/\r?\n/);
28398
+ return { secret: lineHit(lines, SECRET_PATTERNS), send: lineHit(lines, SEND_PATTERNS) };
28399
+ }
28400
+ function locateScript(pkgText, name) {
28401
+ const start = pkgText.search(/"scripts"\s*:/);
28402
+ const esc2 = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
28403
+ const re2 = new RegExp(`"${esc2}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`, "g");
28404
+ re2.lastIndex = Math.max(0, start);
28405
+ const m = re2.exec(pkgText);
28406
+ if (!m) return { line: 1, col: 1, span: name.slice(0, 120) };
28407
+ const valueIndex = m.index + m[0].indexOf('"', m[0].indexOf(":")) + 1;
28408
+ const before = pkgText.slice(0, valueIndex);
28409
+ const line = before.split("\n").length;
28410
+ const col = valueIndex - (before.lastIndexOf("\n") + 1) + 1;
28411
+ return { line, col, span: (m[1] ?? "").slice(0, 120) };
28412
+ }
28413
+ function lifecycleFindings(input) {
28414
+ const scripts = parseScripts(input.pkgText);
28415
+ const names = (input.names ?? autoScriptNames(scripts)).filter((n) => Object.prototype.hasOwnProperty.call(scripts, n));
28416
+ const hits = [];
28417
+ for (const name of names) {
28418
+ let found = null;
28419
+ try {
28420
+ const targets = scriptTargets(name, scripts);
28421
+ const where = locateScript(input.pkgText, name);
28422
+ const base = { script: name, scriptText: scripts[name] ?? "", ...where };
28423
+ for (const rel of [...new Set(targets.files)]) {
28424
+ const text = input.readLocal(rel);
28425
+ if (text === null) continue;
28426
+ const a = analyzeSource(text);
28427
+ if (a.secret && a.send) {
28428
+ found = { ...base, file: rel, secret: a.secret, send: a.send };
28429
+ break;
28430
+ }
28431
+ }
28432
+ if (!found) {
28433
+ for (const inline of targets.inline) {
28434
+ const a = analyzeSource(inline);
28435
+ if (a.secret && a.send) {
28436
+ found = { ...base, file: null, secret: a.secret, send: a.send };
28437
+ break;
28438
+ }
28439
+ }
28440
+ }
28441
+ } catch {
28442
+ found = null;
28443
+ }
28444
+ if (found) hits.push(found);
28445
+ }
28446
+ return hits;
28447
+ }
28448
+ function describeHit(h) {
28449
+ const where = 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}).`;
28450
+ return `The "${h.script}" script of package.json runs by itself when a package manager installs or tests this project. ${where}`;
28451
+ }
28452
+ function readLocalText(pkgDir, rel) {
28453
+ try {
28454
+ const abs = resolve2(pkgDir, rel);
28455
+ const within = (root, p) => {
28456
+ const r = relative3(root, p);
28457
+ return r !== "" && !r.startsWith("..") && !isAbsolute2(r) && !r.split(sep).includes("..");
28458
+ };
28459
+ if (!within(pkgDir, abs) || !existsSync(abs)) return null;
28460
+ const real = realpathSync(abs);
28461
+ if (!within(realpathSync(pkgDir), real)) return null;
28462
+ const st = statSync(real);
28463
+ if (!st.isFile() || st.size > MAX_SOURCE_BYTES) return null;
28464
+ const buf = Buffer.alloc(st.size);
28465
+ const fd = openSync(real, "r");
28466
+ try {
28467
+ readSync(fd, buf, 0, st.size, 0);
28468
+ } finally {
28469
+ closeSync(fd);
28470
+ }
28471
+ if (buf.includes(0)) return null;
28472
+ return buf.toString("utf8");
28473
+ } catch {
28474
+ return null;
28475
+ }
28476
+ }
28477
+
28016
28478
  // ../core/src/scanner/orchestrator.ts
28479
+ import { dirname } from "node:path";
28017
28480
  init_heuristic_engine();
28018
28481
 
28019
28482
  // ../core/src/capabilities.ts
28020
28483
  import { readFile as readFile2 } from "node:fs/promises";
28021
- import { join as join5 } from "node:path";
28484
+ import { join as join6 } from "node:path";
28022
28485
  init_zod();
28023
28486
  var CAPABILITIES = ["private-data", "untrusted-input", "exfiltration"];
28024
28487
  var CAPABILITIES_FILE = "capabilities.yaml";
@@ -28091,7 +28554,7 @@ function parseCapabilityRules(data) {
28091
28554
  async function loadCapabilityRules(definitionsDir) {
28092
28555
  let raw;
28093
28556
  try {
28094
- raw = await readFile2(join5(definitionsDir, CAPABILITIES_FILE), "utf8");
28557
+ raw = await readFile2(join6(definitionsDir, CAPABILITIES_FILE), "utf8");
28095
28558
  } catch {
28096
28559
  return { ok: false, missing: true, error: `${CAPABILITIES_FILE} was not found in ${definitionsDir}` };
28097
28560
  }
@@ -28373,7 +28836,7 @@ function classifyCapabilities(server2, rules) {
28373
28836
  init_zod();
28374
28837
  import { constants } from "node:fs";
28375
28838
  import { lstat, open as open2 } from "node:fs/promises";
28376
- import { join as join6 } from "node:path";
28839
+ import { join as join7 } from "node:path";
28377
28840
  init_severity_paths();
28378
28841
  init_walker();
28379
28842
  var TRIFECTA_RULE_ID = "EX-023";
@@ -28415,7 +28878,7 @@ function stripJsonc(text) {
28415
28878
  }
28416
28879
  return out.replace(/,(\s*[}\]])/g, "$1");
28417
28880
  }
28418
- function parseJsonLoose(text) {
28881
+ function parseJsonLoose2(text) {
28419
28882
  try {
28420
28883
  return JSON.parse(text);
28421
28884
  } catch {
@@ -28470,7 +28933,7 @@ function serverEntries(servers) {
28470
28933
  function parseMcpConfig(rel, role, text) {
28471
28934
  if (role !== "mcp-config" && !(role === "config" && /\.jsonc?$/i.test(rel))) return null;
28472
28935
  if (role === "config" && !text.includes("mcpServers")) return null;
28473
- const top = Obj.safeParse(parseJsonLoose(text));
28936
+ const top = Obj.safeParse(parseJsonLoose2(text));
28474
28937
  if (!top.success) return null;
28475
28938
  const doc = top.data;
28476
28939
  const entries = [];
@@ -28512,7 +28975,7 @@ function parsePins(json2) {
28512
28975
  return out;
28513
28976
  }
28514
28977
  async function readPins(root, maxBytes = MAX_PINS_BYTES) {
28515
- const path = join6(root, ".exorcist", "pins.json");
28978
+ const path = join7(root, ".exorcist", "pins.json");
28516
28979
  const none = (note) => ({ pins: /* @__PURE__ */ new Map(), note });
28517
28980
  let info;
28518
28981
  try {
@@ -28672,6 +29135,21 @@ async function* pathNameFindings(root, def) {
28672
29135
  } catch {
28673
29136
  }
28674
29137
  }
29138
+ function lifecycleScanFindings(text, absPath, rel, def) {
29139
+ const dir = dirname(absPath);
29140
+ return lifecycleFindings({ pkgText: text, readLocal: (r) => readLocalText(dir, r) }).map((h) => ({
29141
+ source: "signature",
29142
+ ruleId: def.id,
29143
+ title: def.title,
29144
+ severity: def.severity,
29145
+ file: rel,
29146
+ line: h.line,
29147
+ col: h.col,
29148
+ span: h.span,
29149
+ owasp: def.owasp,
29150
+ fix: `${describeHit(h)} ${def.fix}`
29151
+ }));
29152
+ }
28675
29153
  async function* scanRepo(root, options) {
28676
29154
  const defs = await loadDefinitions(options.definitionsDir);
28677
29155
  const canaries = loadCanariesFile(canariesPath(root));
@@ -28688,6 +29166,7 @@ async function* scanRepo(root, options) {
28688
29166
  let filesSkipped = 0;
28689
29167
  let findingsTotal = 0;
28690
29168
  const ex026 = defs.find((d) => d.id === "EX-026");
29169
+ const ex036 = defs.find((d) => d.id === "EX-036" && d.enabled !== false && d.match.analysis === "lifecycle-scripts");
28691
29170
  for await (const file of walkRepo(root, options.maxFileSizeBytes)) {
28692
29171
  yield { type: "file", file };
28693
29172
  if (file.tooLarge) {
@@ -28723,7 +29202,8 @@ async function* scanRepo(root, options) {
28723
29202
  const heurs = options.bedrockClient ? await runHeuristics(file, norm, sigs, options.bedrockClient) : [];
28724
29203
  const traps = canaryFindings(text, file.rel, records, ex022);
28725
29204
  const sourceTools = (file.role === "code" || file.role === "unknown") && languageOf(file.rel) !== null ? scanSourceTools(file, text, defs) : [];
28726
- let deduped = deduplicate([...sigs, ...heurs, ...traps, ...sourceTools]);
29205
+ const lifecycle = ex036 && file.role === "manifest" && file.rel.split("/").pop() === "package.json" ? lifecycleScanFindings(text, file.path, file.rel, ex036) : [];
29206
+ let deduped = deduplicate([...sigs, ...heurs, ...traps, ...sandboxFindings(text, file.rel), ...sourceTools, ...lifecycle]);
28727
29207
  if (checkVault && deduped.length > 0 && file.rel.includes(".exorcist/vault/")) {
28728
29208
  const backup = checkVault(file.rel, await readFile3(file.path));
28729
29209
  if (backup) deduped = deduped.map((f) => asBackupFinding(f, backup));
@@ -28959,6 +29439,34 @@ var ENTRIES = {
28959
29439
  headline: "A file or folder name is giving your AI orders",
28960
29440
  attack: 'The name of a file or folder reads like an instruction ("ignore previous instructions...") or hides invisible characters. An agent that lists the project reads every name, so a name alone can steer it.'
28961
29441
  },
29442
+ "EX-030": {
29443
+ headline: "This text asks your AI to change its own settings or guards",
29444
+ attack: "A file tells the agent to add a wildcard to its trusted commands, switch on auto-approve, or edit its hooks, custom agents, steering files or AGENTS.md. If the agent obeys, it stops asking you before it runs commands, and the change stays after the poisoned file is gone."
29445
+ },
29446
+ "EX-031": {
29447
+ headline: "This text tells your AI to skip, delete or weaken your tests and checks",
29448
+ attack: 'A file tells the agent to add .skip to tests, delete a test file as "flaky", commit with --no-verify, add "|| true" to a CI step, lower a coverage threshold, or make a failing check pass without fixing it. A bad change then gets through because the checks no longer catch it.'
29449
+ },
29450
+ "EX-032": {
29451
+ headline: "This text tells your AI to send your code somewhere else",
29452
+ attack: "A file tells the agent to push to a remote that is not your origin, add a new remote, publish a package, switch the package registry, or open a pull request against another repository. If the agent obeys, your code or a poisoned package leaves your control."
29453
+ },
29454
+ "EX-033": {
29455
+ headline: "This settings file lets your AI run any command without asking you",
29456
+ attack: "A committed settings file lists a wildcard or a bare shell name as trusted (Kiro trusted commands, Claude Code or Cursor allow rules). Whoever wrote the file decides that the agent never asks before running a command, so a poisoned file elsewhere in the project can then run anything on your machine."
29457
+ },
29458
+ "EX-034": {
29459
+ headline: "This settings file lets Copilot run any terminal command without asking you",
29460
+ attack: "The terminal auto-approve map in a committed settings file marks a pattern that matches every command as approved. The agent then runs commands without showing you a prompt."
29461
+ },
29462
+ "EX-035": {
29463
+ headline: "This project file switches off the sandbox around your AI tool servers",
29464
+ 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."
29465
+ },
29466
+ "EX-036": {
29467
+ headline: "A script that runs by itself sends your secrets out",
29468
+ 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.'
29469
+ },
28962
29470
  "EX-027": {
28963
29471
  headline: "Your AI read untrusted text and private data, and now wants to send something out",
28964
29472
  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."
@@ -29087,6 +29595,28 @@ var AllowedReadsSchema = external_exports.object({ version: external_exports.lit
29087
29595
  init_walker();
29088
29596
  var MAX_SCAN_BYTES = 10 * 1048576;
29089
29597
 
29598
+ // ../core/src/mcp-write-guard.ts
29599
+ var MAX_READ_BYTES = 2 * 1024 * 1024;
29600
+
29601
+ // ../core/src/web-fetch-guard.ts
29602
+ init_zod();
29603
+ init_canary();
29604
+ var EventSchema = external_exports.object({
29605
+ tool_name: external_exports.string().optional(),
29606
+ tool_input: external_exports.record(external_exports.unknown())
29607
+ });
29608
+
29609
+ // ../core/src/env-write-guard.ts
29610
+ init_zod();
29611
+ var EventSchema2 = external_exports.object({
29612
+ tool_name: external_exports.string().optional(),
29613
+ tool_input: external_exports.record(external_exports.unknown())
29614
+ });
29615
+ var MAX_TEXT_CHARS = 2 * 1024 * 1024;
29616
+
29617
+ // ../core/src/env-values.ts
29618
+ var MAX_ENV_FILE_BYTES = 256 * 1024;
29619
+
29090
29620
  // ../core/src/gate.ts
29091
29621
  init_walker();
29092
29622
 
@@ -29109,9 +29639,9 @@ var BUNDLED_DEFINITIONS_VERSION = "20261124.0";
29109
29639
  // ../core/src/liveupdate.ts
29110
29640
  init_zod();
29111
29641
  import { createHash as createHash2, createPrivateKey, createPublicKey, generateKeyPairSync, randomBytes as randomBytes2, sign as edSign, verify as edVerify } from "node:crypto";
29112
- import { closeSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync as readFileSync3, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
29642
+ import { closeSync as closeSync2, fstatSync, lstatSync, mkdirSync, openSync as openSync2, readFileSync as readFileSync3, readSync as readSync2, readdirSync, renameSync, rmSync, statSync as statSync2, writeFileSync } from "node:fs";
29113
29643
  import { homedir } from "node:os";
29114
- import { basename as basename3, join as join7, resolve as resolve2 } from "node:path";
29644
+ import { basename as basename3, join as join8, resolve as resolve3 } from "node:path";
29115
29645
  var DEFINITIONS_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
29116
29646
  MCowBQYDK2VwAyEAn4o+dmOJXIzsygT2CF/3go/1E/bk9Ub16r4hGtJJjhM=
29117
29647
  -----END PUBLIC KEY-----
@@ -29189,19 +29719,19 @@ function parseManifest(manifestBytes) {
29189
29719
  }
29190
29720
  function installedDefinitionsRoot(env = process.env) {
29191
29721
  const fromEnv = env["EXORCIST_DEFINITIONS_HOME"];
29192
- if (fromEnv) return resolve2(fromEnv);
29193
- return join7(env["HOME"] || env["USERPROFILE"] || homedir(), ".exorcist", "definitions");
29722
+ if (fromEnv) return resolve3(fromEnv);
29723
+ return join8(env["HOME"] || env["USERPROFILE"] || homedir(), ".exorcist", "definitions");
29194
29724
  }
29195
29725
  function verifySetFolder(dir, expectedVersion, publicKeyPem) {
29196
29726
  try {
29197
29727
  if (!lstatSync(dir).isDirectory()) return fail("not a real folder (a symlink or a file)");
29198
- const defsDir = join7(dir, "definitions");
29199
- for (const [p, kind] of [[join7(dir, MANIFEST_NAME), "file"], [join7(dir, SIGNATURE_NAME), "file"], [defsDir, "dir"]]) {
29728
+ const defsDir = join8(dir, "definitions");
29729
+ for (const [p, kind] of [[join8(dir, MANIFEST_NAME), "file"], [join8(dir, SIGNATURE_NAME), "file"], [defsDir, "dir"]]) {
29200
29730
  const st = lstatSync(p);
29201
29731
  if (kind === "file" ? !st.isFile() : !st.isDirectory()) return fail(`${basename3(p)} is not a plain ${kind === "file" ? "file" : "folder"}`);
29202
29732
  }
29203
- const manifestBytes = readFileSync3(join7(dir, MANIFEST_NAME));
29204
- const bad = verifySignature(manifestBytes, readFileSync3(join7(dir, SIGNATURE_NAME)), publicKeyPem);
29733
+ const manifestBytes = readFileSync3(join8(dir, MANIFEST_NAME));
29734
+ const bad = verifySignature(manifestBytes, readFileSync3(join8(dir, SIGNATURE_NAME)), publicKeyPem);
29205
29735
  if (bad) return fail("the manifest signature does not verify");
29206
29736
  const m = parseManifest(manifestBytes);
29207
29737
  if (!m.ok) return m;
@@ -29211,7 +29741,7 @@ function verifySetFolder(dir, expectedVersion, publicKeyPem) {
29211
29741
  const extra = onDisk.filter((n) => !listed.includes(n));
29212
29742
  if (extra.length > 0) return fail(`definitions/ holds files the manifest does not list: ${extra.map((n) => printable(n)).join(", ")}`);
29213
29743
  for (const name of listed) {
29214
- const p = join7(defsDir, name);
29744
+ const p = join8(defsDir, name);
29215
29745
  let st;
29216
29746
  try {
29217
29747
  st = lstatSync(p);
@@ -29242,7 +29772,7 @@ function findActiveInstalledSet(o = {}) {
29242
29772
  }
29243
29773
  const newer = names.filter((n) => isValidVersion(n) && compareVersions(n, BUNDLED_DEFINITIONS_VERSION) > 0).sort((a, b) => compareVersions(b, a));
29244
29774
  for (const name of newer) {
29245
- const r = verifyInstalledSet(join7(root, name), pem);
29775
+ const r = verifyInstalledSet(join8(root, name), pem);
29246
29776
  if (r.ok) return r.set;
29247
29777
  }
29248
29778
  return null;
@@ -29267,6 +29797,49 @@ var BaselineSchema = external_exports.object({
29267
29797
  entries: external_exports.array(BaselineEntrySchema)
29268
29798
  }).strict();
29269
29799
 
29800
+ // ../core/src/kiro-evidence.ts
29801
+ init_zod();
29802
+ var KiroEventSchema = external_exports.object({
29803
+ id: external_exports.string(),
29804
+ timestamp: external_exports.string(),
29805
+ payload: external_exports.object({ type: external_exports.string() }).passthrough()
29806
+ }).passthrough();
29807
+ var CRED_KEY = "(?:(?<![A-Za-z])|(?<=\\\\[nrt]))(?<key>aws_secret_access_key|aws_access_key_id|aws_session_token|password|_authToken)";
29808
+ var CRED_DELIMITED_SOURCE = `${CRED_KEY}(?<sep>(?:\\\\*["'])?[ \\t]*[=:][ \\t]*)(?:(?<q>\\\\*["'])(?<quoted>[^"'\\\\]{4,})|(?<bare>[^\\s"'\\\\,;}]{4,}))`;
29809
+ var DROP = Symbol("drop");
29810
+ var SessionJsonSchema = external_exports.object({
29811
+ id: external_exports.string().optional(),
29812
+ title: external_exports.string().optional(),
29813
+ agentMode: external_exports.string().optional(),
29814
+ createdAt: external_exports.string().optional(),
29815
+ lastModifiedAt: external_exports.string().optional(),
29816
+ modelId: external_exports.string().optional(),
29817
+ autopilot: external_exports.boolean().optional(),
29818
+ approveForMe: external_exports.boolean().optional()
29819
+ }).passthrough();
29820
+
29821
+ // ../core/src/run-scripts-guard.ts
29822
+ var INSTALL_SET = [...INSTALL_HOOKS];
29823
+
29824
+ // ../core/src/shell-read-guard.ts
29825
+ var VALUE_FLAGS2 = {
29826
+ cat: /* @__PURE__ */ new Set(),
29827
+ head: /* @__PURE__ */ new Set(["-n", "-c", "--lines", "--bytes"]),
29828
+ tail: /* @__PURE__ */ new Set(["-n", "-c", "--lines", "--bytes", "-s", "--sleep-interval"]),
29829
+ less: /* @__PURE__ */ new Set(["-b", "-h", "-j", "-p", "-P", "-t", "-T", "-x", "-y", "-z"]),
29830
+ more: /* @__PURE__ */ new Set(["-n", "-p"]),
29831
+ bat: /* @__PURE__ */ new Set(["-l", "--language", "-r", "--line-range", "--theme", "--style", "--tabs", "--wrap"]),
29832
+ batcat: /* @__PURE__ */ new Set(["-l", "--language", "-r", "--line-range", "--theme", "--style", "--tabs", "--wrap"]),
29833
+ nl: /* @__PURE__ */ new Set(["-b", "-d", "-f", "-h", "-i", "-l", "-n", "-s", "-v", "-w"]),
29834
+ sed: /* @__PURE__ */ new Set(["-e", "-f", "--expression", "--file", "-l", "-E", "-s"]),
29835
+ awk: /* @__PURE__ */ new Set(["-F", "-v", "-f", "--file", "-e", "--source"]),
29836
+ gawk: /* @__PURE__ */ new Set(["-F", "-v", "-f", "--file", "-e", "--source"]),
29837
+ grep: /* @__PURE__ */ new Set(["-e", "-f", "-m", "-A", "-B", "-C", "--include", "--exclude", "--exclude-dir", "--regexp", "--file", "--max-count", "--label", "--color", "-d", "-D"])
29838
+ };
29839
+ VALUE_FLAGS2["egrep"] = VALUE_FLAGS2["grep"] ?? /* @__PURE__ */ new Set();
29840
+ VALUE_FLAGS2["fgrep"] = VALUE_FLAGS2["grep"] ?? /* @__PURE__ */ new Set();
29841
+ var FILE_PROGRAMS = new Set(Object.keys(VALUE_FLAGS2));
29842
+
29270
29843
  // ../shield/src/paraphrase.ts
29271
29844
  var W = String.raw`[\s\W_]{0,3}`;
29272
29845
  var words = (...ws) => ws.join(`${W}`);
@@ -29513,11 +30086,11 @@ var LockSchema = external_exports.object({
29513
30086
 
29514
30087
  // ../shield/src/vault.ts
29515
30088
  import { createHash as createHash3, randomBytes as randomBytes3 } from "node:crypto";
29516
- import { copyFileSync, existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync4, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
29517
- import { basename as basename4, dirname, isAbsolute as isAbsolute2, join as join8, resolve as resolve3 } from "node:path";
30089
+ import { copyFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync4, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync2 } from "node:fs";
30090
+ import { basename as basename4, dirname as dirname2, isAbsolute as isAbsolute3, join as join9, resolve as resolve4 } from "node:path";
29518
30091
  init_zod();
29519
30092
  var SafeRel = external_exports.string().min(1).max(1024).refine(
29520
- (p) => !isAbsolute2(p) && !p.includes("\\") && !p.includes("\0") && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== ".."),
30093
+ (p) => !isAbsolute3(p) && !p.includes("\\") && !p.includes("\0") && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== ".."),
29521
30094
  "unsafe path"
29522
30095
  );
29523
30096
  var EditedFileSchema = external_exports.object({
@@ -29547,18 +30120,18 @@ function newId(label, now) {
29547
30120
  return `${stamp}-${slug}-${randomBytes3(2).toString("hex")}`;
29548
30121
  }
29549
30122
  function entryDir(vaultDir, id) {
29550
- return join8(vaultDir, id);
30123
+ return join9(vaultDir, id);
29551
30124
  }
29552
30125
  function writeManifest(vaultDir, e) {
29553
- writeFileSync2(join8(entryDir(vaultDir, e.id), "manifest.json"), `${JSON.stringify(e, null, 2)}
30126
+ writeFileSync2(join9(entryDir(vaultDir, e.id), "manifest.json"), `${JSON.stringify(e, null, 2)}
29554
30127
  `, "utf8");
29555
30128
  }
29556
30129
  function listEntries(vaultDir) {
29557
- if (!existsSync(vaultDir)) return [];
30130
+ if (!existsSync2(vaultDir)) return [];
29558
30131
  const out = [];
29559
30132
  for (const name of readdirSync2(vaultDir)) {
29560
- const file = join8(vaultDir, name, "manifest.json");
29561
- if (!existsSync(file)) continue;
30133
+ const file = join9(vaultDir, name, "manifest.json");
30134
+ if (!existsSync2(file)) continue;
29562
30135
  try {
29563
30136
  const parsed = EntrySchema.safeParse(JSON.parse(readFileSync4(file, "utf8")));
29564
30137
  if (parsed.success) out.push(parsed.data);
@@ -29590,7 +30163,7 @@ function readConfig(path) {
29590
30163
  var writeConfig = (path, cfg) => writeFileSync2(path, `${JSON.stringify(cfg, null, 2)}
29591
30164
  `, "utf8");
29592
30165
  function quarantineServer(o) {
29593
- const configPath = resolve3(o.configPath);
30166
+ const configPath = resolve4(o.configPath);
29594
30167
  const cfg = readConfig(configPath);
29595
30168
  if (!cfg.ok) return cfg;
29596
30169
  const entry = cfg.value.mcpServers?.[o.serverName];
@@ -29604,7 +30177,7 @@ function quarantineServer(o) {
29604
30177
  mkdirSync2(dir, { recursive: true });
29605
30178
  const backup = `${JSON.stringify(entry, null, 2)}
29606
30179
  `;
29607
- writeFileSync2(join8(dir, "entry.json"), backup, "utf8");
30180
+ writeFileSync2(join9(dir, "entry.json"), backup, "utf8");
29608
30181
  const e = {
29609
30182
  id,
29610
30183
  kind: "mcp-server",
@@ -29623,9 +30196,99 @@ function quarantineServer(o) {
29623
30196
 
29624
30197
  // ../shield/src/events.ts
29625
30198
  init_zod();
30199
+
30200
+ // ../shield/src/chain.ts
30201
+ init_zod();
30202
+
30203
+ // ../shield/src/chain-core.ts
30204
+ init_zod();
30205
+
30206
+ // ../shield/src/sha256.ts
30207
+ var K = new Uint32Array([
30208
+ 1116352408,
30209
+ 1899447441,
30210
+ 3049323471,
30211
+ 3921009573,
30212
+ 961987163,
30213
+ 1508970993,
30214
+ 2453635748,
30215
+ 2870763221,
30216
+ 3624381080,
30217
+ 310598401,
30218
+ 607225278,
30219
+ 1426881987,
30220
+ 1925078388,
30221
+ 2162078206,
30222
+ 2614888103,
30223
+ 3248222580,
30224
+ 3835390401,
30225
+ 4022224774,
30226
+ 264347078,
30227
+ 604807628,
30228
+ 770255983,
30229
+ 1249150122,
30230
+ 1555081692,
30231
+ 1996064986,
30232
+ 2554220882,
30233
+ 2821834349,
30234
+ 2952996808,
30235
+ 3210313671,
30236
+ 3336571891,
30237
+ 3584528711,
30238
+ 113926993,
30239
+ 338241895,
30240
+ 666307205,
30241
+ 773529912,
30242
+ 1294757372,
30243
+ 1396182291,
30244
+ 1695183700,
30245
+ 1986661051,
30246
+ 2177026350,
30247
+ 2456956037,
30248
+ 2730485921,
30249
+ 2820302411,
30250
+ 3259730800,
30251
+ 3345764771,
30252
+ 3516065817,
30253
+ 3600352804,
30254
+ 4094571909,
30255
+ 275423344,
30256
+ 430227734,
30257
+ 506948616,
30258
+ 659060556,
30259
+ 883997877,
30260
+ 958139571,
30261
+ 1322822218,
30262
+ 1537002063,
30263
+ 1747873779,
30264
+ 1955562222,
30265
+ 2024104815,
30266
+ 2227730452,
30267
+ 2361852424,
30268
+ 2428436474,
30269
+ 2756734187,
30270
+ 3204031479,
30271
+ 3329325298
30272
+ ]);
30273
+
30274
+ // ../shield/src/chain-core.ts
30275
+ var HEX64 = /^[0-9a-f]{64}$/;
30276
+ var HeadRecordSchema = external_exports.object({
30277
+ v: external_exports.literal(1),
30278
+ genesis: external_exports.string().regex(HEX64),
30279
+ seq: external_exports.number().int().positive(),
30280
+ hash: external_exports.string().regex(HEX64)
30281
+ }).strict();
30282
+
30283
+ // ../shield/src/chain.ts
30284
+ var GenesisFileSchema = external_exports.object({ v: external_exports.literal(1), genesis: external_exports.string().regex(HEX64) }).strict();
30285
+ var CHUNK = 1 << 20;
30286
+
30287
+ // ../shield/src/events.ts
29626
30288
  var MAX_EVENT_BYTES = 1024 * 1024;
29627
30289
  var MAX_LINE_BYTES = 8 * 1024;
29628
- var MAX_READ_BYTES = 8 * 1024 * 1024;
30290
+ var MAX_READ_BYTES2 = 8 * 1024 * 1024;
30291
+ var HEX642 = /^[0-9a-f]{64}$/;
29629
30292
  var NAME_CHARS2 = 80;
29630
30293
  var WHY_CHARS = 400;
29631
30294
  var MESSAGE_CHARS = 600;
@@ -29639,7 +30302,11 @@ var Base = {
29639
30302
  time: Time2,
29640
30303
  pid: external_exports.number().int().positive(),
29641
30304
  server: Name2,
29642
- session: external_exports.string().regex(KEY_RE).optional()
30305
+ session: external_exports.string().regex(KEY_RE).optional(),
30306
+ /** Hash-chain fields (chain.ts). Absent on lines written before the chain existed or when the lock could not be taken. */
30307
+ seq: external_exports.number().int().positive().optional(),
30308
+ prev: external_exports.string().regex(HEX642).optional(),
30309
+ hash: external_exports.string().regex(HEX642).optional()
29643
30310
  };
29644
30311
  var StartEvent = external_exports.object({
29645
30312
  ...Base,
@@ -29688,12 +30355,12 @@ var MAX_HASHED_BYTES = 64 * 1024 * 1024;
29688
30355
  var MAX_EVENT_BYTES2 = 16 * 1024 * 1024;
29689
30356
 
29690
30357
  // ../shield/src/locate.ts
29691
- import { existsSync as existsSync2, readdirSync as readdirSync3, statSync as statSync3 } from "node:fs";
29692
- import { dirname as dirname2, isAbsolute as isAbsolute3, join as join9, parse as parse3, resolve as resolve4 } from "node:path";
30358
+ import { existsSync as existsSync3, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
30359
+ import { dirname as dirname3, isAbsolute as isAbsolute4, join as join10, parse as parse3, resolve as resolve5 } from "node:path";
29693
30360
  import { fileURLToPath } from "node:url";
29694
30361
  function hasDefinitions(dir) {
29695
30362
  try {
29696
- return statSync3(dir).isDirectory() && readdirSync3(dir).some((f) => /^EX-\d{3}.*\.yaml$/.test(f));
30363
+ return statSync4(dir).isDirectory() && readdirSync3(dir).some((f) => /^EX-\d{3}.*\.yaml$/.test(f));
29697
30364
  } catch {
29698
30365
  return false;
29699
30366
  }
@@ -29701,13 +30368,13 @@ function hasDefinitions(dir) {
29701
30368
  function findDefinitionsDir(o) {
29702
30369
  const env = o.env ?? process.env;
29703
30370
  const cwd = o.cwd ?? process.cwd();
29704
- if (o.explicit) return resolve4(cwd, o.explicit);
30371
+ if (o.explicit) return resolve5(cwd, o.explicit);
29705
30372
  const fromEnv = env["EXORCIST_DEFINITIONS"];
29706
- if (fromEnv) return resolve4(cwd, fromEnv);
30373
+ if (fromEnv) return resolve5(cwd, fromEnv);
29707
30374
  const installed = findActiveInstalledSet({ env, ...o.publicKeyPem ? { publicKeyPem: o.publicKeyPem } : {} });
29708
30375
  if (installed && hasDefinitions(installed.definitionsDir)) return installed.definitionsDir;
29709
- const here = dirname2(fileURLToPath(o.callerUrl));
29710
- const candidates = [join9(here, "..", "definitions"), join9(here, "..", "..", "..", "definitions"), join9(cwd, "definitions")];
30376
+ const here = dirname3(fileURLToPath(o.callerUrl));
30377
+ const candidates = [join10(here, "..", "definitions"), join10(here, "..", "..", "..", "definitions"), join10(cwd, "definitions")];
29711
30378
  return candidates.find(hasDefinitions) ?? null;
29712
30379
  }
29713
30380
 
@@ -29741,7 +30408,7 @@ function isWrapped(entry) {
29741
30408
 
29742
30409
  // src/tools.ts
29743
30410
  import { homedir as homedir2 } from "node:os";
29744
- import { basename as basename5, dirname as dirname3, isAbsolute as isAbsolute4, join as join10, relative as relative3, resolve as resolve5, sep } from "node:path";
30411
+ import { basename as basename5, dirname as dirname4, isAbsolute as isAbsolute5, join as join11, relative as relative4, resolve as resolve6, sep as sep2 } from "node:path";
29745
30412
  var quotesWanted = (ctx2, asked) => asked === true && ctx2.noQuotes !== true;
29746
30413
  var RANK = { critical: 0, high: 1, medium: 2, low: 3 };
29747
30414
  var HIDDEN2 = /[\u200B-\u200D\uFEFF\u202A-\u202E\u2066-\u2069\u{E0000}-\u{E007F}]/gu;
@@ -29753,17 +30420,17 @@ function findDefinitionsDir2(cwd) {
29753
30420
  return findDefinitionsDir({ callerUrl: import.meta.url, cwd });
29754
30421
  }
29755
30422
  function resolveInside(cwd, p, roots = [], primary) {
29756
- const real = (d) => realpathSync(d);
29757
- const extra = roots.filter((r) => existsSync3(r)).map(real);
30423
+ const real = (d) => realpathSync2(d);
30424
+ const extra = roots.filter((r) => existsSync4(r)).map(real);
29758
30425
  const first = primary !== void 0 && extra.includes(real(primary)) ? [real(primary)] : [];
29759
30426
  const bases = [.../* @__PURE__ */ new Set([...first, real(cwd), ...extra])];
29760
- const tries = isAbsolute4(p) ? [p] : bases.map((b) => resolve5(b, p));
29761
- const found = tries.find((t) => existsSync3(t));
30427
+ const tries = isAbsolute5(p) ? [p] : bases.map((b) => resolve6(b, p));
30428
+ const found = tries.find((t) => existsSync4(t));
29762
30429
  if (!found) return { ok: false, error: `Path not found: ${p}` };
29763
- const target = realpathSync(found);
30430
+ const target = realpathSync2(found);
29764
30431
  const base = bases.find((b) => {
29765
- const rel = relative3(b, target);
29766
- return !rel.startsWith("..") && !isAbsolute4(rel);
30432
+ const rel = relative4(b, target);
30433
+ return !rel.startsWith("..") && !isAbsolute5(rel);
29767
30434
  });
29768
30435
  if (!base) {
29769
30436
  const where = bases.length > 1 ? `the project folder (${bases[0]}) or the folders your client shared` : `the project folder (${bases[0]})`;
@@ -29794,23 +30461,23 @@ var PROJECT_MARKERS = [
29794
30461
  "README"
29795
30462
  ];
29796
30463
  function looksLikeProject(dir) {
29797
- const has = (n) => existsSync3(join10(dir, n));
30464
+ const has = (n) => existsSync4(join11(dir, n));
29798
30465
  if (has("plugin.json") || has("POWER.md")) return false;
29799
30466
  return PROJECT_MARKERS.some(has);
29800
30467
  }
29801
- var SENSITIVE_IN_HOME = [".ssh", ".aws", ".gnupg", ".kube", ".docker", ".azure", ".config", ".password-store", join10("Library", "Keychains")];
30468
+ var SENSITIVE_IN_HOME = [".ssh", ".aws", ".gnupg", ".kube", ".docker", ".azure", ".config", ".password-store", join11("Library", "Keychains")];
29802
30469
  var SENSITIVE_ABSOLUTE = ["/etc", "/private/etc", "/System", "/var/root", "/root"];
29803
30470
  var isWithin = (base, p) => {
29804
- const rel = relative3(base, p);
29805
- return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
30471
+ const rel = relative4(base, p);
30472
+ return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
29806
30473
  };
29807
30474
  function sensitiveReason(real, home = homedir2()) {
29808
- const realHome = existsSync3(home) ? realpathSync(home) : home;
29809
- if (dirname3(real) === real) return "it is the filesystem root";
30475
+ const realHome = existsSync4(home) ? realpathSync2(home) : home;
30476
+ if (dirname4(real) === real) return "it is the filesystem root";
29810
30477
  if (isWithin(real, realHome)) return real === realHome ? "it is the home folder" : "it contains the home folder";
29811
30478
  for (const n of SENSITIVE_IN_HOME) {
29812
- const s = join10(realHome, n);
29813
- if (isWithin(s, real) || isWithin(real, s)) return `it holds credentials or settings (${n.split(sep)[0]})`;
30479
+ const s = join11(realHome, n);
30480
+ if (isWithin(s, real) || isWithin(real, s)) return `it holds credentials or settings (${n.split(sep2)[0]})`;
29814
30481
  }
29815
30482
  for (const s of SENSITIVE_ABSOLUTE) if (isWithin(s, real)) return "it is a system folder";
29816
30483
  return null;
@@ -29823,21 +30490,21 @@ function approvalMessage(folder) {
29823
30490
  }
29824
30491
  var FIXES = "Either set EXORCIST_ROOTS to the absolute path of the project folder in the env of the exorcist MCP server, or add the exorcist server to the workspace .kiro/settings/mcp.json, where Kiro starts it in the project folder.";
29825
30492
  function noProjectError(ctx2, p, inside2) {
29826
- if (inside2.outside || isAbsolute4(p) || (ctx2.roots?.length ?? 0) > 0 || looksLikeProject(ctx2.cwd)) return null;
30493
+ if (inside2.outside || isAbsolute5(p) || (ctx2.roots?.length ?? 0) > 0 || looksLikeProject(ctx2.cwd)) return null;
29827
30494
  const how = ctx2.ask ? "Call the tool again with the absolute path of the project folder; the person will be asked to allow it for this session. Other fixes: set EXORCIST_ROOTS to that folder in the env of the exorcist MCP server, or add the exorcist server to the workspace .kiro/settings/mcp.json, where Kiro starts it in the project folder." : FIXES;
29828
30495
  return `No project folder is known, so "${p}" was not scanned. This server was started in ${ctx2.cwd}, which is not a project, and the client did not share a workspace folder (MCP roots). Nothing was checked. ${how} Do not report this as a clean scan.`;
29829
30496
  }
29830
30497
  async function resolveAllowed(ctx2, p) {
29831
30498
  const first = resolveInside(ctx2.cwd, p, ctx2.roots, ctx2.base);
29832
- if (first.ok || !first.outside || !isAbsolute4(p)) return first;
30499
+ if (first.ok || !first.outside || !isAbsolute5(p)) return first;
29833
30500
  const noRoots = (ctx2.roots?.length ?? 0) === 0;
29834
30501
  if (!ctx2.ask) {
29835
30502
  return noRoots && !looksLikeProject(ctx2.cwd) ? { ...first, error: `${first.error} No project folder is known. ${FIXES}` } : first;
29836
30503
  }
29837
30504
  let folder;
29838
30505
  try {
29839
- const real = realpathSync(p);
29840
- folder = statSync4(real).isDirectory() ? real : dirname3(real);
30506
+ const real = realpathSync2(p);
30507
+ folder = statSync5(real).isDirectory() ? real : dirname4(real);
29841
30508
  } catch {
29842
30509
  return first;
29843
30510
  }
@@ -29869,16 +30536,16 @@ function usableRoots(entries, home) {
29869
30536
  continue;
29870
30537
  }
29871
30538
  } else if (/^[a-z][a-z0-9+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path)) continue;
29872
- if (!isAbsolute4(path) || !existsSync3(path)) continue;
30539
+ if (!isAbsolute5(path) || !existsSync4(path)) continue;
29873
30540
  let real;
29874
30541
  try {
29875
- if (!statSync4(path).isDirectory()) continue;
29876
- real = realpathSync(path);
30542
+ if (!statSync5(path).isDirectory()) continue;
30543
+ real = realpathSync2(path);
29877
30544
  } catch {
29878
30545
  continue;
29879
30546
  }
29880
- const realHome = existsSync3(home) ? realpathSync(home) : home;
29881
- if (real === resolve5("/") || real === realHome || dirname3(real) === real) continue;
30547
+ const realHome = existsSync4(home) ? realpathSync2(home) : home;
30548
+ if (real === resolve6("/") || real === realHome || dirname4(real) === real) continue;
29882
30549
  if (!out.includes(real)) out.push(real);
29883
30550
  }
29884
30551
  return out;
@@ -29920,8 +30587,8 @@ async function scanRepoTool(ctx2, a) {
29920
30587
  if (!inside2.ok) return err(inside2.error);
29921
30588
  const defs = await loadDefs(ctx2);
29922
30589
  if (!defs.ok) return err(defs.error);
29923
- const isFile = statSync4(inside2.path).isFile();
29924
- const root = isFile ? dirname3(inside2.path) : inside2.path;
30590
+ const isFile = statSync5(inside2.path).isFile();
30591
+ const root = isFile ? dirname4(inside2.path) : inside2.path;
29925
30592
  const only = isFile ? basename5(inside2.path) : null;
29926
30593
  const findings = [];
29927
30594
  let files = 0;
@@ -29938,7 +30605,7 @@ async function scanMcpConfigTool(ctx2, a) {
29938
30605
  const none = noProjectError(ctx2, a.path, inside2);
29939
30606
  if (none) return err(none);
29940
30607
  if (!inside2.ok) return err(inside2.error);
29941
- if (!statSync4(inside2.path).isFile()) return err(`${a.path} is a folder. Give the path of an MCP config file.`);
30608
+ if (!statSync5(inside2.path).isFile()) return err(`${a.path} is a folder. Give the path of an MCP config file.`);
29942
30609
  const defs = await loadDefs(ctx2);
29943
30610
  if (!defs.ok) return err(defs.error);
29944
30611
  const text = readFileSync5(inside2.path, "utf8");
@@ -29948,7 +30615,7 @@ async function scanMcpConfigTool(ctx2, a) {
29948
30615
  } catch {
29949
30616
  return err(`${a.path} is not valid JSON.`);
29950
30617
  }
29951
- const rel = relative3(inside2.base, inside2.path);
30618
+ const rel = relative4(inside2.base, inside2.path);
29952
30619
  const findings = scanText(text, "mcp-config", defs.defs, rel);
29953
30620
  const servers = Object.entries(config2.mcpServers ?? {});
29954
30621
  const local = servers.filter(([, e]) => typeof e["command"] === "string");
@@ -29987,7 +30654,7 @@ async function quarantineTool(ctx2, a) {
29987
30654
  configPath: inside2.path,
29988
30655
  serverName: a.server,
29989
30656
  reason: a.reason?.slice(0, 200) ?? "quarantined from an AI agent request",
29990
- vaultDir: join10(inside2.base, ".exorcist", "vault")
30657
+ vaultDir: join11(inside2.base, ".exorcist", "vault")
29991
30658
  });
29992
30659
  if (!r.ok) return err(r.error);
29993
30660
  return {
@@ -29997,7 +30664,7 @@ Tell the user. They can undo this with: exorcist vault restore ${r.value.id}`
29997
30664
  }
29998
30665
 
29999
30666
  // src/index.ts
30000
- var VERSION = "0.2.0";
30667
+ var VERSION = "0.3.1";
30001
30668
  var ctx = {
30002
30669
  cwd: process.cwd(),
30003
30670
  approved: [],