@vantageos/mcp-doctor 0.13.2 → 0.14.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/CHANGELOG.md +27 -0
- package/README.md +55 -1
- package/dist/doctor.js +576 -200
- package/package.json +10 -3
package/dist/doctor.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/doctor.ts
|
|
4
|
-
import { readFileSync as
|
|
5
|
-
import { dirname as
|
|
4
|
+
import { readFileSync as readFileSync17, realpathSync } from "fs";
|
|
5
|
+
import { dirname as dirname18, join as join29, resolve as resolve4 } from "path";
|
|
6
6
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7
7
|
|
|
8
8
|
// src/scan.ts
|
|
@@ -3937,9 +3937,9 @@ function stringValueAt(file, line, col) {
|
|
|
3937
3937
|
return { kind: "string", value: m[2] };
|
|
3938
3938
|
}
|
|
3939
3939
|
function identReturned(file, name) {
|
|
3940
|
-
const
|
|
3940
|
+
const esc5 = name.replace(/[$]/g, "\\$&");
|
|
3941
3941
|
const re = new RegExp(
|
|
3942
|
-
`(?:\\breturn|=>)\\s*(?:\\(\\s*)*${
|
|
3942
|
+
`(?:\\breturn|=>)\\s*(?:\\(\\s*)*${esc5}(?![\\w$])(?!\\s*(?:\\?\\.|\\.|\\(|\\[|=))`
|
|
3943
3943
|
);
|
|
3944
3944
|
return re.test(uncommentedLines(file).join("\n"));
|
|
3945
3945
|
}
|
|
@@ -5375,6 +5375,76 @@ var c9VerbDeclared = {
|
|
|
5375
5375
|
}
|
|
5376
5376
|
};
|
|
5377
5377
|
|
|
5378
|
+
// src/detectors/literalLoop.ts
|
|
5379
|
+
function closeOf(shape, open) {
|
|
5380
|
+
const pairs = { "(": ")", "[": "]", "{": "}" };
|
|
5381
|
+
const want = [];
|
|
5382
|
+
for (let i = open; i < shape.length; i++) {
|
|
5383
|
+
const c = shape[i];
|
|
5384
|
+
if (c in pairs) want.push(pairs[c]);
|
|
5385
|
+
else if (c === ")" || c === "]" || c === "}") {
|
|
5386
|
+
if (want.pop() !== c) return -1;
|
|
5387
|
+
if (want.length === 0) return i;
|
|
5388
|
+
}
|
|
5389
|
+
}
|
|
5390
|
+
return -1;
|
|
5391
|
+
}
|
|
5392
|
+
var esc = (s) => s.replace(/[$]/g, "\\$&");
|
|
5393
|
+
function occurrences(text, name) {
|
|
5394
|
+
return [...text.matchAll(new RegExp(String.raw`(?<![\w$.])${esc(name)}(?![\w$])`, "g"))].map(
|
|
5395
|
+
(m) => m.index ?? 0
|
|
5396
|
+
);
|
|
5397
|
+
}
|
|
5398
|
+
function enclosingLoopList(shape, code, at, id, readAt) {
|
|
5399
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(id)) return void 0;
|
|
5400
|
+
const head = new RegExp(
|
|
5401
|
+
String.raw`for\s*\(\s*const\s+${esc(id)}\s+of\s+([A-Za-z_$][\w$]*)\s*\)`,
|
|
5402
|
+
"g"
|
|
5403
|
+
);
|
|
5404
|
+
let best;
|
|
5405
|
+
for (const m of shape.matchAll(head)) {
|
|
5406
|
+
const start = m.index ?? 0;
|
|
5407
|
+
let i = start + m[0].length;
|
|
5408
|
+
while (i < shape.length && /\s/.test(shape[i])) i++;
|
|
5409
|
+
let end;
|
|
5410
|
+
if (shape[i] === "{") end = closeOf(shape, i);
|
|
5411
|
+
else {
|
|
5412
|
+
end = shape.indexOf(";", i);
|
|
5413
|
+
if (end < 0) end = shape.length;
|
|
5414
|
+
}
|
|
5415
|
+
if (end < 0) continue;
|
|
5416
|
+
if (start < at && at < end && (best === void 0 || start > best.start))
|
|
5417
|
+
best = { start, list: m[1], bodyFrom: i, bodyTo: end };
|
|
5418
|
+
}
|
|
5419
|
+
if (!best) return void 0;
|
|
5420
|
+
for (const o of occurrences(shape.slice(best.bodyFrom, best.bodyTo), id)) {
|
|
5421
|
+
if (!readAt(shape, best.bodyFrom + o)) return void 0;
|
|
5422
|
+
}
|
|
5423
|
+
const declRe = new RegExp(
|
|
5424
|
+
String.raw`(?:export\s+)?const\s+${esc(best.list)}\s*(?::[^=]+)?=\s*\[([^\]]*)\]\s*(?:as\s+const\s*)?;`,
|
|
5425
|
+
"g"
|
|
5426
|
+
);
|
|
5427
|
+
const decls = [...code.matchAll(declRe)];
|
|
5428
|
+
if (decls.length !== 1) return void 0;
|
|
5429
|
+
const nameAt = new RegExp(String.raw`(?<![\w$])${esc(best.list)}(?![\w$])`);
|
|
5430
|
+
const declAt = (decls[0].index ?? 0) + decls[0][0].search(nameAt);
|
|
5431
|
+
for (const o of occurrences(shape, best.list)) {
|
|
5432
|
+
if (o === declAt) continue;
|
|
5433
|
+
const before = shape.slice(Math.max(0, o - 200), o);
|
|
5434
|
+
const after = shape.slice(o + best.list.length);
|
|
5435
|
+
if (/for\s*\(\s*const\s+[A-Za-z_$][\w$]*\s+of\s+$/.test(before) && /^\s*\)/.test(after))
|
|
5436
|
+
continue;
|
|
5437
|
+
return void 0;
|
|
5438
|
+
}
|
|
5439
|
+
const out = [];
|
|
5440
|
+
for (const item of decls[0][1].split(",").map((x) => x.trim()).filter((x) => x !== "")) {
|
|
5441
|
+
const lit = /^(["'`])([^"'`$]*)\1$/.exec(item);
|
|
5442
|
+
if (!lit) return void 0;
|
|
5443
|
+
out.push(lit[2]);
|
|
5444
|
+
}
|
|
5445
|
+
return out.length > 0 ? out : void 0;
|
|
5446
|
+
}
|
|
5447
|
+
|
|
5378
5448
|
// src/detectors/nodeCoreExports.ts
|
|
5379
5449
|
var TABLE = {
|
|
5380
5450
|
http: {
|
|
@@ -5523,7 +5593,7 @@ var lineAt = (m, offset) => {
|
|
|
5523
5593
|
return n;
|
|
5524
5594
|
};
|
|
5525
5595
|
var anchorAt = (s, offset) => `${s.rel}:${lineAt(s.shape, offset)}`;
|
|
5526
|
-
var
|
|
5596
|
+
var esc2 = (s) => s.replace(/[$.*+?^()[\]{}|\\]/g, "\\$&");
|
|
5527
5597
|
var CLOSE = { "(": ")", "[": "]", "{": "}" };
|
|
5528
5598
|
function matchClose(m, open) {
|
|
5529
5599
|
const stack = [];
|
|
@@ -5851,7 +5921,7 @@ function wrapperProof(s, server, mine) {
|
|
|
5851
5921
|
for (const h of mine) {
|
|
5852
5922
|
const after = m.slice(h.at + h.len);
|
|
5853
5923
|
const before = m.slice(0, h.at);
|
|
5854
|
-
const bind = new RegExp(String.raw`^\s*\.\s*bind\s*\(\s*${
|
|
5924
|
+
const bind = new RegExp(String.raw`^\s*\.\s*bind\s*\(\s*${esc2(server)}\s*\)`).exec(after);
|
|
5855
5925
|
const decl = /(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*$/.exec(before);
|
|
5856
5926
|
if (bind && decl) {
|
|
5857
5927
|
nBind++;
|
|
@@ -5907,7 +5977,7 @@ function wrapperProof(s, server, mine) {
|
|
|
5907
5977
|
bEnd = matchClose(m, bStart);
|
|
5908
5978
|
} else return "the function literal has no readable body";
|
|
5909
5979
|
if (bEnd < 0) return "the function body is unbalanced";
|
|
5910
|
-
const idRe = new RegExp(String.raw`(?<![\w$.])${
|
|
5980
|
+
const idRe = new RegExp(String.raw`(?<![\w$.])${esc2(alias)}(?![\w$])`, "g");
|
|
5911
5981
|
const all = [...m.matchAll(idRe)].map((x) => x.index ?? 0);
|
|
5912
5982
|
const inBody = all.filter((i) => i > bStart && i < bEnd);
|
|
5913
5983
|
if (inBody.length !== 1 || all.length !== 2)
|
|
@@ -5934,6 +6004,72 @@ function wrapperProof(s, server, mine) {
|
|
|
5934
6004
|
return `the wrapper does not forward exactly its own parameters (${names.join(", ")}) to \`${alias}\``;
|
|
5935
6005
|
return untouchedParams(s, params, names, bStart, bEnd, argsOpen, argsClose);
|
|
5936
6006
|
}
|
|
6007
|
+
function methodArgumentRead(shape, o) {
|
|
6008
|
+
const before = shape.slice(Math.max(0, o - 80), o);
|
|
6009
|
+
const after = shape.slice(o);
|
|
6010
|
+
return /\.\s*[A-Za-z_$][\w$]*\s*\(\s*$/.test(before) && /^[A-Za-z_$][\w$]*\s*[,)]/.test(after);
|
|
6011
|
+
}
|
|
6012
|
+
function decoratorProof(s, server, mine) {
|
|
6013
|
+
if (mine.some((h) => h.computed)) return "a computed member access";
|
|
6014
|
+
const m = s.shape;
|
|
6015
|
+
let alias;
|
|
6016
|
+
let assign;
|
|
6017
|
+
let nBind = 0;
|
|
6018
|
+
let nAssign = 0;
|
|
6019
|
+
for (const h of mine) {
|
|
6020
|
+
const after = m.slice(h.at + h.len);
|
|
6021
|
+
const before = m.slice(0, h.at);
|
|
6022
|
+
const bind = new RegExp(String.raw`^\s*\.\s*bind\s*\(\s*${esc2(server)}\s*\)`).exec(after);
|
|
6023
|
+
const decl = /(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]+)?=\s*$/.exec(before);
|
|
6024
|
+
if (bind && decl) {
|
|
6025
|
+
nBind++;
|
|
6026
|
+
alias = decl[1];
|
|
6027
|
+
} else if (/^\s*=(?![=>])/.test(after)) {
|
|
6028
|
+
nAssign++;
|
|
6029
|
+
assign = h;
|
|
6030
|
+
} else return "the method is read in a form other than its rebind";
|
|
6031
|
+
}
|
|
6032
|
+
if (nBind !== 1 || alias === void 0 || nAssign !== 1 || assign === void 0)
|
|
6033
|
+
return "no single `.bind(server)` original and single `server.M = <function>`";
|
|
6034
|
+
const rhsAt = assign.at + assign.len + (/^\s*=/.exec(m.slice(assign.at + assign.len))?.[0].length ?? 0);
|
|
6035
|
+
const head = /^[\s(]*(?:async\s+)?(?:function\b\s*[\w$]*\s*)?\(/.exec(m.slice(rhsAt));
|
|
6036
|
+
if (!head) return "the assigned value is not a function literal";
|
|
6037
|
+
const pOpen = rhsAt + head[0].length - 1;
|
|
6038
|
+
const pClose = matchClose(m, pOpen);
|
|
6039
|
+
if (pClose < 0) return "the parameter list is unbalanced";
|
|
6040
|
+
const names = splitList(m, pOpen + 1, pClose).map((p) => /^\s*([A-Za-z_$][\w$]*)/.exec(p)?.[1]);
|
|
6041
|
+
if (names.length < 2 || names.some((n) => n === void 0))
|
|
6042
|
+
return "the parameters are not plain names";
|
|
6043
|
+
const first = names[0];
|
|
6044
|
+
const handler = names[names.length - 1];
|
|
6045
|
+
const tail = m.slice(pClose + 1);
|
|
6046
|
+
const arrow = /^\s*(?::[^=>{]*)?=>\s*\{/.exec(tail);
|
|
6047
|
+
const fnBody = arrow ? void 0 : /^\s*(?::[^{]*)?\{/.exec(tail);
|
|
6048
|
+
const opened = arrow ?? fnBody;
|
|
6049
|
+
if (!opened) return "the function literal has no block body";
|
|
6050
|
+
const bStart = pClose + 1 + opened[0].length - 1;
|
|
6051
|
+
const bEnd = matchClose(m, bStart);
|
|
6052
|
+
if (bEnd < 0) return "the function body is unbalanced";
|
|
6053
|
+
const idRe = new RegExp(String.raw`(?<![\w$.])${esc2(alias)}(?![\w$])`, "g");
|
|
6054
|
+
const all = [...m.matchAll(idRe)].map((x) => x.index ?? 0);
|
|
6055
|
+
const inBody = all.filter((i) => i > bStart && i < bEnd);
|
|
6056
|
+
if (inBody.length !== 1 || all.length !== 2)
|
|
6057
|
+
return `the original \`${alias}\` is referenced ${all.length - 1} time(s) after its binding (once, in the wrapper, is the proof)`;
|
|
6058
|
+
const callOpen = inBody[0] + alias.length + (/^\s*/.exec(m.slice(inBody[0] + alias.length))?.[0].length ?? 0);
|
|
6059
|
+
if (m[callOpen] !== "(") return `the original \`${alias}\` is not called directly`;
|
|
6060
|
+
const callClose = matchClose(m, callOpen);
|
|
6061
|
+
if (callClose < 0) return "the call of the original is unbalanced";
|
|
6062
|
+
const args = splitList(m, callOpen + 1, callClose);
|
|
6063
|
+
const arg0 = (args[0] ?? "").replace(/\s+as\s+[\w$<>[\]|. ]+$/, "").trim();
|
|
6064
|
+
if (arg0 !== first)
|
|
6065
|
+
return `the first parameter \`${first}\` is not forwarded unchanged as the first argument`;
|
|
6066
|
+
const hRe = new RegExp(String.raw`(?<![\w$.])${esc2(handler)}(?![\w$])`, "g");
|
|
6067
|
+
for (const u of m.slice(bStart, bEnd).matchAll(hRe)) {
|
|
6068
|
+
const after = m.slice(bStart + (u.index ?? 0) + handler.length);
|
|
6069
|
+
if (!/^\s*\(/.test(after)) return `the handler \`${handler}\` is used other than as a call`;
|
|
6070
|
+
}
|
|
6071
|
+
return void 0;
|
|
6072
|
+
}
|
|
5937
6073
|
var PRIMITIVE_TYPE = /^(?:(?:string|number|boolean|bigint|symbol|null|undefined|"[^"]*"|'[^']*'|\d+)\s*\|?\s*)+$/;
|
|
5938
6074
|
function enclosingOpens(m, at, lo) {
|
|
5939
6075
|
const out = [];
|
|
@@ -5965,7 +6101,7 @@ function untouchedParams(s, params, names, bStart, bEnd, fwdOpen, fwdClose) {
|
|
|
5965
6101
|
const decl = params[k].replace(/^\.\.\.\s*/, "");
|
|
5966
6102
|
const typed = /^[A-Za-z_$][\w$]*\s*\??\s*:\s*([^=]*?)\s*(?:=(?![=>]).*)?$/s.exec(decl);
|
|
5967
6103
|
const primitive = typed !== void 0 && typed !== null && PRIMITIVE_TYPE.test(typed[1]);
|
|
5968
|
-
const re = new RegExp(String.raw`(?<![\w$.])${
|
|
6104
|
+
const re = new RegExp(String.raw`(?<![\w$.])${esc2(id)}(?![\w$])`, "g");
|
|
5969
6105
|
for (const o of m.slice(bStart, bEnd).matchAll(re)) {
|
|
5970
6106
|
const i = bStart + (o.index ?? 0);
|
|
5971
6107
|
if (i >= fwdOpen && i <= fwdClose) continue;
|
|
@@ -6011,6 +6147,8 @@ function toolRegistrations(tree) {
|
|
|
6011
6147
|
const schema = s.shape.slice(c.args[0][0], c.args[0][1]).trim();
|
|
6012
6148
|
if (/^(?:[\w$]+\.)*[\w$]*RequestSchema$/.test(schema) && !/CallToolRequestSchema$/.test(schema))
|
|
6013
6149
|
continue;
|
|
6150
|
+
const listed = enclosingLoopList(s.shape, s.code, c.args[0][0], schema, methodArgumentRead);
|
|
6151
|
+
if (listed !== void 0 && !listed.includes("tools/call")) continue;
|
|
6014
6152
|
if (!/CallToolRequestSchema$/.test(schema)) {
|
|
6015
6153
|
unread2.push({
|
|
6016
6154
|
anchor: c.anchor,
|
|
@@ -6053,7 +6191,7 @@ function toolRegistrations(tree) {
|
|
|
6053
6191
|
const hits = [];
|
|
6054
6192
|
for (const h of s.shape.matchAll(
|
|
6055
6193
|
new RegExp(
|
|
6056
|
-
String.raw`(?<![\w$])${
|
|
6194
|
+
String.raw`(?<![\w$])${esc2(name)}\s*(?:\.\s*(tool|registerTool|registerToolTask)\b(?!\s*(?:<[^<>()]*>)?\s*\()|\[)`,
|
|
6057
6195
|
"g"
|
|
6058
6196
|
)
|
|
6059
6197
|
)) {
|
|
@@ -6072,8 +6210,9 @@ function toolRegistrations(tree) {
|
|
|
6072
6210
|
for (const method of new Set(live.map((h) => h.method).filter((m) => !!m))) {
|
|
6073
6211
|
const mine = live.filter((h) => h.method === method);
|
|
6074
6212
|
const proof = regs.length === 0 ? "no tool is registered by a direct call anywhere in the tree" : wrapperProof(s, name, mine);
|
|
6075
|
-
|
|
6076
|
-
|
|
6213
|
+
const decorated = proof === void 0 || regs.length === 0 ? proof : decoratorProof(s, name, mine);
|
|
6214
|
+
if (proof === void 0 || decorated === void 0) transparent.add(method);
|
|
6215
|
+
else why.set(method, `${proof}; not a decorator either: ${decorated}`);
|
|
6077
6216
|
}
|
|
6078
6217
|
for (const h of live) {
|
|
6079
6218
|
if (h.method !== void 0 && transparent.has(h.method)) continue;
|
|
@@ -6547,7 +6686,7 @@ function recursiveGroups(s) {
|
|
|
6547
6686
|
const fns = namedFns(s);
|
|
6548
6687
|
const refs = (f, g) => {
|
|
6549
6688
|
const body = s.shape.slice(f.from, f.to);
|
|
6550
|
-
return new RegExp(String.raw`(?<![\w$.])(?:this\s*\.\s*)?${
|
|
6689
|
+
return new RegExp(String.raw`(?<![\w$.])(?:this\s*\.\s*)?${esc2(g.name)}(?![\w$])`).test(body) || new RegExp(String.raw`(?:\.|\?\.)\s*${esc2(g.name)}\s*(?:<[^<>()]*>)?\(`).test(body);
|
|
6551
6690
|
};
|
|
6552
6691
|
const n = fns.length;
|
|
6553
6692
|
const reach = fns.map((f) => fns.map((g) => refs(f, g)));
|
|
@@ -6639,7 +6778,7 @@ function unresolvedCalls(tree, s, from, to, self, skip, upstream) {
|
|
|
6639
6778
|
for (const m of s.shape.matchAll(/\bclass\s+([A-Za-z_$][\w$]*)/g)) local.add(m[1]);
|
|
6640
6779
|
const binds = new Map(importBindings(s).map((b) => [b.local, b]));
|
|
6641
6780
|
const inSkip = (at) => skip.some((g) => at >= g.from && at <= g.to);
|
|
6642
|
-
const selfRe = self ? new RegExp(String.raw`(?<![\w$])${
|
|
6781
|
+
const selfRe = self ? new RegExp(String.raw`(?<![\w$])${esc2(self)}(?![\w$])`) : void 0;
|
|
6643
6782
|
const crossFile = (module, name) => {
|
|
6644
6783
|
const base = module.replace(/\.(?:js|ts|tsx|mjs)$/, "").split("/").pop() ?? "";
|
|
6645
6784
|
for (const d of srcs(tree)) {
|
|
@@ -6658,7 +6797,7 @@ function unresolvedCalls(tree, s, from, to, self, skip, upstream) {
|
|
|
6658
6797
|
if (b !== void 0) return !b.module.startsWith(".");
|
|
6659
6798
|
if (depth > 4 || local.has(root)) return false;
|
|
6660
6799
|
const init = new RegExp(
|
|
6661
|
-
String.raw`(?:const|let|var)\s+${
|
|
6800
|
+
String.raw`(?:const|let|var)\s+${esc2(root)}\s*(?::[^=]+?)?=\s*(?:await\s+)?(?:new\s+)?([A-Za-z_$][\w$]*)`
|
|
6662
6801
|
).exec(s.shape);
|
|
6663
6802
|
return init !== null && init[1] !== root && external(init[1], depth + 1);
|
|
6664
6803
|
};
|
|
@@ -6785,7 +6924,7 @@ function requestingFunctions(tree) {
|
|
|
6785
6924
|
for (let round = 0; round < 6; round++) {
|
|
6786
6925
|
let grew = false;
|
|
6787
6926
|
for (const n of [...names.keys()]) {
|
|
6788
|
-
for (const c of callsMatching(tree, new RegExp(String.raw`^(?:[\w$]+\.)*${
|
|
6927
|
+
for (const c of callsMatching(tree, new RegExp(String.raw`^(?:[\w$]+\.)*${esc2(n)}$`))) {
|
|
6789
6928
|
if (!callReaches(c.src, c.callee, n, names.get(n))) continue;
|
|
6790
6929
|
for (const f of enclosingFns(c.src, c.start)) if (f.name && add(f.name, c.src)) grew = true;
|
|
6791
6930
|
}
|
|
@@ -6798,7 +6937,7 @@ function callReaches(s, callee, name, defs) {
|
|
|
6798
6937
|
if (callee.includes(".")) return true;
|
|
6799
6938
|
if (defs.has(s)) return true;
|
|
6800
6939
|
for (const h of s.code.matchAll(/import\s*(?:type\s*)?\{([^}]*)\}\s*from\s*["']([^"']+)["']/g)) {
|
|
6801
|
-
if (!new RegExp(String.raw`(?<![\w$])${
|
|
6940
|
+
if (!new RegExp(String.raw`(?<![\w$])${esc2(name)}(?![\w$])`).test(h[1])) continue;
|
|
6802
6941
|
const base = h[2].replace(/\.(?:js|ts|tsx|mjs)$/, "").split("/").pop() ?? "";
|
|
6803
6942
|
for (const d of defs)
|
|
6804
6943
|
if ((d.rel.replace(/\.(?:js|ts|tsx|mjs)$/, "").split("/").pop() ?? "") === base)
|
|
@@ -6811,7 +6950,7 @@ function callsRequester(tree, s, from, to) {
|
|
|
6811
6950
|
const text = s.shape.slice(from, to);
|
|
6812
6951
|
for (const [n, defs] of reqs) {
|
|
6813
6952
|
for (const h of text.matchAll(
|
|
6814
|
-
new RegExp(String.raw`(?<![\w$])((?:[\w$]+\s*\.\s*)*)${
|
|
6953
|
+
new RegExp(String.raw`(?<![\w$])((?:[\w$]+\s*\.\s*)*)${esc2(n)}\s*\(`, "g")
|
|
6815
6954
|
)) {
|
|
6816
6955
|
if (callReaches(s, h[1] ? `${h[1]}${n}`.replace(/\s+/g, "") : n, n, defs)) return true;
|
|
6817
6956
|
}
|
|
@@ -6819,7 +6958,7 @@ function callsRequester(tree, s, from, to) {
|
|
|
6819
6958
|
return false;
|
|
6820
6959
|
}
|
|
6821
6960
|
function bodyOfNamed(s, name) {
|
|
6822
|
-
const n =
|
|
6961
|
+
const n = esc2(name);
|
|
6823
6962
|
const re = new RegExp(
|
|
6824
6963
|
String.raw`(?:\bfunction\s*\*?\s*${n}\s*\(|(?:const|let|var)\s+${n}\s*(?::[^=]+)?=\s*(?:async\s*)?(?:function\s*)?\(|(?:^|[\n;{},])\s*(?:async\s+)?${n}\s*\()`
|
|
6825
6964
|
);
|
|
@@ -9891,8 +10030,8 @@ var RECORD_LINE_RE = /^[\s>*_\-+]*Provenance\s*:\s*(.*)$/i;
|
|
|
9891
10030
|
var SHASUM_HEX_RE = /\bshasum\b[^\n]*?\b([0-9a-f]{40})\b/i;
|
|
9892
10031
|
function judgeProvenanceRecord(line, name, version) {
|
|
9893
10032
|
const body = line.match(RECORD_LINE_RE)?.[1] ?? "";
|
|
9894
|
-
const
|
|
9895
|
-
const named = new RegExp(`(?:^|[\\s(])${
|
|
10033
|
+
const esc5 = (x) => x.replace(/[.+*?^$()[\]{}|\\/]/g, "\\$&");
|
|
10034
|
+
const named = new RegExp(`(?:^|[\\s(])${esc5(name)}@v?${esc5(version)}(?![\\w.-]*\\d)`);
|
|
9896
10035
|
if (!named.test(body)) {
|
|
9897
10036
|
return { ok: false, why: `it does not name ${name}@${version}, the artifact being published` };
|
|
9898
10037
|
}
|
|
@@ -10353,6 +10492,94 @@ function runtimeSourceRoot(runtime) {
|
|
|
10353
10492
|
return runtime.remote ? runtime.sourceRoot : runtime.root;
|
|
10354
10493
|
}
|
|
10355
10494
|
|
|
10495
|
+
// src/detectors/i18nKeys.ts
|
|
10496
|
+
import { existsSync as existsSync7, readFileSync as readFileSync8 } from "fs";
|
|
10497
|
+
import { dirname as dirname4, join as join8, resolve as resolve2 } from "path";
|
|
10498
|
+
var CALL_RE = /^([A-Za-z_$][\w$]*)\(\s*(["'`])([A-Za-z-]+)\2\s*,\s*(["'`])([\w.-]+)\4\s*(?:,[\s\S]*)?\)$/;
|
|
10499
|
+
function leadingCall(expr) {
|
|
10500
|
+
const head = expr.match(/^[A-Za-z_$][\w$]*\(/);
|
|
10501
|
+
if (!head) return null;
|
|
10502
|
+
let depth = 0;
|
|
10503
|
+
let quote = null;
|
|
10504
|
+
for (let i = head[0].length - 1; i < expr.length; i++) {
|
|
10505
|
+
const c = expr[i];
|
|
10506
|
+
if (quote) {
|
|
10507
|
+
if (c === "\\") i++;
|
|
10508
|
+
else if (c === quote) quote = null;
|
|
10509
|
+
continue;
|
|
10510
|
+
}
|
|
10511
|
+
if (c === '"' || c === "'" || c === "`") quote = c;
|
|
10512
|
+
else if (c === "(") depth++;
|
|
10513
|
+
else if (c === ")" && --depth === 0) return expr.slice(0, i + 1);
|
|
10514
|
+
}
|
|
10515
|
+
return null;
|
|
10516
|
+
}
|
|
10517
|
+
var LOCALES_PATH_RE = /locales\/(?:\$\{[^}]+\}|[A-Za-z-]+)\.json/;
|
|
10518
|
+
function importedModule(file, fn) {
|
|
10519
|
+
const text = file.lines.map((l) => l.raw).join("\n");
|
|
10520
|
+
const re = /import\s*\{([^}]*)\}\s*from\s*["'](\.{1,2}\/[^"']+)["']/g;
|
|
10521
|
+
for (const m of text.matchAll(re)) {
|
|
10522
|
+
const names = m[1].split(",").map((s) => s.trim().replace(/^type\s+/, ""));
|
|
10523
|
+
const local = names.map(
|
|
10524
|
+
(n) => n.split(/\s+as\s+/).pop()?.trim()
|
|
10525
|
+
);
|
|
10526
|
+
if (!local.includes(fn)) continue;
|
|
10527
|
+
const spec = m[2];
|
|
10528
|
+
const base = resolve2(dirname4(file.path), spec);
|
|
10529
|
+
for (const candidate of [
|
|
10530
|
+
base.replace(/\.js$/, ".ts"),
|
|
10531
|
+
base,
|
|
10532
|
+
`${base}.ts`,
|
|
10533
|
+
join8(base, "index.ts")
|
|
10534
|
+
]) {
|
|
10535
|
+
if (existsSync7(candidate) && !candidate.endsWith("/")) return candidate;
|
|
10536
|
+
}
|
|
10537
|
+
return null;
|
|
10538
|
+
}
|
|
10539
|
+
return null;
|
|
10540
|
+
}
|
|
10541
|
+
function readI18nCall(tree, file, expr) {
|
|
10542
|
+
const call = leadingCall(expr.trim());
|
|
10543
|
+
const m = call?.match(CALL_RE);
|
|
10544
|
+
if (!m) return null;
|
|
10545
|
+
const [, fn, , locale, , key] = m;
|
|
10546
|
+
const mod = importedModule(file, fn);
|
|
10547
|
+
if (mod === null)
|
|
10548
|
+
return {
|
|
10549
|
+
kind: "unresolved",
|
|
10550
|
+
why: `\`${fn}\` is not imported from a relative module of the tree`
|
|
10551
|
+
};
|
|
10552
|
+
let modText;
|
|
10553
|
+
try {
|
|
10554
|
+
modText = readFileSync8(mod, "utf8");
|
|
10555
|
+
} catch {
|
|
10556
|
+
return { kind: "unresolved", why: `the module of \`${fn}\` (${mod}) is unreadable` };
|
|
10557
|
+
}
|
|
10558
|
+
if (!LOCALES_PATH_RE.test(modText))
|
|
10559
|
+
return {
|
|
10560
|
+
kind: "unresolved",
|
|
10561
|
+
why: `the module of \`${fn}\` names no \`locales/<locale>.json\` resource path`
|
|
10562
|
+
};
|
|
10563
|
+
const jsonPath = join8(dirname4(mod), "locales", `${locale}.json`);
|
|
10564
|
+
const shown = jsonPath.startsWith(tree.root) ? jsonPath.slice(tree.root.length + 1) : jsonPath;
|
|
10565
|
+
let data;
|
|
10566
|
+
try {
|
|
10567
|
+
data = JSON.parse(readFileSync8(jsonPath, "utf8"));
|
|
10568
|
+
} catch {
|
|
10569
|
+
return { kind: "unresolved", why: `${shown} is missing or not JSON` };
|
|
10570
|
+
}
|
|
10571
|
+
let node = data;
|
|
10572
|
+
for (const part of key.split(".")) {
|
|
10573
|
+
node = node && typeof node === "object" ? node[part] : void 0;
|
|
10574
|
+
}
|
|
10575
|
+
if (typeof node !== "string" || node.trim().length === 0)
|
|
10576
|
+
return {
|
|
10577
|
+
kind: "unresolved",
|
|
10578
|
+
why: `key \`${key}\` does not resolve to a non-empty string in ${shown}`
|
|
10579
|
+
};
|
|
10580
|
+
return { kind: "text", text: node, source: `${shown}#${key}`, locale };
|
|
10581
|
+
}
|
|
10582
|
+
|
|
10356
10583
|
// src/detectors/c19-served-descriptions.ts
|
|
10357
10584
|
var PIN6 = STANDARD_PIN;
|
|
10358
10585
|
var TOOL_DESC_INLINE_RE = /\b(?:s\.tool|\.tool|registerTool)\s*\(\s*(?:["'`][^"'`]+["'`]|[A-Za-z_$][\w$]*)\s*,\s*["'`]([^"'`]+)["'`]/;
|
|
@@ -10393,7 +10620,12 @@ function findInlineDescription(tree, siteAnchor, toolName) {
|
|
|
10393
10620
|
const v = readDescriptionValue(`${after}
|
|
10394
10621
|
${tail}`);
|
|
10395
10622
|
if (v.kind === "literal" && v.text.length > 0) return v.text;
|
|
10396
|
-
if (v.kind === "non-literal"
|
|
10623
|
+
if (v.kind === "non-literal") {
|
|
10624
|
+
const i18n = readI18nCall(tree, file, v.expr);
|
|
10625
|
+
if (i18n?.kind === "text") return i18n.text;
|
|
10626
|
+
const marked = i18n?.kind === "unresolved" ? { ...v, expr: `${v.expr} (${i18n.why})` } : v;
|
|
10627
|
+
if (!nonLiteral) nonLiteral = marked;
|
|
10628
|
+
}
|
|
10397
10629
|
continue;
|
|
10398
10630
|
}
|
|
10399
10631
|
if (n >= siteLine) {
|
|
@@ -10743,8 +10975,8 @@ var c21ProgressiveDisclosure = {
|
|
|
10743
10975
|
};
|
|
10744
10976
|
|
|
10745
10977
|
// src/detectors/c22-test-ratio-gate.ts
|
|
10746
|
-
import { existsSync as
|
|
10747
|
-
import { join as
|
|
10978
|
+
import { existsSync as existsSync8, readFileSync as readFileSync9, statSync as statSync9 } from "fs";
|
|
10979
|
+
import { join as join9 } from "path";
|
|
10748
10980
|
var DOC_FILES2 = ["README.md", "README.fr.md", "CHANGELOG.md"];
|
|
10749
10981
|
var RATIO_RE = /\b(?:coverage|ratio de tests?|test ratio|couverture)\b[^\n%]{0,40}?(\d{1,3}(?:\.\d+)?\s?%)/i;
|
|
10750
10982
|
var IDENTIFIER_RE = /\b(?:run[/#]?\s?\d+|workflow run|gh run|actions\/runs\/\d+|CI#\d+|\b[0-9a-f]{7,40}\b)/i;
|
|
@@ -10769,15 +11001,15 @@ function c22PositiveControls() {
|
|
|
10769
11001
|
function findRatioCitations(root, unreadable) {
|
|
10770
11002
|
const hits = [];
|
|
10771
11003
|
for (const name of DOC_FILES2) {
|
|
10772
|
-
const path =
|
|
10773
|
-
if (!
|
|
11004
|
+
const path = join9(root, name);
|
|
11005
|
+
if (!existsSync8(path)) continue;
|
|
10774
11006
|
let text;
|
|
10775
11007
|
try {
|
|
10776
11008
|
if (!statSync9(path).isFile()) {
|
|
10777
11009
|
unreadable.push({ anchor: name, reason: `${name} is not a regular file \u2014 not read` });
|
|
10778
11010
|
continue;
|
|
10779
11011
|
}
|
|
10780
|
-
text =
|
|
11012
|
+
text = readFileSync9(path, "utf8");
|
|
10781
11013
|
} catch (err) {
|
|
10782
11014
|
unreadable.push({ anchor: name, reason: `${name} could not be read (${fsErrorCode(err)})` });
|
|
10783
11015
|
continue;
|
|
@@ -11335,16 +11567,16 @@ var c25BuildIdentity = {
|
|
|
11335
11567
|
// src/detectors/c26-subpackage-lockfile.ts
|
|
11336
11568
|
import { spawnSync } from "child_process";
|
|
11337
11569
|
import {
|
|
11338
|
-
existsSync as
|
|
11570
|
+
existsSync as existsSync9,
|
|
11339
11571
|
mkdtempSync,
|
|
11340
|
-
readFileSync as
|
|
11572
|
+
readFileSync as readFileSync10,
|
|
11341
11573
|
readdirSync as readdirSync6,
|
|
11342
11574
|
rmSync,
|
|
11343
11575
|
statSync as statSync10,
|
|
11344
11576
|
writeFileSync
|
|
11345
11577
|
} from "fs";
|
|
11346
11578
|
import { tmpdir } from "os";
|
|
11347
|
-
import { basename as basename2, join as
|
|
11579
|
+
import { basename as basename2, join as join10, relative as relative5, sep as sep4 } from "path";
|
|
11348
11580
|
var PIN9 = STANDARD_PIN;
|
|
11349
11581
|
var DEPLOY_CONFIG_FILES = [
|
|
11350
11582
|
"railway.json",
|
|
@@ -11371,7 +11603,7 @@ function walkForConfigs(dir, depth, seen, onSkip) {
|
|
|
11371
11603
|
return;
|
|
11372
11604
|
}
|
|
11373
11605
|
for (const name of entries) {
|
|
11374
|
-
const full =
|
|
11606
|
+
const full = join10(dir, name);
|
|
11375
11607
|
let st;
|
|
11376
11608
|
try {
|
|
11377
11609
|
st = statSync10(full);
|
|
@@ -11406,7 +11638,7 @@ function probeForCandidate(dir, depth) {
|
|
|
11406
11638
|
}
|
|
11407
11639
|
const subdirs = [];
|
|
11408
11640
|
for (const name of entries) {
|
|
11409
|
-
const full =
|
|
11641
|
+
const full = join10(dir, name);
|
|
11410
11642
|
let st;
|
|
11411
11643
|
try {
|
|
11412
11644
|
st = statSync10(full);
|
|
@@ -11430,7 +11662,7 @@ function probeForCandidate(dir, depth) {
|
|
|
11430
11662
|
function resolveRailwayRootDirectory(configPath) {
|
|
11431
11663
|
let text;
|
|
11432
11664
|
try {
|
|
11433
|
-
text =
|
|
11665
|
+
text = readFileSync10(configPath, "utf8");
|
|
11434
11666
|
} catch (err) {
|
|
11435
11667
|
return {
|
|
11436
11668
|
error: `could not read ${configPath}: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -11475,13 +11707,13 @@ function c26DeriveScope(root, tree) {
|
|
|
11475
11707
|
};
|
|
11476
11708
|
}
|
|
11477
11709
|
if (typeof resolved === "string" && resolved.trim()) {
|
|
11478
|
-
sites.push({ ...site, dir:
|
|
11710
|
+
sites.push({ ...site, dir: join10(site.dir, resolved) });
|
|
11479
11711
|
continue;
|
|
11480
11712
|
}
|
|
11481
11713
|
}
|
|
11482
11714
|
if (site.configFile === "vercel.json") {
|
|
11483
11715
|
try {
|
|
11484
|
-
JSON.parse(
|
|
11716
|
+
JSON.parse(readFileSync10(site.configPath, "utf8"));
|
|
11485
11717
|
} catch (err) {
|
|
11486
11718
|
return {
|
|
11487
11719
|
sites: [],
|
|
@@ -11499,7 +11731,7 @@ function c26DeriveScope(root, tree) {
|
|
|
11499
11731
|
}
|
|
11500
11732
|
function findLockfile2(dir) {
|
|
11501
11733
|
for (const l of LOCKFILES2) {
|
|
11502
|
-
if (
|
|
11734
|
+
if (existsSync9(join10(dir, l.name))) return l;
|
|
11503
11735
|
}
|
|
11504
11736
|
return null;
|
|
11505
11737
|
}
|
|
@@ -11550,8 +11782,8 @@ function nameDrift(lockfileName, siteDir, isolatedDir, stderr) {
|
|
|
11550
11782
|
}
|
|
11551
11783
|
if (lockfileName === "bun.lock" || lockfileName === "bun.lockb") {
|
|
11552
11784
|
try {
|
|
11553
|
-
const manifestText =
|
|
11554
|
-
const lockText =
|
|
11785
|
+
const manifestText = readFileSync10(join10(isolatedDir, "package.json"), "utf8");
|
|
11786
|
+
const lockText = readFileSync10(join10(isolatedDir, lockfileName), "utf8");
|
|
11555
11787
|
const drifted = nameBunDrift(manifestText, lockText);
|
|
11556
11788
|
if (drifted.length > 0) return drifted.join(", ");
|
|
11557
11789
|
} catch {
|
|
@@ -11563,8 +11795,8 @@ function nameDrift(lockfileName, siteDir, isolatedDir, stderr) {
|
|
|
11563
11795
|
return `dependency name not statically extractable from this manager's output at ${siteDir} \u2014 raw: ${stderr.slice(0, 300).trim()}`;
|
|
11564
11796
|
}
|
|
11565
11797
|
function gateSite(site) {
|
|
11566
|
-
const pkgPath =
|
|
11567
|
-
if (!
|
|
11798
|
+
const pkgPath = join10(site.dir, "package.json");
|
|
11799
|
+
if (!existsSync9(pkgPath)) {
|
|
11568
11800
|
return {
|
|
11569
11801
|
site,
|
|
11570
11802
|
status: "skipped",
|
|
@@ -11580,17 +11812,17 @@ function gateSite(site) {
|
|
|
11580
11812
|
detail: `no lockfile (${LOCKFILES2.map((l) => l.name).join("/")}) present at ${site.dir} while its deployment (${site.configFile}) requires one`
|
|
11581
11813
|
};
|
|
11582
11814
|
}
|
|
11583
|
-
const isolated = mkdtempSync(
|
|
11815
|
+
const isolated = mkdtempSync(join10(tmpdir(), "mcp-doctor-c26-"));
|
|
11584
11816
|
try {
|
|
11585
11817
|
let manifestText;
|
|
11586
11818
|
let lockText;
|
|
11587
|
-
const lockPath =
|
|
11819
|
+
const lockPath = join10(site.dir, lock.name);
|
|
11588
11820
|
try {
|
|
11589
11821
|
for (const p of [pkgPath, lockPath]) {
|
|
11590
11822
|
if (!statSync10(p).isFile()) throw new Error(`${p} is not a regular file`);
|
|
11591
11823
|
}
|
|
11592
|
-
manifestText =
|
|
11593
|
-
lockText =
|
|
11824
|
+
manifestText = readFileSync10(pkgPath, "utf8");
|
|
11825
|
+
lockText = readFileSync10(lockPath, "utf8");
|
|
11594
11826
|
} catch (err) {
|
|
11595
11827
|
return {
|
|
11596
11828
|
site,
|
|
@@ -11598,8 +11830,8 @@ function gateSite(site) {
|
|
|
11598
11830
|
reason: `${site.dir}: package.json or ${lock.name} is present but cannot be read (${err instanceof Error ? err.message : String(err)}) \u2014 the frozen install was not run`
|
|
11599
11831
|
};
|
|
11600
11832
|
}
|
|
11601
|
-
writeFileSync(
|
|
11602
|
-
writeFileSync(
|
|
11833
|
+
writeFileSync(join10(isolated, "package.json"), manifestText);
|
|
11834
|
+
writeFileSync(join10(isolated, lock.name), lockText);
|
|
11603
11835
|
let proc;
|
|
11604
11836
|
try {
|
|
11605
11837
|
proc = spawnSync(lock.command, lock.args, {
|
|
@@ -11673,7 +11905,7 @@ var c26SubpackageLockfile = {
|
|
|
11673
11905
|
const reason = `${prefix}deployment configuration found only under skipped director${hidden.length === 1 ? "y" : "ies"}: ${hidden.map((d) => `${d.path} (${d.reason}) -> ${d.candidate}`).join("; ")} \u2014 C-26 does not descend into skipped directories, so these site(s) were not judged`;
|
|
11674
11906
|
return {
|
|
11675
11907
|
id: this.id,
|
|
11676
|
-
anchor:
|
|
11908
|
+
anchor: join10(tree.root, hidden[0].candidate),
|
|
11677
11909
|
state: "could-not-judge",
|
|
11678
11910
|
reason,
|
|
11679
11911
|
verdict: `could not judge: ${reason}`
|
|
@@ -11745,8 +11977,8 @@ var c26SubpackageLockfile = {
|
|
|
11745
11977
|
};
|
|
11746
11978
|
|
|
11747
11979
|
// src/detectors/c27-subpackage-types.ts
|
|
11748
|
-
import { existsSync as
|
|
11749
|
-
import { join as
|
|
11980
|
+
import { existsSync as existsSync10, readdirSync as readdirSync7 } from "fs";
|
|
11981
|
+
import { join as join11, relative as relative6 } from "path";
|
|
11750
11982
|
var TSCONFIG_RE = /^tsconfig(?:\..+)?\.json$/;
|
|
11751
11983
|
var FROZEN_RE = /\bnpm\s+ci\b|\b(?:bun|pnpm|yarn)\s+(?:install|i)\b[^\n]*--frozen-lockfile|\byarn\s+install\b[^\n]*--immutable|\bbun\s+ci\b/;
|
|
11752
11984
|
var INSTALL_RE2 = /\b(?:npm\s+(?:install|i)|(?:bun|pnpm|yarn)\s+(?:install|i|add))\b/;
|
|
@@ -11855,14 +12087,14 @@ var c27SubpackageTypes = {
|
|
|
11855
12087
|
for (const site of tsSites) {
|
|
11856
12088
|
const siteRel = relative6(base, site.dir) || ".";
|
|
11857
12089
|
const docs = [];
|
|
11858
|
-
const dockerfile =
|
|
11859
|
-
if (
|
|
12090
|
+
const dockerfile = join11(site.dir, "Dockerfile");
|
|
12091
|
+
if (existsSync10(dockerfile)) {
|
|
11860
12092
|
const text = readText(dockerfile);
|
|
11861
12093
|
if (text === null) unreadDocs.push(`${siteRel}/Dockerfile`);
|
|
11862
12094
|
else docs.push({ where: `${siteRel}/Dockerfile`, segments: dockerSegments(text) });
|
|
11863
12095
|
}
|
|
11864
|
-
const railway =
|
|
11865
|
-
if (
|
|
12096
|
+
const railway = join11(site.dir, "railway.json");
|
|
12097
|
+
if (existsSync10(railway)) {
|
|
11866
12098
|
const text = readText(railway);
|
|
11867
12099
|
if (text === null) unreadDocs.push(`${siteRel}/railway.json`);
|
|
11868
12100
|
else docs.push({ where: `${siteRel}/railway.json`, segments: railwayBuildCommand(text) });
|
|
@@ -12130,8 +12362,8 @@ var c30SkillsOrgBound = {
|
|
|
12130
12362
|
};
|
|
12131
12363
|
|
|
12132
12364
|
// src/detectors/c31-plugin-installable.ts
|
|
12133
|
-
import { existsSync as
|
|
12134
|
-
import { basename as basename3, dirname as
|
|
12365
|
+
import { existsSync as existsSync11, readdirSync as readdirSync8, statSync as statSync11 } from "fs";
|
|
12366
|
+
import { basename as basename3, dirname as dirname5, join as join12, relative as relative8, sep as sep5 } from "path";
|
|
12135
12367
|
var MIN_README_WORDS = 40;
|
|
12136
12368
|
var KEBAB_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
12137
12369
|
var EXACT_VERSION_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?$/;
|
|
@@ -12316,7 +12548,7 @@ function judgeFolder(tree, folder, manifestPath2, out) {
|
|
|
12316
12548
|
text: `plugin.json \`name\` ${typeof name === "string" ? `"${name}"` : "is absent"} is not kebab-case`
|
|
12317
12549
|
});
|
|
12318
12550
|
}
|
|
12319
|
-
const pkgPath =
|
|
12551
|
+
const pkgPath = existsSync11(join12(folder, "package.json")) ? join12(folder, "package.json") : existsSync11(join12(tree.root, "package.json")) ? join12(tree.root, "package.json") : null;
|
|
12320
12552
|
const pkg = pkgPath ? readJsonRecord(pkgPath) : null;
|
|
12321
12553
|
if (!pkg || typeof pkg.version !== "string") {
|
|
12322
12554
|
out.unreadable.push({
|
|
@@ -12347,9 +12579,9 @@ function judgeFolder(tree, folder, manifestPath2, out) {
|
|
|
12347
12579
|
text: "no licence: plugin.json has no `license` and the folder has no LICENSE file"
|
|
12348
12580
|
});
|
|
12349
12581
|
}
|
|
12350
|
-
const readmePath =
|
|
12582
|
+
const readmePath = join12(folder, "README.md");
|
|
12351
12583
|
const readme = readText(readmePath);
|
|
12352
|
-
if (readme === null &&
|
|
12584
|
+
if (readme === null && existsSync11(readmePath)) {
|
|
12353
12585
|
out.unreadable.push({
|
|
12354
12586
|
anchor: rel(readmePath),
|
|
12355
12587
|
reason: `${rel(readmePath)} is present but cannot be read as text (permission, or not a regular file) \u2014 its length and credential content are unread`
|
|
@@ -12378,13 +12610,13 @@ function judgeFolder(tree, folder, manifestPath2, out) {
|
|
|
12378
12610
|
}
|
|
12379
12611
|
}
|
|
12380
12612
|
let servers = null;
|
|
12381
|
-
let mcpAnchor = rel(
|
|
12613
|
+
let mcpAnchor = rel(join12(folder, ".mcp.json"));
|
|
12382
12614
|
const inline = manifest.mcpServers;
|
|
12383
12615
|
if (isRecord(inline)) {
|
|
12384
12616
|
servers = inline;
|
|
12385
12617
|
mcpAnchor = a;
|
|
12386
12618
|
} else if (typeof inline === "string") {
|
|
12387
|
-
const target =
|
|
12619
|
+
const target = join12(folder, inline);
|
|
12388
12620
|
const j = readJsonRecord(target);
|
|
12389
12621
|
mcpAnchor = rel(target);
|
|
12390
12622
|
if (j) servers = isRecord(j.mcpServers) ? j.mcpServers : j;
|
|
@@ -12393,8 +12625,8 @@ function judgeFolder(tree, folder, manifestPath2, out) {
|
|
|
12393
12625
|
anchor: mcpAnchor,
|
|
12394
12626
|
reason: `${mcpAnchor} (named by plugin.json mcpServers) is not a parseable JSON object`
|
|
12395
12627
|
});
|
|
12396
|
-
} else if (
|
|
12397
|
-
const j = readJsonRecord(
|
|
12628
|
+
} else if (existsSync11(join12(folder, ".mcp.json"))) {
|
|
12629
|
+
const j = readJsonRecord(join12(folder, ".mcp.json"));
|
|
12398
12630
|
if (j) servers = isRecord(j.mcpServers) ? j.mcpServers : j;
|
|
12399
12631
|
else
|
|
12400
12632
|
out.unreadable.push({
|
|
@@ -12414,9 +12646,9 @@ function judgeFolder(tree, folder, manifestPath2, out) {
|
|
|
12414
12646
|
judgeServers(servers, mcpAnchor, out);
|
|
12415
12647
|
}
|
|
12416
12648
|
try {
|
|
12417
|
-
if (statSync11(
|
|
12649
|
+
if (statSync11(join12(folder, "bin")).isDirectory()) {
|
|
12418
12650
|
out.reds.push({
|
|
12419
|
-
anchor: rel(
|
|
12651
|
+
anchor: rel(join12(folder, "bin")),
|
|
12420
12652
|
text: "a top-level bin/ directory (a plugin ships no bin/ at its top level)"
|
|
12421
12653
|
});
|
|
12422
12654
|
}
|
|
@@ -12424,8 +12656,8 @@ function judgeFolder(tree, folder, manifestPath2, out) {
|
|
|
12424
12656
|
const code = fsErrorCode(err);
|
|
12425
12657
|
if (code !== "ENOENT" && code !== "ENOTDIR") {
|
|
12426
12658
|
out.unreadable.push({
|
|
12427
|
-
anchor: rel(
|
|
12428
|
-
reason: `${rel(
|
|
12659
|
+
anchor: rel(join12(folder, "bin")),
|
|
12660
|
+
reason: `${rel(join12(folder, "bin"))} could not be probed (${code}) \u2014 whether the plugin ships a top-level bin/ is unread`
|
|
12429
12661
|
});
|
|
12430
12662
|
}
|
|
12431
12663
|
}
|
|
@@ -12469,7 +12701,7 @@ var c31PluginInstallable = {
|
|
|
12469
12701
|
);
|
|
12470
12702
|
}
|
|
12471
12703
|
const out = { reds: [], unreadable: [...refusedManifests] };
|
|
12472
|
-
for (const m of manifests) judgeFolder(tree,
|
|
12704
|
+
for (const m of manifests) judgeFolder(tree, dirname5(dirname5(m.path)), m.path, out);
|
|
12473
12705
|
const anchor = manifests[0].rel;
|
|
12474
12706
|
if (out.reds.length > 0) {
|
|
12475
12707
|
const shown = out.reds.slice(0, 6).map((r) => r.text).join("; ");
|
|
@@ -13359,10 +13591,10 @@ var RESULT_PAYLOAD_KEYS = [
|
|
|
13359
13591
|
var RESULT_ANCHOR_KEYS = ["content", "structuredContent", "resultType"];
|
|
13360
13592
|
function baseIsResult(file, base, tree) {
|
|
13361
13593
|
if (!base) return false;
|
|
13362
|
-
const
|
|
13594
|
+
const esc5 = base.replace(/[$]/g, "\\$&");
|
|
13363
13595
|
const keys = RESULT_PAYLOAD_KEYS.join("|");
|
|
13364
13596
|
const assigned = new RegExp(
|
|
13365
|
-
`\\b${
|
|
13597
|
+
`\\b${esc5}\\s*(?:\\.\\s*(?:${keys})|\\[\\s*["'](?:${keys})["']\\s*\\])\\s*=(?![=>])`
|
|
13366
13598
|
);
|
|
13367
13599
|
if (file.lines.some((l) => !l.comment && assigned.test(l.raw))) return true;
|
|
13368
13600
|
const one = { ...tree, files: [file] };
|
|
@@ -13511,8 +13743,8 @@ var d7Inner = {
|
|
|
13511
13743
|
var d7 = guardUnreadablePackageJson(d7Inner, { authoritative: true });
|
|
13512
13744
|
|
|
13513
13745
|
// src/detectors/d8.ts
|
|
13514
|
-
import { existsSync as
|
|
13515
|
-
import { dirname as
|
|
13746
|
+
import { existsSync as existsSync12, statSync as statSync12 } from "fs";
|
|
13747
|
+
import { dirname as dirname6, join as join13, relative as relative9 } from "path";
|
|
13516
13748
|
var POSITIVE_CONTROL2 = 'server.registerTool("list_items", { ... }, handler);';
|
|
13517
13749
|
function d8PositiveControl() {
|
|
13518
13750
|
return {
|
|
@@ -13522,9 +13754,9 @@ function d8PositiveControl() {
|
|
|
13522
13754
|
};
|
|
13523
13755
|
}
|
|
13524
13756
|
function resolveBaseDir(tree) {
|
|
13525
|
-
if (tree.packageJson) return
|
|
13757
|
+
if (tree.packageJson) return dirname6(tree.packageJson.path);
|
|
13526
13758
|
try {
|
|
13527
|
-
return statSync12(tree.root).isDirectory() ? tree.root :
|
|
13759
|
+
return statSync12(tree.root).isDirectory() ? tree.root : dirname6(tree.root);
|
|
13528
13760
|
} catch {
|
|
13529
13761
|
return tree.root;
|
|
13530
13762
|
}
|
|
@@ -13532,9 +13764,9 @@ function resolveBaseDir(tree) {
|
|
|
13532
13764
|
function findEvalsFile(tree) {
|
|
13533
13765
|
let dir = resolveBaseDir(tree);
|
|
13534
13766
|
for (let depth = 0; depth < 8; depth++) {
|
|
13535
|
-
const candidate =
|
|
13536
|
-
if (
|
|
13537
|
-
const parent =
|
|
13767
|
+
const candidate = join13(dir, "evals", "evals.json");
|
|
13768
|
+
if (existsSync12(candidate)) return candidate;
|
|
13769
|
+
const parent = dirname6(dir);
|
|
13538
13770
|
if (parent === dir) break;
|
|
13539
13771
|
dir = parent;
|
|
13540
13772
|
}
|
|
@@ -13685,8 +13917,8 @@ var d8 = {
|
|
|
13685
13917
|
};
|
|
13686
13918
|
|
|
13687
13919
|
// src/detectors/d9.ts
|
|
13688
|
-
import { existsSync as
|
|
13689
|
-
import { dirname as
|
|
13920
|
+
import { existsSync as existsSync13 } from "fs";
|
|
13921
|
+
import { dirname as dirname7, join as join14 } from "path";
|
|
13690
13922
|
var SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
13691
13923
|
var POSITIVE_CONTROL3 = "1.2.3-beta.1+build.7";
|
|
13692
13924
|
function d9PositiveControl() {
|
|
@@ -13734,9 +13966,9 @@ var d9Inner = {
|
|
|
13734
13966
|
verdict: `no "version" field in ${pkgPath.split("/").pop()} -> set a valid SemVer version`
|
|
13735
13967
|
};
|
|
13736
13968
|
}
|
|
13737
|
-
const projectDir =
|
|
13738
|
-
const changelogPath =
|
|
13739
|
-
const hasChangelog =
|
|
13969
|
+
const projectDir = dirname7(pkgPath);
|
|
13970
|
+
const changelogPath = join14(projectDir, "CHANGELOG.md");
|
|
13971
|
+
const hasChangelog = existsSync13(changelogPath);
|
|
13740
13972
|
const validSemver = SEMVER_RE.test(version);
|
|
13741
13973
|
if (validSemver && hasChangelog) {
|
|
13742
13974
|
return {
|
|
@@ -13765,8 +13997,8 @@ var d9Inner = {
|
|
|
13765
13997
|
var d9 = guardUnreadablePackageJson(d9Inner, { authoritative: false });
|
|
13766
13998
|
|
|
13767
13999
|
// src/detectors/d10.ts
|
|
13768
|
-
import { existsSync as
|
|
13769
|
-
import { dirname as
|
|
14000
|
+
import { existsSync as existsSync14 } from "fs";
|
|
14001
|
+
import { dirname as dirname8, join as join15 } from "path";
|
|
13770
14002
|
var DESCRIPTION_FR_RE = /"description_fr"\s*:\s*"[^"]+"/;
|
|
13771
14003
|
var POSITIVE_CONTROL4 = '"description_fr": "Un serveur MCP conforme.",';
|
|
13772
14004
|
function d10PositiveControl() {
|
|
@@ -13808,6 +14040,8 @@ function scanSourceDescriptionFr(tree) {
|
|
|
13808
14040
|
const line = file.lines[i];
|
|
13809
14041
|
if (line.comment || !MENTION_RE.test(line.raw)) continue;
|
|
13810
14042
|
const anchor = `${file.rel}:${line.n}`;
|
|
14043
|
+
if (/description_fr\s*\?\s*:/.test(line.raw) && !/description_fr\s*:/.test(line.raw))
|
|
14044
|
+
continue;
|
|
13811
14045
|
const key = line.raw.match(/description_fr\s*:/);
|
|
13812
14046
|
if (!key || key.index === void 0) {
|
|
13813
14047
|
undecidable ??= {
|
|
@@ -13824,6 +14058,22 @@ ${tail}`);
|
|
|
13824
14058
|
if (v.kind === "non-literal") {
|
|
13825
14059
|
const ident = v.expr.match(/^([A-Za-z_$][\w$]*)\s*[,}]?\s*$/);
|
|
13826
14060
|
if (ident && bindings.get(ident[1])) return { present: true, anchor };
|
|
14061
|
+
const i18n = readI18nCall(tree, file, v.expr);
|
|
14062
|
+
if (i18n?.kind === "text" && i18n.locale === "fr") return { present: true, anchor };
|
|
14063
|
+
if (i18n?.kind === "text") {
|
|
14064
|
+
undecidable ??= {
|
|
14065
|
+
anchor,
|
|
14066
|
+
reason: `description_fr at ${anchor} is read from the "${i18n.locale}" resource (${i18n.source}), not from "fr": the French field carries no French description`
|
|
14067
|
+
};
|
|
14068
|
+
continue;
|
|
14069
|
+
}
|
|
14070
|
+
if (i18n?.kind === "unresolved") {
|
|
14071
|
+
undecidable ??= {
|
|
14072
|
+
anchor,
|
|
14073
|
+
reason: `description_fr at ${anchor} is the translation call \`${v.expr}\`, not read back: ${i18n.why}; verdict undecidable`
|
|
14074
|
+
};
|
|
14075
|
+
continue;
|
|
14076
|
+
}
|
|
13827
14077
|
const form = ident ? "an identifier that does not resolve to a same-tree string const" : /\w\s*\(/.test(v.expr) ? "a call" : "a non-literal expression";
|
|
13828
14078
|
undecidable ??= {
|
|
13829
14079
|
anchor,
|
|
@@ -13867,7 +14117,7 @@ var d10Inner = {
|
|
|
13867
14117
|
};
|
|
13868
14118
|
}
|
|
13869
14119
|
const { path: pkgPath, json: pkg } = tree.packageJson;
|
|
13870
|
-
const root =
|
|
14120
|
+
const root = dirname8(pkgPath);
|
|
13871
14121
|
const descriptionFr = typeof pkg.description_fr === "string" ? pkg.description_fr.trim() : "";
|
|
13872
14122
|
const hasDescriptionFrJson = descriptionFr.length > 0;
|
|
13873
14123
|
const sourceScan = scanSourceDescriptionFr(tree);
|
|
@@ -13881,8 +14131,8 @@ var d10Inner = {
|
|
|
13881
14131
|
};
|
|
13882
14132
|
}
|
|
13883
14133
|
const hasDescriptionFr = hasDescriptionFrJson || sourceScan.present;
|
|
13884
|
-
const readmeFrPath =
|
|
13885
|
-
const hasReadmeFr =
|
|
14134
|
+
const readmeFrPath = join15(root, "README.fr.md");
|
|
14135
|
+
const hasReadmeFr = existsSync14(readmeFrPath);
|
|
13886
14136
|
const missing = [];
|
|
13887
14137
|
if (!hasDescriptionFr) missing.push("description_fr (package.json or source _meta)");
|
|
13888
14138
|
if (!hasReadmeFr) missing.push("README.fr.md");
|
|
@@ -14290,8 +14540,8 @@ var d15 = {
|
|
|
14290
14540
|
};
|
|
14291
14541
|
|
|
14292
14542
|
// src/detectors/d16.ts
|
|
14293
|
-
import { existsSync as
|
|
14294
|
-
import { dirname as
|
|
14543
|
+
import { existsSync as existsSync15, readFileSync as readFileSync11, statSync as statSync13 } from "fs";
|
|
14544
|
+
import { dirname as dirname9, join as join16 } from "path";
|
|
14295
14545
|
var DISCOVER_RE2 = /server\/discover|DiscoverResult|ServerDiscover|handleServerDiscover/;
|
|
14296
14546
|
var HEALTH_ROUTE_FRAMEWORK_RE = /\b[A-Za-z_$][\w$]*\.(?:get|post|put|patch|delete|all|route|use)\s*\(\s*["'`][^"'`]*\/health/;
|
|
14297
14547
|
var HEALTH_ROUTE_RAWPATH_RE = /\bpathname\s*===?\s*["'`][^"'`]*\/health/;
|
|
@@ -14356,7 +14606,7 @@ function d16PositiveControls() {
|
|
|
14356
14606
|
negative: c.re.test(c.negative)
|
|
14357
14607
|
}));
|
|
14358
14608
|
}
|
|
14359
|
-
function collectPkgIdents(file) {
|
|
14609
|
+
function collectPkgIdents(file, tree) {
|
|
14360
14610
|
const idents = /* @__PURE__ */ new Set();
|
|
14361
14611
|
for (const line of file.lines) {
|
|
14362
14612
|
if (line.comment) continue;
|
|
@@ -14365,8 +14615,56 @@ function collectPkgIdents(file) {
|
|
|
14365
14615
|
const mb = line.raw.match(PKG_IMPORT_BIND_RE);
|
|
14366
14616
|
if (mb) idents.add(mb[1]);
|
|
14367
14617
|
}
|
|
14618
|
+
if (tree && manifestVersionEqualsPackage(tree))
|
|
14619
|
+
for (const id of manifestIdents(file)) idents.add(id);
|
|
14368
14620
|
return idents;
|
|
14369
14621
|
}
|
|
14622
|
+
var MANIFEST_LOADER = "loadServerManifest";
|
|
14623
|
+
function manifestVersionEqualsPackage(tree) {
|
|
14624
|
+
const pkgVersion = tree.packageJson?.json.version;
|
|
14625
|
+
if (typeof pkgVersion !== "string" || pkgVersion.length === 0 || !tree.packageJson) return false;
|
|
14626
|
+
try {
|
|
14627
|
+
const manifest = JSON.parse(
|
|
14628
|
+
readFileSync11(join16(dirname9(tree.packageJson.path), "mcp-server.json"), "utf8")
|
|
14629
|
+
);
|
|
14630
|
+
return manifest.version === pkgVersion;
|
|
14631
|
+
} catch {
|
|
14632
|
+
return false;
|
|
14633
|
+
}
|
|
14634
|
+
}
|
|
14635
|
+
function manifestIdents(file) {
|
|
14636
|
+
const code = file.lines.filter((l) => !l.comment).map((l) => l.raw);
|
|
14637
|
+
const loaders = /* @__PURE__ */ new Set([MANIFEST_LOADER]);
|
|
14638
|
+
code.forEach((raw, i) => {
|
|
14639
|
+
const fn = raw.match(/^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(/);
|
|
14640
|
+
if (!fn) return;
|
|
14641
|
+
let depth = 0;
|
|
14642
|
+
let opened = false;
|
|
14643
|
+
for (let j = i; j < code.length; j++) {
|
|
14644
|
+
if (code[j].includes(`${MANIFEST_LOADER}(`)) {
|
|
14645
|
+
loaders.add(fn[1]);
|
|
14646
|
+
return;
|
|
14647
|
+
}
|
|
14648
|
+
for (const c of code[j]) {
|
|
14649
|
+
if (c === "{") {
|
|
14650
|
+
depth++;
|
|
14651
|
+
opened = true;
|
|
14652
|
+
} else if (c === "}") depth--;
|
|
14653
|
+
}
|
|
14654
|
+
if (opened && depth <= 0) return;
|
|
14655
|
+
}
|
|
14656
|
+
});
|
|
14657
|
+
const out = /* @__PURE__ */ new Set();
|
|
14658
|
+
const callee = [...loaders].map((n) => n.replace(/[$]/g, "\\$&")).join("|");
|
|
14659
|
+
const bind = new RegExp(
|
|
14660
|
+
`(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*(?:await\\s+)?(?:${callee})\\s*\\(`
|
|
14661
|
+
);
|
|
14662
|
+
for (const raw of code) {
|
|
14663
|
+
const m = raw.match(bind);
|
|
14664
|
+
if (m) out.add(m[1]);
|
|
14665
|
+
}
|
|
14666
|
+
return out;
|
|
14667
|
+
}
|
|
14370
14668
|
function extractHandlerBody(file, startIdx) {
|
|
14371
14669
|
const code = file.lines.filter((l) => !l.comment);
|
|
14372
14670
|
const startPos = code.findIndex((l) => l.n === file.lines[startIdx].n);
|
|
@@ -14438,7 +14736,7 @@ function packageJsonVersionConsts(tree) {
|
|
|
14438
14736
|
function sdkServerVersionSurface(tree) {
|
|
14439
14737
|
const derived = packageJsonVersionConsts(tree);
|
|
14440
14738
|
for (const file of tree.files) {
|
|
14441
|
-
const pkgIdents = collectPkgIdents(file);
|
|
14739
|
+
const pkgIdents = collectPkgIdents(file, tree);
|
|
14442
14740
|
for (let idx = 0; idx < file.lines.length; idx++) {
|
|
14443
14741
|
const line = file.lines[idx];
|
|
14444
14742
|
if (line.comment || !SDK_SERVER_NEW_RE.test(line.raw)) continue;
|
|
@@ -14461,7 +14759,7 @@ function evalSurfaces(tree) {
|
|
|
14461
14759
|
const sdk = sdkServerVersionSurface(tree);
|
|
14462
14760
|
if (sdk) out.push(sdk);
|
|
14463
14761
|
for (const file of tree.files) {
|
|
14464
|
-
const pkgIdents = collectPkgIdents(file);
|
|
14762
|
+
const pkgIdents = collectPkgIdents(file, tree);
|
|
14465
14763
|
file.lines.forEach((line, idx) => {
|
|
14466
14764
|
if (line.comment) return;
|
|
14467
14765
|
if (DISCOVER_RE2.test(line.raw) || HEALTH_ROUTE_RE2.test(line.raw)) {
|
|
@@ -14613,15 +14911,15 @@ var d16 = {
|
|
|
14613
14911
|
};
|
|
14614
14912
|
function readPackageVersion(root) {
|
|
14615
14913
|
try {
|
|
14616
|
-
let dir = statSync13(root).isDirectory() ? root :
|
|
14914
|
+
let dir = statSync13(root).isDirectory() ? root : dirname9(root);
|
|
14617
14915
|
for (let depth = 0; depth < 8; depth++) {
|
|
14618
|
-
const candidate =
|
|
14619
|
-
if (
|
|
14916
|
+
const candidate = join16(dir, "package.json");
|
|
14917
|
+
if (existsSync15(candidate)) {
|
|
14620
14918
|
if (!statSync13(candidate).isFile()) return null;
|
|
14621
|
-
const pkg = JSON.parse(
|
|
14919
|
+
const pkg = JSON.parse(readFileSync11(candidate, "utf8"));
|
|
14622
14920
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
14623
14921
|
}
|
|
14624
|
-
const parent =
|
|
14922
|
+
const parent = dirname9(dir);
|
|
14625
14923
|
if (parent === dir) break;
|
|
14626
14924
|
dir = parent;
|
|
14627
14925
|
}
|
|
@@ -14632,8 +14930,8 @@ function readPackageVersion(root) {
|
|
|
14632
14930
|
}
|
|
14633
14931
|
|
|
14634
14932
|
// src/detectors/dAppI18n.ts
|
|
14635
|
-
import { existsSync as
|
|
14636
|
-
import { dirname as
|
|
14933
|
+
import { existsSync as existsSync16, readFileSync as readFileSync12, statSync as statSync14 } from "fs";
|
|
14934
|
+
import { dirname as dirname10, join as join17 } from "path";
|
|
14637
14935
|
function flattenKeys(obj, prefix = "") {
|
|
14638
14936
|
if (obj === null || typeof obj !== "object" || Array.isArray(obj)) {
|
|
14639
14937
|
return prefix ? [prefix] : [];
|
|
@@ -14667,7 +14965,7 @@ function dAppI18nPositiveControls() {
|
|
|
14667
14965
|
function readJson2(path) {
|
|
14668
14966
|
try {
|
|
14669
14967
|
if (!statSync14(path).isFile()) return { ok: false };
|
|
14670
|
-
return { ok: true, value: JSON.parse(
|
|
14968
|
+
return { ok: true, value: JSON.parse(readFileSync12(path, "utf8")) };
|
|
14671
14969
|
} catch {
|
|
14672
14970
|
return { ok: false };
|
|
14673
14971
|
}
|
|
@@ -14683,12 +14981,12 @@ var dAppI18n = {
|
|
|
14683
14981
|
`DAppI18n key-diff control FAILED: detectsGap=${control.detectsGap} detectsComplete=${control.detectsComplete} \u2014 matcher broken, verdict untrustworthy`
|
|
14684
14982
|
);
|
|
14685
14983
|
}
|
|
14686
|
-
const root = tree.packageJson ?
|
|
14687
|
-
const i18nDir =
|
|
14688
|
-
const enPath =
|
|
14689
|
-
const frPath =
|
|
14690
|
-
const hasI18n =
|
|
14691
|
-
const hasFr =
|
|
14984
|
+
const root = tree.packageJson ? dirname10(tree.packageJson.path) : tree.root;
|
|
14985
|
+
const i18nDir = join17(root, "i18n");
|
|
14986
|
+
const enPath = join17(i18nDir, "en.json");
|
|
14987
|
+
const frPath = join17(i18nDir, "fr.json");
|
|
14988
|
+
const hasI18n = existsSync16(i18nDir);
|
|
14989
|
+
const hasFr = existsSync16(frPath);
|
|
14692
14990
|
if (!hasI18n && !hasFr) {
|
|
14693
14991
|
return {
|
|
14694
14992
|
id: this.id,
|
|
@@ -14716,7 +15014,7 @@ var dAppI18n = {
|
|
|
14716
15014
|
verdict: `could not judge: ${reason}`
|
|
14717
15015
|
};
|
|
14718
15016
|
}
|
|
14719
|
-
if (!
|
|
15017
|
+
if (!existsSync16(enPath)) {
|
|
14720
15018
|
const reason = "i18n/fr.json exists but no source-locale i18n/en.json to compare its keys against (App Rule 2)";
|
|
14721
15019
|
return {
|
|
14722
15020
|
id: this.id,
|
|
@@ -14866,13 +15164,13 @@ var dDebugOptIn = {
|
|
|
14866
15164
|
|
|
14867
15165
|
// src/detectors/extManifests.ts
|
|
14868
15166
|
import { readdirSync as readdirSync9, statSync as statSync15 } from "fs";
|
|
14869
|
-
import { join as
|
|
15167
|
+
import { join as join18 } from "path";
|
|
14870
15168
|
function findExtensionManifests(tree) {
|
|
14871
15169
|
const out = [];
|
|
14872
15170
|
const root = tree.root;
|
|
14873
15171
|
let base;
|
|
14874
15172
|
try {
|
|
14875
|
-
base = statSync15(root).isDirectory() ? root :
|
|
15173
|
+
base = statSync15(root).isDirectory() ? root : join18(root, "..");
|
|
14876
15174
|
} catch {
|
|
14877
15175
|
return out;
|
|
14878
15176
|
}
|
|
@@ -14885,7 +15183,7 @@ function findExtensionManifests(tree) {
|
|
|
14885
15183
|
return;
|
|
14886
15184
|
}
|
|
14887
15185
|
for (const name of entries) {
|
|
14888
|
-
const full =
|
|
15186
|
+
const full = join18(dir, name);
|
|
14889
15187
|
let st;
|
|
14890
15188
|
try {
|
|
14891
15189
|
st = statSync15(full);
|
|
@@ -14913,20 +15211,20 @@ function findExtensionManifests(tree) {
|
|
|
14913
15211
|
}
|
|
14914
15212
|
|
|
14915
15213
|
// src/detectors/vendorRegistry.ts
|
|
14916
|
-
import { existsSync as
|
|
14917
|
-
import { dirname as
|
|
15214
|
+
import { existsSync as existsSync17, readFileSync as readFileSync13 } from "fs";
|
|
15215
|
+
import { dirname as dirname11, join as join19 } from "path";
|
|
14918
15216
|
import { fileURLToPath } from "url";
|
|
14919
15217
|
function locateRegistry() {
|
|
14920
15218
|
let dir;
|
|
14921
15219
|
try {
|
|
14922
|
-
dir =
|
|
15220
|
+
dir = dirname11(fileURLToPath(import.meta.url));
|
|
14923
15221
|
} catch {
|
|
14924
15222
|
return null;
|
|
14925
15223
|
}
|
|
14926
15224
|
for (let depth = 0; depth < 5; depth++) {
|
|
14927
|
-
const candidate =
|
|
14928
|
-
if (
|
|
14929
|
-
const parent =
|
|
15225
|
+
const candidate = join19(dir, "vendor-namespaces.json");
|
|
15226
|
+
if (existsSync17(candidate)) return candidate;
|
|
15227
|
+
const parent = dirname11(dir);
|
|
14930
15228
|
if (parent === dir) break;
|
|
14931
15229
|
dir = parent;
|
|
14932
15230
|
}
|
|
@@ -14942,7 +15240,7 @@ function loadRegistry(path) {
|
|
|
14942
15240
|
}
|
|
14943
15241
|
let parsed;
|
|
14944
15242
|
try {
|
|
14945
|
-
parsed = JSON.parse(
|
|
15243
|
+
parsed = JSON.parse(readFileSync13(p, "utf8"));
|
|
14946
15244
|
} catch (err) {
|
|
14947
15245
|
return {
|
|
14948
15246
|
ok: false,
|
|
@@ -15521,7 +15819,7 @@ var dExt3 = {
|
|
|
15521
15819
|
|
|
15522
15820
|
// src/detectors/dExt4.ts
|
|
15523
15821
|
import { readdirSync as readdirSync10, statSync as statSync16 } from "fs";
|
|
15524
|
-
import { join as
|
|
15822
|
+
import { join as join20, relative as relative10 } from "path";
|
|
15525
15823
|
function canonical(name) {
|
|
15526
15824
|
return name.replace(/[-_]/g, "").toLowerCase();
|
|
15527
15825
|
}
|
|
@@ -15545,7 +15843,7 @@ function findHooksDirs(tree, unreadable, gaps) {
|
|
|
15545
15843
|
const out = [];
|
|
15546
15844
|
let base;
|
|
15547
15845
|
try {
|
|
15548
|
-
base = statSync16(root).isDirectory() ? root :
|
|
15846
|
+
base = statSync16(root).isDirectory() ? root : join20(root, "..");
|
|
15549
15847
|
} catch {
|
|
15550
15848
|
return out;
|
|
15551
15849
|
}
|
|
@@ -15566,7 +15864,7 @@ function findHooksDirs(tree, unreadable, gaps) {
|
|
|
15566
15864
|
return;
|
|
15567
15865
|
}
|
|
15568
15866
|
for (const name of entries) {
|
|
15569
|
-
const full =
|
|
15867
|
+
const full = join20(dir, name);
|
|
15570
15868
|
let st;
|
|
15571
15869
|
try {
|
|
15572
15870
|
st = statSync16(full);
|
|
@@ -15747,8 +16045,8 @@ var dExt4 = {
|
|
|
15747
16045
|
};
|
|
15748
16046
|
|
|
15749
16047
|
// src/detectors/dExt5.ts
|
|
15750
|
-
import { existsSync as
|
|
15751
|
-
import { dirname as
|
|
16048
|
+
import { existsSync as existsSync18 } from "fs";
|
|
16049
|
+
import { dirname as dirname12, join as join21 } from "path";
|
|
15752
16050
|
function nonEmptyString(v) {
|
|
15753
16051
|
return typeof v === "string" && v.trim().length > 0;
|
|
15754
16052
|
}
|
|
@@ -15787,7 +16085,7 @@ var dExt5 = {
|
|
|
15787
16085
|
}
|
|
15788
16086
|
for (const manifestPath2 of manifests) {
|
|
15789
16087
|
const shortPath = manifestPath2.split("/").slice(-2).join("/");
|
|
15790
|
-
const root =
|
|
16088
|
+
const root = dirname12(manifestPath2);
|
|
15791
16089
|
const cannotRead = (reason) => ({
|
|
15792
16090
|
id: this.id,
|
|
15793
16091
|
anchor: shortPath,
|
|
@@ -15810,7 +16108,7 @@ var dExt5 = {
|
|
|
15810
16108
|
if (!nonEmptyString(parsed.description_fr)) {
|
|
15811
16109
|
missing.push("description_fr (extension.json)");
|
|
15812
16110
|
}
|
|
15813
|
-
if (!
|
|
16111
|
+
if (!existsSync18(join21(root, "README.fr.md"))) {
|
|
15814
16112
|
missing.push("README.fr.md");
|
|
15815
16113
|
}
|
|
15816
16114
|
if (isToolExtension(parsed.type) && "tools" in parsed) {
|
|
@@ -15853,8 +16151,8 @@ var dExt5 = {
|
|
|
15853
16151
|
};
|
|
15854
16152
|
|
|
15855
16153
|
// src/detectors/dExt7.ts
|
|
15856
|
-
import { existsSync as
|
|
15857
|
-
import { dirname as
|
|
16154
|
+
import { existsSync as existsSync19 } from "fs";
|
|
16155
|
+
import { dirname as dirname13, join as join22 } from "path";
|
|
15858
16156
|
var ABSENCE_FLAG_FIELDS = [
|
|
15859
16157
|
"extensionAbsent",
|
|
15860
16158
|
"extension_absent",
|
|
@@ -15920,11 +16218,11 @@ var dExt7 = {
|
|
|
15920
16218
|
const unreadable = [];
|
|
15921
16219
|
const decided = (() => {
|
|
15922
16220
|
for (const manifestPath2 of manifests) {
|
|
15923
|
-
const extDir =
|
|
16221
|
+
const extDir = dirname13(manifestPath2);
|
|
15924
16222
|
const extLabel = extDir.split("/").pop() ?? extDir;
|
|
15925
|
-
const evalsPath =
|
|
16223
|
+
const evalsPath = join22(extDir, "evals", "evals.json");
|
|
15926
16224
|
const shortPath = `${extLabel}/evals/evals.json`;
|
|
15927
|
-
if (!
|
|
16225
|
+
if (!existsSync19(evalsPath)) {
|
|
15928
16226
|
return {
|
|
15929
16227
|
id: this.id,
|
|
15930
16228
|
anchor: `${extLabel}/extension.json`,
|
|
@@ -15988,8 +16286,8 @@ var dExt7 = {
|
|
|
15988
16286
|
};
|
|
15989
16287
|
|
|
15990
16288
|
// src/detectors/dExt8.ts
|
|
15991
|
-
import { existsSync as
|
|
15992
|
-
import { dirname as
|
|
16289
|
+
import { existsSync as existsSync20 } from "fs";
|
|
16290
|
+
import { dirname as dirname14, join as join23 } from "path";
|
|
15993
16291
|
var SEMVER_RE2 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
15994
16292
|
var POSITIVE_CONTROL5 = "1.2.3-beta.1+build.7";
|
|
15995
16293
|
function dExt8PositiveControl() {
|
|
@@ -16023,11 +16321,11 @@ var dExt8 = {
|
|
|
16023
16321
|
let finding;
|
|
16024
16322
|
let judgedConforming = 0;
|
|
16025
16323
|
for (const manifestPath2 of manifests) {
|
|
16026
|
-
const extDir =
|
|
16324
|
+
const extDir = dirname14(manifestPath2);
|
|
16027
16325
|
const extLabel = extDir.split("/").pop() ?? extDir;
|
|
16028
|
-
const pkgPath =
|
|
16326
|
+
const pkgPath = join23(extDir, "package.json");
|
|
16029
16327
|
const shortPkgPath = `${extLabel}/package.json`;
|
|
16030
|
-
if (!
|
|
16328
|
+
if (!existsSync20(pkgPath)) {
|
|
16031
16329
|
unreadable.push({
|
|
16032
16330
|
anchor: shortPkgPath,
|
|
16033
16331
|
reason: `could not locate ${shortPkgPath} for extension "${extLabel}" \u2014 cannot verify SemVer/CHANGELOG (Extension Rule 8)`
|
|
@@ -16062,8 +16360,8 @@ var dExt8 = {
|
|
|
16062
16360
|
continue;
|
|
16063
16361
|
}
|
|
16064
16362
|
const validSemver = SEMVER_RE2.test(version);
|
|
16065
|
-
const changelogPath =
|
|
16066
|
-
const hasChangelog =
|
|
16363
|
+
const changelogPath = join23(extDir, "CHANGELOG.md");
|
|
16364
|
+
const hasChangelog = existsSync20(changelogPath);
|
|
16067
16365
|
if (!validSemver) {
|
|
16068
16366
|
finding ??= {
|
|
16069
16367
|
id: this.id,
|
|
@@ -16097,14 +16395,14 @@ var dExt8 = {
|
|
|
16097
16395
|
};
|
|
16098
16396
|
|
|
16099
16397
|
// src/detectors/dExt9.ts
|
|
16100
|
-
import { readFileSync as
|
|
16101
|
-
import { join as
|
|
16398
|
+
import { readFileSync as readFileSync14, readdirSync as readdirSync11, statSync as statSync17 } from "fs";
|
|
16399
|
+
import { join as join24, relative as relative11 } from "path";
|
|
16102
16400
|
function collectHooksDirSources(tree, unreadable, gaps) {
|
|
16103
16401
|
const root = tree.root;
|
|
16104
16402
|
const out = [];
|
|
16105
16403
|
let base;
|
|
16106
16404
|
try {
|
|
16107
|
-
base = statSync17(root).isDirectory() ? root :
|
|
16405
|
+
base = statSync17(root).isDirectory() ? root : join24(root, "..");
|
|
16108
16406
|
} catch {
|
|
16109
16407
|
return out;
|
|
16110
16408
|
}
|
|
@@ -16125,7 +16423,7 @@ function collectHooksDirSources(tree, unreadable, gaps) {
|
|
|
16125
16423
|
return;
|
|
16126
16424
|
}
|
|
16127
16425
|
for (const name of entries) {
|
|
16128
|
-
const full =
|
|
16426
|
+
const full = join24(dir, name);
|
|
16129
16427
|
let st;
|
|
16130
16428
|
try {
|
|
16131
16429
|
st = statSync17(full);
|
|
@@ -16151,11 +16449,11 @@ function collectHooksDirSources(tree, unreadable, gaps) {
|
|
|
16151
16449
|
if (!f.endsWith(".ts") || f.endsWith(".d.ts")) continue;
|
|
16152
16450
|
const stem = f.replace(/\.ts$/, "");
|
|
16153
16451
|
if (stem === "index") continue;
|
|
16154
|
-
const filePath =
|
|
16452
|
+
const filePath = join24(full, f);
|
|
16155
16453
|
let body;
|
|
16156
16454
|
try {
|
|
16157
16455
|
if (!statSync17(filePath).isFile()) throw new Error("not a regular file");
|
|
16158
|
-
body =
|
|
16456
|
+
body = readFileSync14(filePath, "utf8");
|
|
16159
16457
|
} catch {
|
|
16160
16458
|
const shortPath = filePath.split("/").slice(-2).join("/");
|
|
16161
16459
|
unreadable.push({
|
|
@@ -16629,21 +16927,21 @@ function codeLines(tree) {
|
|
|
16629
16927
|
for (const file of tree.files) for (const l of file.lines) if (!l.comment) out.push(l.raw);
|
|
16630
16928
|
return out;
|
|
16631
16929
|
}
|
|
16632
|
-
var
|
|
16930
|
+
var esc3 = (x) => x.replace(/[$]/g, "\\$&");
|
|
16633
16931
|
function resolvesToLiteral(tree, path) {
|
|
16634
16932
|
const lines2 = codeLines(tree);
|
|
16635
16933
|
const plainLiteral = (name) => {
|
|
16636
|
-
const decl = new RegExp(`\\b(?:const|let|var)\\s+${
|
|
16934
|
+
const decl = new RegExp(`\\b(?:const|let|var)\\s+${esc3(name)}\\s*(?::[^=]+)?=\\s*(.*)$`);
|
|
16637
16935
|
const found = lines2.map((l) => l.match(decl)).filter((m) => m !== null);
|
|
16638
16936
|
if (found.length !== 1 || !LITERAL_VALUE_RE.test(found[0][1])) return false;
|
|
16639
|
-
const param = new RegExp(`[(,]\\s*${
|
|
16937
|
+
const param = new RegExp(`[(,]\\s*${esc3(name)}\\s*[:,)=?]|\\bfunction\\s+${esc3(name)}\\b`);
|
|
16640
16938
|
return !lines2.some((l) => param.test(l));
|
|
16641
16939
|
};
|
|
16642
16940
|
if (/[()]/.test(path)) return false;
|
|
16643
16941
|
if (!path.includes(".")) return plainLiteral(path);
|
|
16644
16942
|
const prop = path.split(".").pop() ?? "";
|
|
16645
|
-
const def = new RegExp(`(?:^|[\\s{,])${
|
|
16646
|
-
const shorthand = new RegExp(`[{,]\\s*${
|
|
16943
|
+
const def = new RegExp(`(?:^|[\\s{,])${esc3(prop)}\\s*:\\s*([^,}\\n]+)`);
|
|
16944
|
+
const shorthand = new RegExp(`[{,]\\s*${esc3(prop)}\\s*[,}]`);
|
|
16647
16945
|
const defs = lines2.map((l) => l.match(def)).filter((m) => m !== null);
|
|
16648
16946
|
if (defs.length === 0 || lines2.some((l) => shorthand.test(l))) return false;
|
|
16649
16947
|
return defs.every((m) => {
|
|
@@ -16701,19 +16999,19 @@ function boundToSystemState(tree, path) {
|
|
|
16701
16999
|
const lines2 = codeLines(tree);
|
|
16702
17000
|
if (/[()]/.test(path)) return null;
|
|
16703
17001
|
if (!path.includes(".")) {
|
|
16704
|
-
const destructured = new RegExp(`\\{[^}]*\\b${
|
|
17002
|
+
const destructured = new RegExp(`\\{[^}]*\\b${esc3(path)}\\b[^}]*\\}\\s*=\\s*process\\.env\\b`);
|
|
16705
17003
|
if (lines2.some((l) => destructured.test(l)) && URL_ENV_NAME_RE.test(path)) return "env-url";
|
|
16706
|
-
const decl = new RegExp(`\\b(?:const|let|var)\\s+${
|
|
17004
|
+
const decl = new RegExp(`\\b(?:const|let|var)\\s+${esc3(path)}\\s*(?::[^=]+)?=\\s*(.*)$`);
|
|
16707
17005
|
const found = lines2.map((l) => l.match(decl)).filter((m) => m !== null);
|
|
16708
17006
|
if (found.length !== 1) return null;
|
|
16709
17007
|
const param = new RegExp(
|
|
16710
|
-
`\\([^()]*\\b${
|
|
17008
|
+
`\\([^()]*\\b${esc3(path)}\\b[^()]*\\)\\s*(?::[^=]+)?=>|\\bfunction\\b[^(]*\\([^)]*\\b${esc3(path)}\\b`
|
|
16711
17009
|
);
|
|
16712
17010
|
if (lines2.some((l) => param.test(l))) return null;
|
|
16713
17011
|
return exprSystemKind(found[0][1]);
|
|
16714
17012
|
}
|
|
16715
17013
|
const prop = path.split(".").pop() ?? "";
|
|
16716
|
-
const def = new RegExp(`(?:^|[\\s{,])${
|
|
17014
|
+
const def = new RegExp(`(?:^|[\\s{,])${esc3(prop)}\\s*:\\s*([^,}\\n]+)`);
|
|
16717
17015
|
const defs = lines2.map((l) => l.match(def)).filter((m) => m !== null);
|
|
16718
17016
|
if (defs.length === 0) return null;
|
|
16719
17017
|
const kinds = defs.map((m) => exprSystemKind(m[1]));
|
|
@@ -17784,8 +18082,8 @@ var e10MrtrOnly = {
|
|
|
17784
18082
|
};
|
|
17785
18083
|
|
|
17786
18084
|
// src/detectors/e11-surfaces-derived.ts
|
|
17787
|
-
import { existsSync as
|
|
17788
|
-
import { dirname as
|
|
18085
|
+
import { existsSync as existsSync21, statSync as statSync18 } from "fs";
|
|
18086
|
+
import { dirname as dirname15, join as join25, relative as relative12, sep as sep6 } from "path";
|
|
17789
18087
|
var ALL = ["chat", "cowork", "claude-code"];
|
|
17790
18088
|
function excludedSurfaces(c) {
|
|
17791
18089
|
const cause = /* @__PURE__ */ new Map();
|
|
@@ -17856,7 +18154,7 @@ var e11SurfacesDerived = {
|
|
|
17856
18154
|
});
|
|
17857
18155
|
continue;
|
|
17858
18156
|
}
|
|
17859
|
-
const folder =
|
|
18157
|
+
const folder = dirname15(m.path);
|
|
17860
18158
|
const rel = (p) => relative12(tree.root, p).split(sep6).join("/") || ".";
|
|
17861
18159
|
if (!Array.isArray(j.surfaces)) {
|
|
17862
18160
|
reds.push({
|
|
@@ -17874,9 +18172,9 @@ var e11SurfacesDerived = {
|
|
|
17874
18172
|
text: `${m.rel} surfaces ${unknown.join(", ")} are not in {${ALL.join(", ")}}`
|
|
17875
18173
|
});
|
|
17876
18174
|
}
|
|
17877
|
-
const mcp =
|
|
18175
|
+
const mcp = join25(folder, ".mcp.json");
|
|
17878
18176
|
let localMcp = false;
|
|
17879
|
-
if (
|
|
18177
|
+
if (existsSync21(mcp)) {
|
|
17880
18178
|
const mj = readJsonRecord(mcp);
|
|
17881
18179
|
if (!mj)
|
|
17882
18180
|
unreadable.push({
|
|
@@ -17893,9 +18191,9 @@ var e11SurfacesDerived = {
|
|
|
17893
18191
|
}
|
|
17894
18192
|
}
|
|
17895
18193
|
const cause = excludedSurfaces({
|
|
17896
|
-
bin: isDir(
|
|
17897
|
-
hooks: isDir(
|
|
17898
|
-
agents: isDir(
|
|
18194
|
+
bin: isDir(join25(folder, "bin"), rel(join25(folder, "bin")), unreadable),
|
|
18195
|
+
hooks: isDir(join25(folder, "hooks"), rel(join25(folder, "hooks")), unreadable),
|
|
18196
|
+
agents: isDir(join25(folder, "agents"), rel(join25(folder, "agents")), unreadable),
|
|
17899
18197
|
localMcp
|
|
17900
18198
|
});
|
|
17901
18199
|
for (const s of declared) {
|
|
@@ -18020,7 +18318,7 @@ var e12HostCapabilityPlacement = {
|
|
|
18020
18318
|
|
|
18021
18319
|
// src/detectors/installedAs.ts
|
|
18022
18320
|
import { readdirSync as readdirSync12, statSync as statSync19 } from "fs";
|
|
18023
|
-
import { join as
|
|
18321
|
+
import { join as join26 } from "path";
|
|
18024
18322
|
var KEY = (k) => `(?:["']${k}["']|\\b${k}\\b)`;
|
|
18025
18323
|
function flagTrueRe(key) {
|
|
18026
18324
|
return new RegExp(`${KEY(key)}\\s*:\\s*true\\b`);
|
|
@@ -18045,7 +18343,7 @@ function declaredDependencies(tree) {
|
|
|
18045
18343
|
}
|
|
18046
18344
|
function readInstalledAs(tree) {
|
|
18047
18345
|
const out = { installed: false, missing: [], publishers: [], unread: [] };
|
|
18048
|
-
const nm =
|
|
18346
|
+
const nm = join26(baseOf(tree), "node_modules");
|
|
18049
18347
|
try {
|
|
18050
18348
|
out.installed = statSync19(nm).isDirectory();
|
|
18051
18349
|
} catch {
|
|
@@ -18054,7 +18352,7 @@ function readInstalledAs(tree) {
|
|
|
18054
18352
|
if (!out.installed) return out;
|
|
18055
18353
|
const methods = authMethodsRe();
|
|
18056
18354
|
for (const dep of declaredDependencies(tree)) {
|
|
18057
|
-
const dir =
|
|
18355
|
+
const dir = join26(nm, dep);
|
|
18058
18356
|
try {
|
|
18059
18357
|
if (!statSync19(dir).isDirectory()) throw new Error("not a directory");
|
|
18060
18358
|
} catch {
|
|
@@ -18075,7 +18373,7 @@ function readInstalledAs(tree) {
|
|
|
18075
18373
|
for (const n of names) {
|
|
18076
18374
|
if (files.length >= MAX_FILES_PER_PACKAGE) return;
|
|
18077
18375
|
if (n === "node_modules") continue;
|
|
18078
|
-
const full =
|
|
18376
|
+
const full = join26(d, n);
|
|
18079
18377
|
let st;
|
|
18080
18378
|
try {
|
|
18081
18379
|
st = statSync19(full);
|
|
@@ -19280,7 +19578,7 @@ function outboundSites(tree) {
|
|
|
19280
19578
|
if (!BARE_IDENT.test(first)) continue;
|
|
19281
19579
|
const fns = enclosingFns(c.src, c.start);
|
|
19282
19580
|
const inner = fns[fns.length - 1];
|
|
19283
|
-
if (!inner || !new RegExp(String.raw`(?<![\w$.])${
|
|
19581
|
+
if (!inner || !new RegExp(String.raw`(?<![\w$.])${esc2(first)}(?![\w$])`).test(inner.header))
|
|
19284
19582
|
continue;
|
|
19285
19583
|
const named = [...fns].reverse().find((f) => f.name !== void 0);
|
|
19286
19584
|
if (!named?.name) continue;
|
|
@@ -19309,7 +19607,7 @@ function outboundSites(tree) {
|
|
|
19309
19607
|
const applies = w.bodies.every((b) => b.timeout);
|
|
19310
19608
|
for (const c of callsMatching(
|
|
19311
19609
|
tree,
|
|
19312
|
-
new RegExp(String.raw`^(?:[\w$]+(?:\?\.|\.))*${
|
|
19610
|
+
new RegExp(String.raw`^(?:[\w$]+(?:\?\.|\.))*${esc2(w.name)}$`)
|
|
19313
19611
|
)) {
|
|
19314
19612
|
if (isDeclaration(c) || !callReaches(c.src, c.callee, w.name, w.defs)) continue;
|
|
19315
19613
|
if (w.bodies.some((b) => b.src === c.src && c.start > b.open && c.start < b.close)) continue;
|
|
@@ -19320,7 +19618,7 @@ function outboundSites(tree) {
|
|
|
19320
19618
|
const returned = /(?:\breturn\s+|=>\s*)$/.test(
|
|
19321
19619
|
c.src.shape.slice(Math.max(0, c.start - 12), c.start)
|
|
19322
19620
|
);
|
|
19323
|
-
if (host?.name && returned && BARE_IDENT.test(first) && new RegExp(String.raw`(?<![\w$.])${
|
|
19621
|
+
if (host?.name && returned && BARE_IDENT.test(first) && new RegExp(String.raw`(?<![\w$.])${esc2(first)}(?![\w$])`).test(host.header) && !wrapperNames.has(host.name)) {
|
|
19324
19622
|
unreadable.push({
|
|
19325
19623
|
anchor: c.anchor,
|
|
19326
19624
|
reason: `${c.anchor} \`${c.callee}(...)\` is a wrapper (${w.name}, ${w.anchor}) called through a second wrapper (${host.name}): two levels of indirection, the timeout of its call sites is not followed`
|
|
@@ -20610,6 +20908,16 @@ function resolveConstLiteral(tree, name, file) {
|
|
|
20610
20908
|
}
|
|
20611
20909
|
return null;
|
|
20612
20910
|
}
|
|
20911
|
+
var OUTBOUND_CLIENTS = /* @__PURE__ */ new Set(["createPaginatedUpstreamClient"]);
|
|
20912
|
+
function outboundCallee(file, line, col) {
|
|
20913
|
+
const obj = enclosingOpener(file, line, col);
|
|
20914
|
+
if (!obj || obj.ch !== "{") return null;
|
|
20915
|
+
const call = enclosingOpener(file, obj.line, obj.col);
|
|
20916
|
+
if (!call || call.ch !== "(") return null;
|
|
20917
|
+
const before = uncommentedLines(file)[call.line - 1].slice(0, call.col);
|
|
20918
|
+
const name = before.match(/([A-Za-z_$][\w$]*)\s*(?:<[^>()]*>)?\s*$/)?.[1];
|
|
20919
|
+
return name !== void 0 && OUTBOUND_CLIENTS.has(name) ? name : null;
|
|
20920
|
+
}
|
|
20613
20921
|
function classifyAllowedOrigins(tree) {
|
|
20614
20922
|
const out = { sites: 0, first: "", ok: [], reds: [], unresolved: [], declared: [] };
|
|
20615
20923
|
const judged = /* @__PURE__ */ new Set();
|
|
@@ -20633,6 +20941,7 @@ function classifyAllowedOrigins(tree) {
|
|
|
20633
20941
|
const after = site.col + site.match[0].length;
|
|
20634
20942
|
const rest = site.line.raw.slice(after);
|
|
20635
20943
|
if (TYPE_ANNOTATION_RE.test(rest)) continue;
|
|
20944
|
+
if (outboundCallee(site.file, site.line.n, site.col) !== null) continue;
|
|
20636
20945
|
if (rest.startsWith("{")) {
|
|
20637
20946
|
const entry = declaredEntryAt(site.file, site.line.n, after);
|
|
20638
20947
|
if (entry !== null) {
|
|
@@ -21217,12 +21526,12 @@ var s27ElicitationFloor = {
|
|
|
21217
21526
|
};
|
|
21218
21527
|
|
|
21219
21528
|
// src/detectors/s28-claim-forwarded.ts
|
|
21220
|
-
import { existsSync as
|
|
21221
|
-
import { dirname as
|
|
21529
|
+
import { existsSync as existsSync22, readFileSync as readFileSync15, readdirSync as readdirSync13, statSync as statSync20 } from "fs";
|
|
21530
|
+
import { dirname as dirname16, join as join27, relative as relative13 } from "path";
|
|
21222
21531
|
var PIN11 = STANDARD_PIN;
|
|
21223
21532
|
var CLAIM_TOKEN = /\bverified(?:Org|Person)\b/;
|
|
21224
21533
|
var ANY_CLAIM = /\bverified(?:Actor|Org|Person)\b/g;
|
|
21225
|
-
var
|
|
21534
|
+
var CALL_RE2 = /\b([A-Za-z_$][\w$]*)\s*\.\s*(query|mutation|action)\s*\(/g;
|
|
21226
21535
|
var GUARD_RE = /\b(?:unresolved\w*Denial|requireVerified\w+|requireClaim\w*)\s*\(|verified-org-unresolved/;
|
|
21227
21536
|
var FLEET_WIDE = /fleet-wide:\s*\S[^\n]{7,}/;
|
|
21228
21537
|
var SCOPE_MARKERS = /\bwithOrgScope\b|\brequireAuthenticatedCaller\b|\bresolveInboxReader\b|\bresolveVerified\w*\b|\brequireScope\b|\bgetUserIdentity\b|\bisMaster\b|\bscope\b/;
|
|
@@ -21286,7 +21595,7 @@ function listTs(dir, unread2, out = []) {
|
|
|
21286
21595
|
}
|
|
21287
21596
|
for (const n of names) {
|
|
21288
21597
|
if (n === "node_modules" || n === "_generated" || n === "__tests__") continue;
|
|
21289
|
-
const p =
|
|
21598
|
+
const p = join27(dir, n);
|
|
21290
21599
|
let st;
|
|
21291
21600
|
try {
|
|
21292
21601
|
st = statSync20(p);
|
|
@@ -21305,14 +21614,14 @@ function listTs(dir, unread2, out = []) {
|
|
|
21305
21614
|
function discoverBackend(root) {
|
|
21306
21615
|
let dir = root;
|
|
21307
21616
|
try {
|
|
21308
|
-
if (!statSync20(root).isDirectory()) dir =
|
|
21617
|
+
if (!statSync20(root).isDirectory()) dir = dirname16(root);
|
|
21309
21618
|
} catch {
|
|
21310
21619
|
return void 0;
|
|
21311
21620
|
}
|
|
21312
21621
|
for (let up = 0; up < 5; up++) {
|
|
21313
|
-
const cand =
|
|
21314
|
-
if (
|
|
21315
|
-
const parent =
|
|
21622
|
+
const cand = join27(dir, "convex");
|
|
21623
|
+
if (existsSync22(join27(cand, "schema.ts"))) return cand;
|
|
21624
|
+
const parent = dirname16(dir);
|
|
21316
21625
|
if (parent === dir) break;
|
|
21317
21626
|
dir = parent;
|
|
21318
21627
|
}
|
|
@@ -21323,7 +21632,7 @@ function readDoors(backendRoot, unread2) {
|
|
|
21323
21632
|
for (const path of listTs(backendRoot, unread2)) {
|
|
21324
21633
|
let text;
|
|
21325
21634
|
try {
|
|
21326
|
-
text =
|
|
21635
|
+
text = readFileSync15(path, "utf8");
|
|
21327
21636
|
} catch (err) {
|
|
21328
21637
|
unread2.push(`${path} could not be read (${fsErrorCode(err)})`);
|
|
21329
21638
|
continue;
|
|
@@ -21388,8 +21697,8 @@ function readDoors(backendRoot, unread2) {
|
|
|
21388
21697
|
return doors;
|
|
21389
21698
|
}
|
|
21390
21699
|
function definitionOf(name, files) {
|
|
21391
|
-
const
|
|
21392
|
-
const re = new RegExp(`(?:\\b(?:const|let|var)\\s+${
|
|
21700
|
+
const esc5 = name.replace(/\$/g, "\\$");
|
|
21701
|
+
const re = new RegExp(`(?:\\b(?:const|let|var)\\s+${esc5}\\b|\\bfunction\\s+${esc5}\\b)`);
|
|
21393
21702
|
for (const f of files) {
|
|
21394
21703
|
const hit = re.exec(f.m);
|
|
21395
21704
|
if (!hit) continue;
|
|
@@ -21457,7 +21766,7 @@ function scanS28(tree) {
|
|
|
21457
21766
|
if (hit) for (const s of hit[2].matchAll(/["'`]([\w/]+:[\w]+)["'`]/g)) actorDoors.add(s[1]);
|
|
21458
21767
|
}
|
|
21459
21768
|
for (const { f, text, m } of files) {
|
|
21460
|
-
for (let hit =
|
|
21769
|
+
for (let hit = CALL_RE2.exec(m); hit; hit = CALL_RE2.exec(m)) {
|
|
21461
21770
|
const recv = hit[1];
|
|
21462
21771
|
if (!/convex|client/i.test(recv)) continue;
|
|
21463
21772
|
const open = hit.index + hit[0].length - 1;
|
|
@@ -21970,7 +22279,7 @@ var s34AccessRecheck = {
|
|
|
21970
22279
|
};
|
|
21971
22280
|
|
|
21972
22281
|
// src/detectors/s35-scope-in-read.ts
|
|
21973
|
-
var
|
|
22282
|
+
var CALL_RE3 = /\b([A-Za-z_$][\w$]*)\s*\.\s*(query|action)\s*\(/g;
|
|
21974
22283
|
var NARROW_WORD = /\b(?:org|orgId|orgSlug|organizationId|organisationId|organization|organisation|tenantId|namespace|recipient|recipientId|owner|ownerId|createdBy|assignedTo|oauthCtx|fromAllowList)\b/;
|
|
21975
22284
|
var CARRY_WORD = /\b(?:orgId|organizationId|organisationId|tenantId|verifiedOrg|verifiedPerson|verifiedActor|oauthCtx)\b/;
|
|
21976
22285
|
var PAGINATION_WORD = /\b(?:nextCursor|truncated|hasMore|total)\b/;
|
|
@@ -22029,7 +22338,7 @@ function blockEnd(m, at) {
|
|
|
22029
22338
|
return m.length;
|
|
22030
22339
|
}
|
|
22031
22340
|
var lineAt3 = (m, offset) => m.slice(0, offset).split("\n").length;
|
|
22032
|
-
var
|
|
22341
|
+
var esc4 = (s) => s.replace(/\$/g, "\\$");
|
|
22033
22342
|
function boundNames(m, callStart) {
|
|
22034
22343
|
const lineStart = m.lastIndexOf("\n", callStart - 1) + 1;
|
|
22035
22344
|
const before = m.slice(lineStart, callStart);
|
|
@@ -22114,7 +22423,7 @@ function rebound(m, names, from, to) {
|
|
|
22114
22423
|
for (const name of names) {
|
|
22115
22424
|
for (const hit of region.matchAll(
|
|
22116
22425
|
new RegExp(
|
|
22117
|
-
`\\b(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*(?::[^=]+)?=\\s*${
|
|
22426
|
+
`\\b(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*(?::[^=]+)?=\\s*${esc4(name)}\\s*(?:;|$)`,
|
|
22118
22427
|
"gm"
|
|
22119
22428
|
)
|
|
22120
22429
|
)) {
|
|
@@ -22127,7 +22436,7 @@ function narrowingsOver(m, names, from, to) {
|
|
|
22127
22436
|
const out = [];
|
|
22128
22437
|
const region = m.slice(from, to);
|
|
22129
22438
|
for (const name of names) {
|
|
22130
|
-
const n =
|
|
22439
|
+
const n = esc4(name);
|
|
22131
22440
|
for (const hit of region.matchAll(/\bscopeFilter(List|Get)\s*\(/g)) {
|
|
22132
22441
|
const open = from + (hit.index ?? 0) + hit[0].length - 1;
|
|
22133
22442
|
const close = matchClose3(m, open);
|
|
@@ -22173,7 +22482,7 @@ function scanS35(tree) {
|
|
|
22173
22482
|
if (!isProductSource(file.rel)) continue;
|
|
22174
22483
|
const m = masked2(file);
|
|
22175
22484
|
const raw = file.lines.map((l) => l.raw).join("\n");
|
|
22176
|
-
for (const hit of m.matchAll(
|
|
22485
|
+
for (const hit of m.matchAll(CALL_RE3)) {
|
|
22177
22486
|
if (!/convex|client/i.test(hit[1])) continue;
|
|
22178
22487
|
const start = hit.index ?? 0;
|
|
22179
22488
|
const open = start + hit[0].length - 1;
|
|
@@ -22678,6 +22987,17 @@ function declaredVariables(tree) {
|
|
|
22678
22987
|
const vars = [];
|
|
22679
22988
|
const cnj = [];
|
|
22680
22989
|
const calls = callsMatching(tree, /^defineVariables$/);
|
|
22990
|
+
const literalByKey = /* @__PURE__ */ new Map();
|
|
22991
|
+
for (const c of calls) {
|
|
22992
|
+
const o = c.args[0] ? objectOpenAt(c.src, c.args[0][0]) : -1;
|
|
22993
|
+
for (const p of (o >= 0 ? objectProps(c.src, o) : null) ?? []) {
|
|
22994
|
+
if (p.spread) continue;
|
|
22995
|
+
const vo = objectOpenAt(c.src, p.from + c.src.code.slice(p.from, p.to).indexOf(":") + 1);
|
|
22996
|
+
const env = (vo >= 0 ? objectProps(c.src, vo) : null)?.find((q) => q.key === "env");
|
|
22997
|
+
const name = env ? stringLiteral(env.value) : null;
|
|
22998
|
+
if (name !== null) literalByKey.set(p.key, name);
|
|
22999
|
+
}
|
|
23000
|
+
}
|
|
22681
23001
|
for (const c of calls) {
|
|
22682
23002
|
const o = c.args[0] ? objectOpenAt(c.src, c.args[0][0]) : -1;
|
|
22683
23003
|
const props = o >= 0 ? objectProps(c.src, o) : null;
|
|
@@ -22699,7 +23019,14 @@ function declaredVariables(tree) {
|
|
|
22699
23019
|
const vo = objectOpenAt(c.src, p.from + c.src.code.slice(p.from, p.to).indexOf(":") + 1);
|
|
22700
23020
|
const sub = vo >= 0 ? objectProps(c.src, vo) : null;
|
|
22701
23021
|
const env = sub?.find((q) => q.key === "env");
|
|
22702
|
-
|
|
23022
|
+
let envName = env ? stringLiteral(env.value) : null;
|
|
23023
|
+
if (env && envName === null) {
|
|
23024
|
+
const member = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*\.([A-Za-z_$][\w$]*)\s*$/.exec(
|
|
23025
|
+
env.value
|
|
23026
|
+
);
|
|
23027
|
+
const holder = member ? literalByKey.get(member[1]) : void 0;
|
|
23028
|
+
if (holder !== void 0) envName = `\${${holder}}`;
|
|
23029
|
+
}
|
|
22703
23030
|
if (!sub || envName === null) {
|
|
22704
23031
|
cnj.push({
|
|
22705
23032
|
anchor: anchorAt(c.src, p.from),
|
|
@@ -22720,6 +23047,34 @@ function declaredVariables(tree) {
|
|
|
22720
23047
|
}
|
|
22721
23048
|
return { vars, calls: calls.length, cnj };
|
|
22722
23049
|
}
|
|
23050
|
+
function s37Read(shape, o) {
|
|
23051
|
+
const before = shape.slice(Math.max(0, o - 60), o);
|
|
23052
|
+
const after = shape.slice(o);
|
|
23053
|
+
const id = /^[A-Za-z_$][\w$]*/.exec(after)?.[0] ?? "";
|
|
23054
|
+
const rest = after.slice(id.length);
|
|
23055
|
+
if (/(?:process\.)?env\s*\[\s*$/.test(before) && /^\s*\]/.test(rest)) return true;
|
|
23056
|
+
if (/[{,]\s*[A-Za-z_$][\w$]*\s*:\s*$/.test(before) && /^\s*[,}]/.test(rest)) {
|
|
23057
|
+
const open = openingBrace(shape, o);
|
|
23058
|
+
return open >= 0 && /(?:\breturn|(?:[\w$\])]|\s)=)\s*$/.test(shape.slice(Math.max(0, open - 40), open));
|
|
23059
|
+
}
|
|
23060
|
+
return false;
|
|
23061
|
+
}
|
|
23062
|
+
function openingBrace(shape, o) {
|
|
23063
|
+
let depth = 0;
|
|
23064
|
+
for (let i = o - 1; i >= 0; i--) {
|
|
23065
|
+
const c = shape[i];
|
|
23066
|
+
if (c === "}") depth++;
|
|
23067
|
+
else if (c === "{") {
|
|
23068
|
+
if (depth === 0) return i;
|
|
23069
|
+
depth--;
|
|
23070
|
+
}
|
|
23071
|
+
}
|
|
23072
|
+
return -1;
|
|
23073
|
+
}
|
|
23074
|
+
function loopNamesAt(s, bracket) {
|
|
23075
|
+
const id = /^\s*([A-Za-z_$][\w$]*)\s*\]/.exec(s.code.slice(bracket))?.[1];
|
|
23076
|
+
return id === void 0 ? void 0 : enclosingLoopList(s.shape, s.code, bracket, id, s37Read);
|
|
23077
|
+
}
|
|
22723
23078
|
function envReads(s) {
|
|
22724
23079
|
const out = [];
|
|
22725
23080
|
const m = s.shape;
|
|
@@ -22736,6 +23091,12 @@ function envReads(s) {
|
|
|
22736
23091
|
out.push({ src: s, at, name: h[2], form: "process.env.NAME", end: at + h[0].length });
|
|
22737
23092
|
} else {
|
|
22738
23093
|
const { v, end } = lit(at + h[0].length);
|
|
23094
|
+
const listed = v === null ? loopNamesAt(s, at + h[0].length) : void 0;
|
|
23095
|
+
if (listed) {
|
|
23096
|
+
for (const name of listed)
|
|
23097
|
+
out.push({ src: s, at, name, form: "process.env[<name of a literal list>]", end });
|
|
23098
|
+
continue;
|
|
23099
|
+
}
|
|
22739
23100
|
out.push({
|
|
22740
23101
|
src: s,
|
|
22741
23102
|
at,
|
|
@@ -22757,6 +23118,12 @@ function envReads(s) {
|
|
|
22757
23118
|
out.push({ src: s, at, name: h[2], form: "env.NAME", end: at + h[0].length });
|
|
22758
23119
|
} else {
|
|
22759
23120
|
const { v, end } = lit(at + h[0].length);
|
|
23121
|
+
const listed = v === null ? loopNamesAt(s, at + h[0].length) : void 0;
|
|
23122
|
+
if (listed) {
|
|
23123
|
+
for (const name of listed)
|
|
23124
|
+
out.push({ src: s, at, name, form: "env[<name of a literal list>]", end });
|
|
23125
|
+
continue;
|
|
23126
|
+
}
|
|
22760
23127
|
out.push({
|
|
22761
23128
|
src: s,
|
|
22762
23129
|
at,
|
|
@@ -23846,6 +24213,15 @@ function scanS40(tree) {
|
|
|
23846
24213
|
}
|
|
23847
24214
|
res.tools = tools;
|
|
23848
24215
|
res.applies = tools.length > 0;
|
|
24216
|
+
const upstreamCalled = surface.calls.length > 0 || surface.paginatedClients.length > 0 || surface.tokenConstructions.length > 0;
|
|
24217
|
+
const registered2 = toolRegistrations(tree).regs.length;
|
|
24218
|
+
if (tools.length === 0 && upstreamCalled && registered2 > 0 && res.cnj.length === 0) {
|
|
24219
|
+
const first = surface.calls[0]?.anchor ?? surface.paginatedClients[0]?.anchor ?? surface.tokenConstructions[0]?.anchor;
|
|
24220
|
+
res.cnj.push({
|
|
24221
|
+
anchor: first ?? "-",
|
|
24222
|
+
note: `the tree calls an upstream (first: ${first ?? "a paginated client or token construction"}) and registers ${registered2} tool(s), but no tool handler is traced to that call: whether a tool serves upstream rows is unread`
|
|
24223
|
+
});
|
|
24224
|
+
}
|
|
23849
24225
|
const usesFilter = (text) => /(?<![\w$.])filterTargetsInPersonScope\s*\(/.test(text);
|
|
23850
24226
|
for (const t of tools) {
|
|
23851
24227
|
const s = t.src;
|
|
@@ -24596,18 +24972,18 @@ var detectors = registered.map(
|
|
|
24596
24972
|
|
|
24597
24973
|
// src/runtime/launch.ts
|
|
24598
24974
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
24599
|
-
import { existsSync as
|
|
24600
|
-
import { dirname as
|
|
24975
|
+
import { existsSync as existsSync23, readFileSync as readFileSync16, statSync as statSync21 } from "fs";
|
|
24976
|
+
import { dirname as dirname17, isAbsolute, join as join28, resolve as resolve3 } from "path";
|
|
24601
24977
|
function findPackageDir(target) {
|
|
24602
24978
|
let dir;
|
|
24603
24979
|
try {
|
|
24604
|
-
dir = statSync21(target).isDirectory() ? target :
|
|
24980
|
+
dir = statSync21(target).isDirectory() ? target : dirname17(target);
|
|
24605
24981
|
} catch {
|
|
24606
24982
|
return null;
|
|
24607
24983
|
}
|
|
24608
24984
|
for (let depth = 0; depth < 8; depth++) {
|
|
24609
|
-
if (
|
|
24610
|
-
const parent =
|
|
24985
|
+
if (existsSync23(join28(dir, "package.json"))) return dir;
|
|
24986
|
+
const parent = dirname17(dir);
|
|
24611
24987
|
if (parent === dir) break;
|
|
24612
24988
|
dir = parent;
|
|
24613
24989
|
}
|
|
@@ -24631,20 +25007,20 @@ function deriveLaunchPlan(target) {
|
|
|
24631
25007
|
}
|
|
24632
25008
|
let pkg;
|
|
24633
25009
|
try {
|
|
24634
|
-
if (!statSync21(
|
|
24635
|
-
return { error: `${
|
|
25010
|
+
if (!statSync21(join28(pkgDir, "package.json")).isFile()) {
|
|
25011
|
+
return { error: `${join28(pkgDir, "package.json")} is not a regular file \u2014 not read` };
|
|
24636
25012
|
}
|
|
24637
|
-
pkg = JSON.parse(
|
|
25013
|
+
pkg = JSON.parse(readFileSync16(join28(pkgDir, "package.json"), "utf8"));
|
|
24638
25014
|
} catch (err) {
|
|
24639
25015
|
return {
|
|
24640
|
-
error: `could not parse ${
|
|
25016
|
+
error: `could not parse ${join28(pkgDir, "package.json")}: ${err instanceof Error ? err.message : String(err)}`
|
|
24641
25017
|
};
|
|
24642
25018
|
}
|
|
24643
25019
|
const bin = firstBinEntry(pkg.bin);
|
|
24644
25020
|
if (bin) {
|
|
24645
25021
|
return {
|
|
24646
25022
|
command: process.execPath,
|
|
24647
|
-
args: [isAbsolute(bin) ? bin :
|
|
25023
|
+
args: [isAbsolute(bin) ? bin : resolve3(pkgDir, bin)],
|
|
24648
25024
|
cwd: pkgDir
|
|
24649
25025
|
};
|
|
24650
25026
|
}
|
|
@@ -24657,7 +25033,7 @@ function deriveLaunchPlan(target) {
|
|
|
24657
25033
|
if (main2) {
|
|
24658
25034
|
return {
|
|
24659
25035
|
command: process.execPath,
|
|
24660
|
-
args: [isAbsolute(main2) ? main2 :
|
|
25036
|
+
args: [isAbsolute(main2) ? main2 : resolve3(pkgDir, main2)],
|
|
24661
25037
|
cwd: pkgDir
|
|
24662
25038
|
};
|
|
24663
25039
|
}
|
|
@@ -25085,14 +25461,14 @@ function readEvalCounts(target) {
|
|
|
25085
25461
|
if (!pkgDir) return { counts };
|
|
25086
25462
|
let dir = pkgDir;
|
|
25087
25463
|
for (let depth = 0; depth < 8; depth++) {
|
|
25088
|
-
const candidate =
|
|
25089
|
-
if (
|
|
25464
|
+
const candidate = join28(dir, "evals", "evals.json");
|
|
25465
|
+
if (existsSync23(candidate)) {
|
|
25090
25466
|
let text;
|
|
25091
25467
|
try {
|
|
25092
25468
|
if (!statSync21(candidate).isFile()) {
|
|
25093
25469
|
return { counts, unreadable: `${candidate} is not a regular file \u2014 not read` };
|
|
25094
25470
|
}
|
|
25095
|
-
text =
|
|
25471
|
+
text = readFileSync16(candidate, "utf8");
|
|
25096
25472
|
} catch (err) {
|
|
25097
25473
|
return {
|
|
25098
25474
|
counts,
|
|
@@ -25108,7 +25484,7 @@ function readEvalCounts(target) {
|
|
|
25108
25484
|
}
|
|
25109
25485
|
return { counts };
|
|
25110
25486
|
}
|
|
25111
|
-
const parent =
|
|
25487
|
+
const parent = dirname17(dir);
|
|
25112
25488
|
if (parent === dir) break;
|
|
25113
25489
|
dir = parent;
|
|
25114
25490
|
}
|
|
@@ -25721,8 +26097,8 @@ var USAGE = [
|
|
|
25721
26097
|
].join("\n");
|
|
25722
26098
|
function readVersion() {
|
|
25723
26099
|
try {
|
|
25724
|
-
const here =
|
|
25725
|
-
const manifest = JSON.parse(
|
|
26100
|
+
const here = dirname18(fileURLToPath2(import.meta.url));
|
|
26101
|
+
const manifest = JSON.parse(readFileSync17(join29(here, "..", "package.json"), "utf8"));
|
|
25726
26102
|
return manifest.version ?? null;
|
|
25727
26103
|
} catch {
|
|
25728
26104
|
return null;
|
|
@@ -25842,7 +26218,7 @@ function isDirectInvocation() {
|
|
|
25842
26218
|
return false;
|
|
25843
26219
|
}
|
|
25844
26220
|
try {
|
|
25845
|
-
return realpathSync(
|
|
26221
|
+
return realpathSync(resolve4(entry)) === selfReal;
|
|
25846
26222
|
} catch {
|
|
25847
26223
|
return false;
|
|
25848
26224
|
}
|