@vantageos/mcp-doctor 0.22.0 → 0.24.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,13 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ dotted,
3
4
  isJudgeable,
5
+ lineOf,
4
6
  parseFile,
5
- scanR4FilterPaths
7
+ propRead,
8
+ scanR4FilterPaths,
9
+ sourceOf,
10
+ unwrap,
11
+ walk
6
12
  } from "./chunk-OLW7SIJF.js";
7
13
 
8
14
  // src/doctor.ts
9
- import { readFileSync as readFileSync28, realpathSync, statSync as statSync27 } from "fs";
10
- import { dirname as dirname19, join as join37, resolve as resolve4 } from "path";
15
+ import { readFileSync as readFileSync30, realpathSync, statSync as statSync27 } from "fs";
16
+ import { dirname as dirname20, join as join38, resolve as resolve4 } from "path";
11
17
  import { fileURLToPath as fileURLToPath2 } from "url";
12
18
 
13
19
  // src/scan.ts
@@ -51,7 +57,7 @@ function isCommentLine(raw) {
51
57
  }
52
58
  var UNSCANNED_RE = /\.(?:m?js|cjs|jsx|mts|cts)$/;
53
59
  var NOT_PRODUCT_NAME_RE = /\.d\.[mc]?ts$|\.(?:test|spec)\.[mc]?[jt]sx?$|\.config\.[mc]?[jt]s$|\.min\./;
