layermap 0.1.13 → 0.1.15

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/cli.mjs CHANGED
@@ -12,28 +12,96 @@ import { parseArgs } from "node:util";
12
12
  // src/agent/environment.ts
13
13
  import { execFile } from "node:child_process";
14
14
  import { createHash as createHash5 } from "node:crypto";
15
- import { existsSync as existsSync4, readFileSync as readFileSync4 } from "node:fs";
15
+ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
16
16
  import { mkdir, readdir, readFile, rename, rm, stat, utimes, writeFile } from "node:fs/promises";
17
17
  import { createRequire } from "node:module";
18
18
  import { homedir } from "node:os";
19
- import path10 from "node:path";
19
+ import path11 from "node:path";
20
20
  import { fileURLToPath } from "node:url";
21
21
 
22
22
  // src/layermap.ts
23
23
  import { createHash as createHash4 } from "node:crypto";
24
24
  import { mkdirSync } from "node:fs";
25
25
  import { lstat as lstat2, realpath as realpath2 } from "node:fs/promises";
26
- import path9 from "node:path";
26
+ import path10 from "node:path";
27
27
  import { DatabaseSync } from "@photostructure/sqlite";
28
28
 
29
29
  // src/capture-policy.ts
30
- import path2 from "node:path";
30
+ import path3 from "node:path";
31
31
 
32
32
  // src/file-universe.ts
33
- import path from "node:path";
33
+ import path2 from "node:path";
34
34
 
35
35
  // src/git-runner.ts
36
36
  import { spawn } from "node:child_process";
