veoflow 0.1.1 → 0.1.2
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 +2028 -306
- package/native/veo-extract.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/web/assets/index-Cw2mJ_5P.js +330 -0
- package/web/assets/index-DwAmGVhN.css +1 -0
- package/web/index.html +6 -2
- package/web/assets/index-BVAfkuNB.js +0 -329
- package/web/assets/index-urDnyqbC.css +0 -1
package/dist/veo.mjs
CHANGED
|
@@ -26,9 +26,9 @@ var __commonJS = (cb, mod) => function __require2() {
|
|
|
26
26
|
throw mod = 0, e;
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
var __export = (
|
|
29
|
+
var __export = (target2, all2) => {
|
|
30
30
|
for (var name in all2)
|
|
31
|
-
__defProp(
|
|
31
|
+
__defProp(target2, name, { get: all2[name], enumerable: true });
|
|
32
32
|
};
|
|
33
33
|
var __copyProps = (to, from, except, desc) => {
|
|
34
34
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -38,12 +38,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
38
38
|
}
|
|
39
39
|
return to;
|
|
40
40
|
};
|
|
41
|
-
var __toESM = (mod, isNodeMode,
|
|
41
|
+
var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
42
42
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
43
43
|
// file that has been converted to a CommonJS file using a Babel-
|
|
44
44
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
45
45
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
46
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(
|
|
46
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
|
|
47
47
|
mod
|
|
48
48
|
));
|
|
49
49
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
@@ -896,6 +896,36 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
896
896
|
callsTo(fnId) {
|
|
897
897
|
return this.rows("type = 'CALLS' AND dst = :id", { id: fnId });
|
|
898
898
|
}
|
|
899
|
+
/** How many facts of a type each file holds (functions or calls per file, for the file list). */
|
|
900
|
+
countByFile(type) {
|
|
901
|
+
const rows = this.db.prepare(
|
|
902
|
+
`SELECT file, COUNT(*) AS n FROM facts WHERE ${VISIBLE} AND type = :type AND file IS NOT NULL GROUP BY file`
|
|
903
|
+
).all({ type, run: this.run });
|
|
904
|
+
return new Map(rows.map((r) => [r.file, r.n]));
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* CALLS grouped by one end: for each function, how many calls and how many
|
|
908
|
+
* distinct functions at the other end. Limited to `ids` when given.
|
|
909
|
+
*/
|
|
910
|
+
callCounts(end, ids2) {
|
|
911
|
+
const other = end === "src" ? "dst" : "src";
|
|
912
|
+
const out = /* @__PURE__ */ new Map();
|
|
913
|
+
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 = 'CALLS'${where} GROUP BY ${end}`
|
|
915
|
+
).all({ ...params, run: this.run });
|
|
916
|
+
if (!ids2) {
|
|
917
|
+
for (const r of query("", {})) out.set(r.k, { calls: r.calls, functions: r.functions });
|
|
918
|
+
return out;
|
|
919
|
+
}
|
|
920
|
+
for (let i = 0; i < ids2.length; i += 500) {
|
|
921
|
+
const batch = ids2.slice(i, i + 500);
|
|
922
|
+
const params = Object.fromEntries(batch.map((id, j) => [`p${j}`, id]));
|
|
923
|
+
const list = batch.map((_, j) => `:p${j}`).join(",");
|
|
924
|
+
for (const r of query(` AND ${end} IN (${list})`, params))
|
|
925
|
+
out.set(r.k, { calls: r.calls, functions: r.functions });
|
|
926
|
+
}
|
|
927
|
+
return out;
|
|
928
|
+
}
|
|
899
929
|
count(type) {
|
|
900
930
|
const sql = `SELECT COUNT(*) AS n FROM facts WHERE ${VISIBLE}${type ? " AND type = :type" : ""}`;
|
|
901
931
|
return this.db.prepare(sql).get({ run: this.run, ...type ? { type } : {} }).n;
|
|
@@ -952,13 +982,13 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
952
982
|
* (the graph "as of" that run, design §5.3 A5).
|
|
953
983
|
*/
|
|
954
984
|
reader(run) {
|
|
955
|
-
const
|
|
956
|
-
if (
|
|
957
|
-
const info = this.runInfo(
|
|
958
|
-
if (!info) throw new Error(`run ${
|
|
985
|
+
const target2 = run ?? this.currentRun();
|
|
986
|
+
if (target2 === null) return new GraphReader(this.db, 0);
|
|
987
|
+
const info = this.runInfo(target2);
|
|
988
|
+
if (!info) throw new Error(`run ${target2} does not exist`);
|
|
959
989
|
if (info.status !== "committed")
|
|
960
|
-
throw new Error(`run ${
|
|
961
|
-
return new GraphReader(this.db,
|
|
990
|
+
throw new Error(`run ${target2} is ${info.status}; only committed runs can be read`);
|
|
991
|
+
return new GraphReader(this.db, target2);
|
|
962
992
|
}
|
|
963
993
|
runs() {
|
|
964
994
|
return this.db.prepare("SELECT * FROM runs ORDER BY run_id").all().map(toRunInfo);
|
|
@@ -1093,11 +1123,11 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
1093
1123
|
* the stage's scopes that it did not re-emit. Scopes belong to a stage: the
|
|
1094
1124
|
* sweep only closes facts this stage wrote in those scopes.
|
|
1095
1125
|
*/
|
|
1096
|
-
writeStage(stage,
|
|
1126
|
+
writeStage(stage, write2) {
|
|
1097
1127
|
this.assertOpen();
|
|
1098
1128
|
const startedAt = now();
|
|
1099
|
-
const scopes = new Set(
|
|
1100
|
-
for (const { scope, fact } of
|
|
1129
|
+
const scopes = new Set(write2.scopes);
|
|
1130
|
+
for (const { scope, fact } of write2.facts) {
|
|
1101
1131
|
if (!scopes.has(scope))
|
|
1102
1132
|
throw new Error(`fact ${fact.id} has scope ${scope}, which the stage did not declare`);
|
|
1103
1133
|
}
|
|
@@ -1128,7 +1158,7 @@ CREATE TABLE IF NOT EXISTS lock (
|
|
|
1128
1158
|
`INSERT INTO facts (id, type, stage, scope, rev, file, src, dst, hash, payload, from_run, to_run)
|
|
1129
1159
|
VALUES (:id, :type, :stage, :scope, :rev, :file, :src, :dst, :hash, :payload, :run, NULL)`
|
|
1130
1160
|
);
|
|
1131
|
-
for (const { scope, fact } of
|
|
1161
|
+
for (const { scope, fact } of write2.facts) {
|
|
1132
1162
|
if (emitted.has(fact.id)) throw new Error(`fact ${fact.id} written twice in stage ${stage}`);
|
|
1133
1163
|
emitted.add(fact.id);
|
|
1134
1164
|
const rev = revisionOf(fact);
|
|
@@ -1642,14 +1672,14 @@ async function runNow(request) {
|
|
|
1642
1672
|
current = stage.name;
|
|
1643
1673
|
run.startStage(stage.name);
|
|
1644
1674
|
const started = Date.now();
|
|
1645
|
-
const
|
|
1675
|
+
const write2 = await stage.run({
|
|
1646
1676
|
projectId,
|
|
1647
1677
|
runId: run.runId,
|
|
1648
1678
|
plans,
|
|
1649
1679
|
view: run.view(),
|
|
1650
1680
|
evidence: request.evidence
|
|
1651
1681
|
});
|
|
1652
|
-
const info = run.writeStage(stage.name,
|
|
1682
|
+
const info = run.writeStage(stage.name, write2);
|
|
1653
1683
|
emit({
|
|
1654
1684
|
type: "stage.completed",
|
|
1655
1685
|
projectId,
|
|
@@ -1942,7 +1972,15 @@ var init_src5 = __esm({
|
|
|
1942
1972
|
// packages/query/src/engine.ts
|
|
1943
1973
|
import { EventEmitter } from "node:events";
|
|
1944
1974
|
import { basename as basename2, resolve as resolve2 } from "node:path";
|
|
1945
|
-
|
|
1975
|
+
function checkLimit(limit, fallback, max) {
|
|
1976
|
+
if (limit === void 0) return fallback;
|
|
1977
|
+
if (!Number.isInteger(limit) || limit < 1)
|
|
1978
|
+
throw new VeoError("invalid-arguments", `limit must be a positive integer (got ${String(limit)})`, {
|
|
1979
|
+
fields: ["limit"]
|
|
1980
|
+
});
|
|
1981
|
+
return Math.min(limit, max);
|
|
1982
|
+
}
|
|
1983
|
+
var GROUP_BY, SEARCH_LIMIT, SEARCH_MAX, AGGREGATE_MAX, OUTLINE_MAX, byCodePoint, sleep2, slug2, Engine;
|
|
1946
1984
|
var init_engine = __esm({
|
|
1947
1985
|
"packages/query/src/engine.ts"() {
|
|
1948
1986
|
"use strict";
|
|
@@ -1950,6 +1988,17 @@ var init_engine = __esm({
|
|
|
1950
1988
|
init_src3();
|
|
1951
1989
|
init_src5();
|
|
1952
1990
|
init_src2();
|
|
1991
|
+
GROUP_BY = {
|
|
1992
|
+
File: ["status", "language", "source", "folder"],
|
|
1993
|
+
Function: ["file", "kind", "exported"],
|
|
1994
|
+
UnresolvedCallSite: ["reason", "status", "file"],
|
|
1995
|
+
CALLS: ["to", "from", "form", "resolution"]
|
|
1996
|
+
};
|
|
1997
|
+
SEARCH_LIMIT = 20;
|
|
1998
|
+
SEARCH_MAX = 100;
|
|
1999
|
+
AGGREGATE_MAX = 50;
|
|
2000
|
+
OUTLINE_MAX = 500;
|
|
2001
|
+
byCodePoint = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
1953
2002
|
sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
1954
2003
|
slug2 = (s) => s.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-.]+|-+$/g, "").slice(0, 48) || "source";
|
|
1955
2004
|
Engine = class {
|
|
@@ -2125,6 +2174,17 @@ var init_engine = __esm({
|
|
|
2125
2174
|
const reader = this.reader(project2);
|
|
2126
2175
|
return { ...this.meta(project2, reader), files: reader.facts("File") };
|
|
2127
2176
|
}
|
|
2177
|
+
/** Functions and calls per file, for the file list (not an MCP tool: a UI aid). */
|
|
2178
|
+
fileCounts(args, cwd) {
|
|
2179
|
+
const project2 = this.resolveProject(args, cwd);
|
|
2180
|
+
const reader = this.reader(project2);
|
|
2181
|
+
const functions = reader.countByFile("Function");
|
|
2182
|
+
const calls = reader.countByFile("CALLS");
|
|
2183
|
+
const counts = {};
|
|
2184
|
+
for (const f of reader.facts("File"))
|
|
2185
|
+
counts[f.id] = { functions: functions.get(f.id) ?? 0, calls: calls.get(f.id) ?? 0 };
|
|
2186
|
+
return { ...this.meta(project2, reader), counts };
|
|
2187
|
+
}
|
|
2128
2188
|
/** A file's functions, the calls among them, its unresolved sites and findings. */
|
|
2129
2189
|
fileGraph(args, cwd) {
|
|
2130
2190
|
const project2 = this.resolveProject(args, cwd);
|
|
@@ -2167,7 +2227,12 @@ var init_engine = __esm({
|
|
|
2167
2227
|
id: edge.id,
|
|
2168
2228
|
from: edge.from,
|
|
2169
2229
|
to: edge.to,
|
|
2170
|
-
function: {
|
|
2230
|
+
function: {
|
|
2231
|
+
id: otherId,
|
|
2232
|
+
qualifiedName: other?.qualifiedName ?? otherId,
|
|
2233
|
+
path,
|
|
2234
|
+
...other ? { line: other.evidence.span.start.line } : {}
|
|
2235
|
+
},
|
|
2171
2236
|
form: edge.form,
|
|
2172
2237
|
resolution: edge.resolution,
|
|
2173
2238
|
evidence: edge.evidence
|
|
@@ -2227,6 +2292,223 @@ var init_engine = __esm({
|
|
|
2227
2292
|
});
|
|
2228
2293
|
return { ...this.meta(project2, reader), function: fn.id, direction, calls };
|
|
2229
2294
|
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Find functions or files by name (generic graph tool `search_nodes`, design
|
|
2297
|
+
* §12 A3, limited to R1's labels). Ranked: exact name, then name prefix, then
|
|
2298
|
+
* a match anywhere in the qualified name or path; ties by path then id, in
|
|
2299
|
+
* code-point order so every machine returns the same page.
|
|
2300
|
+
*/
|
|
2301
|
+
searchNodes(args, cwd) {
|
|
2302
|
+
const project2 = this.resolveProject(args, cwd);
|
|
2303
|
+
const reader = this.reader(project2);
|
|
2304
|
+
if (args.label !== "Function" && args.label !== "File")
|
|
2305
|
+
throw new VeoError(
|
|
2306
|
+
"invalid-arguments",
|
|
2307
|
+
`search_nodes supports Function and File (got ${String(args.label)})`,
|
|
2308
|
+
{ fields: ["label"] }
|
|
2309
|
+
);
|
|
2310
|
+
if (args.filters?.status !== void 0 && args.label !== "File")
|
|
2311
|
+
throw new VeoError("invalid-arguments", "filters.status applies to File only", { fields: ["filters"] });
|
|
2312
|
+
const limit = checkLimit(args.limit, SEARCH_LIMIT, SEARCH_MAX);
|
|
2313
|
+
const text = (args.text ?? "").trim().toLowerCase();
|
|
2314
|
+
const prefix = args.filters?.path;
|
|
2315
|
+
const files = reader.facts("File");
|
|
2316
|
+
const pathOf = new Map(files.map((f) => [f.id, f.path]));
|
|
2317
|
+
const rank = (name, short, path) => {
|
|
2318
|
+
if (!text) return 3;
|
|
2319
|
+
const n = name.toLowerCase();
|
|
2320
|
+
const s = short.toLowerCase();
|
|
2321
|
+
if (s === text || n === text) return 0;
|
|
2322
|
+
if (s.startsWith(text) || n.startsWith(text)) return 1;
|
|
2323
|
+
if (n.includes(text)) return 2;
|
|
2324
|
+
if (path.toLowerCase().includes(text)) return 3;
|
|
2325
|
+
return -1;
|
|
2326
|
+
};
|
|
2327
|
+
const scored = [];
|
|
2328
|
+
if (args.label === "File") {
|
|
2329
|
+
for (const f of files) {
|
|
2330
|
+
if (prefix && !f.path.startsWith(prefix)) continue;
|
|
2331
|
+
if (args.filters?.status && f.status !== args.filters.status) continue;
|
|
2332
|
+
const score = rank(f.path, f.path.slice(f.path.lastIndexOf("/") + 1), f.path);
|
|
2333
|
+
if (score >= 0) scored.push({ score, path: f.path, id: f.id });
|
|
2334
|
+
}
|
|
2335
|
+
} else {
|
|
2336
|
+
for (const fn of reader.facts("Function")) {
|
|
2337
|
+
const path = pathOf.get(fn.file) ?? "";
|
|
2338
|
+
if (prefix && !path.startsWith(prefix)) continue;
|
|
2339
|
+
const score = rank(fn.qualifiedName, fn.name, path);
|
|
2340
|
+
if (score >= 0) scored.push({ score, path, id: fn.id });
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
scored.sort((a, b) => a.score - b.score || byCodePoint(a.path, b.path) || byCodePoint(a.id, b.id));
|
|
2344
|
+
const page = scored.slice(0, limit);
|
|
2345
|
+
let results;
|
|
2346
|
+
if (args.label === "File") {
|
|
2347
|
+
const byId = new Map(files.map((f) => [f.id, f]));
|
|
2348
|
+
results = page.map(({ id }) => {
|
|
2349
|
+
const f = byId.get(id);
|
|
2350
|
+
return {
|
|
2351
|
+
label: "File",
|
|
2352
|
+
id,
|
|
2353
|
+
name: f.path,
|
|
2354
|
+
path: f.path,
|
|
2355
|
+
status: f.status,
|
|
2356
|
+
functions: reader.facts("Function", id).length
|
|
2357
|
+
};
|
|
2358
|
+
});
|
|
2359
|
+
} else {
|
|
2360
|
+
const ids2 = page.map((p) => p.id);
|
|
2361
|
+
const incoming = reader.callCounts("dst", ids2);
|
|
2362
|
+
const outgoing = reader.callCounts("src", ids2);
|
|
2363
|
+
results = page.map(({ id, path }) => {
|
|
2364
|
+
const fn = reader.fact(id);
|
|
2365
|
+
return {
|
|
2366
|
+
label: "Function",
|
|
2367
|
+
id,
|
|
2368
|
+
name: fn.qualifiedName,
|
|
2369
|
+
path,
|
|
2370
|
+
callers: incoming.get(id)?.functions ?? 0,
|
|
2371
|
+
callees: outgoing.get(id)?.functions ?? 0,
|
|
2372
|
+
callsIn: incoming.get(id)?.calls ?? 0,
|
|
2373
|
+
callsOut: outgoing.get(id)?.calls ?? 0,
|
|
2374
|
+
evidence: fn.evidence
|
|
2375
|
+
};
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
return {
|
|
2379
|
+
...this.meta(project2, reader),
|
|
2380
|
+
label: args.label,
|
|
2381
|
+
text: args.text ?? "",
|
|
2382
|
+
total: scored.length,
|
|
2383
|
+
truncated: scored.length > limit,
|
|
2384
|
+
results
|
|
2385
|
+
};
|
|
2386
|
+
}
|
|
2387
|
+
/**
|
|
2388
|
+
* Counts grouped by a property (generic graph tool `aggregate`, design §12
|
|
2389
|
+
* A3, limited to R1's labels). Sorted by count, then key in code-point
|
|
2390
|
+
* 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.
|
|
2392
|
+
*/
|
|
2393
|
+
aggregate(args, cwd) {
|
|
2394
|
+
const project2 = this.resolveProject(args, cwd);
|
|
2395
|
+
const reader = this.reader(project2);
|
|
2396
|
+
if (!Object.hasOwn(GROUP_BY, args.label))
|
|
2397
|
+
throw new VeoError("invalid-arguments", `aggregate supports ${Object.keys(GROUP_BY).join(", ")}`, {
|
|
2398
|
+
fields: ["label"]
|
|
2399
|
+
});
|
|
2400
|
+
const allowed = GROUP_BY[args.label];
|
|
2401
|
+
if (!allowed.includes(args.groupBy))
|
|
2402
|
+
throw new VeoError("invalid-arguments", `${args.label} can be grouped by ${allowed.join(", ")}`, {
|
|
2403
|
+
fields: ["groupBy"]
|
|
2404
|
+
});
|
|
2405
|
+
const open2 = args.filters?.open;
|
|
2406
|
+
if (open2 !== void 0 && args.label !== "UnresolvedCallSite")
|
|
2407
|
+
throw new VeoError("invalid-arguments", "filters.open applies to UnresolvedCallSite only", {
|
|
2408
|
+
fields: ["filters"]
|
|
2409
|
+
});
|
|
2410
|
+
const limit = checkLimit(args.limit, AGGREGATE_MAX, AGGREGATE_MAX);
|
|
2411
|
+
const prefix = args.filters?.path;
|
|
2412
|
+
const files = reader.facts("File");
|
|
2413
|
+
const pathOf = new Map(files.map((f) => [f.id, f.path]));
|
|
2414
|
+
const inPath = (fileId) => !prefix || (pathOf.get(fileId) ?? "").startsWith(prefix);
|
|
2415
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2416
|
+
const add = (key) => counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
2417
|
+
let named;
|
|
2418
|
+
const fnName = (key) => reader.fact(key)?.qualifiedName;
|
|
2419
|
+
if (args.label === "File") {
|
|
2420
|
+
for (const f of files) {
|
|
2421
|
+
if (prefix && !f.path.startsWith(prefix)) continue;
|
|
2422
|
+
const folder = f.path.includes("/") ? f.path.slice(0, f.path.lastIndexOf("/")) : ".";
|
|
2423
|
+
const value = { status: f.status, language: f.language ?? "none", source: f.source, folder }[args.groupBy];
|
|
2424
|
+
add(String(value));
|
|
2425
|
+
}
|
|
2426
|
+
} else if (args.label === "Function") {
|
|
2427
|
+
for (const fn of reader.facts("Function")) {
|
|
2428
|
+
if (!inPath(fn.file)) continue;
|
|
2429
|
+
add(String({ file: fn.file, kind: fn.kind, exported: fn.exported }[args.groupBy]));
|
|
2430
|
+
}
|
|
2431
|
+
if (args.groupBy === "file") named = (key) => pathOf.get(key);
|
|
2432
|
+
} else if (args.label === "UnresolvedCallSite") {
|
|
2433
|
+
for (const site of reader.facts("UnresolvedCallSite")) {
|
|
2434
|
+
if (!inPath(site.file)) continue;
|
|
2435
|
+
if (open2 && !isOpenQuestion(site)) continue;
|
|
2436
|
+
add(String({ reason: site.reason, status: site.status, file: site.file }[args.groupBy]));
|
|
2437
|
+
}
|
|
2438
|
+
if (args.groupBy === "file") named = (key) => pathOf.get(key);
|
|
2439
|
+
} else if ((args.groupBy === "to" || args.groupBy === "from") && !prefix) {
|
|
2440
|
+
for (const [key, c] of reader.callCounts(args.groupBy === "to" ? "dst" : "src"))
|
|
2441
|
+
counts.set(key, c.calls);
|
|
2442
|
+
named = fnName;
|
|
2443
|
+
} else {
|
|
2444
|
+
const fileOf = new Map(reader.facts("Function").map((f) => [f.id, f.file]));
|
|
2445
|
+
for (const call of reader.facts("CALLS")) {
|
|
2446
|
+
const owner = fileOf.get(call.from);
|
|
2447
|
+
if (prefix && (!owner || !inPath(owner))) continue;
|
|
2448
|
+
add(
|
|
2449
|
+
String(
|
|
2450
|
+
{ to: call.to, from: call.from, form: call.form, resolution: call.resolution }[args.groupBy]
|
|
2451
|
+
)
|
|
2452
|
+
);
|
|
2453
|
+
}
|
|
2454
|
+
if (args.groupBy === "to" || args.groupBy === "from") named = fnName;
|
|
2455
|
+
}
|
|
2456
|
+
const sorted = [...counts].sort(([ka, a], [kb, b]) => b - a || byCodePoint(ka, kb));
|
|
2457
|
+
let total = 0;
|
|
2458
|
+
for (const [, n] of sorted) total += n;
|
|
2459
|
+
return {
|
|
2460
|
+
...this.meta(project2, reader),
|
|
2461
|
+
label: args.label,
|
|
2462
|
+
groupBy: args.groupBy,
|
|
2463
|
+
total,
|
|
2464
|
+
groupCount: sorted.length,
|
|
2465
|
+
truncated: sorted.length > limit,
|
|
2466
|
+
groups: sorted.slice(0, limit).map(([key, count]) => {
|
|
2467
|
+
const name = named?.(key);
|
|
2468
|
+
return name === void 0 ? { key, count } : { key, count, name };
|
|
2469
|
+
})
|
|
2470
|
+
};
|
|
2471
|
+
}
|
|
2472
|
+
/**
|
|
2473
|
+
* A file's functions in source order, each with its callers and callees
|
|
2474
|
+
* (distinct functions), call counts and unresolved sites, plus the file's
|
|
2475
|
+
* totals (design §12, A9). At most 500 functions.
|
|
2476
|
+
*/
|
|
2477
|
+
fileOutline(args, cwd) {
|
|
2478
|
+
const project2 = this.resolveProject(args, cwd);
|
|
2479
|
+
const reader = this.reader(project2);
|
|
2480
|
+
const file2 = reader.fact(args.file);
|
|
2481
|
+
if (!file2 || file2.type !== "File")
|
|
2482
|
+
throw new VeoError("not-found", `no file ${args.file}`, { kind: "file", id: args.file });
|
|
2483
|
+
const facts = reader.inFile(file2.id);
|
|
2484
|
+
const fns = facts.flatMap((f) => f.type === "Function" ? [f] : []).sort(
|
|
2485
|
+
(a, b) => a.evidence.span.start.line - b.evidence.span.start.line || a.evidence.span.start.column - b.evidence.span.start.column || byCodePoint(a.id, b.id)
|
|
2486
|
+
);
|
|
2487
|
+
const shown = fns.slice(0, OUTLINE_MAX);
|
|
2488
|
+
const ids2 = shown.map((f) => f.id);
|
|
2489
|
+
const incoming = reader.callCounts("dst", ids2);
|
|
2490
|
+
const outgoing = reader.callCounts("src", ids2);
|
|
2491
|
+
const sites = facts.flatMap((f) => f.type === "UnresolvedCallSite" ? [f] : []);
|
|
2492
|
+
const unresolvedIn = /* @__PURE__ */ new Map();
|
|
2493
|
+
for (const s of sites) unresolvedIn.set(s.enclosingFn, (unresolvedIn.get(s.enclosingFn) ?? 0) + 1);
|
|
2494
|
+
return {
|
|
2495
|
+
...this.meta(project2, reader),
|
|
2496
|
+
file: file2,
|
|
2497
|
+
functions: shown.map((f) => ({
|
|
2498
|
+
...this.functionView(f, file2.path),
|
|
2499
|
+
callers: incoming.get(f.id)?.functions ?? 0,
|
|
2500
|
+
callees: outgoing.get(f.id)?.functions ?? 0,
|
|
2501
|
+
callsIn: incoming.get(f.id)?.calls ?? 0,
|
|
2502
|
+
callsOut: outgoing.get(f.id)?.calls ?? 0,
|
|
2503
|
+
unresolved: unresolvedIn.get(f.id) ?? 0
|
|
2504
|
+
})),
|
|
2505
|
+
total: fns.length,
|
|
2506
|
+
truncated: fns.length > OUTLINE_MAX,
|
|
2507
|
+
calls: facts.filter((f) => f.type === "CALLS").length,
|
|
2508
|
+
unresolved: sites.length,
|
|
2509
|
+
open: sites.filter(isOpenQuestion).length
|
|
2510
|
+
};
|
|
2511
|
+
}
|
|
2230
2512
|
/** Unresolved call sites: open questions only, unless `includeAll` (design A6). */
|
|
2231
2513
|
listUnresolvedSites(args, cwd) {
|
|
2232
2514
|
const project2 = this.resolveProject(args, cwd);
|
|
@@ -2273,7 +2555,7 @@ var init_view = __esm({
|
|
|
2273
2555
|
file: null,
|
|
2274
2556
|
selection: null,
|
|
2275
2557
|
panel: "evidence",
|
|
2276
|
-
showUnresolved:
|
|
2558
|
+
showUnresolved: false
|
|
2277
2559
|
};
|
|
2278
2560
|
str = (field, optional2 = false) => (a) => optional2 && a[field] === void 0 || typeof a[field] === "string" && a[field].length > 0 ? [] : [field];
|
|
2279
2561
|
oneOf = (field, values) => (a) => values.includes(a[field]) ? [] : [field];
|
|
@@ -2300,7 +2582,9 @@ var init_view = __esm({
|
|
|
2300
2582
|
...s,
|
|
2301
2583
|
file: a.file ?? s.file,
|
|
2302
2584
|
selection: { kind: a.kind, id: a.id },
|
|
2303
|
-
panel: "evidence"
|
|
2585
|
+
panel: "evidence",
|
|
2586
|
+
// An unresolved site is only drawn when sites are shown.
|
|
2587
|
+
showUnresolved: a.kind === "site" ? true : s.showUnresolved
|
|
2304
2588
|
})
|
|
2305
2589
|
},
|
|
2306
2590
|
clearSelection: {
|
|
@@ -2310,9 +2594,9 @@ var init_view = __esm({
|
|
|
2310
2594
|
apply: (s) => ({ ...s, selection: null })
|
|
2311
2595
|
},
|
|
2312
2596
|
showPanel: {
|
|
2313
|
-
description: "Show the evidence panel
|
|
2597
|
+
description: "Show the evidence panel, the open-questions list or the last answer",
|
|
2314
2598
|
control: { kind: "tab", testId: "show-panel" },
|
|
2315
|
-
check: oneOf("panel", ["evidence", "questions"]),
|
|
2599
|
+
check: oneOf("panel", ["evidence", "questions", "answer"]),
|
|
2316
2600
|
apply: (s, a) => ({ ...s, panel: a.panel })
|
|
2317
2601
|
},
|
|
2318
2602
|
toggleUnresolved: {
|
|
@@ -2332,6 +2616,16 @@ var init_view = __esm({
|
|
|
2332
2616
|
description: "Analyze the project again",
|
|
2333
2617
|
control: { kind: "button", testId: "reanalyze" },
|
|
2334
2618
|
check: none
|
|
2619
|
+
},
|
|
2620
|
+
ask: {
|
|
2621
|
+
description: "Ask a question about the analyzed code (built-in questions offline; anything with a model)",
|
|
2622
|
+
control: { kind: "button", testId: "ask", shortcut: "Mod+K" },
|
|
2623
|
+
check: str("question")
|
|
2624
|
+
},
|
|
2625
|
+
openSettings: {
|
|
2626
|
+
description: "Set the model provider: base URL, API key and model name",
|
|
2627
|
+
control: { kind: "button", testId: "settings" },
|
|
2628
|
+
check: none
|
|
2335
2629
|
}
|
|
2336
2630
|
};
|
|
2337
2631
|
}
|
|
@@ -3358,8 +3652,8 @@ var init_types = __esm({
|
|
|
3358
3652
|
description
|
|
3359
3653
|
});
|
|
3360
3654
|
}
|
|
3361
|
-
pipe(
|
|
3362
|
-
return ZodPipeline.create(this,
|
|
3655
|
+
pipe(target2) {
|
|
3656
|
+
return ZodPipeline.create(this, target2);
|
|
3363
3657
|
}
|
|
3364
3658
|
readonly() {
|
|
3365
3659
|
return ZodReadonly.create(this);
|
|
@@ -6459,8 +6753,8 @@ function defineLazy(object3, key, getter) {
|
|
|
6459
6753
|
function objectClone(obj) {
|
|
6460
6754
|
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
6461
6755
|
}
|
|
6462
|
-
function assignProp(
|
|
6463
|
-
Object.defineProperty(
|
|
6756
|
+
function assignProp(target2, prop, value) {
|
|
6757
|
+
Object.defineProperty(target2, prop, {
|
|
6464
6758
|
value,
|
|
6465
6759
|
writable: true,
|
|
6466
6760
|
enumerable: true,
|
|
@@ -6474,8 +6768,8 @@ function rawShape(def) {
|
|
|
6474
6768
|
function sourceShape(schema) {
|
|
6475
6769
|
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
6476
6770
|
}
|
|
6477
|
-
function deferProp(
|
|
6478
|
-
Object.defineProperty(
|
|
6771
|
+
function deferProp(target2, key, getter) {
|
|
6772
|
+
Object.defineProperty(target2, key, {
|
|
6479
6773
|
get() {
|
|
6480
6774
|
const value = getter();
|
|
6481
6775
|
assignProp(this, key, value);
|
|
@@ -6485,36 +6779,36 @@ function deferProp(target, key, getter) {
|
|
|
6485
6779
|
configurable: true
|
|
6486
6780
|
});
|
|
6487
6781
|
}
|
|
6488
|
-
function putProp(
|
|
6489
|
-
if (key in
|
|
6490
|
-
assignProp(
|
|
6782
|
+
function putProp(target2, key, value) {
|
|
6783
|
+
if (key in target2)
|
|
6784
|
+
assignProp(target2, key, value);
|
|
6491
6785
|
else
|
|
6492
|
-
|
|
6786
|
+
target2[key] = value;
|
|
6493
6787
|
}
|
|
6494
|
-
function mirrorShape(
|
|
6788
|
+
function mirrorShape(target2, source, keys, wrap) {
|
|
6495
6789
|
const raw = sourceShape(source);
|
|
6496
6790
|
for (const key of keys) {
|
|
6497
6791
|
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
6498
6792
|
if (!desc.enumerable)
|
|
6499
6793
|
continue;
|
|
6500
6794
|
if (desc.get) {
|
|
6501
|
-
deferProp(
|
|
6795
|
+
deferProp(target2, key, () => {
|
|
6502
6796
|
const value = source._zod.def.shape[key];
|
|
6503
6797
|
return wrap ? wrap(value, key) : value;
|
|
6504
6798
|
});
|
|
6505
6799
|
} else
|
|
6506
|
-
putProp(
|
|
6800
|
+
putProp(target2, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
6507
6801
|
}
|
|
6508
6802
|
}
|
|
6509
|
-
function mirrorProps(
|
|
6803
|
+
function mirrorProps(target2, source) {
|
|
6510
6804
|
for (const key of Reflect.ownKeys(source)) {
|
|
6511
6805
|
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
6512
6806
|
if (!desc.enumerable)
|
|
6513
6807
|
continue;
|
|
6514
6808
|
if (desc.get)
|
|
6515
|
-
deferProp(
|
|
6809
|
+
deferProp(target2, key, () => source[key]);
|
|
6516
6810
|
else
|
|
6517
|
-
putProp(
|
|
6811
|
+
putProp(target2, key, desc.value);
|
|
6518
6812
|
}
|
|
6519
6813
|
}
|
|
6520
6814
|
function mergeDefs(...defs) {
|
|
@@ -6623,35 +6917,35 @@ function normalizeParams(_params) {
|
|
|
6623
6917
|
return params;
|
|
6624
6918
|
}
|
|
6625
6919
|
function createTransparentProxy(getter) {
|
|
6626
|
-
let
|
|
6920
|
+
let target2;
|
|
6627
6921
|
return new Proxy({}, {
|
|
6628
6922
|
get(_, prop, receiver) {
|
|
6629
|
-
|
|
6630
|
-
return Reflect.get(
|
|
6923
|
+
target2 ?? (target2 = getter());
|
|
6924
|
+
return Reflect.get(target2, prop, receiver);
|
|
6631
6925
|
},
|
|
6632
6926
|
set(_, prop, value, receiver) {
|
|
6633
|
-
|
|
6634
|
-
return Reflect.set(
|
|
6927
|
+
target2 ?? (target2 = getter());
|
|
6928
|
+
return Reflect.set(target2, prop, value, receiver);
|
|
6635
6929
|
},
|
|
6636
6930
|
has(_, prop) {
|
|
6637
|
-
|
|
6638
|
-
return Reflect.has(
|
|
6931
|
+
target2 ?? (target2 = getter());
|
|
6932
|
+
return Reflect.has(target2, prop);
|
|
6639
6933
|
},
|
|
6640
6934
|
deleteProperty(_, prop) {
|
|
6641
|
-
|
|
6642
|
-
return Reflect.deleteProperty(
|
|
6935
|
+
target2 ?? (target2 = getter());
|
|
6936
|
+
return Reflect.deleteProperty(target2, prop);
|
|
6643
6937
|
},
|
|
6644
6938
|
ownKeys(_) {
|
|
6645
|
-
|
|
6646
|
-
return Reflect.ownKeys(
|
|
6939
|
+
target2 ?? (target2 = getter());
|
|
6940
|
+
return Reflect.ownKeys(target2);
|
|
6647
6941
|
},
|
|
6648
6942
|
getOwnPropertyDescriptor(_, prop) {
|
|
6649
|
-
|
|
6650
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
6943
|
+
target2 ?? (target2 = getter());
|
|
6944
|
+
return Reflect.getOwnPropertyDescriptor(target2, prop);
|
|
6651
6945
|
},
|
|
6652
6946
|
defineProperty(_, prop, descriptor) {
|
|
6653
|
-
|
|
6654
|
-
return Reflect.defineProperty(
|
|
6947
|
+
target2 ?? (target2 = getter());
|
|
6948
|
+
return Reflect.defineProperty(target2, prop, descriptor);
|
|
6655
6949
|
}
|
|
6656
6950
|
});
|
|
6657
6951
|
}
|
|
@@ -7206,10 +7500,10 @@ function $constructor(name, initializer3, proto, params) {
|
|
|
7206
7500
|
let up = own2;
|
|
7207
7501
|
while (up && up !== ctorProto)
|
|
7208
7502
|
up = Object.getPrototypeOf(up);
|
|
7209
|
-
const
|
|
7210
|
-
if (!initialized.has(
|
|
7211
|
-
initialized.add(
|
|
7212
|
-
members(
|
|
7503
|
+
const target2 = up ?? own2;
|
|
7504
|
+
if (!initialized.has(target2)) {
|
|
7505
|
+
initialized.add(target2);
|
|
7506
|
+
members(target2, protoMembers);
|
|
7213
7507
|
}
|
|
7214
7508
|
}
|
|
7215
7509
|
const proto2 = _.prototype;
|
|
@@ -16662,8 +16956,8 @@ var init_pt = __esm({
|
|
|
16662
16956
|
case "not_multiple_of":
|
|
16663
16957
|
return `N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${issue2.divisor}`;
|
|
16664
16958
|
case "unrecognized_keys": {
|
|
16665
|
-
const
|
|
16666
|
-
return `Chave${
|
|
16959
|
+
const plural3 = issue2.keys.length > 1 ? "s" : "";
|
|
16960
|
+
return `Chave${plural3} inv\xE1lida${plural3}: ${joinValues(issue2.keys, ", ")}`;
|
|
16667
16961
|
}
|
|
16668
16962
|
case "invalid_key":
|
|
16669
16963
|
return `Entrada inv\xE1lida n${translateOriginWithArticle(issue2.origin, "definite")}`;
|
|
@@ -16813,8 +17107,8 @@ var init_pt_BR = __esm({
|
|
|
16813
17107
|
case "not_multiple_of":
|
|
16814
17108
|
return `N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${issue2.divisor}`;
|
|
16815
17109
|
case "unrecognized_keys": {
|
|
16816
|
-
const
|
|
16817
|
-
return `Chave${
|
|
17110
|
+
const plural3 = issue2.keys.length > 1 ? "s" : "";
|
|
17111
|
+
return `Chave${plural3} inv\xE1lida${plural3}: ${joinValues(issue2.keys, ", ")}`;
|
|
16818
17112
|
}
|
|
16819
17113
|
case "invalid_key":
|
|
16820
17114
|
return `Entrada inv\xE1lida n${translateOriginWithArticle(issue2.origin, "definite")}`;
|
|
@@ -19193,8 +19487,8 @@ function withParser(schema, parser) {
|
|
|
19193
19487
|
installCompiledUserMethods(clone2, schema, parser);
|
|
19194
19488
|
return clone2;
|
|
19195
19489
|
}
|
|
19196
|
-
function installCompiledUserMethods(
|
|
19197
|
-
const targetAny =
|
|
19490
|
+
function installCompiledUserMethods(target2, source, parser) {
|
|
19491
|
+
const targetAny = target2;
|
|
19198
19492
|
const sourceAny = source;
|
|
19199
19493
|
if (typeof sourceAny.safeParse === "function") {
|
|
19200
19494
|
const originalSafeParse = sourceAny.safeParse;
|
|
@@ -21824,26 +22118,26 @@ var init_api = __esm({
|
|
|
21824
22118
|
});
|
|
21825
22119
|
|
|
21826
22120
|
// node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/to-json-schema.js
|
|
21827
|
-
function assignProps(
|
|
22121
|
+
function assignProps(target2, ...sources) {
|
|
21828
22122
|
for (const source of sources) {
|
|
21829
22123
|
for (const key of Reflect.ownKeys(source)) {
|
|
21830
22124
|
if (Object.prototype.propertyIsEnumerable.call(source, key)) {
|
|
21831
|
-
assignProp(
|
|
22125
|
+
assignProp(target2, key, source[key]);
|
|
21832
22126
|
}
|
|
21833
22127
|
}
|
|
21834
22128
|
}
|
|
21835
|
-
return
|
|
22129
|
+
return target2;
|
|
21836
22130
|
}
|
|
21837
22131
|
function initializeContext(params) {
|
|
21838
|
-
let
|
|
21839
|
-
if (
|
|
21840
|
-
|
|
21841
|
-
if (
|
|
21842
|
-
|
|
22132
|
+
let target2 = params?.target ?? "draft-2020-12";
|
|
22133
|
+
if (target2 === "draft-4")
|
|
22134
|
+
target2 = "draft-04";
|
|
22135
|
+
if (target2 === "draft-7")
|
|
22136
|
+
target2 = "draft-07";
|
|
21843
22137
|
return {
|
|
21844
22138
|
processors: params.processors ?? {},
|
|
21845
22139
|
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
21846
|
-
target,
|
|
22140
|
+
target: target2,
|
|
21847
22141
|
unrepresentable: params?.unrepresentable ?? "throw",
|
|
21848
22142
|
override: params?.override ?? (() => {
|
|
21849
22143
|
}),
|
|
@@ -22351,8 +22645,8 @@ var init_to_json_schema = __esm({
|
|
|
22351
22645
|
return finalize(ctx, schema);
|
|
22352
22646
|
};
|
|
22353
22647
|
createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
22354
|
-
const { libraryOptions, target } = params ?? {};
|
|
22355
|
-
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
22648
|
+
const { libraryOptions, target: target2 } = params ?? {};
|
|
22649
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target: target2, io, processors });
|
|
22356
22650
|
processSchema(schema, ctx);
|
|
22357
22651
|
extractDefs(ctx, schema);
|
|
22358
22652
|
return finalize(ctx, schema);
|
|
@@ -24870,8 +25164,8 @@ var init_schemas3 = __esm({
|
|
|
24870
25164
|
catch(params) {
|
|
24871
25165
|
return _catch2(this, params);
|
|
24872
25166
|
},
|
|
24873
|
-
pipe(
|
|
24874
|
-
return pipe(this,
|
|
25167
|
+
pipe(target2) {
|
|
25168
|
+
return pipe(this, target2);
|
|
24875
25169
|
},
|
|
24876
25170
|
readonly() {
|
|
24877
25171
|
return readonly(this);
|
|
@@ -33290,8 +33584,8 @@ var require_resolve = __commonJS({
|
|
|
33290
33584
|
}
|
|
33291
33585
|
return count;
|
|
33292
33586
|
}
|
|
33293
|
-
function getFullPath(resolver, id = "",
|
|
33294
|
-
if (
|
|
33587
|
+
function getFullPath(resolver, id = "", normalize2) {
|
|
33588
|
+
if (normalize2 !== false)
|
|
33295
33589
|
id = normalizeId(id);
|
|
33296
33590
|
const p = resolver.parse(id);
|
|
33297
33591
|
return _getFullPath(resolver, p);
|
|
@@ -34886,7 +35180,7 @@ var require_fast_uri = __commonJS({
|
|
|
34886
35180
|
}
|
|
34887
35181
|
return decodedScheme;
|
|
34888
35182
|
}
|
|
34889
|
-
function
|
|
35183
|
+
function normalize2(uri, options) {
|
|
34890
35184
|
if (typeof uri === "string") {
|
|
34891
35185
|
uri = /** @type {T} */
|
|
34892
35186
|
normalizeString(uri, options);
|
|
@@ -34930,57 +35224,57 @@ var require_fast_uri = __commonJS({
|
|
|
34930
35224
|
return serialize(resolved, schemelessOptions);
|
|
34931
35225
|
}
|
|
34932
35226
|
function resolveComponent(base, relative2, options, skipNormalization) {
|
|
34933
|
-
const
|
|
35227
|
+
const target2 = {};
|
|
34934
35228
|
if (!skipNormalization) {
|
|
34935
35229
|
base = parse4(serialize(base, options), options);
|
|
34936
35230
|
relative2 = parse4(serialize(relative2, options), options);
|
|
34937
35231
|
}
|
|
34938
35232
|
options = options || {};
|
|
34939
35233
|
if (!options.tolerant && relative2.scheme) {
|
|
34940
|
-
|
|
34941
|
-
|
|
34942
|
-
|
|
34943
|
-
|
|
34944
|
-
|
|
34945
|
-
|
|
35234
|
+
target2.scheme = relative2.scheme;
|
|
35235
|
+
target2.userinfo = relative2.userinfo;
|
|
35236
|
+
target2.host = relative2.host;
|
|
35237
|
+
target2.port = relative2.port;
|
|
35238
|
+
target2.path = removeDotSegments(relative2.path || "");
|
|
35239
|
+
target2.query = relative2.query;
|
|
34946
35240
|
} else {
|
|
34947
35241
|
if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
|
|
34948
|
-
|
|
34949
|
-
|
|
34950
|
-
|
|
34951
|
-
|
|
34952
|
-
|
|
35242
|
+
target2.userinfo = relative2.userinfo;
|
|
35243
|
+
target2.host = relative2.host;
|
|
35244
|
+
target2.port = relative2.port;
|
|
35245
|
+
target2.path = removeDotSegments(relative2.path || "");
|
|
35246
|
+
target2.query = relative2.query;
|
|
34953
35247
|
} else {
|
|
34954
35248
|
if (!relative2.path) {
|
|
34955
|
-
|
|
35249
|
+
target2.path = base.path;
|
|
34956
35250
|
if (relative2.query !== void 0) {
|
|
34957
|
-
|
|
35251
|
+
target2.query = relative2.query;
|
|
34958
35252
|
} else {
|
|
34959
|
-
|
|
35253
|
+
target2.query = base.query;
|
|
34960
35254
|
}
|
|
34961
35255
|
} else {
|
|
34962
35256
|
if (relative2.path[0] === "/") {
|
|
34963
|
-
|
|
35257
|
+
target2.path = removeDotSegments(relative2.path);
|
|
34964
35258
|
} else {
|
|
34965
35259
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
34966
|
-
|
|
35260
|
+
target2.path = "/" + relative2.path;
|
|
34967
35261
|
} else if (!base.path) {
|
|
34968
|
-
|
|
35262
|
+
target2.path = relative2.path;
|
|
34969
35263
|
} else {
|
|
34970
|
-
|
|
35264
|
+
target2.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
|
|
34971
35265
|
}
|
|
34972
|
-
|
|
35266
|
+
target2.path = removeDotSegments(target2.path);
|
|
34973
35267
|
}
|
|
34974
|
-
|
|
35268
|
+
target2.query = relative2.query;
|
|
34975
35269
|
}
|
|
34976
|
-
|
|
34977
|
-
|
|
34978
|
-
|
|
35270
|
+
target2.userinfo = base.userinfo;
|
|
35271
|
+
target2.host = base.host;
|
|
35272
|
+
target2.port = base.port;
|
|
34979
35273
|
}
|
|
34980
|
-
|
|
35274
|
+
target2.scheme = base.scheme;
|
|
34981
35275
|
}
|
|
34982
|
-
|
|
34983
|
-
return
|
|
35276
|
+
target2.fragment = relative2.fragment;
|
|
35277
|
+
return target2;
|
|
34984
35278
|
}
|
|
34985
35279
|
function equal(uriA, uriB, options) {
|
|
34986
35280
|
const normalizedA = normalizeComparableURI(uriA, options);
|
|
@@ -35264,7 +35558,7 @@ var require_fast_uri = __commonJS({
|
|
|
35264
35558
|
}
|
|
35265
35559
|
var fastUri = {
|
|
35266
35560
|
SCHEMES,
|
|
35267
|
-
normalize,
|
|
35561
|
+
normalize: normalize2,
|
|
35268
35562
|
resolve: resolve5,
|
|
35269
35563
|
resolveComponent,
|
|
35270
35564
|
equal,
|
|
@@ -35646,12 +35940,12 @@ var require_core = __commonJS({
|
|
|
35646
35940
|
return this;
|
|
35647
35941
|
}
|
|
35648
35942
|
keywordMetaschema.call(this, def);
|
|
35649
|
-
const
|
|
35943
|
+
const definition2 = {
|
|
35650
35944
|
...def,
|
|
35651
35945
|
type: (0, dataType_1.getJSONTypes)(def.type),
|
|
35652
35946
|
schemaType: (0, dataType_1.getJSONTypes)(def.schemaType)
|
|
35653
35947
|
};
|
|
35654
|
-
(0, util_1.eachItem)(keyword,
|
|
35948
|
+
(0, util_1.eachItem)(keyword, definition2.type.length === 0 ? (k) => addRule.call(this, k, definition2) : (k) => definition2.type.forEach((t) => addRule.call(this, k, definition2, t)));
|
|
35655
35949
|
return this;
|
|
35656
35950
|
}
|
|
35657
35951
|
getKeyword(keyword) {
|
|
@@ -35844,9 +36138,9 @@ var require_core = __commonJS({
|
|
|
35844
36138
|
throw new Error('$data keyword must have "code" or "validate" function');
|
|
35845
36139
|
}
|
|
35846
36140
|
}
|
|
35847
|
-
function addRule(keyword,
|
|
36141
|
+
function addRule(keyword, definition2, dataType) {
|
|
35848
36142
|
var _a3;
|
|
35849
|
-
const post =
|
|
36143
|
+
const post = definition2 === null || definition2 === void 0 ? void 0 : definition2.post;
|
|
35850
36144
|
if (dataType && post)
|
|
35851
36145
|
throw new Error('keyword with "post" flag cannot have "type"');
|
|
35852
36146
|
const { RULES } = this;
|
|
@@ -35856,22 +36150,22 @@ var require_core = __commonJS({
|
|
|
35856
36150
|
RULES.rules.push(ruleGroup);
|
|
35857
36151
|
}
|
|
35858
36152
|
RULES.keywords[keyword] = true;
|
|
35859
|
-
if (!
|
|
36153
|
+
if (!definition2)
|
|
35860
36154
|
return;
|
|
35861
36155
|
const rule = {
|
|
35862
36156
|
keyword,
|
|
35863
36157
|
definition: {
|
|
35864
|
-
...
|
|
35865
|
-
type: (0, dataType_1.getJSONTypes)(
|
|
35866
|
-
schemaType: (0, dataType_1.getJSONTypes)(
|
|
36158
|
+
...definition2,
|
|
36159
|
+
type: (0, dataType_1.getJSONTypes)(definition2.type),
|
|
36160
|
+
schemaType: (0, dataType_1.getJSONTypes)(definition2.schemaType)
|
|
35867
36161
|
}
|
|
35868
36162
|
};
|
|
35869
|
-
if (
|
|
35870
|
-
addBeforeRule.call(this, ruleGroup, rule,
|
|
36163
|
+
if (definition2.before)
|
|
36164
|
+
addBeforeRule.call(this, ruleGroup, rule, definition2.before);
|
|
35871
36165
|
else
|
|
35872
36166
|
ruleGroup.rules.push(rule);
|
|
35873
36167
|
RULES.all[keyword] = rule;
|
|
35874
|
-
(_a3 =
|
|
36168
|
+
(_a3 = definition2.implements) === null || _a3 === void 0 ? void 0 : _a3.forEach((kwd) => this.addKeyword(kwd));
|
|
35875
36169
|
}
|
|
35876
36170
|
function addBeforeRule(ruleGroup, rule, before) {
|
|
35877
36171
|
const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
|
|
@@ -39213,24 +39507,24 @@ var init_mcp = __esm({
|
|
|
39213
39507
|
}
|
|
39214
39508
|
});
|
|
39215
39509
|
this.server.setRequestHandler(ListToolsRequestSchema, () => ({
|
|
39216
|
-
tools: Object.entries(this._registeredTools).filter(([,
|
|
39510
|
+
tools: Object.entries(this._registeredTools).filter(([, tool2]) => tool2.enabled).map(([name, tool2]) => {
|
|
39217
39511
|
const toolDefinition = {
|
|
39218
39512
|
name,
|
|
39219
|
-
title:
|
|
39220
|
-
description:
|
|
39513
|
+
title: tool2.title,
|
|
39514
|
+
description: tool2.description,
|
|
39221
39515
|
inputSchema: (() => {
|
|
39222
|
-
const obj = normalizeObjectSchema(
|
|
39516
|
+
const obj = normalizeObjectSchema(tool2.inputSchema);
|
|
39223
39517
|
return obj ? toJsonSchemaCompat(obj, {
|
|
39224
39518
|
strictUnions: true,
|
|
39225
39519
|
pipeStrategy: "input"
|
|
39226
39520
|
}) : EMPTY_OBJECT_JSON_SCHEMA;
|
|
39227
39521
|
})(),
|
|
39228
|
-
annotations:
|
|
39229
|
-
execution:
|
|
39230
|
-
_meta:
|
|
39522
|
+
annotations: tool2.annotations,
|
|
39523
|
+
execution: tool2.execution,
|
|
39524
|
+
_meta: tool2._meta
|
|
39231
39525
|
};
|
|
39232
|
-
if (
|
|
39233
|
-
const obj = normalizeObjectSchema(
|
|
39526
|
+
if (tool2.outputSchema) {
|
|
39527
|
+
const obj = normalizeObjectSchema(tool2.outputSchema);
|
|
39234
39528
|
if (obj) {
|
|
39235
39529
|
toolDefinition.outputSchema = toJsonSchemaCompat(obj, {
|
|
39236
39530
|
strictUnions: true,
|
|
@@ -39243,16 +39537,16 @@ var init_mcp = __esm({
|
|
|
39243
39537
|
}));
|
|
39244
39538
|
this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
39245
39539
|
try {
|
|
39246
|
-
const
|
|
39247
|
-
if (!
|
|
39540
|
+
const tool2 = this._registeredTools[request.params.name];
|
|
39541
|
+
if (!tool2) {
|
|
39248
39542
|
throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
|
|
39249
39543
|
}
|
|
39250
|
-
if (!
|
|
39544
|
+
if (!tool2.enabled) {
|
|
39251
39545
|
throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
|
|
39252
39546
|
}
|
|
39253
39547
|
const isTaskRequest = !!request.params.task;
|
|
39254
|
-
const taskSupport =
|
|
39255
|
-
const isTaskHandler = "createTask" in
|
|
39548
|
+
const taskSupport = tool2.execution?.taskSupport;
|
|
39549
|
+
const isTaskHandler = "createTask" in tool2.handler;
|
|
39256
39550
|
if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) {
|
|
39257
39551
|
throw new McpError(ErrorCode.InternalError, `Tool ${request.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
|
|
39258
39552
|
}
|
|
@@ -39260,14 +39554,14 @@ var init_mcp = __esm({
|
|
|
39260
39554
|
throw new McpError(ErrorCode.MethodNotFound, `Tool ${request.params.name} requires task augmentation (taskSupport: 'required')`);
|
|
39261
39555
|
}
|
|
39262
39556
|
if (taskSupport === "optional" && !isTaskRequest && isTaskHandler) {
|
|
39263
|
-
return await this.handleAutomaticTaskPolling(
|
|
39557
|
+
return await this.handleAutomaticTaskPolling(tool2, request, extra);
|
|
39264
39558
|
}
|
|
39265
|
-
const args = await this.validateToolInput(
|
|
39266
|
-
const result2 = await this.executeToolHandler(
|
|
39559
|
+
const args = await this.validateToolInput(tool2, request.params.arguments, request.params.name);
|
|
39560
|
+
const result2 = await this.executeToolHandler(tool2, args, extra);
|
|
39267
39561
|
if (isTaskRequest) {
|
|
39268
39562
|
return result2;
|
|
39269
39563
|
}
|
|
39270
|
-
await this.validateToolOutput(
|
|
39564
|
+
await this.validateToolOutput(tool2, result2, request.params.name);
|
|
39271
39565
|
return result2;
|
|
39272
39566
|
} catch (error62) {
|
|
39273
39567
|
if (error62 instanceof McpError) {
|
|
@@ -39300,12 +39594,12 @@ var init_mcp = __esm({
|
|
|
39300
39594
|
/**
|
|
39301
39595
|
* Validates tool input arguments against the tool's input schema.
|
|
39302
39596
|
*/
|
|
39303
|
-
async validateToolInput(
|
|
39304
|
-
if (!
|
|
39597
|
+
async validateToolInput(tool2, args, toolName) {
|
|
39598
|
+
if (!tool2.inputSchema) {
|
|
39305
39599
|
return void 0;
|
|
39306
39600
|
}
|
|
39307
|
-
const inputObj = normalizeObjectSchema(
|
|
39308
|
-
const schemaToParse = inputObj ??
|
|
39601
|
+
const inputObj = normalizeObjectSchema(tool2.inputSchema);
|
|
39602
|
+
const schemaToParse = inputObj ?? tool2.inputSchema;
|
|
39309
39603
|
const parseResult = await safeParseAsync2(schemaToParse, args);
|
|
39310
39604
|
if (!parseResult.success) {
|
|
39311
39605
|
const error62 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
@@ -39317,8 +39611,8 @@ var init_mcp = __esm({
|
|
|
39317
39611
|
/**
|
|
39318
39612
|
* Validates tool output against the tool's output schema.
|
|
39319
39613
|
*/
|
|
39320
|
-
async validateToolOutput(
|
|
39321
|
-
if (!
|
|
39614
|
+
async validateToolOutput(tool2, result2, toolName) {
|
|
39615
|
+
if (!tool2.outputSchema) {
|
|
39322
39616
|
return;
|
|
39323
39617
|
}
|
|
39324
39618
|
if (!("content" in result2)) {
|
|
@@ -39330,7 +39624,7 @@ var init_mcp = __esm({
|
|
|
39330
39624
|
if (!result2.structuredContent) {
|
|
39331
39625
|
throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`);
|
|
39332
39626
|
}
|
|
39333
|
-
const outputObj = normalizeObjectSchema(
|
|
39627
|
+
const outputObj = normalizeObjectSchema(tool2.outputSchema);
|
|
39334
39628
|
const parseResult = await safeParseAsync2(outputObj, result2.structuredContent);
|
|
39335
39629
|
if (!parseResult.success) {
|
|
39336
39630
|
const error62 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
@@ -39341,15 +39635,15 @@ var init_mcp = __esm({
|
|
|
39341
39635
|
/**
|
|
39342
39636
|
* Executes a tool handler (either regular or task-based).
|
|
39343
39637
|
*/
|
|
39344
|
-
async executeToolHandler(
|
|
39345
|
-
const handler =
|
|
39638
|
+
async executeToolHandler(tool2, args, extra) {
|
|
39639
|
+
const handler = tool2.handler;
|
|
39346
39640
|
const isTaskHandler = "createTask" in handler;
|
|
39347
39641
|
if (isTaskHandler) {
|
|
39348
39642
|
if (!extra.taskStore) {
|
|
39349
39643
|
throw new Error("No task store provided.");
|
|
39350
39644
|
}
|
|
39351
39645
|
const taskExtra = { ...extra, taskStore: extra.taskStore };
|
|
39352
|
-
if (
|
|
39646
|
+
if (tool2.inputSchema) {
|
|
39353
39647
|
const typedHandler = handler;
|
|
39354
39648
|
return await Promise.resolve(typedHandler.createTask(args, taskExtra));
|
|
39355
39649
|
} else {
|
|
@@ -39357,7 +39651,7 @@ var init_mcp = __esm({
|
|
|
39357
39651
|
return await Promise.resolve(typedHandler.createTask(taskExtra));
|
|
39358
39652
|
}
|
|
39359
39653
|
}
|
|
39360
|
-
if (
|
|
39654
|
+
if (tool2.inputSchema) {
|
|
39361
39655
|
const typedHandler = handler;
|
|
39362
39656
|
return await Promise.resolve(typedHandler(args, extra));
|
|
39363
39657
|
} else {
|
|
@@ -39368,12 +39662,12 @@ var init_mcp = __esm({
|
|
|
39368
39662
|
/**
|
|
39369
39663
|
* Handles automatic task polling for tools with taskSupport 'optional'.
|
|
39370
39664
|
*/
|
|
39371
|
-
async handleAutomaticTaskPolling(
|
|
39665
|
+
async handleAutomaticTaskPolling(tool2, request, extra) {
|
|
39372
39666
|
if (!extra.taskStore) {
|
|
39373
39667
|
throw new Error("No task store provided for task-capable tool.");
|
|
39374
39668
|
}
|
|
39375
|
-
const args = await this.validateToolInput(
|
|
39376
|
-
const handler =
|
|
39669
|
+
const args = await this.validateToolInput(tool2, request.params.arguments, request.params.name);
|
|
39670
|
+
const handler = tool2.handler;
|
|
39377
39671
|
const taskExtra = { ...extra, taskStore: extra.taskStore };
|
|
39378
39672
|
const createTaskResult = args ? await Promise.resolve(handler.createTask(args, taskExtra)) : (
|
|
39379
39673
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -40011,8 +40305,8 @@ function errorJson(e) {
|
|
|
40011
40305
|
return { code: "internal", message: e instanceof Error ? e.message.split("\n")[0] : String(e) };
|
|
40012
40306
|
}
|
|
40013
40307
|
async function callTool(engine, name, args, cwd) {
|
|
40014
|
-
const
|
|
40015
|
-
return await
|
|
40308
|
+
const tool2 = TOOLS[name];
|
|
40309
|
+
return await tool2.call(engine, args, cwd);
|
|
40016
40310
|
}
|
|
40017
40311
|
function result(value, isError = false) {
|
|
40018
40312
|
return {
|
|
@@ -40022,22 +40316,22 @@ function result(value, isError = false) {
|
|
|
40022
40316
|
}
|
|
40023
40317
|
function createMcpServer(engine, options = {}) {
|
|
40024
40318
|
const server = new McpServer({ name: "veoflow", version: options.version ?? "0.0.0" });
|
|
40025
|
-
for (const [name,
|
|
40319
|
+
for (const [name, tool2] of Object.entries(TOOLS)) {
|
|
40026
40320
|
server.registerTool(
|
|
40027
40321
|
name,
|
|
40028
|
-
{ description:
|
|
40322
|
+
{ description: tool2.description, inputSchema: external_exports.strictObject(tool2.input) },
|
|
40029
40323
|
(() => result({ code: "internal", message: "unreachable" }, true))
|
|
40030
40324
|
);
|
|
40031
40325
|
}
|
|
40032
40326
|
server.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
40033
40327
|
const name = request.params.name;
|
|
40034
|
-
const
|
|
40035
|
-
if (!
|
|
40328
|
+
const tool2 = Object.hasOwn(TOOLS, name) ? TOOLS[name] : void 0;
|
|
40329
|
+
if (!tool2)
|
|
40036
40330
|
return result(
|
|
40037
40331
|
{ code: "not-found", message: `no tool ${name}`, details: { kind: "tool", id: name } },
|
|
40038
40332
|
true
|
|
40039
40333
|
);
|
|
40040
|
-
const parsed = external_exports.object(
|
|
40334
|
+
const parsed = external_exports.object(tool2.input).strict().safeParse(request.params.arguments ?? {});
|
|
40041
40335
|
if (!parsed.success) {
|
|
40042
40336
|
const fields = [
|
|
40043
40337
|
...new Set(
|
|
@@ -40159,6 +40453,42 @@ var init_server3 = __esm({
|
|
|
40159
40453
|
includeAll: external_exports.boolean().optional()
|
|
40160
40454
|
},
|
|
40161
40455
|
call: (e, a, cwd) => e.listUnresolvedSites(a, cwd)
|
|
40456
|
+
},
|
|
40457
|
+
search_nodes: {
|
|
40458
|
+
description: "Find functions or files by name (generic graph tool). Ranked: exact name, then prefix, then anywhere in the qualified name or path. 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
|
+
input: {
|
|
40460
|
+
project,
|
|
40461
|
+
label: external_exports.enum(["Function", "File"]),
|
|
40462
|
+
text: external_exports.string().optional().describe("Name or part of a name or path; omitted lists everything"),
|
|
40463
|
+
filters: external_exports.object({
|
|
40464
|
+
path: external_exports.string().min(1).optional().describe("Only results whose file path starts with this prefix"),
|
|
40465
|
+
status: external_exports.enum(["analyzed", "degraded", "not_analyzed"]).optional().describe("Files only")
|
|
40466
|
+
}).optional(),
|
|
40467
|
+
limit: external_exports.number().int().positive().optional()
|
|
40468
|
+
},
|
|
40469
|
+
call: (e, a, cwd) => e.searchNodes(a, cwd)
|
|
40470
|
+
},
|
|
40471
|
+
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).",
|
|
40473
|
+
input: {
|
|
40474
|
+
project,
|
|
40475
|
+
label: external_exports.enum(["File", "Function", "UnresolvedCallSite", "CALLS"]),
|
|
40476
|
+
groupBy: external_exports.string().min(1),
|
|
40477
|
+
filters: external_exports.object({
|
|
40478
|
+
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")
|
|
40480
|
+
}).optional(),
|
|
40481
|
+
limit: external_exports.number().int().positive().optional()
|
|
40482
|
+
},
|
|
40483
|
+
call: (e, a, cwd) => e.aggregate(a, cwd)
|
|
40484
|
+
},
|
|
40485
|
+
file_outline: {
|
|
40486
|
+
description: "A file's functions in source order, each with its callers and callees (distinct functions), calls in and out, and unresolved call sites, plus the file's totals. At most 500 functions.",
|
|
40487
|
+
input: {
|
|
40488
|
+
project,
|
|
40489
|
+
file: external_exports.string().min(1).describe("A file id, as returned by search_nodes or listed files")
|
|
40490
|
+
},
|
|
40491
|
+
call: (e, a, cwd) => e.fileOutline(a, cwd)
|
|
40162
40492
|
}
|
|
40163
40493
|
};
|
|
40164
40494
|
}
|
|
@@ -44850,8 +45180,8 @@ var require_send = __commonJS({
|
|
|
44850
45180
|
var { parseTokenList } = require_parseTokenList();
|
|
44851
45181
|
var { createHttpError } = require_createHttpError();
|
|
44852
45182
|
var extname = path.extname;
|
|
44853
|
-
var
|
|
44854
|
-
var
|
|
45183
|
+
var join9 = path.join;
|
|
45184
|
+
var normalize2 = path.normalize;
|
|
44855
45185
|
var resolve5 = path.resolve;
|
|
44856
45186
|
var sep3 = path.sep;
|
|
44857
45187
|
var Readable = stream.Readable;
|
|
@@ -44930,20 +45260,20 @@ var require_send = __commonJS({
|
|
|
44930
45260
|
let parts;
|
|
44931
45261
|
if (root !== null) {
|
|
44932
45262
|
if (path2) {
|
|
44933
|
-
path2 =
|
|
45263
|
+
path2 = normalize2("." + sep3 + path2);
|
|
44934
45264
|
}
|
|
44935
45265
|
if (UP_PATH_REGEXP.test(path2)) {
|
|
44936
45266
|
debug('malicious path "%s"', path2);
|
|
44937
45267
|
return { statusCode: 403 };
|
|
44938
45268
|
}
|
|
44939
45269
|
parts = path2.split(sep3);
|
|
44940
|
-
path2 =
|
|
45270
|
+
path2 = normalize2(join9(root, path2));
|
|
44941
45271
|
} else {
|
|
44942
45272
|
if (UP_PATH_REGEXP.test(path2)) {
|
|
44943
45273
|
debug('malicious path "%s"', path2);
|
|
44944
45274
|
return { statusCode: 403 };
|
|
44945
45275
|
}
|
|
44946
|
-
parts =
|
|
45276
|
+
parts = normalize2(path2).split(sep3);
|
|
44947
45277
|
path2 = resolve5(path2);
|
|
44948
45278
|
}
|
|
44949
45279
|
return { path: path2, parts };
|
|
@@ -45220,7 +45550,7 @@ var require_send = __commonJS({
|
|
|
45220
45550
|
let err;
|
|
45221
45551
|
for (let i = 0; i < options.index.length; i++) {
|
|
45222
45552
|
const index = options.index[i];
|
|
45223
|
-
const p =
|
|
45553
|
+
const p = join9(path2, index);
|
|
45224
45554
|
const { error: error62, stat } = await tryStat(p);
|
|
45225
45555
|
if (error62) {
|
|
45226
45556
|
err = error62;
|
|
@@ -46195,8 +46525,8 @@ var require_dirList = __commonJS({
|
|
|
46195
46525
|
FST_STATIC_MULTIROOT_LIST_CONFLICT
|
|
46196
46526
|
} = require_errors2();
|
|
46197
46527
|
var fastqConcurrency = Math.max(1, os.cpus().length - 1);
|
|
46198
|
-
function isPathInsideRoot(root,
|
|
46199
|
-
const relativePath = path.relative(root,
|
|
46528
|
+
function isPathInsideRoot(root, target2) {
|
|
46529
|
+
const relativePath = path.relative(root, target2);
|
|
46200
46530
|
return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${path.sep}`) && !path.isAbsolute(relativePath);
|
|
46201
46531
|
}
|
|
46202
46532
|
var dirList = {
|
|
@@ -46391,7 +46721,7 @@ var require_static = __commonJS({
|
|
|
46391
46721
|
"use strict";
|
|
46392
46722
|
var path = __require("node:path");
|
|
46393
46723
|
var { fileURLToPath: fileURLToPath3 } = __require("node:url");
|
|
46394
|
-
var { statSync:
|
|
46724
|
+
var { statSync: statSync5 } = __require("node:fs");
|
|
46395
46725
|
var { readdir, stat } = __require("node:fs/promises");
|
|
46396
46726
|
var { basename: basename4 } = __require("node:path");
|
|
46397
46727
|
var { glob } = require_index_min();
|
|
@@ -46568,8 +46898,8 @@ var require_static = __commonJS({
|
|
|
46568
46898
|
}
|
|
46569
46899
|
}
|
|
46570
46900
|
}
|
|
46571
|
-
for (const [
|
|
46572
|
-
const pathname =
|
|
46901
|
+
for (const [dirname7, rootPath] of indexDirs.entries()) {
|
|
46902
|
+
const pathname = dirname7 + (dirname7.endsWith("/") ? "" : "/");
|
|
46573
46903
|
const file2 = "/" + pathname.replace(prefix, "");
|
|
46574
46904
|
setUpHeadAndGet(routeOpts, pathname, file2, rootPath);
|
|
46575
46905
|
if (opts.redirect === true) {
|
|
@@ -46835,7 +47165,7 @@ var require_static = __commonJS({
|
|
|
46835
47165
|
}
|
|
46836
47166
|
let pathStat;
|
|
46837
47167
|
try {
|
|
46838
|
-
pathStat =
|
|
47168
|
+
pathStat = statSync5(rootPath);
|
|
46839
47169
|
} catch (e) {
|
|
46840
47170
|
if (e.code === "ENOENT") {
|
|
46841
47171
|
!suppressWarning && fastify.log.warn(`"root" path "${rootPath}" must exist`);
|
|
@@ -46939,7 +47269,7 @@ var require_static = __commonJS({
|
|
|
46939
47269
|
return indexFiles.find((filename) => {
|
|
46940
47270
|
const p = path.join(root, pathname, filename);
|
|
46941
47271
|
try {
|
|
46942
|
-
const stats =
|
|
47272
|
+
const stats = statSync5(p);
|
|
46943
47273
|
return !stats.isDirectory();
|
|
46944
47274
|
} catch {
|
|
46945
47275
|
return false;
|
|
@@ -47115,17 +47445,17 @@ var require_buffer_util = __commonJS({
|
|
|
47115
47445
|
function concat(list, totalLength) {
|
|
47116
47446
|
if (list.length === 0) return EMPTY_BUFFER;
|
|
47117
47447
|
if (list.length === 1) return list[0];
|
|
47118
|
-
const
|
|
47448
|
+
const target2 = Buffer.allocUnsafe(totalLength);
|
|
47119
47449
|
let offset = 0;
|
|
47120
47450
|
for (let i = 0; i < list.length; i++) {
|
|
47121
47451
|
const buf = list[i];
|
|
47122
|
-
|
|
47452
|
+
target2.set(buf, offset);
|
|
47123
47453
|
offset += buf.length;
|
|
47124
47454
|
}
|
|
47125
47455
|
if (offset < totalLength) {
|
|
47126
|
-
return new FastBuffer(
|
|
47456
|
+
return new FastBuffer(target2.buffer, target2.byteOffset, offset);
|
|
47127
47457
|
}
|
|
47128
|
-
return
|
|
47458
|
+
return target2;
|
|
47129
47459
|
}
|
|
47130
47460
|
function _mask(source, mask, output2, offset, length) {
|
|
47131
47461
|
for (let i = 0; i < length; i++) {
|
|
@@ -48549,29 +48879,29 @@ var require_sender = __commonJS({
|
|
|
48549
48879
|
offset += 2;
|
|
48550
48880
|
payloadLength = 126;
|
|
48551
48881
|
}
|
|
48552
|
-
const
|
|
48553
|
-
|
|
48554
|
-
if (options.rsv1)
|
|
48555
|
-
|
|
48882
|
+
const target2 = Buffer.allocUnsafe(merge2 ? dataLength + offset : offset);
|
|
48883
|
+
target2[0] = options.fin ? options.opcode | 128 : options.opcode;
|
|
48884
|
+
if (options.rsv1) target2[0] |= 64;
|
|
48885
|
+
target2[1] = payloadLength;
|
|
48556
48886
|
if (payloadLength === 126) {
|
|
48557
|
-
|
|
48887
|
+
target2.writeUInt16BE(dataLength, 2);
|
|
48558
48888
|
} else if (payloadLength === 127) {
|
|
48559
|
-
|
|
48560
|
-
|
|
48561
|
-
}
|
|
48562
|
-
if (!options.mask) return [
|
|
48563
|
-
|
|
48564
|
-
|
|
48565
|
-
|
|
48566
|
-
|
|
48567
|
-
|
|
48568
|
-
if (skipMasking) return [
|
|
48889
|
+
target2[2] = target2[3] = 0;
|
|
48890
|
+
target2.writeUIntBE(dataLength, 4, 6);
|
|
48891
|
+
}
|
|
48892
|
+
if (!options.mask) return [target2, data];
|
|
48893
|
+
target2[1] |= 128;
|
|
48894
|
+
target2[offset - 4] = mask[0];
|
|
48895
|
+
target2[offset - 3] = mask[1];
|
|
48896
|
+
target2[offset - 2] = mask[2];
|
|
48897
|
+
target2[offset - 1] = mask[3];
|
|
48898
|
+
if (skipMasking) return [target2, data];
|
|
48569
48899
|
if (merge2) {
|
|
48570
|
-
applyMask(data, mask,
|
|
48571
|
-
return [
|
|
48900
|
+
applyMask(data, mask, target2, offset, dataLength);
|
|
48901
|
+
return [target2];
|
|
48572
48902
|
}
|
|
48573
48903
|
applyMask(data, mask, data, 0, dataLength);
|
|
48574
|
-
return [
|
|
48904
|
+
return [target2, data];
|
|
48575
48905
|
}
|
|
48576
48906
|
/**
|
|
48577
48907
|
* Sends a close message to the other peer.
|
|
@@ -50812,16 +51142,16 @@ var require_buffer_list = __commonJS({
|
|
|
50812
51142
|
}
|
|
50813
51143
|
return keys;
|
|
50814
51144
|
}
|
|
50815
|
-
function _objectSpread(
|
|
51145
|
+
function _objectSpread(target2) {
|
|
50816
51146
|
for (var i = 1; i < arguments.length; i++) {
|
|
50817
51147
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
50818
51148
|
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
50819
|
-
_defineProperty(
|
|
50820
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
50821
|
-
Object.defineProperty(
|
|
51149
|
+
_defineProperty(target2, key, source[key]);
|
|
51150
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target2, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
51151
|
+
Object.defineProperty(target2, key, Object.getOwnPropertyDescriptor(source, key));
|
|
50822
51152
|
});
|
|
50823
51153
|
}
|
|
50824
|
-
return
|
|
51154
|
+
return target2;
|
|
50825
51155
|
}
|
|
50826
51156
|
function _defineProperty(obj, key, value) {
|
|
50827
51157
|
key = _toPropertyKey(key);
|
|
@@ -50837,13 +51167,13 @@ var require_buffer_list = __commonJS({
|
|
|
50837
51167
|
throw new TypeError("Cannot call a class as a function");
|
|
50838
51168
|
}
|
|
50839
51169
|
}
|
|
50840
|
-
function _defineProperties(
|
|
51170
|
+
function _defineProperties(target2, props) {
|
|
50841
51171
|
for (var i = 0; i < props.length; i++) {
|
|
50842
51172
|
var descriptor = props[i];
|
|
50843
51173
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
50844
51174
|
descriptor.configurable = true;
|
|
50845
51175
|
if ("value" in descriptor) descriptor.writable = true;
|
|
50846
|
-
Object.defineProperty(
|
|
51176
|
+
Object.defineProperty(target2, _toPropertyKey(descriptor.key), descriptor);
|
|
50847
51177
|
}
|
|
50848
51178
|
}
|
|
50849
51179
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
@@ -50871,8 +51201,8 @@ var require_buffer_list = __commonJS({
|
|
|
50871
51201
|
var _require2 = __require("util");
|
|
50872
51202
|
var inspect = _require2.inspect;
|
|
50873
51203
|
var custom2 = inspect && inspect.custom || "inspect";
|
|
50874
|
-
function copyBuffer(src,
|
|
50875
|
-
Buffer2.prototype.copy.call(src,
|
|
51204
|
+
function copyBuffer(src, target2, offset) {
|
|
51205
|
+
Buffer2.prototype.copy.call(src, target2, offset);
|
|
50876
51206
|
}
|
|
50877
51207
|
module.exports = /* @__PURE__ */ (function() {
|
|
50878
51208
|
function BufferList() {
|
|
@@ -50922,7 +51252,7 @@ var require_buffer_list = __commonJS({
|
|
|
50922
51252
|
}
|
|
50923
51253
|
}, {
|
|
50924
51254
|
key: "join",
|
|
50925
|
-
value: function
|
|
51255
|
+
value: function join9(s) {
|
|
50926
51256
|
if (this.length === 0) return "";
|
|
50927
51257
|
var p = this.head;
|
|
50928
51258
|
var ret = "" + p.data;
|
|
@@ -52436,16 +52766,16 @@ var require_from = __commonJS({
|
|
|
52436
52766
|
}
|
|
52437
52767
|
return keys;
|
|
52438
52768
|
}
|
|
52439
|
-
function _objectSpread(
|
|
52769
|
+
function _objectSpread(target2) {
|
|
52440
52770
|
for (var i = 1; i < arguments.length; i++) {
|
|
52441
52771
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
52442
52772
|
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
52443
|
-
_defineProperty(
|
|
52444
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
52445
|
-
Object.defineProperty(
|
|
52773
|
+
_defineProperty(target2, key, source[key]);
|
|
52774
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target2, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
52775
|
+
Object.defineProperty(target2, key, Object.getOwnPropertyDescriptor(source, key));
|
|
52446
52776
|
});
|
|
52447
52777
|
}
|
|
52448
|
-
return
|
|
52778
|
+
return target2;
|
|
52449
52779
|
}
|
|
52450
52780
|
function _defineProperty(obj, key, value) {
|
|
52451
52781
|
key = _toPropertyKey(key);
|
|
@@ -60778,8 +61108,8 @@ var require_atomic_sleep = __commonJS({
|
|
|
60778
61108
|
}
|
|
60779
61109
|
throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");
|
|
60780
61110
|
}
|
|
60781
|
-
const
|
|
60782
|
-
while (
|
|
61111
|
+
const target2 = Date.now() + Number(ms);
|
|
61112
|
+
while (target2 > Date.now()) {
|
|
60783
61113
|
}
|
|
60784
61114
|
};
|
|
60785
61115
|
module.exports = sleep3;
|
|
@@ -60906,7 +61236,7 @@ var require_sonic_boom = __commonJS({
|
|
|
60906
61236
|
fsWrite = () => fs.write(this.fd, this._writingBuf, this.release);
|
|
60907
61237
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
60908
61238
|
this._writingBuf = "";
|
|
60909
|
-
this.write =
|
|
61239
|
+
this.write = write2;
|
|
60910
61240
|
this.flush = flush;
|
|
60911
61241
|
this.flushSync = flushSync;
|
|
60912
61242
|
this._actualWrite = actualWrite;
|
|
@@ -61039,7 +61369,7 @@ var require_sonic_boom = __commonJS({
|
|
|
61039
61369
|
}
|
|
61040
61370
|
return Buffer.concat(bufs, len);
|
|
61041
61371
|
}
|
|
61042
|
-
function
|
|
61372
|
+
function write2(data) {
|
|
61043
61373
|
if (this.destroyed) {
|
|
61044
61374
|
throw new Error("SonicBoom destroyed");
|
|
61045
61375
|
}
|
|
@@ -61605,7 +61935,7 @@ var require_thread_stream = __commonJS({
|
|
|
61605
61935
|
var { version: version3 } = require_package();
|
|
61606
61936
|
var { EventEmitter: EventEmitter2 } = __require("events");
|
|
61607
61937
|
var { Worker } = __require("worker_threads");
|
|
61608
|
-
var { join:
|
|
61938
|
+
var { join: join9 } = __require("path");
|
|
61609
61939
|
var { pathToFileURL } = __require("url");
|
|
61610
61940
|
var { wait } = require_wait();
|
|
61611
61941
|
var {
|
|
@@ -61656,7 +61986,7 @@ var require_thread_stream = __commonJS({
|
|
|
61656
61986
|
function createWorker(stream, opts) {
|
|
61657
61987
|
const { filename, workerData } = opts;
|
|
61658
61988
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
61659
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
61989
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join9(__dirname, "lib", "worker.js");
|
|
61660
61990
|
const worker = new Worker(toExecute, {
|
|
61661
61991
|
...opts.workerOpts,
|
|
61662
61992
|
name: opts.workerOpts?.name || "thread-stream",
|
|
@@ -61700,7 +62030,7 @@ var require_thread_stream = __commonJS({
|
|
|
61700
62030
|
}
|
|
61701
62031
|
return;
|
|
61702
62032
|
}
|
|
61703
|
-
|
|
62033
|
+
write2(stream, leftover, noop);
|
|
61704
62034
|
continue;
|
|
61705
62035
|
}
|
|
61706
62036
|
if (leftover === 0) {
|
|
@@ -62004,7 +62334,7 @@ var require_thread_stream = __commonJS({
|
|
|
62004
62334
|
});
|
|
62005
62335
|
}
|
|
62006
62336
|
}
|
|
62007
|
-
function
|
|
62337
|
+
function write2(stream, maxBytes, cb) {
|
|
62008
62338
|
const current = Atomics.load(stream[kImpl].state, WRITE_INDEX);
|
|
62009
62339
|
let offset = current;
|
|
62010
62340
|
let remaining = maxBytes;
|
|
@@ -62089,7 +62419,7 @@ var require_thread_stream = __commonJS({
|
|
|
62089
62419
|
} else if (leftover < 0) {
|
|
62090
62420
|
throw new Error("overwritten");
|
|
62091
62421
|
}
|
|
62092
|
-
|
|
62422
|
+
write2(stream, leftover, cb);
|
|
62093
62423
|
}
|
|
62094
62424
|
}
|
|
62095
62425
|
function flushSync(stream) {
|
|
@@ -62122,9 +62452,9 @@ var require_transport = __commonJS({
|
|
|
62122
62452
|
"node_modules/.pnpm/pino@10.3.1/node_modules/pino/lib/transport.js"(exports, module) {
|
|
62123
62453
|
"use strict";
|
|
62124
62454
|
var { createRequire: createRequire3 } = __require("module");
|
|
62125
|
-
var { existsSync:
|
|
62455
|
+
var { existsSync: existsSync8 } = __require("node:fs");
|
|
62126
62456
|
var getCallers = require_caller();
|
|
62127
|
-
var { join:
|
|
62457
|
+
var { join: join9, isAbsolute: isAbsolute2, sep: sep3 } = __require("node:path");
|
|
62128
62458
|
var { fileURLToPath: fileURLToPath3 } = __require("node:url");
|
|
62129
62459
|
var sleep3 = require_atomic_sleep();
|
|
62130
62460
|
var onExit = require_on_exit_leak_free();
|
|
@@ -62196,7 +62526,7 @@ var require_transport = __commonJS({
|
|
|
62196
62526
|
return false;
|
|
62197
62527
|
}
|
|
62198
62528
|
}
|
|
62199
|
-
return
|
|
62529
|
+
return isAbsolute2(path) && !existsSync8(path);
|
|
62200
62530
|
}
|
|
62201
62531
|
function stripQuotes(value) {
|
|
62202
62532
|
const first = value[0];
|
|
@@ -62270,14 +62600,14 @@ var require_transport = __commonJS({
|
|
|
62270
62600
|
const options = {
|
|
62271
62601
|
...fullOptions.options
|
|
62272
62602
|
};
|
|
62273
|
-
const
|
|
62603
|
+
const callers2 = typeof caller === "string" ? [caller] : caller;
|
|
62274
62604
|
const bundlerOverrides = typeof globalThis === "object" && Object.prototype.hasOwnProperty.call(globalThis, "__bundlerPathsOverrides") && globalThis.__bundlerPathsOverrides && typeof globalThis.__bundlerPathsOverrides === "object" ? globalThis.__bundlerPathsOverrides : /* @__PURE__ */ Object.create(null);
|
|
62275
|
-
let
|
|
62276
|
-
if (
|
|
62605
|
+
let target2 = fullOptions.target;
|
|
62606
|
+
if (target2 && targets) {
|
|
62277
62607
|
throw new Error("only one of target or targets can be specified");
|
|
62278
62608
|
}
|
|
62279
62609
|
if (targets) {
|
|
62280
|
-
|
|
62610
|
+
target2 = bundlerOverrides["pino-worker"] || join9(__dirname, "worker.js");
|
|
62281
62611
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
62282
62612
|
return {
|
|
62283
62613
|
...dest,
|
|
@@ -62295,7 +62625,7 @@ var require_transport = __commonJS({
|
|
|
62295
62625
|
});
|
|
62296
62626
|
});
|
|
62297
62627
|
} else if (pipeline) {
|
|
62298
|
-
|
|
62628
|
+
target2 = bundlerOverrides["pino-worker"] || join9(__dirname, "worker.js");
|
|
62299
62629
|
options.pipelines = [pipeline.map((dest) => {
|
|
62300
62630
|
return {
|
|
62301
62631
|
...dest,
|
|
@@ -62310,18 +62640,18 @@ var require_transport = __commonJS({
|
|
|
62310
62640
|
options.dedupe = dedupe;
|
|
62311
62641
|
}
|
|
62312
62642
|
options.pinoWillSendConfig = true;
|
|
62313
|
-
const name = targets || pipeline ? "pino.transport" :
|
|
62314
|
-
return buildStream(fixTarget(
|
|
62643
|
+
const name = targets || pipeline ? "pino.transport" : target2;
|
|
62644
|
+
return buildStream(fixTarget(target2), options, worker, sync, name);
|
|
62315
62645
|
function fixTarget(origin) {
|
|
62316
62646
|
origin = bundlerOverrides[origin] || origin;
|
|
62317
|
-
if (
|
|
62647
|
+
if (isAbsolute2(origin) || origin.indexOf("file://") === 0) {
|
|
62318
62648
|
return origin;
|
|
62319
62649
|
}
|
|
62320
62650
|
if (origin === "pino/file") {
|
|
62321
|
-
return
|
|
62651
|
+
return join9(__dirname, "..", "file.js");
|
|
62322
62652
|
}
|
|
62323
62653
|
let fixTarget2;
|
|
62324
|
-
for (const filePath of
|
|
62654
|
+
for (const filePath of callers2) {
|
|
62325
62655
|
try {
|
|
62326
62656
|
const context = filePath === "node:repl" ? process.cwd() + sep3 : filePath;
|
|
62327
62657
|
fixTarget2 = createRequire3(context).resolve(origin);
|
|
@@ -62972,7 +63302,7 @@ var require_proto = __commonJS({
|
|
|
62972
63302
|
return "Pino";
|
|
62973
63303
|
},
|
|
62974
63304
|
[lsCacheSym]: initialLsCache,
|
|
62975
|
-
[writeSym]:
|
|
63305
|
+
[writeSym]: write2,
|
|
62976
63306
|
[asJsonSym]: asJson,
|
|
62977
63307
|
[getLevelSym]: getLevel,
|
|
62978
63308
|
[setLevelSym]: setLevel
|
|
@@ -63075,7 +63405,7 @@ var require_proto = __commonJS({
|
|
|
63075
63405
|
function defaultMixinMergeStrategy(mergeObject, mixinObject) {
|
|
63076
63406
|
return Object.assign(mixinObject, mergeObject);
|
|
63077
63407
|
}
|
|
63078
|
-
function
|
|
63408
|
+
function write2(_obj, msg, num) {
|
|
63079
63409
|
const t = this[timeSym]();
|
|
63080
63410
|
const mixin = this[mixinSym];
|
|
63081
63411
|
const errorKey = this[errorKeySym];
|
|
@@ -63298,7 +63628,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
63298
63628
|
return circularValue;
|
|
63299
63629
|
}
|
|
63300
63630
|
let res = "";
|
|
63301
|
-
let
|
|
63631
|
+
let join9 = ",";
|
|
63302
63632
|
const originalIndentation = indentation;
|
|
63303
63633
|
if (Array.isArray(value)) {
|
|
63304
63634
|
if (value.length === 0) {
|
|
@@ -63312,7 +63642,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
63312
63642
|
indentation += spacer;
|
|
63313
63643
|
res += `
|
|
63314
63644
|
${indentation}`;
|
|
63315
|
-
|
|
63645
|
+
join9 = `,
|
|
63316
63646
|
${indentation}`;
|
|
63317
63647
|
}
|
|
63318
63648
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -63320,13 +63650,13 @@ ${indentation}`;
|
|
|
63320
63650
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
63321
63651
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
63322
63652
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
63323
|
-
res +=
|
|
63653
|
+
res += join9;
|
|
63324
63654
|
}
|
|
63325
63655
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
63326
63656
|
res += tmp !== void 0 ? tmp : "null";
|
|
63327
63657
|
if (value.length - 1 > maximumBreadth) {
|
|
63328
63658
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
63329
|
-
res += `${
|
|
63659
|
+
res += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
63330
63660
|
}
|
|
63331
63661
|
if (spacer !== "") {
|
|
63332
63662
|
res += `
|
|
@@ -63347,7 +63677,7 @@ ${originalIndentation}`;
|
|
|
63347
63677
|
let separator = "";
|
|
63348
63678
|
if (spacer !== "") {
|
|
63349
63679
|
indentation += spacer;
|
|
63350
|
-
|
|
63680
|
+
join9 = `,
|
|
63351
63681
|
${indentation}`;
|
|
63352
63682
|
whitespace = " ";
|
|
63353
63683
|
}
|
|
@@ -63361,13 +63691,13 @@ ${indentation}`;
|
|
|
63361
63691
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
63362
63692
|
if (tmp !== void 0) {
|
|
63363
63693
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
63364
|
-
separator =
|
|
63694
|
+
separator = join9;
|
|
63365
63695
|
}
|
|
63366
63696
|
}
|
|
63367
63697
|
if (keyLength > maximumBreadth) {
|
|
63368
63698
|
const removedKeys = keyLength - maximumBreadth;
|
|
63369
63699
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
63370
|
-
separator =
|
|
63700
|
+
separator = join9;
|
|
63371
63701
|
}
|
|
63372
63702
|
if (spacer !== "" && separator.length > 1) {
|
|
63373
63703
|
res = `
|
|
@@ -63408,7 +63738,7 @@ ${originalIndentation}`;
|
|
|
63408
63738
|
}
|
|
63409
63739
|
const originalIndentation = indentation;
|
|
63410
63740
|
let res = "";
|
|
63411
|
-
let
|
|
63741
|
+
let join9 = ",";
|
|
63412
63742
|
if (Array.isArray(value)) {
|
|
63413
63743
|
if (value.length === 0) {
|
|
63414
63744
|
return "[]";
|
|
@@ -63421,7 +63751,7 @@ ${originalIndentation}`;
|
|
|
63421
63751
|
indentation += spacer;
|
|
63422
63752
|
res += `
|
|
63423
63753
|
${indentation}`;
|
|
63424
|
-
|
|
63754
|
+
join9 = `,
|
|
63425
63755
|
${indentation}`;
|
|
63426
63756
|
}
|
|
63427
63757
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -63429,13 +63759,13 @@ ${indentation}`;
|
|
|
63429
63759
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
63430
63760
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
63431
63761
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
63432
|
-
res +=
|
|
63762
|
+
res += join9;
|
|
63433
63763
|
}
|
|
63434
63764
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
63435
63765
|
res += tmp !== void 0 ? tmp : "null";
|
|
63436
63766
|
if (value.length - 1 > maximumBreadth) {
|
|
63437
63767
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
63438
|
-
res += `${
|
|
63768
|
+
res += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
63439
63769
|
}
|
|
63440
63770
|
if (spacer !== "") {
|
|
63441
63771
|
res += `
|
|
@@ -63448,7 +63778,7 @@ ${originalIndentation}`;
|
|
|
63448
63778
|
let whitespace = "";
|
|
63449
63779
|
if (spacer !== "") {
|
|
63450
63780
|
indentation += spacer;
|
|
63451
|
-
|
|
63781
|
+
join9 = `,
|
|
63452
63782
|
${indentation}`;
|
|
63453
63783
|
whitespace = " ";
|
|
63454
63784
|
}
|
|
@@ -63457,7 +63787,7 @@ ${indentation}`;
|
|
|
63457
63787
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
63458
63788
|
if (tmp !== void 0) {
|
|
63459
63789
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
63460
|
-
separator =
|
|
63790
|
+
separator = join9;
|
|
63461
63791
|
}
|
|
63462
63792
|
}
|
|
63463
63793
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -63515,20 +63845,20 @@ ${originalIndentation}`;
|
|
|
63515
63845
|
indentation += spacer;
|
|
63516
63846
|
let res2 = `
|
|
63517
63847
|
${indentation}`;
|
|
63518
|
-
const
|
|
63848
|
+
const join10 = `,
|
|
63519
63849
|
${indentation}`;
|
|
63520
63850
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
63521
63851
|
let i = 0;
|
|
63522
63852
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
63523
63853
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
63524
63854
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
63525
|
-
res2 +=
|
|
63855
|
+
res2 += join10;
|
|
63526
63856
|
}
|
|
63527
63857
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
63528
63858
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
63529
63859
|
if (value.length - 1 > maximumBreadth) {
|
|
63530
63860
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
63531
|
-
res2 += `${
|
|
63861
|
+
res2 += `${join10}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
63532
63862
|
}
|
|
63533
63863
|
res2 += `
|
|
63534
63864
|
${originalIndentation}`;
|
|
@@ -63544,16 +63874,16 @@ ${originalIndentation}`;
|
|
|
63544
63874
|
return '"[Object]"';
|
|
63545
63875
|
}
|
|
63546
63876
|
indentation += spacer;
|
|
63547
|
-
const
|
|
63877
|
+
const join9 = `,
|
|
63548
63878
|
${indentation}`;
|
|
63549
63879
|
let res = "";
|
|
63550
63880
|
let separator = "";
|
|
63551
63881
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
63552
63882
|
if (isTypedArrayWithEntries(value)) {
|
|
63553
|
-
res += stringifyTypedArray(value,
|
|
63883
|
+
res += stringifyTypedArray(value, join9, maximumBreadth);
|
|
63554
63884
|
keys = keys.slice(value.length);
|
|
63555
63885
|
maximumPropertiesToStringify -= value.length;
|
|
63556
|
-
separator =
|
|
63886
|
+
separator = join9;
|
|
63557
63887
|
}
|
|
63558
63888
|
if (deterministic) {
|
|
63559
63889
|
keys = sort(keys, comparator);
|
|
@@ -63564,13 +63894,13 @@ ${indentation}`;
|
|
|
63564
63894
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
63565
63895
|
if (tmp !== void 0) {
|
|
63566
63896
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
63567
|
-
separator =
|
|
63897
|
+
separator = join9;
|
|
63568
63898
|
}
|
|
63569
63899
|
}
|
|
63570
63900
|
if (keyLength > maximumBreadth) {
|
|
63571
63901
|
const removedKeys = keyLength - maximumBreadth;
|
|
63572
63902
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
63573
|
-
separator =
|
|
63903
|
+
separator = join9;
|
|
63574
63904
|
}
|
|
63575
63905
|
if (separator !== "") {
|
|
63576
63906
|
res = `
|
|
@@ -63736,7 +64066,7 @@ var require_multistream = __commonJS({
|
|
|
63736
64066
|
});
|
|
63737
64067
|
}
|
|
63738
64068
|
const res = {
|
|
63739
|
-
write,
|
|
64069
|
+
write: write2,
|
|
63740
64070
|
add,
|
|
63741
64071
|
remove,
|
|
63742
64072
|
emit,
|
|
@@ -63756,7 +64086,7 @@ var require_multistream = __commonJS({
|
|
|
63756
64086
|
}
|
|
63757
64087
|
streamsArray = null;
|
|
63758
64088
|
return res;
|
|
63759
|
-
function
|
|
64089
|
+
function write2(data) {
|
|
63760
64090
|
let dest;
|
|
63761
64091
|
const level = this.lastLevel;
|
|
63762
64092
|
const { streams } = this;
|
|
@@ -63858,7 +64188,7 @@ var require_multistream = __commonJS({
|
|
|
63858
64188
|
};
|
|
63859
64189
|
}
|
|
63860
64190
|
return {
|
|
63861
|
-
write,
|
|
64191
|
+
write: write2,
|
|
63862
64192
|
add,
|
|
63863
64193
|
remove,
|
|
63864
64194
|
minLevel: level,
|
|
@@ -63971,11 +64301,11 @@ var require_pino = __commonJS({
|
|
|
63971
64301
|
depthLimit: 5,
|
|
63972
64302
|
edgeLimit: 100
|
|
63973
64303
|
};
|
|
63974
|
-
var
|
|
64304
|
+
var normalize2 = createArgsNormalizer(defaultOptions2);
|
|
63975
64305
|
var serializers = Object.assign(/* @__PURE__ */ Object.create(null), stdSerializers);
|
|
63976
64306
|
function pino(...args) {
|
|
63977
64307
|
const instance = {};
|
|
63978
|
-
const { opts, stream } =
|
|
64308
|
+
const { opts, stream } = normalize2(instance, caller(), ...args);
|
|
63979
64309
|
if (opts.level && typeof opts.level === "string" && DEFAULT_LEVELS[opts.level.toLowerCase()] !== void 0) opts.level = opts.level.toLowerCase();
|
|
63980
64310
|
const {
|
|
63981
64311
|
redact,
|
|
@@ -70411,7 +70741,7 @@ var require_fast_uri2 = __commonJS({
|
|
|
70411
70741
|
}
|
|
70412
70742
|
return decodedScheme;
|
|
70413
70743
|
}
|
|
70414
|
-
function
|
|
70744
|
+
function normalize2(uri, options) {
|
|
70415
70745
|
if (typeof uri === "string") {
|
|
70416
70746
|
uri = /** @type {T} */
|
|
70417
70747
|
normalizeString(uri, options);
|
|
@@ -70454,64 +70784,64 @@ var require_fast_uri2 = __commonJS({
|
|
|
70454
70784
|
schemelessOptions.skipEscape = true;
|
|
70455
70785
|
return serialize(resolved, schemelessOptions);
|
|
70456
70786
|
}
|
|
70457
|
-
function copyHost(
|
|
70458
|
-
|
|
70787
|
+
function copyHost(target2, source) {
|
|
70788
|
+
target2.host = source.host;
|
|
70459
70789
|
if (source.ipv6Zone !== void 0) {
|
|
70460
|
-
|
|
70790
|
+
target2.ipv6Zone = source.ipv6Zone;
|
|
70461
70791
|
}
|
|
70462
70792
|
}
|
|
70463
70793
|
function resolveComponent(base, relative2, options, skipNormalization) {
|
|
70464
|
-
const
|
|
70794
|
+
const target2 = {};
|
|
70465
70795
|
if (!skipNormalization) {
|
|
70466
70796
|
base = parse4(serialize(base, options), options);
|
|
70467
70797
|
relative2 = parse4(serialize(relative2, options), options);
|
|
70468
70798
|
}
|
|
70469
70799
|
options = options || {};
|
|
70470
70800
|
if (!options.tolerant && relative2.scheme) {
|
|
70471
|
-
|
|
70472
|
-
|
|
70473
|
-
copyHost(
|
|
70474
|
-
|
|
70475
|
-
|
|
70476
|
-
|
|
70801
|
+
target2.scheme = relative2.scheme;
|
|
70802
|
+
target2.userinfo = relative2.userinfo;
|
|
70803
|
+
copyHost(target2, relative2);
|
|
70804
|
+
target2.port = relative2.port;
|
|
70805
|
+
target2.path = removeDotSegments(relative2.path || "");
|
|
70806
|
+
target2.query = relative2.query;
|
|
70477
70807
|
} else {
|
|
70478
70808
|
if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
|
|
70479
|
-
|
|
70480
|
-
copyHost(
|
|
70481
|
-
|
|
70482
|
-
|
|
70483
|
-
|
|
70809
|
+
target2.userinfo = relative2.userinfo;
|
|
70810
|
+
copyHost(target2, relative2);
|
|
70811
|
+
target2.port = relative2.port;
|
|
70812
|
+
target2.path = removeDotSegments(relative2.path || "");
|
|
70813
|
+
target2.query = relative2.query;
|
|
70484
70814
|
} else {
|
|
70485
70815
|
if (!relative2.path) {
|
|
70486
|
-
|
|
70816
|
+
target2.path = base.path;
|
|
70487
70817
|
if (relative2.query !== void 0) {
|
|
70488
|
-
|
|
70818
|
+
target2.query = relative2.query;
|
|
70489
70819
|
} else {
|
|
70490
|
-
|
|
70820
|
+
target2.query = base.query;
|
|
70491
70821
|
}
|
|
70492
70822
|
} else {
|
|
70493
70823
|
if (relative2.path[0] === "/") {
|
|
70494
|
-
|
|
70824
|
+
target2.path = removeDotSegments(relative2.path);
|
|
70495
70825
|
} else {
|
|
70496
70826
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
70497
|
-
|
|
70827
|
+
target2.path = "/" + relative2.path;
|
|
70498
70828
|
} else if (!base.path) {
|
|
70499
|
-
|
|
70829
|
+
target2.path = relative2.path;
|
|
70500
70830
|
} else {
|
|
70501
|
-
|
|
70831
|
+
target2.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
|
|
70502
70832
|
}
|
|
70503
|
-
|
|
70833
|
+
target2.path = removeDotSegments(target2.path);
|
|
70504
70834
|
}
|
|
70505
|
-
|
|
70835
|
+
target2.query = relative2.query;
|
|
70506
70836
|
}
|
|
70507
|
-
|
|
70508
|
-
copyHost(
|
|
70509
|
-
|
|
70837
|
+
target2.userinfo = base.userinfo;
|
|
70838
|
+
copyHost(target2, base);
|
|
70839
|
+
target2.port = base.port;
|
|
70510
70840
|
}
|
|
70511
|
-
|
|
70841
|
+
target2.scheme = base.scheme;
|
|
70512
70842
|
}
|
|
70513
|
-
|
|
70514
|
-
return
|
|
70843
|
+
target2.fragment = relative2.fragment;
|
|
70844
|
+
return target2;
|
|
70515
70845
|
}
|
|
70516
70846
|
function equal(uriA, uriB, options) {
|
|
70517
70847
|
const normalizedA = normalizeComparableURI(uriA, options);
|
|
@@ -70804,7 +71134,7 @@ var require_fast_uri2 = __commonJS({
|
|
|
70804
71134
|
}
|
|
70805
71135
|
var fastUri = {
|
|
70806
71136
|
SCHEMES,
|
|
70807
|
-
normalize,
|
|
71137
|
+
normalize: normalize2,
|
|
70808
71138
|
resolve: resolve5,
|
|
70809
71139
|
resolveComponent,
|
|
70810
71140
|
equal,
|
|
@@ -80933,8 +81263,8 @@ var require_response = __commonJS({
|
|
|
80933
81263
|
function Response(req, onEnd, reject) {
|
|
80934
81264
|
http.ServerResponse.call(this, req);
|
|
80935
81265
|
if (req._lightMyRequest?.payloadAsStream) {
|
|
80936
|
-
const
|
|
80937
|
-
this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable({ read }) };
|
|
81266
|
+
const read2 = this.emit.bind(this, "drain");
|
|
81267
|
+
this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable({ read: read2 }) };
|
|
80938
81268
|
const signal = req._lightMyRequest.signal;
|
|
80939
81269
|
if (signal) {
|
|
80940
81270
|
addAbortSignal(signal, this._lightMyRequest.stream);
|
|
@@ -82938,9 +83268,1110 @@ ${body}`);
|
|
|
82938
83268
|
}
|
|
82939
83269
|
});
|
|
82940
83270
|
|
|
83271
|
+
// packages/agents/src/types.ts
|
|
83272
|
+
var init_types3 = __esm({
|
|
83273
|
+
"packages/agents/src/types.ts"() {
|
|
83274
|
+
"use strict";
|
|
83275
|
+
}
|
|
83276
|
+
});
|
|
83277
|
+
|
|
83278
|
+
// packages/agents/src/config.ts
|
|
83279
|
+
import { chmodSync, existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync3, renameSync as renameSync3, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
83280
|
+
import { dirname as dirname4, join as join6 } from "node:path";
|
|
83281
|
+
function read(home) {
|
|
83282
|
+
const path = configPath(home);
|
|
83283
|
+
if (!existsSync5(path)) return {};
|
|
83284
|
+
try {
|
|
83285
|
+
return JSON.parse(readFileSync3(path, "utf8"));
|
|
83286
|
+
} catch {
|
|
83287
|
+
throw new VeoError("invalid-arguments", `${path} is not valid JSON; fix or delete it`);
|
|
83288
|
+
}
|
|
83289
|
+
}
|
|
83290
|
+
function write(home, config2) {
|
|
83291
|
+
const path = configPath(home);
|
|
83292
|
+
mkdirSync4(dirname4(path), { recursive: true });
|
|
83293
|
+
const tmp = `${path}.tmp`;
|
|
83294
|
+
rmSync2(tmp, { force: true });
|
|
83295
|
+
writeFileSync2(tmp, JSON.stringify(config2, null, 2) + "\n", { mode: 384, flag: "wx" });
|
|
83296
|
+
chmodSync(tmp, 384);
|
|
83297
|
+
renameSync3(tmp, path);
|
|
83298
|
+
}
|
|
83299
|
+
function loadSettings(home, env = process.env) {
|
|
83300
|
+
const m = read(home).model ?? {};
|
|
83301
|
+
const str3 = (v) => typeof v === "string" ? v.trim() : "";
|
|
83302
|
+
const fromFile = str3(m.apiKey) || null;
|
|
83303
|
+
const fromEnv = env.OPENROUTER_API_KEY?.trim() || null;
|
|
83304
|
+
return {
|
|
83305
|
+
baseUrl: str3(m.baseUrl) || DEFAULT_BASE_URL,
|
|
83306
|
+
model: str3(m.model) || DEFAULT_MODEL,
|
|
83307
|
+
apiKey: fromFile ?? fromEnv,
|
|
83308
|
+
keySource: fromFile ? "config" : fromEnv ? "env" : null
|
|
83309
|
+
};
|
|
83310
|
+
}
|
|
83311
|
+
function publicSettings(s) {
|
|
83312
|
+
return {
|
|
83313
|
+
baseUrl: s.baseUrl,
|
|
83314
|
+
model: s.model,
|
|
83315
|
+
apiKeySet: s.apiKey !== null,
|
|
83316
|
+
// A hint only for keys long enough that four characters reveal nothing useful.
|
|
83317
|
+
apiKeyHint: s.apiKey && s.apiKey.length >= 12 ? s.apiKey.slice(-4) : null,
|
|
83318
|
+
keySource: s.keySource,
|
|
83319
|
+
configured: s.apiKey !== null
|
|
83320
|
+
};
|
|
83321
|
+
}
|
|
83322
|
+
function saveSettings(home, update, env = process.env) {
|
|
83323
|
+
const config2 = read(home);
|
|
83324
|
+
const m = { ...config2.model ?? {} };
|
|
83325
|
+
if (update.baseUrl !== void 0) {
|
|
83326
|
+
const url2 = update.baseUrl.trim();
|
|
83327
|
+
if (url2 && !/^https?:\/\/[^\s]+$/.test(url2))
|
|
83328
|
+
throw new VeoError("invalid-arguments", `base URL must start with http:// or https:// (got "${url2}")`, {
|
|
83329
|
+
fields: ["baseUrl"]
|
|
83330
|
+
});
|
|
83331
|
+
if (url2) m.baseUrl = url2.replace(/\/+$/, "");
|
|
83332
|
+
else delete m.baseUrl;
|
|
83333
|
+
}
|
|
83334
|
+
if (update.model !== void 0) {
|
|
83335
|
+
const model = update.model.trim();
|
|
83336
|
+
if (model) m.model = model;
|
|
83337
|
+
else delete m.model;
|
|
83338
|
+
}
|
|
83339
|
+
if (update.apiKey === null) delete m.apiKey;
|
|
83340
|
+
else if (update.apiKey !== void 0 && update.apiKey.trim()) m.apiKey = update.apiKey.trim();
|
|
83341
|
+
write(home, { ...config2, model: m });
|
|
83342
|
+
return loadSettings(home, env);
|
|
83343
|
+
}
|
|
83344
|
+
var DEFAULT_BASE_URL, DEFAULT_MODEL, configPath;
|
|
83345
|
+
var init_config = __esm({
|
|
83346
|
+
"packages/agents/src/config.ts"() {
|
|
83347
|
+
"use strict";
|
|
83348
|
+
init_src();
|
|
83349
|
+
DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
|
|
83350
|
+
DEFAULT_MODEL = "anthropic/claude-sonnet-5.5";
|
|
83351
|
+
configPath = (home) => join6(home, "config.json");
|
|
83352
|
+
}
|
|
83353
|
+
});
|
|
83354
|
+
|
|
83355
|
+
// packages/agents/src/grammar.ts
|
|
83356
|
+
function tool(ctx, name, args, run) {
|
|
83357
|
+
ctx.calls.push({ tool: name, args });
|
|
83358
|
+
return run();
|
|
83359
|
+
}
|
|
83360
|
+
function say(qualifiedName) {
|
|
83361
|
+
if (!qualifiedName.includes("<")) return qualifiedName;
|
|
83362
|
+
return qualifiedName.split(/\.(?![^<]*>)/).map((part) => {
|
|
83363
|
+
const m = /^<([a-z]+)(?::([^>]*))?>(?:#\d+)?$/.exec(part);
|
|
83364
|
+
if (!m) return part;
|
|
83365
|
+
if (m[1] === "callback") return `${m[2] ?? "anonymous"} callback`;
|
|
83366
|
+
if (m[1] === "module") return "top level";
|
|
83367
|
+
if (m[1] === "iife") return "immediately invoked function";
|
|
83368
|
+
return `${m[1]} function`;
|
|
83369
|
+
}).join(" \u203A ");
|
|
83370
|
+
}
|
|
83371
|
+
function parseTarget(raw) {
|
|
83372
|
+
let text = raw.trim().replace(/[?.!]+$/, "");
|
|
83373
|
+
let path;
|
|
83374
|
+
const inFile = /^(.+?)\s+(?:in|from)\s+([\w@./-]+\.[A-Za-z0-9]+)$/.exec(text);
|
|
83375
|
+
if (inFile) {
|
|
83376
|
+
text = inFile[1];
|
|
83377
|
+
path = inFile[2];
|
|
83378
|
+
}
|
|
83379
|
+
const name = text.replace(/^(?:the\s+)?(?:function|method|class)\s+/i, "").replace(/[`'"]/g, "").replace(/\(\)$/, "").trim();
|
|
83380
|
+
return path ? { name, path } : { name };
|
|
83381
|
+
}
|
|
83382
|
+
function resolveFunction(ctx, raw) {
|
|
83383
|
+
const { name, path } = parseTarget(raw);
|
|
83384
|
+
const filters = path ? { path } : void 0;
|
|
83385
|
+
const args = { label: "Function", text: name, ...filters ? { filters } : {}, limit: 20 };
|
|
83386
|
+
const r = tool(
|
|
83387
|
+
ctx,
|
|
83388
|
+
"search_nodes",
|
|
83389
|
+
args,
|
|
83390
|
+
() => ctx.engine.searchNodes({
|
|
83391
|
+
project: ctx.project,
|
|
83392
|
+
label: "Function",
|
|
83393
|
+
text: name,
|
|
83394
|
+
limit: 20,
|
|
83395
|
+
...filters ? { filters } : {}
|
|
83396
|
+
})
|
|
83397
|
+
);
|
|
83398
|
+
const lower = name.toLowerCase();
|
|
83399
|
+
const exact = r.results.filter(
|
|
83400
|
+
(h) => h.name.toLowerCase() === lower || h.name.toLowerCase().split(".").pop() === lower
|
|
83401
|
+
);
|
|
83402
|
+
const here = ctx.file ? exact.filter((h) => h.id.startsWith(`${ctx.file}:`)) : [];
|
|
83403
|
+
const full = exact.filter((h) => h.name.toLowerCase() === lower);
|
|
83404
|
+
const pick2 = here.length === 1 ? here : full.length > 0 ? full : exact;
|
|
83405
|
+
if (pick2.length === 1) return { kind: "one", hit: pick2[0], name };
|
|
83406
|
+
if (pick2.length > 1) return { kind: "many", hits: pick2, total: pick2.length, name };
|
|
83407
|
+
return { kind: "none", near: r.results.slice(0, 8), name };
|
|
83408
|
+
}
|
|
83409
|
+
function resolveFile(ctx, raw) {
|
|
83410
|
+
const name = raw.trim().replace(/[?.!`'"]+$/g, "").replace(/^[`'"]|^(?:the\s+)?file\s+/gi, "");
|
|
83411
|
+
const r = tool(
|
|
83412
|
+
ctx,
|
|
83413
|
+
"search_nodes",
|
|
83414
|
+
{ label: "File", text: name, limit: 20 },
|
|
83415
|
+
() => ctx.engine.searchNodes({ project: ctx.project, label: "File", text: name, limit: 20 })
|
|
83416
|
+
);
|
|
83417
|
+
const lower = name.toLowerCase();
|
|
83418
|
+
const exact = r.results.filter(
|
|
83419
|
+
(h) => h.path.toLowerCase() === lower || h.path.toLowerCase().endsWith(`/${lower}`)
|
|
83420
|
+
);
|
|
83421
|
+
if (exact.length === 1) return { kind: "one", hit: exact[0] };
|
|
83422
|
+
if (exact.length > 1) return { kind: "many", hits: exact, name };
|
|
83423
|
+
if (r.results.length === 1) return { kind: "one", hit: r.results[0] };
|
|
83424
|
+
return { kind: r.results.length ? "many" : "none", hits: r.results.slice(0, 10), name };
|
|
83425
|
+
}
|
|
83426
|
+
function unresolvedName(ctx, r, verb) {
|
|
83427
|
+
if (r.kind === "none" && r.near.length === 0 && ctx.fallThrough) return null;
|
|
83428
|
+
if (r.kind === "many")
|
|
83429
|
+
return {
|
|
83430
|
+
summary: `"${r.name}" matches ${plural2(r.hits.length, "function")}; which one did you mean?`,
|
|
83431
|
+
results: r.hits.map(fnItem),
|
|
83432
|
+
suggestions: r.hits.slice(0, 3).map((h) => `${verb} ${h.name} in ${h.path}`)
|
|
83433
|
+
};
|
|
83434
|
+
return {
|
|
83435
|
+
summary: `No function named "${r.name}" in the last analysis.`,
|
|
83436
|
+
results: r.near.map(fnItem),
|
|
83437
|
+
...r.near.length ? { note: "Functions with similar names are listed." } : {}
|
|
83438
|
+
};
|
|
83439
|
+
}
|
|
83440
|
+
function normalize(question) {
|
|
83441
|
+
return question.trim().replace(/\s+/g, " ").replace(/^(?:please\s+|can you\s+|could you\s+)?(?:tell me\s+|show me\s+(?=the\s+))?/i, "").replace(/[?!.\s]+$/, "");
|
|
83442
|
+
}
|
|
83443
|
+
function answerWithGrammar(engine, project2, question, options = {}) {
|
|
83444
|
+
const text = normalize(question);
|
|
83445
|
+
for (const intent of INTENTS)
|
|
83446
|
+
for (const pattern of intent.patterns) {
|
|
83447
|
+
const m = text.match(new RegExp(pattern.source, `${pattern.flags.replace("i", "")}i`));
|
|
83448
|
+
if (!m) continue;
|
|
83449
|
+
const ctx = {
|
|
83450
|
+
engine,
|
|
83451
|
+
project: project2,
|
|
83452
|
+
calls: [],
|
|
83453
|
+
fallThrough: options.fallThrough ?? false,
|
|
83454
|
+
...options.file ? { file: options.file } : {}
|
|
83455
|
+
};
|
|
83456
|
+
const body = intent.handle(ctx, m, question);
|
|
83457
|
+
if (body === null) return null;
|
|
83458
|
+
return { question, via: "grammar", intent: intent.name, toolCalls: ctx.calls, ...body };
|
|
83459
|
+
}
|
|
83460
|
+
return null;
|
|
83461
|
+
}
|
|
83462
|
+
var IN_FILE_NOTE, target, plural2, fnItem, fileItem, callers, callees, definition, fileFunctions, fileQuestions, TOP, largestFiles, mostCalled, questionsByReason, filesByQuestions, overview, REASONS, STATUS_WORDS, LANGUAGE_WORDS, INTENTS, EXAMPLES, HELP_SUMMARY;
|
|
83463
|
+
var init_grammar = __esm({
|
|
83464
|
+
"packages/agents/src/grammar.ts"() {
|
|
83465
|
+
"use strict";
|
|
83466
|
+
IN_FILE_NOTE = "Calls are linked within each file for now; calls from other files are not shown yet.";
|
|
83467
|
+
target = (m) => m[2] ? `${m[1]} in ${m[2]}` : m[1];
|
|
83468
|
+
plural2 = (n, one, many = `${one}s`) => `${n.toLocaleString("en-US")} ${n === 1 ? one : many}`;
|
|
83469
|
+
fnItem = (h) => ({
|
|
83470
|
+
kind: "function",
|
|
83471
|
+
id: h.id,
|
|
83472
|
+
label: h.name,
|
|
83473
|
+
detail: `${h.path}:${h.evidence?.span.start.line ?? "?"} \xB7 ${plural2(h.callers ?? 0, "caller")} \xB7 ${plural2(h.callees ?? 0, "callee")}`,
|
|
83474
|
+
file: h.id.slice(0, h.id.lastIndexOf(":")),
|
|
83475
|
+
path: h.path,
|
|
83476
|
+
...h.evidence ? { line: h.evidence.span.start.line } : {}
|
|
83477
|
+
});
|
|
83478
|
+
fileItem = (h) => ({
|
|
83479
|
+
kind: "file",
|
|
83480
|
+
id: h.id,
|
|
83481
|
+
label: h.path,
|
|
83482
|
+
detail: `${plural2(h.functions ?? 0, "function")}${h.status && h.status !== "analyzed" ? ` \xB7 ${h.status}` : ""}`,
|
|
83483
|
+
file: h.id,
|
|
83484
|
+
path: h.path
|
|
83485
|
+
});
|
|
83486
|
+
callers = (ctx, m) => {
|
|
83487
|
+
const r = resolveFunction(ctx, target(m));
|
|
83488
|
+
if (r.kind !== "one") return unresolvedName(ctx, r, "who calls");
|
|
83489
|
+
const out = tool(
|
|
83490
|
+
ctx,
|
|
83491
|
+
"list_calls",
|
|
83492
|
+
{ function: r.hit.id, direction: "in" },
|
|
83493
|
+
() => ctx.engine.listCalls({ project: ctx.project, function: r.hit.id, direction: "in" })
|
|
83494
|
+
);
|
|
83495
|
+
const fns = new Set(out.calls.map((c) => c.function.id));
|
|
83496
|
+
return {
|
|
83497
|
+
summary: out.calls.length === 0 ? `No calls to ${say(r.hit.name)} were found.` : `${say(r.hit.name)} is called ${plural2(out.calls.length, "time")} by ${plural2(fns.size, "function")}.`,
|
|
83498
|
+
// The caveat matters most when nothing in the file calls it.
|
|
83499
|
+
...out.calls.length === 0 ? { note: IN_FILE_NOTE } : {},
|
|
83500
|
+
results: [
|
|
83501
|
+
fnItem(r.hit),
|
|
83502
|
+
...out.calls.map((c) => ({
|
|
83503
|
+
kind: "call",
|
|
83504
|
+
id: c.id,
|
|
83505
|
+
// The caller; the row's kind already says it is a call to the function asked about.
|
|
83506
|
+
label: c.function.qualifiedName,
|
|
83507
|
+
...c.function.line !== void 0 ? { fnLine: c.function.line } : {},
|
|
83508
|
+
detail: `${c.function.path}:${c.evidence.span.start.line}`,
|
|
83509
|
+
file: c.evidence.file,
|
|
83510
|
+
path: c.function.path,
|
|
83511
|
+
line: c.evidence.span.start.line
|
|
83512
|
+
}))
|
|
83513
|
+
],
|
|
83514
|
+
suggestions: [`what does ${r.hit.name} call`]
|
|
83515
|
+
};
|
|
83516
|
+
};
|
|
83517
|
+
callees = (ctx, m) => {
|
|
83518
|
+
const r = resolveFunction(ctx, target(m));
|
|
83519
|
+
if (r.kind !== "one") return unresolvedName(ctx, r, "what does");
|
|
83520
|
+
const out = tool(
|
|
83521
|
+
ctx,
|
|
83522
|
+
"list_calls",
|
|
83523
|
+
{ function: r.hit.id, direction: "out" },
|
|
83524
|
+
() => ctx.engine.listCalls({ project: ctx.project, function: r.hit.id, direction: "out" })
|
|
83525
|
+
);
|
|
83526
|
+
const file2 = r.hit.id.slice(0, r.hit.id.lastIndexOf(":"));
|
|
83527
|
+
const sites = tool(
|
|
83528
|
+
ctx,
|
|
83529
|
+
"list_unresolved_sites",
|
|
83530
|
+
{ file: file2, includeAll: true },
|
|
83531
|
+
() => ctx.engine.listUnresolvedSites({ project: ctx.project, file: file2, includeAll: true })
|
|
83532
|
+
).sites.filter((s) => s.enclosingFn === r.hit.id);
|
|
83533
|
+
return {
|
|
83534
|
+
summary: `${say(r.hit.name)} makes ${plural2(out.calls.length, "resolved call")}${sites.length ? ` and ${plural2(sites.length, "unresolved call site")}` : ""}.`,
|
|
83535
|
+
// The caveat matters most when nothing in the file calls it.
|
|
83536
|
+
...out.calls.length === 0 ? { note: IN_FILE_NOTE } : {},
|
|
83537
|
+
results: [
|
|
83538
|
+
fnItem(r.hit),
|
|
83539
|
+
...out.calls.map((c) => ({
|
|
83540
|
+
kind: "call",
|
|
83541
|
+
id: c.id,
|
|
83542
|
+
label: c.function.qualifiedName,
|
|
83543
|
+
...c.function.line !== void 0 ? { fnLine: c.function.line } : {},
|
|
83544
|
+
detail: `${r.hit.path}:${c.evidence.span.start.line}`,
|
|
83545
|
+
file: c.evidence.file,
|
|
83546
|
+
path: r.hit.path,
|
|
83547
|
+
line: c.evidence.span.start.line
|
|
83548
|
+
})),
|
|
83549
|
+
...sites.map((s) => ({
|
|
83550
|
+
kind: "site",
|
|
83551
|
+
id: s.id,
|
|
83552
|
+
label: `? ${s.expression}`,
|
|
83553
|
+
detail: `${r.hit.path}:${s.evidence.span.start.line} \xB7 ${REASONS[s.reason] ?? s.reason}`,
|
|
83554
|
+
file: s.file,
|
|
83555
|
+
path: r.hit.path,
|
|
83556
|
+
line: s.evidence.span.start.line
|
|
83557
|
+
}))
|
|
83558
|
+
],
|
|
83559
|
+
suggestions: [`who calls ${r.hit.name}`]
|
|
83560
|
+
};
|
|
83561
|
+
};
|
|
83562
|
+
definition = (ctx, m) => {
|
|
83563
|
+
const r = resolveFunction(ctx, target(m));
|
|
83564
|
+
if (r.kind === "one")
|
|
83565
|
+
return {
|
|
83566
|
+
summary: `${say(r.hit.name)} is defined at ${r.hit.path}:${r.hit.evidence?.span.start.line ?? "?"}.`,
|
|
83567
|
+
results: [fnItem(r.hit)],
|
|
83568
|
+
suggestions: [`who calls ${r.hit.name}`, `what does ${r.hit.name} call`]
|
|
83569
|
+
};
|
|
83570
|
+
if (r.kind === "many")
|
|
83571
|
+
return {
|
|
83572
|
+
summary: `"${r.name}" is defined in ${plural2(r.hits.length, "place")}.`,
|
|
83573
|
+
results: r.hits.map(fnItem)
|
|
83574
|
+
};
|
|
83575
|
+
const f = resolveFile(ctx, m[1]);
|
|
83576
|
+
if (f.kind === "one")
|
|
83577
|
+
return {
|
|
83578
|
+
summary: `${f.hit.path} is a file with ${plural2(f.hit.functions ?? 0, "function")}.`,
|
|
83579
|
+
results: [fileItem(f.hit)]
|
|
83580
|
+
};
|
|
83581
|
+
return unresolvedName(ctx, r, "where is");
|
|
83582
|
+
};
|
|
83583
|
+
fileFunctions = (ctx, m) => {
|
|
83584
|
+
const f = resolveFile(ctx, m[1]);
|
|
83585
|
+
if (f.kind === "none" && ctx.fallThrough) return null;
|
|
83586
|
+
if (f.kind !== "one")
|
|
83587
|
+
return {
|
|
83588
|
+
summary: f.kind === "many" ? `"${f.name}" matches ${plural2(f.hits.length, "file")}; which one?` : `No file matching "${f.name}".`,
|
|
83589
|
+
results: f.hits.map(fileItem)
|
|
83590
|
+
};
|
|
83591
|
+
const o = tool(
|
|
83592
|
+
ctx,
|
|
83593
|
+
"file_outline",
|
|
83594
|
+
{ file: f.hit.id },
|
|
83595
|
+
() => ctx.engine.fileOutline({ project: ctx.project, file: f.hit.id })
|
|
83596
|
+
);
|
|
83597
|
+
return {
|
|
83598
|
+
summary: `${f.hit.path} defines ${plural2(o.functions.length, "function")} with ${plural2(o.calls, "call")} between them and ${plural2(o.open, "open question")}.`,
|
|
83599
|
+
results: [
|
|
83600
|
+
fileItem(f.hit),
|
|
83601
|
+
...o.functions.map((fn) => ({
|
|
83602
|
+
kind: "function",
|
|
83603
|
+
id: fn.id,
|
|
83604
|
+
label: fn.qualifiedName,
|
|
83605
|
+
detail: `line ${fn.evidence.span.start.line} \xB7 ${plural2(fn.callers, "caller")} \xB7 ${plural2(fn.callees, "callee")}${fn.unresolved ? ` \xB7 ${fn.unresolved} unresolved` : ""}`,
|
|
83606
|
+
file: f.hit.id,
|
|
83607
|
+
path: f.hit.path,
|
|
83608
|
+
line: fn.evidence.span.start.line
|
|
83609
|
+
}))
|
|
83610
|
+
],
|
|
83611
|
+
suggestions: [`open questions in ${f.hit.path}`]
|
|
83612
|
+
};
|
|
83613
|
+
};
|
|
83614
|
+
fileQuestions = (ctx, m) => {
|
|
83615
|
+
const f = resolveFile(ctx, m[1]);
|
|
83616
|
+
if (f.kind === "none" && ctx.fallThrough) return null;
|
|
83617
|
+
if (f.kind !== "one")
|
|
83618
|
+
return {
|
|
83619
|
+
summary: f.kind === "many" ? `"${f.name}" matches ${plural2(f.hits.length, "file")}; which one?` : `No file matching "${f.name}".`,
|
|
83620
|
+
results: f.hits.map(fileItem)
|
|
83621
|
+
};
|
|
83622
|
+
const sites = tool(
|
|
83623
|
+
ctx,
|
|
83624
|
+
"list_unresolved_sites",
|
|
83625
|
+
{ file: f.hit.id },
|
|
83626
|
+
() => ctx.engine.listUnresolvedSites({ project: ctx.project, file: f.hit.id })
|
|
83627
|
+
).sites;
|
|
83628
|
+
return {
|
|
83629
|
+
summary: `${f.hit.path} has ${plural2(sites.length, "open question")} (call sites that could not be resolved, such as dynamic dispatch).`,
|
|
83630
|
+
results: sites.map((s) => ({
|
|
83631
|
+
kind: "site",
|
|
83632
|
+
id: s.id,
|
|
83633
|
+
label: `? ${s.expression}`,
|
|
83634
|
+
detail: `line ${s.evidence.span.start.line} \xB7 ${REASONS[s.reason] ?? s.reason}`,
|
|
83635
|
+
file: s.file,
|
|
83636
|
+
path: f.hit.path,
|
|
83637
|
+
line: s.evidence.span.start.line
|
|
83638
|
+
}))
|
|
83639
|
+
};
|
|
83640
|
+
};
|
|
83641
|
+
TOP = 10;
|
|
83642
|
+
largestFiles = (ctx) => {
|
|
83643
|
+
const r = tool(
|
|
83644
|
+
ctx,
|
|
83645
|
+
"aggregate",
|
|
83646
|
+
{ label: "Function", groupBy: "file" },
|
|
83647
|
+
() => ctx.engine.aggregate({ project: ctx.project, label: "Function", groupBy: "file" })
|
|
83648
|
+
);
|
|
83649
|
+
const top = r.groups.slice(0, TOP);
|
|
83650
|
+
return {
|
|
83651
|
+
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.",
|
|
83652
|
+
results: top.map((g) => ({
|
|
83653
|
+
kind: "file",
|
|
83654
|
+
id: g.key,
|
|
83655
|
+
label: g.name ?? g.key,
|
|
83656
|
+
detail: plural2(g.count, "function"),
|
|
83657
|
+
file: g.key,
|
|
83658
|
+
path: g.name ?? g.key,
|
|
83659
|
+
count: g.count
|
|
83660
|
+
}))
|
|
83661
|
+
};
|
|
83662
|
+
};
|
|
83663
|
+
mostCalled = (ctx) => {
|
|
83664
|
+
const r = tool(
|
|
83665
|
+
ctx,
|
|
83666
|
+
"aggregate",
|
|
83667
|
+
{ label: "CALLS", groupBy: "to" },
|
|
83668
|
+
() => ctx.engine.aggregate({ project: ctx.project, label: "CALLS", groupBy: "to" })
|
|
83669
|
+
);
|
|
83670
|
+
const top = r.groups.slice(0, TOP);
|
|
83671
|
+
return {
|
|
83672
|
+
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.",
|
|
83673
|
+
note: IN_FILE_NOTE,
|
|
83674
|
+
results: top.map((g) => {
|
|
83675
|
+
const file2 = g.key.slice(0, g.key.lastIndexOf(":"));
|
|
83676
|
+
return {
|
|
83677
|
+
kind: "function",
|
|
83678
|
+
id: g.key,
|
|
83679
|
+
label: g.name ?? g.key,
|
|
83680
|
+
detail: `${plural2(g.count, "call")} \xB7 ${file2.slice(file2.indexOf(":") + 1)}`,
|
|
83681
|
+
file: file2,
|
|
83682
|
+
path: file2.slice(file2.indexOf(":") + 1),
|
|
83683
|
+
count: g.count
|
|
83684
|
+
};
|
|
83685
|
+
})
|
|
83686
|
+
};
|
|
83687
|
+
};
|
|
83688
|
+
questionsByReason = (ctx) => {
|
|
83689
|
+
const r = tool(
|
|
83690
|
+
ctx,
|
|
83691
|
+
"aggregate",
|
|
83692
|
+
{ label: "UnresolvedCallSite", groupBy: "reason", filters: { open: true } },
|
|
83693
|
+
() => ctx.engine.aggregate({
|
|
83694
|
+
project: ctx.project,
|
|
83695
|
+
label: "UnresolvedCallSite",
|
|
83696
|
+
groupBy: "reason",
|
|
83697
|
+
filters: { open: true }
|
|
83698
|
+
})
|
|
83699
|
+
);
|
|
83700
|
+
return {
|
|
83701
|
+
summary: `${plural2(r.total, "open question")}: call sites that could not be resolved, by reason.`,
|
|
83702
|
+
results: r.groups.map((g) => ({
|
|
83703
|
+
kind: "group",
|
|
83704
|
+
id: g.key,
|
|
83705
|
+
label: g.key,
|
|
83706
|
+
detail: plural2(g.count, "site"),
|
|
83707
|
+
count: g.count
|
|
83708
|
+
})),
|
|
83709
|
+
suggestions: ["files with the most open questions"]
|
|
83710
|
+
};
|
|
83711
|
+
};
|
|
83712
|
+
filesByQuestions = (ctx) => {
|
|
83713
|
+
const r = tool(
|
|
83714
|
+
ctx,
|
|
83715
|
+
"aggregate",
|
|
83716
|
+
{ label: "UnresolvedCallSite", groupBy: "file", filters: { open: true } },
|
|
83717
|
+
() => ctx.engine.aggregate({
|
|
83718
|
+
project: ctx.project,
|
|
83719
|
+
label: "UnresolvedCallSite",
|
|
83720
|
+
groupBy: "file",
|
|
83721
|
+
filters: { open: true }
|
|
83722
|
+
})
|
|
83723
|
+
);
|
|
83724
|
+
const top = r.groups.slice(0, TOP);
|
|
83725
|
+
return {
|
|
83726
|
+
summary: top.length ? `${top[0].name ?? top[0].key} has the most open questions (${top[0].count}).` : "There are no open questions.",
|
|
83727
|
+
results: top.map((g) => ({
|
|
83728
|
+
kind: "file",
|
|
83729
|
+
id: g.key,
|
|
83730
|
+
label: g.name ?? g.key,
|
|
83731
|
+
detail: plural2(g.count, "open question"),
|
|
83732
|
+
file: g.key,
|
|
83733
|
+
path: g.name ?? g.key,
|
|
83734
|
+
count: g.count
|
|
83735
|
+
}))
|
|
83736
|
+
};
|
|
83737
|
+
};
|
|
83738
|
+
overview = (ctx) => {
|
|
83739
|
+
const files = tool(
|
|
83740
|
+
ctx,
|
|
83741
|
+
"aggregate",
|
|
83742
|
+
{ label: "File", groupBy: "status" },
|
|
83743
|
+
() => ctx.engine.aggregate({ project: ctx.project, label: "File", groupBy: "status" })
|
|
83744
|
+
);
|
|
83745
|
+
const langs = tool(
|
|
83746
|
+
ctx,
|
|
83747
|
+
"aggregate",
|
|
83748
|
+
{ label: "File", groupBy: "language" },
|
|
83749
|
+
() => ctx.engine.aggregate({ project: ctx.project, label: "File", groupBy: "language" })
|
|
83750
|
+
);
|
|
83751
|
+
const fns = tool(
|
|
83752
|
+
ctx,
|
|
83753
|
+
"aggregate",
|
|
83754
|
+
{ label: "Function", groupBy: "kind" },
|
|
83755
|
+
() => ctx.engine.aggregate({ project: ctx.project, label: "Function", groupBy: "kind" })
|
|
83756
|
+
);
|
|
83757
|
+
const calls = tool(
|
|
83758
|
+
ctx,
|
|
83759
|
+
"aggregate",
|
|
83760
|
+
{ label: "CALLS", groupBy: "resolution" },
|
|
83761
|
+
() => ctx.engine.aggregate({ project: ctx.project, label: "CALLS", groupBy: "resolution" })
|
|
83762
|
+
);
|
|
83763
|
+
const open2 = tool(
|
|
83764
|
+
ctx,
|
|
83765
|
+
"aggregate",
|
|
83766
|
+
{ label: "UnresolvedCallSite", groupBy: "reason", filters: { open: true } },
|
|
83767
|
+
() => ctx.engine.aggregate({
|
|
83768
|
+
project: ctx.project,
|
|
83769
|
+
label: "UnresolvedCallSite",
|
|
83770
|
+
groupBy: "reason",
|
|
83771
|
+
filters: { open: true }
|
|
83772
|
+
})
|
|
83773
|
+
);
|
|
83774
|
+
const group = (id, label, count) => ({
|
|
83775
|
+
kind: "group",
|
|
83776
|
+
id,
|
|
83777
|
+
label,
|
|
83778
|
+
count
|
|
83779
|
+
});
|
|
83780
|
+
const n = (x) => x.toLocaleString("en-US");
|
|
83781
|
+
return {
|
|
83782
|
+
summary: `${plural2(files.total, "file")}, ${plural2(fns.total, "function")}, ${plural2(calls.total, "call")} and ${plural2(open2.total, "open question")}.`,
|
|
83783
|
+
results: [
|
|
83784
|
+
...files.groups.map(
|
|
83785
|
+
(g) => group(
|
|
83786
|
+
`files:${g.key}`,
|
|
83787
|
+
`${n(g.count)} ${g.count === 1 ? "file" : "files"} ${STATUS_WORDS[g.key] ?? g.key}`,
|
|
83788
|
+
g.count
|
|
83789
|
+
)
|
|
83790
|
+
),
|
|
83791
|
+
...langs.groups.map(
|
|
83792
|
+
(g) => group(
|
|
83793
|
+
`language:${g.key}`,
|
|
83794
|
+
`${n(g.count)} ${LANGUAGE_WORDS[g.key] ?? g.key} ${g.count === 1 ? "file" : "files"}`,
|
|
83795
|
+
g.count
|
|
83796
|
+
)
|
|
83797
|
+
),
|
|
83798
|
+
...open2.groups.map(
|
|
83799
|
+
(g) => group(
|
|
83800
|
+
`open:${g.key}`,
|
|
83801
|
+
`${n(g.count)} open ${g.count === 1 ? "question" : "questions"}: ${g.key.replace(/-/g, " ")}`,
|
|
83802
|
+
g.count
|
|
83803
|
+
)
|
|
83804
|
+
)
|
|
83805
|
+
],
|
|
83806
|
+
suggestions: ["largest files", "most called functions", "open questions by reason"]
|
|
83807
|
+
};
|
|
83808
|
+
};
|
|
83809
|
+
REASONS = {
|
|
83810
|
+
"dynamic-dispatch": "type unknown",
|
|
83811
|
+
reflection: "reflection",
|
|
83812
|
+
"imported-symbol": "imported",
|
|
83813
|
+
"runtime-global": "built-in"
|
|
83814
|
+
};
|
|
83815
|
+
STATUS_WORDS = {
|
|
83816
|
+
analyzed: "analyzed",
|
|
83817
|
+
degraded: "partly analyzed",
|
|
83818
|
+
not_analyzed: "not analyzed"
|
|
83819
|
+
};
|
|
83820
|
+
LANGUAGE_WORDS = {
|
|
83821
|
+
typescript: "TypeScript",
|
|
83822
|
+
tsx: "TSX",
|
|
83823
|
+
javascript: "JavaScript",
|
|
83824
|
+
jsx: "JSX",
|
|
83825
|
+
python: "Python",
|
|
83826
|
+
go: "Go",
|
|
83827
|
+
rust: "Rust",
|
|
83828
|
+
none: "other"
|
|
83829
|
+
};
|
|
83830
|
+
INTENTS = [
|
|
83831
|
+
{
|
|
83832
|
+
name: "help",
|
|
83833
|
+
patterns: [/^(?:help|\?|what can (?:i|you) (?:ask|do)|what questions can i ask)$/],
|
|
83834
|
+
handle: () => ({ summary: HELP_SUMMARY, results: [], suggestions: EXAMPLES })
|
|
83835
|
+
},
|
|
83836
|
+
{
|
|
83837
|
+
name: "callers",
|
|
83838
|
+
patterns: [
|
|
83839
|
+
/^(?:who|what|which functions?)\s+(?:calls|uses|invokes)\s+(.+)$/,
|
|
83840
|
+
/^(?:show\s+|list\s+)?(?:the\s+)?callers\s+(?:of|for|to)\s+(.+)$/,
|
|
83841
|
+
/^where\s+is\s+(.+?)\s+(?:called|used|invoked)\s+(?:in|from)\s+([\w@./-]+\.[a-z0-9]+)$/,
|
|
83842
|
+
/^where\s+is\s+(.+?)\s+(?:called|used|invoked)(?:\s+from)?$/
|
|
83843
|
+
],
|
|
83844
|
+
handle: callers
|
|
83845
|
+
},
|
|
83846
|
+
{
|
|
83847
|
+
name: "callees",
|
|
83848
|
+
patterns: [
|
|
83849
|
+
/^what\s+does\s+(.+?)\s+(?:call|invoke|use)$/,
|
|
83850
|
+
/^(?:show\s+|list\s+)?(?:the\s+)?(?:callees|calls)\s+(?:of|from|made by|in)\s+(.+)$/,
|
|
83851
|
+
/^(?:which|what)\s+functions\s+does\s+(.+?)\s+call$/
|
|
83852
|
+
],
|
|
83853
|
+
handle: callees
|
|
83854
|
+
},
|
|
83855
|
+
{
|
|
83856
|
+
name: "open-questions-in-file",
|
|
83857
|
+
patterns: [/^(?:open questions|unresolved(?:\s+calls|\s+call\s+sites)?)\s+(?:in|for)\s+(.+)$/],
|
|
83858
|
+
handle: fileQuestions
|
|
83859
|
+
},
|
|
83860
|
+
{
|
|
83861
|
+
name: "files-by-open-questions",
|
|
83862
|
+
patterns: [
|
|
83863
|
+
/^(?:which\s+)?files?\s+(?:with|have)\s+(?:the\s+)?most\s+(?:open\s+questions|unresolved(?:\s+calls|\s+call\s+sites)?)$/
|
|
83864
|
+
],
|
|
83865
|
+
handle: filesByQuestions
|
|
83866
|
+
},
|
|
83867
|
+
{
|
|
83868
|
+
name: "open-questions",
|
|
83869
|
+
patterns: [
|
|
83870
|
+
/^(?:open questions|unresolved(?:\s+calls|\s+call\s+sites)?)(?:\s+by\s+reason)?$/,
|
|
83871
|
+
/what\s+(?:could(?:n'?t| not)|can'?t|cannot)\s+(?:be\s+)?resolve/
|
|
83872
|
+
],
|
|
83873
|
+
handle: questionsByReason
|
|
83874
|
+
},
|
|
83875
|
+
{
|
|
83876
|
+
name: "largest-files",
|
|
83877
|
+
patterns: [
|
|
83878
|
+
/^(?:(?:what|which)\s+are\s+)?(?:the\s+)?(?:largest|biggest)\s+files?$/,
|
|
83879
|
+
/^(?:which\s+)?files?\s+(?:with|have)\s+(?:the\s+)?most\s+functions$/
|
|
83880
|
+
],
|
|
83881
|
+
handle: largestFiles
|
|
83882
|
+
},
|
|
83883
|
+
{
|
|
83884
|
+
name: "most-called",
|
|
83885
|
+
patterns: [
|
|
83886
|
+
/^(?:(?:what|which)\s+are\s+)?(?:the\s+)?most[-\s]?(?:called|used)(?:\s+functions)?$/,
|
|
83887
|
+
/^(?:the\s+)?hot\s?spots?$/,
|
|
83888
|
+
/^(?:which|what)\s+functions?\s+(?:is|are)\s+called\s+the\s+most$/
|
|
83889
|
+
],
|
|
83890
|
+
handle: mostCalled
|
|
83891
|
+
},
|
|
83892
|
+
{
|
|
83893
|
+
name: "file-functions",
|
|
83894
|
+
patterns: [
|
|
83895
|
+
/^(?:what|which)\s+functions\s+(?:are\s+)?(?:in|defined in)\s+(.+)$/,
|
|
83896
|
+
/^(?:outline|functions)\s+(?:of|in)\s+(.+)$/,
|
|
83897
|
+
/^what(?:'s| is)\s+in\s+(.+)$/
|
|
83898
|
+
],
|
|
83899
|
+
handle: fileFunctions
|
|
83900
|
+
},
|
|
83901
|
+
{
|
|
83902
|
+
name: "overview",
|
|
83903
|
+
patterns: [
|
|
83904
|
+
/^(?:stats|statistics|summary|overview|project (?:stats|summary|overview))$/,
|
|
83905
|
+
/^how\s+(?:big|large)\s+is\s+(?:this|the)\s+(?:project|code(?:base)?|repo(?:sitory)?)$/,
|
|
83906
|
+
/^how\s+many\s+(?:files|functions|calls)(?:\s+(?:are\s+there|does\s+(?:it|this\s+project)\s+have))?(?:\s+in\s+(?:this|the)\s+(?:project|code(?:base)?|repo(?:sitory)?))?$/
|
|
83907
|
+
],
|
|
83908
|
+
handle: overview
|
|
83909
|
+
},
|
|
83910
|
+
{
|
|
83911
|
+
name: "definition",
|
|
83912
|
+
patterns: [
|
|
83913
|
+
/^where\s+is\s+(.+?)\s+(?:defined|declared|implemented)\s+in\s+([\w@./-]+\.[a-z0-9]+)$/,
|
|
83914
|
+
/^where\s+is\s+(.+?)\s+(?:defined|declared|implemented)$/,
|
|
83915
|
+
/^(?:find|show|go to|open|locate)\s+(?:me\s+)?(.+)$/,
|
|
83916
|
+
/^where\s+is\s+(.+)$/
|
|
83917
|
+
],
|
|
83918
|
+
handle: definition
|
|
83919
|
+
}
|
|
83920
|
+
];
|
|
83921
|
+
EXAMPLES = [
|
|
83922
|
+
"overview",
|
|
83923
|
+
"largest files",
|
|
83924
|
+
"most called functions",
|
|
83925
|
+
"open questions by reason",
|
|
83926
|
+
"who calls <function>",
|
|
83927
|
+
"what does <function> call",
|
|
83928
|
+
"where is <function> defined",
|
|
83929
|
+
"functions in <file>",
|
|
83930
|
+
"open questions in <file>"
|
|
83931
|
+
];
|
|
83932
|
+
HELP_SUMMARY = "Without a model, Ask understands these questions; with a model configured in Settings, it answers anything about the analyzed code.";
|
|
83933
|
+
}
|
|
83934
|
+
});
|
|
83935
|
+
|
|
83936
|
+
// packages/agents/src/chat.ts
|
|
83937
|
+
function toolDefinitions() {
|
|
83938
|
+
return CHAT_TOOLS.map((name) => {
|
|
83939
|
+
const { project: _project, ...input2 } = TOOLS[name].input;
|
|
83940
|
+
return {
|
|
83941
|
+
type: "function",
|
|
83942
|
+
function: {
|
|
83943
|
+
name,
|
|
83944
|
+
description: TOOLS[name].description,
|
|
83945
|
+
parameters: external_exports.toJSONSchema(external_exports.object(input2))
|
|
83946
|
+
}
|
|
83947
|
+
};
|
|
83948
|
+
});
|
|
83949
|
+
}
|
|
83950
|
+
function systemPrompt(project2) {
|
|
83951
|
+
return [
|
|
83952
|
+
"You answer questions about a codebase using veoflow's knowledge graph of it.",
|
|
83953
|
+
`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
|
+
"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
|
+
"Look things up with the tools; 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.",
|
|
83956
|
+
"Cite locations exactly as path:line from tool results (for example src/cart.ts:42).",
|
|
83957
|
+
"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
|
+
].join("\n");
|
|
83959
|
+
}
|
|
83960
|
+
async function complete(settings, body, fetchImpl) {
|
|
83961
|
+
let response;
|
|
83962
|
+
try {
|
|
83963
|
+
response = await fetchImpl(`${settings.baseUrl}/chat/completions`, {
|
|
83964
|
+
method: "POST",
|
|
83965
|
+
headers: {
|
|
83966
|
+
"content-type": "application/json",
|
|
83967
|
+
authorization: `Bearer ${settings.apiKey ?? ""}`,
|
|
83968
|
+
// OpenRouter's optional attribution headers.
|
|
83969
|
+
"x-title": "veoflow",
|
|
83970
|
+
"http-referer": "https://github.com/mudit70/veoapp"
|
|
83971
|
+
},
|
|
83972
|
+
body: JSON.stringify({ model: settings.model, temperature: 0, ...body }),
|
|
83973
|
+
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
83974
|
+
});
|
|
83975
|
+
} catch (e) {
|
|
83976
|
+
const name = e.name;
|
|
83977
|
+
throw new ModelError(
|
|
83978
|
+
name === "TimeoutError" ? "model-timeout" : "model-unreachable",
|
|
83979
|
+
name === "TimeoutError" ? `The model did not answer within ${TIMEOUT_MS / 1e3} seconds. Try again, or choose a faster model.` : `Couldn't reach ${settings.baseUrl}. Check the base URL and that the server is running.`
|
|
83980
|
+
);
|
|
83981
|
+
}
|
|
83982
|
+
const text = await response.text();
|
|
83983
|
+
let json2 = {};
|
|
83984
|
+
try {
|
|
83985
|
+
json2 = JSON.parse(text);
|
|
83986
|
+
} catch {
|
|
83987
|
+
}
|
|
83988
|
+
if (!response.ok) {
|
|
83989
|
+
const detail = json2.error?.message ?? text.slice(0, 200);
|
|
83990
|
+
const code = response.status === 401 || response.status === 403 ? "model-auth" : response.status === 429 ? "model-rate-limit" : response.status === 404 ? "model-not-found" : "model-error";
|
|
83991
|
+
const hint = code === "model-auth" ? "The provider refused the API key. Check the API key in Settings." : code === "model-rate-limit" ? "The provider is rate limiting requests. Try again in a moment." : code === "model-not-found" ? `The model "${settings.model}" was not found. Check the model name in Settings.` : `The provider returned an error (${response.status}).`;
|
|
83992
|
+
throw new ModelError(code, detail ? `${hint} (${detail.slice(0, 160)})` : hint);
|
|
83993
|
+
}
|
|
83994
|
+
const message2 = json2.choices?.[0]?.message;
|
|
83995
|
+
if (!message2)
|
|
83996
|
+
throw new ModelError("model-error", `unexpected response from the provider: ${text.slice(0, 200)}`);
|
|
83997
|
+
return message2;
|
|
83998
|
+
}
|
|
83999
|
+
function harvest(tool2, result2, items, locations) {
|
|
84000
|
+
const r = result2;
|
|
84001
|
+
const add = (item) => {
|
|
84002
|
+
if (items.size < MAX_ITEMS && !items.has(`${item.kind}:${item.id}`))
|
|
84003
|
+
items.set(`${item.kind}:${item.id}`, item);
|
|
84004
|
+
};
|
|
84005
|
+
const prove = (path, span) => {
|
|
84006
|
+
if (!path || !span) return;
|
|
84007
|
+
const list = locations.get(path) ?? [];
|
|
84008
|
+
list.push([span.start.line, span.end.line]);
|
|
84009
|
+
locations.set(path, list);
|
|
84010
|
+
};
|
|
84011
|
+
const fileOf = (id) => id.slice(0, id.lastIndexOf(":"));
|
|
84012
|
+
const fn = (f) => {
|
|
84013
|
+
prove(f.path, f.evidence?.span);
|
|
84014
|
+
add({
|
|
84015
|
+
kind: "function",
|
|
84016
|
+
id: f.id,
|
|
84017
|
+
label: f.qualifiedName ?? f.name ?? f.id,
|
|
84018
|
+
file: fileOf(f.id),
|
|
84019
|
+
path: f.path,
|
|
84020
|
+
...f.evidence ? { line: f.evidence.span.start.line, detail: `${f.path}:${f.evidence.span.start.line}` } : {}
|
|
84021
|
+
});
|
|
84022
|
+
};
|
|
84023
|
+
if (tool2 === "search_nodes")
|
|
84024
|
+
for (const h of r.results ?? []) {
|
|
84025
|
+
if (h.label === "Function") fn(h);
|
|
84026
|
+
else add({ kind: "file", id: h.id, label: h.path, file: h.id, path: h.path });
|
|
84027
|
+
}
|
|
84028
|
+
else if (tool2 === "get_function") fn(r.function);
|
|
84029
|
+
else if (tool2 === "file_outline") {
|
|
84030
|
+
const file2 = r.file;
|
|
84031
|
+
add({ kind: "file", id: file2.id, label: file2.path, file: file2.id, path: file2.path });
|
|
84032
|
+
for (const f of r.functions ?? []) fn(f);
|
|
84033
|
+
} else if (tool2 === "list_calls")
|
|
84034
|
+
for (const c of r.calls ?? []) {
|
|
84035
|
+
const path = c.evidence.file.slice(c.evidence.file.indexOf(":") + 1);
|
|
84036
|
+
prove(path, c.evidence.span);
|
|
84037
|
+
add({
|
|
84038
|
+
kind: "call",
|
|
84039
|
+
id: c.id,
|
|
84040
|
+
label: `${r.direction === "in" ? `${c.function.qualifiedName} \u2192` : `\u2192 ${c.function.qualifiedName}`}`,
|
|
84041
|
+
detail: `${path}:${c.evidence.span.start.line}`,
|
|
84042
|
+
file: c.evidence.file,
|
|
84043
|
+
path,
|
|
84044
|
+
line: c.evidence.span.start.line
|
|
84045
|
+
});
|
|
84046
|
+
}
|
|
84047
|
+
else if (tool2 === "list_unresolved_sites")
|
|
84048
|
+
for (const s of r.sites ?? []) {
|
|
84049
|
+
const path = s.file.slice(s.file.indexOf(":") + 1);
|
|
84050
|
+
prove(path, s.evidence.span);
|
|
84051
|
+
add({
|
|
84052
|
+
kind: "site",
|
|
84053
|
+
id: s.id,
|
|
84054
|
+
label: `? ${s.expression}`,
|
|
84055
|
+
detail: `${path}:${s.evidence.span.start.line} \xB7 ${s.reason}`,
|
|
84056
|
+
file: s.file,
|
|
84057
|
+
path,
|
|
84058
|
+
line: s.evidence.span.start.line
|
|
84059
|
+
});
|
|
84060
|
+
}
|
|
84061
|
+
}
|
|
84062
|
+
function checkCitations(prose, locations) {
|
|
84063
|
+
const out = [];
|
|
84064
|
+
const seen = /* @__PURE__ */ new Set();
|
|
84065
|
+
for (const m of prose.matchAll(CITATION)) {
|
|
84066
|
+
const [text, path, line] = [m[0], m[1], Number(m[2])];
|
|
84067
|
+
if (seen.has(text)) continue;
|
|
84068
|
+
seen.add(text);
|
|
84069
|
+
let verified = false;
|
|
84070
|
+
for (const [known, spans] of locations)
|
|
84071
|
+
if (known === path || known.endsWith(`/${path}`)) {
|
|
84072
|
+
if (spans.some(([a, b]) => line >= a && line <= b)) verified = true;
|
|
84073
|
+
}
|
|
84074
|
+
out.push({ text, path, line, verified });
|
|
84075
|
+
}
|
|
84076
|
+
return out;
|
|
84077
|
+
}
|
|
84078
|
+
async function answerWithModel(engine, project2, question, settings, fetchImpl = fetch) {
|
|
84079
|
+
const calls = [];
|
|
84080
|
+
const items = /* @__PURE__ */ new Map();
|
|
84081
|
+
const locations = /* @__PURE__ */ new Map();
|
|
84082
|
+
const messages = [
|
|
84083
|
+
{ role: "system", content: systemPrompt(project2) },
|
|
84084
|
+
{ role: "user", content: question }
|
|
84085
|
+
];
|
|
84086
|
+
const tools = toolDefinitions();
|
|
84087
|
+
const allowed = new Set(CHAT_TOOLS);
|
|
84088
|
+
let prose;
|
|
84089
|
+
let truncated;
|
|
84090
|
+
const base = { question, via: "model", model: settings.model };
|
|
84091
|
+
let refused = false;
|
|
84092
|
+
const runTool = async (name, args) => {
|
|
84093
|
+
if (calls.length >= TOOL_BUDGET) {
|
|
84094
|
+
refused = true;
|
|
84095
|
+
return JSON.stringify({ error: { code: "budget", message: "tool budget used up" } });
|
|
84096
|
+
}
|
|
84097
|
+
if (!allowed.has(name)) {
|
|
84098
|
+
calls.push({ tool: name, args, error: "not an allowed read tool" });
|
|
84099
|
+
return JSON.stringify({
|
|
84100
|
+
error: {
|
|
84101
|
+
code: "not-allowed",
|
|
84102
|
+
message: `${name} is not available; use one of ${CHAT_TOOLS.join(", ")}`
|
|
84103
|
+
}
|
|
84104
|
+
});
|
|
84105
|
+
}
|
|
84106
|
+
const { project: _ignored, ...rest } = args;
|
|
84107
|
+
const { project: _p, ...input2 } = TOOLS[name].input;
|
|
84108
|
+
const parsed = external_exports.object(input2).strict().safeParse(rest);
|
|
84109
|
+
if (!parsed.success) {
|
|
84110
|
+
const message2 = parsed.error.issues.map((i) => `${i.path.join(".") || "arguments"}: ${i.message}`).join("; ");
|
|
84111
|
+
calls.push({ tool: name, args: rest, error: message2 });
|
|
84112
|
+
return JSON.stringify({ error: { code: "invalid-arguments", message: message2 } });
|
|
84113
|
+
}
|
|
84114
|
+
let result2;
|
|
84115
|
+
try {
|
|
84116
|
+
result2 = await callTool(engine, name, { ...rest, project: project2 });
|
|
84117
|
+
} catch (e) {
|
|
84118
|
+
const err = errorJson(e);
|
|
84119
|
+
calls.push({ tool: name, args: rest, error: err.message });
|
|
84120
|
+
return JSON.stringify({ error: err });
|
|
84121
|
+
}
|
|
84122
|
+
calls.push({ tool: name, args: rest });
|
|
84123
|
+
harvest(name, result2, items, locations);
|
|
84124
|
+
return JSON.stringify(result2);
|
|
84125
|
+
};
|
|
84126
|
+
try {
|
|
84127
|
+
for (let round = 0; ; round++) {
|
|
84128
|
+
if (round >= MAX_ROUNDS || calls.length >= TOOL_BUDGET) {
|
|
84129
|
+
messages.push({
|
|
84130
|
+
role: "user",
|
|
84131
|
+
content: "The tool budget is used up. Answer now with what the tools returned, and say what you could not check."
|
|
84132
|
+
});
|
|
84133
|
+
const last = await complete(settings, { messages, tools, tool_choice: "none" }, fetchImpl);
|
|
84134
|
+
prose = last.content ?? "";
|
|
84135
|
+
if (last.tool_calls?.length || refused)
|
|
84136
|
+
truncated = { reason: `stopped after ${TOOL_BUDGET} tool calls (the budget)` };
|
|
84137
|
+
break;
|
|
84138
|
+
}
|
|
84139
|
+
const message2 = await complete(settings, { messages, tools, tool_choice: "auto" }, fetchImpl);
|
|
84140
|
+
messages.push({
|
|
84141
|
+
role: "assistant",
|
|
84142
|
+
content: message2.content ?? null,
|
|
84143
|
+
...message2.tool_calls ? { tool_calls: message2.tool_calls } : {}
|
|
84144
|
+
});
|
|
84145
|
+
if (!message2.tool_calls?.length) {
|
|
84146
|
+
prose = message2.content ?? "";
|
|
84147
|
+
break;
|
|
84148
|
+
}
|
|
84149
|
+
for (const call of message2.tool_calls) {
|
|
84150
|
+
let args = {};
|
|
84151
|
+
try {
|
|
84152
|
+
const parsed = JSON.parse(call.function.arguments || "{}");
|
|
84153
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
|
|
84154
|
+
args = parsed;
|
|
84155
|
+
} catch {
|
|
84156
|
+
}
|
|
84157
|
+
let content = await runTool(call.function.name, args);
|
|
84158
|
+
if (content.length > RESULT_CHARS)
|
|
84159
|
+
content = `${content.slice(0, RESULT_CHARS)}\u2026 (cut; ask a narrower question)`;
|
|
84160
|
+
messages.push({ role: "tool", tool_call_id: call.id, content });
|
|
84161
|
+
}
|
|
84162
|
+
if (refused) truncated = { reason: `stopped after ${TOOL_BUDGET} tool calls (the budget)` };
|
|
84163
|
+
}
|
|
84164
|
+
} catch (e) {
|
|
84165
|
+
const err = e instanceof ModelError ? { code: e.code, message: e.message } : { code: "model-error", message: String(e.message ?? e) };
|
|
84166
|
+
return {
|
|
84167
|
+
...base,
|
|
84168
|
+
summary: `The model could not answer: ${err.message}`,
|
|
84169
|
+
results: [...items.values()],
|
|
84170
|
+
toolCalls: calls,
|
|
84171
|
+
error: err
|
|
84172
|
+
};
|
|
84173
|
+
}
|
|
84174
|
+
const citations = checkCitations(prose, locations);
|
|
84175
|
+
const unverified = citations.filter((c) => !c.verified).length;
|
|
84176
|
+
return {
|
|
84177
|
+
...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
|
+
results: [...items.values()],
|
|
84180
|
+
prose,
|
|
84181
|
+
citations,
|
|
84182
|
+
...truncated ? { truncated } : {},
|
|
84183
|
+
toolCalls: calls
|
|
84184
|
+
};
|
|
84185
|
+
}
|
|
84186
|
+
async function testConnection(settings, fetchImpl = fetch) {
|
|
84187
|
+
if (!settings.apiKey)
|
|
84188
|
+
return { ok: false, toolCalls: false, model: settings.model, message: "No API key is set." };
|
|
84189
|
+
try {
|
|
84190
|
+
const message2 = await complete(
|
|
84191
|
+
settings,
|
|
84192
|
+
{
|
|
84193
|
+
max_tokens: 50,
|
|
84194
|
+
messages: [{ role: "user", content: "Call the ping tool." }],
|
|
84195
|
+
tools: [
|
|
84196
|
+
{
|
|
84197
|
+
type: "function",
|
|
84198
|
+
function: {
|
|
84199
|
+
name: "ping",
|
|
84200
|
+
description: "Answers pong.",
|
|
84201
|
+
parameters: { type: "object", properties: {} }
|
|
84202
|
+
}
|
|
84203
|
+
}
|
|
84204
|
+
],
|
|
84205
|
+
tool_choice: { type: "function", function: { name: "ping" } }
|
|
84206
|
+
},
|
|
84207
|
+
fetchImpl
|
|
84208
|
+
);
|
|
84209
|
+
const toolCalls = Boolean(message2.tool_calls?.length);
|
|
84210
|
+
return {
|
|
84211
|
+
ok: true,
|
|
84212
|
+
toolCalls,
|
|
84213
|
+
model: settings.model,
|
|
84214
|
+
message: toolCalls ? `Connected to ${settings.model}; it can call tools.` : `Connected to ${settings.model}, but it did not call a tool. Ask needs a model that supports tool calls; until then only the built-in questions work.`
|
|
84215
|
+
};
|
|
84216
|
+
} catch (e) {
|
|
84217
|
+
return {
|
|
84218
|
+
ok: false,
|
|
84219
|
+
toolCalls: false,
|
|
84220
|
+
model: settings.model,
|
|
84221
|
+
message: e instanceof ModelError ? e.message : String(e.message ?? e)
|
|
84222
|
+
};
|
|
84223
|
+
}
|
|
84224
|
+
}
|
|
84225
|
+
var CHAT_TOOLS, TOOL_BUDGET, MAX_ROUNDS, RESULT_CHARS, MAX_ITEMS, TIMEOUT_MS, ModelError, CITATION;
|
|
84226
|
+
var init_chat = __esm({
|
|
84227
|
+
"packages/agents/src/chat.ts"() {
|
|
84228
|
+
"use strict";
|
|
84229
|
+
init_zod();
|
|
84230
|
+
init_src7();
|
|
84231
|
+
CHAT_TOOLS = [
|
|
84232
|
+
"search_nodes",
|
|
84233
|
+
"aggregate",
|
|
84234
|
+
"file_outline",
|
|
84235
|
+
"get_function",
|
|
84236
|
+
"list_calls",
|
|
84237
|
+
"list_unresolved_sites",
|
|
84238
|
+
"run_status"
|
|
84239
|
+
];
|
|
84240
|
+
TOOL_BUDGET = 8;
|
|
84241
|
+
MAX_ROUNDS = 10;
|
|
84242
|
+
RESULT_CHARS = 12e3;
|
|
84243
|
+
MAX_ITEMS = 40;
|
|
84244
|
+
TIMEOUT_MS = 9e4;
|
|
84245
|
+
ModelError = class extends Error {
|
|
84246
|
+
constructor(code, message2) {
|
|
84247
|
+
super(message2);
|
|
84248
|
+
this.code = code;
|
|
84249
|
+
}
|
|
84250
|
+
code;
|
|
84251
|
+
};
|
|
84252
|
+
CITATION = /(?<![\w/:.@-])(?:[\w.-]+:(?=[\w@./-]+\.[A-Za-z]))?(?:\.\/)?((?:[\w@.-]+\/)*[\w@-][\w@.-]*\.[A-Za-z][A-Za-z0-9]*):(\d+)(?::\d+)?(?![\w/])/g;
|
|
84253
|
+
}
|
|
84254
|
+
});
|
|
84255
|
+
|
|
84256
|
+
// packages/agents/src/ask.ts
|
|
84257
|
+
async function ask(engine, home, project2, question, options = {}) {
|
|
84258
|
+
const text = question.trim();
|
|
84259
|
+
const mode = options.mode ?? "auto";
|
|
84260
|
+
if (!text)
|
|
84261
|
+
return {
|
|
84262
|
+
question,
|
|
84263
|
+
via: "help",
|
|
84264
|
+
summary: HELP_SUMMARY,
|
|
84265
|
+
results: [],
|
|
84266
|
+
toolCalls: [],
|
|
84267
|
+
suggestions: suggest(engine, project2)
|
|
84268
|
+
};
|
|
84269
|
+
const settings = loadSettings(home, options.env);
|
|
84270
|
+
const modelReady = mode !== "grammar" && settings.apiKey !== null;
|
|
84271
|
+
if (mode !== "model") {
|
|
84272
|
+
const answer = answerWithGrammar(engine, project2, text, {
|
|
84273
|
+
fallThrough: modelReady,
|
|
84274
|
+
...options.file ? { file: options.file } : {}
|
|
84275
|
+
});
|
|
84276
|
+
if (answer) return answer;
|
|
84277
|
+
}
|
|
84278
|
+
if (mode !== "grammar" && settings.apiKey)
|
|
84279
|
+
return answerWithModel(engine, project2, text, settings, options.fetch);
|
|
84280
|
+
return {
|
|
84281
|
+
question,
|
|
84282
|
+
via: "help",
|
|
84283
|
+
summary: mode === "grammar" || settings.apiKey ? `That isn't one of the built-in questions. ${HELP_SUMMARY}` : "That isn't one of the built-in questions, and no model is configured. Add an OpenRouter key and model in Settings to ask anything, or try one of these.",
|
|
84284
|
+
results: [],
|
|
84285
|
+
toolCalls: [],
|
|
84286
|
+
// A few starters and the question shapes; the full list is in the Ask bar.
|
|
84287
|
+
suggestions: [...suggest(engine, project2).slice(0, 3), ...EXAMPLES.filter((e) => e.includes("<"))]
|
|
84288
|
+
};
|
|
84289
|
+
}
|
|
84290
|
+
function suggest(engine, project2) {
|
|
84291
|
+
const out = ["overview"];
|
|
84292
|
+
try {
|
|
84293
|
+
const called = engine.aggregate({ project: project2, label: "CALLS", groupBy: "to", limit: 10 }).groups.find((g) => sourceFile(g.key.slice(g.key.indexOf(":") + 1)) && !(g.name ?? "<").includes("<"));
|
|
84294
|
+
if (called?.name) out.push(`who calls ${called.name}`);
|
|
84295
|
+
const largest = engine.aggregate({ project: project2, label: "Function", groupBy: "file" }).groups.find((g) => sourceFile(g.name));
|
|
84296
|
+
if (largest?.name) out.push(`functions in ${largest.name}`);
|
|
84297
|
+
const questions = engine.aggregate({ project: project2, label: "UnresolvedCallSite", groupBy: "file", filters: { open: true } }).groups.find((g) => sourceFile(g.name));
|
|
84298
|
+
if (questions?.name) out.push(`open questions in ${questions.name}`);
|
|
84299
|
+
} catch {
|
|
84300
|
+
}
|
|
84301
|
+
out.push("largest files", "most called functions");
|
|
84302
|
+
return [...new Set(out)];
|
|
84303
|
+
}
|
|
84304
|
+
var TEST_PATH, sourceFile;
|
|
84305
|
+
var init_ask = __esm({
|
|
84306
|
+
"packages/agents/src/ask.ts"() {
|
|
84307
|
+
"use strict";
|
|
84308
|
+
init_chat();
|
|
84309
|
+
init_config();
|
|
84310
|
+
init_grammar();
|
|
84311
|
+
TEST_PATH = /(^|\/)(__tests__|__mocks__|tests?|e2e|specs?|fixtures?)\/|\.(test|spec|e2e|stories)\.[a-z0-9]+$/i;
|
|
84312
|
+
sourceFile = (path) => path !== void 0 && !TEST_PATH.test(path);
|
|
84313
|
+
}
|
|
84314
|
+
});
|
|
84315
|
+
|
|
84316
|
+
// packages/agents/src/view.ts
|
|
84317
|
+
function viewCommands(item) {
|
|
84318
|
+
if (!item.file) return [];
|
|
84319
|
+
if (item.kind === "file") return [{ name: "openFile", args: { file: item.file } }];
|
|
84320
|
+
if (item.kind === "function" || item.kind === "call" || item.kind === "site")
|
|
84321
|
+
return [
|
|
84322
|
+
{ name: "openFile", args: { file: item.file } },
|
|
84323
|
+
{ name: "select", args: { kind: item.kind, id: item.id, file: item.file } }
|
|
84324
|
+
];
|
|
84325
|
+
return [];
|
|
84326
|
+
}
|
|
84327
|
+
var init_view2 = __esm({
|
|
84328
|
+
"packages/agents/src/view.ts"() {
|
|
84329
|
+
"use strict";
|
|
84330
|
+
}
|
|
84331
|
+
});
|
|
84332
|
+
|
|
84333
|
+
// packages/agents/src/index.ts
|
|
84334
|
+
var src_exports2 = {};
|
|
84335
|
+
__export(src_exports2, {
|
|
84336
|
+
CHAT_TOOLS: () => CHAT_TOOLS,
|
|
84337
|
+
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
84338
|
+
DEFAULT_MODEL: () => DEFAULT_MODEL,
|
|
84339
|
+
EXAMPLES: () => EXAMPLES,
|
|
84340
|
+
HELP_SUMMARY: () => HELP_SUMMARY,
|
|
84341
|
+
INTENTS: () => INTENTS,
|
|
84342
|
+
IN_FILE_NOTE: () => IN_FILE_NOTE,
|
|
84343
|
+
TOOL_BUDGET: () => TOOL_BUDGET,
|
|
84344
|
+
answerWithGrammar: () => answerWithGrammar,
|
|
84345
|
+
answerWithModel: () => answerWithModel,
|
|
84346
|
+
ask: () => ask,
|
|
84347
|
+
checkCitations: () => checkCitations,
|
|
84348
|
+
configPath: () => configPath,
|
|
84349
|
+
loadSettings: () => loadSettings,
|
|
84350
|
+
normalize: () => normalize,
|
|
84351
|
+
publicSettings: () => publicSettings,
|
|
84352
|
+
saveSettings: () => saveSettings,
|
|
84353
|
+
say: () => say,
|
|
84354
|
+
suggest: () => suggest,
|
|
84355
|
+
systemPrompt: () => systemPrompt,
|
|
84356
|
+
testConnection: () => testConnection,
|
|
84357
|
+
toolDefinitions: () => toolDefinitions,
|
|
84358
|
+
viewCommands: () => viewCommands
|
|
84359
|
+
});
|
|
84360
|
+
var init_src8 = __esm({
|
|
84361
|
+
"packages/agents/src/index.ts"() {
|
|
84362
|
+
"use strict";
|
|
84363
|
+
init_types3();
|
|
84364
|
+
init_config();
|
|
84365
|
+
init_grammar();
|
|
84366
|
+
init_chat();
|
|
84367
|
+
init_ask();
|
|
84368
|
+
init_view2();
|
|
84369
|
+
}
|
|
84370
|
+
});
|
|
84371
|
+
|
|
82941
84372
|
// packages/server/src/server.ts
|
|
82942
|
-
import { existsSync as
|
|
82943
|
-
import { dirname as
|
|
84373
|
+
import { existsSync as existsSync6, statSync as statSync3 } from "node:fs";
|
|
84374
|
+
import { dirname as dirname5, isAbsolute, join as join7, resolve as resolve3 } from "node:path";
|
|
82944
84375
|
import { fileURLToPath } from "node:url";
|
|
82945
84376
|
function hostName(host) {
|
|
82946
84377
|
return host.startsWith("[") ? host.slice(0, host.indexOf("]") + 1) : host.replace(/:\d+$/, "");
|
|
@@ -82987,8 +84418,11 @@ async function createServer(engine, options = {}) {
|
|
|
82987
84418
|
app.get("/api/projects", async () => engine.listProjects());
|
|
82988
84419
|
app.post(
|
|
82989
84420
|
"/api/projects",
|
|
82990
|
-
{ schema: { body: { type: "object", required: ["name"], properties: { name: str2 } } } },
|
|
82991
|
-
async (req, reply) =>
|
|
84421
|
+
{ schema: { body: { type: "object", required: ["name"], properties: { name: str2, root: str2 } } } },
|
|
84422
|
+
async (req, reply) => {
|
|
84423
|
+
if (req.body.root !== void 0) checkFolder(req.body.root);
|
|
84424
|
+
return reply.status(201).send(engine.createProject({ name: req.body.name }));
|
|
84425
|
+
}
|
|
82992
84426
|
);
|
|
82993
84427
|
app.get(
|
|
82994
84428
|
"/api/projects/:project/sources",
|
|
@@ -83008,7 +84442,10 @@ async function createServer(engine, options = {}) {
|
|
|
83008
84442
|
}
|
|
83009
84443
|
}
|
|
83010
84444
|
},
|
|
83011
|
-
async (req, reply) =>
|
|
84445
|
+
async (req, reply) => {
|
|
84446
|
+
checkFolder(req.body.root);
|
|
84447
|
+
return reply.status(201).send(engine.addSource({ ...req.body, ...req.params }));
|
|
84448
|
+
}
|
|
83012
84449
|
);
|
|
83013
84450
|
app.post(
|
|
83014
84451
|
"/api/projects/:project/runs",
|
|
@@ -83033,6 +84470,11 @@ async function createServer(engine, options = {}) {
|
|
|
83033
84470
|
},
|
|
83034
84471
|
async (req) => engine.listRuns({ ...req.params, ...req.query.limit ? { limit: Number(req.query.limit) } : {} })
|
|
83035
84472
|
);
|
|
84473
|
+
app.get(
|
|
84474
|
+
"/api/projects/:project/file-counts",
|
|
84475
|
+
{ schema: { params: projectParams } },
|
|
84476
|
+
async (req) => engine.fileCounts(req.params)
|
|
84477
|
+
);
|
|
83036
84478
|
app.get(
|
|
83037
84479
|
"/api/projects/:project/files",
|
|
83038
84480
|
{ schema: { params: projectParams } },
|
|
@@ -83089,6 +84531,167 @@ async function createServer(engine, options = {}) {
|
|
|
83089
84531
|
includeAll: req.query.includeAll === "true"
|
|
83090
84532
|
})
|
|
83091
84533
|
);
|
|
84534
|
+
app.post(
|
|
84535
|
+
"/api/projects/:project/ask",
|
|
84536
|
+
{
|
|
84537
|
+
schema: {
|
|
84538
|
+
params: projectParams,
|
|
84539
|
+
body: {
|
|
84540
|
+
type: "object",
|
|
84541
|
+
required: ["question"],
|
|
84542
|
+
additionalProperties: false,
|
|
84543
|
+
properties: {
|
|
84544
|
+
question: { type: "string", maxLength: 2e3 },
|
|
84545
|
+
mode: { type: "string", enum: ["auto", "model", "grammar"] },
|
|
84546
|
+
file: { type: "string", maxLength: 1e3 }
|
|
84547
|
+
}
|
|
84548
|
+
}
|
|
84549
|
+
}
|
|
84550
|
+
},
|
|
84551
|
+
async (req) => {
|
|
84552
|
+
const project2 = engine.resolveProject(req.params).id;
|
|
84553
|
+
const mode = isLocal(req) ? req.body.mode : "grammar";
|
|
84554
|
+
return ask(engine, engine.catalog.home, project2, req.body.question, {
|
|
84555
|
+
...mode ? { mode } : {},
|
|
84556
|
+
...req.body.file ? { file: req.body.file } : {}
|
|
84557
|
+
});
|
|
84558
|
+
}
|
|
84559
|
+
);
|
|
84560
|
+
app.get(
|
|
84561
|
+
"/api/projects/:project/suggestions",
|
|
84562
|
+
{ schema: { params: projectParams } },
|
|
84563
|
+
async (req) => ({ suggestions: suggest(engine, engine.resolveProject(req.params).id) })
|
|
84564
|
+
);
|
|
84565
|
+
app.get("/api/settings", async () => ({ model: publicSettings(loadSettings(engine.catalog.home)) }));
|
|
84566
|
+
app.put(
|
|
84567
|
+
"/api/settings",
|
|
84568
|
+
{
|
|
84569
|
+
schema: {
|
|
84570
|
+
body: {
|
|
84571
|
+
type: "object",
|
|
84572
|
+
additionalProperties: false,
|
|
84573
|
+
properties: {
|
|
84574
|
+
baseUrl: { type: "string", maxLength: 500 },
|
|
84575
|
+
model: { type: "string", maxLength: 200 },
|
|
84576
|
+
apiKey: { type: ["string", "null"], maxLength: 500 }
|
|
84577
|
+
}
|
|
84578
|
+
}
|
|
84579
|
+
}
|
|
84580
|
+
},
|
|
84581
|
+
async (req) => {
|
|
84582
|
+
localOnly(req);
|
|
84583
|
+
return { model: publicSettings(saveSettings(engine.catalog.home, req.body)) };
|
|
84584
|
+
}
|
|
84585
|
+
);
|
|
84586
|
+
app.post(
|
|
84587
|
+
"/api/settings/test",
|
|
84588
|
+
{
|
|
84589
|
+
schema: {
|
|
84590
|
+
body: {
|
|
84591
|
+
type: "object",
|
|
84592
|
+
additionalProperties: false,
|
|
84593
|
+
properties: {
|
|
84594
|
+
baseUrl: { type: "string", maxLength: 500 },
|
|
84595
|
+
model: { type: "string", maxLength: 200 },
|
|
84596
|
+
apiKey: { type: "string", maxLength: 500 }
|
|
84597
|
+
}
|
|
84598
|
+
}
|
|
84599
|
+
}
|
|
84600
|
+
},
|
|
84601
|
+
async (req) => {
|
|
84602
|
+
localOnly(req);
|
|
84603
|
+
const stored = loadSettings(engine.catalog.home);
|
|
84604
|
+
const body = req.body ?? {};
|
|
84605
|
+
const baseUrl = body.baseUrl?.trim().replace(/\/+$/, "") || stored.baseUrl;
|
|
84606
|
+
if (!/^https?:\/\/\S+$/.test(baseUrl))
|
|
84607
|
+
return {
|
|
84608
|
+
ok: false,
|
|
84609
|
+
toolCalls: false,
|
|
84610
|
+
model: stored.model,
|
|
84611
|
+
message: "The base URL must start with http:// or https://."
|
|
84612
|
+
};
|
|
84613
|
+
return testConnection({
|
|
84614
|
+
...stored,
|
|
84615
|
+
baseUrl,
|
|
84616
|
+
model: body.model?.trim() || stored.model,
|
|
84617
|
+
apiKey: body.apiKey?.trim() || stored.apiKey
|
|
84618
|
+
});
|
|
84619
|
+
}
|
|
84620
|
+
);
|
|
84621
|
+
app.get(
|
|
84622
|
+
"/api/projects/:project/search",
|
|
84623
|
+
{
|
|
84624
|
+
schema: {
|
|
84625
|
+
params: projectParams,
|
|
84626
|
+
querystring: {
|
|
84627
|
+
type: "object",
|
|
84628
|
+
required: ["label"],
|
|
84629
|
+
properties: {
|
|
84630
|
+
label: { type: "string", enum: ["Function", "File"] },
|
|
84631
|
+
text: { type: "string" },
|
|
84632
|
+
path: str2,
|
|
84633
|
+
status: { type: "string", enum: ["analyzed", "degraded", "not_analyzed"] },
|
|
84634
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" }
|
|
84635
|
+
}
|
|
84636
|
+
}
|
|
84637
|
+
}
|
|
84638
|
+
},
|
|
84639
|
+
async (req) => {
|
|
84640
|
+
const { label, text, path, status, limit } = req.query;
|
|
84641
|
+
const filters = {
|
|
84642
|
+
...path ? { path } : {},
|
|
84643
|
+
...status ? { status } : {}
|
|
84644
|
+
};
|
|
84645
|
+
return engine.searchNodes({
|
|
84646
|
+
...req.params,
|
|
84647
|
+
label,
|
|
84648
|
+
...text !== void 0 ? { text } : {},
|
|
84649
|
+
...Object.keys(filters).length ? { filters } : {},
|
|
84650
|
+
...limit ? { limit: Number(limit) } : {}
|
|
84651
|
+
});
|
|
84652
|
+
}
|
|
84653
|
+
);
|
|
84654
|
+
app.get(
|
|
84655
|
+
"/api/projects/:project/aggregate",
|
|
84656
|
+
{
|
|
84657
|
+
schema: {
|
|
84658
|
+
params: projectParams,
|
|
84659
|
+
querystring: {
|
|
84660
|
+
type: "object",
|
|
84661
|
+
required: ["label", "groupBy"],
|
|
84662
|
+
properties: {
|
|
84663
|
+
label: { type: "string", enum: ["File", "Function", "UnresolvedCallSite", "CALLS"] },
|
|
84664
|
+
groupBy: str2,
|
|
84665
|
+
open: { type: "string", enum: ["true", "false"] },
|
|
84666
|
+
path: str2,
|
|
84667
|
+
limit: { type: "string", pattern: "^[1-9][0-9]*$" }
|
|
84668
|
+
}
|
|
84669
|
+
}
|
|
84670
|
+
}
|
|
84671
|
+
},
|
|
84672
|
+
async (req) => engine.aggregate({
|
|
84673
|
+
...req.params,
|
|
84674
|
+
label: req.query.label,
|
|
84675
|
+
groupBy: req.query.groupBy,
|
|
84676
|
+
...req.query.open !== void 0 || req.query.path ? {
|
|
84677
|
+
filters: {
|
|
84678
|
+
...req.query.open !== void 0 ? { open: req.query.open === "true" } : {},
|
|
84679
|
+
...req.query.path ? { path: req.query.path } : {}
|
|
84680
|
+
}
|
|
84681
|
+
} : {},
|
|
84682
|
+
...req.query.limit ? { limit: Number(req.query.limit) } : {}
|
|
84683
|
+
})
|
|
84684
|
+
);
|
|
84685
|
+
app.get(
|
|
84686
|
+
"/api/projects/:project/file-outline",
|
|
84687
|
+
{
|
|
84688
|
+
schema: {
|
|
84689
|
+
params: projectParams,
|
|
84690
|
+
querystring: { type: "object", required: ["file"], properties: { file: str2 } }
|
|
84691
|
+
}
|
|
84692
|
+
},
|
|
84693
|
+
async (req) => engine.fileOutline({ ...req.params, file: req.query.file })
|
|
84694
|
+
);
|
|
83092
84695
|
app.post(
|
|
83093
84696
|
"/api/projects/:project/snippet",
|
|
83094
84697
|
{
|
|
@@ -83112,7 +84715,7 @@ async function createServer(engine, options = {}) {
|
|
|
83112
84715
|
async (req) => engine.snippet({ ...req.params, ...req.body })
|
|
83113
84716
|
);
|
|
83114
84717
|
const webRoot = options.webRoot === void 0 ? defaultWebRoot : options.webRoot;
|
|
83115
|
-
const hasUi = webRoot !== null &&
|
|
84718
|
+
const hasUi = webRoot !== null && existsSync6(join7(webRoot, "index.html"));
|
|
83116
84719
|
if (hasUi) await app.register(import_static.default, { root: webRoot });
|
|
83117
84720
|
app.setNotFoundHandler((req, reply) => {
|
|
83118
84721
|
if (req.url.startsWith("/api/") || !hasUi)
|
|
@@ -83138,6 +84741,31 @@ async function listen(engine, options = {}) {
|
|
|
83138
84741
|
}
|
|
83139
84742
|
};
|
|
83140
84743
|
}
|
|
84744
|
+
function checkFolder(root) {
|
|
84745
|
+
if (!isAbsolute(root))
|
|
84746
|
+
throw new VeoError(
|
|
84747
|
+
"invalid-arguments",
|
|
84748
|
+
`Enter an absolute path (for example /Users/you/app), not "${root}"`,
|
|
84749
|
+
{
|
|
84750
|
+
fields: ["root"]
|
|
84751
|
+
}
|
|
84752
|
+
);
|
|
84753
|
+
let dir;
|
|
84754
|
+
try {
|
|
84755
|
+
dir = statSync3(root).isDirectory();
|
|
84756
|
+
} catch {
|
|
84757
|
+
dir = false;
|
|
84758
|
+
}
|
|
84759
|
+
if (!dir) throw new VeoError("source-not-found", `${root} is not a folder`, { root });
|
|
84760
|
+
}
|
|
84761
|
+
function localOnly(req) {
|
|
84762
|
+
if (!isLocal(req))
|
|
84763
|
+
throw new VeoError("forbidden", "settings can only be changed from the machine running veoflow");
|
|
84764
|
+
}
|
|
84765
|
+
function isLocal(req) {
|
|
84766
|
+
const ip = req.socket.remoteAddress ?? "";
|
|
84767
|
+
return ip === "::1" || /^(?:::ffff:)?127\./.test(ip);
|
|
84768
|
+
}
|
|
83141
84769
|
var import_static, import_websocket, import_fastify, STATUS, defaultWebRoot, LOOPBACK, str2, strings, position, projectParams;
|
|
83142
84770
|
var init_server4 = __esm({
|
|
83143
84771
|
"packages/server/src/server.ts"() {
|
|
@@ -83146,6 +84774,7 @@ var init_server4 = __esm({
|
|
|
83146
84774
|
import_websocket = __toESM(require_websocket2(), 1);
|
|
83147
84775
|
import_fastify = __toESM(require_fastify(), 1);
|
|
83148
84776
|
init_src();
|
|
84777
|
+
init_src8();
|
|
83149
84778
|
STATUS = {
|
|
83150
84779
|
"not-found": 404,
|
|
83151
84780
|
"source-not-found": 404,
|
|
@@ -83158,7 +84787,7 @@ var init_server4 = __esm({
|
|
|
83158
84787
|
ambiguous: 409,
|
|
83159
84788
|
locked: 409
|
|
83160
84789
|
};
|
|
83161
|
-
defaultWebRoot = process.env.VEO_WEB_ROOT ?? resolve3(
|
|
84790
|
+
defaultWebRoot = process.env.VEO_WEB_ROOT ?? resolve3(dirname5(fileURLToPath(import.meta.url)), "../../web/dist");
|
|
83162
84791
|
LOOPBACK = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]", "::1"]);
|
|
83163
84792
|
str2 = { type: "string", minLength: 1 };
|
|
83164
84793
|
strings = { type: "array", items: { type: "string" } };
|
|
@@ -83172,13 +84801,13 @@ var init_server4 = __esm({
|
|
|
83172
84801
|
});
|
|
83173
84802
|
|
|
83174
84803
|
// packages/server/src/index.ts
|
|
83175
|
-
var
|
|
83176
|
-
__export(
|
|
84804
|
+
var src_exports3 = {};
|
|
84805
|
+
__export(src_exports3, {
|
|
83177
84806
|
createServer: () => createServer,
|
|
83178
84807
|
listen: () => listen,
|
|
83179
84808
|
urlHost: () => urlHost
|
|
83180
84809
|
});
|
|
83181
|
-
var
|
|
84810
|
+
var init_src9 = __esm({
|
|
83182
84811
|
"packages/server/src/index.ts"() {
|
|
83183
84812
|
"use strict";
|
|
83184
84813
|
init_server4();
|
|
@@ -83189,8 +84818,8 @@ var init_src8 = __esm({
|
|
|
83189
84818
|
init_src();
|
|
83190
84819
|
init_src6();
|
|
83191
84820
|
import { spawn } from "node:child_process";
|
|
83192
|
-
import { existsSync as
|
|
83193
|
-
import { basename as basename3, dirname as
|
|
84821
|
+
import { existsSync as existsSync7, readFileSync as readFileSync4, statSync as statSync4 } from "node:fs";
|
|
84822
|
+
import { basename as basename3, dirname as dirname6, join as join8, resolve as resolve4 } from "node:path";
|
|
83194
84823
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
83195
84824
|
import { parseArgs } from "node:util";
|
|
83196
84825
|
var USAGE = `veoflow \u2014 a knowledge graph of your code (also runs as \`veo\`)
|
|
@@ -83203,6 +84832,11 @@ Usage:
|
|
|
83203
84832
|
veoflow serve [--port 7420] [--host 127.0.0.1] [--no-open]
|
|
83204
84833
|
serve the UI and API
|
|
83205
84834
|
veoflow mcp serve the MCP tools over stdio
|
|
84835
|
+
veoflow ask "<question>" [--project <id>] [--mode auto|grammar|model]
|
|
84836
|
+
ask about the analyzed code
|
|
84837
|
+
veoflow config [get [<key>] | set <key> <value> | test]
|
|
84838
|
+
model settings: model.baseUrl, model.name, model.apiKey
|
|
84839
|
+
("set model.apiKey -" reads the key from stdin)
|
|
83206
84840
|
veoflow projects list projects
|
|
83207
84841
|
veoflow help | --version`;
|
|
83208
84842
|
var UsageError = class extends Error {
|
|
@@ -83210,7 +84844,7 @@ var UsageError = class extends Error {
|
|
|
83210
84844
|
function version2() {
|
|
83211
84845
|
if (process.env.VEO_VERSION) return process.env.VEO_VERSION;
|
|
83212
84846
|
const pkg = JSON.parse(
|
|
83213
|
-
|
|
84847
|
+
readFileSync4(join8(dirname6(fileURLToPath2(import.meta.url)), "../package.json"), "utf8")
|
|
83214
84848
|
);
|
|
83215
84849
|
return pkg.version;
|
|
83216
84850
|
}
|
|
@@ -83314,7 +84948,7 @@ async function main(argv, io) {
|
|
|
83314
84948
|
});
|
|
83315
84949
|
if (positionals.length !== 1) throw new UsageError("usage: veoflow add <dir> [--project <id>]");
|
|
83316
84950
|
const root = resolve4(io.cwd, positionals[0]);
|
|
83317
|
-
if (!
|
|
84951
|
+
if (!existsSync7(root) || !statSync4(root).isDirectory())
|
|
83318
84952
|
throw new VeoError("source-not-found", `${root} is not a directory`);
|
|
83319
84953
|
let project2 = values.project ?? engine.catalog.resolveProjectForCwd(io.cwd)?.id;
|
|
83320
84954
|
if (!project2) {
|
|
@@ -83349,7 +84983,7 @@ async function main(argv, io) {
|
|
|
83349
84983
|
const port = values.port === void 0 ? 7420 : Number(values.port);
|
|
83350
84984
|
if (!Number.isInteger(port) || port < 0 || port > 65535)
|
|
83351
84985
|
throw new UsageError(`invalid --port ${values.port}`);
|
|
83352
|
-
const { listen: listen2 } = await Promise.resolve().then(() => (
|
|
84986
|
+
const { listen: listen2 } = await Promise.resolve().then(() => (init_src9(), src_exports3));
|
|
83353
84987
|
let started;
|
|
83354
84988
|
try {
|
|
83355
84989
|
started = await listen2(engine, { port, ...values.host ? { host: values.host } : {} });
|
|
@@ -83370,6 +85004,91 @@ async function main(argv, io) {
|
|
|
83370
85004
|
}, started.url);
|
|
83371
85005
|
return 0;
|
|
83372
85006
|
}
|
|
85007
|
+
case "ask": {
|
|
85008
|
+
const { values, positionals } = parseArgs({
|
|
85009
|
+
args: rest,
|
|
85010
|
+
strict: true,
|
|
85011
|
+
allowPositionals: true,
|
|
85012
|
+
options: { project: { type: "string" }, mode: { type: "string" }, json: { type: "boolean" } }
|
|
85013
|
+
});
|
|
85014
|
+
if (positionals.length === 0)
|
|
85015
|
+
throw new UsageError('usage: veoflow ask "<question>" [--project <id>]');
|
|
85016
|
+
const mode = values.mode ?? "auto";
|
|
85017
|
+
if (mode !== "auto" && mode !== "grammar" && mode !== "model")
|
|
85018
|
+
throw new UsageError(`invalid --mode ${mode} (auto, grammar or model)`);
|
|
85019
|
+
const { ask: ask2 } = await Promise.resolve().then(() => (init_src8(), src_exports2));
|
|
85020
|
+
const project2 = pickProject(engine, values.project, io.cwd);
|
|
85021
|
+
const answer = await ask2(engine, engine.catalog.home, project2, positionals.join(" "), { mode });
|
|
85022
|
+
if (values.json) {
|
|
85023
|
+
io.out(JSON.stringify(answer, null, 2));
|
|
85024
|
+
return answer.error ? 1 : 0;
|
|
85025
|
+
}
|
|
85026
|
+
io.out(answer.summary);
|
|
85027
|
+
if (answer.note) io.out(`note: ${answer.note}`);
|
|
85028
|
+
if (answer.prose) io.out(`
|
|
85029
|
+
${plain(answer.prose)}`);
|
|
85030
|
+
for (const c of answer.citations ?? [])
|
|
85031
|
+
if (!c.verified) io.out(`unverified: ${c.text} was not returned by any tool`);
|
|
85032
|
+
if (answer.results.length) io.out("");
|
|
85033
|
+
for (const r of answer.results.slice(0, 25))
|
|
85034
|
+
io.out(` ${r.label}${r.detail ? ` (${r.detail})` : ""}`);
|
|
85035
|
+
if (answer.results.length > 25) io.out(` \u2026 ${answer.results.length - 25} more`);
|
|
85036
|
+
if (answer.truncated) io.out(`truncated: ${answer.truncated.reason}`);
|
|
85037
|
+
if (answer.suggestions?.length) io.out(`
|
|
85038
|
+
try: ${answer.suggestions.join(" \xB7 ")}`);
|
|
85039
|
+
return answer.error || mode === "model" && answer.via !== "model" ? 1 : 0;
|
|
85040
|
+
}
|
|
85041
|
+
case "config": {
|
|
85042
|
+
const [action = "get", key, value] = rest;
|
|
85043
|
+
const { loadSettings: loadSettings2, publicSettings: publicSettings2, saveSettings: saveSettings2, testConnection: testConnection2 } = await Promise.resolve().then(() => (init_src8(), src_exports2));
|
|
85044
|
+
const home = engine.catalog.home;
|
|
85045
|
+
const keys = {
|
|
85046
|
+
"model.baseUrl": "baseUrl",
|
|
85047
|
+
"model.name": "model",
|
|
85048
|
+
"model.apiKey": "apiKey"
|
|
85049
|
+
};
|
|
85050
|
+
const show = () => {
|
|
85051
|
+
const p = publicSettings2(loadSettings2(home));
|
|
85052
|
+
return {
|
|
85053
|
+
"model.baseUrl": p.baseUrl,
|
|
85054
|
+
"model.name": p.model,
|
|
85055
|
+
"model.apiKey": p.apiKeySet ? `set (\u2026${p.apiKeyHint}, from ${p.keySource})` : "not set"
|
|
85056
|
+
};
|
|
85057
|
+
};
|
|
85058
|
+
if (action === "get") {
|
|
85059
|
+
const all2 = show();
|
|
85060
|
+
if (key && !(key in all2))
|
|
85061
|
+
throw new UsageError(`unknown key ${key} (${Object.keys(keys).join(", ")})`);
|
|
85062
|
+
for (const [k, v] of Object.entries(all2)) if (!key || k === key) io.out(key ? v : `${k} = ${v}`);
|
|
85063
|
+
return 0;
|
|
85064
|
+
}
|
|
85065
|
+
if (action === "set") {
|
|
85066
|
+
if (!key || !(key in keys) || value === void 0)
|
|
85067
|
+
throw new UsageError(`usage: veoflow config set <${Object.keys(keys).join("|")}> <value>`);
|
|
85068
|
+
const field = keys[key];
|
|
85069
|
+
let v = value;
|
|
85070
|
+
if (field === "apiKey" && value === "-") {
|
|
85071
|
+
if (process.stdin.isTTY)
|
|
85072
|
+
throw new UsageError(
|
|
85073
|
+
"pipe the key in, so it never shows on screen: pbpaste | veoflow config set model.apiKey -"
|
|
85074
|
+
);
|
|
85075
|
+
v = readFileSync4(0, "utf8").trim();
|
|
85076
|
+
if (!v)
|
|
85077
|
+
throw new UsageError(
|
|
85078
|
+
"no key on stdin; to remove the stored key: veoflow config set model.apiKey ''"
|
|
85079
|
+
);
|
|
85080
|
+
}
|
|
85081
|
+
saveSettings2(home, { [field]: field === "apiKey" && v === "" ? null : v });
|
|
85082
|
+
io.out(`${key} = ${show()[key]}`);
|
|
85083
|
+
return 0;
|
|
85084
|
+
}
|
|
85085
|
+
if (action === "test") {
|
|
85086
|
+
const r = await testConnection2(loadSettings2(home));
|
|
85087
|
+
(r.ok && r.toolCalls ? io.out : io.err)(r.message);
|
|
85088
|
+
return r.ok ? 0 : 1;
|
|
85089
|
+
}
|
|
85090
|
+
throw new UsageError("usage: veoflow config [get [<key>] | set <key> <value> | test]");
|
|
85091
|
+
}
|
|
83373
85092
|
default:
|
|
83374
85093
|
throw new UsageError(`unknown command ${command}
|
|
83375
85094
|
|
|
@@ -83390,6 +85109,9 @@ ${USAGE}`);
|
|
|
83390
85109
|
if (!keepOpen) engine.close();
|
|
83391
85110
|
}
|
|
83392
85111
|
}
|
|
85112
|
+
function plain(text) {
|
|
85113
|
+
return text.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, "");
|
|
85114
|
+
}
|
|
83393
85115
|
export {
|
|
83394
85116
|
main
|
|
83395
85117
|
};
|