54
- function walk(dir, out, onSkip, unscanned = [], seen = { files: 0 }) {
60
+ function walk2(dir, out, onSkip, unscanned = [], seen = { files: 0 }) {
55
61
  let entries;
56
62
  try {
57
63
  entries = readdirSync(dir);
@@ -73,7 +79,7 @@ function walk(dir, out, onSkip, unscanned = [], seen = { files: 0 }) {
73
79
  onSkip(full);
74
80
  continue;
75
81
  }
76
- walk(full, out, onSkip, unscanned, seen);
82
+ walk2(full, out, onSkip, unscanned, seen);
77
83
  continue;
78
84
  }
79
85
  if (!st.isFile()) {
@@ -190,7 +196,7 @@ function loadTree(root, backendRoot) {
190
196
  throw new SubjectUnreadableError(root, "the directory is empty (0 entries)");
191
197
  }
192
198
  const seen = { files: 0 };
193
- walk(root, filePaths, (d, reason) => recordSkip(tree, d, root, reason), unscanned, seen);
199
+ walk2(root, filePaths, (d, reason) => recordSkip(tree, d, root, reason), unscanned, seen);
194
200
  for (const p of filePaths) {
195
201
  try {
196
202
  tree.files.push(loadFile(p, baseDir));
@@ -654,7 +660,7 @@ function findDiskFiles(tree, pred) {
654
660
  const out = [];
655
661
  const refused = [];
656
662
  const base = baseOf(tree);
657
- const walk3 = (dir) => {
663
+ const walk4 = (dir) => {
658
664
  let entries;
659
665
  try {
660
666
  entries = readdirSync2(dir);
@@ -679,14 +685,14 @@ function findDiskFiles(tree, pred) {
679
685
  recordSkip(tree, full, base);
680
686
  continue;
681
687
  }
682
- walk3(full);
688
+ walk4(full);
683
689
  } else {
684
- const rel = relative2(base, full).split(sep2).join("/");
685
- if (!pred(name, rel)) continue;
690
+ const rel2 = relative2(base, full).split(sep2).join("/");
691
+ if (!pred(name, rel2)) continue;
686
692
  if (!st.isFile()) {
687
693
  const why = "not a regular file (FIFO, socket or device) \u2014 not read";
688
694
  recordSkip(tree, full, base, why);
689
- refused.push({ rel, reason: why });
695
+ refused.push({ rel: rel2, reason: why });
690
696
  continue;
691
697
  }
692
698
  try {
@@ -694,14 +700,14 @@ function findDiskFiles(tree, pred) {
694
700
  } catch (err) {
695
701
  const why = `could not be read (${fsErrorCode(err)}) \u2014 not read`;
696
702
  recordSkip(tree, full, base, why);
697
- refused.push({ rel, reason: why });
703
+ refused.push({ rel: rel2, reason: why });
698
704
  continue;
699
705
  }
700
- out.push({ path: full, rel, name });
706
+ out.push({ path: full, rel: rel2, name });
701
707
  }
702
708
  }
703
709
  };
704
- walk3(base);
710
+ walk4(base);
705
711
  return Object.assign(out, { refused });
706
712
  }
707
713
  function readText(path) {
@@ -800,6 +806,7 @@ var MANUFACT_RULES_PIN = "7e5513eff22c0e2174c100d26e0aa40f642a562f";
800
806
  var C40_RULES_PIN = "941156e5734007188d1e3c54adadf3f1a3f84761";
801
807
  var C19_RULES_PIN = "1596b8c552d8b836f4d6044569fb2e15c3bfe6cb";
802
808
  var S51_RULES_PIN = "3b4982f7da3d34f0dc3bb42f8d3f3c5f9480943a";
809
+ var C41_RULES_PIN = "173d3f0bef155a362ffce9fbe9bb4f1d1115e5b8";
803
810
 
804
811
  // src/detectors/dLocalIdentity.ts
805
812
  var CLOUD_IDENTITY_PACKAGE = "@vantageos/cloud-identity";
@@ -1960,6 +1967,38 @@ function splitArgs(text, open, max = Number.POSITIVE_INFINITY) {
1960
1967
  }
1961
1968
  return null;
1962
1969
  }
1970
+ function parameterBehindLocal(body, local, paramNames, nameParam) {
1971
+ const decl = new RegExp(`\\bconst\\s+${local.replace(/\$/g, "\\$")}\\s*(?::[^=\\n]+)?=(?!=)`);
1972
+ const m = body.match(decl);
1973
+ if (!m || m.index === void 0) return -1;
1974
+ const start = m.index + m[0].length;
1975
+ let depth = 0;
1976
+ let end = body.length;
1977
+ for (let i = start; i < body.length; i++) {
1978
+ const c = body[i];
1979
+ if (c === '"' || c === "'" || c === "`") {
1980
+ for (i++; i < body.length && body[i] !== c; i++) if (body[i] === "\\") i++;
1981
+ continue;
1982
+ }
1983
+ if ("([{".includes(c)) depth++;
1984
+ else if (")]}".includes(c)) depth--;
1985
+ else if (c === ";" && depth <= 0) {
1986
+ end = i;
1987
+ break;
1988
+ }
1989
+ if (depth < 0) {
1990
+ end = i;
1991
+ break;
1992
+ }
1993
+ }
1994
+ const init = body.slice(start, end);
1995
+ const read = [];
1996
+ paramNames.forEach((p, k) => {
1997
+ if (p && p !== nameParam && new RegExp(`(?<![\\w$.])${p.replace(/\$/g, "\\$")}(?![\\w$])`).test(init))
1998
+ read.push(k);
1999
+ });
2000
+ return read.length === 1 ? read[0] : -1;
2001
+ }
1963
2002
  function scanWrappers(tree) {
1964
2003
  const cached = wrapperScans.get(tree);
1965
2004
  if (cached) return cached;
@@ -1979,7 +2018,7 @@ function scanWrappers(tree) {
1979
2018
  lineStart.push(off);
1980
2019
  off += l.raw.length + 1;
1981
2020
  }
1982
- const lineOf4 = (idx) => {
2021
+ const lineOf6 = (idx) => {
1983
2022
  let lo = 0;
1984
2023
  let hi = lineStart.length - 1;
1985
2024
  while (lo < hi) {
@@ -2030,12 +2069,13 @@ function scanWrappers(tree) {
2030
2069
  const k = paramNames.indexOf(c[1]);
2031
2070
  if (k < 0) continue;
2032
2071
  idxs.add(k);
2033
- scan.internal.add(`${file.rel}:${lineOf4(bodyOpen + (c.index ?? 0))}`);
2072
+ scan.internal.add(`${file.rel}:${lineOf6(bodyOpen + (c.index ?? 0))}`);
2034
2073
  const after = body.slice((c.index ?? 0) + c[0].length, (c.index ?? 0) + c[0].length + 3e3);
2035
2074
  const dm = after.match(/(?:^|[\s{,])description\b\s*(?::\s*([A-Za-z_$][\w$]*))?\s*[,}]/);
2036
2075
  if (dm) {
2037
2076
  const ref = dm[1] ?? "description";
2038
2077
  descIdx = paramNames.indexOf(ref);
2078
+ if (descIdx < 0) descIdx = parameterBehindLocal(body, ref, paramNames, c[1]);
2039
2079
  }
2040
2080
  }
2041
2081
  if (idxs.size !== 1) return;
@@ -2045,7 +2085,7 @@ function scanWrappers(tree) {
2045
2085
  descIdx,
2046
2086
  file,
2047
2087
  declLine: line.n,
2048
- endLine: lineOf4(bodyEnd)
2088
+ endLine: lineOf6(bodyEnd)
2049
2089
  });
2050
2090
  });
2051
2091
  }
@@ -2725,11 +2765,11 @@ var presentResult = (id, anchor, verdict3) => ({
2725
2765
  state: "present",
2726
2766
  verdict: verdict3
2727
2767
  });
2728
- function isProductSource(rel) {
2768
+ function isProductSource(rel2) {
2729
2769
  return !/(^|\/)(scripts|evals|examples|docs|e2e|test|tests|__tests__|spec|specs|fixtures|mocks?)\//.test(
2730
- rel
2770
+ rel2
2731
2771
  ) && // `bin/` is tooling only at the top of the tree: `src/bin/server.ts` is the stdio entry of a server.
2732
- !/^bin\//.test(rel) && !/\.(?:test|spec)\.[jt]sx?$/.test(rel);
2772
+ !/^bin\//.test(rel2) && !/\.(?:test|spec)\.[jt]sx?$/.test(rel2);
2733
2773
  }
2734
2774
  function productHits(tree, re) {
2735
2775
  return lineHits(tree, re).filter((h) => isProductSource(h.file.rel));
@@ -2786,7 +2826,7 @@ function governingWorkflows(tree) {
2786
2826
  }
2787
2827
  return [];
2788
2828
  }
2789
- function lineOf(text, re) {
2829
+ function lineOf2(text, re) {
2790
2830
  const m = re.exec(text);
2791
2831
  if (!m) return 1;
2792
2832
  return text.slice(0, m.index).split("\n").length;
@@ -3147,7 +3187,7 @@ function collect(base) {
3147
3187
  const out = [];
3148
3188
  const unmeasured = [];
3149
3189
  const relOf = (full) => relative3(base, full).split(sep3).join("/");
3150
- const walk3 = (dir, depth) => {
3190
+ const walk4 = (dir, depth) => {
3151
3191
  if (depth > 8) {
3152
3192
  unmeasured.push(`${relOf(dir)}/ (deeper than 8 levels, not walked)`);
3153
3193
  return;
@@ -3161,35 +3201,35 @@ function collect(base) {
3161
3201
  }
3162
3202
  for (const name of entries.sort()) {
3163
3203
  const full = join4(dir, name);
3164
- const rel = relOf(full);
3165
- const candidate = BUNDLE_EXT_RE.test(name) && UI_PATH_RE.test(rel);
3204
+ const rel2 = relOf(full);
3205
+ const candidate = BUNDLE_EXT_RE.test(name) && UI_PATH_RE.test(rel2);
3166
3206
  let st;
3167
3207
  try {
3168
3208
  st = statSync5(full);
3169
3209
  } catch {
3170
- if (candidate) unmeasured.push(`${rel} (cannot be read: dangling link or permission)`);
3210
+ if (candidate) unmeasured.push(`${rel2} (cannot be read: dangling link or permission)`);
3171
3211
  continue;
3172
3212
  }
3173
3213
  if (st.isDirectory()) {
3174
- if (!WALK_SKIP.has(name)) walk3(full, depth + 1);
3214
+ if (!WALK_SKIP.has(name)) walk4(full, depth + 1);
3175
3215
  } else if (candidate) {
3176
3216
  if (!st.isFile()) {
3177
- unmeasured.push(`${rel} (not a regular file, not read)`);
3217
+ unmeasured.push(`${rel2} (not a regular file, not read)`);
3178
3218
  continue;
3179
3219
  }
3180
3220
  if (st.size > MAX_MEASURE_BYTES) {
3181
- unmeasured.push(`${rel} (${(st.size / 1048576).toFixed(0)} MB, too large to measure)`);
3221
+ unmeasured.push(`${rel2} (${(st.size / 1048576).toFixed(0)} MB, too large to measure)`);
3182
3222
  continue;
3183
3223
  }
3184
3224
  try {
3185
- out.push({ rel, gz: gzipSync(readFileSync4(full), { level: 9 }).length });
3225
+ out.push({ rel: rel2, gz: gzipSync(readFileSync4(full), { level: 9 }).length });
3186
3226
  } catch {
3187
- unmeasured.push(`${rel} (read or compression failed)`);
3227
+ unmeasured.push(`${rel2} (read or compression failed)`);
3188
3228
  }
3189
3229
  }
3190
3230
  }
3191
3231
  };
3192
- walk3(base, 0);
3232
+ walk4(base, 0);
3193
3233
  return { bundles: out, unmeasured };
3194
3234
  }
3195
3235
  var kb = (n) => `${(n / 1024).toFixed(1)} KB gz`;
@@ -4546,7 +4586,7 @@ function readDeclaredUpstreams(tree) {
4546
4586
  const decls = [];
4547
4587
  const unreadable2 = [];
4548
4588
  let located = false;
4549
- const fromJson = (rel, v) => {
4589
+ const fromJson = (rel2, v) => {
4550
4590
  if (v === null || typeof v !== "object") return;
4551
4591
  const root = v;
4552
4592
  const holders = [
@@ -4562,7 +4602,7 @@ function readDeclaredUpstreams(tree) {
4562
4602
  const add = (name, o) => {
4563
4603
  if (typeof name !== "string") return;
4564
4604
  const t = o && typeof o === "object" ? o.tenancy : void 0;
4565
- decls.push({ name, tenancy: typeof t === "string" ? t : void 0, anchor: `${rel}:1` });
4605
+ decls.push({ name, tenancy: typeof t === "string" ? t : void 0, anchor: `${rel2}:1` });
4566
4606
  };
4567
4607
  if (Array.isArray(u)) {
4568
4608
  for (const e of u) {
@@ -4573,8 +4613,8 @@ function readDeclaredUpstreams(tree) {
4573
4613
  for (const [k, e] of Object.entries(u)) add(k, e);
4574
4614
  } else {
4575
4615
  unreadable2.push({
4576
- anchor: `${rel}:1`,
4577
- reason: `${rel} has an \`upstreams\` key that is neither a list nor an object`
4616
+ anchor: `${rel2}:1`,
4617
+ reason: `${rel2} has an \`upstreams\` key that is neither a list nor an object`
4578
4618
  });
4579
4619
  }
4580
4620
  }
@@ -4695,9 +4735,9 @@ function insideLoop(s, off) {
4695
4735
  function controlTree(files) {
4696
4736
  return {
4697
4737
  root: "/nonexistent-control-root",
4698
- files: Object.entries(files).map(([rel, text]) => ({
4699
- path: rel,
4700
- rel,
4738
+ files: Object.entries(files).map(([rel2, text]) => ({
4739
+ path: rel2,
4740
+ rel: rel2,
4701
4741
  lines: text.split("\n").map((raw, i) => ({ n: i + 1, raw, comment: false }))
4702
4742
  })),
4703
4743
  packageJson: null,
@@ -6413,8 +6453,8 @@ function skillsCacheProblems(tree) {
6413
6453
  let first = "";
6414
6454
  for (const [method, anchors] of sites) {
6415
6455
  for (const anchor of anchors) {
6416
- const rel = anchor.slice(0, anchor.lastIndexOf(":"));
6417
- if (!(ttl.some((h) => h.file.rel === rel) && scope2.some((h) => h.file.rel === rel))) {
6456
+ const rel2 = anchor.slice(0, anchor.lastIndexOf(":"));
6457
+ if (!(ttl.some((h) => h.file.rel === rel2) && scope2.some((h) => h.file.rel === rel2))) {
6418
6458
  problems.push(`${method} (${anchor})`);
6419
6459
  first = first || anchor;
6420
6460
  }
@@ -6658,16 +6698,16 @@ function hostToolProblems(tree) {
6658
6698
  const unresolvedSites = findUnresolvedToolSites(tree);
6659
6699
  const named = [];
6660
6700
  for (const c of caps) {
6661
- for (const ts6 of TOOL_SETTINGS) {
6662
- if (c.key !== ts6.cap) continue;
6701
+ for (const ts9 of TOOL_SETTINGS) {
6702
+ if (c.key !== ts9.cap) continue;
6663
6703
  const m = c.body.match(
6664
- new RegExp(`["'\`]?${ts6.setting}["'\`]?\\s*:\\s*["'\`]([^"'\`]+)["'\`]`)
6704
+ new RegExp(`["'\`]?${ts9.setting}["'\`]?\\s*:\\s*["'\`]([^"'\`]+)["'\`]`)
6665
6705
  );
6666
6706
  if (m)
6667
6707
  named.push({
6668
6708
  name: m[1],
6669
- kind: ts6.kind,
6670
- from: `${ts6.cap}.${ts6.setting}`,
6709
+ kind: ts9.kind,
6710
+ from: `${ts9.cap}.${ts9.setting}`,
6671
6711
  anchor: c.anchor
6672
6712
  });
6673
6713
  }
@@ -6736,11 +6776,11 @@ function hostToolProblems(tree) {
6736
6776
  text: `${n.from} tool \`${n.name}\` does not list "app" in ui.visibility`
6737
6777
  });
6738
6778
  }
6739
- const rel = t.anchor.slice(0, t.anchor.lastIndexOf(":"));
6740
- if (!lineHits(tree, /resource_link|ResourceLink/).some((h) => h.file.rel === rel)) {
6779
+ const rel2 = t.anchor.slice(0, t.anchor.lastIndexOf(":"));
6780
+ if (!lineHits(tree, /resource_link|ResourceLink/).some((h) => h.file.rel === rel2)) {
6741
6781
  problems.push({
6742
6782
  anchor: t.anchor,
6743
- text: `${n.from} tool \`${n.name}\` never returns a ResourceLink (no resource_link in ${rel})`
6783
+ text: `${n.from} tool \`${n.name}\` never returns a ResourceLink (no resource_link in ${rel2})`
6744
6784
  });
6745
6785
  }
6746
6786
  }
@@ -6865,8 +6905,8 @@ var a9Entrypoint = {
6865
6905
  reason: "no ontoolresult / onToolResult handler is found in the tree \u2014 whether the first view renders from the initial tool result is unread"
6866
6906
  });
6867
6907
  }
6868
- for (const rel of handlerFiles) {
6869
- const file = tree.files.find((f) => f.rel === rel);
6908
+ for (const rel2 of handlerFiles) {
6909
+ const file = tree.files.find((f) => f.rel === rel2);
6870
6910
  if (!file) continue;
6871
6911
  const handler = codeSites(
6872
6912
  { ...tree, files: [file] },
@@ -6876,7 +6916,7 @@ var a9Entrypoint = {
6876
6916
  if (handler && connect && connect.line.n < handler.line.n) {
6877
6917
  reds.push({
6878
6918
  anchor: handler.anchor,
6879
- text: `${rel}: ontoolresult is registered at line ${handler.line.n}, AFTER connect at line ${connect.line.n} \u2014 the initial tool result can arrive before the handler exists (register ontoolresult before connect)`
6919
+ text: `${rel2}: ontoolresult is registered at line ${handler.line.n}, AFTER connect at line ${connect.line.n} \u2014 the initial tool result can arrive before the handler exists (register ontoolresult before connect)`
6880
6920
  });
6881
6921
  }
6882
6922
  }
@@ -7216,8 +7256,8 @@ function resourceCallEnd(file, n) {
7216
7256
  }
7217
7257
  return file.lines.length;
7218
7258
  }
7219
- var within = (r, rel, n) => (r.get(rel) ?? []).some(([a, b]) => n >= a && n <= b);
7220
- var addRange = (r, rel, a, b) => r.set(rel, [...r.get(rel) ?? [], [a, b]]);
7259
+ var within = (r, rel2, n) => (r.get(rel2) ?? []).some(([a, b]) => n >= a && n <= b);
7260
+ var addRange = (r, rel2, a, b) => r.set(rel2, [...r.get(rel2) ?? [], [a, b]]);
7221
7261
  function run(tree) {
7222
7262
  const covered = /* @__PURE__ */ new Map();
7223
7263
  const consts = /* @__PURE__ */ new Set();
@@ -7685,7 +7725,7 @@ var MECHANISM_BASE_SET = /* @__PURE__ */ new Set([
7685
7725
  "indexed-hybrid-rrf",
7686
7726
  "upstream-delegated"
7687
7727
  ]);
7688
- var isDataLayerFile = (rel) => /(^|\/)convex\//.test(rel);
7728
+ var isDataLayerFile = (rel2) => /(^|\/)convex\//.test(rel2);
7689
7729
  function judgeIndexedFromSource(tree, id, indexed) {
7690
7730
  const names2 = indexed.map((t) => `"${t.name}" (${t.searchMechanism})`).join(", ");
7691
7731
  const dataLayer = tree.files.filter((f) => isJudgeable(f) && isDataLayerFile(f.rel));
@@ -9172,7 +9212,7 @@ function jsonToS(v, root, seen, depth = 0) {
9172
9212
  return v.enum !== void 0 || v.const !== void 0 ? SCALAR : { k: "any" };
9173
9213
  return parts.length === 1 ? parts[0] : { k: "all", parts };
9174
9214
  }
9175
- function walk2(s, path, useAt, out, loc) {
9215
+ function walk3(s, path, useAt, out, loc) {
9176
9216
  const offsetsFor = (...offs) => offs.filter((o) => o !== void 0);
9177
9217
  switch (s.k) {
9178
9218
  case "union": {
@@ -9201,18 +9241,18 @@ function walk2(s, path, useAt, out, loc) {
9201
9241
  anchor: loc(unreadB[0].at ?? s.at ?? useAt).anchor
9202
9242
  });
9203
9243
  }
9204
- for (const b of branches2) if (b.k !== "unread") walk2(b, path, useAt, out, loc);
9244
+ for (const b of branches2) if (b.k !== "unread") walk3(b, path, useAt, out, loc);
9205
9245
  return;
9206
9246
  }
9207
9247
  case "array":
9208
- if (s.items) walk2(s.items, `${path}[]`, useAt, out, loc);
9209
- s.prefix.forEach((p, i) => walk2(p, `${path}[${i}]`, useAt, out, loc));
9248
+ if (s.items) walk3(s.items, `${path}[]`, useAt, out, loc);
9249
+ s.prefix.forEach((p, i) => walk3(p, `${path}[${i}]`, useAt, out, loc));
9210
9250
  return;
9211
9251
  case "object":
9212
- for (const p of s.props) walk2(p.schema, `${path}.${p.label}`, p.at ?? useAt, out, loc);
9252
+ for (const p of s.props) walk3(p.schema, `${path}.${p.label}`, p.at ?? useAt, out, loc);
9213
9253
  return;
9214
9254
  case "all":
9215
- for (const p of s.parts) walk2(p, path, useAt, out, loc);
9255
+ for (const p of s.parts) walk3(p, path, useAt, out, loc);
9216
9256
  return;
9217
9257
  case "unread":
9218
9258
  out.push({
@@ -9540,7 +9580,7 @@ function runStatic(tree) {
9540
9580
  const finalSchema = located.kind === "json" ? jsonSchemaOf(located.node, ctx) : evalZod(located.node, ctx);
9541
9581
  j.argumentCount += countArgs(finalSchema);
9542
9582
  const sites = [];
9543
- walk2(finalSchema, tool.name, void 0, sites, loc);
9583
+ walk3(finalSchema, tool.name, void 0, sites, loc);
9544
9584
  judgeSites(dedupe(sites), false, j);
9545
9585
  }
9546
9586
  return verdictOf(j, "static, from source", tools[0].anchor);
@@ -9583,7 +9623,7 @@ function runServedHalf(runtime) {
9583
9623
  const schema = jsonToS(t.inputSchema, { root: t.inputSchema }, /* @__PURE__ */ new Set());
9584
9624
  j.argumentCount += countArgs(schema);
9585
9625
  const sites = [];
9586
- walk2(schema, t.name, void 0, sites, () => ({ anchor: `${anchor} tools/list ${t.name}` }));
9626
+ walk3(schema, t.name, void 0, sites, () => ({ anchor: `${anchor} tools/list ${t.name}` }));
9587
9627
  judgeSites(dedupe(sites), true, j);
9588
9628
  }
9589
9629
  return verdictOf(j, "served tools/list inputSchema", anchor);
@@ -9763,7 +9803,7 @@ function controlSites(text) {
9763
9803
  if (located.kind !== "zod") return [];
9764
9804
  const ctx = moduleCtx(file, null);
9765
9805
  const sites = [];
9766
- walk2(evalZod(located.node, ctx), "c", void 0, sites, () => ({ anchor: "<s43-control>" }));
9806
+ walk3(evalZod(located.node, ctx), "c", void 0, sites, () => ({ anchor: "<s43-control>" }));
9767
9807
  return sites;
9768
9808
  }
9769
9809
  function s43Controls() {
@@ -10308,7 +10348,7 @@ function ceilingCensus(tree) {
10308
10348
  continue;
10309
10349
  }
10310
10350
  if (!isRecord(json) || !("contextCeiling" in json)) continue;
10311
- const anchor = `${f.rel}:${lineOf(text, /"contextCeiling"/)}`;
10351
+ const anchor = `${f.rel}:${lineOf2(text, /"contextCeiling"/)}`;
10312
10352
  const c = json.contextCeiling;
10313
10353
  if (!isRecord(c)) {
10314
10354
  census.partial.push({
@@ -11030,8 +11070,8 @@ function findProvenanceClaim(tree, root, unreadable2) {
11030
11070
  const hit = workflowStatements(text).find(([, l]) => PROVENANCE_RE2.test(l));
11031
11071
  if (hit) {
11032
11072
  const line = hit[0];
11033
- const rel = relative4(root, workflowsDir) || WORKFLOW_DIR;
11034
- return { site: `${rel}/${name}:${line}`, text };
11073
+ const rel2 = relative4(root, workflowsDir) || WORKFLOW_DIR;
11074
+ return { site: `${rel2}/${name}:${line}`, text };
11035
11075
  }
11036
11076
  }
11037
11077
  }
@@ -11463,23 +11503,79 @@ var BARE_STRING_RE = /^\s*["'`]([^"'`]+)["'`]\s*,?\s*$/;
11463
11503
  var BACKWARD_LOOKBACK = 10;
11464
11504
  var FORWARD_LOOKAHEAD = 6;
11465
11505
  var DESCRIPTION_KEY_RE = /\bdescription\s*:/;
11506
+ function templateLength(s) {
11507
+ let i = 1;
11508
+ while (i < s.length) {
11509
+ const c = s[i];
11510
+ if (c === "\\") i += 2;
11511
+ else if (c === "`") return i + 1;
11512
+ else if (c === "$" && s[i + 1] === "{") {
11513
+ let depth = 1;
11514
+ i += 2;
11515
+ while (i < s.length && depth > 0) {
11516
+ const d = s[i];
11517
+ if (d === "`") {
11518
+ const inner = templateLength(s.slice(i));
11519
+ if (inner < 0) return -1;
11520
+ i += inner;
11521
+ continue;
11522
+ }
11523
+ if (d === '"' || d === "'") {
11524
+ for (i++; i < s.length && s[i] !== d; i++) if (s[i] === "\\") i++;
11525
+ } else if (d === "{") depth++;
11526
+ else if (d === "}") depth--;
11527
+ i++;
11528
+ }
11529
+ } else i++;
11530
+ }
11531
+ return -1;
11532
+ }
11533
+ function readDeclaredDescription(text) {
11534
+ let rest = text.replace(/^\s+/, "");
11535
+ let acc = "";
11536
+ let first = true;
11537
+ for (; ; ) {
11538
+ const q = rest[0];
11539
+ let len2 = -1;
11540
+ if (q === "`") len2 = templateLength(rest);
11541
+ else if (q === '"' || q === "'") {
11542
+ let i = 1;
11543
+ while (i < rest.length && rest[i] !== q && rest[i] !== "\n") i += rest[i] === "\\" ? 2 : 1;
11544
+ if (rest[i] === q) len2 = i + 1;
11545
+ }
11546
+ if (len2 < 0) {
11547
+ const expr = rest.split("\n")[0].trim().slice(0, 60);
11548
+ return { kind: "non-literal", expr: first ? expr : `\u2026+ ${expr}` };
11549
+ }
11550
+ first = false;
11551
+ const piece = rest.slice(0, len2);
11552
+ const lit = q === "`" ? readDescriptionValue(piece) : void 0;
11553
+ acc += lit?.kind === "literal" ? lit.text : q === "`" ? piece : piece.slice(1, -1);
11554
+ rest = rest.slice(len2).replace(/^\s+/, "");
11555
+ if (rest.startsWith("+")) {
11556
+ rest = rest.slice(1).replace(/^\s+/, "");
11557
+ continue;
11558
+ }
11559
+ return { kind: "literal", text: acc };
11560
+ }
11561
+ }
11466
11562
  function findInlineDescription(tree, siteAnchor, toolName2) {
11467
11563
  const forwarded = wrapperDescriptionArg(tree, siteAnchor);
11468
11564
  if (forwarded !== void 0) {
11469
11565
  const resolved = /^[A-Za-z_$][\w$]*$/.test(forwarded) ? constExpression(tree, forwarded) : null;
11470
- const v = readDescriptionValue(resolved ?? forwarded);
11566
+ const v = readDeclaredDescription(resolved ?? forwarded);
11471
11567
  if (v.kind === "literal" && v.text.length > 0) return v.text;
11472
11568
  if (v.kind === "non-literal") return v;
11473
11569
  }
11474
- const [rel, lineStr] = siteAnchor.split(":");
11475
- const file = tree.files.find((f) => f.rel === rel);
11570
+ const [rel2, lineStr] = siteAnchor.split(":");
11571
+ const file = tree.files.find((f) => f.rel === rel2);
11476
11572
  if (!file) return void 0;
11477
11573
  const siteLine = Number.parseInt(lineStr, 10);
11478
11574
  let floor = 1;
11479
11575
  for (const other of findRegisteredTools(tree)) {
11480
11576
  const [orel, oline] = other.anchor.split(":");
11481
11577
  const n = Number.parseInt(oline, 10);
11482
- if (orel === rel && n < siteLine) floor = Math.max(floor, ownCallEnd(file, n) + 1);
11578
+ if (orel === rel2 && n < siteLine) floor = Math.max(floor, ownCallEnd(file, n) + 1);
11483
11579
  }
11484
11580
  const start = Math.max(floor, siteLine - BACKWARD_LOOKBACK);
11485
11581
  const end = Math.min(siteLine + FORWARD_LOOKAHEAD, file.lines.length + 1);
@@ -11493,7 +11589,7 @@ function findInlineDescription(tree, siteAnchor, toolName2) {
11493
11589
  if (key && key.index !== void 0) {
11494
11590
  const after = line.raw.slice(key.index + key[0].length);
11495
11591
  const tail = file.lines.slice(n, n + 8).filter((l) => !l.comment).map((l) => l.raw).join("\n");
11496
- const v = readDescriptionValue(`${after}
11592
+ const v = readDeclaredDescription(`${after}
11497
11593
  ${tail}`);
11498
11594
  if (v.kind === "literal" && v.text.length > 0) return v.text;
11499
11595
  if (v.kind === "non-literal") {
@@ -11507,6 +11603,12 @@ ${tail}`);
11507
11603
  if (n >= siteLine) {
11508
11604
  const bare = line.raw.match(BARE_STRING_RE);
11509
11605
  if (bare && bare[1] !== toolName2) return bare[1];
11606
+ if (!bare && /^\s*(["'`]).*\1\s*\+\s*$/.test(line.raw)) {
11607
+ const chain = file.lines.slice(n - 1, n + 8).filter((l) => !l.comment).map((l) => l.raw).join("\n");
11608
+ const v = readDeclaredDescription(chain);
11609
+ if (v.kind === "literal" && v.text.length > 0 && v.text !== toolName2) return v.text;
11610
+ if (v.kind === "non-literal" && !nonLiteral) nonLiteral = v;
11611
+ }
11510
11612
  }
11511
11613
  }
11512
11614
  return nonLiteral;
@@ -12162,7 +12264,7 @@ var c24AcceptanceAtDispatch = {
12162
12264
  `C24 positive control FAILED: ${JSON.stringify(ctl)} \u2014 the dispatch matcher cannot tell an instrument job from another, verdict untrustworthy`
12163
12265
  );
12164
12266
  }
12165
- const candidates = diskText(tree, (_name, rel) => DISPATCH_PATH_RE.test(rel));
12267
+ const candidates = diskText(tree, (_name, rel2) => DISPATCH_PATH_RE.test(rel2));
12166
12268
  const docs = candidates.filter((d) => INSTRUMENT_RE.test(d.text) && ACTION_RE.test(d.text));
12167
12269
  const unreadDocs = refusedAsUnreadable(
12168
12270
  candidates.refused,
@@ -12829,10 +12931,10 @@ function renderCoverage(scope2, verdicts) {
12829
12931
  }
12830
12932
  }
12831
12933
  return verdicts.map((v) => {
12832
- const rel = relative5(process.cwd(), v.site.dir) || v.site.dir;
12833
- if (v.status === "skipped") return `SKIPPED ${rel} (${v.reason})`;
12834
- if (v.status === "unreadable") return `UNREAD ${rel} (${v.reason})`;
12835
- return `ANALYSED ${rel} -> ${v.ok ? "GREEN" : "RED"}: ${v.detail}`;
12934
+ const rel2 = relative5(process.cwd(), v.site.dir) || v.site.dir;
12935
+ if (v.status === "skipped") return `SKIPPED ${rel2} (${v.reason})`;
12936
+ if (v.status === "unreadable") return `UNREAD ${rel2} (${v.reason})`;
12937
+ return `ANALYSED ${rel2} -> ${v.ok ? "GREEN" : "RED"}: ${v.detail}`;
12836
12938
  }).join(" | ");
12837
12939
  }
12838
12940
  var c26SubpackageLockfile = {
@@ -13096,7 +13198,7 @@ function workflowEvidence(text) {
13096
13198
  if (NOTIFY_RE.test(window)) signal = i + 1;
13097
13199
  }
13098
13200
  });
13099
- const identity = IDENTITY_CHECK_RE.test(text) ? lineOf(text, IDENTITY_CHECK_RE) : null;
13201
+ const identity = IDENTITY_CHECK_RE.test(text) ? lineOf2(text, IDENTITY_CHECK_RE) : null;
13100
13202
  return { signal, identity };
13101
13203
  }
13102
13204
  var c28DeployFailureSignal = {
@@ -13145,7 +13247,7 @@ var c28DeployFailureSignal = {
13145
13247
  for (const w of deploys) {
13146
13248
  const ev = workflowEvidence(w.text);
13147
13249
  if (ev.signal === null && ev.identity === null) {
13148
- reds.push(`${w.rel}:${lineOf(w.text, DEPLOY_RE)}`);
13250
+ reds.push(`${w.rel}:${lineOf2(w.text, DEPLOY_RE)}`);
13149
13251
  } else {
13150
13252
  oks.push({
13151
13253
  rel: w.rel,
@@ -13192,15 +13294,15 @@ function pluginPackages(tree) {
13192
13294
  }
13193
13295
  return [...out].sort();
13194
13296
  }
13195
- function filesUnder(dir, unread2, rel) {
13297
+ function filesUnder(dir, unread2, rel2) {
13196
13298
  const out = /* @__PURE__ */ new Map();
13197
13299
  let incomplete = false;
13198
- const walk3 = (d, prefix) => {
13300
+ const walk4 = (d, prefix) => {
13199
13301
  let names2;
13200
13302
  try {
13201
13303
  names2 = readdirSync8(d);
13202
13304
  } catch (e) {
13203
- unread2.push({ anchor: rel, reason: `${prefix || "."} not listed (${e.message})` });
13305
+ unread2.push({ anchor: rel2, reason: `${prefix || "."} not listed (${e.message})` });
13204
13306
  incomplete = true;
13205
13307
  return;
13206
13308
  }
@@ -13208,29 +13310,29 @@ function filesUnder(dir, unread2, rel) {
13208
13310
  const full = join12(d, n);
13209
13311
  const r = prefix ? `${prefix}/${n}` : n;
13210
13312
  try {
13211
- if (statSync11(full).isDirectory()) walk3(full, r);
13313
+ if (statSync11(full).isDirectory()) walk4(full, r);
13212
13314
  else out.set(r, readFileSync11(full));
13213
13315
  } catch (e) {
13214
13316
  out.set(r, null);
13215
13317
  unread2.push({
13216
- anchor: `${rel}/${r}`,
13318
+ anchor: `${rel2}/${r}`,
13217
13319
  reason: `not read (${e.message}): not compared`
13218
13320
  });
13219
13321
  }
13220
13322
  }
13221
13323
  };
13222
- walk3(dir, "");
13324
+ walk4(dir, "");
13223
13325
  return { files: out, incomplete };
13224
13326
  }
13225
- function absenceOf(base, rel) {
13327
+ function absenceOf(base, rel2) {
13226
13328
  try {
13227
- statSync11(join12(base, rel));
13228
- return `${rel} exists but was not read by the scan`;
13329
+ statSync11(join12(base, rel2));
13330
+ return `${rel2} exists but was not read by the scan`;
13229
13331
  } catch (e) {
13230
13332
  if (e.code !== "ENOENT")
13231
- return `${rel} not read (${e.message})`;
13333
+ return `${rel2} not read (${e.message})`;
13232
13334
  }
13233
- const parts = rel.split("/");
13335
+ const parts = rel2.split("/");
13234
13336
  for (let i = parts.length - 1; i >= 0; i--) {
13235
13337
  const dir = parts.slice(0, i).join("/");
13236
13338
  try {
@@ -13238,7 +13340,7 @@ function absenceOf(base, rel) {
13238
13340
  return true;
13239
13341
  } catch (e) {
13240
13342
  if (e.code === "ENOENT") continue;
13241
- return `${dir || "."} not listed (${e.message}): whether ${rel} is there is not read`;
13343
+ return `${dir || "."} not listed (${e.message}): whether ${rel2} is there is not read`;
13242
13344
  }
13243
13345
  }
13244
13346
  return true;
@@ -13248,22 +13350,22 @@ function packageSkillProblems(tree, skillFiles, unread2) {
13248
13350
  const packages = pluginPackages(tree);
13249
13351
  if (packages.length === 0 || skillFiles.length === 0) return [];
13250
13352
  const skillsRoot = (pkg) => pkg ? `${pkg}/skills` : "skills";
13251
- const inPackage = (rel) => packages.some((p) => rel.startsWith(`${skillsRoot(p)}/`));
13353
+ const inPackage = (rel2) => packages.some((p) => rel2.startsWith(`${skillsRoot(p)}/`));
13252
13354
  const names2 = [...new Set(skillFiles.map((s) => s.dir))].sort();
13253
13355
  const out = [];
13254
13356
  for (const pkg of packages) {
13255
13357
  const at = pkg || ".";
13256
13358
  const missing = [];
13257
13359
  for (const name of names2) {
13258
- const rel = `${skillsRoot(pkg)}/${name}/SKILL.md`;
13259
- const copy = skillFiles.find((s) => s.rel === rel);
13360
+ const rel2 = `${skillsRoot(pkg)}/${name}/SKILL.md`;
13361
+ const copy = skillFiles.find((s) => s.rel === rel2);
13260
13362
  if (!copy) {
13261
- const absent = absenceOf(base, rel);
13363
+ const absent = absenceOf(base, rel2);
13262
13364
  if (absent === true) missing.push(name);
13263
- else unread2.push({ anchor: rel, reason: absent });
13365
+ else unread2.push({ anchor: rel2, reason: absent });
13264
13366
  continue;
13265
13367
  }
13266
- const served = skillFiles.find((s) => s.dir === name && s.rel !== rel && !inPackage(s.rel));
13368
+ const served = skillFiles.find((s) => s.dir === name && s.rel !== rel2 && !inPackage(s.rel));
13267
13369
  if (!served) {
13268
13370
  if (pkg) {
13269
13371
  const servedRel = `skills/${name}/SKILL.md`;
@@ -13273,7 +13375,7 @@ function packageSkillProblems(tree, skillFiles, unread2) {
13273
13375
  continue;
13274
13376
  }
13275
13377
  const servedDir = served.rel.slice(0, -"/SKILL.md".length);
13276
- const copyDir = rel.slice(0, -"/SKILL.md".length);
13378
+ const copyDir = rel2.slice(0, -"/SKILL.md".length);
13277
13379
  const servedWalk = filesUnder(join12(base, servedDir), unread2, servedDir);
13278
13380
  const copyWalk = filesUnder(join12(base, copyDir), unread2, copyDir);
13279
13381
  const a = servedWalk.files;
@@ -13287,7 +13389,7 @@ function packageSkillProblems(tree, skillFiles, unread2) {
13287
13389
  });
13288
13390
  if (missingFiles.length + extraFiles.length + differing.length > 0)
13289
13391
  out.push({
13290
- anchor: rel,
13392
+ anchor: rel2,
13291
13393
  text: `the package copy ${copyDir}/ is not derived from the served ${servedDir}/: ${[
13292
13394
  missingFiles.length ? `missing ${missingFiles.join(", ")}` : "",
13293
13395
  differing.length ? `differing ${differing.join(", ")}` : "",
@@ -13599,16 +13701,16 @@ function judgeServers(servers, anchor, out) {
13599
13701
  }
13600
13702
  }
13601
13703
  function judgeFolder(tree, folder, manifestPath2, out) {
13602
- const rel = (p) => relative8(tree.root, p).split(sep5).join("/") || ".";
13704
+ const rel2 = (p) => relative8(tree.root, p).split(sep5).join("/") || ".";
13603
13705
  const manifest = readJsonRecord(manifestPath2);
13604
13706
  if (!manifest) {
13605
13707
  out.unreadable.push({
13606
- anchor: rel(manifestPath2),
13607
- reason: `${rel(manifestPath2)} is present but is not a parseable JSON object \u2014 the plugin cannot be judged`
13708
+ anchor: rel2(manifestPath2),
13709
+ reason: `${rel2(manifestPath2)} is present but is not a parseable JSON object \u2014 the plugin cannot be judged`
13608
13710
  });
13609
13711
  return;
13610
13712
  }
13611
- const a = rel(manifestPath2);
13713
+ const a = rel2(manifestPath2);
13612
13714
  const name = manifest.name;
13613
13715
  if (typeof name !== "string" || !KEBAB_RE.test(name)) {
13614
13716
  out.reds.push({
@@ -13637,8 +13739,8 @@ function judgeFolder(tree, folder, manifestPath2, out) {
13637
13739
  } catch (err) {
13638
13740
  folderListed = false;
13639
13741
  out.unreadable.push({
13640
- anchor: rel(folder),
13641
- reason: `${rel(folder)} cannot be listed (${fsErrorCode(err)}) \u2014 whether it carries a LICENSE file is unread`
13742
+ anchor: rel2(folder),
13743
+ reason: `${rel2(folder)} cannot be listed (${fsErrorCode(err)}) \u2014 whether it carries a LICENSE file is unread`
13642
13744
  });
13643
13745
  }
13644
13746
  if (!hasLicenseField && !hasLicenseFile && folderListed) {
@@ -13651,16 +13753,16 @@ function judgeFolder(tree, folder, manifestPath2, out) {
13651
13753
  const readme = readText(readmePath);
13652
13754
  if (readme === null && existsSync11(readmePath)) {
13653
13755
  out.unreadable.push({
13654
- anchor: rel(readmePath),
13655
- 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`
13756
+ anchor: rel2(readmePath),
13757
+ reason: `${rel2(readmePath)} is present but cannot be read as text (permission, or not a regular file) \u2014 its length and credential content are unread`
13656
13758
  });
13657
13759
  } else if (readme === null) {
13658
- out.reds.push({ anchor: rel(folder), text: "no README.md at the plugin folder root" });
13760
+ out.reds.push({ anchor: rel2(folder), text: "no README.md at the plugin folder root" });
13659
13761
  } else {
13660
13762
  const n = proseWordCount(readme);
13661
13763
  if (n < MIN_README_WORDS) {
13662
13764
  out.reds.push({
13663
- anchor: rel(readmePath),
13765
+ anchor: rel2(readmePath),
13664
13766
  text: `README.md has ${n} words outside code blocks (minimum ${MIN_README_WORDS})`
13665
13767
  });
13666
13768
  }
@@ -13669,8 +13771,8 @@ function judgeFolder(tree, folder, manifestPath2, out) {
13669
13771
  for (const shape of CREDENTIAL_SHAPES) {
13670
13772
  if (shape.re.test(lines2[i])) {
13671
13773
  out.reds.push({
13672
- anchor: `${rel(readmePath)}:${i + 1}`,
13673
- text: `${rel(readmePath)}:${i + 1} carries a literal credential (${shape.id}) \u2014 a README template shows an environment-variable reference, never a value`
13774
+ anchor: `${rel2(readmePath)}:${i + 1}`,
13775
+ text: `${rel2(readmePath)}:${i + 1} carries a literal credential (${shape.id}) \u2014 a README template shows an environment-variable reference, never a value`
13674
13776
  });
13675
13777
  break;
13676
13778
  }
@@ -13678,7 +13780,7 @@ function judgeFolder(tree, folder, manifestPath2, out) {
13678
13780
  }
13679
13781
  }
13680
13782
  let servers = null;
13681
- let mcpAnchor = rel(join13(folder, ".mcp.json"));
13783
+ let mcpAnchor = rel2(join13(folder, ".mcp.json"));
13682
13784
  const inline = manifest.mcpServers;
13683
13785
  if (isRecord(inline)) {
13684
13786
  servers = inline;
@@ -13686,7 +13788,7 @@ function judgeFolder(tree, folder, manifestPath2, out) {
13686
13788
  } else if (typeof inline === "string") {
13687
13789
  const target = join13(folder, inline);
13688
13790
  const j = readJsonRecord(target);
13689
- mcpAnchor = rel(target);
13791
+ mcpAnchor = rel2(target);
13690
13792
  if (j) servers = isRecord(j.mcpServers) ? j.mcpServers : j;
13691
13793
  else
13692
13794
  out.unreadable.push({
@@ -13703,7 +13805,7 @@ function judgeFolder(tree, folder, manifestPath2, out) {
13703
13805
  });
13704
13806
  } else {
13705
13807
  out.reds.push({
13706
- anchor: rel(folder),
13808
+ anchor: rel2(folder),
13707
13809
  text: "no .mcp.json (and no plugin.json mcpServers): the plugin does not reference the MCP server it ships"
13708
13810
  });
13709
13811
  }
@@ -13716,7 +13818,7 @@ function judgeFolder(tree, folder, manifestPath2, out) {
13716
13818
  try {
13717
13819
  if (statSync12(join13(folder, "bin")).isDirectory()) {
13718
13820
  out.reds.push({
13719
- anchor: rel(join13(folder, "bin")),
13821
+ anchor: rel2(join13(folder, "bin")),
13720
13822
  text: "a top-level bin/ directory (a plugin ships no bin/ at its top level)"
13721
13823
  });
13722
13824
  }
@@ -13724,8 +13826,8 @@ function judgeFolder(tree, folder, manifestPath2, out) {
13724
13826
  const code = fsErrorCode(err);
13725
13827
  if (code !== "ENOENT" && code !== "ENOTDIR") {
13726
13828
  out.unreadable.push({
13727
- anchor: rel(join13(folder, "bin")),
13728
- reason: `${rel(join13(folder, "bin"))} could not be probed (${code}) \u2014 whether the plugin ships a top-level bin/ is unread`
13829
+ anchor: rel2(join13(folder, "bin")),
13830
+ reason: `${rel2(join13(folder, "bin"))} could not be probed (${code}) \u2014 whether the plugin ships a top-level bin/ is unread`
13729
13831
  });
13730
13832
  }
13731
13833
  }
@@ -13755,7 +13857,7 @@ var c31PluginInstallable = {
13755
13857
  }
13756
13858
  const manifests = findDiskFiles(
13757
13859
  tree,
13758
- (_n, rel) => rel === ".claude-plugin/plugin.json" || rel.endsWith("/.claude-plugin/plugin.json")
13860
+ (_n, rel2) => rel2 === ".claude-plugin/plugin.json" || rel2.endsWith("/.claude-plugin/plugin.json")
13759
13861
  );
13760
13862
  const refusedManifests = refusedAsUnreadable(
13761
13863
  manifests.refused,
@@ -13991,8 +14093,8 @@ import { readFileSync as readFileSync12, readdirSync as readdirSync10, statSync
13991
14093
  import { join as join14 } from "path";
13992
14094
  var ID3 = "C34 plugin-families";
13993
14095
  var RULE3 = "C-34";
13994
- function familyOf(rel) {
13995
- const segs = rel.split("/");
14096
+ function familyOf(rel2) {
14097
+ const segs = rel2.split("/");
13996
14098
  const name = segs[segs.length - 1];
13997
14099
  const parent = segs[segs.length - 2] ?? "";
13998
14100
  if (name === "plugin.json" && parent === ".claude-plugin")
@@ -14075,12 +14177,12 @@ function writesFile(text, f) {
14075
14177
  function testFiles(tree, unread2) {
14076
14178
  const base = baseOf(tree);
14077
14179
  const out = [];
14078
- const walk3 = (dir, rel) => {
14180
+ const walk4 = (dir, rel2) => {
14079
14181
  let names2;
14080
14182
  try {
14081
14183
  names2 = readdirSync10(dir);
14082
14184
  } catch (err) {
14083
- unread2.push(`${rel}/ (not listed: ${err.message})`);
14185
+ unread2.push(`${rel2}/ (not listed: ${err.message})`);
14084
14186
  return;
14085
14187
  }
14086
14188
  for (const name of names2) {
@@ -14092,14 +14194,14 @@ function testFiles(tree, unread2) {
14092
14194
  } catch {
14093
14195
  continue;
14094
14196
  }
14095
- if (st.isDirectory()) walk3(full, `${rel}/${name}`);
14197
+ if (st.isDirectory()) walk4(full, `${rel2}/${name}`);
14096
14198
  else if (/\.[cm]?[jt]sx?$/.test(name))
14097
- out.push({ rel: `${rel}/${name}`, text: readText(full) ?? "" });
14199
+ out.push({ rel: `${rel2}/${name}`, text: readText(full) ?? "" });
14098
14200
  }
14099
14201
  };
14100
14202
  for (const d of ["tests", "test", "__tests__"]) {
14101
14203
  try {
14102
- if (statSync13(join14(base, d)).isDirectory()) walk3(join14(base, d), d);
14204
+ if (statSync13(join14(base, d)).isDirectory()) walk4(join14(base, d), d);
14103
14205
  } catch {
14104
14206
  }
14105
14207
  }
@@ -14110,9 +14212,9 @@ function testFiles(tree, unread2) {
14110
14212
  function run2(tree) {
14111
14213
  const found = findDiskFiles(
14112
14214
  tree,
14113
- (name, rel) => familyOf(rel) !== null && !/(^|\/)(dist|node_modules)\//.test(rel) && name.endsWith(".json")
14215
+ (name, rel2) => familyOf(rel2) !== null && !/(^|\/)(dist|node_modules)\//.test(rel2) && name.endsWith(".json")
14114
14216
  );
14115
- const dirOf = (rel) => rel.split("/").slice(0, -1).join("/");
14217
+ const dirOf = (rel2) => rel2.split("/").slice(0, -1).join("/");
14116
14218
  const agentDirs = new Set(
14117
14219
  found.filter((f) => f.name === "plugin.json" && familyOf(f.rel)?.id === "agent").map((f) => dirOf(f.rel))
14118
14220
  );
@@ -14129,12 +14231,12 @@ function run2(tree) {
14129
14231
  const unread2 = found.refused.map((r) => `${r.rel} (${r.reason})`);
14130
14232
  const scripts = findDiskFiles(
14131
14233
  tree,
14132
- (name, rel) => /\.(?:mjs|cjs|js|ts)$/.test(name) && !/(^|\/)(dist|node_modules|tests?|__tests__)\//.test(rel) && !/\.(?:test|spec)\.[cm]?[jt]s$/.test(name)
14234
+ (name, rel2) => /\.(?:mjs|cjs|js|ts)$/.test(name) && !/(^|\/)(dist|node_modules|tests?|__tests__)\//.test(rel2) && !/\.(?:test|spec)\.[cm]?[jt]s$/.test(name)
14133
14235
  ).map((f) => ({ file: f, text: readText(f.path) ?? "" }));
14134
14236
  const tests = testFiles(tree, unread2);
14135
14237
  const wiring = findDiskFiles(
14136
14238
  tree,
14137
- (name, rel) => name === "package.json" && !rel.includes("node_modules/") || /\.github\/workflows\/[^/]+\.ya?ml$/.test(rel)
14239
+ (name, rel2) => name === "package.json" && !rel2.includes("node_modules/") || /\.github\/workflows\/[^/]+\.ya?ml$/.test(rel2)
14138
14240
  ).map((f) => ({ file: f, text: readText(f.path) ?? "" }));
14139
14241
  const badManifests = wiring.filter((w) => w.file.name === "package.json").filter((w) => {
14140
14242
  try {
@@ -14233,7 +14335,7 @@ function readJson2(path) {
14233
14335
  function pluginManifests(tree) {
14234
14336
  return findDiskFiles(
14235
14337
  tree,
14236
- (name, rel) => name === "plugin.json" && !/(^|\/)(dist|node_modules)\//.test(rel)
14338
+ (name, rel2) => name === "plugin.json" && !/(^|\/)(dist|node_modules)\//.test(rel2)
14237
14339
  ).map((f) => {
14238
14340
  const r = readJson2(f.path);
14239
14341
  const d = r.ok && r.value && typeof r.value === "object" ? r.value.description : void 0;
@@ -14459,11 +14561,11 @@ function registrationWindow(tree, anchor) {
14459
14561
  }
14460
14562
  function findManifestsUnder(root) {
14461
14563
  const out = [];
14462
- for (const rel of ["plugin.json", ".claude-plugin/plugin.json", ".cursor-plugin/plugin.json"]) {
14463
- const r = readJson2(join15(root, rel));
14564
+ for (const rel2 of ["plugin.json", ".claude-plugin/plugin.json", ".cursor-plugin/plugin.json"]) {
14565
+ const r = readJson2(join15(root, rel2));
14464
14566
  if (!r.ok) continue;
14465
14567
  const d = r.value && typeof r.value === "object" ? r.value.description : void 0;
14466
- out.push({ rel, description: typeof d === "string" ? d : void 0 });
14568
+ out.push({ rel: rel2, description: typeof d === "string" ? d : void 0 });
14467
14569
  }
14468
14570
  return out;
14469
14571
  }
@@ -15304,6 +15406,290 @@ var c40ToolDocumentation = {
15304
15406
  runServed: runServed4
15305
15407
  };
15306
15408
 
15409
+ // src/detectors/c41-vantageos-latest.ts
15410
+ import { spawnSync as spawnSync2 } from "child_process";
15411
+ import { readFileSync as readFileSync16, readdirSync as readdirSync12 } from "fs";
15412
+ import { join as join18, relative as relative9, sep as sep6 } from "path";
15413
+ var RULE9 = "C-41";
15414
+ var SCOPE = "@vantageos/";
15415
+ var FIELDS = [
15416
+ "dependencies",
15417
+ "devDependencies",
15418
+ "peerDependencies",
15419
+ "optionalDependencies"
15420
+ ];
15421
+ var NON_REGISTRY_SPEC = /^(?:file|link|workspace|portal|patch|git|git\+[a-z]+|github|gitlab|bitbucket|gist|https?|npm):/i;
15422
+ var OWNER_REPO_SHORTHAND = /^[^\s@/]+\/[^\s/]+$/;
15423
+ function rel(root, p) {
15424
+ return relative9(root, p).split(sep6).join("/") || ".";
15425
+ }
15426
+ function walkManifests(tree, dir, out, unread2) {
15427
+ let entries;
15428
+ try {
15429
+ entries = readdirSync12(dir, { withFileTypes: true });
15430
+ } catch (e) {
15431
+ unread2.push({
15432
+ manifest: `${rel(tree.root, dir)}/`,
15433
+ reason: `directory unreadable (${fsErrorCode(e)})`
15434
+ });
15435
+ return;
15436
+ }
15437
+ for (const e of entries) {
15438
+ const p = join18(dir, e.name);
15439
+ if (e.isDirectory()) {
15440
+ if (SKIP_DIRS.has(e.name)) {
15441
+ recordSkip(tree, p, tree.root);
15442
+ continue;
15443
+ }
15444
+ walkManifests(tree, p, out, unread2);
15445
+ } else if (e.isFile() && e.name === "package.json") {
15446
+ out.push(p);
15447
+ }
15448
+ }
15449
+ }
15450
+ function lineOf3(text, pkg) {
15451
+ const i = text.split("\n").findIndex((l) => l.includes(`"${pkg}"`));
15452
+ return i < 0 ? 1 : i + 1;
15453
+ }
15454
+ function parseVantageosAlias(spec) {
15455
+ const m = /^npm:(@vantageos\/[^@\s]+)(?:@(.*))?$/.exec(spec.trim());
15456
+ if (!m) return void 0;
15457
+ return { pkg: m[1], spec: m[2] === void 0 || m[2].trim() === "" ? "*" : m[2].trim() };
15458
+ }
15459
+ function c41Collect(tree) {
15460
+ const files = [];
15461
+ const unreadable2 = [];
15462
+ walkManifests(tree, tree.root, files, unreadable2);
15463
+ const decls = [];
15464
+ for (const file of files.sort()) {
15465
+ const manifest = rel(tree.root, file);
15466
+ let text;
15467
+ let json;
15468
+ try {
15469
+ text = readFileSync16(file, "utf8");
15470
+ json = JSON.parse(text);
15471
+ } catch (e) {
15472
+ unreadable2.push({ manifest, reason: e instanceof Error ? e.message : String(e) });
15473
+ continue;
15474
+ }
15475
+ if (typeof json !== "object" || json === null || Array.isArray(json)) {
15476
+ unreadable2.push({ manifest, reason: "not a JSON object" });
15477
+ continue;
15478
+ }
15479
+ for (const field of FIELDS) {
15480
+ const block = json[field];
15481
+ if (block === void 0) continue;
15482
+ if (typeof block !== "object" || block === null || Array.isArray(block)) {
15483
+ unreadable2.push({ manifest, reason: `${field} is not an object` });
15484
+ continue;
15485
+ }
15486
+ for (const [pkg, spec] of Object.entries(block)) {
15487
+ const alias = typeof spec === "string" ? parseVantageosAlias(spec) : void 0;
15488
+ if (alias) {
15489
+ decls.push({
15490
+ manifest,
15491
+ line: lineOf3(text, pkg),
15492
+ field: `${field} (alias ${pkg})`,
15493
+ pkg: alias.pkg,
15494
+ spec: alias.spec
15495
+ });
15496
+ continue;
15497
+ }
15498
+ if (!pkg.startsWith(SCOPE)) continue;
15499
+ decls.push({ manifest, line: lineOf3(text, pkg), field, pkg, spec });
15500
+ }
15501
+ }
15502
+ }
15503
+ return { decls, unreadable: unreadable2 };
15504
+ }
15505
+ function isRegistrySpec(spec) {
15506
+ const s = spec.trim();
15507
+ return !NON_REGISTRY_SPEC.test(s) && !OWNER_REPO_SHORTHAND.test(s) && !s.includes("://");
15508
+ }
15509
+ function c41JudgeDeclarations(id, { decls, unreadable: unreadable2 }, resolver) {
15510
+ const lagging = [];
15511
+ const unjudged = unreadable2.map((u) => ({
15512
+ anchor: u.manifest,
15513
+ reason: `${u.manifest} could not be read (${u.reason})`
15514
+ }));
15515
+ let firstLagAnchor;
15516
+ for (const d of decls) {
15517
+ const anchor = `${d.manifest}:${d.line}`;
15518
+ const where = `${d.manifest} ${d.field}`;
15519
+ if (typeof d.spec !== "string") {
15520
+ unjudged.push({
15521
+ anchor,
15522
+ reason: `${d.pkg} in ${where} has a non-string spec (${JSON.stringify(d.spec)})`
15523
+ });
15524
+ continue;
15525
+ }
15526
+ if (!isRegistrySpec(d.spec)) {
15527
+ unjudged.push({
15528
+ anchor,
15529
+ reason: `${d.pkg} in ${where} is declared as "${d.spec}", not a registry spec: which published version it installs is not decidable from the registry`
15530
+ });
15531
+ continue;
15532
+ }
15533
+ const latest = resolver.latest(d.pkg);
15534
+ if (!latest.ok) {
15535
+ unjudged.push({
15536
+ anchor,
15537
+ reason: `registry did not give the latest version of ${d.pkg} (${latest.reason})`
15538
+ });
15539
+ continue;
15540
+ }
15541
+ const selected = resolver.satisfying(d.pkg, d.spec);
15542
+ if (!selected.ok) {
15543
+ unjudged.push({
15544
+ anchor,
15545
+ reason: `registry did not give the versions "${d.spec}" selects for ${d.pkg} (${selected.reason})`
15546
+ });
15547
+ continue;
15548
+ }
15549
+ if (!selected.value.includes(latest.value)) {
15550
+ lagging.push(
15551
+ `${d.pkg} "${d.spec}" does not accept latest ${latest.value} (${where}, ${anchor})`
15552
+ );
15553
+ firstLagAnchor ??= anchor;
15554
+ }
15555
+ }
15556
+ if (lagging.length > 0) {
15557
+ const tail = unjudged.length > 0 ? `; ${unjudged.length} other declaration(s) not judged: ${unjudged.map((u) => u.reason).join("; ")}` : "";
15558
+ return {
15559
+ id,
15560
+ anchor: firstLagAnchor ?? "-",
15561
+ state: "non-conforming",
15562
+ verdict: `${lagging.length} @vantageos/* dependenc${lagging.length === 1 ? "y is" : "ies are"} behind latest: ${lagging.join("; ")}${tail} (${RULE9})`
15563
+ };
15564
+ }
15565
+ if (unjudged.length > 0) {
15566
+ return couldNotJudge(
15567
+ id,
15568
+ unjudged[0].anchor,
15569
+ `${unjudged.length} @vantageos/* declaration(s) not judged: ${unjudged.map((u) => u.reason).join("; ")} (${RULE9})`
15570
+ );
15571
+ }
15572
+ if (decls.length === 0) {
15573
+ return {
15574
+ id,
15575
+ anchor: "-",
15576
+ state: "absent",
15577
+ verdict: `no @vantageos/* dependency declared in any package.json; ${RULE9} does not oblige (said aloud)`
15578
+ };
15579
+ }
15580
+ return {
15581
+ id,
15582
+ anchor: `${decls[0].manifest}:${decls[0].line}`,
15583
+ state: "present",
15584
+ verdict: `${decls.length} @vantageos/* declaration(s), each accepting the registry's latest (${RULE9})`
15585
+ };
15586
+ }
15587
+ function c41Judge(tree, resolver) {
15588
+ return c41JudgeDeclarations(c41VantageosLatest.id, c41Collect(tree), resolver);
15589
+ }
15590
+ function npmView(args, registry, timeoutMs) {
15591
+ const full = [
15592
+ "view",
15593
+ ...args,
15594
+ "--json",
15595
+ "--fetch-retries=0",
15596
+ ...registry ? [`--registry=${registry}`] : []
15597
+ ];
15598
+ const r = spawnSync2("npm", full, { encoding: "utf8", timeout: timeoutMs });
15599
+ if (r.error) return { ok: false, reason: `npm ${full.join(" ")}: ${r.error.message}` };
15600
+ let parsed;
15601
+ try {
15602
+ parsed = r.stdout.trim() === "" ? void 0 : JSON.parse(r.stdout);
15603
+ } catch {
15604
+ return { ok: false, reason: `npm ${args.join(" ")}: unparseable reply (exit ${r.status})` };
15605
+ }
15606
+ if (r.status !== 0) {
15607
+ const err = parsed?.error;
15608
+ const summary = err?.summary ?? (r.stderr.split("\n").find((l) => l.includes("error")) || `exit ${r.status}`);
15609
+ if (err?.code === "E404" && /^No match found for version/.test(err.summary ?? "")) {
15610
+ return { ok: false, reason: summary, noMatch: true };
15611
+ }
15612
+ return { ok: false, reason: `npm ${args.join(" ")}: ${err?.code ?? ""} ${summary}`.trim() };
15613
+ }
15614
+ if (parsed === void 0) return { ok: false, reason: `npm ${args.join(" ")}: empty reply` };
15615
+ return { ok: true, value: parsed };
15616
+ }
15617
+ function npmResolver(opts = {}) {
15618
+ const timeoutMs = opts.timeoutMs ?? 3e4;
15619
+ const latestCache = /* @__PURE__ */ new Map();
15620
+ const setCache = /* @__PURE__ */ new Map();
15621
+ return {
15622
+ latest(pkg) {
15623
+ const hit = latestCache.get(pkg);
15624
+ if (hit) return hit;
15625
+ const r = npmView([pkg, "dist-tags.latest"], opts.registry, timeoutMs);
15626
+ const out = !r.ok ? { ok: false, reason: r.reason } : typeof r.value === "string" ? { ok: true, value: r.value } : {
15627
+ ok: false,
15628
+ reason: `npm view ${pkg} dist-tags.latest: not a version (${JSON.stringify(r.value)})`
15629
+ };
15630
+ if (out.ok) latestCache.set(pkg, out);
15631
+ return out;
15632
+ },
15633
+ satisfying(pkg, spec) {
15634
+ const key = `${pkg}@${spec}`;
15635
+ const hit = setCache.get(key);
15636
+ if (hit) return hit;
15637
+ const r = npmView([key, "version"], opts.registry, timeoutMs);
15638
+ let out;
15639
+ if (!r.ok) out = "noMatch" in r ? { ok: true, value: [] } : { ok: false, reason: r.reason };
15640
+ else if (typeof r.value === "string") out = { ok: true, value: [r.value] };
15641
+ else if (Array.isArray(r.value) && r.value.every((v) => typeof v === "string"))
15642
+ out = { ok: true, value: r.value };
15643
+ else
15644
+ out = {
15645
+ ok: false,
15646
+ reason: `npm view ${key} version: not a version list (${JSON.stringify(r.value)})`
15647
+ };
15648
+ if (out.ok) setCache.set(key, out);
15649
+ return out;
15650
+ }
15651
+ };
15652
+ }
15653
+ function c41PositiveControls() {
15654
+ const decl = (spec) => ({
15655
+ manifest: "package.json",
15656
+ line: 1,
15657
+ field: "dependencies",
15658
+ pkg: "@vantageos/x",
15659
+ spec
15660
+ });
15661
+ const reg = {
15662
+ latest: () => ({ ok: true, value: "1.1.0" }),
15663
+ satisfying: (_p, s) => ({ ok: true, value: s === "^1.0.0" ? ["1.0.0", "1.1.0"] : ["0.9.0"] })
15664
+ };
15665
+ const dead = {
15666
+ latest: () => ({ ok: false, reason: "offline" }),
15667
+ satisfying: () => ({ ok: false, reason: "offline" })
15668
+ };
15669
+ const cases = [
15670
+ ["lag", { decls: [decl("^0.9.0")], unreadable: [] }, reg, "non-conforming"],
15671
+ ["accepts", { decls: [decl("^1.0.0")], unreadable: [] }, reg, "present"],
15672
+ ["offline", { decls: [decl("^1.0.0")], unreadable: [] }, dead, "could-not-judge"],
15673
+ ["file spec", { decls: [decl("file:../x")], unreadable: [] }, reg, "could-not-judge"],
15674
+ ["none", { decls: [], unreadable: [] }, reg, "absent"]
15675
+ ];
15676
+ for (const [name, input, resolver, want] of cases) {
15677
+ const got = c41JudgeDeclarations("C41 control", input, resolver).state;
15678
+ if (got !== want)
15679
+ throw new Error(`C41 positive control "${name}": expected ${want}, got ${got}`);
15680
+ }
15681
+ }
15682
+ var c41VantageosLatest = {
15683
+ id: "C41 vantageos-latest",
15684
+ rule: RULE9,
15685
+ pin: C41_RULES_PIN,
15686
+ run(tree) {
15687
+ c41PositiveControls();
15688
+ return c41Judge(tree, defaultResolver);
15689
+ }
15690
+ };
15691
+ var defaultResolver = npmResolver();
15692
+
15307
15693
  // src/detectors/d2.ts
15308
15694
  var SESSION_RE = /mcp-session-id/i;
15309
15695
  var GENERATOR_RE = /\bsessionIdGenerator\s*:\s*(?!undefined\b)\S/;
@@ -16126,10 +16512,137 @@ var d5 = {
16126
16512
  };
16127
16513
 
16128
16514
  // src/detectors/d6.ts
16515
+ import * as ts from "typescript";
16129
16516
  var COMMUNITY_RE = /["'`]io\.modelcontextprotocol\/ui["'`]\s*:|_meta\s*\[\s*["'`]io\.modelcontextprotocol\/ui["'`]\s*\]/;
16130
16517
  var FLAT_RE = /["'`]ui\/resourceUri["'`]\s*:|_meta\s*\[\s*["'`]ui\/resourceUri["'`]\s*\]/;
16131
- var NESTED_UI_RE = /_meta\s*:\s*\{\s*ui\b/;
16132
- var RESOURCE_URI_RE = /\bresourceUri\b/;
16518
+ var RESOURCE_REGISTRATIONS = /* @__PURE__ */ new Set([
16519
+ "registerResource",
16520
+ "resource",
16521
+ "registerResourceTemplate",
16522
+ "registerAppResource"
16523
+ ]);
16524
+ function staticKey(name) {
16525
+ if (ts.isIdentifier(name) || ts.isStringLiteralLike(name) || ts.isNumericLiteral(name))
16526
+ return name.text;
16527
+ if (ts.isComputedPropertyName(name) && ts.isStringLiteralLike(name.expression))
16528
+ return name.expression.text;
16529
+ return void 0;
16530
+ }
16531
+ function scanKind(rel2) {
16532
+ return rel2.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
16533
+ }
16534
+ function scanFileForBinding(file, scan) {
16535
+ const text = file.lines.map((l) => l.raw).join("\n");
16536
+ if (!text.includes("_meta") && !text.includes("registerAppTool")) return;
16537
+ const sf = ts.createSourceFile(file.rel, text, ts.ScriptTarget.Latest, true, scanKind(file.rel));
16538
+ const at = (n) => `${file.rel}:${sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1}`;
16539
+ const unread2 = (n, why) => {
16540
+ scan.unread.push({ anchor: at(n), why });
16541
+ };
16542
+ const bind = (n) => {
16543
+ scan.bound ??= { anchor: at(n) };
16544
+ };
16545
+ const readUiObject = (obj) => {
16546
+ let named = false;
16547
+ let opaque = false;
16548
+ for (const p of obj.properties) {
16549
+ if (ts.isSpreadAssignment(p)) {
16550
+ opaque = true;
16551
+ continue;
16552
+ }
16553
+ if (ts.isShorthandPropertyAssignment(p)) {
16554
+ if (p.name.text === "resourceUri") named = true;
16555
+ continue;
16556
+ }
16557
+ if (ts.isPropertyAssignment(p) || ts.isMethodDeclaration(p)) {
16558
+ const k = staticKey(p.name);
16559
+ if (k === void 0) opaque = true;
16560
+ else if (k === "resourceUri") named = true;
16561
+ }
16562
+ }
16563
+ if (named) bind(obj);
16564
+ else if (opaque)
16565
+ unread2(obj, "a `ui` object built from a spread or a computed key that names no resourceUri");
16566
+ else scan.partial ??= { anchor: at(obj) };
16567
+ };
16568
+ const readUiValue = (v, site) => {
16569
+ const e = ts.isParenthesizedExpression(v) ? v.expression : v;
16570
+ if (ts.isObjectLiteralExpression(e)) readUiObject(e);
16571
+ else
16572
+ unread2(
16573
+ site,
16574
+ `\`ui\` is the expression \`${e.getText(sf).slice(0, 40)}\`, not an object literal`
16575
+ );
16576
+ };
16577
+ const readMetaObject = (obj) => {
16578
+ let sawUi = false;
16579
+ let opaque = false;
16580
+ for (const p of obj.properties) {
16581
+ if (ts.isSpreadAssignment(p)) {
16582
+ opaque = true;
16583
+ continue;
16584
+ }
16585
+ if (ts.isShorthandPropertyAssignment(p)) {
16586
+ if (p.name.text === "ui") {
16587
+ sawUi = true;
16588
+ unread2(p, "`ui` is a shorthand variable, not an object literal");
16589
+ }
16590
+ continue;
16591
+ }
16592
+ if (!ts.isPropertyAssignment(p)) continue;
16593
+ const k = staticKey(p.name);
16594
+ if (k === void 0) {
16595
+ opaque = true;
16596
+ continue;
16597
+ }
16598
+ if (k === "ui") {
16599
+ sawUi = true;
16600
+ readUiValue(p.initializer, p);
16601
+ }
16602
+ }
16603
+ if (!sawUi && opaque)
16604
+ unread2(obj, "a `_meta` object built from a spread or a computed key, no `ui` beside it");
16605
+ };
16606
+ const visit = (n) => {
16607
+ if (ts.isCallExpression(n)) {
16608
+ const c = n.expression;
16609
+ const name = ts.isIdentifier(c) ? c.text : ts.isPropertyAccessExpression(c) ? c.name.text : "";
16610
+ if (name === "registerAppTool") bind(n);
16611
+ if (RESOURCE_REGISTRATIONS.has(name)) return;
16612
+ }
16613
+ if (ts.isPropertyAssignment(n) && staticKey(n.name) === "_meta") {
16614
+ const v = ts.isParenthesizedExpression(n.initializer) ? n.initializer.expression : n.initializer;
16615
+ if (ts.isObjectLiteralExpression(v)) readMetaObject(v);
16616
+ else
16617
+ unread2(
16618
+ n,
16619
+ `\`_meta\` is the expression \`${v.getText(sf).slice(0, 40)}\`, not an object literal`
16620
+ );
16621
+ }
16622
+ if (ts.isBinaryExpression(n) && n.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
16623
+ const last = lastSegment2(n.left);
16624
+ if (last?.name === "resourceUri" && lastSegment2(last.obj)?.name === "ui") {
16625
+ const owner = lastSegment2(last.obj);
16626
+ if (owner && lastSegment2(owner.obj)?.name === "_meta") bind(n);
16627
+ } else if (last?.name === "ui" && lastSegment2(last.obj)?.name === "_meta") {
16628
+ readUiValue(n.right, n);
16629
+ }
16630
+ }
16631
+ ts.forEachChild(n, visit);
16632
+ };
16633
+ visit(sf);
16634
+ }
16635
+ function lastSegment2(e) {
16636
+ if (ts.isPropertyAccessExpression(e)) return { obj: e.expression, name: e.name.text };
16637
+ if (ts.isElementAccessExpression(e) && ts.isStringLiteralLike(e.argumentExpression))
16638
+ return { obj: e.expression, name: e.argumentExpression.text };
16639
+ return void 0;
16640
+ }
16641
+ function scanUiBinding(tree) {
16642
+ const scan = { bound: null, partial: null, unread: [] };
16643
+ for (const file of tree.files) scanFileForBinding(file, scan);
16644
+ return scan;
16645
+ }
16133
16646
  var d6 = {
16134
16647
  id: "D6 mcp-apps ui-key",
16135
16648
  rule: "A-6",
@@ -16137,15 +16650,11 @@ var d6 = {
16137
16650
  run(tree) {
16138
16651
  let community = null;
16139
16652
  let flat = null;
16140
- let nested2 = null;
16141
- let sawResourceUri = false;
16142
16653
  for (const file of tree.files) {
16143
16654
  for (const line of file.lines) {
16144
16655
  if (line.comment) continue;
16145
16656
  if (!community && COMMUNITY_RE.test(line.raw)) community = { file: file.rel, line: line.n };
16146
16657
  if (!flat && FLAT_RE.test(line.raw)) flat = { file: file.rel, line: line.n };
16147
- if (!nested2 && NESTED_UI_RE.test(line.raw)) nested2 = { file: file.rel, line: line.n };
16148
- if (RESOURCE_URI_RE.test(line.raw)) sawResourceUri = true;
16149
16658
  }
16150
16659
  }
16151
16660
  if (community) {
@@ -16164,17 +16673,29 @@ var d6 = {
16164
16673
  verdict: "flat ui/resourceUri key (deprecated) -> _meta.ui.resourceUri"
16165
16674
  };
16166
16675
  }
16167
- if (nested2 && sawResourceUri) {
16676
+ const binding = scanUiBinding(tree);
16677
+ if (binding.bound) {
16168
16678
  return {
16169
16679
  id: this.id,
16170
- anchor: `${nested2.file}:${nested2.line}`,
16680
+ anchor: binding.bound.anchor,
16171
16681
  state: "present",
16172
16682
  verdict: "GA nested _meta.ui.resourceUri"
16173
16683
  };
16174
16684
  }
16175
16685
  const ui = uiResourceSites(tree);
16176
16686
  if (ui.length > 0) {
16177
- const partial = nested2 ? ` (a nested _meta.ui at ${nested2.file}:${nested2.line} names no resourceUri)` : "";
16687
+ if (binding.unread.length > 0) {
16688
+ const u = binding.unread[0];
16689
+ const reason = `could not determine binding: the App serves ${ui.length} ui:// resource(s) and no \`_meta.ui.resourceUri\` was read, but ${u.anchor} holds a shape the reader cannot follow (${u.why})${binding.unread.length > 1 ? `; ${binding.unread.length - 1} more` : ""} (A-6)`;
16690
+ return {
16691
+ id: this.id,
16692
+ anchor: u.anchor,
16693
+ state: "could-not-judge",
16694
+ reason,
16695
+ verdict: `could not judge: ${reason}`
16696
+ };
16697
+ }
16698
+ const partial = binding.partial ? ` (a nested _meta.ui at ${binding.partial.anchor} names no resourceUri)` : "";
16178
16699
  return {
16179
16700
  id: this.id,
16180
16701
  anchor: ui[0].anchor,
@@ -16193,7 +16714,7 @@ var d6 = {
16193
16714
 
16194
16715
  // src/detectors/d8.ts
16195
16716
  import { existsSync as existsSync12, statSync as statSync15 } from "fs";
16196
- import { dirname as dirname6, join as join18, relative as relative9 } from "path";
16717
+ import { dirname as dirname6, join as join19, relative as relative10 } from "path";
16197
16718
  var POSITIVE_CONTROL2 = 'server.registerTool("list_items", { ... }, handler);';
16198
16719
  function d8PositiveControl() {
16199
16720
  return {
@@ -16213,7 +16734,7 @@ function resolveBaseDir(tree) {
16213
16734
  function findEvalsFile(tree) {
16214
16735
  let dir = resolveBaseDir(tree);
16215
16736
  for (let depth = 0; depth < 8; depth++) {
16216
- const candidate = join18(dir, "evals", "evals.json");
16737
+ const candidate = join19(dir, "evals", "evals.json");
16217
16738
  if (existsSync12(candidate)) return candidate;
16218
16739
  const parent = dirname6(dir);
16219
16740
  if (parent === dir) break;
@@ -16276,7 +16797,7 @@ var d8 = {
16276
16797
  };
16277
16798
  }
16278
16799
  const baseDir = resolveBaseDir(tree);
16279
- const displayPath = relative9(baseDir, evalsPath) || evalsPath;
16800
+ const displayPath = relative10(baseDir, evalsPath) || evalsPath;
16280
16801
  const parsed = readJsonObject(evalsPath);
16281
16802
  if (parsed === null || !Array.isArray(parsed.cases)) {
16282
16803
  return couldNotJudge(
@@ -16367,7 +16888,7 @@ var d8 = {
16367
16888
 
16368
16889
  // src/detectors/d9.ts
16369
16890
  import { existsSync as existsSync13 } from "fs";
16370
- import { dirname as dirname7, join as join19 } from "path";
16891
+ import { dirname as dirname7, join as join20 } from "path";
16371
16892
  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-]+)*))?$/;
16372
16893
  var POSITIVE_CONTROL3 = "1.2.3-beta.1+build.7";
16373
16894
  function d9PositiveControl() {
@@ -16416,7 +16937,7 @@ var d9Inner = {
16416
16937
  };
16417
16938
  }
16418
16939
  const projectDir = dirname7(pkgPath);
16419
- const changelogPath = join19(projectDir, "CHANGELOG.md");
16940
+ const changelogPath = join20(projectDir, "CHANGELOG.md");
16420
16941
  const hasChangelog = existsSync13(changelogPath);
16421
16942
  const validSemver = SEMVER_RE.test(version);
16422
16943
  if (validSemver && hasChangelog) {
@@ -16447,7 +16968,7 @@ var d9 = guardUnreadablePackageJson(d9Inner, { authoritative: false });
16447
16968
 
16448
16969
  // src/detectors/d10.ts
16449
16970
  import { existsSync as existsSync14 } from "fs";
16450
- import { dirname as dirname8, join as join20 } from "path";
16971
+ import { dirname as dirname8, join as join21 } from "path";
16451
16972
  var DESCRIPTION_FR_RE = /"description_fr"\s*:\s*"[^"]+"/;
16452
16973
  var POSITIVE_CONTROL4 = '"description_fr": "Un serveur MCP conforme.",';
16453
16974
  function d10PositiveControl() {
@@ -16580,7 +17101,7 @@ var d10Inner = {
16580
17101
  };
16581
17102
  }
16582
17103
  const hasDescriptionFr = hasDescriptionFrJson || sourceScan.present;
16583
- const readmeFrPath = join20(root, "README.fr.md");
17104
+ const readmeFrPath = join21(root, "README.fr.md");
16584
17105
  const hasReadmeFr = existsSync14(readmeFrPath);
16585
17106
  const missing = [];
16586
17107
  if (!hasDescriptionFr) missing.push("description_fr (package.json or source _meta)");
@@ -16879,8 +17400,8 @@ var d15 = {
16879
17400
  };
16880
17401
 
16881
17402
  // src/detectors/d16.ts
16882
- import { existsSync as existsSync15, readFileSync as readFileSync16, statSync as statSync16 } from "fs";
16883
- import { dirname as dirname9, join as join21 } from "path";
17403
+ import { existsSync as existsSync15, readFileSync as readFileSync17, statSync as statSync16 } from "fs";
17404
+ import { dirname as dirname9, join as join22 } from "path";
16884
17405
  var DISCOVER_RE2 = /server\/discover|DiscoverResult|ServerDiscover|handleServerDiscover/;
16885
17406
  var HEALTH_ROUTE_FRAMEWORK_RE = /\b[A-Za-z_$][\w$]*\.(?:get|post|put|patch|delete|all|route|use)\s*\(\s*["'`][^"'`]*\/health/;
16886
17407
  var HEALTH_ROUTE_RAWPATH_RE = /\bpathname\s*===?\s*["'`][^"'`]*\/health/;
@@ -16964,7 +17485,7 @@ function manifestVersionEqualsPackage(tree) {
16964
17485
  if (typeof pkgVersion !== "string" || pkgVersion.length === 0 || !tree.packageJson) return false;
16965
17486
  try {
16966
17487
  const manifest = JSON.parse(
16967
- readFileSync16(join21(dirname9(tree.packageJson.path), "mcp-server.json"), "utf8")
17488
+ readFileSync17(join22(dirname9(tree.packageJson.path), "mcp-server.json"), "utf8")
16968
17489
  );
16969
17490
  return manifest.version === pkgVersion;
16970
17491
  } catch {
@@ -17252,10 +17773,10 @@ function readPackageVersion(root) {
17252
17773
  try {
17253
17774
  let dir = statSync16(root).isDirectory() ? root : dirname9(root);
17254
17775
  for (let depth = 0; depth < 8; depth++) {
17255
- const candidate = join21(dir, "package.json");
17776
+ const candidate = join22(dir, "package.json");
17256
17777
  if (existsSync15(candidate)) {
17257
17778
  if (!statSync16(candidate).isFile()) return null;
17258
- const pkg = JSON.parse(readFileSync16(candidate, "utf8"));
17779
+ const pkg = JSON.parse(readFileSync17(candidate, "utf8"));
17259
17780
  return typeof pkg.version === "string" ? pkg.version : null;
17260
17781
  }
17261
17782
  const parent = dirname9(dir);
@@ -17269,8 +17790,8 @@ function readPackageVersion(root) {
17269
17790
  }
17270
17791
 
17271
17792
  // src/detectors/dAppI18n.ts
17272
- import { existsSync as existsSync16, readFileSync as readFileSync17, statSync as statSync17 } from "fs";
17273
- import { dirname as dirname10, join as join22 } from "path";
17793
+ import { existsSync as existsSync16, readFileSync as readFileSync18, statSync as statSync17 } from "fs";
17794
+ import { dirname as dirname10, join as join23 } from "path";
17274
17795
  function flattenKeys(obj, prefix = "") {
17275
17796
  if (obj === null || typeof obj !== "object" || Array.isArray(obj)) {
17276
17797
  return prefix ? [prefix] : [];
@@ -17304,7 +17825,7 @@ function dAppI18nPositiveControls() {
17304
17825
  function readJson3(path) {
17305
17826
  try {
17306
17827
  if (!statSync17(path).isFile()) return { ok: false };
17307
- return { ok: true, value: JSON.parse(readFileSync17(path, "utf8")) };
17828
+ return { ok: true, value: JSON.parse(readFileSync18(path, "utf8")) };
17308
17829
  } catch {
17309
17830
  return { ok: false };
17310
17831
  }
@@ -17321,9 +17842,9 @@ var dAppI18n = {
17321
17842
  );
17322
17843
  }
17323
17844
  const root = tree.packageJson ? dirname10(tree.packageJson.path) : tree.root;
17324
- const i18nDir = join22(root, "i18n");
17325
- const enPath = join22(i18nDir, "en.json");
17326
- const frPath = join22(i18nDir, "fr.json");
17845
+ const i18nDir = join23(root, "i18n");
17846
+ const enPath = join23(i18nDir, "en.json");
17847
+ const frPath = join23(i18nDir, "fr.json");
17327
17848
  const hasI18n = existsSync16(i18nDir);
17328
17849
  const hasFr = existsSync16(frPath);
17329
17850
  if (!hasI18n && !hasFr) {
@@ -17502,27 +18023,27 @@ var dDebugOptIn = {
17502
18023
  };
17503
18024
 
17504
18025
  // src/detectors/extManifests.ts
17505
- import { readdirSync as readdirSync12, statSync as statSync18 } from "fs";
17506
- import { join as join23 } from "path";
18026
+ import { readdirSync as readdirSync13, statSync as statSync18 } from "fs";
18027
+ import { join as join24 } from "path";
17507
18028
  function findExtensionManifests(tree) {
17508
18029
  const out = [];
17509
18030
  const root = tree.root;
17510
18031
  let base;
17511
18032
  try {
17512
- base = statSync18(root).isDirectory() ? root : join23(root, "..");
18033
+ base = statSync18(root).isDirectory() ? root : join24(root, "..");
17513
18034
  } catch {
17514
18035
  return out;
17515
18036
  }
17516
- const walk3 = (dir) => {
18037
+ const walk4 = (dir) => {
17517
18038
  let entries;
17518
18039
  try {
17519
- entries = readdirSync12(dir);
18040
+ entries = readdirSync13(dir);
17520
18041
  } catch (err) {
17521
18042
  recordSkip(tree, dir, base, `could not be listed (${fsErrorCode(err)}) \u2014 not read`);
17522
18043
  return;
17523
18044
  }
17524
18045
  for (const name of entries) {
17525
- const full = join23(dir, name);
18046
+ const full = join24(dir, name);
17526
18047
  let st;
17527
18048
  try {
17528
18049
  st = statSync18(full);
@@ -17535,7 +18056,7 @@ function findExtensionManifests(tree) {
17535
18056
  recordSkip(tree, full, base);
17536
18057
  continue;
17537
18058
  }
17538
- walk3(full);
18059
+ walk4(full);
17539
18060
  } else if (name === "extension.json") {
17540
18061
  if (!st.isFile()) {
17541
18062
  recordSkip(tree, full, base, "not a regular file (FIFO, socket or device) \u2014 not read");
@@ -17545,13 +18066,13 @@ function findExtensionManifests(tree) {
17545
18066
  }
17546
18067
  }
17547
18068
  };
17548
- walk3(base);
18069
+ walk4(base);
17549
18070
  return out;
17550
18071
  }
17551
18072
 
17552
18073
  // src/detectors/vendorRegistry.ts
17553
- import { existsSync as existsSync17, readFileSync as readFileSync18 } from "fs";
17554
- import { dirname as dirname11, join as join24 } from "path";
18074
+ import { existsSync as existsSync17, readFileSync as readFileSync19 } from "fs";
18075
+ import { dirname as dirname11, join as join25 } from "path";
17555
18076
  import { fileURLToPath } from "url";
17556
18077
  function locateRegistry() {
17557
18078
  let dir;
@@ -17561,7 +18082,7 @@ function locateRegistry() {
17561
18082
  return null;
17562
18083
  }
17563
18084
  for (let depth = 0; depth < 5; depth++) {
17564
- const candidate = join24(dir, "vendor-namespaces.json");
18085
+ const candidate = join25(dir, "vendor-namespaces.json");
17565
18086
  if (existsSync17(candidate)) return candidate;
17566
18087
  const parent = dirname11(dir);
17567
18088
  if (parent === dir) break;
@@ -17579,7 +18100,7 @@ function loadRegistry(path) {
17579
18100
  }
17580
18101
  let parsed;
17581
18102
  try {
17582
- parsed = JSON.parse(readFileSync18(p, "utf8"));
18103
+ parsed = JSON.parse(readFileSync19(p, "utf8"));
17583
18104
  } catch (err) {
17584
18105
  return {
17585
18106
  ok: false,
@@ -18209,8 +18730,8 @@ var dExt3 = {
18209
18730
  };
18210
18731
 
18211
18732
  // src/detectors/dExt4.ts
18212
- import { readdirSync as readdirSync13, statSync as statSync19 } from "fs";
18213
- import { join as join25, relative as relative10 } from "path";
18733
+ import { readdirSync as readdirSync14, statSync as statSync19 } from "fs";
18734
+ import { join as join26, relative as relative11 } from "path";
18214
18735
  function canonical(name) {
18215
18736
  return name.replace(/[-_]/g, "").toLowerCase();
18216
18737
  }
@@ -18234,28 +18755,28 @@ function findHooksDirs(tree, unreadable2, gaps) {
18234
18755
  const out = [];
18235
18756
  let base;
18236
18757
  try {
18237
- base = statSync19(root).isDirectory() ? root : join25(root, "..");
18758
+ base = statSync19(root).isDirectory() ? root : join26(root, "..");
18238
18759
  } catch {
18239
18760
  return out;
18240
18761
  }
18241
18762
  const noteUnread = (path, what, err) => {
18242
18763
  gaps.count++;
18243
- const anchor = relative10(base, path) || ".";
18764
+ const anchor = relative11(base, path) || ".";
18244
18765
  const reason = `${anchor} ${what} (${fsErrorCode(err)}) \u2014 a hooks/ directory under it may exist unseen, so the implemented hooks are unverifiable (Extension Rule 4)`;
18245
18766
  if (!unreadable2.some((u) => u.anchor === anchor && u.reason === reason)) {
18246
18767
  unreadable2.push({ anchor, reason });
18247
18768
  }
18248
18769
  };
18249
- const walk3 = (dir) => {
18770
+ const walk4 = (dir) => {
18250
18771
  let entries;
18251
18772
  try {
18252
- entries = readdirSync13(dir);
18773
+ entries = readdirSync14(dir);
18253
18774
  } catch (err) {
18254
18775
  noteUnread(dir, "could not be listed", err);
18255
18776
  return;
18256
18777
  }
18257
18778
  for (const name of entries) {
18258
- const full = join25(dir, name);
18779
+ const full = join26(dir, name);
18259
18780
  let st;
18260
18781
  try {
18261
18782
  st = statSync19(full);
@@ -18273,7 +18794,7 @@ function findHooksDirs(tree, unreadable2, gaps) {
18273
18794
  const tokens = /* @__PURE__ */ new Set();
18274
18795
  let files;
18275
18796
  try {
18276
- files = readdirSync13(full);
18797
+ files = readdirSync14(full);
18277
18798
  } catch (err) {
18278
18799
  noteUnread(full, "could not be listed", err);
18279
18800
  files = [];
@@ -18286,10 +18807,10 @@ function findHooksDirs(tree, unreadable2, gaps) {
18286
18807
  }
18287
18808
  out.push({ anchor: `${name}/`, tokens });
18288
18809
  }
18289
- walk3(full);
18810
+ walk4(full);
18290
18811
  }
18291
18812
  };
18292
- walk3(base);
18813
+ walk4(base);
18293
18814
  return out;
18294
18815
  }
18295
18816
  var LIFECYCLE_OBJ_RE = /\blifecycle\s*:\s*\{/;
@@ -18437,7 +18958,7 @@ var dExt4 = {
18437
18958
 
18438
18959
  // src/detectors/dExt5.ts
18439
18960
  import { existsSync as existsSync18 } from "fs";
18440
- import { dirname as dirname12, join as join26 } from "path";
18961
+ import { dirname as dirname12, join as join27 } from "path";
18441
18962
  function nonEmptyString(v) {
18442
18963
  return typeof v === "string" && v.trim().length > 0;
18443
18964
  }
@@ -18499,7 +19020,7 @@ var dExt5 = {
18499
19020
  if (!nonEmptyString(parsed.description_fr)) {
18500
19021
  missing.push("description_fr (extension.json)");
18501
19022
  }
18502
- if (!existsSync18(join26(root, "README.fr.md"))) {
19023
+ if (!existsSync18(join27(root, "README.fr.md"))) {
18503
19024
  missing.push("README.fr.md");
18504
19025
  }
18505
19026
  if (isToolExtension(parsed.type) && "tools" in parsed) {
@@ -18543,7 +19064,7 @@ var dExt5 = {
18543
19064
 
18544
19065
  // src/detectors/dExt7.ts
18545
19066
  import { existsSync as existsSync19 } from "fs";
18546
- import { dirname as dirname13, join as join27 } from "path";
19067
+ import { dirname as dirname13, join as join28 } from "path";
18547
19068
  var ABSENCE_FLAG_FIELDS = [
18548
19069
  "extensionAbsent",
18549
19070
  "extension_absent",
@@ -18615,7 +19136,7 @@ var dExt7 = {
18615
19136
  for (const manifestPath2 of manifests) {
18616
19137
  const extDir = dirname13(manifestPath2);
18617
19138
  const extLabel = extDir.split("/").pop() ?? extDir;
18618
- const evalsPath = join27(extDir, "evals", "evals.json");
19139
+ const evalsPath = join28(extDir, "evals", "evals.json");
18619
19140
  const shortPath = `${extLabel}/evals/evals.json`;
18620
19141
  if (!existsSync19(evalsPath)) {
18621
19142
  return {
@@ -18682,7 +19203,7 @@ var dExt7 = {
18682
19203
 
18683
19204
  // src/detectors/dExt8.ts
18684
19205
  import { existsSync as existsSync20 } from "fs";
18685
- import { dirname as dirname14, join as join28 } from "path";
19206
+ import { dirname as dirname14, join as join29 } from "path";
18686
19207
  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-]+)*))?$/;
18687
19208
  var POSITIVE_CONTROL5 = "1.2.3-beta.1+build.7";
18688
19209
  function dExt8PositiveControl() {
@@ -18718,7 +19239,7 @@ var dExt8 = {
18718
19239
  for (const manifestPath2 of manifests) {
18719
19240
  const extDir = dirname14(manifestPath2);
18720
19241
  const extLabel = extDir.split("/").pop() ?? extDir;
18721
- const pkgPath = join28(extDir, "package.json");
19242
+ const pkgPath = join29(extDir, "package.json");
18722
19243
  const shortPkgPath = `${extLabel}/package.json`;
18723
19244
  if (!existsSync20(pkgPath)) {
18724
19245
  unreadable2.push({
@@ -18755,7 +19276,7 @@ var dExt8 = {
18755
19276
  continue;
18756
19277
  }
18757
19278
  const validSemver = SEMVER_RE2.test(version);
18758
- const changelogPath = join28(extDir, "CHANGELOG.md");
19279
+ const changelogPath = join29(extDir, "CHANGELOG.md");
18759
19280
  const hasChangelog = existsSync20(changelogPath);
18760
19281
  if (!validSemver) {
18761
19282
  finding ??= {
@@ -18790,35 +19311,35 @@ var dExt8 = {
18790
19311
  };
18791
19312
 
18792
19313
  // src/detectors/dExt9.ts
18793
- import { readFileSync as readFileSync19, readdirSync as readdirSync14, statSync as statSync20 } from "fs";
18794
- import { join as join29, relative as relative11 } from "path";
19314
+ import { readFileSync as readFileSync20, readdirSync as readdirSync15, statSync as statSync20 } from "fs";
19315
+ import { join as join30, relative as relative12 } from "path";
18795
19316
  function collectHooksDirSources(tree, unreadable2, gaps) {
18796
19317
  const root = tree.root;
18797
19318
  const out = [];
18798
19319
  let base;
18799
19320
  try {
18800
- base = statSync20(root).isDirectory() ? root : join29(root, "..");
19321
+ base = statSync20(root).isDirectory() ? root : join30(root, "..");
18801
19322
  } catch {
18802
19323
  return out;
18803
19324
  }
18804
19325
  const noteUnread = (path, what, err) => {
18805
19326
  gaps.count++;
18806
- const anchor = relative11(base, path) || ".";
19327
+ const anchor = relative12(base, path) || ".";
18807
19328
  const reason = `${anchor} ${what} (${fsErrorCode(err)}) \u2014 a hooks/ directory under it may exist unseen, so the timeout guards are undeterminable (Extension Rule 9)`;
18808
19329
  if (!unreadable2.some((u) => u.anchor === anchor && u.reason === reason)) {
18809
19330
  unreadable2.push({ anchor, reason });
18810
19331
  }
18811
19332
  };
18812
- const walk3 = (dir) => {
19333
+ const walk4 = (dir) => {
18813
19334
  let entries;
18814
19335
  try {
18815
- entries = readdirSync14(dir);
19336
+ entries = readdirSync15(dir);
18816
19337
  } catch (err) {
18817
19338
  noteUnread(dir, "could not be listed", err);
18818
19339
  return;
18819
19340
  }
18820
19341
  for (const name of entries) {
18821
- const full = join29(dir, name);
19342
+ const full = join30(dir, name);
18822
19343
  let st;
18823
19344
  try {
18824
19345
  st = statSync20(full);
@@ -18835,7 +19356,7 @@ function collectHooksDirSources(tree, unreadable2, gaps) {
18835
19356
  if (name === "hooks") {
18836
19357
  let files;
18837
19358
  try {
18838
- files = readdirSync14(full);
19359
+ files = readdirSync15(full);
18839
19360
  } catch (err) {
18840
19361
  noteUnread(full, "could not be listed", err);
18841
19362
  files = [];
@@ -18844,11 +19365,11 @@ function collectHooksDirSources(tree, unreadable2, gaps) {
18844
19365
  if (!f.endsWith(".ts") || f.endsWith(".d.ts")) continue;
18845
19366
  const stem = f.replace(/\.ts$/, "");
18846
19367
  if (stem === "index") continue;
18847
- const filePath = join29(full, f);
19368
+ const filePath = join30(full, f);
18848
19369
  let body;
18849
19370
  try {
18850
19371
  if (!statSync20(filePath).isFile()) throw new Error("not a regular file");
18851
- body = readFileSync19(filePath, "utf8");
19372
+ body = readFileSync20(filePath, "utf8");
18852
19373
  } catch {
18853
19374
  const shortPath = filePath.split("/").slice(-2).join("/");
18854
19375
  unreadable2.push({
@@ -18864,10 +19385,10 @@ function collectHooksDirSources(tree, unreadable2, gaps) {
18864
19385
  });
18865
19386
  }
18866
19387
  }
18867
- walk3(full);
19388
+ walk4(full);
18868
19389
  }
18869
19390
  };
18870
- walk3(base);
19391
+ walk4(base);
18871
19392
  return out;
18872
19393
  }
18873
19394
  var LIFECYCLE_OBJ_RE2 = /\blifecycle\s*:\s*\{/;
@@ -19234,6 +19755,194 @@ var dServer2 = guardUnreadablePackageJson(dServer2Inner, {
19234
19755
  authoritative: false
19235
19756
  });
19236
19757
 
19758
+ // src/detectors/dServer6Flow.ts
19759
+ import * as ts2 from "typescript";
19760
+ var LOG_CALL_RE = /^(?:console|logger|log)\.(?:log|info|warn|error|debug|trace)$/;
19761
+ var STREAM_WRITE_RE = /^process\.(?:stderr|stdout)\.write$/;
19762
+ var ALWAYS_INFRA_PROPS = /* @__PURE__ */ new Set(["hostname"]);
19763
+ var OBJECT_INFRA_PROPS = /* @__PURE__ */ new Set(["host", "url", "origin", "href"]);
19764
+ var SERVERISH_NAME_RE = /server|srv|listener|endpoint|url|uri|origin/i;
19765
+ var INFRA_NAME_RE = /host|url|uri|origin|endpoint|addr/i;
19766
+ var SERVER_FACTORY_RE = /(?:^|\.)(?:serve|createServer|listen)$/;
19767
+ var MAX_DEPTH = 4;
19768
+ function scriptKind(rel2) {
19769
+ if (/\.tsx$/i.test(rel2)) return ts2.ScriptKind.TSX;
19770
+ if (/\.jsx$/i.test(rel2)) return ts2.ScriptKind.JSX;
19771
+ if (/\.(?:js|mjs|cjs)$/i.test(rel2)) return ts2.ScriptKind.JS;
19772
+ return ts2.ScriptKind.TS;
19773
+ }
19774
+ function declsIn(scope2, name) {
19775
+ const out = [];
19776
+ if (ts2.isFunctionLike(scope2)) {
19777
+ for (const p of scope2.parameters) {
19778
+ let found = false;
19779
+ const visitName = (n) => {
19780
+ if (ts2.isIdentifier(n)) found ||= n.text === name;
19781
+ else for (const e of n.elements) if (ts2.isBindingElement(e)) visitName(e.name);
19782
+ };
19783
+ visitName(p.name);
19784
+ if (found) out.push({ kind: "opaque" });
19785
+ }
19786
+ }
19787
+ walk(
19788
+ scope2,
19789
+ (n) => {
19790
+ if (ts2.isVariableDeclaration(n)) {
19791
+ if (ts2.isIdentifier(n.name)) {
19792
+ if (n.name.text === name) out.push({ kind: "var", init: n.initializer, node: n });
19793
+ } else if (ts2.isObjectBindingPattern(n.name)) {
19794
+ for (const el of n.name.elements) {
19795
+ if (!ts2.isIdentifier(el.name) || el.name.text !== name) continue;
19796
+ const prop2 = el.propertyName && ts2.isIdentifier(el.propertyName) ? el.propertyName.text : el.propertyName && ts2.isStringLiteralLike(el.propertyName) ? el.propertyName.text : el.propertyName ? void 0 : el.name.text;
19797
+ if (prop2 && n.initializer && !el.dotDotDotToken)
19798
+ out.push({ kind: "binding", prop: prop2, init: n.initializer, node: el });
19799
+ else out.push({ kind: "opaque" });
19800
+ }
19801
+ } else if (ts2.isArrayBindingPattern(n.name)) {
19802
+ for (const el of n.name.elements)
19803
+ if (ts2.isBindingElement(el) && ts2.isIdentifier(el.name) && el.name.text === name)
19804
+ out.push({ kind: "opaque" });
19805
+ }
19806
+ }
19807
+ },
19808
+ true
19809
+ );
19810
+ return out;
19811
+ }
19812
+ function declOf(id) {
19813
+ for (let s = id.parent; s; s = s.parent) {
19814
+ if (!(ts2.isFunctionLike(s) || ts2.isSourceFile(s))) continue;
19815
+ const ds = declsIn(s, id.text);
19816
+ if (ds.length === 0) continue;
19817
+ return ds.length === 1 ? ds[0] : { kind: "opaque" };
19818
+ }
19819
+ return void 0;
19820
+ }
19821
+ function isServerish(e, depth) {
19822
+ const u = unwrap(e);
19823
+ if (depth > MAX_DEPTH) return false;
19824
+ if (ts2.isNewExpression(u)) return dotted(u.expression) === "URL";
19825
+ if (ts2.isCallExpression(u)) {
19826
+ const c = dotted(u.expression);
19827
+ return c !== void 0 && SERVER_FACTORY_RE.test(c);
19828
+ }
19829
+ const pr = propRead(u);
19830
+ if (pr) return OBJECT_INFRA_PROPS.has(pr.name) && isServerish(pr.obj, depth + 1);
19831
+ if (ts2.isIdentifier(u)) {
19832
+ if (SERVERISH_NAME_RE.test(u.text)) return true;
19833
+ const d = declOf(u);
19834
+ return d?.kind === "var" && d.init !== void 0 && isServerish(d.init, depth + 1);
19835
+ }
19836
+ return false;
19837
+ }
19838
+ function pathOf(obj, name) {
19839
+ const d = dotted(obj);
19840
+ return d === void 0 ? void 0 : `${d}.${name}`;
19841
+ }
19842
+ function infraProp(obj, name) {
19843
+ return ALWAYS_INFRA_PROPS.has(name) || OBJECT_INFRA_PROPS.has(name) && isServerish(obj, 0);
19844
+ }
19845
+ function leaves(e, out = []) {
19846
+ const u = unwrap(e);
19847
+ if (ts2.isTemplateExpression(u)) {
19848
+ for (const s of u.templateSpans) leaves(s.expression, out);
19849
+ } else if (ts2.isBinaryExpression(u) && u.operatorToken.kind === ts2.SyntaxKind.PlusToken) {
19850
+ leaves(u.left, out);
19851
+ leaves(u.right, out);
19852
+ } else if (ts2.isConditionalExpression(u)) {
19853
+ leaves(u.whenTrue, out);
19854
+ leaves(u.whenFalse, out);
19855
+ } else if (ts2.isObjectLiteralExpression(u)) {
19856
+ for (const p of u.properties) {
19857
+ if (ts2.isPropertyAssignment(p)) leaves(p.initializer, out);
19858
+ else if (ts2.isShorthandPropertyAssignment(p)) out.push(p.name);
19859
+ }
19860
+ } else if (ts2.isArrayLiteralExpression(u)) {
19861
+ for (const x of u.elements) if (!ts2.isSpreadElement(x)) leaves(x, out);
19862
+ } else if (ts2.isCallExpression(u)) {
19863
+ const callee = dotted(u.expression);
19864
+ if (callee === "String" || callee === "JSON.stringify") {
19865
+ for (const a of u.arguments) leaves(a, out);
19866
+ } else if (ts2.isPropertyAccessExpression(u.expression) && u.expression.name.text === "toString") {
19867
+ leaves(u.expression.expression, out);
19868
+ } else out.push(u);
19869
+ } else {
19870
+ out.push(u);
19871
+ }
19872
+ return out;
19873
+ }
19874
+ function classify3(e, depth) {
19875
+ if (depth > MAX_DEPTH) return null;
19876
+ const u = unwrap(e);
19877
+ const pr = propRead(u);
19878
+ if (pr) {
19879
+ return infraProp(pr.obj, pr.name) ? {
19880
+ kind: "hit",
19881
+ via: `${u.getText()} (a ${pr.name} read off ${pr.obj.getText()})`,
19882
+ path: pathOf(pr.obj, pr.name)
19883
+ } : null;
19884
+ }
19885
+ if (ts2.isIdentifier(u)) {
19886
+ const d = declOf(u);
19887
+ if (!d) return null;
19888
+ if (d.kind === "binding") {
19889
+ return infraProp(d.init, d.prop) ? {
19890
+ kind: "hit",
19891
+ via: `${u.text} (destructured: ${d.prop} of ${d.init.getText()}${d.prop === u.text ? "" : `, renamed ${u.text}`})`,
19892
+ path: pathOf(d.init, d.prop)
19893
+ } : null;
19894
+ }
19895
+ if (d.kind === "var" && d.init) {
19896
+ const inner = unwrap(d.init);
19897
+ for (const l of leaves(inner)) {
19898
+ const v = classify3(l, depth + 1);
19899
+ if (v?.kind === "hit") return { kind: "hit", via: `${u.text} <- ${v.via}`, path: v.path };
19900
+ if (v?.kind === "unknown") return v;
19901
+ }
19902
+ const flowsFromCall = ts2.isCallExpression(inner) || ts2.isNewExpression(inner);
19903
+ if (flowsFromCall && INFRA_NAME_RE.test(u.text) && depth === 0)
19904
+ return {
19905
+ kind: "unknown",
19906
+ reason: `${u.text} is assigned from ${inner.getText().slice(0, 60)}, a call whose value this reader cannot follow`
19907
+ };
19908
+ return null;
19909
+ }
19910
+ if (d.kind === "opaque" && INFRA_NAME_RE.test(u.text) && depth === 0)
19911
+ return {
19912
+ kind: "unknown",
19913
+ reason: `${u.text} is a parameter or has several declarations, so where its value comes from cannot be followed`
19914
+ };
19915
+ }
19916
+ return null;
19917
+ }
19918
+ function dServer6Flow(file) {
19919
+ const hits = [];
19920
+ const unknown = [];
19921
+ const sf = ts2.createSourceFile(
19922
+ file.rel,
19923
+ sourceOf(file),
19924
+ ts2.ScriptTarget.Latest,
19925
+ true,
19926
+ scriptKind(file.rel)
19927
+ );
19928
+ walk(sf, (n) => {
19929
+ if (!ts2.isCallExpression(n)) return;
19930
+ const callee = dotted(n.expression);
19931
+ if (!callee || !(LOG_CALL_RE.test(callee) || STREAM_WRITE_RE.test(callee))) return;
19932
+ for (const arg of n.arguments) {
19933
+ if (ts2.isSpreadElement(arg)) continue;
19934
+ for (const l of leaves(arg)) {
19935
+ const v = classify3(l, 0);
19936
+ if (v?.kind === "hit")
19937
+ hits.push({ line: lineOf(n), text: l.getText(), via: v.via, path: v.path });
19938
+ else if (v?.kind === "unknown")
19939
+ unknown.push({ line: lineOf(n), text: l.getText(), reason: v.reason });
19940
+ }
19941
+ }
19942
+ });
19943
+ return { hits, unknown };
19944
+ }
19945
+
19237
19946
  // src/detectors/dServer6.ts
19238
19947
  var LOG_OPENER_RE = /\b(?:console|logger|log)\.(?:log|info|warn|error|debug|trace)\s*\(|\bprocess\.(?:stderr|stdout)\.write\s*\(/;
19239
19948
  var SECRET_RE = /\b(?:api[_-]?key|token|secret|passwd|password|authorization|auth[_-]?token|bearer|access[_-]?key|client[_-]?secret|private[_-]?key)\b/i;
@@ -19501,6 +20210,27 @@ var dServer6 = {
19501
20210
  }
19502
20211
  }
19503
20212
  }
20213
+ for (const file of tree.files) {
20214
+ const flow = dServer6Flow(file);
20215
+ const seen = new Set(findings.filter((f) => f.form === "D").map((f) => f.site));
20216
+ for (const h of flow.hits) {
20217
+ const site = `${file.rel}:${h.line}`;
20218
+ if (seen.has(site)) continue;
20219
+ if (h.path && resolvesToLiteral(tree, h.path)) continue;
20220
+ seen.add(site);
20221
+ findings.push({
20222
+ site,
20223
+ form: "D",
20224
+ note: `identifier flow: ${h.via} reaches the log call`
20225
+ });
20226
+ }
20227
+ for (const u of flow.unknown) {
20228
+ unreadable2.push({
20229
+ anchor: `${file.rel}:${u.line}`,
20230
+ reason: `cannot follow the value of ${u.text} logged at ${file.rel}:${u.line}: ${u.reason} \u2014 internal-infrastructure detail unverifiable (C-6)`
20231
+ });
20232
+ }
20233
+ }
19504
20234
  for (const file of tree.files) {
19505
20235
  for (const line of file.lines) {
19506
20236
  if (line.comment) continue;
@@ -19940,7 +20670,7 @@ function codeText(file) {
19940
20670
  }
19941
20671
  return { file, text: parts.join(""), kind: Uint8Array.from(kinds), lineStart };
19942
20672
  }
19943
- function lineOf2(ct, off) {
20673
+ function lineOf4(ct, off) {
19944
20674
  let lo = 0;
19945
20675
  let hi = ct.lineStart.length - 1;
19946
20676
  while (lo < hi) {
@@ -20066,8 +20796,8 @@ function on401Path(ct, siteStart, siteEnd) {
20066
20796
  }
20067
20797
  }
20068
20798
  }
20069
- const first = Math.max(1, lineOf2(ct, siteStart) - PATH_LINES_BEFORE);
20070
- const last = Math.min(ct.lineStart.length, lineOf2(ct, siteEnd) + PATH_LINES_AFTER);
20799
+ const first = Math.max(1, lineOf4(ct, siteStart) - PATH_LINES_BEFORE);
20800
+ const last = Math.min(ct.lineStart.length, lineOf4(ct, siteEnd) + PATH_LINES_AFTER);
20071
20801
  const from = Math.max(blockStart, ct.lineStart[first - 1]);
20072
20802
  const to = Math.min(blockEnd2, last < ct.lineStart.length ? ct.lineStart[last] : t.length);
20073
20803
  for (const m of t.slice(from, to).matchAll(/\b401\b/g)) {
@@ -20085,7 +20815,7 @@ function scanChallengeSites(files) {
20085
20815
  const open = m.index ?? 0;
20086
20816
  const close2 = open + m[0].length - 1;
20087
20817
  if (ct.kind[open] !== 1 || ct.kind[close2] !== 1) continue;
20088
- const anchor = `${file.rel}:${lineOf2(ct, open)}`;
20818
+ const anchor = `${file.rel}:${lineOf4(ct, open)}`;
20089
20819
  const before = t.slice(Math.max(0, open - 200), open);
20090
20820
  const after = t.slice(close2 + 1, close2 + 200);
20091
20821
  let form = null;
@@ -20686,7 +21416,7 @@ function configPlaces(tree, reg) {
20686
21416
  meta: placeOf(tree, config, "_meta")
20687
21417
  };
20688
21418
  }
20689
- function lineOf3(anchor) {
21419
+ function lineOf5(anchor) {
20690
21420
  const i = anchor.lastIndexOf(":");
20691
21421
  return [anchor.slice(0, i), Number(anchor.slice(i + 1))];
20692
21422
  }
@@ -20792,8 +21522,8 @@ function judgeStatic(tree, id) {
20792
21522
  to: fn ? lineAt(gate.src.shape, fn.close) : lineAt(gate.src.shape, gate.at) + 1
20793
21523
  }));
20794
21524
  regUnread = unread2.filter((u) => {
20795
- const [rel, n] = lineOf3(u.anchor);
20796
- return !spans.some((sp) => sp.rel === rel && n >= sp.from && n <= sp.to);
21525
+ const [rel2, n] = lineOf5(u.anchor);
21526
+ return !spans.some((sp) => sp.rel === rel2 && n >= sp.from && n <= sp.to);
20797
21527
  });
20798
21528
  for (const { gate, fn } of installers) {
20799
21529
  const ex = gateExemptions(tree, gate, fn);
@@ -20844,7 +21574,7 @@ function judgeStatic(tree, id) {
20844
21574
  }
20845
21575
  const decided = problems.length > 0 ? {
20846
21576
  id,
20847
- anchor: lineOf3(problems[0].match(/\(([^()\s]+:\d+)\)/)?.[1] ?? "-:0").join(":"),
21577
+ anchor: lineOf5(problems[0].match(/\(([^()\s]+:\d+)\)/)?.[1] ?? "-:0").join(":"),
20848
21578
  state: "non-conforming",
20849
21579
  verdict: `${problems.join("; ")} -> every tool declares { domain, mode } (mode exactly read | write, read <-> readOnlyHint true), and the shared decision of ${CLOUD_IDENTITY} refuses tools/call and filters tools/list for every registered tool (mcp-server-standard "Agent tool roles", rules 2-4, 7)`
20850
21580
  } : {
@@ -21393,7 +22123,7 @@ var e10MrtrOnly = {
21393
22123
 
21394
22124
  // src/detectors/e11-surfaces-derived.ts
21395
22125
  import { existsSync as existsSync21, statSync as statSync21 } from "fs";
21396
- import { dirname as dirname15, join as join30, relative as relative12, sep as sep6 } from "path";
22126
+ import { dirname as dirname15, join as join31, relative as relative13, sep as sep7 } from "path";
21397
22127
  var ALL = ["chat", "cowork", "claude-code"];
21398
22128
  function excludedSurfaces(c) {
21399
22129
  const cause = /* @__PURE__ */ new Map();
@@ -21465,7 +22195,7 @@ var e11SurfacesDerived = {
21465
22195
  continue;
21466
22196
  }
21467
22197
  const folder = dirname15(m.path);
21468
- const rel = (p) => relative12(tree.root, p).split(sep6).join("/") || ".";
22198
+ const rel2 = (p) => relative13(tree.root, p).split(sep7).join("/") || ".";
21469
22199
  if (!Array.isArray(j.surfaces)) {
21470
22200
  reds.push({
21471
22201
  anchor: m.rel,
@@ -21482,14 +22212,14 @@ var e11SurfacesDerived = {
21482
22212
  text: `${m.rel} surfaces ${unknown.join(", ")} are not in {${ALL.join(", ")}}`
21483
22213
  });
21484
22214
  }
21485
- const mcp = join30(folder, ".mcp.json");
22215
+ const mcp = join31(folder, ".mcp.json");
21486
22216
  let localMcp = false;
21487
22217
  if (existsSync21(mcp)) {
21488
22218
  const mj = readJsonRecord(mcp);
21489
22219
  if (!mj)
21490
22220
  unreadable2.push({
21491
- anchor: rel(mcp),
21492
- reason: `${rel(mcp)} is not a parseable JSON object \u2014 local MCP commands are unread`
22221
+ anchor: rel2(mcp),
22222
+ reason: `${rel2(mcp)} is not a parseable JSON object \u2014 local MCP commands are unread`
21493
22223
  });
21494
22224
  else {
21495
22225
  const servers = isRecord(mj.mcpServers) ? mj.mcpServers : mj;
@@ -21501,9 +22231,9 @@ var e11SurfacesDerived = {
21501
22231
  }
21502
22232
  }
21503
22233
  const cause = excludedSurfaces({
21504
- bin: isDir(join30(folder, "bin"), rel(join30(folder, "bin")), unreadable2),
21505
- hooks: isDir(join30(folder, "hooks"), rel(join30(folder, "hooks")), unreadable2),
21506
- agents: isDir(join30(folder, "agents"), rel(join30(folder, "agents")), unreadable2),
22234
+ bin: isDir(join31(folder, "bin"), rel2(join31(folder, "bin")), unreadable2),
22235
+ hooks: isDir(join31(folder, "hooks"), rel2(join31(folder, "hooks")), unreadable2),
22236
+ agents: isDir(join31(folder, "agents"), rel2(join31(folder, "agents")), unreadable2),
21507
22237
  localMcp
21508
22238
  });
21509
22239
  for (const s of declared) {
@@ -21627,8 +22357,8 @@ var e12HostCapabilityPlacement = {
21627
22357
  };
21628
22358
 
21629
22359
  // src/detectors/installedAs.ts
21630
- import { readdirSync as readdirSync15, statSync as statSync22 } from "fs";
21631
- import { join as join31 } from "path";
22360
+ import { readFileSync as readFileSync21, readdirSync as readdirSync16, statSync as statSync22 } from "fs";
22361
+ import { dirname as dirname16, join as join32, relative as relative14, sep as sep8 } from "path";
21632
22362
  var KEY = (k) => `(?:\\[\\s*["'\`]${k}["'\`]\\s*\\]|["']${k}["']|\\b${k}\\b)`;
21633
22363
  function keyRe(key) {
21634
22364
  return new RegExp(`${KEY(key)}\\s*(?<sep>:)`);
@@ -21649,17 +22379,193 @@ var REGISTER_HANDLER_RE = /\.(?:get|post|put|all|on|route)\s*(?<sep>\()\s*(?:["'
21649
22379
  var REGISTER_MOUNT_RE = /\.use\s*(?<sep>\()\s*["'`]\/register["'`]/;
21650
22380
  var REGISTER_LITERAL_RE = /(?<sep>["'`])\/register["'`]/;
21651
22381
  var ROUTE_RE = /["'`]\/?\.well-known\/oauth-authorization-server["'`]/;
22382
+ var ENTRY_FIELDS = ["exports", "main", "module", "bin"];
22383
+ var IMPORT_RE = /\b(?:from|import)\s*(["'])([^"'\n]+)\1|\b(?:import|require)\s*\(\s*(["'`])([^"'`\n]+)\3\s*\)/g;
22384
+ var NONLITERAL_IMPORT_RE = /\b(?:import|require)\s*\((?!\s*["'`])/g;
22385
+ var RESOLVE_SUFFIXES = [
22386
+ "",
22387
+ ".js",
22388
+ ".mjs",
22389
+ ".cjs",
22390
+ ".json",
22391
+ "/index.js",
22392
+ "/index.mjs",
22393
+ "/index.cjs"
22394
+ ];
22395
+ var FIXTURE_DIRS = /* @__PURE__ */ new Set([
22396
+ "test",
22397
+ "tests",
22398
+ "__test__",
22399
+ "__tests__",
22400
+ "test-utils",
22401
+ "spec",
22402
+ "specs",
22403
+ "e2e",
22404
+ "__mocks__",
22405
+ "mocks",
22406
+ "__fixtures__",
22407
+ "fixture",
22408
+ "fixtures",
22409
+ "example",
22410
+ "examples",
22411
+ "samples",
22412
+ "demo",
22413
+ "docs"
22414
+ ]);
21652
22415
  var MAX_BYTES = 1e6;
21653
22416
  var MAX_FILES_PER_PACKAGE = 3e3;
21654
22417
  var SOURCE_EXT = /\.(?:js|mjs|cjs|json)$/;
22418
+ var FACT_KEYS = ["cimd", "registration", "iss", "none"];
22419
+ var countFacts = (f) => FACT_KEYS.filter((k) => f[k]).length;
21655
22420
  function declaredDependencies(tree) {
21656
22421
  const json = tree.packageJson?.json;
21657
22422
  const deps = json && typeof json.dependencies === "object" ? json.dependencies : null;
21658
22423
  return deps && !Array.isArray(deps) ? Object.keys(deps).sort() : [];
21659
22424
  }
22425
+ function declaredEntries(dir, dep, unread2) {
22426
+ let json;
22427
+ try {
22428
+ json = JSON.parse(readFileSync21(join32(dir, "package.json"), "utf8"));
22429
+ } catch (e) {
22430
+ if (e.code === "ENOENT") return null;
22431
+ unread2.push(
22432
+ `${dep}/package.json (not parsed: ${e.message}; the package is not read)`
22433
+ );
22434
+ return [];
22435
+ }
22436
+ if (!json || typeof json !== "object" || Array.isArray(json)) {
22437
+ unread2.push(`${dep}/package.json (not an object; the package is not read)`);
22438
+ return [];
22439
+ }
22440
+ const pj = json;
22441
+ if (!ENTRY_FIELDS.some((f) => pj[f] !== void 0)) return null;
22442
+ const targets = [];
22443
+ const collect2 = (v, field) => {
22444
+ if (typeof v === "string") targets.push(v);
22445
+ else if (Array.isArray(v)) for (const x of v) collect2(x, field);
22446
+ else if (v === null)
22447
+ return;
22448
+ else if (typeof v === "object")
22449
+ for (const x of Object.values(v)) collect2(x, field);
22450
+ else
22451
+ unread2.push(
22452
+ `${dep}/package.json (${field}: a ${typeof v} is not an entry form this reader knows: not followed)`
22453
+ );
22454
+ };
22455
+ for (const f of ENTRY_FIELDS) if (pj[f] !== void 0) collect2(pj[f], f);
22456
+ return targets;
22457
+ }
22458
+ function walkPackage(dir, nm, skipFixtures, unread2) {
22459
+ const files = [];
22460
+ const walk4 = (d) => {
22461
+ let names2;
22462
+ try {
22463
+ names2 = readdirSync16(d).sort();
22464
+ } catch (e) {
22465
+ unread2.push(`${d.slice(nm.length + 1)} (directory not listed: ${e.message})`);
22466
+ return;
22467
+ }
22468
+ for (const n of names2) {
22469
+ if (files.length >= MAX_FILES_PER_PACKAGE) return;
22470
+ if (n === "node_modules") continue;
22471
+ const full = join32(d, n);
22472
+ let st;
22473
+ try {
22474
+ st = statSync22(full);
22475
+ } catch (e) {
22476
+ unread2.push(`${full.slice(nm.length + 1)} (not stat'ed: ${e.message})`);
22477
+ continue;
22478
+ }
22479
+ if (st.isDirectory()) {
22480
+ if (skipFixtures && FIXTURE_DIRS.has(n.toLowerCase())) {
22481
+ unread2.push(`${full.slice(nm.length + 1)} (test/example directory: not read)`);
22482
+ continue;
22483
+ }
22484
+ walk4(full);
22485
+ } else if (st.isFile() && SOURCE_EXT.test(n)) files.push(full);
22486
+ }
22487
+ };
22488
+ walk4(dir);
22489
+ return files;
22490
+ }
22491
+ var escapeRe4 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
22492
+ function followEntries(dir, nm, targets, files, load2, unread2) {
22493
+ const dep = dir.slice(nm.length + 1);
22494
+ const show = (f) => f.slice(nm.length + 1);
22495
+ const reached = /* @__PURE__ */ new Set();
22496
+ const queue = [];
22497
+ const enqueue = (f) => {
22498
+ if (reached.has(f)) return;
22499
+ reached.add(f);
22500
+ queue.push(f);
22501
+ };
22502
+ const resolve5 = (base, spec) => {
22503
+ for (const suffix of RESOLVE_SUFFIXES) {
22504
+ const f = join32(base, spec + suffix);
22505
+ if (f !== dir && !f.startsWith(dir + sep8)) return "outside";
22506
+ let st;
22507
+ try {
22508
+ st = statSync22(f);
22509
+ } catch {
22510
+ continue;
22511
+ }
22512
+ if (!st.isFile()) continue;
22513
+ return SOURCE_EXT.test(f) ? { path: f } : "not-source";
22514
+ }
22515
+ return "not-found";
22516
+ };
22517
+ const take = (r, where, spec) => {
22518
+ if (typeof r === "object") enqueue(r.path);
22519
+ else if (r === "not-found") unread2.push(`${where} ("${spec}" not resolved: not followed)`);
22520
+ else if (r === "outside") unread2.push(`${where} ("${spec}" leaves the package: not followed)`);
22521
+ };
22522
+ for (const t of targets) {
22523
+ if (t.includes("*")) {
22524
+ const re = new RegExp(`^${t.replace(/^\.\//, "").split("*").map(escapeRe4).join(".*")}$`);
22525
+ for (const f of files) if (re.test(relative14(dir, f).split(sep8).join("/"))) enqueue(f);
22526
+ continue;
22527
+ }
22528
+ take(resolve5(dir, t), `${dep}/package.json`, t);
22529
+ }
22530
+ while (queue.length > 0) {
22531
+ if (reached.size > MAX_FILES_PER_PACKAGE) {
22532
+ unread2.push(
22533
+ `${dep} (more than ${MAX_FILES_PER_PACKAGE} files reached: the rest were not read)`
22534
+ );
22535
+ break;
22536
+ }
22537
+ const f = queue.shift();
22538
+ const file = load2(f);
22539
+ if (!file || f.endsWith(".json")) continue;
22540
+ const text = file.lines.map((l) => l.raw).join("\n");
22541
+ const at = (index) => {
22542
+ const head = text.slice(0, index);
22543
+ return { n: head.split("\n").length, col: index - (head.lastIndexOf("\n") + 1) };
22544
+ };
22545
+ for (const m of text.matchAll(IMPORT_RE)) {
22546
+ const { n, col } = at(m.index);
22547
+ if (!isCodeAt(file, n, col)) continue;
22548
+ const spec = m[2] ?? m[4];
22549
+ const where = `${show(f)}:${n}`;
22550
+ if (spec.includes("${")) unread2.push(`${where} (import of a computed path: not followed)`);
22551
+ else if (spec.startsWith("./") || spec.startsWith("../"))
22552
+ take(resolve5(dirname16(f), spec), where, spec);
22553
+ else if (spec.startsWith("#"))
22554
+ unread2.push(`${where} (subpath import "${spec}": not followed)`);
22555
+ else if (spec.startsWith("/") || spec.startsWith("file:"))
22556
+ unread2.push(`${where} (absolute import "${spec}": not followed)`);
22557
+ }
22558
+ for (const m of text.matchAll(NONLITERAL_IMPORT_RE)) {
22559
+ const { n, col } = at(m.index);
22560
+ if (isCodeAt(file, n, col))
22561
+ unread2.push(`${show(f)}:${n} (non-literal import/require: its target not followed)`);
22562
+ }
22563
+ }
22564
+ return reached;
22565
+ }
21660
22566
  function readInstalledAs(tree) {
21661
22567
  const out = { installed: false, missing: [], publishers: [], unread: [] };
21662
- const nm = join31(baseOf(tree), "node_modules");
22568
+ const nm = join32(baseOf(tree), "node_modules");
21663
22569
  try {
21664
22570
  out.installed = statSync22(nm).isDirectory();
21665
22571
  } catch {
@@ -21667,74 +22573,75 @@ function readInstalledAs(tree) {
21667
22573
  }
21668
22574
  if (!out.installed) return out;
21669
22575
  const methods = authMethodsRe();
22576
+ const perPublisher = [];
21670
22577
  for (const dep of declaredDependencies(tree)) {
21671
- const dir = join31(nm, dep);
22578
+ const dir = join32(nm, dep);
21672
22579
  try {
21673
22580
  if (!statSync22(dir).isDirectory()) throw new Error("not a directory");
21674
22581
  } catch {
21675
22582
  out.missing.push(dep);
21676
22583
  continue;
21677
22584
  }
21678
- const files = [];
21679
- const walk3 = (d) => {
21680
- let names2;
21681
- try {
21682
- names2 = readdirSync15(d).sort();
21683
- } catch (e) {
21684
- out.unread.push(
21685
- `${d.slice(nm.length + 1)} (directory not listed: ${e.message})`
21686
- );
21687
- return;
21688
- }
21689
- for (const n of names2) {
21690
- if (files.length >= MAX_FILES_PER_PACKAGE) return;
21691
- if (n === "node_modules") continue;
21692
- const full = join31(d, n);
21693
- let st;
21694
- try {
21695
- st = statSync22(full);
21696
- } catch (e) {
21697
- out.unread.push(`${full.slice(nm.length + 1)} (not stat'ed: ${e.message})`);
21698
- continue;
21699
- }
21700
- if (st.isDirectory()) walk3(full);
21701
- else if (st.isFile() && SOURCE_EXT.test(n) && !n.endsWith(".d.ts")) files.push(full);
21702
- }
21703
- };
21704
- walk3(dir);
22585
+ const entries = declaredEntries(dir, dep, out.unread);
22586
+ const files = walkPackage(dir, nm, entries === null, out.unread);
21705
22587
  if (files.length >= MAX_FILES_PER_PACKAGE) {
21706
22588
  out.unread.push(`${dep} (more than ${MAX_FILES_PER_PACKAGE} files: the rest were not read)`);
21707
22589
  }
21708
22590
  const read = [];
21709
- for (const f of files) {
21710
- const rel = f.slice(nm.length + 1);
22591
+ const load2 = (f) => {
22592
+ const rel2 = f.slice(nm.length + 1);
21711
22593
  try {
21712
22594
  if (statSync22(f).size > MAX_BYTES) {
21713
- out.unread.push(`${rel} (larger than ${MAX_BYTES} bytes: not read)`);
21714
- continue;
22595
+ out.unread.push(`${rel2} (larger than ${MAX_BYTES} bytes: not read)`);
22596
+ return void 0;
21715
22597
  }
21716
22598
  const file = loadSourceFile(f, nm);
21717
- read.push({ rel, file, rows: uncommentedLines(file) });
22599
+ read.push({ rel: rel2, file, rows: uncommentedLines(file) });
22600
+ return file;
21718
22601
  } catch (e) {
21719
- out.unread.push(`${rel} (not read: ${e.message})`);
22602
+ out.unread.push(`${rel2} (not read: ${e.message})`);
22603
+ return void 0;
22604
+ }
22605
+ };
22606
+ if (entries === null) {
22607
+ for (const f of files) load2(f);
22608
+ } else {
22609
+ const reached = followEntries(dir, nm, entries, files, load2, out.unread);
22610
+ const manifest = join32(dir, "package.json");
22611
+ const outside = files.filter((f) => f !== manifest && !reached.has(f)).length;
22612
+ if (outside > 0) {
22613
+ out.unread.push(
22614
+ `${dep} (${outside} file${outside === 1 ? "" : "s"} outside what its declared entry points load: not read)`
22615
+ );
21720
22616
  }
21721
22617
  }
21722
- if (!read.some((r) => r.rows.some((row) => ROUTE_RE.test(row)))) continue;
22618
+ const routeFiles = read.filter((r) => r.rows.some((row) => ROUTE_RE.test(row)));
22619
+ if (routeFiles.length === 0) continue;
21723
22620
  out.publishers.push(dep);
21724
22621
  const find = (...res) => {
21725
22622
  for (const re of res) {
21726
- for (const r of read) {
22623
+ for (const r of routeFiles) {
21727
22624
  const n = separatorLines(r.file, re)[0];
21728
22625
  if (n !== void 0) return { anchor: `node_modules/${r.rel}:${n}` };
21729
22626
  }
21730
22627
  }
21731
22628
  return void 0;
21732
22629
  };
21733
- out.cimd ??= find(flagTrueRe("client_id_metadata_document_supported"));
21734
- out.registration ??= find(REGISTRATION_KEY_RE, REGISTER_HANDLER_RE, REGISTER_MOUNT_RE);
21735
- out.iss ??= find(flagTrueRe("authorization_response_iss_parameter_supported"));
21736
- out.none ??= find(methods.none);
21737
- out.authMethodsKeyWithoutNone ??= find(methods.key);
22630
+ const facts = {
22631
+ cimd: find(flagTrueRe("client_id_metadata_document_supported")),
22632
+ registration: find(REGISTRATION_KEY_RE, REGISTER_HANDLER_RE, REGISTER_MOUNT_RE),
22633
+ iss: find(flagTrueRe("authorization_response_iss_parameter_supported")),
22634
+ none: find(methods.none)
22635
+ };
22636
+ perPublisher.push({ dep, facts });
22637
+ }
22638
+ let best;
22639
+ for (const p of perPublisher) {
22640
+ if (!best || countFacts(p.facts) > countFacts(best.facts)) best = p;
22641
+ }
22642
+ if (best && countFacts(best.facts) > 0) {
22643
+ out.factsFrom = best.dep;
22644
+ for (const k of FACT_KEYS) if (best.facts[k]) out[k] = best.facts[k];
21738
22645
  }
21739
22646
  return out;
21740
22647
  }
@@ -21792,7 +22699,7 @@ function delegatedAsElements(tree, fallbackAnchor) {
21792
22699
  const g = inst.cimd && inst.none ? [
21793
22700
  {
21794
22701
  status: "ok",
21795
- text: `CIMD announced (${inst.cimd.anchor}) and "none" listed (${inst.none.anchor}) by the installed ${pk}`,
22702
+ text: `CIMD announced (${inst.cimd.anchor}) and "none" listed (${inst.none.anchor}) by the installed ${inst.factsFrom ?? pk}`,
21796
22703
  anchor: inst.cimd.anchor
21797
22704
  }
21798
22705
  ] : owed(
@@ -21801,7 +22708,7 @@ function delegatedAsElements(tree, fallbackAnchor) {
21801
22708
  const l = inst.iss ? [
21802
22709
  {
21803
22710
  status: "owed",
21804
- text: `the installed ${pk} announces authorization_response_iss_parameter_supported: true (${inst.iss.anchor}); owed (probe): \`iss\` is returned on every authorization response, error responses included`,
22711
+ text: `the installed ${inst.factsFrom ?? pk} announces authorization_response_iss_parameter_supported: true (${inst.iss.anchor}); owed (probe): \`iss\` is returned on every authorization response, error responses included`,
21805
22712
  anchor: inst.iss.anchor
21806
22713
  }
21807
22714
  ] : owed(
@@ -22941,8 +23848,8 @@ var s12ListPagination = {
22941
23848
  for (const [method, anchors] of sites) {
22942
23849
  for (const a of anchors) {
22943
23850
  handled++;
22944
- const rel = a.slice(0, a.lastIndexOf(":"));
22945
- if (!withCursor.has(rel)) {
23851
+ const rel2 = a.slice(0, a.lastIndexOf(":"));
23852
+ if (!withCursor.has(rel2)) {
22946
23853
  reds.push({
22947
23854
  anchor: a,
22948
23855
  text: `${method} is handled at ${a} in a file with no nextCursor (a list that can exceed a page returns nextCursor)`
@@ -23689,8 +24596,8 @@ function documentsFootprint(manifestText) {
23689
24596
  } catch {
23690
24597
  return false;
23691
24598
  }
23692
- const walk3 = (v) => {
23693
- if (Array.isArray(v)) return v.some(walk3);
24599
+ const walk4 = (v) => {
24600
+ if (Array.isArray(v)) return v.some(walk4);
23694
24601
  if (v === null || typeof v !== "object") return false;
23695
24602
  for (const [k, val] of Object.entries(v)) {
23696
24603
  if (k === "footprint") {
@@ -23698,11 +24605,11 @@ function documentsFootprint(manifestText) {
23698
24605
  if (Array.isArray(val) && val.length > 0) return true;
23699
24606
  if (val !== null && typeof val === "object" && Object.keys(val).length > 0) return true;
23700
24607
  }
23701
- if (walk3(val)) return true;
24608
+ if (walk4(val)) return true;
23702
24609
  }
23703
24610
  return false;
23704
24611
  };
23705
- return walk3(json);
24612
+ return walk4(json);
23706
24613
  }
23707
24614
 
23708
24615
  // src/detectors/s17-forward-auth.ts
@@ -24052,7 +24959,7 @@ var s20ScopeMinimization = {
24052
24959
 
24053
24960
  // src/detectors/s21-stdio-proxy-sandbox.ts
24054
24961
  var LAUNCH_RE = /(?<![.\w$])(?:spawn|spawnSync|exec|execSync|execFile|execFileSync|fork)\s*\(|child_process\s*\.\s*(?:spawn|spawnSync|exec|execSync|execFile|execFileSync|fork)\s*\(|\bnew\s+StdioClientTransport\s*\(/g;
24055
- var IMPORT_RE = /child_process|\bexeca\b|StdioClientTransport/;
24962
+ var IMPORT_RE2 = /child_process|\bexeca\b|StdioClientTransport/;
24056
24963
  var SANDBOX_RE = /\b(?:docker|podman|bwrap|bubblewrap|firejail|nsjail|chroot|seccomp|unshare|landlock|gvisor|runsc)\b|\bsandbox\w*\b|--network[= ]none|--read-only/i;
24057
24964
  var LOG_RE = /\blogger\s*\.\s*\w+\s*\(|\blog\s*\.\s*\w+\s*\(|\bconsole\s*\.\s*(?:log|info|warn|error|debug)\s*\(|\b(?:audit|logLaunch|logSpawn|logProcess|logCommand)\w*\s*\(/i;
24058
24965
  var DANGEROUS_RE = /shell\s*:\s*true|["'`](?:sh|bash|zsh|sudo|cmd(?:\.exe)?|powershell(?:\.exe)?)["'`]/;
@@ -24082,7 +24989,7 @@ var s21StdioProxySandbox = {
24082
24989
  if (!isProductSource(file.rel)) continue;
24083
24990
  const rows = uncommentedLines(file);
24084
24991
  const text = rows.join("\n");
24085
- if (!IMPORT_RE.test(text)) continue;
24992
+ if (!IMPORT_RE2.test(text)) continue;
24086
24993
  const launches = [];
24087
24994
  rows.forEach((row, i) => {
24088
24995
  if (new RegExp(LAUNCH_RE.source).test(row)) launches.push(i);
@@ -24496,11 +25403,11 @@ function leavesOf(tree, v, file, depth) {
24496
25403
  }
24497
25404
  function classifyOriginValue(tree, value, file) {
24498
25405
  const v = value.trim();
24499
- const leaves = leavesOf(tree, v, file, 0);
24500
- const wild = leaves.strings.find((x) => x.slice(1, -1).includes("*"));
25406
+ const leaves2 = leavesOf(tree, v, file, 0);
25407
+ const wild = leaves2.strings.find((x) => x.slice(1, -1).includes("*"));
24501
25408
  if (wild) return { kind: "wildcard", detail: wild };
24502
- if (leaves.unresolved) return { kind: "unresolved", detail: leaves.unresolved };
24503
- if (leaves.strings.length === 0)
25409
+ if (leaves2.unresolved) return { kind: "unresolved", detail: leaves2.unresolved };
25410
+ if (leaves2.strings.length === 0)
24504
25411
  return { kind: "empty", detail: v.startsWith("[") ? v : `${v} (an empty list)` };
24505
25412
  return { kind: "ok", detail: v };
24506
25413
  }
@@ -24686,19 +25593,47 @@ var s24ToolRateLimit = {
24686
25593
  };
24687
25594
 
24688
25595
  // src/detectors/s25-resource-discipline.ts
24689
- var SUBJECT_RE2 = /registerResource\s*\(|\.resource\s*\(|\bResourceTemplate\s*\(|resources\/read|ReadResourceRequestSchema|\bresources\s*:\s*\{|type\s*:\s*["'`](?:image|audio)["'`]|\bblob\s*:/;
25596
+ import * as ts3 from "typescript";
25597
+ var SUBJECT_RE2 = /registerResource\s*\(|\.resource\s*\(|\bResourceTemplate\s*\(|resources\/read|ReadResourceRequestSchema|\bresources\s*:\s*\{|type\s*:\s*["'`](?:image|audio)["'`]/;
24690
25598
  var HANDLER_RE = /registerResource\s*\(|\.resource\s*\(|ReadResourceRequestSchema/;
24691
25599
  var DEREF_RE = /\b(?:readFile|readFileSync|createReadStream|readdir|readdirSync|stat|statSync|open|fetch)\s*\(([^)]*)\)/g;
24692
25600
  var CALLER_ARG_RE = /\b(?:uri|url|path|params|href|pathname)\b/;
24693
25601
  var VALID_RE2 = /\bresolve\s*\(|\bnormalize\s*\(|\bstartsWith\s*\(|\.includes\(\s*["'`]\.\.|\bnew URL\s*\(|\ballowlist\b|\bisAllowed\w*|\bvalidate\w*\s*\(|\bsanitize\w*\s*\(|\.parse\s*\(|\brealpath\w*\s*\(/i;
24694
25602
  var SCHEME_RE = /["'`]([^\s"'`:/]+(?: [^\s"'`:/]+)*):\/\/[^"'`]*["'`]/g;
24695
25603
  var RFC3986_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/;
25604
+ function blobAssignments(file) {
25605
+ const text = file.lines.map((l) => l.raw).join("\n");
25606
+ if (!text.includes("blob")) return { sites: [], unparsed: false };
25607
+ const kind = file.rel.endsWith(".tsx") ? ts3.ScriptKind.TSX : ts3.ScriptKind.TS;
25608
+ const sf = ts3.createSourceFile(file.rel, text, ts3.ScriptTarget.Latest, true, kind);
25609
+ const unparsed = (sf.parseDiagnostics ?? []).length > 0;
25610
+ const sites = [];
25611
+ const lineAt4 = (n) => sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1;
25612
+ const visit = (n) => {
25613
+ if (ts3.isPropertyAssignment(n)) {
25614
+ const k = n.name;
25615
+ const key = ts3.isIdentifier(k) || ts3.isStringLiteralLike(k) ? k.text : ts3.isComputedPropertyName(k) && ts3.isStringLiteralLike(k.expression) ? k.expression.text : void 0;
25616
+ if (key === "blob") sites.push({ line: lineAt4(n), value: n.initializer.getText(sf) });
25617
+ } else if (ts3.isBinaryExpression(n) && n.operatorToken.kind === ts3.SyntaxKind.EqualsToken) {
25618
+ const l = n.left;
25619
+ const name = ts3.isPropertyAccessExpression(l) ? l.name.text : ts3.isElementAccessExpression(l) && ts3.isStringLiteralLike(l.argumentExpression) ? l.argumentExpression.text : void 0;
25620
+ if (name === "blob") sites.push({ line: lineAt4(n), value: n.right.getText(sf) });
25621
+ }
25622
+ ts3.forEachChild(n, visit);
25623
+ };
25624
+ visit(sf);
25625
+ return { sites, unparsed };
25626
+ }
24696
25627
  function s25Controls() {
24697
25628
  return {
24698
- sees: !RFC3986_SCHEME.test("my_app") && !RFC3986_SCHEME.test("1app") && !RFC3986_SCHEME.test("my app") && SUBJECT_RE2.test("registerResource('a', 'x://y', {}, h)"),
24699
- spares: RFC3986_SCHEME.test("my-app+v2.x") && RFC3986_SCHEME.test("https") && !SUBJECT_RE2.test("const x = 1")
25629
+ sees: !RFC3986_SCHEME.test("my_app") && !RFC3986_SCHEME.test("1app") && !RFC3986_SCHEME.test("my app") && SUBJECT_RE2.test("registerResource('a', 'x://y', {}, h)") && blobFixture("const a = { blob: raw };") === 1 && blobFixture('const a = { "blob": raw };') === 1 && blobFixture("a.blob = raw;") === 1,
25630
+ spares: RFC3986_SCHEME.test("my-app+v2.x") && RFC3986_SCHEME.test("https") && !SUBJECT_RE2.test("const x = 1") && blobFixture("const S = new Set([\"blob:\", 'blob:', `blob:`]);") === 0
24700
25631
  };
24701
25632
  }
25633
+ function blobFixture(code) {
25634
+ const lines2 = code.split("\n").map((raw, i) => ({ n: i + 1, raw, comment: false }));
25635
+ return blobAssignments({ path: "control.ts", rel: "control.ts", lines: lines2 }).sites.length;
25636
+ }
24702
25637
  var s25ResourceDiscipline = {
24703
25638
  id: "S25 resource-discipline",
24704
25639
  rule: "S-25",
@@ -24713,15 +25648,20 @@ var s25ResourceDiscipline = {
24713
25648
  const reds = [];
24714
25649
  let subject = 0;
24715
25650
  let first = "";
25651
+ const unread2 = [];
24716
25652
  for (const file of tree.files) {
24717
25653
  if (!isProductSource(file.rel)) continue;
24718
25654
  const rows = uncommentedLines(file);
24719
25655
  const text = rows.join("\n");
24720
- if (!SUBJECT_RE2.test(text)) continue;
25656
+ const blobs = blobAssignments(file);
25657
+ if (blobs.unparsed) unread2.push(file.rel);
25658
+ const blobAt = /* @__PURE__ */ new Map();
25659
+ if (!blobs.unparsed) for (const b of blobs.sites) blobAt.set(b.line, b.value);
25660
+ if (!SUBJECT_RE2.test(text) && blobAt.size === 0) continue;
24721
25661
  subject++;
24722
25662
  const at = (i) => `${file.rel}:${i + 1}`;
24723
25663
  rows.forEach((row, i) => {
24724
- if (!first && SUBJECT_RE2.test(row)) first = at(i);
25664
+ if (!first && (SUBJECT_RE2.test(row) || blobAt.has(i + 1))) first = at(i);
24725
25665
  for (const m of row.matchAll(SCHEME_RE)) {
24726
25666
  const scheme = m[1];
24727
25667
  if (scheme.includes("$") || scheme.includes("{")) continue;
@@ -24731,14 +25671,14 @@ var s25ResourceDiscipline = {
24731
25671
  );
24732
25672
  }
24733
25673
  }
24734
- const blob = row.match(/\bblob\s*:\s*(.+?)(?:,|\}|$)/);
24735
- if (blob && !/base64|btoa|b64/i.test(blob[1])) {
25674
+ const blob = blobAt.get(i + 1);
25675
+ if (blob !== void 0 && !/base64|btoa|b64/i.test(blob)) {
24736
25676
  reds.push(
24737
- `${at(i)} sets blob to a value that is not base64-encoded (${blob[1].trim().slice(0, 40)}): binary content is base64`
25677
+ `${at(i)} sets blob to a value that is not base64-encoded (${blob.trim().replace(/\s+/g, " ").slice(0, 40)}): binary content is base64`
24738
25678
  );
24739
25679
  }
24740
25680
  const near = rows.slice(Math.max(0, i - 3), i + 4).join("\n");
24741
- if ((/type\s*:\s*["'`](?:image|audio)["'`]/.test(row) || blob) && !/mimeType/.test(near)) {
25681
+ if ((/type\s*:\s*["'`](?:image|audio)["'`]/.test(row) || blob !== void 0) && !/mimeType/.test(near)) {
24742
25682
  reds.push(
24743
25683
  `${at(i)} carries binary content with no valid MIME type (no mimeType within three lines)`
24744
25684
  );
@@ -24759,6 +25699,16 @@ var s25ResourceDiscipline = {
24759
25699
  }
24760
25700
  });
24761
25701
  }
25702
+ if (reds.length === 0 && unread2.length > 0) {
25703
+ const reason = `could not determine blob assignments: ${unread2.join(", ")} did not parse, so a \`blob\` property in it was not read (S-25)`;
25704
+ return {
25705
+ id: this.id,
25706
+ anchor: `${unread2[0]}:1`,
25707
+ state: "could-not-judge",
25708
+ reason,
25709
+ verdict: `could not judge: ${reason}`
25710
+ };
25711
+ }
24762
25712
  if (subject === 0) {
24763
25713
  return absentResult(
24764
25714
  this.id,
@@ -24998,8 +25948,8 @@ var s27ElicitationFloor = {
24998
25948
  };
24999
25949
 
25000
25950
  // src/detectors/s28-claim-forwarded.ts
25001
- import { existsSync as existsSync22, readFileSync as readFileSync20, readdirSync as readdirSync16, statSync as statSync23 } from "fs";
25002
- import { dirname as dirname16, join as join32, relative as relative13 } from "path";
25951
+ import { existsSync as existsSync22, readFileSync as readFileSync22, readdirSync as readdirSync17, statSync as statSync23 } from "fs";
25952
+ import { dirname as dirname17, join as join33, relative as relative15 } from "path";
25003
25953
 
25004
25954
  // src/detectors/backendReceiver.ts
25005
25955
  var CLIENT_NAME = /convex|client/i;
@@ -25107,14 +26057,14 @@ function splitTop3(m, from, to) {
25107
26057
  function listTs(dir, unread2, out = []) {
25108
26058
  let names2;
25109
26059
  try {
25110
- names2 = readdirSync16(dir);
26060
+ names2 = readdirSync17(dir);
25111
26061
  } catch (err) {
25112
26062
  unread2.push(`${dir} could not be listed (${fsErrorCode(err)})`);
25113
26063
  return out;
25114
26064
  }
25115
26065
  for (const n of names2) {
25116
26066
  if (n === "node_modules" || n === "_generated" || n === "__tests__") continue;
25117
- const p = join32(dir, n);
26067
+ const p = join33(dir, n);
25118
26068
  let st;
25119
26069
  try {
25120
26070
  st = statSync23(p);
@@ -25133,14 +26083,14 @@ function listTs(dir, unread2, out = []) {
25133
26083
  function discoverBackend(root) {
25134
26084
  let dir = root;
25135
26085
  try {
25136
- if (!statSync23(root).isDirectory()) dir = dirname16(root);
26086
+ if (!statSync23(root).isDirectory()) dir = dirname17(root);
25137
26087
  } catch {
25138
26088
  return void 0;
25139
26089
  }
25140
26090
  for (let up2 = 0; up2 < 5; up2++) {
25141
- const cand = join32(dir, "convex");
25142
- if (existsSync22(join32(cand, "schema.ts"))) return cand;
25143
- const parent = dirname16(dir);
26091
+ const cand = join33(dir, "convex");
26092
+ if (existsSync22(join33(cand, "schema.ts"))) return cand;
26093
+ const parent = dirname17(dir);
25144
26094
  if (parent === dir) break;
25145
26095
  dir = parent;
25146
26096
  }
@@ -25151,18 +26101,18 @@ function readDoors(backendRoot, unread2) {
25151
26101
  for (const path of listTs(backendRoot, unread2)) {
25152
26102
  let text;
25153
26103
  try {
25154
- text = readFileSync20(path, "utf8");
26104
+ text = readFileSync22(path, "utf8");
25155
26105
  } catch (err) {
25156
26106
  unread2.push(`${path} could not be read (${fsErrorCode(err)})`);
25157
26107
  continue;
25158
26108
  }
25159
26109
  const file = {
25160
26110
  path,
25161
- rel: relative13(backendRoot, path),
26111
+ rel: relative15(backendRoot, path),
25162
26112
  lines: text.split("\n").map((raw, i) => ({ n: i + 1, raw, comment: false }))
25163
26113
  };
25164
26114
  const m = masked(file);
25165
- const module = relative13(backendRoot, path).replace(/\.ts$/, "").split("\\").join("/");
26115
+ const module = relative15(backendRoot, path).replace(/\.ts$/, "").split("\\").join("/");
25166
26116
  const re = /\bexport\s+const\s+([A-Za-z_$][\w$]*)\s*=\s*(?:query|mutation|action)\s*\(/g;
25167
26117
  for (let hit = re.exec(m); hit; hit = re.exec(m)) {
25168
26118
  const open = hit.index + hit[0].length - 1;
@@ -28650,10 +29600,10 @@ var s41LakeReader = {
28650
29600
  };
28651
29601
 
28652
29602
  // src/detectors/s42-write-read-claims.ts
28653
- import { readFileSync as readFileSync21 } from "fs";
28654
- import { relative as relative14 } from "path";
29603
+ import { readFileSync as readFileSync23 } from "fs";
29604
+ import { relative as relative16 } from "path";
28655
29605
  var ID9 = "S42 write-read-claims";
28656
- var RULE9 = "S-42";
29606
+ var RULE10 = "S-42";
28657
29607
  var CLAIMS = ["verifiedOrg", "verifiedPerson", "verifiedActor", "seatOrgSlug"];
28658
29608
  var KEY_RE = new RegExp(`\\b(${CLAIMS.join("|")})\\s*\\??\\s*:`, "g");
28659
29609
  var CALL_RE4 = /\b([A-Za-z_$][\w$]*)\s*\.\s*(query|mutation|action)\s*\(/g;
@@ -28698,18 +29648,18 @@ function readDoorAccess(backendRoot, unread2) {
28698
29648
  for (const path of listTs(backendRoot, unread2)) {
28699
29649
  let text;
28700
29650
  try {
28701
- text = readFileSync21(path, "utf8");
29651
+ text = readFileSync23(path, "utf8");
28702
29652
  } catch (err) {
28703
29653
  unread2.push(`${path} could not be read (${fsErrorCode(err)})`);
28704
29654
  continue;
28705
29655
  }
28706
29656
  const file = {
28707
29657
  path,
28708
- rel: relative14(backendRoot, path),
29658
+ rel: relative16(backendRoot, path),
28709
29659
  lines: text.split("\n").map((raw, i) => ({ n: i + 1, raw, comment: false }))
28710
29660
  };
28711
29661
  const m = masked(file);
28712
- const module = relative14(backendRoot, path).replace(/\.ts$/, "").split("\\").join("/");
29662
+ const module = relative16(backendRoot, path).replace(/\.ts$/, "").split("\\").join("/");
28713
29663
  const re = /\bexport\s+const\s+([A-Za-z_$][\w$]*)\s*=\s*(query|mutation|action|internalMutation|internalQuery)\s*\(/g;
28714
29664
  for (let hit = re.exec(m); hit; hit = re.exec(m)) {
28715
29665
  const open = hit.index + hit[0].length - 1;
@@ -28733,7 +29683,7 @@ function readDoorAccess(backendRoot, unread2) {
28733
29683
  const c = o < 0 ? -1 : matchClose2(m, o);
28734
29684
  return c < 0 ? void 0 : text.slice(o, c + 1);
28735
29685
  };
28736
- const walk3 = (body, seen, depth) => {
29686
+ const walk4 = (body, seen, depth) => {
28737
29687
  for (const h of body.matchAll(/\bdb\s*\.\s*insert\s*\(\s*["'`](\w+)["'`]/g))
28738
29688
  acc.writes.add(h[1]);
28739
29689
  for (const h of body.matchAll(/\bdb\s*\.\s*query\s*\(\s*["'`](\w+)["'`]/g))
@@ -28747,10 +29697,10 @@ function readDoorAccess(backendRoot, unread2) {
28747
29697
  if (seen.has(c[1])) continue;
28748
29698
  seen.add(c[1]);
28749
29699
  const sub = fnBodyRaw(c[1]);
28750
- if (sub) walk3(sub, seen, depth + 1);
29700
+ if (sub) walk4(sub, seen, depth + 1);
28751
29701
  }
28752
29702
  };
28753
- walk3(raw, /* @__PURE__ */ new Set([hit[1]]), 0);
29703
+ walk4(raw, /* @__PURE__ */ new Set([hit[1]]), 0);
28754
29704
  out.set(`${module}:${hit[1]}`, acc);
28755
29705
  }
28756
29706
  }
@@ -28782,14 +29732,14 @@ function scanS42(tree) {
28782
29732
  if (door !== void 0 || importsConvex(m, text))
28783
29733
  unread2.push({
28784
29734
  anchor: at,
28785
- reason: `${tool}: the receiver is not resolved to a backend client \u2014 ${rcv.why} (${RULE9})`
29735
+ reason: `${tool}: the receiver is not resolved to a backend client \u2014 ${rcv.why} (${RULE10})`
28786
29736
  });
28787
29737
  continue;
28788
29738
  }
28789
29739
  if (door === void 0) {
28790
29740
  unread2.push({
28791
29741
  anchor: at,
28792
- reason: `${tool}: a backend door named by an expression (${RULE9})`
29742
+ reason: `${tool}: a backend door named by an expression (${RULE10})`
28793
29743
  });
28794
29744
  continue;
28795
29745
  }
@@ -28815,7 +29765,7 @@ function scanS42(tree) {
28815
29765
  if (unresolved !== void 0) {
28816
29766
  unread2.push({
28817
29767
  anchor: at,
28818
- reason: `${tool}: the claims spread by ${unresolved}(...) cannot be resolved (no definition with readable claim keys in the tree) (${RULE9})`
29768
+ reason: `${tool}: the claims spread by ${unresolved}(...) cannot be resolved (no definition with readable claim keys in the tree) (${RULE10})`
28819
29769
  });
28820
29770
  continue;
28821
29771
  }
@@ -28826,12 +29776,12 @@ function scanS42(tree) {
28826
29776
  if (calls.length > 0 && !backendRoot)
28827
29777
  unread2.push({
28828
29778
  anchor: tree.root,
28829
- reason: `no backend source found above the scanned tree, so no door's table can be read (${RULE9})`
29779
+ reason: `no backend source found above the scanned tree, so no door's table can be read (${RULE10})`
28830
29780
  });
28831
29781
  const fsUnread = [];
28832
29782
  const access = backendRoot ? readDoorAccess(backendRoot, fsUnread) : /* @__PURE__ */ new Map();
28833
29783
  for (const u of fsUnread)
28834
- unread2.push({ anchor: backendRoot ?? tree.root, reason: `${u} (${RULE9})` });
29784
+ unread2.push({ anchor: backendRoot ?? tree.root, reason: `${u} (${RULE10})` });
28835
29785
  return { calls, unread: unread2, backend: backendRoot, access };
28836
29786
  }
28837
29787
  function runStatic3(tree) {
@@ -28841,7 +29791,7 @@ function runStatic3(tree) {
28841
29791
  id: ID9,
28842
29792
  anchor: tree.root,
28843
29793
  state: "absent",
28844
- verdict: `no backend door call in the tree \u2014 ${RULE9} n/a`
29794
+ verdict: `no backend door call in the tree \u2014 ${RULE10} n/a`
28845
29795
  };
28846
29796
  const writesOf = /* @__PURE__ */ new Map();
28847
29797
  const readsOf = /* @__PURE__ */ new Map();
@@ -28851,7 +29801,7 @@ function runStatic3(tree) {
28851
29801
  if (c.claims.size > 0 || c.keyed)
28852
29802
  unread2.push({
28853
29803
  anchor: c.at,
28854
- reason: `${c.tool}: door ${c.door} is not defined in the backend read (${RULE9})`
29804
+ reason: `${c.tool}: door ${c.door} is not defined in the backend read (${RULE10})`
28855
29805
  });
28856
29806
  continue;
28857
29807
  }
@@ -28885,29 +29835,29 @@ function runStatic3(tree) {
28885
29835
  id: ID9,
28886
29836
  anchor: red[0].slice(red[0].indexOf("(") + 1).split(", ")[1]?.replace(")", "") ?? tree.root,
28887
29837
  state: "non-conforming",
28888
- verdict: `${red.length} write/read claim mismatch(es): a row written without a claim its reads forward is stored where those reads cannot return it (${RULE9}): ${red.join("; ")}.`
29838
+ verdict: `${red.length} write/read claim mismatch(es): a row written without a claim its reads forward is stored where those reads cannot return it (${RULE10}): ${red.join("; ")}.`
28889
29839
  } : {
28890
29840
  id: ID9,
28891
29841
  anchor: tree.root,
28892
29842
  state: "present",
28893
- verdict: `${compared} table(s) with both a write and a read tool compared: every write forwards the claims its reads forward${keyedTables.length > 0 ? `; resolved by one helper keyed by the door on ${keyedTables.join(", ")}` : ""} (${RULE9}).`
29843
+ verdict: `${compared} table(s) with both a write and a read tool compared: every write forwards the claims its reads forward${keyedTables.length > 0 ? `; resolved by one helper keyed by the door on ${keyedTables.join(", ")}` : ""} (${RULE10}).`
28894
29844
  };
28895
29845
  return settle(ID9, decided, unread2);
28896
29846
  }
28897
29847
  var s42WriteReadClaims = {
28898
29848
  id: ID9,
28899
- rule: RULE9,
29849
+ rule: RULE10,
28900
29850
  pin: STANDARD_PIN,
28901
29851
  run: runStatic3
28902
29852
  };
28903
29853
 
28904
29854
  // src/detectors/s44-closed-output.ts
28905
29855
  var ID10 = "S44 closed-output";
28906
- var RULE10 = "S-44";
29856
+ var RULE11 = "S-44";
28907
29857
  function judge(sites, j) {
28908
29858
  for (const s of sites) {
28909
29859
  if (s.kind === "unread")
28910
- j.unread.push({ anchor: s.anchor, reason: `${s.path}: ${s.form} (${RULE10})` });
29860
+ j.unread.push({ anchor: s.anchor, reason: `${s.path}: ${s.form} (${RULE11})` });
28911
29861
  else if (s.exempt) j.exempt.push(s);
28912
29862
  else j.violations.push(s);
28913
29863
  }
@@ -28919,18 +29869,18 @@ function verdictOf2(j, scope2, anchorFallback) {
28919
29869
  id: ID10,
28920
29870
  anchor: anchorFallback,
28921
29871
  state: "absent",
28922
- verdict: `${j.toolCount} tool(s) read (${scope2}), none declares an output schema \u2014 ${RULE10} n/a`
29872
+ verdict: `${j.toolCount} tool(s) read (${scope2}), none declares an output schema \u2014 ${RULE11} n/a`
28923
29873
  };
28924
29874
  const decided = j.violations.length > 0 ? {
28925
29875
  id: ID10,
28926
29876
  anchor: j.violations[0].anchor,
28927
29877
  state: "non-conforming",
28928
- 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 (${RULE10}): ${j.violations.map((v) => `${v.path} (${v.form}, ${v.anchor})`).join(", ")}.${ex}`
29878
+ 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 (${RULE11}): ${j.violations.map((v) => `${v.path} (${v.form}, ${v.anchor})`).join(", ")}.${ex}`
28929
29879
  } : {
28930
29880
  id: ID10,
28931
29881
  anchor: anchorFallback,
28932
29882
  state: "present",
28933
- verdict: `${j.withOutput} output schema(s) read (${scope2}): no object refuses an added field (${RULE10}).${ex}`
29883
+ verdict: `${j.withOutput} output schema(s) read (${scope2}): no object refuses an added field (${RULE11}).${ex}`
28934
29884
  };
28935
29885
  return settle(ID10, decided, j.unread);
28936
29886
  }
@@ -28962,7 +29912,7 @@ function runStatic4(tree) {
28962
29912
  if (tools.length === 0) {
28963
29913
  const surface = toolSurfaceAnchor(tree);
28964
29914
  if (surface || unresolved.length > 0) {
28965
- const reason = noToolsLocatedReason(tree, `no output schema could be read (${RULE10})`);
29915
+ const reason = noToolsLocatedReason(tree, `no output schema could be read (${RULE11})`);
28966
29916
  return couldNotJudge(
28967
29917
  ID10,
28968
29918
  surface ?? unresolved[0],
@@ -28973,7 +29923,7 @@ function runStatic4(tree) {
28973
29923
  id: ID10,
28974
29924
  anchor: tree.root,
28975
29925
  state: "absent",
28976
- verdict: `no MCP tool registered in product source \u2014 ${RULE10} n/a`
29926
+ verdict: `no MCP tool registered in product source \u2014 ${RULE11} n/a`
28977
29927
  };
28978
29928
  }
28979
29929
  const j = {
@@ -28986,7 +29936,7 @@ function runStatic4(tree) {
28986
29936
  for (const a of unresolved)
28987
29937
  j.unread.push({
28988
29938
  anchor: a,
28989
- reason: `a tool registered here has a name the scan cannot resolve, so its output schema is unread (${RULE10})`
29939
+ reason: `a tool registered here has a name the scan cannot resolve, so its output schema is unread (${RULE11})`
28990
29940
  });
28991
29941
  for (const tool of tools) {
28992
29942
  const read = closedOutputSites(tree, tool.name, tool.anchor);
@@ -29002,7 +29952,7 @@ function runServedHalf2(runtime) {
29002
29952
  return couldNotJudge(
29003
29953
  ID10,
29004
29954
  anchor,
29005
- `the server could not be started/introspected, so no served outputSchema was read: ${runtime.launchError} (${RULE10})`
29955
+ `the server could not be started/introspected, so no served outputSchema was read: ${runtime.launchError} (${RULE11})`
29006
29956
  );
29007
29957
  const j = {
29008
29958
  violations: [],
@@ -29020,15 +29970,15 @@ function runServedHalf2(runtime) {
29020
29970
  }
29021
29971
  var s44ClosedOutput = {
29022
29972
  id: ID10,
29023
- rule: RULE10,
29973
+ rule: RULE11,
29024
29974
  pin: STANDARD_PIN,
29025
29975
  run: runStatic4,
29026
29976
  runServed: (runtime) => runServedHalf2(runtime)
29027
29977
  };
29028
29978
 
29029
29979
  // src/detectors/s45-origin-targets.ts
29030
- import { readFileSync as readFileSync22 } from "fs";
29031
- import { join as join33 } from "path";
29980
+ import { readFileSync as readFileSync24 } from "fs";
29981
+ import { join as join34 } from "path";
29032
29982
 
29033
29983
  // src/detectors/data/pslPrivate.ts
29034
29984
  var PSL_PRIVATE_RULES = [
@@ -32485,7 +33435,7 @@ var PSL_PRIVATE_RULES = [
32485
33435
  // src/detectors/s45-origin-targets.ts
32486
33436
  var HOSTS_VERIFICATION = (id) => HOSTS[id]?.verification;
32487
33437
  var ID11 = "S45 origin-targets";
32488
- var RULE11 = "S-45";
33438
+ var RULE12 = "S-45";
32489
33439
  var PIN12 = STANDARD_PIN;
32490
33440
  var PLATFORM_HOSTS = PSL_PRIVATE_RULES.map((r) => r.startsWith("*.") ? r.slice(2) : r);
32491
33441
  var TRANSPORT_RE4 = /\bStreamableHTTPServerTransport\b|\bWebStandardStreamableHTTPServerTransport\b|\bcreateMcpHandler\s*\(|\.(?:post|all)\(\s*["'`]\/mcp["'`]|\bbuildHttpApp\s*\(/;
@@ -32548,16 +33498,16 @@ function servesStreamableHttp(tree, manifest) {
32548
33498
  });
32549
33499
  }
32550
33500
  function run7(tree) {
32551
- const manifestPath2 = join33(tree.root, "mcp-server.json");
33501
+ const manifestPath2 = join34(tree.root, "mcp-server.json");
32552
33502
  let manifest = {};
32553
33503
  try {
32554
- manifest = JSON.parse(readFileSync22(manifestPath2, "utf8"));
33504
+ manifest = JSON.parse(readFileSync24(manifestPath2, "utf8"));
32555
33505
  } catch (err) {
32556
33506
  if (fsErrorCode(err) !== "ENOENT")
32557
33507
  return couldNotJudge(
32558
33508
  ID11,
32559
33509
  manifestPath2,
32560
- `mcp-server.json could not be read or parsed (${fsErrorCode(err)}) (${RULE11})`
33510
+ `mcp-server.json could not be read or parsed (${fsErrorCode(err)}) (${RULE12})`
32561
33511
  );
32562
33512
  }
32563
33513
  const files = tree.files.map((f) => ({ f, text: textOf(f) }));
@@ -32568,11 +33518,11 @@ function run7(tree) {
32568
33518
  id: ID11,
32569
33519
  anchor: manifestPath2,
32570
33520
  state: "absent",
32571
- verdict: hasHttp ? `no target host declared (mcp-server.json distribution.targets is absent): the server is not distributed on hosts \u2014 ${RULE11} n/a` : `no HTTP transport and no target host declared (mcp-server.json distribution.targets): not a remote server \u2014 ${RULE11} n/a`
33521
+ verdict: hasHttp ? `no target host declared (mcp-server.json distribution.targets is absent): the server is not distributed on hosts \u2014 ${RULE12} n/a` : `no HTTP transport and no target host declared (mcp-server.json distribution.targets): not a remote server \u2014 ${RULE12} n/a`
32572
33522
  };
32573
33523
  }
32574
33524
  if (read.kind === "unreadable")
32575
- return couldNotJudge(ID11, manifestPath2, `${read.reason} (${RULE11})`);
33525
+ return couldNotJudge(ID11, manifestPath2, `${read.reason} (${RULE12})`);
32576
33526
  const targets = read.targets;
32577
33527
  const red = [];
32578
33528
  const unread2 = [];
@@ -32602,7 +33552,7 @@ function run7(tree) {
32602
33552
  }
32603
33553
  }
32604
33554
  try {
32605
- const env = readFileSync22(join33(tree.root, ".env.example"), "utf8");
33555
+ const env = readFileSync24(join34(tree.root, ".env.example"), "utf8");
32606
33556
  for (const m of env.matchAll(/^PUBLIC_BASE_URL=(\S+)/gm))
32607
33557
  urls.push({ url: m[1], where: ".env.example" });
32608
33558
  } catch {
@@ -32660,28 +33610,28 @@ function run7(tree) {
32660
33610
  id: ID11,
32661
33611
  anchor: manifestPath2,
32662
33612
  state: "non-conforming",
32663
- verdict: `${RULE11}: ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
33613
+ verdict: `${RULE12}: ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
32664
33614
  };
32665
- if (unread2.length > 0) return couldNotJudge(ID11, manifestPath2, `${unread2.join("; ")} (${RULE11})`);
33615
+ if (unread2.length > 0) return couldNotJudge(ID11, manifestPath2, `${unread2.join("; ")} (${RULE12})`);
32666
33616
  return {
32667
33617
  id: ID11,
32668
33618
  anchor: manifestPath2,
32669
33619
  state: "present",
32670
- verdict: `declared targets ${targets.join(", ")}: owned origin (${publicUrls.map((u) => hostOf2(u.url)).join(", ")}), Streamable HTTP served, every declared verification path read from configuration (${RULE11})`
33620
+ verdict: `declared targets ${targets.join(", ")}: owned origin (${publicUrls.map((u) => hostOf2(u.url)).join(", ")}), Streamable HTTP served, every declared verification path read from configuration (${RULE12})`
32671
33621
  };
32672
33622
  }
32673
33623
  var s45OriginTargets = {
32674
33624
  id: ID11,
32675
- rule: RULE11,
33625
+ rule: RULE12,
32676
33626
  pin: PIN12,
32677
33627
  run: run7
32678
33628
  };
32679
33629
 
32680
33630
  // src/detectors/s46-registration-redirects.ts
32681
- import { readFileSync as readFileSync23 } from "fs";
32682
- import { join as join34 } from "path";
33631
+ import { readFileSync as readFileSync25 } from "fs";
33632
+ import { join as join35 } from "path";
32683
33633
  var ID12 = "S46 registration-redirects";
32684
- var RULE12 = "S-46";
33634
+ var RULE13 = "S-46";
32685
33635
  var AS_ROUTE = /["'`]\/?\.well-known\/oauth-authorization-server["'`]/;
32686
33636
  var CIMD_RE2 = flagTrueRe("client_id_metadata_document_supported");
32687
33637
  function textOf2(f) {
@@ -32700,16 +33650,16 @@ function siteOf(files, re) {
32700
33650
  return void 0;
32701
33651
  }
32702
33652
  function run8(tree) {
32703
- const manifestPath2 = join34(tree.root, "mcp-server.json");
33653
+ const manifestPath2 = join35(tree.root, "mcp-server.json");
32704
33654
  let manifest = {};
32705
33655
  try {
32706
- manifest = JSON.parse(readFileSync23(manifestPath2, "utf8"));
33656
+ manifest = JSON.parse(readFileSync25(manifestPath2, "utf8"));
32707
33657
  } catch (err) {
32708
33658
  if (fsErrorCode(err) !== "ENOENT")
32709
33659
  return couldNotJudge(
32710
33660
  ID12,
32711
33661
  manifestPath2,
32712
- `mcp-server.json could not be read or parsed (${fsErrorCode(err)}) (${RULE12})`
33662
+ `mcp-server.json could not be read or parsed (${fsErrorCode(err)}) (${RULE13})`
32713
33663
  );
32714
33664
  }
32715
33665
  const read = readTargets(manifest);
@@ -32718,10 +33668,10 @@ function run8(tree) {
32718
33668
  id: ID12,
32719
33669
  anchor: manifestPath2,
32720
33670
  state: "absent",
32721
- verdict: `no target host declared (mcp-server.json distribution.targets is absent) \u2014 ${RULE12} n/a`
33671
+ verdict: `no target host declared (mcp-server.json distribution.targets is absent) \u2014 ${RULE13} n/a`
32722
33672
  };
32723
33673
  if (read.kind === "unreadable")
32724
- return couldNotJudge(ID12, manifestPath2, `${read.reason} (${RULE12})`);
33674
+ return couldNotJudge(ID12, manifestPath2, `${read.reason} (${RULE13})`);
32725
33675
  const installed = readInstalledAs(tree);
32726
33676
  const asSite = siteOf(tree.files, AS_ROUTE);
32727
33677
  if (!asSite && installed.publishers.length === 0)
@@ -32729,7 +33679,7 @@ function run8(tree) {
32729
33679
  id: ID12,
32730
33680
  anchor: manifestPath2,
32731
33681
  state: "absent",
32732
- verdict: `no authorization server in the tree or installed (no ${".well-known/oauth-authorization-server"} route): the server authenticates no person \u2014 ${RULE12} n/a`
33682
+ verdict: `no authorization server in the tree or installed (no ${".well-known/oauth-authorization-server"} route): the server authenticates no person \u2014 ${RULE13} n/a`
32733
33683
  };
32734
33684
  const first = (...res) => {
32735
33685
  for (const re of res) {
@@ -32766,19 +33716,19 @@ function run8(tree) {
32766
33716
  id: ID12,
32767
33717
  anchor: asSite ?? manifestPath2,
32768
33718
  state: "non-conforming",
32769
- verdict: `${RULE12}: ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
33719
+ verdict: `${RULE13}: ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
32770
33720
  };
32771
33721
  if (unread2.length > 0)
32772
33722
  return couldNotJudge(
32773
33723
  ID12,
32774
33724
  asSite ?? manifestPath2,
32775
- `CIMD (${cimd}) and DCR (${dcr}) offered; ${unread2.join("; ")} (${RULE12})`
33725
+ `CIMD (${cimd}) and DCR (${dcr}) offered; ${unread2.join("; ")} (${RULE13})`
32776
33726
  );
32777
33727
  return {
32778
33728
  id: ID12,
32779
33729
  anchor: asSite ?? manifestPath2,
32780
33730
  state: "present",
32781
- verdict: `CIMD (${cimd}) and DCR (${dcr}) offered; no declared host needs a redirect callback (${RULE12})`
33731
+ verdict: `CIMD (${cimd}) and DCR (${dcr}) offered; no declared host needs a redirect callback (${RULE13})`
32782
33732
  };
32783
33733
  }
32784
33734
  function sameTarget(location, redirect) {
@@ -32845,7 +33795,7 @@ function judgeServed2(runtime) {
32845
33795
  let facts;
32846
33796
  if (!runtime.served && runtime.publicAuth) facts = runtime.publicAuth;
32847
33797
  else {
32848
- const got = servedOrCouldNotJudge(ID12, RULE12, runtime);
33798
+ const got = servedOrCouldNotJudge(ID12, RULE13, runtime);
32849
33799
  if ("cnj" in got) return got.cnj;
32850
33800
  facts = got.served;
32851
33801
  }
@@ -32855,17 +33805,17 @@ function judgeServed2(runtime) {
32855
33805
  return couldNotJudge(
32856
33806
  ID12,
32857
33807
  anchor,
32858
- `no source tree was given (--source), so the declared targets (mcp-server.json distribution.targets) were not read (${RULE12})`
33808
+ `no source tree was given (--source), so the declared targets (mcp-server.json distribution.targets) were not read (${RULE13})`
32859
33809
  );
32860
33810
  let manifest = {};
32861
33811
  try {
32862
- manifest = JSON.parse(readFileSync23(join34(src, "mcp-server.json"), "utf8"));
33812
+ manifest = JSON.parse(readFileSync25(join35(src, "mcp-server.json"), "utf8"));
32863
33813
  } catch (err) {
32864
33814
  if (fsErrorCode(err) !== "ENOENT")
32865
33815
  return couldNotJudge(
32866
33816
  ID12,
32867
33817
  anchor,
32868
- `mcp-server.json not read: ${err.message} (${RULE12})`
33818
+ `mcp-server.json not read: ${err.message} (${RULE13})`
32869
33819
  );
32870
33820
  }
32871
33821
  const read = readTargets(manifest);
@@ -32874,15 +33824,15 @@ function judgeServed2(runtime) {
32874
33824
  id: ID12,
32875
33825
  anchor,
32876
33826
  state: "absent",
32877
- verdict: `no target host declared (mcp-server.json distribution.targets is absent) \u2014 ${RULE12} n/a`
33827
+ verdict: `no target host declared (mcp-server.json distribution.targets is absent) \u2014 ${RULE13} n/a`
32878
33828
  };
32879
- if (read.kind === "unreadable") return couldNotJudge(ID12, anchor, `${read.reason} (${RULE12})`);
33829
+ if (read.kind === "unreadable") return couldNotJudge(ID12, anchor, `${read.reason} (${RULE13})`);
32880
33830
  const as = facts.authServer;
32881
33831
  if (as.kind !== "document")
32882
33832
  return couldNotJudge(
32883
33833
  ID12,
32884
33834
  anchor,
32885
- `the authorization-server metadata was not read: ${as.kind === "not-run" ? as.reason : `${as.url}: ${as.reason}`} (${RULE12})`
33835
+ `the authorization-server metadata was not read: ${as.kind === "not-run" ? as.reason : `${as.url}: ${as.reason}`} (${RULE13})`
32886
33836
  );
32887
33837
  const doc = as.document;
32888
33838
  const red = [];
@@ -32935,15 +33885,15 @@ function judgeServed2(runtime) {
32935
33885
  id: ID12,
32936
33886
  anchor,
32937
33887
  state: "non-conforming",
32938
- verdict: `${RULE12} (served): ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
33888
+ verdict: `${RULE13} (served): ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
32939
33889
  };
32940
33890
  if (unread2.length > 0)
32941
- return couldNotJudge(ID12, anchor, `${ok.join("; ")}; ${unread2.join("; ")} (${RULE12}, served)`);
32942
- return { id: ID12, anchor, state: "present", verdict: `${ok.join("; ")} (${RULE12}, served)` };
33891
+ return couldNotJudge(ID12, anchor, `${ok.join("; ")}; ${unread2.join("; ")} (${RULE13}, served)`);
33892
+ return { id: ID12, anchor, state: "present", verdict: `${ok.join("; ")} (${RULE13}, served)` };
32943
33893
  }
32944
33894
  var s46RegistrationRedirects = {
32945
33895
  id: ID12,
32946
- rule: RULE12,
33896
+ rule: RULE13,
32947
33897
  pin: STANDARD_PIN,
32948
33898
  run: run8,
32949
33899
  runServed: runServed5
@@ -32951,7 +33901,7 @@ var s46RegistrationRedirects = {
32951
33901
 
32952
33902
  // src/detectors/s47-webhook-delivery.ts
32953
33903
  var ID13 = "S47 webhook-delivery";
32954
- var RULE13 = "S-47";
33904
+ var RULE14 = "S-47";
32955
33905
  var OUTBOUND_RE = /\bfetch\s*\(|\b(?:undici\.)?request\s*\(|\.post\s*\(|\bhttps?\.request\s*\(/;
32956
33906
  var CALLBACK_RE = /\b(?:callbackUrl|callback_url|webhookUrl|webhook_url)\b|\b(?:subscription|subscriber|sub|delivery|callback|webhook|target)\w*\??\.(?:url|uri|href|endpoint)\b/;
32957
33907
  var HEADERS = ["webhook-id", "webhook-timestamp", "webhook-signature"];
@@ -33105,7 +34055,7 @@ function bodyOf(file, line, col, levels = 0) {
33105
34055
  return { start: b.startLine, end: b.endLine, text: b.text };
33106
34056
  }
33107
34057
  function run9(tree) {
33108
- const { surface, early } = eventsGate(ID13, tree, RULE13);
34058
+ const { surface, early } = eventsGate(ID13, tree, RULE14);
33109
34059
  if (early) return early;
33110
34060
  const anchor = surface.declared?.anchor ?? surface.methods.get("events/subscribe")?.[0] ?? "-";
33111
34061
  const outbound2 = lineHits(tree, OUTBOUND_RE);
@@ -33165,28 +34115,28 @@ function run9(tree) {
33165
34115
  return couldNotJudge(
33166
34116
  ID13,
33167
34117
  anchor,
33168
- `${[...red, ...unread2].join("; ")} in this tree, but ${surface.helpers.join(", ")} is imported and may deliver events from outside it (${RULE13})`
34118
+ `${[...red, ...unread2].join("; ")} in this tree, but ${surface.helpers.join(", ")} is imported and may deliver events from outside it (${RULE14})`
33169
34119
  );
33170
34120
  if (red.length > 0)
33171
34121
  return {
33172
34122
  id: ID13,
33173
34123
  anchor,
33174
34124
  state: "non-conforming",
33175
- verdict: `${RULE13}: ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
34125
+ verdict: `${RULE14}: ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
33176
34126
  };
33177
- if (unread2.length > 0) return couldNotJudge(ID13, anchor, `${unread2.join("; ")} (${RULE13})`);
34127
+ if (unread2.length > 0) return couldNotJudge(ID13, anchor, `${unread2.join("; ")} (${RULE14})`);
33178
34128
  return {
33179
34129
  id: ID13,
33180
34130
  anchor: delivery?.anchor ?? anchor,
33181
34131
  state: "present",
33182
- verdict: `events delivered by webhook (${delivery?.anchor}), signed with ${HEADERS.join(", ")}, callback verified before the first delivery (${RULE13})`
34132
+ verdict: `events delivered by webhook (${delivery?.anchor}), signed with ${HEADERS.join(", ")}, callback verified before the first delivery (${RULE14})`
33183
34133
  };
33184
34134
  }
33185
- var s47WebhookDelivery = { id: ID13, rule: RULE13, pin: STANDARD_PIN, run: run9 };
34135
+ var s47WebhookDelivery = { id: ID13, rule: RULE14, pin: STANDARD_PIN, run: run9 };
33186
34136
 
33187
34137
  // src/detectors/s48-per-member.ts
33188
34138
  var ID14 = "S48 per-member";
33189
- var RULE14 = "S-48";
34139
+ var RULE15 = "S-48";
33190
34140
  var AS_ROUTE2 = /["'`]\/?\.well-known\/oauth-authorization-server["'`]/;
33191
34141
  var CRED = "(?:TOKEN|KEY|SECRET|BEARER|CREDENTIAL|PASSWORD)";
33192
34142
  var CRED_CAMEL = "(?:[Tt]oken|[Kk]ey|[Ss]ecret|[Bb]earer|[Cc]redential|[Pp]assword)";
@@ -33225,12 +34175,12 @@ function run10(tree) {
33225
34175
  id: ID14,
33226
34176
  anchor: "-",
33227
34177
  state: "absent",
33228
- verdict: `no authorization server in the tree or installed, and the ${RULE14} scope condition ${S48_CONDITION} is false here: ${scope2.found} \u2014 ${RULE14} n/a`
34178
+ verdict: `no authorization server in the tree or installed, and the ${RULE15} scope condition ${S48_CONDITION} is false here: ${scope2.found} \u2014 ${RULE15} n/a`
33229
34179
  };
33230
34180
  return couldNotJudge(
33231
34181
  ID14,
33232
34182
  scope2.anchor,
33233
- `the ${RULE14} scope condition ${S48_CONDITION} cannot be read: ${scope2.why} (${RULE14})`
34183
+ `the ${RULE15} scope condition ${S48_CONDITION} cannot be read: ${scope2.why} (${RULE15})`
33234
34184
  );
33235
34185
  }
33236
34186
  const anchor = asSite?.anchor ?? `node_modules/${installed.publishers[0]}`;
@@ -33257,26 +34207,26 @@ function run10(tree) {
33257
34207
  id: ID14,
33258
34208
  anchor: fallbacks[0]?.anchor ?? anchor,
33259
34209
  state: "non-conforming",
33260
- verdict: `${RULE14}: ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
34210
+ verdict: `${RULE15}: ${red.join("; ")}${unread2.length > 0 ? `; also could not judge: ${unread2.join("; ")}` : ""}`
33261
34211
  };
33262
34212
  if (unread2.length > 0)
33263
34213
  return couldNotJudge(
33264
34214
  ID14,
33265
34215
  anchor,
33266
- `no shared-credential fallback found; ${unread2.join("; ")} (${RULE14})`
34216
+ `no shared-credential fallback found; ${unread2.join("; ")} (${RULE15})`
33267
34217
  );
33268
34218
  return {
33269
34219
  id: ID14,
33270
34220
  anchor: challenge?.anchor ?? anchor,
33271
34221
  state: "present",
33272
- verdict: `no shared-credential fallback on the request path; a member with no credential is refused with a 401 challenge (${challenge?.anchor}) (${RULE14})`
34222
+ verdict: `no shared-credential fallback on the request path; a member with no credential is refused with a 401 challenge (${challenge?.anchor}) (${RULE15})`
33273
34223
  };
33274
34224
  }
33275
- var s48PerMember = { id: ID14, rule: RULE14, pin: STANDARD_PIN, run: run10 };
34225
+ var s48PerMember = { id: ID14, rule: RULE15, pin: STANDARD_PIN, run: run10 };
33276
34226
 
33277
34227
  // src/detectors/s49-server-metadata.ts
33278
34228
  var ID15 = "S49 server-metadata";
33279
- var RULE15 = "S-49";
34229
+ var RULE16 = "S-49";
33280
34230
  var PLACEHOLDER = /^(?:|\?+|tbd|tba|todo|n\/a|xxx+|placeholder|changeme|lorem ipsum.*|-+)$/i;
33281
34231
  var RESERVED_HOST = /(?:^|\.)(?:example\.(?:com|net|org)|example|test|invalid|localhost)$/i;
33282
34232
  function isPlaceholder(v) {
@@ -33351,15 +34301,15 @@ function verdict2(anchor, v, note) {
33351
34301
  id: ID15,
33352
34302
  anchor,
33353
34303
  state: "non-conforming",
33354
- verdict: `${RULE15}: ${v.red.join("; ")}${v.unread.length > 0 ? `; also could not judge: ${v.unread.join("; ")}` : ""}${v.ok.length > 0 ? ` (found: ${v.ok.join("; ")})` : ""}${note}`
34304
+ verdict: `${RULE16}: ${v.red.join("; ")}${v.unread.length > 0 ? `; also could not judge: ${v.unread.join("; ")}` : ""}${v.ok.length > 0 ? ` (found: ${v.ok.join("; ")})` : ""}${note}`
33355
34305
  };
33356
34306
  if (v.unread.length > 0)
33357
34307
  return couldNotJudge(
33358
34308
  ID15,
33359
34309
  anchor,
33360
- `${v.unread.join("; ")}${v.ok.length > 0 ? ` (found: ${v.ok.join("; ")})` : ""} (${RULE15}${note})`
34310
+ `${v.unread.join("; ")}${v.ok.length > 0 ? ` (found: ${v.ok.join("; ")})` : ""} (${RULE16}${note})`
33361
34311
  );
33362
- return { id: ID15, anchor, state: "present", verdict: `${v.ok.join("; ")} (${RULE15}${note})` };
34312
+ return { id: ID15, anchor, state: "present", verdict: `${v.ok.join("; ")} (${RULE16}${note})` };
33363
34313
  }
33364
34314
  var MANIFEST_FIELDS = [
33365
34315
  ["name", "string"],
@@ -33400,13 +34350,13 @@ function run11(tree) {
33400
34350
  id: ID15,
33401
34351
  anchor: "-",
33402
34352
  state: "absent",
33403
- verdict: `no server manifest and no MCP server surface (S-14's predicate: no server construction, no registered tool): not an MCP server \u2014 ${RULE15} n/a`
34353
+ verdict: `no server manifest and no MCP server surface (S-14's predicate: no server construction, no registered tool): not an MCP server \u2014 ${RULE16} n/a`
33404
34354
  };
33405
34355
  const what = read.length > 0 ? `read ${read.join(", ")}: no placeholder` : "no server manifest (mcp-server.json, mcp.json, server.json) at the tree root";
33406
34356
  return couldNotJudge(
33407
34357
  ID15,
33408
34358
  read[0] ?? "-",
33409
- `${what}${v.unread.length > 0 ? `; ${v.unread.join("; ")}` : ""}; the eight items are judged on the served initialize answer (serverInfo, instructions, capabilities) \u2014 decided by the served half (${RULE15})`
34359
+ `${what}${v.unread.length > 0 ? `; ${v.unread.join("; ")}` : ""}; the eight items are judged on the served initialize answer (serverInfo, instructions, capabilities) \u2014 decided by the served half (${RULE16})`
33410
34360
  );
33411
34361
  }
33412
34362
  function runServed6(runtime) {
@@ -33415,14 +34365,14 @@ function runServed6(runtime) {
33415
34365
  return couldNotJudge(
33416
34366
  ID15,
33417
34367
  anchor,
33418
- `the initialize answer was not read: ${runtime.launchError} (${RULE15})`
34368
+ `the initialize answer was not read: ${runtime.launchError} (${RULE16})`
33419
34369
  );
33420
34370
  const init = runtime.served?.initialize;
33421
34371
  if (!init)
33422
34372
  return couldNotJudge(
33423
34373
  ID15,
33424
34374
  anchor,
33425
- `the introspector recorded no initialize result (instructions unread) (${RULE15})`
34375
+ `the introspector recorded no initialize result (instructions unread) (${RULE16})`
33426
34376
  );
33427
34377
  const v = { red: [], unread: [], ok: [] };
33428
34378
  const si = runtime.serverInfo;
@@ -33445,7 +34395,7 @@ function runServed6(runtime) {
33445
34395
  }
33446
34396
  var s49ServerMetadata = {
33447
34397
  id: ID15,
33448
- rule: RULE15,
34398
+ rule: RULE16,
33449
34399
  pin: MANUFACT_RULES_PIN,
33450
34400
  run: run11,
33451
34401
  runServed: runServed6
@@ -33453,8 +34403,8 @@ var s49ServerMetadata = {
33453
34403
 
33454
34404
  // src/detectors/s50-served-discovery.ts
33455
34405
  var ID16 = "S50 served-discovery";
33456
- var RULE16 = "S-50";
33457
- function pathOf(url) {
34406
+ var RULE17 = "S-50";
34407
+ function pathOf2(url) {
33458
34408
  try {
33459
34409
  return new URL(url).pathname;
33460
34410
  } catch {
@@ -33474,23 +34424,23 @@ function judgeCards(cards, v) {
33474
34424
  const served = cards.filter((c) => c.status === 200 && c.json);
33475
34425
  const noAnswer = cards.filter((c) => c.status === void 0);
33476
34426
  const good = served.find((c) => cardGaps(c.json).length === 0);
33477
- if (good) return v.ok.push(`server card at ${pathOf(good.url)}`);
34427
+ if (good) return v.ok.push(`server card at ${pathOf2(good.url)}`);
33478
34428
  if (served.length > 0) {
33479
34429
  for (const c of served)
33480
34430
  v.red.push(
33481
- `the card at ${pathOf(c.url)} lacks ${cardGaps(c.json).join(", ")}`
34431
+ `the card at ${pathOf2(c.url)} lacks ${cardGaps(c.json).join(", ")}`
33482
34432
  );
33483
34433
  return;
33484
34434
  }
33485
- const seen = cards.filter((c) => c.status !== void 0).map((c) => `${pathOf(c.url)} ${c.status}${c.status === 200 ? " (not JSON)" : ""}`);
34435
+ const seen = cards.filter((c) => c.status !== void 0).map((c) => `${pathOf2(c.url)} ${c.status}${c.status === 200 ? " (not JSON)" : ""}`);
33486
34436
  if (noAnswer.length > 0 && seen.length === 0)
33487
34437
  return v.unread.push(
33488
- `no card candidate answered: ${noAnswer.map((c) => `${pathOf(c.url)} ${c.detail ?? "no answer"}`).join(", ")}`
34438
+ `no card candidate answered: ${noAnswer.map((c) => `${pathOf2(c.url)} ${c.detail ?? "no answer"}`).join(", ")}`
33489
34439
  );
33490
34440
  v.red.push(`no server card served (${seen.join(", ")})`);
33491
34441
  if (noAnswer.length > 0)
33492
34442
  v.unread.push(
33493
- `card candidates unanswered: ${noAnswer.map((c) => `${pathOf(c.url)} ${c.detail ?? ""}`).join(", ")}`
34443
+ `card candidates unanswered: ${noAnswer.map((c) => `${pathOf2(c.url)} ${c.detail ?? ""}`).join(", ")}`
33494
34444
  );
33495
34445
  }
33496
34446
  function judgeLanding(landing, v) {
@@ -33524,19 +34474,19 @@ function judgeLanding(landing, v) {
33524
34474
  function run12(tree) {
33525
34475
  const read = readDeclaredTargets(tree.root);
33526
34476
  if (read.targets.kind === "unreadable")
33527
- return couldNotJudge(ID16, read.file ?? "-", `${read.targets.reason} (${RULE16})`);
34477
+ return couldNotJudge(ID16, read.file ?? "-", `${read.targets.reason} (${RULE17})`);
33528
34478
  const manifest = read.manifest ?? {};
33529
34479
  if (!servesStreamableHttp(tree, manifest))
33530
34480
  return {
33531
34481
  id: ID16,
33532
34482
  anchor: "-",
33533
34483
  state: "absent",
33534
- verdict: `no Streamable HTTP transport (none in the source, none in the server manifest): no MCP URL to discover the server from \u2014 ${RULE16} n/a`
34484
+ verdict: `no Streamable HTTP transport (none in the source, none in the server manifest): no MCP URL to discover the server from \u2014 ${RULE17} n/a`
33535
34485
  };
33536
34486
  return couldNotJudge(
33537
34487
  ID16,
33538
34488
  "-",
33539
- `the server serves Streamable HTTP: the server card and the setup page are read on the served URL \u2014 run with --url (${RULE16})`
34489
+ `the server serves Streamable HTTP: the server card and the setup page are read on the served URL \u2014 run with --url (${RULE17})`
33540
34490
  );
33541
34491
  }
33542
34492
  function runServed7(runtime) {
@@ -33546,9 +34496,9 @@ function runServed7(runtime) {
33546
34496
  return couldNotJudge(
33547
34497
  ID16,
33548
34498
  anchor,
33549
- runtime.launchError ? `the server was not read (${runtime.launchError}) and no public read was recorded (${RULE16})` : `the introspector recorded no server-card or setup-page read (${RULE16})`
34499
+ runtime.launchError ? `the server was not read (${runtime.launchError}) and no public read was recorded (${RULE17})` : `the introspector recorded no server-card or setup-page read (${RULE17})`
33550
34500
  );
33551
- if (d.kind === "not-run") return couldNotJudge(ID16, anchor, `${d.reason} (${RULE16})`);
34501
+ if (d.kind === "not-run") return couldNotJudge(ID16, anchor, `${d.reason} (${RULE17})`);
33552
34502
  const v = { red: [], unread: [], ok: [] };
33553
34503
  judgeCards(d.cards, v);
33554
34504
  judgeLanding(d.landing, v);
@@ -33556,7 +34506,7 @@ function runServed7(runtime) {
33556
34506
  return couldNotJudge(
33557
34507
  ID16,
33558
34508
  anchor,
33559
- `the MCP handshake failed: ${runtime.launchError}; the public reads found: ${[...v.red, ...v.unread, ...v.ok].join("; ")} (${RULE16})`
34509
+ `the MCP handshake failed: ${runtime.launchError}; the public reads found: ${[...v.red, ...v.unread, ...v.ok].join("; ")} (${RULE17})`
33560
34510
  );
33561
34511
  const scope2 = " \u2014 read without a credential, on the endpoint's origin only";
33562
34512
  if (v.red.length > 0)
@@ -33564,26 +34514,26 @@ function runServed7(runtime) {
33564
34514
  id: ID16,
33565
34515
  anchor,
33566
34516
  state: "non-conforming",
33567
- verdict: `${RULE16}: ${v.red.join("; ")}${v.unread.length > 0 ? `; also could not judge: ${v.unread.join("; ")}` : ""}${v.ok.length > 0 ? ` (found: ${v.ok.join("; ")})` : ""}${scope2}`
34517
+ verdict: `${RULE17}: ${v.red.join("; ")}${v.unread.length > 0 ? `; also could not judge: ${v.unread.join("; ")}` : ""}${v.ok.length > 0 ? ` (found: ${v.ok.join("; ")})` : ""}${scope2}`
33568
34518
  };
33569
34519
  if (v.unread.length > 0)
33570
34520
  return couldNotJudge(
33571
34521
  ID16,
33572
34522
  anchor,
33573
- `${v.unread.join("; ")}${v.ok.length > 0 ? ` (found: ${v.ok.join("; ")})` : ""} (${RULE16})`
34523
+ `${v.unread.join("; ")}${v.ok.length > 0 ? ` (found: ${v.ok.join("; ")})` : ""} (${RULE17})`
33574
34524
  );
33575
- return { id: ID16, anchor, state: "present", verdict: `${v.ok.join("; ")} (${RULE16}${scope2})` };
34525
+ return { id: ID16, anchor, state: "present", verdict: `${v.ok.join("; ")} (${RULE17}${scope2})` };
33576
34526
  }
33577
34527
  var s50ServedDiscovery = {
33578
34528
  id: ID16,
33579
- rule: RULE16,
34529
+ rule: RULE17,
33580
34530
  pin: MANUFACT_RULES_PIN,
33581
34531
  run: run12,
33582
34532
  runServed: runServed7
33583
34533
  };
33584
34534
 
33585
34535
  // src/detectors/s51-served-output.ts
33586
- import * as ts2 from "typescript";
34536
+ import * as ts5 from "typescript";
33587
34537
 
33588
34538
  // src/detectors/jsonSchemaCheck.ts
33589
34539
  var ANNOTATIONS = /* @__PURE__ */ new Set([
@@ -33933,15 +34883,15 @@ function schemaCheckControls() {
33933
34883
  }
33934
34884
 
33935
34885
  // src/detectors/outputContract.ts
33936
- import * as ts from "typescript";
34886
+ import * as ts4 from "typescript";
33937
34887
  var lineOfPos = (sf, pos) => sf.getLineAndCharacterOfPosition(pos).line + 1;
33938
34888
  var startLine = (n) => lineOfPos(n.getSourceFile(), n.getStart(n.getSourceFile()));
33939
34889
  function isFunctionLikeExpr(e) {
33940
- return ts.isArrowFunction(e) || ts.isFunctionExpression(e);
34890
+ return ts4.isArrowFunction(e) || ts4.isFunctionExpression(e);
33941
34891
  }
33942
34892
  var unwrapExpr = (e) => {
33943
34893
  let x = e;
33944
- while (ts.isParenthesizedExpression(x) || ts.isAsExpression(x) || ts.isSatisfiesExpression(x) || ts.isNonNullExpression(x) || ts.isAwaitExpression(x) || ts.isTypeAssertionExpression(x))
34894
+ while (ts4.isParenthesizedExpression(x) || ts4.isAsExpression(x) || ts4.isSatisfiesExpression(x) || ts4.isNonNullExpression(x) || ts4.isAwaitExpression(x) || ts4.isTypeAssertionExpression(x))
33945
34895
  x = x.expression;
33946
34896
  return x;
33947
34897
  };
@@ -33949,10 +34899,10 @@ function sameFileFunction(sf, name) {
33949
34899
  let found;
33950
34900
  const visit = (n) => {
33951
34901
  if (found) return;
33952
- if (ts.isFunctionDeclaration(n) && n.name?.text === name && n.body) found = n;
33953
- else if (ts.isVariableDeclaration(n) && ts.isIdentifier(n.name) && n.name.text === name && n.initializer && isFunctionLikeExpr(unwrapExpr(n.initializer)))
34902
+ if (ts4.isFunctionDeclaration(n) && n.name?.text === name && n.body) found = n;
34903
+ else if (ts4.isVariableDeclaration(n) && ts4.isIdentifier(n.name) && n.name.text === name && n.initializer && isFunctionLikeExpr(unwrapExpr(n.initializer)))
33954
34904
  found = unwrapExpr(n.initializer);
33955
- else ts.forEachChild(n, visit);
34905
+ else ts4.forEachChild(n, visit);
33956
34906
  };
33957
34907
  visit(sf);
33958
34908
  return found;
@@ -33962,59 +34912,59 @@ function completes(stmts) {
33962
34912
  return stmtCompletes(stmts[stmts.length - 1]);
33963
34913
  }
33964
34914
  function stmtCompletes(s) {
33965
- if (ts.isReturnStatement(s) || ts.isThrowStatement(s)) return false;
33966
- if (ts.isBlock(s)) return completes(s.statements);
33967
- if (ts.isIfStatement(s))
34915
+ if (ts4.isReturnStatement(s) || ts4.isThrowStatement(s)) return false;
34916
+ if (ts4.isBlock(s)) return completes(s.statements);
34917
+ if (ts4.isIfStatement(s))
33968
34918
  return !s.elseStatement || stmtCompletes(s.thenStatement) || stmtCompletes(s.elseStatement);
33969
- if (ts.isTryStatement(s)) {
34919
+ if (ts4.isTryStatement(s)) {
33970
34920
  if (s.finallyBlock && !completes(s.finallyBlock.statements)) return false;
33971
34921
  return completes(s.tryBlock.statements) || (s.catchClause ? completes(s.catchClause.block.statements) : false);
33972
34922
  }
33973
- if (ts.isSwitchStatement(s)) {
34923
+ if (ts4.isSwitchStatement(s)) {
33974
34924
  const clauses = s.caseBlock.clauses;
33975
- if (!clauses.some((c) => ts.isDefaultClause(c))) return true;
34925
+ if (!clauses.some((c) => ts4.isDefaultClause(c))) return true;
33976
34926
  return clauses.some((c) => c.statements.length === 0 || completes(c.statements));
33977
34927
  }
33978
34928
  return true;
33979
34929
  }
33980
- function collectReturns(body, sf, rel, out, inCatch = false) {
34930
+ function collectReturns(body, sf, rel2, out, inCatch = false) {
33981
34931
  const visit = (n, catching) => {
33982
- if (n !== body && ts.isFunctionLike(n)) return;
33983
- if (ts.isReturnStatement(n)) {
34932
+ if (n !== body && ts4.isFunctionLike(n)) return;
34933
+ if (ts4.isReturnStatement(n)) {
33984
34934
  out.push({
33985
- anchor: `${rel}:${startLine(n)}`,
34935
+ anchor: `${rel2}:${startLine(n)}`,
33986
34936
  ...n.expression ? { expr: n.expression } : {},
33987
34937
  form: n.expression ? "return" : "bare-return",
33988
34938
  inCatch: catching
33989
34939
  });
33990
34940
  return;
33991
34941
  }
33992
- if (ts.isCatchClause(n)) {
34942
+ if (ts4.isCatchClause(n)) {
33993
34943
  visit(n.block, true);
33994
34944
  return;
33995
34945
  }
33996
- ts.forEachChild(n, (c) => visit(c, catching));
34946
+ ts4.forEachChild(n, (c) => visit(c, catching));
33997
34947
  };
33998
34948
  visit(body, inCatch);
33999
34949
  void sf;
34000
34950
  }
34001
- function functionReturns(fn, sf, rel) {
34951
+ function functionReturns(fn, sf, rel2) {
34002
34952
  const out = [];
34003
34953
  const body = fn.body;
34004
34954
  if (!body) return out;
34005
- if (!ts.isBlock(body)) {
34955
+ if (!ts4.isBlock(body)) {
34006
34956
  out.push({
34007
- anchor: `${rel}:${startLine(body)}`,
34957
+ anchor: `${rel2}:${startLine(body)}`,
34008
34958
  expr: body,
34009
34959
  form: "concise",
34010
34960
  inCatch: false
34011
34961
  });
34012
34962
  return out;
34013
34963
  }
34014
- collectReturns(body, sf, rel, out);
34964
+ collectReturns(body, sf, rel2, out);
34015
34965
  if (completes(body.statements))
34016
34966
  out.push({
34017
- anchor: `${rel}:${lineOfPos(sf, body.getEnd())}`,
34967
+ anchor: `${rel2}:${lineOfPos(sf, body.getEnd())}`,
34018
34968
  form: "fall-through",
34019
34969
  inCatch: false
34020
34970
  });
@@ -34026,19 +34976,19 @@ function registrationCall(sf, line, name) {
34026
34976
  const a = startLine(n);
34027
34977
  const b = lineOfPos(sf, n.getEnd());
34028
34978
  if (a > line || b < line) return;
34029
- if (ts.isCallExpression(n)) {
34979
+ if (ts4.isCallExpression(n)) {
34030
34980
  const names2 = n.arguments.some((arg) => {
34031
34981
  const u = unwrapExpr(arg);
34032
- if (ts.isStringLiteralLike(u)) return u.text === name;
34033
- return (ts.isIdentifier(u) || ts.isPropertyAccessExpression(u)) && startLine(u) === line;
34982
+ if (ts4.isStringLiteralLike(u)) return u.text === name;
34983
+ return (ts4.isIdentifier(u) || ts4.isPropertyAccessExpression(u)) && startLine(u) === line;
34034
34984
  });
34035
34985
  if (names2 && n.arguments.some((arg) => {
34036
34986
  const x = unwrapExpr(arg);
34037
- return isFunctionLikeExpr(x) || ts.isIdentifier(x) || ts.isCallExpression(x);
34987
+ return isFunctionLikeExpr(x) || ts4.isIdentifier(x) || ts4.isCallExpression(x);
34038
34988
  }))
34039
34989
  best = n;
34040
34990
  }
34041
- ts.forEachChild(n, visit);
34991
+ ts4.forEachChild(n, visit);
34042
34992
  };
34043
34993
  visit(sf);
34044
34994
  return best;
@@ -34047,9 +34997,9 @@ function caseClause(sf, name) {
34047
34997
  let found;
34048
34998
  const visit = (n) => {
34049
34999
  if (found) return;
34050
- if (ts.isCaseClause(n) && ts.isStringLiteralLike(n.expression) && n.expression.text === name)
35000
+ if (ts4.isCaseClause(n) && ts4.isStringLiteralLike(n.expression) && n.expression.text === name)
34051
35001
  found = n;
34052
- else ts.forEachChild(n, visit);
35002
+ else ts4.forEachChild(n, visit);
34053
35003
  };
34054
35004
  visit(sf);
34055
35005
  return found;
@@ -34065,9 +35015,9 @@ function sourceFileOf(f) {
34065
35015
  }
34066
35016
  function readHandler(tree, tool) {
34067
35017
  const cut = tool.anchor.lastIndexOf(":");
34068
- const rel = tool.anchor.slice(0, cut);
35018
+ const rel2 = tool.anchor.slice(0, cut);
34069
35019
  const line = Number(tool.anchor.slice(cut + 1));
34070
- const file = tree.files.find((f) => f.rel === rel);
35020
+ const file = tree.files.find((f) => f.rel === rel2);
34071
35021
  if (!file)
34072
35022
  return {
34073
35023
  kind: "unread",
@@ -34079,33 +35029,33 @@ function readHandler(tree, tool) {
34079
35029
  if (call) {
34080
35030
  const last = [...call.arguments].reverse().find((a) => {
34081
35031
  const x = unwrapExpr(a);
34082
- return isFunctionLikeExpr(x) || ts.isIdentifier(x) || ts.isCallExpression(x) && x.arguments.some((w) => isFunctionLikeExpr(unwrapExpr(w)));
35032
+ return isFunctionLikeExpr(x) || ts4.isIdentifier(x) || ts4.isCallExpression(x) && x.arguments.some((w) => isFunctionLikeExpr(unwrapExpr(w)));
34083
35033
  });
34084
35034
  let u = last ? unwrapExpr(last) : void 0;
34085
- if (u && ts.isCallExpression(u))
35035
+ if (u && ts4.isCallExpression(u))
34086
35036
  u = [...u.arguments].map(unwrapExpr).reverse().find(isFunctionLikeExpr);
34087
35037
  if (u && isFunctionLikeExpr(u))
34088
35038
  return {
34089
35039
  kind: "read",
34090
- anchor: `${rel}:${startLine(u)}`,
34091
- returns: functionReturns(u, sf, rel),
35040
+ anchor: `${rel2}:${startLine(u)}`,
35041
+ returns: functionReturns(u, sf, rel2),
34092
35042
  sf,
34093
35043
  file
34094
35044
  };
34095
- if (u && ts.isIdentifier(u)) {
35045
+ if (u && ts4.isIdentifier(u)) {
34096
35046
  const fn = sameFileFunction(sf, u.text);
34097
35047
  if (fn)
34098
35048
  return {
34099
35049
  kind: "read",
34100
- anchor: `${rel}:${startLine(fn)}`,
34101
- returns: functionReturns(fn, sf, rel),
35050
+ anchor: `${rel2}:${startLine(fn)}`,
35051
+ returns: functionReturns(fn, sf, rel2),
34102
35052
  sf,
34103
35053
  file
34104
35054
  };
34105
35055
  return {
34106
35056
  kind: "unread",
34107
- anchor: `${rel}:${startLine(u)}`,
34108
- reason: `${tool.name}: its handler \`${u.text}\` is not a function declared in ${rel}`
35057
+ anchor: `${rel2}:${startLine(u)}`,
35058
+ reason: `${tool.name}: its handler \`${u.text}\` is not a function declared in ${rel2}`
34109
35059
  };
34110
35060
  }
34111
35061
  }
@@ -34150,20 +35100,20 @@ function productRegistrations(tree) {
34150
35100
  function returnedValues(expr, sf, depth = 0) {
34151
35101
  if (expr === void 0) return [{ kind: "nullish", form: "undefined" }];
34152
35102
  const e = unwrapExpr(expr);
34153
- if (e.kind === ts.SyntaxKind.NullKeyword) return [{ kind: "nullish", form: "null" }];
34154
- if (ts.isIdentifier(e) && e.text === "undefined") return [{ kind: "nullish", form: "undefined" }];
34155
- if (ts.isVoidExpression(e)) return [{ kind: "nullish", form: "void" }];
34156
- if (ts.isObjectLiteralExpression(e)) return [{ kind: "object", node: e }];
34157
- if (ts.isConditionalExpression(e))
35103
+ if (e.kind === ts4.SyntaxKind.NullKeyword) return [{ kind: "nullish", form: "null" }];
35104
+ if (ts4.isIdentifier(e) && e.text === "undefined") return [{ kind: "nullish", form: "undefined" }];
35105
+ if (ts4.isVoidExpression(e)) return [{ kind: "nullish", form: "void" }];
35106
+ if (ts4.isObjectLiteralExpression(e)) return [{ kind: "object", node: e }];
35107
+ if (ts4.isConditionalExpression(e))
34158
35108
  return [...returnedValues(e.whenTrue, sf, depth), ...returnedValues(e.whenFalse, sf, depth)];
34159
35109
  if (depth >= 4)
34160
35110
  return [{ kind: "unread", form: `\`${e.getText(sf).slice(0, 60)}\` (followed too deep)` }];
34161
- if (ts.isIdentifier(e)) {
35111
+ if (ts4.isIdentifier(e)) {
34162
35112
  const init = constInitOf(e);
34163
35113
  if (init) return returnedValues(init, sf, depth + 1).filter((v) => v.kind !== "nullish");
34164
35114
  return [{ kind: "unread", form: `identifier \`${e.text}\` not bound to a const in reach` }];
34165
35115
  }
34166
- if (ts.isCallExpression(e) && ts.isIdentifier(e.expression)) {
35116
+ if (ts4.isCallExpression(e) && ts4.isIdentifier(e.expression)) {
34167
35117
  const fn = sameFileFunction(sf, e.expression.text);
34168
35118
  if (fn) {
34169
35119
  const out = [];
@@ -34179,11 +35129,11 @@ function returnedValues(expr, sf, depth = 0) {
34179
35129
  }
34180
35130
  function constInitOf(id) {
34181
35131
  for (let x = id.parent; x; x = x.parent) {
34182
- if (!(ts.isBlock(x) || ts.isSourceFile(x))) continue;
35132
+ if (!(ts4.isBlock(x) || ts4.isSourceFile(x))) continue;
34183
35133
  for (const st of x.statements) {
34184
- if (!ts.isVariableStatement(st) || !(st.declarationList.flags & ts.NodeFlags.Const)) continue;
35134
+ if (!ts4.isVariableStatement(st) || !(st.declarationList.flags & ts4.NodeFlags.Const)) continue;
34185
35135
  for (const d of st.declarationList.declarations)
34186
- if (ts.isIdentifier(d.name) && d.name.text === id.text && d.initializer && d.getStart() < id.getStart())
35136
+ if (ts4.isIdentifier(d.name) && d.name.text === id.text && d.initializer && d.getStart() < id.getStart())
34187
35137
  return d.initializer;
34188
35138
  }
34189
35139
  }
@@ -34191,17 +35141,17 @@ function constInitOf(id) {
34191
35141
  }
34192
35142
  function prop(obj, name) {
34193
35143
  for (const p of obj.properties) {
34194
- if (ts.isPropertyAssignment(p) && (ts.isIdentifier(p.name) || ts.isStringLiteralLike(p.name)) && p.name.text === name)
35144
+ if (ts4.isPropertyAssignment(p) && (ts4.isIdentifier(p.name) || ts4.isStringLiteralLike(p.name)) && p.name.text === name)
34195
35145
  return { kind: "value", value: p.initializer };
34196
- if (ts.isShorthandPropertyAssignment(p) && p.name.text === name)
35146
+ if (ts4.isShorthandPropertyAssignment(p) && p.name.text === name)
34197
35147
  return { kind: "shorthand", ident: p.name };
34198
35148
  }
34199
- if (obj.properties.some((p) => ts.isSpreadAssignment(p))) return { kind: "spread" };
35149
+ if (obj.properties.some((p) => ts4.isSpreadAssignment(p))) return { kind: "spread" };
34200
35150
  return { kind: "absent" };
34201
35151
  }
34202
35152
  function isErrorObject(obj) {
34203
35153
  const p = prop(obj, "isError");
34204
- return p.kind === "value" && p.value.kind === ts.SyntaxKind.TrueKeyword;
35154
+ return p.kind === "value" && p.value.kind === ts4.SyntaxKind.TrueKeyword;
34205
35155
  }
34206
35156
  function servedToolCalls(id, rule, runtime) {
34207
35157
  const anchor = `${runtime.root} (served)`;
@@ -34255,73 +35205,73 @@ function names(list, max = 400) {
34255
35205
 
34256
35206
  // src/detectors/s51-served-output.ts
34257
35207
  var ID17 = "S51 served-output";
34258
- var RULE17 = "S-51";
35208
+ var RULE18 = "S-51";
34259
35209
  var isNullish = (e) => {
34260
35210
  let x = e;
34261
- while (ts2.isParenthesizedExpression(x) || ts2.isAsExpression(x)) x = x.expression;
34262
- return x.kind === ts2.SyntaxKind.NullKeyword || ts2.isIdentifier(x) && x.text === "undefined" || ts2.isVoidExpression(x);
35211
+ while (ts5.isParenthesizedExpression(x) || ts5.isAsExpression(x)) x = x.expression;
35212
+ return x.kind === ts5.SyntaxKind.NullKeyword || ts5.isIdentifier(x) && x.text === "undefined" || ts5.isVoidExpression(x);
34263
35213
  };
34264
35214
  var strip = (e) => {
34265
35215
  let x = e;
34266
- while (ts2.isParenthesizedExpression(x) || ts2.isAsExpression(x) || ts2.isSatisfiesExpression(x))
35216
+ while (ts5.isParenthesizedExpression(x) || ts5.isAsExpression(x) || ts5.isSatisfiesExpression(x))
34267
35217
  x = x.expression;
34268
35218
  return x;
34269
35219
  };
34270
- var isOutputKey = (n) => (ts2.isIdentifier(n) || ts2.isStringLiteralLike(n)) && n.text === "outputSchema";
35220
+ var isOutputKey = (n) => (ts5.isIdentifier(n) || ts5.isStringLiteralLike(n)) && n.text === "outputSchema";
34271
35221
  var objectHasOutput = (e) => {
34272
35222
  const x = strip(e);
34273
- return ts2.isObjectLiteralExpression(x) && x.properties.some(
34274
- (p) => (ts2.isPropertyAssignment(p) || ts2.isShorthandPropertyAssignment(p)) && isOutputKey(p.name)
35223
+ return ts5.isObjectLiteralExpression(x) && x.properties.some(
35224
+ (p) => (ts5.isPropertyAssignment(p) || ts5.isShorthandPropertyAssignment(p)) && isOutputKey(p.name)
34275
35225
  );
34276
35226
  };
34277
35227
  var LOGICAL = /* @__PURE__ */ new Set([
34278
- ts2.SyntaxKind.AmpersandAmpersandToken,
34279
- ts2.SyntaxKind.BarBarToken,
34280
- ts2.SyntaxKind.QuestionQuestionToken
35228
+ ts5.SyntaxKind.AmpersandAmpersandToken,
35229
+ ts5.SyntaxKind.BarBarToken,
35230
+ ts5.SyntaxKind.QuestionQuestionToken
34281
35231
  ]);
34282
35232
  function branches(e) {
34283
35233
  const x = strip(e);
34284
- if (ts2.isConditionalExpression(x)) return [x.whenTrue, x.whenFalse];
34285
- if (ts2.isBinaryExpression(x) && LOGICAL.has(x.operatorToken.kind)) {
34286
- if (x.operatorToken.kind === ts2.SyntaxKind.AmpersandAmpersandToken)
34287
- return [ts2.factory.createIdentifier("undefined"), x.right];
35234
+ if (ts5.isConditionalExpression(x)) return [x.whenTrue, x.whenFalse];
35235
+ if (ts5.isBinaryExpression(x) && LOGICAL.has(x.operatorToken.kind)) {
35236
+ if (x.operatorToken.kind === ts5.SyntaxKind.AmpersandAmpersandToken)
35237
+ return [ts5.factory.createIdentifier("undefined"), x.right];
34288
35238
  return [x.left, x.right];
34289
35239
  }
34290
35240
  return void 0;
34291
35241
  }
34292
- var accessesOutput = (n) => ts2.isPropertyAccessExpression(n) && n.name.text === "outputSchema" || ts2.isElementAccessExpression(n) && ts2.isStringLiteralLike(n.argumentExpression) && n.argumentExpression.text === "outputSchema";
35242
+ var accessesOutput = (n) => ts5.isPropertyAccessExpression(n) && n.name.text === "outputSchema" || ts5.isElementAccessExpression(n) && ts5.isStringLiteralLike(n.argumentExpression) && n.argumentExpression.text === "outputSchema";
34293
35243
  function underCondition(n) {
34294
- for (let x = n.parent; x && !ts2.isFunctionLike(x) && !ts2.isSourceFile(x); x = x.parent) {
34295
- if (ts2.isIfStatement(x) || ts2.isConditionalExpression(x)) return true;
34296
- if (ts2.isBinaryExpression(x) && LOGICAL.has(x.operatorToken.kind)) return true;
35244
+ for (let x = n.parent; x && !ts5.isFunctionLike(x) && !ts5.isSourceFile(x); x = x.parent) {
35245
+ if (ts5.isIfStatement(x) || ts5.isConditionalExpression(x)) return true;
35246
+ if (ts5.isBinaryExpression(x) && LOGICAL.has(x.operatorToken.kind)) return true;
34297
35247
  }
34298
35248
  return false;
34299
35249
  }
34300
- function exemptionSites(sf, rel) {
35250
+ function exemptionSites(sf, rel2) {
34301
35251
  const out = [];
34302
- const at = (n) => `${rel}:${sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1}`;
35252
+ const at = (n) => `${rel2}:${sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1}`;
34303
35253
  const text = (n) => n.getText(sf).replace(/\s+/g, " ").slice(0, 120);
34304
35254
  const visit = (n) => {
34305
- if (ts2.isSpreadAssignment(n)) {
35255
+ if (ts5.isSpreadAssignment(n)) {
34306
35256
  const b = branches(n.expression);
34307
35257
  if (b?.some(objectHasOutput) && !b.every(objectHasOutput))
34308
35258
  out.push({ anchor: at(n), form: "X1", text: text(n) });
34309
- } else if (ts2.isPropertyAssignment(n) && isOutputKey(n.name)) {
35259
+ } else if (ts5.isPropertyAssignment(n) && isOutputKey(n.name)) {
34310
35260
  const b = branches(n.initializer);
34311
35261
  if (isNullish(n.initializer) || b?.some(isNullish))
34312
35262
  out.push({ anchor: at(n), form: "X2", text: text(n) });
34313
- } else if (ts2.isBinaryExpression(n) && n.operatorToken.kind === ts2.SyntaxKind.EqualsToken && accessesOutput(n.left) && (underCondition(n) || isNullish(n.right) || branches(n.right)?.some(isNullish))) {
35263
+ } else if (ts5.isBinaryExpression(n) && n.operatorToken.kind === ts5.SyntaxKind.EqualsToken && accessesOutput(n.left) && (underCondition(n) || isNullish(n.right) || branches(n.right)?.some(isNullish))) {
34314
35264
  out.push({ anchor: at(n), form: "X3", text: text(n) });
34315
- } else if (ts2.isDeleteExpression(n) && accessesOutput(strip(n.expression))) {
35265
+ } else if (ts5.isDeleteExpression(n) && accessesOutput(strip(n.expression))) {
34316
35266
  out.push({ anchor: at(n), form: "X3", text: text(n) });
34317
35267
  }
34318
- ts2.forEachChild(n, visit);
35268
+ ts5.forEachChild(n, visit);
34319
35269
  };
34320
35270
  visit(sf);
34321
35271
  return out;
34322
35272
  }
34323
35273
  function s51Controls() {
34324
- const sf = (code) => ts2.createSourceFile("c.ts", code, ts2.ScriptTarget.Latest, true, ts2.ScriptKind.TS);
35274
+ const sf = (code) => ts5.createSourceFile("c.ts", code, ts5.ScriptTarget.Latest, true, ts5.ScriptKind.TS);
34325
35275
  const red = [
34326
35276
  "f({ ...(s !== undefined ? { outputSchema: s } : {}) });",
34327
35277
  "f({ outputSchema: skip.has(n) ? undefined : s });",
@@ -34350,18 +35300,18 @@ function runStatic5(tree) {
34350
35300
  return couldNotJudge(
34351
35301
  ID17,
34352
35302
  surface ?? unresolved[0],
34353
- noToolsLocatedReason(tree, `no registration was read (${RULE17})`)
35303
+ noToolsLocatedReason(tree, `no registration was read (${RULE18})`)
34354
35304
  );
34355
35305
  return {
34356
35306
  id: ID17,
34357
35307
  anchor: tree.root,
34358
35308
  state: "absent",
34359
- verdict: `no MCP tool registered in product source \u2014 ${RULE17} n/a`
35309
+ verdict: `no MCP tool registered in product source \u2014 ${RULE18} n/a`
34360
35310
  };
34361
35311
  }
34362
35312
  const unread2 = unresolved.map((a) => ({
34363
35313
  anchor: a,
34364
- reason: `a tool registered here has a name the scan cannot resolve, so whether it declares an output schema is unread (${RULE17})`
35314
+ reason: `a tool registered here has a name the scan cannot resolve, so whether it declares an output schema is unread (${RULE18})`
34365
35315
  }));
34366
35316
  const missing = [];
34367
35317
  const declared = [];
@@ -34372,7 +35322,7 @@ function runStatic5(tree) {
34372
35322
  const loc = r.sites.find(
34373
35323
  (s) => s.path === t.name && s.kind === "unread" && /^registration/.test(s.form)
34374
35324
  );
34375
- if (loc) unread2.push({ anchor: loc.anchor, reason: `${loc.form} (${RULE17})` });
35325
+ if (loc) unread2.push({ anchor: loc.anchor, reason: `${loc.form} (${RULE18})` });
34376
35326
  else declared.push(t.name);
34377
35327
  }
34378
35328
  }
@@ -34395,7 +35345,7 @@ function runStatic5(tree) {
34395
35345
  id: ID17,
34396
35346
  anchor: exemptions[0]?.anchor ?? missing[0].replace(/^.* \((.*)\)$/, "$1"),
34397
35347
  state: "non-conforming",
34398
- verdict: `${parts.join("; ")} \u2014 every served tool carries an outputSchema and no code path exempts one (${RULE17})`
35348
+ verdict: `${parts.join("; ")} \u2014 every served tool carries an outputSchema and no code path exempts one (${RULE18})`
34399
35349
  },
34400
35350
  unread2
34401
35351
  );
@@ -34405,17 +35355,17 @@ function runStatic5(tree) {
34405
35355
  couldNotJudge(
34406
35356
  ID17,
34407
35357
  tools[0].anchor,
34408
- `static half: ${declared.length} registered tool(s) declare an outputSchema and no exemption mechanism (X1..X3) is in the registration code; unread by a static run: whether each served result's structuredContent validates against it (${names(declared)}) \u2014 run --mode=dynamic (${RULE17})`
35358
+ `static half: ${declared.length} registered tool(s) declare an outputSchema and no exemption mechanism (X1..X3) is in the registration code; unread by a static run: whether each served result's structuredContent validates against it (${names(declared)}) \u2014 run --mode=dynamic (${RULE18})`
34409
35359
  ),
34410
35360
  unread2
34411
35361
  );
34412
35362
  }
34413
35363
  function runServedHalf3(runtime) {
34414
- const got = servedToolCalls(ID17, RULE17, runtime);
35364
+ const got = servedToolCalls(ID17, RULE18, runtime);
34415
35365
  if ("cnj" in got) return got.cnj;
34416
35366
  const { calls, tools, anchor } = got;
34417
35367
  if (tools.length === 0)
34418
- return { id: ID17, anchor, state: "absent", verdict: `the server serves no tool \u2014 ${RULE17} n/a` };
35368
+ return { id: ID17, anchor, state: "absent", verdict: `the server serves no tool \u2014 ${RULE18} n/a` };
34419
35369
  const noSchema = tools.filter((t) => t.outputSchema === void 0).map((t) => t.name);
34420
35370
  const invalid = [];
34421
35371
  const unread2 = [];
@@ -34427,7 +35377,7 @@ function runServedHalf3(runtime) {
34427
35377
  if (why || !c || c.kind !== "result") {
34428
35378
  unread2.push({
34429
35379
  anchor: `${anchor} tools/call ${t.name}`,
34430
- reason: `${t.name}: ${why} (${RULE17})`
35380
+ reason: `${t.name}: ${why} (${RULE18})`
34431
35381
  });
34432
35382
  continue;
34433
35383
  }
@@ -34442,7 +35392,7 @@ function runServedHalf3(runtime) {
34442
35392
  else if (v.kind === "unread")
34443
35393
  unread2.push({
34444
35394
  anchor: `${anchor} tools/list ${t.name}`,
34445
- reason: `${t.name}: the outputSchema could not be read at ${v.path} \u2014 ${v.why} (${RULE17})`
35395
+ reason: `${t.name}: the outputSchema could not be read at ${v.path} \u2014 ${v.why} (${RULE18})`
34446
35396
  });
34447
35397
  else validated++;
34448
35398
  }
@@ -34456,7 +35406,7 @@ function runServedHalf3(runtime) {
34456
35406
  parts.push(`${invalid.length} served result(s) do not validate: ${invalid.join("; ")}`);
34457
35407
  return settle(
34458
35408
  ID17,
34459
- { id: ID17, anchor, state: "non-conforming", verdict: `${parts.join("; ")} (${RULE17})` },
35409
+ { id: ID17, anchor, state: "non-conforming", verdict: `${parts.join("; ")} (${RULE18})` },
34460
35410
  unread2
34461
35411
  );
34462
35412
  }
@@ -34466,23 +35416,23 @@ function runServedHalf3(runtime) {
34466
35416
  id: ID17,
34467
35417
  anchor,
34468
35418
  state: "present",
34469
- verdict: `${tools.length} served tool(s) declare an outputSchema; ${validated} successful result(s) read, each structuredContent valid against it (${RULE17})`
35419
+ verdict: `${tools.length} served tool(s) declare an outputSchema; ${validated} successful result(s) read, each structuredContent valid against it (${RULE18})`
34470
35420
  },
34471
35421
  unread2
34472
35422
  );
34473
35423
  }
34474
35424
  var s51ServedOutput = {
34475
35425
  id: ID17,
34476
- rule: RULE17,
35426
+ rule: RULE18,
34477
35427
  pin: S51_RULES_PIN,
34478
35428
  run: runStatic5,
34479
35429
  runServed: (runtime) => runServedHalf3(runtime)
34480
35430
  };
34481
35431
 
34482
35432
  // src/detectors/s52-no-null-success.ts
34483
- import * as ts3 from "typescript";
35433
+ import * as ts6 from "typescript";
34484
35434
  var ID18 = "S52 no-null-success";
34485
- var RULE18 = "S-52";
35435
+ var RULE19 = "S-52";
34486
35436
  function nullReturns(tool, read) {
34487
35437
  const red = [];
34488
35438
  const unread2 = [];
@@ -34501,20 +35451,20 @@ function nullReturns(tool, read) {
34501
35451
  else if (v.kind === "unread")
34502
35452
  unread2.push({
34503
35453
  anchor: r.anchor,
34504
- reason: `${tool}: the returned value is ${v.form} (${RULE18})`
35454
+ reason: `${tool}: the returned value is ${v.form} (${RULE19})`
34505
35455
  });
34506
35456
  else {
34507
35457
  if (isErrorObject(v.node)) continue;
34508
35458
  const sc = prop(v.node, "structuredContent");
34509
35459
  if (sc.kind === "value") {
34510
35460
  const x = sc.value;
34511
- if (x.kind === ts3.SyntaxKind.NullKeyword || ts3.isIdentifier(x) && x.text === "undefined")
35461
+ if (x.kind === ts6.SyntaxKind.NullKeyword || ts6.isIdentifier(x) && x.text === "undefined")
34512
35462
  red.push({ tool, anchor: r.anchor, form: "N2 `structuredContent: null`" });
34513
- else if (ts3.isObjectLiteralExpression(x) && x.properties.length === 0)
35463
+ else if (ts6.isObjectLiteralExpression(x) && x.properties.length === 0)
34514
35464
  red.push({ tool, anchor: r.anchor, form: "N4 `structuredContent: {}`" });
34515
35465
  }
34516
35466
  const content = prop(v.node, "content");
34517
- if (content.kind === "value" && ts3.isArrayLiteralExpression(content.value) && content.value.elements.length === 0)
35467
+ if (content.kind === "value" && ts6.isArrayLiteralExpression(content.value) && content.value.elements.length === 0)
34518
35468
  red.push({ tool, anchor: r.anchor, form: "N5 `content: []`" });
34519
35469
  else if (content.kind === "absent")
34520
35470
  red.push({ tool, anchor: r.anchor, form: "N5 a result with no `content`" });
@@ -34546,25 +35496,25 @@ function runStatic6(tree) {
34546
35496
  return couldNotJudge(
34547
35497
  ID18,
34548
35498
  surface ?? unresolved[0],
34549
- noToolsLocatedReason(tree, `no handler was read (${RULE18})`)
35499
+ noToolsLocatedReason(tree, `no handler was read (${RULE19})`)
34550
35500
  );
34551
35501
  return {
34552
35502
  id: ID18,
34553
35503
  anchor: tree.root,
34554
35504
  state: "absent",
34555
- verdict: `no MCP tool registered in product source \u2014 ${RULE18} n/a`
35505
+ verdict: `no MCP tool registered in product source \u2014 ${RULE19} n/a`
34556
35506
  };
34557
35507
  }
34558
35508
  const red = [];
34559
35509
  const unread2 = unresolved.map((a) => ({
34560
35510
  anchor: a,
34561
- reason: `a tool registered here has a name the scan cannot resolve, so its handler is unread (${RULE18})`
35511
+ reason: `a tool registered here has a name the scan cannot resolve, so its handler is unread (${RULE19})`
34562
35512
  }));
34563
35513
  const read = [];
34564
35514
  for (const t of tools) {
34565
35515
  const h = readHandler(tree, t);
34566
35516
  if (h.kind === "unread") {
34567
- unread2.push({ anchor: h.anchor, reason: `${h.reason} (${RULE18})` });
35517
+ unread2.push({ anchor: h.anchor, reason: `${h.reason} (${RULE19})` });
34568
35518
  continue;
34569
35519
  }
34570
35520
  read.push(t.name);
@@ -34579,7 +35529,7 @@ function runStatic6(tree) {
34579
35529
  id: ID18,
34580
35530
  anchor: red[0].anchor,
34581
35531
  state: "non-conforming",
34582
- verdict: `${red.length} success-path return(s) answer null or empty: ${red.map((f) => `${f.tool} ${f.form} (${f.anchor})`).join("; ")} \u2014 a tool that found nothing returns a typed empty value (${RULE18})`
35532
+ verdict: `${red.length} success-path return(s) answer null or empty: ${red.map((f) => `${f.tool} ${f.form} (${f.anchor})`).join("; ")} \u2014 a tool that found nothing returns a typed empty value (${RULE19})`
34583
35533
  },
34584
35534
  unread2
34585
35535
  );
@@ -34588,17 +35538,17 @@ function runStatic6(tree) {
34588
35538
  couldNotJudge(
34589
35539
  ID18,
34590
35540
  tools[0].anchor,
34591
- `static half: no success-path return writes null or empty in the ${read.length} handler(s) read (${names(read)}); unread by a static run: what each returned expression evaluates to \u2014 run --mode=dynamic (${RULE18})`
35541
+ `static half: no success-path return writes null or empty in the ${read.length} handler(s) read (${names(read)}); unread by a static run: what each returned expression evaluates to \u2014 run --mode=dynamic (${RULE19})`
34592
35542
  ),
34593
35543
  unread2
34594
35544
  );
34595
35545
  }
34596
35546
  function runServedHalf4(runtime) {
34597
- const got = servedToolCalls(ID18, RULE18, runtime);
35547
+ const got = servedToolCalls(ID18, RULE19, runtime);
34598
35548
  if ("cnj" in got) return got.cnj;
34599
35549
  const { calls, anchor } = got;
34600
35550
  if (runtime.tools.length === 0)
34601
- return { id: ID18, anchor, state: "absent", verdict: `the server serves no tool \u2014 ${RULE18} n/a` };
35551
+ return { id: ID18, anchor, state: "absent", verdict: `the server serves no tool \u2014 ${RULE19} n/a` };
34602
35552
  const red = [];
34603
35553
  const unread2 = [];
34604
35554
  let ok = 0;
@@ -34608,7 +35558,7 @@ function runServedHalf4(runtime) {
34608
35558
  if (why || !c || c.kind !== "result") {
34609
35559
  unread2.push({
34610
35560
  anchor: `${anchor} tools/call ${t.name}`,
34611
- reason: `${t.name}: ${why} (${RULE18})`
35561
+ reason: `${t.name}: ${why} (${RULE19})`
34612
35562
  });
34613
35563
  continue;
34614
35564
  }
@@ -34623,7 +35573,7 @@ function runServedHalf4(runtime) {
34623
35573
  id: ID18,
34624
35574
  anchor,
34625
35575
  state: "non-conforming",
34626
- verdict: `${red.length} successful result(s) answer null or empty: ${red.join("; ")} (${RULE18})`
35576
+ verdict: `${red.length} successful result(s) answer null or empty: ${red.join("; ")} (${RULE19})`
34627
35577
  },
34628
35578
  unread2
34629
35579
  );
@@ -34633,38 +35583,38 @@ function runServedHalf4(runtime) {
34633
35583
  id: ID18,
34634
35584
  anchor,
34635
35585
  state: "present",
34636
- verdict: `${ok} successful result(s) read, each carrying a typed value (${RULE18})`
35586
+ verdict: `${ok} successful result(s) read, each carrying a typed value (${RULE19})`
34637
35587
  },
34638
35588
  unread2
34639
35589
  );
34640
35590
  }
34641
35591
  var s52NoNullSuccess = {
34642
35592
  id: ID18,
34643
- rule: RULE18,
35593
+ rule: RULE19,
34644
35594
  pin: S51_RULES_PIN,
34645
35595
  run: runStatic6,
34646
35596
  runServed: (runtime) => runServedHalf4(runtime)
34647
35597
  };
34648
35598
 
34649
35599
  // src/detectors/s53-structured-not-text.ts
34650
- import * as ts4 from "typescript";
35600
+ import * as ts7 from "typescript";
34651
35601
  var ID19 = "S53 structured-not-text";
34652
- var RULE19 = "S-53";
35602
+ var RULE20 = "S-53";
34653
35603
  function classifyTextExpr(e, sf, depth = 0) {
34654
35604
  let x = e;
34655
- while (ts4.isParenthesizedExpression(x) || ts4.isAsExpression(x)) x = x.expression;
34656
- if (ts4.isStringLiteral(x) || ts4.isNoSubstitutionTemplateLiteral(x)) return { kind: "none" };
35605
+ while (ts7.isParenthesizedExpression(x) || ts7.isAsExpression(x)) x = x.expression;
35606
+ if (ts7.isStringLiteral(x) || ts7.isNoSubstitutionTemplateLiteral(x)) return { kind: "none" };
34657
35607
  const t = x.getText(sf);
34658
- if (ts4.isCallExpression(x) && /^JSON\s*\.\s*stringify$/.test(x.expression.getText(sf)))
35608
+ if (ts7.isCallExpression(x) && /^JSON\s*\.\s*stringify$/.test(x.expression.getText(sf)))
34659
35609
  return { kind: "data", form: "T1 JSON.stringify(...) in the text" };
34660
- if (ts4.isTemplateExpression(x) || ts4.isBinaryExpression(x) && x.operatorToken.kind === ts4.SyntaxKind.PlusToken) {
35610
+ if (ts7.isTemplateExpression(x) || ts7.isBinaryExpression(x) && x.operatorToken.kind === ts7.SyntaxKind.PlusToken) {
34661
35611
  if (/\bJSON\s*\.\s*stringify\s*\(/.test(t))
34662
35612
  return { kind: "data", form: "T2 a serialized value inside the text" };
34663
35613
  if (/\.\s*(join|map)\s*\(/.test(t))
34664
35614
  return { kind: "data", form: "T2 a list joined into the text" };
34665
35615
  if (/\.\s*length\b/.test(t))
34666
35616
  return { kind: "data", form: "T2 a count interpolated into the text" };
34667
- const spans = ts4.isTemplateExpression(x) ? x.templateSpans.map((sp) => sp.expression) : [x.left, x.right];
35617
+ const spans = ts7.isTemplateExpression(x) ? x.templateSpans.map((sp) => sp.expression) : [x.left, x.right];
34668
35618
  const idSpan = spans.find(
34669
35619
  (sp) => /(?:^|\.)id$|[a-z0-9](?:Id|Ids|ID)$/.test(sp.getText(sf).trim())
34670
35620
  );
@@ -34673,7 +35623,7 @@ function classifyTextExpr(e, sf, depth = 0) {
34673
35623
  kind: "data",
34674
35624
  form: `T2 an identifier interpolated into the text (${idSpan.getText(sf).trim()})`
34675
35625
  };
34676
- if (ts4.isBinaryExpression(x)) {
35626
+ if (ts7.isBinaryExpression(x)) {
34677
35627
  const parts = [classifyTextExpr(x.left, sf, depth), classifyTextExpr(x.right, sf, depth)];
34678
35628
  return parts.find((p) => p.kind === "data") ?? parts.find((p) => p.kind === "unread") ?? { kind: "none" };
34679
35629
  }
@@ -34682,16 +35632,16 @@ function classifyTextExpr(e, sf, depth = 0) {
34682
35632
  form: `a template with interpolated values \`${t.replace(/\s+/g, " ").slice(0, 60)}\``
34683
35633
  };
34684
35634
  }
34685
- if (ts4.isCallExpression(x) && /\.\s*join$/.test(x.expression.getText(sf)))
35635
+ if (ts7.isCallExpression(x) && /\.\s*join$/.test(x.expression.getText(sf)))
34686
35636
  return { kind: "data", form: "T2 a list joined into the text" };
34687
- if (ts4.isConditionalExpression(x)) {
35637
+ if (ts7.isConditionalExpression(x)) {
34688
35638
  const parts = [
34689
35639
  classifyTextExpr(x.whenTrue, sf, depth),
34690
35640
  classifyTextExpr(x.whenFalse, sf, depth)
34691
35641
  ];
34692
35642
  return parts.find((p) => p.kind === "data") ?? parts.find((p) => p.kind === "unread") ?? { kind: "none" };
34693
35643
  }
34694
- if (ts4.isIdentifier(x) && depth < 2) {
35644
+ if (ts7.isIdentifier(x) && depth < 2) {
34695
35645
  const init = constInit(x);
34696
35646
  if (init) return classifyTextExpr(init, sf, depth + 1);
34697
35647
  }
@@ -34699,11 +35649,11 @@ function classifyTextExpr(e, sf, depth = 0) {
34699
35649
  }
34700
35650
  function constInit(id) {
34701
35651
  for (let p = id.parent; p; p = p.parent) {
34702
- if (!(ts4.isBlock(p) || ts4.isSourceFile(p))) continue;
35652
+ if (!(ts7.isBlock(p) || ts7.isSourceFile(p))) continue;
34703
35653
  for (const st of p.statements) {
34704
- if (!ts4.isVariableStatement(st) || !(st.declarationList.flags & ts4.NodeFlags.Const)) continue;
35654
+ if (!ts7.isVariableStatement(st) || !(st.declarationList.flags & ts7.NodeFlags.Const)) continue;
34705
35655
  for (const d of st.declarationList.declarations)
34706
- if (ts4.isIdentifier(d.name) && d.name.text === id.text && d.initializer && d.getStart() < id.getStart())
35656
+ if (ts7.isIdentifier(d.name) && d.name.text === id.text && d.initializer && d.getStart() < id.getStart())
34707
35657
  return d.initializer;
34708
35658
  }
34709
35659
  }
@@ -34712,11 +35662,11 @@ function constInit(id) {
34712
35662
  function textOnlyReturn(obj, sf) {
34713
35663
  const content = prop(obj, "content");
34714
35664
  if (content.kind === "absent") return { kind: "none" };
34715
- if (content.kind !== "value" || !ts4.isArrayLiteralExpression(content.value))
35665
+ if (content.kind !== "value" || !ts7.isArrayLiteralExpression(content.value))
34716
35666
  return { kind: "unread", form: "a `content` that is not an array literal" };
34717
35667
  const out = [];
34718
35668
  for (const el of content.value.elements) {
34719
- if (!ts4.isObjectLiteralExpression(el)) {
35669
+ if (!ts7.isObjectLiteralExpression(el)) {
34720
35670
  out.push({ kind: "unread", form: "a content block that is not an object literal" });
34721
35671
  continue;
34722
35672
  }
@@ -34736,26 +35686,26 @@ function runStatic7(tree) {
34736
35686
  return couldNotJudge(
34737
35687
  ID19,
34738
35688
  surface ?? unresolved[0],
34739
- noToolsLocatedReason(tree, `no handler was read (${RULE19})`)
35689
+ noToolsLocatedReason(tree, `no handler was read (${RULE20})`)
34740
35690
  );
34741
35691
  return {
34742
35692
  id: ID19,
34743
35693
  anchor: tree.root,
34744
35694
  state: "absent",
34745
- verdict: `no MCP tool registered in product source \u2014 ${RULE19} n/a`
35695
+ verdict: `no MCP tool registered in product source \u2014 ${RULE20} n/a`
34746
35696
  };
34747
35697
  }
34748
35698
  const red = [];
34749
35699
  const unread2 = unresolved.map((a) => ({
34750
35700
  anchor: a,
34751
- reason: `a tool registered here has a name the scan cannot resolve, so its handler is unread (${RULE19})`
35701
+ reason: `a tool registered here has a name the scan cannot resolve, so its handler is unread (${RULE20})`
34752
35702
  }));
34753
35703
  const read = [];
34754
35704
  let firstRed = "";
34755
35705
  for (const t of tools) {
34756
35706
  const h = readHandler(tree, t);
34757
35707
  if (h.kind === "unread") {
34758
- unread2.push({ anchor: h.anchor, reason: `${h.reason} (${RULE19})` });
35708
+ unread2.push({ anchor: h.anchor, reason: `${h.reason} (${RULE20})` });
34759
35709
  continue;
34760
35710
  }
34761
35711
  read.push(t.name);
@@ -34766,7 +35716,7 @@ function runStatic7(tree) {
34766
35716
  if (v.kind === "unread")
34767
35717
  unread2.push({
34768
35718
  anchor: r.anchor,
34769
- reason: `${t.name}: the returned value is ${v.form} (${RULE19})`
35719
+ reason: `${t.name}: the returned value is ${v.form} (${RULE20})`
34770
35720
  });
34771
35721
  continue;
34772
35722
  }
@@ -34775,7 +35725,7 @@ function runStatic7(tree) {
34775
35725
  if (sc.kind === "spread") {
34776
35726
  unread2.push({
34777
35727
  anchor: r.anchor,
34778
- reason: `${t.name}: a result object built with a spread, structuredContent unread (${RULE19})`
35728
+ reason: `${t.name}: a result object built with a spread, structuredContent unread (${RULE20})`
34779
35729
  });
34780
35730
  continue;
34781
35731
  }
@@ -34785,7 +35735,7 @@ function runStatic7(tree) {
34785
35735
  red.push(`${t.name} ${c.form}, no structuredContent (${r.anchor})`);
34786
35736
  firstRed ||= r.anchor;
34787
35737
  } else if (c.kind === "unread")
34788
- unread2.push({ anchor: r.anchor, reason: `${t.name}: ${c.form} (${RULE19})` });
35738
+ unread2.push({ anchor: r.anchor, reason: `${t.name}: ${c.form} (${RULE20})` });
34789
35739
  }
34790
35740
  }
34791
35741
  }
@@ -34796,7 +35746,7 @@ function runStatic7(tree) {
34796
35746
  id: ID19,
34797
35747
  anchor: firstRed,
34798
35748
  state: "non-conforming",
34799
- verdict: `${red.length} success-path return(s) carry data in the text only: ${red.join("; ")} \u2014 return it as structuredContent under the outputSchema, the text being its serialization (${RULE19})`
35749
+ verdict: `${red.length} success-path return(s) carry data in the text only: ${red.join("; ")} \u2014 return it as structuredContent under the outputSchema, the text being its serialization (${RULE20})`
34800
35750
  },
34801
35751
  unread2
34802
35752
  );
@@ -34805,7 +35755,7 @@ function runStatic7(tree) {
34805
35755
  couldNotJudge(
34806
35756
  ID19,
34807
35757
  tools[0].anchor,
34808
- `static half: no text-only return carrying data in the ${read.length} handler(s) read (${names(read)}); unread by a static run: whether each served text is the serialization of its structuredContent \u2014 run --mode=dynamic (${RULE19})`
35758
+ `static half: no text-only return carrying data in the ${read.length} handler(s) read (${names(read)}); unread by a static run: whether each served text is the serialization of its structuredContent \u2014 run --mode=dynamic (${RULE20})`
34809
35759
  ),
34810
35760
  unread2
34811
35761
  );
@@ -34900,11 +35850,11 @@ function servedTextForm(c) {
34900
35850
  return { kind: "green" };
34901
35851
  }
34902
35852
  function runServedHalf5(runtime) {
34903
- const got = servedToolCalls(ID19, RULE19, runtime);
35853
+ const got = servedToolCalls(ID19, RULE20, runtime);
34904
35854
  if ("cnj" in got) return got.cnj;
34905
35855
  const { calls, anchor } = got;
34906
35856
  if (runtime.tools.length === 0)
34907
- return { id: ID19, anchor, state: "absent", verdict: `the server serves no tool \u2014 ${RULE19} n/a` };
35857
+ return { id: ID19, anchor, state: "absent", verdict: `the server serves no tool \u2014 ${RULE20} n/a` };
34908
35858
  const red = [];
34909
35859
  const unread2 = [];
34910
35860
  let ok = 0;
@@ -34914,7 +35864,7 @@ function runServedHalf5(runtime) {
34914
35864
  if (why || !c || c.kind !== "result") {
34915
35865
  unread2.push({
34916
35866
  anchor: `${anchor} tools/call ${t.name}`,
34917
- reason: `${t.name}: ${why} (${RULE19})`
35867
+ reason: `${t.name}: ${why} (${RULE20})`
34918
35868
  });
34919
35869
  continue;
34920
35870
  }
@@ -34923,7 +35873,7 @@ function runServedHalf5(runtime) {
34923
35873
  else if (v.kind === "unread")
34924
35874
  unread2.push({
34925
35875
  anchor: `${anchor} tools/call ${t.name}`,
34926
- reason: `${t.name}: ${v.form} (${RULE19})`
35876
+ reason: `${t.name}: ${v.form} (${RULE20})`
34927
35877
  });
34928
35878
  else ok++;
34929
35879
  }
@@ -34934,7 +35884,7 @@ function runServedHalf5(runtime) {
34934
35884
  id: ID19,
34935
35885
  anchor,
34936
35886
  state: "non-conforming",
34937
- verdict: `${red.length} successful result(s) carry data in free text: ${red.join("; ")} (${RULE19})`
35887
+ verdict: `${red.length} successful result(s) carry data in free text: ${red.join("; ")} (${RULE20})`
34938
35888
  },
34939
35889
  unread2
34940
35890
  );
@@ -34944,25 +35894,25 @@ function runServedHalf5(runtime) {
34944
35894
  id: ID19,
34945
35895
  anchor,
34946
35896
  state: "present",
34947
- verdict: `${ok} successful result(s) read: data in structuredContent, text its serialization or summary (${RULE19})`
35897
+ verdict: `${ok} successful result(s) read: data in structuredContent, text its serialization or summary (${RULE20})`
34948
35898
  },
34949
35899
  unread2
34950
35900
  );
34951
35901
  }
34952
35902
  var s53StructuredNotText = {
34953
35903
  id: ID19,
34954
- rule: RULE19,
35904
+ rule: RULE20,
34955
35905
  pin: S51_RULES_PIN,
34956
35906
  run: runStatic7,
34957
35907
  runServed: (runtime) => runServedHalf5(runtime)
34958
35908
  };
34959
35909
 
34960
35910
  // src/detectors/s54-tools-tested.ts
34961
- import { readFileSync as readFileSync24, readdirSync as readdirSync17, statSync as statSync24 } from "fs";
34962
- import { join as join35, relative as relative15, sep as sep7 } from "path";
34963
- import * as ts5 from "typescript";
35911
+ import { readFileSync as readFileSync26, readdirSync as readdirSync18, statSync as statSync24 } from "fs";
35912
+ import { join as join36, relative as relative17, sep as sep9 } from "path";
35913
+ import * as ts8 from "typescript";
34964
35914
  var ID20 = "S54 tools-tested";
34965
- var RULE20 = "S-54";
35915
+ var RULE21 = "S-54";
34966
35916
  var TEST_DIR = /(^|\/)(test|tests|__tests__|spec|specs|e2e)\//;
34967
35917
  var TEST_NAME = /\.(test|spec)\.[cm]?[jt]sx?$/;
34968
35918
  var CODE2 = /\.[cm]?[jt]sx?$/;
@@ -34970,87 +35920,87 @@ var NOT_TESTS = /* @__PURE__ */ new Set([
34970
35920
  ...Object.keys(SKIP_DIR_INFO).filter((d) => !SKIP_DIR_INFO[d].authored),
34971
35921
  "fixtures"
34972
35922
  ]);
34973
- function isTestFile(rel) {
34974
- return CODE2.test(rel) && !/\.d\.[cm]?ts$/.test(rel) && (TEST_NAME.test(rel) || TEST_DIR.test(rel));
35923
+ function isTestFile(rel2) {
35924
+ return CODE2.test(rel2) && !/\.d\.[cm]?ts$/.test(rel2) && (TEST_NAME.test(rel2) || TEST_DIR.test(rel2));
34975
35925
  }
34976
35926
  function testFiles2(root) {
34977
35927
  const files = [];
34978
35928
  const unread2 = [];
34979
- const walk3 = (dir) => {
35929
+ const walk4 = (dir) => {
34980
35930
  let entries;
34981
35931
  try {
34982
- entries = readdirSync17(dir);
35932
+ entries = readdirSync18(dir);
34983
35933
  } catch (e) {
34984
35934
  unread2.push({
34985
- anchor: relative15(root, dir) || ".",
34986
- reason: `directory not listed (${e.message}) (${RULE20})`
35935
+ anchor: relative17(root, dir) || ".",
35936
+ reason: `directory not listed (${e.message}) (${RULE21})`
34987
35937
  });
34988
35938
  return;
34989
35939
  }
34990
35940
  for (const name of entries) {
34991
- const full = join35(dir, name);
35941
+ const full = join36(dir, name);
34992
35942
  let st;
34993
35943
  try {
34994
35944
  st = statSync24(full);
34995
35945
  } catch (e) {
34996
35946
  unread2.push({
34997
- anchor: relative15(root, full),
34998
- reason: `not read (${e.message}) (${RULE20})`
35947
+ anchor: relative17(root, full),
35948
+ reason: `not read (${e.message}) (${RULE21})`
34999
35949
  });
35000
35950
  continue;
35001
35951
  }
35002
35952
  if (st.isDirectory()) {
35003
- if (!NOT_TESTS.has(name)) walk3(full);
35953
+ if (!NOT_TESTS.has(name)) walk4(full);
35004
35954
  continue;
35005
35955
  }
35006
- const rel = relative15(root, full).split(sep7).join("/");
35007
- if (!st.isFile() || !isTestFile(rel)) continue;
35956
+ const rel2 = relative17(root, full).split(sep9).join("/");
35957
+ if (!st.isFile() || !isTestFile(rel2)) continue;
35008
35958
  try {
35009
- const text = readFileSync24(full, "utf8");
35010
- const kind = /x$/.test(rel) ? ts5.ScriptKind.TSX : /\.[cm]?js$/.test(rel) ? ts5.ScriptKind.JS : ts5.ScriptKind.TS;
35011
- files.push({ rel, sf: ts5.createSourceFile(rel, text, ts5.ScriptTarget.Latest, true, kind) });
35959
+ const text = readFileSync26(full, "utf8");
35960
+ const kind = /x$/.test(rel2) ? ts8.ScriptKind.TSX : /\.[cm]?js$/.test(rel2) ? ts8.ScriptKind.JS : ts8.ScriptKind.TS;
35961
+ files.push({ rel: rel2, sf: ts8.createSourceFile(rel2, text, ts8.ScriptTarget.Latest, true, kind) });
35012
35962
  } catch (e) {
35013
35963
  unread2.push({
35014
- anchor: rel,
35015
- reason: `test file not read (${e.message}) (${RULE20})`
35964
+ anchor: rel2,
35965
+ reason: `test file not read (${e.message}) (${RULE21})`
35016
35966
  });
35017
35967
  }
35018
35968
  }
35019
35969
  };
35020
- walk3(root);
35970
+ walk4(root);
35021
35971
  return { files, unread: unread2 };
35022
35972
  }
35023
35973
  var up = (n) => {
35024
35974
  let x = n;
35025
- while (x.parent && (ts5.isParenthesizedExpression(x.parent) || ts5.isAsExpression(x.parent) || ts5.isNonNullExpression(x.parent) || ts5.isAwaitExpression(x.parent) || ts5.isSatisfiesExpression(x.parent)))
35975
+ while (x.parent && (ts8.isParenthesizedExpression(x.parent) || ts8.isAsExpression(x.parent) || ts8.isNonNullExpression(x.parent) || ts8.isAwaitExpression(x.parent) || ts8.isSatisfiesExpression(x.parent)))
35026
35976
  x = x.parent;
35027
35977
  return x;
35028
35978
  };
35029
35979
  var calleeName = (c) => {
35030
35980
  const e = c.expression;
35031
- if (ts5.isIdentifier(e)) return e.text;
35032
- if (ts5.isPropertyAccessExpression(e)) return e.name.text;
35981
+ if (ts8.isIdentifier(e)) return e.text;
35982
+ if (ts8.isPropertyAccessExpression(e)) return e.name.text;
35033
35983
  return void 0;
35034
35984
  };
35035
- var propName = (p) => p.name && (ts5.isIdentifier(p.name) || ts5.isStringLiteralLike(p.name)) ? p.name.text : void 0;
35985
+ var propName = (p) => p.name && (ts8.isIdentifier(p.name) || ts8.isStringLiteralLike(p.name)) ? p.name.text : void 0;
35036
35986
  function invoked(access) {
35037
35987
  const a = up(access);
35038
35988
  const p = a.parent;
35039
35989
  if (!p) return false;
35040
- if (ts5.isCallExpression(p) && p.expression === a) return true;
35041
- if (ts5.isPropertyAccessExpression(p) && p.expression === a && ["handler", "callback"].includes(p.name.text)) {
35990
+ if (ts8.isCallExpression(p) && p.expression === a) return true;
35991
+ if (ts8.isPropertyAccessExpression(p) && p.expression === a && ["handler", "callback"].includes(p.name.text)) {
35042
35992
  const q = up(p).parent;
35043
- return !!q && ts5.isCallExpression(q) && up(q.expression) === up(p);
35993
+ return !!q && ts8.isCallExpression(q) && up(q.expression) === up(p);
35044
35994
  }
35045
- if (ts5.isVariableDeclaration(p) && p.initializer && up(p.initializer) === a && ts5.isIdentifier(p.name)) {
35995
+ if (ts8.isVariableDeclaration(p) && p.initializer && up(p.initializer) === a && ts8.isIdentifier(p.name)) {
35046
35996
  const bound = p.name.text;
35047
35997
  let scope2 = p;
35048
- while (scope2.parent && !ts5.isBlock(scope2) && !ts5.isSourceFile(scope2)) scope2 = scope2.parent;
35998
+ while (scope2.parent && !ts8.isBlock(scope2) && !ts8.isSourceFile(scope2)) scope2 = scope2.parent;
35049
35999
  let called = false;
35050
36000
  const visit = (n) => {
35051
36001
  if (called) return;
35052
- if (ts5.isIdentifier(n) && n.text === bound && n !== p.name && invoked(n)) called = true;
35053
- else ts5.forEachChild(n, visit);
36002
+ if (ts8.isIdentifier(n) && n.text === bound && n !== p.name && invoked(n)) called = true;
36003
+ else ts8.forEachChild(n, visit);
35054
36004
  };
35055
36005
  visit(scope2);
35056
36006
  return called;
@@ -35061,27 +36011,27 @@ function callsAt(e, helpers) {
35061
36011
  const x = up(e);
35062
36012
  const p = x.parent;
35063
36013
  if (!p) return false;
35064
- if (ts5.isPropertyAssignment(p) && p.initializer === x && propName(p) === "name" || ts5.isShorthandPropertyAssignment(p) && p.name === x && p.name.text === "name") {
36014
+ if (ts8.isPropertyAssignment(p) && p.initializer === x && propName(p) === "name" || ts8.isShorthandPropertyAssignment(p) && p.name === x && p.name.text === "name") {
35065
36015
  const obj = p.parent;
35066
36016
  const holder = up(obj).parent;
35067
- if (holder && ts5.isCallExpression(holder) && holder.arguments.some((a) => up(a) === up(obj)) && calleeName(holder) === "callTool")
36017
+ if (holder && ts8.isCallExpression(holder) && holder.arguments.some((a) => up(a) === up(obj)) && calleeName(holder) === "callTool")
35068
36018
  return true;
35069
- if (holder && ts5.isPropertyAssignment(holder) && propName(holder) === "params") {
36019
+ if (holder && ts8.isPropertyAssignment(holder) && propName(holder) === "params") {
35070
36020
  const req = holder.parent;
35071
36021
  return req.properties.some(
35072
- (q) => ts5.isPropertyAssignment(q) && propName(q) === "method" && ts5.isStringLiteralLike(q.initializer) && q.initializer.text === "tools/call"
36022
+ (q) => ts8.isPropertyAssignment(q) && propName(q) === "method" && ts8.isStringLiteralLike(q.initializer) && q.initializer.text === "tools/call"
35073
36023
  );
35074
36024
  }
35075
36025
  return false;
35076
36026
  }
35077
- if (ts5.isCallExpression(p) && p.arguments.some((a) => up(a) === x)) {
36027
+ if (ts8.isCallExpression(p) && p.arguments.some((a) => up(a) === x)) {
35078
36028
  const i = p.arguments.findIndex((a) => up(a) === x);
35079
- if (calleeName(p) === "get" && i === 0 && ts5.isPropertyAccessExpression(p.expression))
36029
+ if (calleeName(p) === "get" && i === 0 && ts8.isPropertyAccessExpression(p.expression))
35080
36030
  return invoked(p);
35081
36031
  const name = calleeName(p);
35082
36032
  return !!name && (helpers.get(name)?.has(i) ?? false);
35083
36033
  }
35084
- if (ts5.isElementAccessExpression(p) && up(p.argumentExpression) === x) return invoked(p);
36034
+ if (ts8.isElementAccessExpression(p) && up(p.argumentExpression) === x) return invoked(p);
35085
36035
  return false;
35086
36036
  }
35087
36037
  function deriveHelpers(files) {
@@ -35089,10 +36039,10 @@ function deriveHelpers(files) {
35089
36039
  const fns = [];
35090
36040
  for (const { sf } of files) {
35091
36041
  const visit = (n) => {
35092
- if (ts5.isFunctionDeclaration(n) && n.name && n.body) fns.push({ name: n.name.text, fn: n });
35093
- else if (ts5.isVariableDeclaration(n) && ts5.isIdentifier(n.name) && n.initializer && (ts5.isArrowFunction(n.initializer) || ts5.isFunctionExpression(n.initializer)))
36042
+ if (ts8.isFunctionDeclaration(n) && n.name && n.body) fns.push({ name: n.name.text, fn: n });
36043
+ else if (ts8.isVariableDeclaration(n) && ts8.isIdentifier(n.name) && n.initializer && (ts8.isArrowFunction(n.initializer) || ts8.isFunctionExpression(n.initializer)))
35094
36044
  fns.push({ name: n.name.text, fn: n.initializer });
35095
- ts5.forEachChild(n, visit);
36045
+ ts8.forEachChild(n, visit);
35096
36046
  };
35097
36047
  visit(sf);
35098
36048
  }
@@ -35100,14 +36050,14 @@ function deriveHelpers(files) {
35100
36050
  let grew = false;
35101
36051
  for (const { name, fn } of fns) {
35102
36052
  fn.parameters.forEach((param, i) => {
35103
- if (!ts5.isIdentifier(param.name) || helpers.get(name)?.has(i)) return;
36053
+ if (!ts8.isIdentifier(param.name) || helpers.get(name)?.has(i)) return;
35104
36054
  const pname = param.name.text;
35105
36055
  let hit = false;
35106
36056
  const visit = (n) => {
35107
36057
  if (hit) return;
35108
- if (ts5.isIdentifier(n) && n.text === pname && n !== param.name && callsAt(n, helpers))
36058
+ if (ts8.isIdentifier(n) && n.text === pname && n !== param.name && callsAt(n, helpers))
35109
36059
  hit = true;
35110
- else ts5.forEachChild(n, visit);
36060
+ else ts8.forEachChild(n, visit);
35111
36061
  };
35112
36062
  if (fn.body) visit(fn.body);
35113
36063
  if (hit) {
@@ -35125,11 +36075,11 @@ function testCalls(files, tools) {
35125
36075
  const helpers = deriveHelpers(files);
35126
36076
  const wanted = new Set(tools);
35127
36077
  const out = new Map(tools.map((t) => [t, []]));
35128
- for (const { rel, sf } of files) {
36078
+ for (const { rel: rel2, sf } of files) {
35129
36079
  const visit = (n) => {
35130
- if ((ts5.isStringLiteral(n) || ts5.isNoSubstitutionTemplateLiteral(n)) && wanted.has(n.text) && callsAt(n, helpers))
35131
- out.get(n.text)?.push(`${rel}:${sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1}`);
35132
- ts5.forEachChild(n, visit);
36080
+ if ((ts8.isStringLiteral(n) || ts8.isNoSubstitutionTemplateLiteral(n)) && wanted.has(n.text) && callsAt(n, helpers))
36081
+ out.get(n.text)?.push(`${rel2}:${sf.getLineAndCharacterOfPosition(n.getStart(sf)).line + 1}`);
36082
+ ts8.forEachChild(n, visit);
35133
36083
  };
35134
36084
  visit(sf);
35135
36085
  }
@@ -35139,7 +36089,7 @@ function s54Controls() {
35139
36089
  const f = (code) => [
35140
36090
  {
35141
36091
  rel: "c.test.ts",
35142
- sf: ts5.createSourceFile("c.test.ts", code, ts5.ScriptTarget.Latest, true, ts5.ScriptKind.TS)
36092
+ sf: ts8.createSourceFile("c.test.ts", code, ts8.ScriptTarget.Latest, true, ts8.ScriptKind.TS)
35143
36093
  }
35144
36094
  ];
35145
36095
  const k = (code) => (testCalls(f(code), ["t"]).get("t") ?? []).length;
@@ -35161,25 +36111,25 @@ function runStatic8(tree) {
35161
36111
  return couldNotJudge(
35162
36112
  ID20,
35163
36113
  surface ?? unresolved[0],
35164
- noToolsLocatedReason(tree, `no tool name was derived (${RULE20})`)
36114
+ noToolsLocatedReason(tree, `no tool name was derived (${RULE21})`)
35165
36115
  );
35166
36116
  return {
35167
36117
  id: ID20,
35168
36118
  anchor: tree.root,
35169
36119
  state: "absent",
35170
- verdict: `no MCP tool registered in product source \u2014 ${RULE20} n/a`
36120
+ verdict: `no MCP tool registered in product source \u2014 ${RULE21} n/a`
35171
36121
  };
35172
36122
  }
35173
36123
  let root = tree.root;
35174
36124
  try {
35175
- if (!statSync24(root).isDirectory()) root = join35(root, "..");
36125
+ if (!statSync24(root).isDirectory()) root = join36(root, "..");
35176
36126
  } catch {
35177
36127
  }
35178
36128
  const { files, unread: unread2 } = testFiles2(root);
35179
36129
  for (const a of unresolved)
35180
36130
  unread2.push({
35181
36131
  anchor: a,
35182
- reason: `a tool registered here has a computed name, so whether a test calls it is unread (${RULE20})`
36132
+ reason: `a tool registered here has a computed name, so whether a test calls it is unread (${RULE21})`
35183
36133
  });
35184
36134
  if (files.length === 0)
35185
36135
  return settle(
@@ -35187,7 +36137,7 @@ function runStatic8(tree) {
35187
36137
  couldNotJudge(
35188
36138
  ID20,
35189
36139
  tools[0].anchor,
35190
- `no test file under ${root} (searched: *.test.* / *.spec.* and test/, tests/, __tests__/, spec/, specs/, e2e/ directories): a suite outside the scanned root is not read, so whether the ${tools.length} registered tool(s) are called is unread (${RULE20})`
36140
+ `no test file under ${root} (searched: *.test.* / *.spec.* and test/, tests/, __tests__/, spec/, specs/, e2e/ directories): a suite outside the scanned root is not read, so whether the ${tools.length} registered tool(s) are called is unread (${RULE21})`
35191
36141
  ),
35192
36142
  unread2
35193
36143
  );
@@ -35203,7 +36153,7 @@ function runStatic8(tree) {
35203
36153
  id: ID20,
35204
36154
  anchor: untested[0].anchor,
35205
36155
  state: "non-conforming",
35206
- verdict: `${untested.length} of ${tools.length} registered tool(s) are called by no test (${files.length} test file(s) read under ${root}; call positions K1..K4): ${names(untested.map((t) => `${t.name} (${t.anchor})`))} (${RULE20})`
36156
+ verdict: `${untested.length} of ${tools.length} registered tool(s) are called by no test (${files.length} test file(s) read under ${root}; call positions K1..K4): ${names(untested.map((t) => `${t.name} (${t.anchor})`))} (${RULE21})`
35207
36157
  },
35208
36158
  unread2
35209
36159
  );
@@ -35213,14 +36163,14 @@ function runStatic8(tree) {
35213
36163
  id: ID20,
35214
36164
  anchor: tools[0].anchor,
35215
36165
  state: "present",
35216
- verdict: `${tools.length} registered tool(s), each called by at least one test (${files.length} test file(s) read under ${root}) (${RULE20})`
36166
+ verdict: `${tools.length} registered tool(s), each called by at least one test (${files.length} test file(s) read under ${root}) (${RULE21})`
35217
36167
  },
35218
36168
  unread2
35219
36169
  );
35220
36170
  }
35221
36171
  function runServedHalf6(runtime) {
35222
36172
  const anchor = `${runtime.root} (served)`;
35223
- const why = runtime.remote ? `a URL scan has no repository: S-54 reads the repository's test files, which the served list does not carry (${RULE20})` : `the served tools/list does not say which tests call a tool: S-54 is read from the repository (static) (${RULE20})`;
36173
+ const why = runtime.remote ? `a URL scan has no repository: S-54 reads the repository's test files, which the served list does not carry (${RULE21})` : `the served tools/list does not say which tests call a tool: S-54 is read from the repository (static) (${RULE21})`;
35224
36174
  return couldNotJudge(
35225
36175
  ID20,
35226
36176
  anchor,
@@ -35229,7 +36179,7 @@ function runServedHalf6(runtime) {
35229
36179
  }
35230
36180
  var s54ToolsTested = {
35231
36181
  id: ID20,
35232
- rule: RULE20,
36182
+ rule: RULE21,
35233
36183
  pin: S51_RULES_PIN,
35234
36184
  run: runStatic8,
35235
36185
  runServed: (runtime) => runServedHalf6(runtime)
@@ -35275,6 +36225,7 @@ var registered = [
35275
36225
  c37DirectoryListing,
35276
36226
  c38FieldBudget,
35277
36227
  c40ToolDocumentation,
36228
+ c41VantageosLatest,
35278
36229
  s45OriginTargets,
35279
36230
  s46RegistrationRedirects,
35280
36231
  s47WebhookDelivery,
@@ -35519,13 +36470,13 @@ function parseEventsArgs(args) {
35519
36470
  }
35520
36471
 
35521
36472
  // src/gate.ts
35522
- import { readFileSync as readFileSync25 } from "fs";
36473
+ import { readFileSync as readFileSync27 } from "fs";
35523
36474
  var OWED_FILE_NAME = "mcp-doctor.owed.json";
35524
36475
  var FORMAT = `expected {"owed": [{"id": "<detector id, the table's first column>", "reason": "<why this row may publish undecided>"}, ...]}`;
35525
36476
  function readOwedFile(path, opts) {
35526
36477
  let text;
35527
36478
  try {
35528
- text = readFileSync25(path, "utf8");
36479
+ text = readFileSync27(path, "utf8");
35529
36480
  } catch (err) {
35530
36481
  const code = err.code;
35531
36482
  if (code === "ENOENT" && !opts.explicit) return { kind: "none", path };
@@ -35727,7 +36678,7 @@ import { createServer } from "https";
35727
36678
  import { Webhook } from "standardwebhooks";
35728
36679
 
35729
36680
  // src/runtime/publicTarget.ts
35730
- import { spawnSync as spawnSync2 } from "child_process";
36681
+ import { spawnSync as spawnSync3 } from "child_process";
35731
36682
  import { isIP } from "net";
35732
36683
 
35733
36684
  // src/runtime/ianaSpecial.ts
@@ -36113,10 +37064,10 @@ function v4ToBig(ip) {
36113
37064
  }
36114
37065
  function v6ToBig(ip) {
36115
37066
  let s = ip.toLowerCase();
36116
- const dotted = /(\d+\.\d+\.\d+\.\d+)$/.exec(s);
36117
- if (dotted) {
36118
- const v = v4ToBig(dotted[1]);
36119
- s = `${s.slice(0, -dotted[1].length)}${(v >> 16n).toString(16)}:${(v & 0xffffn).toString(16)}`;
37067
+ const dotted2 = /(\d+\.\d+\.\d+\.\d+)$/.exec(s);
37068
+ if (dotted2) {
37069
+ const v = v4ToBig(dotted2[1]);
37070
+ s = `${s.slice(0, -dotted2[1].length)}${(v >> 16n).toString(16)}:${(v & 0xffffn).toString(16)}`;
36120
37071
  }
36121
37072
  const [head, tail] = s.includes("::") ? s.split("::") : [s, void 0];
36122
37073
  const h = (head ?? "").split(":").filter((x) => x !== "");
@@ -36159,7 +37110,7 @@ function resolveHost(host) {
36159
37110
  const bare = host.replace(/^\[|\]$/g, "");
36160
37111
  if (isIP(bare) !== 0) return { addresses: [bare] };
36161
37112
  const script = "require('node:dns').promises.lookup(process.argv[1], { all: true, verbatim: true }).then((a) => process.stdout.write(JSON.stringify(a.map((x) => x.address)))).catch((e) => { process.stdout.write(JSON.stringify({ error: e && e.code ? e.code : String(e) })); })";
36162
- const out = spawnSync2(process.execPath, ["-e", script, bare], {
37113
+ const out = spawnSync3(process.execPath, ["-e", script, bare], {
36163
37114
  encoding: "utf8",
36164
37115
  timeout: 1e4
36165
37116
  });
@@ -37075,19 +38026,19 @@ function verifySignature(secret, h) {
37075
38026
  }
37076
38027
 
37077
38028
  // src/runtime/launch.ts
37078
- import { spawnSync as spawnSync3 } from "child_process";
37079
- import { existsSync as existsSync23, readFileSync as readFileSync26, statSync as statSync25 } from "fs";
37080
- import { dirname as dirname17, isAbsolute, join as join36, resolve as resolve3 } from "path";
38029
+ import { spawnSync as spawnSync4 } from "child_process";
38030
+ import { existsSync as existsSync23, readFileSync as readFileSync28, statSync as statSync25 } from "fs";
38031
+ import { dirname as dirname18, isAbsolute, join as join37, resolve as resolve3 } from "path";
37081
38032
  function findPackageDir(target) {
37082
38033
  let dir;
37083
38034
  try {
37084
- dir = statSync25(target).isDirectory() ? target : dirname17(target);
38035
+ dir = statSync25(target).isDirectory() ? target : dirname18(target);
37085
38036
  } catch {
37086
38037
  return null;
37087
38038
  }
37088
38039
  for (let depth = 0; depth < 8; depth++) {
37089
- if (existsSync23(join36(dir, "package.json"))) return dir;
37090
- const parent = dirname17(dir);
38040
+ if (existsSync23(join37(dir, "package.json"))) return dir;
38041
+ const parent = dirname18(dir);
37091
38042
  if (parent === dir) break;
37092
38043
  dir = parent;
37093
38044
  }
@@ -37111,13 +38062,13 @@ function deriveLaunchPlan(target) {
37111
38062
  }
37112
38063
  let pkg;
37113
38064
  try {
37114
- if (!statSync25(join36(pkgDir, "package.json")).isFile()) {
37115
- return { error: `${join36(pkgDir, "package.json")} is not a regular file \u2014 not read` };
38065
+ if (!statSync25(join37(pkgDir, "package.json")).isFile()) {
38066
+ return { error: `${join37(pkgDir, "package.json")} is not a regular file \u2014 not read` };
37116
38067
  }
37117
- pkg = JSON.parse(readFileSync26(join36(pkgDir, "package.json"), "utf8"));
38068
+ pkg = JSON.parse(readFileSync28(join37(pkgDir, "package.json"), "utf8"));
37118
38069
  } catch (err) {
37119
38070
  return {
37120
- error: `could not parse ${join36(pkgDir, "package.json")}: ${err instanceof Error ? err.message : String(err)}`
38071
+ error: `could not parse ${join37(pkgDir, "package.json")}: ${err instanceof Error ? err.message : String(err)}`
37121
38072
  };
37122
38073
  }
37123
38074
  const bin = firstBinEntry(pkg.bin);
@@ -37898,14 +38849,14 @@ function readEvalCounts(target) {
37898
38849
  if (!pkgDir) return { counts };
37899
38850
  let dir = pkgDir;
37900
38851
  for (let depth = 0; depth < 8; depth++) {
37901
- const candidate = join36(dir, "evals", "evals.json");
38852
+ const candidate = join37(dir, "evals", "evals.json");
37902
38853
  if (existsSync23(candidate)) {
37903
38854
  let text;
37904
38855
  try {
37905
38856
  if (!statSync25(candidate).isFile()) {
37906
38857
  return { counts, unreadable: `${candidate} is not a regular file \u2014 not read` };
37907
38858
  }
37908
- text = readFileSync26(candidate, "utf8");
38859
+ text = readFileSync28(candidate, "utf8");
37909
38860
  } catch (err) {
37910
38861
  return {
37911
38862
  counts,
@@ -37921,7 +38872,7 @@ function readEvalCounts(target) {
37921
38872
  }
37922
38873
  return { counts };
37923
38874
  }
37924
- const parent = dirname17(dir);
38875
+ const parent = dirname18(dir);
37925
38876
  if (parent === dir) break;
37926
38877
  dir = parent;
37927
38878
  }
@@ -37936,7 +38887,7 @@ function statSyncSafe(p) {
37936
38887
  }
37937
38888
  function deriveExpectedCommit(cwd) {
37938
38889
  try {
37939
- const out = spawnSync3("git", ["rev-parse", "HEAD"], {
38890
+ const out = spawnSync4("git", ["rev-parse", "HEAD"], {
37940
38891
  cwd,
37941
38892
  encoding: "utf8",
37942
38893
  timeout: 5e3
@@ -38030,7 +38981,7 @@ function displayUrl(url) {
38030
38981
  }
38031
38982
  }
38032
38983
  function introspect(plan, root, evalSource, expectedCommit, evalsNote, secrets) {
38033
- const proc = spawnSync3(process.execPath, ["--input-type=module", "-e", INTROSPECTOR], {
38984
+ const proc = spawnSync4(process.execPath, ["--input-type=module", "-e", INTROSPECTOR], {
38034
38985
  env: { ...process.env, MCP_DOCTOR_PLAN: JSON.stringify(plan) },
38035
38986
  encoding: "utf8",
38036
38987
  timeout: 2e4,
@@ -38295,7 +39246,7 @@ function parseUrlArgs(args, env) {
38295
39246
  }
38296
39247
 
38297
39248
  // src/kit/rule-ids.ts
38298
- import { readFileSync as readFileSync27 } from "fs";
39249
+ import { readFileSync as readFileSync29 } from "fs";
38299
39250
  var StandardUnreadableError = class extends Error {
38300
39251
  constructor(path, cause) {
38301
39252
  super(
@@ -38335,7 +39286,7 @@ function stateless(pattern) {
38335
39286
  function deriveRuleIds(path, pattern) {
38336
39287
  let blob;
38337
39288
  try {
38338
- blob = readFileSync27(path, "utf8");
39289
+ blob = readFileSync29(path, "utf8");
38339
39290
  } catch (e) {
38340
39291
  throw new StandardUnreadableError(path, e);
38341
39292
  }
@@ -38451,7 +39402,7 @@ function checkedRuleIds(entries) {
38451
39402
 
38452
39403
  // src/kit/report.ts
38453
39404
  import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
38454
- import { dirname as dirname18 } from "path";
39405
+ import { dirname as dirname19 } from "path";
38455
39406
  function renderReport(ctx) {
38456
39407
  const lines2 = [];
38457
39408
  lines2.push(`${ctx.title} report \u2014 target: ${ctx.target}`);
@@ -38469,7 +39420,7 @@ function renderReport(ctx) {
38469
39420
  return lines2.join("\n");
38470
39421
  }
38471
39422
  function writeReport(path, ctx) {
38472
- mkdirSync(dirname18(path), { recursive: true });
39423
+ mkdirSync(dirname19(path), { recursive: true });
38473
39424
  writeFileSync2(path, renderReport(ctx), "utf8");
38474
39425
  }
38475
39426
 
@@ -38796,11 +39747,11 @@ function renderJson(surface, results, skipped, coverage, gate) {
38796
39747
  function renderResults(surface, results, coverageLine) {
38797
39748
  const cols = { item: 24, anchor: 26, state: 15 };
38798
39749
  const header = `${pad("item", cols.item)} | ${pad("file:line", cols.anchor)} | ${pad("state", cols.state)} | verdict`;
38799
- const sep8 = "-".repeat(header.length);
39750
+ const sep10 = "-".repeat(header.length);
38800
39751
  const rows = results.map(
38801
39752
  (r) => `${pad(r.id, cols.item)} | ${pad(r.anchor, cols.anchor)} | ${pad(r.state, cols.state)} | ${r.verdict}`
38802
39753
  );
38803
- const table = [`surface: ${surface}`, coverageLine, header, sep8, ...rows].join("\n");
39754
+ const table = [`surface: ${surface}`, coverageLine, header, sep10, ...rows].join("\n");
38804
39755
  const unjudged = results.filter((r) => r.state === "could-not-judge");
38805
39756
  if (unjudged.length === 0) return table;
38806
39757
  const cnjHeader = `could-not-judge (${unjudged.length}) \u2014 the doctor could NOT read these; this is NOT a clean bill:`;
@@ -38882,8 +39833,8 @@ var USAGE = [
38882
39833
  ].join("\n");
38883
39834
  function readVersion() {
38884
39835
  try {
38885
- const here = dirname19(fileURLToPath2(import.meta.url));
38886
- const manifest = JSON.parse(readFileSync28(join37(here, "..", "package.json"), "utf8"));
39836
+ const here = dirname20(fileURLToPath2(import.meta.url));
39837
+ const manifest = JSON.parse(readFileSync30(join38(here, "..", "package.json"), "utf8"));
38887
39838
  return manifest.version ?? null;
38888
39839
  } catch {
38889
39840
  return null;
@@ -38951,10 +39902,10 @@ function runEventsMode(endpoint, rest, options) {
38951
39902
  }
38952
39903
  function defaultOwedPath(target) {
38953
39904
  try {
38954
- if (statSync27(target).isFile()) return join37(dirname19(target), OWED_FILE_NAME);
39905
+ if (statSync27(target).isFile()) return join38(dirname20(target), OWED_FILE_NAME);
38955
39906
  } catch {
38956
39907
  }
38957
- return join37(target, OWED_FILE_NAME);
39908
+ return join38(target, OWED_FILE_NAME);
38958
39909
  }
38959
39910
  function main() {
38960
39911
  const argv = process.argv.slice(2);