veoflow 0.4.1 → 0.4.3
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/bin/veoflow.mjs +1 -1
- package/dist/veo.mjs +975 -179
- package/native/veo-extract.darwin-arm64.node +0 -0
- package/native/veo-extract.darwin-x64.node +0 -0
- package/native/veo-extract.linux-arm64-gnu.node +0 -0
- package/native/veo-extract.linux-x64-gnu.node +0 -0
- package/native/veo-extract.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/web/assets/index-C8y32Zs3.css +1 -0
- package/web/assets/index-DcI5_Yly.js +340 -0
- package/web/index.html +2 -2
- package/web/assets/index-B1jlmnXU.js +0 -339
- package/web/assets/index-kkPksq2O.css +0 -1
package/dist/veo.mjs
CHANGED
|
@@ -181,6 +181,8 @@ function classify(path) {
|
|
|
181
181
|
function unsupportedLanguage(path) {
|
|
182
182
|
const name = path.slice(path.lastIndexOf("/") + 1).toLowerCase();
|
|
183
183
|
if (name.endsWith(".component.html")) return "Angular template";
|
|
184
|
+
if (name === "dockerfile" || name.startsWith("dockerfile.") || name.endsWith(".dockerfile"))
|
|
185
|
+
return "Docker";
|
|
184
186
|
const dot = name.lastIndexOf(".");
|
|
185
187
|
return dot > 0 ? UNSUPPORTED[name.slice(dot + 1)] ?? null : null;
|
|
186
188
|
}
|
|
@@ -244,7 +246,15 @@ var init_classify = __esm({
|
|
|
244
246
|
hs: "Haskell",
|
|
245
247
|
lua: "Lua",
|
|
246
248
|
pl: "Perl",
|
|
247
|
-
astro: "Astro"
|
|
249
|
+
astro: "Astro",
|
|
250
|
+
html: "HTML",
|
|
251
|
+
htm: "HTML",
|
|
252
|
+
css: "CSS",
|
|
253
|
+
scss: "CSS",
|
|
254
|
+
sass: "CSS",
|
|
255
|
+
less: "CSS",
|
|
256
|
+
tf: "Terraform",
|
|
257
|
+
hcl: "HCL"
|
|
248
258
|
};
|
|
249
259
|
utf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
250
260
|
}
|
|
@@ -292,7 +302,7 @@ function literalPrefix(pattern) {
|
|
|
292
302
|
return i < 0 ? p : p.slice(0, i);
|
|
293
303
|
}
|
|
294
304
|
function defaultExcludedFile(path) {
|
|
295
|
-
return /\.timestamp-\d+(?:-[0-9a-f]+)?\.[cm]?[jt]s$/i.test(path) ? "generated" : null;
|
|
305
|
+
return /\.timestamp-\d+(?:-[0-9a-f]+)?\.[cm]?[jt]s$/i.test(path) || /[.-]min\.[cm]?js$|\.bundle\.[cm]?js$/i.test(path) ? "generated" : null;
|
|
296
306
|
}
|
|
297
307
|
function defaultExcludedDir(path) {
|
|
298
308
|
const parts = path.split("/");
|
|
@@ -369,6 +379,11 @@ var init_glob = __esm({
|
|
|
369
379
|
".svn",
|
|
370
380
|
"node_modules",
|
|
371
381
|
"bower_components",
|
|
382
|
+
// Vendored third-party code (#261, plan D57): Yarn's releases and plugins, vendor/, third_party/.
|
|
383
|
+
".yarn",
|
|
384
|
+
"vendor",
|
|
385
|
+
"third_party",
|
|
386
|
+
"third-party",
|
|
372
387
|
"dist",
|
|
373
388
|
"build",
|
|
374
389
|
"out",
|
|
@@ -385,7 +400,16 @@ var init_glob = __esm({
|
|
|
385
400
|
...TOOL_DIRS
|
|
386
401
|
]);
|
|
387
402
|
VCS_DIRS = /* @__PURE__ */ new Set([".git", ".hg", ".svn"]);
|
|
388
|
-
LIBRARY_DIRS = /* @__PURE__ */ new Set([
|
|
403
|
+
LIBRARY_DIRS = /* @__PURE__ */ new Set([
|
|
404
|
+
"node_modules",
|
|
405
|
+
"bower_components",
|
|
406
|
+
".venv",
|
|
407
|
+
"venv",
|
|
408
|
+
".yarn",
|
|
409
|
+
"vendor",
|
|
410
|
+
"third_party",
|
|
411
|
+
"third-party"
|
|
412
|
+
]);
|
|
389
413
|
OptIn = class {
|
|
390
414
|
paths;
|
|
391
415
|
anchored;
|
|
@@ -643,7 +667,7 @@ function sha256File(abs) {
|
|
|
643
667
|
}
|
|
644
668
|
return hash2.digest("hex");
|
|
645
669
|
}
|
|
646
|
-
function fileFromBytes(path, language, bytes, maxFileBytes) {
|
|
670
|
+
function fileFromBytes(path, language, bytes, maxFileBytes, optedIn = false) {
|
|
647
671
|
const file2 = { path, language, size: bytes.length, contentHash: sha256(bytes) };
|
|
648
672
|
const skip = languageSkip(path, language);
|
|
649
673
|
if (skip) return { ...file2, skip };
|
|
@@ -651,8 +675,24 @@ function fileFromBytes(path, language, bytes, maxFileBytes) {
|
|
|
651
675
|
if (looksBinary(bytes)) return { ...file2, skip: "binary" };
|
|
652
676
|
const content = decodeUtf8(bytes);
|
|
653
677
|
if (content === null) return { ...file2, skip: "invalid-utf8" };
|
|
678
|
+
if (!optedIn && (language === "javascript" || language === "jsx") && looksMinified(content))
|
|
679
|
+
return { ...file2, skip: "minified" };
|
|
654
680
|
return { ...file2, content };
|
|
655
681
|
}
|
|
682
|
+
function looksMinified(content) {
|
|
683
|
+
if (content.length < MINIFIED_MIN_BYTES) return false;
|
|
684
|
+
let long = 0;
|
|
685
|
+
let space = 0;
|
|
686
|
+
for (const line of content.split("\n"))
|
|
687
|
+
if (line.length > 1e3) {
|
|
688
|
+
long += line.length;
|
|
689
|
+
for (let i = 0; i < line.length; i++) {
|
|
690
|
+
const c = line.charCodeAt(i);
|
|
691
|
+
if (c === 32 || c === 9 || c === 13) space++;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return long > content.length / 2 && space < long * 0.08;
|
|
695
|
+
}
|
|
656
696
|
function planSource(source, options = {}) {
|
|
657
697
|
const maxFileBytes = options.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES;
|
|
658
698
|
const hardMax = Math.max(maxFileBytes, options.hardMaxFileBytes ?? HARD_MAX_FILE_BYTES);
|
|
@@ -712,8 +752,74 @@ function planSource(source, options = {}) {
|
|
|
712
752
|
plan.notices.push("No JavaScript or TypeScript files were found.");
|
|
713
753
|
const unsupported = unsupportedNotice(plan.unsupported);
|
|
714
754
|
if (unsupported) plan.notices.push(unsupported);
|
|
755
|
+
const minified = plan.files.filter((f) => f.skip === "minified").length;
|
|
756
|
+
if (minified)
|
|
757
|
+
plan.notices.push(
|
|
758
|
+
`${minified} minified file${minified === 1 ? " is" : "s are"} not analyzed (built output); choose ${minified === 1 ? "it" : "them"} to analyze anyway.`
|
|
759
|
+
);
|
|
760
|
+
const unread = unreadNotice(plan.files);
|
|
761
|
+
if (unread) plan.notices.push(unread);
|
|
762
|
+
const tooLarge = plan.files.filter((f) => f.skip === "too-large");
|
|
763
|
+
const choosable = tooLarge.filter((f) => f.size <= hardMax).length;
|
|
764
|
+
const never2 = tooLarge.length - choosable;
|
|
765
|
+
if (choosable)
|
|
766
|
+
plan.notices.push(
|
|
767
|
+
`${count(choosable, "file")} over the ${megabytes(maxFileBytes)} size limit ${choosable === 1 ? "is" : "are"} not analyzed; choose ${choosable === 1 ? "it" : "them"} to analyze anyway (up to ${megabytes(hardMax)}).`
|
|
768
|
+
);
|
|
769
|
+
if (never2)
|
|
770
|
+
plan.notices.push(
|
|
771
|
+
`${count(never2, "file")} over ${megabytes(hardMax)} ${never2 === 1 ? "is" : "are"} never analyzed.`
|
|
772
|
+
);
|
|
773
|
+
const ignored = ignoredSourceFolders(source.root, plan.unpinned);
|
|
774
|
+
if (ignored.length)
|
|
775
|
+
plan.notices.push(
|
|
776
|
+
`${ignored.length === 1 ? `${ignored[0]} holds source files but is` : `${ignored.length} folders holding source files (${ignored.slice(0, 3).join(", ")}${ignored.length > 3 ? ", \u2026" : ""}) are`} left out by .gitignore, so ${ignored.length === 1 ? "it isn't" : "they aren't"} in the commit and ${ignored.length === 1 ? "isn't" : "aren't"} analyzed.`
|
|
777
|
+
);
|
|
715
778
|
return plan;
|
|
716
779
|
}
|
|
780
|
+
function unreadNotice(files) {
|
|
781
|
+
const by = /* @__PURE__ */ new Map();
|
|
782
|
+
for (const f of files)
|
|
783
|
+
if (f.skip === "language-not-analyzed") {
|
|
784
|
+
const name = LANGUAGE_NAMES[f.language] ?? f.language;
|
|
785
|
+
by.set(name, (by.get(name) ?? 0) + 1);
|
|
786
|
+
}
|
|
787
|
+
if (!by.size) return null;
|
|
788
|
+
const parts = [...by].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).map(([name, n]) => `${n.toLocaleString("en-US")} ${name} ${n === 1 ? "file" : "files"}`);
|
|
789
|
+
const list = parts.length === 1 ? parts[0] : `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
|
|
790
|
+
const total = [...by.values()].reduce((a, b) => a + b, 0);
|
|
791
|
+
return `${list} ${total === 1 ? "is" : "are"} listed but not analyzed yet: veoflow analyzes JavaScript and TypeScript (with Vue, Svelte and Angular components) today.`;
|
|
792
|
+
}
|
|
793
|
+
function ignoredSourceFolders(root, unpinned) {
|
|
794
|
+
const out = [];
|
|
795
|
+
for (const u of unpinned) {
|
|
796
|
+
if (u.reason !== "gitignored" || !u.path.endsWith("/")) continue;
|
|
797
|
+
const rel = u.path.slice(0, -1);
|
|
798
|
+
if (rel.split("/").some(
|
|
799
|
+
(part) => DEFAULT_EXCLUDED_DIRS.has(part) || OUTPUT_FOLDERS.has(part.toLowerCase()) || part.startsWith(".")
|
|
800
|
+
))
|
|
801
|
+
continue;
|
|
802
|
+
let budget = 2e3;
|
|
803
|
+
const holds = (dir) => {
|
|
804
|
+
let entries;
|
|
805
|
+
try {
|
|
806
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
807
|
+
} catch {
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
for (const e of entries) {
|
|
811
|
+
if (--budget < 0) return false;
|
|
812
|
+
if (e.isFile() && classify(e.name)) return true;
|
|
813
|
+
if (e.isDirectory() && !e.isSymbolicLink() && !DEFAULT_EXCLUDED_DIRS.has(e.name) && !e.name.startsWith(".")) {
|
|
814
|
+
if (holds(join2(dir, e.name))) return true;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return false;
|
|
818
|
+
};
|
|
819
|
+
if (holds(join2(root, ...rel.split("/")))) out.push(u.path);
|
|
820
|
+
}
|
|
821
|
+
return out;
|
|
822
|
+
}
|
|
717
823
|
function isSourcePath(rel) {
|
|
718
824
|
return classify(rel) !== null || rel.toLowerCase().endsWith(".html");
|
|
719
825
|
}
|
|
@@ -996,7 +1102,7 @@ function planGit(source, top, prefix, head, branch, filter, maxFileBytes, hardMa
|
|
|
996
1102
|
});
|
|
997
1103
|
continue;
|
|
998
1104
|
} else {
|
|
999
|
-
planned = fileFromBytes(f.rel, f.language, bytes, limit(f));
|
|
1105
|
+
planned = fileFromBytes(f.rel, f.language, bytes, limit(f), optIn.covers(f.rel));
|
|
1000
1106
|
}
|
|
1001
1107
|
if (f.commit) planned.commit = f.commit;
|
|
1002
1108
|
if (f.origin) planned.origin = f.origin;
|
|
@@ -1196,7 +1302,7 @@ function planPlain(source, filter, maxFileBytes, hardMax, onlyPaths) {
|
|
|
1196
1302
|
plan.files.push({ path: rel, language, size: st.size, contentHash: "", skip: "unreadable" });
|
|
1197
1303
|
continue;
|
|
1198
1304
|
}
|
|
1199
|
-
plan.files.push(fileFromBytes(rel, language, bytes, limit(rel)));
|
|
1305
|
+
plan.files.push(fileFromBytes(rel, language, bytes, limit(rel), optIn.covers(rel)));
|
|
1200
1306
|
}
|
|
1201
1307
|
};
|
|
1202
1308
|
walk(source.root, rootReal, false);
|
|
@@ -1261,7 +1367,7 @@ function planPlain(source, filter, maxFileBytes, hardMax, onlyPaths) {
|
|
|
1261
1367
|
plan.revision = `sha256:${sha256(lines.join(""))}`;
|
|
1262
1368
|
return plan;
|
|
1263
1369
|
}
|
|
1264
|
-
var RULE_EXCLUDED_LIMIT, RuleExcludedCollector, DEFAULT_MAX_FILE_BYTES, HARD_MAX_FILE_BYTES, RESOLVER_MANIFEST, RESOLVER_INPUT, UnsupportedCounter, WORKSPACE_FILES;
|
|
1370
|
+
var RULE_EXCLUDED_LIMIT, RuleExcludedCollector, DEFAULT_MAX_FILE_BYTES, HARD_MAX_FILE_BYTES, RESOLVER_MANIFEST, RESOLVER_INPUT, MINIFIED_MIN_BYTES, count, megabytes, OUTPUT_FOLDERS, LANGUAGE_NAMES, UnsupportedCounter, WORKSPACE_FILES;
|
|
1265
1371
|
var init_plan = __esm({
|
|
1266
1372
|
"packages/planner/src/plan.ts"() {
|
|
1267
1373
|
"use strict";
|
|
@@ -1303,6 +1409,35 @@ var init_plan = __esm({
|
|
|
1303
1409
|
HARD_MAX_FILE_BYTES = 64 * 1024 * 1024;
|
|
1304
1410
|
RESOLVER_MANIFEST = /(^|\/)(package\.json|(ts|js)config[^/]*\.json|package-lock\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml|yarn\.lock|\.npmrc|\.yarnrc\.yml)$/;
|
|
1305
1411
|
RESOLVER_INPUT = /\.(json|jsonc|lock|ya?ml|toml|mod|sum)$|(^|\/)(\.npmrc|\.nvmrc|\.babelrc)$/i;
|
|
1412
|
+
MINIFIED_MIN_BYTES = 2e4;
|
|
1413
|
+
count = (n, noun) => `${n.toLocaleString("en-US")} ${noun}${n === 1 ? "" : "s"}`;
|
|
1414
|
+
megabytes = (bytes) => `${Number((bytes / (1024 * 1024)).toFixed(2))} MB`;
|
|
1415
|
+
OUTPUT_FOLDERS = /* @__PURE__ */ new Set([
|
|
1416
|
+
"lib",
|
|
1417
|
+
"esm",
|
|
1418
|
+
"cjs",
|
|
1419
|
+
"es",
|
|
1420
|
+
"types",
|
|
1421
|
+
"typings",
|
|
1422
|
+
"public",
|
|
1423
|
+
"storybook-static",
|
|
1424
|
+
"cdk.out",
|
|
1425
|
+
"env",
|
|
1426
|
+
"htmlcov",
|
|
1427
|
+
"site",
|
|
1428
|
+
"_site",
|
|
1429
|
+
"out-tsc",
|
|
1430
|
+
"tmp",
|
|
1431
|
+
"temp",
|
|
1432
|
+
"cache",
|
|
1433
|
+
"generated",
|
|
1434
|
+
"gen",
|
|
1435
|
+
"artifacts",
|
|
1436
|
+
"release",
|
|
1437
|
+
"releases",
|
|
1438
|
+
"docs"
|
|
1439
|
+
]);
|
|
1440
|
+
LANGUAGE_NAMES = { python: "Python", go: "Go", rust: "Rust" };
|
|
1306
1441
|
UnsupportedCounter = class {
|
|
1307
1442
|
counts = /* @__PURE__ */ new Map();
|
|
1308
1443
|
add(path) {
|
|
@@ -1360,6 +1495,8 @@ function listDirectory(source, dir, options = {}) {
|
|
|
1360
1495
|
else if (e.kind === "dir" ? filter.excludesDir(e.path) || filter.includesNothingIn(e.path) : !filter.matches(e.path))
|
|
1361
1496
|
entry.excludedBy = "rule";
|
|
1362
1497
|
else if (e.kind === "file" && (e.size ?? 0) > maxFileBytes) entry.excludedBy = "too-large";
|
|
1498
|
+
else if (mayBeMinified(entry) && options.skipped?.(e.path) === "minified")
|
|
1499
|
+
entry.excludedBy = "minified";
|
|
1363
1500
|
} else if (entry.notAnalyzable === "over-hard-cap") entry.excludedBy = "too-large";
|
|
1364
1501
|
entries.push(entry);
|
|
1365
1502
|
}
|
|
@@ -1445,25 +1582,26 @@ function applySelection(source, paths, selected, options = {}) {
|
|
|
1445
1582
|
`${path} can't be analyzed (${first.notAnalyzable === "over-hard-cap" ? "it is over the 64 MB cap" : first.notAnalyzable === "symlink" ? "it is a symbolic link" : "type declarations are not analyzed"})`,
|
|
1446
1583
|
{ fields: ["paths"] }
|
|
1447
1584
|
);
|
|
1448
|
-
const
|
|
1585
|
+
const inside2 = (p) => p === path || p.startsWith(`${path}/`);
|
|
1449
1586
|
const written = (rule) => {
|
|
1450
1587
|
const r = rule.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
1451
|
-
return rule.startsWith("/") && (kind === "dir" ?
|
|
1588
|
+
return rule.startsWith("/") && (kind === "dir" ? inside2(r) : r === path);
|
|
1452
1589
|
};
|
|
1453
1590
|
if (selected) {
|
|
1454
1591
|
rules = { ...rules, exclude: rules.exclude.filter((r) => !written(r)) };
|
|
1455
|
-
if (entry().excludedBy) rules = { ...rules, optIn: [...rules.optIn.filter((p) => !
|
|
1456
|
-
for (const o of rules.optIn.filter((p) => p !== path &&
|
|
1592
|
+
if (entry().excludedBy) rules = { ...rules, optIn: [...rules.optIn.filter((p) => !inside2(p)), path] };
|
|
1593
|
+
for (const o of rules.optIn.filter((p) => p !== path && inside2(p))) {
|
|
1457
1594
|
const without = { ...rules, optIn: rules.optIn.filter((p) => p !== o) };
|
|
1458
1595
|
let needed = false;
|
|
1459
1596
|
try {
|
|
1460
|
-
|
|
1597
|
+
const below = find({ ...source, ...without }, o, options);
|
|
1598
|
+
needed = !!below.excludedBy || mayBeMinified(below);
|
|
1461
1599
|
} catch {
|
|
1462
1600
|
}
|
|
1463
1601
|
if (!needed) rules = without;
|
|
1464
1602
|
}
|
|
1465
1603
|
} else {
|
|
1466
|
-
rules = { ...rules, optIn: rules.optIn.filter((p) => !
|
|
1604
|
+
rules = { ...rules, optIn: rules.optIn.filter((p) => !inside2(p)) };
|
|
1467
1605
|
if (!entry().excludedBy)
|
|
1468
1606
|
rules = { ...rules, exclude: [...rules.exclude, kind === "dir" ? `/${path}/` : `/${path}`] };
|
|
1469
1607
|
}
|
|
@@ -1481,7 +1619,7 @@ function find(source, path, options) {
|
|
|
1481
1619
|
});
|
|
1482
1620
|
return entry;
|
|
1483
1621
|
}
|
|
1484
|
-
var notFound;
|
|
1622
|
+
var notFound, mayBeMinified;
|
|
1485
1623
|
var init_browse = __esm({
|
|
1486
1624
|
"packages/planner/src/browse.ts"() {
|
|
1487
1625
|
"use strict";
|
|
@@ -1494,6 +1632,7 @@ var init_browse = __esm({
|
|
|
1494
1632
|
kind: "folder",
|
|
1495
1633
|
id: dir
|
|
1496
1634
|
});
|
|
1635
|
+
mayBeMinified = (e) => e.kind === "file" && (e.language === "javascript" || e.language === "jsx") && (e.size ?? 0) >= MINIFIED_MIN_BYTES;
|
|
1497
1636
|
}
|
|
1498
1637
|
});
|
|
1499
1638
|
|
|
@@ -1685,6 +1824,7 @@ var init_project_store = __esm({
|
|
|
1685
1824
|
};
|
|
1686
1825
|
SCHEMA = `
|
|
1687
1826
|
CREATE TABLE IF NOT EXISTS meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);
|
|
1827
|
+
CREATE TABLE IF NOT EXISTS run_summaries (run INTEGER NOT NULL, key TEXT NOT NULL, value TEXT NOT NULL, PRIMARY KEY (run, key));
|
|
1688
1828
|
CREATE TABLE IF NOT EXISTS runs (
|
|
1689
1829
|
run_id INTEGER PRIMARY KEY,
|
|
1690
1830
|
kind TEXT NOT NULL,
|
|
@@ -1787,6 +1927,16 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
1787
1927
|
const within = this.stages ? stages.filter((s) => this.stages.includes(s)) : stages;
|
|
1788
1928
|
return new _GraphReader(this.#db, this.run, within, this.base);
|
|
1789
1929
|
}
|
|
1930
|
+
/**
|
|
1931
|
+
* The scopes a stage's visible facts are written under (#259), read through
|
|
1932
|
+
* the scope index: a stage finds what it wrote without reading other facts.
|
|
1933
|
+
*/
|
|
1934
|
+
scopesOf(stage) {
|
|
1935
|
+
if (!STAGE_NAME.test(stage)) throw new Error(`invalid stage name ${JSON.stringify(stage)}`);
|
|
1936
|
+
if (this.stages && !this.stages.includes(stage)) return [];
|
|
1937
|
+
const sql = `SELECT DISTINCT scope FROM facts INDEXED BY facts_by_scope WHERE stage = :stage AND ${visibleAt(this.base === void 0 ? { run: this.run } : { run: this.run, base: this.base })} ORDER BY scope`;
|
|
1938
|
+
return this.#db.prepare(sql).all({ stage, ...this.pin }).map((r) => r.scope);
|
|
1939
|
+
}
|
|
1790
1940
|
rows(where, params) {
|
|
1791
1941
|
const sql = `SELECT payload, rev FROM facts WHERE ${this.visible} AND ${where} ORDER BY id`;
|
|
1792
1942
|
return this.#db.prepare(sql).all({ ...params, ...this.pin }).map((r) => {
|
|
@@ -1995,6 +2145,16 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
1995
2145
|
const row = this.#db.prepare("SELECT * FROM runs WHERE run_id = ?").get(runId);
|
|
1996
2146
|
return row ? toRunInfo(row) : void 0;
|
|
1997
2147
|
}
|
|
2148
|
+
runSummary(runId, key) {
|
|
2149
|
+
const row = this.#db.prepare("SELECT value FROM run_summaries WHERE run = ? AND key = ?").get(runId, key);
|
|
2150
|
+
return row ? JSON.parse(row.value) : void 0;
|
|
2151
|
+
}
|
|
2152
|
+
setRunSummary(runId, key, value) {
|
|
2153
|
+
transaction(this.#db, () => {
|
|
2154
|
+
if (this.runInfo(runId)?.status !== "committed") throw new Error(`run ${runId} is not committed`);
|
|
2155
|
+
this.#db.prepare("INSERT OR REPLACE INTO run_summaries (run, key, value) VALUES (?, ?, ?)").run(runId, key, JSON.stringify(value));
|
|
2156
|
+
});
|
|
2157
|
+
}
|
|
1998
2158
|
/**
|
|
1999
2159
|
* Fail any run left `running` by a process that no longer exists (e.g. it
|
|
2000
2160
|
* was killed), undoing its writes. Returns the recovered run ids.
|
|
@@ -2099,6 +2259,7 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
2099
2259
|
this.#db.prepare("DELETE FROM facts WHERE side = ?").run(run_id);
|
|
2100
2260
|
this.#db.prepare("DELETE FROM side_closed WHERE run = ?").run(run_id);
|
|
2101
2261
|
this.#db.prepare("DELETE FROM runs WHERE run_id = ?").run(run_id);
|
|
2262
|
+
this.#db.prepare("DELETE FROM run_summaries WHERE run = ?").run(run_id);
|
|
2102
2263
|
}
|
|
2103
2264
|
return drafts.length;
|
|
2104
2265
|
}
|
|
@@ -2310,6 +2471,7 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
2310
2471
|
this.#db.prepare("DELETE FROM side_closed WHERE run IN (SELECT value FROM json_each(:dropped))").run({ dropped: droppedSide });
|
|
2311
2472
|
const ids2 = JSON.stringify(drop.map((r) => r.runId));
|
|
2312
2473
|
this.#db.prepare("DELETE FROM runs WHERE run_id IN (SELECT value FROM json_each(?))").run(ids2);
|
|
2474
|
+
this.#db.prepare("DELETE FROM run_summaries WHERE run IN (SELECT value FROM json_each(?))").run(ids2);
|
|
2313
2475
|
this.#db.prepare("DELETE FROM reader_pins WHERE expires_at <= ?").run(at);
|
|
2314
2476
|
return {
|
|
2315
2477
|
runs: drop.map((r) => r.runId),
|
|
@@ -3634,7 +3796,7 @@ var PROTOCOL_VERSION;
|
|
|
3634
3796
|
var init_protocol = __esm({
|
|
3635
3797
|
"protocol/index.ts"() {
|
|
3636
3798
|
"use strict";
|
|
3637
|
-
PROTOCOL_VERSION = "1.
|
|
3799
|
+
PROTOCOL_VERSION = "1.6.0";
|
|
3638
3800
|
}
|
|
3639
3801
|
});
|
|
3640
3802
|
|
|
@@ -3935,7 +4097,7 @@ var init_stage1 = __esm({
|
|
|
3935
4097
|
init_src4();
|
|
3936
4098
|
init_protocol();
|
|
3937
4099
|
STAGE1 = "stage1";
|
|
3938
|
-
QUIET_SKIPS = /* @__PURE__ */ new Set(["language-not-analyzed", "declaration-file", "entitlement"]);
|
|
4100
|
+
QUIET_SKIPS = /* @__PURE__ */ new Set(["language-not-analyzed", "declaration-file", "entitlement", "minified"]);
|
|
3939
4101
|
byOffset = (a, b) => a.site.start.offset - b.site.start.offset || a.site.end.offset - b.site.end.offset;
|
|
3940
4102
|
BATCH_BYTES2 = 32 << 20;
|
|
3941
4103
|
stage1 = { name: STAGE1, run: runStage1 };
|
|
@@ -3963,12 +4125,7 @@ function runTemplateLink(ctx) {
|
|
|
3963
4125
|
scopes.add(scope);
|
|
3964
4126
|
facts.push({ scope, fact });
|
|
3965
4127
|
};
|
|
3966
|
-
for (const
|
|
3967
|
-
if (e.via === "template-link") scopes.add(scopeOf(`${e.evidence.file}|${e.component}`));
|
|
3968
|
-
for (const u of view.facts("UnresolvedCallSite"))
|
|
3969
|
-
if (u.component) scopes.add(scopeOf(`${u.file}|${u.component}`));
|
|
3970
|
-
for (const f of view.facts("Finding"))
|
|
3971
|
-
if (f.id.startsWith(`${TEMPLATE_LINK}|`)) scopes.add(scopeOf(f.component ?? f.file));
|
|
4128
|
+
for (const scope of view.scopesOf(TEMPLATE_LINK)) scopes.add(scope);
|
|
3972
4129
|
const roots = ctx.plans.map((p) => ({
|
|
3973
4130
|
source: p.sourceId,
|
|
3974
4131
|
root: p.root,
|
|
@@ -3999,9 +4156,9 @@ function runTemplateLink(ctx) {
|
|
|
3999
4156
|
if (ownerRoot) {
|
|
4000
4157
|
const abs = join8(ownerRoot.root, ...owner.path.split("/").slice(0, -1), ...d.specifier.split("/"));
|
|
4001
4158
|
for (const r of roots) {
|
|
4002
|
-
const
|
|
4003
|
-
if (
|
|
4004
|
-
const inRel =
|
|
4159
|
+
const inside2 = relative2(r.root, abs);
|
|
4160
|
+
if (inside2 && !inside2.startsWith("..") && !inside2.startsWith(sep4) && !/^[a-zA-Z]:/.test(inside2)) {
|
|
4161
|
+
const inRel = inside2.split(sep4).join("/");
|
|
4005
4162
|
const file2 = fileById.get(ids.file(r.source, inRel));
|
|
4006
4163
|
if (file2)
|
|
4007
4164
|
return file2.language === "angular-template" ? { kind: "file", file: file2 } : { kind: "not-analyzed" };
|
|
@@ -4276,6 +4433,7 @@ var init_engine = __esm({
|
|
|
4276
4433
|
slug2 = (s) => s.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-.]+|-+$/g, "").slice(0, 48) || "source";
|
|
4277
4434
|
LICENSE_FINDINGS = /* @__PURE__ */ new Set(["license", "entitlement", "frozen"]);
|
|
4278
4435
|
Engine = class {
|
|
4436
|
+
afterCommit;
|
|
4279
4437
|
catalog;
|
|
4280
4438
|
/** Run events from every project (run.started, stage.completed, ...). */
|
|
4281
4439
|
events = new EventEmitter();
|
|
@@ -4307,6 +4465,7 @@ var init_engine = __esm({
|
|
|
4307
4465
|
this.repository = options.repository ?? new GraphRepository();
|
|
4308
4466
|
this.license = options.license ?? {};
|
|
4309
4467
|
this.runner = options.runner;
|
|
4468
|
+
this.afterCommit = options.afterCommit;
|
|
4310
4469
|
if (options.runner && options.repository)
|
|
4311
4470
|
throw new Error(
|
|
4312
4471
|
"a runner's run processes use the SQLite backend: give a runner or a repository, not both"
|
|
@@ -4573,7 +4732,10 @@ var init_engine = __esm({
|
|
|
4573
4732
|
id: args.source
|
|
4574
4733
|
});
|
|
4575
4734
|
const maxFileBytes = this.catalog.projectSettings(project2.id).maxFileMB * MB;
|
|
4576
|
-
const rules = applySelection(source, args.paths, args.selected, {
|
|
4735
|
+
const rules = applySelection(source, args.paths, args.selected, {
|
|
4736
|
+
maxFileBytes,
|
|
4737
|
+
skipped: this.lastSkips(project2, source.id)
|
|
4738
|
+
});
|
|
4577
4739
|
return { source: this.catalog.updateSource(project2.id, source.id, rules) };
|
|
4578
4740
|
}
|
|
4579
4741
|
/**
|
|
@@ -4660,7 +4822,16 @@ var init_engine = __esm({
|
|
|
4660
4822
|
project: project2.id,
|
|
4661
4823
|
source: source.id,
|
|
4662
4824
|
dir,
|
|
4663
|
-
entries: listDirectory(source, dir, { maxFileBytes })
|
|
4825
|
+
entries: listDirectory(source, dir, { maxFileBytes, skipped: this.lastSkips(project2, source.id) })
|
|
4826
|
+
};
|
|
4827
|
+
}
|
|
4828
|
+
/** Why the current run skipped each file of a source, read as asked (none before the first run). */
|
|
4829
|
+
lastSkips(project2, sourceId) {
|
|
4830
|
+
if (this.handle(project2).store.currentRun() === null) return void 0;
|
|
4831
|
+
const reader = this.reader(project2);
|
|
4832
|
+
return (path) => {
|
|
4833
|
+
const file2 = reader.fact(ids.file(sourceId, path));
|
|
4834
|
+
return file2?.type === "File" && file2.status === "not_analyzed" ? file2.reason : void 0;
|
|
4664
4835
|
};
|
|
4665
4836
|
}
|
|
4666
4837
|
// -------------------------------------------------------------------------
|
|
@@ -4709,6 +4880,13 @@ var init_engine = __esm({
|
|
|
4709
4880
|
}
|
|
4710
4881
|
}).then((info) => {
|
|
4711
4882
|
if (info.status === "committed") {
|
|
4883
|
+
if (this.afterCommit && info.kind === "history")
|
|
4884
|
+
try {
|
|
4885
|
+
this.afterCommit(this, project2.id, info.runId);
|
|
4886
|
+
} catch (e) {
|
|
4887
|
+
process.stderr.write(`veoflow: after the run: ${e.message}
|
|
4888
|
+
`);
|
|
4889
|
+
}
|
|
4712
4890
|
try {
|
|
4713
4891
|
pruneHistory(handle, this.retention);
|
|
4714
4892
|
} catch (e) {
|
|
@@ -5385,6 +5563,43 @@ var init_engine = __esm({
|
|
|
5385
5563
|
* stages' query modules (plan D43: R2's queries live in their own package).
|
|
5386
5564
|
* R1's own reads stay limited to R1's stages.
|
|
5387
5565
|
*/
|
|
5566
|
+
/**
|
|
5567
|
+
* Start an internal command in a separate process (`<runner> <args…>`, as
|
|
5568
|
+
* runs are), so heavy derived work never blocks this process (#249).
|
|
5569
|
+
* Says "no-runner" when this engine has none (work is then done in-process).
|
|
5570
|
+
*/
|
|
5571
|
+
spawnInternal(args, timeoutMs = 10 * 6e4) {
|
|
5572
|
+
if (!this.runner) return Promise.resolve("no-runner");
|
|
5573
|
+
const [command, ...base2] = this.runner.command;
|
|
5574
|
+
const child = spawn(command, [...base2, ...args], {
|
|
5575
|
+
stdio: "ignore",
|
|
5576
|
+
env: { ...process.env, VEOFLOW_HOME: this.catalog.home }
|
|
5577
|
+
});
|
|
5578
|
+
const timer = setTimeout(() => child.kill(), timeoutMs);
|
|
5579
|
+
timer.unref?.();
|
|
5580
|
+
return new Promise((resolve9) => {
|
|
5581
|
+
child.once("error", () => {
|
|
5582
|
+
clearTimeout(timer);
|
|
5583
|
+
resolve9("failed");
|
|
5584
|
+
});
|
|
5585
|
+
child.once("exit", (code) => {
|
|
5586
|
+
clearTimeout(timer);
|
|
5587
|
+
resolve9(code === 0 ? "ok" : "failed");
|
|
5588
|
+
});
|
|
5589
|
+
});
|
|
5590
|
+
}
|
|
5591
|
+
/** Whether this engine has a run of the project in progress (its process may still be finishing up). */
|
|
5592
|
+
runInProgress(project2) {
|
|
5593
|
+
return (this.inflight.get(project2)?.size ?? 0) > 0;
|
|
5594
|
+
}
|
|
5595
|
+
/** A committed run's kept summary, by key (#249); undefined until one is kept. */
|
|
5596
|
+
runSummary(project2, run2, key) {
|
|
5597
|
+
return this.handle(this.resolveProject({ project: project2 })).store.runSummary(run2, key);
|
|
5598
|
+
}
|
|
5599
|
+
/** Keep a summary derived from a committed run's graph (#249). */
|
|
5600
|
+
setRunSummary(project2, run2, key, value) {
|
|
5601
|
+
this.handle(this.resolveProject({ project: project2 })).store.setRunSummary(run2, key, value);
|
|
5602
|
+
}
|
|
5388
5603
|
readAllStages(args, cwd) {
|
|
5389
5604
|
const project2 = this.resolveProject(args, cwd);
|
|
5390
5605
|
const reader = this.pinnedReader(project2, args.run);
|
|
@@ -5788,9 +6003,9 @@ var init_engine = __esm({
|
|
|
5788
6003
|
total,
|
|
5789
6004
|
groupCount: sorted.length,
|
|
5790
6005
|
truncated: sorted.length > limit,
|
|
5791
|
-
groups: sorted.slice(0, limit).map(([key,
|
|
6006
|
+
groups: sorted.slice(0, limit).map(([key, count2]) => {
|
|
5792
6007
|
const name = named?.(key);
|
|
5793
|
-
return name === void 0 ? { key, count } : { key, count, name };
|
|
6008
|
+
return name === void 0 ? { key, count: count2 } : { key, count: count2, name };
|
|
5794
6009
|
})
|
|
5795
6010
|
};
|
|
5796
6011
|
}
|
|
@@ -5839,6 +6054,11 @@ var init_engine = __esm({
|
|
|
5839
6054
|
}
|
|
5840
6055
|
/** Unresolved call sites: open questions only, unless `includeAll` (design A6). */
|
|
5841
6056
|
listUnresolvedSites(args, cwd) {
|
|
6057
|
+
const paged = args.limit !== void 0 || args.offset !== void 0;
|
|
6058
|
+
if (args.limit !== void 0 && (!Number.isInteger(args.limit) || args.limit < 1))
|
|
6059
|
+
throw new VeoError("invalid-arguments", "limit must be 1 or more", { fields: ["limit"] });
|
|
6060
|
+
if (args.offset !== void 0 && (!Number.isInteger(args.offset) || args.offset < 0))
|
|
6061
|
+
throw new VeoError("invalid-arguments", "offset must be 0 or more", { fields: ["offset"] });
|
|
5842
6062
|
const project2 = this.resolveProject(args, cwd);
|
|
5843
6063
|
this.checkSource(project2, args.source);
|
|
5844
6064
|
const reader = this.reader(project2, args.run);
|
|
@@ -5846,9 +6066,15 @@ var init_engine = __esm({
|
|
|
5846
6066
|
throw new VeoError("not-found", `no file ${args.file}`, { kind: "file", id: args.file });
|
|
5847
6067
|
const everywhere = args.file ? visibleSites(reader.inFile(args.file)) : visibleSites(reader.facts("UnresolvedCallSite"), reader);
|
|
5848
6068
|
const all2 = args.source ? everywhere.filter((s) => s.file.startsWith(`${args.source}:`)) : everywhere;
|
|
6069
|
+
const listed = args.includeAll ? all2 : all2.filter(isOpenQuestion);
|
|
6070
|
+
if (!paged) return { ...this.meta(project2, reader), sites: withProvenance(reader, listed) };
|
|
6071
|
+
const offset = args.offset ?? 0;
|
|
6072
|
+
const page = listed.slice(offset, args.limit === void 0 ? void 0 : offset + args.limit);
|
|
5849
6073
|
return {
|
|
5850
6074
|
...this.meta(project2, reader),
|
|
5851
|
-
sites: withProvenance(reader,
|
|
6075
|
+
sites: withProvenance(reader, page),
|
|
6076
|
+
total: listed.length,
|
|
6077
|
+
offset
|
|
5852
6078
|
};
|
|
5853
6079
|
}
|
|
5854
6080
|
/** The analyzed text around an evidence span (exactly what was analyzed). */
|
|
@@ -6156,6 +6382,12 @@ var init_src6 = __esm({
|
|
|
6156
6382
|
function cmp(a, b) {
|
|
6157
6383
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
6158
6384
|
}
|
|
6385
|
+
function nonNegative(offset) {
|
|
6386
|
+
const n = offset ?? 0;
|
|
6387
|
+
if (!Number.isInteger(n) || n < 0)
|
|
6388
|
+
throw new VeoError("invalid-arguments", "offset must be 0 or more", { fields: ["offset"] });
|
|
6389
|
+
return n;
|
|
6390
|
+
}
|
|
6159
6391
|
function positiveLimit(limit, def, max) {
|
|
6160
6392
|
const n = limit ?? def;
|
|
6161
6393
|
if (!Number.isInteger(n) || n < 1 || n > max)
|
|
@@ -6195,30 +6427,35 @@ function findingsIn(reader, groupOf, files) {
|
|
|
6195
6427
|
path: pathOf(fact.file),
|
|
6196
6428
|
group: groupOf.get(fact.file)?.id ?? null,
|
|
6197
6429
|
line: fact.evidence.span.start.line,
|
|
6198
|
-
text,
|
|
6430
|
+
text: oneLine(text),
|
|
6199
6431
|
reason,
|
|
6200
6432
|
...candidates ? { candidates } : {},
|
|
6201
6433
|
...exhaustive === false ? { exhaustive } : {},
|
|
6202
6434
|
evidence: fact.evidence
|
|
6203
6435
|
});
|
|
6204
6436
|
for (const u of each("UnresolvedImport"))
|
|
6205
|
-
row(u, u.outcome === "broken" ? "broken" : u.outcome, u.specifier, u.reason);
|
|
6437
|
+
if (u.reason !== "asset") row(u, u.outcome === "broken" ? "broken" : u.outcome, u.specifier, u.reason);
|
|
6206
6438
|
const expressions = /* @__PURE__ */ new Map();
|
|
6439
|
+
const resolutions = each("SiteResolution");
|
|
6207
6440
|
const narrowed = new Set(
|
|
6208
|
-
|
|
6441
|
+
resolutions.filter((r) => r.status === "unresolved" && r.importOutcome === null && r.candidates?.length).map((r) => r.site)
|
|
6209
6442
|
);
|
|
6210
6443
|
for (const s of each("UnresolvedCallSite")) {
|
|
6211
6444
|
expressions.set(s.id, s.expression);
|
|
6212
6445
|
if (isOpenQuestion(s) && !narrowed.has(s.id)) row(s, "open-call", s.expression, s.reason);
|
|
6213
6446
|
}
|
|
6214
|
-
for (const r of
|
|
6447
|
+
for (const r of resolutions) {
|
|
6215
6448
|
if (r.status !== "unresolved" || r.importOutcome !== null) continue;
|
|
6216
6449
|
const text = expressions.get(r.site) ?? r.site;
|
|
6217
|
-
if (r.candidates?.length) row(r, "open-call", text, "
|
|
6450
|
+
if (r.candidates?.length) row(r, "open-call", text, "candidates", r.candidates.length, r.exhaustive);
|
|
6218
6451
|
else row(r, "open-call", text, r.steps.at(-1)?.kind ?? "unresolved");
|
|
6219
6452
|
}
|
|
6220
6453
|
return rows.sort(byEvidence);
|
|
6221
6454
|
}
|
|
6455
|
+
function oneLine(text, max = 120) {
|
|
6456
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
6457
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}\u2026` : flat;
|
|
6458
|
+
}
|
|
6222
6459
|
function tally(counts, kind) {
|
|
6223
6460
|
if (kind === "broken") counts.broken++;
|
|
6224
6461
|
else if (kind === "not-analyzed") counts.notAnalyzed++;
|
|
@@ -6242,27 +6479,38 @@ function summary(g, functions, findings) {
|
|
|
6242
6479
|
}
|
|
6243
6480
|
function listGroups(engine, args, cwd) {
|
|
6244
6481
|
const limit = positiveLimit(args.limit, GROUPS_MAX, GROUPS_MAX);
|
|
6482
|
+
const offset = nonNegative(args.offset);
|
|
6245
6483
|
const { meta: meta3, reader, stage2: stage22 } = open(engine, args, cwd);
|
|
6246
6484
|
const inScope = (source) => args.source === void 0 || source === args.source;
|
|
6247
6485
|
const groups2 = reader.facts("Group").filter((g) => inScope(g.source)).sort((a, b) => cmp(a.id, b.id));
|
|
6248
6486
|
const groupOf = groupIndex(groups2);
|
|
6249
6487
|
const findings = /* @__PURE__ */ new Map();
|
|
6250
|
-
let
|
|
6488
|
+
let brokenImports2 = 0;
|
|
6251
6489
|
let openCalls = 0;
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
if (
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6490
|
+
const run2 = args.run ?? meta3.committedRun;
|
|
6491
|
+
const kept = run2 === null ? void 0 : keptFindingSummary(engine, meta3.project, run2);
|
|
6492
|
+
if (kept) {
|
|
6493
|
+
for (const g of groups2) if (kept.groups[g.id]) findings.set(g.id, kept.groups[g.id]);
|
|
6494
|
+
for (const [source, c] of Object.entries(kept.sources))
|
|
6495
|
+
if (inScope(source)) {
|
|
6496
|
+
brokenImports2 += c.broken;
|
|
6497
|
+
openCalls += c.openCalls;
|
|
6498
|
+
}
|
|
6499
|
+
} else
|
|
6500
|
+
for (const f of findingsIn(reader, groupOf, null)) {
|
|
6501
|
+
if (!inScope(sourceOf2(f.file))) continue;
|
|
6502
|
+
if (f.kind === "broken") brokenImports2++;
|
|
6503
|
+
if (f.kind === "open-call") openCalls++;
|
|
6504
|
+
if (!f.group) continue;
|
|
6505
|
+
const c = findings.get(f.group) ?? zero();
|
|
6506
|
+
tally(c, f.kind);
|
|
6507
|
+
findings.set(f.group, c);
|
|
6508
|
+
}
|
|
6261
6509
|
const functions = reader.countByFile("Function");
|
|
6262
6510
|
const files = reader.facts("File").filter((f) => inScope(f.source));
|
|
6263
6511
|
let fnCount = 0;
|
|
6264
6512
|
for (const f of files) fnCount += functions.get(f.id) ?? 0;
|
|
6265
|
-
const shown = groups2.slice(
|
|
6513
|
+
const shown = groups2.slice(offset, offset + limit);
|
|
6266
6514
|
const ids2 = new Set(shown.map((g) => g.id));
|
|
6267
6515
|
const importers = /* @__PURE__ */ new Map();
|
|
6268
6516
|
for (const g of groups2) for (const p of g.externalPackages) importers.set(p, (importers.get(p) ?? 0) + 1);
|
|
@@ -6276,12 +6524,13 @@ function listGroups(engine, args, cwd) {
|
|
|
6276
6524
|
stats: {
|
|
6277
6525
|
files: files.length,
|
|
6278
6526
|
functions: fnCount,
|
|
6279
|
-
crossFileCalls: reader.
|
|
6280
|
-
brokenImports,
|
|
6527
|
+
crossFileCalls: [...reader.countByFile("CALLS_CROSS_FILE")].filter(([file2]) => inScope(sourceOf2(file2))).reduce((n, [, c]) => n + c, 0),
|
|
6528
|
+
brokenImports: brokenImports2,
|
|
6281
6529
|
openCalls
|
|
6282
6530
|
},
|
|
6283
6531
|
total: groups2.length,
|
|
6284
|
-
|
|
6532
|
+
offset,
|
|
6533
|
+
truncated: groups2.length > offset + limit,
|
|
6285
6534
|
groups: shown.map((g) => summary(g, functions, findings)),
|
|
6286
6535
|
dependsOn: reader.facts("DEPENDS_ON").filter((d) => ids2.has(d.from) && ids2.has(d.to)).sort((a, b) => cmp(a.id, b.id)).map(({ id, from, to, imports, calls, evidence }) => ({ id, from, to, imports, calls, evidence })),
|
|
6287
6536
|
externalPackages: {
|
|
@@ -6555,6 +6804,33 @@ function listFindings(engine, args, cwd) {
|
|
|
6555
6804
|
files = g.files;
|
|
6556
6805
|
} else if (args.file !== void 0) files = [fileFact(reader, args.file).id];
|
|
6557
6806
|
const kinds = new Set(args.kind?.length ? args.kind : ["broken", "not-analyzed", "open-call"]);
|
|
6807
|
+
const offset = nonNegative(args.offset);
|
|
6808
|
+
const run2 = args.run ?? meta3.committedRun;
|
|
6809
|
+
const kept = run2 === null || args.source !== void 0 || args.file !== void 0 ? void 0 : keptFindingSummary(engine, meta3.project, run2);
|
|
6810
|
+
const keptCounts = kept && (args.group === void 0 ? kept.counts : kept.groups[args.group] ?? zero());
|
|
6811
|
+
if (keptCounts) {
|
|
6812
|
+
const order = (files ?? reader.facts("File").map((f) => f.id)).slice().sort(cmp);
|
|
6813
|
+
const total = [...kinds].reduce((n, k) => n + keptCounts[KIND_COUNT[k]], 0);
|
|
6814
|
+
const page = [];
|
|
6815
|
+
let skipped = 0;
|
|
6816
|
+
for (const file2 of order) {
|
|
6817
|
+
if (page.length >= limit || skipped + page.length >= total) break;
|
|
6818
|
+
for (const f of findingsIn(reader, groupOf, [file2])) {
|
|
6819
|
+
if (!kinds.has(f.kind)) continue;
|
|
6820
|
+
if (skipped < offset) skipped++;
|
|
6821
|
+
else page.push(f);
|
|
6822
|
+
}
|
|
6823
|
+
}
|
|
6824
|
+
return {
|
|
6825
|
+
...meta3,
|
|
6826
|
+
stage2: stage22,
|
|
6827
|
+
counts: keptCounts,
|
|
6828
|
+
total,
|
|
6829
|
+
offset,
|
|
6830
|
+
truncated: offset + Math.min(page.length, limit) < total,
|
|
6831
|
+
findings: page.slice(0, limit)
|
|
6832
|
+
};
|
|
6833
|
+
}
|
|
6558
6834
|
const counts = zero();
|
|
6559
6835
|
const rows = [];
|
|
6560
6836
|
for (const f of findingsIn(reader, groupOf, files)) {
|
|
@@ -6567,8 +6843,9 @@ function listFindings(engine, args, cwd) {
|
|
|
6567
6843
|
stage2: stage22,
|
|
6568
6844
|
counts,
|
|
6569
6845
|
total: rows.length,
|
|
6570
|
-
|
|
6571
|
-
|
|
6846
|
+
offset,
|
|
6847
|
+
truncated: rows.length > offset + limit,
|
|
6848
|
+
findings: rows.slice(offset, offset + limit)
|
|
6572
6849
|
};
|
|
6573
6850
|
}
|
|
6574
6851
|
function siteLinks(engine, args, cwd) {
|
|
@@ -6611,7 +6888,30 @@ function siteLinks(engine, args, cwd) {
|
|
|
6611
6888
|
});
|
|
6612
6889
|
return { ...meta3, stage2: stage22, links };
|
|
6613
6890
|
}
|
|
6614
|
-
|
|
6891
|
+
function summarizeFindings(engine, project2, run2) {
|
|
6892
|
+
const { reader } = open(engine, { project: project2, run: run2 });
|
|
6893
|
+
const files = reader.facts("File");
|
|
6894
|
+
const summary2 = {
|
|
6895
|
+
counts: zero(),
|
|
6896
|
+
groups: {},
|
|
6897
|
+
sources: {},
|
|
6898
|
+
files: {
|
|
6899
|
+
listed: files.length,
|
|
6900
|
+
analyzed: files.filter((f) => f.status === "analyzed" || f.status === "degraded").length
|
|
6901
|
+
}
|
|
6902
|
+
};
|
|
6903
|
+
for (const f of findingsIn(reader, groupIndex(reader.facts("Group")), null)) {
|
|
6904
|
+
tally(summary2.counts, f.kind);
|
|
6905
|
+
if (f.group) tally(summary2.groups[f.group] ??= zero(), f.kind);
|
|
6906
|
+
tally(summary2.sources[sourceOf2(f.file)] ??= zero(), f.kind);
|
|
6907
|
+
}
|
|
6908
|
+
engine.setRunSummary(project2, run2, FINDINGS_SUMMARY, summary2);
|
|
6909
|
+
return summary2.counts;
|
|
6910
|
+
}
|
|
6911
|
+
function keptFindingSummary(engine, project2, run2) {
|
|
6912
|
+
return engine.runSummary(project2, run2, FINDINGS_SUMMARY);
|
|
6913
|
+
}
|
|
6914
|
+
var STAGE2, GROUPS_MAX, GROUP_NODES_MAX, GROUP_COLLAPSE_OVER, IMPORTS_MAX, FINDINGS_MAX, TOP_PACKAGES, pathOf, sourceOf2, byEvidence, FINDING_KINDS, KIND_COUNT, zero, FINDINGS_SUMMARY;
|
|
6615
6915
|
var init_reads = __esm({
|
|
6616
6916
|
"packages/query-imports/src/reads.ts"() {
|
|
6617
6917
|
"use strict";
|
|
@@ -6627,7 +6927,14 @@ var init_reads = __esm({
|
|
|
6627
6927
|
sourceOf2 = (fileId) => fileId.slice(0, fileId.indexOf(":"));
|
|
6628
6928
|
byEvidence = (a, b) => cmp(a.evidence.file, b.evidence.file) || a.evidence.span.start.offset - b.evidence.span.start.offset || cmp(a.id, b.id);
|
|
6629
6929
|
FINDING_KINDS = ["broken", "not-analyzed", "pending", "open-call"];
|
|
6930
|
+
KIND_COUNT = {
|
|
6931
|
+
broken: "broken",
|
|
6932
|
+
"not-analyzed": "notAnalyzed",
|
|
6933
|
+
pending: "pending",
|
|
6934
|
+
"open-call": "openCalls"
|
|
6935
|
+
};
|
|
6630
6936
|
zero = () => ({ broken: 0, notAnalyzed: 0, pending: 0, openCalls: 0 });
|
|
6937
|
+
FINDINGS_SUMMARY = "findings/v3";
|
|
6631
6938
|
}
|
|
6632
6939
|
});
|
|
6633
6940
|
|
|
@@ -6870,7 +7177,8 @@ function explain(engine, args, cwd) {
|
|
|
6870
7177
|
stage2: stage22,
|
|
6871
7178
|
total: items.length,
|
|
6872
7179
|
truncated: items.length > EXPLAIN_MAX,
|
|
6873
|
-
items: items.slice(0, EXPLAIN_MAX)
|
|
7180
|
+
items: items.slice(0, EXPLAIN_MAX),
|
|
7181
|
+
...file2.status !== "analyzed" ? { file: { status: file2.status, ...file2.reason ? { reason: file2.reason } : {} } } : {}
|
|
6874
7182
|
};
|
|
6875
7183
|
}
|
|
6876
7184
|
var EXPLAIN_MAX, pathOf2, cmp2, IMPORT_REASONS, SITE_REASONS, STATUS_WORDS, base, RESOLUTION_WORDS;
|
|
@@ -6891,6 +7199,8 @@ var init_explain = __esm({
|
|
|
6891
7199
|
"default-excluded": "the file is in a folder left out of analysis (installed, generated or tool code)",
|
|
6892
7200
|
"excluded-by-rule": "a rule of the source leaves the file out",
|
|
6893
7201
|
"too-large": "the file is over the size limit",
|
|
7202
|
+
asset: "it is a stylesheet, image, font or data file the bundler handles, not code",
|
|
7203
|
+
minified: "the file is minified (built output); choose it to analyze it",
|
|
6894
7204
|
"language-not-analyzed": "the file's language isn't analyzed yet"
|
|
6895
7205
|
};
|
|
6896
7206
|
SITE_REASONS = {
|
|
@@ -6901,6 +7211,7 @@ var init_explain = __esm({
|
|
|
6901
7211
|
"dynamic-sql": "it runs SQL built at run time",
|
|
6902
7212
|
"imported-symbol": "it calls something imported from another file, which Stage 2 links",
|
|
6903
7213
|
"runtime-global": "it is part of the language or runtime (a built-in), outside the code analyzed",
|
|
7214
|
+
"builtin-value": "the value it is called on is built in (a string, a number, a DOM element, a fetch response), so it runs code of the runtime, outside the code analyzed",
|
|
6904
7215
|
"template-binding": "it is a call in a template file, resolved against the components that declare the template",
|
|
6905
7216
|
"template-reference": "it names a component, directive, pipe or member registered outside this file, which Stage 2 links"
|
|
6906
7217
|
};
|
|
@@ -7024,10 +7335,51 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
7024
7335
|
},
|
|
7025
7336
|
stage2: { agree: 0, "different-callee": 0, "checker-only": 0, "not-linked-yet": 0, changed: 0 }
|
|
7026
7337
|
};
|
|
7338
|
+
const compilerCallees = (s) => {
|
|
7339
|
+
const out = /* @__PURE__ */ new Set();
|
|
7340
|
+
for (const c of calls) {
|
|
7341
|
+
if (c.file !== s.file || c.site.start.line !== s.line || c.site.start.column !== s.column) continue;
|
|
7342
|
+
if (c.site.end.line !== s.end.line || c.site.end.column !== s.end.column || !c.callee) continue;
|
|
7343
|
+
const def = checkers.adapterDef(adapterFiles, c);
|
|
7344
|
+
const fn = def ? reader.facts("Function", fileId(c.callee.file)).find((f) => f.qualifiedName === def.qualifiedName) : void 0;
|
|
7345
|
+
if (fn) out.add(fn.id);
|
|
7346
|
+
}
|
|
7347
|
+
return out;
|
|
7348
|
+
};
|
|
7349
|
+
const perFile = /* @__PURE__ */ new Map();
|
|
7350
|
+
const factsOf = (file2) => {
|
|
7351
|
+
let got = perFile.get(file2);
|
|
7352
|
+
if (!got) {
|
|
7353
|
+
got = {
|
|
7354
|
+
sites: reader.facts("UnresolvedCallSite", file2),
|
|
7355
|
+
resolutions: new Map(reader.facts("SiteResolution", file2).map((r) => [r.site, r]))
|
|
7356
|
+
};
|
|
7357
|
+
perFile.set(file2, got);
|
|
7358
|
+
}
|
|
7359
|
+
return got;
|
|
7360
|
+
};
|
|
7361
|
+
const candidatesAt = (s) => {
|
|
7362
|
+
const file2 = fileId(s.file);
|
|
7363
|
+
const { sites: sites2, resolutions } = factsOf(file2);
|
|
7364
|
+
const site = sites2.find(
|
|
7365
|
+
(x) => x.evidence.span.start.line === s.line && x.evidence.span.start.column === s.column && x.evidence.span.end.line === s.end.line && x.evidence.span.end.column === s.end.column
|
|
7366
|
+
);
|
|
7367
|
+
const res = site && resolutions.get(site.id);
|
|
7368
|
+
if (!res?.candidates?.length) return void 0;
|
|
7369
|
+
const functions = res.candidates.map((c) => c.function);
|
|
7370
|
+
const compiler = compilerCallees(s);
|
|
7371
|
+
return {
|
|
7372
|
+
functions,
|
|
7373
|
+
exhaustive: res.exhaustive !== false,
|
|
7374
|
+
// Unknown, not "not among them", when the compiler's callee maps to no function.
|
|
7375
|
+
...compiler.size ? { includesCompiler: functions.some((f) => compiler.has(f)) } : {}
|
|
7376
|
+
};
|
|
7377
|
+
};
|
|
7027
7378
|
for (const s of report.sites) {
|
|
7028
7379
|
if (DISAGREE.has(s.category)) {
|
|
7029
7380
|
const category2 = s.category;
|
|
7030
7381
|
counts.stage1[category2]++;
|
|
7382
|
+
const narrowed = category2 === "checker-only" && stage22 ? candidatesAt(s) : void 0;
|
|
7031
7383
|
sites.push({
|
|
7032
7384
|
stage: "stage1",
|
|
7033
7385
|
category: category2,
|
|
@@ -7037,7 +7389,8 @@ async function checkCode(engine, args, cwd = process.cwd()) {
|
|
|
7037
7389
|
column: s.column,
|
|
7038
7390
|
veoflow: s.adapter,
|
|
7039
7391
|
compiler: s.checker,
|
|
7040
|
-
...changed.has(s.file) ? { changed: true } : {}
|
|
7392
|
+
...changed.has(s.file) ? { changed: true } : {},
|
|
7393
|
+
...narrowed ? { candidates: narrowed } : {}
|
|
7041
7394
|
});
|
|
7042
7395
|
continue;
|
|
7043
7396
|
}
|
|
@@ -7107,6 +7460,84 @@ var init_check = __esm({
|
|
|
7107
7460
|
}
|
|
7108
7461
|
});
|
|
7109
7462
|
|
|
7463
|
+
// packages/query-imports/src/totals.ts
|
|
7464
|
+
function projectTotals(engine, args, cwd) {
|
|
7465
|
+
const top = args.top ?? 10;
|
|
7466
|
+
if (!Number.isInteger(top) || top < 0 || top > TOTALS_TOP_MAX)
|
|
7467
|
+
throw new VeoError("invalid-arguments", `top must be 0 to ${TOTALS_TOP_MAX}`, { fields: ["top"] });
|
|
7468
|
+
if (args.source !== void 0 && (typeof args.source !== "string" || args.source === ""))
|
|
7469
|
+
throw new VeoError("invalid-arguments", "source must be a non-empty id", { fields: ["source"] });
|
|
7470
|
+
const { meta: meta3, reader } = engine.readAllStages(args, cwd);
|
|
7471
|
+
const inScope = (id) => args.source === void 0 || id.startsWith(`${args.source}:`);
|
|
7472
|
+
const sum = (counts) => {
|
|
7473
|
+
let n = 0;
|
|
7474
|
+
for (const [file2, c] of counts) if (inScope(file2)) n += c;
|
|
7475
|
+
return n;
|
|
7476
|
+
};
|
|
7477
|
+
const fileOf = (fn) => fn.slice(0, fn.indexOf(":", fn.indexOf(":") + 1));
|
|
7478
|
+
const files = { listed: 0, analyzed: 0, partly: 0, notAnalyzed: [] };
|
|
7479
|
+
const why = /* @__PURE__ */ new Map();
|
|
7480
|
+
const listed = reader.facts("File").filter((f) => inScope(f.id));
|
|
7481
|
+
for (const f of listed) {
|
|
7482
|
+
files.listed++;
|
|
7483
|
+
if (f.status === "analyzed") files.analyzed++;
|
|
7484
|
+
else if (f.status === "degraded") files.partly++;
|
|
7485
|
+
else {
|
|
7486
|
+
const reason = f.reason ?? f.status;
|
|
7487
|
+
why.set(reason, (why.get(reason) ?? 0) + 1);
|
|
7488
|
+
}
|
|
7489
|
+
}
|
|
7490
|
+
files.notAnalyzed = [...why].map(([reason, n]) => ({ reason, files: n })).sort((a, b) => b.files - a.files || (a.reason < b.reason ? -1 : 1));
|
|
7491
|
+
let mostCalled2 = [];
|
|
7492
|
+
if (top > 0) {
|
|
7493
|
+
const own2 = new Map(listed.filter((f) => !f.origin).map((f) => [f.id, f.path]));
|
|
7494
|
+
mostCalled2 = [...reader.callCounts("dst")].filter(([id]) => own2.has(fileOf(id))).sort((a, b) => b[1].calls - a[1].calls || (a[0] < b[0] ? -1 : 1)).slice(0, top).map(([id, c]) => {
|
|
7495
|
+
const f = reader.fact(id);
|
|
7496
|
+
const file2 = fileOf(id);
|
|
7497
|
+
return {
|
|
7498
|
+
id,
|
|
7499
|
+
name: f?.type === "Function" ? f.qualifiedName : id.slice(file2.length + 1),
|
|
7500
|
+
path: own2.get(file2),
|
|
7501
|
+
calls: c.calls,
|
|
7502
|
+
callers: c.functions
|
|
7503
|
+
};
|
|
7504
|
+
});
|
|
7505
|
+
}
|
|
7506
|
+
const findings = listFindings(
|
|
7507
|
+
engine,
|
|
7508
|
+
{
|
|
7509
|
+
...args.project !== void 0 ? { project: args.project } : {},
|
|
7510
|
+
// The same run as the counts above, even if another commits meanwhile.
|
|
7511
|
+
...args.run !== void 0 ? { run: args.run } : meta3.committedRun !== null ? { run: meta3.committedRun } : {},
|
|
7512
|
+
...args.source !== void 0 ? { source: args.source } : {},
|
|
7513
|
+
kind: ["open-call"],
|
|
7514
|
+
limit: 1
|
|
7515
|
+
},
|
|
7516
|
+
cwd
|
|
7517
|
+
);
|
|
7518
|
+
return {
|
|
7519
|
+
...meta3,
|
|
7520
|
+
stage2: reader.count("Group") > 0,
|
|
7521
|
+
source: args.source ?? null,
|
|
7522
|
+
calls: {
|
|
7523
|
+
withinFiles: sum(reader.countByFile("CALLS")),
|
|
7524
|
+
acrossFiles: sum(reader.countByFile("CALLS_CROSS_FILE"))
|
|
7525
|
+
},
|
|
7526
|
+
openCalls: findings.counts.openCalls,
|
|
7527
|
+
files,
|
|
7528
|
+
mostCalled: mostCalled2
|
|
7529
|
+
};
|
|
7530
|
+
}
|
|
7531
|
+
var TOTALS_TOP_MAX;
|
|
7532
|
+
var init_totals = __esm({
|
|
7533
|
+
"packages/query-imports/src/totals.ts"() {
|
|
7534
|
+
"use strict";
|
|
7535
|
+
init_src();
|
|
7536
|
+
init_reads();
|
|
7537
|
+
TOTALS_TOP_MAX = 100;
|
|
7538
|
+
}
|
|
7539
|
+
});
|
|
7540
|
+
|
|
7110
7541
|
// packages/query-imports/src/report.ts
|
|
7111
7542
|
import { arch, platform, release } from "node:os";
|
|
7112
7543
|
function spanOf(f) {
|
|
@@ -7295,6 +7726,7 @@ var init_src7 = __esm({
|
|
|
7295
7726
|
init_reads();
|
|
7296
7727
|
init_explain();
|
|
7297
7728
|
init_check();
|
|
7729
|
+
init_totals();
|
|
7298
7730
|
init_report();
|
|
7299
7731
|
CROSS_FILE_CALLS_MAX = 500;
|
|
7300
7732
|
}
|
|
@@ -9404,11 +9836,11 @@ function lockedVersions(path, text) {
|
|
|
9404
9836
|
}
|
|
9405
9837
|
function statements(source, path, result2) {
|
|
9406
9838
|
const fileId = ids.file(source, path);
|
|
9407
|
-
const
|
|
9839
|
+
const byKey2 = /* @__PURE__ */ new Map();
|
|
9408
9840
|
const formOf = (i) => i.kind === "require" ? "require" : i.kind === "dynamic" ? "dynamic" : i.typeOnly ? "type-only" : "static";
|
|
9409
9841
|
for (const i of result2.imports) {
|
|
9410
9842
|
const key = `${i.span.start.offset}\0${i.specifier}`;
|
|
9411
|
-
const existing =
|
|
9843
|
+
const existing = byKey2.get(key);
|
|
9412
9844
|
const binding2 = [
|
|
9413
9845
|
i.kind === "namespace" ? "*" : i.importedName,
|
|
9414
9846
|
i.localName
|
|
@@ -9418,7 +9850,7 @@ function statements(source, path, result2) {
|
|
|
9418
9850
|
if (existing.form === "type-only" && !i.typeOnly) existing.form = "static";
|
|
9419
9851
|
continue;
|
|
9420
9852
|
}
|
|
9421
|
-
|
|
9853
|
+
byKey2.set(key, {
|
|
9422
9854
|
source,
|
|
9423
9855
|
path,
|
|
9424
9856
|
fileId,
|
|
@@ -9436,12 +9868,12 @@ function statements(source, path, result2) {
|
|
|
9436
9868
|
e.kind === "reexport-all" ? "*" : e.sourceName ?? e.exportedName,
|
|
9437
9869
|
e.exportedName
|
|
9438
9870
|
];
|
|
9439
|
-
const existing =
|
|
9871
|
+
const existing = byKey2.get(key);
|
|
9440
9872
|
if (existing) {
|
|
9441
9873
|
existing.bindings.push(binding2);
|
|
9442
9874
|
if (existing.form === "type-only" && !e.typeOnly) existing.form = "re-export";
|
|
9443
9875
|
} else
|
|
9444
|
-
|
|
9876
|
+
byKey2.set(key, {
|
|
9445
9877
|
source,
|
|
9446
9878
|
path,
|
|
9447
9879
|
fileId,
|
|
@@ -9451,7 +9883,7 @@ function statements(source, path, result2) {
|
|
|
9451
9883
|
bindings: [binding2]
|
|
9452
9884
|
});
|
|
9453
9885
|
}
|
|
9454
|
-
const list = [...
|
|
9886
|
+
const list = [...byKey2.values()].sort(
|
|
9455
9887
|
(a, b) => a.span.start.offset - b.span.start.offset || (a.specifier < b.specifier ? -1 : 1)
|
|
9456
9888
|
);
|
|
9457
9889
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -9562,8 +9994,8 @@ function resolveImports2(plans, files) {
|
|
|
9562
9994
|
const escapes = /* @__PURE__ */ new Map();
|
|
9563
9995
|
for (const s of toResolve) {
|
|
9564
9996
|
if (!isRelative(s.specifier)) continue;
|
|
9565
|
-
const
|
|
9566
|
-
if (
|
|
9997
|
+
const inside2 = posix2.normalize(posix2.join(posix2.dirname(s.path), s.specifier));
|
|
9998
|
+
if (inside2 !== ".." && !inside2.startsWith("../")) continue;
|
|
9567
9999
|
const plan = treeOf.get(s.source).plan;
|
|
9568
10000
|
const abs = resolvePath(plan.root, ...posix2.dirname(s.path).split("/"), ...s.specifier.split("/"));
|
|
9569
10001
|
const within = (root) => {
|
|
@@ -10265,8 +10697,15 @@ function resolveImports2(plans, files) {
|
|
|
10265
10697
|
target2 = {
|
|
10266
10698
|
kind: "unresolved",
|
|
10267
10699
|
outcome: "not-analyzed",
|
|
10268
|
-
|
|
10269
|
-
|
|
10700
|
+
// A stylesheet, image, font or data file isn't code to analyze (#265): `asset`, not a finding.
|
|
10701
|
+
reason: file2?.reason ?? (file2 ? "not-analyzed" : isAsset(where) ? "asset" : "language-not-analyzed"),
|
|
10702
|
+
steps: [
|
|
10703
|
+
...steps,
|
|
10704
|
+
{
|
|
10705
|
+
kind: "not-analyzed",
|
|
10706
|
+
detail: !file2 && isAsset(where) ? `${where} is an asset (not code)` : `${where} is not analyzed`
|
|
10707
|
+
}
|
|
10708
|
+
]
|
|
10270
10709
|
};
|
|
10271
10710
|
} else if (aliasOutside) {
|
|
10272
10711
|
target2 = {
|
|
@@ -10753,7 +11192,7 @@ function importFacts(resolved) {
|
|
|
10753
11192
|
}
|
|
10754
11193
|
return { edges, unresolved, packages: [...packages.values()] };
|
|
10755
11194
|
}
|
|
10756
|
-
var import_semver, SCRIPT_LANGUAGES, BATCH_BYTES3, BUILTINS, PROBE_EXTENSIONS, OWN_EXTENSIONS, VITE_BASED, DOCUSAURUS_CLIENT, isRelative, isUrl, DEPENDENCY_FIELDS, aboveCache;
|
|
11195
|
+
var import_semver, SCRIPT_LANGUAGES, BATCH_BYTES3, BUILTINS, PROBE_EXTENSIONS, ASSET, isAsset, OWN_EXTENSIONS, VITE_BASED, DOCUSAURUS_CLIENT, isRelative, isUrl, DEPENDENCY_FIELDS, aboveCache;
|
|
10757
11196
|
var init_imports = __esm({
|
|
10758
11197
|
"packages/stage2/src/imports.ts"() {
|
|
10759
11198
|
"use strict";
|
|
@@ -10778,6 +11217,8 @@ var init_imports = __esm({
|
|
|
10778
11217
|
".svelte",
|
|
10779
11218
|
".json"
|
|
10780
11219
|
];
|
|
11220
|
+
ASSET = /\.(css|scss|sass|less|styl|pcss|svg|png|jpe?g|gif|webp|avif|ico|bmp|woff2?|ttf|otf|eot|mp3|mp4|webm|ogg|wav|json|ya?ml|toml|md|txt|csv|glsl|frag|vert)(\?.*)?$/i;
|
|
11221
|
+
isAsset = (path) => ASSET.test(path);
|
|
10781
11222
|
OWN_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
10782
11223
|
".js",
|
|
10783
11224
|
".jsx",
|
|
@@ -10872,10 +11313,10 @@ function typeGraph(input2) {
|
|
|
10872
11313
|
return via?.target.kind === "file" ? exportedAt(via.target.file.id, e.sourceName ?? name, depth + 1) : null;
|
|
10873
11314
|
}
|
|
10874
11315
|
if (e.kind === "default" && !e.localName && !e.sourceName) {
|
|
10875
|
-
const
|
|
11316
|
+
const inside2 = result2.types.find(
|
|
10876
11317
|
(t) => t.span.start.offset >= e.span.start.offset && t.span.end.offset <= e.span.end.offset
|
|
10877
11318
|
);
|
|
10878
|
-
return
|
|
11319
|
+
return inside2 ? { file: file2, name: inside2.name } : null;
|
|
10879
11320
|
}
|
|
10880
11321
|
if (e.kind === "named" || e.kind === "default") {
|
|
10881
11322
|
const local = e.localName ?? e.sourceName ?? name;
|
|
@@ -11011,18 +11452,18 @@ function candidateSets(input2, graph = typeGraph(input2)) {
|
|
|
11011
11452
|
const key = declKey;
|
|
11012
11453
|
const records = /* @__PURE__ */ new Map();
|
|
11013
11454
|
const recordOf = (site) => {
|
|
11014
|
-
let
|
|
11015
|
-
if (!
|
|
11016
|
-
|
|
11455
|
+
let byKey2 = records.get(site.file);
|
|
11456
|
+
if (!byKey2) {
|
|
11457
|
+
byKey2 = new Map(
|
|
11017
11458
|
(resultOf(site.file)?.unresolved ?? []).map((u) => [
|
|
11018
11459
|
`${u.caller}\0${u.expression}\0${u.site.start.offset}`,
|
|
11019
11460
|
u
|
|
11020
11461
|
])
|
|
11021
11462
|
);
|
|
11022
|
-
records.set(site.file,
|
|
11463
|
+
records.set(site.file, byKey2);
|
|
11023
11464
|
}
|
|
11024
11465
|
const caller = site.enclosingFn.slice(site.file.length + 1);
|
|
11025
|
-
return
|
|
11466
|
+
return byKey2.get(`${caller}\0${site.expression}\0${site.evidence.span.start.offset}`);
|
|
11026
11467
|
};
|
|
11027
11468
|
const typedMemo = /* @__PURE__ */ new Map();
|
|
11028
11469
|
const typedCandidates = (type, member) => {
|
|
@@ -11540,7 +11981,7 @@ function groups(input2) {
|
|
|
11540
11981
|
const asClusters = (files2) => {
|
|
11541
11982
|
for (const c of clusters(files2, input2.imports, input2.calls, fnFile))
|
|
11542
11983
|
push({
|
|
11543
|
-
id: ids.cluster(plan.sourceId, c.
|
|
11984
|
+
id: ids.cluster(plan.sourceId, c.key),
|
|
11544
11985
|
name: c.name,
|
|
11545
11986
|
kind: "cluster",
|
|
11546
11987
|
source: plan.sourceId,
|
|
@@ -11641,10 +12082,10 @@ function folderUnits(files) {
|
|
|
11641
12082
|
roots.add("");
|
|
11642
12083
|
continue;
|
|
11643
12084
|
}
|
|
11644
|
-
const
|
|
11645
|
-
const direct =
|
|
12085
|
+
const inside2 = analyzed.filter((f) => top(f) === dir);
|
|
12086
|
+
const direct = inside2.filter((f) => f.path.split("/").length === 2);
|
|
11646
12087
|
const children = new Set(
|
|
11647
|
-
|
|
12088
|
+
inside2.filter((f) => f.path.split("/").length > 2).map((f) => f.path.split("/")[1])
|
|
11648
12089
|
);
|
|
11649
12090
|
if (direct.length === 0 && children.size >= 2) for (const c of children) roots.add(`${dir}/${c}`);
|
|
11650
12091
|
else roots.add(dir);
|
|
@@ -11700,23 +12141,46 @@ function clusters(files, imports, calls, fnFile) {
|
|
|
11700
12141
|
list.push(files[i]);
|
|
11701
12142
|
members2.set(c, list);
|
|
11702
12143
|
});
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
12144
|
+
return [...members2.values()].map(nameCluster).sort(byKey).map(disambiguate());
|
|
12145
|
+
}
|
|
12146
|
+
function ancestors(dir) {
|
|
12147
|
+
if (!dir) return [""];
|
|
12148
|
+
const parts = dir.split("/");
|
|
12149
|
+
return ["", ...parts.map((_, i) => parts.slice(0, i + 1).join("/"))];
|
|
12150
|
+
}
|
|
12151
|
+
function nameCluster(list) {
|
|
12152
|
+
const dirs = list.map((f) => {
|
|
12153
|
+
const d = posix4.dirname(f.path);
|
|
12154
|
+
return d === "." ? "" : d;
|
|
11708
12155
|
});
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
);
|
|
12156
|
+
const counts = /* @__PURE__ */ new Map();
|
|
12157
|
+
for (const d of dirs) for (const a of ancestors(d)) counts.set(a, (counts.get(a) ?? 0) + 1);
|
|
12158
|
+
const root = [...counts].filter(([, n]) => n === list.length).sort((x, y) => y[0].length - x[0].length)[0][0];
|
|
12159
|
+
const need = Math.ceil(list.length * 0.75);
|
|
12160
|
+
const main2 = [...counts].filter(([dir, n]) => n >= need && inside(`${dir}/x`, root)).sort((x, y) => y[0].length - x[0].length || y[1] - x[1] || cmp4(x[0], y[0]))[0][0];
|
|
12161
|
+
const outside = list.length - counts.get(main2);
|
|
12162
|
+
const roles = /* @__PURE__ */ new Map();
|
|
12163
|
+
for (const f of list) {
|
|
12164
|
+
const parts = posix4.basename(f.path).split(".");
|
|
12165
|
+
if (parts.length >= 3)
|
|
12166
|
+
roles.set(parts[parts.length - 2], (roles.get(parts[parts.length - 2]) ?? 0) + 1);
|
|
12167
|
+
}
|
|
12168
|
+
const [role, shared] = [...roles].sort((x, y) => y[1] - x[1] || cmp4(x[0], y[0]))[0] ?? ["", 0];
|
|
12169
|
+
const base2 = `${main2 || "(root)"}${list.length > 1 && shared >= Math.ceil(list.length * 0.6) ? ` \xB7 ${role} files` : ""}`;
|
|
12170
|
+
const name = outside > 0 ? `${base2} (+${outside} elsewhere in ${root || "the repository"})` : base2;
|
|
12171
|
+
return { name, root, main: main2, files: list };
|
|
12172
|
+
}
|
|
12173
|
+
function disambiguate() {
|
|
11712
12174
|
const seen = /* @__PURE__ */ new Set();
|
|
11713
|
-
return
|
|
11714
|
-
const
|
|
11715
|
-
const
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
12175
|
+
return (c) => {
|
|
12176
|
+
const key = c.main || "(root)";
|
|
12177
|
+
const taken = seen.has(key);
|
|
12178
|
+
seen.add(key);
|
|
12179
|
+
if (!taken) return { key, name: c.name, root: c.root, files: c.files };
|
|
12180
|
+
const first = [...c.files].map((f) => f.path).sort(cmp4).find((p) => inside(p, c.main));
|
|
12181
|
+
const within = c.main ? first.slice(c.main.length + 1) : first;
|
|
12182
|
+
return { key: `${key} (${within})`, name: `${c.name} (${within})`, root: c.root, files: c.files };
|
|
12183
|
+
};
|
|
11720
12184
|
}
|
|
11721
12185
|
function louvain(n, edges) {
|
|
11722
12186
|
let assignment = Array.from({ length: n }, (_, i) => i);
|
|
@@ -11798,7 +12262,7 @@ function localMoves(n, edges, initial) {
|
|
|
11798
12262
|
}
|
|
11799
12263
|
return { community, moved };
|
|
11800
12264
|
}
|
|
11801
|
-
var DEFAULT_CLUSTER_THRESHOLD, cmp4;
|
|
12265
|
+
var DEFAULT_CLUSTER_THRESHOLD, cmp4, inside, byKey;
|
|
11802
12266
|
var init_groups = __esm({
|
|
11803
12267
|
"packages/stage2/src/groups.ts"() {
|
|
11804
12268
|
"use strict";
|
|
@@ -11806,6 +12270,8 @@ var init_groups = __esm({
|
|
|
11806
12270
|
init_imports();
|
|
11807
12271
|
DEFAULT_CLUSTER_THRESHOLD = 200;
|
|
11808
12272
|
cmp4 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
12273
|
+
inside = (path, dir) => dir === "" || path.startsWith(`${dir}/`);
|
|
12274
|
+
byKey = (a, b) => cmp4(a.main, b.main) || b.files.length - a.files.length || cmp4(a.files[0].path, b.files[0].path);
|
|
11809
12275
|
}
|
|
11810
12276
|
});
|
|
11811
12277
|
|
|
@@ -16992,14 +17458,14 @@ function codePointLength(str3) {
|
|
|
16992
17458
|
const units = str3.length;
|
|
16993
17459
|
if (!highSurrogate.test(str3))
|
|
16994
17460
|
return units;
|
|
16995
|
-
let
|
|
17461
|
+
let count2 = units;
|
|
16996
17462
|
for (let i = 0; i < units - 1; i++) {
|
|
16997
17463
|
if ((str3.charCodeAt(i) & 64512) === 55296 && (str3.charCodeAt(i + 1) & 64512) === 56320) {
|
|
16998
|
-
|
|
17464
|
+
count2--;
|
|
16999
17465
|
i++;
|
|
17000
17466
|
}
|
|
17001
17467
|
}
|
|
17002
|
-
return
|
|
17468
|
+
return count2;
|
|
17003
17469
|
}
|
|
17004
17470
|
function getLengthableOrigin(input2) {
|
|
17005
17471
|
if (Array.isArray(input2))
|
|
@@ -21462,8 +21928,8 @@ var init_az = __esm({
|
|
|
21462
21928
|
});
|
|
21463
21929
|
|
|
21464
21930
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/be.js
|
|
21465
|
-
function getBelarusianPlural(
|
|
21466
|
-
const absCount = Math.abs(
|
|
21931
|
+
function getBelarusianPlural(count2, one, few, many) {
|
|
21932
|
+
const absCount = Math.abs(count2);
|
|
21467
21933
|
const lastDigit = absCount % 10;
|
|
21468
21934
|
const lastTwoDigits = absCount % 100;
|
|
21469
21935
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -24236,8 +24702,8 @@ var init_hu = __esm({
|
|
|
24236
24702
|
});
|
|
24237
24703
|
|
|
24238
24704
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/hy.js
|
|
24239
|
-
function getArmenianPlural(
|
|
24240
|
-
return Math.abs(
|
|
24705
|
+
function getArmenianPlural(count2, one, many) {
|
|
24706
|
+
return Math.abs(count2) === 1 ? one : many;
|
|
24241
24707
|
}
|
|
24242
24708
|
function withDefiniteArticle(word) {
|
|
24243
24709
|
if (!word)
|
|
@@ -27112,8 +27578,8 @@ var init_ro = __esm({
|
|
|
27112
27578
|
});
|
|
27113
27579
|
|
|
27114
27580
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/ru.js
|
|
27115
|
-
function getRussianPlural(
|
|
27116
|
-
const absCount = Math.abs(
|
|
27581
|
+
function getRussianPlural(count2, one, few, many) {
|
|
27582
|
+
const absCount = Math.abs(count2);
|
|
27117
27583
|
const lastDigit = absCount % 10;
|
|
27118
27584
|
const lastTwoDigits = absCount % 100;
|
|
27119
27585
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -43423,20 +43889,20 @@ var require_resolve = __commonJS({
|
|
|
43423
43889
|
return false;
|
|
43424
43890
|
}
|
|
43425
43891
|
function countKeys(schema) {
|
|
43426
|
-
let
|
|
43892
|
+
let count2 = 0;
|
|
43427
43893
|
for (const key in schema) {
|
|
43428
43894
|
if (key === "$ref")
|
|
43429
43895
|
return Infinity;
|
|
43430
|
-
|
|
43896
|
+
count2++;
|
|
43431
43897
|
if (SIMPLE_INLINED.has(key))
|
|
43432
43898
|
continue;
|
|
43433
43899
|
if (typeof schema[key] == "object") {
|
|
43434
|
-
(0, util_1.eachItem)(schema[key], (sch) =>
|
|
43900
|
+
(0, util_1.eachItem)(schema[key], (sch) => count2 += countKeys(sch));
|
|
43435
43901
|
}
|
|
43436
|
-
if (
|
|
43902
|
+
if (count2 === Infinity)
|
|
43437
43903
|
return Infinity;
|
|
43438
43904
|
}
|
|
43439
|
-
return
|
|
43905
|
+
return count2;
|
|
43440
43906
|
}
|
|
43441
43907
|
function getFullPath(resolver, id = "", normalize2) {
|
|
43442
43908
|
if (normalize2 !== false)
|
|
@@ -46918,8 +47384,8 @@ var require_contains = __commonJS({
|
|
|
46918
47384
|
cxt.result(valid, () => cxt.reset());
|
|
46919
47385
|
function validateItemsWithCount() {
|
|
46920
47386
|
const schValid = gen.name("_valid");
|
|
46921
|
-
const
|
|
46922
|
-
validateItems(schValid, () => gen.if(schValid, () => checkLimits(
|
|
47387
|
+
const count2 = gen.let("count", 0);
|
|
47388
|
+
validateItems(schValid, () => gen.if(schValid, () => checkLimits(count2)));
|
|
46923
47389
|
}
|
|
46924
47390
|
function validateItems(_valid, block) {
|
|
46925
47391
|
gen.forRange("i", 0, len, (i) => {
|
|
@@ -46932,16 +47398,16 @@ var require_contains = __commonJS({
|
|
|
46932
47398
|
block();
|
|
46933
47399
|
});
|
|
46934
47400
|
}
|
|
46935
|
-
function checkLimits(
|
|
46936
|
-
gen.code((0, codegen_1._)`${
|
|
47401
|
+
function checkLimits(count2) {
|
|
47402
|
+
gen.code((0, codegen_1._)`${count2}++`);
|
|
46937
47403
|
if (max === void 0) {
|
|
46938
|
-
gen.if((0, codegen_1._)`${
|
|
47404
|
+
gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true).break());
|
|
46939
47405
|
} else {
|
|
46940
|
-
gen.if((0, codegen_1._)`${
|
|
47406
|
+
gen.if((0, codegen_1._)`${count2} > ${max}`, () => gen.assign(valid, false).break());
|
|
46941
47407
|
if (min === 1)
|
|
46942
47408
|
gen.assign(valid, true);
|
|
46943
47409
|
else
|
|
46944
|
-
gen.if((0, codegen_1._)`${
|
|
47410
|
+
gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true));
|
|
46945
47411
|
}
|
|
46946
47412
|
}
|
|
46947
47413
|
}
|
|
@@ -50431,13 +50897,24 @@ var init_server3 = __esm({
|
|
|
50431
50897
|
},
|
|
50432
50898
|
call: (e, a, cwd) => crossFileCalls(e, a, cwd)
|
|
50433
50899
|
},
|
|
50900
|
+
project_totals: {
|
|
50901
|
+
description: "A project's totals as every screen states them (#254): calls within files and across them, the open calls Findings lists (Stage 1's open questions plus calls through imports that couldn't be linked), the own-code functions called most, counting calls from other files, and the files listed: how many were analyzed (fully or partly) and the rest by why not. `stage2: false` means calls across files aren't linked.",
|
|
50902
|
+
input: {
|
|
50903
|
+
project,
|
|
50904
|
+
run,
|
|
50905
|
+
source: external_exports.string().optional().describe("One source only"),
|
|
50906
|
+
top: external_exports.number().int().optional().describe(`How many most-called functions (0 to ${TOTALS_TOP_MAX}; default 10)`)
|
|
50907
|
+
},
|
|
50908
|
+
call: (e, a, cwd) => projectTotals(e, a, cwd)
|
|
50909
|
+
},
|
|
50434
50910
|
list_groups: {
|
|
50435
50911
|
description: "The project map (R2): groups of files (workspace packages, repositories, and clusters inside large ones), each with file, function and external-package counts and finding counts; DEPENDS_ON edges between them (imports and cross-file calls, with one as evidence); the external packages (how many, and the most imported); and project totals. `stage2: false` means Stage 2 hasn't run.",
|
|
50436
50912
|
input: {
|
|
50437
50913
|
project,
|
|
50438
50914
|
run,
|
|
50439
50915
|
source: external_exports.string().optional().describe("One source only"),
|
|
50440
|
-
limit: external_exports.number().int().optional().describe(`At most this many groups (1 to ${GROUPS_MAX}; default ${GROUPS_MAX})`)
|
|
50916
|
+
limit: external_exports.number().int().optional().describe(`At most this many groups (1 to ${GROUPS_MAX}; default ${GROUPS_MAX})`),
|
|
50917
|
+
offset: external_exports.number().int().optional().describe("Skip this many groups first (paging; default 0)")
|
|
50441
50918
|
},
|
|
50442
50919
|
call: (e, a, cwd) => listGroups(e, a, cwd)
|
|
50443
50920
|
},
|
|
@@ -50466,12 +50943,13 @@ var init_server3 = __esm({
|
|
|
50466
50943
|
source: external_exports.string().optional(),
|
|
50467
50944
|
group: external_exports.string().optional().describe("A group id"),
|
|
50468
50945
|
file: external_exports.string().optional().describe("A file id"),
|
|
50469
|
-
limit: external_exports.number().int().optional().describe(`At most this many (1 to ${FINDINGS_MAX}; default 100)`)
|
|
50946
|
+
limit: external_exports.number().int().optional().describe(`At most this many (1 to ${FINDINGS_MAX}; default 100)`),
|
|
50947
|
+
offset: external_exports.number().int().optional().describe("Skip this many first (paging; default 0); `total` counts them all")
|
|
50470
50948
|
},
|
|
50471
50949
|
call: (e, a, cwd) => listFindings(e, a, cwd)
|
|
50472
50950
|
},
|
|
50473
50951
|
explain: {
|
|
50474
|
-
description: "Why a link, an import or an unresolved call came out as it did (R2): the steps the analysis took, or where they stopped (how an import specifier resolved, each re-export hop, the definition; why a call wasn't resolved; which component a template call was read against). Pass an id (an import, a call, a call site, a resolution or a finding) or a file and a line (everything on that line).",
|
|
50952
|
+
description: "Why a link, an import or an unresolved call came out as it did (R2): the steps the analysis took, or where they stopped (how an import specifier resolved, each re-export hop, the definition; why a call wasn't resolved; which component a template call was read against). Pass an id (an import, a call, a call site, a resolution or a finding) or a file and a line (everything on that line; `file` then says when the file wasn't fully analyzed, and why).",
|
|
50475
50953
|
input: {
|
|
50476
50954
|
project,
|
|
50477
50955
|
run,
|
|
@@ -50488,7 +50966,9 @@ var init_server3 = __esm({
|
|
|
50488
50966
|
run,
|
|
50489
50967
|
file: external_exports.string().optional().describe("A file id, to restrict to one file"),
|
|
50490
50968
|
includeAll: external_exports.boolean().optional(),
|
|
50491
|
-
source: external_exports.string().optional().describe("One source only")
|
|
50969
|
+
source: external_exports.string().optional().describe("One source only"),
|
|
50970
|
+
limit: external_exports.number().int().optional().describe("At most this many sites (paging); with it, `total` counts them all"),
|
|
50971
|
+
offset: external_exports.number().int().optional().describe("Skip this many sites first (paging)")
|
|
50492
50972
|
},
|
|
50493
50973
|
call: (e, a, cwd) => e.listUnresolvedSites(a, cwd)
|
|
50494
50974
|
},
|
|
@@ -53631,7 +54111,7 @@ var require_fastify_plugin = __commonJS({
|
|
|
53631
54111
|
"use strict";
|
|
53632
54112
|
var getPluginName = require_getPluginName();
|
|
53633
54113
|
var toCamelCase = require_toCamelCase();
|
|
53634
|
-
var
|
|
54114
|
+
var count2 = 0;
|
|
53635
54115
|
function plugin(fn, options = {}) {
|
|
53636
54116
|
let autoName = false;
|
|
53637
54117
|
if (fn.default !== void 0) {
|
|
@@ -53655,7 +54135,7 @@ var require_fastify_plugin = __commonJS({
|
|
|
53655
54135
|
}
|
|
53656
54136
|
if (!options.name) {
|
|
53657
54137
|
autoName = true;
|
|
53658
|
-
options.name = getPluginName(fn) + "-auto-" +
|
|
54138
|
+
options.name = getPluginName(fn) + "-auto-" + count2++;
|
|
53659
54139
|
}
|
|
53660
54140
|
fn[/* @__PURE__ */ Symbol.for("skip-override")] = options.encapsulate !== true;
|
|
53661
54141
|
fn[/* @__PURE__ */ Symbol.for("fastify.display-name")] = options.name;
|
|
@@ -54574,8 +55054,8 @@ var require_depd = __commonJS({
|
|
|
54574
55054
|
return deprecate;
|
|
54575
55055
|
}
|
|
54576
55056
|
function eehaslisteners(emitter, type) {
|
|
54577
|
-
var
|
|
54578
|
-
return
|
|
55057
|
+
var count2 = typeof emitter.listenerCount !== "function" ? emitter.listeners(type).length : emitter.listenerCount(type);
|
|
55058
|
+
return count2 > 0;
|
|
54579
55059
|
}
|
|
54580
55060
|
function isignored(namespace) {
|
|
54581
55061
|
if (process.noDeprecation) {
|
|
@@ -61956,13 +62436,13 @@ var require_stream_writable = __commonJS({
|
|
|
61956
62436
|
var buffer = new Array(l);
|
|
61957
62437
|
var holder = state.corkedRequestsFree;
|
|
61958
62438
|
holder.entry = entry;
|
|
61959
|
-
var
|
|
62439
|
+
var count2 = 0;
|
|
61960
62440
|
var allBuffers = true;
|
|
61961
62441
|
while (entry) {
|
|
61962
|
-
buffer[
|
|
62442
|
+
buffer[count2] = entry;
|
|
61963
62443
|
if (!entry.isBuf) allBuffers = false;
|
|
61964
62444
|
entry = entry.next;
|
|
61965
|
-
|
|
62445
|
+
count2 += 1;
|
|
61966
62446
|
}
|
|
61967
62447
|
buffer.allBuffers = allBuffers;
|
|
61968
62448
|
doWrite(stream, state, true, state.length, buffer, "", holder.finish);
|
|
@@ -79282,9 +79762,9 @@ var require_parseJson = __commonJS({
|
|
|
79282
79762
|
pos++;
|
|
79283
79763
|
} else if (c === "u") {
|
|
79284
79764
|
pos++;
|
|
79285
|
-
let
|
|
79765
|
+
let count2 = 4;
|
|
79286
79766
|
let code = 0;
|
|
79287
|
-
while (
|
|
79767
|
+
while (count2--) {
|
|
79288
79768
|
code <<= 4;
|
|
79289
79769
|
c = s[pos];
|
|
79290
79770
|
if (c === void 0) {
|
|
@@ -80718,12 +81198,12 @@ var require_schemes2 = __commonJS({
|
|
|
80718
81198
|
mailtoComponent.path = void 0;
|
|
80719
81199
|
}
|
|
80720
81200
|
let query = "";
|
|
80721
|
-
let
|
|
81201
|
+
let count2 = 0;
|
|
80722
81202
|
for (const name in headers) {
|
|
80723
|
-
if (
|
|
81203
|
+
if (count2++ !== 0) query += "&";
|
|
80724
81204
|
query += mailtoEncodeHeaderName(name) + "=" + encodeWithAllow(String(headers[name]), HFNAME);
|
|
80725
81205
|
}
|
|
80726
|
-
if (
|
|
81206
|
+
if (count2 !== 0) {
|
|
80727
81207
|
mailtoComponent.query = query;
|
|
80728
81208
|
} else {
|
|
80729
81209
|
mailtoComponent.headers = void 0;
|
|
@@ -91411,6 +91891,24 @@ var init_config = __esm({
|
|
|
91411
91891
|
});
|
|
91412
91892
|
|
|
91413
91893
|
// packages/agents/src/grammar.ts
|
|
91894
|
+
function stage2Ran(ctx) {
|
|
91895
|
+
return ctx.engine.readAllStages({ project: ctx.project, ...ctx.run !== void 0 ? { run: ctx.run } : {} }).reader.count("Group") > 0;
|
|
91896
|
+
}
|
|
91897
|
+
function onlyCross(cross, listed) {
|
|
91898
|
+
const seen = new Set(listed.map((c) => c.id));
|
|
91899
|
+
const calls = cross.calls.filter((c) => !seen.has(c.id));
|
|
91900
|
+
return { calls, total: cross.total - (cross.calls.length - calls.length) };
|
|
91901
|
+
}
|
|
91902
|
+
function callTotals(ctx, fn) {
|
|
91903
|
+
const { reader } = ctx.engine.readAllStages({
|
|
91904
|
+
project: ctx.project,
|
|
91905
|
+
...ctx.run !== void 0 ? { run: ctx.run } : {}
|
|
91906
|
+
});
|
|
91907
|
+
return {
|
|
91908
|
+
callers: reader.callCounts("dst", [fn]).get(fn)?.functions ?? 0,
|
|
91909
|
+
callees: reader.callCounts("src", [fn]).get(fn)?.functions ?? 0
|
|
91910
|
+
};
|
|
91911
|
+
}
|
|
91414
91912
|
function tool(ctx, name, args, run2) {
|
|
91415
91913
|
const scoped = ctx.source !== void 0 && SCOPED_TOOLS.has(name) && args.file === void 0;
|
|
91416
91914
|
ctx.calls.push({
|
|
@@ -91612,11 +92110,16 @@ function nameRepositories(engine, project2, results) {
|
|
|
91612
92110
|
return repo && item.detail && !item.detail.startsWith(`${repo} \u203A `) ? { ...item, detail: `${repo} \u203A ${item.detail}` } : item;
|
|
91613
92111
|
});
|
|
91614
92112
|
}
|
|
91615
|
-
var IN_FILE_NOTE, SCOPED_TOOLS, target, plural3, fnItem, fileItem, callers, callees, definition, fileFunctions, fileQuestions, TOP, largestFiles, mostCalled, questionsByReason, filesByQuestions, overview, REASONS, STATUS_WORDS2, LANGUAGE_WORDS, INTENTS, EXAMPLES, HELP_SUMMARY;
|
|
92113
|
+
var IN_FILE_NOTE, fnItemWithTotals, SCOPED_TOOLS, target, plural3, fnItem, fileItem, callers, callees, definition, fileFunctions, fileQuestions, TOP, largestFiles, mostCalled, brokenImports, questionsByReason, filesByQuestions, overview, REASONS, STATUS_WORDS2, LANGUAGE_WORDS, INTENTS, EXAMPLES, HELP_SUMMARY;
|
|
91616
92114
|
var init_grammar = __esm({
|
|
91617
92115
|
"packages/agents/src/grammar.ts"() {
|
|
91618
92116
|
"use strict";
|
|
91619
|
-
|
|
92117
|
+
init_src7();
|
|
92118
|
+
IN_FILE_NOTE = "Calls through imports aren't linked in this analysis (Stage 2 didn't run): only calls within each file, and from component templates, are shown.";
|
|
92119
|
+
fnItemWithTotals = (ctx, h) => {
|
|
92120
|
+
const t = callTotals(ctx, h.id);
|
|
92121
|
+
return fnItem({ ...h, callers: t.callers, callees: t.callees });
|
|
92122
|
+
};
|
|
91620
92123
|
SCOPED_TOOLS = /* @__PURE__ */ new Set(["search_nodes", "aggregate", "list_unresolved_sites"]);
|
|
91621
92124
|
target = (m) => m[2] ? `${m[1]} in ${m[2]}` : m[1];
|
|
91622
92125
|
plural3 = (n, one, many = `${one}s`) => `${n.toLocaleString("en-US")} ${n === 1 ? one : many}`;
|
|
@@ -91647,13 +92150,27 @@ var init_grammar = __esm({
|
|
|
91647
92150
|
{ function: r.hit.id, direction: "in" },
|
|
91648
92151
|
() => ctx.engine.listCalls({ project: ctx.project, function: r.hit.id, direction: "in" })
|
|
91649
92152
|
);
|
|
91650
|
-
const
|
|
92153
|
+
const cross = tool(
|
|
92154
|
+
ctx,
|
|
92155
|
+
"cross_file_calls",
|
|
92156
|
+
{ function: r.hit.id, direction: "in", limit: 500 },
|
|
92157
|
+
() => crossFileCalls(ctx.engine, {
|
|
92158
|
+
project: ctx.project,
|
|
92159
|
+
...ctx.run !== void 0 ? { run: ctx.run } : {},
|
|
92160
|
+
function: r.hit.id,
|
|
92161
|
+
direction: "in",
|
|
92162
|
+
limit: 500
|
|
92163
|
+
})
|
|
92164
|
+
);
|
|
92165
|
+
const { calls: crossCalls, total: crossTotal } = onlyCross(cross, out.calls);
|
|
92166
|
+
const total = out.calls.length + crossTotal;
|
|
92167
|
+
const fns = /* @__PURE__ */ new Set([...out.calls.map((c) => c.function.id), ...crossCalls.map((c) => c.from.id)]);
|
|
92168
|
+
const linked = stage2Ran(ctx);
|
|
91651
92169
|
return {
|
|
91652
|
-
summary:
|
|
91653
|
-
|
|
91654
|
-
...out.calls.length === 0 ? { note: IN_FILE_NOTE } : {},
|
|
92170
|
+
summary: total === 0 ? `No calls to ${say(r.hit.name)} were found.` : `${say(r.hit.name)} is called ${plural3(total, "time")} by ${cross.truncated ? "at least " : ""}${plural3(fns.size, "function")}${crossTotal ? ` (${plural3(crossTotal, "call")} from other files)` : ""}.`,
|
|
92171
|
+
...!linked ? { note: IN_FILE_NOTE } : cross.truncated ? { note: `The first ${cross.calls.length} calls from other files are listed.` } : {},
|
|
91655
92172
|
results: [
|
|
91656
|
-
|
|
92173
|
+
fnItemWithTotals(ctx, r.hit),
|
|
91657
92174
|
...out.calls.map((c) => ({
|
|
91658
92175
|
kind: "call",
|
|
91659
92176
|
id: c.id,
|
|
@@ -91665,6 +92182,15 @@ var init_grammar = __esm({
|
|
|
91665
92182
|
file: c.evidence.file,
|
|
91666
92183
|
path: c.function.path,
|
|
91667
92184
|
line: c.evidence.span.start.line
|
|
92185
|
+
})),
|
|
92186
|
+
...crossCalls.map((c) => ({
|
|
92187
|
+
kind: "call",
|
|
92188
|
+
id: c.id,
|
|
92189
|
+
label: c.from.name,
|
|
92190
|
+
detail: `${c.from.path}:${c.evidence.span.start.line} \xB7 from another file`,
|
|
92191
|
+
file: c.evidence.file,
|
|
92192
|
+
path: c.from.path,
|
|
92193
|
+
line: c.evidence.span.start.line
|
|
91668
92194
|
}))
|
|
91669
92195
|
],
|
|
91670
92196
|
suggestions: [`what does ${r.hit.name} call`]
|
|
@@ -91680,18 +92206,51 @@ var init_grammar = __esm({
|
|
|
91680
92206
|
() => ctx.engine.listCalls({ project: ctx.project, function: r.hit.id, direction: "out" })
|
|
91681
92207
|
);
|
|
91682
92208
|
const file2 = r.hit.id.slice(0, r.hit.id.lastIndexOf(":"));
|
|
92209
|
+
const cross = tool(
|
|
92210
|
+
ctx,
|
|
92211
|
+
"cross_file_calls",
|
|
92212
|
+
{ function: r.hit.id, direction: "out", limit: 500 },
|
|
92213
|
+
() => crossFileCalls(ctx.engine, {
|
|
92214
|
+
project: ctx.project,
|
|
92215
|
+
...ctx.run !== void 0 ? { run: ctx.run } : {},
|
|
92216
|
+
function: r.hit.id,
|
|
92217
|
+
direction: "out",
|
|
92218
|
+
limit: 500
|
|
92219
|
+
})
|
|
92220
|
+
);
|
|
92221
|
+
const { reader } = ctx.engine.readAllStages({
|
|
92222
|
+
project: ctx.project,
|
|
92223
|
+
...ctx.run !== void 0 ? { run: ctx.run } : {}
|
|
92224
|
+
});
|
|
92225
|
+
const resolution = new Map(reader.facts("SiteResolution", file2).map((x) => [x.site, x]));
|
|
92226
|
+
const linkedSites = new Set(cross.calls.map((c) => c.id.replace(/^CALLS_CROSS_FILE\|site\|/, "")));
|
|
91683
92227
|
const sites = tool(
|
|
91684
92228
|
ctx,
|
|
91685
92229
|
"list_unresolved_sites",
|
|
91686
92230
|
{ file: file2, includeAll: true },
|
|
91687
92231
|
() => ctx.engine.listUnresolvedSites({ project: ctx.project, file: file2, includeAll: true })
|
|
91688
|
-
).sites.filter((s) => s.enclosingFn === r.hit.id);
|
|
92232
|
+
).sites.filter((s) => s.enclosingFn === r.hit.id && !linkedSites.has(s.id));
|
|
92233
|
+
const nameOf = (id) => {
|
|
92234
|
+
const f = reader.fact(id);
|
|
92235
|
+
return f?.type === "Function" ? `${say(f.qualifiedName)} (${f.file.slice(f.file.indexOf(":") + 1)})` : id;
|
|
92236
|
+
};
|
|
92237
|
+
const { calls: crossCalls, total: crossTotal } = onlyCross(cross, out.calls);
|
|
92238
|
+
const resolved = out.calls.length + crossTotal;
|
|
92239
|
+
const narrowed = sites.filter((s) => resolution.get(s.id)?.candidates?.length).length;
|
|
91689
92240
|
return {
|
|
91690
|
-
summary: `${say(r.hit.name)} makes ${plural3(
|
|
91691
|
-
|
|
91692
|
-
...out.calls.length === 0 ? { note: IN_FILE_NOTE } : {},
|
|
92241
|
+
summary: `${say(r.hit.name)} makes ${plural3(resolved, "resolved call")}${crossTotal ? ` (${plural3(crossTotal, "call")} to other files)` : ""}${sites.length ? ` and ${plural3(sites.length, "unresolved call site")}` : ""}${narrowed ? `, ${plural3(narrowed, "with known candidates", "with known candidates")}` : ""}.`,
|
|
92242
|
+
...!stage2Ran(ctx) ? { note: IN_FILE_NOTE } : {},
|
|
91693
92243
|
results: [
|
|
91694
|
-
|
|
92244
|
+
fnItemWithTotals(ctx, r.hit),
|
|
92245
|
+
...crossCalls.map((c) => ({
|
|
92246
|
+
kind: "call",
|
|
92247
|
+
id: c.id,
|
|
92248
|
+
label: c.to.name,
|
|
92249
|
+
detail: `${r.hit.path}:${c.evidence.span.start.line} \xB7 in ${c.to.path}`,
|
|
92250
|
+
file: c.evidence.file,
|
|
92251
|
+
path: r.hit.path,
|
|
92252
|
+
line: c.evidence.span.start.line
|
|
92253
|
+
})),
|
|
91695
92254
|
...out.calls.map((c) => ({
|
|
91696
92255
|
kind: "call",
|
|
91697
92256
|
id: c.id,
|
|
@@ -91703,15 +92262,20 @@ var init_grammar = __esm({
|
|
|
91703
92262
|
path: r.hit.path,
|
|
91704
92263
|
line: c.evidence.span.start.line
|
|
91705
92264
|
})),
|
|
91706
|
-
...sites.map((s) =>
|
|
91707
|
-
|
|
91708
|
-
|
|
91709
|
-
|
|
91710
|
-
|
|
91711
|
-
|
|
91712
|
-
|
|
91713
|
-
|
|
91714
|
-
|
|
92265
|
+
...sites.map((s) => {
|
|
92266
|
+
const res = resolution.get(s.id);
|
|
92267
|
+
const candidates = res?.candidates ?? [];
|
|
92268
|
+
const why = candidates.length ? `possibly ${candidates.map((c) => nameOf(c.function)).join(" or ")}${res.exhaustive === false ? " (known; there may be others)" : ""}` : REASONS[s.reason] ?? s.reason;
|
|
92269
|
+
return {
|
|
92270
|
+
kind: "site",
|
|
92271
|
+
id: s.id,
|
|
92272
|
+
label: `? ${s.expression}`,
|
|
92273
|
+
detail: `${r.hit.path}:${s.evidence.span.start.line} \xB7 ${why}`,
|
|
92274
|
+
file: s.file,
|
|
92275
|
+
path: r.hit.path,
|
|
92276
|
+
line: s.evidence.span.start.line
|
|
92277
|
+
};
|
|
92278
|
+
})
|
|
91715
92279
|
],
|
|
91716
92280
|
suggestions: [`who calls ${r.hit.name}`]
|
|
91717
92281
|
};
|
|
@@ -91815,12 +92379,33 @@ var init_grammar = __esm({
|
|
|
91815
92379
|
};
|
|
91816
92380
|
};
|
|
91817
92381
|
mostCalled = (ctx) => {
|
|
91818
|
-
const
|
|
91819
|
-
|
|
91820
|
-
|
|
92382
|
+
const linked = stage2Ran(ctx);
|
|
92383
|
+
let groups2;
|
|
92384
|
+
if (!linked) {
|
|
92385
|
+
const args = { label: "CALLS", groupBy: "to", filters: { ownCode: true } };
|
|
92386
|
+
groups2 = tool(
|
|
92387
|
+
ctx,
|
|
92388
|
+
"aggregate",
|
|
92389
|
+
args,
|
|
92390
|
+
() => ctx.engine.aggregate({ project: ctx.project, ...args })
|
|
92391
|
+
).groups;
|
|
92392
|
+
} else {
|
|
92393
|
+
const args = { top: TOP, ...ctx.source ? { source: ctx.source } : {} };
|
|
92394
|
+
groups2 = tool(
|
|
92395
|
+
ctx,
|
|
92396
|
+
"project_totals",
|
|
92397
|
+
args,
|
|
92398
|
+
() => projectTotals(ctx.engine, {
|
|
92399
|
+
project: ctx.project,
|
|
92400
|
+
...ctx.run !== void 0 ? { run: ctx.run } : {},
|
|
92401
|
+
...args
|
|
92402
|
+
})
|
|
92403
|
+
).mostCalled.map((f) => ({ key: f.id, name: f.name, count: f.calls }));
|
|
92404
|
+
}
|
|
92405
|
+
const top = groups2.slice(0, TOP);
|
|
91821
92406
|
return {
|
|
91822
92407
|
summary: top.length ? `The most-called function is ${say(top[0].name ?? top[0].key)} (${plural3(top[0].count, "call")}).` : "No calls have been found yet.",
|
|
91823
|
-
note: IN_FILE_NOTE,
|
|
92408
|
+
...!linked ? { note: IN_FILE_NOTE } : {},
|
|
91824
92409
|
results: top.map((g) => {
|
|
91825
92410
|
const file2 = g.key.slice(0, g.key.lastIndexOf(":"));
|
|
91826
92411
|
return {
|
|
@@ -91835,6 +92420,35 @@ var init_grammar = __esm({
|
|
|
91835
92420
|
})
|
|
91836
92421
|
};
|
|
91837
92422
|
};
|
|
92423
|
+
brokenImports = (ctx) => {
|
|
92424
|
+
const args = { kind: ["broken"], limit: 50, ...ctx.source ? { source: ctx.source } : {} };
|
|
92425
|
+
const r = tool(
|
|
92426
|
+
ctx,
|
|
92427
|
+
"list_findings",
|
|
92428
|
+
args,
|
|
92429
|
+
() => listFindings(ctx.engine, {
|
|
92430
|
+
project: ctx.project,
|
|
92431
|
+
...ctx.run !== void 0 ? { run: ctx.run } : {},
|
|
92432
|
+
...args,
|
|
92433
|
+
kind: ["broken"]
|
|
92434
|
+
})
|
|
92435
|
+
);
|
|
92436
|
+
const n = r.counts.broken;
|
|
92437
|
+
return {
|
|
92438
|
+
summary: n ? `${plural3(n, "broken import")}: imports whose target doesn't exist in the code analyzed.` : "No broken imports were found.",
|
|
92439
|
+
...n > r.findings.length ? { note: `The first ${r.findings.length} are listed; Findings lists them all.` } : {},
|
|
92440
|
+
results: r.findings.map((f) => ({
|
|
92441
|
+
kind: "file",
|
|
92442
|
+
id: f.file,
|
|
92443
|
+
label: f.text,
|
|
92444
|
+
detail: `${f.path}:${f.line} \xB7 ${f.reason.replace(/-/g, " ")}`,
|
|
92445
|
+
file: f.file,
|
|
92446
|
+
path: f.path,
|
|
92447
|
+
line: f.line
|
|
92448
|
+
})),
|
|
92449
|
+
suggestions: ["open questions by reason", "overview"]
|
|
92450
|
+
};
|
|
92451
|
+
};
|
|
91838
92452
|
questionsByReason = (ctx) => {
|
|
91839
92453
|
const r = tool(
|
|
91840
92454
|
ctx,
|
|
@@ -91921,15 +92535,29 @@ var init_grammar = __esm({
|
|
|
91921
92535
|
filters: { open: true }
|
|
91922
92536
|
})
|
|
91923
92537
|
);
|
|
91924
|
-
const group = (id, label,
|
|
92538
|
+
const group = (id, label, count2) => ({
|
|
91925
92539
|
kind: "group",
|
|
91926
92540
|
id,
|
|
91927
92541
|
label,
|
|
91928
|
-
count
|
|
92542
|
+
count: count2
|
|
91929
92543
|
});
|
|
91930
92544
|
const n = (x) => x.toLocaleString("en-US");
|
|
92545
|
+
const totalsArgs = { top: 0, ...ctx.source ? { source: ctx.source } : {} };
|
|
92546
|
+
const totals = stage2Ran(ctx) ? tool(
|
|
92547
|
+
ctx,
|
|
92548
|
+
"project_totals",
|
|
92549
|
+
totalsArgs,
|
|
92550
|
+
() => projectTotals(ctx.engine, {
|
|
92551
|
+
project: ctx.project,
|
|
92552
|
+
...ctx.run !== void 0 ? { run: ctx.run } : {},
|
|
92553
|
+
...totalsArgs
|
|
92554
|
+
})
|
|
92555
|
+
) : null;
|
|
91931
92556
|
return {
|
|
91932
|
-
summary: `${plural3(files.total, "file")}, ${plural3(fns.total, "function")}, ${plural3(calls.total, "call")} and ${plural3(open3.total, "open question")}.`,
|
|
92557
|
+
summary: totals ? `${plural3(files.total, "file")}, ${plural3(fns.total, "function")}, ${plural3(totals.calls.withinFiles + totals.calls.acrossFiles, "call")} (${n(totals.calls.acrossFiles)} across files) and ${plural3(totals.openCalls, "open call")}.` : `${plural3(files.total, "file")}, ${plural3(fns.total, "function")}, ${plural3(calls.total, "call")} and ${plural3(open3.total, "open question")}.`,
|
|
92558
|
+
...totals && totals.openCalls !== open3.total ? {
|
|
92559
|
+
note: `${plural3(open3.total, "open question")} within files, by reason below; Findings also lists calls through imports that couldn't be linked.`
|
|
92560
|
+
} : {},
|
|
91933
92561
|
results: [
|
|
91934
92562
|
...files.groups.map(
|
|
91935
92563
|
(g) => group(
|
|
@@ -91961,6 +92589,7 @@ var init_grammar = __esm({
|
|
|
91961
92589
|
reflection: "reflection",
|
|
91962
92590
|
"imported-symbol": "imported",
|
|
91963
92591
|
"runtime-global": "built-in",
|
|
92592
|
+
"builtin-value": "on a built-in value",
|
|
91964
92593
|
"template-binding": "awaiting its component",
|
|
91965
92594
|
"template-reference": "registered elsewhere"
|
|
91966
92595
|
};
|
|
@@ -92024,6 +92653,15 @@ var init_grammar = __esm({
|
|
|
92024
92653
|
],
|
|
92025
92654
|
handle: questionsByReason
|
|
92026
92655
|
},
|
|
92656
|
+
{
|
|
92657
|
+
// #265: a findings question, not a function's name.
|
|
92658
|
+
name: "broken-imports",
|
|
92659
|
+
patterns: [
|
|
92660
|
+
/^(?:(?:show|list|find)\s+(?:me\s+)?|(?:what|which)\s+are\s+)?(?:the\s+|all\s+)?broken\s+imports?$/,
|
|
92661
|
+
/^(?:which\s+|what\s+)?imports?\s+(?:are\s+)?broken$/
|
|
92662
|
+
],
|
|
92663
|
+
handle: brokenImports
|
|
92664
|
+
},
|
|
92027
92665
|
{
|
|
92028
92666
|
name: "largest-files",
|
|
92029
92667
|
patterns: [
|
|
@@ -92102,8 +92740,8 @@ function toolDefinitions() {
|
|
|
92102
92740
|
function systemPrompt(project2) {
|
|
92103
92741
|
return [
|
|
92104
92742
|
"You answer questions about a codebase using veoflow's knowledge graph of it.",
|
|
92105
|
-
`The project is "${project2}". What the graph holds today: files; functions (with qualified names such as Cart.addItem); calls between functions resolved within each file; and unresolved call sites (dynamic dispatch, imported symbols
|
|
92106
|
-
"
|
|
92743
|
+
`The project is "${project2}". What the graph holds today: files; functions (with qualified names such as Cart.addItem); calls between functions resolved within each file; calls across files when cross-file linking (Stage 2) ran; and unresolved call sites (dynamic dispatch, imported symbols, runtime globals).`,
|
|
92744
|
+
"list_calls returns calls within each file; cross_file_calls returns the calls between files. When cross_file_calls finds none and the project has imports, cross-file linking may not have run: say so when it matters.",
|
|
92107
92745
|
"Always look things up with the tools before answering, even when the question seems general; never guess or rely on memory. Start with search_nodes to find functions or files by name, then use list_calls, file_outline, get_function, list_unresolved_sites or aggregate.",
|
|
92108
92746
|
'Some names are generated for anonymous functions, such as authRoutes.<callback:post>#5. In your answer describe them in words with their location ("the post callback in authRoutes at src/routes/auth.ts:519") rather than repeating the generated name.',
|
|
92109
92747
|
"Cite locations exactly as path:line from tool results (for example src/cart.ts:42).",
|
|
@@ -92259,9 +92897,9 @@ function splitMentioned(prose, citations, items) {
|
|
|
92259
92897
|
if (m && (!at.has(key) || m.index < at.get(key))) at.set(key, m.index);
|
|
92260
92898
|
}
|
|
92261
92899
|
}
|
|
92262
|
-
const
|
|
92263
|
-
for (const c of citations) if (c.target)
|
|
92264
|
-
const mentioned = [...at].sort(([, a], [, b]) => a - b).map(([key]) =>
|
|
92900
|
+
const byKey2 = new Map(items.map((i) => [`${i.kind}:${i.id}`, i]));
|
|
92901
|
+
for (const c of citations) if (c.target) byKey2.set(`${c.target.kind}:${c.target.id}`, c.target);
|
|
92902
|
+
const mentioned = [...at].sort(([, a], [, b]) => a - b).map(([key]) => byKey2.get(key)).filter(Boolean);
|
|
92265
92903
|
const keys = new Set(mentioned.map((i) => `${i.kind}:${i.id}`));
|
|
92266
92904
|
return { mentioned, lookups: items.filter((i) => !keys.has(`${i.kind}:${i.id}`)) };
|
|
92267
92905
|
}
|
|
@@ -92436,6 +93074,8 @@ var init_chat = __esm({
|
|
|
92436
93074
|
"file_outline",
|
|
92437
93075
|
"get_function",
|
|
92438
93076
|
"list_calls",
|
|
93077
|
+
"cross_file_calls",
|
|
93078
|
+
"project_totals",
|
|
92439
93079
|
"list_unresolved_sites",
|
|
92440
93080
|
"run_status"
|
|
92441
93081
|
];
|
|
@@ -92652,11 +93292,26 @@ async function createServer(engine, options = {}) {
|
|
|
92652
93292
|
socket.on("close", () => clients.delete(socket));
|
|
92653
93293
|
});
|
|
92654
93294
|
app.get("/api/health", async () => ({ ok: true }));
|
|
93295
|
+
const summarizing = /* @__PURE__ */ new Set();
|
|
93296
|
+
const unsummarizable = /* @__PURE__ */ new Set();
|
|
93297
|
+
const ensureCounts = (project2, run2) => {
|
|
93298
|
+
const key = `${project2}\0${run2}`;
|
|
93299
|
+
if (summarizing.has(key) || unsummarizable.has(key)) return;
|
|
93300
|
+
summarizing.add(key);
|
|
93301
|
+
void engine.spawnInternal(["__summarize", project2, String(run2)]).then((outcome) => {
|
|
93302
|
+
if (outcome === "no-runner") summarizeFindings(engine, project2, run2);
|
|
93303
|
+
else if (outcome === "failed") unsummarizable.add(key);
|
|
93304
|
+
}).catch(() => unsummarizable.add(key)).finally(() => summarizing.delete(key));
|
|
93305
|
+
};
|
|
92655
93306
|
app.get("/api/projects", async (req) => ({
|
|
92656
93307
|
projects: engine.listProjects().projects.map((p) => {
|
|
92657
93308
|
if (req.query.findings !== "1" || p.error || p.committedRun === null) return p;
|
|
92658
93309
|
try {
|
|
92659
|
-
|
|
93310
|
+
const kept = keptFindingSummary(engine, p.id, p.committedRun);
|
|
93311
|
+
if (kept) return { ...p, findings: kept.counts, ...kept.files ? { files: kept.files } : {} };
|
|
93312
|
+
if (unsummarizable.has(`${p.id}\0${p.committedRun}`)) return p;
|
|
93313
|
+
if (!engine.runInProgress(p.id)) ensureCounts(p.id, p.committedRun);
|
|
93314
|
+
return { ...p, findingsPending: true };
|
|
92660
93315
|
} catch {
|
|
92661
93316
|
return p;
|
|
92662
93317
|
}
|
|
@@ -92944,18 +93599,27 @@ async function createServer(engine, options = {}) {
|
|
|
92944
93599
|
params: projectParams,
|
|
92945
93600
|
querystring: {
|
|
92946
93601
|
type: "object",
|
|
92947
|
-
properties: {
|
|
93602
|
+
properties: {
|
|
93603
|
+
file: str2,
|
|
93604
|
+
source: str2,
|
|
93605
|
+
includeAll: { type: "string", enum: ["true", "false"] },
|
|
93606
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" },
|
|
93607
|
+
offset: { type: "string", pattern: "^(0|[1-9][0-9]*)$" }
|
|
93608
|
+
}
|
|
92948
93609
|
}
|
|
92949
93610
|
}
|
|
92950
93611
|
},
|
|
92951
93612
|
async (req) => engine.listUnresolvedSites({
|
|
92952
93613
|
...req.params,
|
|
92953
93614
|
...req.query.file ? { file: req.query.file } : {},
|
|
93615
|
+
...req.query.limit ? { limit: Number(req.query.limit) } : {},
|
|
93616
|
+
...req.query.offset ? { offset: Number(req.query.offset) } : {},
|
|
92954
93617
|
...req.query.source !== void 0 ? { source: req.query.source } : {},
|
|
92955
93618
|
includeAll: req.query.includeAll === "true"
|
|
92956
93619
|
})
|
|
92957
93620
|
);
|
|
92958
93621
|
const positive = { type: "string", pattern: "^[1-9][0-9]*$" };
|
|
93622
|
+
const count2 = { type: "string", pattern: "^(0|[1-9][0-9]*)$" };
|
|
92959
93623
|
const oneOrMore = (item) => ({ anyOf: [item, { type: "array", items: item }] });
|
|
92960
93624
|
const list = (v) => v === void 0 ? void 0 : Array.isArray(v) ? v : [v];
|
|
92961
93625
|
app.get(
|
|
@@ -92966,14 +93630,15 @@ async function createServer(engine, options = {}) {
|
|
|
92966
93630
|
querystring: {
|
|
92967
93631
|
type: "object",
|
|
92968
93632
|
additionalProperties: false,
|
|
92969
|
-
properties: { source: str2, limit: positive }
|
|
93633
|
+
properties: { source: str2, limit: positive, offset: count2 }
|
|
92970
93634
|
}
|
|
92971
93635
|
}
|
|
92972
93636
|
},
|
|
92973
93637
|
async (req) => listGroups(engine, {
|
|
92974
93638
|
...req.params,
|
|
92975
93639
|
...req.query.source !== void 0 ? { source: req.query.source } : {},
|
|
92976
|
-
...req.query.limit ? { limit: Number(req.query.limit) } : {}
|
|
93640
|
+
...req.query.limit ? { limit: Number(req.query.limit) } : {},
|
|
93641
|
+
...req.query.offset ? { offset: Number(req.query.offset) } : {}
|
|
92977
93642
|
})
|
|
92978
93643
|
);
|
|
92979
93644
|
app.get(
|
|
@@ -93028,18 +93693,20 @@ async function createServer(engine, options = {}) {
|
|
|
93028
93693
|
source: str2,
|
|
93029
93694
|
group: str2,
|
|
93030
93695
|
file: str2,
|
|
93031
|
-
limit: positive
|
|
93696
|
+
limit: positive,
|
|
93697
|
+
offset: count2
|
|
93032
93698
|
}
|
|
93033
93699
|
}
|
|
93034
93700
|
}
|
|
93035
93701
|
},
|
|
93036
93702
|
async (req) => {
|
|
93037
|
-
const { limit, kind, ...rest } = req.query;
|
|
93703
|
+
const { limit, offset, kind, ...rest } = req.query;
|
|
93038
93704
|
return listFindings(engine, {
|
|
93039
93705
|
...req.params,
|
|
93040
93706
|
...rest,
|
|
93041
93707
|
...kind !== void 0 ? { kind: list(kind) } : {},
|
|
93042
|
-
...limit ? { limit: Number(limit) } : {}
|
|
93708
|
+
...limit ? { limit: Number(limit) } : {},
|
|
93709
|
+
...offset ? { offset: Number(offset) } : {}
|
|
93043
93710
|
});
|
|
93044
93711
|
}
|
|
93045
93712
|
);
|
|
@@ -93065,6 +93732,27 @@ async function createServer(engine, options = {}) {
|
|
|
93065
93732
|
return crossFileCalls(engine, { ...req.params, ...rest, ...limit ? { limit: Number(limit) } : {} });
|
|
93066
93733
|
}
|
|
93067
93734
|
);
|
|
93735
|
+
app.get(
|
|
93736
|
+
"/api/projects/:project/totals",
|
|
93737
|
+
{
|
|
93738
|
+
schema: {
|
|
93739
|
+
params: projectParams,
|
|
93740
|
+
querystring: {
|
|
93741
|
+
type: "object",
|
|
93742
|
+
additionalProperties: false,
|
|
93743
|
+
properties: { source: str2, top: { type: "string", pattern: "^[0-9]+$" } }
|
|
93744
|
+
}
|
|
93745
|
+
}
|
|
93746
|
+
},
|
|
93747
|
+
async (req) => {
|
|
93748
|
+
const { top, ...rest } = req.query;
|
|
93749
|
+
return projectTotals(engine, {
|
|
93750
|
+
...req.params,
|
|
93751
|
+
...rest,
|
|
93752
|
+
...top !== void 0 ? { top: Number(top) } : {}
|
|
93753
|
+
});
|
|
93754
|
+
}
|
|
93755
|
+
);
|
|
93068
93756
|
app.get(
|
|
93069
93757
|
"/api/projects/:project/explain",
|
|
93070
93758
|
{
|
|
@@ -93668,6 +94356,10 @@ function describeCheck(r, cwd, projectFlag) {
|
|
|
93668
94356
|
`${shown}:${site.line}:${site.column} ${words[site.category] ?? site.category} (${site.stage})`
|
|
93669
94357
|
);
|
|
93670
94358
|
out.push(` veoflow: ${site.veoflow}`);
|
|
94359
|
+
if (site.candidates)
|
|
94360
|
+
out.push(
|
|
94361
|
+
` candidates: ${site.candidates.functions.length} ${site.candidates.exhaustive ? "(all)" : "(known; may not be all)"}${site.candidates.includesCompiler === void 0 ? "" : site.candidates.includesCompiler ? ", the compiler's among them" : ", the compiler's not among them"}`
|
|
94362
|
+
);
|
|
93671
94363
|
out.push(` compiler: ${site.compiler}`);
|
|
93672
94364
|
out.push(
|
|
93673
94365
|
site.changed ? ` why: changed since the analysis; veoflow run, then veoflow explain ${shown}:${site.line}${projectFlag ? ` --project ${projectFlag}` : ""}` : ` why: veoflow explain ${shown}:${site.line}${projectFlag ? ` --project ${projectFlag}` : ""}`
|
|
@@ -93736,7 +94428,9 @@ async function runAnalysis(engine, project2, io, source, draft = false, commit =
|
|
|
93736
94428
|
...branch !== void 0 ? { branch } : {},
|
|
93737
94429
|
...debug ? { debug: true, ...debug.until !== void 0 ? { until: debug.until } : {} } : {}
|
|
93738
94430
|
});
|
|
93739
|
-
for (const s of run2.sources)
|
|
94431
|
+
for (const s of run2.sources)
|
|
94432
|
+
for (const n of s.notices ?? [])
|
|
94433
|
+
io.out(` note: ${run2.sources.length > 1 ? `${s.sourceId}: ` : ""}${n}`);
|
|
93740
94434
|
if (draft && run2.kind !== "draft")
|
|
93741
94435
|
io.out(" note: nothing to draft (no git source, or no analysis yet): this was an ordinary run");
|
|
93742
94436
|
if (run2.status === "committed" && run2.kind === "draft") {
|
|
@@ -93763,8 +94457,8 @@ async function runAnalysis(engine, project2, io, source, draft = false, commit =
|
|
|
93763
94457
|
return 0;
|
|
93764
94458
|
}
|
|
93765
94459
|
if (run2.status === "committed") {
|
|
93766
|
-
const
|
|
93767
|
-
io.out(`run ${run2.runId} committed: ${
|
|
94460
|
+
const { files } = engine.listFiles({ project: project2 });
|
|
94461
|
+
io.out(`run ${run2.runId} committed: ${files.length} files${fileBreakdown(files)}`);
|
|
93768
94462
|
return 0;
|
|
93769
94463
|
}
|
|
93770
94464
|
io.err(`run ${run2.runId} failed: ${run2.error ?? "unknown error"}`);
|
|
@@ -93773,6 +94467,39 @@ async function runAnalysis(engine, project2, io, source, draft = false, commit =
|
|
|
93773
94467
|
engine.events.off("event", listener);
|
|
93774
94468
|
}
|
|
93775
94469
|
}
|
|
94470
|
+
var FILE_REASONS = {
|
|
94471
|
+
"language-not-analyzed": "language not analyzed yet",
|
|
94472
|
+
"parse-failure": "could not be parsed",
|
|
94473
|
+
"declaration-file": "type declarations",
|
|
94474
|
+
"too-large": "over the size limit",
|
|
94475
|
+
minified: "minified",
|
|
94476
|
+
binary: "not text",
|
|
94477
|
+
"invalid-utf8": "not UTF-8",
|
|
94478
|
+
unreadable: "unreadable",
|
|
94479
|
+
entitlement: "beyond the license",
|
|
94480
|
+
frozen: "kept from an earlier analysis"
|
|
94481
|
+
};
|
|
94482
|
+
function fileBreakdown(files) {
|
|
94483
|
+
const analyzed = files.filter((f) => f.status === "analyzed").length;
|
|
94484
|
+
if (analyzed === files.length) return "";
|
|
94485
|
+
const n = (x) => x.toLocaleString("en-US");
|
|
94486
|
+
const why = (list) => {
|
|
94487
|
+
const by = /* @__PURE__ */ new Map();
|
|
94488
|
+
for (const f of list) {
|
|
94489
|
+
const w = FILE_REASONS[f.reason ?? ""] ?? f.reason ?? f.status;
|
|
94490
|
+
by.set(w, (by.get(w) ?? 0) + 1);
|
|
94491
|
+
}
|
|
94492
|
+
const sorted = [...by].sort((a, b) => b[1] - a[1]);
|
|
94493
|
+
return sorted.length === 1 ? sorted[0][0] : sorted.map(([w, c]) => `${n(c)} ${w}`).join(", ");
|
|
94494
|
+
};
|
|
94495
|
+
const partly = files.filter((f) => f.status === "degraded" || f.status === "parse_error");
|
|
94496
|
+
const not = files.filter((f) => f.status === "not_analyzed");
|
|
94497
|
+
return ` (${[
|
|
94498
|
+
`${n(analyzed)} analyzed`,
|
|
94499
|
+
...partly.length ? [`${n(partly.length)} partly (${why(partly)})`] : [],
|
|
94500
|
+
...not.length ? [`${n(not.length)} not analyzed (${why(not)})`] : []
|
|
94501
|
+
].join(", ")})`;
|
|
94502
|
+
}
|
|
93776
94503
|
function selfCommand() {
|
|
93777
94504
|
return [process.execPath, resolve8(dirname8(fileURLToPath2(import.meta.url)), "../bin/veoflow.mjs")];
|
|
93778
94505
|
}
|
|
@@ -93799,6 +94526,7 @@ async function serveRun(io) {
|
|
|
93799
94526
|
}
|
|
93800
94527
|
const engine = new Engine(io.home, {
|
|
93801
94528
|
stages: request.stages.map((n) => known[n]),
|
|
94529
|
+
afterCommit: summarizeFindings,
|
|
93802
94530
|
...request.retention ? { retention: request.retention } : {},
|
|
93803
94531
|
license: request.license,
|
|
93804
94532
|
killableRuns: true
|
|
@@ -93811,6 +94539,17 @@ async function serveRun(io) {
|
|
|
93811
94539
|
await last;
|
|
93812
94540
|
return 0;
|
|
93813
94541
|
}
|
|
94542
|
+
function usageFor(command) {
|
|
94543
|
+
const out = [];
|
|
94544
|
+
let inside2 = false;
|
|
94545
|
+
for (const line of USAGE.split("\n")) {
|
|
94546
|
+
if (/^ {2}veoflow /.test(line))
|
|
94547
|
+
inside2 = line.startsWith(` veoflow ${command} `) || line === ` veoflow ${command}`;
|
|
94548
|
+
else if (!/^ {3,}/.test(line)) inside2 = false;
|
|
94549
|
+
if (inside2) out.push(line);
|
|
94550
|
+
}
|
|
94551
|
+
return out.length ? out.join("\n") : null;
|
|
94552
|
+
}
|
|
93814
94553
|
async function main(argv, io) {
|
|
93815
94554
|
const [command, ...rest] = argv;
|
|
93816
94555
|
if (!command) {
|
|
@@ -93825,8 +94564,29 @@ async function main(argv, io) {
|
|
|
93825
94564
|
io.out(version2());
|
|
93826
94565
|
return 0;
|
|
93827
94566
|
}
|
|
94567
|
+
if (rest.includes("--help") || rest.includes("-h")) {
|
|
94568
|
+
const lines = usageFor(command);
|
|
94569
|
+
if (lines) {
|
|
94570
|
+
io.out(lines);
|
|
94571
|
+
return 0;
|
|
94572
|
+
}
|
|
94573
|
+
}
|
|
93828
94574
|
const self2 = io.self ?? selfCommand();
|
|
93829
94575
|
if (command === "__run") return await serveRun(io);
|
|
94576
|
+
if (command === "__summarize") {
|
|
94577
|
+
const [project2, run2] = rest;
|
|
94578
|
+
if (!project2 || !/^\d+$/.test(run2 ?? "")) {
|
|
94579
|
+
io.err("usage: veoflow __summarize <project> <run>");
|
|
94580
|
+
return 2;
|
|
94581
|
+
}
|
|
94582
|
+
const engine2 = new Engine(io.home);
|
|
94583
|
+
try {
|
|
94584
|
+
summarizeFindings(engine2, project2, Number(run2));
|
|
94585
|
+
} finally {
|
|
94586
|
+
engine2.close();
|
|
94587
|
+
}
|
|
94588
|
+
return 0;
|
|
94589
|
+
}
|
|
93830
94590
|
if (command === "mcp") {
|
|
93831
94591
|
const { serveStdio: serveStdio2 } = await Promise.resolve().then(() => (init_src9(), src_exports2));
|
|
93832
94592
|
await serveStdio2(io.home, version2(), { runner: { command: self2 } });
|
|
@@ -93834,6 +94594,8 @@ async function main(argv, io) {
|
|
|
93834
94594
|
}
|
|
93835
94595
|
const engine = new Engine(io.home, {
|
|
93836
94596
|
stages: [stage2],
|
|
94597
|
+
// Finding counts kept with each run, so the projects home never scans findings (#249).
|
|
94598
|
+
afterCommit: summarizeFindings,
|
|
93837
94599
|
...command === "serve" ? { runner: { command: self2 } } : ["run", "add", "include", "exclude"].includes(command) ? { killableRuns: true } : {}
|
|
93838
94600
|
});
|
|
93839
94601
|
let keepOpen = false;
|
|
@@ -93869,6 +94631,21 @@ async function main(argv, io) {
|
|
|
93869
94631
|
if (!existsSync10(root) || !statSync5(root).isDirectory())
|
|
93870
94632
|
throw new VeoError("source-not-found", `${root} is not a directory`);
|
|
93871
94633
|
let project2 = values.project ?? engine.catalog.resolveProjectForCwd(io.cwd)?.id;
|
|
94634
|
+
if (values.project !== void 0) {
|
|
94635
|
+
const want = values.project;
|
|
94636
|
+
const all2 = engine.catalog.listProjects();
|
|
94637
|
+
const named = all2.filter((p) => p.name.toLowerCase() === want.toLowerCase());
|
|
94638
|
+
const found = all2.find((p) => p.id === want) ?? (named.length === 1 ? named[0] : void 0);
|
|
94639
|
+
if (!found && named.length > 1)
|
|
94640
|
+
throw new UsageError(
|
|
94641
|
+
`${named.length} projects are named ${want} (${named.map((p) => p.id).join(", ")}); pass one's id`
|
|
94642
|
+
);
|
|
94643
|
+
if (!found)
|
|
94644
|
+
throw new UsageError(
|
|
94645
|
+
`no project ${want}: create it with veoflow init "${want}"${all2.length === 0 ? ", or leave out --project to make one named after the folder" : ""}`
|
|
94646
|
+
);
|
|
94647
|
+
project2 = found.id;
|
|
94648
|
+
}
|
|
93872
94649
|
if (!project2) {
|
|
93873
94650
|
const all2 = engine.catalog.listProjects();
|
|
93874
94651
|
if (all2.length === 1) project2 = all2[0].id;
|
|
@@ -94099,7 +94876,7 @@ async function main(argv, io) {
|
|
|
94099
94876
|
const mode = values.mode ?? "auto";
|
|
94100
94877
|
if (mode !== "auto" && mode !== "grammar" && mode !== "model")
|
|
94101
94878
|
throw new UsageError(`invalid --mode ${mode} (auto, grammar or model)`);
|
|
94102
|
-
const { ask: ask2 } = await Promise.resolve().then(() => (init_src10(), src_exports3));
|
|
94879
|
+
const { ask: ask2, say: say2 } = await Promise.resolve().then(() => (init_src10(), src_exports3));
|
|
94103
94880
|
const project2 = pickProject(engine, values.project, io.cwd);
|
|
94104
94881
|
const answer = await ask2(engine, engine.catalog.home, project2, positionals.join(" "), {
|
|
94105
94882
|
mode,
|
|
@@ -94117,7 +94894,9 @@ ${plain(answer.prose)}`);
|
|
|
94117
94894
|
if (!c.verified) io.out(`unverified: ${c.text} was not returned by any tool`);
|
|
94118
94895
|
if (answer.results.length) io.out("");
|
|
94119
94896
|
for (const r of answer.results.slice(0, 25))
|
|
94120
|
-
io.out(
|
|
94897
|
+
io.out(
|
|
94898
|
+
` ${r.kind === "function" || r.kind === "call" ? say2(r.label) : r.label}${r.detail ? ` (${r.detail})` : ""}`
|
|
94899
|
+
);
|
|
94121
94900
|
if (answer.results.length > 25) io.out(` \u2026 ${answer.results.length - 25} more`);
|
|
94122
94901
|
if (answer.truncated) io.out(`truncated: ${answer.truncated.reason}`);
|
|
94123
94902
|
if (answer.suggestions?.length) io.out(`
|
|
@@ -94210,11 +94989,26 @@ try: ${answer.suggestions.join(" \xB7 ")}`);
|
|
|
94210
94989
|
io.out(JSON.stringify(r, null, 2));
|
|
94211
94990
|
return 0;
|
|
94212
94991
|
}
|
|
94213
|
-
if (r.
|
|
94992
|
+
if (r.file?.status === "not_analyzed")
|
|
94993
|
+
io.out(
|
|
94994
|
+
`${m[1]} isn't analyzed (${FILE_REASONS[r.file.reason ?? ""] ?? r.file.reason ?? "not analyzed"}), so there is nothing to explain on line ${m[2]}`
|
|
94995
|
+
);
|
|
94996
|
+
else if (r.items.length === 0) io.out(`nothing to explain on line ${m[2]} of ${file2}`);
|
|
94997
|
+
if (r.file && r.file.status !== "not_analyzed")
|
|
94998
|
+
io.out(
|
|
94999
|
+
`note: ${m[1]} was only partly analyzed (${FILE_REASONS[r.file.reason ?? ""] ?? r.file.reason ?? r.file.status})`
|
|
95000
|
+
);
|
|
95001
|
+
const flat = (t, max = 160) => {
|
|
95002
|
+
const one = t.replace(/\s+/g, " ").trim();
|
|
95003
|
+
return one.length > max ? `${one.slice(0, max - 1)}\u2026` : one;
|
|
95004
|
+
};
|
|
94214
95005
|
for (const item of r.items) {
|
|
94215
|
-
io.out(
|
|
94216
|
-
|
|
94217
|
-
|
|
95006
|
+
io.out(
|
|
95007
|
+
`${flat(item.subject, 80)} ${item.outcome} (${item.path}${item.line ? `:${item.line}` : ""})`
|
|
95008
|
+
);
|
|
95009
|
+
io.out(` ${flat(item.summary)}`);
|
|
95010
|
+
const steps = item.steps[0]?.detail === item.summary ? item.steps.slice(1) : item.steps;
|
|
95011
|
+
for (const [i, step] of steps.entries()) io.out(` ${i + 1}. ${flat(step.detail)}`);
|
|
94218
95012
|
for (const c of item.candidates ?? []) io.out(` could be ${c.name} (${c.path})`);
|
|
94219
95013
|
}
|
|
94220
95014
|
if (r.truncated) io.out(`(${r.total - r.items.length} more not shown; use --json)`);
|
|
@@ -94450,5 +95244,7 @@ function plain(text) {
|
|
|
94450
95244
|
return text.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, "");
|
|
94451
95245
|
}
|
|
94452
95246
|
export {
|
|
94453
|
-
|
|
95247
|
+
fileBreakdown,
|
|
95248
|
+
main,
|
|
95249
|
+
usageFor
|
|
94454
95250
|
};
|