layermap 0.1.11 → 0.1.13

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,18 +12,18 @@ 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 readFileSync3 } from "node:fs";
15
+ import { existsSync as existsSync4, 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 path9 from "node:path";
19
+ import path10 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 path8 from "node:path";
26
+ import path9 from "node:path";
27
27
  import { DatabaseSync } from "@photostructure/sqlite";
28
28
 
29
29
  // src/capture-policy.ts
@@ -1221,10 +1221,10 @@ function mergeDefs(...defs) {
1221
1221
  function cloneDef(schema) {
1222
1222
  return mergeDefs(schema._zod.def);
1223
1223
  }
1224
- function getElementAtPath(obj, path11) {
1225
- if (!path11)
1224
+ function getElementAtPath(obj, path12) {
1225
+ if (!path12)
1226
1226
  return obj;
1227
- return path11.reduce((acc, key) => acc?.[key], obj);
1227
+ return path12.reduce((acc, key) => acc?.[key], obj);
1228
1228
  }
1229
1229
  function promiseAllObject(promisesObj) {
1230
1230
  const keys = Object.keys(promisesObj);
@@ -1633,11 +1633,11 @@ function explicitlyAborted(x, startIndex = 0) {
1633
1633
  }
1634
1634
  return false;
1635
1635
  }
1636
- function prefixIssues(path11, issues) {
1636
+ function prefixIssues(path12, issues) {
1637
1637
  return issues.map((iss) => {
1638
1638
  var _a3;
1639
1639
  (_a3 = iss).path ?? (_a3.path = []);
1640
- iss.path.unshift(path11);
1640
+ iss.path.unshift(path12);
1641
1641
  return iss;
1642
1642
  });
1643
1643
  }
@@ -1784,16 +1784,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1784
1784
  }
1785
1785
  function formatError(error51, mapper = (issue2) => issue2.message) {
1786
1786
  const fieldErrors = { _errors: [] };
1787
- const processError = (error52, path11 = []) => {
1787
+ const processError = (error52, path12 = []) => {
1788
1788
  for (const issue2 of error52.issues) {
1789
1789
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1790
- issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
1790
+ issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1791
1791
  } else if (issue2.code === "invalid_key") {
1792
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1792
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1793
1793
  } else if (issue2.code === "invalid_element") {
1794
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1794
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1795
1795
  } else {
1796
- const fullpath = [...path11, ...issue2.path];
1796
+ const fullpath = [...path12, ...issue2.path];
1797
1797
  if (fullpath.length === 0) {
1798
1798
  fieldErrors._errors.push(mapper(issue2));
1799
1799
  } else {
@@ -1820,17 +1820,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1820
1820
  }
1821
1821
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1822
1822
  const result = { errors: [] };
1823
- const processError = (error52, path11 = []) => {
1823
+ const processError = (error52, path12 = []) => {
1824
1824
  var _a3, _b;
1825
1825
  for (const issue2 of error52.issues) {
1826
1826
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1827
- issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
1827
+ issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1828
1828
  } else if (issue2.code === "invalid_key") {
1829
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1829
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1830
1830
  } else if (issue2.code === "invalid_element") {
1831
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1831
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1832
1832
  } else {
1833
- const fullpath = [...path11, ...issue2.path];
1833
+ const fullpath = [...path12, ...issue2.path];
1834
1834
  if (fullpath.length === 0) {
1835
1835
  result.errors.push(mapper(issue2));
1836
1836
  continue;
@@ -1862,8 +1862,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1862
1862
  }
1863
1863
  function toDotPath(_path) {
1864
1864
  const segs = [];
1865
- const path11 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1866
- for (const seg of path11) {
1865
+ const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1866
+ for (const seg of path12) {
1867
1867
  if (typeof seg === "number")
1868
1868
  segs.push(`[${seg}]`);
1869
1869
  else if (typeof seg === "symbol")
@@ -14555,13 +14555,13 @@ function resolveRef(ref, ctx) {
14555
14555
  if (!ref.startsWith("#")) {
14556
14556
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14557
14557
  }
14558
- const path11 = ref.slice(1).split("/").filter(Boolean);
14559
- if (path11.length === 0) {
14558
+ const path12 = ref.slice(1).split("/").filter(Boolean);
14559
+ if (path12.length === 0) {
14560
14560
  return ctx.rootSchema;
14561
14561
  }
14562
14562
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14563
- if (path11[0] === defsKey) {
14564
- const key = path11[1];
14563
+ if (path12[0] === defsKey) {
14564
+ const key = path12[1];
14565
14565
  if (!key || !ctx.defs[key]) {
14566
14566
  throw new Error(`Reference not found: ${ref}`);
14567
14567
  }
@@ -15801,8 +15801,8 @@ var MapAnalysisSchema = external_exports.object({
15801
15801
  var mapPathAllowed = (relative, prefixes) => prefixes.some(
15802
15802
  (prefix) => prefix === "." || relative === prefix || relative.startsWith(`${prefix}/`)
15803
15803
  );
15804
- var mapTestPath = (path11) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
15805
- path11
15804
+ var mapTestPath = (path12) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
15805
+ path12
15806
15806
  );
15807
15807
 
15808
15808
  // src/project-map-reference-types.ts
@@ -15886,11 +15886,11 @@ var string4 = (value) => {
15886
15886
  var identity = (id2, reconstructed) => id2 === reconstructed ? [] : [JSON.stringify(id2)];
15887
15887
  function encodeMapText(graph) {
15888
15888
  const files = /* @__PURE__ */ new Map();
15889
- const file2 = (path11) => {
15890
- let ref = files.get(path11);
15889
+ const file2 = (path12) => {
15890
+ let ref = files.get(path12);
15891
15891
  if (!ref) {
15892
15892
  ref = `F${files.size + 1}`;
15893
- files.set(path11, ref);
15893
+ files.set(path12, ref);
15894
15894
  }
15895
15895
  return ref;
15896
15896
  };
@@ -15938,7 +15938,7 @@ function encodeMapText(graph) {
15938
15938
  rows.push(`B ${node(frontier.entityRef)} ${frontier.direction}`);
15939
15939
  return [
15940
15940
  ...header,
15941
- ...[...files].map(([path11, ref]) => `${ref} ${JSON.stringify(path11)}`),
15941
+ ...[...files].map(([path12, ref]) => `${ref} ${JSON.stringify(path12)}`),
15942
15942
  ...rows
15943
15943
  ].join("\n");
15944
15944
  }
@@ -15958,10 +15958,10 @@ function decodeMapText(text) {
15958
15958
  const at = (value) => {
15959
15959
  const match = /^(F[1-9]\d*):(\d+)-(\d+)@(\d+)-(\d+)$/u.exec(value ?? "");
15960
15960
  if (!match) return failed();
15961
- const path11 = files.get(match[1] ?? "");
15962
- if (path11 === void 0) return failed();
15961
+ const path12 = files.get(match[1] ?? "");
15962
+ if (path12 === void 0) return failed();
15963
15963
  return MapAnchorSchema.parse({
15964
- path: path11,
15964
+ path: path12,
15965
15965
  startLine: Number(match[2]),
15966
15966
  endLine: Number(match[3]),
15967
15967
  start: Number(match[4]),
@@ -16038,8 +16038,8 @@ function decodeMapText(text) {
16038
16038
  var locationSchema = MapAnchorSchema.describe(
16039
16039
  "Source location: start/end are zero-based UTF-16 offsets with an exclusive end; line numbers are one-based."
16040
16040
  );
16041
- var location = ({ path: path11, startLine, endLine, start, end }) => ({
16042
- path: path11,
16041
+ var location = ({ path: path12, startLine, endLine, start, end }) => ({
16042
+ path: path12,
16043
16043
  startLine,
16044
16044
  endLine,
16045
16045
  start,
@@ -16142,11 +16142,11 @@ var MapNavigationObjectsSchema = external_exports.union([
16142
16142
  ),
16143
16143
  external_exports.object({ files: external_exports.array(searchFileSchema) }).passthrough().refine((value) => !("format" in value), "Text navigation must decode through its format.").transform(
16144
16144
  (value) => value.files.flatMap(
16145
- ({ path: path11, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
16145
+ ({ path: path12, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
16146
16146
  id: id2,
16147
16147
  name,
16148
16148
  kind,
16149
- anchor: { path: path11, startLine, endLine, start, end },
16149
+ anchor: { path: path12, startLine, endLine, start, end },
16150
16150
  ...execution ? { execution } : {}
16151
16151
  }))
16152
16152
  )
@@ -16159,10 +16159,10 @@ var mapSearchNavigation = (result) => {
16159
16159
  for (const [index, object2] of found.entries()) {
16160
16160
  const ranking = rankings[index];
16161
16161
  if (!ranking) throw new Error("PROJECT_MAP_SEARCH_RANKING_MISSING");
16162
- const path11 = object2.anchor.path;
16162
+ const path12 = object2.anchor.path;
16163
16163
  let file2 = files.at(-1);
16164
- if (file2?.path !== path11) {
16165
- file2 = { path: path11, symbols: [] };
16164
+ if (file2?.path !== path12) {
16165
+ file2 = { path: path12, symbols: [] };
16166
16166
  files.push(file2);
16167
16167
  }
16168
16168
  file2.symbols.push({
@@ -16288,8 +16288,8 @@ var MapViewGraph = class {
16288
16288
  }
16289
16289
  return object2;
16290
16290
  }
16291
- objectsAt(path11) {
16292
- return this.statements.path.all(this.version, path11).map((row) => {
16291
+ objectsAt(path12) {
16292
+ return this.statements.path.all(this.version, path12).map((row) => {
16293
16293
  const object2 = MapObjectSchema.parse(JSON.parse(String(row.object_json)));
16294
16294
  this.objects.set(object2.id, object2);
16295
16295
  return object2;
@@ -16408,8 +16408,8 @@ var MapViewGraph = class {
16408
16408
  );
16409
16409
  }
16410
16410
  };
16411
- function mapSelectDeclarations(graph, path11, name, line) {
16412
- const objects2 = graph.objectsAt(path11).filter((object2) => !mapIsModule(object2));
16411
+ function mapSelectDeclarations(graph, path12, name, line) {
16412
+ const objects2 = graph.objectsAt(path12).filter((object2) => !mapIsModule(object2));
16413
16413
  const matching = name === void 0 ? objects2 : objects2.filter(
16414
16414
  (object2) => object2.name === name || name.includes(".") && graph.qualifiedName(object2.id) === name
16415
16415
  );
@@ -16431,12 +16431,12 @@ function requireMapObject(store, version2, selector, prefixes) {
16431
16431
  if ([entityRef, locator, symbol2].filter((value) => value !== void 0).length !== 1 || entityRef !== void 0 && !entityRef.length)
16432
16432
  throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
16433
16433
  if (symbol2) {
16434
- const path11 = normalizeProjectEvidencePath(symbol2.path);
16435
- if (!mapPathAllowed(path11, prefixes))
16434
+ const path12 = normalizeProjectEvidencePath(symbol2.path);
16435
+ if (!mapPathAllowed(path12, prefixes))
16436
16436
  throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
16437
16437
  const selected = mapSelectDeclarations(
16438
16438
  new MapViewGraph(store, version2),
16439
- path11,
16439
+ path12,
16440
16440
  symbol2.name,
16441
16441
  symbol2.line
16442
16442
  );
@@ -16447,14 +16447,14 @@ function requireMapObject(store, version2, selector, prefixes) {
16447
16447
  }
16448
16448
  let rows;
16449
16449
  if (locator) {
16450
- const path11 = normalizeProjectEvidencePath(locator.path);
16450
+ const path12 = normalizeProjectEvidencePath(locator.path);
16451
16451
  if (!Number.isSafeInteger(locator.start) || locator.start < 0 || locator.kind !== void 0 && !MapObjectKindSchema.safeParse(locator.kind).success)
16452
16452
  throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
16453
- if (!mapPathAllowed(path11, prefixes))
16453
+ if (!mapPathAllowed(path12, prefixes))
16454
16454
  throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
16455
16455
  rows = store.database.prepare(`SELECT object_json FROM project_map_objects
16456
16456
  WHERE version_ref = ? AND path = ? AND json_extract(object_json, '$.anchor.start') = ?
16457
- AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path11, locator.start, locator.kind ?? null, locator.kind ?? null);
16457
+ AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path12, locator.start, locator.kind ?? null, locator.kind ?? null);
16458
16458
  } else {
16459
16459
  rows = store.database.prepare(
16460
16460
  "SELECT object_json FROM project_map_objects WHERE version_ref = ? AND entity_ref = ?"
@@ -16495,13 +16495,13 @@ function mapQueryPage(count, materialize, navigation, budget) {
16495
16495
 
16496
16496
  // src/project-map-query-selection.ts
16497
16497
  var mapQuerySelection = (input, knownKinds) => {
16498
- const path11 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
16498
+ const path12 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
16499
16499
  const kinds = input.kinds ?? knownKinds;
16500
16500
  if (!Array.isArray(kinds) || !kinds.length || kinds.length > knownKinds.length || kinds.some((kind) => !knownKinds.includes(kind)))
16501
16501
  throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
16502
- return { path: path11, kinds: [...new Set(kinds)].sort() };
16502
+ return { path: path12, kinds: [...new Set(kinds)].sort() };
16503
16503
  };
16504
- var mapQueryPathMatches = (path11, prefix) => prefix === "." || path11 === prefix || path11.startsWith(`${prefix}/`);
16504
+ var mapQueryPathMatches = (path12, prefix) => prefix === "." || path12 === prefix || path12.startsWith(`${prefix}/`);
16505
16505
  var mapQueryPathSql = (column) => `(? = '.' OR ${column} = ? OR substr(${column}, 1, length(?) + 1) = ? || '/')`;
16506
16506
 
16507
16507
  // src/project-map-search-focus.ts
@@ -16599,7 +16599,7 @@ var declarationKinds = /* @__PURE__ */ new Set([
16599
16599
  "METHOD",
16600
16600
  "TYPE"
16601
16601
  ]);
16602
- var fileStem = (path11) => path11.slice(path11.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
16602
+ var fileStem = (path12) => path12.slice(path12.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
16603
16603
  var compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
16604
16604
  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
16605
  function mapSearchQuery(input) {
@@ -16626,10 +16626,10 @@ function mapSearchQuery(input) {
16626
16626
  }
16627
16627
  function rank(object2, documentation, relationCount, query, focus) {
16628
16628
  const name = object2.name.toLowerCase();
16629
- const path11 = object2.anchor.path.toLowerCase();
16629
+ const path12 = object2.anchor.path.toLowerCase();
16630
16630
  const values = {
16631
16631
  NAME: [name],
16632
- PATH: [path11],
16632
+ PATH: [path12],
16633
16633
  DOCUMENTATION: documentation.map((text) => text.toLowerCase())
16634
16634
  };
16635
16635
  const matched = query.terms.map((term) => ({
@@ -16654,12 +16654,12 @@ function rank(object2, documentation, relationCount, query, focus) {
16654
16654
  score += 7e3;
16655
16655
  signals.push("SYMBOL_CONTAINS");
16656
16656
  } else if (matchedFields.includes("NAME")) signals.push("SYMBOL_CONTAINS");
16657
- if (object2.kind === "FILE" && fileStem(path11) === normalizedQuery) {
16657
+ if (object2.kind === "FILE" && fileStem(path12) === normalizedQuery) {
16658
16658
  score += 11e3;
16659
16659
  signals.push("EXACT_FILE_STEM");
16660
16660
  }
16661
16661
  if (matchedFields.includes("PATH")) {
16662
- score += path11.includes(normalizedQuery) ? 2500 : 0;
16662
+ score += path12.includes(normalizedQuery) ? 2500 : 0;
16663
16663
  signals.push("PATH_CONTAINS");
16664
16664
  }
16665
16665
  if (matchedFields.includes("DOCUMENTATION")) {
@@ -16674,8 +16674,8 @@ function rank(object2, documentation, relationCount, query, focus) {
16674
16674
  score += kindWeight[object2.kind] + Math.min(1200, relationCount * 20) + (focus?.score ?? 0);
16675
16675
  if (declarationKinds.has(object2.kind)) signals.push("DECLARATION");
16676
16676
  if (relationCount > 0) signals.push("GRAPH_CONNECTED");
16677
- const isTest = mapTestPath(path11);
16678
- const isGenerated = generatedPath.test(path11);
16677
+ const isTest = mapTestPath(path12);
16678
+ const isGenerated = generatedPath.test(path12);
16679
16679
  const hasTestIntent = query.terms.some((term) => testQuery.test(term));
16680
16680
  score += isTest ? hasTestIntent ? 1e3 : -5e3 : 300;
16681
16681
  score += isGenerated ? -3e3 : 300;
@@ -17159,13 +17159,13 @@ function utf16Offsets(text) {
17159
17159
  }
17160
17160
  function offsetConverter(files, offsets) {
17161
17161
  const converters = /* @__PURE__ */ new Map();
17162
- return (path11, offset) => {
17163
- let convert = converters.get(path11);
17162
+ return (path12, offset) => {
17163
+ let convert = converters.get(path12);
17164
17164
  if (!convert) {
17165
- const text = files[path11];
17165
+ const text = files[path12];
17166
17166
  if (text === void 0) return invalid();
17167
17167
  convert = offsets === "UTF16" ? (value) => value <= text.length ? value : invalid() : utf16Offsets(text);
17168
- converters.set(path11, convert);
17168
+ converters.set(path12, convert);
17169
17169
  }
17170
17170
  return convert(offset);
17171
17171
  };
@@ -17196,7 +17196,7 @@ function mapFactsAnalysis(facts, input, context) {
17196
17196
  const collect = new MapOutputCollector(output);
17197
17197
  const positions = new MapSourcePositions(input.files);
17198
17198
  const offset = offsetConverter(input.files, context.offsets);
17199
- const anchor = (path11, start, end) => positions.span(path11, offset(path11, start), offset(path11, end));
17199
+ const anchor = (path12, start, end) => positions.span(path12, offset(path12, start), offset(path12, end));
17200
17200
  const located = /* @__PURE__ */ new Map();
17201
17201
  const canonical = /* @__PURE__ */ new Map();
17202
17202
  const bySpan = /* @__PURE__ */ new Map();
@@ -17766,8 +17766,8 @@ var goModule = /(?:^|\/)go\.mod$/u;
17766
17766
  var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
17767
17767
  var GO_MAP_LANGUAGE = Object.freeze({
17768
17768
  id: "go-1.24-map-v9",
17769
- claims: (path11) => path11.endsWith(".go"),
17770
- reads: (path11) => goModule.test(path11),
17769
+ claims: (path12) => path12.endsWith(".go"),
17770
+ reads: (path12) => goModule.test(path12),
17771
17771
  // A module path, or the standard library, whose first path element has no dot.
17772
17772
  importName: (specifier) => {
17773
17773
  const parts = specifier.split("/");
@@ -17776,7 +17776,7 @@ var GO_MAP_LANGUAGE = Object.freeze({
17776
17776
  return parts.slice(0, size).join("/");
17777
17777
  },
17778
17778
  // Go imports a package: the directory of the file.
17779
- importTarget: (path11) => `${path11.slice(0, path11.lastIndexOf("/") + 1) || "./"}`,
17779
+ importTarget: (path12) => `${path12.slice(0, path12.lastIndexOf("/") + 1) || "./"}`,
17780
17780
  create: () => new GoMapAnalyzer()
17781
17781
  });
17782
17782
  var GO_GAPS = [
@@ -17822,12 +17822,12 @@ var GoMapAnalyzer = class {
17822
17822
  }
17823
17823
  }
17824
17824
  async analyze(session, signal) {
17825
- const modules = session.readable.map((entry) => entry.path).filter((path11) => goModule.test(path11)).sort();
17826
- const moduleOf = (path11) => {
17825
+ const modules = session.readable.map((entry) => entry.path).filter((path12) => goModule.test(path12)).sort();
17826
+ const moduleOf = (path12) => {
17827
17827
  let best;
17828
17828
  for (const modFile of modules) {
17829
17829
  const directory = modFile.slice(0, modFile.lastIndexOf("/") + 1);
17830
- if (path11.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
17830
+ if (path12.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
17831
17831
  best = modFile;
17832
17832
  }
17833
17833
  return best;
@@ -17843,11 +17843,11 @@ var GoMapAnalyzer = class {
17843
17843
  for (const modFile of [...groups.keys()].sort()) {
17844
17844
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
17845
17845
  const files = /* @__PURE__ */ Object.create(null);
17846
- for (const path11 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
17847
- const text = session.texts[path11];
17846
+ for (const path12 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
17847
+ const text = session.texts[path12];
17848
17848
  if (text === void 0)
17849
17849
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
17850
- files[path11] = text;
17850
+ files[path12] = text;
17851
17851
  }
17852
17852
  const input = {
17853
17853
  contextRef: digestValue({
@@ -17882,8 +17882,8 @@ var GoMapAnalyzer = class {
17882
17882
  if (text === void 0 || !existsSync2(this.resources.compilerPath))
17883
17883
  throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
17884
17884
  const files = /* @__PURE__ */ Object.create(null);
17885
- for (const [path11, value] of Object.entries(input.files))
17886
- if (this.claims(path11) || goModule.test(path11)) files[path11] = value;
17885
+ for (const [path12, value] of Object.entries(input.files))
17886
+ if (this.claims(path12) || goModule.test(path12)) files[path12] = value;
17887
17887
  const facts = await this.operation(
17888
17888
  {
17889
17889
  ...input,
@@ -17913,14 +17913,14 @@ var BUILD_FILES = [
17913
17913
  "pom.xml"
17914
17914
  ];
17915
17915
  var buildFile = /(?:^|\/)(?:pom\.xml|(?:build|settings)\.gradle(?:\.kts)?)$/u;
17916
- var directoryOf = (path11) => path11.slice(0, path11.lastIndexOf("/") + 1);
17917
- var nameOf = (path11) => path11.slice(path11.lastIndexOf("/") + 1);
17916
+ var directoryOf = (path12) => path12.slice(0, path12.lastIndexOf("/") + 1);
17917
+ var nameOf = (path12) => path12.slice(path12.lastIndexOf("/") + 1);
17918
17918
  var DEFAULT_RELEASE = 21;
17919
17919
  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
17920
  var JAVA_MAP_LANGUAGE = Object.freeze({
17921
17921
  id: "javac-lombok-1.18.48-map-v8",
17922
- claims: (path11) => path11.endsWith(".java"),
17923
- reads: (path11) => buildFile.test(path11),
17922
+ claims: (path12) => path12.endsWith(".java"),
17923
+ reads: (path12) => buildFile.test(path12),
17924
17924
  // A package of the Java platform, or a library named by its first two package segments.
17925
17925
  importName: (specifier) => platformPackage.test(specifier) ? "Java standard library" : specifier.split(".").slice(0, 2).join("."),
17926
17926
  create: () => new JavaMapAnalyzer()
@@ -18010,12 +18010,12 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18010
18010
  // The worker's request for a context: the Java sources, the release and which are tests.
18011
18011
  request(input, buildTexts) {
18012
18012
  const files = /* @__PURE__ */ Object.create(null);
18013
- for (const [path11, text] of Object.entries(input.files))
18014
- if (this.claims(path11)) files[path11] = text;
18013
+ for (const [path12, text] of Object.entries(input.files))
18014
+ if (this.claims(path12)) files[path12] = text;
18015
18015
  return {
18016
18016
  files,
18017
18017
  release: javaRelease(buildTexts, this.resources.runtimeVersion),
18018
- tests: Object.keys(files).filter((path11) => mapTestPath(path11))
18018
+ tests: Object.keys(files).filter((path12) => mapTestPath(path12))
18019
18019
  };
18020
18020
  }
18021
18021
  // The build files of a context's root directory, which declare its Java version.
@@ -18027,35 +18027,35 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18027
18027
  }
18028
18028
  async analyze(session, signal) {
18029
18029
  this.refreshRuntime();
18030
- const builds = session.readable.map((entry) => entry.path).filter((path11) => buildFile.test(path11));
18031
- for (const path11 of builds) session.configuration(path11);
18032
- const rank2 = (path11) => BUILD_FILES.indexOf(nameOf(path11));
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));
18033
18033
  const roots = /* @__PURE__ */ new Map();
18034
18034
  const modules = /* @__PURE__ */ new Map();
18035
- for (const path11 of builds) {
18036
- const directory = directoryOf(path11);
18035
+ for (const path12 of builds) {
18036
+ const directory = directoryOf(path12);
18037
18037
  const current = modules.get(directory);
18038
- if (current === void 0 || rank2(path11) < rank2(current)) modules.set(directory, path11);
18039
- const text = session.texts[path11] ?? "";
18040
- if (/settings\.gradle(?:\.kts)?$/u.test(path11) || path11.endsWith("pom.xml") && /<modules>/u.test(text)) {
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)) {
18041
18041
  const root = roots.get(directory);
18042
- if (root === void 0 || rank2(path11) < rank2(root)) roots.set(directory, path11);
18042
+ if (root === void 0 || rank2(path12) < rank2(root)) roots.set(directory, path12);
18043
18043
  }
18044
18044
  }
18045
- const configOf = (path11) => {
18045
+ const configOf = (path12) => {
18046
18046
  let outer;
18047
18047
  for (const directory of roots.keys())
18048
- if (path11.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
18048
+ if (path12.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
18049
18049
  outer = directory;
18050
18050
  if (outer !== void 0) return roots.get(outer);
18051
18051
  let nearest;
18052
18052
  for (const directory of modules.keys())
18053
- if (path11.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
18053
+ if (path12.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
18054
18054
  nearest = directory;
18055
18055
  return nearest === void 0 ? "" : modules.get(nearest);
18056
18056
  };
18057
- const output = (path11) => [...modules.keys()].some(
18058
- (directory) => path11.startsWith(`${directory}build/`) || path11.startsWith(`${directory}target/`)
18057
+ const output = (path12) => [...modules.keys()].some(
18058
+ (directory) => path12.startsWith(`${directory}build/`) || path12.startsWith(`${directory}target/`)
18059
18059
  );
18060
18060
  const groups = /* @__PURE__ */ new Map();
18061
18061
  for (const entry of session.readable) {
@@ -18070,13 +18070,13 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18070
18070
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
18071
18071
  const files = /* @__PURE__ */ Object.create(null);
18072
18072
  const rootBuilds = configPath ? BUILD_FILES.map((name) => `${directoryOf(configPath)}${name}`).filter(
18073
- (path11) => builds.includes(path11)
18073
+ (path12) => builds.includes(path12)
18074
18074
  ) : [];
18075
- for (const path11 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
18076
- const text = session.texts[path11];
18075
+ for (const path12 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
18076
+ const text = session.texts[path12];
18077
18077
  if (text === void 0)
18078
18078
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18079
- files[path11] = text;
18079
+ files[path12] = text;
18080
18080
  }
18081
18081
  const input = {
18082
18082
  contextRef: digestValue({
@@ -18119,7 +18119,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18119
18119
  const prior = JavaStateSchema.safeParse(previous?.state).data;
18120
18120
  const incremental = previous && prior?.basis === basis ? {
18121
18121
  changed: Object.keys(request.files).filter(
18122
- (path11) => digests.get(path11) !== previous.digests.get(path11)
18122
+ (path12) => digests.get(path12) !== previous.digests.get(path12)
18123
18123
  ),
18124
18124
  state: prior.java
18125
18125
  } : void 0;
@@ -18148,14 +18148,14 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18148
18148
  continue;
18149
18149
  }
18150
18150
  const focus = new Set(facts.focus);
18151
- if (!incremental || facts.focus.some((path11) => !Object.hasOwn(request.files, path11)) || incremental.changed.some((path11) => !focus.has(path11)))
18151
+ if (!incremental || facts.focus.some((path12) => !Object.hasOwn(request.files, path12)) || incremental.changed.some((path12) => !focus.has(path12)))
18152
18152
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18153
18153
  analysis.objects = analysis.objects.filter((object2) => focus.has(object2.anchor.path));
18154
18154
  analysis.relations = analysis.relations.filter((relation) => focus.has(relation.anchor.path));
18155
18155
  analysis.notes = analysis.notes.filter((note) => focus.has(note.anchor.path));
18156
18156
  session.accept(analysis, {
18157
18157
  state,
18158
- linked: analysis.parsedFiles.filter((path11) => !focus.has(path11))
18158
+ linked: analysis.parsedFiles.filter((path12) => !focus.has(path12))
18159
18159
  });
18160
18160
  }
18161
18161
  }
@@ -18467,12 +18467,12 @@ var PYTHON_STANDARD_LIBRARY = /* @__PURE__ */ new Set([
18467
18467
  // src/project-map-language-python.ts
18468
18468
  var CONFIGURATION = ["pyrightconfig.json", "pyproject.toml", "setup.cfg"];
18469
18469
  var pythonConfig = /(?:^|\/)(?:pyrightconfig\.json|pyproject\.toml|setup\.cfg)$/u;
18470
- var directoryOf2 = (path11) => path11.slice(0, path11.lastIndexOf("/") + 1);
18470
+ var directoryOf2 = (path12) => path12.slice(0, path12.lastIndexOf("/") + 1);
18471
18471
  var DEFAULT_PYTHON = { major: 3, minor: 13 };
18472
18472
  var PYTHON_MAP_LANGUAGE = Object.freeze({
18473
18473
  id: "pyright-1.1.414-map-v13",
18474
- claims: (path11) => /\.pyi?$/u.test(path11),
18475
- reads: (path11) => pythonConfig.test(path11),
18474
+ claims: (path12) => /\.pyi?$/u.test(path12),
18475
+ reads: (path12) => pythonConfig.test(path12),
18476
18476
  // An absolute import names the standard library or a distribution's top-level package.
18477
18477
  importName: (specifier) => {
18478
18478
  const top = specifier.split(".", 1)[0] ?? specifier;
@@ -18524,21 +18524,21 @@ var PythonMapAnalyzer = class {
18524
18524
  return {
18525
18525
  root: input.configPath ? directoryOf2(input.configPath).replace(/\/$/u, "") : "",
18526
18526
  pythonVersion: pythonVersion(input.files, input.configPath),
18527
- tests: Object.keys(input.files).filter((path11) => this.claims(path11) && mapTestPath(path11))
18527
+ tests: Object.keys(input.files).filter((path12) => this.claims(path12) && mapTestPath(path12))
18528
18528
  };
18529
18529
  }
18530
18530
  async analyze(session, signal) {
18531
18531
  const roots = /* @__PURE__ */ new Map();
18532
- for (const path11 of session.readable.map((entry) => entry.path).filter((path12) => pythonConfig.test(path12))) {
18533
- const directory = directoryOf2(path11);
18532
+ for (const path12 of session.readable.map((entry) => entry.path).filter((path13) => pythonConfig.test(path13))) {
18533
+ const directory = directoryOf2(path12);
18534
18534
  const current = roots.get(directory);
18535
18535
  const rank2 = (file2) => CONFIGURATION.indexOf(file2.slice(directory.length));
18536
- if (current === void 0 || rank2(path11) < rank2(current)) roots.set(directory, path11);
18536
+ if (current === void 0 || rank2(path12) < rank2(current)) roots.set(directory, path12);
18537
18537
  }
18538
- const rootOf = (path11) => {
18538
+ const rootOf = (path12) => {
18539
18539
  let best;
18540
18540
  for (const directory of roots.keys())
18541
- if (path11.startsWith(directory) && (best === void 0 || directory.length > best.length))
18541
+ if (path12.startsWith(directory) && (best === void 0 || directory.length > best.length))
18542
18542
  best = directory;
18543
18543
  return best === void 0 ? "" : roots.get(best);
18544
18544
  };
@@ -18553,11 +18553,11 @@ var PythonMapAnalyzer = class {
18553
18553
  for (const configPath of [...groups.keys()].sort()) {
18554
18554
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
18555
18555
  const files = /* @__PURE__ */ Object.create(null);
18556
- for (const path11 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
18557
- const text = session.texts[path11];
18556
+ for (const path12 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
18557
+ const text = session.texts[path12];
18558
18558
  if (text === void 0)
18559
18559
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18560
- files[path11] = text;
18560
+ files[path12] = text;
18561
18561
  }
18562
18562
  const input = {
18563
18563
  contextRef: digestValue({
@@ -18605,8 +18605,8 @@ var PythonMapAnalyzer = class {
18605
18605
  if (input.files[reference.targetPath] === void 0)
18606
18606
  throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
18607
18607
  const files = /* @__PURE__ */ Object.create(null);
18608
- for (const [path11, value] of Object.entries(input.files))
18609
- if (this.claims(path11) || pythonConfig.test(path11)) files[path11] = value;
18608
+ for (const [path12, value] of Object.entries(input.files))
18609
+ if (this.claims(path12) || pythonConfig.test(path12)) files[path12] = value;
18610
18610
  const facts = await this.operation(
18611
18611
  {
18612
18612
  ...input,
@@ -18626,8 +18626,8 @@ var PythonMapAnalyzer = class {
18626
18626
  // src/project-map-language-typescript.ts
18627
18627
  var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
18628
18628
  id: "typescript-7.0.2-map-v17",
18629
- claims: (path11) => /\.[cm]?[jt]sx?$/u.test(path11),
18630
- reads: (path11) => path11.endsWith(".json") || path11 === "pnpm-workspace.yaml",
18629
+ claims: (path12) => /\.[cm]?[jt]sx?$/u.test(path12),
18630
+ reads: (path12) => path12.endsWith(".json") || path12 === "pnpm-workspace.yaml",
18631
18631
  create: () => new TypeScriptMapAnalyzer()
18632
18632
  });
18633
18633
  var CONFIGURATIONS_KEPT = 4;
@@ -18739,9 +18739,9 @@ var TypeScriptMapAnalyzer = class {
18739
18739
  accept(analysis);
18740
18740
  return;
18741
18741
  }
18742
- const required2 = analysis.requiredFiles.map((path11) => {
18743
- const entry = byPath.get(path11);
18744
- if (!entry || Object.hasOwn(texts, path11))
18742
+ const required2 = analysis.requiredFiles.map((path12) => {
18743
+ const entry = byPath.get(path12);
18744
+ if (!entry || Object.hasOwn(texts, path12))
18745
18745
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18746
18746
  return entry;
18747
18747
  });
@@ -18799,16 +18799,16 @@ var MAP_LANGUAGES = Object.freeze([
18799
18799
  ]);
18800
18800
  var mapAnalyzerSuite = (languages) => languages.map((language) => language.id).sort().join("+");
18801
18801
  var PROJECT_MAP_ANALYZER = mapAnalyzerSuite(MAP_LANGUAGES);
18802
- var mapCodePath = (path11) => MAP_LANGUAGES.some((language) => language.claims(path11));
18803
- var languageOf = (path11) => MAP_LANGUAGES.find((language) => language.claims(path11));
18804
- var mapLanguageOf = (path11) => languageOf(path11)?.id;
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;
18805
18805
  var npmPackage = (specifier) => {
18806
18806
  if (specifier.startsWith("node:")) return "node:*";
18807
18807
  const parts = specifier.split("/");
18808
18808
  return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? specifier;
18809
18809
  };
18810
18810
  var mapExternalImport = (sourcePath, specifier) => languageOf(sourcePath)?.importName?.(specifier) ?? npmPackage(specifier);
18811
- var mapImportTarget = (path11) => languageOf(path11)?.importTarget?.(path11) ?? path11;
18811
+ var mapImportTarget = (path12) => languageOf(path12)?.importTarget?.(path12) ?? path12;
18812
18812
 
18813
18813
  // src/project-map-view.ts
18814
18814
  var MAP_VIEW_FORMAT = "PROJECT_MAP_VIEW_V1";
@@ -18847,10 +18847,10 @@ var notFound = () => {
18847
18847
  };
18848
18848
  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
18849
  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 = (path11, directory) => directory === "." || path11.startsWith(`${directory}/`);
18851
- var parentDirectory = (path11) => {
18852
- const slash = path11.lastIndexOf("/");
18853
- return slash < 0 ? "." : path11.slice(0, slash);
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);
18854
18854
  };
18855
18855
  var compareText2 = (left, right) => left < right ? -1 : left > right ? 1 : 0;
18856
18856
  var byCount = ([leftName, left], [rightName, right]) => right - left || compareText2(leftName, rightName);
@@ -18924,7 +18924,7 @@ function pageBlocks(view, head, whole, offset, budget) {
18924
18924
  if (offset === blocks.length) return materialize(0);
18925
18925
  return mapQueryPage(blocks.length - offset, materialize, (page) => page, budget);
18926
18926
  }
18927
- var inModule = (path11, module) => module.direct ? parentDirectory(path11) === module.directory : within(path11, module.directory);
18927
+ var inModule = (path12, module) => module.direct ? parentDirectory(path12) === module.directory : within(path12, module.directory);
18928
18928
  var moduleLabel = (module) => module.direct ? `${module.directory === "." ? "" : `${module.directory}/`}* (files directly here)` : `${module.directory}/`;
18929
18929
  function childModules(module, files) {
18930
18930
  if (module.direct) return [];
@@ -19077,12 +19077,12 @@ function loadMemberCalls(store, version2) {
19077
19077
  FROM project_map_relations
19078
19078
  WHERE version_ref = ? AND to_ref IS NULL AND json_extract(relation_json, '$.kind') = 'CALLS'
19079
19079
  AND json_extract(relation_json, '$.unresolvedReason') IN ('SYMBOL_NOT_RESOLVED', 'SYNTAX_ONLY')`).all(version2)) {
19080
- const path11 = String(row.path);
19080
+ const path12 = String(row.path);
19081
19081
  const target = String(row.target);
19082
19082
  const name = MEMBER_NAME.exec(target)?.[1];
19083
- const language = mapLanguageOf(path11);
19083
+ const language = mapLanguageOf(path12);
19084
19084
  if (!name || !language) continue;
19085
- const call = { from: String(row.from_ref), path: path11, line: Number(row.line), target };
19085
+ const call = { from: String(row.from_ref), path: path12, line: Number(row.line), target };
19086
19086
  const key = memberKey(language, name);
19087
19087
  const known = calls.get(key);
19088
19088
  if (known) known.push(call);
@@ -19137,10 +19137,10 @@ function loadCoverageNotes(store, version2) {
19137
19137
  if (!codes.includes(gap.code)) codes.push(gap.code);
19138
19138
  files.set(gap.path, codes);
19139
19139
  }
19140
- for (const [path11, codes] of files)
19140
+ for (const [path12, codes] of files)
19141
19141
  if (codes.length > 1 && codes.includes("NOT_IN_PARSED_CONTEXT"))
19142
19142
  files.set(
19143
- path11,
19143
+ path12,
19144
19144
  codes.filter((code) => code !== "NOT_IN_PARSED_CONTEXT")
19145
19145
  );
19146
19146
  return { files, limits: [...limits] };
@@ -19175,9 +19175,9 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19175
19175
  const visiblePaths = new Set(visible.map((entry) => entry.path));
19176
19176
  const code = visible.filter((entry) => entry.state === "TEXT" && mapCodePath(entry.path)).map((entry) => entry.path);
19177
19177
  const modules = mapModules(directory, code);
19178
- const moduleOf = (path11) => modules.find((module) => inModule(path11, module));
19179
- const outside = (path11) => {
19180
- const parts = path11.split("/");
19178
+ const moduleOf = (path12) => modules.find((module) => inModule(path12, module));
19179
+ const outside = (path12) => {
19180
+ const parts = path12.split("/");
19181
19181
  return `${parts.slice(0, Math.min(2, parts.length - 1)).join("/") || "."}/ (outside)`;
19182
19182
  };
19183
19183
  const moduleImports = /* @__PURE__ */ new Map();
@@ -19202,8 +19202,8 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19202
19202
  const blocks = [];
19203
19203
  if (modules.length > 1) {
19204
19204
  const sizes = /* @__PURE__ */ new Map();
19205
- for (const path11 of code) {
19206
- const module = moduleOf(path11);
19205
+ for (const path12 of code) {
19206
+ const module = moduleOf(path12);
19207
19207
  if (module) increment(sizes, moduleLabel(module));
19208
19208
  }
19209
19209
  blocks.push(
@@ -19232,18 +19232,18 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19232
19232
  )}${packages.length > shown.length ? `, +${packages.length - shown.length} more` : ""}`
19233
19233
  );
19234
19234
  }
19235
- const lineCount = (path11) => {
19236
- const file2 = facts.files.get(path11);
19237
- const gaps = coverage.files.get(path11) ?? [];
19235
+ const lineCount = (path12) => {
19236
+ const file2 = facts.files.get(path12);
19237
+ const gaps = coverage.files.get(path12) ?? [];
19238
19238
  if (file2?.parsed === false) return `[not parsed${gaps.length ? `: ${gaps.join("; ")}` : ""}]`;
19239
19239
  return `${file2 ? `${file2.lines}L` : "?L"}${gaps.length ? ` [${gaps.join("; ")}]` : ""}`;
19240
19240
  };
19241
19241
  const codeDirectories = /* @__PURE__ */ new Set();
19242
- for (const path11 of code)
19243
- for (let parent = parentDirectory(path11); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
19242
+ for (const path12 of code)
19243
+ for (let parent = parentDirectory(path12); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
19244
19244
  codeDirectories.add(parent);
19245
- const groupOf = (path11) => {
19246
- let group = parentDirectory(path11);
19245
+ const groupOf = (path12) => {
19246
+ let group = parentDirectory(path12);
19247
19247
  for (let parent = group; parent !== "." && parent !== directory && !codeDirectories.has(parent); parent = parentDirectory(parent))
19248
19248
  group = parent;
19249
19249
  return group;
@@ -19275,11 +19275,11 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19275
19275
  ]);
19276
19276
  }
19277
19277
  const detailed = [
19278
- ...code.map((path11) => {
19279
- const declarations = (facts.exported.get(path11) ?? []).map(({ text: text2 }) => text2);
19278
+ ...code.map((path12) => {
19279
+ const declarations = (facts.exported.get(path12) ?? []).map(({ text: text2 }) => text2);
19280
19280
  return [
19281
- path11,
19282
- `${path11} ${lineCount(path11)}${declarations.length ? `: ${declarations.join(", ")}` : ""}`
19281
+ path12,
19282
+ `${path12} ${lineCount(path12)}${declarations.length ? `: ${declarations.join(", ")}` : ""}`
19283
19283
  ];
19284
19284
  }),
19285
19285
  ...listedOther.map((entry) => [
@@ -19290,7 +19290,7 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19290
19290
  ];
19291
19291
  const directories = /* @__PURE__ */ new Map();
19292
19292
  for (const entry of [
19293
- ...code.map((path11) => ({ path: path11, item: lineCount(path11) })),
19293
+ ...code.map((path12) => ({ path: path12, item: lineCount(path12) })),
19294
19294
  ...listedOther.map((entry2) => ({
19295
19295
  path: entry2.path,
19296
19296
  item: entry2.state === "TEXT" ? "" : `(${entry2.state})`
@@ -19318,10 +19318,10 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19318
19318
  );
19319
19319
  const text = visible.filter((entry) => entry.state === "TEXT").length;
19320
19320
  const resolution = /* @__PURE__ */ new Map();
19321
- for (const path11 of code) {
19322
- const counts = facts.calls.get(path11);
19321
+ for (const path12 of code) {
19322
+ const counts = facts.calls.get(path12);
19323
19323
  if (!counts) continue;
19324
- const language = facts.files.get(path11)?.language ?? "unknown";
19324
+ const language = facts.files.get(path12)?.language ?? "unknown";
19325
19325
  const total = resolution.get(language) ?? { resolved: 0, unresolved: 0, external: 0 };
19326
19326
  total.resolved += counts.resolved;
19327
19327
  total.unresolved += counts.unresolved;
@@ -19379,8 +19379,8 @@ var DeclarationGroups = class {
19379
19379
  prefixes;
19380
19380
  showTests;
19381
19381
  memberCalls;
19382
- visible(path11) {
19383
- return mapPathAllowed(path11, this.prefixes) && (this.showTests || !mapTestPath(path11));
19382
+ visible(path12) {
19383
+ return mapPathAllowed(path12, this.prefixes) && (this.showTests || !mapTestPath(path12));
19384
19384
  }
19385
19385
  entry(object2, imported = false) {
19386
19386
  if (mapIsModule(object2)) return imported ? "(file)" : "(module scope)";
@@ -19424,11 +19424,11 @@ var DeclarationGroups = class {
19424
19424
  value.lines.push(line);
19425
19425
  aggregates.set(key, value);
19426
19426
  };
19427
- const dispatch = (arrow, label, ref2, path11, line) => {
19427
+ const dispatch = (arrow, label, ref2, path12, line) => {
19428
19428
  const other = graph.object(graph.owner(ref2));
19429
19429
  if (owned.has(other.id)) return;
19430
- if (!this.visible(path11)) {
19431
- if (mapPathAllowed(path11, this.prefixes)) omittedTests++;
19430
+ if (!this.visible(path12)) {
19431
+ if (mapPathAllowed(path12, this.prefixes)) omittedTests++;
19432
19432
  return;
19433
19433
  }
19434
19434
  add(arrow, label, other, line);
@@ -19585,7 +19585,7 @@ var DeclarationGroups = class {
19585
19585
  else files2.set(call.path, [item]);
19586
19586
  }
19587
19587
  lines.push(
19588
- ` \u2190 possible callers by name: ${[...files2].map(([path11, items]) => `${path11}: ${items.join(", ")}`).join("; ")}${inTests}`
19588
+ ` \u2190 possible callers by name: ${[...files2].map(([path12, items]) => `${path12}: ${items.join(", ")}`).join("; ")}${inTests}`
19589
19589
  );
19590
19590
  } else if (possibleInTests)
19591
19591
  lines.push(` \u2190 possible callers by name: ${possibleInTests} in test files (includeTests)`);
@@ -19621,14 +19621,14 @@ var DeclarationGroups = class {
19621
19621
  return { lines, neighbors: [...new Set(neighbors)] };
19622
19622
  }
19623
19623
  };
19624
- function fileView(store, coverage, graph, input, path11, prefixes) {
19625
- const entry = store.getEntry(input.version, path11);
19626
- if (!entry || !mapPathAllowed(path11, prefixes)) return notFound();
19627
- const showTests = input.includeTests === true || mapTestPath(path11);
19628
- const module = mapCodePath(path11) ? graph.objectsAt(path11).find((object2) => mapIsModule(object2)) : void 0;
19629
- const gaps = coverage.files.get(path11) ?? [];
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) ?? [];
19630
19630
  const head = [
19631
- `PROJECT MAP \xB7 FILE ${path11} \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`}`
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`}`
19632
19632
  ];
19633
19633
  if (!module || entry.state !== "TEXT")
19634
19634
  return pageBlocks("FILE", head, [], input.offset ?? 0, input.outputBudget);
@@ -19648,7 +19648,7 @@ function fileView(store, coverage, graph, input, path11, prefixes) {
19648
19648
  tags.set(relation.from, list);
19649
19649
  }
19650
19650
  const describe3 = (object2) => [
19651
- `${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path11 ? "" : ` (${object2.anchor.path})`}`,
19651
+ `${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path12 ? "" : ` (${object2.anchor.path})`}`,
19652
19652
  ...tags.get(object2.id) ?? []
19653
19653
  ].join(" ");
19654
19654
  const declarations = [];
@@ -19663,11 +19663,11 @@ function fileView(store, coverage, graph, input, path11, prefixes) {
19663
19663
  );
19664
19664
  }
19665
19665
  const elsewhere = /* @__PURE__ */ new Map();
19666
- for (const object2 of graph.objectsAt(path11)) {
19666
+ for (const object2 of graph.objectsAt(path12)) {
19667
19667
  const parent = mapIsModule(object2) ? void 0 : graph.parent(object2.id);
19668
19668
  if (parent === void 0 || !graph.isAddressable(object2)) continue;
19669
19669
  const container = graph.object(parent);
19670
- if (mapIsModule(container) || container.anchor.path === path11) continue;
19670
+ if (mapIsModule(container) || container.anchor.path === path12) continue;
19671
19671
  const into = elsewhere.get(parent);
19672
19672
  if (into) into.push(object2);
19673
19673
  else elsewhere.set(parent, [object2]);
@@ -19681,7 +19681,7 @@ function fileView(store, coverage, graph, input, path11, prefixes) {
19681
19681
  if (declarations.length) blocks.push(["DECLARATIONS (* exported)", ...declarations].join("\n"));
19682
19682
  const imports = /* @__PURE__ */ new Set();
19683
19683
  const external = /* @__PURE__ */ new Set();
19684
- const fileObjects = graph.objectsAt(path11).map((object2) => object2.id);
19684
+ const fileObjects = graph.objectsAt(path12).map((object2) => object2.id);
19685
19685
  for (const relation of graph.relationsFrom(fileObjects)) {
19686
19686
  if (!IMPORT_KINDS.has(relation.kind)) continue;
19687
19687
  if (relation.to === void 0) external.add(relation.target);
@@ -19692,8 +19692,8 @@ function fileView(store, coverage, graph, input, path11, prefixes) {
19692
19692
  }
19693
19693
  const importers = /* @__PURE__ */ new Set();
19694
19694
  const testImporters = /* @__PURE__ */ new Set();
19695
- const imported = mapImportTarget(path11);
19696
- const packageModules = imported === path11 ? [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);
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);
19697
19697
  for (const relation of graph.relationsTo(packageModules)) {
19698
19698
  if (!IMPORT_KINDS.has(relation.kind)) continue;
19699
19699
  const source = relation.anchor.path;
@@ -19721,16 +19721,16 @@ function fileView(store, coverage, graph, input, path11, prefixes) {
19721
19721
  if (scope.length) blocks.push(["MODULE SCOPE (top-level statements)", ...scope].join("\n"));
19722
19722
  return pageBlocks("FILE", head, blocks, input.offset ?? 0, input.outputBudget);
19723
19723
  }
19724
- function declarationView(graph, input, path11, prefixes, memberCalls) {
19724
+ function declarationView(graph, input, path12, prefixes, memberCalls) {
19725
19725
  const requested = input.depth ?? 1;
19726
19726
  if (!Number.isSafeInteger(requested) || requested < 1 || requested > MAP_VIEW_LIMITS.directedDepth)
19727
19727
  return invalid2();
19728
19728
  const both = (input.direction ?? "BOTH") === "BOTH";
19729
19729
  const depth = both ? Math.min(requested, MAP_VIEW_LIMITS.bothDepth) : requested;
19730
19730
  const { name, line } = input;
19731
- const selected = mapSelectDeclarations(graph, path11, name, line);
19731
+ const selected = mapSelectDeclarations(graph, path12, name, line);
19732
19732
  if (!selected.length) return notFound();
19733
- const showTests = input.includeTests === true || mapTestPath(path11);
19733
+ const showTests = input.includeTests === true || mapTestPath(path12);
19734
19734
  const groups = new DeclarationGroups(graph, input, prefixes, showTests, memberCalls);
19735
19735
  const blocks = [];
19736
19736
  const seen = /* @__PURE__ */ new Set();
@@ -19778,7 +19778,7 @@ function declarationView(graph, input, path11, prefixes, memberCalls) {
19778
19778
  );
19779
19779
  }
19780
19780
  const head = [
19781
- `PROJECT MAP \xB7 DECLARATION ${path11}${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"}`,
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"}`,
19782
19782
  ...truncated ? [`Expansion stopped at ${MAP_VIEW_LIMITS.declarations} declarations.`] : [],
19783
19783
  ...(input.direction ?? "BOTH") === "OUTGOING" ? [] : [callerCoverage(input.textSearch ?? DEFAULT_TEXT_SEARCH)]
19784
19784
  ];
@@ -19905,10 +19905,10 @@ var ProjectMapQuery = class {
19905
19905
  view(input, signal) {
19906
19906
  this.requireReadableMap(input.version, signal);
19907
19907
  const { offset, prefixes } = admission(input);
19908
- const path11 = normalizeProjectEvidencePath(input.path, true) || ".";
19908
+ const path12 = normalizeProjectEvidencePath(input.path, true) || ".";
19909
19909
  const view = mapView(
19910
19910
  this.store,
19911
- { ...input, path: path11, offset, allowedPathPrefixes: prefixes },
19911
+ { ...input, path: path12, offset, allowedPathPrefixes: prefixes },
19912
19912
  this.views
19913
19913
  );
19914
19914
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
@@ -20813,7 +20813,7 @@ var CodeIndexStore = class {
20813
20813
  const staged = this.stageUnits(buildRef, paths, linked);
20814
20814
  const reused = linked ? this.database.prepare(`SELECT path, unit_ref FROM project_map_version_units
20815
20815
  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: path11 }) => !paths.has(path11)) || staged.some(({ path: path11 }) => linked?.paths.has(path11)))
20816
+ if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path: path12 }) => !paths.has(path12)) || staged.some(({ path: path12 }) => linked?.paths.has(path12)))
20817
20817
  throw new MapReplayConflict();
20818
20818
  const units = [...staged, ...reused].sort(
20819
20819
  (left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
@@ -20864,7 +20864,7 @@ var CodeIndexStore = class {
20864
20864
  const member = this.database.prepare(
20865
20865
  "INSERT INTO project_map_version_units VALUES (?, ?, ?)"
20866
20866
  );
20867
- for (const { path: path11, unit } of reused) member.run(version2.version, path11, unit);
20867
+ for (const { path: path12, unit } of reused) member.run(version2.version, path12, unit);
20868
20868
  this.database.prepare("INSERT INTO project_map_coverage VALUES (?, ?)").run(version2.version, canonicalJson(coverage));
20869
20869
  }
20870
20870
  this.database.exec("COMMIT");
@@ -20928,7 +20928,7 @@ var CodeIndexStore = class {
20928
20928
  corrupt2();
20929
20929
  }
20930
20930
  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((path11) => !linked.paths.has(path11));
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));
20932
20932
  if (database.prepare(`SELECT 1 FROM project_map_objects gone
20933
20933
  WHERE gone.version_ref = ? AND gone.path IN (SELECT value FROM json_each(?))
20934
20934
  AND gone.entity_ref NOT IN (SELECT entity_ref FROM project_map_publish_objects)
@@ -20953,17 +20953,17 @@ var CodeIndexStore = class {
20953
20953
  const units = [];
20954
20954
  for (const row of database.prepare(`SELECT path FROM project_map_publish_objects
20955
20955
  UNION SELECT path FROM project_map_publish_relations ORDER BY path`).all()) {
20956
- const path11 = String(row.path);
20957
- const hash2 = createHash3("sha256").update(path11).update("\0");
20956
+ const path12 = String(row.path);
20957
+ const hash2 = createHash3("sha256").update(path12).update("\0");
20958
20958
  for (const [mark, statement] of [
20959
20959
  ["object", objects2],
20960
20960
  ["relation", relations],
20961
20961
  ["note", pathNotes]
20962
20962
  ])
20963
- for (const fact of statement.all(path11))
20963
+ for (const fact of statement.all(path12))
20964
20964
  for (const value of Object.values(fact))
20965
20965
  hash2.update(mark).update("\0").update(String(value)).update("\0");
20966
- units.push({ path: path11, unit: hash2.digest("hex") });
20966
+ units.push({ path: path12, unit: hash2.digest("hex") });
20967
20967
  }
20968
20968
  return units;
20969
20969
  }
@@ -20981,13 +20981,13 @@ var CodeIndexStore = class {
20981
20981
  "INSERT INTO project_map_unit_notes SELECT ?, * FROM project_map_publish_notes WHERE path = ?"
20982
20982
  );
20983
20983
  const member = database.prepare("INSERT INTO project_map_version_units VALUES (?, ?, ?)");
20984
- for (const { path: path11, unit } of units) {
20985
- if (insertUnit.run(unit, path11).changes) {
20986
- unitObjects.run(unit, path11);
20987
- unitRelations.run(unit, path11);
20988
- unitNotes.run(unit, path11);
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);
20989
20989
  }
20990
- member.run(version2, path11, unit);
20990
+ member.run(version2, path12, unit);
20991
20991
  }
20992
20992
  }
20993
20993
  /** Earlier versions of a project's scope built by the same analyzer, most recent first. */
@@ -21228,21 +21228,21 @@ var contextFiles = (context) => [
21228
21228
  function replayableContexts(parent, digests) {
21229
21229
  const sharing = /* @__PURE__ */ new Map();
21230
21230
  for (const [ref, { context }] of parent.contexts)
21231
- for (const path11 of contextFiles(context)) {
21232
- const refs = sharing.get(path11) ?? /* @__PURE__ */ new Set();
21231
+ for (const path12 of contextFiles(context)) {
21232
+ const refs = sharing.get(path12) ?? /* @__PURE__ */ new Set();
21233
21233
  refs.add(ref);
21234
- sharing.set(path11, refs);
21234
+ sharing.set(path12, refs);
21235
21235
  }
21236
21236
  const unchanged = /* @__PURE__ */ new Set();
21237
21237
  for (const [ref, { context }] of parent.contexts)
21238
21238
  if (contextFiles(context).every(
21239
- (path11) => digests.get(path11) !== void 0 && digests.get(path11) === parent.entries.get(path11)
21239
+ (path12) => digests.get(path12) !== void 0 && digests.get(path12) === parent.entries.get(path12)
21240
21240
  ))
21241
21241
  unchanged.add(ref);
21242
21242
  const replayable = /* @__PURE__ */ new Set();
21243
21243
  for (const [ref, { context }] of parent.contexts)
21244
21244
  if (unchanged.has(ref) && contextFiles(context).every(
21245
- (path11) => [...sharing.get(path11) ?? []].every((other) => unchanged.has(other))
21245
+ (path12) => [...sharing.get(path12) ?? []].every((other) => unchanged.has(other))
21246
21246
  ))
21247
21247
  replayable.add(ref);
21248
21248
  return { replayable, sharing };
@@ -21275,8 +21275,8 @@ var ProjectMapAnalyzer = class {
21275
21275
  languages;
21276
21276
  observe;
21277
21277
  id;
21278
- claims(path11) {
21279
- return this.languages.some((language) => language.claims(path11));
21278
+ claims(path12) {
21279
+ return this.languages.some((language) => language.claims(path12));
21280
21280
  }
21281
21281
  references(input, reference, signal) {
21282
21282
  const language = this.languages.find((language2) => language2.claims(reference.targetPath));
@@ -21316,7 +21316,7 @@ var ProjectMapAnalyzer = class {
21316
21316
  const reuse = (contextRef2, request, files2) => {
21317
21317
  const digest = digestValue({
21318
21318
  request,
21319
- files: files2.map((path11) => [path11, digests.get(path11) ?? null])
21319
+ files: files2.map((path12) => [path12, digests.get(path12) ?? null])
21320
21320
  });
21321
21321
  requests.set(contextRef2, digest);
21322
21322
  if (!parent || !replayable.has(contextRef2)) return void 0;
@@ -21356,7 +21356,7 @@ var ProjectMapAnalyzer = class {
21356
21356
  const ref = analysis.contexts[0]?.ref ?? "";
21357
21357
  if (options?.linked?.length) {
21358
21358
  if (!parent || analysis.contexts.length !== 1) return invalidParent();
21359
- for (const path11 of options.linked) linked.add(path11);
21359
+ for (const path12 of options.linked) linked.add(path12);
21360
21360
  this.observe?.({
21361
21361
  operation: "LINK",
21362
21362
  phase: "FINISHED",
@@ -21383,7 +21383,7 @@ var ProjectMapAnalyzer = class {
21383
21383
  });
21384
21384
  for (const file2 of analysis.parsedFiles) parsed.add(file2);
21385
21385
  const staged = factPaths(analysis);
21386
- for (const path11 of staged) stagedPaths.add(path11);
21386
+ for (const path12 of staged) stagedPaths.add(path12);
21387
21387
  for (const context of analysis.contexts) {
21388
21388
  for (const file2 of context.configurationFiles) configurationInputs.add(file2);
21389
21389
  if (!replayed.has(context.ref))
@@ -21412,7 +21412,7 @@ var ProjectMapAnalyzer = class {
21412
21412
  accept,
21413
21413
  reuse,
21414
21414
  previous,
21415
- configuration: (path11) => configurationInputs.add(path11),
21415
+ configuration: (path12) => configurationInputs.add(path12),
21416
21416
  observe: this.observe
21417
21417
  },
21418
21418
  signal
@@ -21449,12 +21449,12 @@ var ProjectMapAnalyzer = class {
21449
21449
  if (files.objects.length) accept(files);
21450
21450
  if (parent && (replayed.size || linked.size)) {
21451
21451
  for (const ref of replayed.keys())
21452
- for (const path11 of contextFiles(parent.contexts.get(ref)?.context ?? invalidParent()))
21453
- if (analyzedFiles.has(path11) || [...sharing.get(path11) ?? []].some((other) => !replayed.has(other)))
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)))
21454
21454
  throw new MapReplayConflict();
21455
- for (const paths of replayed.values()) for (const path11 of paths) linked.add(path11);
21456
- for (const path11 of linked)
21457
- if (analyzedFiles.has(path11) || stagedPaths.has(path11)) 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();
21458
21458
  parent.link([...linked]);
21459
21459
  }
21460
21460
  result.parsedFiles = [...parsed].sort();
@@ -21744,8 +21744,8 @@ var CodeIndex = class {
21744
21744
  for (const entry of this.store.listEntries(candidate))
21745
21745
  if (entry.contentDigest) entries2.set(entry.path, entry.contentDigest);
21746
21746
  let changed = 0;
21747
- for (const [path11, digest] of digests) if (entries2.get(path11) !== digest) changed++;
21748
- for (const path11 of entries2.keys()) if (!digests.has(path11)) changed++;
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++;
21749
21749
  if (!best || changed < best.changed) best = { version: candidate, entries: entries2, changed };
21750
21750
  }
21751
21751
  if (!best) return void 0;
@@ -21884,8 +21884,157 @@ var CodeIndex = class {
21884
21884
  };
21885
21885
 
21886
21886
  // src/project-map-changes.ts
21887
+ import { readFileSync as readFileSync3 } from "node:fs";
21888
+ import path8 from "node:path";
21889
+
21890
+ // src/project-map-names.ts
21887
21891
  import { readFileSync as readFileSync2 } from "node:fs";
21888
21892
  import path7 from "node:path";
21893
+ var CONFIG_KEY = /^\s*(?:export\s+|-\s+)?["']?([A-Za-z_][\w.-]*)["']?\s*(?:=|:(?:\s|$))/u;
21894
+ var CODE_READS = [
21895
+ // process.env.NAME, import.meta.env.NAME
21896
+ /\benv\.([A-Za-z_]\w*)/gu,
21897
+ // getenv("NAME"), os.Getenv, os.LookupEnv, System.getProperty, env("NAME")
21898
+ /\b(?:getenv|Getenv|LookupEnv|setenv|Setenv|getProperty|env)\s*\(\s*["'`]([^"'`\s]+)["'`]/gu,
21899
+ // os.environ["NAME"], os.environ.get("NAME"), config.get("key"), settings["key"], viper.GetString("key")
21900
+ /\b(?:environ|env|conf|config|cfg|settings|viper)\w*(?:\s*\.\s*\w+)?\s*(?:<[^<>()]*>)?\s*[[(]\s*["'`]([^"'`\s]+)["'`]/giu,
21901
+ // "LOG_LEVEL": a quoted name spelled as an environment variable, as option tables keep them
21902
+ /["'`]([A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+)["'`]/gu
21903
+ ];
21904
+ var PLACEHOLDER = /\$\{([A-Za-z_][\w.-]*)/gu;
21905
+ var PYTHON_FIELD = /^\s+([A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+)\s*:/gu;
21906
+ var NAME = /^[A-Za-z_][\w.-]+[A-Za-z0-9]$/u;
21907
+ var UPPER = /^[A-Z][A-Z0-9_]*$/u;
21908
+ 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
+ var HISTORY = /(?:^|\/)(?:CHANGELOG|CHANGES|HISTORY|NEWS|RELEASES?|release[-_ ]?notes)[^/]*$/iu;
21910
+ var LIMIT = Object.freeze({ names: 50, mentions: 5 });
21911
+ var literal2 = (text) => text.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
21912
+ var wholeName = (name) => new RegExp(`(?<![\\w-])${literal2(name)}(?![\\w-])`, "u");
21913
+ var quotedName = (name) => new RegExp(
21914
+ `["'\`]${literal2(name)}["'\`]|\\benv\\.${literal2(name)}\\b|\\$\\{${literal2(name)}[}:]`,
21915
+ "u"
21916
+ );
21917
+ function codeReads(line, file2) {
21918
+ const names = /* @__PURE__ */ new Set();
21919
+ const extra = file2.endsWith(".java") ? [PLACEHOLDER] : file2.endsWith(".py") ? [PYTHON_FIELD] : [];
21920
+ for (const pattern of [...CODE_READS, ...extra])
21921
+ for (const match of line.matchAll(pattern)) if (match[1]) names.add(match[1]);
21922
+ return names;
21923
+ }
21924
+ function diffLines(diff) {
21925
+ const removed = /* @__PURE__ */ new Map();
21926
+ const added = /* @__PURE__ */ new Map();
21927
+ let gone;
21928
+ let fresh;
21929
+ let inHunk = false;
21930
+ let line = 0;
21931
+ for (const text of diff.split("\n")) {
21932
+ if (text.startsWith("diff --git ")) {
21933
+ const match = /^diff --git a\/(.+) b\/(.+)$/u.exec(text);
21934
+ gone = [];
21935
+ fresh = /* @__PURE__ */ new Set();
21936
+ if (match?.[1] && !match[1].startsWith('"')) removed.set(match[1], gone);
21937
+ if (match?.[2] && !match[2].startsWith('"')) added.set(match[2], fresh);
21938
+ inHunk = false;
21939
+ } else if (text.startsWith("rename from ") && gone)
21940
+ removed.set(text.slice("rename from ".length), gone);
21941
+ else if (text.startsWith("rename to ") && fresh)
21942
+ added.set(text.slice("rename to ".length), fresh);
21943
+ else if (text.startsWith("@@ ")) {
21944
+ inHunk = true;
21945
+ line = Number(/\+(\d+)/u.exec(text)?.[1] ?? 0);
21946
+ } else if (inHunk && text.startsWith("-")) gone?.push(text.slice(1));
21947
+ else if (inHunk && text.startsWith("+")) fresh?.add(line++);
21948
+ }
21949
+ return { removed, added };
21950
+ }
21951
+ async function strandedNames(project, diff, files, configuration, git2, options) {
21952
+ const { removed, added } = diffLines(diff);
21953
+ const from = /* @__PURE__ */ new Map();
21954
+ for (const file2 of files) {
21955
+ const lines = file2.basePath === void 0 ? void 0 : removed.get(file2.basePath);
21956
+ if (!lines?.length || file2.status === "DELETED" || mapTestPath(file2.path)) continue;
21957
+ const config2 = configuration(file2.path);
21958
+ if (!config2 && !mapLanguageOf(file2.path)) continue;
21959
+ const names2 = /* @__PURE__ */ new Set();
21960
+ for (const line of lines)
21961
+ if (config2) {
21962
+ const key = CONFIG_KEY.exec(line)?.[1];
21963
+ if (key) names2.add(key);
21964
+ for (const match of line.matchAll(PLACEHOLDER)) if (match[1]) names2.add(match[1]);
21965
+ } else for (const name of codeReads(line, file2.path)) names2.add(name);
21966
+ let text;
21967
+ try {
21968
+ text = readFileSync2(path7.join(project, file2.path), "utf8");
21969
+ } catch {
21970
+ continue;
21971
+ }
21972
+ for (const name of names2)
21973
+ if (NAME.test(name) && !PLATFORM.test(name) && !from.has(name) && !wholeName(name).test(text))
21974
+ from.set(name, { path: file2.path, code: !config2 });
21975
+ }
21976
+ const names = [...from.keys()].slice(0, LIMIT.names);
21977
+ if (!names.length) return [];
21978
+ const patterns = new Map(
21979
+ names.map((name) => [name, { whole: wholeName(name), quoted: quotedName(name) }])
21980
+ );
21981
+ let found;
21982
+ try {
21983
+ found = (await git2.run(
21984
+ [
21985
+ "grep",
21986
+ "-n",
21987
+ "-I",
21988
+ "-w",
21989
+ "-F",
21990
+ "--untracked",
21991
+ "--full-name",
21992
+ "--no-color",
21993
+ ...names.flatMap((name) => ["-e", name]),
21994
+ "--",
21995
+ "."
21996
+ ],
21997
+ options
21998
+ )).stdout.toString("utf8");
21999
+ } catch (error51) {
22000
+ if (error51 instanceof GitCommandError && !options.signal?.aborted) return [];
22001
+ throw error51;
22002
+ }
22003
+ const untracked = new Set(
22004
+ files.filter((file2) => file2.status === "ADDED" && !added.has(file2.path)).map((file2) => file2.path)
22005
+ );
22006
+ const moved = /* @__PURE__ */ new Set();
22007
+ const mentions = /* @__PURE__ */ new Map();
22008
+ for (const hit of found.split("\n")) {
22009
+ const match = /^(.+?):(\d+):(.*)$/u.exec(hit);
22010
+ if (!match) continue;
22011
+ const [, file2 = "", number4 = "", line = ""] = match;
22012
+ if (HISTORY.test(file2)) continue;
22013
+ const at = Number(number4);
22014
+ const code = mapLanguageOf(file2) !== void 0;
22015
+ const reads = code ? codeReads(line, file2) : void 0;
22016
+ const key = configuration(file2) ? CONFIG_KEY.exec(line)?.[1] : void 0;
22017
+ for (const name of names) {
22018
+ const source = from.get(name);
22019
+ const pattern = patterns.get(name);
22020
+ if (!source || !pattern || file2 === source.path || !pattern.whole.test(line)) continue;
22021
+ if (untracked.has(file2) || added.get(file2)?.has(at)) {
22022
+ moved.add(name);
22023
+ continue;
22024
+ }
22025
+ const uses = UPPER.test(name) ? !reads || reads.has(name) || pattern.quoted.test(line) : reads ? reads.has(name) : source.code && /[_.-]/u.test(name) && key === name;
22026
+ if (uses) mentions.set(name, [...mentions.get(name) ?? [], `${file2}:${at}`]);
22027
+ }
22028
+ }
22029
+ return names.filter((name) => !moved.has(name) && mentions.has(name)).map((name) => ({
22030
+ name,
22031
+ from: from.get(name)?.path ?? "",
22032
+ mentions: mentions.get(name) ?? []
22033
+ }));
22034
+ }
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` : ""}`;
22036
+
22037
+ // src/project-map-changes.ts
21889
22038
  var git = new GitRunner();
21890
22039
  var gitOptions = (cwd, signal) => ({
21891
22040
  cwd,
@@ -21937,9 +22086,17 @@ async function readMapChanges(project, base, signal) {
21937
22086
  baseText: (await git.run(["show", `${commit}:${file2.basePath}`], gitOptions(project, signal))).stdout.toString("utf8")
21938
22087
  };
21939
22088
  const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter(Boolean);
21940
- for (const path11 of untracked)
21941
- files.push({ path: path11, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
21942
- return { base, commit, files };
22089
+ for (const path12 of untracked)
22090
+ files.push({ path: path12, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
22091
+ const stranded = await strandedNames(
22092
+ project,
22093
+ diff,
22094
+ files,
22095
+ (file2) => nonCodeKind(file2) === "configuration",
22096
+ git,
22097
+ gitOptions(project, signal)
22098
+ );
22099
+ return { base, commit, files, stranded };
21943
22100
  }
21944
22101
  function parseMapDiff(text) {
21945
22102
  const files = [];
@@ -22008,7 +22165,7 @@ var NON_CODE = [
22008
22165
  [/(?:^|\/)\.env[^/]*$|\.(?:ya?ml|toml|ini|properties|conf|cfg)$/iu, "configuration"],
22009
22166
  [/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte)$/iu, "template"]
22010
22167
  ];
22011
- var nonCodeKind = (path11) => NON_CODE.find(([pattern]) => pattern.test(path11))?.[1];
22168
+ var nonCodeKind = (path12) => NON_CODE.find(([pattern]) => pattern.test(path12))?.[1];
22012
22169
  var LIMITS = Object.freeze({ depth: 8, declarations: 800, changed: 200, chain: 3, byName: 40 });
22013
22170
  var CALLER_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES"]);
22014
22171
  var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
@@ -22203,12 +22360,12 @@ var Tracer = class {
22203
22360
  this.areas.set(area, known);
22204
22361
  }
22205
22362
  /** A related test file; the closest relation (lowest rank) explains it. */
22206
- test(path11, name, why, rank2) {
22207
- if (!mapRunnableTest(path11)) return;
22208
- const known = this.tests.get(path11) ?? { names: /* @__PURE__ */ new Set(), why, rank: rank2 };
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 };
22209
22366
  if (rank2 < known.rank) Object.assign(known, { why, rank: rank2 });
22210
22367
  if (name && !name.startsWith("<")) known.names.add(name);
22211
- this.tests.set(path11, known);
22368
+ this.tests.set(path12, known);
22212
22369
  }
22213
22370
  };
22214
22371
  var mapRunnableTest = (file2) => /_test\.(?:go|py)$|(?:^|\/)test_[^/]*\.py$|\.(?:test|spec)\.[cm]?[jt]sx?$|(?:Test|Tests|IT)\.(?:java|kt)$/u.test(
@@ -22221,7 +22378,7 @@ function mapChangeImpact(store, working, base, changes, project) {
22221
22378
  const changed = [];
22222
22379
  const unclear = [];
22223
22380
  const removed = [];
22224
- const declarations = (g, path11) => g.objectsAt(path11).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
22381
+ const declarations = (g, path12) => g.objectsAt(path12).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
22225
22382
  let changedCount = 0;
22226
22383
  const starts = [];
22227
22384
  for (const file2 of changes.files) {
@@ -22309,18 +22466,18 @@ function mapChangeImpact(store, working, base, changes, project) {
22309
22466
  beforeTracer.trace(gone);
22310
22467
  for (const entry of beforeTracer.entries.values())
22311
22468
  if (!tracer.entries.has(entry.label)) tracer.entries.set(entry.label, entry);
22312
- for (const [path11, test] of beforeTracer.tests) {
22313
- const known = tracer.tests.get(path11);
22469
+ for (const [path12, test] of beforeTracer.tests) {
22470
+ const known = tracer.tests.get(path12);
22314
22471
  if (known) for (const name of test.names) known.names.add(name);
22315
- else tracer.tests.set(path11, test);
22472
+ else tracer.tests.set(path12, test);
22316
22473
  }
22317
22474
  for (const [area, known] of beforeTracer.areas) {
22318
22475
  const now = tracer.areas.get(area);
22319
22476
  if (!now) tracer.areas.set(area, known);
22320
22477
  else {
22321
22478
  for (const name of known.through) now.through.add(name);
22322
- for (const [path11, names] of known.tests)
22323
- now.tests.set(path11, /* @__PURE__ */ new Set([...now.tests.get(path11) ?? [], ...names]));
22479
+ for (const [path12, names] of known.tests)
22480
+ now.tests.set(path12, /* @__PURE__ */ new Set([...now.tests.get(path12) ?? [], ...names]));
22324
22481
  }
22325
22482
  }
22326
22483
  unclear.push(...beforeTracer.unclear.filter((line) => !line.includes("has no callers")));
@@ -22334,8 +22491,8 @@ function mapChangeImpact(store, working, base, changes, project) {
22334
22491
  entries: [...tracer.entries.values()].sort(
22335
22492
  (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)
22336
22493
  ),
22337
- tests: [...tracer.tests].map(([path11, test]) => ({
22338
- path: path11,
22494
+ tests: [...tracer.tests].map(([path12, test]) => ({
22495
+ path: path12,
22339
22496
  names: [...test.names].sort(),
22340
22497
  why: test.why,
22341
22498
  rank: test.rank
@@ -22345,7 +22502,7 @@ function mapChangeImpact(store, working, base, changes, project) {
22345
22502
  areas: [...tracer.areas].map(([area, known]) => ({
22346
22503
  area,
22347
22504
  through: [...known.through].sort(),
22348
- tests: [...known.tests].map(([path11, names]) => ({ path: path11, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
22505
+ tests: [...known.tests].map(([path12, names]) => ({ path: path12, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
22349
22506
  })).sort((left, right) => right.tests.length - left.tests.length),
22350
22507
  unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
22351
22508
  truncated: tracer.truncated
@@ -22357,17 +22514,22 @@ function existingTestsChanged(before, after, file2, project) {
22357
22514
  let workingLines = [];
22358
22515
  if (file2.status !== "DELETED" && project)
22359
22516
  try {
22360
- workingLines = readFileSync2(path7.join(project, file2.path), "utf8").split("\n");
22517
+ workingLines = readFileSync3(path8.join(project, file2.path), "utf8").split("\n");
22361
22518
  } catch {
22362
22519
  }
22363
22520
  const key = (graph, object2) => `${object2.kind}\0${graph.qualifiedName(object2.id)}`;
22364
- const text = (lines, object2) => lines.slice(object2.anchor.startLine - 1, object2.anchor.endLine).map((line) => line.trimEnd()).join("\n");
22521
+ const body = (lines, object2) => lines.slice(object2.anchor.startLine - 1, object2.anchor.endLine).map((line) => line.trimEnd());
22522
+ const extended = (before2, after2) => {
22523
+ let at = 0;
22524
+ for (const line of after2) if (at < before2.length && line === before2[at]) at++;
22525
+ return at === before2.length;
22526
+ };
22365
22527
  const now = new Map(
22366
22528
  (file2.status === "DELETED" ? [] : after.objectsAt(file2.path)).filter((object2) => !mapIsModule(object2) && after.isAddressable(object2)).map((object2) => [key(after, object2), object2])
22367
22529
  );
22368
22530
  const changed = before.objectsAt(file2.basePath).filter((object2) => !mapIsModule(object2) && before.isAddressable(object2)).filter((object2) => {
22369
22531
  const counterpart = now.get(key(before, object2));
22370
- return !counterpart || text(baseLines, object2) !== text(workingLines, counterpart);
22532
+ return !counterpart || !extended(body(baseLines, object2), body(workingLines, counterpart));
22371
22533
  });
22372
22534
  return changed.filter(
22373
22535
  (object2) => !changed.some(
@@ -22439,7 +22601,7 @@ function routeTests(project, store, version2, entries, tracer) {
22439
22601
  if (!mapRunnableTest(candidate)) continue;
22440
22602
  let text;
22441
22603
  try {
22442
- text = readFileSync2(path7.join(project, candidate), "utf8");
22604
+ text = readFileSync3(path8.join(project, candidate), "utf8");
22443
22605
  } catch {
22444
22606
  continue;
22445
22607
  }
@@ -22457,9 +22619,9 @@ function routeTests(project, store, version2, entries, tracer) {
22457
22619
  }
22458
22620
  }
22459
22621
  }
22460
- function sameDirectoryTests(store, version2, path11, tracer) {
22461
- const slash = path11.lastIndexOf("/");
22462
- const directory = slash < 0 ? "" : path11.slice(0, slash + 1);
22622
+ function sameDirectoryTests(store, version2, path12, tracer) {
22623
+ const slash = path12.lastIndexOf("/");
22624
+ const directory = slash < 0 ? "" : path12.slice(0, slash + 1);
22463
22625
  for (const row of store.database.prepare(
22464
22626
  "SELECT DISTINCT path FROM project_map_objects WHERE version_ref = ? AND path LIKE ? ESCAPE '\\'"
22465
22627
  ).all(version2, `${directory.replace(/[\\%_]/gu, (c) => `\\${c}`)}%`)) {
@@ -22480,6 +22642,7 @@ var LIST = Object.freeze({
22480
22642
  entries: 40,
22481
22643
  tests: 12,
22482
22644
  unclear: 20,
22645
+ stranded: 12,
22483
22646
  names: 6,
22484
22647
  areas: 8,
22485
22648
  areaTests: 3,
@@ -22507,6 +22670,16 @@ Nothing changed against ${changes.base}.`;
22507
22670
  impact.removed,
22508
22671
  LIST.changed
22509
22672
  );
22673
+ if (changes.stranded.length) {
22674
+ list(
22675
+ "NAMES STILL USED ELSEWHERE (environment variables and configuration keys the diff removed from a file, found by text)",
22676
+ changes.stranded.map(strandedNameLine),
22677
+ LIST.stranded
22678
+ );
22679
+ lines.push(
22680
+ "These places still read or set the old name. If the diff renamed or dropped it on purpose, update them too or keep the old name working. Names built at run time are not found."
22681
+ );
22682
+ }
22510
22683
  if (impact.rewrittenTests.length) {
22511
22684
  list(
22512
22685
  "EXISTING TESTS CHANGED (tests that existed before this diff, whose code it changed or removed)",
@@ -22580,7 +22753,7 @@ Nothing changed against ${changes.base}.`;
22580
22753
  var SCHEMA_VERSION = 2;
22581
22754
  var KEEP_VERSIONS = 3;
22582
22755
  function openMapDatabase(file2) {
22583
- mkdirSync(path8.dirname(file2), { recursive: true, mode: 448 });
22756
+ mkdirSync(path9.dirname(file2), { recursive: true, mode: 448 });
22584
22757
  const database = new DatabaseSync(file2);
22585
22758
  try {
22586
22759
  database.exec("PRAGMA busy_timeout = 30000;");
@@ -22617,7 +22790,7 @@ function openMapDatabase(file2) {
22617
22790
  throw error51;
22618
22791
  }
22619
22792
  }
22620
- var mapDatabasePath = (cacheDirectory2, canonicalProject) => path8.join(
22793
+ var mapDatabasePath = (cacheDirectory2, canonicalProject) => path9.join(
22621
22794
  cacheDirectory2,
22622
22795
  "projects",
22623
22796
  createHash4("sha256").update(canonicalProject).digest("hex").slice(0, 24),
@@ -22767,19 +22940,19 @@ var LayerMap = class _LayerMap {
22767
22940
 
22768
22941
  // src/agent/environment.ts
22769
22942
  var packageRoot = (() => {
22770
- for (let directory = path9.dirname(fileURLToPath(import.meta.url)); ; ) {
22771
- const manifest = path9.join(directory, "package.json");
22772
- if (existsSync4(manifest) && JSON.parse(readFileSync3(manifest, "utf8")).name === "layermap")
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")
22773
22946
  return directory;
22774
- if (path9.dirname(directory) === directory) throw new Error("LayerMap cannot find its package.");
22775
- directory = path9.dirname(directory);
22947
+ if (path10.dirname(directory) === directory) throw new Error("LayerMap cannot find its package.");
22948
+ directory = path10.dirname(directory);
22776
22949
  }
22777
22950
  })();
22778
- var packageVersion = async () => JSON.parse(await readFile(path9.join(packageRoot, "package.json"), "utf8")).version;
22951
+ var packageVersion = async () => JSON.parse(await readFile(path10.join(packageRoot, "package.json"), "utf8")).version;
22779
22952
  var cacheDirectory = (env = process.env) => {
22780
- if (env.LAYERMAP_CACHE) return path9.resolve(env.LAYERMAP_CACHE);
22781
- if (process.platform === "darwin") return path9.join(homedir(), "Library", "Caches", "layermap");
22782
- return path9.join(env.XDG_CACHE_HOME || path9.join(homedir(), ".cache"), "layermap");
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");
22783
22956
  };
22784
22957
  var projectDirectory = (directory) => new Promise(
22785
22958
  (resolve) => execFile(
@@ -22787,7 +22960,7 @@ var projectDirectory = (directory) => new Promise(
22787
22960
  ["rev-parse", "--show-toplevel"],
22788
22961
  { cwd: directory, timeout: 1e4 },
22789
22962
  (error51, stdout) => resolve(
22790
- error51 ? { directory: path9.resolve(directory), git: false } : { directory: stdout.trim(), git: true }
22963
+ error51 ? { directory: path10.resolve(directory), git: false } : { directory: stdout.trim(), git: true }
22791
22964
  )
22792
22965
  )
22793
22966
  );
@@ -22797,7 +22970,7 @@ var relativeTo = (directory, value) => Object.fromEntries(
22797
22970
  Object.fromEntries(
22798
22971
  Object.entries(resources).map(([key, field]) => [
22799
22972
  key,
22800
- key.endsWith("Path") && typeof field === "string" && field.startsWith(directory) ? path9.relative(directory, field) : field
22973
+ key.endsWith("Path") && typeof field === "string" && field.startsWith(directory) ? path10.relative(directory, field) : field
22801
22974
  ])
22802
22975
  )
22803
22976
  ])
@@ -22808,7 +22981,7 @@ var resolvePlaceholder = (field) => {
22808
22981
  createRequire(import.meta.url).resolve("typescript/package.json")
22809
22982
  );
22810
22983
  const native = `@typescript/typescript-${process.platform}-${process.arch}/package.json`;
22811
- return path9.join(path9.dirname(compiler.resolve(native)), "lib", "tsc");
22984
+ return path10.join(path10.dirname(compiler.resolve(native)), "lib", "tsc");
22812
22985
  }
22813
22986
  return field.replaceAll("{platform}", process.platform).replaceAll("{arch}", process.arch);
22814
22987
  };
@@ -22819,24 +22992,24 @@ var absoluteIn = (directory, value) => Object.fromEntries(
22819
22992
  Object.entries(resources).map(([key, field]) => {
22820
22993
  if (!key.endsWith("Path") || typeof field !== "string") return [key, field];
22821
22994
  const resolved = resolvePlaceholder(field);
22822
- return [key, path9.isAbsolute(resolved) ? resolved : path9.join(directory, resolved)];
22995
+ return [key, path10.isAbsolute(resolved) ? resolved : path10.join(directory, resolved)];
22823
22996
  })
22824
22997
  )
22825
22998
  ])
22826
22999
  );
22827
23000
  var readAnalyzers = async (directory) => {
22828
- const file2 = path9.join(directory, "analyzers.json");
23001
+ const file2 = path10.join(directory, "analyzers.json");
22829
23002
  if (!existsSync4(file2)) return void 0;
22830
23003
  const analyzers = absoluteIn(directory, JSON.parse(await readFile(file2, "utf8")));
22831
23004
  return analyzers.java.runtimePath ? analyzers : { ...analyzers, java: { ...analyzers.java, ...discoverJavaRuntime() } };
22832
23005
  };
22833
23006
  var sourceDigest = async () => {
22834
- const hash2 = createHash5("sha256").update(await readFile(path9.join(packageRoot, "package.json")));
23007
+ const hash2 = createHash5("sha256").update(await readFile(path10.join(packageRoot, "package.json")));
22835
23008
  for (const part of ["src", "go-map", "java-map", "scripts"]) {
22836
- const directory = path9.join(packageRoot, part);
23009
+ const directory = path10.join(packageRoot, part);
22837
23010
  if (!existsSync4(directory)) continue;
22838
23011
  for (const entry of (await readdir(directory, { recursive: true })).sort()) {
22839
- const file2 = path9.join(directory, entry);
23012
+ const file2 = path10.join(directory, entry);
22840
23013
  const info = await stat(file2);
22841
23014
  if (info.isFile()) hash2.update(`${part}/${entry}\0${info.size}\0${info.mtimeMs}\0`);
22842
23015
  }
@@ -22844,11 +23017,11 @@ var sourceDigest = async () => {
22844
23017
  return hash2.digest("hex").slice(0, 16);
22845
23018
  };
22846
23019
  async function resolveAnalyzers(cache, log2, env = process.env) {
22847
- for (const directory2 of [env.LAYERMAP_ANALYZERS, path9.join(packageRoot, "analyzers")]) {
22848
- const analyzers = directory2 && await readAnalyzers(path9.resolve(directory2));
23020
+ for (const directory2 of [env.LAYERMAP_ANALYZERS, path10.join(packageRoot, "analyzers")]) {
23021
+ const analyzers = directory2 && await readAnalyzers(path10.resolve(directory2));
22849
23022
  if (analyzers) return analyzers;
22850
23023
  }
22851
- const directory = path9.join(cache, "analyzers", await sourceDigest());
23024
+ const directory = path10.join(cache, "analyzers", await sourceDigest());
22852
23025
  const built = await readAnalyzers(directory);
22853
23026
  if (built) return built;
22854
23027
  log2("Building the language analyzers (once per LayerMap version)...");
@@ -22864,32 +23037,32 @@ async function resolveAnalyzers(cache, log2, env = process.env) {
22864
23037
  python: parser.pythonResources,
22865
23038
  java: parser.javaResources
22866
23039
  });
22867
- await writeFile(path9.join(staging, "analyzers.json"), `${JSON.stringify(stored, null, 2)}
23040
+ await writeFile(path10.join(staging, "analyzers.json"), `${JSON.stringify(stored, null, 2)}
22868
23041
  `);
22869
23042
  await rename(staging, directory).catch(() => rm(staging, { recursive: true, force: true }));
22870
23043
  return await readAnalyzers(directory);
22871
23044
  }
22872
23045
  var DAY = 24 * 60 * 60 * 1e3;
22873
23046
  async function pruneCache(cache, project, now = Date.now()) {
22874
- const used = path9.join(path9.dirname(mapDatabasePath(cache, project)), "last-used");
22875
- await mkdir(path9.dirname(used), { recursive: true, mode: 448 });
23047
+ const used = path10.join(path10.dirname(mapDatabasePath(cache, project)), "last-used");
23048
+ await mkdir(path10.dirname(used), { recursive: true, mode: 448 });
22876
23049
  await writeFile(used, "");
22877
23050
  await utimes(used, now / 1e3, now / 1e3);
22878
- const projects = path9.join(cache, "projects");
23051
+ const projects = path10.join(cache, "projects");
22879
23052
  for (const name of await readdir(projects).catch(() => [])) {
22880
- const directory = path9.join(projects, name);
22881
- const marker = path9.join(directory, "last-used");
23053
+ const directory = path10.join(projects, name);
23054
+ const marker = path10.join(directory, "last-used");
22882
23055
  const last = (await stat(existsSync4(marker) ? marker : directory).catch(() => void 0))?.mtimeMs;
22883
23056
  if (last !== void 0 && now - last > 30 * DAY)
22884
23057
  await rm(directory, { recursive: true, force: true });
22885
23058
  }
22886
- const builds = path9.join(cache, "analyzers");
23059
+ const builds = path10.join(cache, "analyzers");
22887
23060
  const current = await sourceDigest();
22888
23061
  for (const name of await readdir(builds).catch(() => [])) {
22889
23062
  if (name === current) continue;
22890
- const built = (await stat(path9.join(builds, name)).catch(() => void 0))?.mtimeMs;
23063
+ const built = (await stat(path10.join(builds, name)).catch(() => void 0))?.mtimeMs;
22891
23064
  if (built !== void 0 && now - built > (name.includes(".") ? DAY / 24 : DAY))
22892
- await rm(path9.join(builds, name), { recursive: true, force: true });
23065
+ await rm(path10.join(builds, name), { recursive: true, force: true });
22893
23066
  }
22894
23067
  }
22895
23068
 
@@ -22907,10 +23080,10 @@ var AGENT_MAP_TOOL_HOST = Object.freeze({
22907
23080
  scope: "project",
22908
23081
  // Agents reach for grep by habit; these say which questions the map answers in one call.
22909
23082
  lead: {
22910
- explore: "Use this before grep or reading files to answer what calls a function or method, what changing it affects (callers traced up to entry points such as HTTP routes, handlers, jobs and commands), what it calls, and what a directory or file contains: one call returns the callers or callees up to 8 levels deep, with file paths and line numbers, for TypeScript, JavaScript, Go, Python and Java.",
23083
+ explore: "Use this instead of grep to answer what calls a function or method, what changing it affects (callers traced up to entry points such as HTTP routes, handlers, jobs and commands), what it calls, and what a directory or file contains: one call returns the callers or callees up to 8 levels deep, with file paths and line numbers, for TypeScript, JavaScript, Go, Python and Java.",
22911
23084
  search: "Use this to find where a function, method, class or type is declared, by name or by words in its name, path or documentation, before exploring its callers with project_explore_map.",
22912
23085
  references: "Use this to list every place a declaration is used (calls, imports, re-exports, reads and writes), compiled from current source: more complete than searching for its name.",
22913
- check: "Use this after editing code and before reporting the work done: it lists what the uncommitted changes affect, from the changed functions up to the HTTP routes, jobs and commands that reach them, plus the existing tests related to them."
23086
+ check: "Use this once the edits are done, before reporting the work done: it lists what the uncommitted changes affect, from the changed functions up to the HTTP routes, jobs and commands that reach them, plus the existing tests related to them."
22914
23087
  }
22915
23088
  });
22916
23089
  var MAP_TOOL_NAMES = Object.freeze({
@@ -22919,7 +23092,7 @@ var MAP_TOOL_NAMES = Object.freeze({
22919
23092
  references: "project_find_references",
22920
23093
  check: "project_check_changes"
22921
23094
  });
22922
- var mapDirectoryPath = (path11) => path11.length > 1 && path11.endsWith("/") && !path11.endsWith("//") ? path11.slice(0, -1) : path11;
23095
+ var mapDirectoryPath = (path12) => path12.length > 1 && path12.endsWith("/") && !path12.endsWith("//") ? path12.slice(0, -1) : path12;
22923
23096
  var ProjectMapSearchInputSchema = external_exports.object({
22924
23097
  path: external_exports.string().default("."),
22925
23098
  query: external_exports.string().min(1).max(256),
@@ -22948,7 +23121,7 @@ var ProjectMapCheckInputSchema = external_exports.object({
22948
23121
  base: external_exports.string().min(1).max(200).default("HEAD").describe(
22949
23122
  "Commit, branch or tag to compare the working tree with (HEAD, so the uncommitted changes, by default; main for a whole branch)."
22950
23123
  )
22951
- }).strict();
23124
+ }).strip();
22952
23125
  var locatorSchema = MapObjectLocatorSchema.describe(
22953
23126
  "Declaration location: path and UTF-16 start offset; include kind to distinguish declarations at the same offset."
22954
23127
  );
@@ -22973,7 +23146,7 @@ var mapToolDescriptions = (host) => {
22973
23146
  return Object.freeze({
22974
23147
  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.`,
22975
23148
  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.`,
22976
- 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; 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.`,
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.`,
22977
23150
  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.`
22978
23151
  });
22979
23152
  };
@@ -23071,8 +23244,8 @@ async function runMapTool(map2, name, args, signal) {
23071
23244
  throw error51;
23072
23245
  }
23073
23246
  }
23074
- var AGENT_MAP_INSTRUCTIONS = `Use the LayerMap tools before grep or reading files whenever a task asks what calls something, what a change affects, where something is used, or how the code is organized: project_explore_map on a declaration with direction INCOMING and depth up to 8 traces its callers up to the entry points (HTTP routes, handlers, jobs, commands) in one call, which grep can only approximate one name at a time. LayerMap is a static, layered map of this repository for TypeScript/JavaScript, Go, Python and Java: directories and modules, each file's declarations, and each declaration's callers and callees up to 8 hops. path "." shows what exists. Continue from any NOT EXPANDED declarations a view names, then confirm entry points in source. When the edits are done, call project_check_changes once before reporting the work done, not after every edit: it lists the entry points and existing tests the changes reach, and the existing tests the diff rewrote. The map is static: dynamic dispatch, framework wiring and unresolved targets need source reading, and a missing relationship does not prove absence. The first call on a project builds its map, which can take minutes on a large repository; later calls update only what changed.`;
23075
- var AGENT_MAP_NOTE = "The layermap MCP server is available here. For questions about what calls a function, what a change affects or where code is used, start with its project_explore_map tool (direction INCOMING, depth up to 8) before grep, then confirm in source. When the edits are done, call its project_check_changes tool once before reporting the work done.";
23247
+ var AGENT_MAP_INSTRUCTIONS = `Use the LayerMap tools instead of grep whenever a task needs to know what calls something, what a change could affect beyond the code at hand, where something is used, or how the code is organized; a change confined to code you have read does not need them: project_explore_map on a declaration with direction INCOMING and depth up to 8 traces its callers up to the entry points (HTTP routes, handlers, jobs, commands) in one call, which grep can only approximate one name at a time. LayerMap is a static, layered map of this repository for TypeScript/JavaScript, Go, Python and Java: directories and modules, each file's declarations, and each declaration's callers and callees up to 8 hops. path "." shows what exists. Continue from any NOT EXPANDED declarations a view names, then confirm entry points in source. When the edits are done, call project_check_changes once before reporting the work done, not after every edit: it lists the entry points and existing tests the changes reach, and the existing tests the diff rewrote. The map is static: dynamic dispatch, framework wiring and unresolved targets need source reading, and a missing relationship does not prove absence. The first call on a project builds its map, which can take minutes on a large repository; later calls update only what changed.`;
23248
+ var AGENT_MAP_NOTE = "The layermap MCP server is available here. When a task needs to know what calls a function, what a change could affect beyond the code you are editing, or where code is used, use its project_explore_map tool (direction INCOMING, depth up to 8) instead of grep, then confirm in source; a change confined to code you have read does not need it. When the edits are done, call its project_check_changes tool once before reporting the work done.";
23076
23249
 
23077
23250
  // src/agent/mcp.ts
23078
23251
  function serveMcp(options) {
@@ -23214,15 +23387,15 @@ import { execFile as execFile2 } from "node:child_process";
23214
23387
  import { existsSync as existsSync5 } from "node:fs";
23215
23388
  import { mkdir as mkdir2, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
23216
23389
  import { homedir as homedir2 } from "node:os";
23217
- import path10 from "node:path";
23390
+ import path11 from "node:path";
23218
23391
  var SERVER = "layermap";
23219
23392
  var SETUP_RULE = `mcp__${SERVER}`;
23220
23393
  var PLUGIN_RULE = `mcp__plugin_${SERVER}_${SERVER}`;
23221
23394
  var BEGIN = "<!-- layermap:begin -->";
23222
23395
  var END = "<!-- layermap:end -->";
23223
23396
  var mcpLaunchCommand = (version2) => {
23224
- const script = path10.resolve(process.argv[1] ?? "");
23225
- if (script.includes(`${path10.sep}_npx${path10.sep}`))
23397
+ const script = path11.resolve(process.argv[1] ?? "");
23398
+ if (script.includes(`${path11.sep}_npx${path11.sep}`))
23226
23399
  return ["npx", "-y", `layermap@${version2}`, "mcp"];
23227
23400
  const execArgv = [];
23228
23401
  for (let index = 0; index < process.execArgv.length; index++) {
@@ -23253,7 +23426,7 @@ async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
23253
23426
  throw new Error(`${file2} has permissions.allow that is not a list.`);
23254
23427
  if (settings.permissions.allow.includes(rule)) return false;
23255
23428
  settings.permissions.allow.push(rule);
23256
- await mkdir2(path10.dirname(file2), { recursive: true });
23429
+ await mkdir2(path11.dirname(file2), { recursive: true });
23257
23430
  await writeFile2(file2, `${JSON.stringify(settings, null, 2)}
23258
23431
  `);
23259
23432
  return true;
@@ -23287,7 +23460,7 @@ ${END}`;
23287
23460
  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}
23288
23461
  `;
23289
23462
  if (next === text) return;
23290
- await mkdir2(path10.dirname(file2), { recursive: true });
23463
+ await mkdir2(path11.dirname(file2), { recursive: true });
23291
23464
  await writeFile2(file2, next);
23292
23465
  }
23293
23466
  async function removeInstructionNote(file2) {
@@ -23315,14 +23488,14 @@ async function disallowInClaudeSettings(file2) {
23315
23488
  }
23316
23489
  var YAML_BEGIN = "# layermap:begin";
23317
23490
  var YAML_END = "# layermap:end";
23318
- var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(path10.delimiter).find(
23319
- (directory) => path10.isAbsolute(directory) && existsSync5(path10.join(directory, "node")) && existsSync5(path10.join(directory, "npx"))
23320
- ) ?? path10.dirname(process.execPath);
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);
23321
23494
  var dshPatchBlock = (command, env) => {
23322
23495
  const node = nodeDirectory(env);
23323
- const npx = path10.join(node, "npx");
23496
+ const npx = path11.join(node, "npx");
23324
23497
  const [program = "", ...args] = command[0] === "npx" && existsSync5(npx) ? [npx, ...command.slice(1)] : command;
23325
- const searchPath = `${JSON.stringify(`${node}${path10.delimiter}`)} + process.env.PATH`;
23498
+ const searchPath = `${JSON.stringify(`${node}${path11.delimiter}`)} + process.env.PATH`;
23326
23499
  return [
23327
23500
  `${YAML_BEGIN} (written by \`layermap setup dsh\`; \`layermap remove dsh\` deletes it)`,
23328
23501
  "- insert:",
@@ -23357,7 +23530,7 @@ async function writeDshPatch(file2, block) {
23357
23530
  `;
23358
23531
  }
23359
23532
  if (next === text) return;
23360
- await mkdir2(path10.dirname(file2), { recursive: true });
23533
+ await mkdir2(path11.dirname(file2), { recursive: true });
23361
23534
  await writeFile2(file2, next);
23362
23535
  }
23363
23536
  async function removeDshPatch(file2) {
@@ -23375,31 +23548,31 @@ async function removeDshPatch(file2) {
23375
23548
  var agentFiles = (options) => {
23376
23549
  const env = options.env ?? process.env;
23377
23550
  if (options.agent === "dsh") {
23378
- const home = env.DSH_HOME || path10.join(homedir2(), ".dsh");
23551
+ const home = env.DSH_HOME || path11.join(homedir2(), ".dsh");
23379
23552
  return {
23380
- settings: path10.join(home, "cordis.patch.yml"),
23381
- instructions: path10.join(home, "AGENTS.md")
23553
+ settings: path11.join(home, "cordis.patch.yml"),
23554
+ instructions: path11.join(home, "AGENTS.md")
23382
23555
  };
23383
23556
  }
23384
23557
  if (options.agent === "codex") {
23385
- const home = env.CODEX_HOME ?? path10.join(homedir2(), ".codex");
23386
- return { settings: path10.join(home, "config.toml"), instructions: path10.join(home, "AGENTS.md") };
23558
+ const home = env.CODEX_HOME ?? path11.join(homedir2(), ".codex");
23559
+ return { settings: path11.join(home, "config.toml"), instructions: path11.join(home, "AGENTS.md") };
23387
23560
  }
23388
23561
  if (options.scope === "user") {
23389
- const home = env.CLAUDE_CONFIG_DIR ?? path10.join(homedir2(), ".claude");
23562
+ const home = env.CLAUDE_CONFIG_DIR ?? path11.join(homedir2(), ".claude");
23390
23563
  return {
23391
- settings: path10.join(home, "settings.json"),
23392
- instructions: path10.join(home, "CLAUDE.md")
23564
+ settings: path11.join(home, "settings.json"),
23565
+ instructions: path11.join(home, "CLAUDE.md")
23393
23566
  };
23394
23567
  }
23395
23568
  const local = options.scope === "local";
23396
23569
  return {
23397
- settings: path10.join(
23570
+ settings: path11.join(
23398
23571
  options.project,
23399
23572
  ".claude",
23400
23573
  local ? "settings.local.json" : "settings.json"
23401
23574
  ),
23402
- instructions: path10.join(options.project, local ? "CLAUDE.local.md" : "CLAUDE.md")
23575
+ instructions: path11.join(options.project, local ? "CLAUDE.local.md" : "CLAUDE.md")
23403
23576
  };
23404
23577
  };
23405
23578
  async function setupAgent(options) {