layermap 0.1.37 → 0.1.39

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -14740,7 +14740,6 @@ process.once(
14740
14740
  helper.stdin.end(
14741
14741
  JSON.stringify({
14742
14742
  operation: message.operation,
14743
- modFile: message.modFile ?? "",
14744
14743
  files: message.files,
14745
14744
  ...message.targets ? { targets: message.targets } : {}
14746
14745
  })
@@ -15710,10 +15710,15 @@ var MapVirtualFiles = class {
15710
15710
  import path5 from "node:path";
15711
15711
  function pnpmPackages(text2) {
15712
15712
  const lines = text2.replace(/^\uFEFF/u, "").split(/\r?\n/u).filter((line) => line.trim() && !line.trimStart().startsWith("#"));
15713
- if (!/^packages:\s*(?:#.*)?$/u.test(lines[0] ?? "")) return void 0;
15713
+ const keys = lines.flatMap(
15714
+ (line, index) => /^packages:\s*(?:#.*)?$/u.test(line) ? [index] : []
15715
+ );
15716
+ if (keys.length !== 1 || keys[0] === void 0) return void 0;
15717
+ const after = lines.slice(keys[0] + 1);
15718
+ const end = after.findIndex((line) => !/^\s/u.test(line) && !line.startsWith("-"));
15714
15719
  const patterns = [];
15715
- for (const line of lines.slice(1)) {
15716
- const match = /^\s+-\s+("(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s#]+)\s*(?:#.*)?$/u.exec(line);
15720
+ for (const line of end === -1 ? after : after.slice(0, end)) {
15721
+ const match = /^\s*-\s+("(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s#]+)\s*(?:#.*)?$/u.exec(line);
15717
15722
  if (!match?.[1]) return void 0;
15718
15723
  const value = match[1];
15719
15724
  try {
package/dist/cli.mjs CHANGED
@@ -16055,6 +16055,7 @@ var mapPathAllowed = (relative, prefixes) => prefixes.some(
16055
16055
  var mapTestPath = (path17) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
16056
16056
  path17
16057
16057
  );
16058
+ var MAP_MIGRATION_PATH = /(?:^|\/)migrations?\/|\.sql$/iu;
16058
16059
 
16059
16060
  // src/project-map-reference-types.ts
16060
16061
  var MapReferenceKindSchema = external_exports.enum([
@@ -17239,6 +17240,7 @@ function mapPageFrontier(frontier, rows2) {
17239
17240
 
17240
17241
  // src/project-map-language-go.ts
17241
17242
  import { existsSync as existsSync4 } from "node:fs";
17243
+ import { posix } from "node:path";
17242
17244
 
17243
17245
  // src/project-map-analysis-validation.ts
17244
17246
  function validateMapAnalysis(analysis, input) {
@@ -17448,7 +17450,7 @@ function mapFactsAnalysis(facts, input, context) {
17448
17450
  optionsDigest: context.optionsDigest,
17449
17451
  mode: context.configPath ? "CONFIGURED" : "INFERRED",
17450
17452
  inputFiles: Object.keys(input.files).sort(),
17451
- configurationFiles: context.configPath ? [context.configPath] : []
17453
+ configurationFiles: context.configurationFiles ? [...context.configurationFiles] : context.configPath ? [context.configPath] : []
17452
17454
  }
17453
17455
  ],
17454
17456
  objects: [],
@@ -18037,11 +18039,12 @@ function runMapOperation(resources, input, schema, signal, observeTiming) {
18037
18039
 
18038
18040
  // src/project-map-language-go.ts
18039
18041
  var goModule = /(?:^|\/)go\.mod$/u;
18042
+ var goWork = /(?:^|\/)go\.work$/u;
18040
18043
  var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
18041
18044
  var GO_MAP_LANGUAGE = Object.freeze({
18042
- id: "go-1.24-map-v9",
18045
+ id: "go-1.24-map-v10",
18043
18046
  claims: (path17) => path17.endsWith(".go"),
18044
- reads: (path17) => goModule.test(path17),
18047
+ reads: (path17) => goModule.test(path17) || goWork.test(path17),
18045
18048
  // A module path, or the standard library, whose first path element has no dot.
18046
18049
  importName: (specifier) => {
18047
18050
  const parts = specifier.split("/");
@@ -18062,15 +18065,68 @@ var GO_GAPS = [
18062
18065
  "DETAILED_REFERENCES_AVAILABLE_ON_DEMAND",
18063
18066
  "LOCAL_BINDINGS_MAPPED_WHEN_LINKED"
18064
18067
  ];
18065
- var goMapAnalysis = (facts, input, modFile) => mapFactsAnalysis(facts, input, {
18068
+ var goMapAnalysis = (facts, input, configurations) => mapFactsAnalysis(facts, input, {
18066
18069
  language: "go",
18067
18070
  offsets: "UTF8_BYTES",
18068
- ...modFile ? { configPath: modFile } : {},
18071
+ ...input.configPath ? { configPath: input.configPath } : {},
18072
+ configurationFiles: configurations,
18069
18073
  optionsDigest: digestValue({ goos: "linux", goarch: "amd64", cgo: false }),
18070
- gaps: [...modFile ? [] : [{ code: "NO_GO_MODULE" }], ...GO_GAPS.map((code) => ({ code }))],
18074
+ gaps: [
18075
+ ...input.configPath ? [] : [{ code: "NO_GO_MODULE" }],
18076
+ ...GO_GAPS.map((code) => ({ code }))
18077
+ ],
18071
18078
  typeIssues: "GO_TYPE_CHECK_ISSUES",
18072
18079
  contract: "Declares a Go interface. This does not establish runtime enforcement or business authority."
18073
18080
  });
18081
+ var goLocalModules = (path17, text) => {
18082
+ const directive = goWork.test(path17) ? "use" : "replace";
18083
+ const found = [];
18084
+ let block = false;
18085
+ for (const raw of text.split("\n")) {
18086
+ const line = raw.replace(/\/\/.*$/u, "").trim();
18087
+ let entry;
18088
+ if (block) {
18089
+ if (line === ")") block = false;
18090
+ else entry = line;
18091
+ } else if (line === `${directive} (`) block = true;
18092
+ else if (line.startsWith(`${directive} `)) entry = line.slice(directive.length + 1);
18093
+ const target = directive === "use" ? entry : entry?.split("=>")[1];
18094
+ const directory = target?.trim().split(/\s+/u)[0]?.replace(/^(["`])(.*)\1$/u, "$2");
18095
+ if (!directory || !/^\.\.?(?:\/|$)/u.test(directory)) continue;
18096
+ const joined = posix.normalize(posix.join(posix.dirname(path17), directory)).replace(/\/$/u, "");
18097
+ if (joined !== ".." && !joined.startsWith("../")) found.push(joined);
18098
+ }
18099
+ return found;
18100
+ };
18101
+ var goModuleGroups = (files, text) => {
18102
+ const modules = files.filter((path17) => goModule.test(path17)).sort();
18103
+ const moduleAt = new Map(modules.map((path17) => [posix.dirname(path17), path17]));
18104
+ const parent = new Map(modules.map((path17) => [path17, path17]));
18105
+ const root = (path17) => {
18106
+ const up = parent.get(path17) ?? path17;
18107
+ return up === path17 ? path17 : root(up);
18108
+ };
18109
+ const works = [];
18110
+ for (const path17 of [...files].filter((file2) => goModule.test(file2) || goWork.test(file2)).sort()) {
18111
+ const linked = goLocalModules(path17, text(path17)).flatMap((dir) => moduleAt.get(dir) ?? []);
18112
+ const first = goWork.test(path17) ? linked[0] : path17;
18113
+ if (!first) continue;
18114
+ if (goWork.test(path17)) works.push([path17, first]);
18115
+ for (const module of linked) {
18116
+ const [low = first, high = module] = [root(first), root(module)].sort();
18117
+ if (low !== high) parent.set(high, low);
18118
+ }
18119
+ }
18120
+ const members = /* @__PURE__ */ new Map();
18121
+ for (const path17 of modules) members.set(root(path17), [...members.get(root(path17)) ?? [], path17]);
18122
+ const named = new Map(works.reverse().map(([work, module]) => [root(module), work]));
18123
+ return new Map(
18124
+ modules.map((path17) => [
18125
+ path17,
18126
+ { configPath: named.get(root(path17)) ?? root(path17), modules: members.get(root(path17)) ?? [] }
18127
+ ])
18128
+ );
18129
+ };
18074
18130
  var GoMapAnalyzer = class {
18075
18131
  constructor(resources = installedGoMapResources()) {
18076
18132
  this.resources = resources;
@@ -18096,28 +18152,37 @@ var GoMapAnalyzer = class {
18096
18152
  }
18097
18153
  }
18098
18154
  async analyze(session, signal) {
18099
- const modules = session.readable.map((entry) => entry.path).filter((path17) => goModule.test(path17)).sort();
18155
+ const paths = session.readable.map((entry) => entry.path);
18156
+ const groupOf = goModuleGroups(paths, (path17) => session.texts[path17] ?? "");
18100
18157
  const moduleOf = (path17) => {
18101
18158
  let best;
18102
- for (const modFile of modules) {
18159
+ for (const modFile of groupOf.keys()) {
18103
18160
  const directory = modFile.slice(0, modFile.lastIndexOf("/") + 1);
18104
18161
  if (path17.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
18105
18162
  best = modFile;
18106
18163
  }
18107
18164
  return best;
18108
18165
  };
18109
- const groups = /* @__PURE__ */ new Map();
18110
- for (const entry of session.readable) {
18111
- if (!this.claims(entry.path)) continue;
18112
- const key = moduleOf(entry.path) ?? "";
18113
- const into = groups.get(key);
18114
- if (into) into.push(entry.path);
18115
- else groups.set(key, [entry.path]);
18166
+ const contexts = /* @__PURE__ */ new Map();
18167
+ for (const path17 of paths) {
18168
+ if (!this.claims(path17)) continue;
18169
+ const module = moduleOf(path17);
18170
+ const group = module ? groupOf.get(module) : void 0;
18171
+ const configPath = group?.configPath ?? "";
18172
+ const into = contexts.get(configPath);
18173
+ if (into) into.sources.push(path17);
18174
+ else
18175
+ contexts.set(configPath, {
18176
+ configurations: group ? [.../* @__PURE__ */ new Set([...group.modules, configPath])].sort() : [],
18177
+ sources: [path17]
18178
+ });
18116
18179
  }
18117
- for (const modFile of [...groups.keys()].sort()) {
18180
+ for (const [configPath, { configurations, sources }] of [...contexts].sort(
18181
+ ([left], [right]) => left < right ? -1 : left > right ? 1 : 0
18182
+ )) {
18118
18183
  if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
18119
18184
  const files = /* @__PURE__ */ Object.create(null);
18120
- for (const path17 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
18185
+ for (const path17 of [...sources, ...configurations]) {
18121
18186
  const text = session.texts[path17];
18122
18187
  if (text === void 0)
18123
18188
  throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
@@ -18126,26 +18191,26 @@ var GoMapAnalyzer = class {
18126
18191
  const input = {
18127
18192
  contextRef: digestValue({
18128
18193
  analyzer: this.id,
18129
- configPath: modFile || null
18194
+ configPath: configPath || null
18130
18195
  }),
18131
- ...modFile ? { configPath: modFile } : {},
18196
+ ...configPath ? { configPath } : {},
18132
18197
  files,
18133
18198
  inventory: Object.keys(files).sort(),
18134
18199
  syntaxOnly: false
18135
18200
  };
18136
18201
  const built = existsSync4(this.resources.compilerPath);
18137
- const reused = session.reuse(input.contextRef, { modFile, built }, Object.keys(files));
18202
+ const reused = session.reuse(input.contextRef, { configurations, built }, Object.keys(files));
18138
18203
  if (reused) {
18139
18204
  session.accept(reused);
18140
18205
  continue;
18141
18206
  }
18142
18207
  const facts = built ? await this.operation(
18143
- { ...input, operation: "BUILD", modFile },
18208
+ { ...input, operation: "BUILD" },
18144
18209
  MapFactsSchema,
18145
18210
  signal,
18146
18211
  session.observe
18147
18212
  ) : { files: [], objects: [], relations: [], notes: [], typeErrors: 0 };
18148
- const analysis = goMapAnalysis(facts, input, modFile || void 0);
18213
+ const analysis = goMapAnalysis(facts, input, configurations);
18149
18214
  if (!built) analysis.gaps.push({ code: "GO_ANALYZER_NOT_BUILT" });
18150
18215
  validateMapAnalysis(analysis, input);
18151
18216
  session.accept(analysis);
@@ -18156,13 +18221,12 @@ var GoMapAnalyzer = class {
18156
18221
  return { pages: references.map(() => null), requiredFiles: [] };
18157
18222
  const files = /* @__PURE__ */ Object.create(null);
18158
18223
  for (const [path17, value] of Object.entries(input.files))
18159
- if (this.claims(path17) || goModule.test(path17)) files[path17] = value;
18224
+ if (this.claims(path17) || this.reads(path17)) files[path17] = value;
18160
18225
  const facts = await this.operation(
18161
18226
  {
18162
18227
  ...input,
18163
18228
  files,
18164
18229
  operation: "REFERENCES",
18165
- modFile: input.configPath ?? "",
18166
18230
  targets: references.map(({ targetPath, symbolStart }) => ({
18167
18231
  path: targetPath,
18168
18232
  offset: mapFactsOffset(input.files[targetPath] ?? "", symbolStart, "UTF8_BYTES")
@@ -22712,6 +22776,66 @@ function newModuleDependencies(store, cache, working, base, files) {
22712
22776
  (left, right) => Number(right.back !== void 0) - Number(left.back !== void 0) || (left.from < right.from ? -1 : left.from > right.from ? 1 : 0) || (left.to < right.to ? -1 : left.to > right.to ? 1 : 0)
22713
22777
  );
22714
22778
  }
22779
+ var MANIFEST = /(?:^|\/)(?:package\.json|go\.mod|pom\.xml|build\.gradle(?:\.kts)?|pyproject\.toml|setup\.py|setup\.cfg)$/u;
22780
+ var directoryOf3 = (path17) => path17.slice(0, Math.max(path17.lastIndexOf("/"), 0));
22781
+ var directoryLabel = (directory) => directory ? `${directory}/` : "./";
22782
+ function mapReuseImports(store, cache, working) {
22783
+ const roots = store.listEntries(working).filter((entry) => MANIFEST.test(entry.path)).map((entry) => directoryOf3(entry.path)).sort((left, right) => right.length - left.length);
22784
+ const packageOf = (path17) => roots.find((root) => !root || path17.startsWith(`${root}/`)) ?? "";
22785
+ const directories = /* @__PURE__ */ new Map();
22786
+ const packages = /* @__PURE__ */ new Map();
22787
+ const files = /* @__PURE__ */ new Set();
22788
+ for (const { source, target } of cache.imports(store, working)) {
22789
+ if (target === null) continue;
22790
+ files.add(`${source}\0${target}`);
22791
+ if (mapTestPath(source)) continue;
22792
+ const from = directoryOf3(source);
22793
+ const to = directoryOf3(target);
22794
+ if (from !== to) {
22795
+ const targets = directories.get(from) ?? /* @__PURE__ */ new Map();
22796
+ targets.set(to, []);
22797
+ directories.set(from, targets);
22798
+ }
22799
+ const fromPackage = packageOf(source);
22800
+ const toPackage = packageOf(target);
22801
+ if (fromPackage !== toPackage)
22802
+ packages.set(fromPackage, (packages.get(fromPackage) ?? /* @__PURE__ */ new Set()).add(toPackage));
22803
+ }
22804
+ const use = (user, [from, fromPackage], [to, toPackage]) => {
22805
+ const imported = from === to || directories.get(from)?.has(to) === true;
22806
+ return {
22807
+ user,
22808
+ from: directoryLabel(from),
22809
+ to: directoryLabel(to),
22810
+ imported,
22811
+ cycle: !imported && pathBetween(directories, to, from) !== void 0,
22812
+ ...fromPackage === toPackage ? {} : { packages: [directoryLabel(fromPackage), directoryLabel(toPackage)] }
22813
+ };
22814
+ };
22815
+ const graph = new MapViewGraph(store, working);
22816
+ const usedFrom = /* @__PURE__ */ new Map();
22817
+ const used = (path17) => {
22818
+ let found = usedFrom.get(path17);
22819
+ if (found === void 0) {
22820
+ found = graph.relationsTo(graph.objectsAt(path17).map((object2) => object2.id)).some((relation) => graph.object(relation.from).anchor.path !== path17);
22821
+ usedFrom.set(path17, found);
22822
+ }
22823
+ return found;
22824
+ };
22825
+ return (path17, existing) => {
22826
+ const added = [directoryOf3(path17), packageOf(path17)];
22827
+ const old = [directoryOf3(existing), packageOf(existing)];
22828
+ const ahead = use("NEW", added, old);
22829
+ if (files.has(`${path17}\0${existing}`)) return ahead;
22830
+ if (files.has(`${existing}\0${path17}`))
22831
+ return { ...use("EXISTING", old, added), from: existing, to: path17 };
22832
+ const usable = used(existing);
22833
+ if (usable && ahead.imported) return ahead;
22834
+ if (directories.get(old[0])?.has(added[0])) return use("EXISTING", old, added);
22835
+ if (usable && (added[1] === old[1] || packages.get(added[1])?.has(old[1]))) return ahead;
22836
+ return packages.get(old[1])?.has(added[1]) ? use("EXISTING", old, added) : void 0;
22837
+ };
22838
+ }
22715
22839
 
22716
22840
  // src/project-map-names.ts
22717
22841
  import { readFileSync as readFileSync3 } from "node:fs";
@@ -22865,7 +22989,7 @@ var MODULES = /* @__PURE__ */ new Set(["FILE", "PACKAGE", "CONFIG"]);
22865
22989
  var MEMBER_CONTAINERS2 = /* @__PURE__ */ new Set(["CLASS", "INTERFACE", "TYPE", "ENUM"]);
22866
22990
  var KINDS = /* @__PURE__ */ new Set(["FUNCTION", "METHOD", "CLASS", "VARIABLE"]);
22867
22991
  var MIN_LINES = 3;
22868
- var SHORT_COPIES = 3;
22992
+ var CONVENTION = 3;
22869
22993
  var ALIKE = 0.8;
22870
22994
  var SIBLINGS_ALIKE = 0.95;
22871
22995
  var KEYWORDS = new Set(
@@ -22917,7 +23041,7 @@ function lineWords(line) {
22917
23041
  var within2 = (lines, declaration) => lines.some(([from, to]) => from <= declaration.startLine && declaration.endLine <= to);
22918
23042
  var copyText = (code) => code.replace(/^export\s+(?:default\s+)?/u, "").replace(/\s+/gu, " ").trim();
22919
23043
  async function similarCode(store, working, base, files, read) {
22920
- const code = (path17) => mapCodePath(path17) !== void 0 && !mapTestPath(path17);
23044
+ const code = (path17) => mapCodePath(path17) && !mapTestPath(path17) && !MAP_MIGRATION_PATH.test(path17);
22921
23045
  const changed = files.filter((file2) => file2.status !== "DELETED" && code(file2.path));
22922
23046
  if (!changed.length) return [];
22923
23047
  const names = (version2, path17) => new Set(declarations(rows(store, version2, path17)).map((item) => item.qualifiedName));
@@ -22951,28 +23075,29 @@ async function similarCode(store, working, base, files, read) {
22951
23075
  }
22952
23076
  const all = [];
22953
23077
  const shortCopies = /* @__PURE__ */ new Map();
22954
- await Promise.all(
22955
- [...byPath].map(async ([path17, inFile]) => {
23078
+ const texts = await Promise.all(
23079
+ [...byPath].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(async ([path17, inFile]) => {
22956
23080
  const found2 = declarations(inFile).filter(
22957
23081
  (item) => KINDS.has(item.kind) && (long(item) ? longAdded : shortNames.has(item.qualifiedName))
22958
23082
  );
22959
- if (!found2.length) return;
22960
- const text = await read(path17);
22961
- if (text === void 0) return;
22962
- const lines = text.split("\n").map(lineWords);
22963
- for (const declaration of found2) {
22964
- if (!long(declaration)) {
22965
- const key = `${declaration.qualifiedName}\0${copyText(text.slice(declaration.start, declaration.end))}`;
22966
- shortCopies.set(key, [...shortCopies.get(key) ?? [], declaration]);
22967
- continue;
22968
- }
22969
- const words = /* @__PURE__ */ new Map();
22970
- for (const line of lines.slice(declaration.startLine - 1, declaration.endLine))
22971
- for (const word of line) words.set(word, (words.get(word) ?? 0) + 1);
22972
- all.push({ declaration, words });
22973
- }
23083
+ return { found: found2, text: found2.length ? await read(path17) : void 0 };
22974
23084
  })
22975
23085
  );
23086
+ for (const { found: found2, text } of texts) {
23087
+ if (text === void 0) continue;
23088
+ const lines = text.split("\n").map(lineWords);
23089
+ for (const declaration of found2) {
23090
+ if (!long(declaration)) {
23091
+ const key = `${declaration.qualifiedName}\0${copyText(text.slice(declaration.start, declaration.end))}`;
23092
+ shortCopies.set(key, [...shortCopies.get(key) ?? [], declaration]);
23093
+ continue;
23094
+ }
23095
+ const words = /* @__PURE__ */ new Map();
23096
+ for (const line of lines.slice(declaration.startLine - 1, declaration.endLine))
23097
+ for (const word of line) words.set(word, (words.get(word) ?? 0) + 1);
23098
+ all.push({ declaration, words });
23099
+ }
23100
+ }
22976
23101
  const frequency = /* @__PURE__ */ new Map();
22977
23102
  for (const { words } of all)
22978
23103
  for (const word of words.keys()) frequency.set(word, (frequency.get(word) ?? 0) + 1);
@@ -23033,7 +23158,7 @@ async function similarCode(store, working, base, files, read) {
23033
23158
  const siblings = declaration.container !== void 0 && them.container === declaration.container;
23034
23159
  return score >= (siblings ? SIBLINGS_ALIKE : ALIKE);
23035
23160
  }).sort(([, left], [, right]) => right - left);
23036
- if (!alike.length) continue;
23161
+ if (!alike.length || alike.length > CONVENTION) continue;
23037
23162
  const linked = linkedTo(declaration);
23038
23163
  const unlinked = alike.filter(([other]) => !linked.has(other.declaration.id));
23039
23164
  const best = unlinked[0];
@@ -23041,7 +23166,7 @@ async function similarCode(store, working, base, files, read) {
23041
23166
  }
23042
23167
  for (const copies of shortCopies.values()) {
23043
23168
  const existing = copies.filter((copy) => !added.has(copy.id)).sort((left, right) => left.path < right.path ? -1 : 1);
23044
- if (!existing.length || existing.length > SHORT_COPIES) continue;
23169
+ if (!existing.length || existing.length > CONVENTION) continue;
23045
23170
  for (const declaration of copies) {
23046
23171
  if (!added.has(declaration.id)) continue;
23047
23172
  const linked = linkedTo(declaration);
@@ -23146,7 +23271,14 @@ async function readMapChanges(project, base, signal) {
23146
23271
  };
23147
23272
  const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((path17) => path17 && !inExcludedDirectory(path17));
23148
23273
  for (const path17 of untracked)
23149
- files.push({ path: path17, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
23274
+ files.push({
23275
+ path: path17,
23276
+ status: "ADDED",
23277
+ lines: [EVERYTHING],
23278
+ baseLines: [],
23279
+ hunks: [],
23280
+ binary: false
23281
+ });
23150
23282
  const stranded = await strandedNames(
23151
23283
  project,
23152
23284
  diff,
@@ -23175,6 +23307,7 @@ function parseMapDiff(text) {
23175
23307
  status: "MODIFIED",
23176
23308
  lines: [],
23177
23309
  baseLines: [],
23310
+ hunks: [],
23178
23311
  binary: false
23179
23312
  };
23180
23313
  continue;
@@ -23200,6 +23333,12 @@ function parseMapDiff(text) {
23200
23333
  Number(hunk[3]),
23201
23334
  hunk[4] === void 0 ? 1 : Number(hunk[4])
23202
23335
  ];
23336
+ current.hunks.push({
23337
+ baseStart: oldStart,
23338
+ baseCount: oldCount,
23339
+ start: newStart,
23340
+ count: newCount
23341
+ });
23203
23342
  if (oldCount > 0) current.baseLines.push([oldStart, oldStart + oldCount - 1]);
23204
23343
  current.lines.push(
23205
23344
  newCount > 0 ? [newStart, newStart + newCount - 1] : [newStart + 1, newStart]
@@ -23211,6 +23350,14 @@ function parseMapDiff(text) {
23211
23350
  }
23212
23351
  var testCode = (file2) => mapTestPath(file2) || /(?:^|\/)testFixtures\//u.test(file2);
23213
23352
  var overlaps = (lines, start, end) => lines.some(([from, to]) => from <= end && start <= to);
23353
+ var workingLine = (file2, line) => {
23354
+ let shift = 0;
23355
+ for (const hunk of file2?.hunks ?? []) {
23356
+ if ((hunk.baseCount ? hunk.baseStart : hunk.baseStart + 1) > line) break;
23357
+ shift += hunk.count - hunk.baseCount;
23358
+ }
23359
+ return line + shift;
23360
+ };
23214
23361
  var NON_CODE = [
23215
23362
  [
23216
23363
  /(?:^|\/)(?:package-lock\.json|pnpm-lock\.yaml|yarn\.lock|go\.sum|poetry\.lock|Pipfile\.lock|uv\.lock|Cargo\.lock|gradle\.lockfile)$/u,
@@ -23220,7 +23367,7 @@ var NON_CODE = [
23220
23367
  /(?:^|\/)(?:package\.json|go\.mod|pom\.xml|build\.gradle(?:\.kts)?|settings\.gradle(?:\.kts)?|pyproject\.toml|setup\.py|setup\.cfg|requirements[^/]*\.txt|Makefile|Dockerfile|tsconfig[^/]*\.json)$/u,
23221
23368
  "build or dependency file"
23222
23369
  ],
23223
- [/(?:^|\/)migrations?\/|\.sql$/iu, "database migration or schema"],
23370
+ [MAP_MIGRATION_PATH, "database migration or schema"],
23224
23371
  [/(?:^|\/)\.env[^/]*$|\.(?:ya?ml|toml|ini|properties|conf|cfg)$/iu, "configuration"],
23225
23372
  [/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte|wxml)$/iu, "template"]
23226
23373
  ];
@@ -23757,18 +23904,35 @@ async function mapChangeImpact(store, working, base, changes, shapes, until, pro
23757
23904
  const changedIn = new Map(
23758
23905
  changes.files.flatMap((file2) => file2.basePath ? [[file2.basePath, file2]] : [])
23759
23906
  );
23760
- const same2 = (g, ref) => `${g.object(ref).kind}\0${g.qualifiedName(ref)}`;
23761
- const stillUses = (relation, user) => {
23762
- const file2 = changedIn.get(relation.anchor.path);
23763
- if (file2 && (file2.status === "DELETED" || overlaps(file2.baseLines, relation.anchor.startLine, relation.anchor.endLine)))
23764
- return false;
23765
- const name = same2(before, user);
23766
- const now = graph.objectsAt(file2?.path ?? relation.anchor.path).find((object2) => same2(graph, object2.id) === name);
23767
- if (!now || relation.to === void 0) return true;
23768
- const used = same2(before, relation.to);
23769
- const tag = mapIsModule(before.object(relation.to));
23770
- return !graph.relationsFrom(graph.scope(now.id).refs).some(
23771
- (use) => NAMING_KINDS.has(use.kind) && use.to !== void 0 && (tag ? use.target === relation.target : same2(graph, use.to) === used)
23907
+ const nowAt = (anchor) => {
23908
+ const file2 = changedIn.get(anchor.path);
23909
+ if (file2 && (file2.status === "DELETED" || overlaps(file2.baseLines, anchor.startLine, anchor.endLine)))
23910
+ return void 0;
23911
+ return {
23912
+ path: file2?.path ?? anchor.path,
23913
+ startLine: workingLine(file2, anchor.startLine),
23914
+ endLine: workingLine(file2, anchor.endLine)
23915
+ };
23916
+ };
23917
+ const samePlace = (anchor, place) => anchor.path === place.path && anchor.startLine === place.startLine && anchor.endLine === place.endLine;
23918
+ const replaces = (now, removed2) => now.kind === removed2.kind && now.name === removed2.name;
23919
+ const relationsNow = /* @__PURE__ */ new Map();
23920
+ const relationsIn = (path17) => {
23921
+ let found = relationsNow.get(path17);
23922
+ if (!found) {
23923
+ found = graph.relationsFrom(graph.objectsAt(path17).map((object2) => object2.id));
23924
+ relationsNow.set(path17, found);
23925
+ }
23926
+ return found;
23927
+ };
23928
+ const stillUses = (relation) => {
23929
+ const place = nowAt(relation.anchor);
23930
+ if (!place) return false;
23931
+ if (relation.to === void 0) return true;
23932
+ const used = before.object(relation.to);
23933
+ const tag = mapIsModule(used);
23934
+ return !relationsIn(place.path).some(
23935
+ (use) => NAMING_KINDS.has(use.kind) && use.to !== void 0 && samePlace(use.anchor, place) && (tag ? use.target === relation.target : replaces(graph.object(use.to), used))
23772
23936
  );
23773
23937
  };
23774
23938
  const gone = [];
@@ -23797,8 +23961,7 @@ async function mapChangeImpact(store, working, base, changes, shapes, until, pro
23797
23961
  before.objectsAt(file2.basePath).filter((member) => inside(member.id)).map((member) => member.id)
23798
23962
  )) {
23799
23963
  const owner = before.owner(relation.from);
23800
- if (!NAMING_KINDS.has(relation.kind) || inside(owner) || !stillUses(relation, owner))
23801
- continue;
23964
+ if (!NAMING_KINDS.has(relation.kind) || inside(owner) || !stillUses(relation)) continue;
23802
23965
  const user = before.object(owner);
23803
23966
  usedBy.add(
23804
23967
  mapIsModule(user) ? `${user.anchor.path}${mapMiniprogramTemplate(user.anchor.path) ? " (template)" : ": top-level code"}` : `${user.anchor.path}: ${before.qualifiedName(owner)}`
@@ -23816,28 +23979,56 @@ async function mapChangeImpact(store, working, base, changes, shapes, until, pro
23816
23979
  }
23817
23980
  }
23818
23981
  await beforeTracer.shapes.read(goneShapes.flatMap((item) => item.shapes));
23819
- const nowDeclared = new Set(
23820
- changes.files.flatMap(
23821
- (file2) => file2.status === "DELETED" ? [] : graph.objectsAt(file2.path).map((object2) => same2(graph, object2.id))
23982
+ const declared = /* @__PURE__ */ new Map();
23983
+ for (const file2 of changes.files)
23984
+ if (file2.status !== "DELETED") {
23985
+ for (const object2 of graph.objectsAt(file2.path))
23986
+ if (mapIsShape(object2)) {
23987
+ const key = `${object2.kind}\0${object2.name}`;
23988
+ declared.set(key, [...declared.get(key) ?? [], object2]);
23989
+ }
23990
+ }
23991
+ const successors = (shape) => {
23992
+ const removed2 = before.object(shape);
23993
+ return declared.get(`${removed2.kind}\0${removed2.name}`) ?? [];
23994
+ };
23995
+ await tracer.shapes.read(
23996
+ goneShapes.flatMap(
23997
+ (item) => item.shapes.flatMap((shape) => successors(shape).map((object2) => object2.id))
23822
23998
  )
23823
23999
  );
24000
+ const unfollowed = /* @__PURE__ */ new Set();
23824
24001
  for (const { shapes: inRemoved, inside, usedBy } of goneShapes)
23825
24002
  for (const shape of inRemoved) {
23826
- if (nowDeclared.has(same2(before, shape))) continue;
23827
24003
  if (beforeTracer.shapes.unread.has(shape))
23828
24004
  unclear.push(
23829
24005
  `${before.object(shape).anchor.path}: ${before.qualifiedName(shape)} was removed, and who used it was not read; search the code for its name`
23830
24006
  );
24007
+ const now = successors(shape);
23831
24008
  for (const { owner, anchor } of beforeTracer.shapes.uses.get(shape) ?? []) {
23832
- const file2 = changedIn.get(anchor.path);
23833
- if (inside(owner) || file2 && (file2.status === "DELETED" || overlaps(file2.baseLines, anchor.startLine, anchor.endLine)))
24009
+ const place = nowAt(anchor);
24010
+ if (inside(owner) || !place || now.some(
24011
+ (object2) => tracer.shapes.uses.get(object2.id)?.some((use) => samePlace(use.anchor, place))
24012
+ ))
24013
+ continue;
24014
+ if (now.some((object2) => tracer.shapes.unread.has(object2.id))) {
24015
+ unfollowed.add(`${before.object(shape).anchor.path}: ${before.qualifiedName(shape)}`);
23834
24016
  continue;
24017
+ }
23835
24018
  const user = before.object(owner);
23836
24019
  usedBy.add(
23837
24020
  mapIsModule(user) ? `${user.anchor.path}: top-level code` : `${user.anchor.path}: ${before.qualifiedName(owner)}`
23838
24021
  );
23839
24022
  }
23840
24023
  }
24024
+ if (unfollowed.size)
24025
+ unclear.push(
24026
+ `${unfollowed.size} removed fields or types are used on lines the diff left alone, and whether that code now uses what took their place was not read (${[
24027
+ ...unfollowed
24028
+ ].sort().slice(0, LIST.names).join(
24029
+ ", "
24030
+ )}${unfollowed.size > LIST.names ? ", \u2026" : ""}); project_find_references lists their uses`
24031
+ );
23841
24032
  const removedAt = (ref) => {
23842
24033
  for (let at = ref; at !== void 0; at = before.parent(at))
23843
24034
  if (gone.includes(at)) return true;
@@ -23888,7 +24079,11 @@ async function mapChangeImpact(store, working, base, changes, shapes, until, pro
23888
24079
  if (gone.length) {
23889
24080
  await beforeTracer.trace(gone, gone);
23890
24081
  for (const entry of beforeTracer.entries.values())
23891
- if (!tracer.entries.has(entry.label)) tracer.entries.set(entry.label, entry);
24082
+ if (!tracer.entries.has(entry.label))
24083
+ tracer.entries.set(
24084
+ entry.label,
24085
+ entry.route && removedRoutes.includes(entry.label) ? { ...entry, removed: true } : entry
24086
+ );
23892
24087
  for (const [path17, test] of beforeTracer.tests) {
23893
24088
  const known = tracer.tests.get(path17);
23894
24089
  if (known) for (const name of test.names) known.names.add(name);
@@ -24235,17 +24430,29 @@ async function checkMapChanges(input, signal) {
24235
24430
  changes,
24236
24431
  impact,
24237
24432
  await mapRouteClients(project, index.store, working, impact, signal),
24238
- await similarCode(
24433
+ reusable(
24239
24434
  index.store,
24240
24435
  working,
24241
- base,
24242
- changes.files,
24243
- (file2) => readFile(path11.join(project, file2), "utf8").catch(() => void 0)
24436
+ await similarCode(
24437
+ index.store,
24438
+ working,
24439
+ base,
24440
+ changes.files,
24441
+ (file2) => readFile(path11.join(project, file2), "utf8").catch(() => void 0)
24442
+ )
24244
24443
  ),
24245
24444
  changes.files.length ? await compileBreaks(input, changes, base, until, signal) : void 0
24246
24445
  )
24247
24446
  };
24248
24447
  }
24448
+ function reusable(store, working, similar) {
24449
+ if (!similar.length) return [];
24450
+ const importsFor = mapReuseImports(store, new MapViewCache(), working);
24451
+ return similar.flatMap((item) => {
24452
+ const imports2 = importsFor(item.path, item.like.path);
24453
+ return imports2 ? [{ ...item, imports: imports2 }] : [];
24454
+ });
24455
+ }
24249
24456
  async function mapRouteClients(project, store, working, impact, signal) {
24250
24457
  const affected = impact.entries.filter(
24251
24458
  (entry) => entry.route && entry.certain && entry.chain.length <= 2
@@ -24445,33 +24652,7 @@ Nothing changed against ${changes.base}.`;
24445
24652
  `Decide for each whether it runs the way the project's layers do: code others build on (shared types, storage, utilities) should not import the features or interfaces built on it.${impact.dependencies.some((dependency) => dependency.back) ? " A cycle ties the modules together, so neither can change or be tested alone." : ""} If one runs the wrong way, move what both need into the lower module or pass it in, rather than import upward.`
24446
24653
  );
24447
24654
  }
24448
- if (similar.length) {
24449
- const declaration = (item) => `${item.path}: ${item.name} ${item.label}`;
24450
- const pairs = /* @__PURE__ */ new Map();
24451
- for (const item of similar) {
24452
- const key = `${item.path}\0${item.like.path}`;
24453
- pairs.set(key, [...pairs.get(key) ?? [], item]);
24454
- }
24455
- list(
24456
- "EXISTING CODE LIKE THE NEW CODE (declarations the diff adds whose code reads almost the same as code the project already has)",
24457
- [...pairs.values()].flatMap((items) => {
24458
- const [first] = items;
24459
- if (items.length < 3)
24460
- return items.map(
24461
- (item) => `${declaration(item)} ~ ${declaration(item.like)}${item.others ? ` (+${item.others} more alike)` : ""}`
24462
- );
24463
- const names = items.slice(0, LIST.similarNames).map((item) => `${item.name} ~ ${item.like.name}`);
24464
- return [
24465
- `${first.path} repeats ${first.like.path} in ${items.length} declarations: ${names.join(", ")}${items.length > LIST.similarNames ? ", \u2026" : ""}`
24466
- ];
24467
- }),
24468
- LIST.similar
24469
- );
24470
- lines.push(
24471
- "Use the existing code rather than a copy, or, if the new code replaces it, remove the old; keep both only when they are meant to differ. Code that does the same in other words is not found."
24472
- );
24473
- }
24474
- const entry = (item) => `${item.route ? JSON.stringify(item.label) : item.label}${item.chain.length ? ` \u2192 ${item.chain.join(" \u2192 ")}` : ""}${item.site ? ` (registered at ${item.site})` : ""}`;
24655
+ const entry = (item) => `${item.route ? JSON.stringify(item.label) : item.label}${item.chain.length ? ` \u2192 ${item.chain.join(" \u2192 ")}` : ""}${item.removed ? ` (the diff removes it${item.site ? `; registered at ${item.site} before` : ""})` : item.site ? ` (registered at ${item.site})` : ""}`;
24475
24656
  list(
24476
24657
  "AFFECTED ENTRY POINTS (through resolved calls)",
24477
24658
  impact.entries.filter((e) => e.certain).map(entry),
@@ -24557,6 +24738,38 @@ Nothing changed against ${changes.base}.`;
24557
24738
  lines.push(
24558
24739
  "Static estimate: calls through dependency injection, reflection, string dispatch, configuration and database coupling are not mapped, so an empty list does not prove the change is safe; confirm the entry points in source."
24559
24740
  );
24741
+ if (similar.length) {
24742
+ const declaration = (item) => `${item.path}: ${item.name} ${item.label}`;
24743
+ const reach = ({ user, from, to, imported, cycle, packages }) => {
24744
+ const using = user === "NEW" ? "using it" : "the existing code using the new";
24745
+ if (imported)
24746
+ return user === "NEW" ? "no new import" : `the existing code can use the new with no new import: ${from} already imports ${to}`;
24747
+ return `${using} imports ${to} from ${from} for the first time${packages ? `, in ${packages[1]}, which ${packages[0]} already imports` : ""}${cycle ? `; ${to} already reaches ${from}, so the import closes a cycle` : ""}`;
24748
+ };
24749
+ const pairs = /* @__PURE__ */ new Map();
24750
+ for (const item of similar) {
24751
+ const key = `${item.path}\0${item.like.path}`;
24752
+ pairs.set(key, [...pairs.get(key) ?? [], item]);
24753
+ }
24754
+ list(
24755
+ "EXISTING CODE LIKE THE NEW CODE (declarations the diff adds whose code reads almost the same as code the project already has; weigh them after everything above)",
24756
+ [...pairs.values()].flatMap((items) => {
24757
+ const [first] = items;
24758
+ if (items.length < 3)
24759
+ return items.map(
24760
+ (item) => `${declaration(item)} ~ ${declaration(item.like)} (${item.others ? `+${item.others} more alike; ` : ""}${reach(item.imports)})`
24761
+ );
24762
+ const names = items.slice(0, LIST.similarNames).map((item) => `${item.name} ~ ${item.like.name}`);
24763
+ return [
24764
+ `${first.path} repeats ${first.like.path} in ${items.length} declarations: ${names.join(", ")}${items.length > LIST.similarNames ? ", \u2026" : ""} (${reach(first.imports)})`
24765
+ ];
24766
+ }),
24767
+ LIST.similar
24768
+ );
24769
+ lines.push(
24770
+ "Where it needs no new import, or only one that runs the way the project's layers do, and both copies must stay the same, keep one; code alike for another feature, layer or table is often meant to differ, so keep both. Change existing code only where it is part of the task; tell the user of the rest."
24771
+ );
24772
+ }
24560
24773
  return lines.join("\n");
24561
24774
  }
24562
24775
 
@@ -25234,7 +25447,7 @@ var mapToolDescriptions = (host) => {
25234
25447
  return Object.freeze({
25235
25448
  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.`,
25236
25449
  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.`,
25237
- 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, and the code using a field or type, 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, or through code that uses a changed field or type; 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; NEW COMPILE ERRORS, what the compiler reports on lines the diff left unchanged and did not report before, in code a tsconfig covers; PACKAGES NOT FOUND, packages the changed code needs that are not installed in this directory, whose types the trace then lacks; 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, or uses when it is a field or type, 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.`,
25450
+ 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, and the code using a field or type, 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, or through code that uses a changed field or type; 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; NEW COMPILE ERRORS, what the compiler reports on lines the diff left unchanged and did not report before, in code a tsconfig covers; PACKAGES NOT FOUND, packages the changed code needs that are not installed in this directory, whose types the trace then lacks; 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, or uses when it is a field or type, 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, removing the old if the new replaces it, or having the existing code use the new where it is the one that can, unless the two are meant to differ, and changing existing code only where it is part of the task while telling the user of the rest; 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.`,
25238
25451
  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.`
25239
25452
  });
25240
25453
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "layermap",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
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",
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.37");
296
+ const tools = await next.start("0.1.39");
297
297
  for (const tool of tools) {
298
298
  if (registered.has(tool.name)) continue;
299
299
  registered.add(tool.name);