layermap 0.1.33 → 0.1.34

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![npm downloads](https://img.shields.io/npm/dm/layermap)](https://www.npmjs.com/package/layermap)
10
10
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/coffeecoproject/layermap/blob/main/LICENSE)
11
11
 
12
- **LayerMap tells your coding agent what calls a function and what changing it affects, up to the HTTP routes, in one call.** With at most 15 requests, agents found **97.9%** of affected endpoints with LayerMap vs 58.8% without; with no limit, Claude Code cost **33% less** in the 0.1.5 re-run ([benchmark](https://github.com/coffeecoproject/layermap/blob/main/docs/benchmark.md)).
12
+ **LayerMap tells your coding agent what calls a function and what changing it affects, up to the HTTP routes, in one call.** With at most 15 requests, Claude Code on Opus 5.5 found **99.9%** of affected endpoints with LayerMap vs 76.0% without; with no limit, it found about the same and cost **48% less**, or 27% less without the task that gained most ([benchmark](https://github.com/coffeecoproject/layermap/blob/main/docs/benchmark.md)).
13
13
 
14
14
  **Resolved by each language's compiler or type checker, not guessed from names by tree-sitter:** calls through interfaces, base classes, templates and decorators link as the compiler links them, for TypeScript, JavaScript, Go, Python and Java.
15
15
 
@@ -65,23 +65,30 @@ projects, graded blind against truth sets cross-checked with each language's own
65
65
 
66
66
  | | With LayerMap | Without |
67
67
  |---|---|---|
68
+ | Endpoints found, at most 15 requests (Claude Code on Opus 5.5, 6 tasks × 3 runs) | **99.9%** | 76.0% |
69
+ | Cost / time at that limit (Opus 5.5) | +12% / +4% | |
70
+ | Endpoints found, no request limit (Opus 5.5, 6 tasks × 2 runs) | 100% | 99.7% |
71
+ | Cost / time, no request limit (Opus 5.5, maps built ahead) | **−48% / −33%**; −27% / −21% without the task that gained most | |
72
+ | Ripple tasks: runs leaving other features' tests passing (Opus 5.5, 4 tasks × 3 runs) | 12 of 12 | 12 of 12 |
68
73
  | Endpoints found, at most 15 requests (`gpt-5.5`, 6 tasks × 3 runs) | **97.9%** | 58.8% |
69
74
  | Used unprompted by Claude Code / Codex (plugin installed, two rounds) | **12 of 12 / 12 of 12** | — |
70
75
  | Endpoints found, no request limit (Claude Code / Codex, 0.1.5) | 100% / 100% | 99.0% / 100% |
71
76
  | Claude Code cost, no request limit (0.1.5 re-run; first round −32%) | **−33%** | |
72
77
  | Codex input tokens, no request limit (current defaults) | +14% | |
73
- | Time, no request limit (Claude Code / Codex) | +25% / +20% | |
78
+ | Time, no request limit (Claude Code on `claude-opus-5` / Codex, 0.1.5) | +25% / +20% | |
74
79
  | Failing tests the change check lists (Go / Python, functions made to fail) | **100% / 94–98%** | — |
75
80
  | Ripple tasks: runs leaving other features' tests passing (Codex / Claude Code, 4 tasks × 6 runs with, × 3 without) | **23 of 24** / 11 of 24 | 3 of 12 / 4 of 12 |
76
81
  | Everyday tasks, no impact analysis needed: done right / time (Claude Code and Codex, 8 tasks × 2 runs) | 32 of 32 / +12–31% | 32 of 32 |
77
82
 
78
- With a tight budget, the map finds far more of the affected code, at about 24% more tokens. With
79
- no limit, both agents find nearly everything either way. Claude Code costs a third less with the
80
- map. Codex's current defaults already search lean, so the map no longer saves it tokens; at
81
- reasoning effort max, in the first round, it saved 55%. Agents with the map explore more widely,
83
+ With a tight budget, the map finds far more of the affected code, at 12–24% more cost or tokens. With
84
+ no limit, both agents find nearly everything either way. Claude Code costs a third to a half less
85
+ with the map. On Opus 5.5 it was also a third faster, though one task accounts for much of that gap
86
+ and the maps were built ahead; on `claude-opus-5` it was a quarter slower. Codex's current defaults already search lean, so the map no longer saves it tokens; at
87
+ reasoning effort max, in the first round, it saved 55%. Codex with the map explores more widely,
82
88
  which takes longer. On requests whose obvious change breaks another feature, the change check
83
89
  helped Codex keep to the requested feature. Claude Code saw which tests of other features it had
84
- changed but often kept the broader change on purpose, so it showed no clear difference. On small
90
+ changed but often kept the broader change on purpose, so it showed no clear difference; on Opus 5.5
91
+ it broke nothing with or without the map, and the check cost 17% more. On small
85
92
  local tasks the map changed nothing but cost about a fifth more time and money. These are small samples on tasks written by LayerMap's authors.
86
93
  The [report](https://github.com/coffeecoproject/layermap/blob/main/docs/benchmark.md) has the
87
94
  setup, the published tasks and the limitations.
@@ -166,7 +173,9 @@ depend on each other; whether that direction suits the project's layers is for t
166
173
  declaration the change adds reads almost the same as code the project already has, it names both, so
167
174
  the agent can use the existing code instead of a copy. When the change takes away the last call to a
168
175
  declaration, as when new code replaces old, it names that declaration, so the agent can delete what
169
- the change left behind. It never writes or runs tests. In Claude Code and
176
+ the change left behind. The map does not link a field or type to the code reading it, so for one the
177
+ change touches, the check searches for its references and follows that code up to the entry points
178
+ and tests, as possibly affected. It never writes or runs tests. In Claude Code and
170
179
  CodeBuddy Code the plugin asks the agent once, before it finishes, to run this check for each repository it edited code in
171
180
  and has not checked since, whether through its edit tools or shell commands, which count for the code files they name
172
181
  (changes another session makes in the same work tree do not count); the Pi extension does the same after the agent's own
@@ -228,7 +237,9 @@ npx layermap check test/billing.test.ts # also: what of the change this test d
228
237
 
229
238
  **What can't it see?** Calls the compiler cannot resolve statically: dependency injection, unknown
230
239
  framework routing, reflection and computed names. The tools say where a trace stops, and a missing
231
- relationship does not prove absence.
240
+ relationship does not prove absence. TypeScript and JavaScript types come from the packages installed
241
+ in the project's `node_modules` (never mapped themselves); where they are not installed, as in a
242
+ fresh worktree, values typed by them have no type to follow, and the tools name those packages.
232
243
 
233
244
  **Windows?** Experimental. LayerMap's tests pass on Windows, but it has not yet been tried with
234
245
  Claude Code or Codex on a real Windows machine, so please test it on your own projects first and
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -14742,7 +14742,7 @@ process.once(
14742
14742
  operation: message.operation,
14743
14743
  modFile: message.modFile ?? "",
14744
14744
  files: message.files,
14745
- ...message.target ? { target: message.target } : {}
14745
+ ...message.targets ? { targets: message.targets } : {}
14746
14746
  })
14747
14747
  );
14748
14748
  }
@@ -14717,7 +14717,7 @@ process.once(
14717
14717
  // Large projects attribute every class in one compilation.
14718
14718
  "-XX:MaxRAMPercentage=40",
14719
14719
  "-XX:+UseParallelGC",
14720
- // A references request attributes only the files that may refer to its target, through
14720
+ // A references request attributes only the files that may refer to its targets, through
14721
14721
  // javac's task implementation (Program.load).
14722
14722
  "--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
14723
14723
  "-cp",
@@ -14756,7 +14756,7 @@ process.once(
14756
14756
  release: message.release,
14757
14757
  tests: message.tests,
14758
14758
  lombok: path3.join(path3.dirname(message.compilerPath), "lombok.jar"),
14759
- ...message.target ? { target: message.target } : {},
14759
+ ...message.targets ? { targets: message.targets } : {},
14760
14760
  ...message.incremental ? { incremental: message.incremental } : {}
14761
14761
  })
14762
14762
  );
@@ -121988,13 +121988,13 @@ function extractPython(source, tests) {
121988
121988
 
121989
121989
  // src/project-map-python-references.ts
121990
121990
  var Names = class extends ParseTreeWalker {
121991
- constructor(name) {
121991
+ constructor(names) {
121992
121992
  super();
121993
- this.name = name;
121993
+ this.names = names;
121994
121994
  this.found = [];
121995
121995
  }
121996
121996
  visitName(node) {
121997
- if (this.name === void 0 || node.d.value === this.name) this.found.push(node);
121997
+ if (!this.names || this.names.has(node.d.value)) this.found.push(node);
121998
121998
  return false;
121999
121999
  }
122000
122000
  };
@@ -122047,37 +122047,52 @@ function kindOf(name, declarations) {
122047
122047
  (declaration) => declaration.type === 5 /* Function */ || declaration.type === 6 /* Class */
122048
122048
  ) ? "REFERENCE" : "READ";
122049
122049
  }
122050
- function findPythonReferences(source, target) {
122050
+ function findPythonReferences(source, targets) {
122051
122051
  const evaluator = source.program.evaluator;
122052
122052
  if (!evaluator) throw new Error("PROJECT_MAP_ANALYSIS_FAILED");
122053
- const parsed = source.program.getParseResults(source.uriOf(target.path));
122054
- if (!parsed) throw new Error("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE");
122055
- const all = new Names();
122056
- all.walk(parsed.parserOutput.parseTree);
122057
- const at = all.found.find((node) => node.start === target.offset);
122058
- if (!at) throw new Error("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE");
122059
- const declarations = resolved(evaluator, at);
122060
- const keys = new Set(declarations.map(declarationKey).filter((key) => key !== void 0));
122061
- const references = [];
122053
+ const named = /* @__PURE__ */ new Map();
122054
+ const namesIn = (path3) => {
122055
+ const known = named.get(path3);
122056
+ if (known) return known;
122057
+ const all = new Names();
122058
+ const parsed = source.program.getParseResults(source.uriOf(path3));
122059
+ if (parsed) all.walk(parsed.parserOutput.parseTree);
122060
+ const found = new Map(all.found.map((node) => [node.start, node]));
122061
+ named.set(path3, found);
122062
+ return found;
122063
+ };
122064
+ const wanted = /* @__PURE__ */ new Map();
122065
+ const pages = targets.map((target) => {
122066
+ const at = namesIn(target.path).get(target.offset);
122067
+ if (!at) return null;
122068
+ const keys = new Set(
122069
+ resolved(evaluator, at).map(declarationKey).filter((key) => key !== void 0)
122070
+ );
122071
+ const page = { references: [] };
122072
+ wanted.set(at.d.value, [...wanted.get(at.d.value) ?? [], { keys, page }]);
122073
+ return page;
122074
+ });
122062
122075
  for (const path3 of source.paths) {
122063
122076
  const uri = source.uriOf(path3);
122064
122077
  const tree = source.program.getParseResults(uri)?.parserOutput.parseTree;
122065
122078
  if (!tree) continue;
122066
122079
  source.program.getBoundSourceFile(uri);
122067
- const names = new Names(at.d.value);
122080
+ const names = new Names(new Set(wanted.keys()));
122068
122081
  names.walk(tree);
122069
122082
  for (const name of names.found) {
122070
122083
  const found = resolved(evaluator, name);
122071
- if (!found.some((declaration) => keys.has(declarationKey(declaration) ?? ""))) continue;
122072
- references.push({
122073
- path: path3,
122074
- start: name.start,
122075
- end: name.start + name.length,
122076
- kind: kindOf(name, found)
122077
- });
122084
+ const declared = found.map((declaration) => declarationKey(declaration) ?? "");
122085
+ for (const { keys, page } of wanted.get(name.d.value) ?? [])
122086
+ if (declared.some((key) => keys.has(key)))
122087
+ page.references.push({
122088
+ path: path3,
122089
+ start: name.start,
122090
+ end: name.start + name.length,
122091
+ kind: kindOf(name, found)
122092
+ });
122078
122093
  }
122079
122094
  }
122080
- return { references };
122095
+ return { pages };
122081
122096
  }
122082
122097
 
122083
122098
  // src/project-map-python-worker.ts
@@ -122097,9 +122112,9 @@ process.once(
122097
122112
  });
122098
122113
  try {
122099
122114
  if (message.operation === "REFERENCES") {
122100
- if (!message.target) throw new Error("PROJECT_MAP_PROTOCOL_INVALID");
122115
+ if (!message.targets) throw new Error("PROJECT_MAP_PROTOCOL_INVALID");
122101
122116
  trace.phase = "REFERENCES";
122102
- process.send?.({ result: findPythonReferences(source, message.target) });
122117
+ process.send?.({ result: findPythonReferences(source, message.targets) });
122103
122118
  } else {
122104
122119
  trace.phase = "TRAVERSAL";
122105
122120
  process.send?.({ result: extractPython(source, new Set(message.tests)) });