layermap 0.1.52 → 0.1.53

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
@@ -37,7 +37,7 @@ function mapCallLog(cache) {
37
37
  // src/agent/environment.ts
38
38
  import { createHash as createHash6 } from "node:crypto";
39
39
  import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
40
- import { mkdir as mkdir2, readdir, readFile as readFile4, rename as rename2, rm, stat as stat2, utimes, writeFile } from "node:fs/promises";
40
+ import { mkdir as mkdir2, readdir, readFile as readFile5, rename as rename2, rm, stat as stat2, utimes, writeFile } from "node:fs/promises";
41
41
  import { createRequire } from "node:module";
42
42
  import { homedir } from "node:os";
43
43
  import path16 from "node:path";
@@ -22918,9 +22918,178 @@ var CodeIndex = class {
22918
22918
  };
22919
22919
 
22920
22920
  // src/project-map-change-diff.ts
22921
- import { lstat as lstat3, open as open2 } from "node:fs/promises";
22921
+ import { lstat as lstat3, open as open2, readFile as readFile2 } from "node:fs/promises";
22922
22922
  import path12 from "node:path";
22923
22923
 
22924
+ // src/project-map-change-runtime.ts
22925
+ import { transformSync } from "esbuild";
22926
+ var LOADERS = {
22927
+ ".ts": "ts",
22928
+ ".mts": "ts",
22929
+ ".cts": "ts",
22930
+ ".tsx": "tsx"
22931
+ };
22932
+ var DECORATED = /\b__decorat(?:orStart|eClass|eParam)\b/u;
22933
+ var PAIRS = 4e6;
22934
+ var mapErasable = (path20) => !path20.endsWith(".d.ts") && LOADERS[path20.slice(path20.lastIndexOf("."))] !== void 0;
22935
+ function erase(text, path20) {
22936
+ const loader = LOADERS[path20.slice(path20.lastIndexOf("."))];
22937
+ if (!loader) return void 0;
22938
+ let code;
22939
+ let map2;
22940
+ try {
22941
+ ({ code, map: map2 } = transformSync(text, {
22942
+ loader,
22943
+ sourcefile: path20,
22944
+ target: "esnext",
22945
+ // Lowered, so a decorator shows in the helpers it needs.
22946
+ supported: { decorators: false },
22947
+ jsx: "preserve",
22948
+ legalComments: "none",
22949
+ sourcemap: "external",
22950
+ logLevel: "silent",
22951
+ // Fields declared without a value are fields at run time under the standard semantics, and an
22952
+ // import is kept as written: whichever the project's settings, a change to either is code.
22953
+ tsconfigRaw: {
22954
+ compilerOptions: { useDefineForClassFields: true, verbatimModuleSyntax: true }
22955
+ }
22956
+ }));
22957
+ } catch {
22958
+ return void 0;
22959
+ }
22960
+ if (DECORATED.test(code)) return void 0;
22961
+ const lines = code.split("\n");
22962
+ if (lines.at(-1) === "") lines.pop();
22963
+ const from = sourceLines(map2, lines.length);
22964
+ if (!from) return void 0;
22965
+ return { lines: lines.map((line) => line.trim()), from };
22966
+ }
22967
+ var VLQ = new Map(
22968
+ [..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].map((c, i) => [c, i])
22969
+ );
22970
+ function sourceLines(map2, count) {
22971
+ let mappings;
22972
+ try {
22973
+ mappings = String(JSON.parse(map2).mappings);
22974
+ } catch {
22975
+ return void 0;
22976
+ }
22977
+ const seen = [];
22978
+ let source = 0;
22979
+ const groups = mappings.split(";");
22980
+ for (const [generated, group] of groups.entries()) {
22981
+ for (const segment of group ? group.split(",") : []) {
22982
+ const fields2 = [];
22983
+ let value = 0;
22984
+ let shift = 0;
22985
+ for (const char of segment) {
22986
+ const digit = VLQ.get(char);
22987
+ if (digit === void 0) return void 0;
22988
+ value += (digit & 31) << shift;
22989
+ if (digit & 32) shift += 5;
22990
+ else {
22991
+ fields2.push(value & 1 ? -(value >>> 1) : value >>> 1);
22992
+ value = 0;
22993
+ shift = 0;
22994
+ }
22995
+ }
22996
+ if (fields2.length < 4) continue;
22997
+ source += fields2[2];
22998
+ if (fields2[2] === 0 && fields2[3] === 0) continue;
22999
+ const lines = seen[generated] ?? [];
23000
+ lines.push(source + 1);
23001
+ seen[generated] = lines;
23002
+ }
23003
+ }
23004
+ const last = [];
23005
+ const next = [];
23006
+ for (let line = 0, at; line < count; line++) {
23007
+ last[line] = at;
23008
+ const own = seen[line];
23009
+ if (own?.length) at = Math.max(...own);
23010
+ }
23011
+ for (let line = count - 1, at; line >= 0; line--) {
23012
+ next[line] = at;
23013
+ const own = seen[line];
23014
+ if (own?.length) at = Math.min(...own);
23015
+ }
23016
+ const from = [];
23017
+ for (let line = 0; line < count; line++) {
23018
+ const own = seen[line];
23019
+ if (own?.length) from.push([Math.min(...own), Math.max(...own)]);
23020
+ else if (last[line] === void 0 && next[line] === void 0) return void 0;
23021
+ else from.push([last[line] ?? 1, next[line] ?? Number.MAX_SAFE_INTEGER]);
23022
+ }
23023
+ return from;
23024
+ }
23025
+ var touches = (region, [start, end]) => region.from <= region.to ? start <= region.to && region.from <= end : start <= region.to && end >= region.from;
23026
+ function mapRuntimeLines(path20, baseText, text, hunks) {
23027
+ const before = erase(baseText, path20);
23028
+ const after = erase(text, path20);
23029
+ if (!before || !after) return void 0;
23030
+ const regions = hunks.map((hunk) => ({
23031
+ base: hunk.baseCount ? { from: hunk.baseStart, to: hunk.baseStart + hunk.baseCount - 1 } : { from: hunk.baseStart + 1, to: hunk.baseStart },
23032
+ working: hunk.count ? { from: hunk.start, to: hunk.start + hunk.count - 1 } : { from: hunk.start + 1, to: hunk.start }
23033
+ }));
23034
+ const outside = (erased, side) => erased.lines.filter(
23035
+ (_, line) => !regions.some((region) => touches(region[side], erased.from[line]))
23036
+ );
23037
+ const kept = outside(before, "base");
23038
+ const left = outside(after, "working");
23039
+ const bare = (line) => line?.replace(/,$/u, "");
23040
+ if (kept.length !== left.length || kept.some((line, at) => bare(line) !== bare(left[at])))
23041
+ return void 0;
23042
+ const lines = [];
23043
+ for (const region of regions) {
23044
+ const pick2 = (erased, side) => erased.lines.flatMap((line, at) => {
23045
+ const from = erased.from[at];
23046
+ return touches(side, from) ? [{ line, from }] : [];
23047
+ });
23048
+ lines.push(
23049
+ ...changedIn(pick2(before, region.base), pick2(after, region.working), region.working)
23050
+ );
23051
+ }
23052
+ const same3 = before.lines.length === after.lines.length && before.lines.every((line, at) => line === after.lines[at]);
23053
+ if (!same3 && !lines.length) return void 0;
23054
+ const seen = /* @__PURE__ */ new Set();
23055
+ return lines.sort(([a, b], [c, d]) => a - c || b - d).filter((range) => !seen.has(`${range}`) && Boolean(seen.add(`${range}`)));
23056
+ }
23057
+ function changedIn(base, working, region) {
23058
+ if (base.length === working.length && base.every((piece, at) => piece.line === working[at]?.line))
23059
+ return [];
23060
+ const whole = [region.from, region.to];
23061
+ if (base.length * working.length > PAIRS) return [whole];
23062
+ const width = working.length + 1;
23063
+ const table = new Uint32Array((base.length + 1) * width);
23064
+ for (let i = base.length - 1; i >= 0; i--)
23065
+ for (let j = working.length - 1; j >= 0; j--)
23066
+ table[i * width + j] = base[i]?.line === working[j]?.line ? table[(i + 1) * width + j + 1] + 1 : Math.max(table[(i + 1) * width + j], table[i * width + j + 1]);
23067
+ const pairs = [];
23068
+ for (let i = 0, j = 0; i < base.length && j < working.length; )
23069
+ if (base[i]?.line === working[j]?.line) pairs.push([i++, j++]);
23070
+ else if (table[(i + 1) * width + j] >= table[i * width + j + 1]) i++;
23071
+ else j++;
23072
+ const lines = [];
23073
+ const clamp = (start, end) => {
23074
+ const from = Math.max(start, region.from);
23075
+ const to = Math.min(end, region.to);
23076
+ lines.push(region.from <= region.to && from <= to ? [from, to] : whole);
23077
+ };
23078
+ const matched = new Set(pairs.map(([, j]) => j));
23079
+ for (const [j, piece] of working.entries()) if (!matched.has(j)) clamp(...piece.from);
23080
+ const bounds = [[-1, -1], ...pairs, [base.length, working.length]];
23081
+ for (let at = 1; at < bounds.length; at++) {
23082
+ const [i0, j0] = bounds[at - 1];
23083
+ const [i1, j1] = bounds[at];
23084
+ if (i1 - i0 <= 1) continue;
23085
+ clamp(
23086
+ j0 >= 0 ? working[j0].from[1] : region.from,
23087
+ j1 < working.length ? working[j1].from[0] : region.to
23088
+ );
23089
+ }
23090
+ return lines;
23091
+ }
23092
+
22924
23093
  // src/project-map-names.ts
22925
23094
  import { readFile } from "node:fs/promises";
22926
23095
  import path11 from "node:path";
@@ -23083,6 +23252,7 @@ async function readMapChanges(project, base, signal, options = { names: true })
23083
23252
  // not analyze is told the way git tells it, by a NUL in its first 8000 bytes.
23084
23253
  binary: !mapLanguageOf(file2) && await startsBinary(path12.join(project, file2))
23085
23254
  });
