veoflow 0.1.2 → 0.1.4
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 +1429 -231
- 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-BDhfBjwe.js +331 -0
- package/web/assets/index-P-aSV80b.css +1 -0
- package/web/index.html +2 -2
- package/web/assets/index-Cw2mJ_5P.js +0 -330
- package/web/assets/index-DwAmGVhN.css +0 -1
package/dist/veo.mjs
CHANGED
|
@@ -154,6 +154,10 @@ function classify(path) {
|
|
|
154
154
|
return "typescript";
|
|
155
155
|
case "tsx":
|
|
156
156
|
return "tsx";
|
|
157
|
+
case "vue":
|
|
158
|
+
return "vue";
|
|
159
|
+
case "svelte":
|
|
160
|
+
return "svelte";
|
|
157
161
|
case "py":
|
|
158
162
|
return "python";
|
|
159
163
|
case "go":
|
|
@@ -164,6 +168,12 @@ function classify(path) {
|
|
|
164
168
|
return null;
|
|
165
169
|
}
|
|
166
170
|
}
|
|
171
|
+
function unsupportedLanguage(path) {
|
|
172
|
+
const name = path.slice(path.lastIndexOf("/") + 1).toLowerCase();
|
|
173
|
+
if (name.endsWith(".component.html")) return "Angular template";
|
|
174
|
+
const dot = name.lastIndexOf(".");
|
|
175
|
+
return dot > 0 ? UNSUPPORTED[name.slice(dot + 1)] ?? null : null;
|
|
176
|
+
}
|
|
167
177
|
function languageSkip(path, language) {
|
|
168
178
|
if (/\.d\.[mc]?ts$/i.test(path)) return "declaration-file";
|
|
169
179
|
return ANALYZED_LANGUAGES.has(language) ? null : "language-not-analyzed";
|
|
@@ -180,17 +190,62 @@ function decodeUtf8(bytes) {
|
|
|
180
190
|
return null;
|
|
181
191
|
}
|
|
182
192
|
}
|
|
183
|
-
var ANALYZED_LANGUAGES, utf8;
|
|
193
|
+
var ANALYZED_LANGUAGES, UNSUPPORTED, utf8;
|
|
184
194
|
var init_classify = __esm({
|
|
185
195
|
"packages/planner/src/classify.ts"() {
|
|
186
196
|
"use strict";
|
|
187
|
-
ANALYZED_LANGUAGES = /* @__PURE__ */ new Set([
|
|
197
|
+
ANALYZED_LANGUAGES = /* @__PURE__ */ new Set([
|
|
198
|
+
"javascript",
|
|
199
|
+
"jsx",
|
|
200
|
+
"typescript",
|
|
201
|
+
"tsx",
|
|
202
|
+
"vue",
|
|
203
|
+
"svelte",
|
|
204
|
+
"angular-template"
|
|
205
|
+
]);
|
|
206
|
+
UNSUPPORTED = {
|
|
207
|
+
java: "Java",
|
|
208
|
+
kt: "Kotlin",
|
|
209
|
+
kts: "Kotlin",
|
|
210
|
+
scala: "Scala",
|
|
211
|
+
groovy: "Groovy",
|
|
212
|
+
cs: "C#",
|
|
213
|
+
vb: "Visual Basic",
|
|
214
|
+
php: "PHP",
|
|
215
|
+
rb: "Ruby",
|
|
216
|
+
swift: "Swift",
|
|
217
|
+
m: "Objective-C or MATLAB",
|
|
218
|
+
mm: "Objective-C++",
|
|
219
|
+
c: "C",
|
|
220
|
+
h: "C/C++ header",
|
|
221
|
+
cc: "C++",
|
|
222
|
+
cpp: "C++",
|
|
223
|
+
cxx: "C++",
|
|
224
|
+
hpp: "C/C++ header",
|
|
225
|
+
hh: "C/C++ header",
|
|
226
|
+
hxx: "C/C++ header",
|
|
227
|
+
dart: "Dart",
|
|
228
|
+
ex: "Elixir",
|
|
229
|
+
exs: "Elixir",
|
|
230
|
+
erl: "Erlang",
|
|
231
|
+
clj: "Clojure",
|
|
232
|
+
cljs: "ClojureScript",
|
|
233
|
+
cljc: "Clojure",
|
|
234
|
+
hs: "Haskell",
|
|
235
|
+
lua: "Lua",
|
|
236
|
+
pl: "Perl",
|
|
237
|
+
astro: "Astro"
|
|
238
|
+
};
|
|
188
239
|
utf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
189
240
|
}
|
|
190
241
|
});
|
|
191
242
|
|
|
192
243
|
// packages/planner/src/glob.ts
|
|
193
244
|
function globToRegExp(pattern) {
|
|
245
|
+
if (pattern.startsWith("/")) {
|
|
246
|
+
const literal2 = literalPath(pattern).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
247
|
+
return new RegExp(`^${literal2}(?:/.*)?$`);
|
|
248
|
+
}
|
|
194
249
|
let p = pattern.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
195
250
|
if (!p.includes("/")) p = `**/${p}`;
|
|
196
251
|
if (p.endsWith("/")) p = `${p}**`;
|
|
@@ -218,14 +273,39 @@ function globToRegExp(pattern) {
|
|
|
218
273
|
}
|
|
219
274
|
return new RegExp(`^${re}$`);
|
|
220
275
|
}
|
|
221
|
-
|
|
276
|
+
function literalPath(rule) {
|
|
277
|
+
return rule.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
278
|
+
}
|
|
279
|
+
function literalPrefix(pattern) {
|
|
280
|
+
const p = pattern.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
281
|
+
const i = p.search(/[*?{]/);
|
|
282
|
+
return i < 0 ? p : p.slice(0, i);
|
|
283
|
+
}
|
|
284
|
+
function defaultExcludedFile(path) {
|
|
285
|
+
return /\.timestamp-\d+(?:-[0-9a-f]+)?\.[cm]?[jt]s$/i.test(path) ? "generated" : null;
|
|
286
|
+
}
|
|
287
|
+
function defaultExcludedDir(path) {
|
|
288
|
+
const parts = path.split("/");
|
|
289
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
290
|
+
const name = parts[i];
|
|
291
|
+
if (DEFAULT_EXCLUDED_DIRS.has(name))
|
|
292
|
+
return {
|
|
293
|
+
dir: parts.slice(0, i + 1).join("/"),
|
|
294
|
+
origin: VCS_DIRS.has(name) ? "vcs" : LIBRARY_DIRS.has(name) ? "library" : TOOL_DIRS.has(name) ? "tool" : "generated"
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
var PathFilter, TOOL_DIRS, DEFAULT_EXCLUDED_DIRS, VCS_DIRS, LIBRARY_DIRS, OptIn;
|
|
222
300
|
var init_glob = __esm({
|
|
223
301
|
"packages/planner/src/glob.ts"() {
|
|
224
302
|
"use strict";
|
|
225
303
|
PathFilter = class {
|
|
226
304
|
include;
|
|
227
305
|
exclude;
|
|
306
|
+
includePatterns;
|
|
228
307
|
constructor(include, exclude) {
|
|
308
|
+
this.includePatterns = include;
|
|
229
309
|
this.include = include.map(globToRegExp);
|
|
230
310
|
this.exclude = exclude.map(globToRegExp);
|
|
231
311
|
}
|
|
@@ -240,11 +320,39 @@ var init_glob = __esm({
|
|
|
240
320
|
for (let i = 1; i < parts.length; i++) if (this.excludesDir(parts.slice(0, i).join("/"))) return false;
|
|
241
321
|
return this.include.length === 0 || this.include.some((re) => re.test(path));
|
|
242
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Whether include rules leave out everything a folder could hold: no include
|
|
325
|
+
* pattern can match a path below it.
|
|
326
|
+
*/
|
|
327
|
+
includesNothingIn(dir) {
|
|
328
|
+
if (this.includePatterns.length === 0) return false;
|
|
329
|
+
return !this.includePatterns.some((p) => {
|
|
330
|
+
if (p.startsWith("/")) {
|
|
331
|
+
const path = literalPath(p);
|
|
332
|
+
return path === dir || path.startsWith(`${dir}/`) || dir.startsWith(`${path}/`);
|
|
333
|
+
}
|
|
334
|
+
if (!p.replace(/^\.\//, "").includes("/")) return true;
|
|
335
|
+
const prefix = literalPrefix(p);
|
|
336
|
+
return prefix.startsWith(`${dir}/`) || `${dir}/`.startsWith(prefix);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
243
339
|
/** Whether a directory is excluded as a whole. */
|
|
244
340
|
excludesDir(dir) {
|
|
245
341
|
return this.exclude.some((re) => re.test(dir) || re.test(`${dir}/`));
|
|
246
342
|
}
|
|
247
343
|
};
|
|
344
|
+
TOOL_DIRS = /* @__PURE__ */ new Set([
|
|
345
|
+
".claude",
|
|
346
|
+
".claire",
|
|
347
|
+
".cursor",
|
|
348
|
+
".windsurf",
|
|
349
|
+
".gemini",
|
|
350
|
+
".codex",
|
|
351
|
+
".agents",
|
|
352
|
+
".idea",
|
|
353
|
+
".vscode",
|
|
354
|
+
".history"
|
|
355
|
+
]);
|
|
248
356
|
DEFAULT_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
249
357
|
".git",
|
|
250
358
|
".hg",
|
|
@@ -262,8 +370,34 @@ var init_glob = __esm({
|
|
|
262
370
|
"target",
|
|
263
371
|
"__pycache__",
|
|
264
372
|
".venv",
|
|
265
|
-
"venv"
|
|
373
|
+
"venv",
|
|
374
|
+
// Tools' and agents' workspaces (D38): their files, and worktrees inside them, are not the project's code.
|
|
375
|
+
...TOOL_DIRS
|
|
266
376
|
]);
|
|
377
|
+
VCS_DIRS = /* @__PURE__ */ new Set([".git", ".hg", ".svn"]);
|
|
378
|
+
LIBRARY_DIRS = /* @__PURE__ */ new Set(["node_modules", "bower_components", ".venv", "venv"]);
|
|
379
|
+
OptIn = class {
|
|
380
|
+
paths;
|
|
381
|
+
anchored;
|
|
382
|
+
constructor(paths = [], exclude = []) {
|
|
383
|
+
const clean = (p) => p.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
384
|
+
this.paths = paths.map(clean).filter((p) => p.length > 0);
|
|
385
|
+
this.anchored = exclude.filter((r) => r.startsWith("/")).map(literalPath).filter((p) => p.length > 0);
|
|
386
|
+
}
|
|
387
|
+
/** The path was chosen: it, or a folder it is in, is opted in more specifically than any anchored exclude. */
|
|
388
|
+
covers(path) {
|
|
389
|
+
const depth = (list) => list.reduce((d, o) => path === o || path.startsWith(`${o}/`) ? Math.max(d, o.length) : d, -1);
|
|
390
|
+
const chosen = depth(this.paths);
|
|
391
|
+
return chosen >= 0 && chosen > depth(this.anchored);
|
|
392
|
+
}
|
|
393
|
+
/** Something below this folder was chosen (so the folder must be walked). */
|
|
394
|
+
below(dir) {
|
|
395
|
+
return this.paths.some((o) => o.startsWith(`${dir}/`));
|
|
396
|
+
}
|
|
397
|
+
get size() {
|
|
398
|
+
return this.paths.length;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
267
401
|
}
|
|
268
402
|
});
|
|
269
403
|
|
|
@@ -334,6 +468,24 @@ function lsTree(top, commit, prefix) {
|
|
|
334
468
|
}
|
|
335
469
|
return entries;
|
|
336
470
|
}
|
|
471
|
+
function lsTreeDir(top, commit, dir) {
|
|
472
|
+
const out = git(top, ["ls-tree", "-z", "-l", "--full-tree", dir ? `${commit}:${dir}` : commit]);
|
|
473
|
+
const entries = [];
|
|
474
|
+
for (const record2 of out.toString("utf8").split("\0")) {
|
|
475
|
+
if (!record2) continue;
|
|
476
|
+
const tab = record2.indexOf(" ");
|
|
477
|
+
const [mode, type, sha, size] = record2.slice(0, tab).split(/ +/);
|
|
478
|
+
const name = record2.slice(tab + 1);
|
|
479
|
+
entries.push({
|
|
480
|
+
mode,
|
|
481
|
+
type,
|
|
482
|
+
sha,
|
|
483
|
+
path: dir ? `${dir}/${name}` : name,
|
|
484
|
+
...type === "blob" ? { size: Number(size) } : {}
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
return entries;
|
|
488
|
+
}
|
|
337
489
|
function blobSizes(top, shas) {
|
|
338
490
|
const sizes = /* @__PURE__ */ new Map();
|
|
339
491
|
if (shas.length === 0) return sizes;
|
|
@@ -442,10 +594,6 @@ function sha256File(abs) {
|
|
|
442
594
|
}
|
|
443
595
|
return hash2.digest("hex");
|
|
444
596
|
}
|
|
445
|
-
function inExcludedDir(path) {
|
|
446
|
-
const parts = path.split("/");
|
|
447
|
-
return parts.slice(0, -1).some((p) => DEFAULT_EXCLUDED_DIRS.has(p));
|
|
448
|
-
}
|
|
449
597
|
function fileFromBytes(path, language, bytes, maxFileBytes) {
|
|
450
598
|
const file2 = { path, language, size: bytes.length, contentHash: sha256(bytes) };
|
|
451
599
|
const skip = languageSkip(path, language);
|
|
@@ -458,6 +606,7 @@ function fileFromBytes(path, language, bytes, maxFileBytes) {
|
|
|
458
606
|
}
|
|
459
607
|
function planSource(source, options = {}) {
|
|
460
608
|
const maxFileBytes = options.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES;
|
|
609
|
+
const hardMax = Math.max(maxFileBytes, options.hardMaxFileBytes ?? HARD_MAX_FILE_BYTES);
|
|
461
610
|
if (!existsSync2(source.root) || !statSync(source.root).isDirectory())
|
|
462
611
|
throw new VeoError("source-not-found", `source ${source.id}: ${source.root} is not a directory`, {
|
|
463
612
|
source: source.id,
|
|
@@ -466,9 +615,10 @@ function planSource(source, options = {}) {
|
|
|
466
615
|
const filter = new PathFilter(source.include, source.exclude);
|
|
467
616
|
const repo = repoInfo(source.root);
|
|
468
617
|
let plan;
|
|
469
|
-
if (repo?.head)
|
|
618
|
+
if (repo?.head)
|
|
619
|
+
plan = planGit(source, repo.top, repo.prefix, repo.head, repo.branch, filter, maxFileBytes, hardMax);
|
|
470
620
|
else {
|
|
471
|
-
plan = planPlain(source, filter, maxFileBytes);
|
|
621
|
+
plan = planPlain(source, filter, maxFileBytes, hardMax);
|
|
472
622
|
if (repo)
|
|
473
623
|
plan.notices.push(
|
|
474
624
|
"The repository has no commits yet, so it was analyzed as a plain folder (latest only)."
|
|
@@ -476,10 +626,63 @@ function planSource(source, options = {}) {
|
|
|
476
626
|
}
|
|
477
627
|
if (!plan.files.some((f) => ANALYZED_LANGUAGES.has(f.language)))
|
|
478
628
|
plan.notices.push("No JavaScript or TypeScript files were found.");
|
|
629
|
+
const unsupported = unsupportedNotice(plan.unsupported);
|
|
630
|
+
if (unsupported) plan.notices.push(unsupported);
|
|
479
631
|
return plan;
|
|
480
632
|
}
|
|
481
|
-
function
|
|
633
|
+
function isSourcePath(rel) {
|
|
634
|
+
return classify(rel) !== null || rel.toLowerCase().endsWith(".html");
|
|
635
|
+
}
|
|
636
|
+
function manifestDir(rel) {
|
|
637
|
+
return rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : "";
|
|
638
|
+
}
|
|
639
|
+
function dependsOnAngular(text) {
|
|
640
|
+
try {
|
|
641
|
+
const json2 = JSON.parse(text.replace(/^\uFEFF/, ""));
|
|
642
|
+
return ["dependencies", "devDependencies", "peerDependencies"].some(
|
|
643
|
+
(k) => json2[k]?.["@angular/core"] !== void 0
|
|
644
|
+
);
|
|
645
|
+
} catch {
|
|
646
|
+
return false;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
function angularTemplates(htmls, manifests) {
|
|
650
|
+
const angular = new Map([...manifests].map(([dir, text]) => [dir, dependsOnAngular(text)]));
|
|
651
|
+
const root = angular.get("") ?? false;
|
|
652
|
+
const out = /* @__PURE__ */ new Set();
|
|
653
|
+
for (const rel of htmls) {
|
|
654
|
+
let dir = manifestDir(rel);
|
|
655
|
+
let nearest = false;
|
|
656
|
+
for (; ; ) {
|
|
657
|
+
if (angular.has(dir)) {
|
|
658
|
+
nearest = angular.get(dir);
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
if (dir === "") break;
|
|
662
|
+
dir = manifestDir(dir);
|
|
663
|
+
}
|
|
664
|
+
if (nearest || root) out.add(rel);
|
|
665
|
+
}
|
|
666
|
+
return out;
|
|
667
|
+
}
|
|
668
|
+
function unsupportedNotice(unsupported) {
|
|
669
|
+
if (!unsupported.length) return null;
|
|
670
|
+
const files = (n) => `${n.toLocaleString("en-US")} ${n === 1 ? "file" : "files"}`;
|
|
671
|
+
const parts = unsupported.slice(0, 3).map((u) => `${u.files.toLocaleString("en-US")} ${u.language} ${u.files === 1 ? "file" : "files"}`);
|
|
672
|
+
const rest = unsupported.slice(3);
|
|
673
|
+
if (rest.length)
|
|
674
|
+
parts.push(
|
|
675
|
+
`${files(rest.reduce((n, u) => n + u.files, 0))} in ${rest.length} other ${rest.length === 1 ? "language" : "languages"}`
|
|
676
|
+
);
|
|
677
|
+
const list = parts.length === 1 ? parts[0] : `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
|
|
678
|
+
const total = unsupported.reduce((n, u) => n + u.files, 0);
|
|
679
|
+
return `${list} ${total === 1 ? "is" : "are"} not analyzed: veoflow does not read ${unsupported.length === 1 ? "this language" : "these languages"} yet.`;
|
|
680
|
+
}
|
|
681
|
+
function planGit(source, top, prefix, head, branch, filter, maxFileBytes, hardMax) {
|
|
482
682
|
const changes = workTreeChanges(top, prefix);
|
|
683
|
+
const optIn = new OptIn(source.optIn, source.exclude);
|
|
684
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
685
|
+
const ruled = new RuleExcludedCollector(filter);
|
|
483
686
|
const plan = {
|
|
484
687
|
sourceId: source.id,
|
|
485
688
|
root: source.root,
|
|
@@ -490,16 +693,47 @@ function planGit(source, top, prefix, head, branch, filter, maxFileBytes) {
|
|
|
490
693
|
files: [],
|
|
491
694
|
unpinned: [],
|
|
492
695
|
skipped: [],
|
|
696
|
+
unsupported: [],
|
|
697
|
+
defaultExcluded: [],
|
|
698
|
+
ruleExcluded: [],
|
|
699
|
+
ruleExcludedMore: 0,
|
|
493
700
|
notices: []
|
|
494
701
|
};
|
|
495
702
|
const candidates = [];
|
|
703
|
+
const unsupported = new UnsupportedCounter();
|
|
704
|
+
const htmls = [];
|
|
705
|
+
const manifests = [];
|
|
496
706
|
let entries = 0;
|
|
497
707
|
const collect = (repoDir, commit, treePrefix, relBase, sub) => {
|
|
498
708
|
for (const entry of lsTree(repoDir, commit, treePrefix)) {
|
|
499
709
|
entries++;
|
|
500
710
|
const within = treePrefix ? entry.path.slice(treePrefix.length + 1) : entry.path;
|
|
501
711
|
const rel = relBase ? `${relBase}/${within}` : within;
|
|
502
|
-
|
|
712
|
+
const excluded = defaultExcludedDir(rel);
|
|
713
|
+
let origin;
|
|
714
|
+
if (excluded) {
|
|
715
|
+
if (excluded.origin === "vcs" || !optIn.covers(rel)) {
|
|
716
|
+
if (excluded.origin !== "vcs" && entry.type === "blob") {
|
|
717
|
+
const folder = defaults.get(excluded.dir) ?? {
|
|
718
|
+
path: excluded.dir,
|
|
719
|
+
origin: excluded.origin,
|
|
720
|
+
files: 0
|
|
721
|
+
};
|
|
722
|
+
folder.files = (folder.files ?? 0) + 1;
|
|
723
|
+
defaults.set(excluded.dir, folder);
|
|
724
|
+
}
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
origin = excluded.origin;
|
|
728
|
+
}
|
|
729
|
+
if (entry.type === "blob" && defaultExcludedFile(rel)) {
|
|
730
|
+
if (!optIn.covers(rel)) {
|
|
731
|
+
defaults.set(rel, { path: rel, origin: "generated", files: 1 });
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
origin ??= "generated";
|
|
735
|
+
}
|
|
736
|
+
const tag = origin ? { origin } : {};
|
|
503
737
|
if (entry.type === "commit") {
|
|
504
738
|
const dir = submoduleDir(repoDir, entry.path);
|
|
505
739
|
if (!dir || !hasCommit(dir, entry.sha)) {
|
|
@@ -509,17 +743,59 @@ function planGit(source, top, prefix, head, branch, filter, maxFileBytes) {
|
|
|
509
743
|
collect(dir, entry.sha, "", rel, entry.sha);
|
|
510
744
|
continue;
|
|
511
745
|
}
|
|
512
|
-
if (entry.type
|
|
746
|
+
if (entry.type === "blob" && entry.mode !== "120000" && (rel === "package.json" || rel.endsWith("/package.json")))
|
|
747
|
+
manifests.push({ rel, sha: entry.sha, repoDir });
|
|
748
|
+
if (entry.type !== "blob") continue;
|
|
749
|
+
if (!filter.matches(rel) && !optIn.covers(rel)) {
|
|
750
|
+
if (isSourcePath(rel)) ruled.file(rel);
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
513
753
|
const language = classify(rel);
|
|
514
754
|
if (entry.mode === "120000") {
|
|
515
|
-
if (language
|
|
755
|
+
if (language || rel.toLowerCase().endsWith(".html"))
|
|
756
|
+
plan.skipped.push({ path: rel, reason: "symlink" });
|
|
516
757
|
continue;
|
|
517
758
|
}
|
|
518
759
|
if (language)
|
|
519
|
-
candidates.push({ rel, sha: entry.sha, language, repoDir, ...sub ? { commit: sub } : {} });
|
|
760
|
+
candidates.push({ rel, sha: entry.sha, language, repoDir, ...sub ? { commit: sub } : {}, ...tag });
|
|
761
|
+
else if (rel.toLowerCase().endsWith(".html"))
|
|
762
|
+
htmls.push({
|
|
763
|
+
rel,
|
|
764
|
+
sha: entry.sha,
|
|
765
|
+
language: "angular-template",
|
|
766
|
+
repoDir,
|
|
767
|
+
...sub ? { commit: sub } : {},
|
|
768
|
+
...tag
|
|
769
|
+
});
|
|
770
|
+
else unsupported.add(rel);
|
|
520
771
|
}
|
|
521
772
|
};
|
|
522
773
|
collect(top, head, prefix, "");
|
|
774
|
+
if (htmls.length > 0) {
|
|
775
|
+
const texts = /* @__PURE__ */ new Map();
|
|
776
|
+
const byRepoDir = /* @__PURE__ */ new Map();
|
|
777
|
+
for (const m of manifests) byRepoDir.set(m.repoDir, [...byRepoDir.get(m.repoDir) ?? [], m]);
|
|
778
|
+
for (const [repoDir, list] of byRepoDir) {
|
|
779
|
+
const shas = list.map((m) => m.sha);
|
|
780
|
+
const sizes = new Map([...blobSizes(repoDir, shas)].filter(([, n]) => n <= maxFileBytes));
|
|
781
|
+
const blobs = readBlobs(repoDir, shas, sizes);
|
|
782
|
+
for (const m of list) {
|
|
783
|
+
const blob = blobs.get(m.sha);
|
|
784
|
+
if (blob) texts.set(manifestDir(m.rel), blob.toString("utf8"));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
const angular = angularTemplates(
|
|
788
|
+
htmls.map((h) => h.rel),
|
|
789
|
+
texts
|
|
790
|
+
);
|
|
791
|
+
for (const h of htmls) {
|
|
792
|
+
if (angular.has(h.rel)) candidates.push(h);
|
|
793
|
+
else unsupported.add(h.rel);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
plan.unsupported = unsupported.list();
|
|
797
|
+
plan.defaultExcluded = [...defaults.values()].sort((a, b) => a.path < b.path ? -1 : 1);
|
|
798
|
+
ruled.apply(plan);
|
|
523
799
|
if (entries === 0 && prefix)
|
|
524
800
|
plan.notices.push(
|
|
525
801
|
`${prefix} is not in the last commit (it may be untracked or ignored), so there was nothing to analyze.`
|
|
@@ -535,7 +811,12 @@ function planGit(source, top, prefix, head, branch, filter, maxFileBytes) {
|
|
|
535
811
|
repoDir,
|
|
536
812
|
files.map((f) => f.sha)
|
|
537
813
|
);
|
|
538
|
-
const
|
|
814
|
+
const limit = (f) => optIn.covers(f.rel) ? hardMax : maxFileBytes;
|
|
815
|
+
const readable = /* @__PURE__ */ new Map();
|
|
816
|
+
for (const f of files) {
|
|
817
|
+
const size = sizes.get(f.sha);
|
|
818
|
+
if (size !== void 0 && size <= limit(f)) readable.set(f.sha, size);
|
|
819
|
+
}
|
|
539
820
|
const blobs = readBlobs(
|
|
540
821
|
repoDir,
|
|
541
822
|
files.map((f) => f.sha),
|
|
@@ -558,9 +839,10 @@ function planGit(source, top, prefix, head, branch, filter, maxFileBytes) {
|
|
|
558
839
|
});
|
|
559
840
|
continue;
|
|
560
841
|
} else {
|
|
561
|
-
planned = fileFromBytes(f.rel, f.language, bytes,
|
|
842
|
+
planned = fileFromBytes(f.rel, f.language, bytes, limit(f));
|
|
562
843
|
}
|
|
563
844
|
if (f.commit) planned.commit = f.commit;
|
|
845
|
+
if (f.origin) planned.origin = f.origin;
|
|
564
846
|
plan.files.push(planned);
|
|
565
847
|
}
|
|
566
848
|
}
|
|
@@ -589,7 +871,7 @@ function planGit(source, top, prefix, head, branch, filter, maxFileBytes) {
|
|
|
589
871
|
plan.unpinned.sort((a, b) => a.path < b.path ? -1 : 1);
|
|
590
872
|
return plan;
|
|
591
873
|
}
|
|
592
|
-
function planPlain(source, filter, maxFileBytes) {
|
|
874
|
+
function planPlain(source, filter, maxFileBytes, hardMax) {
|
|
593
875
|
const plan = {
|
|
594
876
|
sourceId: source.id,
|
|
595
877
|
root: source.root,
|
|
@@ -600,13 +882,25 @@ function planPlain(source, filter, maxFileBytes) {
|
|
|
600
882
|
files: [],
|
|
601
883
|
unpinned: [],
|
|
602
884
|
skipped: [],
|
|
885
|
+
unsupported: [],
|
|
886
|
+
defaultExcluded: [],
|
|
887
|
+
ruleExcluded: [],
|
|
888
|
+
ruleExcludedMore: 0,
|
|
603
889
|
notices: []
|
|
604
890
|
};
|
|
605
891
|
const rootReal = realpathSync(source.root);
|
|
606
892
|
const within = (real) => real === rootReal || real.startsWith(rootReal + sep);
|
|
607
893
|
const toRel = (abs) => relative(source.root, abs).split(sep).join("/");
|
|
608
894
|
const inputs = [];
|
|
609
|
-
const
|
|
895
|
+
const unsupported = new UnsupportedCounter();
|
|
896
|
+
const htmls = [];
|
|
897
|
+
const manifests = /* @__PURE__ */ new Map();
|
|
898
|
+
const optIn = new OptIn(source.optIn, source.exclude);
|
|
899
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
900
|
+
const ruled = new RuleExcludedCollector(filter);
|
|
901
|
+
const limit = (rel) => optIn.covers(rel) ? hardMax : maxFileBytes;
|
|
902
|
+
const origins = /* @__PURE__ */ new Map();
|
|
903
|
+
const walk = (dir, dirReal, restricted) => {
|
|
610
904
|
let names;
|
|
611
905
|
try {
|
|
612
906
|
names = readdirSync(dir).sort();
|
|
@@ -617,6 +911,7 @@ function planPlain(source, filter, maxFileBytes) {
|
|
|
617
911
|
for (const name of names) {
|
|
618
912
|
const abs = join2(dir, name);
|
|
619
913
|
const rel = toRel(abs);
|
|
914
|
+
if (restricted && !optIn.covers(rel) && !optIn.below(rel)) continue;
|
|
620
915
|
let st;
|
|
621
916
|
try {
|
|
622
917
|
st = lstatSync(abs);
|
|
@@ -638,13 +933,52 @@ function planPlain(source, filter, maxFileBytes) {
|
|
|
638
933
|
continue;
|
|
639
934
|
}
|
|
640
935
|
if (st.isDirectory()) {
|
|
641
|
-
|
|
642
|
-
|
|
936
|
+
const whole = optIn.covers(rel);
|
|
937
|
+
const wanted = whole || optIn.below(rel);
|
|
938
|
+
const excluded = DEFAULT_EXCLUDED_DIRS.has(name) ? defaultExcludedDir(`${rel}/x`) : null;
|
|
939
|
+
let narrow = restricted;
|
|
940
|
+
if (excluded) {
|
|
941
|
+
if (excluded.origin === "vcs") continue;
|
|
942
|
+
if (!whole && excluded.dir === rel && !defaults.has(rel))
|
|
943
|
+
defaults.set(rel, { path: rel, origin: excluded.origin, files: null });
|
|
944
|
+
if (!wanted) continue;
|
|
945
|
+
if (!whole) narrow = true;
|
|
946
|
+
} else if (!whole && filter.excludesDir(rel)) {
|
|
947
|
+
ruled.dir(rel);
|
|
948
|
+
if (!wanted) continue;
|
|
949
|
+
narrow = true;
|
|
950
|
+
}
|
|
951
|
+
walk(abs, join2(dirReal, name), narrow);
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
if (st.isFile() && name === "package.json" && st.size <= maxFileBytes) {
|
|
955
|
+
try {
|
|
956
|
+
manifests.set(manifestDir(rel), readFileSync(abs, "utf8"));
|
|
957
|
+
} catch {
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
const inDefault = defaultExcludedDir(rel);
|
|
961
|
+
if (inDefault && (inDefault.origin === "vcs" || !optIn.covers(rel))) continue;
|
|
962
|
+
if (inDefault && inDefault.origin !== "vcs") origins.set(rel, inDefault.origin);
|
|
963
|
+
if (!st.isFile()) continue;
|
|
964
|
+
if (defaultExcludedFile(rel)) {
|
|
965
|
+
if (!optIn.covers(rel)) {
|
|
966
|
+
defaults.set(rel, { path: rel, origin: "generated", files: 1 });
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
if (!origins.has(rel)) origins.set(rel, "generated");
|
|
970
|
+
}
|
|
971
|
+
if (!filter.matches(rel) && !optIn.covers(rel)) {
|
|
972
|
+
if (isSourcePath(rel)) ruled.file(rel);
|
|
643
973
|
continue;
|
|
644
974
|
}
|
|
645
|
-
if (!st.isFile() || !filter.matches(rel)) continue;
|
|
646
975
|
const language = classify(rel);
|
|
976
|
+
if (!language && rel.toLowerCase().endsWith(".html")) {
|
|
977
|
+
htmls.push({ abs, rel, size: st.size });
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
647
980
|
if (!language) {
|
|
981
|
+
unsupported.add(rel);
|
|
648
982
|
if (RESOLVER_INPUT.test(rel) && st.size <= maxFileBytes) {
|
|
649
983
|
try {
|
|
650
984
|
inputs.push({ path: rel, hash: sha256(readFileSync(abs)) });
|
|
@@ -653,7 +987,7 @@ function planPlain(source, filter, maxFileBytes) {
|
|
|
653
987
|
}
|
|
654
988
|
continue;
|
|
655
989
|
}
|
|
656
|
-
if (st.size >
|
|
990
|
+
if (st.size > limit(rel)) {
|
|
657
991
|
let hash2;
|
|
658
992
|
try {
|
|
659
993
|
hash2 = sha256File(abs);
|
|
@@ -670,10 +1004,53 @@ function planPlain(source, filter, maxFileBytes) {
|
|
|
670
1004
|
plan.files.push({ path: rel, language, size: st.size, contentHash: "", skip: "unreadable" });
|
|
671
1005
|
continue;
|
|
672
1006
|
}
|
|
673
|
-
plan.files.push(fileFromBytes(rel, language, bytes,
|
|
1007
|
+
plan.files.push(fileFromBytes(rel, language, bytes, limit(rel)));
|
|
674
1008
|
}
|
|
675
1009
|
};
|
|
676
|
-
walk(source.root, rootReal);
|
|
1010
|
+
walk(source.root, rootReal, false);
|
|
1011
|
+
const angular = angularTemplates(
|
|
1012
|
+
htmls.map((h) => h.rel),
|
|
1013
|
+
manifests
|
|
1014
|
+
);
|
|
1015
|
+
for (const h of htmls) {
|
|
1016
|
+
if (!angular.has(h.rel)) {
|
|
1017
|
+
unsupported.add(h.rel);
|
|
1018
|
+
continue;
|
|
1019
|
+
}
|
|
1020
|
+
if (h.size > limit(h.rel)) {
|
|
1021
|
+
let hash2 = "";
|
|
1022
|
+
try {
|
|
1023
|
+
hash2 = sha256File(h.abs);
|
|
1024
|
+
} catch {
|
|
1025
|
+
}
|
|
1026
|
+
plan.files.push({
|
|
1027
|
+
path: h.rel,
|
|
1028
|
+
language: "angular-template",
|
|
1029
|
+
size: h.size,
|
|
1030
|
+
contentHash: hash2,
|
|
1031
|
+
skip: "too-large"
|
|
1032
|
+
});
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
try {
|
|
1036
|
+
plan.files.push(fileFromBytes(h.rel, "angular-template", readFileSync(h.abs), limit(h.rel)));
|
|
1037
|
+
} catch {
|
|
1038
|
+
plan.files.push({
|
|
1039
|
+
path: h.rel,
|
|
1040
|
+
language: "angular-template",
|
|
1041
|
+
size: h.size,
|
|
1042
|
+
contentHash: "",
|
|
1043
|
+
skip: "unreadable"
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
plan.unsupported = unsupported.list();
|
|
1048
|
+
plan.defaultExcluded = [...defaults.values()].sort((a, b) => a.path < b.path ? -1 : 1);
|
|
1049
|
+
ruled.apply(plan);
|
|
1050
|
+
for (const f of plan.files) {
|
|
1051
|
+
const origin = origins.get(f.path);
|
|
1052
|
+
if (origin) f.origin = origin;
|
|
1053
|
+
}
|
|
677
1054
|
plan.files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
678
1055
|
const lines = [
|
|
679
1056
|
...plan.files.map((f) => `${f.path}\0${f.contentHash}
|
|
@@ -684,7 +1061,7 @@ function planPlain(source, filter, maxFileBytes) {
|
|
|
684
1061
|
plan.revision = `sha256:${sha256(lines.join(""))}`;
|
|
685
1062
|
return plan;
|
|
686
1063
|
}
|
|
687
|
-
var DEFAULT_MAX_FILE_BYTES, RESOLVER_INPUT;
|
|
1064
|
+
var RULE_EXCLUDED_LIMIT, RuleExcludedCollector, DEFAULT_MAX_FILE_BYTES, HARD_MAX_FILE_BYTES, RESOLVER_INPUT, UnsupportedCounter;
|
|
688
1065
|
var init_plan = __esm({
|
|
689
1066
|
"packages/planner/src/plan.ts"() {
|
|
690
1067
|
"use strict";
|
|
@@ -692,8 +1069,221 @@ var init_plan = __esm({
|
|
|
692
1069
|
init_classify();
|
|
693
1070
|
init_git();
|
|
694
1071
|
init_glob();
|
|
1072
|
+
RULE_EXCLUDED_LIMIT = 1e3;
|
|
1073
|
+
RuleExcludedCollector = class {
|
|
1074
|
+
constructor(filter) {
|
|
1075
|
+
this.filter = filter;
|
|
1076
|
+
}
|
|
1077
|
+
filter;
|
|
1078
|
+
paths = /* @__PURE__ */ new Map();
|
|
1079
|
+
file(rel) {
|
|
1080
|
+
const parts = rel.split("/");
|
|
1081
|
+
for (let i = 1; i < parts.length; i++) {
|
|
1082
|
+
const dir = parts.slice(0, i).join("/");
|
|
1083
|
+
if (this.filter.excludesDir(dir)) {
|
|
1084
|
+
const folder = this.paths.get(dir) ?? { path: dir, kind: "dir", files: 0 };
|
|
1085
|
+
if (folder.files !== null) folder.files = (folder.files ?? 0) + 1;
|
|
1086
|
+
this.paths.set(dir, folder);
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
this.paths.set(rel, { path: rel, kind: "file" });
|
|
1091
|
+
}
|
|
1092
|
+
/** A folder not walked (plain sources). */
|
|
1093
|
+
dir(rel) {
|
|
1094
|
+
this.paths.set(rel, { path: rel, kind: "dir", files: null });
|
|
1095
|
+
}
|
|
1096
|
+
apply(plan) {
|
|
1097
|
+
const all2 = [...this.paths.values()].sort((a, b) => a.path < b.path ? -1 : 1);
|
|
1098
|
+
plan.ruleExcluded = all2.slice(0, RULE_EXCLUDED_LIMIT);
|
|
1099
|
+
plan.ruleExcludedMore = all2.length - plan.ruleExcluded.length;
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
695
1102
|
DEFAULT_MAX_FILE_BYTES = 10 * 1024 * 1024;
|
|
1103
|
+
HARD_MAX_FILE_BYTES = 64 * 1024 * 1024;
|
|
696
1104
|
RESOLVER_INPUT = /\.(json|jsonc|lock|ya?ml|toml|mod|sum)$|(^|\/)(\.npmrc|\.nvmrc|\.babelrc)$/i;
|
|
1105
|
+
UnsupportedCounter = class {
|
|
1106
|
+
counts = /* @__PURE__ */ new Map();
|
|
1107
|
+
add(path) {
|
|
1108
|
+
const language = unsupportedLanguage(path);
|
|
1109
|
+
if (language) this.counts.set(language, (this.counts.get(language) ?? 0) + 1);
|
|
1110
|
+
}
|
|
1111
|
+
list() {
|
|
1112
|
+
return [...this.counts].map(([language, files]) => ({ language, files })).sort((a, b) => b.files - a.files || (a.language < b.language ? -1 : 1));
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
// packages/planner/src/browse.ts
|
|
1119
|
+
import { lstatSync as lstatSync2, readdirSync as readdirSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
1120
|
+
import { join as join3, sep as sep2 } from "node:path";
|
|
1121
|
+
function listDirectory(source, dir, options = {}) {
|
|
1122
|
+
const maxFileBytes = options.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES;
|
|
1123
|
+
const hardMax = Math.max(maxFileBytes, options.hardMaxFileBytes ?? HARD_MAX_FILE_BYTES);
|
|
1124
|
+
dir = dir.replace(/^\/+|\/+$/g, "");
|
|
1125
|
+
if (dir.split("/").some((p) => p === ".." || p === "."))
|
|
1126
|
+
throw new VeoError("invalid-arguments", `bad folder ${dir}`, { fields: ["dir"] });
|
|
1127
|
+
const raw = rawEntries(source, dir);
|
|
1128
|
+
const filter = new PathFilter(source.include, source.exclude);
|
|
1129
|
+
const optIn = new OptIn(source.optIn, source.exclude);
|
|
1130
|
+
const entries = [];
|
|
1131
|
+
for (const e of raw) {
|
|
1132
|
+
const name = e.path.slice(e.path.lastIndexOf("/") + 1);
|
|
1133
|
+
if (VCS_DIRS.has(name) && e.kind === "dir") continue;
|
|
1134
|
+
const entry = { path: e.path, kind: e.kind };
|
|
1135
|
+
const chosen = optIn.covers(e.path);
|
|
1136
|
+
if (chosen) entry.optedIn = true;
|
|
1137
|
+
const inDefault = e.kind === "dir" && DEFAULT_EXCLUDED_DIRS.has(name) ? defaultExcludedDir(`${e.path}/x`) : defaultExcludedDir(e.path);
|
|
1138
|
+
if (e.kind === "file") {
|
|
1139
|
+
entry.size = e.size;
|
|
1140
|
+
entry.language = classify(e.path) ?? null;
|
|
1141
|
+
if (e.symlink) entry.notAnalyzable = "symlink";
|
|
1142
|
+
else if (/\.d\.[cm]?ts$/i.test(e.path)) entry.notAnalyzable = "declaration-file";
|
|
1143
|
+
else if ((e.size ?? 0) > hardMax) entry.notAnalyzable = "over-hard-cap";
|
|
1144
|
+
}
|
|
1145
|
+
const origin = inDefault && inDefault.origin !== "vcs" ? inDefault.origin : e.kind === "file" ? defaultExcludedFile(e.path) : null;
|
|
1146
|
+
if (origin) entry.origin = origin;
|
|
1147
|
+
if (!chosen) {
|
|
1148
|
+
if (inDefault && inDefault.origin !== "vcs") entry.excludedBy = inDefault.origin;
|
|
1149
|
+
else if (e.kind === "file" && defaultExcludedFile(e.path)) entry.excludedBy = "generated";
|
|
1150
|
+
else if (e.kind === "dir" ? filter.excludesDir(e.path) || filter.includesNothingIn(e.path) : !filter.matches(e.path))
|
|
1151
|
+
entry.excludedBy = "rule";
|
|
1152
|
+
else if (e.kind === "file" && (e.size ?? 0) > maxFileBytes) entry.excludedBy = "too-large";
|
|
1153
|
+
} else if (entry.notAnalyzable === "over-hard-cap") entry.excludedBy = "too-large";
|
|
1154
|
+
entries.push(entry);
|
|
1155
|
+
}
|
|
1156
|
+
return entries.sort((a, b) => a.kind === b.kind ? a.path < b.path ? -1 : 1 : a.kind === "dir" ? -1 : 1);
|
|
1157
|
+
}
|
|
1158
|
+
function rawEntries(source, dir) {
|
|
1159
|
+
const repo = repoInfo(source.root);
|
|
1160
|
+
if (repo?.head) {
|
|
1161
|
+
const at = ` at ${repo.head.slice(0, 12)}`;
|
|
1162
|
+
let repoDir = repo.top;
|
|
1163
|
+
let commit = repo.head;
|
|
1164
|
+
let inRepo = repo.prefix.replace(/\/$/, "");
|
|
1165
|
+
const list = () => {
|
|
1166
|
+
try {
|
|
1167
|
+
return lsTreeDir(repoDir, commit, inRepo);
|
|
1168
|
+
} catch {
|
|
1169
|
+
throw notFound(source, dir, at);
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
for (const part of dir ? dir.split("/") : []) {
|
|
1173
|
+
const next = inRepo ? `${inRepo}/${part}` : part;
|
|
1174
|
+
const entry = list().find((e) => e.path === next);
|
|
1175
|
+
if (entry?.type === "tree") inRepo = next;
|
|
1176
|
+
else if (entry?.type === "commit") {
|
|
1177
|
+
const sub = submoduleDir(repoDir, next);
|
|
1178
|
+
if (!sub || !hasCommit(sub, entry.sha))
|
|
1179
|
+
throw notFound(source, dir, " (a submodule that isn't checked out)");
|
|
1180
|
+
repoDir = sub;
|
|
1181
|
+
commit = entry.sha;
|
|
1182
|
+
inRepo = "";
|
|
1183
|
+
} else throw notFound(source, dir, at);
|
|
1184
|
+
}
|
|
1185
|
+
return list().flatMap((e) => {
|
|
1186
|
+
const path = (dir ? `${dir}/` : "") + e.path.slice(e.path.lastIndexOf("/") + 1);
|
|
1187
|
+
if (e.type === "blob")
|
|
1188
|
+
return [{ path, kind: "file", size: e.size, ...e.mode === "120000" ? { symlink: true } : {} }];
|
|
1189
|
+
return [{ path, kind: "dir" }];
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
const abs = join3(source.root, ...dir.split("/").filter(Boolean));
|
|
1193
|
+
let names;
|
|
1194
|
+
try {
|
|
1195
|
+
const root = realpathSync2(source.root);
|
|
1196
|
+
const real = realpathSync2(abs);
|
|
1197
|
+
if (real !== root && !real.startsWith(root + sep2)) throw new Error("outside");
|
|
1198
|
+
if (dir && real !== join3(root, ...dir.split("/"))) throw new Error("through a link");
|
|
1199
|
+
names = readdirSync2(abs);
|
|
1200
|
+
} catch {
|
|
1201
|
+
throw notFound(source, dir);
|
|
1202
|
+
}
|
|
1203
|
+
return names.flatMap((name) => {
|
|
1204
|
+
const path = dir ? `${dir}/${name}` : name;
|
|
1205
|
+
try {
|
|
1206
|
+
const st = lstatSync2(join3(abs, name));
|
|
1207
|
+
if (st.isDirectory()) return [{ path, kind: "dir" }];
|
|
1208
|
+
if (st.isFile()) return [{ path, kind: "file", size: st.size }];
|
|
1209
|
+
if (st.isSymbolicLink()) return [{ path, kind: "file", size: st.size, symlink: true }];
|
|
1210
|
+
} catch {
|
|
1211
|
+
}
|
|
1212
|
+
return [];
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
function applySelection(source, paths, selected, options = {}) {
|
|
1216
|
+
let rules = {
|
|
1217
|
+
include: [...source.include],
|
|
1218
|
+
exclude: [...source.exclude],
|
|
1219
|
+
optIn: [...source.optIn ?? []]
|
|
1220
|
+
};
|
|
1221
|
+
for (const raw of paths) {
|
|
1222
|
+
const path = raw.replace(/\\/g, "/").replace(/^\.?\/+|\/+$/g, "");
|
|
1223
|
+
if (!path)
|
|
1224
|
+
throw new VeoError(
|
|
1225
|
+
"invalid-arguments",
|
|
1226
|
+
"the source root can't be selected; choose files or folders in it",
|
|
1227
|
+
{ fields: ["paths"] }
|
|
1228
|
+
);
|
|
1229
|
+
const entry = () => find({ ...source, ...rules }, path, options);
|
|
1230
|
+
const first = entry();
|
|
1231
|
+
const kind = first.kind;
|
|
1232
|
+
if (selected && first.notAnalyzable)
|
|
1233
|
+
throw new VeoError(
|
|
1234
|
+
"invalid-arguments",
|
|
1235
|
+
`${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"})`,
|
|
1236
|
+
{ fields: ["paths"] }
|
|
1237
|
+
);
|
|
1238
|
+
const inside = (p) => p === path || p.startsWith(`${path}/`);
|
|
1239
|
+
const written = (rule) => {
|
|
1240
|
+
const r = rule.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
1241
|
+
return rule.startsWith("/") && (kind === "dir" ? inside(r) : r === path);
|
|
1242
|
+
};
|
|
1243
|
+
if (selected) {
|
|
1244
|
+
rules = { ...rules, exclude: rules.exclude.filter((r) => !written(r)) };
|
|
1245
|
+
if (entry().excludedBy) rules = { ...rules, optIn: [...rules.optIn.filter((p) => !inside(p)), path] };
|
|
1246
|
+
for (const o of rules.optIn.filter((p) => p !== path && inside(p))) {
|
|
1247
|
+
const without = { ...rules, optIn: rules.optIn.filter((p) => p !== o) };
|
|
1248
|
+
let needed = false;
|
|
1249
|
+
try {
|
|
1250
|
+
needed = !!find({ ...source, ...without }, o, options).excludedBy;
|
|
1251
|
+
} catch {
|
|
1252
|
+
}
|
|
1253
|
+
if (!needed) rules = without;
|
|
1254
|
+
}
|
|
1255
|
+
} else {
|
|
1256
|
+
rules = { ...rules, optIn: rules.optIn.filter((p) => !inside(p)) };
|
|
1257
|
+
if (!entry().excludedBy)
|
|
1258
|
+
rules = { ...rules, exclude: [...rules.exclude, kind === "dir" ? `/${path}/` : `/${path}`] };
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
return rules;
|
|
1262
|
+
}
|
|
1263
|
+
function find(source, path, options) {
|
|
1264
|
+
const slash = path.lastIndexOf("/");
|
|
1265
|
+
const parent = slash < 0 ? "" : path.slice(0, slash);
|
|
1266
|
+
const entry = listDirectory(source, parent, options).find((e) => e.path === path);
|
|
1267
|
+
if (!entry)
|
|
1268
|
+
throw new VeoError("not-found", `no file or folder ${path} in source ${source.id}`, {
|
|
1269
|
+
kind: "path",
|
|
1270
|
+
id: path
|
|
1271
|
+
});
|
|
1272
|
+
return entry;
|
|
1273
|
+
}
|
|
1274
|
+
var notFound;
|
|
1275
|
+
var init_browse = __esm({
|
|
1276
|
+
"packages/planner/src/browse.ts"() {
|
|
1277
|
+
"use strict";
|
|
1278
|
+
init_src();
|
|
1279
|
+
init_classify();
|
|
1280
|
+
init_glob();
|
|
1281
|
+
init_git();
|
|
1282
|
+
init_plan();
|
|
1283
|
+
notFound = (source, dir, at = "") => new VeoError("not-found", `no folder ${dir || "."} in source ${source.id}${at}`, {
|
|
1284
|
+
kind: "folder",
|
|
1285
|
+
id: dir
|
|
1286
|
+
});
|
|
697
1287
|
}
|
|
698
1288
|
});
|
|
699
1289
|
|
|
@@ -757,7 +1347,10 @@ function indexColumns(fact) {
|
|
|
757
1347
|
case "Function":
|
|
758
1348
|
return { file: fact.file, src: null, dst: null };
|
|
759
1349
|
case "CALLS":
|
|
1350
|
+
case "CALLS_CROSS_FILE":
|
|
760
1351
|
return { file: fact.evidence.file, src: fact.from, dst: fact.to };
|
|
1352
|
+
case "DeclaredTemplate":
|
|
1353
|
+
return { file: fact.file, src: null, dst: null };
|
|
761
1354
|
case "UnresolvedCallSite":
|
|
762
1355
|
return { file: fact.file, src: fact.enclosingFn, dst: null };
|
|
763
1356
|
case "Finding":
|
|
@@ -775,7 +1368,7 @@ function sourceOf(fileId) {
|
|
|
775
1368
|
}
|
|
776
1369
|
function factSource(fact) {
|
|
777
1370
|
if (fact.type === "File") return fact.source;
|
|
778
|
-
if (fact.type === "CALLS") return sourceOf(fact.evidence.file);
|
|
1371
|
+
if (fact.type === "CALLS" || fact.type === "CALLS_CROSS_FILE") return sourceOf(fact.evidence.file);
|
|
779
1372
|
return sourceOf(fact.evidence ? fact.evidence.file : fact.file);
|
|
780
1373
|
}
|
|
781
1374
|
function processAlive(pid) {
|
|
@@ -891,10 +1484,10 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
891
1484
|
return this.rows("file = :file", { file: file2 });
|
|
892
1485
|
}
|
|
893
1486
|
callsFrom(fnId) {
|
|
894
|
-
return this.rows("type
|
|
1487
|
+
return this.rows("type IN ('CALLS', 'CALLS_CROSS_FILE') AND src = :id", { id: fnId });
|
|
895
1488
|
}
|
|
896
1489
|
callsTo(fnId) {
|
|
897
|
-
return this.rows("type
|
|
1490
|
+
return this.rows("type IN ('CALLS', 'CALLS_CROSS_FILE') AND dst = :id", { id: fnId });
|
|
898
1491
|
}
|
|
899
1492
|
/** How many facts of a type each file holds (functions or calls per file, for the file list). */
|
|
900
1493
|
countByFile(type) {
|
|
@@ -911,7 +1504,7 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
911
1504
|
const other = end === "src" ? "dst" : "src";
|
|
912
1505
|
const out = /* @__PURE__ */ new Map();
|
|
913
1506
|
const query = (where, params) => this.db.prepare(
|
|
914
|
-
`SELECT ${end} AS k, COUNT(*) AS calls, COUNT(DISTINCT ${other}) AS functions FROM facts WHERE ${VISIBLE} AND type
|
|
1507
|
+
`SELECT ${end} AS k, COUNT(*) AS calls, COUNT(DISTINCT ${other}) AS functions FROM facts WHERE ${VISIBLE} AND type IN ('CALLS', 'CALLS_CROSS_FILE')${where} GROUP BY ${end}`
|
|
915
1508
|
).all({ ...params, run: this.run });
|
|
916
1509
|
if (!ids2) {
|
|
917
1510
|
for (const r of query("", {})) out.set(r.k, { calls: r.calls, functions: r.functions });
|
|
@@ -1256,7 +1849,7 @@ ${payload}`);
|
|
|
1256
1849
|
// packages/store/src/evidence-store.ts
|
|
1257
1850
|
import { createHash as createHash3 } from "node:crypto";
|
|
1258
1851
|
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, renameSync, writeFileSync } from "node:fs";
|
|
1259
|
-
import { dirname as dirname2, join as
|
|
1852
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
1260
1853
|
var EvidenceStore;
|
|
1261
1854
|
var init_evidence_store = __esm({
|
|
1262
1855
|
"packages/store/src/evidence-store.ts"() {
|
|
@@ -1272,7 +1865,7 @@ var init_evidence_store = __esm({
|
|
|
1272
1865
|
}
|
|
1273
1866
|
pathFor(hash2) {
|
|
1274
1867
|
if (!/^[0-9a-f]{64}$/.test(hash2)) throw new Error(`invalid content hash ${hash2}`);
|
|
1275
|
-
return
|
|
1868
|
+
return join4(this.dir, hash2.slice(0, 2), hash2);
|
|
1276
1869
|
}
|
|
1277
1870
|
/** Store content; returns its SHA-256. */
|
|
1278
1871
|
put(content) {
|
|
@@ -1301,8 +1894,8 @@ var init_evidence_store = __esm({
|
|
|
1301
1894
|
import {
|
|
1302
1895
|
existsSync as existsSync4,
|
|
1303
1896
|
mkdirSync as mkdirSync2,
|
|
1304
|
-
readdirSync as
|
|
1305
|
-
realpathSync as
|
|
1897
|
+
readdirSync as readdirSync3,
|
|
1898
|
+
realpathSync as realpathSync3,
|
|
1306
1899
|
renameSync as renameSync2,
|
|
1307
1900
|
rmdirSync,
|
|
1308
1901
|
rmSync,
|
|
@@ -1310,12 +1903,12 @@ import {
|
|
|
1310
1903
|
symlinkSync
|
|
1311
1904
|
} from "node:fs";
|
|
1312
1905
|
import { homedir } from "node:os";
|
|
1313
|
-
import { basename, dirname as dirname3, join as
|
|
1906
|
+
import { basename, dirname as dirname3, join as join5, resolve, sep as sep3 } from "node:path";
|
|
1314
1907
|
function defaultHome() {
|
|
1315
1908
|
const configured = process.env.VEOFLOW_HOME ?? process.env.VEO_HOME;
|
|
1316
1909
|
if (configured) return configured;
|
|
1317
|
-
const home =
|
|
1318
|
-
const legacy =
|
|
1910
|
+
const home = join5(homedir(), ".veoflow");
|
|
1911
|
+
const legacy = join5(homedir(), ".veo");
|
|
1319
1912
|
const outcome = migrateLegacyHome(legacy, home);
|
|
1320
1913
|
switch (outcome) {
|
|
1321
1914
|
case "moved":
|
|
@@ -1342,10 +1935,10 @@ function defaultHome() {
|
|
|
1342
1935
|
}
|
|
1343
1936
|
}
|
|
1344
1937
|
function inUse(dir) {
|
|
1345
|
-
const projects =
|
|
1938
|
+
const projects = join5(dir, "projects");
|
|
1346
1939
|
if (!existsSync4(projects)) return false;
|
|
1347
|
-
for (const id of
|
|
1348
|
-
const graph =
|
|
1940
|
+
for (const id of readdirSync3(projects)) {
|
|
1941
|
+
const graph = join5(projects, id, "graph.sqlite");
|
|
1349
1942
|
if (!existsSync4(graph)) continue;
|
|
1350
1943
|
try {
|
|
1351
1944
|
const db = openDatabase(graph);
|
|
@@ -1361,9 +1954,9 @@ function inUse(dir) {
|
|
|
1361
1954
|
return false;
|
|
1362
1955
|
}
|
|
1363
1956
|
function migrateLegacyHome(legacy, home) {
|
|
1364
|
-
if (!existsSync4(
|
|
1957
|
+
if (!existsSync4(join5(legacy, "catalog.sqlite"))) return "none";
|
|
1365
1958
|
if (existsSync4(home)) {
|
|
1366
|
-
if (existsSync4(
|
|
1959
|
+
if (existsSync4(join5(home, "catalog.sqlite"))) return "both";
|
|
1367
1960
|
try {
|
|
1368
1961
|
rmdirSync(home);
|
|
1369
1962
|
} catch {
|
|
@@ -1395,20 +1988,21 @@ function canonicalPath(path) {
|
|
|
1395
1988
|
rest.unshift(basename(p));
|
|
1396
1989
|
p = parent;
|
|
1397
1990
|
}
|
|
1398
|
-
return
|
|
1991
|
+
return join5(realpathSync3.native(p), ...rest);
|
|
1399
1992
|
}
|
|
1400
1993
|
function isWithin(child, parent) {
|
|
1401
1994
|
const c = resolve(child);
|
|
1402
1995
|
const p = resolve(parent);
|
|
1403
|
-
return c === p || c.startsWith(p.endsWith(
|
|
1996
|
+
return c === p || c.startsWith(p.endsWith(sep3) ? p : p + sep3);
|
|
1404
1997
|
}
|
|
1405
|
-
var SCHEMA2, Catalog;
|
|
1998
|
+
var DEFAULT_PROJECT_SETTINGS, SCHEMA2, Catalog;
|
|
1406
1999
|
var init_catalog = __esm({
|
|
1407
2000
|
"packages/store/src/catalog.ts"() {
|
|
1408
2001
|
"use strict";
|
|
1409
2002
|
init_src();
|
|
1410
2003
|
init_project_store();
|
|
1411
2004
|
init_sqlite();
|
|
2005
|
+
DEFAULT_PROJECT_SETTINGS = { maxFileMB: 10 };
|
|
1412
2006
|
SCHEMA2 = `
|
|
1413
2007
|
CREATE TABLE IF NOT EXISTS projects (id TEXT PRIMARY KEY, name TEXT NOT NULL, created_at TEXT NOT NULL);
|
|
1414
2008
|
CREATE TABLE IF NOT EXISTS sources (
|
|
@@ -1425,17 +2019,57 @@ CREATE TABLE IF NOT EXISTS sources (
|
|
|
1425
2019
|
Catalog = class {
|
|
1426
2020
|
constructor(home = defaultHome()) {
|
|
1427
2021
|
this.home = home;
|
|
1428
|
-
mkdirSync2(
|
|
1429
|
-
this.db = openDatabase(
|
|
2022
|
+
mkdirSync2(join5(home, "projects"), { recursive: true });
|
|
2023
|
+
this.db = openDatabase(join5(home, "catalog.sqlite"));
|
|
1430
2024
|
this.db.exec(SCHEMA2);
|
|
2025
|
+
const has = (table, column) => this.db.prepare(`PRAGMA table_info(${table})`).all().some(
|
|
2026
|
+
(c) => c.name === column
|
|
2027
|
+
);
|
|
2028
|
+
if (!has("sources", "opt_in"))
|
|
2029
|
+
this.db.exec("ALTER TABLE sources ADD COLUMN opt_in TEXT NOT NULL DEFAULT '[]'");
|
|
2030
|
+
if (!has("projects", "settings"))
|
|
2031
|
+
this.db.exec("ALTER TABLE projects ADD COLUMN settings TEXT NOT NULL DEFAULT '{}'");
|
|
1431
2032
|
}
|
|
1432
2033
|
home;
|
|
1433
2034
|
db;
|
|
2035
|
+
/** A project's analysis settings (defaults for anything not set). */
|
|
2036
|
+
projectSettings(projectId) {
|
|
2037
|
+
const row = this.db.prepare("SELECT settings FROM projects WHERE id = ?").get(projectId);
|
|
2038
|
+
if (!row) throw new VeoError("not-found", `no project ${projectId}`);
|
|
2039
|
+
return { ...DEFAULT_PROJECT_SETTINGS, ...JSON.parse(row.settings || "{}") };
|
|
2040
|
+
}
|
|
2041
|
+
setProjectSettings(projectId, settings) {
|
|
2042
|
+
const next = { ...this.projectSettings(projectId), ...settings };
|
|
2043
|
+
this.db.prepare("UPDATE projects SET settings = ? WHERE id = ?").run(JSON.stringify(next), projectId);
|
|
2044
|
+
return next;
|
|
2045
|
+
}
|
|
2046
|
+
/** Change a source's rules (plan D36): applied at the next run. */
|
|
2047
|
+
updateSource(projectId, sourceId, rules) {
|
|
2048
|
+
const source = this.listSources(projectId).find((s) => s.id === sourceId);
|
|
2049
|
+
if (!source)
|
|
2050
|
+
throw new VeoError("not-found", `no source ${sourceId} in ${projectId}`, {
|
|
2051
|
+
kind: "source",
|
|
2052
|
+
id: sourceId
|
|
2053
|
+
});
|
|
2054
|
+
const next = {
|
|
2055
|
+
include: rules.include ?? source.include,
|
|
2056
|
+
exclude: rules.exclude ?? source.exclude,
|
|
2057
|
+
optIn: rules.optIn ?? source.optIn ?? []
|
|
2058
|
+
};
|
|
2059
|
+
this.db.prepare("UPDATE sources SET include = ?, exclude = ?, opt_in = ? WHERE project_id = ? AND id = ?").run(
|
|
2060
|
+
JSON.stringify(next.include),
|
|
2061
|
+
JSON.stringify(next.exclude),
|
|
2062
|
+
JSON.stringify(next.optIn),
|
|
2063
|
+
projectId,
|
|
2064
|
+
sourceId
|
|
2065
|
+
);
|
|
2066
|
+
return { ...source, ...next };
|
|
2067
|
+
}
|
|
1434
2068
|
close() {
|
|
1435
2069
|
this.db.close();
|
|
1436
2070
|
}
|
|
1437
2071
|
projectDir(id) {
|
|
1438
|
-
return
|
|
2072
|
+
return join5(this.home, "projects", id);
|
|
1439
2073
|
}
|
|
1440
2074
|
createProject(name, id) {
|
|
1441
2075
|
const base = assertSourceId(id ?? slug(name));
|
|
@@ -1466,7 +2100,7 @@ CREATE TABLE IF NOT EXISTS sources (
|
|
|
1466
2100
|
/** Delete a project and its store directory. Refused while a run holds its lock. */
|
|
1467
2101
|
deleteProject(id) {
|
|
1468
2102
|
if (!this.getProject(id)) throw new VeoError("not-found", `no project ${id}`);
|
|
1469
|
-
const graph =
|
|
2103
|
+
const graph = join5(this.projectDir(id), "graph.sqlite");
|
|
1470
2104
|
if (existsSync4(graph)) {
|
|
1471
2105
|
const db = openDatabase(graph);
|
|
1472
2106
|
try {
|
|
@@ -1509,7 +2143,7 @@ CREATE TABLE IF NOT EXISTS sources (
|
|
|
1509
2143
|
);
|
|
1510
2144
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1511
2145
|
this.db.prepare(
|
|
1512
|
-
"INSERT INTO sources (project_id, id, kind, root, include, exclude, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)"
|
|
2146
|
+
"INSERT INTO sources (project_id, id, kind, root, include, exclude, opt_in, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
|
|
1513
2147
|
).run(
|
|
1514
2148
|
projectId,
|
|
1515
2149
|
source.id,
|
|
@@ -1517,9 +2151,10 @@ CREATE TABLE IF NOT EXISTS sources (
|
|
|
1517
2151
|
root,
|
|
1518
2152
|
JSON.stringify(source.include),
|
|
1519
2153
|
JSON.stringify(source.exclude),
|
|
2154
|
+
JSON.stringify(source.optIn ?? []),
|
|
1520
2155
|
createdAt
|
|
1521
2156
|
);
|
|
1522
|
-
return { ...source, root, projectId, createdAt };
|
|
2157
|
+
return { ...source, optIn: source.optIn ?? [], root, projectId, createdAt };
|
|
1523
2158
|
}
|
|
1524
2159
|
removeSource(projectId, sourceId) {
|
|
1525
2160
|
this.db.prepare("DELETE FROM sources WHERE project_id = ? AND id = ?").run(projectId, sourceId);
|
|
@@ -1532,6 +2167,7 @@ CREATE TABLE IF NOT EXISTS sources (
|
|
|
1532
2167
|
root: r.root,
|
|
1533
2168
|
include: JSON.parse(r.include),
|
|
1534
2169
|
exclude: JSON.parse(r.exclude),
|
|
2170
|
+
optIn: JSON.parse(r.opt_in ?? "[]"),
|
|
1535
2171
|
createdAt: r.created_at
|
|
1536
2172
|
}));
|
|
1537
2173
|
}
|
|
@@ -1562,7 +2198,7 @@ CREATE TABLE IF NOT EXISTS sources (
|
|
|
1562
2198
|
|
|
1563
2199
|
// packages/store/src/index.ts
|
|
1564
2200
|
import { mkdirSync as mkdirSync3 } from "node:fs";
|
|
1565
|
-
import { join as
|
|
2201
|
+
import { join as join6 } from "node:path";
|
|
1566
2202
|
var GraphRepository;
|
|
1567
2203
|
var init_src2 = __esm({
|
|
1568
2204
|
"packages/store/src/index.ts"() {
|
|
@@ -1576,8 +2212,8 @@ var init_src2 = __esm({
|
|
|
1576
2212
|
GraphRepository = class {
|
|
1577
2213
|
openProject(projectId, dir, options = {}) {
|
|
1578
2214
|
mkdirSync3(dir, { recursive: true });
|
|
1579
|
-
const store = new ProjectStore(projectId,
|
|
1580
|
-
const evidence = new EvidenceStore(
|
|
2215
|
+
const store = new ProjectStore(projectId, join6(dir, "graph.sqlite"), options);
|
|
2216
|
+
const evidence = new EvidenceStore(join6(dir, "evidence"));
|
|
1581
2217
|
return { store, evidence, close: () => store.close() };
|
|
1582
2218
|
}
|
|
1583
2219
|
};
|
|
@@ -1610,7 +2246,9 @@ function executeRun(request) {
|
|
|
1610
2246
|
queue.tail = next.catch(() => void 0);
|
|
1611
2247
|
return next;
|
|
1612
2248
|
}
|
|
1613
|
-
function sourcesOf(plans) {
|
|
2249
|
+
function sourcesOf(plans, request) {
|
|
2250
|
+
const specs = request.sources;
|
|
2251
|
+
const maxFileBytes = request.planOptions?.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES;
|
|
1614
2252
|
return plans.map((p) => ({
|
|
1615
2253
|
sourceId: p.sourceId,
|
|
1616
2254
|
revision: p.revision,
|
|
@@ -1618,9 +2256,21 @@ function sourcesOf(plans) {
|
|
|
1618
2256
|
kind: p.kind,
|
|
1619
2257
|
...p.kind === "git" ? { dirty: p.dirty } : {},
|
|
1620
2258
|
...p.unpinned.length ? { unpinned: p.unpinned } : {},
|
|
2259
|
+
...p.unsupported.length ? { unsupported: p.unsupported } : {},
|
|
2260
|
+
...filterOf(specs.find((s) => s.id === p.sourceId)),
|
|
2261
|
+
maxFileBytes,
|
|
2262
|
+
...p.defaultExcluded.length ? { defaultExcluded: p.defaultExcluded } : {},
|
|
2263
|
+
...p.ruleExcluded.length ? { ruleExcluded: p.ruleExcluded } : {},
|
|
2264
|
+
...p.ruleExcludedMore ? { ruleExcludedMore: p.ruleExcludedMore } : {},
|
|
1621
2265
|
...p.notices.length ? { notices: p.notices } : {}
|
|
1622
2266
|
}));
|
|
1623
2267
|
}
|
|
2268
|
+
function filterOf(spec) {
|
|
2269
|
+
if (!spec) return {};
|
|
2270
|
+
const optIn = spec.optIn ?? [];
|
|
2271
|
+
if (spec.include.length === 0 && spec.exclude.length === 0 && optIn.length === 0) return {};
|
|
2272
|
+
return { filter: { include: spec.include, exclude: spec.exclude, optIn } };
|
|
2273
|
+
}
|
|
1624
2274
|
async function runNow(request) {
|
|
1625
2275
|
const { projectId, store } = request;
|
|
1626
2276
|
const trigger = request.trigger ?? "manual";
|
|
@@ -1645,7 +2295,7 @@ async function runNow(request) {
|
|
|
1645
2295
|
planError = e;
|
|
1646
2296
|
}
|
|
1647
2297
|
try {
|
|
1648
|
-
run = store.beginRun({ trigger, sources: sourcesOf(plans) });
|
|
2298
|
+
run = store.beginRun({ trigger, sources: sourcesOf(plans, request) });
|
|
1649
2299
|
break;
|
|
1650
2300
|
} catch (e) {
|
|
1651
2301
|
if (!(e instanceof ProjectLockedError)) throw e;
|
|
@@ -1666,7 +2316,7 @@ async function runNow(request) {
|
|
|
1666
2316
|
}
|
|
1667
2317
|
let current = "plan";
|
|
1668
2318
|
try {
|
|
1669
|
-
emit({ type: "run.started", projectId, runId: run.runId, trigger, sources: sourcesOf(plans) });
|
|
2319
|
+
emit({ type: "run.started", projectId, runId: run.runId, trigger, sources: sourcesOf(plans, request) });
|
|
1670
2320
|
if (planError) throw planError;
|
|
1671
2321
|
for (const stage of request.stages) {
|
|
1672
2322
|
current = stage.name;
|
|
@@ -1729,6 +2379,7 @@ var init_run = __esm({
|
|
|
1729
2379
|
var init_src3 = __esm({
|
|
1730
2380
|
"packages/planner/src/index.ts"() {
|
|
1731
2381
|
"use strict";
|
|
2382
|
+
init_browse();
|
|
1732
2383
|
init_classify();
|
|
1733
2384
|
init_glob();
|
|
1734
2385
|
init_plan();
|
|
@@ -1770,7 +2421,7 @@ var PROTOCOL_VERSION;
|
|
|
1770
2421
|
var init_protocol = __esm({
|
|
1771
2422
|
"protocol/index.ts"() {
|
|
1772
2423
|
"use strict";
|
|
1773
|
-
PROTOCOL_VERSION = "1.
|
|
2424
|
+
PROTOCOL_VERSION = "1.2.0";
|
|
1774
2425
|
}
|
|
1775
2426
|
});
|
|
1776
2427
|
|
|
@@ -1799,7 +2450,9 @@ function factsForFile(sourceId, file2, result2) {
|
|
|
1799
2450
|
language: file2.language,
|
|
1800
2451
|
contentHash: file2.contentHash,
|
|
1801
2452
|
status: "not_analyzed",
|
|
1802
|
-
...file2.commit ? { commit: file2.commit } : {}
|
|
2453
|
+
...file2.commit ? { commit: file2.commit } : {},
|
|
2454
|
+
...file2.origin ? { origin: file2.origin } : {},
|
|
2455
|
+
...file2.skip === "too-large" ? { size: file2.size } : {}
|
|
1803
2456
|
};
|
|
1804
2457
|
if (!result2 && !file2.skip) {
|
|
1805
2458
|
node2.reason = "adapter-no-result";
|
|
@@ -1846,6 +2499,7 @@ function factsForFile(sourceId, file2, result2) {
|
|
|
1846
2499
|
isGenerator: d.isGenerator,
|
|
1847
2500
|
implicit: d.implicit,
|
|
1848
2501
|
overloads: d.overloads,
|
|
2502
|
+
...d.title ? { title: d.title } : {},
|
|
1849
2503
|
evidence: evidence(d.span)
|
|
1850
2504
|
};
|
|
1851
2505
|
facts.push(fn);
|
|
@@ -1880,6 +2534,20 @@ function factsForFile(sourceId, file2, result2) {
|
|
|
1880
2534
|
};
|
|
1881
2535
|
facts.push(site);
|
|
1882
2536
|
}
|
|
2537
|
+
for (const t of result2.templates) {
|
|
2538
|
+
facts.push({
|
|
2539
|
+
type: "DeclaredTemplate",
|
|
2540
|
+
id: `template|${fileId}|${t.component}`,
|
|
2541
|
+
file: fileId,
|
|
2542
|
+
component: t.component,
|
|
2543
|
+
specifier: t.specifier,
|
|
2544
|
+
methods: t.methods,
|
|
2545
|
+
signals: t.signals,
|
|
2546
|
+
fields: t.fields,
|
|
2547
|
+
inherits: t.inherits,
|
|
2548
|
+
evidence: evidence(t.span)
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
1883
2551
|
for (const [d, ordinal] of withOrdinals(
|
|
1884
2552
|
result2.diagnostics.filter((d2) => d2.severity !== "info"),
|
|
1885
2553
|
(d2) => d2.code
|
|
@@ -1960,18 +2628,212 @@ var init_readback = __esm({
|
|
|
1960
2628
|
}
|
|
1961
2629
|
});
|
|
1962
2630
|
|
|
2631
|
+
// packages/stages/src/template-link.ts
|
|
2632
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
2633
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
2634
|
+
import { join as join7, posix, relative as relative2, sep as sep4 } from "node:path";
|
|
2635
|
+
function runTemplateLink(ctx) {
|
|
2636
|
+
const view = ctx.view;
|
|
2637
|
+
const files = view.facts("File");
|
|
2638
|
+
const fileById = new Map(files.map((f) => [f.id, f]));
|
|
2639
|
+
const scopes = /* @__PURE__ */ new Set();
|
|
2640
|
+
const facts = [];
|
|
2641
|
+
const push = (scope, fact) => {
|
|
2642
|
+
scopes.add(scope);
|
|
2643
|
+
facts.push({ scope, fact });
|
|
2644
|
+
};
|
|
2645
|
+
for (const e of view.facts("CALLS_CROSS_FILE"))
|
|
2646
|
+
if (e.via === "template-link") scopes.add(scopeOf(`${e.evidence.file}|${e.component}`));
|
|
2647
|
+
for (const u of view.facts("UnresolvedCallSite"))
|
|
2648
|
+
if (u.component) scopes.add(scopeOf(`${u.file}|${u.component}`));
|
|
2649
|
+
for (const f of view.facts("Finding"))
|
|
2650
|
+
if (f.id.startsWith(`${TEMPLATE_LINK}|`)) scopes.add(scopeOf(f.component ?? f.file));
|
|
2651
|
+
const roots = ctx.plans.map((p) => ({
|
|
2652
|
+
source: p.sourceId,
|
|
2653
|
+
root: p.root,
|
|
2654
|
+
kind: p.kind,
|
|
2655
|
+
revision: p.revision
|
|
2656
|
+
}));
|
|
2657
|
+
const exists = (r, rel) => {
|
|
2658
|
+
if (r.kind !== "git") return existsSync5(join7(r.root, ...rel.split("/")));
|
|
2659
|
+
try {
|
|
2660
|
+
execFileSync2("git", ["-C", r.root, "cat-file", "-e", `${r.revision}:./${rel}`], { stdio: "ignore" });
|
|
2661
|
+
return true;
|
|
2662
|
+
} catch {
|
|
2663
|
+
return false;
|
|
2664
|
+
}
|
|
2665
|
+
};
|
|
2666
|
+
const resolveTarget = (d) => {
|
|
2667
|
+
if (d.specifier === null) return { kind: "computed" };
|
|
2668
|
+
const owner = fileById.get(d.file);
|
|
2669
|
+
if (!owner) return { kind: "not-found" };
|
|
2670
|
+
const ownerRoot = roots.find((r) => r.source === owner.source);
|
|
2671
|
+
const rel = d.specifier.startsWith("/") ? posix.normalize(d.specifier.slice(1)) : posix.normalize(posix.join(posix.dirname(owner.path), d.specifier));
|
|
2672
|
+
if (!rel.startsWith("../") && rel !== "..") {
|
|
2673
|
+
const file2 = fileById.get(ids.file(owner.source, rel));
|
|
2674
|
+
if (file2)
|
|
2675
|
+
return file2.language === "angular-template" ? { kind: "file", file: file2 } : { kind: "not-analyzed" };
|
|
2676
|
+
return { kind: ownerRoot && exists(ownerRoot, rel) ? "not-analyzed" : "not-found" };
|
|
2677
|
+
}
|
|
2678
|
+
if (ownerRoot) {
|
|
2679
|
+
const abs = join7(ownerRoot.root, ...owner.path.split("/").slice(0, -1), ...d.specifier.split("/"));
|
|
2680
|
+
for (const r of roots) {
|
|
2681
|
+
const inside = relative2(r.root, abs);
|
|
2682
|
+
if (inside && !inside.startsWith("..") && !inside.startsWith(sep4) && !/^[a-zA-Z]:/.test(inside)) {
|
|
2683
|
+
const inRel = inside.split(sep4).join("/");
|
|
2684
|
+
const file2 = fileById.get(ids.file(r.source, inRel));
|
|
2685
|
+
if (file2)
|
|
2686
|
+
return file2.language === "angular-template" ? { kind: "file", file: file2 } : { kind: "not-analyzed" };
|
|
2687
|
+
return { kind: exists(r, inRel) ? "not-analyzed" : "not-found" };
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
return { kind: "pending" };
|
|
2692
|
+
};
|
|
2693
|
+
const owners = /* @__PURE__ */ new Map();
|
|
2694
|
+
for (const d of view.facts("DeclaredTemplate")) {
|
|
2695
|
+
const key = componentKey(d);
|
|
2696
|
+
scopes.add(scopeOf(key));
|
|
2697
|
+
const target2 = resolveTarget(d);
|
|
2698
|
+
if (target2.kind === "file") {
|
|
2699
|
+
const list = owners.get(target2.file.id) ?? [];
|
|
2700
|
+
list.push(d);
|
|
2701
|
+
owners.set(target2.file.id, list);
|
|
2702
|
+
continue;
|
|
2703
|
+
}
|
|
2704
|
+
const kind = `template-${target2.kind === "computed" ? "url-computed" : target2.kind}`;
|
|
2705
|
+
const message2 = {
|
|
2706
|
+
computed: `${d.component}'s templateUrl is computed, so its template can't be linked`,
|
|
2707
|
+
"not-found": `${d.component} declares ${d.specifier}, which does not exist in the source`,
|
|
2708
|
+
pending: `${d.component} declares ${d.specifier}, which is outside every source of this project; it links when that source is added`,
|
|
2709
|
+
"not-analyzed": `${d.component} declares ${d.specifier}, which exists but was not analyzed as an Angular template`
|
|
2710
|
+
}[target2.kind];
|
|
2711
|
+
const finding = {
|
|
2712
|
+
type: "Finding",
|
|
2713
|
+
id: `${TEMPLATE_LINK}|${kind}|${key}`,
|
|
2714
|
+
kind,
|
|
2715
|
+
file: d.file,
|
|
2716
|
+
message: message2,
|
|
2717
|
+
evidence: d.evidence,
|
|
2718
|
+
severity: target2.kind === "pending" ? "info" : "warning",
|
|
2719
|
+
component: key
|
|
2720
|
+
};
|
|
2721
|
+
push(scopeOf(key), finding);
|
|
2722
|
+
}
|
|
2723
|
+
for (const template of files.filter((f) => f.language === "angular-template")) {
|
|
2724
|
+
const declaring = owners.get(template.id) ?? [];
|
|
2725
|
+
if (declaring.length === 0) {
|
|
2726
|
+
const finding = {
|
|
2727
|
+
type: "Finding",
|
|
2728
|
+
id: `${TEMPLATE_LINK}|template-owner-unknown|${template.id}`,
|
|
2729
|
+
kind: "template-owner-unknown",
|
|
2730
|
+
file: template.id,
|
|
2731
|
+
message: "No component declares this template, so its calls are not part of a component",
|
|
2732
|
+
evidence: null,
|
|
2733
|
+
severity: "info"
|
|
2734
|
+
};
|
|
2735
|
+
push(scopeOf(template.id), finding);
|
|
2736
|
+
continue;
|
|
2737
|
+
}
|
|
2738
|
+
const bindings = view.inFile(template.id).flatMap(
|
|
2739
|
+
(f) => f.type === "UnresolvedCallSite" && f.reason === "template-binding" && !f.component ? [f] : []
|
|
2740
|
+
).sort((a, b) => a.evidence.span.start.offset - b.evidence.span.start.offset);
|
|
2741
|
+
const from = ids.fn(template.source, template.path, "<template>");
|
|
2742
|
+
const evidence = (u) => ({ ...u.evidence, commit: template.commit ?? "" });
|
|
2743
|
+
for (const d of declaring) {
|
|
2744
|
+
const key = componentKey(d);
|
|
2745
|
+
const scope = scopeOf(`${template.id}|${key}`);
|
|
2746
|
+
scopes.add(scope);
|
|
2747
|
+
const owner = fileById.get(d.file);
|
|
2748
|
+
const ordinals = /* @__PURE__ */ new Map();
|
|
2749
|
+
for (const u of bindings) {
|
|
2750
|
+
const [root, ...path] = u.expression.replace(/[\s()!]/g, "").replace(/\?\./g, ".").replace(/^this\./, "").split(".");
|
|
2751
|
+
const method = path.length === 0 ? d.methods.find((m) => m.name === root) : void 0;
|
|
2752
|
+
if (method) {
|
|
2753
|
+
const to = ids.fn(owner.source, owner.path, method.qualifiedName);
|
|
2754
|
+
const n = ordinals.get(to) ?? 0;
|
|
2755
|
+
ordinals.set(to, n + 1);
|
|
2756
|
+
const edge = {
|
|
2757
|
+
type: "CALLS_CROSS_FILE",
|
|
2758
|
+
id: `${ids.edge("CALLS_CROSS_FILE", from, to, n)}|${key}`,
|
|
2759
|
+
from,
|
|
2760
|
+
to,
|
|
2761
|
+
form: "plain",
|
|
2762
|
+
resolution: "static-exact",
|
|
2763
|
+
confidence: 1,
|
|
2764
|
+
evidence: evidence(u),
|
|
2765
|
+
via: "template-link",
|
|
2766
|
+
component: key
|
|
2767
|
+
};
|
|
2768
|
+
push(scope, edge);
|
|
2769
|
+
continue;
|
|
2770
|
+
}
|
|
2771
|
+
const known = [...d.methods.map((m) => m.name), ...d.signals, ...d.fields].includes(root);
|
|
2772
|
+
const [reason, status] = path.length === 0 && d.signals.includes(root) ? ["runtime-global", "external"] : known ? ["dynamic-dispatch", "open"] : d.inherits ? ["template-reference", "awaiting-link"] : ["dynamic-dispatch", "open"];
|
|
2773
|
+
const record2 = {
|
|
2774
|
+
...u,
|
|
2775
|
+
id: `${u.id}|${key}`,
|
|
2776
|
+
reason,
|
|
2777
|
+
status,
|
|
2778
|
+
importSpecifier: null,
|
|
2779
|
+
importedName: null,
|
|
2780
|
+
component: key,
|
|
2781
|
+
evidence: evidence(u)
|
|
2782
|
+
};
|
|
2783
|
+
push(scope, record2);
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
return { scopes: [...scopes], facts };
|
|
2788
|
+
}
|
|
2789
|
+
var TEMPLATE_LINK, scopeOf, componentKey, templateLink;
|
|
2790
|
+
var init_template_link = __esm({
|
|
2791
|
+
"packages/stages/src/template-link.ts"() {
|
|
2792
|
+
"use strict";
|
|
2793
|
+
init_src();
|
|
2794
|
+
TEMPLATE_LINK = "template-link";
|
|
2795
|
+
scopeOf = (key) => `${TEMPLATE_LINK}:${key}`;
|
|
2796
|
+
componentKey = (d) => `${d.file}#${d.component}`;
|
|
2797
|
+
templateLink = { name: TEMPLATE_LINK, run: runTemplateLink };
|
|
2798
|
+
}
|
|
2799
|
+
});
|
|
2800
|
+
|
|
1963
2801
|
// packages/stages/src/index.ts
|
|
1964
2802
|
var init_src5 = __esm({
|
|
1965
2803
|
"packages/stages/src/index.ts"() {
|
|
1966
2804
|
"use strict";
|
|
1967
2805
|
init_stage1();
|
|
1968
2806
|
init_readback();
|
|
2807
|
+
init_template_link();
|
|
1969
2808
|
}
|
|
1970
2809
|
});
|
|
1971
2810
|
|
|
1972
2811
|
// packages/query/src/engine.ts
|
|
1973
2812
|
import { EventEmitter } from "node:events";
|
|
1974
2813
|
import { basename as basename2, resolve as resolve2 } from "node:path";
|
|
2814
|
+
function visibleSites(facts, reader) {
|
|
2815
|
+
const sites = facts.flatMap((f) => f.type === "UnresolvedCallSite" ? [f] : []);
|
|
2816
|
+
const linked = /* @__PURE__ */ new Set();
|
|
2817
|
+
for (const f of facts) {
|
|
2818
|
+
if (f.type === "UnresolvedCallSite" && f.component) linked.add(f.file);
|
|
2819
|
+
if (f.type === "CALLS_CROSS_FILE") linked.add(f.evidence.file);
|
|
2820
|
+
}
|
|
2821
|
+
if (reader) for (const e of reader.facts("CALLS_CROSS_FILE")) linked.add(e.evidence.file);
|
|
2822
|
+
return sites.filter((s) => !(s.reason === "template-binding" && !s.component && linked.has(s.file)));
|
|
2823
|
+
}
|
|
2824
|
+
function byCodePoint(a, b) {
|
|
2825
|
+
const n = Math.min(a.length, b.length);
|
|
2826
|
+
for (let i = 0; i < n; i++) {
|
|
2827
|
+
const x = a.charCodeAt(i);
|
|
2828
|
+
const y = b.charCodeAt(i);
|
|
2829
|
+
if (x === y) continue;
|
|
2830
|
+
const sx = x >= 55296 && x <= 57343;
|
|
2831
|
+
const sy = y >= 55296 && y <= 57343;
|
|
2832
|
+
if (sx !== sy) return sx ? 1 : -1;
|
|
2833
|
+
return x < y ? -1 : 1;
|
|
2834
|
+
}
|
|
2835
|
+
return a.length === b.length ? 0 : a.length < b.length ? -1 : 1;
|
|
2836
|
+
}
|
|
1975
2837
|
function checkLimit(limit, fallback, max) {
|
|
1976
2838
|
if (limit === void 0) return fallback;
|
|
1977
2839
|
if (!Number.isInteger(limit) || limit < 1)
|
|
@@ -1980,7 +2842,7 @@ function checkLimit(limit, fallback, max) {
|
|
|
1980
2842
|
});
|
|
1981
2843
|
return Math.min(limit, max);
|
|
1982
2844
|
}
|
|
1983
|
-
var GROUP_BY, SEARCH_LIMIT, SEARCH_MAX, AGGREGATE_MAX, OUTLINE_MAX,
|
|
2845
|
+
var GROUP_BY, SEARCH_LIMIT, SEARCH_MAX, AGGREGATE_MAX, OUTLINE_MAX, sleep2, MB, MAX_FILE_MB_CAP, normalizePath2, slug2, Engine;
|
|
1984
2846
|
var init_engine = __esm({
|
|
1985
2847
|
"packages/query/src/engine.ts"() {
|
|
1986
2848
|
"use strict";
|
|
@@ -1998,8 +2860,10 @@ var init_engine = __esm({
|
|
|
1998
2860
|
SEARCH_MAX = 100;
|
|
1999
2861
|
AGGREGATE_MAX = 50;
|
|
2000
2862
|
OUTLINE_MAX = 500;
|
|
2001
|
-
byCodePoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
2002
2863
|
sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
2864
|
+
MB = 1024 * 1024;
|
|
2865
|
+
MAX_FILE_MB_CAP = 64;
|
|
2866
|
+
normalizePath2 = (p) => p.replace(/\\/g, "/").replace(/^\.?\/+|\/+$/g, "");
|
|
2003
2867
|
slug2 = (s) => s.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-.]+|-+$/g, "").slice(0, 48) || "source";
|
|
2004
2868
|
Engine = class {
|
|
2005
2869
|
catalog;
|
|
@@ -2109,6 +2973,86 @@ var init_engine = __esm({
|
|
|
2109
2973
|
const project2 = this.resolveProject(args, cwd);
|
|
2110
2974
|
return { sources: this.catalog.listSources(project2.id) };
|
|
2111
2975
|
}
|
|
2976
|
+
/**
|
|
2977
|
+
* Change which files a source analyzes (plan D36): its include and exclude
|
|
2978
|
+
* rules, and the paths chosen despite a rule, a default-excluded folder or
|
|
2979
|
+
* the size limit. Takes effect at the next run; each list given replaces
|
|
2980
|
+
* the old one.
|
|
2981
|
+
*/
|
|
2982
|
+
updateSource(args, cwd) {
|
|
2983
|
+
if (!args.source) throw new VeoError("invalid-arguments", "source is required", { fields: ["source"] });
|
|
2984
|
+
const bad = ["include", "exclude", "optIn"].filter(
|
|
2985
|
+
(k) => args[k] !== void 0 && !(Array.isArray(args[k]) && args[k].every((p) => typeof p === "string" && p !== ""))
|
|
2986
|
+
);
|
|
2987
|
+
if (bad.length)
|
|
2988
|
+
throw new VeoError("invalid-arguments", `${bad.join(", ")} must be lists of paths`, { fields: bad });
|
|
2989
|
+
const project2 = this.resolveProject(args, cwd);
|
|
2990
|
+
const rules = {
|
|
2991
|
+
...args.include ? { include: args.include } : {},
|
|
2992
|
+
...args.exclude ? { exclude: args.exclude } : {},
|
|
2993
|
+
...args.optIn ? { optIn: args.optIn.map(normalizePath2) } : {}
|
|
2994
|
+
};
|
|
2995
|
+
return { source: this.catalog.updateSource(project2.id, args.source, rules) };
|
|
2996
|
+
}
|
|
2997
|
+
/**
|
|
2998
|
+
* Check (`selected`) or uncheck files and folders, as the file picker and
|
|
2999
|
+
* `veoflow include`/`exclude` do (plan D36): the source's rules are changed
|
|
3000
|
+
* so the next run analyzes, or leaves out, exactly those paths.
|
|
3001
|
+
*/
|
|
3002
|
+
select(args, cwd) {
|
|
3003
|
+
if (!Array.isArray(args.paths) || args.paths.length === 0 || !args.paths.every((p) => typeof p === "string"))
|
|
3004
|
+
throw new VeoError("invalid-arguments", "paths must be a non-empty list", { fields: ["paths"] });
|
|
3005
|
+
if (typeof args.selected !== "boolean")
|
|
3006
|
+
throw new VeoError("invalid-arguments", "selected must be true or false", { fields: ["selected"] });
|
|
3007
|
+
const project2 = this.resolveProject(args, cwd);
|
|
3008
|
+
const source = this.catalog.listSources(project2.id).find((s) => s.id === args.source);
|
|
3009
|
+
if (!source)
|
|
3010
|
+
throw new VeoError("not-found", `no source ${args.source} in ${project2.id}`, {
|
|
3011
|
+
kind: "source",
|
|
3012
|
+
id: args.source
|
|
3013
|
+
});
|
|
3014
|
+
const maxFileBytes = this.catalog.projectSettings(project2.id).maxFileMB * MB;
|
|
3015
|
+
const rules = applySelection(source, args.paths, args.selected, { maxFileBytes });
|
|
3016
|
+
return { source: this.catalog.updateSource(project2.id, source.id, rules) };
|
|
3017
|
+
}
|
|
3018
|
+
/** The project's analysis settings (plan D37). */
|
|
3019
|
+
projectSettings(args, cwd) {
|
|
3020
|
+
const project2 = this.resolveProject(args, cwd);
|
|
3021
|
+
return { project: project2.id, settings: this.catalog.projectSettings(project2.id) };
|
|
3022
|
+
}
|
|
3023
|
+
setProjectSettings(args, cwd) {
|
|
3024
|
+
const mb = args.settings?.maxFileMB;
|
|
3025
|
+
if (mb !== void 0 && !(typeof mb === "number" && Number.isFinite(mb) && mb > 0 && mb <= MAX_FILE_MB_CAP))
|
|
3026
|
+
throw new VeoError("invalid-arguments", `maxFileMB must be a number between 0 and ${MAX_FILE_MB_CAP}`, {
|
|
3027
|
+
fields: ["maxFileMB"]
|
|
3028
|
+
});
|
|
3029
|
+
const project2 = this.resolveProject(args, cwd);
|
|
3030
|
+
return {
|
|
3031
|
+
project: project2.id,
|
|
3032
|
+
settings: this.catalog.setProjectSettings(project2.id, mb === void 0 ? {} : { maxFileMB: mb })
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
3035
|
+
/**
|
|
3036
|
+
* One folder of a source, with what the next run would do with each entry
|
|
3037
|
+
* (plan D36): how the UI browses folders the last run left out.
|
|
3038
|
+
*/
|
|
3039
|
+
browse(args, cwd) {
|
|
3040
|
+
const project2 = this.resolveProject(args, cwd);
|
|
3041
|
+
const source = this.catalog.listSources(project2.id).find((s) => s.id === args.source);
|
|
3042
|
+
if (!source)
|
|
3043
|
+
throw new VeoError("not-found", `no source ${args.source} in ${project2.id}`, {
|
|
3044
|
+
kind: "source",
|
|
3045
|
+
id: args.source
|
|
3046
|
+
});
|
|
3047
|
+
const dir = normalizePath2(args.dir ?? "");
|
|
3048
|
+
const maxFileBytes = this.catalog.projectSettings(project2.id).maxFileMB * MB;
|
|
3049
|
+
return {
|
|
3050
|
+
project: project2.id,
|
|
3051
|
+
source: source.id,
|
|
3052
|
+
dir,
|
|
3053
|
+
entries: listDirectory(source, dir, { maxFileBytes })
|
|
3054
|
+
};
|
|
3055
|
+
}
|
|
2112
3056
|
// -------------------------------------------------------------------------
|
|
2113
3057
|
// runs
|
|
2114
3058
|
runProject(project2, onStarted) {
|
|
@@ -2122,7 +3066,8 @@ var init_engine = __esm({
|
|
|
2122
3066
|
store,
|
|
2123
3067
|
evidence,
|
|
2124
3068
|
sources,
|
|
2125
|
-
stages: [stage1],
|
|
3069
|
+
stages: [stage1, templateLink],
|
|
3070
|
+
planOptions: { maxFileBytes: this.catalog.projectSettings(project2.id).maxFileMB * MB },
|
|
2126
3071
|
onEvent: (e) => {
|
|
2127
3072
|
if (e.type === "run.started") onStarted?.(e.runId);
|
|
2128
3073
|
this.events.emit("event", e);
|
|
@@ -2180,6 +3125,8 @@ var init_engine = __esm({
|
|
|
2180
3125
|
const reader = this.reader(project2);
|
|
2181
3126
|
const functions = reader.countByFile("Function");
|
|
2182
3127
|
const calls = reader.countByFile("CALLS");
|
|
3128
|
+
for (const [file2, n] of reader.countByFile("CALLS_CROSS_FILE"))
|
|
3129
|
+
calls.set(file2, (calls.get(file2) ?? 0) + n);
|
|
2183
3130
|
const counts = {};
|
|
2184
3131
|
for (const f of reader.facts("File"))
|
|
2185
3132
|
counts[f.id] = { functions: functions.get(f.id) ?? 0, calls: calls.get(f.id) ?? 0 };
|
|
@@ -2195,14 +3142,25 @@ var init_engine = __esm({
|
|
|
2195
3142
|
const facts = reader.inFile(file2.id);
|
|
2196
3143
|
const fns = facts.flatMap((f) => f.type === "Function" ? [f] : []);
|
|
2197
3144
|
const byId = new Map(fns.map((f) => [f.id, f]));
|
|
3145
|
+
const pathOf = (fileId) => reader.fact(fileId)?.path ?? "";
|
|
3146
|
+
const across = (e, otherId) => {
|
|
3147
|
+
const other = reader.fact(otherId);
|
|
3148
|
+
return this.callView(e, other, other ? pathOf(other.file) : "", otherId);
|
|
3149
|
+
};
|
|
3150
|
+
const incoming = fns.flatMap(
|
|
3151
|
+
(fn) => reader.callsTo(fn.id).filter((e) => e.type === "CALLS_CROSS_FILE" && e.evidence.file !== file2.id)
|
|
3152
|
+
);
|
|
2198
3153
|
return {
|
|
2199
3154
|
...this.meta(project2, reader),
|
|
2200
3155
|
file: file2,
|
|
2201
3156
|
functions: fns.map((f) => this.functionView(f, file2.path)),
|
|
2202
|
-
calls:
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
3157
|
+
calls: [
|
|
3158
|
+
...facts.flatMap(
|
|
3159
|
+
(f) => f.type === "CALLS" ? [this.callView(f, byId.get(f.to), file2.path, f.to)] : f.type === "CALLS_CROSS_FILE" ? [across(f, f.to)] : []
|
|
3160
|
+
),
|
|
3161
|
+
...incoming.map((e) => across(e, e.from))
|
|
3162
|
+
],
|
|
3163
|
+
unresolved: visibleSites(facts),
|
|
2206
3164
|
findings: facts.filter((f) => f.type === "Finding")
|
|
2207
3165
|
};
|
|
2208
3166
|
}
|
|
@@ -2219,6 +3177,7 @@ var init_engine = __esm({
|
|
|
2219
3177
|
isGenerator: f.isGenerator,
|
|
2220
3178
|
implicit: f.implicit,
|
|
2221
3179
|
overloads: f.overloads,
|
|
3180
|
+
...f.title ? { title: f.title } : {},
|
|
2222
3181
|
evidence: f.evidence
|
|
2223
3182
|
};
|
|
2224
3183
|
}
|
|
@@ -2231,11 +3190,13 @@ var init_engine = __esm({
|
|
|
2231
3190
|
id: otherId,
|
|
2232
3191
|
qualifiedName: other?.qualifiedName ?? otherId,
|
|
2233
3192
|
path,
|
|
2234
|
-
...other ? { line: other.evidence.span.start.line } : {}
|
|
3193
|
+
...other ? { line: other.evidence.span.start.line } : {},
|
|
3194
|
+
...other?.title ? { title: other.title } : {}
|
|
2235
3195
|
},
|
|
2236
3196
|
form: edge.form,
|
|
2237
3197
|
resolution: edge.resolution,
|
|
2238
|
-
evidence: edge.evidence
|
|
3198
|
+
evidence: edge.evidence,
|
|
3199
|
+
...edge.type === "CALLS_CROSS_FILE" ? { crossFile: true } : {}
|
|
2239
3200
|
};
|
|
2240
3201
|
}
|
|
2241
3202
|
/** One function, by id or by qualified name (optionally within a file path). */
|
|
@@ -2336,7 +3297,12 @@ var init_engine = __esm({
|
|
|
2336
3297
|
for (const fn of reader.facts("Function")) {
|
|
2337
3298
|
const path = pathOf.get(fn.file) ?? "";
|
|
2338
3299
|
if (prefix && !path.startsWith(prefix)) continue;
|
|
2339
|
-
|
|
3300
|
+
let score = rank(fn.qualifiedName, fn.name, path);
|
|
3301
|
+
if (fn.title && text) {
|
|
3302
|
+
const t = fn.title.toLowerCase();
|
|
3303
|
+
const byTitle = t === text ? 0 : t.startsWith(text) ? 1 : t.includes(text) ? 2 : -1;
|
|
3304
|
+
if (byTitle >= 0) score = score < 0 ? byTitle : Math.min(score, byTitle);
|
|
3305
|
+
}
|
|
2340
3306
|
if (score >= 0) scored.push({ score, path, id: fn.id });
|
|
2341
3307
|
}
|
|
2342
3308
|
}
|
|
@@ -2371,7 +3337,8 @@ var init_engine = __esm({
|
|
|
2371
3337
|
callees: outgoing.get(id)?.functions ?? 0,
|
|
2372
3338
|
callsIn: incoming.get(id)?.calls ?? 0,
|
|
2373
3339
|
callsOut: outgoing.get(id)?.calls ?? 0,
|
|
2374
|
-
evidence: fn.evidence
|
|
3340
|
+
evidence: fn.evidence,
|
|
3341
|
+
...fn.title ? { title: fn.title } : {}
|
|
2375
3342
|
};
|
|
2376
3343
|
});
|
|
2377
3344
|
}
|
|
@@ -2388,7 +3355,9 @@ var init_engine = __esm({
|
|
|
2388
3355
|
* Counts grouped by a property (generic graph tool `aggregate`, design §12
|
|
2389
3356
|
* A3, limited to R1's labels). Sorted by count, then key in code-point
|
|
2390
3357
|
* order; at most 50 groups. `filters.open` limits unresolved call sites to
|
|
2391
|
-
* open questions (design A6); `filters.path` to files under a path prefix
|
|
3358
|
+
* open questions (design A6); `filters.path` to files under a path prefix;
|
|
3359
|
+
* `filters.ownCode` leaves out library, generated and tool files the user chose to
|
|
3360
|
+
* analyze (`File.origin`, plan D36).
|
|
2392
3361
|
*/
|
|
2393
3362
|
aggregate(args, cwd) {
|
|
2394
3363
|
const project2 = this.resolveProject(args, cwd);
|
|
@@ -2411,14 +3380,15 @@ var init_engine = __esm({
|
|
|
2411
3380
|
const prefix = args.filters?.path;
|
|
2412
3381
|
const files = reader.facts("File");
|
|
2413
3382
|
const pathOf = new Map(files.map((f) => [f.id, f.path]));
|
|
2414
|
-
const
|
|
3383
|
+
const foreign = new Set(args.filters?.ownCode ? files.filter((f) => f.origin).map((f) => f.id) : []);
|
|
3384
|
+
const inPath = (fileId) => !foreign.has(fileId) && (!prefix || (pathOf.get(fileId) ?? "").startsWith(prefix));
|
|
2415
3385
|
const counts = /* @__PURE__ */ new Map();
|
|
2416
3386
|
const add = (key) => counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
2417
3387
|
let named;
|
|
2418
3388
|
const fnName = (key) => reader.fact(key)?.qualifiedName;
|
|
2419
3389
|
if (args.label === "File") {
|
|
2420
3390
|
for (const f of files) {
|
|
2421
|
-
if (
|
|
3391
|
+
if (!inPath(f.id)) continue;
|
|
2422
3392
|
const folder = f.path.includes("/") ? f.path.slice(0, f.path.lastIndexOf("/")) : ".";
|
|
2423
3393
|
const value = { status: f.status, language: f.language ?? "none", source: f.source, folder }[args.groupBy];
|
|
2424
3394
|
add(String(value));
|
|
@@ -2430,21 +3400,22 @@ var init_engine = __esm({
|
|
|
2430
3400
|
}
|
|
2431
3401
|
if (args.groupBy === "file") named = (key) => pathOf.get(key);
|
|
2432
3402
|
} else if (args.label === "UnresolvedCallSite") {
|
|
2433
|
-
for (const site of reader.facts("UnresolvedCallSite")) {
|
|
3403
|
+
for (const site of visibleSites(reader.facts("UnresolvedCallSite"), reader)) {
|
|
2434
3404
|
if (!inPath(site.file)) continue;
|
|
2435
3405
|
if (open2 && !isOpenQuestion(site)) continue;
|
|
2436
3406
|
add(String({ reason: site.reason, status: site.status, file: site.file }[args.groupBy]));
|
|
2437
3407
|
}
|
|
2438
3408
|
if (args.groupBy === "file") named = (key) => pathOf.get(key);
|
|
2439
|
-
} else if ((args.groupBy === "to" || args.groupBy === "from") && !prefix) {
|
|
3409
|
+
} else if ((args.groupBy === "to" || args.groupBy === "from") && !prefix && foreign.size === 0) {
|
|
2440
3410
|
for (const [key, c] of reader.callCounts(args.groupBy === "to" ? "dst" : "src"))
|
|
2441
3411
|
counts.set(key, c.calls);
|
|
2442
3412
|
named = fnName;
|
|
2443
3413
|
} else {
|
|
2444
3414
|
const fileOf = new Map(reader.facts("Function").map((f) => [f.id, f.file]));
|
|
2445
|
-
for (const call of reader.facts("CALLS")) {
|
|
3415
|
+
for (const call of [...reader.facts("CALLS"), ...reader.facts("CALLS_CROSS_FILE")]) {
|
|
2446
3416
|
const owner = fileOf.get(call.from);
|
|
2447
|
-
if (prefix && (!owner || !inPath(owner))) continue;
|
|
3417
|
+
if ((prefix || foreign.size) && (!owner || !inPath(owner))) continue;
|
|
3418
|
+
if (foreign.size && foreign.has(fileOf.get(call.to) ?? "")) continue;
|
|
2448
3419
|
add(
|
|
2449
3420
|
String(
|
|
2450
3421
|
{ to: call.to, from: call.from, form: call.form, resolution: call.resolution }[args.groupBy]
|
|
@@ -2488,7 +3459,7 @@ var init_engine = __esm({
|
|
|
2488
3459
|
const ids2 = shown.map((f) => f.id);
|
|
2489
3460
|
const incoming = reader.callCounts("dst", ids2);
|
|
2490
3461
|
const outgoing = reader.callCounts("src", ids2);
|
|
2491
|
-
const sites = facts
|
|
3462
|
+
const sites = visibleSites(facts);
|
|
2492
3463
|
const unresolvedIn = /* @__PURE__ */ new Map();
|
|
2493
3464
|
for (const s of sites) unresolvedIn.set(s.enclosingFn, (unresolvedIn.get(s.enclosingFn) ?? 0) + 1);
|
|
2494
3465
|
return {
|
|
@@ -2504,7 +3475,7 @@ var init_engine = __esm({
|
|
|
2504
3475
|
})),
|
|
2505
3476
|
total: fns.length,
|
|
2506
3477
|
truncated: fns.length > OUTLINE_MAX,
|
|
2507
|
-
calls: facts.filter((f) => f.type === "CALLS").length,
|
|
3478
|
+
calls: facts.filter((f) => f.type === "CALLS" || f.type === "CALLS_CROSS_FILE").length,
|
|
2508
3479
|
unresolved: sites.length,
|
|
2509
3480
|
open: sites.filter(isOpenQuestion).length
|
|
2510
3481
|
};
|
|
@@ -2515,7 +3486,7 @@ var init_engine = __esm({
|
|
|
2515
3486
|
const reader = this.reader(project2);
|
|
2516
3487
|
if (args.file && reader.fact(args.file)?.type !== "File")
|
|
2517
3488
|
throw new VeoError("not-found", `no file ${args.file}`, { kind: "file", id: args.file });
|
|
2518
|
-
const all2 = args.file ? reader.inFile(args.file)
|
|
3489
|
+
const all2 = args.file ? visibleSites(reader.inFile(args.file)) : visibleSites(reader.facts("UnresolvedCallSite"), reader);
|
|
2519
3490
|
return { ...this.meta(project2, reader), sites: args.includeAll ? all2 : all2.filter(isOpenQuestion) };
|
|
2520
3491
|
}
|
|
2521
3492
|
/** The analyzed text around an evidence span (exactly what was analyzed). */
|
|
@@ -16182,11 +17153,11 @@ var init_nl = __esm({
|
|
|
16182
17153
|
case "too_small": {
|
|
16183
17154
|
const adj = issue2.inclusive ? ">=" : ">";
|
|
16184
17155
|
const sizing = getSizing(issue2.origin);
|
|
16185
|
-
const
|
|
17156
|
+
const shortName2 = issue2.origin === "date" ? "vroeg" : issue2.origin === "string" ? "kort" : "klein";
|
|
16186
17157
|
if (sizing) {
|
|
16187
|
-
return `Te ${
|
|
17158
|
+
return `Te ${shortName2}: verwacht dat ${issue2.origin} ${adj}${issue2.minimum.toString()} ${sizing.unit} ${sizing.verb}`;
|
|
16188
17159
|
}
|
|
16189
|
-
return `Te ${
|
|
17160
|
+
return `Te ${shortName2}: verwacht dat ${issue2.origin} ${adj}${issue2.minimum.toString()} is`;
|
|
16190
17161
|
}
|
|
16191
17162
|
case "invalid_format": {
|
|
16192
17163
|
const _issue = issue2;
|
|
@@ -35223,49 +36194,49 @@ var require_fast_uri = __commonJS({
|
|
|
35223
36194
|
schemelessOptions.skipEscape = true;
|
|
35224
36195
|
return serialize(resolved, schemelessOptions);
|
|
35225
36196
|
}
|
|
35226
|
-
function resolveComponent(base,
|
|
36197
|
+
function resolveComponent(base, relative4, options, skipNormalization) {
|
|
35227
36198
|
const target2 = {};
|
|
35228
36199
|
if (!skipNormalization) {
|
|
35229
36200
|
base = parse4(serialize(base, options), options);
|
|
35230
|
-
|
|
36201
|
+
relative4 = parse4(serialize(relative4, options), options);
|
|
35231
36202
|
}
|
|
35232
36203
|
options = options || {};
|
|
35233
|
-
if (!options.tolerant &&
|
|
35234
|
-
target2.scheme =
|
|
35235
|
-
target2.userinfo =
|
|
35236
|
-
target2.host =
|
|
35237
|
-
target2.port =
|
|
35238
|
-
target2.path = removeDotSegments(
|
|
35239
|
-
target2.query =
|
|
36204
|
+
if (!options.tolerant && relative4.scheme) {
|
|
36205
|
+
target2.scheme = relative4.scheme;
|
|
36206
|
+
target2.userinfo = relative4.userinfo;
|
|
36207
|
+
target2.host = relative4.host;
|
|
36208
|
+
target2.port = relative4.port;
|
|
36209
|
+
target2.path = removeDotSegments(relative4.path || "");
|
|
36210
|
+
target2.query = relative4.query;
|
|
35240
36211
|
} else {
|
|
35241
|
-
if (
|
|
35242
|
-
target2.userinfo =
|
|
35243
|
-
target2.host =
|
|
35244
|
-
target2.port =
|
|
35245
|
-
target2.path = removeDotSegments(
|
|
35246
|
-
target2.query =
|
|
36212
|
+
if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
|
|
36213
|
+
target2.userinfo = relative4.userinfo;
|
|
36214
|
+
target2.host = relative4.host;
|
|
36215
|
+
target2.port = relative4.port;
|
|
36216
|
+
target2.path = removeDotSegments(relative4.path || "");
|
|
36217
|
+
target2.query = relative4.query;
|
|
35247
36218
|
} else {
|
|
35248
|
-
if (!
|
|
36219
|
+
if (!relative4.path) {
|
|
35249
36220
|
target2.path = base.path;
|
|
35250
|
-
if (
|
|
35251
|
-
target2.query =
|
|
36221
|
+
if (relative4.query !== void 0) {
|
|
36222
|
+
target2.query = relative4.query;
|
|
35252
36223
|
} else {
|
|
35253
36224
|
target2.query = base.query;
|
|
35254
36225
|
}
|
|
35255
36226
|
} else {
|
|
35256
|
-
if (
|
|
35257
|
-
target2.path = removeDotSegments(
|
|
36227
|
+
if (relative4.path[0] === "/") {
|
|
36228
|
+
target2.path = removeDotSegments(relative4.path);
|
|
35258
36229
|
} else {
|
|
35259
36230
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
35260
|
-
target2.path = "/" +
|
|
36231
|
+
target2.path = "/" + relative4.path;
|
|
35261
36232
|
} else if (!base.path) {
|
|
35262
|
-
target2.path =
|
|
36233
|
+
target2.path = relative4.path;
|
|
35263
36234
|
} else {
|
|
35264
|
-
target2.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
36235
|
+
target2.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative4.path;
|
|
35265
36236
|
}
|
|
35266
36237
|
target2.path = removeDotSegments(target2.path);
|
|
35267
36238
|
}
|
|
35268
|
-
target2.query =
|
|
36239
|
+
target2.query = relative4.query;
|
|
35269
36240
|
}
|
|
35270
36241
|
target2.userinfo = base.userinfo;
|
|
35271
36242
|
target2.host = base.host;
|
|
@@ -35273,7 +36244,7 @@ var require_fast_uri = __commonJS({
|
|
|
35273
36244
|
}
|
|
35274
36245
|
target2.scheme = base.scheme;
|
|
35275
36246
|
}
|
|
35276
|
-
target2.fragment =
|
|
36247
|
+
target2.fragment = relative4.fragment;
|
|
35277
36248
|
return target2;
|
|
35278
36249
|
}
|
|
35279
36250
|
function equal(uriA, uriB, options) {
|
|
@@ -40403,6 +41374,47 @@ var init_server3 = __esm({
|
|
|
40403
41374
|
input: { project },
|
|
40404
41375
|
call: (e, a, cwd) => e.listSources(a, cwd)
|
|
40405
41376
|
},
|
|
41377
|
+
update_source: {
|
|
41378
|
+
description: "Change which files a source analyzes; takes effect at the next run (analyze_files). Each list given replaces the source's old one. Patterns are globs relative to the source root; a rule with a leading '/' is one exact path from the root ('/src/legacy/' is that folder; '*', '{' and '[' are part of the name). optIn lists files or folders to analyze despite an exclude rule, a default-excluded folder (node_modules, dist, .claude, \u2026: library, generated or tool code) or the size limit.",
|
|
41379
|
+
input: {
|
|
41380
|
+
project,
|
|
41381
|
+
source: external_exports.string().describe("Source id, as returned by list_sources"),
|
|
41382
|
+
include: external_exports.array(external_exports.string()).optional().describe("Glob patterns to include (empty: everything)"),
|
|
41383
|
+
exclude: external_exports.array(external_exports.string()).optional().describe("Glob patterns to exclude"),
|
|
41384
|
+
optIn: external_exports.array(external_exports.string()).optional().describe("Paths (files or folders) to analyze anyway")
|
|
41385
|
+
},
|
|
41386
|
+
call: (e, a, cwd) => e.updateSource(a, cwd)
|
|
41387
|
+
},
|
|
41388
|
+
select_files: {
|
|
41389
|
+
description: "Check (selected: true) or uncheck files and folders of a source, as the UI's file picker and `veoflow include`/`exclude` do: the source's rules are changed so the next run analyzes, or leaves out, exactly those paths (the most specific choice wins). Checking a library, generated or tool folder (node_modules, dist, .claude, \u2026) or a file over the size limit includes it; its files are then marked with that origin. Paths are relative to the source root.",
|
|
41390
|
+
input: {
|
|
41391
|
+
project,
|
|
41392
|
+
source: external_exports.string().describe("Source id, as returned by list_sources"),
|
|
41393
|
+
paths: external_exports.array(external_exports.string()).describe("Files or folders, relative to the source root"),
|
|
41394
|
+
selected: external_exports.boolean().describe("true to analyze them, false to leave them out")
|
|
41395
|
+
},
|
|
41396
|
+
call: (e, a, cwd) => e.select(a, cwd)
|
|
41397
|
+
},
|
|
41398
|
+
browse_source: {
|
|
41399
|
+
description: "One folder of a source (git: the last commit) with what the next run would do with each entry: excludedBy (rule, library, generated, too-large) when it would be left out, optedIn when it was chosen anyway, notAnalyzable for files no choice makes analyzable.",
|
|
41400
|
+
input: {
|
|
41401
|
+
project,
|
|
41402
|
+
source: external_exports.string().describe("Source id, as returned by list_sources"),
|
|
41403
|
+
dir: external_exports.string().optional().describe("Folder relative to the source root (default: the root)")
|
|
41404
|
+
},
|
|
41405
|
+
call: (e, a, cwd) => e.browse(a, cwd)
|
|
41406
|
+
},
|
|
41407
|
+
project_settings: {
|
|
41408
|
+
description: "The project's analysis settings: maxFileMB, the per-file size limit (default 10; files over it are not analyzed unless chosen). Pass maxFileMB (up to 64) to change it; it applies at the next run.",
|
|
41409
|
+
input: { project, maxFileMB: external_exports.number().optional().describe("New size limit in MB") },
|
|
41410
|
+
call: (e, a, cwd) => a.maxFileMB === void 0 ? e.projectSettings(a, cwd) : e.setProjectSettings(
|
|
41411
|
+
{
|
|
41412
|
+
...a.project !== void 0 ? { project: a.project } : {},
|
|
41413
|
+
settings: { maxFileMB: a.maxFileMB }
|
|
41414
|
+
},
|
|
41415
|
+
cwd
|
|
41416
|
+
)
|
|
41417
|
+
},
|
|
40406
41418
|
run_status: {
|
|
40407
41419
|
description: "The project's last committed run, any run in progress, and the latest run's details.",
|
|
40408
41420
|
input: { project },
|
|
@@ -40455,7 +41467,7 @@ var init_server3 = __esm({
|
|
|
40455
41467
|
call: (e, a, cwd) => e.listUnresolvedSites(a, cwd)
|
|
40456
41468
|
},
|
|
40457
41469
|
search_nodes: {
|
|
40458
|
-
description:
|
|
41470
|
+
description: 'Find functions or files by name (generic graph tool). Ranked: exact name, then prefix, then anywhere in the qualified name or path; a test callback\'s title (it("adds an item", \u2026)) matches the same way, and the result carries it as `title`. Functions come with callers and callees (distinct functions) and callsIn/callsOut (calls). At most 100 results (default 20); `total` and `truncated` say how many matched.',
|
|
40459
41471
|
input: {
|
|
40460
41472
|
project,
|
|
40461
41473
|
label: external_exports.enum(["Function", "File"]),
|
|
@@ -40469,14 +41481,15 @@ var init_server3 = __esm({
|
|
|
40469
41481
|
call: (e, a, cwd) => e.searchNodes(a, cwd)
|
|
40470
41482
|
},
|
|
40471
41483
|
aggregate: {
|
|
40472
|
-
description: "Counts grouped by a property (generic graph tool): File by status|language|source|folder; Function by file|kind|exported; UnresolvedCallSite by reason|status|file (filters.open: true for open questions only); CALLS by to|from|form|resolution (CALLS by 'to' gives the most-called functions, Function by 'file' the largest files). Sorted by count; at most 50 groups (limit lowers it).",
|
|
41484
|
+
description: "Counts grouped by a property (generic graph tool): File by status|language|source|folder; Function by file|kind|exported; UnresolvedCallSite by reason|status|file (filters.open: true for open questions only); CALLS by to|from|form|resolution (CALLS by 'to' gives the most-called functions, Function by 'file' the largest files; add filters.ownCode: true to leave out library, generated and tool code). Sorted by count; at most 50 groups (limit lowers it).",
|
|
40473
41485
|
input: {
|
|
40474
41486
|
project,
|
|
40475
41487
|
label: external_exports.enum(["File", "Function", "UnresolvedCallSite", "CALLS"]),
|
|
40476
41488
|
groupBy: external_exports.string().min(1),
|
|
40477
41489
|
filters: external_exports.object({
|
|
40478
41490
|
path: external_exports.string().min(1).optional().describe("Only facts in files whose path starts with this prefix"),
|
|
40479
|
-
open: external_exports.boolean().optional().describe("UnresolvedCallSite only: open questions only")
|
|
41491
|
+
open: external_exports.boolean().optional().describe("UnresolvedCallSite only: open questions only"),
|
|
41492
|
+
ownCode: external_exports.boolean().optional().describe("Leave out library, generated and tool files the user chose to analyze (File.origin)")
|
|
40480
41493
|
}).optional(),
|
|
40481
41494
|
limit: external_exports.number().int().positive().optional()
|
|
40482
41495
|
},
|
|
@@ -44455,7 +45468,7 @@ var require_parseTokenList = __commonJS({
|
|
|
44455
45468
|
// node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js
|
|
44456
45469
|
var require_depd = __commonJS({
|
|
44457
45470
|
"node_modules/.pnpm/depd@2.0.0/node_modules/depd/index.js"(exports, module) {
|
|
44458
|
-
var
|
|
45471
|
+
var relative4 = __require("path").relative;
|
|
44459
45472
|
module.exports = depd;
|
|
44460
45473
|
var basePath = process.cwd();
|
|
44461
45474
|
function containsNamespace(str3, namespace) {
|
|
@@ -44647,7 +45660,7 @@ var require_depd = __commonJS({
|
|
|
44647
45660
|
return formatted;
|
|
44648
45661
|
}
|
|
44649
45662
|
function formatLocation(callSite) {
|
|
44650
|
-
return
|
|
45663
|
+
return relative4(basePath, callSite[0]) + ":" + callSite[1] + ":" + callSite[2];
|
|
44651
45664
|
}
|
|
44652
45665
|
function getStack() {
|
|
44653
45666
|
var limit = Error.stackTraceLimit;
|
|
@@ -45180,10 +46193,10 @@ var require_send = __commonJS({
|
|
|
45180
46193
|
var { parseTokenList } = require_parseTokenList();
|
|
45181
46194
|
var { createHttpError } = require_createHttpError();
|
|
45182
46195
|
var extname = path.extname;
|
|
45183
|
-
var
|
|
46196
|
+
var join11 = path.join;
|
|
45184
46197
|
var normalize2 = path.normalize;
|
|
45185
46198
|
var resolve5 = path.resolve;
|
|
45186
|
-
var
|
|
46199
|
+
var sep6 = path.sep;
|
|
45187
46200
|
var Readable = stream.Readable;
|
|
45188
46201
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
45189
46202
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
|
|
@@ -45249,7 +46262,7 @@ var require_send = __commonJS({
|
|
|
45249
46262
|
end: options.end
|
|
45250
46263
|
};
|
|
45251
46264
|
}
|
|
45252
|
-
function
|
|
46265
|
+
function normalizePath3(_path, root) {
|
|
45253
46266
|
let path2 = decode3(_path);
|
|
45254
46267
|
if (path2 == null) {
|
|
45255
46268
|
return { statusCode: 400 };
|
|
@@ -45260,20 +46273,20 @@ var require_send = __commonJS({
|
|
|
45260
46273
|
let parts;
|
|
45261
46274
|
if (root !== null) {
|
|
45262
46275
|
if (path2) {
|
|
45263
|
-
path2 = normalize2("." +
|
|
46276
|
+
path2 = normalize2("." + sep6 + path2);
|
|
45264
46277
|
}
|
|
45265
46278
|
if (UP_PATH_REGEXP.test(path2)) {
|
|
45266
46279
|
debug('malicious path "%s"', path2);
|
|
45267
46280
|
return { statusCode: 403 };
|
|
45268
46281
|
}
|
|
45269
|
-
parts = path2.split(
|
|
45270
|
-
path2 = normalize2(
|
|
46282
|
+
parts = path2.split(sep6);
|
|
46283
|
+
path2 = normalize2(join11(root, path2));
|
|
45271
46284
|
} else {
|
|
45272
46285
|
if (UP_PATH_REGEXP.test(path2)) {
|
|
45273
46286
|
debug('malicious path "%s"', path2);
|
|
45274
46287
|
return { statusCode: 403 };
|
|
45275
46288
|
}
|
|
45276
|
-
parts = normalize2(path2).split(
|
|
46289
|
+
parts = normalize2(path2).split(sep6);
|
|
45277
46290
|
path2 = resolve5(path2);
|
|
45278
46291
|
}
|
|
45279
46292
|
return { path: path2, parts };
|
|
@@ -45550,7 +46563,7 @@ var require_send = __commonJS({
|
|
|
45550
46563
|
let err;
|
|
45551
46564
|
for (let i = 0; i < options.index.length; i++) {
|
|
45552
46565
|
const index = options.index[i];
|
|
45553
|
-
const p =
|
|
46566
|
+
const p = join11(path2, index);
|
|
45554
46567
|
const { error: error62, stat } = await tryStat(p);
|
|
45555
46568
|
if (error62) {
|
|
45556
46569
|
err = error62;
|
|
@@ -45566,7 +46579,7 @@ var require_send = __commonJS({
|
|
|
45566
46579
|
}
|
|
45567
46580
|
async function sendFile(request, path2, options) {
|
|
45568
46581
|
const { error: error62, stat } = await tryStat(path2);
|
|
45569
|
-
if (error62 && error62.code === "ENOENT" && !extname(path2) && path2[path2.length - 1] !==
|
|
46582
|
+
if (error62 && error62.code === "ENOENT" && !extname(path2) && path2[path2.length - 1] !== sep6) {
|
|
45570
46583
|
let err = error62;
|
|
45571
46584
|
for (let i = 0; i < options.extensions.length; i++) {
|
|
45572
46585
|
const extension = options.extensions[i];
|
|
@@ -45594,7 +46607,7 @@ var require_send = __commonJS({
|
|
|
45594
46607
|
async function send(request, _path, options) {
|
|
45595
46608
|
const opts = normalizeOptions(options);
|
|
45596
46609
|
opts.path = _path;
|
|
45597
|
-
const parsed =
|
|
46610
|
+
const parsed = normalizePath3(_path, opts.root);
|
|
45598
46611
|
const { path: path2, parts } = parsed;
|
|
45599
46612
|
if (parsed.statusCode !== void 0) {
|
|
45600
46613
|
return sendError(parsed.statusCode);
|
|
@@ -51252,7 +52265,7 @@ var require_buffer_list = __commonJS({
|
|
|
51252
52265
|
}
|
|
51253
52266
|
}, {
|
|
51254
52267
|
key: "join",
|
|
51255
|
-
value: function
|
|
52268
|
+
value: function join11(s) {
|
|
51256
52269
|
if (this.length === 0) return "";
|
|
51257
52270
|
var p = this.head;
|
|
51258
52271
|
var ret = "" + p.data;
|
|
@@ -61935,7 +62948,7 @@ var require_thread_stream = __commonJS({
|
|
|
61935
62948
|
var { version: version3 } = require_package();
|
|
61936
62949
|
var { EventEmitter: EventEmitter2 } = __require("events");
|
|
61937
62950
|
var { Worker } = __require("worker_threads");
|
|
61938
|
-
var { join:
|
|
62951
|
+
var { join: join11 } = __require("path");
|
|
61939
62952
|
var { pathToFileURL } = __require("url");
|
|
61940
62953
|
var { wait } = require_wait();
|
|
61941
62954
|
var {
|
|
@@ -61986,7 +62999,7 @@ var require_thread_stream = __commonJS({
|
|
|
61986
62999
|
function createWorker(stream, opts) {
|
|
61987
63000
|
const { filename, workerData } = opts;
|
|
61988
63001
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
61989
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
63002
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join11(__dirname, "lib", "worker.js");
|
|
61990
63003
|
const worker = new Worker(toExecute, {
|
|
61991
63004
|
...opts.workerOpts,
|
|
61992
63005
|
name: opts.workerOpts?.name || "thread-stream",
|
|
@@ -62452,9 +63465,9 @@ var require_transport = __commonJS({
|
|
|
62452
63465
|
"node_modules/.pnpm/pino@10.3.1/node_modules/pino/lib/transport.js"(exports, module) {
|
|
62453
63466
|
"use strict";
|
|
62454
63467
|
var { createRequire: createRequire3 } = __require("module");
|
|
62455
|
-
var { existsSync:
|
|
63468
|
+
var { existsSync: existsSync9 } = __require("node:fs");
|
|
62456
63469
|
var getCallers = require_caller();
|
|
62457
|
-
var { join:
|
|
63470
|
+
var { join: join11, isAbsolute: isAbsolute2, sep: sep6 } = __require("node:path");
|
|
62458
63471
|
var { fileURLToPath: fileURLToPath3 } = __require("node:url");
|
|
62459
63472
|
var sleep3 = require_atomic_sleep();
|
|
62460
63473
|
var onExit = require_on_exit_leak_free();
|
|
@@ -62526,7 +63539,7 @@ var require_transport = __commonJS({
|
|
|
62526
63539
|
return false;
|
|
62527
63540
|
}
|
|
62528
63541
|
}
|
|
62529
|
-
return isAbsolute2(path) && !
|
|
63542
|
+
return isAbsolute2(path) && !existsSync9(path);
|
|
62530
63543
|
}
|
|
62531
63544
|
function stripQuotes(value) {
|
|
62532
63545
|
const first = value[0];
|
|
@@ -62607,7 +63620,7 @@ var require_transport = __commonJS({
|
|
|
62607
63620
|
throw new Error("only one of target or targets can be specified");
|
|
62608
63621
|
}
|
|
62609
63622
|
if (targets) {
|
|
62610
|
-
target2 = bundlerOverrides["pino-worker"] ||
|
|
63623
|
+
target2 = bundlerOverrides["pino-worker"] || join11(__dirname, "worker.js");
|
|
62611
63624
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
62612
63625
|
return {
|
|
62613
63626
|
...dest,
|
|
@@ -62625,7 +63638,7 @@ var require_transport = __commonJS({
|
|
|
62625
63638
|
});
|
|
62626
63639
|
});
|
|
62627
63640
|
} else if (pipeline) {
|
|
62628
|
-
target2 = bundlerOverrides["pino-worker"] ||
|
|
63641
|
+
target2 = bundlerOverrides["pino-worker"] || join11(__dirname, "worker.js");
|
|
62629
63642
|
options.pipelines = [pipeline.map((dest) => {
|
|
62630
63643
|
return {
|
|
62631
63644
|
...dest,
|
|
@@ -62648,12 +63661,12 @@ var require_transport = __commonJS({
|
|
|
62648
63661
|
return origin;
|
|
62649
63662
|
}
|
|
62650
63663
|
if (origin === "pino/file") {
|
|
62651
|
-
return
|
|
63664
|
+
return join11(__dirname, "..", "file.js");
|
|
62652
63665
|
}
|
|
62653
63666
|
let fixTarget2;
|
|
62654
63667
|
for (const filePath of callers2) {
|
|
62655
63668
|
try {
|
|
62656
|
-
const context = filePath === "node:repl" ? process.cwd() +
|
|
63669
|
+
const context = filePath === "node:repl" ? process.cwd() + sep6 : filePath;
|
|
62657
63670
|
fixTarget2 = createRequire3(context).resolve(origin);
|
|
62658
63671
|
break;
|
|
62659
63672
|
} catch (err) {
|
|
@@ -63628,7 +64641,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
63628
64641
|
return circularValue;
|
|
63629
64642
|
}
|
|
63630
64643
|
let res = "";
|
|
63631
|
-
let
|
|
64644
|
+
let join11 = ",";
|
|
63632
64645
|
const originalIndentation = indentation;
|
|
63633
64646
|
if (Array.isArray(value)) {
|
|
63634
64647
|
if (value.length === 0) {
|
|
@@ -63642,7 +64655,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
63642
64655
|
indentation += spacer;
|
|
63643
64656
|
res += `
|
|
63644
64657
|
${indentation}`;
|
|
63645
|
-
|
|
64658
|
+
join11 = `,
|
|
63646
64659
|
${indentation}`;
|
|
63647
64660
|
}
|
|
63648
64661
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -63650,13 +64663,13 @@ ${indentation}`;
|
|
|
63650
64663
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
63651
64664
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
63652
64665
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
63653
|
-
res +=
|
|
64666
|
+
res += join11;
|
|
63654
64667
|
}
|
|
63655
64668
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
63656
64669
|
res += tmp !== void 0 ? tmp : "null";
|
|
63657
64670
|
if (value.length - 1 > maximumBreadth) {
|
|
63658
64671
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
63659
|
-
res += `${
|
|
64672
|
+
res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
63660
64673
|
}
|
|
63661
64674
|
if (spacer !== "") {
|
|
63662
64675
|
res += `
|
|
@@ -63677,7 +64690,7 @@ ${originalIndentation}`;
|
|
|
63677
64690
|
let separator = "";
|
|
63678
64691
|
if (spacer !== "") {
|
|
63679
64692
|
indentation += spacer;
|
|
63680
|
-
|
|
64693
|
+
join11 = `,
|
|
63681
64694
|
${indentation}`;
|
|
63682
64695
|
whitespace = " ";
|
|
63683
64696
|
}
|
|
@@ -63691,13 +64704,13 @@ ${indentation}`;
|
|
|
63691
64704
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
63692
64705
|
if (tmp !== void 0) {
|
|
63693
64706
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
63694
|
-
separator =
|
|
64707
|
+
separator = join11;
|
|
63695
64708
|
}
|
|
63696
64709
|
}
|
|
63697
64710
|
if (keyLength > maximumBreadth) {
|
|
63698
64711
|
const removedKeys = keyLength - maximumBreadth;
|
|
63699
64712
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
63700
|
-
separator =
|
|
64713
|
+
separator = join11;
|
|
63701
64714
|
}
|
|
63702
64715
|
if (spacer !== "" && separator.length > 1) {
|
|
63703
64716
|
res = `
|
|
@@ -63738,7 +64751,7 @@ ${originalIndentation}`;
|
|
|
63738
64751
|
}
|
|
63739
64752
|
const originalIndentation = indentation;
|
|
63740
64753
|
let res = "";
|
|
63741
|
-
let
|
|
64754
|
+
let join11 = ",";
|
|
63742
64755
|
if (Array.isArray(value)) {
|
|
63743
64756
|
if (value.length === 0) {
|
|
63744
64757
|
return "[]";
|
|
@@ -63751,7 +64764,7 @@ ${originalIndentation}`;
|
|
|
63751
64764
|
indentation += spacer;
|
|
63752
64765
|
res += `
|
|
63753
64766
|
${indentation}`;
|
|
63754
|
-
|
|
64767
|
+
join11 = `,
|
|
63755
64768
|
${indentation}`;
|
|
63756
64769
|
}
|
|
63757
64770
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -63759,13 +64772,13 @@ ${indentation}`;
|
|
|
63759
64772
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
63760
64773
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
63761
64774
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
63762
|
-
res +=
|
|
64775
|
+
res += join11;
|
|
63763
64776
|
}
|
|
63764
64777
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
63765
64778
|
res += tmp !== void 0 ? tmp : "null";
|
|
63766
64779
|
if (value.length - 1 > maximumBreadth) {
|
|
63767
64780
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
63768
|
-
res += `${
|
|
64781
|
+
res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
63769
64782
|
}
|
|
63770
64783
|
if (spacer !== "") {
|
|
63771
64784
|
res += `
|
|
@@ -63778,7 +64791,7 @@ ${originalIndentation}`;
|
|
|
63778
64791
|
let whitespace = "";
|
|
63779
64792
|
if (spacer !== "") {
|
|
63780
64793
|
indentation += spacer;
|
|
63781
|
-
|
|
64794
|
+
join11 = `,
|
|
63782
64795
|
${indentation}`;
|
|
63783
64796
|
whitespace = " ";
|
|
63784
64797
|
}
|
|
@@ -63787,7 +64800,7 @@ ${indentation}`;
|
|
|
63787
64800
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
63788
64801
|
if (tmp !== void 0) {
|
|
63789
64802
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
63790
|
-
separator =
|
|
64803
|
+
separator = join11;
|
|
63791
64804
|
}
|
|
63792
64805
|
}
|
|
63793
64806
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -63845,20 +64858,20 @@ ${originalIndentation}`;
|
|
|
63845
64858
|
indentation += spacer;
|
|
63846
64859
|
let res2 = `
|
|
63847
64860
|
${indentation}`;
|
|
63848
|
-
const
|
|
64861
|
+
const join12 = `,
|
|
63849
64862
|
${indentation}`;
|
|
63850
64863
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
63851
64864
|
let i = 0;
|
|
63852
64865
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
63853
64866
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
63854
64867
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
63855
|
-
res2 +=
|
|
64868
|
+
res2 += join12;
|
|
63856
64869
|
}
|
|
63857
64870
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
63858
64871
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
63859
64872
|
if (value.length - 1 > maximumBreadth) {
|
|
63860
64873
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
63861
|
-
res2 += `${
|
|
64874
|
+
res2 += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
63862
64875
|
}
|
|
63863
64876
|
res2 += `
|
|
63864
64877
|
${originalIndentation}`;
|
|
@@ -63874,16 +64887,16 @@ ${originalIndentation}`;
|
|
|
63874
64887
|
return '"[Object]"';
|
|
63875
64888
|
}
|
|
63876
64889
|
indentation += spacer;
|
|
63877
|
-
const
|
|
64890
|
+
const join11 = `,
|
|
63878
64891
|
${indentation}`;
|
|
63879
64892
|
let res = "";
|
|
63880
64893
|
let separator = "";
|
|
63881
64894
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
63882
64895
|
if (isTypedArrayWithEntries(value)) {
|
|
63883
|
-
res += stringifyTypedArray(value,
|
|
64896
|
+
res += stringifyTypedArray(value, join11, maximumBreadth);
|
|
63884
64897
|
keys = keys.slice(value.length);
|
|
63885
64898
|
maximumPropertiesToStringify -= value.length;
|
|
63886
|
-
separator =
|
|
64899
|
+
separator = join11;
|
|
63887
64900
|
}
|
|
63888
64901
|
if (deterministic) {
|
|
63889
64902
|
keys = sort(keys, comparator);
|
|
@@ -63894,13 +64907,13 @@ ${indentation}`;
|
|
|
63894
64907
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
63895
64908
|
if (tmp !== void 0) {
|
|
63896
64909
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
63897
|
-
separator =
|
|
64910
|
+
separator = join11;
|
|
63898
64911
|
}
|
|
63899
64912
|
}
|
|
63900
64913
|
if (keyLength > maximumBreadth) {
|
|
63901
64914
|
const removedKeys = keyLength - maximumBreadth;
|
|
63902
64915
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
63903
|
-
separator =
|
|
64916
|
+
separator = join11;
|
|
63904
64917
|
}
|
|
63905
64918
|
if (separator !== "") {
|
|
63906
64919
|
res = `
|
|
@@ -65638,7 +66651,7 @@ var require_reply = __commonJS({
|
|
|
65638
66651
|
return this.header("location", url2).code(code).send();
|
|
65639
66652
|
};
|
|
65640
66653
|
Reply.prototype.callNotFound = function() {
|
|
65641
|
-
|
|
66654
|
+
notFound2(this);
|
|
65642
66655
|
return this;
|
|
65643
66656
|
};
|
|
65644
66657
|
Reply.prototype.then = function(fulfilled, rejected) {
|
|
@@ -66077,7 +67090,7 @@ var require_reply = __commonJS({
|
|
|
66077
67090
|
_Reply.props = props;
|
|
66078
67091
|
return _Reply;
|
|
66079
67092
|
}
|
|
66080
|
-
function
|
|
67093
|
+
function notFound2(reply) {
|
|
66081
67094
|
if (reply[kRouteContext][kFourOhFourContext] === null) {
|
|
66082
67095
|
reply.log.warn("Trying to send a NotFound error inside a 404 handler. Sending basic 404 response.");
|
|
66083
67096
|
reply.code(404).send("404 Not Found");
|
|
@@ -70790,49 +71803,49 @@ var require_fast_uri2 = __commonJS({
|
|
|
70790
71803
|
target2.ipv6Zone = source.ipv6Zone;
|
|
70791
71804
|
}
|
|
70792
71805
|
}
|
|
70793
|
-
function resolveComponent(base,
|
|
71806
|
+
function resolveComponent(base, relative4, options, skipNormalization) {
|
|
70794
71807
|
const target2 = {};
|
|
70795
71808
|
if (!skipNormalization) {
|
|
70796
71809
|
base = parse4(serialize(base, options), options);
|
|
70797
|
-
|
|
71810
|
+
relative4 = parse4(serialize(relative4, options), options);
|
|
70798
71811
|
}
|
|
70799
71812
|
options = options || {};
|
|
70800
|
-
if (!options.tolerant &&
|
|
70801
|
-
target2.scheme =
|
|
70802
|
-
target2.userinfo =
|
|
70803
|
-
copyHost(target2,
|
|
70804
|
-
target2.port =
|
|
70805
|
-
target2.path = removeDotSegments(
|
|
70806
|
-
target2.query =
|
|
71813
|
+
if (!options.tolerant && relative4.scheme) {
|
|
71814
|
+
target2.scheme = relative4.scheme;
|
|
71815
|
+
target2.userinfo = relative4.userinfo;
|
|
71816
|
+
copyHost(target2, relative4);
|
|
71817
|
+
target2.port = relative4.port;
|
|
71818
|
+
target2.path = removeDotSegments(relative4.path || "");
|
|
71819
|
+
target2.query = relative4.query;
|
|
70807
71820
|
} else {
|
|
70808
|
-
if (
|
|
70809
|
-
target2.userinfo =
|
|
70810
|
-
copyHost(target2,
|
|
70811
|
-
target2.port =
|
|
70812
|
-
target2.path = removeDotSegments(
|
|
70813
|
-
target2.query =
|
|
71821
|
+
if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
|
|
71822
|
+
target2.userinfo = relative4.userinfo;
|
|
71823
|
+
copyHost(target2, relative4);
|
|
71824
|
+
target2.port = relative4.port;
|
|
71825
|
+
target2.path = removeDotSegments(relative4.path || "");
|
|
71826
|
+
target2.query = relative4.query;
|
|
70814
71827
|
} else {
|
|
70815
|
-
if (!
|
|
71828
|
+
if (!relative4.path) {
|
|
70816
71829
|
target2.path = base.path;
|
|
70817
|
-
if (
|
|
70818
|
-
target2.query =
|
|
71830
|
+
if (relative4.query !== void 0) {
|
|
71831
|
+
target2.query = relative4.query;
|
|
70819
71832
|
} else {
|
|
70820
71833
|
target2.query = base.query;
|
|
70821
71834
|
}
|
|
70822
71835
|
} else {
|
|
70823
|
-
if (
|
|
70824
|
-
target2.path = removeDotSegments(
|
|
71836
|
+
if (relative4.path[0] === "/") {
|
|
71837
|
+
target2.path = removeDotSegments(relative4.path);
|
|
70825
71838
|
} else {
|
|
70826
71839
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
70827
|
-
target2.path = "/" +
|
|
71840
|
+
target2.path = "/" + relative4.path;
|
|
70828
71841
|
} else if (!base.path) {
|
|
70829
|
-
target2.path =
|
|
71842
|
+
target2.path = relative4.path;
|
|
70830
71843
|
} else {
|
|
70831
|
-
target2.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
71844
|
+
target2.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative4.path;
|
|
70832
71845
|
}
|
|
70833
71846
|
target2.path = removeDotSegments(target2.path);
|
|
70834
71847
|
}
|
|
70835
|
-
target2.query =
|
|
71848
|
+
target2.query = relative4.query;
|
|
70836
71849
|
}
|
|
70837
71850
|
target2.userinfo = base.userinfo;
|
|
70838
71851
|
copyHost(target2, base);
|
|
@@ -70840,7 +71853,7 @@ var require_fast_uri2 = __commonJS({
|
|
|
70840
71853
|
}
|
|
70841
71854
|
target2.scheme = base.scheme;
|
|
70842
71855
|
}
|
|
70843
|
-
target2.fragment =
|
|
71856
|
+
target2.fragment = relative4.fragment;
|
|
70844
71857
|
return target2;
|
|
70845
71858
|
}
|
|
70846
71859
|
function equal(uriA, uriB, options) {
|
|
@@ -71416,7 +72429,7 @@ var require_ajv_compiler = __commonJS({
|
|
|
71416
72429
|
var require_dist3 = __commonJS({
|
|
71417
72430
|
"node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.js"(exports) {
|
|
71418
72431
|
var has = Object.prototype.hasOwnProperty;
|
|
71419
|
-
function
|
|
72432
|
+
function find2(iter, tar, key) {
|
|
71420
72433
|
for (key of iter.keys()) {
|
|
71421
72434
|
if (dequal(key, tar)) return key;
|
|
71422
72435
|
}
|
|
@@ -71440,7 +72453,7 @@ var require_dist3 = __commonJS({
|
|
|
71440
72453
|
for (len of foo) {
|
|
71441
72454
|
tmp = len;
|
|
71442
72455
|
if (tmp && typeof tmp === "object") {
|
|
71443
|
-
tmp =
|
|
72456
|
+
tmp = find2(bar, tmp);
|
|
71444
72457
|
if (!tmp) return false;
|
|
71445
72458
|
}
|
|
71446
72459
|
if (!bar.has(tmp)) return false;
|
|
@@ -71454,7 +72467,7 @@ var require_dist3 = __commonJS({
|
|
|
71454
72467
|
for (len of foo) {
|
|
71455
72468
|
tmp = len[0];
|
|
71456
72469
|
if (tmp && typeof tmp === "object") {
|
|
71457
|
-
tmp =
|
|
72470
|
+
tmp = find2(bar, tmp);
|
|
71458
72471
|
if (!tmp) return false;
|
|
71459
72472
|
}
|
|
71460
72473
|
if (!dequal(len[1], bar.get(tmp))) {
|
|
@@ -79369,7 +80382,7 @@ var require_find_my_way = __commonJS({
|
|
|
79369
80382
|
if (handle === null) return this._defaultRoute(req, res, ctx);
|
|
79370
80383
|
return ctx === void 0 ? handle.handler(req, res, handle.params, handle.store, handle.searchParams) : handle.handler.call(ctx, req, res, handle.params, handle.store, handle.searchParams);
|
|
79371
80384
|
};
|
|
79372
|
-
Router.prototype.find = function
|
|
80385
|
+
Router.prototype.find = function find2(method, path, derivedConstraints) {
|
|
79373
80386
|
let currentNode = method === "GET" ? this._treeGET : this.trees[method];
|
|
79374
80387
|
if (currentNode == null) return null;
|
|
79375
80388
|
if (path.charCodeAt(0) !== 47) {
|
|
@@ -83276,11 +84289,11 @@ var init_types3 = __esm({
|
|
|
83276
84289
|
});
|
|
83277
84290
|
|
|
83278
84291
|
// packages/agents/src/config.ts
|
|
83279
|
-
import { chmodSync, existsSync as
|
|
83280
|
-
import { dirname as dirname4, join as
|
|
84292
|
+
import { chmodSync, existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync3, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
84293
|
+
import { dirname as dirname4, join as join8 } from "node:path";
|
|
83281
84294
|
function read(home) {
|
|
83282
84295
|
const path = configPath(home);
|
|
83283
|
-
if (!
|
|
84296
|
+
if (!existsSync6(path)) return {};
|
|
83284
84297
|
try {
|
|
83285
84298
|
return JSON.parse(readFileSync3(path, "utf8"));
|
|
83286
84299
|
} catch {
|
|
@@ -83348,7 +84361,7 @@ var init_config = __esm({
|
|
|
83348
84361
|
init_src();
|
|
83349
84362
|
DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
|
|
83350
84363
|
DEFAULT_MODEL = "anthropic/claude-sonnet-5.5";
|
|
83351
|
-
configPath = (home) =>
|
|
84364
|
+
configPath = (home) => join8(home, "config.json");
|
|
83352
84365
|
}
|
|
83353
84366
|
});
|
|
83354
84367
|
|
|
@@ -83470,6 +84483,7 @@ var init_grammar = __esm({
|
|
|
83470
84483
|
kind: "function",
|
|
83471
84484
|
id: h.id,
|
|
83472
84485
|
label: h.name,
|
|
84486
|
+
...h.title ? { title: h.title } : {},
|
|
83473
84487
|
detail: `${h.path}:${h.evidence?.span.start.line ?? "?"} \xB7 ${plural2(h.callers ?? 0, "caller")} \xB7 ${plural2(h.callees ?? 0, "callee")}`,
|
|
83474
84488
|
file: h.id.slice(0, h.id.lastIndexOf(":")),
|
|
83475
84489
|
path: h.path,
|
|
@@ -83504,6 +84518,7 @@ var init_grammar = __esm({
|
|
|
83504
84518
|
id: c.id,
|
|
83505
84519
|
// The caller; the row's kind already says it is a call to the function asked about.
|
|
83506
84520
|
label: c.function.qualifiedName,
|
|
84521
|
+
...c.function.title ? { title: c.function.title } : {},
|
|
83507
84522
|
...c.function.line !== void 0 ? { fnLine: c.function.line } : {},
|
|
83508
84523
|
detail: `${c.function.path}:${c.evidence.span.start.line}`,
|
|
83509
84524
|
file: c.evidence.file,
|
|
@@ -83540,6 +84555,7 @@ var init_grammar = __esm({
|
|
|
83540
84555
|
kind: "call",
|
|
83541
84556
|
id: c.id,
|
|
83542
84557
|
label: c.function.qualifiedName,
|
|
84558
|
+
...c.function.title ? { title: c.function.title } : {},
|
|
83543
84559
|
...c.function.line !== void 0 ? { fnLine: c.function.line } : {},
|
|
83544
84560
|
detail: `${r.hit.path}:${c.evidence.span.start.line}`,
|
|
83545
84561
|
file: c.evidence.file,
|
|
@@ -83602,6 +84618,7 @@ var init_grammar = __esm({
|
|
|
83602
84618
|
kind: "function",
|
|
83603
84619
|
id: fn.id,
|
|
83604
84620
|
label: fn.qualifiedName,
|
|
84621
|
+
...fn.title ? { title: fn.title } : {},
|
|
83605
84622
|
detail: `line ${fn.evidence.span.start.line} \xB7 ${plural2(fn.callers, "caller")} \xB7 ${plural2(fn.callees, "callee")}${fn.unresolved ? ` \xB7 ${fn.unresolved} unresolved` : ""}`,
|
|
83606
84623
|
file: f.hit.id,
|
|
83607
84624
|
path: f.hit.path,
|
|
@@ -83640,12 +84657,8 @@ var init_grammar = __esm({
|
|
|
83640
84657
|
};
|
|
83641
84658
|
TOP = 10;
|
|
83642
84659
|
largestFiles = (ctx) => {
|
|
83643
|
-
const
|
|
83644
|
-
|
|
83645
|
-
"aggregate",
|
|
83646
|
-
{ label: "Function", groupBy: "file" },
|
|
83647
|
-
() => ctx.engine.aggregate({ project: ctx.project, label: "Function", groupBy: "file" })
|
|
83648
|
-
);
|
|
84660
|
+
const args = { label: "Function", groupBy: "file", filters: { ownCode: true } };
|
|
84661
|
+
const r = tool(ctx, "aggregate", args, () => ctx.engine.aggregate({ project: ctx.project, ...args }));
|
|
83649
84662
|
const top = r.groups.slice(0, TOP);
|
|
83650
84663
|
return {
|
|
83651
84664
|
summary: top.length ? `The largest file is ${top[0].name ?? top[0].key} with ${plural2(top[0].count, "function")}.` : "No functions have been analyzed yet.",
|
|
@@ -83661,12 +84674,8 @@ var init_grammar = __esm({
|
|
|
83661
84674
|
};
|
|
83662
84675
|
};
|
|
83663
84676
|
mostCalled = (ctx) => {
|
|
83664
|
-
const
|
|
83665
|
-
|
|
83666
|
-
"aggregate",
|
|
83667
|
-
{ label: "CALLS", groupBy: "to" },
|
|
83668
|
-
() => ctx.engine.aggregate({ project: ctx.project, label: "CALLS", groupBy: "to" })
|
|
83669
|
-
);
|
|
84677
|
+
const args = { label: "CALLS", groupBy: "to", filters: { ownCode: true } };
|
|
84678
|
+
const r = tool(ctx, "aggregate", args, () => ctx.engine.aggregate({ project: ctx.project, ...args }));
|
|
83670
84679
|
const top = r.groups.slice(0, TOP);
|
|
83671
84680
|
return {
|
|
83672
84681
|
summary: top.length ? `The most-called function is ${say(top[0].name ?? top[0].key)} (${plural2(top[0].count, "call")}).` : "No calls have been found yet.",
|
|
@@ -83810,7 +84819,9 @@ var init_grammar = __esm({
|
|
|
83810
84819
|
"dynamic-dispatch": "type unknown",
|
|
83811
84820
|
reflection: "reflection",
|
|
83812
84821
|
"imported-symbol": "imported",
|
|
83813
|
-
"runtime-global": "built-in"
|
|
84822
|
+
"runtime-global": "built-in",
|
|
84823
|
+
"template-binding": "awaiting its component",
|
|
84824
|
+
"template-reference": "registered elsewhere"
|
|
83814
84825
|
};
|
|
83815
84826
|
STATUS_WORDS = {
|
|
83816
84827
|
analyzed: "analyzed",
|
|
@@ -83952,7 +84963,8 @@ function systemPrompt(project2) {
|
|
|
83952
84963
|
"You answer questions about a codebase using veoflow's knowledge graph of it.",
|
|
83953
84964
|
`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 waiting for cross-file linking, runtime globals).`,
|
|
83954
84965
|
"Calls across files are not linked yet, so a function can have callers in other files that the graph does not show; say so when it matters.",
|
|
83955
|
-
"
|
|
84966
|
+
"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.",
|
|
84967
|
+
'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.',
|
|
83956
84968
|
"Cite locations exactly as path:line from tool results (for example src/cart.ts:42).",
|
|
83957
84969
|
"Answer briefly: one or two sentences, then a short list if it helps. If the graph cannot answer the question, say what is missing."
|
|
83958
84970
|
].join("\n");
|
|
@@ -84002,23 +85014,24 @@ function harvest(tool2, result2, items, locations) {
|
|
|
84002
85014
|
if (items.size < MAX_ITEMS && !items.has(`${item.kind}:${item.id}`))
|
|
84003
85015
|
items.set(`${item.kind}:${item.id}`, item);
|
|
84004
85016
|
};
|
|
84005
|
-
const prove = (path, span) => {
|
|
85017
|
+
const prove = (path, span, item) => {
|
|
84006
85018
|
if (!path || !span) return;
|
|
84007
85019
|
const list = locations.get(path) ?? [];
|
|
84008
|
-
list.push(
|
|
85020
|
+
list.push({ a: span.start.line, b: span.end.line, ...item ? { item } : {} });
|
|
84009
85021
|
locations.set(path, list);
|
|
84010
85022
|
};
|
|
84011
85023
|
const fileOf = (id) => id.slice(0, id.lastIndexOf(":"));
|
|
84012
85024
|
const fn = (f) => {
|
|
84013
|
-
|
|
84014
|
-
add({
|
|
85025
|
+
const item = {
|
|
84015
85026
|
kind: "function",
|
|
84016
85027
|
id: f.id,
|
|
84017
85028
|
label: f.qualifiedName ?? f.name ?? f.id,
|
|
84018
85029
|
file: fileOf(f.id),
|
|
84019
85030
|
path: f.path,
|
|
84020
85031
|
...f.evidence ? { line: f.evidence.span.start.line, detail: `${f.path}:${f.evidence.span.start.line}` } : {}
|
|
84021
|
-
}
|
|
85032
|
+
};
|
|
85033
|
+
prove(f.path, f.evidence?.span, item);
|
|
85034
|
+
add(item);
|
|
84022
85035
|
};
|
|
84023
85036
|
if (tool2 === "search_nodes")
|
|
84024
85037
|
for (const h of r.results ?? []) {
|
|
@@ -84033,22 +85046,22 @@ function harvest(tool2, result2, items, locations) {
|
|
|
84033
85046
|
} else if (tool2 === "list_calls")
|
|
84034
85047
|
for (const c of r.calls ?? []) {
|
|
84035
85048
|
const path = c.evidence.file.slice(c.evidence.file.indexOf(":") + 1);
|
|
84036
|
-
|
|
84037
|
-
add({
|
|
85049
|
+
const item = {
|
|
84038
85050
|
kind: "call",
|
|
84039
85051
|
id: c.id,
|
|
84040
|
-
label:
|
|
84041
|
-
detail: `${path}:${c.evidence.span.start.line}`,
|
|
85052
|
+
label: c.function.qualifiedName,
|
|
85053
|
+
detail: `${r.direction === "in" ? "calls it" : "called"} \xB7 ${path}:${c.evidence.span.start.line}`,
|
|
84042
85054
|
file: c.evidence.file,
|
|
84043
85055
|
path,
|
|
84044
85056
|
line: c.evidence.span.start.line
|
|
84045
|
-
}
|
|
85057
|
+
};
|
|
85058
|
+
prove(path, c.evidence.span, item);
|
|
85059
|
+
add(item);
|
|
84046
85060
|
}
|
|
84047
85061
|
else if (tool2 === "list_unresolved_sites")
|
|
84048
85062
|
for (const s of r.sites ?? []) {
|
|
84049
85063
|
const path = s.file.slice(s.file.indexOf(":") + 1);
|
|
84050
|
-
|
|
84051
|
-
add({
|
|
85064
|
+
const item = {
|
|
84052
85065
|
kind: "site",
|
|
84053
85066
|
id: s.id,
|
|
84054
85067
|
label: `? ${s.expression}`,
|
|
@@ -84056,7 +85069,9 @@ function harvest(tool2, result2, items, locations) {
|
|
|
84056
85069
|
file: s.file,
|
|
84057
85070
|
path,
|
|
84058
85071
|
line: s.evidence.span.start.line
|
|
84059
|
-
}
|
|
85072
|
+
};
|
|
85073
|
+
prove(path, s.evidence.span, item);
|
|
85074
|
+
add(item);
|
|
84060
85075
|
}
|
|
84061
85076
|
}
|
|
84062
85077
|
function checkCitations(prose, locations) {
|
|
@@ -84066,15 +85081,49 @@ function checkCitations(prose, locations) {
|
|
|
84066
85081
|
const [text, path, line] = [m[0], m[1], Number(m[2])];
|
|
84067
85082
|
if (seen.has(text)) continue;
|
|
84068
85083
|
seen.add(text);
|
|
84069
|
-
let
|
|
85084
|
+
let best = null;
|
|
84070
85085
|
for (const [known, spans] of locations)
|
|
84071
85086
|
if (known === path || known.endsWith(`/${path}`)) {
|
|
84072
|
-
|
|
85087
|
+
for (const s of spans)
|
|
85088
|
+
if (line >= s.a && line <= s.b) {
|
|
85089
|
+
const better = !best || s.item && !best.item || Boolean(s.item) === Boolean(best.item) && s.b - s.a < best.b - best.a;
|
|
85090
|
+
if (better) best = s;
|
|
85091
|
+
}
|
|
84073
85092
|
}
|
|
84074
|
-
out.push({ text, path, line, verified });
|
|
85093
|
+
out.push({ text, path, line, verified: best !== null, ...best?.item ? { target: best.item } : {} });
|
|
84075
85094
|
}
|
|
84076
85095
|
return out;
|
|
84077
85096
|
}
|
|
85097
|
+
function shortName(item) {
|
|
85098
|
+
const label = item.label.replace(/^\? /, "");
|
|
85099
|
+
if (item.kind === "file") return label.slice(label.lastIndexOf("/") + 1);
|
|
85100
|
+
const last = label.split(".").pop() ?? "";
|
|
85101
|
+
return /^[A-Za-z_$][\w$]{3,}$/.test(last) ? last : null;
|
|
85102
|
+
}
|
|
85103
|
+
function splitMentioned(prose, citations, items) {
|
|
85104
|
+
const at = /* @__PURE__ */ new Map();
|
|
85105
|
+
for (const c of citations)
|
|
85106
|
+
if (c.target) {
|
|
85107
|
+
const key = `${c.target.kind}:${c.target.id}`;
|
|
85108
|
+
const i = prose.indexOf(c.text);
|
|
85109
|
+
if (!at.has(key) || i < at.get(key)) at.set(key, i);
|
|
85110
|
+
}
|
|
85111
|
+
const token = (name) => new RegExp(`(?<![\\w$.])${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w$]|\\.[\\w$])`);
|
|
85112
|
+
for (const item of items) {
|
|
85113
|
+
const key = `${item.kind}:${item.id}`;
|
|
85114
|
+
const label = item.label.replace(/^\? /, "");
|
|
85115
|
+
for (const name of [label.includes("<") ? null : label, shortName(item)]) {
|
|
85116
|
+
if (!name) continue;
|
|
85117
|
+
const m = token(name).exec(prose);
|
|
85118
|
+
if (m && (!at.has(key) || m.index < at.get(key))) at.set(key, m.index);
|
|
85119
|
+
}
|
|
85120
|
+
}
|
|
85121
|
+
const byKey = new Map(items.map((i) => [`${i.kind}:${i.id}`, i]));
|
|
85122
|
+
for (const c of citations) if (c.target) byKey.set(`${c.target.kind}:${c.target.id}`, c.target);
|
|
85123
|
+
const mentioned = [...at].sort(([, a], [, b]) => a - b).map(([key]) => byKey.get(key)).filter(Boolean);
|
|
85124
|
+
const keys = new Set(mentioned.map((i) => `${i.kind}:${i.id}`));
|
|
85125
|
+
return { mentioned, lookups: items.filter((i) => !keys.has(`${i.kind}:${i.id}`)) };
|
|
85126
|
+
}
|
|
84078
85127
|
async function answerWithModel(engine, project2, question, settings, fetchImpl = fetch) {
|
|
84079
85128
|
const calls = [];
|
|
84080
85129
|
const items = /* @__PURE__ */ new Map();
|
|
@@ -84173,10 +85222,15 @@ async function answerWithModel(engine, project2, question, settings, fetchImpl =
|
|
|
84173
85222
|
}
|
|
84174
85223
|
const citations = checkCitations(prose, locations);
|
|
84175
85224
|
const unverified = citations.filter((c) => !c.verified).length;
|
|
85225
|
+
const { mentioned, lookups } = splitMentioned(prose, citations, [...items.values()]);
|
|
84176
85226
|
return {
|
|
84177
85227
|
...base,
|
|
84178
|
-
summary: `Answered by ${settings.model} using ${calls.length} tool ${calls.length === 1 ? "call" : "calls"}${unverified ? `; ${unverified} cited ${unverified === 1 ? "location was" : "locations were"} not returned by any tool` : ""}.`,
|
|
84179
|
-
|
|
85228
|
+
summary: calls.length === 0 ? `Answered by ${settings.model} without looking anything up in the graph, so this is general knowledge, not your code. Rephrase the question around a function or file name to get an answer from the graph.` : `Answered by ${settings.model} using ${calls.length} tool ${calls.length === 1 ? "call" : "calls"}${unverified ? `; ${unverified} cited ${unverified === 1 ? "location was" : "locations were"} not returned by any tool` : ""}.`,
|
|
85229
|
+
// Flag, never fabricate: an answer no tool backed is marked as such.
|
|
85230
|
+
...calls.length === 0 ? { ungrounded: true } : {},
|
|
85231
|
+
// What the answer is about first; the rest of the lookups apart.
|
|
85232
|
+
results: mentioned,
|
|
85233
|
+
lookups,
|
|
84180
85234
|
prose,
|
|
84181
85235
|
citations,
|
|
84182
85236
|
...truncated ? { truncated } : {},
|
|
@@ -84351,6 +85405,7 @@ __export(src_exports2, {
|
|
|
84351
85405
|
publicSettings: () => publicSettings,
|
|
84352
85406
|
saveSettings: () => saveSettings,
|
|
84353
85407
|
say: () => say,
|
|
85408
|
+
splitMentioned: () => splitMentioned,
|
|
84354
85409
|
suggest: () => suggest,
|
|
84355
85410
|
systemPrompt: () => systemPrompt,
|
|
84356
85411
|
testConnection: () => testConnection,
|
|
@@ -84370,8 +85425,8 @@ var init_src8 = __esm({
|
|
|
84370
85425
|
});
|
|
84371
85426
|
|
|
84372
85427
|
// packages/server/src/server.ts
|
|
84373
|
-
import { existsSync as
|
|
84374
|
-
import { dirname as dirname5, isAbsolute, join as
|
|
85428
|
+
import { existsSync as existsSync7, statSync as statSync3 } from "node:fs";
|
|
85429
|
+
import { dirname as dirname5, isAbsolute, join as join9, resolve as resolve3 } from "node:path";
|
|
84375
85430
|
import { fileURLToPath } from "node:url";
|
|
84376
85431
|
function hostName(host) {
|
|
84377
85432
|
return host.startsWith("[") ? host.slice(0, host.indexOf("]") + 1) : host.replace(/:\d+$/, "");
|
|
@@ -84447,6 +85502,66 @@ async function createServer(engine, options = {}) {
|
|
|
84447
85502
|
return reply.status(201).send(engine.addSource({ ...req.body, ...req.params }));
|
|
84448
85503
|
}
|
|
84449
85504
|
);
|
|
85505
|
+
const sourceParams = {
|
|
85506
|
+
type: "object",
|
|
85507
|
+
required: ["project", "source"],
|
|
85508
|
+
properties: { project: str2, source: str2 }
|
|
85509
|
+
};
|
|
85510
|
+
const paths = { type: "array", items: str2, maxItems: 1e4 };
|
|
85511
|
+
app.patch(
|
|
85512
|
+
"/api/projects/:project/sources/:source",
|
|
85513
|
+
{
|
|
85514
|
+
schema: {
|
|
85515
|
+
params: sourceParams,
|
|
85516
|
+
body: {
|
|
85517
|
+
type: "object",
|
|
85518
|
+
additionalProperties: false,
|
|
85519
|
+
properties: { include: paths, exclude: paths, optIn: paths }
|
|
85520
|
+
}
|
|
85521
|
+
}
|
|
85522
|
+
},
|
|
85523
|
+
async (req) => engine.updateSource({ ...req.body, ...req.params })
|
|
85524
|
+
);
|
|
85525
|
+
app.post(
|
|
85526
|
+
"/api/projects/:project/sources/:source/select",
|
|
85527
|
+
{
|
|
85528
|
+
schema: {
|
|
85529
|
+
params: sourceParams,
|
|
85530
|
+
body: {
|
|
85531
|
+
type: "object",
|
|
85532
|
+
required: ["paths", "selected"],
|
|
85533
|
+
additionalProperties: false,
|
|
85534
|
+
properties: { paths: { ...paths, minItems: 1 }, selected: { type: "boolean" } }
|
|
85535
|
+
}
|
|
85536
|
+
}
|
|
85537
|
+
},
|
|
85538
|
+
async (req) => engine.select({ ...req.body, ...req.params })
|
|
85539
|
+
);
|
|
85540
|
+
app.get(
|
|
85541
|
+
"/api/projects/:project/sources/:source/browse",
|
|
85542
|
+
{
|
|
85543
|
+
schema: {
|
|
85544
|
+
params: sourceParams,
|
|
85545
|
+
querystring: { type: "object", additionalProperties: false, properties: { dir: { type: "string" } } }
|
|
85546
|
+
}
|
|
85547
|
+
},
|
|
85548
|
+
async (req) => engine.browse({ ...req.params, dir: req.query.dir ?? "" })
|
|
85549
|
+
);
|
|
85550
|
+
app.get(
|
|
85551
|
+
"/api/projects/:project/settings",
|
|
85552
|
+
{ schema: { params: projectParams } },
|
|
85553
|
+
async (req) => engine.projectSettings(req.params)
|
|
85554
|
+
);
|
|
85555
|
+
app.put(
|
|
85556
|
+
"/api/projects/:project/settings",
|
|
85557
|
+
{
|
|
85558
|
+
schema: {
|
|
85559
|
+
params: projectParams,
|
|
85560
|
+
body: { type: "object", additionalProperties: false, properties: { maxFileMB: { type: "number" } } }
|
|
85561
|
+
}
|
|
85562
|
+
},
|
|
85563
|
+
async (req) => engine.setProjectSettings({ ...req.params, settings: req.body })
|
|
85564
|
+
);
|
|
84450
85565
|
app.post(
|
|
84451
85566
|
"/api/projects/:project/runs",
|
|
84452
85567
|
{ schema: { params: projectParams } },
|
|
@@ -84663,6 +85778,7 @@ async function createServer(engine, options = {}) {
|
|
|
84663
85778
|
label: { type: "string", enum: ["File", "Function", "UnresolvedCallSite", "CALLS"] },
|
|
84664
85779
|
groupBy: str2,
|
|
84665
85780
|
open: { type: "string", enum: ["true", "false"] },
|
|
85781
|
+
ownCode: { type: "string", enum: ["true", "false"] },
|
|
84666
85782
|
path: str2,
|
|
84667
85783
|
limit: { type: "string", pattern: "^[1-9][0-9]*$" }
|
|
84668
85784
|
}
|
|
@@ -84673,9 +85789,10 @@ async function createServer(engine, options = {}) {
|
|
|
84673
85789
|
...req.params,
|
|
84674
85790
|
label: req.query.label,
|
|
84675
85791
|
groupBy: req.query.groupBy,
|
|
84676
|
-
...req.query.open !== void 0 || req.query.path ? {
|
|
85792
|
+
...req.query.open !== void 0 || req.query.path || req.query.ownCode !== void 0 ? {
|
|
84677
85793
|
filters: {
|
|
84678
85794
|
...req.query.open !== void 0 ? { open: req.query.open === "true" } : {},
|
|
85795
|
+
...req.query.ownCode !== void 0 ? { ownCode: req.query.ownCode === "true" } : {},
|
|
84679
85796
|
...req.query.path ? { path: req.query.path } : {}
|
|
84680
85797
|
}
|
|
84681
85798
|
} : {},
|
|
@@ -84715,7 +85832,7 @@ async function createServer(engine, options = {}) {
|
|
|
84715
85832
|
async (req) => engine.snippet({ ...req.params, ...req.body })
|
|
84716
85833
|
);
|
|
84717
85834
|
const webRoot = options.webRoot === void 0 ? defaultWebRoot : options.webRoot;
|
|
84718
|
-
const hasUi = webRoot !== null &&
|
|
85835
|
+
const hasUi = webRoot !== null && existsSync7(join9(webRoot, "index.html"));
|
|
84719
85836
|
if (hasUi) await app.register(import_static.default, { root: webRoot });
|
|
84720
85837
|
app.setNotFoundHandler((req, reply) => {
|
|
84721
85838
|
if (req.url.startsWith("/api/") || !hasUi)
|
|
@@ -84817,9 +85934,10 @@ var init_src9 = __esm({
|
|
|
84817
85934
|
// packages/cli/src/main.ts
|
|
84818
85935
|
init_src();
|
|
84819
85936
|
init_src6();
|
|
85937
|
+
init_src2();
|
|
84820
85938
|
import { spawn } from "node:child_process";
|
|
84821
|
-
import { existsSync as
|
|
84822
|
-
import { basename as basename3, dirname as dirname6, join as
|
|
85939
|
+
import { existsSync as existsSync8, readFileSync as readFileSync4, statSync as statSync4 } from "node:fs";
|
|
85940
|
+
import { basename as basename3, dirname as dirname6, join as join10, relative as relative3, resolve as resolve4, sep as sep5 } from "node:path";
|
|
84823
85941
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
84824
85942
|
import { parseArgs } from "node:util";
|
|
84825
85943
|
var USAGE = `veoflow \u2014 a knowledge graph of your code (also runs as \`veo\`)
|
|
@@ -84829,14 +85947,19 @@ Usage:
|
|
|
84829
85947
|
veoflow add <dir> [--project <id>] add a folder to a project and analyze it
|
|
84830
85948
|
[--id <source-id>] [--include <glob>]... [--exclude <glob>]... [--no-run]
|
|
84831
85949
|
veoflow run [--project <id>] analyze a project again
|
|
85950
|
+
veoflow include <path>... [--project <id>] [--source <id>] [--run]
|
|
85951
|
+
veoflow exclude <path>... [--project <id>] [--source <id>] [--run]
|
|
85952
|
+
choose which files and folders are analyzed
|
|
85953
|
+
(paths relative to the working directory)
|
|
84832
85954
|
veoflow serve [--port 7420] [--host 127.0.0.1] [--no-open]
|
|
84833
85955
|
serve the UI and API
|
|
84834
85956
|
veoflow mcp serve the MCP tools over stdio
|
|
84835
85957
|
veoflow ask "<question>" [--project <id>] [--mode auto|grammar|model]
|
|
84836
85958
|
ask about the analyzed code
|
|
84837
|
-
veoflow config [get [<key>] | set <key> <value> | test]
|
|
85959
|
+
veoflow config [get [<key>] | set <key> <value> | test] [--project <id>]
|
|
84838
85960
|
model settings: model.baseUrl, model.name, model.apiKey
|
|
84839
|
-
("set model.apiKey -" reads the key from stdin)
|
|
85961
|
+
("set model.apiKey -" reads the key from stdin);
|
|
85962
|
+
project settings: analysis.maxFileMB (size limit, default 10)
|
|
84840
85963
|
veoflow projects list projects
|
|
84841
85964
|
veoflow help | --version`;
|
|
84842
85965
|
var UsageError = class extends Error {
|
|
@@ -84844,7 +85967,7 @@ var UsageError = class extends Error {
|
|
|
84844
85967
|
function version2() {
|
|
84845
85968
|
if (process.env.VEO_VERSION) return process.env.VEO_VERSION;
|
|
84846
85969
|
const pkg = JSON.parse(
|
|
84847
|
-
readFileSync4(
|
|
85970
|
+
readFileSync4(join10(dirname6(fileURLToPath2(import.meta.url)), "../package.json"), "utf8")
|
|
84848
85971
|
);
|
|
84849
85972
|
return pkg.version;
|
|
84850
85973
|
}
|
|
@@ -84948,7 +86071,7 @@ async function main(argv, io) {
|
|
|
84948
86071
|
});
|
|
84949
86072
|
if (positionals.length !== 1) throw new UsageError("usage: veoflow add <dir> [--project <id>]");
|
|
84950
86073
|
const root = resolve4(io.cwd, positionals[0]);
|
|
84951
|
-
if (!
|
|
86074
|
+
if (!existsSync8(root) || !statSync4(root).isDirectory())
|
|
84952
86075
|
throw new VeoError("source-not-found", `${root} is not a directory`);
|
|
84953
86076
|
let project2 = values.project ?? engine.catalog.resolveProjectForCwd(io.cwd)?.id;
|
|
84954
86077
|
if (!project2) {
|
|
@@ -85038,8 +86161,83 @@ ${plain(answer.prose)}`);
|
|
|
85038
86161
|
try: ${answer.suggestions.join(" \xB7 ")}`);
|
|
85039
86162
|
return answer.error || mode === "model" && answer.via !== "model" ? 1 : 0;
|
|
85040
86163
|
}
|
|
86164
|
+
case "include":
|
|
86165
|
+
case "exclude": {
|
|
86166
|
+
const { values, positionals } = parseArgs({
|
|
86167
|
+
args: rest,
|
|
86168
|
+
allowPositionals: true,
|
|
86169
|
+
strict: true,
|
|
86170
|
+
options: { project: { type: "string" }, source: { type: "string" }, run: { type: "boolean" } }
|
|
86171
|
+
});
|
|
86172
|
+
if (positionals.length === 0)
|
|
86173
|
+
throw new UsageError(
|
|
86174
|
+
`usage: veoflow ${command} <path>... [--project <id>] [--source <id>] [--run]`
|
|
86175
|
+
);
|
|
86176
|
+
const project2 = pickProject(engine, values.project, io.cwd);
|
|
86177
|
+
const sources = engine.listSources({ project: project2 }).sources;
|
|
86178
|
+
const abs = positionals.map((p) => canonicalPath(resolve4(io.cwd, p)));
|
|
86179
|
+
const source = values.source ? sources.find((s) => s.id === values.source) : sources.filter((s) => abs.every((a) => a === s.root || a.startsWith(s.root + sep5))).sort((a, b) => b.root.length - a.root.length)[0];
|
|
86180
|
+
if (!source)
|
|
86181
|
+
throw values.source ? new VeoError("not-found", `no source ${values.source} in ${project2}`) : new UsageError(
|
|
86182
|
+
"the paths are not all inside one source; pass --source <id> with paths inside it"
|
|
86183
|
+
);
|
|
86184
|
+
const paths = abs.map((a) => relative3(source.root, a).split(sep5).join("/"));
|
|
86185
|
+
if (paths.some((p) => p === "" || p.startsWith("..")))
|
|
86186
|
+
throw new UsageError(
|
|
86187
|
+
`paths must be inside the source ${source.id} (${source.root}), not the root itself`
|
|
86188
|
+
);
|
|
86189
|
+
const { source: updated } = engine.select({
|
|
86190
|
+
project: project2,
|
|
86191
|
+
source: source.id,
|
|
86192
|
+
paths,
|
|
86193
|
+
selected: command === "include"
|
|
86194
|
+
});
|
|
86195
|
+
io.out(`${command === "include" ? "included" : "excluded"} ${paths.join(", ")} in ${source.id}`);
|
|
86196
|
+
const rules = [
|
|
86197
|
+
updated.exclude.length ? `exclude ${updated.exclude.join(" ")}` : "",
|
|
86198
|
+
updated.optIn?.length ? `analyze anyway ${updated.optIn.join(" ")}` : ""
|
|
86199
|
+
].filter(Boolean);
|
|
86200
|
+
if (rules.length) io.out(` rules: ${rules.join("; ")}`);
|
|
86201
|
+
if (!values.run) {
|
|
86202
|
+
io.out(` takes effect at the next run (veoflow run --project ${project2})`);
|
|
86203
|
+
return 0;
|
|
86204
|
+
}
|
|
86205
|
+
return await runAnalysis(engine, project2, io);
|
|
86206
|
+
}
|
|
85041
86207
|
case "config": {
|
|
86208
|
+
const projectFlag = rest.indexOf("--project");
|
|
86209
|
+
const projectArg = projectFlag >= 0 ? rest[projectFlag + 1] : void 0;
|
|
86210
|
+
if (projectFlag >= 0) {
|
|
86211
|
+
if (!projectArg) throw new UsageError("--project needs a project id");
|
|
86212
|
+
rest.splice(projectFlag, 2);
|
|
86213
|
+
}
|
|
85042
86214
|
const [action = "get", key, value] = rest;
|
|
86215
|
+
if (key?.startsWith("analysis.") || action === "get" && projectArg && !key) {
|
|
86216
|
+
if (key && key !== "analysis.maxFileMB")
|
|
86217
|
+
throw new UsageError(`unknown key ${key} (analysis.maxFileMB)`);
|
|
86218
|
+
const project2 = pickProject(engine, projectArg, io.cwd);
|
|
86219
|
+
if (action === "get") {
|
|
86220
|
+
io.out(
|
|
86221
|
+
`${key ? "" : "analysis.maxFileMB = "}${engine.projectSettings({ project: project2 }).settings.maxFileMB}`
|
|
86222
|
+
);
|
|
86223
|
+
return 0;
|
|
86224
|
+
}
|
|
86225
|
+
if (action === "set") {
|
|
86226
|
+
const mb = Number(value);
|
|
86227
|
+
if (value === void 0 || value.trim() === "" || !Number.isFinite(mb))
|
|
86228
|
+
throw new UsageError(
|
|
86229
|
+
"usage: veoflow config set analysis.maxFileMB <megabytes> [--project <id>]"
|
|
86230
|
+
);
|
|
86231
|
+
const { settings } = engine.setProjectSettings({ project: project2, settings: { maxFileMB: mb } });
|
|
86232
|
+
io.out(
|
|
86233
|
+
`analysis.maxFileMB = ${settings.maxFileMB} (project ${project2}; takes effect at the next run)`
|
|
86234
|
+
);
|
|
86235
|
+
return 0;
|
|
86236
|
+
}
|
|
86237
|
+
throw new UsageError(
|
|
86238
|
+
"usage: veoflow config [get|set] analysis.maxFileMB [<value>] [--project <id>]"
|
|
86239
|
+
);
|
|
86240
|
+
}
|
|
85043
86241
|
const { loadSettings: loadSettings2, publicSettings: publicSettings2, saveSettings: saveSettings2, testConnection: testConnection2 } = await Promise.resolve().then(() => (init_src8(), src_exports2));
|
|
85044
86242
|
const home = engine.catalog.home;
|
|
85045
86243
|
const keys = {
|