layermap 0.1.6 → 0.1.8
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 +10 -4
- package/analyzers/go/darwin-arm64/go-map +0 -0
- package/analyzers/go/darwin-x64/go-map +0 -0
- package/analyzers/go/linux-arm64/go-map +0 -0
- package/analyzers/go/linux-x64/go-map +0 -0
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/dist/cli.mjs +72 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,12 +70,15 @@ projects, graded blind against truth sets cross-checked with each language's own
|
|
|
70
70
|
| Codex input tokens, no request limit (current defaults) | +14% | |
|
|
71
71
|
| Time, no request limit (Claude Code / Codex) | +25% / +20% | |
|
|
72
72
|
| Failing tests the change check lists (Go / Python, functions made to fail) | **100% / 83–88%** | — |
|
|
73
|
+
| Ripple tasks: runs leaving other features' tests passing (Codex / Claude Code, 4 tasks × 3 runs) | **11 of 12 / 7 of 12** | 3 of 12 / 4 of 12 |
|
|
73
74
|
|
|
74
75
|
With a tight budget, the map finds far more of the affected code, at about 24% more tokens. With
|
|
75
76
|
no limit, both agents find nearly everything either way. Claude Code costs a third less with the
|
|
76
77
|
map. Codex's current defaults already search lean, so the map no longer saves it tokens; at
|
|
77
78
|
reasoning effort max, in the first round, it saved 55%. Agents with the map explore more widely,
|
|
78
|
-
which takes longer.
|
|
79
|
+
which takes longer. On requests whose obvious change breaks another feature, the change check
|
|
80
|
+
helped Codex keep to the requested feature; for Claude Code the gap could be chance, and both took
|
|
81
|
+
longer. These are small samples on tasks written by LayerMap's authors.
|
|
79
82
|
The [report](https://github.com/coffeecoproject/layermap/blob/main/docs/benchmark.md) has the
|
|
80
83
|
setup, the published tasks and the limitations.
|
|
81
84
|
|
|
@@ -132,8 +135,11 @@ Claude Code asks once before each map tool runs in a project. Choose "don't ask
|
|
|
132
135
|
|
|
133
136
|
**After an edit.** When the agent changes code, `project_check_changes` lists what the change
|
|
134
137
|
affects: the routes, jobs and commands that reach the changed functions, what the map cannot see,
|
|
135
|
-
and the existing tests related to the change.
|
|
136
|
-
|
|
138
|
+
and the existing tests related to the change. When the changed code serves several areas (packages
|
|
139
|
+
or modules), it names each one with its tests, so a change meant for one feature does not quietly
|
|
140
|
+
change the others. It never writes or runs tests. In Claude Code the
|
|
141
|
+
plugin asks the agent once, before it finishes, to run this check if it edited code in the repository
|
|
142
|
+
and has not checked since (changes another session makes in the same work tree do not count); set
|
|
137
143
|
`LAYERMAP_STOP_CHECK=0` to turn that off. Codex and DeepSeek Harness are told to run it.
|
|
138
144
|
|
|
139
145
|
**Without plugins:** run `npx layermap setup claude` or `npx layermap setup codex`. Setup does three
|
|
@@ -168,7 +174,7 @@ nothing anywhere ([privacy](https://github.com/coffeecoproject/layermap/blob/mai
|
|
|
168
174
|
| `project_explore_map` | A directory, a file, or a declaration's callers and callees (`direction` INCOMING or OUTGOING, `depth` up to 8). |
|
|
169
175
|
| `project_search_map` | Find declarations by words in their names, paths or documentation. |
|
|
170
176
|
| `project_find_references` | Every usage of a declaration, compiled from current source. |
|
|
171
|
-
| `project_check_changes` | What the uncommitted changes (or those since `base`) affect: changed and removed declarations, the routes, jobs and commands they reach, what to check by hand, and related tests. |
|
|
177
|
+
| `project_check_changes` | What the uncommitted changes (or those since `base`) affect: changed and removed declarations, the routes, jobs and commands they reach, the areas that share the changed code, what to check by hand, and related tests. |
|
|
172
178
|
|
|
173
179
|
The same from the command line:
|
|
174
180
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/cli.mjs
CHANGED
|
@@ -16650,7 +16650,7 @@ function runMapOperation(resources, input, schema, signal, observeTiming) {
|
|
|
16650
16650
|
var goModule = /(?:^|\/)go\.mod$/u;
|
|
16651
16651
|
var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
|
|
16652
16652
|
var GO_MAP_LANGUAGE = Object.freeze({
|
|
16653
|
-
id: "go-1.24-map-
|
|
16653
|
+
id: "go-1.24-map-v8",
|
|
16654
16654
|
claims: (path11) => path11.endsWith(".go"),
|
|
16655
16655
|
reads: (path11) => goModule.test(path11),
|
|
16656
16656
|
// A module path, or the standard library, whose first path element has no dot.
|
|
@@ -22005,6 +22005,7 @@ var LIMITS = Object.freeze({ depth: 8, declarations: 800, changed: 200, chain: 3
|
|
|
22005
22005
|
var CALLER_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES"]);
|
|
22006
22006
|
var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
22007
22007
|
var ROUTE = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
|
|
22008
|
+
var areaOf = (file2) => /\.(?:go|java|kt)$/u.test(file2) ? file2.slice(0, file2.lastIndexOf("/") + 1) || "./" : file2;
|
|
22008
22009
|
var Tracer = class {
|
|
22009
22010
|
constructor(graph, memberCalls) {
|
|
22010
22011
|
this.graph = graph;
|
|
@@ -22015,6 +22016,8 @@ var Tracer = class {
|
|
|
22015
22016
|
reached = /* @__PURE__ */ new Map();
|
|
22016
22017
|
entries = /* @__PURE__ */ new Map();
|
|
22017
22018
|
tests = /* @__PURE__ */ new Map();
|
|
22019
|
+
/** Tests that certainly call the change, by the area of the declaration they call it through. */
|
|
22020
|
+
areas = /* @__PURE__ */ new Map();
|
|
22018
22021
|
unclear = [];
|
|
22019
22022
|
truncated = false;
|
|
22020
22023
|
callerCount = /* @__PURE__ */ new Map();
|
|
@@ -22061,6 +22064,8 @@ var Tracer = class {
|
|
|
22061
22064
|
// Tests closer to the change come first; all of them rank before other relations.
|
|
22062
22065
|
current.depth / 10
|
|
22063
22066
|
);
|
|
22067
|
+
if (certain && mapRunnableTest(callerObject.anchor.path))
|
|
22068
|
+
this.area(current.ref, callerObject.anchor.path, this.name(caller.ref));
|
|
22064
22069
|
continue;
|
|
22065
22070
|
}
|
|
22066
22071
|
if (this.reached.has(caller.ref)) continue;
|
|
@@ -22110,8 +22115,8 @@ var Tracer = class {
|
|
|
22110
22115
|
}
|
|
22111
22116
|
const object2 = this.graph.object(ref);
|
|
22112
22117
|
const parent = this.graph.parent(ref);
|
|
22118
|
+
const constructs = object2.execution === "CONSTRUCTOR" || object2.name === "__init__" || object2.name === "constructor";
|
|
22113
22119
|
if (parent && this.graph.object(parent).kind === "CLASS") {
|
|
22114
|
-
const constructs = object2.execution === "CONSTRUCTOR" || object2.name === "__init__" || object2.name === "constructor";
|
|
22115
22120
|
const implicit = constructs || /^__\w+__$/u.test(object2.name) || object2.kind === "PROPERTY" || this.graph.relationsFrom([ref]).some(
|
|
22116
22121
|
(relation) => relation.kind === "DECORATED_BY" && /property$/u.test(relation.target)
|
|
22117
22122
|
);
|
|
@@ -22124,17 +22129,19 @@ var Tracer = class {
|
|
|
22124
22129
|
}
|
|
22125
22130
|
}
|
|
22126
22131
|
}
|
|
22127
|
-
|
|
22128
|
-
|
|
22129
|
-
|
|
22130
|
-
|
|
22131
|
-
|
|
22132
|
-
|
|
22133
|
-
|
|
22134
|
-
|
|
22135
|
-
|
|
22136
|
-
|
|
22137
|
-
|
|
22132
|
+
if (!constructs) {
|
|
22133
|
+
for (const override of this.graph.relationsFrom([ref]))
|
|
22134
|
+
if (override.kind === "OVERRIDES" && override.to !== void 0) {
|
|
22135
|
+
const contract = override.to;
|
|
22136
|
+
const relations = this.graph.relationsTo([contract]);
|
|
22137
|
+
const only = relations.filter((relation) => relation.kind === "OVERRIDES").length === 1;
|
|
22138
|
+
for (const relation of relations)
|
|
22139
|
+
if (CALLER_KINDS.has(relation.kind)) {
|
|
22140
|
+
const owner = this.graph.owner(relation.from);
|
|
22141
|
+
if (owner !== ref) callers.push({ ref: owner, relation, certain: only });
|
|
22142
|
+
}
|
|
22143
|
+
}
|
|
22144
|
+
}
|
|
22138
22145
|
return callers;
|
|
22139
22146
|
}
|
|
22140
22147
|
decoratorRoutes(current) {
|
|
@@ -22174,6 +22181,15 @@ var Tracer = class {
|
|
|
22174
22181
|
if (known && (known.certain || !certain)) return;
|
|
22175
22182
|
this.entries.set(label, { label, route, chain, ...site ? { site } : {}, certain });
|
|
22176
22183
|
}
|
|
22184
|
+
area(ref, test, name) {
|
|
22185
|
+
const area = areaOf(this.graph.object(ref).anchor.path);
|
|
22186
|
+
const known = this.areas.get(area) ?? { through: /* @__PURE__ */ new Set(), tests: /* @__PURE__ */ new Map() };
|
|
22187
|
+
known.through.add(this.name(ref));
|
|
22188
|
+
const names = known.tests.get(test) ?? /* @__PURE__ */ new Set();
|
|
22189
|
+
if (!name.startsWith("<")) names.add(name);
|
|
22190
|
+
known.tests.set(test, names);
|
|
22191
|
+
this.areas.set(area, known);
|
|
22192
|
+
}
|
|
22177
22193
|
/** A related test file; the closest relation (lowest rank) explains it. */
|
|
22178
22194
|
test(path11, name, why, rank2) {
|
|
22179
22195
|
if (!mapRunnableTest(path11)) return;
|
|
@@ -22280,6 +22296,15 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22280
22296
|
if (known) for (const name of test.names) known.names.add(name);
|
|
22281
22297
|
else tracer.tests.set(path11, test);
|
|
22282
22298
|
}
|
|
22299
|
+
for (const [area, known] of beforeTracer.areas) {
|
|
22300
|
+
const now = tracer.areas.get(area);
|
|
22301
|
+
if (!now) tracer.areas.set(area, known);
|
|
22302
|
+
else {
|
|
22303
|
+
for (const name of known.through) now.through.add(name);
|
|
22304
|
+
for (const [path11, names] of known.tests)
|
|
22305
|
+
now.tests.set(path11, /* @__PURE__ */ new Set([...now.tests.get(path11) ?? [], ...names]));
|
|
22306
|
+
}
|
|
22307
|
+
}
|
|
22283
22308
|
unclear.push(...beforeTracer.unclear.filter((line) => !line.includes("has no callers")));
|
|
22284
22309
|
if (beforeTracer.truncated) tracer.truncated = true;
|
|
22285
22310
|
}
|
|
@@ -22298,6 +22323,11 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22298
22323
|
})).sort(
|
|
22299
22324
|
(left, right) => left.rank - right.rank || (left.path < right.path ? -1 : left.path > right.path ? 1 : 0)
|
|
22300
22325
|
),
|
|
22326
|
+
areas: [...tracer.areas].map(([area, known]) => ({
|
|
22327
|
+
area,
|
|
22328
|
+
through: [...known.through].sort(),
|
|
22329
|
+
tests: [...known.tests].map(([path11, names]) => ({ path: path11, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
|
|
22330
|
+
})).sort((left, right) => right.tests.length - left.tests.length),
|
|
22301
22331
|
unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
|
|
22302
22332
|
truncated: tracer.truncated
|
|
22303
22333
|
};
|
|
@@ -22395,14 +22425,24 @@ function sameDirectoryTests(store, version2, path11, tracer) {
|
|
|
22395
22425
|
tracer.test(candidate, void 0, "in the same directory", 3);
|
|
22396
22426
|
}
|
|
22397
22427
|
}
|
|
22398
|
-
function testNames(names) {
|
|
22428
|
+
function testNames(names, limit = LIST.names) {
|
|
22399
22429
|
if (!names.length) return "";
|
|
22400
22430
|
const tests = names.filter((name) => /(?:^|\.)(?:test|Test|should|it_)\w*$/u.test(name));
|
|
22401
|
-
const shown = (tests.length ? tests : names).slice(0,
|
|
22431
|
+
const shown = (tests.length ? tests : names).slice(0, limit);
|
|
22402
22432
|
const more2 = (tests.length ? tests : names).length - shown.length;
|
|
22403
22433
|
return `: ${shown.join(", ")}${more2 > 0 ? `, +${more2} more` : ""}`;
|
|
22404
22434
|
}
|
|
22405
|
-
var LIST = Object.freeze({
|
|
22435
|
+
var LIST = Object.freeze({
|
|
22436
|
+
changed: 20,
|
|
22437
|
+
entries: 40,
|
|
22438
|
+
tests: 12,
|
|
22439
|
+
unclear: 20,
|
|
22440
|
+
names: 6,
|
|
22441
|
+
areas: 8,
|
|
22442
|
+
areaTests: 3,
|
|
22443
|
+
areaNames: 3,
|
|
22444
|
+
through: 2
|
|
22445
|
+
});
|
|
22406
22446
|
function mapChangesText(changes, impact) {
|
|
22407
22447
|
const files = changes.files.length;
|
|
22408
22448
|
const direct = impact.tests.filter((test) => test.rank < 4);
|
|
@@ -22424,6 +22464,21 @@ Nothing changed against ${changes.base}.`;
|
|
|
22424
22464
|
impact.removed,
|
|
22425
22465
|
LIST.changed
|
|
22426
22466
|
);
|
|
22467
|
+
if (impact.areas.length > 1) {
|
|
22468
|
+
list(
|
|
22469
|
+
`SHARED BY ${impact.areas.length} AREAS (tests that call the changed code, by the code they call it through)`,
|
|
22470
|
+
impact.areas.map((area) => {
|
|
22471
|
+
const through = `${area.through.slice(0, LIST.through).join(", ")}${area.through.length > LIST.through ? ", \u2026" : ""}`;
|
|
22472
|
+
const tests = area.tests.slice(0, LIST.areaTests).map((test) => `${test.path}${testNames(test.names, LIST.areaNames)}`);
|
|
22473
|
+
const more2 = area.tests.length - tests.length;
|
|
22474
|
+
return `${area.area} (${through}): ${tests.join("; ")}${more2 > 0 ? `; +${more2} more files` : ""}`;
|
|
22475
|
+
}),
|
|
22476
|
+
LIST.areas
|
|
22477
|
+
);
|
|
22478
|
+
lines.push(
|
|
22479
|
+
"Each area's tests pin its current behavior. Decide which areas the request is about: if a test of another area fails, the change reached a feature it was not meant to change; narrow the change, for example to the code only the requested area uses, instead of rewriting that test, unless the request covers that behavior too."
|
|
22480
|
+
);
|
|
22481
|
+
}
|
|
22427
22482
|
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})` : ""}`;
|
|
22428
22483
|
list(
|
|
22429
22484
|
"AFFECTED ENTRY POINTS (through resolved calls)",
|
|
@@ -22861,7 +22916,7 @@ var mapToolDescriptions = (host) => {
|
|
|
22861
22916
|
return Object.freeze({
|
|
22862
22917
|
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.`,
|
|
22863
22918
|
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.`,
|
|
22864
|
-
check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it. It does not run or write tests: run the related ones if the change needs verifying, and confirm the entry points in source, since an empty list does not prove a change safe.`,
|
|
22919
|
+
check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it. It does not run or write tests: run the related ones if the change needs verifying; a failing test of an area the request is not about means the change leaked, so narrow the change rather than rewrite that test; and confirm the entry points in source, since an empty list does not prove a change safe.`,
|
|
22865
22920
|
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.`
|
|
22866
22921
|
});
|
|
22867
22922
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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, Go, Python and Java.",
|
|
6
6
|
"license": "Apache-2.0",
|