@vantageos/mcp-doctor 0.13.2 → 0.15.0

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/doctor.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/doctor.ts
4
- import { readFileSync as readFileSync16, realpathSync } from "fs";
5
- import { dirname as dirname17, join as join28, resolve as resolve3 } from "path";
4
+ import { readFileSync as readFileSync17, realpathSync } from "fs";
5
+ import { dirname as dirname18, join as join29, resolve as resolve4 } from "path";
6
6
  import { fileURLToPath as fileURLToPath2 } from "url";
7
7
 
8
8
  // src/scan.ts
@@ -767,7 +767,7 @@ function enclosingBlock(file, line, col, levels = 0) {
767
767
  }
768
768
 
769
769
  // src/detectors/standardPin.ts
770
- var STANDARD_PIN = "c29f83d50781dcca5c99696dcbb5d19bb77ef33d";
770
+ var STANDARD_PIN = "9fdad5b80bebef09d790e1ca9a4419f7ea2db7d1";
771
771
 
772
772
  // src/detectors/dLocalIdentity.ts
773
773
  var CLOUD_IDENTITY_PACKAGE = "@vantageos/cloud-identity";
@@ -3937,9 +3937,9 @@ function stringValueAt(file, line, col) {
3937
3937
  return { kind: "string", value: m[2] };
3938
3938
  }
3939
3939
  function identReturned(file, name) {
3940
- const esc4 = name.replace(/[$]/g, "\\$&");
3940
+ const esc5 = name.replace(/[$]/g, "\\$&");
3941
3941
  const re = new RegExp(
3942
- `(?:\\breturn|=>)\\s*(?:\\(\\s*)*${esc4}(?![\\w$])(?!\\s*(?:\\?\\.|\\.|\\(|\\[|=))`
3942
+ `(?:\\breturn|=>)\\s*(?:\\(\\s*)*${esc5}(?![\\w$])(?!\\s*(?:\\?\\.|\\.|\\(|\\[|=))`
3943
3943
  );
3944
3944
  return re.test(uncommentedLines(file).join("\n"));
3945
3945
  }
@@ -5375,6 +5375,76 @@ var c9VerbDeclared = {
5375
5375
  }
5376
5376
  };
5377
5377
 
