veoflow 0.1.0 → 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/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 = (target, all2) => {
29
+ var __export = (target2, all2) => {
30
30
  for (var name in all2)
31
- __defProp(target, name, { get: all2[name], enumerable: true });
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, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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(target, "default", { value: mod, enumerable: true }) : target,
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 target = run ?? this.currentRun();
956
- if (target === null) return new GraphReader(this.db, 0);
957
- const info = this.runInfo(target);
958
- if (!info) throw new Error(`run ${target} does not exist`);
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 ${target} is ${info.status}; only committed runs can be read`);
961
- return new GraphReader(this.db, target);
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, write) {
1126
+ writeStage(stage, write2) {
1097
1127
  this.assertOpen();
1098
1128
  const startedAt = now();
1099
- const scopes = new Set(write.scopes);
1100
- for (const { scope, fact } of write.facts) {
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 write.facts) {
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);
@@ -1268,11 +1298,89 @@ var init_evidence_store = __esm({
1268
1298
  });
1269
1299
 
1270
1300
  // packages/store/src/catalog.ts
1271
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, realpathSync as realpathSync2, rmSync, statSync as statSync2 } from "node:fs";
1301
+ import {
1302
+ existsSync as existsSync4,
1303
+ mkdirSync as mkdirSync2,
1304
+ readdirSync as readdirSync2,
1305
+ realpathSync as realpathSync2,
1306
+ renameSync as renameSync2,
1307
+ rmdirSync,
1308
+ rmSync,
1309
+ statSync as statSync2,
1310
+ symlinkSync
1311
+ } from "node:fs";
1272
1312
  import { homedir } from "node:os";
1273
1313
  import { basename, dirname as dirname3, join as join4, resolve, sep as sep2 } from "node:path";
1274
1314
  function defaultHome() {
1275
- return process.env.VEO_HOME ?? join4(homedir(), ".veo");
1315
+ const configured = process.env.VEOFLOW_HOME ?? process.env.VEO_HOME;
1316
+ if (configured) return configured;
1317
+ const home = join4(homedir(), ".veoflow");
1318
+ const legacy = join4(homedir(), ".veo");
1319
+ const outcome = migrateLegacyHome(legacy, home);
1320
+ switch (outcome) {
1321
+ case "moved":
1322
+ case "none":
1323
+ return home;
1324
+ case "busy":
1325
+ process.stderr.write(
1326
+ `veoflow: ${legacy} is in use by a running veo; using it for now. Stop it and run veoflow again to move your data to ${home}.
1327
+ `
1328
+ );
1329
+ return legacy;
1330
+ case "failed":
1331
+ process.stderr.write(
1332
+ `veoflow: could not move ${legacy} to ${home}; using ${legacy} for now (will retry).
1333
+ `
1334
+ );
1335
+ return legacy;
1336
+ case "both":
1337
+ process.stderr.write(
1338
+ `veoflow: both ${legacy} and ${home} hold projects; using ${home}. Your older projects are still in ${legacy}.
1339
+ `
1340
+ );
1341
+ return home;
1342
+ }
1343
+ }
1344
+ function inUse(dir) {
1345
+ const projects = join4(dir, "projects");
1346
+ if (!existsSync4(projects)) return false;
1347
+ for (const id of readdirSync2(projects)) {
1348
+ const graph = join4(projects, id, "graph.sqlite");
1349
+ if (!existsSync4(graph)) continue;
1350
+ try {
1351
+ const db = openDatabase(graph);
1352
+ try {
1353
+ const lock = db.prepare("SELECT pid FROM lock WHERE id = 1").get();
1354
+ if (lock && processAlive(Number(lock.pid))) return true;
1355
+ } finally {
1356
+ db.close();
1357
+ }
1358
+ } catch {
1359
+ }
1360
+ }
1361
+ return false;
1362
+ }
1363
+ function migrateLegacyHome(legacy, home) {
1364
+ if (!existsSync4(join4(legacy, "catalog.sqlite"))) return "none";
1365
+ if (existsSync4(home)) {
1366
+ if (existsSync4(join4(home, "catalog.sqlite"))) return "both";
1367
+ try {
1368
+ rmdirSync(home);
1369
+ } catch {
1370
+ return "both";
1371
+ }
1372
+ }
1373
+ if (inUse(legacy)) return "busy";
1374
+ try {
1375
+ renameSync2(legacy, home);
1376
+ } catch {
1377
+ return "failed";
1378
+ }
1379
+ try {
1380
+ symlinkSync(home, legacy, process.platform === "win32" ? "junction" : "dir");
1381
+ } catch {
1382
+ }
1383
+ return "moved";
1276
1384
  }
1277
1385
  function slug(name) {
1278
1386
  const s = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
@@ -1520,7 +1628,7 @@ async function runNow(request) {
1520
1628
  try {
1521
1629
  request.onEvent?.(event);
1522
1630
  } catch (e) {
1523
- console.error(`veo: run event listener failed: ${message(e)}`);
1631
+ console.error(`veoflow: run event listener failed: ${message(e)}`);
1524
1632
  }
1525
1633
  };
1526
1634
  const deadline = Date.now() + (request.lockTimeoutMs ?? 60 * 60 * 1e3);
@@ -1564,14 +1672,14 @@ async function runNow(request) {
1564
1672
  current = stage.name;
1565
1673
  run.startStage(stage.name);
1566
1674
  const started = Date.now();
1567
- const write = await stage.run({
1675
+ const write2 = await stage.run({
1568
1676
  projectId,
1569
1677
  runId: run.runId,
1570
1678
  plans,
1571
1679
  view: run.view(),
1572
1680
  evidence: request.evidence
1573
1681
  });
1574
- const info = run.writeStage(stage.name, write);
1682
+ const info = run.writeStage(stage.name, write2);
1575
1683
  emit({
1576
1684
  type: "stage.completed",
1577
1685
  projectId,
@@ -1864,7 +1972,15 @@ var init_src5 = __esm({
1864
1972
  // packages/query/src/engine.ts
1865
1973
  import { EventEmitter } from "node:events";
1866
1974
  import { basename as basename2, resolve as resolve2 } from "node:path";
1867
- var sleep2, slug2, Engine;
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;
1868
1984
  var init_engine = __esm({
1869
1985
  "packages/query/src/engine.ts"() {
1870
1986
  "use strict";
@@ -1872,6 +1988,17 @@ var init_engine = __esm({
1872
1988
  init_src3();
1873
1989
  init_src5();
1874
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;
1875
2002
  sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
1876
2003
  slug2 = (s) => s.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-.]+|-+$/g, "").slice(0, 48) || "source";
1877
2004
  Engine = class {
@@ -2047,6 +2174,17 @@ var init_engine = __esm({
2047
2174
  const reader = this.reader(project2);
2048
2175
  return { ...this.meta(project2, reader), files: reader.facts("File") };
2049
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
+ }
2050
2188
  /** A file's functions, the calls among them, its unresolved sites and findings. */
2051
2189
  fileGraph(args, cwd) {
2052
2190
  const project2 = this.resolveProject(args, cwd);
@@ -2089,7 +2227,12 @@ var init_engine = __esm({
2089
2227
  id: edge.id,
2090
2228
  from: edge.from,
2091
2229
  to: edge.to,
2092
- function: { id: otherId, qualifiedName: other?.qualifiedName ?? otherId, path },
2230
+ function: {
2231
+ id: otherId,
2232
+ qualifiedName: other?.qualifiedName ?? otherId,
2233
+ path,
2234
+ ...other ? { line: other.evidence.span.start.line } : {}
2235
+ },
2093
2236
  form: edge.form,
2094
2237
  resolution: edge.resolution,
2095
2238
  evidence: edge.evidence
@@ -2149,6 +2292,223 @@ var init_engine = __esm({
2149
2292
  });
2150
2293
  return { ...this.meta(project2, reader), function: fn.id, direction, calls };
2151
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
+ }
2152
2512
  /** Unresolved call sites: open questions only, unless `includeAll` (design A6). */
2153
2513
  listUnresolvedSites(args, cwd) {
2154
2514
  const project2 = this.resolveProject(args, cwd);
@@ -2195,7 +2555,7 @@ var init_view = __esm({
2195
2555
  file: null,
2196
2556
  selection: null,
2197
2557
  panel: "evidence",
2198
- showUnresolved: true
2558
+ showUnresolved: false
2199
2559
  };
2200
2560
  str = (field, optional2 = false) => (a) => optional2 && a[field] === void 0 || typeof a[field] === "string" && a[field].length > 0 ? [] : [field];
2201
2561
  oneOf = (field, values) => (a) => values.includes(a[field]) ? [] : [field];
@@ -2222,7 +2582,9 @@ var init_view = __esm({
2222
2582
  ...s,
2223
2583
  file: a.file ?? s.file,
2224
2584
  selection: { kind: a.kind, id: a.id },
2225
- panel: "evidence"
2585
+ panel: "evidence",
2586
+ // An unresolved site is only drawn when sites are shown.
2587
+ showUnresolved: a.kind === "site" ? true : s.showUnresolved
2226
2588
  })
2227
2589
  },
2228
2590
  clearSelection: {
@@ -2232,9 +2594,9 @@ var init_view = __esm({
2232
2594
  apply: (s) => ({ ...s, selection: null })
2233
2595
  },
2234
2596
  showPanel: {
2235
- description: "Show the evidence panel or the open-questions list",
2597
+ description: "Show the evidence panel, the open-questions list or the last answer",
2236
2598
  control: { kind: "tab", testId: "show-panel" },
2237
- check: oneOf("panel", ["evidence", "questions"]),
2599
+ check: oneOf("panel", ["evidence", "questions", "answer"]),
2238
2600
  apply: (s, a) => ({ ...s, panel: a.panel })
2239
2601
  },
2240
2602
  toggleUnresolved: {
@@ -2254,6 +2616,16 @@ var init_view = __esm({
2254
2616
  description: "Analyze the project again",
2255
2617
  control: { kind: "button", testId: "reanalyze" },
2256
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
2257
2629
  }
2258
2630
  };
2259
2631
  }
@@ -3280,8 +3652,8 @@ var init_types = __esm({
3280
3652
  description
3281
3653
  });
3282
3654
  }
3283
- pipe(target) {
3284
- return ZodPipeline.create(this, target);
3655
+ pipe(target2) {
3656
+ return ZodPipeline.create(this, target2);
3285
3657
  }
3286
3658
  readonly() {
3287
3659
  return ZodReadonly.create(this);
@@ -6381,8 +6753,8 @@ function defineLazy(object3, key, getter) {
6381
6753
  function objectClone(obj) {
6382
6754
  return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
6383
6755
  }
6384
- function assignProp(target, prop, value) {
6385
- Object.defineProperty(target, prop, {
6756
+ function assignProp(target2, prop, value) {
6757
+ Object.defineProperty(target2, prop, {
6386
6758
  value,
6387
6759
  writable: true,
6388
6760
  enumerable: true,
@@ -6396,8 +6768,8 @@ function rawShape(def) {
6396
6768
  function sourceShape(schema) {
6397
6769
  return rawShape(schema._zod.def) ?? schema._zod.def.shape;
6398
6770
  }
6399
- function deferProp(target, key, getter) {
6400
- Object.defineProperty(target, key, {
6771
+ function deferProp(target2, key, getter) {
6772
+ Object.defineProperty(target2, key, {
6401
6773
  get() {
6402
6774
  const value = getter();
6403
6775
  assignProp(this, key, value);
@@ -6407,36 +6779,36 @@ function deferProp(target, key, getter) {
6407
6779
  configurable: true
6408
6780
  });
6409
6781
  }
6410
- function putProp(target, key, value) {
6411
- if (key in target)
6412
- assignProp(target, key, value);
6782
+ function putProp(target2, key, value) {
6783
+ if (key in target2)
6784
+ assignProp(target2, key, value);
6413
6785
  else
6414
- target[key] = value;
6786
+ target2[key] = value;
6415
6787
  }
6416
- function mirrorShape(target, source, keys, wrap) {
6788
+ function mirrorShape(target2, source, keys, wrap) {
6417
6789
  const raw = sourceShape(source);
6418
6790
  for (const key of keys) {
6419
6791
  const desc = Object.getOwnPropertyDescriptor(raw, key);
6420
6792
  if (!desc.enumerable)
6421
6793
  continue;
6422
6794
  if (desc.get) {
6423
- deferProp(target, key, () => {
6795
+ deferProp(target2, key, () => {
6424
6796
  const value = source._zod.def.shape[key];
6425
6797
  return wrap ? wrap(value, key) : value;
6426
6798
  });
6427
6799
  } else
6428
- putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
6800
+ putProp(target2, key, wrap ? wrap(desc.value, key) : desc.value);
6429
6801
  }
6430
6802
  }
6431
- function mirrorProps(target, source) {
6803
+ function mirrorProps(target2, source) {
6432
6804
  for (const key of Reflect.ownKeys(source)) {
6433
6805
  const desc = Object.getOwnPropertyDescriptor(source, key);
6434
6806
  if (!desc.enumerable)
6435
6807
  continue;
6436
6808
  if (desc.get)
6437
- deferProp(target, key, () => source[key]);
6809
+ deferProp(target2, key, () => source[key]);
6438
6810
  else
6439
- putProp(target, key, desc.value);
6811
+ putProp(target2, key, desc.value);
6440
6812
  }
6441
6813
  }
6442
6814
  function mergeDefs(...defs) {
@@ -6545,35 +6917,35 @@ function normalizeParams(_params) {
6545
6917
  return params;
6546
6918
  }
6547
6919
  function createTransparentProxy(getter) {
6548
- let target;
6920
+ let target2;
6549
6921
  return new Proxy({}, {
6550
6922
  get(_, prop, receiver) {
6551
- target ?? (target = getter());
6552
- return Reflect.get(target, prop, receiver);
6923
+ target2 ?? (target2 = getter());
6924
+ return Reflect.get(target2, prop, receiver);
6553
6925
  },
6554
6926
  set(_, prop, value, receiver) {
6555
- target ?? (target = getter());
6556
- return Reflect.set(target, prop, value, receiver);
6927
+ target2 ?? (target2 = getter());
6928
+ return Reflect.set(target2, prop, value, receiver);
6557
6929
  },
6558
6930
  has(_, prop) {
6559
- target ?? (target = getter());
6560
- return Reflect.has(target, prop);
6931
+ target2 ?? (target2 = getter());
6932
+ return Reflect.has(target2, prop);
6561
6933
  },
6562
6934
  deleteProperty(_, prop) {
6563
- target ?? (target = getter());
6564
- return Reflect.deleteProperty(target, prop);
6935
+ target2 ?? (target2 = getter());
6936
+ return Reflect.deleteProperty(target2, prop);
6565
6937
  },
6566
6938
  ownKeys(_) {
6567
- target ?? (target = getter());
6568
- return Reflect.ownKeys(target);
6939
+ target2 ?? (target2 = getter());
6940
+ return Reflect.ownKeys(target2);
6569
6941
  },
6570
6942
  getOwnPropertyDescriptor(_, prop) {
6571
- target ?? (target = getter());
6572
- return Reflect.getOwnPropertyDescriptor(target, prop);
6943
+ target2 ?? (target2 = getter());
6944
+ return Reflect.getOwnPropertyDescriptor(target2, prop);
6573
6945
  },
6574
6946
  defineProperty(_, prop, descriptor) {
6575
- target ?? (target = getter());
6576
- return Reflect.defineProperty(target, prop, descriptor);
6947
+ target2 ?? (target2 = getter());
6948
+ return Reflect.defineProperty(target2, prop, descriptor);
6577
6949
  }
6578
6950
  });
6579
6951
  }
@@ -7128,10 +7500,10 @@ function $constructor(name, initializer3, proto, params) {
7128
7500
  let up = own2;
7129
7501
  while (up && up !== ctorProto)
7130
7502
  up = Object.getPrototypeOf(up);
7131
- const target = up ?? own2;
7132
- if (!initialized.has(target)) {
7133
- initialized.add(target);
7134
- members(target, protoMembers);
7503
+ const target2 = up ?? own2;
7504
+ if (!initialized.has(target2)) {
7505
+ initialized.add(target2);
7506
+ members(target2, protoMembers);
7135
7507
  }
7136
7508
  }
7137
7509
  const proto2 = _.prototype;
@@ -16584,8 +16956,8 @@ var init_pt = __esm({
16584
16956
  case "not_multiple_of":
16585
16957
  return `N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${issue2.divisor}`;
16586
16958
  case "unrecognized_keys": {
16587
- const plural2 = issue2.keys.length > 1 ? "s" : "";
16588
- return `Chave${plural2} inv\xE1lida${plural2}: ${joinValues(issue2.keys, ", ")}`;
16959
+ const plural3 = issue2.keys.length > 1 ? "s" : "";
16960
+ return `Chave${plural3} inv\xE1lida${plural3}: ${joinValues(issue2.keys, ", ")}`;
16589
16961
  }
16590
16962
  case "invalid_key":
16591
16963
  return `Entrada inv\xE1lida n${translateOriginWithArticle(issue2.origin, "definite")}`;
@@ -16735,8 +17107,8 @@ var init_pt_BR = __esm({
16735
17107
  case "not_multiple_of":
16736
17108
  return `N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${issue2.divisor}`;
16737
17109
  case "unrecognized_keys": {
16738
- const plural2 = issue2.keys.length > 1 ? "s" : "";
16739
- return `Chave${plural2} inv\xE1lida${plural2}: ${joinValues(issue2.keys, ", ")}`;
17110
+ const plural3 = issue2.keys.length > 1 ? "s" : "";
17111
+ return `Chave${plural3} inv\xE1lida${plural3}: ${joinValues(issue2.keys, ", ")}`;
16740
17112
  }
16741
17113
  case "invalid_key":
16742
17114
  return `Entrada inv\xE1lida n${translateOriginWithArticle(issue2.origin, "definite")}`;
@@ -19115,8 +19487,8 @@ function withParser(schema, parser) {
19115
19487
  installCompiledUserMethods(clone2, schema, parser);
19116
19488
  return clone2;
19117
19489
  }
19118
- function installCompiledUserMethods(target, source, parser) {
19119
- const targetAny = target;
19490
+ function installCompiledUserMethods(target2, source, parser) {
19491
+ const targetAny = target2;
19120
19492
  const sourceAny = source;
19121
19493
  if (typeof sourceAny.safeParse === "function") {
19122
19494
  const originalSafeParse = sourceAny.safeParse;
@@ -21746,26 +22118,26 @@ var init_api = __esm({
21746
22118
  });
21747
22119
 
21748
22120
  // node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/to-json-schema.js
21749
- function assignProps(target, ...sources) {
22121
+ function assignProps(target2, ...sources) {
21750
22122
  for (const source of sources) {
21751
22123
  for (const key of Reflect.ownKeys(source)) {
21752
22124
  if (Object.prototype.propertyIsEnumerable.call(source, key)) {
21753
- assignProp(target, key, source[key]);
22125
+ assignProp(target2, key, source[key]);
21754
22126
  }
21755
22127
  }
21756
22128
  }
21757
- return target;
22129
+ return target2;
21758
22130
  }
21759
22131
  function initializeContext(params) {
21760
- let target = params?.target ?? "draft-2020-12";
21761
- if (target === "draft-4")
21762
- target = "draft-04";
21763
- if (target === "draft-7")
21764
- target = "draft-07";
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";
21765
22137
  return {
21766
22138
  processors: params.processors ?? {},
21767
22139
  metadataRegistry: params?.metadata ?? globalRegistry,
21768
- target,
22140
+ target: target2,
21769
22141
  unrepresentable: params?.unrepresentable ?? "throw",
21770
22142
  override: params?.override ?? (() => {
21771
22143
  }),
@@ -22273,8 +22645,8 @@ var init_to_json_schema = __esm({
22273
22645
  return finalize(ctx, schema);
22274
22646
  };
22275
22647
  createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
22276
- const { libraryOptions, target } = params ?? {};
22277
- const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
22648
+ const { libraryOptions, target: target2 } = params ?? {};
22649
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target: target2, io, processors });
22278
22650
  processSchema(schema, ctx);
22279
22651
  extractDefs(ctx, schema);
22280
22652
  return finalize(ctx, schema);
@@ -24792,8 +25164,8 @@ var init_schemas3 = __esm({
24792
25164
  catch(params) {
24793
25165
  return _catch2(this, params);
24794
25166
  },
24795
- pipe(target) {
24796
- return pipe(this, target);
25167
+ pipe(target2) {
25168
+ return pipe(this, target2);
24797
25169
  },
24798
25170
  readonly() {
24799
25171
  return readonly(this);
@@ -33212,8 +33584,8 @@ var require_resolve = __commonJS({
33212
33584
  }
33213
33585
  return count;
33214
33586
  }
33215
- function getFullPath(resolver, id = "", normalize) {
33216
- if (normalize !== false)
33587
+ function getFullPath(resolver, id = "", normalize2) {
33588
+ if (normalize2 !== false)
33217
33589
  id = normalizeId(id);
33218
33590
  const p = resolver.parse(id);
33219
33591
  return _getFullPath(resolver, p);
@@ -34808,7 +35180,7 @@ var require_fast_uri = __commonJS({
34808
35180
  }
34809
35181
  return decodedScheme;
34810
35182
  }
34811
- function normalize(uri, options) {
35183
+ function normalize2(uri, options) {
34812
35184
  if (typeof uri === "string") {
34813
35185
  uri = /** @type {T} */
34814
35186
  normalizeString(uri, options);
@@ -34852,57 +35224,57 @@ var require_fast_uri = __commonJS({
34852
35224
  return serialize(resolved, schemelessOptions);
34853
35225
  }
34854
35226
  function resolveComponent(base, relative2, options, skipNormalization) {
34855
- const target = {};
35227
+ const target2 = {};
34856
35228
  if (!skipNormalization) {
34857
35229
  base = parse4(serialize(base, options), options);
34858
35230
  relative2 = parse4(serialize(relative2, options), options);
34859
35231
  }
34860
35232
  options = options || {};
34861
35233
  if (!options.tolerant && relative2.scheme) {
34862
- target.scheme = relative2.scheme;
34863
- target.userinfo = relative2.userinfo;
34864
- target.host = relative2.host;
34865
- target.port = relative2.port;
34866
- target.path = removeDotSegments(relative2.path || "");
34867
- target.query = relative2.query;
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;
34868
35240
  } else {
34869
35241
  if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
34870
- target.userinfo = relative2.userinfo;
34871
- target.host = relative2.host;
34872
- target.port = relative2.port;
34873
- target.path = removeDotSegments(relative2.path || "");
34874
- target.query = relative2.query;
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;
34875
35247
  } else {
34876
35248
  if (!relative2.path) {
34877
- target.path = base.path;
35249
+ target2.path = base.path;
34878
35250
  if (relative2.query !== void 0) {
34879
- target.query = relative2.query;
35251
+ target2.query = relative2.query;
34880
35252
  } else {
34881
- target.query = base.query;
35253
+ target2.query = base.query;
34882
35254
  }
34883
35255
  } else {
34884
35256
  if (relative2.path[0] === "/") {
34885
- target.path = removeDotSegments(relative2.path);
35257
+ target2.path = removeDotSegments(relative2.path);
34886
35258
  } else {
34887
35259
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
34888
- target.path = "/" + relative2.path;
35260
+ target2.path = "/" + relative2.path;
34889
35261
  } else if (!base.path) {
34890
- target.path = relative2.path;
35262
+ target2.path = relative2.path;
34891
35263
  } else {
34892
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
35264
+ target2.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
34893
35265
  }
34894
- target.path = removeDotSegments(target.path);
35266
+ target2.path = removeDotSegments(target2.path);
34895
35267
  }
34896
- target.query = relative2.query;
35268
+ target2.query = relative2.query;
34897
35269
  }
34898
- target.userinfo = base.userinfo;
34899
- target.host = base.host;
34900
- target.port = base.port;
35270
+ target2.userinfo = base.userinfo;
35271
+ target2.host = base.host;
35272
+ target2.port = base.port;
34901
35273
  }
34902
- target.scheme = base.scheme;
35274
+ target2.scheme = base.scheme;
34903
35275
  }
34904
- target.fragment = relative2.fragment;
34905
- return target;
35276
+ target2.fragment = relative2.fragment;
35277
+ return target2;
34906
35278
  }
34907
35279
  function equal(uriA, uriB, options) {
34908
35280
  const normalizedA = normalizeComparableURI(uriA, options);
@@ -35186,7 +35558,7 @@ var require_fast_uri = __commonJS({
35186
35558
  }
35187
35559
  var fastUri = {
35188
35560
  SCHEMES,
35189
- normalize,
35561
+ normalize: normalize2,
35190
35562
  resolve: resolve5,
35191
35563
  resolveComponent,
35192
35564
  equal,
@@ -35568,12 +35940,12 @@ var require_core = __commonJS({
35568
35940
  return this;
35569
35941
  }
35570
35942
  keywordMetaschema.call(this, def);
35571
- const definition = {
35943
+ const definition2 = {
35572
35944
  ...def,
35573
35945
  type: (0, dataType_1.getJSONTypes)(def.type),
35574
35946
  schemaType: (0, dataType_1.getJSONTypes)(def.schemaType)
35575
35947
  };
35576
- (0, util_1.eachItem)(keyword, definition.type.length === 0 ? (k) => addRule.call(this, k, definition) : (k) => definition.type.forEach((t) => addRule.call(this, k, definition, t)));
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)));
35577
35949
  return this;
35578
35950
  }
35579
35951
  getKeyword(keyword) {
@@ -35766,9 +36138,9 @@ var require_core = __commonJS({
35766
36138
  throw new Error('$data keyword must have "code" or "validate" function');
35767
36139
  }
35768
36140
  }
35769
- function addRule(keyword, definition, dataType) {
36141
+ function addRule(keyword, definition2, dataType) {
35770
36142
  var _a3;
35771
- const post = definition === null || definition === void 0 ? void 0 : definition.post;
36143
+ const post = definition2 === null || definition2 === void 0 ? void 0 : definition2.post;
35772
36144
  if (dataType && post)
35773
36145
  throw new Error('keyword with "post" flag cannot have "type"');
35774
36146
  const { RULES } = this;
@@ -35778,22 +36150,22 @@ var require_core = __commonJS({
35778
36150
  RULES.rules.push(ruleGroup);
35779
36151
  }
35780
36152
  RULES.keywords[keyword] = true;
35781
- if (!definition)
36153
+ if (!definition2)
35782
36154
  return;
35783
36155
  const rule = {
35784
36156
  keyword,
35785
36157
  definition: {
35786
- ...definition,
35787
- type: (0, dataType_1.getJSONTypes)(definition.type),
35788
- schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType)
36158
+ ...definition2,
36159
+ type: (0, dataType_1.getJSONTypes)(definition2.type),
36160
+ schemaType: (0, dataType_1.getJSONTypes)(definition2.schemaType)
35789
36161
  }
35790
36162
  };
35791
- if (definition.before)
35792
- addBeforeRule.call(this, ruleGroup, rule, definition.before);
36163
+ if (definition2.before)
36164
+ addBeforeRule.call(this, ruleGroup, rule, definition2.before);
35793
36165
  else
35794
36166
  ruleGroup.rules.push(rule);
35795
36167
  RULES.all[keyword] = rule;
35796
- (_a3 = definition.implements) === null || _a3 === void 0 ? void 0 : _a3.forEach((kwd) => this.addKeyword(kwd));
36168
+ (_a3 = definition2.implements) === null || _a3 === void 0 ? void 0 : _a3.forEach((kwd) => this.addKeyword(kwd));
35797
36169
  }
35798
36170
  function addBeforeRule(ruleGroup, rule, before) {
35799
36171
  const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
@@ -39135,24 +39507,24 @@ var init_mcp = __esm({
39135
39507
  }
39136
39508
  });
39137
39509
  this.server.setRequestHandler(ListToolsRequestSchema, () => ({
39138
- tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name, tool]) => {
39510
+ tools: Object.entries(this._registeredTools).filter(([, tool2]) => tool2.enabled).map(([name, tool2]) => {
39139
39511
  const toolDefinition = {
39140
39512
  name,
39141
- title: tool.title,
39142
- description: tool.description,
39513
+ title: tool2.title,
39514
+ description: tool2.description,
39143
39515
  inputSchema: (() => {
39144
- const obj = normalizeObjectSchema(tool.inputSchema);
39516
+ const obj = normalizeObjectSchema(tool2.inputSchema);
39145
39517
  return obj ? toJsonSchemaCompat(obj, {
39146
39518
  strictUnions: true,
39147
39519
  pipeStrategy: "input"
39148
39520
  }) : EMPTY_OBJECT_JSON_SCHEMA;
39149
39521
  })(),
39150
- annotations: tool.annotations,
39151
- execution: tool.execution,
39152
- _meta: tool._meta
39522
+ annotations: tool2.annotations,
39523
+ execution: tool2.execution,
39524
+ _meta: tool2._meta
39153
39525
  };
39154
- if (tool.outputSchema) {
39155
- const obj = normalizeObjectSchema(tool.outputSchema);
39526
+ if (tool2.outputSchema) {
39527
+ const obj = normalizeObjectSchema(tool2.outputSchema);
39156
39528
  if (obj) {
39157
39529
  toolDefinition.outputSchema = toJsonSchemaCompat(obj, {
39158
39530
  strictUnions: true,
@@ -39165,16 +39537,16 @@ var init_mcp = __esm({
39165
39537
  }));
39166
39538
  this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
39167
39539
  try {
39168
- const tool = this._registeredTools[request.params.name];
39169
- if (!tool) {
39540
+ const tool2 = this._registeredTools[request.params.name];
39541
+ if (!tool2) {
39170
39542
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
39171
39543
  }
39172
- if (!tool.enabled) {
39544
+ if (!tool2.enabled) {
39173
39545
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
39174
39546
  }
39175
39547
  const isTaskRequest = !!request.params.task;
39176
- const taskSupport = tool.execution?.taskSupport;
39177
- const isTaskHandler = "createTask" in tool.handler;
39548
+ const taskSupport = tool2.execution?.taskSupport;
39549
+ const isTaskHandler = "createTask" in tool2.handler;
39178
39550
  if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) {
39179
39551
  throw new McpError(ErrorCode.InternalError, `Tool ${request.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
39180
39552
  }
@@ -39182,14 +39554,14 @@ var init_mcp = __esm({
39182
39554
  throw new McpError(ErrorCode.MethodNotFound, `Tool ${request.params.name} requires task augmentation (taskSupport: 'required')`);
39183
39555
  }
39184
39556
  if (taskSupport === "optional" && !isTaskRequest && isTaskHandler) {
39185
- return await this.handleAutomaticTaskPolling(tool, request, extra);
39557
+ return await this.handleAutomaticTaskPolling(tool2, request, extra);
39186
39558
  }
39187
- const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
39188
- const result2 = await this.executeToolHandler(tool, args, extra);
39559
+ const args = await this.validateToolInput(tool2, request.params.arguments, request.params.name);
39560
+ const result2 = await this.executeToolHandler(tool2, args, extra);
39189
39561
  if (isTaskRequest) {
39190
39562
  return result2;
39191
39563
  }
39192
- await this.validateToolOutput(tool, result2, request.params.name);
39564
+ await this.validateToolOutput(tool2, result2, request.params.name);
39193
39565
  return result2;
39194
39566
  } catch (error62) {
39195
39567
  if (error62 instanceof McpError) {
@@ -39222,12 +39594,12 @@ var init_mcp = __esm({
39222
39594
  /**
39223
39595
  * Validates tool input arguments against the tool's input schema.
39224
39596
  */
39225
- async validateToolInput(tool, args, toolName) {
39226
- if (!tool.inputSchema) {
39597
+ async validateToolInput(tool2, args, toolName) {
39598
+ if (!tool2.inputSchema) {
39227
39599
  return void 0;
39228
39600
  }
39229
- const inputObj = normalizeObjectSchema(tool.inputSchema);
39230
- const schemaToParse = inputObj ?? tool.inputSchema;
39601
+ const inputObj = normalizeObjectSchema(tool2.inputSchema);
39602
+ const schemaToParse = inputObj ?? tool2.inputSchema;
39231
39603
  const parseResult = await safeParseAsync2(schemaToParse, args);
39232
39604
  if (!parseResult.success) {
39233
39605
  const error62 = "error" in parseResult ? parseResult.error : "Unknown error";
@@ -39239,8 +39611,8 @@ var init_mcp = __esm({
39239
39611
  /**
39240
39612
  * Validates tool output against the tool's output schema.
39241
39613
  */
39242
- async validateToolOutput(tool, result2, toolName) {
39243
- if (!tool.outputSchema) {
39614
+ async validateToolOutput(tool2, result2, toolName) {
39615
+ if (!tool2.outputSchema) {
39244
39616
  return;
39245
39617
  }
39246
39618
  if (!("content" in result2)) {
@@ -39252,7 +39624,7 @@ var init_mcp = __esm({
39252
39624
  if (!result2.structuredContent) {
39253
39625
  throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`);
39254
39626
  }
39255
- const outputObj = normalizeObjectSchema(tool.outputSchema);
39627
+ const outputObj = normalizeObjectSchema(tool2.outputSchema);
39256
39628
  const parseResult = await safeParseAsync2(outputObj, result2.structuredContent);
39257
39629
  if (!parseResult.success) {
39258
39630
  const error62 = "error" in parseResult ? parseResult.error : "Unknown error";
@@ -39263,15 +39635,15 @@ var init_mcp = __esm({
39263
39635
  /**
39264
39636
  * Executes a tool handler (either regular or task-based).
39265
39637
  */
39266
- async executeToolHandler(tool, args, extra) {
39267
- const handler = tool.handler;
39638
+ async executeToolHandler(tool2, args, extra) {
39639
+ const handler = tool2.handler;
39268
39640
  const isTaskHandler = "createTask" in handler;
39269
39641
  if (isTaskHandler) {
39270
39642
  if (!extra.taskStore) {
39271
39643
  throw new Error("No task store provided.");
39272
39644
  }
39273
39645
  const taskExtra = { ...extra, taskStore: extra.taskStore };
39274
- if (tool.inputSchema) {
39646
+ if (tool2.inputSchema) {
39275
39647
  const typedHandler = handler;
39276
39648
  return await Promise.resolve(typedHandler.createTask(args, taskExtra));
39277
39649
  } else {
@@ -39279,7 +39651,7 @@ var init_mcp = __esm({
39279
39651
  return await Promise.resolve(typedHandler.createTask(taskExtra));
39280
39652
  }
39281
39653
  }
39282
- if (tool.inputSchema) {
39654
+ if (tool2.inputSchema) {
39283
39655
  const typedHandler = handler;
39284
39656
  return await Promise.resolve(typedHandler(args, extra));
39285
39657
  } else {
@@ -39290,12 +39662,12 @@ var init_mcp = __esm({
39290
39662
  /**
39291
39663
  * Handles automatic task polling for tools with taskSupport 'optional'.
39292
39664
  */
39293
- async handleAutomaticTaskPolling(tool, request, extra) {
39665
+ async handleAutomaticTaskPolling(tool2, request, extra) {
39294
39666
  if (!extra.taskStore) {
39295
39667
  throw new Error("No task store provided for task-capable tool.");
39296
39668
  }
39297
- const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
39298
- const handler = tool.handler;
39669
+ const args = await this.validateToolInput(tool2, request.params.arguments, request.params.name);
39670
+ const handler = tool2.handler;
39299
39671
  const taskExtra = { ...extra, taskStore: extra.taskStore };
39300
39672
  const createTaskResult = args ? await Promise.resolve(handler.createTask(args, taskExtra)) : (
39301
39673
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -39933,8 +40305,8 @@ function errorJson(e) {
39933
40305
  return { code: "internal", message: e instanceof Error ? e.message.split("\n")[0] : String(e) };
39934
40306
  }
39935
40307
  async function callTool(engine, name, args, cwd) {
39936
- const tool = TOOLS[name];
39937
- return await tool.call(engine, args, cwd);
40308
+ const tool2 = TOOLS[name];
40309
+ return await tool2.call(engine, args, cwd);
39938
40310
  }
39939
40311
  function result(value, isError = false) {
39940
40312
  return {
@@ -39943,23 +40315,23 @@ function result(value, isError = false) {
39943
40315
  };
39944
40316
  }
39945
40317
  function createMcpServer(engine, options = {}) {
39946
- const server = new McpServer({ name: "veo", version: "0.1.0" });
39947
- for (const [name, tool] of Object.entries(TOOLS)) {
40318
+ const server = new McpServer({ name: "veoflow", version: options.version ?? "0.0.0" });
40319
+ for (const [name, tool2] of Object.entries(TOOLS)) {
39948
40320
  server.registerTool(
39949
40321
  name,
39950
- { description: tool.description, inputSchema: external_exports.strictObject(tool.input) },
40322
+ { description: tool2.description, inputSchema: external_exports.strictObject(tool2.input) },
39951
40323
  (() => result({ code: "internal", message: "unreachable" }, true))
39952
40324
  );
39953
40325
  }
39954
40326
  server.server.setRequestHandler(CallToolRequestSchema, async (request) => {
39955
40327
  const name = request.params.name;
39956
- const tool = Object.hasOwn(TOOLS, name) ? TOOLS[name] : void 0;
39957
- if (!tool)
40328
+ const tool2 = Object.hasOwn(TOOLS, name) ? TOOLS[name] : void 0;
40329
+ if (!tool2)
39958
40330
  return result(
39959
40331
  { code: "not-found", message: `no tool ${name}`, details: { kind: "tool", id: name } },
39960
40332
  true
39961
40333
  );
39962
- const parsed = external_exports.object(tool.input).strict().safeParse(request.params.arguments ?? {});
40334
+ const parsed = external_exports.object(tool2.input).strict().safeParse(request.params.arguments ?? {});
39963
40335
  if (!parsed.success) {
39964
40336
  const fields = [
39965
40337
  ...new Set(
@@ -39987,9 +40359,9 @@ function createMcpServer(engine, options = {}) {
39987
40359
  });
39988
40360
  return server;
39989
40361
  }
39990
- async function serveStdio(home) {
40362
+ async function serveStdio(home, version3) {
39991
40363
  const engine = new Engine(home);
39992
- const server = createMcpServer(engine, { cwd: process.cwd() });
40364
+ const server = createMcpServer(engine, { cwd: process.cwd(), ...version3 ? { version: version3 } : {} });
39993
40365
  await server.connect(new StdioServerTransport());
39994
40366
  }
39995
40367
  var project, functionId, TOOLS;
@@ -40081,6 +40453,42 @@ var init_server3 = __esm({
40081
40453
  includeAll: external_exports.boolean().optional()
40082
40454
  },
40083
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)
40084
40492
  }
40085
40493
  };
40086
40494
  }
@@ -44772,8 +45180,8 @@ var require_send = __commonJS({
44772
45180
  var { parseTokenList } = require_parseTokenList();
44773
45181
  var { createHttpError } = require_createHttpError();
44774
45182
  var extname = path.extname;
44775
- var join8 = path.join;
44776
- var normalize = path.normalize;
45183
+ var join9 = path.join;
45184
+ var normalize2 = path.normalize;
44777
45185
  var resolve5 = path.resolve;
44778
45186
  var sep3 = path.sep;
44779
45187
  var Readable = stream.Readable;
@@ -44852,20 +45260,20 @@ var require_send = __commonJS({
44852
45260
  let parts;
44853
45261
  if (root !== null) {
44854
45262
  if (path2) {
44855
- path2 = normalize("." + sep3 + path2);
45263
+ path2 = normalize2("." + sep3 + path2);
44856
45264
  }
44857
45265
  if (UP_PATH_REGEXP.test(path2)) {
44858
45266
  debug('malicious path "%s"', path2);
44859
45267
  return { statusCode: 403 };
44860
45268
  }
44861
45269
  parts = path2.split(sep3);
44862
- path2 = normalize(join8(root, path2));
45270
+ path2 = normalize2(join9(root, path2));
44863
45271
  } else {
44864
45272
  if (UP_PATH_REGEXP.test(path2)) {
44865
45273
  debug('malicious path "%s"', path2);
44866
45274
  return { statusCode: 403 };
44867
45275
  }
44868
- parts = normalize(path2).split(sep3);
45276
+ parts = normalize2(path2).split(sep3);
44869
45277
  path2 = resolve5(path2);
44870
45278
  }
44871
45279
  return { path: path2, parts };
@@ -45142,7 +45550,7 @@ var require_send = __commonJS({
45142
45550
  let err;
45143
45551
  for (let i = 0; i < options.index.length; i++) {
45144
45552
  const index = options.index[i];
45145
- const p = join8(path2, index);
45553
+ const p = join9(path2, index);
45146
45554
  const { error: error62, stat } = await tryStat(p);
45147
45555
  if (error62) {
45148
45556
  err = error62;
@@ -46117,8 +46525,8 @@ var require_dirList = __commonJS({
46117
46525
  FST_STATIC_MULTIROOT_LIST_CONFLICT
46118
46526
  } = require_errors2();
46119
46527
  var fastqConcurrency = Math.max(1, os.cpus().length - 1);
46120
- function isPathInsideRoot(root, target) {
46121
- const relativePath = path.relative(root, target);
46528
+ function isPathInsideRoot(root, target2) {
46529
+ const relativePath = path.relative(root, target2);
46122
46530
  return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${path.sep}`) && !path.isAbsolute(relativePath);
46123
46531
  }
46124
46532
  var dirList = {
@@ -46313,7 +46721,7 @@ var require_static = __commonJS({
46313
46721
  "use strict";
46314
46722
  var path = __require("node:path");
46315
46723
  var { fileURLToPath: fileURLToPath3 } = __require("node:url");
46316
- var { statSync: statSync4 } = __require("node:fs");
46724
+ var { statSync: statSync5 } = __require("node:fs");
46317
46725
  var { readdir, stat } = __require("node:fs/promises");
46318
46726
  var { basename: basename4 } = __require("node:path");
46319
46727
  var { glob } = require_index_min();
@@ -46490,8 +46898,8 @@ var require_static = __commonJS({
46490
46898
  }
46491
46899
  }
46492
46900
  }
46493
- for (const [dirname6, rootPath] of indexDirs.entries()) {
46494
- const pathname = dirname6 + (dirname6.endsWith("/") ? "" : "/");
46901
+ for (const [dirname7, rootPath] of indexDirs.entries()) {
46902
+ const pathname = dirname7 + (dirname7.endsWith("/") ? "" : "/");
46495
46903
  const file2 = "/" + pathname.replace(prefix, "");
46496
46904
  setUpHeadAndGet(routeOpts, pathname, file2, rootPath);
46497
46905
  if (opts.redirect === true) {
@@ -46757,7 +47165,7 @@ var require_static = __commonJS({
46757
47165
  }
46758
47166
  let pathStat;
46759
47167
  try {
46760
- pathStat = statSync4(rootPath);
47168
+ pathStat = statSync5(rootPath);
46761
47169
  } catch (e) {
46762
47170
  if (e.code === "ENOENT") {
46763
47171
  !suppressWarning && fastify.log.warn(`"root" path "${rootPath}" must exist`);
@@ -46861,7 +47269,7 @@ var require_static = __commonJS({
46861
47269
  return indexFiles.find((filename) => {
46862
47270
  const p = path.join(root, pathname, filename);
46863
47271
  try {
46864
- const stats = statSync4(p);
47272
+ const stats = statSync5(p);
46865
47273
  return !stats.isDirectory();
46866
47274
  } catch {
46867
47275
  return false;
@@ -47037,17 +47445,17 @@ var require_buffer_util = __commonJS({
47037
47445
  function concat(list, totalLength) {
47038
47446
  if (list.length === 0) return EMPTY_BUFFER;
47039
47447
  if (list.length === 1) return list[0];
47040
- const target = Buffer.allocUnsafe(totalLength);
47448
+ const target2 = Buffer.allocUnsafe(totalLength);
47041
47449
  let offset = 0;
47042
47450
  for (let i = 0; i < list.length; i++) {
47043
47451
  const buf = list[i];
47044
- target.set(buf, offset);
47452
+ target2.set(buf, offset);
47045
47453
  offset += buf.length;
47046
47454
  }
47047
47455
  if (offset < totalLength) {
47048
- return new FastBuffer(target.buffer, target.byteOffset, offset);
47456
+ return new FastBuffer(target2.buffer, target2.byteOffset, offset);
47049
47457
  }
47050
- return target;
47458
+ return target2;
47051
47459
  }
47052
47460
  function _mask(source, mask, output2, offset, length) {
47053
47461
  for (let i = 0; i < length; i++) {
@@ -48471,29 +48879,29 @@ var require_sender = __commonJS({
48471
48879
  offset += 2;
48472
48880
  payloadLength = 126;
48473
48881
  }
48474
- const target = Buffer.allocUnsafe(merge2 ? dataLength + offset : offset);
48475
- target[0] = options.fin ? options.opcode | 128 : options.opcode;
48476
- if (options.rsv1) target[0] |= 64;
48477
- target[1] = payloadLength;
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;
48478
48886
  if (payloadLength === 126) {
48479
- target.writeUInt16BE(dataLength, 2);
48887
+ target2.writeUInt16BE(dataLength, 2);
48480
48888
  } else if (payloadLength === 127) {
48481
- target[2] = target[3] = 0;
48482
- target.writeUIntBE(dataLength, 4, 6);
48483
- }
48484
- if (!options.mask) return [target, data];
48485
- target[1] |= 128;
48486
- target[offset - 4] = mask[0];
48487
- target[offset - 3] = mask[1];
48488
- target[offset - 2] = mask[2];
48489
- target[offset - 1] = mask[3];
48490
- if (skipMasking) return [target, data];
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];
48491
48899
  if (merge2) {
48492
- applyMask(data, mask, target, offset, dataLength);
48493
- return [target];
48900
+ applyMask(data, mask, target2, offset, dataLength);
48901
+ return [target2];
48494
48902
  }
48495
48903
  applyMask(data, mask, data, 0, dataLength);
48496
- return [target, data];
48904
+ return [target2, data];
48497
48905
  }
48498
48906
  /**
48499
48907
  * Sends a close message to the other peer.
@@ -50734,16 +51142,16 @@ var require_buffer_list = __commonJS({
50734
51142
  }
50735
51143
  return keys;
50736
51144
  }
50737
- function _objectSpread(target) {
51145
+ function _objectSpread(target2) {
50738
51146
  for (var i = 1; i < arguments.length; i++) {
50739
51147
  var source = null != arguments[i] ? arguments[i] : {};
50740
51148
  i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
50741
- _defineProperty(target, key, source[key]);
50742
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
50743
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
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));
50744
51152
  });
50745
51153
  }
50746
- return target;
51154
+ return target2;
50747
51155
  }
50748
51156
  function _defineProperty(obj, key, value) {
50749
51157
  key = _toPropertyKey(key);
@@ -50759,13 +51167,13 @@ var require_buffer_list = __commonJS({
50759
51167
  throw new TypeError("Cannot call a class as a function");
50760
51168
  }
50761
51169
  }
50762
- function _defineProperties(target, props) {
51170
+ function _defineProperties(target2, props) {
50763
51171
  for (var i = 0; i < props.length; i++) {
50764
51172
  var descriptor = props[i];
50765
51173
  descriptor.enumerable = descriptor.enumerable || false;
50766
51174
  descriptor.configurable = true;
50767
51175
  if ("value" in descriptor) descriptor.writable = true;
50768
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
51176
+ Object.defineProperty(target2, _toPropertyKey(descriptor.key), descriptor);
50769
51177
  }
50770
51178
  }
50771
51179
  function _createClass(Constructor, protoProps, staticProps) {
@@ -50793,8 +51201,8 @@ var require_buffer_list = __commonJS({
50793
51201
  var _require2 = __require("util");
50794
51202
  var inspect = _require2.inspect;
50795
51203
  var custom2 = inspect && inspect.custom || "inspect";
50796
- function copyBuffer(src, target, offset) {
50797
- Buffer2.prototype.copy.call(src, target, offset);
51204
+ function copyBuffer(src, target2, offset) {
51205
+ Buffer2.prototype.copy.call(src, target2, offset);
50798
51206
  }
50799
51207
  module.exports = /* @__PURE__ */ (function() {
50800
51208
  function BufferList() {
@@ -50844,7 +51252,7 @@ var require_buffer_list = __commonJS({
50844
51252
  }
50845
51253
  }, {
50846
51254
  key: "join",
50847
- value: function join8(s) {
51255
+ value: function join9(s) {
50848
51256
  if (this.length === 0) return "";
50849
51257
  var p = this.head;
50850
51258
  var ret = "" + p.data;
@@ -52358,16 +52766,16 @@ var require_from = __commonJS({
52358
52766
  }
52359
52767
  return keys;
52360
52768
  }
52361
- function _objectSpread(target) {
52769
+ function _objectSpread(target2) {
52362
52770
  for (var i = 1; i < arguments.length; i++) {
52363
52771
  var source = null != arguments[i] ? arguments[i] : {};
52364
52772
  i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
52365
- _defineProperty(target, key, source[key]);
52366
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
52367
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
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));
52368
52776
  });
52369
52777
  }
52370
- return target;
52778
+ return target2;
52371
52779
  }
52372
52780
  function _defineProperty(obj, key, value) {
52373
52781
  key = _toPropertyKey(key);
@@ -60700,8 +61108,8 @@ var require_atomic_sleep = __commonJS({
60700
61108
  }
60701
61109
  throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");
60702
61110
  }
60703
- const target = Date.now() + Number(ms);
60704
- while (target > Date.now()) {
61111
+ const target2 = Date.now() + Number(ms);
61112
+ while (target2 > Date.now()) {
60705
61113
  }
60706
61114
  };
60707
61115
  module.exports = sleep3;
@@ -60828,7 +61236,7 @@ var require_sonic_boom = __commonJS({
60828
61236
  fsWrite = () => fs.write(this.fd, this._writingBuf, this.release);
60829
61237
  } else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
60830
61238
  this._writingBuf = "";
60831
- this.write = write;
61239
+ this.write = write2;
60832
61240
  this.flush = flush;
60833
61241
  this.flushSync = flushSync;
60834
61242
  this._actualWrite = actualWrite;
@@ -60961,7 +61369,7 @@ var require_sonic_boom = __commonJS({
60961
61369
  }
60962
61370
  return Buffer.concat(bufs, len);
60963
61371
  }
60964
- function write(data) {
61372
+ function write2(data) {
60965
61373
  if (this.destroyed) {
60966
61374
  throw new Error("SonicBoom destroyed");
60967
61375
  }
@@ -61527,7 +61935,7 @@ var require_thread_stream = __commonJS({
61527
61935
  var { version: version3 } = require_package();
61528
61936
  var { EventEmitter: EventEmitter2 } = __require("events");
61529
61937
  var { Worker } = __require("worker_threads");
61530
- var { join: join8 } = __require("path");
61938
+ var { join: join9 } = __require("path");
61531
61939
  var { pathToFileURL } = __require("url");
61532
61940
  var { wait } = require_wait();
61533
61941
  var {
@@ -61578,7 +61986,7 @@ var require_thread_stream = __commonJS({
61578
61986
  function createWorker(stream, opts) {
61579
61987
  const { filename, workerData } = opts;
61580
61988
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
61581
- const toExecute = bundlerOverrides["thread-stream-worker"] || join8(__dirname, "lib", "worker.js");
61989
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join9(__dirname, "lib", "worker.js");
61582
61990
  const worker = new Worker(toExecute, {
61583
61991
  ...opts.workerOpts,
61584
61992
  name: opts.workerOpts?.name || "thread-stream",
@@ -61622,7 +62030,7 @@ var require_thread_stream = __commonJS({
61622
62030
  }
61623
62031
  return;
61624
62032
  }
61625
- write(stream, leftover, noop);
62033
+ write2(stream, leftover, noop);
61626
62034
  continue;
61627
62035
  }
61628
62036
  if (leftover === 0) {
@@ -61926,7 +62334,7 @@ var require_thread_stream = __commonJS({
61926
62334
  });
61927
62335
  }
61928
62336
  }
61929
- function write(stream, maxBytes, cb) {
62337
+ function write2(stream, maxBytes, cb) {
61930
62338
  const current = Atomics.load(stream[kImpl].state, WRITE_INDEX);
61931
62339
  let offset = current;
61932
62340
  let remaining = maxBytes;
@@ -62011,7 +62419,7 @@ var require_thread_stream = __commonJS({
62011
62419
  } else if (leftover < 0) {
62012
62420
  throw new Error("overwritten");
62013
62421
  }
62014
- write(stream, leftover, cb);
62422
+ write2(stream, leftover, cb);
62015
62423
  }
62016
62424
  }
62017
62425
  function flushSync(stream) {
@@ -62044,9 +62452,9 @@ var require_transport = __commonJS({
62044
62452
  "node_modules/.pnpm/pino@10.3.1/node_modules/pino/lib/transport.js"(exports, module) {
62045
62453
  "use strict";
62046
62454
  var { createRequire: createRequire3 } = __require("module");
62047
- var { existsSync: existsSync7 } = __require("node:fs");
62455
+ var { existsSync: existsSync8 } = __require("node:fs");
62048
62456
  var getCallers = require_caller();
62049
- var { join: join8, isAbsolute, sep: sep3 } = __require("node:path");
62457
+ var { join: join9, isAbsolute: isAbsolute2, sep: sep3 } = __require("node:path");
62050
62458
  var { fileURLToPath: fileURLToPath3 } = __require("node:url");
62051
62459
  var sleep3 = require_atomic_sleep();
62052
62460
  var onExit = require_on_exit_leak_free();
@@ -62118,7 +62526,7 @@ var require_transport = __commonJS({
62118
62526
  return false;
62119
62527
  }
62120
62528
  }
62121
- return isAbsolute(path) && !existsSync7(path);
62529
+ return isAbsolute2(path) && !existsSync8(path);
62122
62530
  }
62123
62531
  function stripQuotes(value) {
62124
62532
  const first = value[0];
@@ -62192,14 +62600,14 @@ var require_transport = __commonJS({
62192
62600
  const options = {
62193
62601
  ...fullOptions.options
62194
62602
  };
62195
- const callers = typeof caller === "string" ? [caller] : caller;
62603
+ const callers2 = typeof caller === "string" ? [caller] : caller;
62196
62604
  const bundlerOverrides = typeof globalThis === "object" && Object.prototype.hasOwnProperty.call(globalThis, "__bundlerPathsOverrides") && globalThis.__bundlerPathsOverrides && typeof globalThis.__bundlerPathsOverrides === "object" ? globalThis.__bundlerPathsOverrides : /* @__PURE__ */ Object.create(null);
62197
- let target = fullOptions.target;
62198
- if (target && targets) {
62605
+ let target2 = fullOptions.target;
62606
+ if (target2 && targets) {
62199
62607
  throw new Error("only one of target or targets can be specified");
62200
62608
  }
62201
62609
  if (targets) {
62202
- target = bundlerOverrides["pino-worker"] || join8(__dirname, "worker.js");
62610
+ target2 = bundlerOverrides["pino-worker"] || join9(__dirname, "worker.js");
62203
62611
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
62204
62612
  return {
62205
62613
  ...dest,
@@ -62217,7 +62625,7 @@ var require_transport = __commonJS({
62217
62625
  });
62218
62626
  });
62219
62627
  } else if (pipeline) {
62220
- target = bundlerOverrides["pino-worker"] || join8(__dirname, "worker.js");
62628
+ target2 = bundlerOverrides["pino-worker"] || join9(__dirname, "worker.js");
62221
62629
  options.pipelines = [pipeline.map((dest) => {
62222
62630
  return {
62223
62631
  ...dest,
@@ -62232,18 +62640,18 @@ var require_transport = __commonJS({
62232
62640
  options.dedupe = dedupe;
62233
62641
  }
62234
62642
  options.pinoWillSendConfig = true;
62235
- const name = targets || pipeline ? "pino.transport" : target;
62236
- return buildStream(fixTarget(target), options, worker, sync, name);
62643
+ const name = targets || pipeline ? "pino.transport" : target2;
62644
+ return buildStream(fixTarget(target2), options, worker, sync, name);
62237
62645
  function fixTarget(origin) {
62238
62646
  origin = bundlerOverrides[origin] || origin;
62239
- if (isAbsolute(origin) || origin.indexOf("file://") === 0) {
62647
+ if (isAbsolute2(origin) || origin.indexOf("file://") === 0) {
62240
62648
  return origin;
62241
62649
  }
62242
62650
  if (origin === "pino/file") {
62243
- return join8(__dirname, "..", "file.js");
62651
+ return join9(__dirname, "..", "file.js");
62244
62652
  }
62245
62653
  let fixTarget2;
62246
- for (const filePath of callers) {
62654
+ for (const filePath of callers2) {
62247
62655
  try {
62248
62656
  const context = filePath === "node:repl" ? process.cwd() + sep3 : filePath;
62249
62657
  fixTarget2 = createRequire3(context).resolve(origin);
@@ -62894,7 +63302,7 @@ var require_proto = __commonJS({
62894
63302
  return "Pino";
62895
63303
  },
62896
63304
  [lsCacheSym]: initialLsCache,
62897
- [writeSym]: write,
63305
+ [writeSym]: write2,
62898
63306
  [asJsonSym]: asJson,
62899
63307
  [getLevelSym]: getLevel,
62900
63308
  [setLevelSym]: setLevel
@@ -62997,7 +63405,7 @@ var require_proto = __commonJS({
62997
63405
  function defaultMixinMergeStrategy(mergeObject, mixinObject) {
62998
63406
  return Object.assign(mixinObject, mergeObject);
62999
63407
  }
63000
- function write(_obj, msg, num) {
63408
+ function write2(_obj, msg, num) {
63001
63409
  const t = this[timeSym]();
63002
63410
  const mixin = this[mixinSym];
63003
63411
  const errorKey = this[errorKeySym];
@@ -63220,7 +63628,7 @@ var require_safe_stable_stringify = __commonJS({
63220
63628
  return circularValue;
63221
63629
  }
63222
63630
  let res = "";
63223
- let join8 = ",";
63631
+ let join9 = ",";
63224
63632
  const originalIndentation = indentation;
63225
63633
  if (Array.isArray(value)) {
63226
63634
  if (value.length === 0) {
@@ -63234,7 +63642,7 @@ var require_safe_stable_stringify = __commonJS({
63234
63642
  indentation += spacer;
63235
63643
  res += `
63236
63644
  ${indentation}`;
63237
- join8 = `,
63645
+ join9 = `,
63238
63646
  ${indentation}`;
63239
63647
  }
63240
63648
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -63242,13 +63650,13 @@ ${indentation}`;
63242
63650
  for (; i < maximumValuesToStringify - 1; i++) {
63243
63651
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
63244
63652
  res += tmp2 !== void 0 ? tmp2 : "null";
63245
- res += join8;
63653
+ res += join9;
63246
63654
  }
63247
63655
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
63248
63656
  res += tmp !== void 0 ? tmp : "null";
63249
63657
  if (value.length - 1 > maximumBreadth) {
63250
63658
  const removedKeys = value.length - maximumBreadth - 1;
63251
- res += `${join8}"... ${getItemCount(removedKeys)} not stringified"`;
63659
+ res += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
63252
63660
  }
63253
63661
  if (spacer !== "") {
63254
63662
  res += `
@@ -63269,7 +63677,7 @@ ${originalIndentation}`;
63269
63677
  let separator = "";
63270
63678
  if (spacer !== "") {
63271
63679
  indentation += spacer;
63272
- join8 = `,
63680
+ join9 = `,
63273
63681
  ${indentation}`;
63274
63682
  whitespace = " ";
63275
63683
  }
@@ -63283,13 +63691,13 @@ ${indentation}`;
63283
63691
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
63284
63692
  if (tmp !== void 0) {
63285
63693
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
63286
- separator = join8;
63694
+ separator = join9;
63287
63695
  }
63288
63696
  }
63289
63697
  if (keyLength > maximumBreadth) {
63290
63698
  const removedKeys = keyLength - maximumBreadth;
63291
63699
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
63292
- separator = join8;
63700
+ separator = join9;
63293
63701
  }
63294
63702
  if (spacer !== "" && separator.length > 1) {
63295
63703
  res = `
@@ -63330,7 +63738,7 @@ ${originalIndentation}`;
63330
63738
  }
63331
63739
  const originalIndentation = indentation;
63332
63740
  let res = "";
63333
- let join8 = ",";
63741
+ let join9 = ",";
63334
63742
  if (Array.isArray(value)) {
63335
63743
  if (value.length === 0) {
63336
63744
  return "[]";
@@ -63343,7 +63751,7 @@ ${originalIndentation}`;
63343
63751
  indentation += spacer;
63344
63752
  res += `
63345
63753
  ${indentation}`;
63346
- join8 = `,
63754
+ join9 = `,
63347
63755
  ${indentation}`;
63348
63756
  }
63349
63757
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -63351,13 +63759,13 @@ ${indentation}`;
63351
63759
  for (; i < maximumValuesToStringify - 1; i++) {
63352
63760
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
63353
63761
  res += tmp2 !== void 0 ? tmp2 : "null";
63354
- res += join8;
63762
+ res += join9;
63355
63763
  }
63356
63764
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
63357
63765
  res += tmp !== void 0 ? tmp : "null";
63358
63766
  if (value.length - 1 > maximumBreadth) {
63359
63767
  const removedKeys = value.length - maximumBreadth - 1;
63360
- res += `${join8}"... ${getItemCount(removedKeys)} not stringified"`;
63768
+ res += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
63361
63769
  }
63362
63770
  if (spacer !== "") {
63363
63771
  res += `
@@ -63370,7 +63778,7 @@ ${originalIndentation}`;
63370
63778
  let whitespace = "";
63371
63779
  if (spacer !== "") {
63372
63780
  indentation += spacer;
63373
- join8 = `,
63781
+ join9 = `,
63374
63782
  ${indentation}`;
63375
63783
  whitespace = " ";
63376
63784
  }
@@ -63379,7 +63787,7 @@ ${indentation}`;
63379
63787
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
63380
63788
  if (tmp !== void 0) {
63381
63789
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
63382
- separator = join8;
63790
+ separator = join9;
63383
63791
  }
63384
63792
  }
63385
63793
  if (spacer !== "" && separator.length > 1) {
@@ -63437,20 +63845,20 @@ ${originalIndentation}`;
63437
63845
  indentation += spacer;
63438
63846
  let res2 = `
63439
63847
  ${indentation}`;
63440
- const join9 = `,
63848
+ const join10 = `,
63441
63849
  ${indentation}`;
63442
63850
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
63443
63851
  let i = 0;
63444
63852
  for (; i < maximumValuesToStringify - 1; i++) {
63445
63853
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
63446
63854
  res2 += tmp2 !== void 0 ? tmp2 : "null";
63447
- res2 += join9;
63855
+ res2 += join10;
63448
63856
  }
63449
63857
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
63450
63858
  res2 += tmp !== void 0 ? tmp : "null";
63451
63859
  if (value.length - 1 > maximumBreadth) {
63452
63860
  const removedKeys = value.length - maximumBreadth - 1;
63453
- res2 += `${join9}"... ${getItemCount(removedKeys)} not stringified"`;
63861
+ res2 += `${join10}"... ${getItemCount(removedKeys)} not stringified"`;
63454
63862
  }
63455
63863
  res2 += `
63456
63864
  ${originalIndentation}`;
@@ -63466,16 +63874,16 @@ ${originalIndentation}`;
63466
63874
  return '"[Object]"';
63467
63875
  }
63468
63876
  indentation += spacer;
63469
- const join8 = `,
63877
+ const join9 = `,
63470
63878
  ${indentation}`;
63471
63879
  let res = "";
63472
63880
  let separator = "";
63473
63881
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
63474
63882
  if (isTypedArrayWithEntries(value)) {
63475
- res += stringifyTypedArray(value, join8, maximumBreadth);
63883
+ res += stringifyTypedArray(value, join9, maximumBreadth);
63476
63884
  keys = keys.slice(value.length);
63477
63885
  maximumPropertiesToStringify -= value.length;
63478
- separator = join8;
63886
+ separator = join9;
63479
63887
  }
63480
63888
  if (deterministic) {
63481
63889
  keys = sort(keys, comparator);
@@ -63486,13 +63894,13 @@ ${indentation}`;
63486
63894
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
63487
63895
  if (tmp !== void 0) {
63488
63896
  res += `${separator}${strEscape(key2)}: ${tmp}`;
63489
- separator = join8;
63897
+ separator = join9;
63490
63898
  }
63491
63899
  }
63492
63900
  if (keyLength > maximumBreadth) {
63493
63901
  const removedKeys = keyLength - maximumBreadth;
63494
63902
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
63495
- separator = join8;
63903
+ separator = join9;
63496
63904
  }
63497
63905
  if (separator !== "") {
63498
63906
  res = `
@@ -63658,7 +64066,7 @@ var require_multistream = __commonJS({
63658
64066
  });
63659
64067
  }
63660
64068
  const res = {
63661
- write,
64069
+ write: write2,
63662
64070
  add,
63663
64071
  remove,
63664
64072
  emit,
@@ -63678,7 +64086,7 @@ var require_multistream = __commonJS({
63678
64086
  }
63679
64087
  streamsArray = null;
63680
64088
  return res;
63681
- function write(data) {
64089
+ function write2(data) {
63682
64090
  let dest;
63683
64091
  const level = this.lastLevel;
63684
64092
  const { streams } = this;
@@ -63780,7 +64188,7 @@ var require_multistream = __commonJS({
63780
64188
  };
63781
64189
  }
63782
64190
  return {
63783
- write,
64191
+ write: write2,
63784
64192
  add,
63785
64193
  remove,
63786
64194
  minLevel: level,
@@ -63893,11 +64301,11 @@ var require_pino = __commonJS({
63893
64301
  depthLimit: 5,
63894
64302
  edgeLimit: 100
63895
64303
  };
63896
- var normalize = createArgsNormalizer(defaultOptions2);
64304
+ var normalize2 = createArgsNormalizer(defaultOptions2);
63897
64305
  var serializers = Object.assign(/* @__PURE__ */ Object.create(null), stdSerializers);
63898
64306
  function pino(...args) {
63899
64307
  const instance = {};
63900
- const { opts, stream } = normalize(instance, caller(), ...args);
64308
+ const { opts, stream } = normalize2(instance, caller(), ...args);
63901
64309
  if (opts.level && typeof opts.level === "string" && DEFAULT_LEVELS[opts.level.toLowerCase()] !== void 0) opts.level = opts.level.toLowerCase();
63902
64310
  const {
63903
64311
  redact,
@@ -70333,7 +70741,7 @@ var require_fast_uri2 = __commonJS({
70333
70741
  }
70334
70742
  return decodedScheme;
70335
70743
  }
70336
- function normalize(uri, options) {
70744
+ function normalize2(uri, options) {
70337
70745
  if (typeof uri === "string") {
70338
70746
  uri = /** @type {T} */
70339
70747
  normalizeString(uri, options);
@@ -70376,64 +70784,64 @@ var require_fast_uri2 = __commonJS({
70376
70784
  schemelessOptions.skipEscape = true;
70377
70785
  return serialize(resolved, schemelessOptions);
70378
70786
  }
70379
- function copyHost(target, source) {
70380
- target.host = source.host;
70787
+ function copyHost(target2, source) {
70788
+ target2.host = source.host;
70381
70789
  if (source.ipv6Zone !== void 0) {
70382
- target.ipv6Zone = source.ipv6Zone;
70790
+ target2.ipv6Zone = source.ipv6Zone;
70383
70791
  }
70384
70792
  }
70385
70793
  function resolveComponent(base, relative2, options, skipNormalization) {
70386
- const target = {};
70794
+ const target2 = {};
70387
70795
  if (!skipNormalization) {
70388
70796
  base = parse4(serialize(base, options), options);
70389
70797
  relative2 = parse4(serialize(relative2, options), options);
70390
70798
  }
70391
70799
  options = options || {};
70392
70800
  if (!options.tolerant && relative2.scheme) {
70393
- target.scheme = relative2.scheme;
70394
- target.userinfo = relative2.userinfo;
70395
- copyHost(target, relative2);
70396
- target.port = relative2.port;
70397
- target.path = removeDotSegments(relative2.path || "");
70398
- target.query = relative2.query;
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;
70399
70807
  } else {
70400
70808
  if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
70401
- target.userinfo = relative2.userinfo;
70402
- copyHost(target, relative2);
70403
- target.port = relative2.port;
70404
- target.path = removeDotSegments(relative2.path || "");
70405
- target.query = relative2.query;
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;
70406
70814
  } else {
70407
70815
  if (!relative2.path) {
70408
- target.path = base.path;
70816
+ target2.path = base.path;
70409
70817
  if (relative2.query !== void 0) {
70410
- target.query = relative2.query;
70818
+ target2.query = relative2.query;
70411
70819
  } else {
70412
- target.query = base.query;
70820
+ target2.query = base.query;
70413
70821
  }
70414
70822
  } else {
70415
70823
  if (relative2.path[0] === "/") {
70416
- target.path = removeDotSegments(relative2.path);
70824
+ target2.path = removeDotSegments(relative2.path);
70417
70825
  } else {
70418
70826
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
70419
- target.path = "/" + relative2.path;
70827
+ target2.path = "/" + relative2.path;
70420
70828
  } else if (!base.path) {
70421
- target.path = relative2.path;
70829
+ target2.path = relative2.path;
70422
70830
  } else {
70423
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
70831
+ target2.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
70424
70832
  }
70425
- target.path = removeDotSegments(target.path);
70833
+ target2.path = removeDotSegments(target2.path);
70426
70834
  }
70427
- target.query = relative2.query;
70835
+ target2.query = relative2.query;
70428
70836
  }
70429
- target.userinfo = base.userinfo;
70430
- copyHost(target, base);
70431
- target.port = base.port;
70837
+ target2.userinfo = base.userinfo;
70838
+ copyHost(target2, base);
70839
+ target2.port = base.port;
70432
70840
  }
70433
- target.scheme = base.scheme;
70841
+ target2.scheme = base.scheme;
70434
70842
  }
70435
- target.fragment = relative2.fragment;
70436
- return target;
70843
+ target2.fragment = relative2.fragment;
70844
+ return target2;
70437
70845
  }
70438
70846
  function equal(uriA, uriB, options) {
70439
70847
  const normalizedA = normalizeComparableURI(uriA, options);
@@ -70726,7 +71134,7 @@ var require_fast_uri2 = __commonJS({
70726
71134
  }
70727
71135
  var fastUri = {
70728
71136
  SCHEMES,
70729
- normalize,
71137
+ normalize: normalize2,
70730
71138
  resolve: resolve5,
70731
71139
  resolveComponent,
70732
71140
  equal,
@@ -80855,8 +81263,8 @@ var require_response = __commonJS({
80855
81263
  function Response(req, onEnd, reject) {
80856
81264
  http.ServerResponse.call(this, req);
80857
81265
  if (req._lightMyRequest?.payloadAsStream) {
80858
- const read = this.emit.bind(this, "drain");
80859
- 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 }) };
80860
81268
  const signal = req._lightMyRequest.signal;
80861
81269
  if (signal) {
80862
81270
  addAbortSignal(signal, this._lightMyRequest.stream);
@@ -82860,9 +83268,1110 @@ ${body}`);
82860
83268
  }
82861
83269
  });
82862
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
+
82863
84372
  // packages/server/src/server.ts
82864
- import { existsSync as existsSync5 } from "node:fs";
82865
- import { dirname as dirname4, join as join6, resolve as resolve3 } from "node:path";
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";
82866
84375
  import { fileURLToPath } from "node:url";
82867
84376
  function hostName(host) {
82868
84377
  return host.startsWith("[") ? host.slice(0, host.indexOf("]") + 1) : host.replace(/:\d+$/, "");
@@ -82909,8 +84418,11 @@ async function createServer(engine, options = {}) {
82909
84418
  app.get("/api/projects", async () => engine.listProjects());
82910
84419
  app.post(
82911
84420
  "/api/projects",
82912
- { schema: { body: { type: "object", required: ["name"], properties: { name: str2 } } } },
82913
- async (req, reply) => reply.status(201).send(engine.createProject(req.body))
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
+ }
82914
84426
  );
82915
84427
  app.get(
82916
84428
  "/api/projects/:project/sources",
@@ -82930,7 +84442,10 @@ async function createServer(engine, options = {}) {
82930
84442
  }
82931
84443
  }
82932
84444
  },
82933
- async (req, reply) => reply.status(201).send(engine.addSource({ ...req.body, ...req.params }))
84445
+ async (req, reply) => {
84446
+ checkFolder(req.body.root);
84447
+ return reply.status(201).send(engine.addSource({ ...req.body, ...req.params }));
84448
+ }
82934
84449
  );
82935
84450
  app.post(
82936
84451
  "/api/projects/:project/runs",
@@ -82955,6 +84470,11 @@ async function createServer(engine, options = {}) {
82955
84470
  },
82956
84471
  async (req) => engine.listRuns({ ...req.params, ...req.query.limit ? { limit: Number(req.query.limit) } : {} })
82957
84472
  );
84473
+ app.get(
84474
+ "/api/projects/:project/file-counts",
84475
+ { schema: { params: projectParams } },
84476
+ async (req) => engine.fileCounts(req.params)
84477
+ );
82958
84478
  app.get(
82959
84479
  "/api/projects/:project/files",
82960
84480
  { schema: { params: projectParams } },
@@ -83011,6 +84531,167 @@ async function createServer(engine, options = {}) {
83011
84531
  includeAll: req.query.includeAll === "true"
83012
84532
  })
83013
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
+ );
83014
84695
  app.post(
83015
84696
  "/api/projects/:project/snippet",
83016
84697
  {
@@ -83034,12 +84715,12 @@ async function createServer(engine, options = {}) {
83034
84715
  async (req) => engine.snippet({ ...req.params, ...req.body })
83035
84716
  );
83036
84717
  const webRoot = options.webRoot === void 0 ? defaultWebRoot : options.webRoot;
83037
- const hasUi = webRoot !== null && existsSync5(join6(webRoot, "index.html"));
84718
+ const hasUi = webRoot !== null && existsSync6(join7(webRoot, "index.html"));
83038
84719
  if (hasUi) await app.register(import_static.default, { root: webRoot });
83039
84720
  app.setNotFoundHandler((req, reply) => {
83040
84721
  if (req.url.startsWith("/api/") || !hasUi)
83041
84722
  return req.url === "/" && !hasUi ? reply.type("text/html").send(
83042
- "<!doctype html><title>veo</title><p>The veo API is running. Build the UI with <code>pnpm --filter @veo/web build</code>.</p>"
84723
+ "<!doctype html><title>veoflow</title><p>The veoflow API is running. Build the UI with <code>pnpm --filter @veo/web build</code>.</p>"
83043
84724
  ) : reply.status(404).send({ code: "not-found", message: `no route ${req.method} ${req.url}` });
83044
84725
  return reply.sendFile("index.html");
83045
84726
  });
@@ -83056,10 +84737,35 @@ async function listen(engine, options = {}) {
83056
84737
  app,
83057
84738
  url: `http://${urlHost(host)}:${port}`,
83058
84739
  ...loopback ? {} : {
83059
- warning: `veo is listening on ${host}, beyond this machine; anyone who can reach it can read the analyzed code.`
84740
+ warning: `veoflow is listening on ${host}, beyond this machine; anyone who can reach it can read the analyzed code.`
83060
84741
  }
83061
84742
  };
83062
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
+ }
83063
84769
  var import_static, import_websocket, import_fastify, STATUS, defaultWebRoot, LOOPBACK, str2, strings, position, projectParams;
83064
84770
  var init_server4 = __esm({
83065
84771
  "packages/server/src/server.ts"() {
@@ -83068,6 +84774,7 @@ var init_server4 = __esm({
83068
84774
  import_websocket = __toESM(require_websocket2(), 1);
83069
84775
  import_fastify = __toESM(require_fastify(), 1);
83070
84776
  init_src();
84777
+ init_src8();
83071
84778
  STATUS = {
83072
84779
  "not-found": 404,
83073
84780
  "source-not-found": 404,
@@ -83080,7 +84787,7 @@ var init_server4 = __esm({
83080
84787
  ambiguous: 409,
83081
84788
  locked: 409
83082
84789
  };
83083
- defaultWebRoot = process.env.VEO_WEB_ROOT ?? resolve3(dirname4(fileURLToPath(import.meta.url)), "../../web/dist");
84790
+ defaultWebRoot = process.env.VEO_WEB_ROOT ?? resolve3(dirname5(fileURLToPath(import.meta.url)), "../../web/dist");
83084
84791
  LOOPBACK = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]", "::1"]);
83085
84792
  str2 = { type: "string", minLength: 1 };
83086
84793
  strings = { type: "array", items: { type: "string" } };
@@ -83094,13 +84801,13 @@ var init_server4 = __esm({
83094
84801
  });
83095
84802
 
83096
84803
  // packages/server/src/index.ts
83097
- var src_exports2 = {};
83098
- __export(src_exports2, {
84804
+ var src_exports3 = {};
84805
+ __export(src_exports3, {
83099
84806
  createServer: () => createServer,
83100
84807
  listen: () => listen,
83101
84808
  urlHost: () => urlHost
83102
84809
  });
83103
- var init_src8 = __esm({
84810
+ var init_src9 = __esm({
83104
84811
  "packages/server/src/index.ts"() {
83105
84812
  "use strict";
83106
84813
  init_server4();
@@ -83111,28 +84818,33 @@ var init_src8 = __esm({
83111
84818
  init_src();
83112
84819
  init_src6();
83113
84820
  import { spawn } from "node:child_process";
83114
- import { existsSync as existsSync6, readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
83115
- import { basename as basename3, dirname as dirname5, join as join7, resolve as resolve4 } from "node:path";
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";
83116
84823
  import { fileURLToPath as fileURLToPath2 } from "node:url";
83117
84824
  import { parseArgs } from "node:util";
83118
- var USAGE = `veo \u2014 a knowledge graph of your code
84825
+ var USAGE = `veoflow \u2014 a knowledge graph of your code (also runs as \`veo\`)
83119
84826
 
83120
84827
  Usage:
83121
- veo init <name> create a project
83122
- veo add <dir> [--project <id>] add a folder to a project and analyze it
84828
+ veoflow init <name> create a project
84829
+ veoflow add <dir> [--project <id>] add a folder to a project and analyze it
83123
84830
  [--id <source-id>] [--include <glob>]... [--exclude <glob>]... [--no-run]
83124
- veo run [--project <id>] analyze a project again
83125
- veo serve [--port 7420] [--host 127.0.0.1] [--no-open]
84831
+ veoflow run [--project <id>] analyze a project again
84832
+ veoflow serve [--port 7420] [--host 127.0.0.1] [--no-open]
83126
84833
  serve the UI and API
83127
- veo mcp serve the MCP tools over stdio
83128
- veo projects list projects
83129
- veo help | --version`;
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)
84840
+ veoflow projects list projects
84841
+ veoflow help | --version`;
83130
84842
  var UsageError = class extends Error {
83131
84843
  };
83132
84844
  function version2() {
83133
84845
  if (process.env.VEO_VERSION) return process.env.VEO_VERSION;
83134
84846
  const pkg = JSON.parse(
83135
- readFileSync3(join7(dirname5(fileURLToPath2(import.meta.url)), "../package.json"), "utf8")
84847
+ readFileSync4(join8(dirname6(fileURLToPath2(import.meta.url)), "../package.json"), "utf8")
83136
84848
  );
83137
84849
  return pkg.version;
83138
84850
  }
@@ -83162,7 +84874,7 @@ function pickProject(engine, project2, cwd) {
83162
84874
  const all2 = engine.catalog.listProjects();
83163
84875
  if (all2.length === 1) return all2[0].id;
83164
84876
  throw new UsageError(
83165
- all2.length === 0 ? "no projects yet; run `veo add <dir>` or `veo init <name>`" : "several projects exist; pass --project <id>"
84877
+ all2.length === 0 ? "no projects yet; run `veoflow add <dir>` or `veoflow init <name>`" : "several projects exist; pass --project <id>"
83166
84878
  );
83167
84879
  }
83168
84880
  async function runAnalysis(engine, project2, io) {
@@ -83202,7 +84914,7 @@ async function main(argv, io) {
83202
84914
  }
83203
84915
  if (command === "mcp") {
83204
84916
  const { serveStdio: serveStdio2 } = await Promise.resolve().then(() => (init_src7(), src_exports));
83205
- await serveStdio2(io.home);
84917
+ await serveStdio2(io.home, version2());
83206
84918
  return 0;
83207
84919
  }
83208
84920
  const engine = new Engine(io.home);
@@ -83211,7 +84923,7 @@ async function main(argv, io) {
83211
84923
  switch (command) {
83212
84924
  case "init": {
83213
84925
  const { positionals } = parseArgs({ args: rest, allowPositionals: true, strict: true });
83214
- if (positionals.length !== 1) throw new UsageError("usage: veo init <name>");
84926
+ if (positionals.length !== 1) throw new UsageError("usage: veoflow init <name>");
83215
84927
  const { project: project2 } = engine.createProject({ name: positionals[0] });
83216
84928
  io.out(`created project ${project2.id} (${project2.dir})`);
83217
84929
  return 0;
@@ -83234,9 +84946,9 @@ async function main(argv, io) {
83234
84946
  "no-run": { type: "boolean" }
83235
84947
  }
83236
84948
  });
83237
- if (positionals.length !== 1) throw new UsageError("usage: veo add <dir> [--project <id>]");
84949
+ if (positionals.length !== 1) throw new UsageError("usage: veoflow add <dir> [--project <id>]");
83238
84950
  const root = resolve4(io.cwd, positionals[0]);
83239
- if (!existsSync6(root) || !statSync3(root).isDirectory())
84951
+ if (!existsSync7(root) || !statSync4(root).isDirectory())
83240
84952
  throw new VeoError("source-not-found", `${root} is not a directory`);
83241
84953
  let project2 = values.project ?? engine.catalog.resolveProjectForCwd(io.cwd)?.id;
83242
84954
  if (!project2) {
@@ -83271,18 +84983,18 @@ async function main(argv, io) {
83271
84983
  const port = values.port === void 0 ? 7420 : Number(values.port);
83272
84984
  if (!Number.isInteger(port) || port < 0 || port > 65535)
83273
84985
  throw new UsageError(`invalid --port ${values.port}`);
83274
- const { listen: listen2 } = await Promise.resolve().then(() => (init_src8(), src_exports2));
84986
+ const { listen: listen2 } = await Promise.resolve().then(() => (init_src9(), src_exports3));
83275
84987
  let started;
83276
84988
  try {
83277
84989
  started = await listen2(engine, { port, ...values.host ? { host: values.host } : {} });
83278
84990
  } catch (e) {
83279
84991
  if (e.code === "EADDRINUSE") {
83280
- io.err(`port ${port} is already in use; try: veo serve --port ${port + 1}`);
84992
+ io.err(`port ${port} is already in use; try: veoflow serve --port ${port + 1}`);
83281
84993
  return 1;
83282
84994
  }
83283
84995
  throw e;
83284
84996
  }
83285
- io.out(`veo is serving on ${started.url}`);
84997
+ io.out(`veoflow is serving on ${started.url}`);
83286
84998
  if (started.warning) io.err(`warning: ${started.warning}`);
83287
84999
  if (!values["no-open"]) (io.open ?? openBrowser)(started.url);
83288
85000
  keepOpen = true;
@@ -83292,6 +85004,91 @@ async function main(argv, io) {
83292
85004
  }, started.url);
83293
85005
  return 0;
83294
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
+ }
83295
85092
  default:
83296
85093
  throw new UsageError(`unknown command ${command}
83297
85094
 
@@ -83312,6 +85109,9 @@ ${USAGE}`);
83312
85109
  if (!keepOpen) engine.close();
83313
85110
  }
83314
85111
  }
85112
+ function plain(text) {
85113
+ return text.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, "");
85114
+ }
83315
85115
  export {
83316
85116
  main
83317
85117
  };