23255
+ await eraseTypes(project, commit, files, signal);
23086
23256
  const stranded = options.names ? await strandedNames(
23087
23257
  project,
23088
23258
  files,
@@ -23092,6 +23262,22 @@ async function readMapChanges(project, base, signal, options = { names: true })
23092
23262
  ) : { names: [] };
23093
23263
  return { base, commit, files, quoted: parsed.quoted, stranded };
23094
23264
  }
23265
+ async function eraseTypes(project, commit, files, signal) {
23266
+ const erasable = [...files.entries()].filter(
23267
+ ([, file2]) => file2.status !== "DELETED" && !file2.binary && !mapTestPath(file2.path) && mapErasable(file2.path)
23268
+ );
23269
+ for (let at = 0; at < erasable.length; at += 8)
23270
+ await Promise.all(
23271
+ erasable.slice(at, at + 8).map(async ([index, file2]) => {
23272
+ const text = await readFile2(path12.join(project, file2.path), "utf8").catch(() => void 0);
23273
+ const baseText = file2.status === "ADDED" || !file2.basePath ? "" : await git.run(["show", `${commit}:${file2.basePath}`], gitOptions(project, signal)).then((result) => result.stdout.toString("utf8")).catch(() => void 0);
23274
+ if (text === void 0 || baseText === void 0) return;
23275
+ const hunks = file2.hunks.length ? file2.hunks : [{ baseStart: 0, baseCount: 0, start: 1, count: text.split("\n").length }];
23276
+ const runtime = mapRuntimeLines(file2.path, baseText, text, hunks);
23277
+ if (runtime) files[index] = { ...file2, runtime };
23278
+ })
23279
+ );
23280
+ }
23095
23281
  async function startsBinary(file2) {
23096
23282
  if (!(await lstat3(file2).catch(() => void 0))?.isFile()) return false;
23097
23283
  const handle = await open2(file2, "r").catch(() => void 0);
@@ -23217,7 +23403,7 @@ var DOCUMENTATION = /\.(?:md|mdx|markdown|rst|adoc)$|(?:^|\/)(?:LICENSE|NOTICE)[
23217
23403
  var unmappedKind = (path20, binary) => nonCodeKind(path20) ?? (binary ? "binary file" : DOCUMENTATION.test(path20) ? void 0 : UNANALYZED.find(([pattern]) => pattern.test(path20))?.[1] ?? "unanalyzed file");
23218
23404
 
23219
23405
  // src/project-map-changes.ts
23220
- import { readFile as readFile3 } from "node:fs/promises";
23406
+ import { readFile as readFile4 } from "node:fs/promises";
23221
23407
  import path14 from "node:path";
23222
23408
 
23223
23409
  // src/project-map-change-types.ts
@@ -23422,6 +23608,15 @@ var routeClientsLine = ({ route, removed, clients }) => `${JSON.stringify(route)
23422
23608
  var KINDS = /* @__PURE__ */ new Set(["PROPERTY", "TYPE", "INTERFACE", "ENUM"]);
23423
23609
  var READ_MS = 2e4;
23424
23610
  var mapIsShape = (object2) => KINDS.has(object2.kind) && object2.execution !== "CLOSURE";
23611
+ var TYPE_KINDS = /* @__PURE__ */ new Set(["TYPE", "INTERFACE"]);
23612
+ function mapTypeOnly(graph, ref) {
23613
+ for (let at = ref; at !== void 0; at = graph.parent(at)) {
23614
+ const object2 = graph.object(at);
23615
+ if (TYPE_KINDS.has(object2.kind)) return true;
23616
+ if (object2.execution || object2.kind !== "PROPERTY" && object2.kind !== "METHOD") return false;
23617
+ }
23618
+ return false;
23619
+ }
23425
23620
  var mapShapeDeadline = () => Date.now() + READ_MS;
23426
23621
  var MapShapeUses = class {
23427
23622
  constructor(graph, reader, until) {
@@ -24220,7 +24415,7 @@ function mapChangeEdges(links) {
24220
24415
  }
24221
24416
 
24222
24417
  // src/project-map-change-tests.ts
24223
- import { readFile as readFile2 } from "node:fs/promises";
24418
+ import { readFile as readFile3 } from "node:fs/promises";
24224
24419
  import path13 from "node:path";
24225
24420
 
24226
24421
  // src/project-map-route-paths.ts
@@ -24348,7 +24543,7 @@ var MAP_PATH_PARAMETER = "{}";
24348
24543
  async function existingTestsChanged(before, after, file2, project) {
24349
24544
  if (!file2.basePath || file2.baseText === void 0) return [];
24350
24545
  const baseLines = file2.baseText.split("\n");
24351
- const workingLines = file2.status !== "DELETED" && project ? (await readFile2(path13.join(project, file2.path), "utf8").catch(() => void 0))?.split(
24546
+ const workingLines = file2.status !== "DELETED" && project ? (await readFile3(path13.join(project, file2.path), "utf8").catch(() => void 0))?.split(
24352
24547
  "\n"
24353
24548
  ) ?? [] : [];
24354
24549
  const body = (lines, object2) => lines.slice(object2.anchor.startLine - 1, object2.anchor.endLine).map((line) => line.trimEnd());
@@ -24516,7 +24711,7 @@ var RouteRequests = class {
24516
24711
  }
24517
24712
  const batch = this.candidates.slice(at, at + READ_BATCH);
24518
24713
  const texts = await Promise.all(
24519
- batch.map((file2) => readFile2(path13.join(project, file2), "utf8").catch(() => void 0))
24714
+ batch.map((file2) => readFile3(path13.join(project, file2), "utf8").catch(() => void 0))
24520
24715
  );
24521
24716
  for (const [index, text] of texts.entries())
24522
24717
  if (text !== void 0) yield [batch[index], text];
@@ -24624,13 +24819,13 @@ async function mapRemovedImpact(input) {
24624
24819
  input.cache.memberCalls(store, base),
24625
24820
  new MapShapeUses(before, input.shapes, input.until)
24626
24821
  );
24627
- const changedIn = changedInBase(changes.files);
24822
+ const changedIn2 = changedInBase(changes.files);
24628
24823
  const pathNow = (path20) => {
24629
- const file2 = changedIn.get(path20);
24824
+ const file2 = changedIn2.get(path20);
24630
24825
  return file2?.status === "DELETED" ? void 0 : file2?.path ?? path20;
24631
24826
  };
24632
24827
  const nowAt = (anchor) => {
24633
- const file2 = changedIn.get(anchor.path);
24828
+ const file2 = changedIn2.get(anchor.path);
24634
24829
  if (file2 && (file2.status === "DELETED" || overlaps(file2.baseLines, anchor.startLine, anchor.endLine)))
24635
24830
  return void 0;
24636
24831
  return {
@@ -24796,8 +24991,9 @@ async function mapRemovedImpact(input) {
24796
24991
  ))
24797
24992
  topLevel.push(file2.path);
24798
24993
  }
24799
- if (gone2.size) {
24800
- await beforeTracer.trace([...gone2], [...gone2], true);
24994
+ const ran = [...gone2].filter((ref) => !mapTypeOnly(before, ref));
24995
+ if (ran.length) {
24996
+ await beforeTracer.trace(ran, ran, true);
24801
24997
  const siteNow = (site) => {
24802
24998
  const at = site.lastIndexOf(":");
24803
24999
  const line = Number(site.slice(at + 1));
@@ -25086,7 +25282,8 @@ Nothing changed against ${changes.base}.`;
25086
25282
  "Where the diff changed a route's registration, check that the route still reaches the right handler."
25087
25283
  );
25088
25284
  if (impact.untested) {
25089
- const { changed, entries, throughRoutes, routes: routes2, missing, truncated } = impact.untested;
25285
+ const { changed, entries, throughRoutes, routes: routes2, missing, truncated, typeOnly } = impact.untested;
25286
+ const runs = impact.changed.length - typeOnly;
25090
25287
  const items = (shown, limit2) => {
25091
25288
  lines.push(...shown.slice(0, limit2).map((item) => ` ${item}`));
25092
25289
  if (shown.length > limit2) lines.push(` +${shown.length - limit2} more`);
@@ -25096,7 +25293,7 @@ Nothing changed against ${changes.base}.`;
25096
25293
  lines.push(` the map has no code for these given files: ${missing.join(", ")}`);
25097
25294
  if (changed.length) {
25098
25295
  lines.push(
25099
- ` ${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:"}`
25296
+ ` ${changed.length} of ${runs} changed declarations are reached by none of the given tests; ${entries.length ? "the entry points above them, then the declarations:" : "the declarations:"}`
25100
25297
  );
25101
25298
  items(
25102
25299
  entries.map((item) => {
@@ -25123,7 +25320,11 @@ Nothing changed against ${changes.base}.`;
25123
25320
  );
25124
25321
  } else
25125
25322
  lines.push(
25126
- impact.changed.length ? ` none: the given tests reach all ${impact.changed.length} changed declarations` : " none: the diff changes no declarations outside the tests"
25323
+ runs ? ` none: the given tests reach all ${runs} changed declarations` : impact.changed.length ? " none: outside the tests the diff changes types alone (or comments and layout)" : " none: the diff changes no declarations outside the tests"
25324
+ );
25325
+ if (typeOnly)
25326
+ lines.push(
25327
+ ` ${typeOnly} changed declarations change types alone (or comments and layout) and are not judged: none of the code they run changed, and the type checker checks the types`
25127
25328
  );
25128
25329
  if (throughRoutes.length) {
25129
25330
  lines.push(
@@ -25571,8 +25772,10 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
25571
25772
  `the text search for the environment variables and configuration keys the diff removed did not finish (${changes.stranded.failed}), so the files still using them are not listed`
25572
25773
  );
25573
25774
  const unmapped = [];
25574
- let changedCount = 0;
25575
25775
  const starts = [];
25776
+ const traced = [];
25777
+ let typeOnly = 0;
25778
+ let untraced = 0;
25576
25779
  const importers = /* @__PURE__ */ new Map();
25577
25780
  let mapped;
25578
25781
  const mappedPaths = () => mapped ??= store.database.prepare("SELECT DISTINCT path FROM project_map_objects WHERE version_ref = ?").all(working).map((row) => String(row.path));
@@ -25602,21 +25805,26 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
25602
25805
  unmapped.push({ path: file2.path, kind });
25603
25806
  }
25604
25807
  if (!objects2.length) continue;
25605
- const { refs: hits, topLevel } = changedUnits(graph, file2.path, file2.lines);
25808
+ const { refs: hits } = changedUnits(graph, file2.path, file2.lines);
25809
+ const lines = file2.runtime ?? file2.lines;
25810
+ const { refs: running, topLevel } = changedUnits(graph, file2.path, lines);
25606
25811
  for (const ref of hits) {
25607
- if (changedCount++ >= LIMITS.changed) {
25608
- tracer.truncated = true;
25609
- break;
25812
+ const types = !running.has(ref) || mapTypeOnly(graph, ref);
25813
+ if (!types && starts.length >= LIMITS.changed) {
25814
+ untraced++;
25815
+ continue;
25816
+ }
25817
+ const label = `${file2.path}${template ? " (template)" : `: ${graph.qualifiedName(ref)} ${mapDeclarationLabel(graph.object(ref))}`}${file2.status === "ADDED" ? " (new file)" : ""}`;
25818
+ changed.push(label);
25819
+ if (types) typeOnly++;
25820
+ else {
25821
+ traced.push(label);
25822
+ starts.push(tracer.startsAt(ref, lines));
25610
25823
  }
25611
- const object2 = graph.object(ref);
25612
- changed.push(
25613
- `${file2.path}${template ? " (template)" : `: ${graph.qualifiedName(ref)} ${mapDeclarationLabel(object2)}`}${file2.status === "ADDED" ? " (new file)" : ""}`
25614
- );
25615
- starts.push(tracer.startsAt(ref, file2.lines));
25616
25824
  }
25617
25825
  for (const relation of graph.relationsFrom(objects2.map((object2) => object2.id))) {
25618
25826
  const route = mapRegisteredRoute(relation);
25619
- if (route && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine)) {
25827
+ if (route && overlaps(lines, relation.anchor.startLine, relation.anchor.endLine)) {
25620
25828
  const site = `${relation.anchor.path}:${relation.anchor.startLine}`;
25621
25829
  unclear.push({
25622
25830
  text: `the registration of ${JSON.stringify(route)} at ${site} changed; check that the route still reaches the right handler`,
@@ -25692,7 +25900,7 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
25692
25900
  ", "
25693
25901
  )}${unread.length > LIST.names ? ", \u2026" : ""}); project_find_references lists their uses`
25694
25902
  });
25695
- const untested = tests && await untestedChanges(graph, tracer, memberCalls, starts, changed, tests);
25903
+ const untested = tests && await untestedChanges(graph, tracer, memberCalls, starts, traced, tests, typeOnly);
25696
25904
  supportTests(store, working, tracer);
25697
25905
  const taken = base ? await mapRemovedImpact({
25698
25906
  store,
@@ -25731,6 +25939,9 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
25731
25939
  ],
25732
25940
  incomplete: [
25733
25941
  ...incomplete,
25942
+ ...untraced ? [
25943
+ `the diff changes more than ${LIMITS.changed} declarations that run; the ${untraced} after the first ${LIMITS.changed} were not followed, so what only they reach is not listed`
25944
+ ] : [],
25734
25945
  ...tracer.truncated ? [
25735
25946
  `the trace stopped at ${LIMITS.depth} levels or ${LIMITS.declarations} declarations; continue with project_explore_map from the last ones`
25736
25947
  ] : []
@@ -25740,11 +25951,11 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
25740
25951
  uncalled: taken?.uncalled ?? [],
25741
25952
  dependencies: newModuleDependencies(store, views, working, changes.files, links.files),
25742
25953
  ...untested ? { untested } : {},
25743
- truncated: tracer.truncated
25954
+ truncated: tracer.truncated || untraced > 0
25744
25955
  };
25745
25956
  }
25746
25957
  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);
25747
- async function untestedChanges(graph, tracer, memberCalls, starts, changed, tests) {
25958
+ async function untestedChanges(graph, tracer, memberCalls, starts, changed, tests, typeOnly) {
25748
25959
  const given = new Set(tests);
25749
25960
  const handlers = (requests, files) => {
25750
25961
  const into = /* @__PURE__ */ new Map();
@@ -25796,6 +26007,7 @@ async function untestedChanges(graph, tracer, memberCalls, starts, changed, test
25796
26007
  const others = new Set([...tracer.tests.keys()].filter((file2) => !given.has(file2)));
25797
26008
  return {
25798
26009
  changed: unreached.map((at) => changed[at] ?? ""),
26010
+ typeOnly,
25799
26011
  runByOthers: runBy(others, requested),
25800
26012
  mayRun: runBy(given, tracer.mayRequest),
25801
26013
  entries: [...above.entries.values()].sort(entryOrder),
@@ -25895,7 +26107,7 @@ async function checkMapChanges(input, signal) {
25895
26107
  working,
25896
26108
  base,
25897
26109
  changes.files,
25898
- (file2) => readFile3(path14.join(project, file2), "utf8").catch(() => void 0)
26110
+ (file2) => readFile4(path14.join(project, file2), "utf8").catch(() => void 0)
25899
26111
  )
25900
26112
  ),
25901
26113
  changes.files.length ? await compileBreaks(input, views, changes, base, until, signal, phase, baseVersion) : void 0
@@ -26416,7 +26628,7 @@ var packageRoot = (() => {
26416
26628
  directory = path16.dirname(directory);
26417
26629
  }
26418
26630
  })();
26419
- var packageVersion = async () => JSON.parse(await readFile4(path16.join(packageRoot, "package.json"), "utf8")).version;
26631
+ var packageVersion = async () => JSON.parse(await readFile5(path16.join(packageRoot, "package.json"), "utf8")).version;
26420
26632
  var cacheDirectory = (env = process.env) => {
26421
26633
  if (env.LAYERMAP_CACHE) return path16.resolve(env.LAYERMAP_CACHE);
26422
26634
  if (process.platform === "darwin") return path16.join(homedir(), "Library", "Caches", "layermap");
@@ -26476,11 +26688,11 @@ var absoluteIn = (directory, value) => Object.fromEntries(
26476
26688
  var readAnalyzers = async (directory) => {
26477
26689
  const file2 = path16.join(directory, "analyzers.json");
26478
26690
  if (!existsSync6(file2)) return void 0;
26479
- const analyzers = absoluteIn(directory, JSON.parse(await readFile4(file2, "utf8")));
26691
+ const analyzers = absoluteIn(directory, JSON.parse(await readFile5(file2, "utf8")));
26480
26692
  return analyzers.java.runtimePath ? analyzers : { ...analyzers, java: { ...analyzers.java, ...discoverJavaRuntime() } };
26481
26693
  };
26482
26694
  var sourceDigest = async () => {
26483
- const hash2 = createHash6("sha256").update(await readFile4(path16.join(packageRoot, "package.json")));
26695
+ const hash2 = createHash6("sha256").update(await readFile5(path16.join(packageRoot, "package.json")));
26484
26696
  for (const part of ["src", "go-map", "java-map", "scripts"]) {
26485
26697
  const directory = path16.join(packageRoot, part);
26486
26698
  if (!existsSync6(directory)) continue;
@@ -26529,7 +26741,7 @@ async function pruneCache(cache, project, now = Date.now(), installed = packageR
26529
26741
  const directory = path16.join(projects, name);
26530
26742
  const marker = path16.join(directory, "last-used");
26531
26743
  const last = (await stat2(existsSync6(marker) ? marker : directory).catch(() => void 0))?.mtimeMs;
26532
- const owner = await readFile4(marker, "utf8").catch(() => "");
26744
+ const owner = await readFile5(marker, "utf8").catch(() => "");
26533
26745
  if (last !== void 0 && now - last > 30 * DAY || owner !== "" && await gone(owner))
26534
26746
  await rm(directory, { recursive: true, force: true });
26535
26747
  }
@@ -26570,7 +26782,7 @@ async function pruneVersions(versions, own, now) {
26570
26782
  }
26571
26783
  async function pruneNpxInstalls(npx, installed, now) {
26572
26784
  const own = path16.dirname(path16.dirname(installed));
26573
- const manifest = async (file2) => JSON.parse(await readFile4(file2, "utf8").catch(() => "{}"));
26785
+ const manifest = async (file2) => JSON.parse(await readFile5(file2, "utf8").catch(() => "{}"));
26574
26786
  const parts = (version2) => version2?.split(".").map(Number) ?? [];
26575
26787
  const current = parts((await manifest(path16.join(installed, "package.json"))).version);
26576
26788
  const older = (version2) => {
@@ -27116,7 +27328,7 @@ ${text}` : text
27116
27328
  // src/agent/setup.ts
27117
27329
  import { execFile } from "node:child_process";
27118
27330
  import { existsSync as existsSync8 } from "node:fs";
27119
- import { mkdir as mkdir3, readFile as readFile5, rename as rename3, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
27331
+ import { mkdir as mkdir3, readFile as readFile6, rename as rename3, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
27120
27332
  import { homedir as homedir2 } from "node:os";
27121
27333
  import path18 from "node:path";
27122
27334
  var SERVER = "layermap";
@@ -27157,7 +27369,7 @@ var run = (command, args, env) => new Promise((resolve) => {
27157
27369
  );
27158
27370
  });
27159
27371
  async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
27160
- const settings = existsSync8(file2) ? JSON.parse(await readFile5(file2, "utf8")) : {};
27372
+ const settings = existsSync8(file2) ? JSON.parse(await readFile6(file2, "utf8")) : {};
27161
27373
  if (typeof settings !== "object" || settings === null || Array.isArray(settings))
27162
27374
  throw new Error(`${file2} is not a settings object.`);
27163
27375
  settings.permissions ??= {};
@@ -27173,7 +27385,7 @@ async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
27173
27385
  }
27174
27386
  var CODEX_TOOL_TIMEOUT_SEC = 300;
27175
27387
  async function configureCodexServer(file2) {
27176
- const lines = (await readFile5(file2, "utf8")).split("\n");
27388
+ const lines = (await readFile6(file2, "utf8")).split("\n");
27177
27389
  const header2 = lines.findIndex((line) => line.trim() === `[mcp_servers.${SERVER}]`);
27178
27390
  if (header2 < 0) throw new Error(`${file2} has no [mcp_servers.${SERVER}] table.`);
27179
27391
  let end = header2 + 1;
@@ -27196,7 +27408,7 @@ async function writeInstructionNote(file2, note = AGENT_MAP_NOTE) {
27196
27408
  const block = `${BEGIN}
27197
27409
  ${note}
27198
27410
  ${END}`;
27199
- const text = existsSync8(file2) ? await readFile5(file2, "utf8") : "";
27411
+ const text = existsSync8(file2) ? await readFile6(file2, "utf8") : "";
27200
27412
  const start = text.indexOf(BEGIN);
27201
27413
  const end = text.indexOf(END);
27202
27414
  const next = start >= 0 && end > start ? `${text.slice(0, start)}${block}${text.slice(end + END.length)}` : `${text}${text && !text.endsWith("\n") ? "\n" : ""}${text ? "\n" : ""}${block}
@@ -27207,7 +27419,7 @@ ${END}`;
27207
27419
  }
27208
27420
  async function removeInstructionNote(file2) {
27209
27421
  if (!existsSync8(file2)) return;
27210
- const text = await readFile5(file2, "utf8");
27422
+ const text = await readFile6(file2, "utf8");
27211
27423
  const start = text.indexOf(BEGIN);
27212
27424
  const end = text.indexOf(END);
27213
27425
  if (start < 0 || end < start) return;
@@ -27218,7 +27430,7 @@ async function removeInstructionNote(file2) {
27218
27430
  }
27219
27431
  async function disallowInClaudeSettings(file2) {
27220
27432
  if (!existsSync8(file2)) return;
27221
- const settings = JSON.parse(await readFile5(file2, "utf8"));
27433
+ const settings = JSON.parse(await readFile6(file2, "utf8"));
27222
27434
  const allow = settings?.permissions?.allow;
27223
27435
  const ours = (rule) => rule === SETUP_RULE || rule === PLUGIN_RULE;
27224
27436
  if (!Array.isArray(allow) || !allow.some(ours)) return;
@@ -27253,7 +27465,7 @@ var dshPatchBlock = (command, env) => {
27253
27465
  ].join("\n");
27254
27466
  };
27255
27467
  async function writeDshPatch(file2, block) {
27256
- const text = existsSync8(file2) ? await readFile5(file2, "utf8") : "";
27468
+ const text = existsSync8(file2) ? await readFile6(file2, "utf8") : "";
27257
27469
  const start = text.indexOf(YAML_BEGIN);
27258
27470
  const end = text.indexOf(YAML_END);
27259
27471
  let next;
@@ -27274,7 +27486,7 @@ async function writeDshPatch(file2, block) {
27274
27486
  }
27275
27487
  async function removeDshPatch(file2) {
27276
27488
  if (!existsSync8(file2)) return;
27277
- const text = await readFile5(file2, "utf8");
27489
+ const text = await readFile6(file2, "utf8");
27278
27490
  const start = text.indexOf(YAML_BEGIN);
27279
27491
  const end = text.indexOf(YAML_END);
27280
27492
  if (start < 0 || end < start) return;
@@ -27334,7 +27546,7 @@ async function setupAgent(options) {
27334
27546
  await mkdir3(path18.dirname(file2), { recursive: true, mode: 448 });
27335
27547
  await writeFile2(
27336
27548
  `${file2}.${process.pid}`,
27337
- launcherScript(await readFile5(PUBLISHED_LAUNCHER, "utf8"), options.version)
27549
+ launcherScript(await readFile6(PUBLISHED_LAUNCHER, "utf8"), options.version)
27338
27550
  );
27339
27551
  await rename3(`${file2}.${process.pid}`, file2);
27340
27552
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "layermap",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "mcpName": "io.github.coffeecoproject/layermap",
5
5
  "description": "A layered map of a codebase for coding agents: directories, modules and call chains across TypeScript, JavaScript, Go, Python and Java.",
6
6
  "license": "Apache-2.0",
@@ -26,7 +26,8 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@photostructure/sqlite": "3.3.0",
29
- "typescript": "7.0.2"
29
+ "typescript": "7.0.2",
30
+ "esbuild": "0.28.1"
30
31
  },
31
32
  "homepage": "https://github.com/coffeecoproject/layermap",
32
33
  "repository": {
package/pi/layermap.mjs CHANGED
@@ -293,7 +293,7 @@ function layermap(pi) {
293
293
  if (server && !server.dead) return server;
294
294
  starting ??= (async () => {
295
295
  const next = new MapServer(cwd);
296
- const tools = await next.start("0.1.52");
296
+ const tools = await next.start("0.1.53");
297
297
  for (const tool of tools) {
298
298
  if (registered.has(tool.name)) continue;
299
299
  registered.add(tool.name);