5378
+ // src/detectors/literalLoop.ts
5379
+ function closeOf(shape, open) {
5380
+ const pairs = { "(": ")", "[": "]", "{": "}" };
5381
+ const want = [];
5382
+ for (let i = open; i < shape.length; i++) {
5383
+ const c = shape[i];
5384
+ if (c in pairs) want.push(pairs[c]);
5385
+ else if (c === ")" || c === "]" || c === "}") {
5386
+ if (want.pop() !== c) return -1;
5387
+ if (want.length === 0) return i;
5388
+ }
5389
+ }
5390
+ return -1;
5391
+ }
5392
+ var esc = (s) => s.replace(/[$]/g, "\\$&");
5393
+ function occurrences(text, name) {
5394
+ return [...text.matchAll(new RegExp(String.raw`(?<![\w$.])${esc(name)}(?![\w$])`, "g"))].map(
5395
+ (m) => m.index ?? 0
5396
+ );
5397
+ }
5398
+ function enclosingLoopList(shape, code, at, id, readAt) {
5399
+ if (!/^[A-Za-z_$][\w$]*$/.test(id)) return void 0;
5400
+ const head = new RegExp(
5401
+ String.raw`for\s*\(\s*const\s+${esc(id)}\s+of\s+([A-Za-z_$][\w$]*)\s*\)`,
5402
+ "g"
5403
+ );
5404
+ let best;
5405
+ for (const m of shape.matchAll(head)) {
5406
+ const start = m.index ?? 0;
5407
+ let i = start + m[0].length;
5408
+ while (i < shape.length && /\s/.test(shape[i])) i++;
5409
+ let end;
5410
+ if (shape[i] === "{") end = closeOf(shape, i);
5411
+ else {
5412
+ end = shape.indexOf(";", i);
5413
+ if (end < 0) end = shape.length;
5414
+ }
5415
+ if (end < 0) continue;
5416
+ if (start < at && at < end && (best === void 0 || start > best.start))
5417
+ best = { start, list: m[1], bodyFrom: i, bodyTo: end };
5418
+ }
5419
+ if (!best) return void 0;
5420
+ for (const o of occurrences(shape.slice(best.bodyFrom, best.bodyTo), id)) {
5421
+ if (!readAt(shape, best.bodyFrom + o)) return void 0;
5422
+ }
5423
+ const declRe = new RegExp(
5424
+ String.raw`(?:export\s+)?const\s+${esc(best.list)}\s*(?::[^=]+)?=\s*\[([^\]]*)\]\s*(?:as\s+const\s*)?;`,
5425
+ "g"
5426
+ );
5427
+ const decls = [...code.matchAll(declRe)];
5428
+ if (decls.length !== 1) return void 0;
5429
+ const nameAt = new RegExp(String.raw`(?<![\w$])${esc(best.list)}(?![\w$])`);
5430
+ const declAt = (decls[0].index ?? 0) + decls[0][0].search(nameAt);
5431
+ for (const o of occurrences(shape, best.list)) {
5432
+ if (o === declAt) continue;
5433
+ const before = shape.slice(Math.max(0, o - 200), o);
5434
+ const after = shape.slice(o + best.list.length);
5435
+ if (/for\s*\(\s*const\s+[A-Za-z_$][\w$]*\s+of\s+$/.test(before) && /^\s*\)/.test(after))
5436
+ continue;
5437
+ return void 0;
5438
+ }
5439
+ const out = [];
5440
+ for (const item of decls[0][1].split(",").map((x) => x.trim()).filter((x) => x !== "")) {
5441
+ const lit = /^(["'`])([^"'`$]*)\1$/.exec(item);
5442
+ if (!lit) return void 0;
5443
+ out.push(lit[2]);
5444
+ }
5445
+ return out.length > 0 ? out : void 0;
5446
+ }
5447
+
5378
5448
  // src/detectors/nodeCoreExports.ts
5379
5449
  var TABLE = {
5380
5450
  http: {
@@ -5523,7 +5593,7 @@ var lineAt = (m, offset) => {
5523
5593
  return n;
5524
5594
  };
5525
5595
  var anchorAt = (s, offset) => `${s.rel}:${lineAt(s.shape, offset)}`;
5526
- var esc = (s) => s.replace(/[$.*+?^()[\]{}|\\]/g, "\\$&");
5596
+ var esc2 = (s) => s.replace(/[$.*+?^()[\]{}|\\]/g, "\\$&");
5527
5597
  var CLOSE = { "(": ")", "[": "]", "{": "}" };
5528
5598
  function matchClose(m, open) {
5529
5599
  const stack = [];
@@ -5851,7 +5921,7 @@ function wrapperProof(s, server, mine) {
5851
5921
  for (const h of mine) {
5852
5922
  const after = m.slice(h.at + h.len);
5853
5923
  const before = m.slice(0, h.at);
5854
- const bind = new RegExp(String.raw`^\s*\.\s*bind\s*\(\s*${esc(server)}\s*\)`).exec(after);
5924
+ const bind = new RegExp(String.raw`^\s*\.\s*bind\s*\(\s*${esc2(server)}\s*\)`).exec(after);
5855
5925
  const decl = /(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*$/.exec(before);
5856
5926
  if (bind && decl) {
5857
5927
  nBind++;
@@ -5907,7 +5977,7 @@ function wrapperProof(s, server, mine) {
5907
5977
  bEnd = matchClose(m, bStart);
5908
5978
  } else return "the function literal has no readable body";
5909
5979
  if (bEnd < 0) return "the function body is unbalanced";
5910
- const idRe = new RegExp(String.raw`(?<![\w$.])${esc(alias)}(?![\w$])`, "g");
5980
+ const idRe = new RegExp(String.raw`(?<![\w$.])${esc2(alias)}(?![\w$])`, "g");
5911
5981
  const all = [...m.matchAll(idRe)].map((x) => x.index ?? 0);
5912
5982
  const inBody = all.filter((i) => i > bStart && i < bEnd);
5913
5983
  if (inBody.length !== 1 || all.length !== 2)
@@ -5934,6 +6004,72 @@ function wrapperProof(s, server, mine) {
5934
6004
  return `the wrapper does not forward exactly its own parameters (${names.join(", ")}) to \`${alias}\``;
5935
6005
  return untouchedParams(s, params, names, bStart, bEnd, argsOpen, argsClose);
5936
6006
  }
6007
+ function methodArgumentRead(shape, o) {
6008
+ const before = shape.slice(Math.max(0, o - 80), o);
6009
+ const after = shape.slice(o);
6010
+ return /\.\s*[A-Za-z_$][\w$]*\s*\(\s*$/.test(before) && /^[A-Za-z_$][\w$]*\s*[,)]/.test(after);
6011
+ }
6012
+ function decoratorProof(s, server, mine) {
6013
+ if (mine.some((h) => h.computed)) return "a computed member access";
6014
+ const m = s.shape;
6015
+ let alias;
6016
+ let assign;
6017
+ let nBind = 0;
6018
+ let nAssign = 0;
6019
+ for (const h of mine) {
6020
+ const after = m.slice(h.at + h.len);
6021
+ const before = m.slice(0, h.at);
6022
+ const bind = new RegExp(String.raw`^\s*\.\s*bind\s*\(\s*${esc2(server)}\s*\)`).exec(after);
6023
+ const decl = /(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*$/.exec(before);
6024
+ if (bind && decl) {
6025
+ nBind++;
6026
+ alias = decl[1];
6027
+ } else if (/^\s*=(?![=>])/.test(after)) {
6028
+ nAssign++;
6029
+ assign = h;
6030
+ } else return "the method is read in a form other than its rebind";
6031
+ }
6032
+ if (nBind !== 1 || alias === void 0 || nAssign !== 1 || assign === void 0)
6033
+ return "no single `.bind(server)` original and single `server.M = <function>`";
6034
+ const rhsAt = assign.at + assign.len + (/^\s*=/.exec(m.slice(assign.at + assign.len))?.[0].length ?? 0);
6035
+ const head = /^[\s(]*(?:async\s+)?(?:function\b\s*[\w$]*\s*)?\(/.exec(m.slice(rhsAt));
6036
+ if (!head) return "the assigned value is not a function literal";
6037
+ const pOpen = rhsAt + head[0].length - 1;
6038
+ const pClose = matchClose(m, pOpen);
6039
+ if (pClose < 0) return "the parameter list is unbalanced";
6040
+ const names = splitList(m, pOpen + 1, pClose).map((p) => /^\s*([A-Za-z_$][\w$]*)/.exec(p)?.[1]);
6041
+ if (names.length < 2 || names.some((n) => n === void 0))
6042
+ return "the parameters are not plain names";
6043
+ const first = names[0];
6044
+ const handler = names[names.length - 1];
6045
+ const tail = m.slice(pClose + 1);
6046
+ const arrow = /^\s*(?::[^=>{]*)?=>\s*\{/.exec(tail);
6047
+ const fnBody = arrow ? void 0 : /^\s*(?::[^{]*)?\{/.exec(tail);
6048
+ const opened = arrow ?? fnBody;
6049
+ if (!opened) return "the function literal has no block body";
6050
+ const bStart = pClose + 1 + opened[0].length - 1;
6051
+ const bEnd = matchClose(m, bStart);
6052
+ if (bEnd < 0) return "the function body is unbalanced";
6053
+ const idRe = new RegExp(String.raw`(?<![\w$.])${esc2(alias)}(?![\w$])`, "g");
6054
+ const all = [...m.matchAll(idRe)].map((x) => x.index ?? 0);
6055
+ const inBody = all.filter((i) => i > bStart && i < bEnd);
6056
+ if (inBody.length !== 1 || all.length !== 2)
6057
+ return `the original \`${alias}\` is referenced ${all.length - 1} time(s) after its binding (once, in the wrapper, is the proof)`;
6058
+ const callOpen = inBody[0] + alias.length + (/^\s*/.exec(m.slice(inBody[0] + alias.length))?.[0].length ?? 0);
6059
+ if (m[callOpen] !== "(") return `the original \`${alias}\` is not called directly`;
6060
+ const callClose = matchClose(m, callOpen);
6061
+ if (callClose < 0) return "the call of the original is unbalanced";
6062
+ const args = splitList(m, callOpen + 1, callClose);
6063
+ const arg0 = (args[0] ?? "").replace(/\s+as\s+[\w$<>[\]|. ]+$/, "").trim();
6064
+ if (arg0 !== first)
6065
+ return `the first parameter \`${first}\` is not forwarded unchanged as the first argument`;
6066
+ const hRe = new RegExp(String.raw`(?<![\w$.])${esc2(handler)}(?![\w$])`, "g");
6067
+ for (const u of m.slice(bStart, bEnd).matchAll(hRe)) {
6068
+ const after = m.slice(bStart + (u.index ?? 0) + handler.length);
6069
+ if (!/^\s*\(/.test(after)) return `the handler \`${handler}\` is used other than as a call`;
6070
+ }
6071
+ return void 0;
6072
+ }
5937
6073
  var PRIMITIVE_TYPE = /^(?:(?:string|number|boolean|bigint|symbol|null|undefined|"[^"]*"|'[^']*'|\d+)\s*\|?\s*)+$/;
5938
6074
  function enclosingOpens(m, at, lo) {
5939
6075
  const out = [];
@@ -5965,7 +6101,7 @@ function untouchedParams(s, params, names, bStart, bEnd, fwdOpen, fwdClose) {
5965
6101
  const decl = params[k].replace(/^\.\.\.\s*/, "");
5966
6102
  const typed = /^[A-Za-z_$][\w$]*\s*\??\s*:\s*([^=]*?)\s*(?:=(?![=>]).*)?$/s.exec(decl);
5967
6103
  const primitive = typed !== void 0 && typed !== null && PRIMITIVE_TYPE.test(typed[1]);
5968
- const re = new RegExp(String.raw`(?<![\w$.])${esc(id)}(?![\w$])`, "g");
6104
+ const re = new RegExp(String.raw`(?<![\w$.])${esc2(id)}(?![\w$])`, "g");
5969
6105
  for (const o of m.slice(bStart, bEnd).matchAll(re)) {
5970
6106
  const i = bStart + (o.index ?? 0);
5971
6107
  if (i >= fwdOpen && i <= fwdClose) continue;
@@ -6011,6 +6147,8 @@ function toolRegistrations(tree) {
6011
6147
  const schema = s.shape.slice(c.args[0][0], c.args[0][1]).trim();
6012
6148
  if (/^(?:[\w$]+\.)*[\w$]*RequestSchema$/.test(schema) && !/CallToolRequestSchema$/.test(schema))
6013
6149
  continue;
6150
+ const listed = enclosingLoopList(s.shape, s.code, c.args[0][0], schema, methodArgumentRead);
6151
+ if (listed !== void 0 && !listed.includes("tools/call")) continue;
6014
6152
  if (!/CallToolRequestSchema$/.test(schema)) {
6015
6153
  unread2.push({
6016
6154
  anchor: c.anchor,
@@ -6053,7 +6191,7 @@ function toolRegistrations(tree) {
6053
6191
  const hits = [];
6054
6192
  for (const h of s.shape.matchAll(
6055
6193
  new RegExp(
6056
- String.raw`(?<![\w$])${esc(name)}\s*(?:\.\s*(tool|registerTool|registerToolTask)\b(?!\s*(?:<[^<>()]*>)?\s*\()|\[)`,
6194
+ String.raw`(?<![\w$])${esc2(name)}\s*(?:\.\s*(tool|registerTool|registerToolTask)\b(?!\s*(?:<[^<>()]*>)?\s*\()|\[)`,
6057
6195
  "g"
6058
6196
  )
6059
6197
  )) {
@@ -6072,8 +6210,9 @@ function toolRegistrations(tree) {
6072
6210
  for (const method of new Set(live.map((h) => h.method).filter((m) => !!m))) {
6073
6211
  const mine = live.filter((h) => h.method === method);
6074
6212
  const proof = regs.length === 0 ? "no tool is registered by a direct call anywhere in the tree" : wrapperProof(s, name, mine);
6075
- if (proof === void 0) transparent.add(method);
6076
- else why.set(method, proof);
6213
+ const decorated = proof === void 0 || regs.length === 0 ? proof : decoratorProof(s, name, mine);
6214
+ if (proof === void 0 || decorated === void 0) transparent.add(method);
6215
+ else why.set(method, `${proof}; not a decorator either: ${decorated}`);
6077
6216
  }
6078
6217
  for (const h of live) {
6079
6218
  if (h.method !== void 0 && transparent.has(h.method)) continue;
@@ -6547,7 +6686,7 @@ function recursiveGroups(s) {
6547
6686
  const fns = namedFns(s);
6548
6687
  const refs = (f, g) => {
6549
6688
  const body = s.shape.slice(f.from, f.to);
6550
- return new RegExp(String.raw`(?<![\w$.])(?:this\s*\.\s*)?${esc(g.name)}(?![\w$])`).test(body) || new RegExp(String.raw`(?:\.|\?\.)\s*${esc(g.name)}\s*(?:<[^<>()]*>)?\(`).test(body);
6689
+ return new RegExp(String.raw`(?<![\w$.])(?:this\s*\.\s*)?${esc2(g.name)}(?![\w$])`).test(body) || new RegExp(String.raw`(?:\.|\?\.)\s*${esc2(g.name)}\s*(?:<[^<>()]*>)?\(`).test(body);
6551
6690
  };
6552
6691
  const n = fns.length;
6553
6692
  const reach = fns.map((f) => fns.map((g) => refs(f, g)));
@@ -6639,7 +6778,7 @@ function unresolvedCalls(tree, s, from, to, self, skip, upstream) {
6639
6778
  for (const m of s.shape.matchAll(/\bclass\s+([A-Za-z_$][\w$]*)/g)) local.add(m[1]);
6640
6779
  const binds = new Map(importBindings(s).map((b) => [b.local, b]));
6641
6780
  const inSkip = (at) => skip.some((g) => at >= g.from && at <= g.to);
6642
- const selfRe = self ? new RegExp(String.raw`(?<![\w$])${esc(self)}(?![\w$])`) : void 0;
6781
+ const selfRe = self ? new RegExp(String.raw`(?<![\w$])${esc2(self)}(?![\w$])`) : void 0;
6643
6782
  const crossFile = (module, name) => {
6644
6783
  const base = module.replace(/\.(?:js|ts|tsx|mjs)$/, "").split("/").pop() ?? "";
6645
6784
  for (const d of srcs(tree)) {
@@ -6658,7 +6797,7 @@ function unresolvedCalls(tree, s, from, to, self, skip, upstream) {
6658
6797
  if (b !== void 0) return !b.module.startsWith(".");
6659
6798
  if (depth > 4 || local.has(root)) return false;
6660
6799
  const init = new RegExp(
6661
- String.raw`(?:const|let|var)\s+${esc(root)}\s*(?::[^=]+?)?=\s*(?:await\s+)?(?:new\s+)?([A-Za-z_$][\w$]*)`
6800
+ String.raw`(?:const|let|var)\s+${esc2(root)}\s*(?::[^=]+?)?=\s*(?:await\s+)?(?:new\s+)?([A-Za-z_$][\w$]*)`
6662
6801
  ).exec(s.shape);
6663
6802
  return init !== null && init[1] !== root && external(init[1], depth + 1);
6664
6803
  };
@@ -6785,7 +6924,7 @@ function requestingFunctions(tree) {
6785
6924
  for (let round = 0; round < 6; round++) {
6786
6925
  let grew = false;
6787
6926
  for (const n of [...names.keys()]) {
6788
- for (const c of callsMatching(tree, new RegExp(String.raw`^(?:[\w$]+\.)*${esc(n)}$`))) {
6927
+ for (const c of callsMatching(tree, new RegExp(String.raw`^(?:[\w$]+\.)*${esc2(n)}$`))) {
6789
6928
  if (!callReaches(c.src, c.callee, n, names.get(n))) continue;
6790
6929
  for (const f of enclosingFns(c.src, c.start)) if (f.name && add(f.name, c.src)) grew = true;
6791
6930
  }
@@ -6798,7 +6937,7 @@ function callReaches(s, callee, name, defs) {
6798
6937
  if (callee.includes(".")) return true;
6799
6938
  if (defs.has(s)) return true;
6800
6939
  for (const h of s.code.matchAll(/import\s*(?:type\s*)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/g)) {
6801
- if (!new RegExp(String.raw`(?<![\w$])${esc(name)}(?![\w$])`).test(h[1])) continue;
6940
+ if (!new RegExp(String.raw`(?<![\w$])${esc2(name)}(?![\w$])`).test(h[1])) continue;
6802
6941
  const base = h[2].replace(/\.(?:js|ts|tsx|mjs)$/, "").split("/").pop() ?? "";
6803
6942
  for (const d of defs)
6804
6943
  if ((d.rel.replace(/\.(?:js|ts|tsx|mjs)$/, "").split("/").pop() ?? "") === base)
@@ -6811,7 +6950,7 @@ function callsRequester(tree, s, from, to) {
6811
6950
  const text = s.shape.slice(from, to);
6812
6951
  for (const [n, defs] of reqs) {
6813
6952
  for (const h of text.matchAll(
6814
- new RegExp(String.raw`(?<![\w$])((?:[\w$]+\s*\.\s*)*)${esc(n)}\s*\(`, "g")
6953
+ new RegExp(String.raw`(?<![\w$])((?:[\w$]+\s*\.\s*)*)${esc2(n)}\s*\(`, "g")
6815
6954
  )) {
6816
6955
  if (callReaches(s, h[1] ? `${h[1]}${n}`.replace(/\s+/g, "") : n, n, defs)) return true;
6817
6956
  }
@@ -6819,7 +6958,7 @@ function callsRequester(tree, s, from, to) {
6819
6958
  return false;
6820
6959
  }
6821
6960
  function bodyOfNamed(s, name) {
6822
- const n = esc(name);
6961
+ const n = esc2(name);
6823
6962
  const re = new RegExp(
6824
6963
  String.raw`(?:\bfunction\s*\*?\s*${n}\s*\(|(?:const|let|var)\s+${n}\s*(?::[^=]+)?=\s*(?:async\s*)?(?:function\s*)?\(|(?:^|[\n;{},])\s*(?:async\s+)?${n}\s*\()`
6825
6964
  );
@@ -7988,7 +8127,12 @@ function evalShape(n, ctx) {
7988
8127
  props.push({ label: "[computed]", schema: unread(e.form, e.s), at: e.s });
7989
8128
  }
7990
8129
  }
7991
- return { k: "object", props, at: n.s };
8130
+ return {
8131
+ k: "object",
8132
+ props,
8133
+ at: n.s,
8134
+ closed: { form: "raw shape (wrapped in z.object)", at: n.s }
8135
+ };
7992
8136
  }
7993
8137
  function unionArgs(arg, ctx, at) {
7994
8138
  let a = arg;
@@ -8041,7 +8185,7 @@ function zodFactory(m, n, ctx) {
8041
8185
  const a = n.args;
8042
8186
  if (SCALAR_FACTORIES.has(m)) return SCALAR;
8043
8187
  if (ANY_FACTORIES.has(m)) return { k: "any" };
8044
- if (NULL_FACTORIES.has(m)) return { k: "null" };
8188
+ if (NULL_FACTORIES.has(m)) return m === "never" ? { k: "null", never: true } : { k: "null" };
8045
8189
  switch (m) {
8046
8190
  case "array":
8047
8191
  case "set":
@@ -8052,8 +8196,11 @@ function zodFactory(m, n, ctx) {
8052
8196
  }
8053
8197
  case "object":
8054
8198
  case "strictObject":
8055
- case "looseObject":
8056
- return a[0] ? evalZod(a[0], ctx) : { k: "object", props: [], at: n.s };
8199
+ case "looseObject": {
8200
+ const base = a[0] ? evalZod(a[0], ctx) : { k: "object", props: [], at: n.s };
8201
+ if (base.k !== "object") return base;
8202
+ return m === "looseObject" ? { ...base, closed: void 0 } : { ...base, closed: { form: `z.${m}(...)`, at: n.s } };
8203
+ }
8057
8204
  case "record":
8058
8205
  case "partialRecord":
8059
8206
  case "looseRecord":
@@ -8099,6 +8246,17 @@ function zodFactory(m, n, ctx) {
8099
8246
  }
8100
8247
  function zodMethod(base, m, n, ctx) {
8101
8248
  if (base.k === "unread") return base;
8249
+ if (base.k === "object" && (m === "strict" || m === "strip"))
8250
+ return { ...base, closed: { form: `.${m}()`, at: n.s } };
8251
+ if (base.k === "object" && ["passthrough", "loose", "nonstrict"].includes(m))
8252
+ return { ...base, closed: void 0 };
8253
+ if (base.k === "object" && m === "catchall") {
8254
+ const extra = n.args[0] ? evalZod(n.args[0], ctx) : unread(".catchall() with no argument", n.s);
8255
+ if (extra.k === "unread") return unread(`.catchall(...): ${extra.form}`, extra.at ?? n.s);
8256
+ if (extra.k === "null" && extra.never)
8257
+ return { ...base, closed: { form: ".catchall(z.never())", at: n.s } };
8258
+ return { ...base, closed: void 0 };
8259
+ }
8102
8260
  if (IDENTITY_METHODS.has(m)) return base;
8103
8261
  const a = n.args;
8104
8262
  switch (m) {
@@ -8246,7 +8404,8 @@ function jsonToS(v, root, seen, depth = 0) {
8246
8404
  if (isObj(v.patternProperties))
8247
8405
  for (const s of Object.values(v.patternProperties))
8248
8406
  props.push({ label: "*", schema: sub(s), at });
8249
- return { k: "object", props, at };
8407
+ const closer = ["additionalProperties", "unevaluatedProperties"].find((kw) => v[kw] === false);
8408
+ return closer ? { k: "object", props, at, closed: { form: `${closer}: false`, at } } : { k: "object", props, at };
8250
8409
  };
8251
8410
  const type = v.type;
8252
8411
  if (Array.isArray(type)) {
@@ -8346,14 +8505,16 @@ function isJsonLiteral(n) {
8346
8505
  function schemaValue(n) {
8347
8506
  return isJsonLiteral(n) ? { kind: "json", node: n } : { kind: "zod", node: n };
8348
8507
  }
8349
- function fromConfig(obj, ctx) {
8508
+ function fromConfig(obj, ctx, key = "inputSchema") {
8350
8509
  const props = obj.entries.filter((e) => e.kind === "prop");
8351
- const input = props.find((e) => e.key === "inputSchema");
8510
+ const input = props.find((e) => e.key === key);
8352
8511
  if (input) return schemaValue(input.value);
8353
8512
  const literalValued = (e) => isStringish(e.value, ctx) || e.value.k === "lit" && typeof e.value.v !== "string";
8354
8513
  if (props.some((e) => (e.key === "description" || e.key === "title") && isStringish(e.value, ctx)))
8355
8514
  return { kind: "none" };
8356
- if (props.some((e) => e.key === "outputSchema" || e.key === "annotations" || e.key === "_meta"))
8515
+ if (props.some(
8516
+ (e) => e.key === "inputSchema" || e.key === "outputSchema" || e.key === "annotations" || e.key === "_meta"
8517
+ ))
8357
8518
  return { kind: "none" };
8358
8519
  if (props.length > 0 && props.every((e) => ANNOTATION_KEYS.has(e.key) && literalValued(e)))
8359
8520
  return { kind: "none" };
@@ -8368,7 +8529,7 @@ function isStringish(n, ctx) {
8368
8529
  }
8369
8530
  return false;
8370
8531
  }
8371
- function locateSchema(file, toolName, anchorLine) {
8532
+ function locateSchema(file, toolName, anchorLine, key = "inputSchema") {
8372
8533
  const lx = lex(file);
8373
8534
  const ctx = moduleCtx(file, null);
8374
8535
  const lineStart = lx.base + (lx.lineStarts[anchorLine - 1] ?? 0);
@@ -8434,7 +8595,7 @@ function locateSchema(file, toolName, anchorLine) {
8434
8595
  if (open.v === "{") {
8435
8596
  const obj = new Parser(lx, openIdx).parseExpr();
8436
8597
  if (obj.k !== "obj") return { kind: "unread", form: `descriptor of ${toolName}`, at: open.s };
8437
- const input = obj.entries.find((e) => e.kind === "prop" && e.key === "inputSchema");
8598
+ const input = obj.entries.find((e) => e.kind === "prop" && e.key === key);
8438
8599
  return input && input.kind === "prop" ? schemaValue(input.value) : { kind: "none" };
8439
8600
  }
8440
8601
  if (open.v !== "(")
@@ -8447,6 +8608,7 @@ function locateSchema(file, toolName, anchorLine) {
8447
8608
  form: `registration of ${toolName}: name argument not at top level`,
8448
8609
  at: open.s
8449
8610
  };
8611
+ if (key === "outputSchema") return outputOf(args.slice(k + 1), ctx, lx, openIdx, toolName);
8450
8612
  for (const a of args.slice(k + 1)) {
8451
8613
  if (a.k === "fn") return { kind: "none" };
8452
8614
  if (isStringish(a, ctx)) continue;
@@ -8457,11 +8619,34 @@ function locateSchema(file, toolName, anchorLine) {
8457
8619
  else if (d && d.length === 1 && d[0].k === "fn") return { kind: "none" };
8458
8620
  }
8459
8621
  if (node.k === "obj") {
8460
- const cfg = fromConfig(node, ctx);
8622
+ const cfg = fromConfig(node, ctx, key);
8461
8623
  if (cfg) return cfg;
8462
- return schemaValue(node);
8624
+ return key === "inputSchema" ? schemaValue(node) : { kind: "none" };
8463
8625
  }
8464
- return { kind: "zod", node: a };
8626
+ return key === "inputSchema" ? { kind: "zod", node: a } : { kind: "none" };
8627
+ }
8628
+ return { kind: "none" };
8629
+ }
8630
+ function outputOf(args, ctx, lx, openIdx, toolName) {
8631
+ for (const a of args) {
8632
+ let node = a;
8633
+ if (node.k === "id") {
8634
+ const d = ctx.b.decls.get(node.name);
8635
+ if (d && d.length === 1 && d[0].k === "obj") node = d[0];
8636
+ }
8637
+ if (node.k !== "obj") continue;
8638
+ const out = node.entries.find((e) => e.kind === "prop" && e.key === "outputSchema");
8639
+ if (out && out.kind === "prop") return schemaValue(out.value);
8640
+ }
8641
+ const end = new Parser(lx, openIdx).skipGroup(openIdx);
8642
+ for (let j = openIdx; j < end; j++) {
8643
+ const t = lx.toks[j];
8644
+ if (t.t === "id" && t.v === "outputSchema")
8645
+ return {
8646
+ kind: "unread",
8647
+ form: `registration of ${toolName}: outputSchema is named at a position the reader does not take it from`,
8648
+ at: t.s
8649
+ };
8465
8650
  }
8466
8651
  return { kind: "none" };
8467
8652
  }
@@ -8859,6 +9044,93 @@ var s43UnionInput = {
8859
9044
  run: runStatic,
8860
9045
  runServed: (runtime) => runServedHalf(runtime)
8861
9046
  };
9047
+ function walkClosed(s, path, out) {
9048
+ switch (s.k) {
9049
+ case "object":
9050
+ if (s.closed)
9051
+ out.push({ path, kind: "violation", form: s.closed.form, at: s.closed.at ?? s.at });
9052
+ for (const p of s.props) walkClosed(p.schema, `${path}.${p.label}`, out);
9053
+ return;
9054
+ case "union":
9055
+ for (const b of flatten(s.branches)) walkClosed(b, path, out);
9056
+ return;
9057
+ case "array":
9058
+ if (s.items) walkClosed(s.items, `${path}[]`, out);
9059
+ s.prefix.forEach((p, i) => walkClosed(p, `${path}[${i}]`, out));
9060
+ return;
9061
+ case "all":
9062
+ for (const p of s.parts) walkClosed(p, path, out);
9063
+ return;
9064
+ case "unread":
9065
+ out.push({ path, kind: "unread", form: s.form, at: s.at });
9066
+ return;
9067
+ default:
9068
+ return;
9069
+ }
9070
+ }
9071
+ var CLOSED_MARKER_RE = /\/\/\s*allow-closed-output:\s*(.*)$/;
9072
+ function closedExemption(off) {
9073
+ const at = off === void 0 ? null : locate(off);
9074
+ if (!at) return void 0;
9075
+ const lx = lex(at.file);
9076
+ for (const ln of [at.line, at.line - 1]) {
9077
+ const m = lx.comments.get(ln)?.match(CLOSED_MARKER_RE);
9078
+ if (m && m[1].trim().length >= MIN_REASON) return m[1].trim();
9079
+ }
9080
+ return void 0;
9081
+ }
9082
+ function closedOutputSites(tree, toolName, anchor) {
9083
+ const cut = anchor.lastIndexOf(":");
9084
+ const file = tree.files.find((f) => f.rel === anchor.slice(0, cut));
9085
+ if (!file)
9086
+ return {
9087
+ kind: "read",
9088
+ sites: [
9089
+ {
9090
+ path: toolName,
9091
+ kind: "unread",
9092
+ form: "registration file not in the scanned tree",
9093
+ anchor
9094
+ }
9095
+ ]
9096
+ };
9097
+ const located = locateSchema(file, toolName, Number(anchor.slice(cut + 1)), "outputSchema");
9098
+ if (located.kind === "none") return { kind: "none" };
9099
+ const where = (off) => {
9100
+ const at = off === void 0 ? null : locate(off);
9101
+ return at ? `${at.file.rel}:${at.line}` : anchor;
9102
+ };
9103
+ if (located.kind === "unread")
9104
+ return {
9105
+ kind: "read",
9106
+ sites: [{ path: toolName, kind: "unread", form: located.form, anchor: where(located.at) }]
9107
+ };
9108
+ const ctx = moduleCtx(file, tree);
9109
+ const schema = located.kind === "json" ? jsonSchemaOf(located.node, ctx) : evalZod(located.node, ctx);
9110
+ const raw = [];
9111
+ walkClosed(schema, toolName, raw);
9112
+ const seen = /* @__PURE__ */ new Set();
9113
+ const sites = [];
9114
+ for (const r of raw) {
9115
+ const key = `${r.kind}|${r.path}|${r.form}`;
9116
+ if (seen.has(key)) continue;
9117
+ seen.add(key);
9118
+ const exempt = r.kind === "violation" ? closedExemption(r.at) : void 0;
9119
+ sites.push({
9120
+ path: r.path,
9121
+ kind: r.kind,
9122
+ form: r.form,
9123
+ anchor: where(r.at),
9124
+ ...exempt ? { exempt } : {}
9125
+ });
9126
+ }
9127
+ return { kind: "read", sites };
9128
+ }
9129
+ function closedServedSites(schema, toolName, anchor) {
9130
+ const raw = [];
9131
+ walkClosed(jsonToS(schema, { root: schema }, /* @__PURE__ */ new Set()), toolName, raw);
9132
+ return raw.map((r) => ({ path: r.path, kind: r.kind, form: r.form, anchor }));
9133
+ }
8862
9134
 
8863
9135
  // src/detectors/c11-pagination.ts
8864
9136
  var PIN2 = STANDARD_PIN;
@@ -9891,8 +10163,8 @@ var RECORD_LINE_RE = /^[\s>*_\-+]*Provenance\s*:\s*(.*)$/i;
9891
10163
  var SHASUM_HEX_RE = /\bshasum\b[^\n]*?\b([0-9a-f]{40})\b/i;
9892
10164
  function judgeProvenanceRecord(line, name, version) {
9893
10165
  const body = line.match(RECORD_LINE_RE)?.[1] ?? "";
9894
- const esc4 = (x) => x.replace(/[.+*?^$()[\]{}|\\/]/g, "\\$&");
9895
- const named = new RegExp(`(?:^|[\\s(])${esc4(name)}@v?${esc4(version)}(?![\\w.-]*\\d)`);
10166
+ const esc5 = (x) => x.replace(/[.+*?^$()[\]{}|\\/]/g, "\\$&");
10167
+ const named = new RegExp(`(?:^|[\\s(])${esc5(name)}@v?${esc5(version)}(?![\\w.-]*\\d)`);
9896
10168
  if (!named.test(body)) {
9897
10169
  return { ok: false, why: `it does not name ${name}@${version}, the artifact being published` };
9898
10170
  }
@@ -10353,6 +10625,94 @@ function runtimeSourceRoot(runtime) {
10353
10625
  return runtime.remote ? runtime.sourceRoot : runtime.root;
10354
10626
  }
10355
10627
 
10628
+ // src/detectors/i18nKeys.ts
10629
+ import { existsSync as existsSync7, readFileSync as readFileSync8 } from "fs";
10630
+ import { dirname as dirname4, join as join8, resolve as resolve2 } from "path";
10631
+ var CALL_RE = /^([A-Za-z_$][\w$]*)\(\s*(["'`])([A-Za-z-]+)\2\s*,\s*(["'`])([\w.-]+)\4\s*(?:,[\s\S]*)?\)$/;
10632
+ function leadingCall(expr) {
10633
+ const head = expr.match(/^[A-Za-z_$][\w$]*\(/);
10634
+ if (!head) return null;
10635
+ let depth = 0;
10636
+ let quote = null;
10637
+ for (let i = head[0].length - 1; i < expr.length; i++) {
10638
+ const c = expr[i];
10639
+ if (quote) {
10640
+ if (c === "\\") i++;
10641
+ else if (c === quote) quote = null;
10642
+ continue;
10643
+ }
10644
+ if (c === '"' || c === "'" || c === "`") quote = c;
10645
+ else if (c === "(") depth++;
10646
+ else if (c === ")" && --depth === 0) return expr.slice(0, i + 1);
10647
+ }
10648
+ return null;
10649
+ }
10650
+ var LOCALES_PATH_RE = /locales\/(?:\$\{[^}]+\}|[A-Za-z-]+)\.json/;
10651
+ function importedModule(file, fn) {
10652
+ const text = file.lines.map((l) => l.raw).join("\n");
10653
+ const re = /import\s*\{([^}]*)\}\s*from\s*["'](\.{1,2}\/[^"']+)["']/g;
10654
+ for (const m of text.matchAll(re)) {
10655
+ const names = m[1].split(",").map((s) => s.trim().replace(/^type\s+/, ""));
10656
+ const local = names.map(
10657
+ (n) => n.split(/\s+as\s+/).pop()?.trim()
10658
+ );
10659
+ if (!local.includes(fn)) continue;
10660
+ const spec = m[2];
10661
+ const base = resolve2(dirname4(file.path), spec);
10662
+ for (const candidate of [
10663
+ base.replace(/\.js$/, ".ts"),
10664
+ base,
10665
+ `${base}.ts`,
10666
+ join8(base, "index.ts")
10667
+ ]) {
10668
+ if (existsSync7(candidate) && !candidate.endsWith("/")) return candidate;
10669
+ }
10670
+ return null;
10671
+ }
10672
+ return null;
10673
+ }
10674
+ function readI18nCall(tree, file, expr) {
10675
+ const call = leadingCall(expr.trim());
10676
+ const m = call?.match(CALL_RE);
10677
+ if (!m) return null;
10678
+ const [, fn, , locale, , key] = m;
10679
+ const mod = importedModule(file, fn);
10680
+ if (mod === null)
10681
+ return {
10682
+ kind: "unresolved",
10683
+ why: `\`${fn}\` is not imported from a relative module of the tree`
10684
+ };
10685
+ let modText;
10686
+ try {
10687
+ modText = readFileSync8(mod, "utf8");
10688
+ } catch {
10689
+ return { kind: "unresolved", why: `the module of \`${fn}\` (${mod}) is unreadable` };
10690
+ }
10691
+ if (!LOCALES_PATH_RE.test(modText))
10692
+ return {
10693
+ kind: "unresolved",
10694
+ why: `the module of \`${fn}\` names no \`locales/<locale>.json\` resource path`
10695
+ };
10696
+ const jsonPath = join8(dirname4(mod), "locales", `${locale}.json`);
10697
+ const shown = jsonPath.startsWith(tree.root) ? jsonPath.slice(tree.root.length + 1) : jsonPath;
10698
+ let data;
10699
+ try {
10700
+ data = JSON.parse(readFileSync8(jsonPath, "utf8"));
10701
+ } catch {
10702
+ return { kind: "unresolved", why: `${shown} is missing or not JSON` };
10703
+ }
10704
+ let node = data;
10705
+ for (const part of key.split(".")) {
10706
+ node = node && typeof node === "object" ? node[part] : void 0;
10707
+ }
10708
+ if (typeof node !== "string" || node.trim().length === 0)
10709
+ return {
10710
+ kind: "unresolved",
10711
+ why: `key \`${key}\` does not resolve to a non-empty string in ${shown}`
10712
+ };
10713
+ return { kind: "text", text: node, source: `${shown}#${key}`, locale };
10714
+ }
10715
+
10356
10716
  // src/detectors/c19-served-descriptions.ts
10357
10717
  var PIN6 = STANDARD_PIN;
10358
10718
  var TOOL_DESC_INLINE_RE = /\b(?:s\.tool|\.tool|registerTool)\s*\(\s*(?:["'`][^"'`]+["'`]|[A-Za-z_$][\w$]*)\s*,\s*["'`]([^"'`]+)["'`]/;
@@ -10393,7 +10753,12 @@ function findInlineDescription(tree, siteAnchor, toolName) {
10393
10753
  const v = readDescriptionValue(`${after}
10394
10754
  ${tail}`);
10395
10755
  if (v.kind === "literal" && v.text.length > 0) return v.text;
10396
- if (v.kind === "non-literal" && !nonLiteral) nonLiteral = v;
10756
+ if (v.kind === "non-literal") {
10757
+ const i18n = readI18nCall(tree, file, v.expr);
10758
+ if (i18n?.kind === "text") return i18n.text;
10759
+ const marked = i18n?.kind === "unresolved" ? { ...v, expr: `${v.expr} (${i18n.why})` } : v;
10760
+ if (!nonLiteral) nonLiteral = marked;
10761
+ }
10397
10762
  continue;
10398
10763
  }
10399
10764
  if (n >= siteLine) {
@@ -10743,8 +11108,8 @@ var c21ProgressiveDisclosure = {
10743
11108
  };
10744
11109
 
10745
11110
  // src/detectors/c22-test-ratio-gate.ts
10746
- import { existsSync as existsSync7, readFileSync as readFileSync8, statSync as statSync9 } from "fs";
10747
- import { join as join8 } from "path";
11111
+ import { existsSync as existsSync8, readFileSync as readFileSync9, statSync as statSync9 } from "fs";
11112
+ import { join as join9 } from "path";
10748
11113
  var DOC_FILES2 = ["README.md", "README.fr.md", "CHANGELOG.md"];
10749
11114
  var RATIO_RE = /\b(?:coverage|ratio de tests?|test ratio|couverture)\b[^\n%]{0,40}?(\d{1,3}(?:\.\d+)?\s?%)/i;
10750
11115
  var IDENTIFIER_RE = /\b(?:run[/#]?\s?\d+|workflow run|gh run|actions\/runs\/\d+|CI#\d+|\b[0-9a-f]{7,40}\b)/i;
@@ -10769,15 +11134,15 @@ function c22PositiveControls() {
10769
11134
  function findRatioCitations(root, unreadable) {
10770
11135
  const hits = [];
10771
11136
  for (const name of DOC_FILES2) {
10772
- const path = join8(root, name);
10773
- if (!existsSync7(path)) continue;
11137
+ const path = join9(root, name);
11138
+ if (!existsSync8(path)) continue;
10774
11139
  let text;
10775
11140
  try {
10776
11141
  if (!statSync9(path).isFile()) {
10777
11142
  unreadable.push({ anchor: name, reason: `${name} is not a regular file \u2014 not read` });
10778
11143
  continue;
10779
11144
  }
10780
- text = readFileSync8(path, "utf8");
11145
+ text = readFileSync9(path, "utf8");
10781
11146
  } catch (err) {
10782
11147
  unreadable.push({ anchor: name, reason: `${name} could not be read (${fsErrorCode(err)})` });
10783
11148
  continue;
@@ -11335,16 +11700,16 @@ var c25BuildIdentity = {
11335
11700
  // src/detectors/c26-subpackage-lockfile.ts
11336
11701
  import { spawnSync } from "child_process";
11337
11702
  import {
11338
- existsSync as existsSync8,
11703
+ existsSync as existsSync9,
11339
11704
  mkdtempSync,
11340
- readFileSync as readFileSync9,
11705
+ readFileSync as readFileSync10,
11341
11706
  readdirSync as readdirSync6,
11342
11707
  rmSync,
11343
11708
  statSync as statSync10,
11344
11709
  writeFileSync
11345
11710
  } from "fs";
11346
11711
  import { tmpdir } from "os";
11347
- import { basename as basename2, join as join9, relative as relative5, sep as sep4 } from "path";
11712
+ import { basename as basename2, join as join10, relative as relative5, sep as sep4 } from "path";
11348
11713
  var PIN9 = STANDARD_PIN;
11349
11714
  var DEPLOY_CONFIG_FILES = [
11350
11715
  "railway.json",
@@ -11371,7 +11736,7 @@ function walkForConfigs(dir, depth, seen, onSkip) {
11371
11736
  return;
11372
11737
  }
11373
11738
  for (const name of entries) {
11374
- const full = join9(dir, name);
11739
+ const full = join10(dir, name);
11375
11740
  let st;
11376
11741
  try {
11377
11742
  st = statSync10(full);
@@ -11406,7 +11771,7 @@ function probeForCandidate(dir, depth) {
11406
11771
  }
11407
11772
  const subdirs = [];
11408
11773
  for (const name of entries) {
11409
- const full = join9(dir, name);
11774
+ const full = join10(dir, name);
11410
11775
  let st;
11411
11776
  try {
11412
11777
  st = statSync10(full);
@@ -11430,7 +11795,7 @@ function probeForCandidate(dir, depth) {
11430
11795
  function resolveRailwayRootDirectory(configPath) {
11431
11796
  let text;
11432
11797
  try {
11433
- text = readFileSync9(configPath, "utf8");
11798
+ text = readFileSync10(configPath, "utf8");
11434
11799
  } catch (err) {
11435
11800
  return {
11436
11801
  error: `could not read ${configPath}: ${err instanceof Error ? err.message : String(err)}`
@@ -11475,13 +11840,13 @@ function c26DeriveScope(root, tree) {
11475
11840
  };
11476
11841
  }
11477
11842
  if (typeof resolved === "string" && resolved.trim()) {
11478
- sites.push({ ...site, dir: join9(site.dir, resolved) });
11843
+ sites.push({ ...site, dir: join10(site.dir, resolved) });
11479
11844
  continue;
11480
11845
  }
11481
11846
  }
11482
11847
  if (site.configFile === "vercel.json") {
11483
11848
  try {
11484
- JSON.parse(readFileSync9(site.configPath, "utf8"));
11849
+ JSON.parse(readFileSync10(site.configPath, "utf8"));
11485
11850
  } catch (err) {
11486
11851
  return {
11487
11852
  sites: [],
@@ -11499,7 +11864,7 @@ function c26DeriveScope(root, tree) {
11499
11864
  }
11500
11865
  function findLockfile2(dir) {
11501
11866
  for (const l of LOCKFILES2) {
11502
- if (existsSync8(join9(dir, l.name))) return l;
11867
+ if (existsSync9(join10(dir, l.name))) return l;
11503
11868
  }
11504
11869
  return null;
11505
11870
  }
@@ -11550,8 +11915,8 @@ function nameDrift(lockfileName, siteDir, isolatedDir, stderr) {
11550
11915
  }
11551
11916
  if (lockfileName === "bun.lock" || lockfileName === "bun.lockb") {
11552
11917
  try {
11553
- const manifestText = readFileSync9(join9(isolatedDir, "package.json"), "utf8");
11554
- const lockText = readFileSync9(join9(isolatedDir, lockfileName), "utf8");
11918
+ const manifestText = readFileSync10(join10(isolatedDir, "package.json"), "utf8");
11919
+ const lockText = readFileSync10(join10(isolatedDir, lockfileName), "utf8");
11555
11920
  const drifted = nameBunDrift(manifestText, lockText);
11556
11921
  if (drifted.length > 0) return drifted.join(", ");
11557
11922
  } catch {
@@ -11563,8 +11928,8 @@ function nameDrift(lockfileName, siteDir, isolatedDir, stderr) {
11563
11928
  return `dependency name not statically extractable from this manager's output at ${siteDir} \u2014 raw: ${stderr.slice(0, 300).trim()}`;
11564
11929
  }
11565
11930
  function gateSite(site) {
11566
- const pkgPath = join9(site.dir, "package.json");
11567
- if (!existsSync8(pkgPath)) {
11931
+ const pkgPath = join10(site.dir, "package.json");
11932
+ if (!existsSync9(pkgPath)) {
11568
11933
  return {
11569
11934
  site,
11570
11935
  status: "skipped",
@@ -11580,17 +11945,17 @@ function gateSite(site) {
11580
11945
  detail: `no lockfile (${LOCKFILES2.map((l) => l.name).join("/")}) present at ${site.dir} while its deployment (${site.configFile}) requires one`
11581
11946
  };
11582
11947
  }
11583
- const isolated = mkdtempSync(join9(tmpdir(), "mcp-doctor-c26-"));
11948
+ const isolated = mkdtempSync(join10(tmpdir(), "mcp-doctor-c26-"));
11584
11949
  try {
11585
11950
  let manifestText;
11586
11951
  let lockText;
11587
- const lockPath = join9(site.dir, lock.name);
11952
+ const lockPath = join10(site.dir, lock.name);
11588
11953
  try {
11589
11954
  for (const p of [pkgPath, lockPath]) {
11590
11955
  if (!statSync10(p).isFile()) throw new Error(`${p} is not a regular file`);
11591
11956
  }
11592
- manifestText = readFileSync9(pkgPath, "utf8");
11593
- lockText = readFileSync9(lockPath, "utf8");
11957
+ manifestText = readFileSync10(pkgPath, "utf8");
11958
+ lockText = readFileSync10(lockPath, "utf8");
11594
11959
  } catch (err) {
11595
11960
  return {
11596
11961
  site,
@@ -11598,8 +11963,8 @@ function gateSite(site) {
11598
11963
  reason: `${site.dir}: package.json or ${lock.name} is present but cannot be read (${err instanceof Error ? err.message : String(err)}) \u2014 the frozen install was not run`
11599
11964
  };
11600
11965
  }
11601
- writeFileSync(join9(isolated, "package.json"), manifestText);
11602
- writeFileSync(join9(isolated, lock.name), lockText);
11966
+ writeFileSync(join10(isolated, "package.json"), manifestText);
11967
+ writeFileSync(join10(isolated, lock.name), lockText);
11603
11968
  let proc;
11604
11969
  try {
11605
11970
  proc = spawnSync(lock.command, lock.args, {
@@ -11673,7 +12038,7 @@ var c26SubpackageLockfile = {
11673
12038
  const reason = `${prefix}deployment configuration found only under skipped director${hidden.length === 1 ? "y" : "ies"}: ${hidden.map((d) => `${d.path} (${d.reason}) -> ${d.candidate}`).join("; ")} \u2014 C-26 does not descend into skipped directories, so these site(s) were not judged`;
11674
12039
  return {
11675
12040
  id: this.id,
11676
- anchor: join9(tree.root, hidden[0].candidate),
12041
+ anchor: join10(tree.root, hidden[0].candidate),
11677
12042
  state: "could-not-judge",
11678
12043
  reason,
11679
12044
  verdict: `could not judge: ${reason}`
@@ -11745,8 +12110,8 @@ var c26SubpackageLockfile = {
11745
12110
  };
11746
12111
 
11747
12112
  // src/detectors/c27-subpackage-types.ts
11748
- import { existsSync as existsSync9, readdirSync as readdirSync7 } from "fs";
11749
- import { join as join10, relative as relative6 } from "path";
12113
+ import { existsSync as existsSync10, readdirSync as readdirSync7 } from "fs";
12114
+ import { join as join11, relative as relative6 } from "path";
11750
12115
  var TSCONFIG_RE = /^tsconfig(?:\..+)?\.json$/;
11751
12116
  var FROZEN_RE = /\bnpm\s+ci\b|\b(?:bun|pnpm|yarn)\s+(?:install|i)\b[^\n]*--frozen-lockfile|\byarn\s+install\b[^\n]*--immutable|\bbun\s+ci\b/;
11752
12117
  var INSTALL_RE2 = /\b(?:npm\s+(?:install|i)|(?:bun|pnpm|yarn)\s+(?:install|i|add))\b/;
@@ -11855,14 +12220,14 @@ var c27SubpackageTypes = {
11855
12220
  for (const site of tsSites) {
11856
12221
  const siteRel = relative6(base, site.dir) || ".";
11857
12222
  const docs = [];
11858
- const dockerfile = join10(site.dir, "Dockerfile");
11859
- if (existsSync9(dockerfile)) {
12223
+ const dockerfile = join11(site.dir, "Dockerfile");
12224
+ if (existsSync10(dockerfile)) {
11860
12225
  const text = readText(dockerfile);
11861
12226
  if (text === null) unreadDocs.push(`${siteRel}/Dockerfile`);
11862
12227
  else docs.push({ where: `${siteRel}/Dockerfile`, segments: dockerSegments(text) });
11863
12228
  }
11864
- const railway = join10(site.dir, "railway.json");
11865
- if (existsSync9(railway)) {
12229
+ const railway = join11(site.dir, "railway.json");
12230
+ if (existsSync10(railway)) {
11866
12231
  const text = readText(railway);
11867
12232
  if (text === null) unreadDocs.push(`${siteRel}/railway.json`);
11868
12233
  else docs.push({ where: `${siteRel}/railway.json`, segments: railwayBuildCommand(text) });
@@ -12130,8 +12495,8 @@ var c30SkillsOrgBound = {
12130
12495
  };
12131
12496
 
12132
12497
  // src/detectors/c31-plugin-installable.ts
12133
- import { existsSync as existsSync10, readdirSync as readdirSync8, statSync as statSync11 } from "fs";
12134
- import { basename as basename3, dirname as dirname4, join as join11, relative as relative8, sep as sep5 } from "path";
12498
+ import { existsSync as existsSync11, readdirSync as readdirSync8, statSync as statSync11 } from "fs";
12499
+ import { basename as basename3, dirname as dirname5, join as join12, relative as relative8, sep as sep5 } from "path";
12135
12500
  var MIN_README_WORDS = 40;
12136
12501
  var KEBAB_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
12137
12502
  var EXACT_VERSION_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?$/;
@@ -12316,7 +12681,7 @@ function judgeFolder(tree, folder, manifestPath2, out) {
12316
12681
  text: `plugin.json \`name\` ${typeof name === "string" ? `"${name}"` : "is absent"} is not kebab-case`
12317
12682
  });
12318
12683
  }
12319
- const pkgPath = existsSync10(join11(folder, "package.json")) ? join11(folder, "package.json") : existsSync10(join11(tree.root, "package.json")) ? join11(tree.root, "package.json") : null;
12684
+ const pkgPath = existsSync11(join12(folder, "package.json")) ? join12(folder, "package.json") : existsSync11(join12(tree.root, "package.json")) ? join12(tree.root, "package.json") : null;
12320
12685
  const pkg = pkgPath ? readJsonRecord(pkgPath) : null;
12321
12686
  if (!pkg || typeof pkg.version !== "string") {
12322
12687
  out.unreadable.push({
@@ -12347,9 +12712,9 @@ function judgeFolder(tree, folder, manifestPath2, out) {
12347
12712
  text: "no licence: plugin.json has no `license` and the folder has no LICENSE file"
12348
12713
  });
12349
12714
  }
12350
- const readmePath = join11(folder, "README.md");
12715
+ const readmePath = join12(folder, "README.md");
12351
12716
  const readme = readText(readmePath);
12352
- if (readme === null && existsSync10(readmePath)) {
12717
+ if (readme === null && existsSync11(readmePath)) {
12353
12718
  out.unreadable.push({
12354
12719
  anchor: rel(readmePath),
12355
12720
  reason: `${rel(readmePath)} is present but cannot be read as text (permission, or not a regular file) \u2014 its length and credential content are unread`
@@ -12378,13 +12743,13 @@ function judgeFolder(tree, folder, manifestPath2, out) {
12378
12743
  }
12379
12744
  }
12380
12745
  let servers = null;
12381
- let mcpAnchor = rel(join11(folder, ".mcp.json"));
12746
+ let mcpAnchor = rel(join12(folder, ".mcp.json"));
12382
12747
  const inline = manifest.mcpServers;
12383
12748
  if (isRecord(inline)) {
12384
12749
  servers = inline;
12385
12750
  mcpAnchor = a;
12386
12751
  } else if (typeof inline === "string") {
12387
- const target = join11(folder, inline);
12752
+ const target = join12(folder, inline);
12388
12753
  const j = readJsonRecord(target);
12389
12754
  mcpAnchor = rel(target);
12390
12755
  if (j) servers = isRecord(j.mcpServers) ? j.mcpServers : j;
@@ -12393,8 +12758,8 @@ function judgeFolder(tree, folder, manifestPath2, out) {
12393
12758
  anchor: mcpAnchor,
12394
12759
  reason: `${mcpAnchor} (named by plugin.json mcpServers) is not a parseable JSON object`
12395
12760
  });
12396
- } else if (existsSync10(join11(folder, ".mcp.json"))) {
12397
- const j = readJsonRecord(join11(folder, ".mcp.json"));
12761
+ } else if (existsSync11(join12(folder, ".mcp.json"))) {
12762
+ const j = readJsonRecord(join12(folder, ".mcp.json"));
12398
12763
  if (j) servers = isRecord(j.mcpServers) ? j.mcpServers : j;
12399
12764
  else
12400
12765
  out.unreadable.push({
@@ -12414,9 +12779,9 @@ function judgeFolder(tree, folder, manifestPath2, out) {
12414
12779
  judgeServers(servers, mcpAnchor, out);
12415
12780
  }
12416
12781
  try {
12417
- if (statSync11(join11(folder, "bin")).isDirectory()) {
12782
+ if (statSync11(join12(folder, "bin")).isDirectory()) {
12418
12783
  out.reds.push({
12419
- anchor: rel(join11(folder, "bin")),
12784
+ anchor: rel(join12(folder, "bin")),
12420
12785
  text: "a top-level bin/ directory (a plugin ships no bin/ at its top level)"
12421
12786
  });
12422
12787
  }
@@ -12424,8 +12789,8 @@ function judgeFolder(tree, folder, manifestPath2, out) {
12424
12789
  const code = fsErrorCode(err);
12425
12790
  if (code !== "ENOENT" && code !== "ENOTDIR") {
12426
12791
  out.unreadable.push({
12427
- anchor: rel(join11(folder, "bin")),
12428
- reason: `${rel(join11(folder, "bin"))} could not be probed (${code}) \u2014 whether the plugin ships a top-level bin/ is unread`
12792
+ anchor: rel(join12(folder, "bin")),
12793
+ reason: `${rel(join12(folder, "bin"))} could not be probed (${code}) \u2014 whether the plugin ships a top-level bin/ is unread`
12429
12794
  });
12430
12795
  }
12431
12796
  }
@@ -12469,7 +12834,7 @@ var c31PluginInstallable = {
12469
12834
  );
12470
12835
  }
12471
12836
  const out = { reds: [], unreadable: [...refusedManifests] };
12472
- for (const m of manifests) judgeFolder(tree, dirname4(dirname4(m.path)), m.path, out);
12837
+ for (const m of manifests) judgeFolder(tree, dirname5(dirname5(m.path)), m.path, out);
12473
12838
  const anchor = manifests[0].rel;
12474
12839
  if (out.reds.length > 0) {
12475
12840
  const shown = out.reds.slice(0, 6).map((r) => r.text).join("; ");
@@ -13359,10 +13724,10 @@ var RESULT_PAYLOAD_KEYS = [
13359
13724
  var RESULT_ANCHOR_KEYS = ["content", "structuredContent", "resultType"];
13360
13725
  function baseIsResult(file, base, tree) {
13361
13726
  if (!base) return false;
13362
- const esc4 = base.replace(/[$]/g, "\\$&");
13727
+ const esc5 = base.replace(/[$]/g, "\\$&");
13363
13728
  const keys = RESULT_PAYLOAD_KEYS.join("|");
13364
13729
  const assigned = new RegExp(
13365
- `\\b${esc4}\\s*(?:\\.\\s*(?:${keys})|\\[\\s*["'](?:${keys})["']\\s*\\])\\s*=(?![=>])`
13730
+ `\\b${esc5}\\s*(?:\\.\\s*(?:${keys})|\\[\\s*["'](?:${keys})["']\\s*\\])\\s*=(?![=>])`
13366
13731
  );
13367
13732
  if (file.lines.some((l) => !l.comment && assigned.test(l.raw))) return true;
13368
13733
  const one = { ...tree, files: [file] };
@@ -13511,8 +13876,8 @@ var d7Inner = {
13511
13876
  var d7 = guardUnreadablePackageJson(d7Inner, { authoritative: true });
13512
13877
 
13513
13878
  // src/detectors/d8.ts
13514
- import { existsSync as existsSync11, statSync as statSync12 } from "fs";
13515
- import { dirname as dirname5, join as join12, relative as relative9 } from "path";
13879
+ import { existsSync as existsSync12, statSync as statSync12 } from "fs";
13880
+ import { dirname as dirname6, join as join13, relative as relative9 } from "path";
13516
13881
  var POSITIVE_CONTROL2 = 'server.registerTool("list_items", { ... }, handler);';
13517
13882
  function d8PositiveControl() {
13518
13883
  return {
@@ -13522,9 +13887,9 @@ function d8PositiveControl() {
13522
13887
  };
13523
13888
  }
13524
13889
  function resolveBaseDir(tree) {
13525
- if (tree.packageJson) return dirname5(tree.packageJson.path);
13890
+ if (tree.packageJson) return dirname6(tree.packageJson.path);
13526
13891
  try {
13527
- return statSync12(tree.root).isDirectory() ? tree.root : dirname5(tree.root);
13892
+ return statSync12(tree.root).isDirectory() ? tree.root : dirname6(tree.root);
13528
13893
  } catch {
13529
13894
  return tree.root;
13530
13895
  }
@@ -13532,9 +13897,9 @@ function resolveBaseDir(tree) {
13532
13897
  function findEvalsFile(tree) {
13533
13898
  let dir = resolveBaseDir(tree);
13534
13899
  for (let depth = 0; depth < 8; depth++) {
13535
- const candidate = join12(dir, "evals", "evals.json");
13536
- if (existsSync11(candidate)) return candidate;
13537
- const parent = dirname5(dir);
13900
+ const candidate = join13(dir, "evals", "evals.json");
13901
+ if (existsSync12(candidate)) return candidate;
13902
+ const parent = dirname6(dir);
13538
13903
  if (parent === dir) break;
13539
13904
  dir = parent;
13540
13905
  }
@@ -13685,8 +14050,8 @@ var d8 = {
13685
14050
  };
13686
14051
 
13687
14052
  // src/detectors/d9.ts
13688
- import { existsSync as existsSync12 } from "fs";
13689
- import { dirname as dirname6, join as join13 } from "path";
14053
+ import { existsSync as existsSync13 } from "fs";
14054
+ import { dirname as dirname7, join as join14 } from "path";
13690
14055
  var SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
13691
14056
  var POSITIVE_CONTROL3 = "1.2.3-beta.1+build.7";
13692
14057
  function d9PositiveControl() {
@@ -13734,9 +14099,9 @@ var d9Inner = {
13734
14099
  verdict: `no "version" field in ${pkgPath.split("/").pop()} -> set a valid SemVer version`
13735
14100
  };
13736
14101
  }
13737
- const projectDir = dirname6(pkgPath);
13738
- const changelogPath = join13(projectDir, "CHANGELOG.md");
13739
- const hasChangelog = existsSync12(changelogPath);
14102
+ const projectDir = dirname7(pkgPath);
14103
+ const changelogPath = join14(projectDir, "CHANGELOG.md");
14104
+ const hasChangelog = existsSync13(changelogPath);
13740
14105
  const validSemver = SEMVER_RE.test(version);
13741
14106
  if (validSemver && hasChangelog) {
13742
14107
  return {
@@ -13765,8 +14130,8 @@ var d9Inner = {
13765
14130
  var d9 = guardUnreadablePackageJson(d9Inner, { authoritative: false });
13766
14131
 
13767
14132
  // src/detectors/d10.ts
13768
- import { existsSync as existsSync13 } from "fs";
13769
- import { dirname as dirname7, join as join14 } from "path";
14133
+ import { existsSync as existsSync14 } from "fs";
14134
+ import { dirname as dirname8, join as join15 } from "path";
13770
14135
  var DESCRIPTION_FR_RE = /"description_fr"\s*:\s*"[^"]+"/;
13771
14136
  var POSITIVE_CONTROL4 = '"description_fr": "Un serveur MCP conforme.",';
13772
14137
  function d10PositiveControl() {
@@ -13808,6 +14173,8 @@ function scanSourceDescriptionFr(tree) {
13808
14173
  const line = file.lines[i];
13809
14174
  if (line.comment || !MENTION_RE.test(line.raw)) continue;
13810
14175
  const anchor = `${file.rel}:${line.n}`;
14176
+ if (/description_fr\s*\?\s*:/.test(line.raw) && !/description_fr\s*:/.test(line.raw))
14177
+ continue;
13811
14178
  const key = line.raw.match(/description_fr\s*:/);
13812
14179
  if (!key || key.index === void 0) {
13813
14180
  undecidable ??= {
@@ -13824,6 +14191,22 @@ ${tail}`);
13824
14191
  if (v.kind === "non-literal") {
13825
14192
  const ident = v.expr.match(/^([A-Za-z_$][\w$]*)\s*[,}]?\s*$/);
13826
14193
  if (ident && bindings.get(ident[1])) return { present: true, anchor };
14194
+ const i18n = readI18nCall(tree, file, v.expr);
14195
+ if (i18n?.kind === "text" && i18n.locale === "fr") return { present: true, anchor };
14196
+ if (i18n?.kind === "text") {
14197
+ undecidable ??= {
14198
+ anchor,
14199
+ reason: `description_fr at ${anchor} is read from the "${i18n.locale}" resource (${i18n.source}), not from "fr": the French field carries no French description`
14200
+ };
14201
+ continue;
14202
+ }
14203
+ if (i18n?.kind === "unresolved") {
14204
+ undecidable ??= {
14205
+ anchor,
14206
+ reason: `description_fr at ${anchor} is the translation call \`${v.expr}\`, not read back: ${i18n.why}; verdict undecidable`
14207
+ };
14208
+ continue;
14209
+ }
13827
14210
  const form = ident ? "an identifier that does not resolve to a same-tree string const" : /\w\s*\(/.test(v.expr) ? "a call" : "a non-literal expression";
13828
14211
  undecidable ??= {
13829
14212
  anchor,
@@ -13867,7 +14250,7 @@ var d10Inner = {
13867
14250
  };
13868
14251
  }
13869
14252
  const { path: pkgPath, json: pkg } = tree.packageJson;
13870
- const root = dirname7(pkgPath);
14253
+ const root = dirname8(pkgPath);
13871
14254
  const descriptionFr = typeof pkg.description_fr === "string" ? pkg.description_fr.trim() : "";
13872
14255
  const hasDescriptionFrJson = descriptionFr.length > 0;
13873
14256
  const sourceScan = scanSourceDescriptionFr(tree);
@@ -13881,8 +14264,8 @@ var d10Inner = {
13881
14264
  };
13882
14265
  }
13883
14266
  const hasDescriptionFr = hasDescriptionFrJson || sourceScan.present;
13884
- const readmeFrPath = join14(root, "README.fr.md");
13885
- const hasReadmeFr = existsSync13(readmeFrPath);
14267
+ const readmeFrPath = join15(root, "README.fr.md");
14268
+ const hasReadmeFr = existsSync14(readmeFrPath);
13886
14269
  const missing = [];
13887
14270
  if (!hasDescriptionFr) missing.push("description_fr (package.json or source _meta)");
13888
14271
  if (!hasReadmeFr) missing.push("README.fr.md");
@@ -14290,8 +14673,8 @@ var d15 = {
14290
14673
  };
14291
14674
 
14292
14675
  // src/detectors/d16.ts
14293
- import { existsSync as existsSync14, readFileSync as readFileSync10, statSync as statSync13 } from "fs";
14294
- import { dirname as dirname8, join as join15 } from "path";
14676
+ import { existsSync as existsSync15, readFileSync as readFileSync11, statSync as statSync13 } from "fs";
14677
+ import { dirname as dirname9, join as join16 } from "path";
14295
14678
  var DISCOVER_RE2 = /server\/discover|DiscoverResult|ServerDiscover|handleServerDiscover/;
14296
14679
  var HEALTH_ROUTE_FRAMEWORK_RE = /\b[A-Za-z_$][\w$]*\.(?:get|post|put|patch|delete|all|route|use)\s*\(\s*["'`][^"'`]*\/health/;
14297
14680
  var HEALTH_ROUTE_RAWPATH_RE = /\bpathname\s*===?\s*["'`][^"'`]*\/health/;
@@ -14356,7 +14739,7 @@ function d16PositiveControls() {
14356
14739
  negative: c.re.test(c.negative)
14357
14740
  }));
14358
14741
  }
14359
- function collectPkgIdents(file) {
14742
+ function collectPkgIdents(file, tree) {
14360
14743
  const idents = /* @__PURE__ */ new Set();
14361
14744
  for (const line of file.lines) {
14362
14745
  if (line.comment) continue;
@@ -14365,8 +14748,56 @@ function collectPkgIdents(file) {
14365
14748
  const mb = line.raw.match(PKG_IMPORT_BIND_RE);
14366
14749
  if (mb) idents.add(mb[1]);
14367
14750
  }
14751
+ if (tree && manifestVersionEqualsPackage(tree))
14752
+ for (const id of manifestIdents(file)) idents.add(id);
14368
14753
  return idents;
14369
14754
  }
14755
+ var MANIFEST_LOADER = "loadServerManifest";
14756
+ function manifestVersionEqualsPackage(tree) {
14757
+ const pkgVersion = tree.packageJson?.json.version;
14758
+ if (typeof pkgVersion !== "string" || pkgVersion.length === 0 || !tree.packageJson) return false;
14759
+ try {
14760
+ const manifest = JSON.parse(
14761
+ readFileSync11(join16(dirname9(tree.packageJson.path), "mcp-server.json"), "utf8")
14762
+ );
14763
+ return manifest.version === pkgVersion;
14764
+ } catch {
14765
+ return false;
14766
+ }
14767
+ }
14768
+ function manifestIdents(file) {
14769
+ const code = file.lines.filter((l) => !l.comment).map((l) => l.raw);
14770
+ const loaders = /* @__PURE__ */ new Set([MANIFEST_LOADER]);
14771
+ code.forEach((raw, i) => {
14772
+ const fn = raw.match(/^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(/);
14773
+ if (!fn) return;
14774
+ let depth = 0;
14775
+ let opened = false;
14776
+ for (let j = i; j < code.length; j++) {
14777
+ if (code[j].includes(`${MANIFEST_LOADER}(`)) {
14778
+ loaders.add(fn[1]);
14779
+ return;
14780
+ }
14781
+ for (const c of code[j]) {
14782
+ if (c === "{") {
14783
+ depth++;
14784
+ opened = true;
14785
+ } else if (c === "}") depth--;
14786
+ }
14787
+ if (opened && depth <= 0) return;
14788
+ }
14789
+ });
14790
+ const out = /* @__PURE__ */ new Set();
14791
+ const callee = [...loaders].map((n) => n.replace(/[$]/g, "\\$&")).join("|");
14792
+ const bind = new RegExp(
14793
+ `(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*(?:await\\s+)?(?:${callee})\\s*\\(`
14794
+ );
14795
+ for (const raw of code) {
14796
+ const m = raw.match(bind);
14797
+ if (m) out.add(m[1]);
14798
+ }
14799
+ return out;
14800
+ }
14370
14801
  function extractHandlerBody(file, startIdx) {
14371
14802
  const code = file.lines.filter((l) => !l.comment);
14372
14803
  const startPos = code.findIndex((l) => l.n === file.lines[startIdx].n);
@@ -14438,7 +14869,7 @@ function packageJsonVersionConsts(tree) {
14438
14869
  function sdkServerVersionSurface(tree) {
14439
14870
  const derived = packageJsonVersionConsts(tree);
14440
14871
  for (const file of tree.files) {
14441
- const pkgIdents = collectPkgIdents(file);
14872
+ const pkgIdents = collectPkgIdents(file, tree);
14442
14873
  for (let idx = 0; idx < file.lines.length; idx++) {
14443
14874
  const line = file.lines[idx];
14444
14875
  if (line.comment || !SDK_SERVER_NEW_RE.test(line.raw)) continue;
@@ -14461,7 +14892,7 @@ function evalSurfaces(tree) {
14461
14892
  const sdk = sdkServerVersionSurface(tree);
14462
14893
  if (sdk) out.push(sdk);
14463
14894
  for (const file of tree.files) {
14464
- const pkgIdents = collectPkgIdents(file);
14895
+ const pkgIdents = collectPkgIdents(file, tree);
14465
14896
  file.lines.forEach((line, idx) => {
14466
14897
  if (line.comment) return;
14467
14898
  if (DISCOVER_RE2.test(line.raw) || HEALTH_ROUTE_RE2.test(line.raw)) {
@@ -14613,15 +15044,15 @@ var d16 = {
14613
15044
  };
14614
15045
  function readPackageVersion(root) {
14615
15046
  try {
14616
- let dir = statSync13(root).isDirectory() ? root : dirname8(root);
15047
+ let dir = statSync13(root).isDirectory() ? root : dirname9(root);
14617
15048
  for (let depth = 0; depth < 8; depth++) {
14618
- const candidate = join15(dir, "package.json");
14619
- if (existsSync14(candidate)) {
15049
+ const candidate = join16(dir, "package.json");
15050
+ if (existsSync15(candidate)) {
14620
15051
  if (!statSync13(candidate).isFile()) return null;
14621
- const pkg = JSON.parse(readFileSync10(candidate, "utf8"));
15052
+ const pkg = JSON.parse(readFileSync11(candidate, "utf8"));
14622
15053
  return typeof pkg.version === "string" ? pkg.version : null;
14623
15054
  }
14624
- const parent = dirname8(dir);
15055
+ const parent = dirname9(dir);
14625
15056
  if (parent === dir) break;
14626
15057
  dir = parent;
14627
15058
  }
@@ -14632,8 +15063,8 @@ function readPackageVersion(root) {
14632
15063
  }
14633
15064
 
14634
15065
  // src/detectors/dAppI18n.ts
14635
- import { existsSync as existsSync15, readFileSync as readFileSync11, statSync as statSync14 } from "fs";
14636
- import { dirname as dirname9, join as join16 } from "path";
15066
+ import { existsSync as existsSync16, readFileSync as readFileSync12, statSync as statSync14 } from "fs";
15067
+ import { dirname as dirname10, join as join17 } from "path";
14637
15068
  function flattenKeys(obj, prefix = "") {
14638
15069
  if (obj === null || typeof obj !== "object" || Array.isArray(obj)) {
14639
15070
  return prefix ? [prefix] : [];
@@ -14667,7 +15098,7 @@ function dAppI18nPositiveControls() {
14667
15098
  function readJson2(path) {
14668
15099
  try {
14669
15100
  if (!statSync14(path).isFile()) return { ok: false };
14670
- return { ok: true, value: JSON.parse(readFileSync11(path, "utf8")) };
15101
+ return { ok: true, value: JSON.parse(readFileSync12(path, "utf8")) };
14671
15102
  } catch {
14672
15103
  return { ok: false };
14673
15104
  }
@@ -14683,12 +15114,12 @@ var dAppI18n = {
14683
15114
  `DAppI18n key-diff control FAILED: detectsGap=${control.detectsGap} detectsComplete=${control.detectsComplete} \u2014 matcher broken, verdict untrustworthy`
14684
15115
  );
14685
15116
  }
14686
- const root = tree.packageJson ? dirname9(tree.packageJson.path) : tree.root;
14687
- const i18nDir = join16(root, "i18n");
14688
- const enPath = join16(i18nDir, "en.json");
14689
- const frPath = join16(i18nDir, "fr.json");
14690
- const hasI18n = existsSync15(i18nDir);
14691
- const hasFr = existsSync15(frPath);
15117
+ const root = tree.packageJson ? dirname10(tree.packageJson.path) : tree.root;
15118
+ const i18nDir = join17(root, "i18n");
15119
+ const enPath = join17(i18nDir, "en.json");
15120
+ const frPath = join17(i18nDir, "fr.json");
15121
+ const hasI18n = existsSync16(i18nDir);
15122
+ const hasFr = existsSync16(frPath);
14692
15123
  if (!hasI18n && !hasFr) {
14693
15124
  return {
14694
15125
  id: this.id,
@@ -14716,7 +15147,7 @@ var dAppI18n = {
14716
15147
  verdict: `could not judge: ${reason}`
14717
15148
  };
14718
15149
  }
14719
- if (!existsSync15(enPath)) {
15150
+ if (!existsSync16(enPath)) {
14720
15151
  const reason = "i18n/fr.json exists but no source-locale i18n/en.json to compare its keys against (App Rule 2)";
14721
15152
  return {
14722
15153
  id: this.id,
@@ -14866,13 +15297,13 @@ var dDebugOptIn = {
14866
15297
 
14867
15298
  // src/detectors/extManifests.ts
14868
15299
  import { readdirSync as readdirSync9, statSync as statSync15 } from "fs";
14869
- import { join as join17 } from "path";
15300
+ import { join as join18 } from "path";
14870
15301
  function findExtensionManifests(tree) {
14871
15302
  const out = [];
14872
15303
  const root = tree.root;
14873
15304
  let base;
14874
15305
  try {
14875
- base = statSync15(root).isDirectory() ? root : join17(root, "..");
15306
+ base = statSync15(root).isDirectory() ? root : join18(root, "..");
14876
15307
  } catch {
14877
15308
  return out;
14878
15309
  }
@@ -14885,7 +15316,7 @@ function findExtensionManifests(tree) {
14885
15316
  return;
14886
15317
  }
14887
15318
  for (const name of entries) {
14888
- const full = join17(dir, name);
15319
+ const full = join18(dir, name);
14889
15320
  let st;
14890
15321
  try {
14891
15322
  st = statSync15(full);
@@ -14913,20 +15344,20 @@ function findExtensionManifests(tree) {
14913
15344
  }
14914
15345
 
14915
15346
  // src/detectors/vendorRegistry.ts
14916
- import { existsSync as existsSync16, readFileSync as readFileSync12 } from "fs";
14917
- import { dirname as dirname10, join as join18 } from "path";
15347
+ import { existsSync as existsSync17, readFileSync as readFileSync13 } from "fs";
15348
+ import { dirname as dirname11, join as join19 } from "path";
14918
15349
  import { fileURLToPath } from "url";
14919
15350
  function locateRegistry() {
14920
15351
  let dir;
14921
15352
  try {
14922
- dir = dirname10(fileURLToPath(import.meta.url));
15353
+ dir = dirname11(fileURLToPath(import.meta.url));
14923
15354
  } catch {
14924
15355
  return null;
14925
15356
  }
14926
15357
  for (let depth = 0; depth < 5; depth++) {
14927
- const candidate = join18(dir, "vendor-namespaces.json");
14928
- if (existsSync16(candidate)) return candidate;
14929
- const parent = dirname10(dir);
15358
+ const candidate = join19(dir, "vendor-namespaces.json");
15359
+ if (existsSync17(candidate)) return candidate;
15360
+ const parent = dirname11(dir);
14930
15361
  if (parent === dir) break;
14931
15362
  dir = parent;
14932
15363
  }
@@ -14942,7 +15373,7 @@ function loadRegistry(path) {
14942
15373
  }
14943
15374
  let parsed;
14944
15375
  try {
14945
- parsed = JSON.parse(readFileSync12(p, "utf8"));
15376
+ parsed = JSON.parse(readFileSync13(p, "utf8"));
14946
15377
  } catch (err) {
14947
15378
  return {
14948
15379
  ok: false,
@@ -15521,7 +15952,7 @@ var dExt3 = {
15521
15952
 
15522
15953
  // src/detectors/dExt4.ts
15523
15954
  import { readdirSync as readdirSync10, statSync as statSync16 } from "fs";
15524
- import { join as join19, relative as relative10 } from "path";
15955
+ import { join as join20, relative as relative10 } from "path";
15525
15956
  function canonical(name) {
15526
15957
  return name.replace(/[-_]/g, "").toLowerCase();
15527
15958
  }
@@ -15545,7 +15976,7 @@ function findHooksDirs(tree, unreadable, gaps) {
15545
15976
  const out = [];
15546
15977
  let base;
15547
15978
  try {
15548
- base = statSync16(root).isDirectory() ? root : join19(root, "..");
15979
+ base = statSync16(root).isDirectory() ? root : join20(root, "..");
15549
15980
  } catch {
15550
15981
  return out;
15551
15982
  }
@@ -15566,7 +15997,7 @@ function findHooksDirs(tree, unreadable, gaps) {
15566
15997
  return;
15567
15998
  }
15568
15999
  for (const name of entries) {
15569
- const full = join19(dir, name);
16000
+ const full = join20(dir, name);
15570
16001
  let st;
15571
16002
  try {
15572
16003
  st = statSync16(full);
@@ -15747,8 +16178,8 @@ var dExt4 = {
15747
16178
  };
15748
16179
 
15749
16180
  // src/detectors/dExt5.ts
15750
- import { existsSync as existsSync17 } from "fs";
15751
- import { dirname as dirname11, join as join20 } from "path";
16181
+ import { existsSync as existsSync18 } from "fs";
16182
+ import { dirname as dirname12, join as join21 } from "path";
15752
16183
  function nonEmptyString(v) {
15753
16184
  return typeof v === "string" && v.trim().length > 0;
15754
16185
  }
@@ -15787,7 +16218,7 @@ var dExt5 = {
15787
16218
  }
15788
16219
  for (const manifestPath2 of manifests) {
15789
16220
  const shortPath = manifestPath2.split("/").slice(-2).join("/");
15790
- const root = dirname11(manifestPath2);
16221
+ const root = dirname12(manifestPath2);
15791
16222
  const cannotRead = (reason) => ({
15792
16223
  id: this.id,
15793
16224
  anchor: shortPath,
@@ -15810,7 +16241,7 @@ var dExt5 = {
15810
16241
  if (!nonEmptyString(parsed.description_fr)) {
15811
16242
  missing.push("description_fr (extension.json)");
15812
16243
  }
15813
- if (!existsSync17(join20(root, "README.fr.md"))) {
16244
+ if (!existsSync18(join21(root, "README.fr.md"))) {
15814
16245
  missing.push("README.fr.md");
15815
16246
  }
15816
16247
  if (isToolExtension(parsed.type) && "tools" in parsed) {
@@ -15853,8 +16284,8 @@ var dExt5 = {
15853
16284
  };
15854
16285
 
15855
16286
  // src/detectors/dExt7.ts
15856
- import { existsSync as existsSync18 } from "fs";
15857
- import { dirname as dirname12, join as join21 } from "path";
16287
+ import { existsSync as existsSync19 } from "fs";
16288
+ import { dirname as dirname13, join as join22 } from "path";
15858
16289
  var ABSENCE_FLAG_FIELDS = [
15859
16290
  "extensionAbsent",
15860
16291
  "extension_absent",
@@ -15920,11 +16351,11 @@ var dExt7 = {
15920
16351
  const unreadable = [];
15921
16352
  const decided = (() => {
15922
16353
  for (const manifestPath2 of manifests) {
15923
- const extDir = dirname12(manifestPath2);
16354
+ const extDir = dirname13(manifestPath2);
15924
16355
  const extLabel = extDir.split("/").pop() ?? extDir;
15925
- const evalsPath = join21(extDir, "evals", "evals.json");
16356
+ const evalsPath = join22(extDir, "evals", "evals.json");
15926
16357
  const shortPath = `${extLabel}/evals/evals.json`;
15927
- if (!existsSync18(evalsPath)) {
16358
+ if (!existsSync19(evalsPath)) {
15928
16359
  return {
15929
16360
  id: this.id,
15930
16361
  anchor: `${extLabel}/extension.json`,
@@ -15988,8 +16419,8 @@ var dExt7 = {
15988
16419
  };
15989
16420
 
15990
16421
  // src/detectors/dExt8.ts
15991
- import { existsSync as existsSync19 } from "fs";
15992
- import { dirname as dirname13, join as join22 } from "path";
16422
+ import { existsSync as existsSync20 } from "fs";
16423
+ import { dirname as dirname14, join as join23 } from "path";
15993
16424
  var SEMVER_RE2 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
15994
16425
  var POSITIVE_CONTROL5 = "1.2.3-beta.1+build.7";
15995
16426
  function dExt8PositiveControl() {
@@ -16023,11 +16454,11 @@ var dExt8 = {
16023
16454
  let finding;
16024
16455
  let judgedConforming = 0;
16025
16456
  for (const manifestPath2 of manifests) {
16026
- const extDir = dirname13(manifestPath2);
16457
+ const extDir = dirname14(manifestPath2);
16027
16458
  const extLabel = extDir.split("/").pop() ?? extDir;
16028
- const pkgPath = join22(extDir, "package.json");
16459
+ const pkgPath = join23(extDir, "package.json");
16029
16460
  const shortPkgPath = `${extLabel}/package.json`;
16030
- if (!existsSync19(pkgPath)) {
16461
+ if (!existsSync20(pkgPath)) {
16031
16462
  unreadable.push({
16032
16463
  anchor: shortPkgPath,
16033
16464
  reason: `could not locate ${shortPkgPath} for extension "${extLabel}" \u2014 cannot verify SemVer/CHANGELOG (Extension Rule 8)`
@@ -16062,8 +16493,8 @@ var dExt8 = {
16062
16493
  continue;
16063
16494
  }
16064
16495
  const validSemver = SEMVER_RE2.test(version);
16065
- const changelogPath = join22(extDir, "CHANGELOG.md");
16066
- const hasChangelog = existsSync19(changelogPath);
16496
+ const changelogPath = join23(extDir, "CHANGELOG.md");
16497
+ const hasChangelog = existsSync20(changelogPath);
16067
16498
  if (!validSemver) {
16068
16499
  finding ??= {
16069
16500
  id: this.id,
@@ -16097,14 +16528,14 @@ var dExt8 = {
16097
16528
  };
16098
16529
 
16099
16530
  // src/detectors/dExt9.ts
16100
- import { readFileSync as readFileSync13, readdirSync as readdirSync11, statSync as statSync17 } from "fs";
16101
- import { join as join23, relative as relative11 } from "path";
16531
+ import { readFileSync as readFileSync14, readdirSync as readdirSync11, statSync as statSync17 } from "fs";
16532
+ import { join as join24, relative as relative11 } from "path";
16102
16533
  function collectHooksDirSources(tree, unreadable, gaps) {
16103
16534
  const root = tree.root;
16104
16535
  const out = [];
16105
16536
  let base;
16106
16537
  try {
16107
- base = statSync17(root).isDirectory() ? root : join23(root, "..");
16538
+ base = statSync17(root).isDirectory() ? root : join24(root, "..");
16108
16539
  } catch {
16109
16540
  return out;
16110
16541
  }
@@ -16125,7 +16556,7 @@ function collectHooksDirSources(tree, unreadable, gaps) {
16125
16556
  return;
16126
16557
  }
16127
16558
  for (const name of entries) {
16128
- const full = join23(dir, name);
16559
+ const full = join24(dir, name);
16129
16560
  let st;
16130
16561
  try {
16131
16562
  st = statSync17(full);
@@ -16151,11 +16582,11 @@ function collectHooksDirSources(tree, unreadable, gaps) {
16151
16582
  if (!f.endsWith(".ts") || f.endsWith(".d.ts")) continue;
16152
16583
  const stem = f.replace(/\.ts$/, "");
16153
16584
  if (stem === "index") continue;
16154
- const filePath = join23(full, f);
16585
+ const filePath = join24(full, f);
16155
16586
  let body;
16156
16587
  try {
16157
16588
  if (!statSync17(filePath).isFile()) throw new Error("not a regular file");
16158
- body = readFileSync13(filePath, "utf8");
16589
+ body = readFileSync14(filePath, "utf8");
16159
16590
  } catch {
16160
16591
  const shortPath = filePath.split("/").slice(-2).join("/");
16161
16592
  unreadable.push({
@@ -16629,21 +17060,21 @@ function codeLines(tree) {
16629
17060
  for (const file of tree.files) for (const l of file.lines) if (!l.comment) out.push(l.raw);
16630
17061
  return out;
16631
17062
  }
16632
- var esc2 = (x) => x.replace(/[$]/g, "\\$&");
17063
+ var esc3 = (x) => x.replace(/[$]/g, "\\$&");
16633
17064
  function resolvesToLiteral(tree, path) {
16634
17065
  const lines2 = codeLines(tree);
16635
17066
  const plainLiteral = (name) => {
16636
- const decl = new RegExp(`\\b(?:const|let|var)\\s+${esc2(name)}\\s*(?::[^=]+)?=\\s*(.*)$`);
17067
+ const decl = new RegExp(`\\b(?:const|let|var)\\s+${esc3(name)}\\s*(?::[^=]+)?=\\s*(.*)$`);
16637
17068
  const found = lines2.map((l) => l.match(decl)).filter((m) => m !== null);
16638
17069
  if (found.length !== 1 || !LITERAL_VALUE_RE.test(found[0][1])) return false;
16639
- const param = new RegExp(`[(,]\\s*${esc2(name)}\\s*[:,)=?]|\\bfunction\\s+${esc2(name)}\\b`);
17070
+ const param = new RegExp(`[(,]\\s*${esc3(name)}\\s*[:,)=?]|\\bfunction\\s+${esc3(name)}\\b`);
16640
17071
  return !lines2.some((l) => param.test(l));
16641
17072
  };
16642
17073
  if (/[()]/.test(path)) return false;
16643
17074
  if (!path.includes(".")) return plainLiteral(path);
16644
17075
  const prop = path.split(".").pop() ?? "";
16645
- const def = new RegExp(`(?:^|[\\s{,])${esc2(prop)}\\s*:\\s*([^,}\\n]+)`);
16646
- const shorthand = new RegExp(`[{,]\\s*${esc2(prop)}\\s*[,}]`);
17076
+ const def = new RegExp(`(?:^|[\\s{,])${esc3(prop)}\\s*:\\s*([^,}\\n]+)`);
17077
+ const shorthand = new RegExp(`[{,]\\s*${esc3(prop)}\\s*[,}]`);
16647
17078
  const defs = lines2.map((l) => l.match(def)).filter((m) => m !== null);
16648
17079
  if (defs.length === 0 || lines2.some((l) => shorthand.test(l))) return false;
16649
17080
  return defs.every((m) => {
@@ -16701,19 +17132,19 @@ function boundToSystemState(tree, path) {
16701
17132
  const lines2 = codeLines(tree);
16702
17133
  if (/[()]/.test(path)) return null;
16703
17134
  if (!path.includes(".")) {
16704
- const destructured = new RegExp(`\\{[^}]*\\b${esc2(path)}\\b[^}]*\\}\\s*=\\s*process\\.env\\b`);
17135
+ const destructured = new RegExp(`\\{[^}]*\\b${esc3(path)}\\b[^}]*\\}\\s*=\\s*process\\.env\\b`);
16705
17136
  if (lines2.some((l) => destructured.test(l)) && URL_ENV_NAME_RE.test(path)) return "env-url";
16706
- const decl = new RegExp(`\\b(?:const|let|var)\\s+${esc2(path)}\\s*(?::[^=]+)?=\\s*(.*)$`);
17137
+ const decl = new RegExp(`\\b(?:const|let|var)\\s+${esc3(path)}\\s*(?::[^=]+)?=\\s*(.*)$`);
16707
17138
  const found = lines2.map((l) => l.match(decl)).filter((m) => m !== null);
16708
17139
  if (found.length !== 1) return null;
16709
17140
  const param = new RegExp(
16710
- `\\([^()]*\\b${esc2(path)}\\b[^()]*\\)\\s*(?::[^=]+)?=>|\\bfunction\\b[^(]*\\([^)]*\\b${esc2(path)}\\b`
17141
+ `\\([^()]*\\b${esc3(path)}\\b[^()]*\\)\\s*(?::[^=]+)?=>|\\bfunction\\b[^(]*\\([^)]*\\b${esc3(path)}\\b`
16711
17142
  );
16712
17143
  if (lines2.some((l) => param.test(l))) return null;
16713
17144
  return exprSystemKind(found[0][1]);
16714
17145
  }
16715
17146
  const prop = path.split(".").pop() ?? "";
16716
- const def = new RegExp(`(?:^|[\\s{,])${esc2(prop)}\\s*:\\s*([^,}\\n]+)`);
17147
+ const def = new RegExp(`(?:^|[\\s{,])${esc3(prop)}\\s*:\\s*([^,}\\n]+)`);
16717
17148
  const defs = lines2.map((l) => l.match(def)).filter((m) => m !== null);
16718
17149
  if (defs.length === 0) return null;
16719
17150
  const kinds = defs.map((m) => exprSystemKind(m[1]));
@@ -17784,8 +18215,8 @@ var e10MrtrOnly = {
17784
18215
  };
17785
18216
 
17786
18217
  // src/detectors/e11-surfaces-derived.ts
17787
- import { existsSync as existsSync20, statSync as statSync18 } from "fs";
17788
- import { dirname as dirname14, join as join24, relative as relative12, sep as sep6 } from "path";
18218
+ import { existsSync as existsSync21, statSync as statSync18 } from "fs";
18219
+ import { dirname as dirname15, join as join25, relative as relative12, sep as sep6 } from "path";
17789
18220
  var ALL = ["chat", "cowork", "claude-code"];
17790
18221
  function excludedSurfaces(c) {
17791
18222
  const cause = /* @__PURE__ */ new Map();
@@ -17856,7 +18287,7 @@ var e11SurfacesDerived = {
17856
18287
  });
17857
18288
  continue;
17858
18289
  }
17859
- const folder = dirname14(m.path);
18290
+ const folder = dirname15(m.path);
17860
18291
  const rel = (p) => relative12(tree.root, p).split(sep6).join("/") || ".";
17861
18292
  if (!Array.isArray(j.surfaces)) {
17862
18293
  reds.push({
@@ -17874,9 +18305,9 @@ var e11SurfacesDerived = {
17874
18305
  text: `${m.rel} surfaces ${unknown.join(", ")} are not in {${ALL.join(", ")}}`
17875
18306
  });
17876
18307
  }
17877
- const mcp = join24(folder, ".mcp.json");
18308
+ const mcp = join25(folder, ".mcp.json");
17878
18309
  let localMcp = false;
17879
- if (existsSync20(mcp)) {
18310
+ if (existsSync21(mcp)) {
17880
18311
  const mj = readJsonRecord(mcp);
17881
18312
  if (!mj)
17882
18313
  unreadable.push({
@@ -17893,9 +18324,9 @@ var e11SurfacesDerived = {
17893
18324
  }
17894
18325
  }
17895
18326
  const cause = excludedSurfaces({
17896
- bin: isDir(join24(folder, "bin"), rel(join24(folder, "bin")), unreadable),
17897
- hooks: isDir(join24(folder, "hooks"), rel(join24(folder, "hooks")), unreadable),
17898
- agents: isDir(join24(folder, "agents"), rel(join24(folder, "agents")), unreadable),
18327
+ bin: isDir(join25(folder, "bin"), rel(join25(folder, "bin")), unreadable),
18328
+ hooks: isDir(join25(folder, "hooks"), rel(join25(folder, "hooks")), unreadable),
18329
+ agents: isDir(join25(folder, "agents"), rel(join25(folder, "agents")), unreadable),
17899
18330
  localMcp
17900
18331
  });
17901
18332
  for (const s of declared) {
@@ -18020,7 +18451,7 @@ var e12HostCapabilityPlacement = {
18020
18451
 
18021
18452
  // src/detectors/installedAs.ts
18022
18453
  import { readdirSync as readdirSync12, statSync as statSync19 } from "fs";
18023
- import { join as join25 } from "path";
18454
+ import { join as join26 } from "path";
18024
18455
  var KEY = (k) => `(?:["']${k}["']|\\b${k}\\b)`;
18025
18456
  function flagTrueRe(key) {
18026
18457
  return new RegExp(`${KEY(key)}\\s*:\\s*true\\b`);
@@ -18045,7 +18476,7 @@ function declaredDependencies(tree) {
18045
18476
  }
18046
18477
  function readInstalledAs(tree) {
18047
18478
  const out = { installed: false, missing: [], publishers: [], unread: [] };
18048
- const nm = join25(baseOf(tree), "node_modules");
18479
+ const nm = join26(baseOf(tree), "node_modules");
18049
18480
  try {
18050
18481
  out.installed = statSync19(nm).isDirectory();
18051
18482
  } catch {
@@ -18054,7 +18485,7 @@ function readInstalledAs(tree) {
18054
18485
  if (!out.installed) return out;
18055
18486
  const methods = authMethodsRe();
18056
18487
  for (const dep of declaredDependencies(tree)) {
18057
- const dir = join25(nm, dep);
18488
+ const dir = join26(nm, dep);
18058
18489
  try {
18059
18490
  if (!statSync19(dir).isDirectory()) throw new Error("not a directory");
18060
18491
  } catch {
@@ -18075,7 +18506,7 @@ function readInstalledAs(tree) {
18075
18506
  for (const n of names) {
18076
18507
  if (files.length >= MAX_FILES_PER_PACKAGE) return;
18077
18508
  if (n === "node_modules") continue;
18078
- const full = join25(d, n);
18509
+ const full = join26(d, n);
18079
18510
  let st;
18080
18511
  try {
18081
18512
  st = statSync19(full);
@@ -19280,7 +19711,7 @@ function outboundSites(tree) {
19280
19711
  if (!BARE_IDENT.test(first)) continue;
19281
19712
  const fns = enclosingFns(c.src, c.start);
19282
19713
  const inner = fns[fns.length - 1];
19283
- if (!inner || !new RegExp(String.raw`(?<![\w$.])${esc(first)}(?![\w$])`).test(inner.header))
19714
+ if (!inner || !new RegExp(String.raw`(?<![\w$.])${esc2(first)}(?![\w$])`).test(inner.header))
19284
19715
  continue;
19285
19716
  const named = [...fns].reverse().find((f) => f.name !== void 0);
19286
19717
  if (!named?.name) continue;
@@ -19309,7 +19740,7 @@ function outboundSites(tree) {
19309
19740
  const applies = w.bodies.every((b) => b.timeout);
19310
19741
  for (const c of callsMatching(
19311
19742
  tree,
19312
- new RegExp(String.raw`^(?:[\w$]+(?:\?\.|\.))*${esc(w.name)}$`)
19743
+ new RegExp(String.raw`^(?:[\w$]+(?:\?\.|\.))*${esc2(w.name)}$`)
19313
19744
  )) {
19314
19745
  if (isDeclaration(c) || !callReaches(c.src, c.callee, w.name, w.defs)) continue;
19315
19746
  if (w.bodies.some((b) => b.src === c.src && c.start > b.open && c.start < b.close)) continue;
@@ -19320,7 +19751,7 @@ function outboundSites(tree) {
19320
19751
  const returned = /(?:\breturn\s+|=>\s*)$/.test(
19321
19752
  c.src.shape.slice(Math.max(0, c.start - 12), c.start)
19322
19753
  );
19323
- if (host?.name && returned && BARE_IDENT.test(first) && new RegExp(String.raw`(?<![\w$.])${esc(first)}(?![\w$])`).test(host.header) && !wrapperNames.has(host.name)) {
19754
+ if (host?.name && returned && BARE_IDENT.test(first) && new RegExp(String.raw`(?<![\w$.])${esc2(first)}(?![\w$])`).test(host.header) && !wrapperNames.has(host.name)) {
19324
19755
  unreadable.push({
19325
19756
  anchor: c.anchor,
19326
19757
  reason: `${c.anchor} \`${c.callee}(...)\` is a wrapper (${w.name}, ${w.anchor}) called through a second wrapper (${host.name}): two levels of indirection, the timeout of its call sites is not followed`
@@ -20610,6 +21041,16 @@ function resolveConstLiteral(tree, name, file) {
20610
21041
  }
20611
21042
  return null;
20612
21043
  }
21044
+ var OUTBOUND_CLIENTS = /* @__PURE__ */ new Set(["createPaginatedUpstreamClient"]);
21045
+ function outboundCallee(file, line, col) {
21046
+ const obj = enclosingOpener(file, line, col);
21047
+ if (!obj || obj.ch !== "{") return null;
21048
+ const call = enclosingOpener(file, obj.line, obj.col);
21049
+ if (!call || call.ch !== "(") return null;
21050
+ const before = uncommentedLines(file)[call.line - 1].slice(0, call.col);
21051
+ const name = before.match(/([A-Za-z_$][\w$]*)\s*(?:<[^>()]*>)?\s*$/)?.[1];
21052
+ return name !== void 0 && OUTBOUND_CLIENTS.has(name) ? name : null;
21053
+ }
20613
21054
  function classifyAllowedOrigins(tree) {
20614
21055
  const out = { sites: 0, first: "", ok: [], reds: [], unresolved: [], declared: [] };
20615
21056
  const judged = /* @__PURE__ */ new Set();
@@ -20633,6 +21074,7 @@ function classifyAllowedOrigins(tree) {
20633
21074
  const after = site.col + site.match[0].length;
20634
21075
  const rest = site.line.raw.slice(after);
20635
21076
  if (TYPE_ANNOTATION_RE.test(rest)) continue;
21077
+ if (outboundCallee(site.file, site.line.n, site.col) !== null) continue;
20636
21078
  if (rest.startsWith("{")) {
20637
21079
  const entry = declaredEntryAt(site.file, site.line.n, after);
20638
21080
  if (entry !== null) {
@@ -21217,12 +21659,12 @@ var s27ElicitationFloor = {
21217
21659
  };
21218
21660
 
21219
21661
  // src/detectors/s28-claim-forwarded.ts
21220
- import { existsSync as existsSync21, readFileSync as readFileSync14, readdirSync as readdirSync13, statSync as statSync20 } from "fs";
21221
- import { dirname as dirname15, join as join26, relative as relative13 } from "path";
21662
+ import { existsSync as existsSync22, readFileSync as readFileSync15, readdirSync as readdirSync13, statSync as statSync20 } from "fs";
21663
+ import { dirname as dirname16, join as join27, relative as relative13 } from "path";
21222
21664
  var PIN11 = STANDARD_PIN;
21223
21665
  var CLAIM_TOKEN = /\bverified(?:Org|Person)\b/;
21224
21666
  var ANY_CLAIM = /\bverified(?:Actor|Org|Person)\b/g;
21225
- var CALL_RE = /\b([A-Za-z_$][\w$]*)\s*\.\s*(query|mutation|action)\s*\(/g;
21667
+ var CALL_RE2 = /\b([A-Za-z_$][\w$]*)\s*\.\s*(query|mutation|action)\s*\(/g;
21226
21668
  var GUARD_RE = /\b(?:unresolved\w*Denial|requireVerified\w+|requireClaim\w*)\s*\(|verified-org-unresolved/;
21227
21669
  var FLEET_WIDE = /fleet-wide:\s*\S[^\n]{7,}/;
21228
21670
  var SCOPE_MARKERS = /\bwithOrgScope\b|\brequireAuthenticatedCaller\b|\bresolveInboxReader\b|\bresolveVerified\w*\b|\brequireScope\b|\bgetUserIdentity\b|\bisMaster\b|\bscope\b/;
@@ -21286,7 +21728,7 @@ function listTs(dir, unread2, out = []) {
21286
21728
  }
21287
21729
  for (const n of names) {
21288
21730
  if (n === "node_modules" || n === "_generated" || n === "__tests__") continue;
21289
- const p = join26(dir, n);
21731
+ const p = join27(dir, n);
21290
21732
  let st;
21291
21733
  try {
21292
21734
  st = statSync20(p);
@@ -21305,14 +21747,14 @@ function listTs(dir, unread2, out = []) {
21305
21747
  function discoverBackend(root) {
21306
21748
  let dir = root;
21307
21749
  try {
21308
- if (!statSync20(root).isDirectory()) dir = dirname15(root);
21750
+ if (!statSync20(root).isDirectory()) dir = dirname16(root);
21309
21751
  } catch {
21310
21752
  return void 0;
21311
21753
  }
21312
21754
  for (let up = 0; up < 5; up++) {
21313
- const cand = join26(dir, "convex");
21314
- if (existsSync21(join26(cand, "schema.ts"))) return cand;
21315
- const parent = dirname15(dir);
21755
+ const cand = join27(dir, "convex");
21756
+ if (existsSync22(join27(cand, "schema.ts"))) return cand;
21757
+ const parent = dirname16(dir);
21316
21758
  if (parent === dir) break;
21317
21759
  dir = parent;
21318
21760
  }
@@ -21323,7 +21765,7 @@ function readDoors(backendRoot, unread2) {
21323
21765
  for (const path of listTs(backendRoot, unread2)) {
21324
21766
  let text;
21325
21767
  try {
21326
- text = readFileSync14(path, "utf8");
21768
+ text = readFileSync15(path, "utf8");
21327
21769
  } catch (err) {
21328
21770
  unread2.push(`${path} could not be read (${fsErrorCode(err)})`);
21329
21771
  continue;
@@ -21388,8 +21830,8 @@ function readDoors(backendRoot, unread2) {
21388
21830
  return doors;
21389
21831
  }
21390
21832
  function definitionOf(name, files) {
21391
- const esc4 = name.replace(/\$/g, "\\$");
21392
- const re = new RegExp(`(?:\\b(?:const|let|var)\\s+${esc4}\\b|\\bfunction\\s+${esc4}\\b)`);
21833
+ const esc5 = name.replace(/\$/g, "\\$");
21834
+ const re = new RegExp(`(?:\\b(?:const|let|var)\\s+${esc5}\\b|\\bfunction\\s+${esc5}\\b)`);
21393
21835
  for (const f of files) {
21394
21836
  const hit = re.exec(f.m);
21395
21837
  if (!hit) continue;
@@ -21457,7 +21899,7 @@ function scanS28(tree) {
21457
21899
  if (hit) for (const s of hit[2].matchAll(/["'`]([\w/]+:[\w]+)["'`]/g)) actorDoors.add(s[1]);
21458
21900
  }
21459
21901
  for (const { f, text, m } of files) {
21460
- for (let hit = CALL_RE.exec(m); hit; hit = CALL_RE.exec(m)) {
21902
+ for (let hit = CALL_RE2.exec(m); hit; hit = CALL_RE2.exec(m)) {
21461
21903
  const recv = hit[1];
21462
21904
  if (!/convex|client/i.test(recv)) continue;
21463
21905
  const open = hit.index + hit[0].length - 1;
@@ -21970,7 +22412,7 @@ var s34AccessRecheck = {
21970
22412
  };
21971
22413
 
21972
22414
  // src/detectors/s35-scope-in-read.ts
21973
- var CALL_RE2 = /\b([A-Za-z_$][\w$]*)\s*\.\s*(query|action)\s*\(/g;
22415
+ var CALL_RE3 = /\b([A-Za-z_$][\w$]*)\s*\.\s*(query|action)\s*\(/g;
21974
22416
  var NARROW_WORD = /\b(?:org|orgId|orgSlug|organizationId|organisationId|organization|organisation|tenantId|namespace|recipient|recipientId|owner|ownerId|createdBy|assignedTo|oauthCtx|fromAllowList)\b/;
21975
22417
  var CARRY_WORD = /\b(?:orgId|organizationId|organisationId|tenantId|verifiedOrg|verifiedPerson|verifiedActor|oauthCtx)\b/;
21976
22418
  var PAGINATION_WORD = /\b(?:nextCursor|truncated|hasMore|total)\b/;
@@ -22029,7 +22471,7 @@ function blockEnd(m, at) {
22029
22471
  return m.length;
22030
22472
  }
22031
22473
  var lineAt3 = (m, offset) => m.slice(0, offset).split("\n").length;
22032
- var esc3 = (s) => s.replace(/\$/g, "\\$");
22474
+ var esc4 = (s) => s.replace(/\$/g, "\\$");
22033
22475
  function boundNames(m, callStart) {
22034
22476
  const lineStart = m.lastIndexOf("\n", callStart - 1) + 1;
22035
22477
  const before = m.slice(lineStart, callStart);
@@ -22114,7 +22556,7 @@ function rebound(m, names, from, to) {
22114
22556
  for (const name of names) {
22115
22557
  for (const hit of region.matchAll(
22116
22558
  new RegExp(
22117
- `\\b(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*(?::[^=]+)?=\\s*${esc3(name)}\\s*(?:;|$)`,
22559
+ `\\b(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*(?::[^=]+)?=\\s*${esc4(name)}\\s*(?:;|$)`,
22118
22560
  "gm"
22119
22561
  )
22120
22562
  )) {
@@ -22127,7 +22569,7 @@ function narrowingsOver(m, names, from, to) {
22127
22569
  const out = [];
22128
22570
  const region = m.slice(from, to);
22129
22571
  for (const name of names) {
22130
- const n = esc3(name);
22572
+ const n = esc4(name);
22131
22573
  for (const hit of region.matchAll(/\bscopeFilter(List|Get)\s*\(/g)) {
22132
22574
  const open = from + (hit.index ?? 0) + hit[0].length - 1;
22133
22575
  const close = matchClose3(m, open);
@@ -22173,7 +22615,7 @@ function scanS35(tree) {
22173
22615
  if (!isProductSource(file.rel)) continue;
22174
22616
  const m = masked2(file);
22175
22617
  const raw = file.lines.map((l) => l.raw).join("\n");
22176
- for (const hit of m.matchAll(CALL_RE2)) {
22618
+ for (const hit of m.matchAll(CALL_RE3)) {
22177
22619
  if (!/convex|client/i.test(hit[1])) continue;
22178
22620
  const start = hit.index ?? 0;
22179
22621
  const open = start + hit[0].length - 1;
@@ -22678,6 +23120,17 @@ function declaredVariables(tree) {
22678
23120
  const vars = [];
22679
23121
  const cnj = [];
22680
23122
  const calls = callsMatching(tree, /^defineVariables$/);
23123
+ const literalByKey = /* @__PURE__ */ new Map();
23124
+ for (const c of calls) {
23125
+ const o = c.args[0] ? objectOpenAt(c.src, c.args[0][0]) : -1;
23126
+ for (const p of (o >= 0 ? objectProps(c.src, o) : null) ?? []) {
23127
+ if (p.spread) continue;
23128
+ const vo = objectOpenAt(c.src, p.from + c.src.code.slice(p.from, p.to).indexOf(":") + 1);
23129
+ const env = (vo >= 0 ? objectProps(c.src, vo) : null)?.find((q) => q.key === "env");
23130
+ const name = env ? stringLiteral(env.value) : null;
23131
+ if (name !== null) literalByKey.set(p.key, name);
23132
+ }
23133
+ }
22681
23134
  for (const c of calls) {
22682
23135
  const o = c.args[0] ? objectOpenAt(c.src, c.args[0][0]) : -1;
22683
23136
  const props = o >= 0 ? objectProps(c.src, o) : null;
@@ -22699,7 +23152,14 @@ function declaredVariables(tree) {
22699
23152
  const vo = objectOpenAt(c.src, p.from + c.src.code.slice(p.from, p.to).indexOf(":") + 1);
22700
23153
  const sub = vo >= 0 ? objectProps(c.src, vo) : null;
22701
23154
  const env = sub?.find((q) => q.key === "env");
22702
- const envName = env ? stringLiteral(env.value) : null;
23155
+ let envName = env ? stringLiteral(env.value) : null;
23156
+ if (env && envName === null) {
23157
+ const member = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*\.([A-Za-z_$][\w$]*)\s*$/.exec(
23158
+ env.value
23159
+ );
23160
+ const holder = member ? literalByKey.get(member[1]) : void 0;
23161
+ if (holder !== void 0) envName = `\${${holder}}`;
23162
+ }
22703
23163
  if (!sub || envName === null) {
22704
23164
  cnj.push({
22705
23165
  anchor: anchorAt(c.src, p.from),
@@ -22720,6 +23180,34 @@ function declaredVariables(tree) {
22720
23180
  }
22721
23181
  return { vars, calls: calls.length, cnj };
22722
23182
  }
23183
+ function s37Read(shape, o) {
23184
+ const before = shape.slice(Math.max(0, o - 60), o);
23185
+ const after = shape.slice(o);
23186
+ const id = /^[A-Za-z_$][\w$]*/.exec(after)?.[0] ?? "";
23187
+ const rest = after.slice(id.length);
23188
+ if (/(?:process\.)?env\s*\[\s*$/.test(before) && /^\s*\]/.test(rest)) return true;
23189
+ if (/[{,]\s*[A-Za-z_$][\w$]*\s*:\s*$/.test(before) && /^\s*[,}]/.test(rest)) {
23190
+ const open = openingBrace(shape, o);
23191
+ return open >= 0 && /(?:\breturn|(?:[\w$\])]|\s)=)\s*$/.test(shape.slice(Math.max(0, open - 40), open));
23192
+ }
23193
+ return false;
23194
+ }
23195
+ function openingBrace(shape, o) {
23196
+ let depth = 0;
23197
+ for (let i = o - 1; i >= 0; i--) {
23198
+ const c = shape[i];
23199
+ if (c === "}") depth++;
23200
+ else if (c === "{") {
23201
+ if (depth === 0) return i;
23202
+ depth--;
23203
+ }
23204
+ }
23205
+ return -1;
23206
+ }
23207
+ function loopNamesAt(s, bracket) {
23208
+ const id = /^\s*([A-Za-z_$][\w$]*)\s*\]/.exec(s.code.slice(bracket))?.[1];
23209
+ return id === void 0 ? void 0 : enclosingLoopList(s.shape, s.code, bracket, id, s37Read);
23210
+ }
22723
23211
  function envReads(s) {
22724
23212
  const out = [];
22725
23213
  const m = s.shape;
@@ -22736,6 +23224,12 @@ function envReads(s) {
22736
23224
  out.push({ src: s, at, name: h[2], form: "process.env.NAME", end: at + h[0].length });
22737
23225
  } else {
22738
23226
  const { v, end } = lit(at + h[0].length);
23227
+ const listed = v === null ? loopNamesAt(s, at + h[0].length) : void 0;
23228
+ if (listed) {
23229
+ for (const name of listed)
23230
+ out.push({ src: s, at, name, form: "process.env[<name of a literal list>]", end });
23231
+ continue;
23232
+ }
22739
23233
  out.push({
22740
23234
  src: s,
22741
23235
  at,
@@ -22757,6 +23251,12 @@ function envReads(s) {
22757
23251
  out.push({ src: s, at, name: h[2], form: "env.NAME", end: at + h[0].length });
22758
23252
  } else {
22759
23253
  const { v, end } = lit(at + h[0].length);
23254
+ const listed = v === null ? loopNamesAt(s, at + h[0].length) : void 0;
23255
+ if (listed) {
23256
+ for (const name of listed)
23257
+ out.push({ src: s, at, name, form: "env[<name of a literal list>]", end });
23258
+ continue;
23259
+ }
22760
23260
  out.push({
22761
23261
  src: s,
22762
23262
  at,
@@ -23846,6 +24346,15 @@ function scanS40(tree) {
23846
24346
  }
23847
24347
  res.tools = tools;
23848
24348
  res.applies = tools.length > 0;
24349
+ const upstreamCalled = surface.calls.length > 0 || surface.paginatedClients.length > 0 || surface.tokenConstructions.length > 0;
24350
+ const registered2 = toolRegistrations(tree).regs.length;
24351
+ if (tools.length === 0 && upstreamCalled && registered2 > 0 && res.cnj.length === 0) {
24352
+ const first = surface.calls[0]?.anchor ?? surface.paginatedClients[0]?.anchor ?? surface.tokenConstructions[0]?.anchor;
24353
+ res.cnj.push({
24354
+ anchor: first ?? "-",
24355
+ note: `the tree calls an upstream (first: ${first ?? "a paginated client or token construction"}) and registers ${registered2} tool(s), but no tool handler is traced to that call: whether a tool serves upstream rows is unread`
24356
+ });
24357
+ }
23849
24358
  const usesFilter = (text) => /(?<![\w$.])filterTargetsInPersonScope\s*\(/.test(text);
23850
24359
  for (const t of tools) {
23851
24360
  const s = t.src;
@@ -24447,6 +24956,131 @@ var s41LakeReader = {
24447
24956
  }
24448
24957
  };
24449
24958
 
24959
+ // src/detectors/s44-closed-output.ts
24960
+ var ID2 = "S44 closed-output";
24961
+ var RULE2 = "S-44";
24962
+ function judge(sites, j) {
24963
+ for (const s of sites) {
24964
+ if (s.kind === "unread")
24965
+ j.unread.push({ anchor: s.anchor, reason: `${s.path}: ${s.form} (${RULE2})` });
24966
+ else if (s.exempt) j.exempt.push(s);
24967
+ else j.violations.push(s);
24968
+ }
24969
+ }
24970
+ function verdictOf2(j, scope, anchorFallback) {
24971
+ const ex = j.exempt.length > 0 ? ` Exempted (${j.exempt.length}): ${j.exempt.map((e) => `${e.path} (${e.anchor}) \u2014 "${e.exempt}"`).join("; ")}.` : "";
24972
+ if (j.withOutput === 0 && j.unread.length === 0)
24973
+ return {
24974
+ id: ID2,
24975
+ anchor: anchorFallback,
24976
+ state: "absent",
24977
+ verdict: `${j.toolCount} tool(s) read (${scope}), none declares an output schema \u2014 ${RULE2} n/a`
24978
+ };
24979
+ const decided = j.violations.length > 0 ? {
24980
+ id: ID2,
24981
+ anchor: j.violations[0].anchor,
24982
+ state: "non-conforming",
24983
+ verdict: `${j.violations.length} closed object(s) in the output schemas of ${j.withOutput} tool(s): each refuses a field added later, which breaks every client connected before the release (${RULE2}): ${j.violations.map((v) => `${v.path} (${v.form}, ${v.anchor})`).join(", ")}.${ex}`
24984
+ } : {
24985
+ id: ID2,
24986
+ anchor: anchorFallback,
24987
+ state: "present",
24988
+ verdict: `${j.withOutput} output schema(s) read (${scope}): no object refuses an added field (${RULE2}).${ex}`
24989
+ };
24990
+ return settle(ID2, decided, j.unread);
24991
+ }
24992
+ function s44Controls() {
24993
+ const red = closedServedSites(
24994
+ { type: "object", properties: { a: { type: "string" } }, additionalProperties: false },
24995
+ "c",
24996
+ "<s44-control>"
24997
+ );
24998
+ const green = closedServedSites(
24999
+ { type: "object", properties: { a: { type: "object", properties: {} } } },
25000
+ "c",
25001
+ "<s44-control>"
25002
+ );
25003
+ return {
25004
+ sees: red.length === 1 && red[0].kind === "violation" && red[0].path === "c",
25005
+ spares: green.length === 0
25006
+ };
25007
+ }
25008
+ function runStatic2(tree) {
25009
+ const controls = s44Controls();
25010
+ if (!controls.sees || !controls.spares)
25011
+ throw new Error(
25012
+ `S44 positive control FAILED: sees=${controls.sees} spares=${controls.spares} \u2014 reader broken, verdict untrustworthy`
25013
+ );
25014
+ const inProduct = (a) => isProductSource(a.slice(0, a.lastIndexOf(":")));
25015
+ const tools = findRegisteredTools(tree).filter((t) => inProduct(t.anchor));
25016
+ const unresolved = findUnresolvedToolSites(tree).filter(inProduct);
25017
+ if (tools.length === 0) {
25018
+ const surface = toolSurfaceAnchor(tree);
25019
+ if (surface || unresolved.length > 0) {
25020
+ const reason = noToolsLocatedReason(tree, `no output schema could be read (${RULE2})`);
25021
+ return couldNotJudge(
25022
+ ID2,
25023
+ surface ?? unresolved[0],
25024
+ unresolved.length > 0 ? `${reason}; unresolved registration site(s): ${unresolved.join(", ")}` : reason
25025
+ );
25026
+ }
25027
+ return {
25028
+ id: ID2,
25029
+ anchor: tree.root,
25030
+ state: "absent",
25031
+ verdict: `no MCP tool registered in product source \u2014 ${RULE2} n/a`
25032
+ };
25033
+ }
25034
+ const j = {
25035
+ violations: [],
25036
+ exempt: [],
25037
+ unread: [],
25038
+ toolCount: tools.length,
25039
+ withOutput: 0
25040
+ };
25041
+ for (const a of unresolved)
25042
+ j.unread.push({
25043
+ anchor: a,
25044
+ reason: `a tool registered here has a name the scan cannot resolve, so its output schema is unread (${RULE2})`
25045
+ });
25046
+ for (const tool of tools) {
25047
+ const read = closedOutputSites(tree, tool.name, tool.anchor);
25048
+ if (read.kind === "none") continue;
25049
+ j.withOutput++;
25050
+ judge(read.sites, j);
25051
+ }
25052
+ return verdictOf2(j, "static, from source", tools[0].anchor);
25053
+ }
25054
+ function runServedHalf2(runtime) {
25055
+ const anchor = `${runtime.root} (served)`;
25056
+ if (runtime.launchError)
25057
+ return couldNotJudge(
25058
+ ID2,
25059
+ anchor,
25060
+ `the server could not be started/introspected, so no served outputSchema was read: ${runtime.launchError} (${RULE2})`
25061
+ );
25062
+ const j = {
25063
+ violations: [],
25064
+ exempt: [],
25065
+ unread: [],
25066
+ toolCount: runtime.tools.length,
25067
+ withOutput: 0
25068
+ };
25069
+ for (const t of runtime.tools) {
25070
+ if (t.outputSchema === void 0) continue;
25071
+ j.withOutput++;
25072
+ judge(closedServedSites(t.outputSchema, t.name, `${anchor} tools/list ${t.name}`), j);
25073
+ }
25074
+ return verdictOf2(j, "served tools/list outputSchema", anchor);
25075
+ }
25076
+ var s44ClosedOutput = {
25077
+ id: ID2,
25078
+ rule: RULE2,
25079
+ pin: STANDARD_PIN,
25080
+ run: runStatic2,
25081
+ runServed: (runtime) => runServedHalf2(runtime)
25082
+ };
25083
+
24450
25084
  // src/detectors/index.ts
24451
25085
  var registered = [
24452
25086
  d2,
@@ -24553,6 +25187,7 @@ var registered = [
24553
25187
  s40UpstreamRowsNarrowed,
24554
25188
  s41LakeReader,
24555
25189
  s43UnionInput,
25190
+ s44ClosedOutput,
24556
25191
  e5ExtensionIsolation,
24557
25192
  a3SandboxRespected,
24558
25193
  a4WcagGate,
@@ -24587,6 +25222,7 @@ var READS_CODE = /* @__PURE__ */ new Set([
24587
25222
  "S-40",
24588
25223
  "S-41",
24589
25224
  "S-43",
25225
+ "S-44",
24590
25226
  "E-5",
24591
25227
  "A-3"
24592
25228
  ]);
@@ -24596,18 +25232,18 @@ var detectors = registered.map(
24596
25232
 
24597
25233
  // src/runtime/launch.ts
24598
25234
  import { spawnSync as spawnSync2 } from "child_process";
24599
- import { existsSync as existsSync22, readFileSync as readFileSync15, statSync as statSync21 } from "fs";
24600
- import { dirname as dirname16, isAbsolute, join as join27, resolve as resolve2 } from "path";
25235
+ import { existsSync as existsSync23, readFileSync as readFileSync16, statSync as statSync21 } from "fs";
25236
+ import { dirname as dirname17, isAbsolute, join as join28, resolve as resolve3 } from "path";
24601
25237
  function findPackageDir(target) {
24602
25238
  let dir;
24603
25239
  try {
24604
- dir = statSync21(target).isDirectory() ? target : dirname16(target);
25240
+ dir = statSync21(target).isDirectory() ? target : dirname17(target);
24605
25241
  } catch {
24606
25242
  return null;
24607
25243
  }
24608
25244
  for (let depth = 0; depth < 8; depth++) {
24609
- if (existsSync22(join27(dir, "package.json"))) return dir;
24610
- const parent = dirname16(dir);
25245
+ if (existsSync23(join28(dir, "package.json"))) return dir;
25246
+ const parent = dirname17(dir);
24611
25247
  if (parent === dir) break;
24612
25248
  dir = parent;
24613
25249
  }
@@ -24631,20 +25267,20 @@ function deriveLaunchPlan(target) {
24631
25267
  }
24632
25268
  let pkg;
24633
25269
  try {
24634
- if (!statSync21(join27(pkgDir, "package.json")).isFile()) {
24635
- return { error: `${join27(pkgDir, "package.json")} is not a regular file \u2014 not read` };
25270
+ if (!statSync21(join28(pkgDir, "package.json")).isFile()) {
25271
+ return { error: `${join28(pkgDir, "package.json")} is not a regular file \u2014 not read` };
24636
25272
  }
24637
- pkg = JSON.parse(readFileSync15(join27(pkgDir, "package.json"), "utf8"));
25273
+ pkg = JSON.parse(readFileSync16(join28(pkgDir, "package.json"), "utf8"));
24638
25274
  } catch (err) {
24639
25275
  return {
24640
- error: `could not parse ${join27(pkgDir, "package.json")}: ${err instanceof Error ? err.message : String(err)}`
25276
+ error: `could not parse ${join28(pkgDir, "package.json")}: ${err instanceof Error ? err.message : String(err)}`
24641
25277
  };
24642
25278
  }
24643
25279
  const bin = firstBinEntry(pkg.bin);
24644
25280
  if (bin) {
24645
25281
  return {
24646
25282
  command: process.execPath,
24647
- args: [isAbsolute(bin) ? bin : resolve2(pkgDir, bin)],
25283
+ args: [isAbsolute(bin) ? bin : resolve3(pkgDir, bin)],
24648
25284
  cwd: pkgDir
24649
25285
  };
24650
25286
  }
@@ -24657,7 +25293,7 @@ function deriveLaunchPlan(target) {
24657
25293
  if (main2) {
24658
25294
  return {
24659
25295
  command: process.execPath,
24660
- args: [isAbsolute(main2) ? main2 : resolve2(pkgDir, main2)],
25296
+ args: [isAbsolute(main2) ? main2 : resolve3(pkgDir, main2)],
24661
25297
  cwd: pkgDir
24662
25298
  };
24663
25299
  }
@@ -24957,7 +25593,7 @@ const onMessage = (msg) => {
24957
25593
  const props = schemaOf(t).properties;
24958
25594
  return Boolean(props && typeof props === "object" && Object.prototype.hasOwnProperty.call(props, "cursor"));
24959
25595
  };
24960
- tools = served.map((t) => ({ name: String(t && t.name), description: t && typeof t.description === "string" ? t.description : undefined, cursorArgument: takesCursor(t), inputSchema: t && t.inputSchema && typeof t.inputSchema === "object" && !Array.isArray(t.inputSchema) ? t.inputSchema : undefined }));
25596
+ tools = served.map((t) => ({ name: String(t && t.name), description: t && typeof t.description === "string" ? t.description : undefined, cursorArgument: takesCursor(t), inputSchema: t && t.inputSchema && typeof t.inputSchema === "object" && !Array.isArray(t.inputSchema) ? t.inputSchema : undefined, outputSchema: t && t.outputSchema && typeof t.outputSchema === "object" && !Array.isArray(t.outputSchema) ? t.outputSchema : undefined }));
24961
25597
  const methods = ["tools/list"];
24962
25598
  if (capabilities.resources) methods.push("resources/list", "resources/templates/list");
24963
25599
  if (capabilities.prompts) methods.push("prompts/list");
@@ -25085,14 +25721,14 @@ function readEvalCounts(target) {
25085
25721
  if (!pkgDir) return { counts };
25086
25722
  let dir = pkgDir;
25087
25723
  for (let depth = 0; depth < 8; depth++) {
25088
- const candidate = join27(dir, "evals", "evals.json");
25089
- if (existsSync22(candidate)) {
25724
+ const candidate = join28(dir, "evals", "evals.json");
25725
+ if (existsSync23(candidate)) {
25090
25726
  let text;
25091
25727
  try {
25092
25728
  if (!statSync21(candidate).isFile()) {
25093
25729
  return { counts, unreadable: `${candidate} is not a regular file \u2014 not read` };
25094
25730
  }
25095
- text = readFileSync15(candidate, "utf8");
25731
+ text = readFileSync16(candidate, "utf8");
25096
25732
  } catch (err) {
25097
25733
  return {
25098
25734
  counts,
@@ -25108,7 +25744,7 @@ function readEvalCounts(target) {
25108
25744
  }
25109
25745
  return { counts };
25110
25746
  }
25111
- const parent = dirname16(dir);
25747
+ const parent = dirname17(dir);
25112
25748
  if (parent === dir) break;
25113
25749
  dir = parent;
25114
25750
  }
@@ -25262,7 +25898,8 @@ function introspect(plan, root, evalSource, expectedCommit, evalsNote, secrets)
25262
25898
  const count = evals.counts.get(name);
25263
25899
  const base = t.description ? { name, description: t.description } : { name };
25264
25900
  const withCursor = t.cursorArgument === true ? { ...base, cursorArgument: true } : base;
25265
- const withSchema = t.inputSchema ? { ...withCursor, inputSchema: t.inputSchema } : withCursor;
25901
+ const withInput = t.inputSchema ? { ...withCursor, inputSchema: t.inputSchema } : withCursor;
25902
+ const withSchema = t.outputSchema ? { ...withInput, outputSchema: t.outputSchema } : withInput;
25266
25903
  return count === void 0 ? withSchema : { ...withSchema, evalCaseCount: count };
25267
25904
  });
25268
25905
  return {
@@ -25721,8 +26358,8 @@ var USAGE = [
25721
26358
  ].join("\n");
25722
26359
  function readVersion() {
25723
26360
  try {
25724
- const here = dirname17(fileURLToPath2(import.meta.url));
25725
- const manifest = JSON.parse(readFileSync16(join28(here, "..", "package.json"), "utf8"));
26361
+ const here = dirname18(fileURLToPath2(import.meta.url));
26362
+ const manifest = JSON.parse(readFileSync17(join29(here, "..", "package.json"), "utf8"));
25726
26363
  return manifest.version ?? null;
25727
26364
  } catch {
25728
26365
  return null;
@@ -25842,7 +26479,7 @@ function isDirectInvocation() {
25842
26479
  return false;
25843
26480
  }
25844
26481
  try {
25845
- return realpathSync(resolve3(entry)) === selfReal;
26482
+ return realpathSync(resolve4(entry)) === selfReal;
25846
26483
  } catch {
25847
26484
  return false;
25848
26485
  }