layermap 0.1.29 → 0.1.31

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
@@ -7,6 +7,8 @@ var __export = (target, all) => {
7
7
  };
8
8
 
9
9
  // src/cli.ts
10
+ import { realpath as realpath4 } from "node:fs/promises";
11
+ import path15 from "node:path";
10
12
  import { parseArgs } from "node:util";
11
13
 
12
14
  // src/agent/environment.ts
@@ -1305,10 +1307,10 @@ function mergeDefs(...defs) {
1305
1307
  function cloneDef(schema) {
1306
1308
  return mergeDefs(schema._zod.def);
1307
1309
  }
1308
- function getElementAtPath(obj, path15) {
1309
- if (!path15)
1310
+ function getElementAtPath(obj, path16) {
1311
+ if (!path16)
1310
1312
  return obj;
1311
- return path15.reduce((acc, key) => acc?.[key], obj);
1313
+ return path16.reduce((acc, key) => acc?.[key], obj);
1312
1314
  }
1313
1315
  function promiseAllObject(promisesObj) {
1314
1316
  const keys = Object.keys(promisesObj);
@@ -1717,11 +1719,11 @@ function explicitlyAborted(x, startIndex = 0) {
1717
1719
  }
1718
1720
  return false;
1719
1721
  }
1720
- function prefixIssues(path15, issues) {
1722
+ function prefixIssues(path16, issues) {
1721
1723
  return issues.map((iss) => {
1722
1724
  var _a3;
1723
1725
  (_a3 = iss).path ?? (_a3.path = []);
1724
- iss.path.unshift(path15);
1726
+ iss.path.unshift(path16);
1725
1727
  return iss;
1726
1728
  });
1727
1729
  }
@@ -1868,16 +1870,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1868
1870
  }
1869
1871
  function formatError(error51, mapper = (issue2) => issue2.message) {
1870
1872
  const fieldErrors = { _errors: [] };
1871
- const processError = (error52, path15 = []) => {
1873
+ const processError = (error52, path16 = []) => {
1872
1874
  for (const issue2 of error52.issues) {
1873
1875
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1874
- issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
1876
+ issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
1875
1877
  } else if (issue2.code === "invalid_key") {
1876
- processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
1878
+ processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
1877
1879
  } else if (issue2.code === "invalid_element") {
1878
- processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
1880
+ processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
1879
1881
  } else {
1880
- const fullpath = [...path15, ...issue2.path];
1882
+ const fullpath = [...path16, ...issue2.path];
1881
1883
  if (fullpath.length === 0) {
1882
1884
  fieldErrors._errors.push(mapper(issue2));
1883
1885
  } else {
@@ -1904,17 +1906,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1904
1906
  }
1905
1907
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1906
1908
  const result = { errors: [] };
1907
- const processError = (error52, path15 = []) => {
1909
+ const processError = (error52, path16 = []) => {
1908
1910
  var _a3, _b;
1909
1911
  for (const issue2 of error52.issues) {
1910
1912
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1911
- issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
1913
+ issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
1912
1914
  } else if (issue2.code === "invalid_key") {
1913
- processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
1915
+ processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
1914
1916
  } else if (issue2.code === "invalid_element") {
1915
- processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
1917
+ processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
1916
1918
  } else {
1917
- const fullpath = [...path15, ...issue2.path];
1919
+ const fullpath = [...path16, ...issue2.path];
1918
1920
  if (fullpath.length === 0) {
1919
1921
  result.errors.push(mapper(issue2));
1920
1922
  continue;
@@ -1946,8 +1948,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1946
1948
  }
1947
1949
  function toDotPath(_path) {
1948
1950
  const segs = [];
1949
- const path15 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1950
- for (const seg of path15) {
1951
+ const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1952
+ for (const seg of path16) {
1951
1953
  if (typeof seg === "number")
1952
1954
  segs.push(`[${seg}]`);
1953
1955
  else if (typeof seg === "symbol")
@@ -14639,13 +14641,13 @@ function resolveRef(ref, ctx) {
14639
14641
  if (!ref.startsWith("#")) {
14640
14642
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14641
14643
  }
14642
- const path15 = ref.slice(1).split("/").filter(Boolean);
14643
- if (path15.length === 0) {
14644
+ const path16 = ref.slice(1).split("/").filter(Boolean);
14645
+ if (path16.length === 0) {
14644
14646
  return ctx.rootSchema;
14645
14647
  }
14646
14648
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14647
- if (path15[0] === defsKey) {
14648
- const key = path15[1];
14649
+ if (path16[0] === defsKey) {
14650
+ const key = path16[1];
14649
14651
  if (!key || !ctx.defs[key]) {
14650
14652
  throw new Error(`Reference not found: ${ref}`);
14651
14653
  }
@@ -15959,8 +15961,8 @@ var MapAnalysisSchema = external_exports.object({
15959
15961
  var mapPathAllowed = (relative, prefixes) => prefixes.some(
15960
15962
  (prefix) => prefix === "." || relative === prefix || relative.startsWith(`${prefix}/`)
15961
15963
  );
15962
- var mapTestPath = (path15) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
15963
- path15
15964
+ var mapTestPath = (path16) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
15965
+ path16
15964
15966
  );
15965
15967
 
15966
15968
  // src/project-map-reference-types.ts
@@ -16044,11 +16046,11 @@ var string4 = (value) => {
16044
16046
  var identity = (id2, reconstructed) => id2 === reconstructed ? [] : [JSON.stringify(id2)];
16045
16047
  function encodeMapText(graph) {
16046
16048
  const files = /* @__PURE__ */ new Map();
16047
- const file2 = (path15) => {
16048
- let ref = files.get(path15);
16049
+ const file2 = (path16) => {
16050
+ let ref = files.get(path16);
16049
16051
  if (!ref) {
16050
16052
  ref = `F${files.size + 1}`;
16051
- files.set(path15, ref);
16053
+ files.set(path16, ref);
16052
16054
  }
16053
16055
  return ref;
16054
16056
  };
@@ -16096,7 +16098,7 @@ function encodeMapText(graph) {
16096
16098
  rows2.push(`B ${node(frontier.entityRef)} ${frontier.direction}`);
16097
16099
  return [
16098
16100
  ...header,
16099
- ...[...files].map(([path15, ref]) => `${ref} ${JSON.stringify(path15)}`),
16101
+ ...[...files].map(([path16, ref]) => `${ref} ${JSON.stringify(path16)}`),
16100
16102
  ...rows2
16101
16103
  ].join("\n");
16102
16104
  }
@@ -16116,10 +16118,10 @@ function decodeMapText(text) {
16116
16118
  const at = (value) => {
16117
16119
  const match = /^(F[1-9]\d*):(\d+)-(\d+)@(\d+)-(\d+)$/u.exec(value ?? "");
16118
16120
  if (!match) return failed();
16119
- const path15 = files.get(match[1] ?? "");
16120
- if (path15 === void 0) return failed();
16121
+ const path16 = files.get(match[1] ?? "");
16122
+ if (path16 === void 0) return failed();
16121
16123
  return MapAnchorSchema.parse({
16122
- path: path15,
16124
+ path: path16,
16123
16125
  startLine: Number(match[2]),
16124
16126
  endLine: Number(match[3]),
16125
16127
  start: Number(match[4]),
@@ -16196,8 +16198,8 @@ function decodeMapText(text) {
16196
16198
  var locationSchema = MapAnchorSchema.describe(
16197
16199
  "Source location: start/end are zero-based UTF-16 offsets with an exclusive end; line numbers are one-based."
16198
16200
  );
16199
- var location = ({ path: path15, startLine, endLine, start, end }) => ({
16200
- path: path15,
16201
+ var location = ({ path: path16, startLine, endLine, start, end }) => ({
16202
+ path: path16,
16201
16203
  startLine,
16202
16204
  endLine,
16203
16205
  start,
@@ -16300,11 +16302,11 @@ var MapNavigationObjectsSchema = external_exports.union([
16300
16302
  ),
16301
16303
  external_exports.object({ files: external_exports.array(searchFileSchema) }).passthrough().refine((value) => !("format" in value), "Text navigation must decode through its format.").transform(
16302
16304
  (value) => value.files.flatMap(
16303
- ({ path: path15, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
16305
+ ({ path: path16, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
16304
16306
  id: id2,
16305
16307
  name,
16306
16308
  kind,
16307
- anchor: { path: path15, startLine, endLine, start, end },
16309
+ anchor: { path: path16, startLine, endLine, start, end },
16308
16310
  ...execution ? { execution } : {}
16309
16311
  }))
16310
16312
  )
@@ -16317,10 +16319,10 @@ var mapSearchNavigation = (result) => {
16317
16319
  for (const [index, object2] of found.entries()) {
16318
16320
  const ranking = rankings[index];
16319
16321
  if (!ranking) throw new Error("PROJECT_MAP_SEARCH_RANKING_MISSING");
16320
- const path15 = object2.anchor.path;
16322
+ const path16 = object2.anchor.path;
16321
16323
  let file2 = files.at(-1);
16322
- if (file2?.path !== path15) {
16323
- file2 = { path: path15, symbols: [] };
16324
+ if (file2?.path !== path16) {
16325
+ file2 = { path: path16, symbols: [] };
16324
16326
  files.push(file2);
16325
16327
  }
16326
16328
  file2.symbols.push({
@@ -16446,8 +16448,8 @@ var MapViewGraph = class {
16446
16448
  }
16447
16449
  return object2;
16448
16450
  }
16449
- objectsAt(path15) {
16450
- return this.statements.path.all(this.version, path15).map((row) => {
16451
+ objectsAt(path16) {
16452
+ return this.statements.path.all(this.version, path16).map((row) => {
16451
16453
  const object2 = MapObjectSchema.parse(JSON.parse(String(row.object_json)));
16452
16454
  this.objects.set(object2.id, object2);
16453
16455
  return object2;
@@ -16566,8 +16568,8 @@ var MapViewGraph = class {
16566
16568
  );
16567
16569
  }
16568
16570
  };
16569
- function mapSelectDeclarations(graph, path15, name, line) {
16570
- const objects2 = graph.objectsAt(path15).filter((object2) => !mapIsModule(object2));
16571
+ function mapSelectDeclarations(graph, path16, name, line) {
16572
+ const objects2 = graph.objectsAt(path16).filter((object2) => !mapIsModule(object2));
16571
16573
  const matching = name === void 0 ? objects2 : objects2.filter(
16572
16574
  (object2) => object2.name === name || name.includes(".") && graph.qualifiedName(object2.id) === name
16573
16575
  );
@@ -16589,12 +16591,12 @@ function requireMapObject(store, version2, selector, prefixes) {
16589
16591
  if ([entityRef, locator, symbol2].filter((value) => value !== void 0).length !== 1 || entityRef !== void 0 && !entityRef.length)
16590
16592
  throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
16591
16593
  if (symbol2) {
16592
- const path15 = normalizeProjectEvidencePath(symbol2.path);
16593
- if (!mapPathAllowed(path15, prefixes))
16594
+ const path16 = normalizeProjectEvidencePath(symbol2.path);
16595
+ if (!mapPathAllowed(path16, prefixes))
16594
16596
  throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
16595
16597
  const selected = mapSelectDeclarations(
16596
16598
  new MapViewGraph(store, version2),
16597
- path15,
16599
+ path16,
16598
16600
  symbol2.name,
16599
16601
  symbol2.line
16600
16602
  );
@@ -16605,14 +16607,14 @@ function requireMapObject(store, version2, selector, prefixes) {
16605
16607
  }
16606
16608
  let rows2;
16607
16609
  if (locator) {
16608
- const path15 = normalizeProjectEvidencePath(locator.path);
16610
+ const path16 = normalizeProjectEvidencePath(locator.path);
16609
16611
  if (!Number.isSafeInteger(locator.start) || locator.start < 0 || locator.kind !== void 0 && !MapObjectKindSchema.safeParse(locator.kind).success)
16610
16612
  throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
16611
- if (!mapPathAllowed(path15, prefixes))
16613
+ if (!mapPathAllowed(path16, prefixes))
16612
16614
  throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
16613
16615
  rows2 = store.database.prepare(`SELECT object_json FROM project_map_objects
16614
16616
  WHERE version_ref = ? AND path = ? AND json_extract(object_json, '$.anchor.start') = ?
16615
- AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path15, locator.start, locator.kind ?? null, locator.kind ?? null);
16617
+ AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path16, locator.start, locator.kind ?? null, locator.kind ?? null);
16616
16618
  } else {
16617
16619
  rows2 = store.database.prepare(
16618
16620
  "SELECT object_json FROM project_map_objects WHERE version_ref = ? AND entity_ref = ?"
@@ -16653,13 +16655,13 @@ function mapQueryPage(count, materialize, navigation, budget) {
16653
16655
 
16654
16656
  // src/project-map-query-selection.ts
16655
16657
  var mapQuerySelection = (input, knownKinds) => {
16656
- const path15 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
16658
+ const path16 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
16657
16659
  const kinds = input.kinds ?? knownKinds;
16658
16660
  if (!Array.isArray(kinds) || !kinds.length || kinds.length > knownKinds.length || kinds.some((kind) => !knownKinds.includes(kind)))
16659
16661
  throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
16660
- return { path: path15, kinds: [...new Set(kinds)].sort() };
16662
+ return { path: path16, kinds: [...new Set(kinds)].sort() };
16661
16663
  };
16662
- var mapQueryPathMatches = (path15, prefix) => prefix === "." || path15 === prefix || path15.startsWith(`${prefix}/`);
16664
+ var mapQueryPathMatches = (path16, prefix) => prefix === "." || path16 === prefix || path16.startsWith(`${prefix}/`);
16663
16665
  var mapQueryPathSql = (column) => `(? = '.' OR ${column} = ? OR substr(${column}, 1, length(?) + 1) = ? || '/')`;
16664
16666
 
16665
16667
  // src/project-map-search-focus.ts
@@ -16757,7 +16759,7 @@ var declarationKinds = /* @__PURE__ */ new Set([
16757
16759
  "METHOD",
16758
16760
  "TYPE"
16759
16761
  ]);
16760
- var fileStem = (path15) => path15.slice(path15.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
16762
+ var fileStem = (path16) => path16.slice(path16.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
16761
16763
  var compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
16762
16764
  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);
16763
16765
  function mapSearchQuery(input) {
@@ -16784,10 +16786,10 @@ function mapSearchQuery(input) {
16784
16786
  }
16785
16787
  function rank(object2, documentation, relationCount, query, focus) {
16786
16788
  const name = object2.name.toLowerCase();
16787
- const path15 = object2.anchor.path.toLowerCase();
16789
+ const path16 = object2.anchor.path.toLowerCase();
16788
16790
  const values = {
16789
16791
  NAME: [name],
16790
- PATH: [path15],
16792
+ PATH: [path16],
16791
16793
  DOCUMENTATION: documentation.map((text) => text.toLowerCase())
16792
16794
  };
16793
16795
  const matched = query.terms.map((term) => ({
@@ -16812,12 +16814,12 @@ function rank(object2, documentation, relationCount, query, focus) {
16812
16814
  score += 7e3;
16813
16815
  signals.push("SYMBOL_CONTAINS");
16814
16816
  } else if (matchedFields.includes("NAME")) signals.push("SYMBOL_CONTAINS");
16815
- if (object2.kind === "FILE" && fileStem(path15) === normalizedQuery) {
16817
+ if (object2.kind === "FILE" && fileStem(path16) === normalizedQuery) {
16816
16818
  score += 11e3;
16817
16819
  signals.push("EXACT_FILE_STEM");
16818
16820
  }
16819
16821
  if (matchedFields.includes("PATH")) {
16820
- score += path15.includes(normalizedQuery) ? 2500 : 0;
16822
+ score += path16.includes(normalizedQuery) ? 2500 : 0;
16821
16823
  signals.push("PATH_CONTAINS");
16822
16824
  }
16823
16825
  if (matchedFields.includes("DOCUMENTATION")) {
@@ -16832,8 +16834,8 @@ function rank(object2, documentation, relationCount, query, focus) {
16832
16834
  score += kindWeight[object2.kind] + Math.min(1200, relationCount * 20) + (focus?.score ?? 0);
16833
16835
  if (declarationKinds.has(object2.kind)) signals.push("DECLARATION");
16834
16836
  if (relationCount > 0) signals.push("GRAPH_CONNECTED");
16835
- const isTest = mapTestPath(path15);
16836
- const isGenerated = generatedPath.test(path15);
16837
+ const isTest = mapTestPath(path16);
16838
+ const isGenerated = generatedPath.test(path16);
16837
16839
  const hasTestIntent = query.terms.some((term) => testQuery.test(term));
16838
16840
  score += isTest ? hasTestIntent ? 1e3 : -5e3 : 300;
16839
16841
  score += isGenerated ? -3e3 : 300;
@@ -17317,13 +17319,13 @@ function utf16Offsets(text) {
17317
17319
  }
17318
17320
  function offsetConverter(files, offsets) {
17319
17321
  const converters = /* @__PURE__ */ new Map();
17320
- return (path15, offset) => {
17321
- let convert = converters.get(path15);
17322
+ return (path16, offset) => {
17323
+ let convert = converters.get(path16);
17322
17324
  if (!convert) {
17323
- const text = files[path15];
17325
+ const text = files[path16];
17324
17326
  if (text === void 0) return invalid();
17325
17327
  convert = offsets === "UTF16" ? (value) => value <= text.length ? value : invalid() : utf16Offsets(text);
17326
- converters.set(path15, convert);
17328
+ converters.set(path16, convert);
17327
17329
  }
17328
17330
  return convert(offset);
17329
17331
  };
@@ -17354,7 +17356,7 @@ function mapFactsAnalysis(facts, input, context) {
17354
17356
  const collect = new MapOutputCollector(output);
17355
17357
  const positions = new MapSourcePositions(input.files);
17356
17358
  const offset = offsetConverter(input.files, context.offsets);
17357
- const anchor = (path15, start, end) => positions.span(path15, offset(path15, start), offset(path15, end));
17359
+ const anchor = (path16, start, end) => positions.span(path16, offset(path16, start), offset(path16, end));
17358
17360
  const located = /* @__PURE__ */ new Map();
17359
17361
  const canonical = /* @__PURE__ */ new Map();
17360
17362
  const bySpan = /* @__PURE__ */ new Map();
@@ -17921,8 +17923,8 @@ var goModule = /(?:^|\/)go\.mod$/u;
17921
17923
  var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
17922
17924
  var GO_MAP_LANGUAGE = Object.freeze({
17923
17925
  id: "go-1.24-map-v9",
17924
- claims: (path15) => path15.endsWith(".go"),
17925
- reads: (path15) => goModule.test(path15),
17926
+ claims: (path16) => path16.endsWith(".go"),
17927
+ reads: (path16) => goModule.test(path16),
17926
17928
  // A module path, or the standard library, whose first path element has no dot.
17927
17929
  importName: (specifier) => {
17928
17930
  const parts = specifier.split("/");
@@ -17931,7 +17933,7 @@ var GO_MAP_LANGUAGE = Object.freeze({
17931
17933
  return parts.slice(0, size).join("/");
17932
17934
  },
17933
17935
  // Go imports a package: the directory of the file.
17934
- importTarget: (path15) => `${path15.slice(0, path15.lastIndexOf("/") + 1) || "./"}`,
17936
+ importTarget: (path16) => `${path16.slice(0, path16.lastIndexOf("/") + 1) || "./"}`,
17935
17937
  create: () => new GoMapAnalyzer()
17936
17938
  });
17937
17939
  var GO_GAPS = [
@@ -17977,12 +17979,12 @@ var GoMapAnalyzer = class {
17977
17979
  }
17978
17980
  }
17979
17981
  async analyze(session, signal) {
17980
- const modules = session.readable.map((entry) => entry.path).filter((path15) => goModule.test(path15)).sort();
17981
- const moduleOf = (path15) => {
17982
+ const modules = session.readable.map((entry) => entry.path).filter((path16) => goModule.test(path16)).sort();
17983
+ const moduleOf = (path16) => {
17982
17984
  let best;
17983
17985
  for (const modFile of modules) {
17984
17986
  const directory = modFile.slice(0, modFile.lastIndexOf("/") + 1);
17985
- if (path15.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
17987
+ if (path16.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
17986
17988
  best = modFile;
17987
17989
  }
17988
17990
  return best;
@@ -17998,11 +18000,11 @@ var GoMapAnalyzer = class {
17998
18000
  for (const modFile of [...groups.keys()].sort()) {
17999
18001
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
18000
18002
  const files = /* @__PURE__ */ Object.create(null);
18001
- for (const path15 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
18002
- const text = session.texts[path15];
18003
+ for (const path16 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
18004
+ const text = session.texts[path16];
18003
18005
  if (text === void 0)
18004
18006
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18005
- files[path15] = text;
18007
+ files[path16] = text;
18006
18008
  }
18007
18009
  const input = {
18008
18010
  contextRef: digestValue({
@@ -18037,8 +18039,8 @@ var GoMapAnalyzer = class {
18037
18039
  if (text === void 0 || !existsSync3(this.resources.compilerPath))
18038
18040
  throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
18039
18041
  const files = /* @__PURE__ */ Object.create(null);
18040
- for (const [path15, value] of Object.entries(input.files))
18041
- if (this.claims(path15) || goModule.test(path15)) files[path15] = value;
18042
+ for (const [path16, value] of Object.entries(input.files))
18043
+ if (this.claims(path16) || goModule.test(path16)) files[path16] = value;
18042
18044
  const facts = await this.operation(
18043
18045
  {
18044
18046
  ...input,
@@ -18068,14 +18070,14 @@ var BUILD_FILES = [
18068
18070
  "pom.xml"
18069
18071
  ];
18070
18072
  var buildFile = /(?:^|\/)(?:pom\.xml|(?:build|settings)\.gradle(?:\.kts)?)$/u;
18071
- var directoryOf = (path15) => path15.slice(0, path15.lastIndexOf("/") + 1);
18072
- var nameOf = (path15) => path15.slice(path15.lastIndexOf("/") + 1);
18073
+ var directoryOf = (path16) => path16.slice(0, path16.lastIndexOf("/") + 1);
18074
+ var nameOf = (path16) => path16.slice(path16.lastIndexOf("/") + 1);
18073
18075
  var DEFAULT_RELEASE = 21;
18074
18076
  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;
18075
18077
  var JAVA_MAP_LANGUAGE = Object.freeze({
18076
18078
  id: "javac-lombok-1.18.48-map-v8",
18077
- claims: (path15) => path15.endsWith(".java"),
18078
- reads: (path15) => buildFile.test(path15),
18079
+ claims: (path16) => path16.endsWith(".java"),
18080
+ reads: (path16) => buildFile.test(path16),
18079
18081
  // A package of the Java platform, or a library named by its first two package segments.
18080
18082
  importName: (specifier) => platformPackage.test(specifier) ? "Java standard library" : specifier.split(".").slice(0, 2).join("."),
18081
18083
  create: () => new JavaMapAnalyzer()
@@ -18165,12 +18167,12 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18165
18167
  // The worker's request for a context: the Java sources, the release and which are tests.
18166
18168
  request(input, buildTexts) {
18167
18169
  const files = /* @__PURE__ */ Object.create(null);
18168
- for (const [path15, text] of Object.entries(input.files))
18169
- if (this.claims(path15)) files[path15] = text;
18170
+ for (const [path16, text] of Object.entries(input.files))
18171
+ if (this.claims(path16)) files[path16] = text;
18170
18172
  return {
18171
18173
  files,
18172
18174
  release: javaRelease(buildTexts, this.resources.runtimeVersion),
18173
- tests: Object.keys(files).filter((path15) => mapTestPath(path15))
18175
+ tests: Object.keys(files).filter((path16) => mapTestPath(path16))
18174
18176
  };
18175
18177
  }
18176
18178
  // The build files of a context's root directory, which declare its Java version.
@@ -18182,35 +18184,35 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18182
18184
  }
18183
18185
  async analyze(session, signal) {
18184
18186
  this.refreshRuntime();
18185
- const builds = session.readable.map((entry) => entry.path).filter((path15) => buildFile.test(path15));
18186
- for (const path15 of builds) session.configuration(path15);
18187
- const rank2 = (path15) => BUILD_FILES.indexOf(nameOf(path15));
18187
+ const builds = session.readable.map((entry) => entry.path).filter((path16) => buildFile.test(path16));
18188
+ for (const path16 of builds) session.configuration(path16);
18189
+ const rank2 = (path16) => BUILD_FILES.indexOf(nameOf(path16));
18188
18190
  const roots = /* @__PURE__ */ new Map();
18189
18191
  const modules = /* @__PURE__ */ new Map();
18190
- for (const path15 of builds) {
18191
- const directory = directoryOf(path15);
18192
+ for (const path16 of builds) {
18193
+ const directory = directoryOf(path16);
18192
18194
  const current = modules.get(directory);
18193
- if (current === void 0 || rank2(path15) < rank2(current)) modules.set(directory, path15);
18194
- const text = session.texts[path15] ?? "";
18195
- if (/settings\.gradle(?:\.kts)?$/u.test(path15) || path15.endsWith("pom.xml") && /<modules>/u.test(text)) {
18195
+ if (current === void 0 || rank2(path16) < rank2(current)) modules.set(directory, path16);
18196
+ const text = session.texts[path16] ?? "";
18197
+ if (/settings\.gradle(?:\.kts)?$/u.test(path16) || path16.endsWith("pom.xml") && /<modules>/u.test(text)) {
18196
18198
  const root = roots.get(directory);
18197
- if (root === void 0 || rank2(path15) < rank2(root)) roots.set(directory, path15);
18199
+ if (root === void 0 || rank2(path16) < rank2(root)) roots.set(directory, path16);
18198
18200
  }
18199
18201
  }
18200
- const configOf = (path15) => {
18202
+ const configOf = (path16) => {
18201
18203
  let outer;
18202
18204
  for (const directory of roots.keys())
18203
- if (path15.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
18205
+ if (path16.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
18204
18206
  outer = directory;
18205
18207
  if (outer !== void 0) return roots.get(outer);
18206
18208
  let nearest;
18207
18209
  for (const directory of modules.keys())
18208
- if (path15.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
18210
+ if (path16.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
18209
18211
  nearest = directory;
18210
18212
  return nearest === void 0 ? "" : modules.get(nearest);
18211
18213
  };
18212
- const output = (path15) => [...modules.keys()].some(
18213
- (directory) => path15.startsWith(`${directory}build/`) || path15.startsWith(`${directory}target/`)
18214
+ const output = (path16) => [...modules.keys()].some(
18215
+ (directory) => path16.startsWith(`${directory}build/`) || path16.startsWith(`${directory}target/`)
18214
18216
  );
18215
18217
  const groups = /* @__PURE__ */ new Map();
18216
18218
  for (const entry of session.readable) {
@@ -18225,13 +18227,13 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18225
18227
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
18226
18228
  const files = /* @__PURE__ */ Object.create(null);
18227
18229
  const rootBuilds = configPath ? BUILD_FILES.map((name) => `${directoryOf(configPath)}${name}`).filter(
18228
- (path15) => builds.includes(path15)
18230
+ (path16) => builds.includes(path16)
18229
18231
  ) : [];
18230
- for (const path15 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
18231
- const text = session.texts[path15];
18232
+ for (const path16 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
18233
+ const text = session.texts[path16];
18232
18234
  if (text === void 0)
18233
18235
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18234
- files[path15] = text;
18236
+ files[path16] = text;
18235
18237
  }
18236
18238
  const input = {
18237
18239
  contextRef: digestValue({
@@ -18274,7 +18276,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18274
18276
  const prior = JavaStateSchema.safeParse(previous?.state).data;
18275
18277
  const incremental = previous && prior?.basis === basis ? {
18276
18278
  changed: Object.keys(request.files).filter(
18277
- (path15) => digests.get(path15) !== previous.digests.get(path15)
18279
+ (path16) => digests.get(path16) !== previous.digests.get(path16)
18278
18280
  ),
18279
18281
  state: prior.java
18280
18282
  } : void 0;
@@ -18303,14 +18305,14 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
18303
18305
  continue;
18304
18306
  }
18305
18307
  const focus = new Set(facts.focus);
18306
- if (!incremental || facts.focus.some((path15) => !Object.hasOwn(request.files, path15)) || incremental.changed.some((path15) => !focus.has(path15)))
18308
+ if (!incremental || facts.focus.some((path16) => !Object.hasOwn(request.files, path16)) || incremental.changed.some((path16) => !focus.has(path16)))
18307
18309
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18308
18310
  analysis.objects = analysis.objects.filter((object2) => focus.has(object2.anchor.path));
18309
18311
  analysis.relations = analysis.relations.filter((relation) => focus.has(relation.anchor.path));
18310
18312
  analysis.notes = analysis.notes.filter((note) => focus.has(note.anchor.path));
18311
18313
  session.accept(analysis, {
18312
18314
  state,
18313
- linked: analysis.parsedFiles.filter((path15) => !focus.has(path15))
18315
+ linked: analysis.parsedFiles.filter((path16) => !focus.has(path16))
18314
18316
  });
18315
18317
  }
18316
18318
  }
@@ -18622,12 +18624,12 @@ var PYTHON_STANDARD_LIBRARY = /* @__PURE__ */ new Set([
18622
18624
  // src/project-map-language-python.ts
18623
18625
  var CONFIGURATION = ["pyrightconfig.json", "pyproject.toml", "setup.cfg"];
18624
18626
  var pythonConfig = /(?:^|\/)(?:pyrightconfig\.json|pyproject\.toml|setup\.cfg)$/u;
18625
- var directoryOf2 = (path15) => path15.slice(0, path15.lastIndexOf("/") + 1);
18627
+ var directoryOf2 = (path16) => path16.slice(0, path16.lastIndexOf("/") + 1);
18626
18628
  var DEFAULT_PYTHON = { major: 3, minor: 13 };
18627
18629
  var PYTHON_MAP_LANGUAGE = Object.freeze({
18628
18630
  id: "pyright-1.1.414-map-v13",
18629
- claims: (path15) => /\.pyi?$/u.test(path15),
18630
- reads: (path15) => pythonConfig.test(path15),
18631
+ claims: (path16) => /\.pyi?$/u.test(path16),
18632
+ reads: (path16) => pythonConfig.test(path16),
18631
18633
  // An absolute import names the standard library or a distribution's top-level package.
18632
18634
  importName: (specifier) => {
18633
18635
  const top = specifier.split(".", 1)[0] ?? specifier;
@@ -18679,21 +18681,21 @@ var PythonMapAnalyzer = class {
18679
18681
  return {
18680
18682
  root: input.configPath ? directoryOf2(input.configPath).replace(/\/$/u, "") : "",
18681
18683
  pythonVersion: pythonVersion(input.files, input.configPath),
18682
- tests: Object.keys(input.files).filter((path15) => this.claims(path15) && mapTestPath(path15))
18684
+ tests: Object.keys(input.files).filter((path16) => this.claims(path16) && mapTestPath(path16))
18683
18685
  };
18684
18686
  }
18685
18687
  async analyze(session, signal) {
18686
18688
  const roots = /* @__PURE__ */ new Map();
18687
- for (const path15 of session.readable.map((entry) => entry.path).filter((path16) => pythonConfig.test(path16))) {
18688
- const directory = directoryOf2(path15);
18689
+ for (const path16 of session.readable.map((entry) => entry.path).filter((path17) => pythonConfig.test(path17))) {
18690
+ const directory = directoryOf2(path16);
18689
18691
  const current = roots.get(directory);
18690
18692
  const rank2 = (file2) => CONFIGURATION.indexOf(file2.slice(directory.length));
18691
- if (current === void 0 || rank2(path15) < rank2(current)) roots.set(directory, path15);
18693
+ if (current === void 0 || rank2(path16) < rank2(current)) roots.set(directory, path16);
18692
18694
  }
18693
- const rootOf = (path15) => {
18695
+ const rootOf = (path16) => {
18694
18696
  let best;
18695
18697
  for (const directory of roots.keys())
18696
- if (path15.startsWith(directory) && (best === void 0 || directory.length > best.length))
18698
+ if (path16.startsWith(directory) && (best === void 0 || directory.length > best.length))
18697
18699
  best = directory;
18698
18700
  return best === void 0 ? "" : roots.get(best);
18699
18701
  };
@@ -18708,11 +18710,11 @@ var PythonMapAnalyzer = class {
18708
18710
  for (const configPath of [...groups.keys()].sort()) {
18709
18711
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
18710
18712
  const files = /* @__PURE__ */ Object.create(null);
18711
- for (const path15 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
18712
- const text = session.texts[path15];
18713
+ for (const path16 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
18714
+ const text = session.texts[path16];
18713
18715
  if (text === void 0)
18714
18716
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18715
- files[path15] = text;
18717
+ files[path16] = text;
18716
18718
  }
18717
18719
  const input = {
18718
18720
  contextRef: digestValue({
@@ -18760,8 +18762,8 @@ var PythonMapAnalyzer = class {
18760
18762
  if (input.files[reference.targetPath] === void 0)
18761
18763
  throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
18762
18764
  const files = /* @__PURE__ */ Object.create(null);
18763
- for (const [path15, value] of Object.entries(input.files))
18764
- if (this.claims(path15) || pythonConfig.test(path15)) files[path15] = value;
18765
+ for (const [path16, value] of Object.entries(input.files))
18766
+ if (this.claims(path16) || pythonConfig.test(path16)) files[path16] = value;
18765
18767
  const facts = await this.operation(
18766
18768
  {
18767
18769
  ...input,
@@ -18786,8 +18788,10 @@ import {
18786
18788
  isIdentifier,
18787
18789
  isMethodDeclaration,
18788
18790
  isObjectLiteralExpression,
18791
+ isPropertyAccessExpression,
18789
18792
  isPropertyAssignment,
18790
- isStringLiteral
18793
+ isStringLiteral,
18794
+ SyntaxKind
18791
18795
  } from "typescript/unstable/ast";
18792
18796
  var mapMiniprogramTemplate = (file2) => file2.endsWith(".wxml");
18793
18797
  var templateOf = (script) => script.replace(/\.[cm]?[jt]sx?$/u, ".wxml");
@@ -18802,12 +18806,16 @@ function miniprogramConfiguration(template, inventory) {
18802
18806
  if (!root) return configuration;
18803
18807
  }
18804
18808
  }
18809
+ var miniprogramEventOf = (target) => {
18810
+ const match = /^<([^>]+)> (\S+) event$/u.exec(target);
18811
+ return match?.[1] && match[2] ? { tag: match[1], event: match[2] } : void 0;
18812
+ };
18805
18813
 
18806
18814
  // src/project-map-language-typescript.ts
18807
18815
  var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
18808
- id: "typescript-7.0.2-map-v19",
18809
- claims: (path15) => /\.[cm]?[jt]sx?$/u.test(path15),
18810
- reads: (path15) => path15.endsWith(".json") || path15.endsWith(".wxml") || path15 === "pnpm-workspace.yaml",
18816
+ id: "typescript-7.0.2-map-v20",
18817
+ claims: (path16) => /\.[cm]?[jt]sx?$/u.test(path16),
18818
+ reads: (path16) => path16.endsWith(".json") || path16.endsWith(".wxml") || path16 === "pnpm-workspace.yaml",
18811
18819
  create: () => new TypeScriptMapAnalyzer()
18812
18820
  });
18813
18821
  var CONFIGURATIONS_KEPT = 4;
@@ -18929,9 +18937,9 @@ var TypeScriptMapAnalyzer = class {
18929
18937
  accept(analysis);
18930
18938
  return;
18931
18939
  }
18932
- const required2 = analysis.requiredFiles.map((path15) => {
18933
- const entry = byPath.get(path15);
18934
- if (!entry || Object.hasOwn(texts, path15))
18940
+ const required2 = analysis.requiredFiles.map((path16) => {
18941
+ const entry = byPath.get(path16);
18942
+ if (!entry || Object.hasOwn(texts, path16))
18935
18943
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
18936
18944
  return entry;
18937
18945
  });
@@ -18989,16 +18997,16 @@ var MAP_LANGUAGES = Object.freeze([
18989
18997
  ]);
18990
18998
  var mapAnalyzerSuite = (languages) => languages.map((language) => language.id).sort().join("+");
18991
18999
  var PROJECT_MAP_ANALYZER = mapAnalyzerSuite(MAP_LANGUAGES);
18992
- var mapCodePath = (path15) => MAP_LANGUAGES.some((language) => language.claims(path15));
18993
- var languageOf = (path15) => MAP_LANGUAGES.find((language) => language.claims(path15));
18994
- var mapLanguageOf = (path15) => languageOf(path15)?.id;
19000
+ var mapCodePath = (path16) => MAP_LANGUAGES.some((language) => language.claims(path16));
19001
+ var languageOf = (path16) => MAP_LANGUAGES.find((language) => language.claims(path16));
19002
+ var mapLanguageOf = (path16) => languageOf(path16)?.id;
18995
19003
  var npmPackage = (specifier) => {
18996
19004
  if (specifier.startsWith("node:")) return "node:*";
18997
19005
  const parts = specifier.split("/");
18998
19006
  return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? specifier;
18999
19007
  };
19000
19008
  var mapExternalImport = (sourcePath, specifier) => languageOf(sourcePath)?.importName?.(specifier) ?? npmPackage(specifier);
19001
- var mapImportTarget = (path15) => languageOf(path15)?.importTarget?.(path15) ?? path15;
19009
+ var mapImportTarget = (path16) => languageOf(path16)?.importTarget?.(path16) ?? path16;
19002
19010
 
19003
19011
  // src/project-map-view.ts
19004
19012
  var MAP_VIEW_FORMAT = "PROJECT_MAP_VIEW_V1";
@@ -19037,10 +19045,10 @@ var notFound = () => {
19037
19045
  };
19038
19046
  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";
19039
19047
  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.`;
19040
- var within = (path15, directory) => directory === "." || path15.startsWith(`${directory}/`);
19041
- var parentDirectory = (path15) => {
19042
- const slash = path15.lastIndexOf("/");
19043
- return slash < 0 ? "." : path15.slice(0, slash);
19048
+ var within = (path16, directory) => directory === "." || path16.startsWith(`${directory}/`);
19049
+ var parentDirectory = (path16) => {
19050
+ const slash = path16.lastIndexOf("/");
19051
+ return slash < 0 ? "." : path16.slice(0, slash);
19044
19052
  };
19045
19053
  var compareText2 = (left, right) => left < right ? -1 : left > right ? 1 : 0;
19046
19054
  var byCount = ([leftName, left], [rightName, right]) => right - left || compareText2(leftName, rightName);
@@ -19114,7 +19122,7 @@ function pageBlocks(view, head, whole, offset, budget) {
19114
19122
  if (offset === blocks.length) return materialize(0);
19115
19123
  return mapQueryPage(blocks.length - offset, materialize, (page) => page, budget);
19116
19124
  }
19117
- var inModule = (path15, module) => module.direct ? parentDirectory(path15) === module.directory : within(path15, module.directory);
19125
+ var inModule = (path16, module) => module.direct ? parentDirectory(path16) === module.directory : within(path16, module.directory);
19118
19126
  var moduleLabel = (module) => module.direct ? `${module.directory === "." ? "" : `${module.directory}/`}* (files directly here)` : `${module.directory}/`;
19119
19127
  function childModules(module, files) {
19120
19128
  if (module.direct) return [];
@@ -19169,9 +19177,9 @@ function mapProjectModules(entries) {
19169
19177
  (entry) => entry.state === "TEXT" && mapCodePath(entry.path) && !mapTestPath(entry.path)
19170
19178
  ).map((entry) => entry.path)
19171
19179
  );
19172
- return (path15) => {
19173
- if (mapTestPath(path15)) return void 0;
19174
- const module = modules.find((candidate) => inModule(path15, candidate));
19180
+ return (path16) => {
19181
+ if (mapTestPath(path16)) return void 0;
19182
+ const module = modules.find((candidate) => inModule(path16, candidate));
19175
19183
  return module && moduleLabel(module);
19176
19184
  };
19177
19185
  }
@@ -19283,12 +19291,12 @@ function loadMemberCalls(store, version2) {
19283
19291
  FROM project_map_relations
19284
19292
  WHERE version_ref = ? AND to_ref IS NULL AND json_extract(relation_json, '$.kind') = 'CALLS'
19285
19293
  AND json_extract(relation_json, '$.unresolvedReason') IN ('SYMBOL_NOT_RESOLVED', 'SYNTAX_ONLY')`).all(version2)) {
19286
- const path15 = String(row.path);
19294
+ const path16 = String(row.path);
19287
19295
  const target = String(row.target);
19288
19296
  const name = MEMBER_NAME.exec(target)?.[1];
19289
- const language = mapLanguageOf(path15);
19297
+ const language = mapLanguageOf(path16);
19290
19298
  if (!name || !language) continue;
19291
- const call = { from: String(row.from_ref), path: path15, line: Number(row.line), target };
19299
+ const call = { from: String(row.from_ref), path: path16, line: Number(row.line), target };
19292
19300
  const key = memberKey(language, name);
19293
19301
  const known = calls.get(key);
19294
19302
  if (known) known.push(call);
@@ -19343,10 +19351,10 @@ function loadCoverageNotes(store, version2) {
19343
19351
  if (!codes.includes(gap.code)) codes.push(gap.code);
19344
19352
  files.set(gap.path, codes);
19345
19353
  }
19346
- for (const [path15, codes] of files)
19354
+ for (const [path16, codes] of files)
19347
19355
  if (codes.length > 1 && codes.includes("NOT_IN_PARSED_CONTEXT"))
19348
19356
  files.set(
19349
- path15,
19357
+ path16,
19350
19358
  codes.filter((code) => code !== "NOT_IN_PARSED_CONTEXT")
19351
19359
  );
19352
19360
  return { files, limits: [...limits] };
@@ -19386,9 +19394,9 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19386
19394
  const visiblePaths = new Set(visible.map((entry) => entry.path));
19387
19395
  const code = visible.filter((entry) => entry.state === "TEXT" && mapCodePath(entry.path)).map((entry) => entry.path);
19388
19396
  const modules = mapModules(directory, code);
19389
- const moduleOf = (path15) => modules.find((module) => inModule(path15, module));
19390
- const outside = (path15) => {
19391
- const parts = path15.split("/");
19397
+ const moduleOf = (path16) => modules.find((module) => inModule(path16, module));
19398
+ const outside = (path16) => {
19399
+ const parts = path16.split("/");
19392
19400
  return `${parts.slice(0, Math.min(2, parts.length - 1)).join("/") || "."}/ (outside)`;
19393
19401
  };
19394
19402
  const moduleImports = /* @__PURE__ */ new Map();
@@ -19413,8 +19421,8 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19413
19421
  const blocks = [];
19414
19422
  if (modules.length > 1) {
19415
19423
  const sizes = /* @__PURE__ */ new Map();
19416
- for (const path15 of code) {
19417
- const module = moduleOf(path15);
19424
+ for (const path16 of code) {
19425
+ const module = moduleOf(path16);
19418
19426
  if (module) increment(sizes, moduleLabel(module));
19419
19427
  }
19420
19428
  blocks.push(
@@ -19443,18 +19451,18 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19443
19451
  )}${packages.length > shown.length ? `, +${packages.length - shown.length} more` : ""}`
19444
19452
  );
19445
19453
  }
19446
- const lineCount = (path15) => {
19447
- const file2 = facts.files.get(path15);
19448
- const gaps = coverage.files.get(path15) ?? [];
19454
+ const lineCount = (path16) => {
19455
+ const file2 = facts.files.get(path16);
19456
+ const gaps = coverage.files.get(path16) ?? [];
19449
19457
  if (file2?.parsed === false) return `[not parsed${gaps.length ? `: ${gaps.join("; ")}` : ""}]`;
19450
19458
  return `${file2 ? `${file2.lines}L` : "?L"}${gaps.length ? ` [${gaps.join("; ")}]` : ""}`;
19451
19459
  };
19452
19460
  const codeDirectories = /* @__PURE__ */ new Set();
19453
- for (const path15 of code)
19454
- for (let parent = parentDirectory(path15); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
19461
+ for (const path16 of code)
19462
+ for (let parent = parentDirectory(path16); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
19455
19463
  codeDirectories.add(parent);
19456
- const groupOf = (path15) => {
19457
- let group = parentDirectory(path15);
19464
+ const groupOf = (path16) => {
19465
+ let group = parentDirectory(path16);
19458
19466
  for (let parent = group; parent !== "." && parent !== directory && !codeDirectories.has(parent); parent = parentDirectory(parent))
19459
19467
  group = parent;
19460
19468
  return group;
@@ -19486,11 +19494,11 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19486
19494
  ]);
19487
19495
  }
19488
19496
  const detailed = [
19489
- ...code.map((path15) => {
19490
- const declarations2 = (facts.exported.get(path15) ?? []).map(({ text: text2 }) => text2);
19497
+ ...code.map((path16) => {
19498
+ const declarations2 = (facts.exported.get(path16) ?? []).map(({ text: text2 }) => text2);
19491
19499
  return [
19492
- path15,
19493
- `${path15} ${lineCount(path15)}${declarations2.length ? `: ${declarations2.join(", ")}` : ""}`
19500
+ path16,
19501
+ `${path16} ${lineCount(path16)}${declarations2.length ? `: ${declarations2.join(", ")}` : ""}`
19494
19502
  ];
19495
19503
  }),
19496
19504
  ...listedOther.map((entry) => [
@@ -19501,7 +19509,7 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19501
19509
  ];
19502
19510
  const directories = /* @__PURE__ */ new Map();
19503
19511
  for (const entry of [
19504
- ...code.map((path15) => ({ path: path15, item: lineCount(path15) })),
19512
+ ...code.map((path16) => ({ path: path16, item: lineCount(path16) })),
19505
19513
  ...listedOther.map((entry2) => ({
19506
19514
  path: entry2.path,
19507
19515
  item: entry2.state === "TEXT" ? "" : `(${entry2.state})`
@@ -19529,10 +19537,10 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19529
19537
  );
19530
19538
  const text = visible.filter((entry) => entry.state === "TEXT").length;
19531
19539
  const resolution = /* @__PURE__ */ new Map();
19532
- for (const path15 of code) {
19533
- const counts = facts.calls.get(path15);
19540
+ for (const path16 of code) {
19541
+ const counts = facts.calls.get(path16);
19534
19542
  if (!counts) continue;
19535
- const language = facts.files.get(path15)?.language ?? "unknown";
19543
+ const language = facts.files.get(path16)?.language ?? "unknown";
19536
19544
  const total = resolution.get(language) ?? { resolved: 0, unresolved: 0, external: 0 };
19537
19545
  total.resolved += counts.resolved;
19538
19546
  total.unresolved += counts.unresolved;
@@ -19591,8 +19599,8 @@ var DeclarationGroups = class {
19591
19599
  prefixes;
19592
19600
  showTests;
19593
19601
  memberCalls;
19594
- visible(path15) {
19595
- return mapPathAllowed(path15, this.prefixes) && (this.showTests || !mapTestPath(path15));
19602
+ visible(path16) {
19603
+ return mapPathAllowed(path16, this.prefixes) && (this.showTests || !mapTestPath(path16));
19596
19604
  }
19597
19605
  entry(object2, imported = false) {
19598
19606
  if (mapMiniprogramTemplate(object2.anchor.path)) return "(template)";
@@ -19637,11 +19645,11 @@ var DeclarationGroups = class {
19637
19645
  value.lines.push(line);
19638
19646
  aggregates.set(key, value);
19639
19647
  };
19640
- const dispatch = (arrow, label, ref2, path15, line) => {
19648
+ const dispatch = (arrow, label, ref2, path16, line) => {
19641
19649
  const other = graph.object(graph.owner(ref2));
19642
19650
  if (owned.has(other.id)) return;
19643
- if (!this.visible(path15)) {
19644
- if (mapPathAllowed(path15, this.prefixes)) omittedTests++;
19651
+ if (!this.visible(path16)) {
19652
+ if (mapPathAllowed(path16, this.prefixes)) omittedTests++;
19645
19653
  return;
19646
19654
  }
19647
19655
  add(arrow, label, other, line);
@@ -19798,7 +19806,7 @@ var DeclarationGroups = class {
19798
19806
  else files2.set(call.path, [item]);
19799
19807
  }
19800
19808
  lines.push(
19801
- ` \u2190 possible callers by name: ${[...files2].map(([path15, items]) => `${path15}: ${items.join(", ")}`).join("; ")}${inTests}`
19809
+ ` \u2190 possible callers by name: ${[...files2].map(([path16, items]) => `${path16}: ${items.join(", ")}`).join("; ")}${inTests}`
19802
19810
  );
19803
19811
  } else if (possibleInTests)
19804
19812
  lines.push(` \u2190 possible callers by name: ${possibleInTests} in test files (includeTests)`);
@@ -19834,14 +19842,14 @@ var DeclarationGroups = class {
19834
19842
  return { lines, neighbors: [...new Set(neighbors)] };
19835
19843
  }
19836
19844
  };
19837
- function fileView(store, coverage, graph, input, path15, prefixes) {
19838
- const entry = store.getEntry(input.version, path15);
19839
- if (!entry || !mapPathAllowed(path15, prefixes)) return notFound();
19840
- const showTests = input.includeTests === true || mapTestPath(path15);
19841
- const module = mapCodePath(path15) ? graph.objectsAt(path15).find((object2) => mapIsModule(object2)) : mapMiniprogramTemplate(path15) ? graph.objectsAt(path15).find((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : void 0;
19842
- const gaps = coverage.files.get(path15) ?? [];
19845
+ function fileView(store, coverage, graph, input, path16, prefixes) {
19846
+ const entry = store.getEntry(input.version, path16);
19847
+ if (!entry || !mapPathAllowed(path16, prefixes)) return notFound();
19848
+ const showTests = input.includeTests === true || mapTestPath(path16);
19849
+ const module = mapCodePath(path16) ? graph.objectsAt(path16).find((object2) => mapIsModule(object2)) : mapMiniprogramTemplate(path16) ? graph.objectsAt(path16).find((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : void 0;
19850
+ const gaps = coverage.files.get(path16) ?? [];
19843
19851
  const head = [
19844
- `PROJECT MAP \xB7 FILE ${path15} \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`}`
19852
+ `PROJECT MAP \xB7 FILE ${path16} \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`}`
19845
19853
  ];
19846
19854
  if (!module || entry.state !== "TEXT")
19847
19855
  return pageBlocks("FILE", head, [], input.offset ?? 0, input.outputBudget);
@@ -19861,7 +19869,7 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
19861
19869
  tags.set(relation.from, list);
19862
19870
  }
19863
19871
  const describe3 = (object2) => [
19864
- `${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path15 ? "" : ` (${object2.anchor.path})`}`,
19872
+ `${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path16 ? "" : ` (${object2.anchor.path})`}`,
19865
19873
  ...tags.get(object2.id) ?? []
19866
19874
  ].join(" ");
19867
19875
  const declarations2 = [];
@@ -19876,11 +19884,11 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
19876
19884
  );
19877
19885
  }
19878
19886
  const elsewhere = /* @__PURE__ */ new Map();
19879
- for (const object2 of graph.objectsAt(path15)) {
19887
+ for (const object2 of graph.objectsAt(path16)) {
19880
19888
  const parent = mapIsModule(object2) ? void 0 : graph.parent(object2.id);
19881
19889
  if (parent === void 0 || !graph.isAddressable(object2)) continue;
19882
19890
  const container = graph.object(parent);
19883
- if (mapIsModule(container) || container.anchor.path === path15) continue;
19891
+ if (mapIsModule(container) || container.anchor.path === path16) continue;
19884
19892
  const into = elsewhere.get(parent);
19885
19893
  if (into) into.push(object2);
19886
19894
  else elsewhere.set(parent, [object2]);
@@ -19894,7 +19902,7 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
19894
19902
  if (declarations2.length) blocks.push(["DECLARATIONS (* exported)", ...declarations2].join("\n"));
19895
19903
  const imports2 = /* @__PURE__ */ new Set();
19896
19904
  const external = /* @__PURE__ */ new Set();
19897
- const fileObjects = graph.objectsAt(path15).map((object2) => object2.id);
19905
+ const fileObjects = graph.objectsAt(path16).map((object2) => object2.id);
19898
19906
  for (const relation of graph.relationsFrom(fileObjects)) {
19899
19907
  if (!IMPORT_KINDS.has(relation.kind)) continue;
19900
19908
  if (relation.to === void 0) external.add(relation.target);
@@ -19905,8 +19913,8 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
19905
19913
  }
19906
19914
  const importers = /* @__PURE__ */ new Set();
19907
19915
  const testImporters = /* @__PURE__ */ new Set();
19908
- const imported = mapImportTarget(path15);
19909
- const packageModules = imported === path15 ? [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);
19916
+ const imported = mapImportTarget(path16);
19917
+ const packageModules = imported === path16 ? [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);
19910
19918
  for (const relation of graph.relationsTo(packageModules)) {
19911
19919
  if (!IMPORT_KINDS.has(relation.kind)) continue;
19912
19920
  const source = relation.anchor.path;
@@ -19934,16 +19942,16 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
19934
19942
  if (scope.length) blocks.push(["MODULE SCOPE (top-level statements)", ...scope].join("\n"));
19935
19943
  return pageBlocks("FILE", head, blocks, input.offset ?? 0, input.outputBudget);
19936
19944
  }
19937
- function declarationView(graph, input, path15, prefixes, memberCalls) {
19945
+ function declarationView(graph, input, path16, prefixes, memberCalls) {
19938
19946
  const requested = input.depth ?? 1;
19939
19947
  if (!Number.isSafeInteger(requested) || requested < 1 || requested > MAP_VIEW_LIMITS.directedDepth)
19940
19948
  return invalid2();
19941
19949
  const both = (input.direction ?? "BOTH") === "BOTH";
19942
19950
  const depth = both ? Math.min(requested, MAP_VIEW_LIMITS.bothDepth) : requested;
19943
19951
  const { name, line } = input;
19944
- const selected = mapSelectDeclarations(graph, path15, name, line);
19952
+ const selected = mapSelectDeclarations(graph, path16, name, line);
19945
19953
  if (!selected.length) return notFound();
19946
- const showTests = input.includeTests === true || mapTestPath(path15);
19954
+ const showTests = input.includeTests === true || mapTestPath(path16);
19947
19955
  const groups = new DeclarationGroups(graph, input, prefixes, showTests, memberCalls);
19948
19956
  const blocks = [];
19949
19957
  const seen = /* @__PURE__ */ new Set();
@@ -19991,7 +19999,7 @@ function declarationView(graph, input, path15, prefixes, memberCalls) {
19991
19999
  );
19992
20000
  }
19993
20001
  const head = [
19994
- `PROJECT MAP \xB7 DECLARATION ${path15}${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"}`,
20002
+ `PROJECT MAP \xB7 DECLARATION ${path16}${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"}`,
19995
20003
  ...truncated ? [`Expansion stopped at ${MAP_VIEW_LIMITS.declarations} declarations.`] : [],
19996
20004
  ...(input.direction ?? "BOTH") === "OUTGOING" ? [] : [callerCoverage(input.textSearch ?? DEFAULT_TEXT_SEARCH)]
19997
20005
  ];
@@ -20118,10 +20126,10 @@ var ProjectMapQuery = class {
20118
20126
  view(input, signal) {
20119
20127
  this.requireReadableMap(input.version, signal);
20120
20128
  const { offset, prefixes } = admission(input);
20121
- const path15 = normalizeProjectEvidencePath(input.path, true) || ".";
20129
+ const path16 = normalizeProjectEvidencePath(input.path, true) || ".";
20122
20130
  const view = mapView(
20123
20131
  this.store,
20124
- { ...input, path: path15, offset, allowedPathPrefixes: prefixes },
20132
+ { ...input, path: path16, offset, allowedPathPrefixes: prefixes },
20125
20133
  this.views
20126
20134
  );
20127
20135
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
@@ -20321,13 +20329,13 @@ var ProjectMapSourceReader = class _ProjectMapSourceReader {
20321
20329
  */
20322
20330
  async readAll(expected) {
20323
20331
  if (this.signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
20324
- const paths = expected.map(({ path: path15 }) => {
20325
- assertProjectEvidencePathNotSensitive(path15);
20326
- if (isProjectEvidenceTraversalExcluded(path15))
20332
+ const paths = expected.map(({ path: path16 }) => {
20333
+ assertProjectEvidencePathNotSensitive(path16);
20334
+ if (isProjectEvidenceTraversalExcluded(path16))
20327
20335
  throw new ProjectEvidenceError("PROJECT_FILE_NOT_ALLOWED", false);
20328
- return path15;
20336
+ return path16;
20329
20337
  });
20330
- const results = this.commit ? await this.commit.readAll(paths) : await concurrently(paths, (path15) => this.session.captureFile(path15));
20338
+ const results = this.commit ? await this.commit.readAll(paths) : await concurrently(paths, (path16) => this.session.captureFile(path16));
20331
20339
  for (const [index, { entry }] of results.entries()) {
20332
20340
  const wanted = expected[index];
20333
20341
  if (entry.state !== wanted?.state || entry.contentDigest !== wanted.contentDigest || entry.byteLength !== wanted.byteLength)
@@ -21038,7 +21046,7 @@ var CodeIndexStore = class {
21038
21046
  const staged = this.stageUnits(buildRef, paths, linked);
21039
21047
  const reused = linked ? this.database.prepare(`SELECT path, unit_ref FROM project_map_version_units
21040
21048
  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) })) : [];
21041
- if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path: path15 }) => !paths.has(path15)) || staged.some(({ path: path15 }) => linked?.paths.has(path15)))
21049
+ if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path: path16 }) => !paths.has(path16)) || staged.some(({ path: path16 }) => linked?.paths.has(path16)))
21042
21050
  throw new MapReplayConflict();
21043
21051
  const units = [...staged, ...reused].sort(
21044
21052
  (left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
@@ -21089,7 +21097,7 @@ var CodeIndexStore = class {
21089
21097
  const member = this.database.prepare(
21090
21098
  "INSERT INTO project_map_version_units VALUES (?, ?, ?)"
21091
21099
  );
21092
- for (const { path: path15, unit } of reused) member.run(version2.version, path15, unit);
21100
+ for (const { path: path16, unit } of reused) member.run(version2.version, path16, unit);
21093
21101
  this.database.prepare("INSERT INTO project_map_coverage VALUES (?, ?)").run(version2.version, canonicalJson(coverage));
21094
21102
  }
21095
21103
  this.database.exec("COMMIT");
@@ -21153,7 +21161,7 @@ var CodeIndexStore = class {
21153
21161
  corrupt2();
21154
21162
  }
21155
21163
  if (linked) {
21156
- const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((path15) => !linked.paths.has(path15));
21164
+ const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((path16) => !linked.paths.has(path16));
21157
21165
  if (database.prepare(`SELECT 1 FROM project_map_objects gone
21158
21166
  WHERE gone.version_ref = ? AND gone.path IN (SELECT value FROM json_each(?))
21159
21167
  AND gone.entity_ref NOT IN (SELECT entity_ref FROM project_map_publish_objects)
@@ -21178,17 +21186,17 @@ var CodeIndexStore = class {
21178
21186
  const units = [];
21179
21187
  for (const row of database.prepare(`SELECT path FROM project_map_publish_objects
21180
21188
  UNION SELECT path FROM project_map_publish_relations ORDER BY path`).all()) {
21181
- const path15 = String(row.path);
21182
- const hash2 = createHash3("sha256").update(path15).update("\0");
21189
+ const path16 = String(row.path);
21190
+ const hash2 = createHash3("sha256").update(path16).update("\0");
21183
21191
  for (const [mark, statement] of [
21184
21192
  ["object", objects2],
21185
21193
  ["relation", relations],
21186
21194
  ["note", pathNotes]
21187
21195
  ])
21188
- for (const fact of statement.all(path15))
21196
+ for (const fact of statement.all(path16))
21189
21197
  for (const value of Object.values(fact))
21190
21198
  hash2.update(mark).update("\0").update(String(value)).update("\0");
21191
- units.push({ path: path15, unit: hash2.digest("hex") });
21199
+ units.push({ path: path16, unit: hash2.digest("hex") });
21192
21200
  }
21193
21201
  return units;
21194
21202
  }
@@ -21206,13 +21214,13 @@ var CodeIndexStore = class {
21206
21214
  "INSERT INTO project_map_unit_notes SELECT ?, * FROM project_map_publish_notes WHERE path = ?"
21207
21215
  );
21208
21216
  const member = database.prepare("INSERT INTO project_map_version_units VALUES (?, ?, ?)");
21209
- for (const { path: path15, unit } of units) {
21210
- if (insertUnit.run(unit, path15).changes) {
21211
- unitObjects.run(unit, path15);
21212
- unitRelations.run(unit, path15);
21213
- unitNotes.run(unit, path15);
21217
+ for (const { path: path16, unit } of units) {
21218
+ if (insertUnit.run(unit, path16).changes) {
21219
+ unitObjects.run(unit, path16);
21220
+ unitRelations.run(unit, path16);
21221
+ unitNotes.run(unit, path16);
21214
21222
  }
21215
- member.run(version2, path15, unit);
21223
+ member.run(version2, path16, unit);
21216
21224
  }
21217
21225
  }
21218
21226
  /**
@@ -21468,21 +21476,21 @@ var contextFiles = (context) => [
21468
21476
  function replayableContexts(parent, digests) {
21469
21477
  const sharing = /* @__PURE__ */ new Map();
21470
21478
  for (const [ref, { context }] of parent.contexts)
21471
- for (const path15 of contextFiles(context)) {
21472
- const refs = sharing.get(path15) ?? /* @__PURE__ */ new Set();
21479
+ for (const path16 of contextFiles(context)) {
21480
+ const refs = sharing.get(path16) ?? /* @__PURE__ */ new Set();
21473
21481
  refs.add(ref);
21474
- sharing.set(path15, refs);
21482
+ sharing.set(path16, refs);
21475
21483
  }
21476
21484
  const unchanged = /* @__PURE__ */ new Set();
21477
21485
  for (const [ref, { context }] of parent.contexts)
21478
21486
  if (contextFiles(context).every(
21479
- (path15) => digests.get(path15) !== void 0 && digests.get(path15) === parent.entries.get(path15)
21487
+ (path16) => digests.get(path16) !== void 0 && digests.get(path16) === parent.entries.get(path16)
21480
21488
  ))
21481
21489
  unchanged.add(ref);
21482
21490
  const replayable = /* @__PURE__ */ new Set();
21483
21491
  for (const [ref, { context }] of parent.contexts)
21484
21492
  if (unchanged.has(ref) && contextFiles(context).every(
21485
- (path15) => [...sharing.get(path15) ?? []].every((other) => unchanged.has(other))
21493
+ (path16) => [...sharing.get(path16) ?? []].every((other) => unchanged.has(other))
21486
21494
  ))
21487
21495
  replayable.add(ref);
21488
21496
  return { replayable, sharing };
@@ -21515,8 +21523,8 @@ var ProjectMapAnalyzer = class {
21515
21523
  languages;
21516
21524
  observe;
21517
21525
  id;
21518
- claims(path15) {
21519
- return this.languages.some((language) => language.claims(path15));
21526
+ claims(path16) {
21527
+ return this.languages.some((language) => language.claims(path16));
21520
21528
  }
21521
21529
  references(input, reference, signal) {
21522
21530
  const language = this.languages.find((language2) => language2.claims(reference.targetPath));
@@ -21556,7 +21564,7 @@ var ProjectMapAnalyzer = class {
21556
21564
  const reuse = (contextRef2, request, files2) => {
21557
21565
  const digest = digestValue({
21558
21566
  request,
21559
- files: files2.map((path15) => [path15, digests.get(path15) ?? null])
21567
+ files: files2.map((path16) => [path16, digests.get(path16) ?? null])
21560
21568
  });
21561
21569
  requests.set(contextRef2, digest);
21562
21570
  if (!parent || !replayable.has(contextRef2)) return void 0;
@@ -21595,7 +21603,7 @@ var ProjectMapAnalyzer = class {
21595
21603
  const ref = analysis.contexts[0]?.ref ?? "";
21596
21604
  if (options?.linked?.length) {
21597
21605
  if (!parent || analysis.contexts.length !== 1) return invalidParent();
21598
- for (const path15 of options.linked) linked.add(path15);
21606
+ for (const path16 of options.linked) linked.add(path16);
21599
21607
  this.observe?.({
21600
21608
  operation: "LINK",
21601
21609
  phase: "FINISHED",
@@ -21622,7 +21630,7 @@ var ProjectMapAnalyzer = class {
21622
21630
  });
21623
21631
  for (const file2 of analysis.parsedFiles) parsed.add(file2);
21624
21632
  const staged = factPaths(analysis);
21625
- for (const path15 of staged) stagedPaths.add(path15);
21633
+ for (const path16 of staged) stagedPaths.add(path16);
21626
21634
  for (const context of analysis.contexts) {
21627
21635
  for (const file2 of context.configurationFiles) configurationInputs.add(file2);
21628
21636
  if (!replayed.has(context.ref))
@@ -21651,7 +21659,7 @@ var ProjectMapAnalyzer = class {
21651
21659
  accept,
21652
21660
  reuse,
21653
21661
  previous,
21654
- configuration: (path15) => configurationInputs.add(path15),
21662
+ configuration: (path16) => configurationInputs.add(path16),
21655
21663
  observe: this.observe
21656
21664
  },
21657
21665
  signal
@@ -21688,12 +21696,12 @@ var ProjectMapAnalyzer = class {
21688
21696
  if (files.objects.length) accept(files);
21689
21697
  if (parent && (replayed.size || linked.size)) {
21690
21698
  for (const ref of replayed.keys())
21691
- for (const path15 of contextFiles(parent.contexts.get(ref)?.context ?? invalidParent()))
21692
- if (analyzedFiles.has(path15) || [...sharing.get(path15) ?? []].some((other) => !replayed.has(other)))
21699
+ for (const path16 of contextFiles(parent.contexts.get(ref)?.context ?? invalidParent()))
21700
+ if (analyzedFiles.has(path16) || [...sharing.get(path16) ?? []].some((other) => !replayed.has(other)))
21693
21701
  throw new MapReplayConflict();
21694
- for (const paths of replayed.values()) for (const path15 of paths) linked.add(path15);
21695
- for (const path15 of linked)
21696
- if (analyzedFiles.has(path15) || stagedPaths.has(path15)) throw new MapReplayConflict();
21702
+ for (const paths of replayed.values()) for (const path16 of paths) linked.add(path16);
21703
+ for (const path16 of linked)
21704
+ if (analyzedFiles.has(path16) || stagedPaths.has(path16)) throw new MapReplayConflict();
21697
21705
  parent.link([...linked]);
21698
21706
  }
21699
21707
  result.parsedFiles = [...parsed].sort();
@@ -21988,8 +21996,8 @@ var CodeIndex = class {
21988
21996
  for (const entry of this.store.listEntries(candidate))
21989
21997
  if (entry.contentDigest) entries2.set(entry.path, entry.contentDigest);
21990
21998
  let changed = 0;
21991
- for (const [path15, digest] of digests) if (entries2.get(path15) !== digest) changed++;
21992
- for (const path15 of entries2.keys()) if (!digests.has(path15)) changed++;
21999
+ for (const [path16, digest] of digests) if (entries2.get(path16) !== digest) changed++;
22000
+ for (const path16 of entries2.keys()) if (!digests.has(path16)) changed++;
21993
22001
  if (!best || changed < best.changed) best = { version: candidate, entries: entries2, changed };
21994
22002
  }
21995
22003
  if (!best) return void 0;
@@ -22165,16 +22173,16 @@ var LITERAL = /(["'`])((?:\\.|(?!\1)[^\\])*)\1/gu;
22165
22173
  var MOUNTING = /(?:\b(?:prefix|root_path|base_path|basePath|baseURL|baseUrl)\s*[=:]|\b(?:Group|Route|Mount|mount|use|include_router|PathPrefix|StripPrefix)\s*\()\s*$/u;
22166
22174
  var LIMIT = Object.freeze({ routes: 40, clients: 5 });
22167
22175
  var ROUTE = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
22168
- var segments = (path15) => path15.split("/").filter(Boolean).map((text) => ({ text, param: PARAM.test(text) || /[{}$<>%]/u.test(text) }));
22176
+ var segments = (path16) => path16.split("/").filter(Boolean).map((text) => ({ text, param: PARAM.test(text) || /[{}$<>%]/u.test(text) }));
22169
22177
  var routeSegments = (label) => segments(label.slice(label.indexOf("/")));
22170
22178
  function requestedPath(literal3, joined) {
22171
22179
  const match = /^(?:https?:\/\/[^/\s]+|(?:\$\{[^}]*\})+|@\{|redirect:|forward:)?(\/[^\s?#()"'`,;|]*)/u.exec(
22172
22180
  literal3
22173
22181
  ) ?? void 0;
22174
- const path15 = match?.[1];
22175
- if (!path15 || path15.startsWith("//") || path15.length < 3) return void 0;
22176
- const parts = segments(path15);
22177
- if (joined && path15.endsWith("/")) parts.push({ text: "*", param: true });
22182
+ const path16 = match?.[1];
22183
+ if (!path16 || path16.startsWith("//") || path16.length < 3) return void 0;
22184
+ const parts = segments(path16);
22185
+ if (joined && path16.endsWith("/")) parts.push({ text: "*", param: true });
22178
22186
  return parts;
22179
22187
  }
22180
22188
  var same = (route, requested) => route.param || !requested.param && route.text === requested.text;
@@ -22282,9 +22290,9 @@ var routeClientsLine = ({ route, removed, clients }) => `${JSON.stringify(route)
22282
22290
 
22283
22291
  // src/project-map-dependencies.ts
22284
22292
  var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
22285
- function imports(graph, path15) {
22293
+ function imports(graph, path16) {
22286
22294
  const found = [];
22287
- for (const relation of graph.relationsFrom(graph.objectsAt(path15).map((object2) => object2.id)))
22295
+ for (const relation of graph.relationsFrom(graph.objectsAt(path16).map((object2) => object2.id)))
22288
22296
  if (IMPORT_KINDS2.has(relation.kind) && relation.to !== void 0)
22289
22297
  found.push({
22290
22298
  target: graph.object(relation.to).anchor.path,
@@ -22301,9 +22309,9 @@ function pathBetween(edges, from, to) {
22301
22309
  if (via.has(target)) continue;
22302
22310
  via.set(target, module);
22303
22311
  if (target === to) {
22304
- const path15 = [to];
22305
- for (let step = module; step !== from; step = via.get(step) ?? from) path15.unshift(step);
22306
- return [from, ...path15];
22312
+ const path16 = [to];
22313
+ for (let step = module; step !== from; step = via.get(step) ?? from) path16.unshift(step);
22314
+ return [from, ...path16];
22307
22315
  }
22308
22316
  next.push(target);
22309
22317
  }
@@ -22523,9 +22531,9 @@ var KEYWORDS = new Set(
22523
22531
  );
22524
22532
  var ROWS = `SELECT entity_ref AS id, path, name, kind, object_json AS object
22525
22533
  FROM project_map_objects WHERE version_ref = ? AND kind <> 'PROPERTY'`;
22526
- function rows(store, version2, path15) {
22527
- const statement = store.database.prepare(path15 === void 0 ? ROWS : `${ROWS} AND path = ?`);
22528
- return (path15 === void 0 ? statement.all(version2) : statement.all(version2, path15)).map((row) => {
22534
+ function rows(store, version2, path16) {
22535
+ const statement = store.database.prepare(path16 === void 0 ? ROWS : `${ROWS} AND path = ?`);
22536
+ return (path16 === void 0 ? statement.all(version2) : statement.all(version2, path16)).map((row) => {
22529
22537
  const { anchor } = JSON.parse(String(row.object));
22530
22538
  return {
22531
22539
  id: String(row.id),
@@ -22566,10 +22574,10 @@ function lineWords(line) {
22566
22574
  }
22567
22575
  var within2 = (lines, declaration) => lines.some(([from, to]) => from <= declaration.startLine && declaration.endLine <= to);
22568
22576
  async function similarCode(store, working, base, files, read) {
22569
- const code = (path15) => mapCodePath(path15) !== void 0 && !mapTestPath(path15);
22577
+ const code = (path16) => mapCodePath(path16) !== void 0 && !mapTestPath(path16);
22570
22578
  const changed = files.filter((file2) => file2.status !== "DELETED" && code(file2.path));
22571
22579
  if (!changed.length) return [];
22572
- const names = (version2, path15) => new Set(declarations(rows(store, version2, path15)).map((item) => item.qualifiedName));
22580
+ const names = (version2, path16) => new Set(declarations(rows(store, version2, path16)).map((item) => item.qualifiedName));
22573
22581
  const movedOut = /* @__PURE__ */ new Set();
22574
22582
  if (base !== void 0)
22575
22583
  for (const file2 of files) {
@@ -22595,10 +22603,10 @@ async function similarCode(store, working, base, files, read) {
22595
22603
  }
22596
22604
  const all = [];
22597
22605
  await Promise.all(
22598
- [...byPath].map(async ([path15, inFile]) => {
22606
+ [...byPath].map(async ([path16, inFile]) => {
22599
22607
  const found2 = declarations(inFile).filter(eligible);
22600
22608
  if (!found2.length) return;
22601
- const text = await read(path15);
22609
+ const text = await read(path16);
22602
22610
  if (text === void 0) return;
22603
22611
  const lines = text.split("\n").map(lineWords);
22604
22612
  for (const declaration of found2) {
@@ -22732,9 +22740,9 @@ async function readMapChanges(project, base, signal) {
22732
22740
  ...file2,
22733
22741
  baseText: (await git.run(["show", `${commit}:${file2.basePath}`], gitOptions(project, signal))).stdout.toString("utf8")
22734
22742
  };
22735
- const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((path15) => path15 && !inExcludedDirectory(path15));
22736
- for (const path15 of untracked)
22737
- files.push({ path: path15, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
22743
+ const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((path16) => path16 && !inExcludedDirectory(path16));
22744
+ for (const path16 of untracked)
22745
+ files.push({ path: path16, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
22738
22746
  const stranded = await strandedNames(
22739
22747
  project,
22740
22748
  diff,
@@ -22812,7 +22820,7 @@ var NON_CODE = [
22812
22820
  [/(?:^|\/)\.env[^/]*$|\.(?:ya?ml|toml|ini|properties|conf|cfg)$/iu, "configuration"],
22813
22821
  [/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte|wxml)$/iu, "template"]
22814
22822
  ];
22815
- var nonCodeKind = (path15) => NON_CODE.find(([pattern]) => pattern.test(path15))?.[1];
22823
+ var nonCodeKind = (path16) => NON_CODE.find(([pattern]) => pattern.test(path16))?.[1];
22816
22824
  var LIMITS = Object.freeze({ depth: 8, declarations: 800, changed: 200, chain: 3, byName: 40 });
22817
22825
  var CALLER_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES"]);
22818
22826
  var NAMING_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES", "EXTENDS", "IMPLEMENTS"]);
@@ -22839,8 +22847,11 @@ var Tracer = class {
22839
22847
  unclear = [];
22840
22848
  truncated = false;
22841
22849
  callerCount = /* @__PURE__ */ new Map();
22850
+ known = /* @__PURE__ */ new Map();
22842
22851
  // Declarations a decorator maps to a route: entry points already, never "top of a chain".
22843
22852
  routes = /* @__PURE__ */ new Set();
22853
+ /** The declarations each route entry reaches the change through: its handlers. */
22854
+ handlers = /* @__PURE__ */ new Map();
22844
22855
  /** Test support files that call the changed code; the tests beside and below them may use it. */
22845
22856
  support = /* @__PURE__ */ new Set();
22846
22857
  name = (ref) => this.graph.qualifiedName(ref);
@@ -22950,7 +22961,56 @@ var Tracer = class {
22950
22961
  uses.push(`decorated by ${relation.target}`);
22951
22962
  return [...new Set(uses)];
22952
22963
  }
22964
+ /**
22965
+ * How code in the files runs each declaration: "call" when it calls it, directly or through other
22966
+ * code (their module-scope code counts, and other test code is passed through); "route" when it
22967
+ * does not, but one of the handlers is the declaration or calls it. Callers are followed from all
22968
+ * the declarations at once, as the trace follows them, and what reaches a caller reaches what it
22969
+ * calls.
22970
+ */
22971
+ reach(refs, files, handlers) {
22972
+ const how = /* @__PURE__ */ new Map();
22973
+ const below = /* @__PURE__ */ new Map();
22974
+ const seen = new Set(refs);
22975
+ let truncated = false;
22976
+ let frontier = [...seen];
22977
+ for (let depth = 0; frontier.length; depth++) {
22978
+ const next = [];
22979
+ for (const current of frontier) {
22980
+ if (handlers.has(current)) how.set(current, "route");
22981
+ for (const caller of this.callers(current)) {
22982
+ if (files.has(this.graph.object(caller.ref).anchor.path)) {
22983
+ how.set(current, "call");
22984
+ continue;
22985
+ }
22986
+ const callees = below.get(caller.ref);
22987
+ if (callees) callees.push(current);
22988
+ else below.set(caller.ref, [current]);
22989
+ if (seen.has(caller.ref)) continue;
22990
+ if (depth + 1 > LIMITS.depth || seen.size >= LIMITS.declarations) {
22991
+ truncated = true;
22992
+ continue;
22993
+ }
22994
+ seen.add(caller.ref);
22995
+ next.push(caller.ref);
22996
+ }
22997
+ }
22998
+ frontier = next;
22999
+ }
23000
+ for (const kind of ["call", "route"]) {
23001
+ const pending = [...how].filter(([, found]) => found === kind).map(([ref]) => ref);
23002
+ for (let ref = pending.pop(); ref !== void 0; ref = pending.pop())
23003
+ for (const callee of below.get(ref) ?? [])
23004
+ if (!how.has(callee)) {
23005
+ how.set(callee, kind);
23006
+ pending.push(callee);
23007
+ }
23008
+ }
23009
+ return { how, truncated };
23010
+ }
22953
23011
  callers(ref) {
23012
+ const known = this.known.get(ref);
23013
+ if (known) return known;
22954
23014
  const callers = [];
22955
23015
  for (const relation of this.graph.relationsTo([ref]))
22956
23016
  if (CALLER_KINDS.has(relation.kind)) {
@@ -22990,6 +23050,7 @@ var Tracer = class {
22990
23050
  }
22991
23051
  }
22992
23052
  }
23053
+ this.known.set(ref, callers);
22993
23054
  return callers;
22994
23055
  }
22995
23056
  decoratorRoutes(current) {
@@ -23019,6 +23080,7 @@ var Tracer = class {
23019
23080
  );
23020
23081
  }
23021
23082
  entry(label, route, at, site, certain, top = false) {
23083
+ if (route) this.handlers.set(label, (this.handlers.get(label) ?? /* @__PURE__ */ new Set()).add(at.ref));
23022
23084
  const chain = [];
23023
23085
  let step = !top ? at : at.via ? this.reached.get(at.via) : void 0;
23024
23086
  for (; step && chain.length < LIMITS.chain; ) {
@@ -23039,34 +23101,35 @@ var Tracer = class {
23039
23101
  this.areas.set(area, known);
23040
23102
  }
23041
23103
  /** A related test file; the closest relation (lowest rank) explains it. */
23042
- test(path15, name, why, rank2) {
23043
- if (!mapRunnableTest(path15)) return;
23044
- const known = this.tests.get(path15) ?? { names: /* @__PURE__ */ new Set(), why, rank: rank2 };
23104
+ test(path16, name, why, rank2) {
23105
+ if (!mapRunnableTest(path16)) return;
23106
+ const known = this.tests.get(path16) ?? { names: /* @__PURE__ */ new Set(), why, rank: rank2 };
23045
23107
  if (rank2 < known.rank) Object.assign(known, { why, rank: rank2 });
23046
23108
  if (name && !name.startsWith("<")) known.names.add(name);
23047
- this.tests.set(path15, known);
23109
+ this.tests.set(path16, known);
23048
23110
  }
23049
23111
  };
23050
23112
  var mapRunnableTest = (file2) => /_test\.(?:go|py)$|(?:^|\/)test_[^/]*\.py$|\.(?:test|spec)\.[cm]?[jt]sx?$|(?:Test|Tests|IT)\.(?:java|kt)$/u.test(
23051
23113
  file2
23052
23114
  );
23053
23115
  var renamedTemplate = (file2) => file2.status === "RENAMED" && file2.basePath !== void 0 && mapMiniprogramTemplate(file2.basePath);
23054
- function mapChangeImpact(store, working, base, changes, project) {
23116
+ function mapChangeImpact(store, working, base, changes, project, tests) {
23055
23117
  const graph = new MapViewGraph(store, working);
23056
23118
  const cache = new MapViewCache();
23057
- const tracer = new Tracer(graph, cache.memberCalls(store, working));
23119
+ const memberCalls = cache.memberCalls(store, working);
23120
+ const tracer = new Tracer(graph, memberCalls);
23058
23121
  const changed = [];
23059
23122
  const unclear = [];
23060
23123
  const removed = [];
23061
- const declarations2 = (g, path15) => g.objectsAt(path15).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
23062
- const units = (g, path15) => mapMiniprogramTemplate(path15) ? g.objectsAt(path15).filter((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : declarations2(g, path15);
23124
+ const declarations2 = (g, path16) => g.objectsAt(path16).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
23125
+ const units = (g, path16) => mapMiniprogramTemplate(path16) ? g.objectsAt(path16).filter((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : declarations2(g, path16);
23063
23126
  let changedCount = 0;
23064
23127
  const starts = [];
23065
23128
  const importers = /* @__PURE__ */ new Map();
23066
23129
  let mapped;
23067
23130
  const mappedPaths = () => mapped ??= store.database.prepare("SELECT DISTINCT path FROM project_map_objects WHERE version_ref = ?").all(working).map((row) => String(row.path));
23068
- const topLevelChanged = (path15) => {
23069
- const note = `top-level code of ${path15} changed (imports, constants or registrations)`;
23131
+ const topLevelChanged = (path16) => {
23132
+ const note = `top-level code of ${path16} changed (imports, constants or registrations)`;
23070
23133
  if (!unclear.includes(note)) unclear.push(note);
23071
23134
  };
23072
23135
  for (const file2 of changes.files) {
@@ -23118,6 +23181,7 @@ function mapChangeImpact(store, working, base, changes, project) {
23118
23181
  mirroredTests(mappedPaths(), file2.path, tracer);
23119
23182
  }
23120
23183
  tracer.trace(starts);
23184
+ const untested = tests && untestedChanges(project, graph, tracer, memberCalls, starts, changed, tests);
23121
23185
  if (project) routeTests(project, store, working, [...tracer.entries.values()], tracer);
23122
23186
  supportTests(store, working, tracer);
23123
23187
  const rewrittenTests = [];
@@ -23195,6 +23259,46 @@ function mapChangeImpact(store, working, base, changes, project) {
23195
23259
  });
23196
23260
  }
23197
23261
  }
23262
+ const removedAt = (ref) => {
23263
+ for (let at = ref; at !== void 0; at = before.parent(at))
23264
+ if (gone.includes(at)) return true;
23265
+ return false;
23266
+ };
23267
+ const lost = /* @__PURE__ */ new Map();
23268
+ const changedAt = new Map(changes.files.map((file2) => [file2.path, file2]));
23269
+ for (const path16 of mappedPaths().filter(mapMiniprogramTemplate)) {
23270
+ const template = graph.objectsAt(path16).find((object2) => mapIsModule(object2));
23271
+ if (!template) continue;
23272
+ const broken = graph.relationsFrom(graph.scope(template.id).refs).filter((relation) => relation.to === void 0 && NAMING_KINDS.has(relation.kind));
23273
+ if (!broken.length) continue;
23274
+ const file2 = changedAt.get(path16);
23275
+ const basePath = file2 ? file2.basePath : path16;
23276
+ const was = basePath === void 0 ? void 0 : before.objectsAt(basePath).find(mapIsModule);
23277
+ const links = was ? before.relationsFrom(before.scope(was.id).refs) : [];
23278
+ for (const relation of broken) {
23279
+ const earlier = links.filter(
23280
+ (link) => link.kind === relation.kind && link.target === relation.target
23281
+ );
23282
+ if (earlier.some((link) => link.to === void 0)) continue;
23283
+ const event = miniprogramEventOf(relation.target);
23284
+ const at = `${path16}:${relation.anchor.startLine}`;
23285
+ if (file2 && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine)) {
23286
+ unclear.push(
23287
+ event ? `${at} binds the ${event.event} event of <${event.tag}>, which it does not emit` : relation.kind === "REFERENCES" ? `${at} puts <${relation.target}>, which its registration does not find` : `${at} binds ${relation.target}, which its page or component does not register`
23288
+ );
23289
+ continue;
23290
+ }
23291
+ const reached = event ? links.find((link) => link.kind === "REFERENCES" && link.target === event.tag)?.to : earlier.find((link) => link.to !== void 0)?.to;
23292
+ if (reached === void 0 || removedAt(reached)) continue;
23293
+ const object2 = before.object(reached);
23294
+ const name = mapIsModule(object2) ? `${object2.anchor.path} (template)${event ? `: ${event.event} event` : ""}` : `${object2.anchor.path}: ${before.qualifiedName(reached)} ${mapDeclarationLabel(object2)}`;
23295
+ const users = lost.get(name) ?? /* @__PURE__ */ new Set();
23296
+ users.add(`${path16} (template)`);
23297
+ lost.set(name, users);
23298
+ }
23299
+ }
23300
+ for (const [declaration, users] of lost)
23301
+ removed.push({ declaration, usedBy: [...users].sort() });
23198
23302
  for (const file2 of changes.files) {
23199
23303
  if (!file2.basePath || file2.status === "DELETED" || testCode(file2.basePath)) continue;
23200
23304
  const module = before.objectsAt(file2.basePath).find(mapIsModule);
@@ -23207,18 +23311,18 @@ function mapChangeImpact(store, working, base, changes, project) {
23207
23311
  beforeTracer.trace(gone);
23208
23312
  for (const entry of beforeTracer.entries.values())
23209
23313
  if (!tracer.entries.has(entry.label)) tracer.entries.set(entry.label, entry);
23210
- for (const [path15, test] of beforeTracer.tests) {
23211
- const known = tracer.tests.get(path15);
23314
+ for (const [path16, test] of beforeTracer.tests) {
23315
+ const known = tracer.tests.get(path16);
23212
23316
  if (known) for (const name of test.names) known.names.add(name);
23213
- else tracer.tests.set(path15, test);
23317
+ else tracer.tests.set(path16, test);
23214
23318
  }
23215
23319
  for (const [area, known] of beforeTracer.areas) {
23216
23320
  const now = tracer.areas.get(area);
23217
23321
  if (!now) tracer.areas.set(area, known);
23218
23322
  else {
23219
23323
  for (const name of known.through) now.through.add(name);
23220
- for (const [path15, names] of known.tests)
23221
- now.tests.set(path15, /* @__PURE__ */ new Set([...now.tests.get(path15) ?? [], ...names]));
23324
+ for (const [path16, names] of known.tests)
23325
+ now.tests.set(path16, /* @__PURE__ */ new Set([...now.tests.get(path16) ?? [], ...names]));
23222
23326
  }
23223
23327
  }
23224
23328
  unclear.push(...beforeTracer.unclear.filter((line) => !line.includes("has no callers")));
@@ -23243,10 +23347,10 @@ function mapChangeImpact(store, working, base, changes, project) {
23243
23347
  for (const ref of called) {
23244
23348
  const object2 = before.object(ref);
23245
23349
  if (mapIsModule(object2) || testCode(object2.anchor.path) || gone.includes(ref)) continue;
23246
- const path15 = moved.has(object2.anchor.path) ? moved.get(object2.anchor.path) : object2.anchor.path;
23247
- if (path15 === void 0) continue;
23350
+ const path16 = moved.has(object2.anchor.path) ? moved.get(object2.anchor.path) : object2.anchor.path;
23351
+ if (path16 === void 0) continue;
23248
23352
  const name = before.qualifiedName(ref);
23249
- const now = declarations2(graph, path15).find(
23353
+ const now = declarations2(graph, path16).find(
23250
23354
  (candidate) => candidate.kind === object2.kind && graph.qualifiedName(candidate.id) === name
23251
23355
  );
23252
23356
  if (!now || outsideTests(tracer.callers(now.id), graph).length || tracer.usesWithoutCalls(now.id).length)
@@ -23254,7 +23358,7 @@ function mapChangeImpact(store, working, base, changes, project) {
23254
23358
  if (!outsideTests(beforeTracer.callers(ref), before).length) continue;
23255
23359
  const tested = tracer.callers(now.id).length > 0;
23256
23360
  uncalled.push(
23257
- `${path15}: ${name} ${mapDeclarationLabel(now)}${tested ? " (only tests call it now)" : ""}`
23361
+ `${path16}: ${name} ${mapDeclarationLabel(now)}${tested ? " (only tests call it now)" : ""}`
23258
23362
  );
23259
23363
  }
23260
23364
  uncalled.sort();
@@ -23263,11 +23367,9 @@ function mapChangeImpact(store, working, base, changes, project) {
23263
23367
  changed,
23264
23368
  removed,
23265
23369
  rewrittenTests,
23266
- entries: [...tracer.entries.values()].sort(
23267
- (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)
23268
- ),
23269
- tests: [...tracer.tests].map(([path15, test]) => ({
23270
- path: path15,
23370
+ entries: [...tracer.entries.values()].sort(entryOrder),
23371
+ tests: [...tracer.tests].map(([path16, test]) => ({
23372
+ path: path16,
23271
23373
  names: [...test.names].sort(),
23272
23374
  why: test.why,
23273
23375
  rank: test.rank
@@ -23277,15 +23379,55 @@ function mapChangeImpact(store, working, base, changes, project) {
23277
23379
  areas: [...tracer.areas].map(([area, known]) => ({
23278
23380
  area,
23279
23381
  through: [...known.through].sort(),
23280
- tests: [...known.tests].map(([path15, names]) => ({ path: path15, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
23382
+ tests: [...known.tests].map(([path16, names]) => ({ path: path16, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
23281
23383
  })).sort((left, right) => right.tests.length - left.tests.length),
23282
23384
  unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
23283
23385
  removedRoutes,
23284
23386
  uncalled,
23285
23387
  dependencies: newModuleDependencies(store, cache, working, base, changes.files),
23388
+ ...untested ? { untested } : {},
23286
23389
  truncated: tracer.truncated
23287
23390
  };
23288
23391
  }
23392
+ var entryOrder = (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);
23393
+ function untestedChanges(project, graph, tracer, memberCalls, starts, changed, tests) {
23394
+ const given = new Set(tests);
23395
+ const routes = /* @__PURE__ */ new Set();
23396
+ const handlers = /* @__PURE__ */ new Set();
23397
+ if (project)
23398
+ for (const test of given) {
23399
+ let text;
23400
+ try {
23401
+ text = readFileSync3(path10.join(project, test), "utf8");
23402
+ } catch {
23403
+ continue;
23404
+ }
23405
+ for (const [label, refs] of tracer.handlers) {
23406
+ const fragment = routeFragment(label);
23407
+ if (!fragment || !text.includes(fragment)) continue;
23408
+ routes.add(label);
23409
+ for (const ref of refs) handlers.add(ref);
23410
+ }
23411
+ }
23412
+ const { how, truncated } = tracer.reach(starts, given, handlers);
23413
+ const unreached = [];
23414
+ const throughRoutes = [];
23415
+ for (const [at, ref] of starts.entries()) {
23416
+ const found = how.get(ref);
23417
+ if (found === "route") throughRoutes.push(changed[at] ?? "");
23418
+ else if (!found) unreached.push(at);
23419
+ }
23420
+ const above = new Tracer(graph, memberCalls);
23421
+ above.trace(unreached.map((at) => starts[at] ?? ""));
23422
+ return {
23423
+ changed: unreached.map((at) => changed[at] ?? ""),
23424
+ entries: [...above.entries.values()].sort(entryOrder),
23425
+ throughRoutes,
23426
+ routes: throughRoutes.length ? [...routes].sort() : [],
23427
+ missing: tests.filter((test) => !graph.objectsAt(test).length),
23428
+ truncated: unreached.length > 0 && (truncated || above.truncated)
23429
+ };
23430
+ }
23289
23431
  function existingTestsChanged(before, after, file2, project) {
23290
23432
  if (!file2.basePath || file2.baseText === void 0) return [];
23291
23433
  const baseLines = file2.baseText.split("\n");
@@ -23331,10 +23473,10 @@ function importerTests(graph, objects2, tracer, importers) {
23331
23473
  }
23332
23474
  const next = [];
23333
23475
  for (const imported of modules)
23334
- for (const { path: path15, module } of importers.get(imported) ?? [])
23335
- if (testCode(path15))
23476
+ for (const { path: path16, module } of importers.get(imported) ?? [])
23477
+ if (testCode(path16))
23336
23478
  tracer.test(
23337
- path15,
23479
+ path16,
23338
23480
  void 0,
23339
23481
  hop ? "imports a changed file indirectly" : "imports a changed file",
23340
23482
  hop ? 4 : 2
@@ -23372,10 +23514,8 @@ function mirroredTests(paths, file2, tracer) {
23372
23514
  function routeTests(project, store, version2, entries, tracer) {
23373
23515
  const fragments = /* @__PURE__ */ new Map();
23374
23516
  for (const entry of entries) {
23375
- if (!entry.route) continue;
23376
- const route = entry.label.slice(entry.label.indexOf("/"));
23377
- const longest = route.split(/\/(?:\{[^}]*\}|:[^/]+|<[^>]*>|\*)(?=\/|$)/u).sort((left, right) => right.length - left.length)[0];
23378
- if (longest && longest.replace(/\//gu, "").length >= 4) fragments.set(longest, entry.label);
23517
+ const fragment = entry.route ? routeFragment(entry.label) : void 0;
23518
+ if (fragment) fragments.set(fragment, entry.label);
23379
23519
  }
23380
23520
  if (!fragments.size) return;
23381
23521
  let budget = 32 * 1024 * 1024;
@@ -23402,9 +23542,9 @@ function routeTests(project, store, version2, entries, tracer) {
23402
23542
  }
23403
23543
  }
23404
23544
  }
23405
- function sameDirectoryTests(paths, path15, tracer) {
23406
- const slash = path15.lastIndexOf("/");
23407
- const directory = slash < 0 ? "" : path15.slice(0, slash + 1);
23545
+ function sameDirectoryTests(paths, path16, tracer) {
23546
+ const slash = path16.lastIndexOf("/");
23547
+ const directory = slash < 0 ? "" : path16.slice(0, slash + 1);
23408
23548
  for (const candidate of paths) {
23409
23549
  if (!candidate.startsWith(directory)) continue;
23410
23550
  if (candidate.slice(directory.length).includes("/") || !mapTestPath(candidate)) continue;
@@ -23435,15 +23575,19 @@ var LIST = Object.freeze({
23435
23575
  similar: 10,
23436
23576
  similarNames: 3
23437
23577
  });
23438
- function routesIn(graph, path15) {
23578
+ function routesIn(graph, path16) {
23439
23579
  const routes = /* @__PURE__ */ new Set();
23440
- for (const relation of graph.relationsFrom(graph.objectsAt(path15).map((object2) => object2.id))) {
23580
+ for (const relation of graph.relationsFrom(graph.objectsAt(path16).map((object2) => object2.id))) {
23441
23581
  const route = relation.kind === "DECORATED_BY" ? relation.route ?? relation.argument : relation.argument;
23442
23582
  if (route && ROUTE2.test(route)) routes.add(route);
23443
23583
  }
23444
23584
  return routes;
23445
23585
  }
23446
23586
  var routePath = (route) => route.slice(route.indexOf("/"));
23587
+ function routeFragment(label) {
23588
+ const longest = routePath(label).split(/\/(?:\{[^}]*\}|:[^/]+|<[^>]*>|\*)(?=\/|$)/u).sort((left, right) => right.length - left.length)[0];
23589
+ return longest && longest.replace(/\//gu, "").length >= 4 ? longest : void 0;
23590
+ }
23447
23591
  async function checkMapChanges(input, signal) {
23448
23592
  const { index, project, working } = input;
23449
23593
  const changes = await readMapChanges(project, input.base, signal);
@@ -23451,7 +23595,7 @@ async function checkMapChanges(input, signal) {
23451
23595
  const base = changes.files.some(
23452
23596
  (file2) => file2.basePath !== void 0 && (file2.baseLines.length || file2.baseText !== void 0 || renamedTemplate(file2))
23453
23597
  ) ? await input.baseVersion(changes.commit, signal) : void 0;
23454
- const impact = mapChangeImpact(index.store, working, base, changes, project);
23598
+ const impact = mapChangeImpact(index.store, working, base, changes, project, input.tests);
23455
23599
  return {
23456
23600
  text: mapChangesText(
23457
23601
  changes,
@@ -23489,7 +23633,7 @@ function mapChangesText(changes, impact, clients = [], similar = []) {
23489
23633
  const indirect = impact.tests.filter((test) => test.rank >= 4);
23490
23634
  const routes = impact.entries.filter((entry2) => entry2.route);
23491
23635
  const lines = [
23492
- `PROJECT MAP \xB7 CHANGES against ${changes.base} (${changes.commit.slice(0, 12)}) \xB7 ${files} changed file${files === 1 ? "" : "s"} \xB7 ${impact.changed.length} changed and ${impact.removed.length} removed declarations \xB7 ${routes.length} routes and ${impact.entries.length - routes.length} other entry points reached \xB7 ${direct.length} related test files${indirect.length ? ` (+${indirect.length} importing the changes indirectly)` : ""}`
23636
+ `PROJECT MAP \xB7 CHANGES against ${changes.base} (${changes.commit.slice(0, 12)}) \xB7 ${files} changed file${files === 1 ? "" : "s"} \xB7 ${impact.changed.length} changed and ${impact.removed.length} removed declarations \xB7 ${routes.length} routes and ${impact.entries.length - routes.length} other entry points reached \xB7 ${direct.length} related test files${indirect.length ? ` (+${indirect.length} importing the changes indirectly)` : ""}${impact.untested ? ` \xB7 ${impact.untested.changed.length} changed declarations not reached by the given tests` : ""}`
23493
23637
  ];
23494
23638
  if (!files) return `${lines[0]}
23495
23639
  Nothing changed against ${changes.base}.`;
@@ -23616,6 +23760,43 @@ Nothing changed against ${changes.base}.`;
23616
23760
  impact.entries.filter((e) => !e.certain).map(entry),
23617
23761
  LIST.entries
23618
23762
  );
23763
+ if (impact.untested) {
23764
+ const { changed, entries, throughRoutes, routes: routes2, missing, truncated } = impact.untested;
23765
+ const items = (shown, limit) => {
23766
+ lines.push(...shown.slice(0, limit).map((item) => ` ${item}`));
23767
+ if (shown.length > limit) lines.push(` +${shown.length - limit} more`);
23768
+ };
23769
+ lines.push("NOT REACHED BY THE GIVEN TESTS");
23770
+ if (missing.length)
23771
+ lines.push(` the map has no code for these given files: ${missing.join(", ")}`);
23772
+ if (changed.length) {
23773
+ lines.push(
23774
+ ` ${changed.length} of ${impact.changed.length} changed declarations are reached by none of the given tests; ${entries.length ? "the entry points above them, then the declarations:" : "the declarations:"}`
23775
+ );
23776
+ items(
23777
+ entries.map((item) => `${entry(item)}${item.certain ? "" : " (possibly)"}`),
23778
+ LIST.entries
23779
+ );
23780
+ items(changed, LIST.changed);
23781
+ } else
23782
+ lines.push(
23783
+ impact.changed.length ? ` none: the given tests reach all ${impact.changed.length} changed declarations` : " none: the diff changes no declarations outside the tests"
23784
+ );
23785
+ if (throughRoutes.length) {
23786
+ lines.push(
23787
+ ` ${throughRoutes.length} changed declarations are reached only through a route whose path a given test names, found by text (${routes2.map((route) => JSON.stringify(route)).join(", ")}):`
23788
+ );
23789
+ items(throughRoutes, LIST.changed);
23790
+ }
23791
+ if (truncated)
23792
+ lines.push(
23793
+ ` callers were followed ${LIMITS.depth} levels or ${LIMITS.declarations} declarations up; a given test or entry point further up is not seen`
23794
+ );
23795
+ if (impact.changed.length)
23796
+ lines.push(
23797
+ "Reach is followed through resolved calls from the given files and the routes whose paths they name. Reached means a given test calls code that leads to it, not that the test takes that path or checks what it does; a call through dependency injection, reflection or a receiver of unknown type, or a path built at run time, may run code the map does not see."
23798
+ );
23799
+ }
23619
23800
  if (clients.length) {
23620
23801
  list(
23621
23802
  "REQUESTED BY (code and templates outside the tests that request these routes' paths, found by text)",
@@ -23978,7 +24159,8 @@ var LayerMap = class _LayerMap {
23978
24159
  /**
23979
24160
  * What the working tree's changes against a commit (HEAD by default) affect: the changed and
23980
24161
  * removed declarations, the entry points and tests their callers reach, and what the map cannot
23981
- * see. The base commit's map is built only when the diff removes or changes lines there.
24162
+ * see; with test files, by path from the repository root, also the changed code they do not run.
24163
+ * The base commit's map is built only when the diff removes or changes lines there.
23982
24164
  */
23983
24165
  checkChanges(input, signal) {
23984
24166
  return this.using(
@@ -23988,7 +24170,8 @@ var LayerMap = class _LayerMap {
23988
24170
  project: this.project,
23989
24171
  working: await this.current(signal, hold),
23990
24172
  base: input.base ?? "HEAD",
23991
- baseVersion: (commit, baseSignal) => this.versionAt(commit, baseSignal, hold)
24173
+ baseVersion: (commit, baseSignal) => this.versionAt(commit, baseSignal, hold),
24174
+ ...input.tests ? { tests: input.tests } : {}
23992
24175
  },
23993
24176
  signal
23994
24177
  )
@@ -24230,7 +24413,7 @@ var MAP_TOOL_NAMES = Object.freeze({
24230
24413
  references: "project_find_references",
24231
24414
  check: "project_check_changes"
24232
24415
  });
24233
- var mapDirectoryPath = (path15) => path15.length > 1 && path15.endsWith("/") && !path15.endsWith("//") ? path15.slice(0, -1) : path15;
24416
+ var mapDirectoryPath = (path16) => path16.length > 1 && path16.endsWith("/") && !path16.endsWith("//") ? path16.slice(0, -1) : path16;
24234
24417
  var ProjectMapSearchInputSchema = external_exports.object({
24235
24418
  path: external_exports.string().default("."),
24236
24419
  query: external_exports.string().min(1).max(256),
@@ -24261,6 +24444,9 @@ var ProjectMapCheckInputSchema = external_exports.object({
24261
24444
  ),
24262
24445
  path: external_exports.string().optional().describe(
24263
24446
  "A file or directory in the repository to check, when the session works in more than one; the check covers that repository's whole working tree."
24447
+ ),
24448
+ tests: external_exports.array(external_exports.string().min(1).max(1e3)).max(200).optional().describe(
24449
+ "Test files that should cover the change, such as the ones you wrote for it, as paths are given to the other tools: the report then adds NOT REACHED BY THE GIVEN TESTS, the changed declarations none of them calls or requests through a route, with the entry points above them."
24264
24450
  )
24265
24451
  }).strip();
24266
24452
  var locatorSchema = MapObjectLocatorSchema.describe(
@@ -24287,7 +24473,7 @@ var mapToolDescriptions = (host) => {
24287
24473
  return Object.freeze({
24288
24474
  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.`,
24289
24475
  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.`,
24290
- check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; REQUESTED BY, the code and templates outside the tests that request the path of a route whose handler the change reaches or a route it removed, found by text; EXISTING TESTS CHANGED, the tests that existed before the diff and whose code it changed or removed; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; NAMES STILL USED ELSEWHERE, environment variables and configuration keys the diff removed from a file that other files still read or set, found by text; NEW MODULE DEPENDENCIES, imports between the modules of the project overview that the base did not have, and those that make two modules depend on each other, for you to judge against the project's layers; EXISTING CODE LIKE THE NEW CODE, declarations the diff adds whose code reads almost the same as code the project already has; LEFT WITHOUT CALLERS, declarations whose last callers outside the tests the diff removed or changed, and that nothing extends, implements, overrides or wires with a decorator; 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; a new dependency that runs against the layers or closes a cycle means moving what both modules need down rather than importing upward; new code like existing code means using the existing code, or removing the old if the new replaces it; code left without callers means deleting it, with the tests that only test it, when the change replaced it; 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.`,
24476
+ check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; REQUESTED BY, the code and templates outside the tests that request the path of a route whose handler the change reaches or a route it removed, found by text; EXISTING TESTS CHANGED, the tests that existed before the diff and whose code it changed or removed; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; NAMES STILL USED ELSEWHERE, environment variables and configuration keys the diff removed from a file that other files still read or set, found by text; NEW MODULE DEPENDENCIES, imports between the modules of the project overview that the base did not have, and those that make two modules depend on each other, for you to judge against the project's layers; EXISTING CODE LIKE THE NEW CODE, declarations the diff adds whose code reads almost the same as code the project already has; LEFT WITHOUT CALLERS, declarations whose last callers outside the tests the diff removed or changed, and that nothing extends, implements, overrides or wires with a decorator; 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; given tests, NOT REACHED BY THE GIVEN TESTS, the changed declarations none of them calls or requests through a route, with the entry points above them. 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; a new dependency that runs against the layers or closes a cycle means moving what both modules need down rather than importing upward; new code like existing code means using the existing code, or removing the old if the new replaces it; code left without callers means deleting it, with the tests that only test it, when the change replaced it; 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.`,
24291
24477
  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.`
24292
24478
  });
24293
24479
  };
@@ -24329,11 +24515,18 @@ async function routeMapCall(start, { name, args }) {
24329
24515
  const such = repositories.length ? `, such as ${repositories.join(", ")}` : "";
24330
24516
  return named === "." ? `LAYERMAP_NOT_A_GIT_REPOSITORY: This session started in ${start.directory}, which is not in a Git repository. Name a file or directory in one, relative to that folder or absolute${such}.` : `LAYERMAP_NOT_A_GIT_REPOSITORY: ${path13.resolve(start.directory, named)} is not in a Git repository; LayerMap maps Git repositories${start.git ? "" : `. Name a file or directory in one, relative to ${start.directory} or absolute${such}`}.`;
24331
24517
  }
24332
- if (!holder)
24333
- return {
24334
- project: located.project,
24335
- args: value === void 0 ? args : { ...args, path: located.path }
24336
- };
24518
+ if (!holder) {
24519
+ const routed2 = value === void 0 ? args : { ...args, path: located.path };
24520
+ if (!Array.isArray(args.tests)) return { project: located.project, args: routed2 };
24521
+ const tests = [];
24522
+ for (const test of args.tests) {
24523
+ const within4 = await locate(start, test);
24524
+ if (within4?.project !== located.project)
24525
+ return `PROJECT_PATH_INVALID: test ${test} is not in ${located.project}, the repository checked.`;
24526
+ tests.push(within4.path);
24527
+ }
24528
+ return { project: located.project, args: { ...routed2, tests } };
24529
+ }
24337
24530
  const routed = {
24338
24531
  ...args,
24339
24532
  [holder]: { ...args[holder], path: located.path }
@@ -24429,7 +24622,13 @@ async function runMapTool(map2, { name, args }, signal) {
24429
24622
  }
24430
24623
  if (name === MAP_TOOL_NAMES.check) {
24431
24624
  const input2 = args;
24432
- return { text: (await map2.checkChanges({ base: input2.base }, signal)).text, isError: false };
24625
+ return {
24626
+ text: (await map2.checkChanges(
24627
+ { base: input2.base, ...input2.tests ? { tests: input2.tests } : {} },
24628
+ signal
24629
+ )).text,
24630
+ isError: false
24631
+ };
24433
24632
  }
24434
24633
  if (name === MAP_TOOL_NAMES.search) {
24435
24634
  const input2 = args;
@@ -24952,13 +25151,23 @@ Usage:
24952
25151
  [--depth N] [--tests] [--unresolved] [--offset N]
24953
25152
  layermap search QUERY [--path DIR] [--mode ANY|ALL|LITERAL] [--max N] [--offset N]
24954
25153
  layermap refs PATH NAME [--line N] [--path DIR] [--max N] [--cursor C]
24955
- layermap check [--base REF] what the uncommitted changes (or those since REF) affect
25154
+ layermap check [--base REF] [TEST...] what the uncommitted changes (or those since REF) affect,
25155
+ and what of them the test files given do not run
24956
25156
 
24957
25157
  The project is the Git work tree around the current directory unless --project names one; the MCP
24958
25158
  server also maps any other repository a tool call's path names.
24959
25159
  Maps are kept in ${cacheDirectory()}.`;
24960
25160
  var log = (line) => process.stderr.write(`${line}
24961
25161
  `);
25162
+ async function checkedTests(project, tests) {
25163
+ const here = await realpath4(process.cwd());
25164
+ return tests.map((test) => {
25165
+ const relative = path15.relative(project, path15.resolve(here, test));
25166
+ if (!relative || relative === ".." || relative.startsWith(`..${path15.sep}`) || path15.isAbsolute(relative))
25167
+ throw new Error(`${test} is not in ${project}.`);
25168
+ return relative.split(path15.sep).join("/");
25169
+ });
25170
+ }
24962
25171
  var usage = (code) => {
24963
25172
  (code ? process.stderr : process.stdout).write(`${USAGE}
24964
25173
  `);
@@ -25066,7 +25275,13 @@ async function main(argv) {
25066
25275
  offset: number4(values.offset)
25067
25276
  }
25068
25277
  ],
25069
- check: [MAP_TOOL_NAMES.check, { base: values.base }],
25278
+ check: [
25279
+ MAP_TOOL_NAMES.check,
25280
+ {
25281
+ base: values.base,
25282
+ tests: command === "check" && rest.length ? await checkedTests(project, rest) : void 0
25283
+ }
25284
+ ],
25070
25285
  refs: [
25071
25286
  MAP_TOOL_NAMES.references,
25072
25287
  {