layermap 0.1.22 → 0.1.24
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 +3 -1
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/dist/cli.mjs +123 -19
- package/package.json +1 -1
- package/pi/layermap.mjs +5 -4
package/README.md
CHANGED
|
@@ -162,7 +162,9 @@ request that path: a frontend's fetch, a generated API client, a redirect or a l
|
|
|
162
162
|
an import between two modules of the project overview, it names it, and says when the two now
|
|
163
163
|
depend on each other; whether that direction suits the project's layers is for the agent to judge. When a
|
|
164
164
|
declaration the change adds reads almost the same as code the project already has, it names both, so
|
|
165
|
-
the agent can use the existing code instead of a copy.
|
|
165
|
+
the agent can use the existing code instead of a copy. When the change takes away the last call to a
|
|
166
|
+
declaration, as when new code replaces old, it names that declaration, so the agent can delete what
|
|
167
|
+
the change left behind. It never writes or runs tests. In Claude Code and
|
|
166
168
|
CodeBuddy Code the plugin asks the agent once, before it finishes, to run this check for each repository it edited code in
|
|
167
169
|
and has not checked since, whether through its edit tools or shell commands (changes another session makes in the same
|
|
168
170
|
work tree do not count); the Pi extension does the same after the agent's own edits. Set `LAYERMAP_STOP_CHECK=0` to turn that
|
|
Binary file
|
package/dist/cli.mjs
CHANGED
|
@@ -7,6 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
10
11
|
import { parseArgs } from "node:util";
|
|
11
12
|
|
|
12
13
|
// src/agent/environment.ts
|
|
@@ -21,7 +22,7 @@ import { fileURLToPath } from "node:url";
|
|
|
21
22
|
|
|
22
23
|
// src/layermap.ts
|
|
23
24
|
import { createHash as createHash4 } from "node:crypto";
|
|
24
|
-
import { mkdirSync } from "node:fs";
|
|
25
|
+
import { mkdirSync, statSync } from "node:fs";
|
|
25
26
|
import { lstat as lstat2, realpath as realpath2 } from "node:fs/promises";
|
|
26
27
|
import path10 from "node:path";
|
|
27
28
|
import { DatabaseSync } from "@photostructure/sqlite";
|
|
@@ -15481,7 +15482,11 @@ var excludedSegments = Object.freeze([
|
|
|
15481
15482
|
"vendor",
|
|
15482
15483
|
".venv",
|
|
15483
15484
|
"__pycache__",
|
|
15484
|
-
"site-packages"
|
|
15485
|
+
"site-packages",
|
|
15486
|
+
".claude",
|
|
15487
|
+
".codex",
|
|
15488
|
+
".cursor",
|
|
15489
|
+
".pi"
|
|
15485
15490
|
]);
|
|
15486
15491
|
var SOURCE_POLICY = Object.freeze({
|
|
15487
15492
|
sourceExtensions,
|
|
@@ -15507,6 +15512,7 @@ var SOURCE_POLICY = Object.freeze({
|
|
|
15507
15512
|
});
|
|
15508
15513
|
var extensions = new Set(sourceExtensions);
|
|
15509
15514
|
var excluded = new Set(excludedSegments);
|
|
15515
|
+
var inExcludedDirectory = (relativePath) => relativePath.toLowerCase().split("/").slice(0, -1).some((segment) => excluded.has(segment));
|
|
15510
15516
|
var includesInitialEvidencePath = (relativePath, scope) => {
|
|
15511
15517
|
try {
|
|
15512
15518
|
assertProjectEvidencePathNotSensitive(relativePath);
|
|
@@ -15517,10 +15523,9 @@ var includesInitialEvidencePath = (relativePath, scope) => {
|
|
|
15517
15523
|
(prefix) => prefix === "." || relativePath === prefix || relativePath.startsWith(`${prefix}/`)
|
|
15518
15524
|
))
|
|
15519
15525
|
return false;
|
|
15520
|
-
if (isProjectEvidenceTraversalExcluded(relativePath)
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
const basename = segments2.at(-1) ?? "";
|
|
15526
|
+
if (isProjectEvidenceTraversalExcluded(relativePath) || inExcludedDirectory(relativePath))
|
|
15527
|
+
return false;
|
|
15528
|
+
const basename = relativePath.toLowerCase().split("/").at(-1) ?? "";
|
|
15524
15529
|
return extensions.has(path6.posix.extname(basename)) || SOURCE_POLICY.documentationFiles.includes(basename) || SOURCE_POLICY.configurationFiles.includes(basename) || SOURCE_POLICY.workspaceFiles.includes(relativePath);
|
|
15525
15530
|
};
|
|
15526
15531
|
|
|
@@ -22580,14 +22585,14 @@ async function readMapChanges(project, base, signal) {
|
|
|
22580
22585
|
],
|
|
22581
22586
|
gitOptions(project, signal)
|
|
22582
22587
|
)).stdout.toString("utf8");
|
|
22583
|
-
const files = parseMapDiff(diff);
|
|
22588
|
+
const files = parseMapDiff(diff).filter((file2) => !inExcludedDirectory(file2.path));
|
|
22584
22589
|
for (const [index, file2] of files.entries())
|
|
22585
22590
|
if (file2.basePath && file2.status !== "ADDED" && !file2.binary && testCode(file2.basePath))
|
|
22586
22591
|
files[index] = {
|
|
22587
22592
|
...file2,
|
|
22588
22593
|
baseText: (await git.run(["show", `${commit}:${file2.basePath}`], gitOptions(project, signal))).stdout.toString("utf8")
|
|
22589
22594
|
};
|
|
22590
|
-
const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter(
|
|
22595
|
+
const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((path14) => path14 && !inExcludedDirectory(path14));
|
|
22591
22596
|
for (const path14 of untracked)
|
|
22592
22597
|
files.push({ path: path14, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
|
|
22593
22598
|
const stranded = await strandedNames(
|
|
@@ -22939,6 +22944,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22939
22944
|
supportTests(store, working, tracer);
|
|
22940
22945
|
const rewrittenTests = [];
|
|
22941
22946
|
const removedRoutes = [];
|
|
22947
|
+
const uncalled = [];
|
|
22942
22948
|
if (base) {
|
|
22943
22949
|
const before = new MapViewGraph(store, base);
|
|
22944
22950
|
const registered = /* @__PURE__ */ new Set();
|
|
@@ -22997,6 +23003,39 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22997
23003
|
unclear.push(...beforeTracer.unclear.filter((line) => !line.includes("has no callers")));
|
|
22998
23004
|
if (beforeTracer.truncated) tracer.truncated = true;
|
|
22999
23005
|
}
|
|
23006
|
+
const moved = new Map(
|
|
23007
|
+
changes.files.flatMap(
|
|
23008
|
+
(file2) => file2.basePath ? [[file2.basePath, file2.status === "DELETED" ? void 0 : file2.path]] : []
|
|
23009
|
+
)
|
|
23010
|
+
);
|
|
23011
|
+
const called = /* @__PURE__ */ new Set();
|
|
23012
|
+
for (const file2 of changes.files) {
|
|
23013
|
+
if (!file2.basePath || !file2.baseLines.length || file2.binary || testCode(file2.basePath))
|
|
23014
|
+
continue;
|
|
23015
|
+
for (const relation of before.relationsFrom(
|
|
23016
|
+
before.objectsAt(file2.basePath).map((object2) => object2.id)
|
|
23017
|
+
))
|
|
23018
|
+
if (CALLER_KINDS.has(relation.kind) && relation.to !== void 0 && overlaps(file2.baseLines, relation.anchor.startLine, relation.anchor.endLine))
|
|
23019
|
+
called.add(before.owner(relation.to));
|
|
23020
|
+
}
|
|
23021
|
+
const outsideTests = (callers, g) => callers.filter((caller) => !testCode(g.object(caller.ref).anchor.path));
|
|
23022
|
+
for (const ref of called) {
|
|
23023
|
+
const object2 = before.object(ref);
|
|
23024
|
+
if (mapIsModule(object2) || testCode(object2.anchor.path) || gone.includes(ref)) continue;
|
|
23025
|
+
const path14 = moved.has(object2.anchor.path) ? moved.get(object2.anchor.path) : object2.anchor.path;
|
|
23026
|
+
if (path14 === void 0) continue;
|
|
23027
|
+
const name = before.qualifiedName(ref);
|
|
23028
|
+
const now = declarations2(graph, path14).find(
|
|
23029
|
+
(candidate) => candidate.kind === object2.kind && graph.qualifiedName(candidate.id) === name
|
|
23030
|
+
);
|
|
23031
|
+
if (!now || outsideTests(tracer.callers(now.id), graph).length) continue;
|
|
23032
|
+
if (!outsideTests(beforeTracer.callers(ref), before).length) continue;
|
|
23033
|
+
const tested = tracer.callers(now.id).length > 0;
|
|
23034
|
+
uncalled.push(
|
|
23035
|
+
`${path14}: ${name} ${mapDeclarationLabel(now)}${tested ? " (only tests call it now)" : ""}`
|
|
23036
|
+
);
|
|
23037
|
+
}
|
|
23038
|
+
uncalled.sort();
|
|
23000
23039
|
}
|
|
23001
23040
|
return {
|
|
23002
23041
|
changed,
|
|
@@ -23020,6 +23059,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23020
23059
|
})).sort((left, right) => right.tests.length - left.tests.length),
|
|
23021
23060
|
unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
|
|
23022
23061
|
removedRoutes,
|
|
23062
|
+
uncalled,
|
|
23023
23063
|
dependencies: newModuleDependencies(store, cache, working, base, changes.files),
|
|
23024
23064
|
truncated: tracer.truncated
|
|
23025
23065
|
};
|
|
@@ -23242,6 +23282,15 @@ Nothing changed against ${changes.base}.`;
|
|
|
23242
23282
|
impact.removed,
|
|
23243
23283
|
LIST.changed
|
|
23244
23284
|
);
|
|
23285
|
+
list(
|
|
23286
|
+
"LEFT WITHOUT CALLERS (the diff removed or changed their last callers; nothing outside tests calls them now)",
|
|
23287
|
+
impact.uncalled,
|
|
23288
|
+
LIST.changed
|
|
23289
|
+
);
|
|
23290
|
+
if (impact.uncalled.length)
|
|
23291
|
+
lines.push(
|
|
23292
|
+
"If the change replaced them, delete them and the tests that only test them; keep them only if something the map cannot see uses them, such as another package, a framework or a dynamic call."
|
|
23293
|
+
);
|
|
23245
23294
|
if (changes.stranded.length) {
|
|
23246
23295
|
list(
|
|
23247
23296
|
"NAMES STILL USED ELSEWHERE (environment variables and configuration keys the diff removed from a file, found by text)",
|
|
@@ -23382,11 +23431,13 @@ Nothing changed against ${changes.base}.`;
|
|
|
23382
23431
|
// src/layermap.ts
|
|
23383
23432
|
var SCHEMA_VERSION = 2;
|
|
23384
23433
|
var KEEP_VERSIONS = 3;
|
|
23434
|
+
var BUSY_TIMEOUT = "PRAGMA busy_timeout = 30000;";
|
|
23435
|
+
var JOURNAL_LIMIT = 32 * 1024 * 1024;
|
|
23385
23436
|
function openMapDatabase(file2) {
|
|
23386
23437
|
mkdirSync(path10.dirname(file2), { recursive: true, mode: 448 });
|
|
23387
23438
|
const database = new DatabaseSync(file2);
|
|
23388
23439
|
try {
|
|
23389
|
-
database.exec(
|
|
23440
|
+
database.exec(BUSY_TIMEOUT);
|
|
23390
23441
|
const version2 = Number(database.prepare("PRAGMA user_version").get()?.user_version ?? 0);
|
|
23391
23442
|
if (version2 > SCHEMA_VERSION) throw new ProjectEvidenceError("LAYERMAP_DATABASE_NEWER", false);
|
|
23392
23443
|
if (version2 === 0) database.exec("PRAGMA auto_vacuum = INCREMENTAL;");
|
|
@@ -23427,18 +23478,20 @@ var mapDatabasePath = (cacheDirectory2, canonicalProject) => path10.join(
|
|
|
23427
23478
|
"map.sqlite"
|
|
23428
23479
|
);
|
|
23429
23480
|
var LayerMap = class _LayerMap {
|
|
23430
|
-
constructor(project, source, store, index, budget) {
|
|
23481
|
+
constructor(project, source, store, index, budget, journal) {
|
|
23431
23482
|
this.project = project;
|
|
23432
23483
|
this.source = source;
|
|
23433
23484
|
this.store = store;
|
|
23434
23485
|
this.index = index;
|
|
23435
23486
|
this.budget = budget;
|
|
23487
|
+
this.journal = journal;
|
|
23436
23488
|
}
|
|
23437
23489
|
project;
|
|
23438
23490
|
source;
|
|
23439
23491
|
store;
|
|
23440
23492
|
index;
|
|
23441
23493
|
budget;
|
|
23494
|
+
journal;
|
|
23442
23495
|
refreshing;
|
|
23443
23496
|
static async open(options) {
|
|
23444
23497
|
const project = await realpath2(options.project);
|
|
@@ -23449,10 +23502,9 @@ var LayerMap = class _LayerMap {
|
|
|
23449
23502
|
projectRef: `layermap:${createHash4("sha256").update(project).digest("hex").slice(0, 24)}`,
|
|
23450
23503
|
directory: { canonicalPath: project, device: String(stat3.dev), inode: String(stat3.ino) }
|
|
23451
23504
|
};
|
|
23505
|
+
const file2 = mapDatabasePath(options.cacheDirectory, project);
|
|
23452
23506
|
const store = new CodeIndexStore(
|
|
23453
|
-
openMapDatabase(
|
|
23454
|
-
mapDatabasePath(options.cacheDirectory, project)
|
|
23455
|
-
)
|
|
23507
|
+
openMapDatabase(file2)
|
|
23456
23508
|
);
|
|
23457
23509
|
const { typescript, go, python, java } = options.analyzers;
|
|
23458
23510
|
const index = new CodeIndex(
|
|
@@ -23465,10 +23517,14 @@ var LayerMap = class _LayerMap {
|
|
|
23465
23517
|
new JavaMapAnalyzer(java)
|
|
23466
23518
|
])
|
|
23467
23519
|
);
|
|
23468
|
-
return new _LayerMap(
|
|
23469
|
-
|
|
23470
|
-
|
|
23471
|
-
|
|
23520
|
+
return new _LayerMap(
|
|
23521
|
+
project,
|
|
23522
|
+
source,
|
|
23523
|
+
store,
|
|
23524
|
+
index,
|
|
23525
|
+
{ maxBytes: options.maxOutputBytes ?? 96 * 1024, envelopeBytes: 0 },
|
|
23526
|
+
`${file2}-wal`
|
|
23527
|
+
);
|
|
23472
23528
|
}
|
|
23473
23529
|
/** The map version of the directory as it is now, built or updated if needed. */
|
|
23474
23530
|
refresh(signal) {
|
|
@@ -23477,6 +23533,7 @@ var LayerMap = class _LayerMap {
|
|
|
23477
23533
|
initialScope: DEFAULT_INITIAL_EVIDENCE_SCOPE
|
|
23478
23534
|
});
|
|
23479
23535
|
this.prune(version2);
|
|
23536
|
+
this.tidyJournal();
|
|
23480
23537
|
return version2.version;
|
|
23481
23538
|
});
|
|
23482
23539
|
}
|
|
@@ -23507,6 +23564,20 @@ var LayerMap = class _LayerMap {
|
|
|
23507
23564
|
]);
|
|
23508
23565
|
this.store.database.exec("PRAGMA incremental_vacuum;");
|
|
23509
23566
|
}
|
|
23567
|
+
// SQLite leaves the write-ahead log at the size of the largest capture written through it, often
|
|
23568
|
+
// hundreds of megabytes after a build. Once that capture is in the database the log is emptied,
|
|
23569
|
+
// unless another process is reading or writing the map, in which case a later capture empties it.
|
|
23570
|
+
tidyJournal() {
|
|
23571
|
+
if ((statSync(this.journal, { throwIfNoEntry: false })?.size ?? 0) <= JOURNAL_LIMIT) return;
|
|
23572
|
+
const database = this.store.database;
|
|
23573
|
+
database.exec("PRAGMA busy_timeout = 0;");
|
|
23574
|
+
try {
|
|
23575
|
+
database.prepare("PRAGMA wal_checkpoint(TRUNCATE)").get();
|
|
23576
|
+
} catch {
|
|
23577
|
+
} finally {
|
|
23578
|
+
database.exec(BUSY_TIMEOUT);
|
|
23579
|
+
}
|
|
23580
|
+
}
|
|
23510
23581
|
async explore(input, signal) {
|
|
23511
23582
|
const version2 = await this.refresh(signal);
|
|
23512
23583
|
return this.index.query.viewMap(
|
|
@@ -23679,7 +23750,7 @@ async function resolveAnalyzers(cache, log2, env = process.env) {
|
|
|
23679
23750
|
return await readAnalyzers(directory);
|
|
23680
23751
|
}
|
|
23681
23752
|
var DAY = 24 * 60 * 60 * 1e3;
|
|
23682
|
-
async function pruneCache(cache, project, now = Date.now()) {
|
|
23753
|
+
async function pruneCache(cache, project, now = Date.now(), installed = packageRoot) {
|
|
23683
23754
|
const used = path11.join(path11.dirname(mapDatabasePath(cache, project)), "last-used");
|
|
23684
23755
|
await mkdir(path11.dirname(used), { recursive: true, mode: 448 });
|
|
23685
23756
|
await writeFile(used, "");
|
|
@@ -23700,6 +23771,34 @@ async function pruneCache(cache, project, now = Date.now()) {
|
|
|
23700
23771
|
if (built !== void 0 && now - built > (name.includes(".") ? DAY / 24 : DAY))
|
|
23701
23772
|
await rm(path11.join(builds, name), { recursive: true, force: true });
|
|
23702
23773
|
}
|
|
23774
|
+
await pruneNpxInstalls(installed, now);
|
|
23775
|
+
}
|
|
23776
|
+
async function pruneNpxInstalls(installed, now) {
|
|
23777
|
+
const own = path11.dirname(path11.dirname(installed));
|
|
23778
|
+
const npx = path11.dirname(own);
|
|
23779
|
+
if (path11.basename(path11.dirname(installed)) !== "node_modules" || path11.basename(npx) !== "_npx")
|
|
23780
|
+
return;
|
|
23781
|
+
const manifest = async (file2) => JSON.parse(await readFile2(file2, "utf8").catch(() => "{}"));
|
|
23782
|
+
const parts = (version2) => version2?.split(".").map(Number) ?? [];
|
|
23783
|
+
const current = parts((await manifest(path11.join(installed, "package.json"))).version);
|
|
23784
|
+
const older = (version2) => {
|
|
23785
|
+
for (let index = 0; index < 3; index++)
|
|
23786
|
+
if (version2[index] !== current[index]) return (version2[index] ?? 0) < (current[index] ?? 0);
|
|
23787
|
+
return false;
|
|
23788
|
+
};
|
|
23789
|
+
for (const name of await readdir(npx).catch(() => [])) {
|
|
23790
|
+
const directory = path11.join(npx, name);
|
|
23791
|
+
if (directory === own) continue;
|
|
23792
|
+
const requested = (await manifest(path11.join(directory, "package.json"))).dependencies ?? {};
|
|
23793
|
+
if (Object.keys(requested).join() !== "layermap") continue;
|
|
23794
|
+
const version2 = parts(
|
|
23795
|
+
(await manifest(path11.join(directory, "node_modules", "layermap", "package.json"))).version
|
|
23796
|
+
);
|
|
23797
|
+
if (version2.length !== 3 || version2.some(Number.isNaN) || !older(version2)) continue;
|
|
23798
|
+
const at = (await stat(directory).catch(() => void 0))?.mtimeMs;
|
|
23799
|
+
if (at !== void 0 && now - at > 7 * DAY)
|
|
23800
|
+
await rm(directory, { recursive: true, force: true });
|
|
23801
|
+
}
|
|
23703
23802
|
}
|
|
23704
23803
|
|
|
23705
23804
|
// src/agent/mcp.ts
|
|
@@ -23791,7 +23890,7 @@ var mapToolDescriptions = (host) => {
|
|
|
23791
23890
|
return Object.freeze({
|
|
23792
23891
|
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.`,
|
|
23793
23892
|
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.`,
|
|
23794
|
-
check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; REQUESTED BY, the code and templates outside the tests that request the path of a route whose handler the change reaches or a route it removed, found by text; EXISTING TESTS CHANGED, the tests that existed before the diff and whose code it changed or removed; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; NAMES STILL USED ELSEWHERE, environment variables and configuration keys the diff removed from a file that other files still read or set, found by text; NEW MODULE DEPENDENCIES, imports between the modules of the project overview that the base did not have, and those that make two modules depend on each other, for you to judge against the project's layers; EXISTING CODE LIKE THE NEW CODE, declarations the diff adds whose code reads almost the same as code the project already has; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it. It does not run or write tests: run the related ones if the change needs verifying; a failing or rewritten test of a feature the request is not about means the change leaked, so restore the test and narrow the change; a new dependency that runs against the layers or closes a cycle means moving what both modules need down rather than importing upward; new code like existing code means using the existing code, or removing the old if the new replaces it; 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.`,
|
|
23893
|
+
check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; REQUESTED BY, the code and templates outside the tests that request the path of a route whose handler the change reaches or a route it removed, found by text; EXISTING TESTS CHANGED, the tests that existed before the diff and whose code it changed or removed; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; NAMES STILL USED ELSEWHERE, environment variables and configuration keys the diff removed from a file that other files still read or set, found by text; NEW MODULE DEPENDENCIES, imports between the modules of the project overview that the base did not have, and those that make two modules depend on each other, for you to judge against the project's layers; EXISTING CODE LIKE THE NEW CODE, declarations the diff adds whose code reads almost the same as code the project already has; LEFT WITHOUT CALLERS, declarations whose last callers outside the tests the diff removed or changed; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it. It does not run or write tests: run the related ones if the change needs verifying; a failing or rewritten test of a feature the request is not about means the change leaked, so restore the test and narrow the change; a new dependency that runs against the layers or closes a cycle means moving what both modules need down rather than importing upward; new code like existing code means using the existing code, or removing the old if the new replaces it; code left without callers means deleting it, with the tests that only test it, when the change replaced it; call it once when the edits are done; and confirm the entry points in source, since an empty list does not prove a change safe.`,
|
|
23795
23894
|
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.`
|
|
23796
23895
|
});
|
|
23797
23896
|
};
|
|
@@ -24475,6 +24574,11 @@ async function main(argv) {
|
|
|
24475
24574
|
const version2 = await packageVersion();
|
|
24476
24575
|
if (values.version) {
|
|
24477
24576
|
process.stdout.write(`${version2}
|
|
24577
|
+
`);
|
|
24578
|
+
return 0;
|
|
24579
|
+
}
|
|
24580
|
+
if (command === "entry") {
|
|
24581
|
+
process.stdout.write(`${fileURLToPath3(import.meta.url)}
|
|
24478
24582
|
`);
|
|
24479
24583
|
return 0;
|
|
24480
24584
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
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
|
@@ -178,7 +178,7 @@ const fingerprint = (changed) =>
|
|
|
178
178
|
: "";
|
|
179
179
|
|
|
180
180
|
// How long a command runs (ms) before only the files it names count as its changes.
|
|
181
|
-
const LONG_COMMAND =
|
|
181
|
+
const LONG_COMMAND = 10_000;
|
|
182
182
|
|
|
183
183
|
// The folders a shell command names that exist, relative to the directory it runs in.
|
|
184
184
|
async function namedFolders(cwd, command) {
|
|
@@ -213,8 +213,9 @@ export default function layermap(pi) {
|
|
|
213
213
|
// It compares a repository's uncommitted code changes with those it had before the session's
|
|
214
214
|
// first such tool there and those the agent last checked in it, and all of them with those it
|
|
215
215
|
// was last asked about; changes another session makes while this one reads do not count. A
|
|
216
|
-
// command that ran longer than
|
|
217
|
-
// to change the same work tree, so only the files it names count
|
|
216
|
+
// command that ran longer than ten seconds (tests, builds, scripts) leaves time for another
|
|
217
|
+
// session to change the same work tree, so only the files it names count; one that writes code
|
|
218
|
+
// without naming the file, such as a generator or formatter, takes a few seconds.
|
|
218
219
|
const edited = new Set();
|
|
219
220
|
const before = new Map();
|
|
220
221
|
const checked = new Map();
|
|
@@ -227,7 +228,7 @@ export default function layermap(pi) {
|
|
|
227
228
|
if (server && !server.dead) return server;
|
|
228
229
|
starting ??= (async () => {
|
|
229
230
|
const next = new MapServer(cwd);
|
|
230
|
-
const tools = await next.start("0.1.
|
|
231
|
+
const tools = await next.start("0.1.24");
|
|
231
232
|
for (const tool of tools) {
|
|
232
233
|
if (registered.has(tool.name)) continue;
|
|
233
234
|
registered.add(tool.name);
|