37
+
38
+ // src/platform.ts
39
+ import { spawnSync } from "node:child_process";
40
+ import { existsSync } from "node:fs";
41
+ import path from "node:path";
42
+ var executableName = (name, platform = process.platform) => platform === "win32" ? `${name}.exe` : name;
43
+ var searchPath = (env) => env.PATH ?? Object.entries(env).find(([name]) => name.toUpperCase() === "PATH")?.[1] ?? "";
44
+ function findOnPath(files, env, platform) {
45
+ const join = platform === "win32" ? path.win32.join : path.posix.join;
46
+ for (const directory of searchPath(env).split(platform === "win32" ? ";" : ":"))
47
+ for (const file2 of files)
48
+ if (directory && existsSync(join(directory, file2))) return join(directory, file2);
49
+ return void 0;
50
+ }
51
+ var findExecutable = (name, env = process.env, platform = process.platform) => findOnPath([executableName(name, platform)], env, platform);
52
+ var CMD_META = /([()\][%!^"`<>&|;, *?])/gu;
53
+ var cmdArgument = (value) => `"${value.replace(/(\\*)"/gu, '$1$1\\"').replace(/(\\*)$/u, "$1$1")}"`.replace(CMD_META, "^$1").replace(CMD_META, "^$1");
54
+ function commandInvocation(command, args, env = process.env, platform = process.platform) {
55
+ if (platform !== "win32") return { file: command, args: [...args] };
56
+ const program = findOnPath([`${command}.exe`, `${command}.cmd`, `${command}.bat`], env, platform);
57
+ if (!program || program.toLowerCase().endsWith(".exe"))
58
+ return { file: program ?? command, args: [...args] };
59
+ return cmdInvocation(program, args, env.ComSpec ?? process.env.ComSpec ?? "cmd.exe");
60
+ }
61
+ function cmdInvocation(script, args, comspec = "cmd.exe") {
62
+ const line = [script.replace(CMD_META, "^$1"), ...args.map(cmdArgument)].join(" ");
63
+ return { file: comspec, args: ["/d", "/s", "/c", `"${line}"`], windowsVerbatimArguments: true };
64
+ }
65
+ var WINDOWS_SYSTEM = [
66
+ "SystemRoot",
67
+ "windir",
68
+ "SystemDrive",
69
+ "TEMP",
70
+ "TMP",
71
+ "USERPROFILE",
72
+ "LOCALAPPDATA",
73
+ "APPDATA",
74
+ "PATHEXT",
75
+ "ComSpec"
76
+ ];
77
+ function childEnvironment(variables, platform = process.platform, env = process.env) {
78
+ if (platform !== "win32") return variables;
79
+ const system = {};
80
+ for (const name of WINDOWS_SYSTEM) if (env[name] !== void 0) system[name] = env[name];
81
+ return { ...system, ...variables };
82
+ }
83
+ function stopProcessTree(pid, signal, platform = process.platform) {
84
+ if (platform !== "win32") {
85
+ process.kill(-pid, signal);
86
+ return;
87
+ }
88
+ const taskkill = path.win32.join(
89
+ process.env.SystemRoot ?? "C:\\Windows",
90
+ "System32",
91
+ "taskkill.exe"
92
+ );
93
+ spawnSync(taskkill, ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
94
+ }
95
+ function processTreeGone(pid, platform = process.platform) {
96
+ try {
97
+ process.kill(platform === "win32" ? pid : -pid, 0);
98
+ return false;
99
+ } catch (error51) {
100
+ return error51.code === "ESRCH" ? true : void 0;
101
+ }
102
+ }
103
+
104
+ // src/git-runner.ts
37
105
  var CONSTRAINED_CONFIG = [
38
106
  "-c",
39
107
  "core.fsmonitor=false",
@@ -66,8 +134,27 @@ var GitCommandStopUnconfirmedError = class extends GitCommandError {
66
134
  this.name = "GitCommandStopUnconfirmedError";
67
135
  }
68
136
  };
137
+ function gitEnvironment() {
138
+ const windows = process.platform === "win32";
139
+ return childEnvironment({
140
+ LANG: process.env.LANG ?? "C",
141
+ LC_ALL: "C",
142
+ PATH: windows ? process.env.PATH ?? "" : "/usr/bin:/bin",
143
+ ...windows ? {} : { TMPDIR: process.env.TMPDIR ?? "/tmp" },
144
+ GIT_ATTR_NOSYSTEM: "1",
145
+ GIT_CONFIG_COUNT: "0",
146
+ GIT_CONFIG_NOSYSTEM: "1",
147
+ GIT_CONFIG_GLOBAL: "/dev/null",
148
+ GIT_OPTIONAL_LOCKS: "0",
149
+ GIT_TERMINAL_PROMPT: "0",
150
+ GIT_PAGER: "cat",
151
+ PAGER: "cat",
152
+ ...windows ? {} : { GIT_ASKPASS: "/usr/bin/false", SSH_ASKPASS: "/usr/bin/false" }
153
+ });
154
+ }
155
+ var defaultGit = () => process.platform === "win32" ? findExecutable("git") ?? "git.exe" : "/usr/bin/git";
69
156
  var GitRunner = class {
70
- constructor(executable = "/usr/bin/git") {
157
+ constructor(executable = defaultGit()) {
71
158
  this.executable = executable;
72
159
  }
73
160
  executable;
@@ -82,22 +169,8 @@ var GitRunner = class {
82
169
  return new Promise((resolve, reject) => {
83
170
  const child = spawn(this.executable, finalArgs, {
84
171
  cwd: options.cwd,
85
- env: {
86
- LANG: process.env.LANG ?? "C",
87
- LC_ALL: "C",
88
- PATH: "/usr/bin:/bin",
89
- TMPDIR: process.env.TMPDIR ?? "/tmp",
90
- GIT_ATTR_NOSYSTEM: "1",
91
- GIT_CONFIG_COUNT: "0",
92
- GIT_CONFIG_NOSYSTEM: "1",
93
- GIT_CONFIG_GLOBAL: "/dev/null",
94
- GIT_OPTIONAL_LOCKS: "0",
95
- GIT_TERMINAL_PROMPT: "0",
96
- GIT_PAGER: "cat",
97
- PAGER: "cat",
98
- GIT_ASKPASS: "/usr/bin/false",
99
- SSH_ASKPASS: "/usr/bin/false"
100
- },
172
+ env: gitEnvironment(),
173
+ windowsHide: true,
101
174
  stdio: ["pipe", "pipe", "pipe"]
102
175
  });
103
176
  const stdout = [];
@@ -217,8 +290,8 @@ var parseFileUniverse = (output) => {
217
290
  const records = output.toString("utf8").split("\0");
218
291
  for (const record2 of records) {
219
292
  if (record2.length === 0) continue;
220
- const normalized = path.posix.normalize(record2);
221
- if (normalized !== record2 || normalized === "." || normalized === ".." || normalized.startsWith("../") || path.posix.isAbsolute(normalized) || normalized.includes("\\")) {
293
+ const normalized = path2.posix.normalize(record2);
294
+ if (normalized !== record2 || normalized === "." || normalized === ".." || normalized.startsWith("../") || path2.posix.isAbsolute(normalized) || normalized.includes("\\")) {
222
295
  throw new ProjectEvidenceFileUniverseError("PROJECT_FILE_UNIVERSE_INVALID");
223
296
  }
224
297
  files.add(normalized);
@@ -428,23 +501,23 @@ var ProjectEvidencePolicyError = class extends Error {
428
501
  code;
429
502
  };
430
503
  var assertProjectEvidencePathNotSensitive = (relativePath) => {
431
- const segments = relativePath.toLowerCase().split("/");
432
- const basename = segments.at(-1) ?? "";
433
- const extension = path2.posix.extname(basename);
504
+ const segments2 = relativePath.toLowerCase().split("/");
505
+ const basename = segments2.at(-1) ?? "";
506
+ const extension = path3.posix.extname(basename);
434
507
  const containsSensitiveSequence = sensitiveSegmentSequences.some(
435
- (sequence) => segments.length >= sequence.length && segments.some(
436
- (_, start) => sequence.every((segment, offset) => segments[start + offset] === segment)
508
+ (sequence) => segments2.length >= sequence.length && segments2.some(
509
+ (_, start) => sequence.every((segment, offset) => segments2[start + offset] === segment)
437
510
  )
438
511
  );
439
- if (segments.some((segment) => sensitiveSegmentSet.has(segment)) || containsSensitiveSequence || sensitiveBasenameSet.has(basename) || basename === ".env" || basename.startsWith(".env.") || // SQLite databases and their journals hold application data, never project source.
512
+ if (segments2.some((segment) => sensitiveSegmentSet.has(segment)) || containsSensitiveSequence || sensitiveBasenameSet.has(basename) || basename === ".env" || basename.startsWith(".env.") || // SQLite databases and their journals hold application data, never project source.
440
513
  basename.endsWith(".sqlite") || basename.includes(".sqlite-") || sensitiveExtensionSet.has(extension)) {
441
514
  throw new ProjectEvidencePolicyError("PROJECT_CONTENT_RESTRICTED");
442
515
  }
443
516
  };
444
517
  var isProjectEvidenceTraversalExcluded = (relativePath) => relativePath.toLowerCase().split("/").some((segment) => traversalExcludedSegmentSet.has(segment));
445
518
  var isProjectEvidenceTextPath = (relativePath) => {
446
- const basename = path2.posix.basename(relativePath).toLowerCase();
447
- const extension = path2.posix.extname(basename);
519
+ const basename = path3.posix.basename(relativePath).toLowerCase();
520
+ const extension = path3.posix.extname(basename);
448
521
  if (allowedTextBasenameSet.has(basename)) return true;
449
522
  return extension ? allowedTextExtensionSet.has(extension) : allowedExtensionlessNameSet.has(basename);
450
523
  };
@@ -453,7 +526,7 @@ var isProjectEvidenceTextPath = (relativePath) => {
453
526
  import { createHash as createHash2 } from "node:crypto";
454
527
 
455
528
  // src/core.ts
456
- import path3 from "node:path";
529
+ import path4 from "node:path";
457
530
 
458
531
  // node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
459
532
  var external_exports = {};
@@ -1221,10 +1294,10 @@ function mergeDefs(...defs) {
1221
1294
  function cloneDef(schema) {
1222
1295
  return mergeDefs(schema._zod.def);
1223
1296
  }
1224
- function getElementAtPath(obj, path12) {
1225
- if (!path12)
1297
+ function getElementAtPath(obj, path13) {
1298
+ if (!path13)
1226
1299
  return obj;
1227
- return path12.reduce((acc, key) => acc?.[key], obj);
1300
+ return path13.reduce((acc, key) => acc?.[key], obj);
1228
1301
  }
1229
1302
  function promiseAllObject(promisesObj) {
1230
1303
  const keys = Object.keys(promisesObj);
@@ -1633,11 +1706,11 @@ function explicitlyAborted(x, startIndex = 0) {
1633
1706
  }
1634
1707
  return false;
1635
1708
  }
1636
- function prefixIssues(path12, issues) {
1709
+ function prefixIssues(path13, issues) {
1637
1710
  return issues.map((iss) => {
1638
1711
  var _a3;
1639
1712
  (_a3 = iss).path ?? (_a3.path = []);
1640
- iss.path.unshift(path12);
1713
+ iss.path.unshift(path13);
1641
1714
  return iss;
1642
1715
  });
1643
1716
  }
@@ -1784,16 +1857,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1784
1857
  }
1785
1858
  function formatError(error51, mapper = (issue2) => issue2.message) {
1786
1859
  const fieldErrors = { _errors: [] };
1787
- const processError = (error52, path12 = []) => {
1860
+ const processError = (error52, path13 = []) => {
1788
1861
  for (const issue2 of error52.issues) {
1789
1862
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1790
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1863
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1791
1864
  } else if (issue2.code === "invalid_key") {
1792
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1865
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1793
1866
  } else if (issue2.code === "invalid_element") {
1794
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1867
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1795
1868
  } else {
1796
- const fullpath = [...path12, ...issue2.path];
1869
+ const fullpath = [...path13, ...issue2.path];
1797
1870
  if (fullpath.length === 0) {
1798
1871
  fieldErrors._errors.push(mapper(issue2));
1799
1872
  } else {
@@ -1820,17 +1893,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1820
1893
  }
1821
1894
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1822
1895
  const result = { errors: [] };
1823
- const processError = (error52, path12 = []) => {
1896
+ const processError = (error52, path13 = []) => {
1824
1897
  var _a3, _b;
1825
1898
  for (const issue2 of error52.issues) {
1826
1899
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1827
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1900
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1828
1901
  } else if (issue2.code === "invalid_key") {
1829
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1902
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1830
1903
  } else if (issue2.code === "invalid_element") {
1831
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1904
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1832
1905
  } else {
1833
- const fullpath = [...path12, ...issue2.path];
1906
+ const fullpath = [...path13, ...issue2.path];
1834
1907
  if (fullpath.length === 0) {
1835
1908
  result.errors.push(mapper(issue2));
1836
1909
  continue;
@@ -1862,8 +1935,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1862
1935
  }
1863
1936
  function toDotPath(_path) {
1864
1937
  const segs = [];
1865
- const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1866
- for (const seg of path12) {
1938
+ const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1939
+ for (const seg of path13) {
1867
1940
  if (typeof seg === "number")
1868
1941
  segs.push(`[${seg}]`);
1869
1942
  else if (typeof seg === "symbol")
@@ -14555,13 +14628,13 @@ function resolveRef(ref, ctx) {
14555
14628
  if (!ref.startsWith("#")) {
14556
14629
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14557
14630
  }
14558
- const path12 = ref.slice(1).split("/").filter(Boolean);
14559
- if (path12.length === 0) {
14631
+ const path13 = ref.slice(1).split("/").filter(Boolean);
14632
+ if (path13.length === 0) {
14560
14633
  return ctx.rootSchema;
14561
14634
  }
14562
14635
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14563
- if (path12[0] === defsKey) {
14564
- const key = path12[1];
14636
+ if (path13[0] === defsKey) {
14637
+ const key = path13[1];
14565
14638
  if (!key || !ctx.defs[key]) {
14566
14639
  throw new Error(`Reference not found: ${ref}`);
14567
14640
  }
@@ -14989,14 +15062,14 @@ var ProjectEvidencePathError = class extends Error {
14989
15062
  code;
14990
15063
  };
14991
15064
  var normalizeProjectEvidencePath = (value, allowRoot = false) => {
14992
- if (value.includes("\0") || path3.isAbsolute(value) || value.includes("\\")) {
15065
+ if (value.includes("\0") || path4.isAbsolute(value) || value.includes("\\")) {
14993
15066
  throw new ProjectEvidencePathError("PROJECT_PATH_INVALID");
14994
15067
  }
14995
15068
  if (value === ".") {
14996
15069
  if (allowRoot) return "";
14997
15070
  throw new ProjectEvidencePathError("PROJECT_PATH_INVALID");
14998
15071
  }
14999
- const normalized = path3.posix.normalize(value);
15072
+ const normalized = path4.posix.normalize(value);
15000
15073
  if (normalized.length === 0 || normalized !== value || normalized === ".." || normalized.startsWith("../") || value.split("/").some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
15001
15074
  throw new ProjectEvidencePathError("PROJECT_PATH_INVALID");
15002
15075
  }
@@ -15148,14 +15221,14 @@ var CodeCommitReader = class _CodeCommitReader {
15148
15221
  // src/code-worktree-reader.ts
15149
15222
  import { constants as fsConstants } from "node:fs";
15150
15223
  import { lstat, open, realpath } from "node:fs/promises";
15151
- import path4 from "node:path";
15224
+ import path5 from "node:path";
15152
15225
  var fileSystemErrorCode = (error51) => {
15153
15226
  if (typeof error51 !== "object" || error51 === null || !("code" in error51)) return void 0;
15154
15227
  return typeof error51.code === "string" ? error51.code : void 0;
15155
15228
  };
15156
15229
  var isInsideRoot = (root, candidate) => {
15157
- const relative = path4.relative(root, candidate);
15158
- return relative === "" || !relative.startsWith(`..${path4.sep}`) && relative !== "..";
15230
+ const relative = path5.relative(root, candidate);
15231
+ return relative === "" || !relative.startsWith(`..${path5.sep}`) && relative !== "..";
15159
15232
  };
15160
15233
  var stablePathFingerprint = (stats) => [
15161
15234
  stats.dev,
@@ -15198,7 +15271,7 @@ var StableProjectCaptureSession = class _StableProjectCaptureSession {
15198
15271
  }
15199
15272
  async captureFile(relativePath) {
15200
15273
  this.assertNotAborted();
15201
- const absolutePath = path4.join(this.root, ...relativePath.split("/"));
15274
+ const absolutePath = path5.join(this.root, ...relativePath.split("/"));
15202
15275
  const stats = await this.inspectPath(absolutePath, true);
15203
15276
  const fingerprint = stablePathFingerprint(stats);
15204
15277
  const byteLength = stats.isDirectory() ? 0 : Number(stats.size);
@@ -15320,11 +15393,11 @@ var StableProjectCaptureSession = class _StableProjectCaptureSession {
15320
15393
  if (!isInsideRoot(this.root, absolutePath)) {
15321
15394
  throw new ProjectEvidenceError("PROJECT_PATH_OUTSIDE_ROOT", false);
15322
15395
  }
15323
- const relative = path4.relative(this.root, absolutePath);
15324
- const components = relative === "" ? [] : relative.split(path4.sep);
15396
+ const relative = path5.relative(this.root, absolutePath);
15397
+ const components = relative === "" ? [] : relative.split(path5.sep);
15325
15398
  const paths = [
15326
15399
  this.root,
15327
- ...components.map((_, index) => path4.join(this.root, ...components.slice(0, index + 1)))
15400
+ ...components.map((_, index) => path5.join(this.root, ...components.slice(0, index + 1)))
15328
15401
  ];
15329
15402
  let finalStats;
15330
15403
  for (const [index, currentPath] of paths.entries()) {
@@ -15365,7 +15438,7 @@ var StableProjectCaptureSession = class _StableProjectCaptureSession {
15365
15438
  };
15366
15439
 
15367
15440
  // src/source-scope.ts
15368
- import path5 from "node:path";
15441
+ import path6 from "node:path";
15369
15442
  var InitialEvidenceScopeSchema = external_exports.object({
15370
15443
  pathPrefixes: external_exports.array(ProjectEvidenceGrantPathPrefixSchema).min(1).max(64)
15371
15444
  }).strict();
@@ -15445,10 +15518,10 @@ var includesInitialEvidencePath = (relativePath, scope) => {
15445
15518
  ))
15446
15519
  return false;
15447
15520
  if (isProjectEvidenceTraversalExcluded(relativePath)) return false;
15448
- const segments = relativePath.toLowerCase().split("/");
15449
- if (segments.slice(0, -1).some((segment) => excluded.has(segment))) return false;
15450
- const basename = segments.at(-1) ?? "";
15451
- return extensions.has(path5.posix.extname(basename)) || SOURCE_POLICY.documentationFiles.includes(basename) || SOURCE_POLICY.configurationFiles.includes(basename) || SOURCE_POLICY.workspaceFiles.includes(relativePath);
15521
+ const segments2 = relativePath.toLowerCase().split("/");
15522
+ if (segments2.slice(0, -1).some((segment) => excluded.has(segment))) return false;
15523
+ const basename = segments2.at(-1) ?? "";
15524
+ return extensions.has(path6.posix.extname(basename)) || SOURCE_POLICY.documentationFiles.includes(basename) || SOURCE_POLICY.configurationFiles.includes(basename) || SOURCE_POLICY.workspaceFiles.includes(relativePath);
15452
15525
  };
15453
15526
 
15454
15527
  // src/code-index-capture.ts
@@ -15801,8 +15874,8 @@ var MapAnalysisSchema = external_exports.object({
15801
15874
  var mapPathAllowed = (relative, prefixes) => prefixes.some(
15802
15875
  (prefix) => prefix === "." || relative === prefix || relative.startsWith(`${prefix}/`)
15803
15876
  );
15804
- var mapTestPath = (path12) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
15805
- path12
15877
+ var mapTestPath = (path13) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
15878
+ path13
15806
15879
  );
15807
15880
 
15808
15881
  // src/project-map-reference-types.ts
@@ -15886,11 +15959,11 @@ var string4 = (value) => {
15886
15959
  var identity = (id2, reconstructed) => id2 === reconstructed ? [] : [JSON.stringify(id2)];
15887
15960
  function encodeMapText(graph) {
15888
15961
  const files = /* @__PURE__ */ new Map();
15889
- const file2 = (path12) => {
15890
- let ref = files.get(path12);
15962
+ const file2 = (path13) => {
15963
+ let ref = files.get(path13);
15891
15964
  if (!ref) {
15892
15965
  ref = `F${files.size + 1}`;
15893
- files.set(path12, ref);
15966
+ files.set(path13, ref);
15894
15967
  }
15895
15968
  return ref;
15896
15969
  };
@@ -15938,7 +16011,7 @@ function encodeMapText(graph) {
15938
16011
  rows.push(`B ${node(frontier.entityRef)} ${frontier.direction}`);
15939
16012
  return [
15940
16013
  ...header,
15941
- ...[...files].map(([path12, ref]) => `${ref} ${JSON.stringify(path12)}`),
16014
+ ...[...files].map(([path13, ref]) => `${ref} ${JSON.stringify(path13)}`),
15942
16015
  ...rows
15943
16016
  ].join("\n");
15944
16017
  }
@@ -15958,10 +16031,10 @@ function decodeMapText(text) {
15958
16031
  const at = (value) => {
15959
16032
  const match = /^(F[1-9]\d*):(\d+)-(\d+)@(\d+)-(\d+)$/u.exec(value ?? "");
15960
16033
  if (!match) return failed();
15961
- const path12 = files.get(match[1] ?? "");
15962
- if (path12 === void 0) return failed();
16034
+ const path13 = files.get(match[1] ?? "");
16035
+ if (path13 === void 0) return failed();
15963
16036
  return MapAnchorSchema.parse({
15964
- path: path12,
16037
+ path: path13,
15965
16038
  startLine: Number(match[2]),
15966
16039
  endLine: Number(match[3]),
15967
16040
  start: Number(match[4]),
@@ -16038,8 +16111,8 @@ function decodeMapText(text) {
16038
16111
  var locationSchema = MapAnchorSchema.describe(
16039
16112
  "Source location: start/end are zero-based UTF-16 offsets with an exclusive end; line numbers are one-based."
16040
16113
  );
16041
- var location = ({ path: path12, startLine, endLine, start, end }) => ({
16042
- path: path12,
16114
+ var location = ({ path: path13, startLine, endLine, start, end }) => ({
16115
+ path: path13,
16043
16116
  startLine,
16044
16117
  endLine,
16045
16118
  start,
@@ -16142,11 +16215,11 @@ var MapNavigationObjectsSchema = external_exports.union([
16142
16215
  ),
16143
16216
  external_exports.object({ files: external_exports.array(searchFileSchema) }).passthrough().refine((value) => !("format" in value), "Text navigation must decode through its format.").transform(
16144
16217
  (value) => value.files.flatMap(
16145
- ({ path: path12, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
16218
+ ({ path: path13, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
16146
16219
  id: id2,
16147
16220
  name,
16148
16221
  kind,
16149
- anchor: { path: path12, startLine, endLine, start, end },
16222
+ anchor: { path: path13, startLine, endLine, start, end },
16150
16223
  ...execution ? { execution } : {}
16151
16224
  }))
16152
16225
  )
@@ -16159,10 +16232,10 @@ var mapSearchNavigation = (result) => {
16159
16232
  for (const [index, object2] of found.entries()) {
16160
16233
  const ranking = rankings[index];
16161
16234
  if (!ranking) throw new Error("PROJECT_MAP_SEARCH_RANKING_MISSING");
16162
- const path12 = object2.anchor.path;
16235
+ const path13 = object2.anchor.path;
16163
16236
  let file2 = files.at(-1);
16164
- if (file2?.path !== path12) {
16165
- file2 = { path: path12, symbols: [] };
16237
+ if (file2?.path !== path13) {
16238
+ file2 = { path: path13, symbols: [] };
16166
16239
  files.push(file2);
16167
16240
  }
16168
16241
  file2.symbols.push({
@@ -16288,8 +16361,8 @@ var MapViewGraph = class {
16288
16361
  }
16289
16362
  return object2;
16290
16363
  }
16291
- objectsAt(path12) {
16292
- return this.statements.path.all(this.version, path12).map((row) => {
16364
+ objectsAt(path13) {
16365
+ return this.statements.path.all(this.version, path13).map((row) => {
16293
16366
  const object2 = MapObjectSchema.parse(JSON.parse(String(row.object_json)));
16294
16367
  this.objects.set(object2.id, object2);
16295
16368
  return object2;
@@ -16408,8 +16481,8 @@ var MapViewGraph = class {
16408
16481
  );
16409
16482
  }
16410
16483
  };
16411
- function mapSelectDeclarations(graph, path12, name, line) {
16412
- const objects2 = graph.objectsAt(path12).filter((object2) => !mapIsModule(object2));
16484
+ function mapSelectDeclarations(graph, path13, name, line) {
16485
+ const objects2 = graph.objectsAt(path13).filter((object2) => !mapIsModule(object2));
16413
16486
  const matching = name === void 0 ? objects2 : objects2.filter(
16414
16487
  (object2) => object2.name === name || name.includes(".") && graph.qualifiedName(object2.id) === name
16415
16488
  );
@@ -16431,12 +16504,12 @@ function requireMapObject(store, version2, selector, prefixes) {
16431
16504
  if ([entityRef, locator, symbol2].filter((value) => value !== void 0).length !== 1 || entityRef !== void 0 && !entityRef.length)
16432
16505
  throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
16433
16506
  if (symbol2) {
16434
- const path12 = normalizeProjectEvidencePath(symbol2.path);
16435
- if (!mapPathAllowed(path12, prefixes))
16507
+ const path13 = normalizeProjectEvidencePath(symbol2.path);
16508
+ if (!mapPathAllowed(path13, prefixes))
16436
16509
  throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
16437
16510
  const selected = mapSelectDeclarations(
16438
16511
  new MapViewGraph(store, version2),
16439
- path12,
16512
+ path13,
16440
16513
  symbol2.name,
16441
16514
  symbol2.line
16442
16515
  );
@@ -16447,14 +16520,14 @@ function requireMapObject(store, version2, selector, prefixes) {
16447
16520
  }
16448
16521
  let rows;
16449
16522
  if (locator) {
16450
- const path12 = normalizeProjectEvidencePath(locator.path);
16523
+ const path13 = normalizeProjectEvidencePath(locator.path);
16451
16524
  if (!Number.isSafeInteger(locator.start) || locator.start < 0 || locator.kind !== void 0 && !MapObjectKindSchema.safeParse(locator.kind).success)
16452
16525
  throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
16453
- if (!mapPathAllowed(path12, prefixes))
16526
+ if (!mapPathAllowed(path13, prefixes))
16454
16527
  throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
16455
16528
  rows = store.database.prepare(`SELECT object_json FROM project_map_objects
16456
16529
  WHERE version_ref = ? AND path = ? AND json_extract(object_json, '$.anchor.start') = ?
16457
- AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path12, locator.start, locator.kind ?? null, locator.kind ?? null);
16530
+ AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path13, locator.start, locator.kind ?? null, locator.kind ?? null);
16458
16531
  } else {
16459
16532
  rows = store.database.prepare(
16460
16533
  "SELECT object_json FROM project_map_objects WHERE version_ref = ? AND entity_ref = ?"
@@ -16495,13 +16568,13 @@ function mapQueryPage(count, materialize, navigation, budget) {
16495
16568
 
16496
16569
  // src/project-map-query-selection.ts
16497
16570
  var mapQuerySelection = (input, knownKinds) => {
16498
- const path12 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
16571
+ const path13 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
16499
16572
  const kinds = input.kinds ?? knownKinds;
16500
16573
  if (!Array.isArray(kinds) || !kinds.length || kinds.length > knownKinds.length || kinds.some((kind) => !knownKinds.includes(kind)))
16501
16574
  throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
16502
- return { path: path12, kinds: [...new Set(kinds)].sort() };
16575
+ return { path: path13, kinds: [...new Set(kinds)].sort() };
16503
16576
  };
16504
- var mapQueryPathMatches = (path12, prefix) => prefix === "." || path12 === prefix || path12.startsWith(`${prefix}/`);
16577
+ var mapQueryPathMatches = (path13, prefix) => prefix === "." || path13 === prefix || path13.startsWith(`${prefix}/`);
16505
16578
  var mapQueryPathSql = (column) => `(? = '.' OR ${column} = ? OR substr(${column}, 1, length(?) + 1) = ? || '/')`;
16506
16579
 
16507
16580
  // src/project-map-search-focus.ts
@@ -16599,7 +16672,7 @@ var declarationKinds = /* @__PURE__ */ new Set([
16599
16672
  "METHOD",
16600
16673
  "TYPE"
16601
16674
  ]);
16602
- var fileStem = (path12) => path12.slice(path12.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
16675
+ var fileStem = (path13) => path13.slice(path13.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
16603
16676
  var compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
16604
16677
  var compareRows = (left, right) => right.ranking.score - left.ranking.score || compareText(left.object.anchor.path, right.object.anchor.path) || compareText(left.object.id, right.object.id);
16605
16678
  function mapSearchQuery(input) {
@@ -16626,10 +16699,10 @@ function mapSearchQuery(input) {
16626
16699
  }
16627
16700
  function rank(object2, documentation, relationCount, query, focus) {
16628
16701
  const name = object2.name.toLowerCase();
16629
- const path12 = object2.anchor.path.toLowerCase();
16702
+ const path13 = object2.anchor.path.toLowerCase();
16630
16703
  const values = {
16631
16704
  NAME: [name],
16632
- PATH: [path12],
16705
+ PATH: [path13],
16633
16706
  DOCUMENTATION: documentation.map((text) => text.toLowerCase())
16634
16707
  };
16635
16708
  const matched = query.terms.map((term) => ({
@@ -16654,12 +16727,12 @@ function rank(object2, documentation, relationCount, query, focus) {
16654
16727
  score += 7e3;
16655
16728
  signals.push("SYMBOL_CONTAINS");
16656
16729
  } else if (matchedFields.includes("NAME")) signals.push("SYMBOL_CONTAINS");
16657
- if (object2.kind === "FILE" && fileStem(path12) === normalizedQuery) {
16730
+ if (object2.kind === "FILE" && fileStem(path13) === normalizedQuery) {
16658
16731
  score += 11e3;
16659
16732
  signals.push("EXACT_FILE_STEM");
16660
16733
  }
16661
16734
  if (matchedFields.includes("PATH")) {
16662
- score += path12.includes(normalizedQuery) ? 2500 : 0;
16735
+ score += path13.includes(normalizedQuery) ? 2500 : 0;
16663
16736
  signals.push("PATH_CONTAINS");
16664
16737
  }
16665
16738
  if (matchedFields.includes("DOCUMENTATION")) {
@@ -16674,8 +16747,8 @@ function rank(object2, documentation, relationCount, query, focus) {
16674
16747
  score += kindWeight[object2.kind] + Math.min(1200, relationCount * 20) + (focus?.score ?? 0);
16675
16748
  if (declarationKinds.has(object2.kind)) signals.push("DECLARATION");
16676
16749
  if (relationCount > 0) signals.push("GRAPH_CONNECTED");
16677
- const isTest = mapTestPath(path12);
16678
- const isGenerated = generatedPath.test(path12);
16750
+ const isTest = mapTestPath(path13);
16751
+ const isGenerated = generatedPath.test(path13);
16679
16752
  const hasTestIntent = query.terms.some((term) => testQuery.test(term));
16680
16753
  score += isTest ? hasTestIntent ? 1e3 : -5e3 : 300;
16681
16754
  score += isGenerated ? -3e3 : 300;
@@ -16974,7 +17047,7 @@ function mapPageFrontier(frontier, rows) {
16974
17047
  }
16975
17048
 
16976
17049
  // src/project-map-language-go.ts
16977
- import { existsSync as existsSync2 } from "node:fs";
17050
+ import { existsSync as existsSync3 } from "node:fs";
16978
17051
 
16979
17052
  // src/project-map-analysis-validation.ts
16980
17053
  function validateMapAnalysis(analysis, input) {
@@ -17159,13 +17232,13 @@ function utf16Offsets(text) {
17159
17232
  }
17160
17233
  function offsetConverter(files, offsets) {
17161
17234
  const converters = /* @__PURE__ */ new Map();
17162
- return (path12, offset) => {
17163
- let convert = converters.get(path12);
17235
+ return (path13, offset) => {
17236
+ let convert = converters.get(path13);
17164
17237
  if (!convert) {
17165
- const text = files[path12];
17238
+ const text = files[path13];
17166
17239
  if (text === void 0) return invalid();
17167
17240
  convert = offsets === "UTF16" ? (value) => value <= text.length ? value : invalid() : utf16Offsets(text);
17168
- converters.set(path12, convert);
17241
+ converters.set(path13, convert);
17169
17242
  }
17170
17243
  return convert(offset);
17171
17244
  };
@@ -17196,7 +17269,7 @@ function mapFactsAnalysis(facts, input, context) {
17196
17269
  const collect = new MapOutputCollector(output);
17197
17270
  const positions = new MapSourcePositions(input.files);
17198
17271
  const offset = offsetConverter(input.files, context.offsets);
17199
- const anchor = (path12, start, end) => positions.span(path12, offset(path12, start), offset(path12, end));
17272
+ const anchor = (path13, start, end) => positions.span(path13, offset(path13, start), offset(path13, end));
17200
17273
  const located = /* @__PURE__ */ new Map();
17201
17274
  const canonical = /* @__PURE__ */ new Map();
17202
17275
  const bySpan = /* @__PURE__ */ new Map();
@@ -17361,8 +17434,8 @@ function mapReferencesPage(facts, files, reference, offsets) {
17361
17434
 
17362
17435
  // src/project-map-process.ts
17363
17436
  import { execFileSync, spawn as spawn2 } from "node:child_process";
17364
- import { existsSync, readFileSync, realpathSync } from "node:fs";
17365
- import path6 from "node:path";
17437
+ import { existsSync as existsSync2, readFileSync, realpathSync } from "node:fs";
17438
+ import path7 from "node:path";
17366
17439
 
17367
17440
  // src/project-map-failure.ts
17368
17441
  var PhaseSchema = external_exports.enum([
@@ -17487,24 +17560,24 @@ var ProjectMapStopUnconfirmedError = class extends ProjectEvidenceError {
17487
17560
  }
17488
17561
  };
17489
17562
  var installedMapParserResources = () => {
17490
- const directory = path6.dirname(path6.resolve(process.argv[1] ?? "."));
17563
+ const directory = path7.dirname(path7.resolve(process.argv[1] ?? "."));
17491
17564
  return {
17492
- workerPath: path6.join(directory, "project-map-worker.mjs"),
17493
- compilerPath: path6.join(directory, "project-map-native/tsc")
17565
+ workerPath: path7.join(directory, "project-map-worker.mjs"),
17566
+ compilerPath: path7.join(directory, "project-map-native/tsc")
17494
17567
  };
17495
17568
  };
17496
17569
  var installedPythonMapResources = () => {
17497
- const directory = path6.dirname(path6.resolve(process.argv[1] ?? "."));
17570
+ const directory = path7.dirname(path7.resolve(process.argv[1] ?? "."));
17498
17571
  return {
17499
- workerPath: path6.join(directory, "project-map-python-worker.mjs"),
17500
- compilerPath: path6.join(directory, "project-map-python/typeshed")
17572
+ workerPath: path7.join(directory, "project-map-python-worker.mjs"),
17573
+ compilerPath: path7.join(directory, "project-map-python/typeshed")
17501
17574
  };
17502
17575
  };
17503
17576
  function discoverJavaRuntime(env = process.env) {
17504
17577
  const homes = [env.LAYERMAP_JAVA_HOME, env.JAVA_HOME];
17505
- for (const directory of (env.PATH ?? "").split(path6.delimiter)) {
17506
- const java = path6.join(directory, "java");
17507
- if (directory && existsSync(java)) homes.push(path6.dirname(path6.dirname(realpathSync(java))));
17578
+ for (const directory of (env.PATH ?? env.Path ?? "").split(path7.delimiter)) {
17579
+ const java = path7.join(directory, executableName("java"));
17580
+ if (directory && existsSync2(java)) homes.push(path7.dirname(path7.dirname(realpathSync(java))));
17508
17581
  }
17509
17582
  homes.push(
17510
17583
  ...["/opt/homebrew/opt", "/usr/local/opt"].flatMap(
@@ -17512,7 +17585,7 @@ function discoverJavaRuntime(env = process.env) {
17512
17585
  (formula) => `${prefix}/${formula}/libexec/openjdk.jdk/Contents/Home`
17513
17586
  )
17514
17587
  ),
17515
- ...env.HOME ? [path6.join(env.HOME, ".sdkman/candidates/java/current")] : []
17588
+ ...env.HOME ? [path7.join(env.HOME, ".sdkman/candidates/java/current")] : []
17516
17589
  );
17517
17590
  if (process.platform === "darwin")
17518
17591
  try {
@@ -17527,11 +17600,12 @@ function discoverJavaRuntime(env = process.env) {
17527
17600
  }
17528
17601
  for (const home of homes) {
17529
17602
  if (!home) continue;
17530
- const runtimePath = path6.join(home, "bin", "java");
17531
- if (!existsSync(runtimePath) || !existsSync(path6.join(home, "bin", "javac"))) continue;
17603
+ const runtimePath = path7.join(home, "bin", executableName("java"));
17604
+ if (!existsSync2(runtimePath) || !existsSync2(path7.join(home, "bin", executableName("javac"))))
17605
+ continue;
17532
17606
  let release = "";
17533
17607
  try {
17534
- release = readFileSync(path6.join(home, "release"), "utf8");
17608
+ release = readFileSync(path7.join(home, "release"), "utf8");
17535
17609
  } catch {
17536
17610
  continue;
17537
17611
  }
@@ -17542,28 +17616,26 @@ function discoverJavaRuntime(env = process.env) {
17542
17616
  return void 0;
17543
17617
  }
17544
17618
  var installedJavaMapResources = () => {
17545
- const directory = path6.dirname(path6.resolve(process.argv[1] ?? "."));
17546
- const compilerPath = path6.join(directory, "project-map-java/java-map.jar");
17619
+ const directory = path7.dirname(path7.resolve(process.argv[1] ?? "."));
17620
+ const compilerPath = path7.join(directory, "project-map-java/java-map.jar");
17547
17621
  return {
17548
- workerPath: path6.join(directory, "project-map-java-worker.mjs"),
17622
+ workerPath: path7.join(directory, "project-map-java-worker.mjs"),
17549
17623
  compilerPath,
17550
17624
  // A build without a JDK leaves no analyzer to run, whatever runtime this machine has.
17551
- ...existsSync(compilerPath) ? discoverJavaRuntime() : {}
17625
+ ...existsSync2(compilerPath) ? discoverJavaRuntime() : {}
17552
17626
  };
17553
17627
  };
17554
17628
  var installedGoMapResources = () => {
17555
- const directory = path6.dirname(path6.resolve(process.argv[1] ?? "."));
17629
+ const directory = path7.dirname(path7.resolve(process.argv[1] ?? "."));
17556
17630
  return {
17557
- workerPath: path6.join(directory, "project-map-go-worker.mjs"),
17558
- compilerPath: path6.join(directory, "project-map-go/go-map")
17631
+ workerPath: path7.join(directory, "project-map-go-worker.mjs"),
17632
+ compilerPath: path7.join(directory, "project-map-go/go-map")
17559
17633
  };
17560
17634
  };
17561
17635
  function runMapOperation(resources, input, schema, signal, observeTiming) {
17562
- if (process.platform === "win32")
17563
- return Promise.reject(new ProjectEvidenceError("PROJECT_MAP_PLATFORM_UNSUPPORTED", false));
17564
17636
  if (signal.aborted)
17565
17637
  return Promise.reject(new ProjectEvidenceError("PROJECT_READ_CANCELLED", true));
17566
- if (!path6.isAbsolute(resources.workerPath) || !path6.isAbsolute(resources.compilerPath)) {
17638
+ if (!path7.isAbsolute(resources.workerPath) || !path7.isAbsolute(resources.compilerPath)) {
17567
17639
  return Promise.reject(
17568
17640
  new ProjectEvidenceError("PROJECT_MAP_PARSER_CONFIGURATION_INVALID", false)
17569
17641
  );
@@ -17584,14 +17656,15 @@ function runMapOperation(resources, input, schema, signal, observeTiming) {
17584
17656
  return new Promise((resolve, reject) => {
17585
17657
  const child = spawn2(process.execPath, [...resources.execArgv ?? [], resources.workerPath], {
17586
17658
  detached: true,
17659
+ windowsHide: true,
17587
17660
  stdio: ["ignore", "pipe", "pipe", "ipc"],
17588
- env: {
17661
+ env: childEnvironment({
17589
17662
  PATH: "/usr/bin:/bin",
17590
17663
  LANG: "C",
17591
17664
  HOME: process.env.HOME,
17592
17665
  TMPDIR: process.env.TMPDIR,
17593
17666
  ELECTRON_RUN_AS_NODE: "1"
17594
- }
17667
+ })
17595
17668
  });
17596
17669
  let result;
17597
17670
  let resultAt;
@@ -17613,7 +17686,7 @@ function runMapOperation(resources, input, schema, signal, observeTiming) {
17613
17686
  const kill = (value) => {
17614
17687
  if (!child.pid) return;
17615
17688
  try {
17616
- process.kill(-child.pid, value);
17689
+ stopProcessTree(child.pid, value);
17617
17690
  } catch {
17618
17691
  }
17619
17692
  };
@@ -17731,11 +17804,7 @@ function runMapOperation(resources, input, schema, signal, observeTiming) {
17731
17804
  const drained = async () => {
17732
17805
  const until = Date.now() + PROJECT_MAP_LIMITS.stopMs;
17733
17806
  while (child.pid) {
17734
- try {
17735
- process.kill(-child.pid, 0);
17736
- } catch (error51) {
17737
- if (error51.code === "ESRCH") return true;
17738
- }
17807
+ if (processTreeGone(child.pid)) return true;
17739
17808
  if (Date.now() >= until) return false;
17740
17809
  await new Promise((resolve2) => setTimeout(resolve2, 20));
17741
17810
  }
@@ -17766,8 +17835,8 @@ var goModule = /(?:^|\/)go\.mod$/u;
17766
17835
  var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
17767
17836
  var GO_MAP_LANGUAGE = Object.freeze({
17768
17837
  id: "go-1.24-map-v9",
17769
- claims: (path12) => path12.endsWith(".go"),
17770
- reads: (path12) => goModule.test(path12),
17838
+ claims: (path13) => path13.endsWith(".go"),
17839
+ reads: (path13) => goModule.test(path13),
17771
17840
  // A module path, or the standard library, whose first path element has no dot.
17772
17841
  importName: (specifier) => {
17773
17842
  const parts = specifier.split("/");
@@ -17776,7 +17845,7 @@ var GO_MAP_LANGUAGE = Object.freeze({
17776
17845
  return parts.slice(0, size).join("/");
17777
17846
  },
17778
17847
  // Go imports a package: the directory of the file.
17779
- importTarget: (path12) => `${path12.slice(0, path12.lastIndexOf("/") + 1) || "./"}`,
17848
+ importTarget: (path13) => `${path13.slice(0, path13.lastIndexOf("/") + 1) || "./"}`,
17780
17849
  create: () => new GoMapAnalyzer()
17781
17850
  });
17782
17851
  var GO_GAPS = [
@@ -17822,12 +17891,12 @@ var GoMapAnalyzer = class {
17822
17891
  }
17823
17892
  }
17824
17893
  async analyze(session, signal) {
17825
- const modules = session.readable.map((entry) => entry.path).filter((path12) => goModule.test(path12)).sort();
17826
- const moduleOf = (path12) => {
17894
+ const modules = session.readable.map((entry) => entry.path).filter((path13) => goModule.test(path13)).sort();
17895
+ const moduleOf = (path13) => {
17827
17896
  let best;
17828
17897
  for (const modFile of modules) {
17829
17898
  const directory = modFile.slice(0, modFile.lastIndexOf("/") + 1);
17830
- if (path12.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
17899
+ if (path13.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
17831
17900
  best = modFile;
17832
17901
  }
17833
17902
  return best;
@@ -17843,11 +17912,11 @@ var GoMapAnalyzer = class {
17843
17912
  for (const modFile of [...groups.keys()].sort()) {
17844
17913
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
17845
17914
  const files = /* @__PURE__ */ Object.create(null);
17846
- for (const path12 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
17847
- const text = session.texts[path12];
17915
+ for (const path13 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
17916
+ const text = session.texts[path13];
17848
17917
  if (text === void 0)
17849
17918
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
17850
- files[path12] = text;
17919
+ files[path13] = text;
17851
17920
  }
17852
17921
  const input = {
17853
17922
  contextRef: digestValue({
@@ -17859,7 +17928,7 @@ var GoMapAnalyzer = class {
17859
17928
  inventory: Object.keys(files).sort(),
17860
17929
  syntaxOnly: false
17861
17930
  };
17862
- const built = existsSync2(this.resources.compilerPath);
17931
+ const built = existsSync3(this.resources.compilerPath);
17863
17932
  const reused = session.reuse(input.contextRef, { modFile, built }, Object.keys(files));
17864
17933
  if (reused) {
17865
17934
  session.accept(reused);
@@ -17879,11 +17948,11 @@ var GoMapAnalyzer = class {
17879
17948
  }
17880
17949
  async references(input, reference, signal, observe) {
17881
17950
  const text = input.files[reference.targetPath];
17882
- if (text === void 0 || !existsSync2(this.resources.compilerPath))
17951
+ if (text === void 0 || !existsSync3(this.resources.compilerPath))
17883
17952
  throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
17884
17953
  const files = /* @__PURE__ */ Object.create(null);
17885
- for (const [path12, value] of Object.entries(input.files))
17886
- if (this.claims(path12) || goModule.test(path12)) files[path12] = value;
17954
+ for (const [path13, value] of Object.entries(input.files))
17955
+ if (this.claims(path13) || goModule.test(path13)) files[path13] = value;
17887
17956
  const facts = await this.operation(
17888
17957
  {
17889
17958
  ...input,
@@ -17904,7 +17973,7 @@ var GoMapAnalyzer = class {
17904
17973
  };
17905
17974
 
17906
17975
  // src/project-map-language-java.ts
17907
- import { existsSync as existsSync3 } from "node:fs";
17976
+ import { existsSync as existsSync4 } from "node:fs";
17908
17977
  var BUILD_FILES = [
17909
17978
  "settings.gradle.kts",
17910
17979
  "settings.gradle",
@@ -17913,14 +17982,14 @@ var BUILD_FILES = [
17913
17982
  "pom.xml"
17914
17983
  ];
17915
17984
  var buildFile = /(?:^|\/)(?:pom\.xml|(?:build|settings)\.gradle(?:\.kts)?)$/u;
17916
- var directoryOf = (path12) => path12.slice(0, path12.lastIndexOf("/") + 1);
17917
- var nameOf = (path12) => path12.slice(path12.lastIndexOf("/") + 1);
17985
+ var directoryOf = (path13) => path13.slice(0, path13.lastIndexOf("/") + 1);
17986
+ var nameOf = (path13) => path13.slice(path13.lastIndexOf("/") + 1);
17918
17987
  var DEFAULT_RELEASE = 21;
17919
17988
  var platformPackage = /^(?:java|jdk|sun|com\.sun|javax\.(?:annotation\.processing|crypto|imageio|lang\.model|management|naming|net|print|script|security|sound|sql|swing|tools|transaction\.xa|xml))(?:\.|$)/u;
17920
17989
  var JAVA_MAP_LANGUAGE = Object.freeze({
17921
17990
  id: "javac-lombok-1.18.48-map-v8",
17922
- claims: (path12) => path12.endsWith(".java"),
17923
- reads: (path12) => buildFile.test(path12),
17991
+ claims: (path13) => path13.endsWith(".java"),
17992
+ reads: (path13) => buildFile.test(path13),
17924
17993
  // A package of the Java platform, or a library named by its first two package segments.
17925
17994
  importName: (specifier) => platformPackage.test(specifier) ? "Java standard library" : specifier.split(".").slice(0, 2).join("."),
17926
17995
  create: () => new JavaMapAnalyzer()
@@ -17983,7 +18052,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
17983
18052
  // The runtime found at startup may be gone since (an upgraded JDK replaces its directory).
17984
18053
  refreshRuntime() {
17985
18054
  const { runtimePath } = this.resources;
17986
- if (runtimePath && !existsSync3(runtimePath)) {
18055
+ if (runtimePath && !existsSync4(runtimePath)) {
17987
18056
  const { runtimePath: _gone, runtimeVersion: _version, ...rest } = this.resources;
17988
18057
  this.resources = { ...rest, ...discoverJavaRuntime() };
17989
18058
  }
@@ -18010,12 +18079,12 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18010
18079
  // The worker's request for a context: the Java sources, the release and which are tests.
18011
18080
  request(input, buildTexts) {
18012
18081
  const files = /* @__PURE__ */ Object.create(null);
18013
- for (const [path12, text] of Object.entries(input.files))
18014
- if (this.claims(path12)) files[path12] = text;
18082
+ for (const [path13, text] of Object.entries(input.files))
18083
+ if (this.claims(path13)) files[path13] = text;
18015
18084
  return {
18016
18085
  files,
18017
18086
  release: javaRelease(buildTexts, this.resources.runtimeVersion),
18018
- tests: Object.keys(files).filter((path12) => mapTestPath(path12))
18087
+ tests: Object.keys(files).filter((path13) => mapTestPath(path13))
18019
18088
  };
18020
18089
  }
18021
18090
  // The build files of a context's root directory, which declare its Java version.
@@ -18027,35 +18096,35 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18027
18096
  }
18028
18097
  async analyze(session, signal) {
18029
18098
  this.refreshRuntime();
18030
- const builds = session.readable.map((entry) => entry.path).filter((path12) => buildFile.test(path12));
18031
- for (const path12 of builds) session.configuration(path12);
18032
- const rank2 = (path12) => BUILD_FILES.indexOf(nameOf(path12));
18099
+ const builds = session.readable.map((entry) => entry.path).filter((path13) => buildFile.test(path13));
18100
+ for (const path13 of builds) session.configuration(path13);
18101
+ const rank2 = (path13) => BUILD_FILES.indexOf(nameOf(path13));
18033
18102
  const roots = /* @__PURE__ */ new Map();
18034
18103
  const modules = /* @__PURE__ */ new Map();
18035
- for (const path12 of builds) {
18036
- const directory = directoryOf(path12);
18104
+ for (const path13 of builds) {
18105
+ const directory = directoryOf(path13);
18037
18106
  const current = modules.get(directory);
18038
- if (current === void 0 || rank2(path12) < rank2(current)) modules.set(directory, path12);
18039
- const text = session.texts[path12] ?? "";
18040
- if (/settings\.gradle(?:\.kts)?$/u.test(path12) || path12.endsWith("pom.xml") && /<modules>/u.test(text)) {
18107
+ if (current === void 0 || rank2(path13) < rank2(current)) modules.set(directory, path13);
18108
+ const text = session.texts[path13] ?? "";
18109
+ if (/settings\.gradle(?:\.kts)?$/u.test(path13) || path13.endsWith("pom.xml") && /<modules>/u.test(text)) {
18041
18110
  const root = roots.get(directory);
18042
- if (root === void 0 || rank2(path12) < rank2(root)) roots.set(directory, path12);
18111
+ if (root === void 0 || rank2(path13) < rank2(root)) roots.set(directory, path13);
18043
18112
  }
18044
18113
  }
18045
- const configOf = (path12) => {
18114
+ const configOf = (path13) => {
18046
18115
  let outer;
18047
18116
  for (const directory of roots.keys())
18048
- if (path12.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
18117
+ if (path13.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
18049
18118
  outer = directory;
18050
18119
  if (outer !== void 0) return roots.get(outer);
18051
18120
  let nearest;
18052
18121
  for (const directory of modules.keys())
18053
- if (path12.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
18122
+ if (path13.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
18054
18123
  nearest = directory;
18055
18124
  return nearest === void 0 ? "" : modules.get(nearest);
18056
18125
  };
18057
- const output = (path12) => [...modules.keys()].some(
18058
- (directory) => path12.startsWith(`${directory}build/`) || path12.startsWith(`${directory}target/`)
18126
+ const output = (path13) => [...modules.keys()].some(
18127
+ (directory) => path13.startsWith(`${directory}build/`) || path13.startsWith(`${directory}target/`)
18059
18128
  );
18060
18129
  const groups = /* @__PURE__ */ new Map();
18061
18130
  for (const entry of session.readable) {
@@ -18070,13 +18139,13 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18070
18139
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
18071
18140
  const files = /* @__PURE__ */ Object.create(null);
18072
18141
  const rootBuilds = configPath ? BUILD_FILES.map((name) => `${directoryOf(configPath)}${name}`).filter(
18073
- (path12) => builds.includes(path12)
18142
+ (path13) => builds.includes(path13)
18074
18143
  ) : [];
18075
- for (const path12 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
18076
- const text = session.texts[path12];
18144
+ for (const path13 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
18145
+ const text = session.texts[path13];
18077
18146
  if (text === void 0)
18078
18147
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18079
- files[path12] = text;
18148
+ files[path13] = text;
18080
18149
  }
18081
18150
  const input = {
18082
18151
  contextRef: digestValue({
@@ -18101,7 +18170,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18101
18170
  release: request.release,
18102
18171
  tests: request.tests,
18103
18172
  runtime,
18104
- built: existsSync3(this.resources.compilerPath),
18173
+ built: existsSync4(this.resources.compilerPath),
18105
18174
  lombokConfig
18106
18175
  },
18107
18176
  Object.keys(files)
@@ -18119,7 +18188,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18119
18188
  const prior = JavaStateSchema.safeParse(previous?.state).data;
18120
18189
  const incremental = previous && prior?.basis === basis ? {
18121
18190
  changed: Object.keys(request.files).filter(
18122
- (path12) => digests.get(path12) !== previous.digests.get(path12)
18191
+ (path13) => digests.get(path13) !== previous.digests.get(path13)
18123
18192
  ),
18124
18193
  state: prior.java
18125
18194
  } : void 0;
@@ -18136,7 +18205,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18136
18205
  this.resources.runtimeVersion,
18137
18206
  [
18138
18207
  ...this.resources.runtimePath ? [] : [
18139
- existsSync3(this.resources.compilerPath) ? "JAVA_RUNTIME_UNAVAILABLE" : "JAVA_ANALYZER_NOT_BUILT"
18208
+ existsSync4(this.resources.compilerPath) ? "JAVA_RUNTIME_UNAVAILABLE" : "JAVA_ANALYZER_NOT_BUILT"
18140
18209
  ],
18141
18210
  ...lombokConfig ? ["LOMBOK_CONFIG_NOT_APPLIED"] : []
18142
18211
  ]
@@ -18148,14 +18217,14 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18148
18217
  continue;
18149
18218
  }
18150
18219
  const focus = new Set(facts.focus);
18151
- if (!incremental || facts.focus.some((path12) => !Object.hasOwn(request.files, path12)) || incremental.changed.some((path12) => !focus.has(path12)))
18220
+ if (!incremental || facts.focus.some((path13) => !Object.hasOwn(request.files, path13)) || incremental.changed.some((path13) => !focus.has(path13)))
18152
18221
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18153
18222
  analysis.objects = analysis.objects.filter((object2) => focus.has(object2.anchor.path));
18154
18223
  analysis.relations = analysis.relations.filter((relation) => focus.has(relation.anchor.path));
18155
18224
  analysis.notes = analysis.notes.filter((note) => focus.has(note.anchor.path));
18156
18225
  session.accept(analysis, {
18157
18226
  state,
18158
- linked: analysis.parsedFiles.filter((path12) => !focus.has(path12))
18227
+ linked: analysis.parsedFiles.filter((path13) => !focus.has(path13))
18159
18228
  });
18160
18229
  }
18161
18230
  }
@@ -18467,12 +18536,12 @@ var PYTHON_STANDARD_LIBRARY = /* @__PURE__ */ new Set([
18467
18536
  // src/project-map-language-python.ts
18468
18537
  var CONFIGURATION = ["pyrightconfig.json", "pyproject.toml", "setup.cfg"];
18469
18538
  var pythonConfig = /(?:^|\/)(?:pyrightconfig\.json|pyproject\.toml|setup\.cfg)$/u;
18470
- var directoryOf2 = (path12) => path12.slice(0, path12.lastIndexOf("/") + 1);
18539
+ var directoryOf2 = (path13) => path13.slice(0, path13.lastIndexOf("/") + 1);
18471
18540
  var DEFAULT_PYTHON = { major: 3, minor: 13 };
18472
18541
  var PYTHON_MAP_LANGUAGE = Object.freeze({
18473
18542
  id: "pyright-1.1.414-map-v13",
18474
- claims: (path12) => /\.pyi?$/u.test(path12),
18475
- reads: (path12) => pythonConfig.test(path12),
18543
+ claims: (path13) => /\.pyi?$/u.test(path13),
18544
+ reads: (path13) => pythonConfig.test(path13),
18476
18545
  // An absolute import names the standard library or a distribution's top-level package.
18477
18546
  importName: (specifier) => {
18478
18547
  const top = specifier.split(".", 1)[0] ?? specifier;
@@ -18524,21 +18593,21 @@ var PythonMapAnalyzer = class {
18524
18593
  return {
18525
18594
  root: input.configPath ? directoryOf2(input.configPath).replace(/\/$/u, "") : "",
18526
18595
  pythonVersion: pythonVersion(input.files, input.configPath),
18527
- tests: Object.keys(input.files).filter((path12) => this.claims(path12) && mapTestPath(path12))
18596
+ tests: Object.keys(input.files).filter((path13) => this.claims(path13) && mapTestPath(path13))
18528
18597
  };
18529
18598
  }
18530
18599
  async analyze(session, signal) {
18531
18600
  const roots = /* @__PURE__ */ new Map();
18532
- for (const path12 of session.readable.map((entry) => entry.path).filter((path13) => pythonConfig.test(path13))) {
18533
- const directory = directoryOf2(path12);
18601
+ for (const path13 of session.readable.map((entry) => entry.path).filter((path14) => pythonConfig.test(path14))) {
18602
+ const directory = directoryOf2(path13);
18534
18603
  const current = roots.get(directory);
18535
18604
  const rank2 = (file2) => CONFIGURATION.indexOf(file2.slice(directory.length));
18536
- if (current === void 0 || rank2(path12) < rank2(current)) roots.set(directory, path12);
18605
+ if (current === void 0 || rank2(path13) < rank2(current)) roots.set(directory, path13);
18537
18606
  }
18538
- const rootOf = (path12) => {
18607
+ const rootOf = (path13) => {
18539
18608
  let best;
18540
18609
  for (const directory of roots.keys())
18541
- if (path12.startsWith(directory) && (best === void 0 || directory.length > best.length))
18610
+ if (path13.startsWith(directory) && (best === void 0 || directory.length > best.length))
18542
18611
  best = directory;
18543
18612
  return best === void 0 ? "" : roots.get(best);
18544
18613
  };
@@ -18553,11 +18622,11 @@ var PythonMapAnalyzer = class {
18553
18622
  for (const configPath of [...groups.keys()].sort()) {
18554
18623
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
18555
18624
  const files = /* @__PURE__ */ Object.create(null);
18556
- for (const path12 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
18557
- const text = session.texts[path12];
18625
+ for (const path13 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
18626
+ const text = session.texts[path13];
18558
18627
  if (text === void 0)
18559
18628
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18560
- files[path12] = text;
18629
+ files[path13] = text;
18561
18630
  }
18562
18631
  const input = {
18563
18632
  contextRef: digestValue({
@@ -18605,8 +18674,8 @@ var PythonMapAnalyzer = class {
18605
18674
  if (input.files[reference.targetPath] === void 0)
18606
18675
  throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
18607
18676
  const files = /* @__PURE__ */ Object.create(null);
18608
- for (const [path12, value] of Object.entries(input.files))
18609
- if (this.claims(path12) || pythonConfig.test(path12)) files[path12] = value;
18677
+ for (const [path13, value] of Object.entries(input.files))
18678
+ if (this.claims(path13) || pythonConfig.test(path13)) files[path13] = value;
18610
18679
  const facts = await this.operation(
18611
18680
  {
18612
18681
  ...input,
@@ -18626,8 +18695,8 @@ var PythonMapAnalyzer = class {
18626
18695
  // src/project-map-language-typescript.ts
18627
18696
  var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
18628
18697
  id: "typescript-7.0.2-map-v17",
18629
- claims: (path12) => /\.[cm]?[jt]sx?$/u.test(path12),
18630
- reads: (path12) => path12.endsWith(".json") || path12 === "pnpm-workspace.yaml",
18698
+ claims: (path13) => /\.[cm]?[jt]sx?$/u.test(path13),
18699
+ reads: (path13) => path13.endsWith(".json") || path13 === "pnpm-workspace.yaml",
18631
18700
  create: () => new TypeScriptMapAnalyzer()
18632
18701
  });
18633
18702
  var CONFIGURATIONS_KEPT = 4;
@@ -18739,9 +18808,9 @@ var TypeScriptMapAnalyzer = class {
18739
18808
  accept(analysis);
18740
18809
  return;
18741
18810
  }
18742
- const required2 = analysis.requiredFiles.map((path12) => {
18743
- const entry = byPath.get(path12);
18744
- if (!entry || Object.hasOwn(texts, path12))
18811
+ const required2 = analysis.requiredFiles.map((path13) => {
18812
+ const entry = byPath.get(path13);
18813
+ if (!entry || Object.hasOwn(texts, path13))
18745
18814
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18746
18815
  return entry;
18747
18816
  });
@@ -18799,16 +18868,16 @@ var MAP_LANGUAGES = Object.freeze([
18799
18868
  ]);
18800
18869
  var mapAnalyzerSuite = (languages) => languages.map((language) => language.id).sort().join("+");
18801
18870
  var PROJECT_MAP_ANALYZER = mapAnalyzerSuite(MAP_LANGUAGES);
18802
- var mapCodePath = (path12) => MAP_LANGUAGES.some((language) => language.claims(path12));
18803
- var languageOf = (path12) => MAP_LANGUAGES.find((language) => language.claims(path12));
18804
- var mapLanguageOf = (path12) => languageOf(path12)?.id;
18871
+ var mapCodePath = (path13) => MAP_LANGUAGES.some((language) => language.claims(path13));
18872
+ var languageOf = (path13) => MAP_LANGUAGES.find((language) => language.claims(path13));
18873
+ var mapLanguageOf = (path13) => languageOf(path13)?.id;
18805
18874
  var npmPackage = (specifier) => {
18806
18875
  if (specifier.startsWith("node:")) return "node:*";
18807
18876
  const parts = specifier.split("/");
18808
18877
  return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? specifier;
18809
18878
  };
18810
18879
  var mapExternalImport = (sourcePath, specifier) => languageOf(sourcePath)?.importName?.(specifier) ?? npmPackage(specifier);
18811
- var mapImportTarget = (path12) => languageOf(path12)?.importTarget?.(path12) ?? path12;
18880
+ var mapImportTarget = (path13) => languageOf(path13)?.importTarget?.(path13) ?? path13;
18812
18881
 
18813
18882
  // src/project-map-view.ts
18814
18883
  var MAP_VIEW_FORMAT = "PROJECT_MAP_VIEW_V1";
@@ -18847,10 +18916,10 @@ var notFound = () => {
18847
18916
  };
18848
18917
  var MAP_KINDS_LEGEND = "kinds f function, c class, m method, p property, v variable, t type, i interface, e enum; numbers are 1-based source lines";
18849
18918
  var MAP_DECLARATION_LEGEND = `@n marks where a relationship occurs and +n counts further sites, which project_find_references lists; a quoted path after the sites is the route the call or value is registered under there: its HTTP methods when the registration names them, then its path joined with the prefixes of the routers it is registered on, as far as the same function or file sets them (a prefix added where a router is mounted or passed in is not included); route "\u2026" after a decorator is the full route the decorator maps, its class's path joined with its own. Static relationships are grouped by the declaration that owns them. Callers are direct calls, uses as a value (stored, passed, returned or selected, then usually invoked through that value) and calls through an interface, type or base member that a declaration implements (dispatched from); dispatches to lists the members that implement an interface, type or base member, which a call through it may reach; trace stops names calls whose target is a function value, a member without a mapped implementation or a computed key, which only source reading can follow; possible callers by name are calls elsewhere, in the same language, of a member with a method's name on a receiver of unknown type (an untyped value, or one an unloaded package produced); they may or may not reach that method.`;
18850
- var within = (path12, directory) => directory === "." || path12.startsWith(`${directory}/`);
18851
- var parentDirectory = (path12) => {
18852
- const slash = path12.lastIndexOf("/");
18853
- return slash < 0 ? "." : path12.slice(0, slash);
18919
+ var within = (path13, directory) => directory === "." || path13.startsWith(`${directory}/`);
18920
+ var parentDirectory = (path13) => {
18921
+ const slash = path13.lastIndexOf("/");
18922
+ return slash < 0 ? "." : path13.slice(0, slash);
18854
18923
  };
18855
18924
  var compareText2 = (left, right) => left < right ? -1 : left > right ? 1 : 0;
18856
18925
  var byCount = ([leftName, left], [rightName, right]) => right - left || compareText2(leftName, rightName);
@@ -18924,7 +18993,7 @@ function pageBlocks(view, head, whole, offset, budget) {
18924
18993
  if (offset === blocks.length) return materialize(0);
18925
18994
  return mapQueryPage(blocks.length - offset, materialize, (page) => page, budget);
18926
18995
  }
18927
- var inModule = (path12, module) => module.direct ? parentDirectory(path12) === module.directory : within(path12, module.directory);
18996
+ var inModule = (path13, module) => module.direct ? parentDirectory(path13) === module.directory : within(path13, module.directory);
18928
18997
  var moduleLabel = (module) => module.direct ? `${module.directory === "." ? "" : `${module.directory}/`}* (files directly here)` : `${module.directory}/`;
18929
18998
  function childModules(module, files) {
18930
18999
  if (module.direct) return [];
@@ -19077,12 +19146,12 @@ function loadMemberCalls(store, version2) {
19077
19146
  FROM project_map_relations
19078
19147
  WHERE version_ref = ? AND to_ref IS NULL AND json_extract(relation_json, '$.kind') = 'CALLS'
19079
19148
  AND json_extract(relation_json, '$.unresolvedReason') IN ('SYMBOL_NOT_RESOLVED', 'SYNTAX_ONLY')`).all(version2)) {
19080
- const path12 = String(row.path);
19149
+ const path13 = String(row.path);
19081
19150
  const target = String(row.target);
19082
19151
  const name = MEMBER_NAME.exec(target)?.[1];
19083
- const language = mapLanguageOf(path12);
19152
+ const language = mapLanguageOf(path13);
19084
19153
  if (!name || !language) continue;
19085
- const call = { from: String(row.from_ref), path: path12, line: Number(row.line), target };
19154
+ const call = { from: String(row.from_ref), path: path13, line: Number(row.line), target };
19086
19155
  const key = memberKey(language, name);
19087
19156
  const known = calls.get(key);
19088
19157
  if (known) known.push(call);
@@ -19137,10 +19206,10 @@ function loadCoverageNotes(store, version2) {
19137
19206
  if (!codes.includes(gap.code)) codes.push(gap.code);
19138
19207
  files.set(gap.path, codes);
19139
19208
  }
19140
- for (const [path12, codes] of files)
19209
+ for (const [path13, codes] of files)
19141
19210
  if (codes.length > 1 && codes.includes("NOT_IN_PARSED_CONTEXT"))
19142
19211
  files.set(
19143
- path12,
19212
+ path13,
19144
19213
  codes.filter((code) => code !== "NOT_IN_PARSED_CONTEXT")
19145
19214
  );
19146
19215
  return { files, limits: [...limits] };
@@ -19175,9 +19244,9 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19175
19244
  const visiblePaths = new Set(visible.map((entry) => entry.path));
19176
19245
  const code = visible.filter((entry) => entry.state === "TEXT" && mapCodePath(entry.path)).map((entry) => entry.path);
19177
19246
  const modules = mapModules(directory, code);
19178
- const moduleOf = (path12) => modules.find((module) => inModule(path12, module));
19179
- const outside = (path12) => {
19180
- const parts = path12.split("/");
19247
+ const moduleOf = (path13) => modules.find((module) => inModule(path13, module));
19248
+ const outside = (path13) => {
19249
+ const parts = path13.split("/");
19181
19250
  return `${parts.slice(0, Math.min(2, parts.length - 1)).join("/") || "."}/ (outside)`;
19182
19251
  };
19183
19252
  const moduleImports = /* @__PURE__ */ new Map();
@@ -19202,8 +19271,8 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19202
19271
  const blocks = [];
19203
19272
  if (modules.length > 1) {
19204
19273
  const sizes = /* @__PURE__ */ new Map();
19205
- for (const path12 of code) {
19206
- const module = moduleOf(path12);
19274
+ for (const path13 of code) {
19275
+ const module = moduleOf(path13);
19207
19276
  if (module) increment(sizes, moduleLabel(module));
19208
19277
  }
19209
19278
  blocks.push(
@@ -19232,18 +19301,18 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19232
19301
  )}${packages.length > shown.length ? `, +${packages.length - shown.length} more` : ""}`
19233
19302
  );
19234
19303
  }
19235
- const lineCount = (path12) => {
19236
- const file2 = facts.files.get(path12);
19237
- const gaps = coverage.files.get(path12) ?? [];
19304
+ const lineCount = (path13) => {
19305
+ const file2 = facts.files.get(path13);
19306
+ const gaps = coverage.files.get(path13) ?? [];
19238
19307
  if (file2?.parsed === false) return `[not parsed${gaps.length ? `: ${gaps.join("; ")}` : ""}]`;
19239
19308
  return `${file2 ? `${file2.lines}L` : "?L"}${gaps.length ? ` [${gaps.join("; ")}]` : ""}`;
19240
19309
  };
19241
19310
  const codeDirectories = /* @__PURE__ */ new Set();
19242
- for (const path12 of code)
19243
- for (let parent = parentDirectory(path12); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
19311
+ for (const path13 of code)
19312
+ for (let parent = parentDirectory(path13); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
19244
19313
  codeDirectories.add(parent);
19245
- const groupOf = (path12) => {
19246
- let group = parentDirectory(path12);
19314
+ const groupOf = (path13) => {
19315
+ let group = parentDirectory(path13);
19247
19316
  for (let parent = group; parent !== "." && parent !== directory && !codeDirectories.has(parent); parent = parentDirectory(parent))
19248
19317
  group = parent;
19249
19318
  return group;
@@ -19275,11 +19344,11 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19275
19344
  ]);
19276
19345
  }
19277
19346
  const detailed = [
19278
- ...code.map((path12) => {
19279
- const declarations = (facts.exported.get(path12) ?? []).map(({ text: text2 }) => text2);
19347
+ ...code.map((path13) => {
19348
+ const declarations = (facts.exported.get(path13) ?? []).map(({ text: text2 }) => text2);
19280
19349
  return [
19281
- path12,
19282
- `${path12} ${lineCount(path12)}${declarations.length ? `: ${declarations.join(", ")}` : ""}`
19350
+ path13,
19351
+ `${path13} ${lineCount(path13)}${declarations.length ? `: ${declarations.join(", ")}` : ""}`
19283
19352
  ];
19284
19353
  }),
19285
19354
  ...listedOther.map((entry) => [
@@ -19290,7 +19359,7 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19290
19359
  ];
19291
19360
  const directories = /* @__PURE__ */ new Map();
19292
19361
  for (const entry of [
19293
- ...code.map((path12) => ({ path: path12, item: lineCount(path12) })),
19362
+ ...code.map((path13) => ({ path: path13, item: lineCount(path13) })),
19294
19363
  ...listedOther.map((entry2) => ({
19295
19364
  path: entry2.path,
19296
19365
  item: entry2.state === "TEXT" ? "" : `(${entry2.state})`
@@ -19318,10 +19387,10 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19318
19387
  );
19319
19388
  const text = visible.filter((entry) => entry.state === "TEXT").length;
19320
19389
  const resolution = /* @__PURE__ */ new Map();
19321
- for (const path12 of code) {
19322
- const counts = facts.calls.get(path12);
19390
+ for (const path13 of code) {
19391
+ const counts = facts.calls.get(path13);
19323
19392
  if (!counts) continue;
19324
- const language = facts.files.get(path12)?.language ?? "unknown";
19393
+ const language = facts.files.get(path13)?.language ?? "unknown";
19325
19394
  const total = resolution.get(language) ?? { resolved: 0, unresolved: 0, external: 0 };
19326
19395
  total.resolved += counts.resolved;
19327
19396
  total.unresolved += counts.unresolved;
@@ -19379,8 +19448,8 @@ var DeclarationGroups = class {
19379
19448
  prefixes;
19380
19449
  showTests;
19381
19450
  memberCalls;
19382
- visible(path12) {
19383
- return mapPathAllowed(path12, this.prefixes) && (this.showTests || !mapTestPath(path12));
19451
+ visible(path13) {
19452
+ return mapPathAllowed(path13, this.prefixes) && (this.showTests || !mapTestPath(path13));
19384
19453
  }
19385
19454
  entry(object2, imported = false) {
19386
19455
  if (mapIsModule(object2)) return imported ? "(file)" : "(module scope)";
@@ -19424,11 +19493,11 @@ var DeclarationGroups = class {
19424
19493
  value.lines.push(line);
19425
19494
  aggregates.set(key, value);
19426
19495
  };
19427
- const dispatch = (arrow, label, ref2, path12, line) => {
19496
+ const dispatch = (arrow, label, ref2, path13, line) => {
19428
19497
  const other = graph.object(graph.owner(ref2));
19429
19498
  if (owned.has(other.id)) return;
19430
- if (!this.visible(path12)) {
19431
- if (mapPathAllowed(path12, this.prefixes)) omittedTests++;
19499
+ if (!this.visible(path13)) {
19500
+ if (mapPathAllowed(path13, this.prefixes)) omittedTests++;
19432
19501
  return;
19433
19502
  }
19434
19503
  add(arrow, label, other, line);
@@ -19585,7 +19654,7 @@ var DeclarationGroups = class {
19585
19654
  else files2.set(call.path, [item]);
19586
19655
  }
19587
19656
  lines.push(
19588
- ` \u2190 possible callers by name: ${[...files2].map(([path12, items]) => `${path12}: ${items.join(", ")}`).join("; ")}${inTests}`
19657
+ ` \u2190 possible callers by name: ${[...files2].map(([path13, items]) => `${path13}: ${items.join(", ")}`).join("; ")}${inTests}`
19589
19658
  );
19590
19659
  } else if (possibleInTests)
19591
19660
  lines.push(` \u2190 possible callers by name: ${possibleInTests} in test files (includeTests)`);
@@ -19621,14 +19690,14 @@ var DeclarationGroups = class {
19621
19690
  return { lines, neighbors: [...new Set(neighbors)] };
19622
19691
  }
19623
19692
  };
19624
- function fileView(store, coverage, graph, input, path12, prefixes) {
19625
- const entry = store.getEntry(input.version, path12);
19626
- if (!entry || !mapPathAllowed(path12, prefixes)) return notFound();
19627
- const showTests = input.includeTests === true || mapTestPath(path12);
19628
- const module = mapCodePath(path12) ? graph.objectsAt(path12).find((object2) => mapIsModule(object2)) : void 0;
19629
- const gaps = coverage.files.get(path12) ?? [];
19693
+ function fileView(store, coverage, graph, input, path13, prefixes) {
19694
+ const entry = store.getEntry(input.version, path13);
19695
+ if (!entry || !mapPathAllowed(path13, prefixes)) return notFound();
19696
+ const showTests = input.includeTests === true || mapTestPath(path13);
19697
+ const module = mapCodePath(path13) ? graph.objectsAt(path13).find((object2) => mapIsModule(object2)) : void 0;
19698
+ const gaps = coverage.files.get(path13) ?? [];
19630
19699
  const head = [
19631
- `PROJECT MAP \xB7 FILE ${path12} \xB7 ${entry.state !== "TEXT" ? entry.state : module ? module.parsing === "NOT_PARSED" ? `not parsed${gaps.length ? ` (${gaps.join("; ")})` : ""}; read it as text` : `${module.anchor.endLine} lines${gaps.length ? ` \xB7 ${gaps.join("; ")}` : ""}` : `${entry.byteLength} bytes, not analyzed; read it as text`}`
19700
+ `PROJECT MAP \xB7 FILE ${path13} \xB7 ${entry.state !== "TEXT" ? entry.state : module ? module.parsing === "NOT_PARSED" ? `not parsed${gaps.length ? ` (${gaps.join("; ")})` : ""}; read it as text` : `${module.anchor.endLine} lines${gaps.length ? ` \xB7 ${gaps.join("; ")}` : ""}` : `${entry.byteLength} bytes, not analyzed; read it as text`}`
19632
19701
  ];
19633
19702
  if (!module || entry.state !== "TEXT")
19634
19703
  return pageBlocks("FILE", head, [], input.offset ?? 0, input.outputBudget);
@@ -19648,7 +19717,7 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
19648
19717
  tags.set(relation.from, list);
19649
19718
  }
19650
19719
  const describe3 = (object2) => [
19651
- `${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path12 ? "" : ` (${object2.anchor.path})`}`,
19720
+ `${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path13 ? "" : ` (${object2.anchor.path})`}`,
19652
19721
  ...tags.get(object2.id) ?? []
19653
19722
  ].join(" ");
19654
19723
  const declarations = [];
@@ -19663,11 +19732,11 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
19663
19732
  );
19664
19733
  }
19665
19734
  const elsewhere = /* @__PURE__ */ new Map();
19666
- for (const object2 of graph.objectsAt(path12)) {
19735
+ for (const object2 of graph.objectsAt(path13)) {
19667
19736
  const parent = mapIsModule(object2) ? void 0 : graph.parent(object2.id);
19668
19737
  if (parent === void 0 || !graph.isAddressable(object2)) continue;
19669
19738
  const container = graph.object(parent);
19670
- if (mapIsModule(container) || container.anchor.path === path12) continue;
19739
+ if (mapIsModule(container) || container.anchor.path === path13) continue;
19671
19740
  const into = elsewhere.get(parent);
19672
19741
  if (into) into.push(object2);
19673
19742
  else elsewhere.set(parent, [object2]);
@@ -19681,7 +19750,7 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
19681
19750
  if (declarations.length) blocks.push(["DECLARATIONS (* exported)", ...declarations].join("\n"));
19682
19751
  const imports = /* @__PURE__ */ new Set();
19683
19752
  const external = /* @__PURE__ */ new Set();
19684
- const fileObjects = graph.objectsAt(path12).map((object2) => object2.id);
19753
+ const fileObjects = graph.objectsAt(path13).map((object2) => object2.id);
19685
19754
  for (const relation of graph.relationsFrom(fileObjects)) {
19686
19755
  if (!IMPORT_KINDS.has(relation.kind)) continue;
19687
19756
  if (relation.to === void 0) external.add(relation.target);
@@ -19692,8 +19761,8 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
19692
19761
  }
19693
19762
  const importers = /* @__PURE__ */ new Set();
19694
19763
  const testImporters = /* @__PURE__ */ new Set();
19695
- const imported = mapImportTarget(path12);
19696
- const packageModules = imported === path12 ? [module.id] : store.listEntries(input.version).filter((entry2) => mapImportTarget(entry2.path) === imported).flatMap((entry2) => graph.objectsAt(entry2.path).filter((object2) => mapIsModule(object2))).map((object2) => object2.id);
19764
+ const imported = mapImportTarget(path13);
19765
+ const packageModules = imported === path13 ? [module.id] : store.listEntries(input.version).filter((entry2) => mapImportTarget(entry2.path) === imported).flatMap((entry2) => graph.objectsAt(entry2.path).filter((object2) => mapIsModule(object2))).map((object2) => object2.id);
19697
19766
  for (const relation of graph.relationsTo(packageModules)) {
19698
19767
  if (!IMPORT_KINDS.has(relation.kind)) continue;
19699
19768
  const source = relation.anchor.path;
@@ -19721,16 +19790,16 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
19721
19790
  if (scope.length) blocks.push(["MODULE SCOPE (top-level statements)", ...scope].join("\n"));
19722
19791
  return pageBlocks("FILE", head, blocks, input.offset ?? 0, input.outputBudget);
19723
19792
  }
19724
- function declarationView(graph, input, path12, prefixes, memberCalls) {
19793
+ function declarationView(graph, input, path13, prefixes, memberCalls) {
19725
19794
  const requested = input.depth ?? 1;
19726
19795
  if (!Number.isSafeInteger(requested) || requested < 1 || requested > MAP_VIEW_LIMITS.directedDepth)
19727
19796
  return invalid2();
19728
19797
  const both = (input.direction ?? "BOTH") === "BOTH";
19729
19798
  const depth = both ? Math.min(requested, MAP_VIEW_LIMITS.bothDepth) : requested;
19730
19799
  const { name, line } = input;
19731
- const selected = mapSelectDeclarations(graph, path12, name, line);
19800
+ const selected = mapSelectDeclarations(graph, path13, name, line);
19732
19801
  if (!selected.length) return notFound();
19733
- const showTests = input.includeTests === true || mapTestPath(path12);
19802
+ const showTests = input.includeTests === true || mapTestPath(path13);
19734
19803
  const groups = new DeclarationGroups(graph, input, prefixes, showTests, memberCalls);
19735
19804
  const blocks = [];
19736
19805
  const seen = /* @__PURE__ */ new Set();
@@ -19778,7 +19847,7 @@ function declarationView(graph, input, path12, prefixes, memberCalls) {
19778
19847
  );
19779
19848
  }
19780
19849
  const head = [
19781
- `PROJECT MAP \xB7 DECLARATION ${path12}${name === void 0 ? "" : ` ${name}`}${line === void 0 ? "" : ` line ${line}`} \xB7 direction ${input.direction ?? "BOTH"} \xB7 depth ${depth}${depth < requested ? ` (BOTH is limited to ${MAP_VIEW_LIMITS.bothDepth})` : ""}${prefixes.includes(".") ? "" : " \xB7 limited to authorized paths"}`,
19850
+ `PROJECT MAP \xB7 DECLARATION ${path13}${name === void 0 ? "" : ` ${name}`}${line === void 0 ? "" : ` line ${line}`} \xB7 direction ${input.direction ?? "BOTH"} \xB7 depth ${depth}${depth < requested ? ` (BOTH is limited to ${MAP_VIEW_LIMITS.bothDepth})` : ""}${prefixes.includes(".") ? "" : " \xB7 limited to authorized paths"}`,
19782
19851
  ...truncated ? [`Expansion stopped at ${MAP_VIEW_LIMITS.declarations} declarations.`] : [],
19783
19852
  ...(input.direction ?? "BOTH") === "OUTGOING" ? [] : [callerCoverage(input.textSearch ?? DEFAULT_TEXT_SEARCH)]
19784
19853
  ];
@@ -19905,10 +19974,10 @@ var ProjectMapQuery = class {
19905
19974
  view(input, signal) {
19906
19975
  this.requireReadableMap(input.version, signal);
19907
19976
  const { offset, prefixes } = admission(input);
19908
- const path12 = normalizeProjectEvidencePath(input.path, true) || ".";
19977
+ const path13 = normalizeProjectEvidencePath(input.path, true) || ".";
19909
19978
  const view = mapView(
19910
19979
  this.store,
19911
- { ...input, path: path12, offset, allowedPathPrefixes: prefixes },
19980
+ { ...input, path: path13, offset, allowedPathPrefixes: prefixes },
19912
19981
  this.views
19913
19982
  );
19914
19983
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
@@ -20279,11 +20348,11 @@ var CodeIndexQuery = class {
20279
20348
  if (basePrefix && !file2.startsWith(basePrefix)) continue;
20280
20349
  const relativeToBase = basePrefix ? file2.slice(basePrefix.length) : file2;
20281
20350
  if (!relativeToBase) continue;
20282
- const segments = relativeToBase.split("/");
20283
- const visibleDepth = Math.min(input.depth, segments.length);
20351
+ const segments2 = relativeToBase.split("/");
20352
+ const visibleDepth = Math.min(input.depth, segments2.length);
20284
20353
  for (let index = 0; index < visibleDepth; index += 1) {
20285
- const entryPath = [base, ...segments.slice(0, index + 1)].filter(Boolean).join("/");
20286
- const kind = index === segments.length - 1 ? "FILE" : "DIRECTORY";
20354
+ const entryPath = [base, ...segments2.slice(0, index + 1)].filter(Boolean).join("/");
20355
+ const kind = index === segments2.length - 1 ? "FILE" : "DIRECTORY";
20287
20356
  if (candidates.get(entryPath) !== "DIRECTORY") candidates.set(entryPath, kind);
20288
20357
  }
20289
20358
  }
@@ -20813,7 +20882,7 @@ var CodeIndexStore = class {
20813
20882
  const staged = this.stageUnits(buildRef, paths, linked);
20814
20883
  const reused = linked ? this.database.prepare(`SELECT path, unit_ref FROM project_map_version_units
20815
20884
  WHERE version_ref = ? AND path IN (SELECT value FROM json_each(?))`).all(linked.version, JSON.stringify([...linked.paths])).map((row) => ({ path: String(row.path), unit: String(row.unit_ref) })) : [];
20816
- if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path: path12 }) => !paths.has(path12)) || staged.some(({ path: path12 }) => linked?.paths.has(path12)))
20885
+ if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path: path13 }) => !paths.has(path13)) || staged.some(({ path: path13 }) => linked?.paths.has(path13)))
20817
20886
  throw new MapReplayConflict();
20818
20887
  const units = [...staged, ...reused].sort(
20819
20888
  (left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
@@ -20864,7 +20933,7 @@ var CodeIndexStore = class {
20864
20933
  const member = this.database.prepare(
20865
20934
  "INSERT INTO project_map_version_units VALUES (?, ?, ?)"
20866
20935
  );
20867
- for (const { path: path12, unit } of reused) member.run(version2.version, path12, unit);
20936
+ for (const { path: path13, unit } of reused) member.run(version2.version, path13, unit);
20868
20937
  this.database.prepare("INSERT INTO project_map_coverage VALUES (?, ?)").run(version2.version, canonicalJson(coverage));
20869
20938
  }
20870
20939
  this.database.exec("COMMIT");
@@ -20928,7 +20997,7 @@ var CodeIndexStore = class {
20928
20997
  corrupt2();
20929
20998
  }
20930
20999
  if (linked) {
20931
- const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((path12) => !linked.paths.has(path12));
21000
+ const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((path13) => !linked.paths.has(path13));
20932
21001
  if (database.prepare(`SELECT 1 FROM project_map_objects gone
20933
21002
  WHERE gone.version_ref = ? AND gone.path IN (SELECT value FROM json_each(?))
20934
21003
  AND gone.entity_ref NOT IN (SELECT entity_ref FROM project_map_publish_objects)
@@ -20953,17 +21022,17 @@ var CodeIndexStore = class {
20953
21022
  const units = [];
20954
21023
  for (const row of database.prepare(`SELECT path FROM project_map_publish_objects
20955
21024
  UNION SELECT path FROM project_map_publish_relations ORDER BY path`).all()) {
20956
- const path12 = String(row.path);
20957
- const hash2 = createHash3("sha256").update(path12).update("\0");
21025
+ const path13 = String(row.path);
21026
+ const hash2 = createHash3("sha256").update(path13).update("\0");
20958
21027
  for (const [mark, statement] of [
20959
21028
  ["object", objects2],
20960
21029
  ["relation", relations],
20961
21030
  ["note", pathNotes]
20962
21031
  ])
20963
- for (const fact of statement.all(path12))
21032
+ for (const fact of statement.all(path13))
20964
21033
  for (const value of Object.values(fact))
20965
21034
  hash2.update(mark).update("\0").update(String(value)).update("\0");
20966
- units.push({ path: path12, unit: hash2.digest("hex") });
21035
+ units.push({ path: path13, unit: hash2.digest("hex") });
20967
21036
  }
20968
21037
  return units;
20969
21038
  }
@@ -20981,13 +21050,13 @@ var CodeIndexStore = class {
20981
21050
  "INSERT INTO project_map_unit_notes SELECT ?, * FROM project_map_publish_notes WHERE path = ?"
20982
21051
  );
20983
21052
  const member = database.prepare("INSERT INTO project_map_version_units VALUES (?, ?, ?)");
20984
- for (const { path: path12, unit } of units) {
20985
- if (insertUnit.run(unit, path12).changes) {
20986
- unitObjects.run(unit, path12);
20987
- unitRelations.run(unit, path12);
20988
- unitNotes.run(unit, path12);
21053
+ for (const { path: path13, unit } of units) {
21054
+ if (insertUnit.run(unit, path13).changes) {
21055
+ unitObjects.run(unit, path13);
21056
+ unitRelations.run(unit, path13);
21057
+ unitNotes.run(unit, path13);
20989
21058
  }
20990
- member.run(version2, path12, unit);
21059
+ member.run(version2, path13, unit);
20991
21060
  }
20992
21061
  }
20993
21062
  /** Earlier versions of a project's scope built by the same analyzer, most recent first. */
@@ -21228,21 +21297,21 @@ var contextFiles = (context) => [
21228
21297
  function replayableContexts(parent, digests) {
21229
21298
  const sharing = /* @__PURE__ */ new Map();
21230
21299
  for (const [ref, { context }] of parent.contexts)
21231
- for (const path12 of contextFiles(context)) {
21232
- const refs = sharing.get(path12) ?? /* @__PURE__ */ new Set();
21300
+ for (const path13 of contextFiles(context)) {
21301
+ const refs = sharing.get(path13) ?? /* @__PURE__ */ new Set();
21233
21302
  refs.add(ref);
21234
- sharing.set(path12, refs);
21303
+ sharing.set(path13, refs);
21235
21304
  }
21236
21305
  const unchanged = /* @__PURE__ */ new Set();
21237
21306
  for (const [ref, { context }] of parent.contexts)
21238
21307
  if (contextFiles(context).every(
21239
- (path12) => digests.get(path12) !== void 0 && digests.get(path12) === parent.entries.get(path12)
21308
+ (path13) => digests.get(path13) !== void 0 && digests.get(path13) === parent.entries.get(path13)
21240
21309
  ))
21241
21310
  unchanged.add(ref);
21242
21311
  const replayable = /* @__PURE__ */ new Set();
21243
21312
  for (const [ref, { context }] of parent.contexts)
21244
21313
  if (unchanged.has(ref) && contextFiles(context).every(
21245
- (path12) => [...sharing.get(path12) ?? []].every((other) => unchanged.has(other))
21314
+ (path13) => [...sharing.get(path13) ?? []].every((other) => unchanged.has(other))
21246
21315
  ))
21247
21316
  replayable.add(ref);
21248
21317
  return { replayable, sharing };
@@ -21275,8 +21344,8 @@ var ProjectMapAnalyzer = class {
21275
21344
  languages;
21276
21345
  observe;
21277
21346
  id;
21278
- claims(path12) {
21279
- return this.languages.some((language) => language.claims(path12));
21347
+ claims(path13) {
21348
+ return this.languages.some((language) => language.claims(path13));
21280
21349
  }
21281
21350
  references(input, reference, signal) {
21282
21351
  const language = this.languages.find((language2) => language2.claims(reference.targetPath));
@@ -21316,7 +21385,7 @@ var ProjectMapAnalyzer = class {
21316
21385
  const reuse = (contextRef2, request, files2) => {
21317
21386
  const digest = digestValue({
21318
21387
  request,
21319
- files: files2.map((path12) => [path12, digests.get(path12) ?? null])
21388
+ files: files2.map((path13) => [path13, digests.get(path13) ?? null])
21320
21389
  });
21321
21390
  requests.set(contextRef2, digest);
21322
21391
  if (!parent || !replayable.has(contextRef2)) return void 0;
@@ -21356,7 +21425,7 @@ var ProjectMapAnalyzer = class {
21356
21425
  const ref = analysis.contexts[0]?.ref ?? "";
21357
21426
  if (options?.linked?.length) {
21358
21427
  if (!parent || analysis.contexts.length !== 1) return invalidParent();
21359
- for (const path12 of options.linked) linked.add(path12);
21428
+ for (const path13 of options.linked) linked.add(path13);
21360
21429
  this.observe?.({
21361
21430
  operation: "LINK",
21362
21431
  phase: "FINISHED",
@@ -21383,7 +21452,7 @@ var ProjectMapAnalyzer = class {
21383
21452
  });
21384
21453
  for (const file2 of analysis.parsedFiles) parsed.add(file2);
21385
21454
  const staged = factPaths(analysis);
21386
- for (const path12 of staged) stagedPaths.add(path12);
21455
+ for (const path13 of staged) stagedPaths.add(path13);
21387
21456
  for (const context of analysis.contexts) {
21388
21457
  for (const file2 of context.configurationFiles) configurationInputs.add(file2);
21389
21458
  if (!replayed.has(context.ref))
@@ -21412,7 +21481,7 @@ var ProjectMapAnalyzer = class {
21412
21481
  accept,
21413
21482
  reuse,
21414
21483
  previous,
21415
- configuration: (path12) => configurationInputs.add(path12),
21484
+ configuration: (path13) => configurationInputs.add(path13),
21416
21485
  observe: this.observe
21417
21486
  },
21418
21487
  signal
@@ -21449,12 +21518,12 @@ var ProjectMapAnalyzer = class {
21449
21518
  if (files.objects.length) accept(files);
21450
21519
  if (parent && (replayed.size || linked.size)) {
21451
21520
  for (const ref of replayed.keys())
21452
- for (const path12 of contextFiles(parent.contexts.get(ref)?.context ?? invalidParent()))
21453
- if (analyzedFiles.has(path12) || [...sharing.get(path12) ?? []].some((other) => !replayed.has(other)))
21521
+ for (const path13 of contextFiles(parent.contexts.get(ref)?.context ?? invalidParent()))
21522
+ if (analyzedFiles.has(path13) || [...sharing.get(path13) ?? []].some((other) => !replayed.has(other)))
21454
21523
  throw new MapReplayConflict();
21455
- for (const paths of replayed.values()) for (const path12 of paths) linked.add(path12);
21456
- for (const path12 of linked)
21457
- if (analyzedFiles.has(path12) || stagedPaths.has(path12)) throw new MapReplayConflict();
21524
+ for (const paths of replayed.values()) for (const path13 of paths) linked.add(path13);
21525
+ for (const path13 of linked)
21526
+ if (analyzedFiles.has(path13) || stagedPaths.has(path13)) throw new MapReplayConflict();
21458
21527
  parent.link([...linked]);
21459
21528
  }
21460
21529
  result.parsedFiles = [...parsed].sort();
@@ -21744,8 +21813,8 @@ var CodeIndex = class {
21744
21813
  for (const entry of this.store.listEntries(candidate))
21745
21814
  if (entry.contentDigest) entries2.set(entry.path, entry.contentDigest);
21746
21815
  let changed = 0;
21747
- for (const [path12, digest] of digests) if (entries2.get(path12) !== digest) changed++;
21748
- for (const path12 of entries2.keys()) if (!digests.has(path12)) changed++;
21816
+ for (const [path13, digest] of digests) if (entries2.get(path13) !== digest) changed++;
21817
+ for (const path13 of entries2.keys()) if (!digests.has(path13)) changed++;
21749
21818
  if (!best || changed < best.changed) best = { version: candidate, entries: entries2, changed };
21750
21819
  }
21751
21820
  if (!best) return void 0;
@@ -21885,11 +21954,159 @@ var CodeIndex = class {
21885
21954
 
21886
21955
  // src/project-map-changes.ts
21887
21956
  import { readFileSync as readFileSync3 } from "node:fs";
21888
- import path8 from "node:path";
21957
+ import path9 from "node:path";
21958
+
21959
+ // src/project-map-clients.ts
21960
+ var CLIENT_FILES = [
21961
+ "ts",
21962
+ "tsx",
21963
+ "mts",
21964
+ "cts",
21965
+ "js",
21966
+ "jsx",
21967
+ "mjs",
21968
+ "cjs",
21969
+ "go",
21970
+ "py",
21971
+ "java",
21972
+ "kt",
21973
+ "html",
21974
+ "htm",
21975
+ "jinja",
21976
+ "jinja2",
21977
+ "j2",
21978
+ "hbs",
21979
+ "ejs",
21980
+ "tmpl",
21981
+ "tpl",
21982
+ "gohtml",
21983
+ "vue",
21984
+ "svelte"
21985
+ ].map((extension) => `*.${extension}`);
21986
+ var PARAM = /^(?:\{[^}]*\}|\$\{[^}]*\}|:\w+\??|<[^>]*>|%[sdvqfx]|\[[^\]]+\]|\*{1,2}|\{\{.*\}\})$/u;
21987
+ var MOUNT = /^(?:api|v\d+(?:\.\d+)?|rest|public|internal|backend)$/iu;
21988
+ var LITERAL = /(["'`])((?:\\.|(?!\1)[^\\])*)\1/gu;
21989
+ var MOUNTING = /(?:\b(?:prefix|root_path|base_path|basePath|baseURL|baseUrl)\s*[=:]|\b(?:Group|Route|Mount|mount|use|include_router|PathPrefix|StripPrefix)\s*\()\s*$/u;
21990
+ var LIMIT = Object.freeze({ routes: 40, clients: 5 });
21991
+ var ROUTE = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
21992
+ var segments = (path13) => path13.split("/").filter(Boolean).map((text) => ({ text, param: PARAM.test(text) || /[{}$<>%]/u.test(text) }));
21993
+ var routeSegments = (label) => segments(label.slice(label.indexOf("/")));
21994
+ function requestedPath(literal3, joined) {
21995
+ const match = /^(?:https?:\/\/[^/\s]+|(?:\$\{[^}]*\})+|@\{|redirect:|forward:)?(\/[^\s?#()"'`,;|]*)/u.exec(
21996
+ literal3
21997
+ ) ?? void 0;
21998
+ const path13 = match?.[1];
21999
+ if (!path13 || path13.startsWith("//") || path13.length < 3) return void 0;
22000
+ const parts = segments(path13);
22001
+ if (joined && path13.endsWith("/")) parts.push({ text: "*", param: true });
22002
+ return parts;
22003
+ }
22004
+ var same = (route, requested) => route.param || !requested.param && route.text === requested.text;
22005
+ function fit(route, requested) {
22006
+ const shorter = Math.min(route.length, requested.length);
22007
+ if (!shorter) return -1;
22008
+ const routeTail = route.slice(route.length - shorter);
22009
+ const requestedTail = requested.slice(requested.length - shorter);
22010
+ if (!routeTail.every((segment, index) => same(segment, requestedTail[index])))
22011
+ return -1;
22012
+ if (!routeTail.some((segment) => !segment.param && segment.text.length >= 3)) return -1;
22013
+ const extra = [
22014
+ ...route.slice(0, route.length - shorter),
22015
+ ...requested.slice(0, requested.length - shorter)
22016
+ ];
22017
+ return extra.every((segment) => MOUNT.test(segment.text)) || shorter >= 2 ? extra.length : -1;
22018
+ }
22019
+ function routeRegistrations(store, version2) {
22020
+ const routes = /* @__PURE__ */ new Set();
22021
+ const sites2 = /* @__PURE__ */ new Set();
22022
+ for (const row of store.database.prepare(
22023
+ "SELECT relation_json FROM project_map_relations WHERE version_ref = ? AND (json_extract(relation_json, '$.route') IS NOT NULL OR json_extract(relation_json, '$.argument') LIKE '%/%')"
22024
+ ).all(version2)) {
22025
+ const relation = JSON.parse(String(row.relation_json));
22026
+ const route = relation.route ?? relation.argument;
22027
+ if (!route || !ROUTE.test(route)) continue;
22028
+ routes.add(route);
22029
+ for (let line = relation.anchor.startLine; line <= relation.anchor.endLine; line++)
22030
+ sites2.add(`${relation.anchor.path}:${line}`);
22031
+ }
22032
+ return { routes, sites: sites2 };
22033
+ }
22034
+ async function routeClients(routes, registrations, git2, options) {
22035
+ const wanted = routes.map((entry) => ({ ...entry, segments: routeSegments(entry.route) })).filter((entry) => entry.segments.some((segment) => !segment.param && segment.text.length >= 3)).slice(0, LIMIT.routes);
22036
+ const known = [.../* @__PURE__ */ new Set([...registrations.routes, ...wanted.map((entry) => entry.route)])].map(
22037
+ (route) => ({ route, segments: routeSegments(route) })
22038
+ );
22039
+ const needles = /* @__PURE__ */ new Set();
22040
+ for (const entry of wanted)
22041
+ for (const segment of entry.segments) if (!segment.param) needles.add(`/${segment.text}`);
22042
+ if (!needles.size) return [];
22043
+ let found;
22044
+ try {
22045
+ found = (await git2.run(
22046
+ [
22047
+ "grep",
22048
+ "-n",
22049
+ "-I",
22050
+ "-F",
22051
+ "--untracked",
22052
+ "--full-name",
22053
+ "--no-color",
22054
+ ...[...needles].flatMap((needle) => ["-e", needle]),
22055
+ "--",
22056
+ ...CLIENT_FILES
22057
+ ],
22058
+ options
22059
+ )).stdout.toString("utf8");
22060
+ } catch (error51) {
22061
+ if (error51 instanceof GitCommandError && !options.signal?.aborted) return [];
22062
+ throw error51;
22063
+ }
22064
+ const clients = /* @__PURE__ */ new Map();
22065
+ for (const hit of found.split("\n")) {
22066
+ const match = /^(.+?):(\d+):(.*)$/u.exec(hit);
22067
+ if (!match) continue;
22068
+ const [, file2 = "", line = "", text = ""] = match;
22069
+ if (mapTestPath(file2) || registrations.sites.has(`${file2}:${line}`)) continue;
22070
+ for (const literal3 of text.matchAll(LITERAL)) {
22071
+ if (MOUNTING.test(text.slice(0, literal3.index))) continue;
22072
+ const after = text.slice((literal3.index ?? 0) + literal3[0].length).trimStart();
22073
+ const requested = requestedPath(literal3[2] ?? "", after.startsWith("+"));
22074
+ if (!requested) continue;
22075
+ const fits = known.map((entry) => ({
22076
+ route: entry.route,
22077
+ extra: fit(entry.segments, requested),
22078
+ literal: entry.segments.filter((segment) => !segment.param).length
22079
+ })).filter((entry) => entry.extra >= 0);
22080
+ const fewest = Math.min(...fits.map((entry) => entry.extra));
22081
+ const named = Math.max(
22082
+ ...fits.filter((entry) => entry.extra === fewest).map((entry) => entry.literal)
22083
+ );
22084
+ const mounted = MOUNT.test(requested[0]?.text ?? "");
22085
+ for (const entry of wanted)
22086
+ if (fits.some(
22087
+ (other) => other.route === entry.route && other.extra === fewest && other.literal === named
22088
+ ))
22089
+ clients.set(
22090
+ entry.route,
22091
+ (clients.get(entry.route) ?? /* @__PURE__ */ new Map()).set(`${file2}:${line}`, mounted)
22092
+ );
22093
+ }
22094
+ }
22095
+ return wanted.map(({ route, removed }) => {
22096
+ const found2 = [...clients.get(route) ?? []];
22097
+ const mounted = found2.some(([, prefixed]) => prefixed);
22098
+ return {
22099
+ route,
22100
+ removed,
22101
+ clients: found2.filter(([, prefixed]) => prefixed || !mounted).map(([site]) => site)
22102
+ };
22103
+ }).filter((entry) => entry.clients.length);
22104
+ }
22105
+ var routeClientsLine = ({ route, removed, clients }) => `${JSON.stringify(route)}${removed ? " (removed or renamed)" : ""} \u2190 ${clients.slice(0, LIMIT.clients).join(", ")}${clients.length > LIMIT.clients ? `, +${clients.length - LIMIT.clients} more` : ""}`;
21889
22106
 
21890
22107
  // src/project-map-names.ts
21891
22108
  import { readFileSync as readFileSync2 } from "node:fs";
21892
- import path7 from "node:path";
22109
+ import path8 from "node:path";
21893
22110
  var CONFIG_KEY = /^\s*(?:export\s+|-\s+)?["']?([A-Za-z_][\w.-]*)["']?\s*(?:=|:(?:\s|$))/u;
21894
22111
  var CODE_READS = [
21895
22112
  // process.env.NAME, import.meta.env.NAME
@@ -21907,7 +22124,7 @@ var NAME = /^[A-Za-z_][\w.-]+[A-Za-z0-9]$/u;
21907
22124
  var UPPER = /^[A-Z][A-Z0-9_]*$/u;
21908
22125
  var PLATFORM = /^(?:GITHUB_\w+|RUNNER_\w+|CI|NODE_ENV|PATH|HOME|USER|PWD|SHELL|LANG|LC_\w+|TZ|TERM|TMPDIR|TEMP|TMP|PYTHONPATH|GOPATH|GOOS|GOARCH|JAVA_HOME)$/u;
21909
22126
  var HISTORY = /(?:^|\/)(?:CHANGELOG|CHANGES|HISTORY|NEWS|RELEASES?|release[-_ ]?notes)[^/]*$/iu;
21910
- var LIMIT = Object.freeze({ names: 50, mentions: 5 });
22127
+ var LIMIT2 = Object.freeze({ names: 50, mentions: 5 });
21911
22128
  var literal2 = (text) => text.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
21912
22129
  var wholeName = (name) => new RegExp(`(?<![\\w-])${literal2(name)}(?![\\w-])`, "u");
21913
22130
  var quotedName = (name) => new RegExp(
@@ -21965,7 +22182,7 @@ async function strandedNames(project, diff, files, configuration, git2, options)
21965
22182
  } else for (const name of codeReads(line, file2.path)) names2.add(name);
21966
22183
  let text;
21967
22184
  try {
21968
- text = readFileSync2(path7.join(project, file2.path), "utf8");
22185
+ text = readFileSync2(path8.join(project, file2.path), "utf8");
21969
22186
  } catch {
21970
22187
  continue;
21971
22188
  }
@@ -21973,7 +22190,7 @@ async function strandedNames(project, diff, files, configuration, git2, options)
21973
22190
  if (NAME.test(name) && !PLATFORM.test(name) && !from.has(name) && !wholeName(name).test(text))
21974
22191
  from.set(name, { path: file2.path, code: !config2 });
21975
22192
  }
21976
- const names = [...from.keys()].slice(0, LIMIT.names);
22193
+ const names = [...from.keys()].slice(0, LIMIT2.names);
21977
22194
  if (!names.length) return [];
21978
22195
  const patterns = new Map(
21979
22196
  names.map((name) => [name, { whole: wholeName(name), quoted: quotedName(name) }])
@@ -22032,7 +22249,7 @@ async function strandedNames(project, diff, files, configuration, git2, options)
22032
22249
  mentions: mentions.get(name) ?? []
22033
22250
  }));
22034
22251
  }
22035
- var strandedNameLine = ({ name, from, mentions }) => `${name}, gone from ${from}: ${mentions.slice(0, LIMIT.mentions).join(", ")}${mentions.length > LIMIT.mentions ? `, +${mentions.length - LIMIT.mentions} more` : ""}`;
22252
+ var strandedNameLine = ({ name, from, mentions }) => `${name}, gone from ${from}: ${mentions.slice(0, LIMIT2.mentions).join(", ")}${mentions.length > LIMIT2.mentions ? `, +${mentions.length - LIMIT2.mentions} more` : ""}`;
22036
22253
 
22037
22254
  // src/project-map-changes.ts
22038
22255
  var git = new GitRunner();
@@ -22086,8 +22303,8 @@ async function readMapChanges(project, base, signal) {
22086
22303
  baseText: (await git.run(["show", `${commit}:${file2.basePath}`], gitOptions(project, signal))).stdout.toString("utf8")
22087
22304
  };
22088
22305
  const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter(Boolean);
22089
- for (const path12 of untracked)
22090
- files.push({ path: path12, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
22306
+ for (const path13 of untracked)
22307
+ files.push({ path: path13, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
22091
22308
  const stranded = await strandedNames(
22092
22309
  project,
22093
22310
  diff,
@@ -22165,11 +22382,11 @@ var NON_CODE = [
22165
22382
  [/(?:^|\/)\.env[^/]*$|\.(?:ya?ml|toml|ini|properties|conf|cfg)$/iu, "configuration"],
22166
22383
  [/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte)$/iu, "template"]
22167
22384
  ];
22168
- var nonCodeKind = (path12) => NON_CODE.find(([pattern]) => pattern.test(path12))?.[1];
22385
+ var nonCodeKind = (path13) => NON_CODE.find(([pattern]) => pattern.test(path13))?.[1];
22169
22386
  var LIMITS = Object.freeze({ depth: 8, declarations: 800, changed: 200, chain: 3, byName: 40 });
22170
22387
  var CALLER_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES"]);
22171
22388
  var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
22172
- var ROUTE = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
22389
+ var ROUTE2 = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
22173
22390
  var areaOf = (file2) => /\.(?:go|java|kt)$/u.test(file2) ? file2.slice(0, file2.lastIndexOf("/") + 1) || "./" : file2;
22174
22391
  var Tracer = class {
22175
22392
  constructor(graph, memberCalls) {
@@ -22216,7 +22433,7 @@ var Tracer = class {
22216
22433
  for (const caller of callers) {
22217
22434
  const site = `${caller.relation.anchor.path}:${caller.relation.anchor.startLine}`;
22218
22435
  const certain = current.certain && caller.certain;
22219
- if (caller.relation.argument && ROUTE.test(caller.relation.argument))
22436
+ if (caller.relation.argument && ROUTE2.test(caller.relation.argument))
22220
22437
  this.entry(caller.relation.argument, true, current, site, certain);
22221
22438
  const callerObject = this.graph.object(caller.ref);
22222
22439
  if (testCode(callerObject.anchor.path)) {
@@ -22317,7 +22534,7 @@ var Tracer = class {
22317
22534
  for (const relation of this.graph.relationsFrom([current.ref])) {
22318
22535
  if (relation.kind !== "DECORATED_BY") continue;
22319
22536
  const route = relation.route ?? relation.argument;
22320
- if (!route || !ROUTE.test(route)) continue;
22537
+ if (!route || !ROUTE2.test(route)) continue;
22321
22538
  this.routes.add(current.ref);
22322
22539
  this.entry(
22323
22540
  route,
@@ -22360,12 +22577,12 @@ var Tracer = class {
22360
22577
  this.areas.set(area, known);
22361
22578
  }
22362
22579
  /** A related test file; the closest relation (lowest rank) explains it. */
22363
- test(path12, name, why, rank2) {
22364
- if (!mapRunnableTest(path12)) return;
22365
- const known = this.tests.get(path12) ?? { names: /* @__PURE__ */ new Set(), why, rank: rank2 };
22580
+ test(path13, name, why, rank2) {
22581
+ if (!mapRunnableTest(path13)) return;
22582
+ const known = this.tests.get(path13) ?? { names: /* @__PURE__ */ new Set(), why, rank: rank2 };
22366
22583
  if (rank2 < known.rank) Object.assign(known, { why, rank: rank2 });
22367
22584
  if (name && !name.startsWith("<")) known.names.add(name);
22368
- this.tests.set(path12, known);
22585
+ this.tests.set(path13, known);
22369
22586
  }
22370
22587
  };
22371
22588
  var mapRunnableTest = (file2) => /_test\.(?:go|py)$|(?:^|\/)test_[^/]*\.py$|\.(?:test|spec)\.[cm]?[jt]sx?$|(?:Test|Tests|IT)\.(?:java|kt)$/u.test(
@@ -22378,7 +22595,7 @@ function mapChangeImpact(store, working, base, changes, project) {
22378
22595
  const changed = [];
22379
22596
  const unclear = [];
22380
22597
  const removed = [];
22381
- const declarations = (g, path12) => g.objectsAt(path12).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
22598
+ const declarations = (g, path13) => g.objectsAt(path13).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
22382
22599
  let changedCount = 0;
22383
22600
  const starts = [];
22384
22601
  for (const file2 of changes.files) {
@@ -22420,7 +22637,7 @@ function mapChangeImpact(store, working, base, changes, project) {
22420
22637
  starts.push(ref);
22421
22638
  }
22422
22639
  for (const relation of graph.relationsFrom(objects2.map((object2) => object2.id)))
22423
- if (relation.argument && ROUTE.test(relation.argument) && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine))
22640
+ if (relation.argument && ROUTE2.test(relation.argument) && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine))
22424
22641
  unclear.push(
22425
22642
  `the registration of ${JSON.stringify(relation.argument)} at ${relation.anchor.path}:${relation.anchor.startLine} changed; check that the route still reaches the right handler`
22426
22643
  );
@@ -22434,8 +22651,18 @@ function mapChangeImpact(store, working, base, changes, project) {
22434
22651
  if (project) routeTests(project, store, working, [...tracer.entries.values()], tracer);
22435
22652
  supportTests(store, working, tracer);
22436
22653
  const rewrittenTests = [];
22654
+ const removedRoutes = [];
22437
22655
  if (base) {
22438
22656
  const before = new MapViewGraph(store, base);
22657
+ const registered = /* @__PURE__ */ new Set();
22658
+ for (const file2 of changes.files)
22659
+ if (file2.status !== "DELETED")
22660
+ for (const route of routesIn(graph, file2.path)) registered.add(route);
22661
+ for (const file2 of changes.files)
22662
+ if (file2.basePath && file2.status !== "ADDED") {
22663
+ for (const route of routesIn(before, file2.basePath))
22664
+ if (!registered.has(route) && !removedRoutes.includes(route)) removedRoutes.push(route);
22665
+ }
22439
22666
  for (const file2 of changes.files)
22440
22667
  if (file2.basePath && file2.baseText !== void 0 && testCode(file2.basePath)) {
22441
22668
  const names = existingTestsChanged(before, graph, file2, project);
@@ -22466,18 +22693,18 @@ function mapChangeImpact(store, working, base, changes, project) {
22466
22693
  beforeTracer.trace(gone);
22467
22694
  for (const entry of beforeTracer.entries.values())
22468
22695
  if (!tracer.entries.has(entry.label)) tracer.entries.set(entry.label, entry);
22469
- for (const [path12, test] of beforeTracer.tests) {
22470
- const known = tracer.tests.get(path12);
22696
+ for (const [path13, test] of beforeTracer.tests) {
22697
+ const known = tracer.tests.get(path13);
22471
22698
  if (known) for (const name of test.names) known.names.add(name);
22472
- else tracer.tests.set(path12, test);
22699
+ else tracer.tests.set(path13, test);
22473
22700
  }
22474
22701
  for (const [area, known] of beforeTracer.areas) {
22475
22702
  const now = tracer.areas.get(area);
22476
22703
  if (!now) tracer.areas.set(area, known);
22477
22704
  else {
22478
22705
  for (const name of known.through) now.through.add(name);
22479
- for (const [path12, names] of known.tests)
22480
- now.tests.set(path12, /* @__PURE__ */ new Set([...now.tests.get(path12) ?? [], ...names]));
22706
+ for (const [path13, names] of known.tests)
22707
+ now.tests.set(path13, /* @__PURE__ */ new Set([...now.tests.get(path13) ?? [], ...names]));
22481
22708
  }
22482
22709
  }
22483
22710
  unclear.push(...beforeTracer.unclear.filter((line) => !line.includes("has no callers")));
@@ -22491,8 +22718,8 @@ function mapChangeImpact(store, working, base, changes, project) {
22491
22718
  entries: [...tracer.entries.values()].sort(
22492
22719
  (left, right) => Number(right.certain) - Number(left.certain) || Number(right.route) - Number(left.route) || (left.label < right.label ? -1 : left.label > right.label ? 1 : 0)
22493
22720
  ),
22494
- tests: [...tracer.tests].map(([path12, test]) => ({
22495
- path: path12,
22721
+ tests: [...tracer.tests].map(([path13, test]) => ({
22722
+ path: path13,
22496
22723
  names: [...test.names].sort(),
22497
22724
  why: test.why,
22498
22725
  rank: test.rank
@@ -22502,9 +22729,10 @@ function mapChangeImpact(store, working, base, changes, project) {
22502
22729
  areas: [...tracer.areas].map(([area, known]) => ({
22503
22730
  area,
22504
22731
  through: [...known.through].sort(),
22505
- tests: [...known.tests].map(([path12, names]) => ({ path: path12, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
22732
+ tests: [...known.tests].map(([path13, names]) => ({ path: path13, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
22506
22733
  })).sort((left, right) => right.tests.length - left.tests.length),
22507
22734
  unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
22735
+ removedRoutes,
22508
22736
  truncated: tracer.truncated
22509
22737
  };
22510
22738
  }
@@ -22514,7 +22742,7 @@ function existingTestsChanged(before, after, file2, project) {
22514
22742
  let workingLines = [];
22515
22743
  if (file2.status !== "DELETED" && project)
22516
22744
  try {
22517
- workingLines = readFileSync3(path8.join(project, file2.path), "utf8").split("\n");
22745
+ workingLines = readFileSync3(path9.join(project, file2.path), "utf8").split("\n");
22518
22746
  } catch {
22519
22747
  }
22520
22748
  const key = (graph, object2) => `${object2.kind}\0${graph.qualifiedName(object2.id)}`;
@@ -22601,7 +22829,7 @@ function routeTests(project, store, version2, entries, tracer) {
22601
22829
  if (!mapRunnableTest(candidate)) continue;
22602
22830
  let text;
22603
22831
  try {
22604
- text = readFileSync3(path8.join(project, candidate), "utf8");
22832
+ text = readFileSync3(path9.join(project, candidate), "utf8");
22605
22833
  } catch {
22606
22834
  continue;
22607
22835
  }
@@ -22619,9 +22847,9 @@ function routeTests(project, store, version2, entries, tracer) {
22619
22847
  }
22620
22848
  }
22621
22849
  }
22622
- function sameDirectoryTests(store, version2, path12, tracer) {
22623
- const slash = path12.lastIndexOf("/");
22624
- const directory = slash < 0 ? "" : path12.slice(0, slash + 1);
22850
+ function sameDirectoryTests(store, version2, path13, tracer) {
22851
+ const slash = path13.lastIndexOf("/");
22852
+ const directory = slash < 0 ? "" : path13.slice(0, slash + 1);
22625
22853
  for (const row of store.database.prepare(
22626
22854
  "SELECT DISTINCT path FROM project_map_objects WHERE version_ref = ? AND path LIKE ? ESCAPE '\\'"
22627
22855
  ).all(version2, `${directory.replace(/[\\%_]/gu, (c) => `\\${c}`)}%`)) {
@@ -22643,13 +22871,39 @@ var LIST = Object.freeze({
22643
22871
  tests: 12,
22644
22872
  unclear: 20,
22645
22873
  stranded: 12,
22874
+ clients: 8,
22646
22875
  names: 6,
22647
22876
  areas: 8,
22648
22877
  areaTests: 3,
22649
22878
  areaNames: 3,
22650
22879
  through: 2
22651
22880
  });
22652
- function mapChangesText(changes, impact) {
22881
+ function routesIn(graph, path13) {
22882
+ const routes = /* @__PURE__ */ new Set();
22883
+ for (const relation of graph.relationsFrom(graph.objectsAt(path13).map((object2) => object2.id))) {
22884
+ const route = relation.kind === "DECORATED_BY" ? relation.route ?? relation.argument : relation.argument;
22885
+ if (route && ROUTE2.test(route)) routes.add(route);
22886
+ }
22887
+ return routes;
22888
+ }
22889
+ var routePath = (route) => route.slice(route.indexOf("/"));
22890
+ async function mapRouteClients(project, store, working, impact, signal) {
22891
+ const affected = impact.entries.filter(
22892
+ (entry) => entry.route && entry.certain && entry.chain.length <= 2
22893
+ );
22894
+ if (!affected.length && !impact.removedRoutes.length) return [];
22895
+ const registrations = routeRegistrations(store, working);
22896
+ const served = (route) => registrations.routes.has(route) || [...registrations.routes].some(
22897
+ (other) => !other.startsWith("/") && routePath(other) === routePath(route)
22898
+ );
22899
+ const routes = [
22900
+ ...affected.map((entry) => ({ route: entry.label, removed: false })),
22901
+ ...impact.removedRoutes.filter((route) => !served(route)).map((route) => ({ route, removed: true }))
22902
+ ];
22903
+ if (!routes.length) return [];
22904
+ return routeClients(routes, registrations, git, gitOptions(project, signal));
22905
+ }
22906
+ function mapChangesText(changes, impact, clients = []) {
22653
22907
  const files = changes.files.length;
22654
22908
  const direct = impact.tests.filter((test) => test.rank < 4);
22655
22909
  const indirect = impact.tests.filter((test) => test.rank >= 4);
@@ -22718,6 +22972,16 @@ Nothing changed against ${changes.base}.`;
22718
22972
  impact.entries.filter((e) => !e.certain).map(entry),
22719
22973
  LIST.entries
22720
22974
  );
22975
+ if (clients.length) {
22976
+ list(
22977
+ "REQUESTED BY (code and templates outside the tests that request these routes' paths, found by text)",
22978
+ clients.map(routeClientsLine),
22979
+ LIST.clients
22980
+ );
22981
+ lines.push(
22982
+ "If the change alters what a route accepts or returns, or its path, these callers must change with it. Paths built at run time are not found."
22983
+ );
22984
+ }
22721
22985
  list(
22722
22986
  "CHECK BY HAND (the map cannot see these)",
22723
22987
  [
@@ -22753,7 +23017,7 @@ Nothing changed against ${changes.base}.`;
22753
23017
  var SCHEMA_VERSION = 2;
22754
23018
  var KEEP_VERSIONS = 3;
22755
23019
  function openMapDatabase(file2) {
22756
- mkdirSync(path9.dirname(file2), { recursive: true, mode: 448 });
23020
+ mkdirSync(path10.dirname(file2), { recursive: true, mode: 448 });
22757
23021
  const database = new DatabaseSync(file2);
22758
23022
  try {
22759
23023
  database.exec("PRAGMA busy_timeout = 30000;");
@@ -22790,7 +23054,7 @@ function openMapDatabase(file2) {
22790
23054
  throw error51;
22791
23055
  }
22792
23056
  }
22793
- var mapDatabasePath = (cacheDirectory2, canonicalProject) => path9.join(
23057
+ var mapDatabasePath = (cacheDirectory2, canonicalProject) => path10.join(
22794
23058
  cacheDirectory2,
22795
23059
  "projects",
22796
23060
  createHash4("sha256").update(canonicalProject).digest("hex").slice(0, 24),
@@ -22917,10 +23181,12 @@ var LayerMap = class _LayerMap {
22917
23181
  const base = changes.files.some(
22918
23182
  (file2) => file2.basePath !== void 0 && (file2.baseLines.length || file2.baseText !== void 0)
22919
23183
  ) ? await this.versionAt(changes.commit, signal) : void 0;
23184
+ const impact = mapChangeImpact(this.store, working, base, changes, this.project);
22920
23185
  return {
22921
23186
  text: mapChangesText(
22922
23187
  changes,
22923
- mapChangeImpact(this.store, working, base, changes, this.project)
23188
+ impact,
23189
+ await mapRouteClients(this.project, this.store, working, impact, signal)
22924
23190
  )
22925
23191
  };
22926
23192
  }
@@ -22940,19 +23206,25 @@ var LayerMap = class _LayerMap {
22940
23206
 
22941
23207
  // src/agent/environment.ts
22942
23208
  var packageRoot = (() => {
22943
- for (let directory = path10.dirname(fileURLToPath(import.meta.url)); ; ) {
22944
- const manifest = path10.join(directory, "package.json");
22945
- if (existsSync4(manifest) && JSON.parse(readFileSync4(manifest, "utf8")).name === "layermap")
23209
+ for (let directory = path11.dirname(fileURLToPath(import.meta.url)); ; ) {
23210
+ const manifest = path11.join(directory, "package.json");
23211
+ if (existsSync5(manifest) && JSON.parse(readFileSync4(manifest, "utf8")).name === "layermap")
22946
23212
  return directory;
22947
- if (path10.dirname(directory) === directory) throw new Error("LayerMap cannot find its package.");
22948
- directory = path10.dirname(directory);
23213
+ if (path11.dirname(directory) === directory) throw new Error("LayerMap cannot find its package.");
23214
+ directory = path11.dirname(directory);
22949
23215
  }
22950
23216
  })();
22951
- var packageVersion = async () => JSON.parse(await readFile(path10.join(packageRoot, "package.json"), "utf8")).version;
23217
+ var packageVersion = async () => JSON.parse(await readFile(path11.join(packageRoot, "package.json"), "utf8")).version;
22952
23218
  var cacheDirectory = (env = process.env) => {
22953
- if (env.LAYERMAP_CACHE) return path10.resolve(env.LAYERMAP_CACHE);
22954
- if (process.platform === "darwin") return path10.join(homedir(), "Library", "Caches", "layermap");
22955
- return path10.join(env.XDG_CACHE_HOME || path10.join(homedir(), ".cache"), "layermap");
23219
+ if (env.LAYERMAP_CACHE) return path11.resolve(env.LAYERMAP_CACHE);
23220
+ if (process.platform === "darwin") return path11.join(homedir(), "Library", "Caches", "layermap");
23221
+ if (process.platform === "win32")
23222
+ return path11.join(
23223
+ env.LOCALAPPDATA || path11.join(homedir(), "AppData", "Local"),
23224
+ "layermap",
23225
+ "Cache"
23226
+ );
23227
+ return path11.join(env.XDG_CACHE_HOME || path11.join(homedir(), ".cache"), "layermap");
22956
23228
  };
22957
23229
  var projectDirectory = (directory) => new Promise(
22958
23230
  (resolve) => execFile(
@@ -22960,7 +23232,7 @@ var projectDirectory = (directory) => new Promise(
22960
23232
  ["rev-parse", "--show-toplevel"],
22961
23233
  { cwd: directory, timeout: 1e4 },
22962
23234
  (error51, stdout) => resolve(
22963
- error51 ? { directory: path10.resolve(directory), git: false } : { directory: stdout.trim(), git: true }
23235
+ error51 ? { directory: path11.resolve(directory), git: false } : { directory: stdout.trim(), git: true }
22964
23236
  )
22965
23237
  )
22966
23238
  );
@@ -22970,7 +23242,7 @@ var relativeTo = (directory, value) => Object.fromEntries(
22970
23242
  Object.fromEntries(
22971
23243
  Object.entries(resources).map(([key, field]) => [
22972
23244
  key,
22973
- key.endsWith("Path") && typeof field === "string" && field.startsWith(directory) ? path10.relative(directory, field) : field
23245
+ key.endsWith("Path") && typeof field === "string" && field.startsWith(directory) ? path11.relative(directory, field) : field
22974
23246
  ])
22975
23247
  )
22976
23248
  ])
@@ -22981,9 +23253,10 @@ var resolvePlaceholder = (field) => {
22981
23253
  createRequire(import.meta.url).resolve("typescript/package.json")
22982
23254
  );
22983
23255
  const native = `@typescript/typescript-${process.platform}-${process.arch}/package.json`;
22984
- return path10.join(path10.dirname(compiler.resolve(native)), "lib", "tsc");
23256
+ return path11.join(path11.dirname(compiler.resolve(native)), "lib", executableName("tsc"));
22985
23257
  }
22986
- return field.replaceAll("{platform}", process.platform).replaceAll("{arch}", process.arch);
23258
+ const resolved = field.replaceAll("{platform}", process.platform).replaceAll("{arch}", process.arch);
23259
+ return field.includes("{platform}") ? executableName(resolved) : resolved;
22987
23260
  };
22988
23261
  var absoluteIn = (directory, value) => Object.fromEntries(
22989
23262
  Object.entries(value).map(([language, resources]) => [
@@ -22992,24 +23265,24 @@ var absoluteIn = (directory, value) => Object.fromEntries(
22992
23265
  Object.entries(resources).map(([key, field]) => {
22993
23266
  if (!key.endsWith("Path") || typeof field !== "string") return [key, field];
22994
23267
  const resolved = resolvePlaceholder(field);
22995
- return [key, path10.isAbsolute(resolved) ? resolved : path10.join(directory, resolved)];
23268
+ return [key, path11.isAbsolute(resolved) ? resolved : path11.join(directory, resolved)];
22996
23269
  })
22997
23270
  )
22998
23271
  ])
22999
23272
  );
23000
23273
  var readAnalyzers = async (directory) => {
23001
- const file2 = path10.join(directory, "analyzers.json");
23002
- if (!existsSync4(file2)) return void 0;
23274
+ const file2 = path11.join(directory, "analyzers.json");
23275
+ if (!existsSync5(file2)) return void 0;
23003
23276
  const analyzers = absoluteIn(directory, JSON.parse(await readFile(file2, "utf8")));
23004
23277
  return analyzers.java.runtimePath ? analyzers : { ...analyzers, java: { ...analyzers.java, ...discoverJavaRuntime() } };
23005
23278
  };
23006
23279
  var sourceDigest = async () => {
23007
- const hash2 = createHash5("sha256").update(await readFile(path10.join(packageRoot, "package.json")));
23280
+ const hash2 = createHash5("sha256").update(await readFile(path11.join(packageRoot, "package.json")));
23008
23281
  for (const part of ["src", "go-map", "java-map", "scripts"]) {
23009
- const directory = path10.join(packageRoot, part);
23010
- if (!existsSync4(directory)) continue;
23282
+ const directory = path11.join(packageRoot, part);
23283
+ if (!existsSync5(directory)) continue;
23011
23284
  for (const entry of (await readdir(directory, { recursive: true })).sort()) {
23012
- const file2 = path10.join(directory, entry);
23285
+ const file2 = path11.join(directory, entry);
23013
23286
  const info = await stat(file2);
23014
23287
  if (info.isFile()) hash2.update(`${part}/${entry}\0${info.size}\0${info.mtimeMs}\0`);
23015
23288
  }
@@ -23017,11 +23290,11 @@ var sourceDigest = async () => {
23017
23290
  return hash2.digest("hex").slice(0, 16);
23018
23291
  };
23019
23292
  async function resolveAnalyzers(cache, log2, env = process.env) {
23020
- for (const directory2 of [env.LAYERMAP_ANALYZERS, path10.join(packageRoot, "analyzers")]) {
23021
- const analyzers = directory2 && await readAnalyzers(path10.resolve(directory2));
23293
+ for (const directory2 of [env.LAYERMAP_ANALYZERS, path11.join(packageRoot, "analyzers")]) {
23294
+ const analyzers = directory2 && await readAnalyzers(path11.resolve(directory2));
23022
23295
  if (analyzers) return analyzers;
23023
23296
  }
23024
- const directory = path10.join(cache, "analyzers", await sourceDigest());
23297
+ const directory = path11.join(cache, "analyzers", await sourceDigest());
23025
23298
  const built = await readAnalyzers(directory);
23026
23299
  if (built) return built;
23027
23300
  log2("Building the language analyzers (once per LayerMap version)...");
@@ -23037,32 +23310,32 @@ async function resolveAnalyzers(cache, log2, env = process.env) {
23037
23310
  python: parser.pythonResources,
23038
23311
  java: parser.javaResources
23039
23312
  });
23040
- await writeFile(path10.join(staging, "analyzers.json"), `${JSON.stringify(stored, null, 2)}
23313
+ await writeFile(path11.join(staging, "analyzers.json"), `${JSON.stringify(stored, null, 2)}
23041
23314
  `);
23042
23315
  await rename(staging, directory).catch(() => rm(staging, { recursive: true, force: true }));
23043
23316
  return await readAnalyzers(directory);
23044
23317
  }
23045
23318
  var DAY = 24 * 60 * 60 * 1e3;
23046
23319
  async function pruneCache(cache, project, now = Date.now()) {
23047
- const used = path10.join(path10.dirname(mapDatabasePath(cache, project)), "last-used");
23048
- await mkdir(path10.dirname(used), { recursive: true, mode: 448 });
23320
+ const used = path11.join(path11.dirname(mapDatabasePath(cache, project)), "last-used");
23321
+ await mkdir(path11.dirname(used), { recursive: true, mode: 448 });
23049
23322
  await writeFile(used, "");
23050
23323
  await utimes(used, now / 1e3, now / 1e3);
23051
- const projects = path10.join(cache, "projects");
23324
+ const projects = path11.join(cache, "projects");
23052
23325
  for (const name of await readdir(projects).catch(() => [])) {
23053
- const directory = path10.join(projects, name);
23054
- const marker = path10.join(directory, "last-used");
23055
- const last = (await stat(existsSync4(marker) ? marker : directory).catch(() => void 0))?.mtimeMs;
23326
+ const directory = path11.join(projects, name);
23327
+ const marker = path11.join(directory, "last-used");
23328
+ const last = (await stat(existsSync5(marker) ? marker : directory).catch(() => void 0))?.mtimeMs;
23056
23329
  if (last !== void 0 && now - last > 30 * DAY)
23057
23330
  await rm(directory, { recursive: true, force: true });
23058
23331
  }
23059
- const builds = path10.join(cache, "analyzers");
23332
+ const builds = path11.join(cache, "analyzers");
23060
23333
  const current = await sourceDigest();
23061
23334
  for (const name of await readdir(builds).catch(() => [])) {
23062
23335
  if (name === current) continue;
23063
- const built = (await stat(path10.join(builds, name)).catch(() => void 0))?.mtimeMs;
23336
+ const built = (await stat(path11.join(builds, name)).catch(() => void 0))?.mtimeMs;
23064
23337
  if (built !== void 0 && now - built > (name.includes(".") ? DAY / 24 : DAY))
23065
- await rm(path10.join(builds, name), { recursive: true, force: true });
23338
+ await rm(path11.join(builds, name), { recursive: true, force: true });
23066
23339
  }
23067
23340
  }
23068
23341
 
@@ -23092,7 +23365,7 @@ var MAP_TOOL_NAMES = Object.freeze({
23092
23365
  references: "project_find_references",
23093
23366
  check: "project_check_changes"
23094
23367
  });
23095
- var mapDirectoryPath = (path12) => path12.length > 1 && path12.endsWith("/") && !path12.endsWith("//") ? path12.slice(0, -1) : path12;
23368
+ var mapDirectoryPath = (path13) => path13.length > 1 && path13.endsWith("/") && !path13.endsWith("//") ? path13.slice(0, -1) : path13;
23096
23369
  var ProjectMapSearchInputSchema = external_exports.object({
23097
23370
  path: external_exports.string().default("."),
23098
23371
  query: external_exports.string().min(1).max(256),
@@ -23146,7 +23419,7 @@ var mapToolDescriptions = (host) => {
23146
23419
  return Object.freeze({
23147
23420
  search: `${lead("search")}Find declarations and files whose names, paths or source documentation match query terms. ANY (default) matches any term, ALL requires every term, LITERAL matches the exact text. Results are ranked by relevance and grouped by file with the declaration name, kind, 1-based line range and matched fields (${MAP_KINDS_LEGEND}). Zoom into a result with project_explore_map({path,name}) or ${host.readResult}. This is not a full-text search and does not prove absence; ${host.textSearch}. Continue with offset and unchanged conditions.`,
23148
23421
  explore: `${lead("explore")}Read the static project map, zooming from the whole project to one declaration. path "." or a directory lists modules, module imports, external packages and its files: with exported declarations when the listing is small, as file names and line counts by directory when larger, and as modules only when very large. Start here to see what exists before searching or reading. A file path lists its declarations and members, imports, importers and top-level statements. A file path with name (or Container.member), optionally narrowed by its start line, or with a line alone, shows that declaration's calls, callers (including uses as a value), writes, heritage, decorators and members, aggregated per related declaration with @line sites; closures and locals are folded into their named container. depth also expands the related declarations hop by hop: up to 8 in one direction, which traces callers up to entry points (INCOMING) or callees down (OUTGOING), and up to 3 for BOTH. To find what a change affects, select the declaration with direction INCOMING and a depth up to 8, continue from any NOT EXPANDED declarations the view names, then confirm the entry points in source. Test files and standard-library call targets are hidden and counted by default; includeTests and includeUnresolved show them. Views use ${MAP_KINDS_LEGEND}. In a declaration view, ${MAP_DECLARATION_LEGEND} ${host.readSource} The map is static: trace stops, possible callers by name, framework wiring and unresolved targets need source reading, and a missing relationship does not prove absence. When a page reports more entries, continue with offset and otherwise unchanged arguments.`,
23149
- check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; EXISTING TESTS CHANGED, the tests that existed before the diff and whose code it changed or removed; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; NAMES STILL USED ELSEWHERE, environment variables and configuration keys the diff removed from a file that other files still read or set, found by text; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it. It does not run or write tests: run the related ones if the change needs verifying; a failing or rewritten test of a feature the request is not about means the change leaked, so restore the test and narrow the change; call it once when the edits are done; and confirm the entry points in source, since an empty list does not prove a change safe.`,
23422
+ check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; REQUESTED BY, the code and templates outside the tests that request the path of a route whose handler the change reaches or a route it removed, found by text; EXISTING TESTS CHANGED, the tests that existed before the diff and whose code it changed or removed; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; NAMES STILL USED ELSEWHERE, environment variables and configuration keys the diff removed from a file that other files still read or set, found by text; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it. It does not run or write tests: run the related ones if the change needs verifying; a failing or rewritten test of a feature the request is not about means the change leaked, so restore the test and narrow the change; call it once when the edits are done; and confirm the entry points in source, since an empty list does not prove a change safe.`,
23150
23423
  references: `${lead("references")}Compute usages of a mapped declaration from current source, including aliases, re-exports and non-call references. Select it with symbol {path,name,line?} as printed by project_explore_map or project_search_map (line is its start line when names repeat), or with an entityRef or locator {path,start,kind}. Broader and more expensive than the cached callers in project_explore_map; file or unsupported declarations may lack a reference target. path and kinds filter usage locations before paging. ${host.grantRules}objects contains compact declarations; targetRef and reference ownerRef identify them. ${host.readReference} A file that several compiler contexts read (such as packages of one workspace) lists its references once per context, each with that context's configPath. Continue with nextCursor and unchanged conditions, including after an empty partial page. Filtered exhaustion and missing results do not prove absence.`
23151
23424
  });
23152
23425
  };
@@ -23384,19 +23657,25 @@ function serveMcp(options) {
23384
23657
 
23385
23658
  // src/agent/setup.ts
23386
23659
  import { execFile as execFile2 } from "node:child_process";
23387
- import { existsSync as existsSync5 } from "node:fs";
23660
+ import { existsSync as existsSync6 } from "node:fs";
23388
23661
  import { mkdir as mkdir2, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
23389
23662
  import { homedir as homedir2 } from "node:os";
23390
- import path11 from "node:path";
23663
+ import path12 from "node:path";
23391
23664
  var SERVER = "layermap";
23392
23665
  var SETUP_RULE = `mcp__${SERVER}`;
23393
23666
  var PLUGIN_RULE = `mcp__plugin_${SERVER}_${SERVER}`;
23394
23667
  var BEGIN = "<!-- layermap:begin -->";
23395
23668
  var END = "<!-- layermap:end -->";
23396
- var mcpLaunchCommand = (version2) => {
23397
- const script = path11.resolve(process.argv[1] ?? "");
23398
- if (script.includes(`${path11.sep}_npx${path11.sep}`))
23399
- return ["npx", "-y", `layermap@${version2}`, "mcp"];
23669
+ var mcpLaunchCommand = (version2, platform = process.platform) => {
23670
+ const script = path12.resolve(process.argv[1] ?? "");
23671
+ if (script.includes(`${path12.sep}_npx${path12.sep}`))
23672
+ return [
23673
+ ...platform === "win32" ? ["cmd", "/c"] : [],
23674
+ "npx",
23675
+ "-y",
23676
+ `layermap@${version2}`,
23677
+ "mcp"
23678
+ ];
23400
23679
  const execArgv = [];
23401
23680
  for (let index = 0; index < process.execArgv.length; index++) {
23402
23681
  const argument = process.execArgv[index];
@@ -23408,16 +23687,22 @@ var mcpLaunchCommand = (version2) => {
23408
23687
  }
23409
23688
  return [process.execPath, ...execArgv, script, "mcp"];
23410
23689
  };
23411
- var run = (command, args, env) => new Promise(
23412
- (resolve) => execFile2(
23413
- command,
23414
- args,
23415
- { env, timeout: 6e4 },
23690
+ var run = (command, args, env) => new Promise((resolve) => {
23691
+ const invocation = commandInvocation(command, args, env);
23692
+ execFile2(
23693
+ invocation.file,
23694
+ invocation.args,
23695
+ {
23696
+ env,
23697
+ timeout: 6e4,
23698
+ windowsHide: true,
23699
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments
23700
+ },
23416
23701
  (error51, stdout, stderr) => resolve({ ok: !error51, output: `${stdout}${stderr}`.trim() })
23417
- )
23418
- );
23702
+ );
23703
+ });
23419
23704
  async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
23420
- const settings = existsSync5(file2) ? JSON.parse(await readFile2(file2, "utf8")) : {};
23705
+ const settings = existsSync6(file2) ? JSON.parse(await readFile2(file2, "utf8")) : {};
23421
23706
  if (typeof settings !== "object" || settings === null || Array.isArray(settings))
23422
23707
  throw new Error(`${file2} is not a settings object.`);
23423
23708
  settings.permissions ??= {};
@@ -23426,7 +23711,7 @@ async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
23426
23711
  throw new Error(`${file2} has permissions.allow that is not a list.`);
23427
23712
  if (settings.permissions.allow.includes(rule)) return false;
23428
23713
  settings.permissions.allow.push(rule);
23429
- await mkdir2(path11.dirname(file2), { recursive: true });
23714
+ await mkdir2(path12.dirname(file2), { recursive: true });
23430
23715
  await writeFile2(file2, `${JSON.stringify(settings, null, 2)}
23431
23716
  `);
23432
23717
  return true;
@@ -23454,17 +23739,17 @@ async function writeInstructionNote(file2, note = AGENT_MAP_NOTE) {
23454
23739
  const block = `${BEGIN}
23455
23740
  ${note}
23456
23741
  ${END}`;
23457
- const text = existsSync5(file2) ? await readFile2(file2, "utf8") : "";
23742
+ const text = existsSync6(file2) ? await readFile2(file2, "utf8") : "";
23458
23743
  const start = text.indexOf(BEGIN);
23459
23744
  const end = text.indexOf(END);
23460
23745
  const next = start >= 0 && end > start ? `${text.slice(0, start)}${block}${text.slice(end + END.length)}` : `${text}${text && !text.endsWith("\n") ? "\n" : ""}${text ? "\n" : ""}${block}
23461
23746
  `;
23462
23747
  if (next === text) return;
23463
- await mkdir2(path11.dirname(file2), { recursive: true });
23748
+ await mkdir2(path12.dirname(file2), { recursive: true });
23464
23749
  await writeFile2(file2, next);
23465
23750
  }
23466
23751
  async function removeInstructionNote(file2) {
23467
- if (!existsSync5(file2)) return;
23752
+ if (!existsSync6(file2)) return;
23468
23753
  const text = await readFile2(file2, "utf8");
23469
23754
  const start = text.indexOf(BEGIN);
23470
23755
  const end = text.indexOf(END);
@@ -23475,7 +23760,7 @@ async function removeInstructionNote(file2) {
23475
23760
  else await writeFile2(file2, rest);
23476
23761
  }
23477
23762
  async function disallowInClaudeSettings(file2) {
23478
- if (!existsSync5(file2)) return;
23763
+ if (!existsSync6(file2)) return;
23479
23764
  const settings = JSON.parse(await readFile2(file2, "utf8"));
23480
23765
  const allow = settings?.permissions?.allow;
23481
23766
  const ours = (rule) => rule === SETUP_RULE || rule === PLUGIN_RULE;
@@ -23488,14 +23773,14 @@ async function disallowInClaudeSettings(file2) {
23488
23773
  }
23489
23774
  var YAML_BEGIN = "# layermap:begin";
23490
23775
  var YAML_END = "# layermap:end";
23491
- var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(path11.delimiter).find(
23492
- (directory) => path11.isAbsolute(directory) && existsSync5(path11.join(directory, "node")) && existsSync5(path11.join(directory, "npx"))
23493
- ) ?? path11.dirname(process.execPath);
23776
+ var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(path12.delimiter).find(
23777
+ (directory) => path12.isAbsolute(directory) && existsSync6(path12.join(directory, "node")) && existsSync6(path12.join(directory, "npx"))
23778
+ ) ?? path12.dirname(process.execPath);
23494
23779
  var dshPatchBlock = (command, env) => {
23495
23780
  const node = nodeDirectory(env);
23496
- const npx = path11.join(node, "npx");
23497
- const [program = "", ...args] = command[0] === "npx" && existsSync5(npx) ? [npx, ...command.slice(1)] : command;
23498
- const searchPath = `${JSON.stringify(`${node}${path11.delimiter}`)} + process.env.PATH`;
23781
+ const npx = path12.join(node, "npx");
23782
+ const [program = "", ...args] = command[0] === "npx" && existsSync6(npx) ? [npx, ...command.slice(1)] : command;
23783
+ const searchPath2 = `${JSON.stringify(`${node}${path12.delimiter}`)} + process.env.PATH`;
23499
23784
  return [
23500
23785
  `${YAML_BEGIN} (written by \`layermap setup dsh\`; \`layermap remove dsh\` deletes it)`,
23501
23786
  "- insert:",
@@ -23507,14 +23792,14 @@ var dshPatchBlock = (command, env) => {
23507
23792
  ` command: ${JSON.stringify(program)}`,
23508
23793
  ` args: ${JSON.stringify(args)}`,
23509
23794
  " env:",
23510
- ` PATH: !!js ${JSON.stringify(searchPath)}`,
23795
+ ` PATH: !!js ${JSON.stringify(searchPath2)}`,
23511
23796
  " cwd: !!js process.cwd()",
23512
23797
  " toolCallTimeoutMs: 120000",
23513
23798
  YAML_END
23514
23799
  ].join("\n");
23515
23800
  };
23516
23801
  async function writeDshPatch(file2, block) {
23517
- const text = existsSync5(file2) ? await readFile2(file2, "utf8") : "";
23802
+ const text = existsSync6(file2) ? await readFile2(file2, "utf8") : "";
23518
23803
  const start = text.indexOf(YAML_BEGIN);
23519
23804
  const end = text.indexOf(YAML_END);
23520
23805
  let next;
@@ -23530,11 +23815,11 @@ async function writeDshPatch(file2, block) {
23530
23815
  `;
23531
23816
  }
23532
23817
  if (next === text) return;
23533
- await mkdir2(path11.dirname(file2), { recursive: true });
23818
+ await mkdir2(path12.dirname(file2), { recursive: true });
23534
23819
  await writeFile2(file2, next);
23535
23820
  }
23536
23821
  async function removeDshPatch(file2) {
23537
- if (!existsSync5(file2)) return;
23822
+ if (!existsSync6(file2)) return;
23538
23823
  const text = await readFile2(file2, "utf8");
23539
23824
  const start = text.indexOf(YAML_BEGIN);
23540
23825
  const end = text.indexOf(YAML_END);
@@ -23548,31 +23833,31 @@ async function removeDshPatch(file2) {
23548
23833
  var agentFiles = (options) => {
23549
23834
  const env = options.env ?? process.env;
23550
23835
  if (options.agent === "dsh") {
23551
- const home = env.DSH_HOME || path11.join(homedir2(), ".dsh");
23836
+ const home = env.DSH_HOME || path12.join(homedir2(), ".dsh");
23552
23837
  return {
23553
- settings: path11.join(home, "cordis.patch.yml"),
23554
- instructions: path11.join(home, "AGENTS.md")
23838
+ settings: path12.join(home, "cordis.patch.yml"),
23839
+ instructions: path12.join(home, "AGENTS.md")
23555
23840
  };
23556
23841
  }
23557
23842
  if (options.agent === "codex") {
23558
- const home = env.CODEX_HOME ?? path11.join(homedir2(), ".codex");
23559
- return { settings: path11.join(home, "config.toml"), instructions: path11.join(home, "AGENTS.md") };
23843
+ const home = env.CODEX_HOME ?? path12.join(homedir2(), ".codex");
23844
+ return { settings: path12.join(home, "config.toml"), instructions: path12.join(home, "AGENTS.md") };
23560
23845
  }
23561
23846
  if (options.scope === "user") {
23562
- const home = env.CLAUDE_CONFIG_DIR ?? path11.join(homedir2(), ".claude");
23847
+ const home = env.CLAUDE_CONFIG_DIR ?? path12.join(homedir2(), ".claude");
23563
23848
  return {
23564
- settings: path11.join(home, "settings.json"),
23565
- instructions: path11.join(home, "CLAUDE.md")
23849
+ settings: path12.join(home, "settings.json"),
23850
+ instructions: path12.join(home, "CLAUDE.md")
23566
23851
  };
23567
23852
  }
23568
23853
  const local = options.scope === "local";
23569
23854
  return {
23570
- settings: path11.join(
23855
+ settings: path12.join(
23571
23856
  options.project,
23572
23857
  ".claude",
23573
23858
  local ? "settings.local.json" : "settings.json"
23574
23859
  ),
23575
- instructions: path11.join(options.project, local ? "CLAUDE.local.md" : "CLAUDE.md")
23860
+ instructions: path12.join(options.project, local ? "CLAUDE.local.md" : "CLAUDE.md")
23576
23861
  };
23577
23862
  };
23578
23863
  async function setupAgent(options) {