layermap 0.1.39 → 0.1.40
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 +1 -0
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/analyzers/project-map-worker.mjs +67 -3
- package/dist/cli.mjs +58 -13
- package/dist/launcher.mjs +4 -2
- package/package.json +1 -1
- package/pi/layermap.mjs +1 -1
package/README.md
CHANGED
|
@@ -225,6 +225,7 @@ npx layermap search "invoice total"
|
|
|
225
225
|
npx layermap refs src/billing/tax.ts calculateTax
|
|
226
226
|
npx layermap check --base main
|
|
227
227
|
npx layermap check test/billing.test.ts # also: what of the change this test does not run
|
|
228
|
+
npx layermap check --json # related tests by rank and what the map cannot follow, as JSON
|
|
228
229
|
```
|
|
229
230
|
|
|
230
231
|
## FAQ
|
|
Binary file
|
|
@@ -15826,8 +15826,13 @@ async function discoverMapConfiguration(api, files) {
|
|
|
15826
15826
|
const workspaceLinks = [...new Map(links.map((link) => [link.from, link])).values()];
|
|
15827
15827
|
applyMapWorkspaceLinks(files, workspaceLinks);
|
|
15828
15828
|
const outputs = /* @__PURE__ */ new Map();
|
|
15829
|
+
const members = /* @__PURE__ */ new Map();
|
|
15829
15830
|
for (const configPath of Object.keys(files.input.files).filter((file2) => configuration.test(file2)).sort()) {
|
|
15830
15831
|
const parsed = await api.parseConfigFile(mapVirtualPath(configPath));
|
|
15832
|
+
members.set(
|
|
15833
|
+
configPath,
|
|
15834
|
+
new Set(parsed.fileNames.flatMap((source) => mapRelativePath(source) ?? []))
|
|
15835
|
+
);
|
|
15831
15836
|
const { rootDir, outDir, outFile, noEmit, declarationDir } = parsed.options;
|
|
15832
15837
|
if (typeof rootDir !== "string" || typeof outDir !== "string" || outFile || noEmit) continue;
|
|
15833
15838
|
for (const source of parsed.fileNames) {
|
|
@@ -15875,6 +15880,7 @@ async function discoverMapConfiguration(api, files) {
|
|
|
15875
15880
|
applyMapWorkspaceContents(files, workspace);
|
|
15876
15881
|
const openFiles = files.input.inventory.filter((file2) => /\.[cm]?[jt]sx?$/u.test(file2));
|
|
15877
15882
|
const snapshot = await api.updateSnapshot({ openFiles: openFiles.map(mapVirtualPath) });
|
|
15883
|
+
let opened;
|
|
15878
15884
|
try {
|
|
15879
15885
|
const selected = /* @__PURE__ */ new Map();
|
|
15880
15886
|
for (let start = 0; start < openFiles.length; start += 32) {
|
|
@@ -15897,6 +15903,26 @@ async function discoverMapConfiguration(api, files) {
|
|
|
15897
15903
|
entry.rootFiles.push(file2);
|
|
15898
15904
|
}
|
|
15899
15905
|
}
|
|
15906
|
+
const inferred = selected.get("INFERRED");
|
|
15907
|
+
const candidates = inferred ? holders(members, selected) : /* @__PURE__ */ new Map();
|
|
15908
|
+
const held = /* @__PURE__ */ new Map();
|
|
15909
|
+
for (const file2 of inferred?.rootFiles ?? []) {
|
|
15910
|
+
const configPath = holder(candidates, file2);
|
|
15911
|
+
if (configPath) held.set(configPath, [...held.get(configPath) ?? [], file2]);
|
|
15912
|
+
}
|
|
15913
|
+
if (held.size && inferred) {
|
|
15914
|
+
opened = await api.updateSnapshot({ openProjects: [...held.keys()].map(mapVirtualPath) });
|
|
15915
|
+
for (const [configPath, rootFiles] of held) {
|
|
15916
|
+
const project = opened.getProject(mapVirtualPath(configPath));
|
|
15917
|
+
if (!project) continue;
|
|
15918
|
+
const entry = selected.get(configPath);
|
|
15919
|
+
if (entry) entry.rootFiles.push(...rootFiles);
|
|
15920
|
+
else selected.set(configPath, { configPath, rootFiles, project });
|
|
15921
|
+
const moved = new Set(rootFiles);
|
|
15922
|
+
inferred.rootFiles = inferred.rootFiles.filter((file2) => !moved.has(file2));
|
|
15923
|
+
}
|
|
15924
|
+
if (!inferred.rootFiles.length) selected.delete("INFERRED");
|
|
15925
|
+
}
|
|
15900
15926
|
const projects = [];
|
|
15901
15927
|
for (const { project, ...entry } of selected.values()) {
|
|
15902
15928
|
const inputFiles = (await project.program.getSourceFileNames()).flatMap((file2) => {
|
|
@@ -15907,9 +15933,47 @@ async function discoverMapConfiguration(api, files) {
|
|
|
15907
15933
|
}
|
|
15908
15934
|
return { projects, workspace };
|
|
15909
15935
|
} finally {
|
|
15936
|
+
await opened?.dispose();
|
|
15910
15937
|
await snapshot.dispose();
|
|
15911
15938
|
}
|
|
15912
15939
|
}
|
|
15940
|
+
var directoryOf = (file2) => {
|
|
15941
|
+
const directory = path6.posix.dirname(file2);
|
|
15942
|
+
return directory === "." ? "" : directory;
|
|
15943
|
+
};
|
|
15944
|
+
var within = (directory, file2) => !directory || inside(directory, file2);
|
|
15945
|
+
function holders(members, selected) {
|
|
15946
|
+
const governing = /* @__PURE__ */ new Set();
|
|
15947
|
+
for (const key2 of selected.keys()) if (key2 !== "INFERRED") governing.add(directoryOf(key2));
|
|
15948
|
+
const governed = /* @__PURE__ */ new Map();
|
|
15949
|
+
for (const [key2, entry] of selected)
|
|
15950
|
+
if (key2 !== "INFERRED") for (const file2 of entry.rootFiles) governed.set(file2, key2);
|
|
15951
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
15952
|
+
for (const [configPath, sources] of members) {
|
|
15953
|
+
const directory = directoryOf(configPath);
|
|
15954
|
+
const deeper = [...governing].filter((own) => own !== directory && within(directory, own));
|
|
15955
|
+
if (!deeper.length) {
|
|
15956
|
+
candidates.set(configPath, sources);
|
|
15957
|
+
continue;
|
|
15958
|
+
}
|
|
15959
|
+
const spans = [...sources].some((source) => {
|
|
15960
|
+
const owner = governed.get(source);
|
|
15961
|
+
return owner !== void 0 && deeper.includes(directoryOf(owner));
|
|
15962
|
+
});
|
|
15963
|
+
if (!spans) candidates.set(configPath, sources);
|
|
15964
|
+
}
|
|
15965
|
+
return candidates;
|
|
15966
|
+
}
|
|
15967
|
+
function holder(candidates, file2) {
|
|
15968
|
+
let best;
|
|
15969
|
+
for (const [configPath, sources] of candidates) {
|
|
15970
|
+
if (!sources.has(file2)) continue;
|
|
15971
|
+
const directory = directoryOf(configPath);
|
|
15972
|
+
const depth = !directory ? 0 : inside(directory, file2) ? directory.split("/").length : -1;
|
|
15973
|
+
if (!best || depth > best.depth) best = { configPath, depth };
|
|
15974
|
+
}
|
|
15975
|
+
return best?.configPath;
|
|
15976
|
+
}
|
|
15913
15977
|
function applyMapWorkspace(files, workspace) {
|
|
15914
15978
|
applyMapWorkspaceLinks(files, workspace.links);
|
|
15915
15979
|
applyMapWorkspaceContents(files, workspace);
|
|
@@ -31984,11 +32048,11 @@ async function extractProjectMap(project, input, trace, read, installed) {
|
|
|
31984
32048
|
await readState(symbol2);
|
|
31985
32049
|
continue;
|
|
31986
32050
|
}
|
|
31987
|
-
const
|
|
31988
|
-
if (
|
|
32051
|
+
const holder2 = callable && item.holder ? materialize(item.holder) : void 0;
|
|
32052
|
+
if (holder2 && item.holder) callableHolders.add(key(item.holder));
|
|
31989
32053
|
for (const destination of callable?.objects ?? [])
|
|
31990
32054
|
collect.relation({
|
|
31991
|
-
from:
|
|
32055
|
+
from: holder2?.id ?? item.owner,
|
|
31992
32056
|
to: destination.id,
|
|
31993
32057
|
kind: item.kind,
|
|
31994
32058
|
anchor: item.anchor,
|
package/dist/cli.mjs
CHANGED
|
@@ -18997,7 +18997,7 @@ var miniprogramEventOf = (target) => {
|
|
|
18997
18997
|
|
|
18998
18998
|
// src/project-map-language-typescript.ts
|
|
18999
18999
|
var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
19000
|
-
id: "typescript-7.0.2-map-
|
|
19000
|
+
id: "typescript-7.0.2-map-v25",
|
|
19001
19001
|
claims: (path17) => /\.[cm]?[jt]sx?$/u.test(path17),
|
|
19002
19002
|
reads: (path17) => path17.endsWith(".json") || path17.endsWith(".wxml") || path17 === "pnpm-workspace.yaml",
|
|
19003
19003
|
create: () => new TypeScriptMapAnalyzer()
|
|
@@ -23372,6 +23372,12 @@ var NON_CODE = [
|
|
|
23372
23372
|
[/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte|wxml)$/iu, "template"]
|
|
23373
23373
|
];
|
|
23374
23374
|
var nonCodeKind = (path17) => NON_CODE.find(([pattern]) => pattern.test(path17))?.[1];
|
|
23375
|
+
var UNANALYZED = [
|
|
23376
|
+
[/\.(?:sh|bash|zsh|fish|ps1|bat|cmd)$/iu, "shell script"],
|
|
23377
|
+
[/\.(?:css|scss|sass|less|styl|wxss|acss)$/iu, "style sheet"]
|
|
23378
|
+
];
|
|
23379
|
+
var DOCUMENTATION = /\.(?:md|mdx|markdown|rst|adoc)$|(?:^|\/)(?:LICENSE|NOTICE)[^/]*$/iu;
|
|
23380
|
+
var unmappedKind = (path17, binary) => nonCodeKind(path17) ?? (binary ? "binary file" : DOCUMENTATION.test(path17) ? void 0 : UNANALYZED.find(([pattern]) => pattern.test(path17))?.[1] ?? "unanalyzed file");
|
|
23375
23381
|
var LIMITS = Object.freeze({
|
|
23376
23382
|
depth: 8,
|
|
23377
23383
|
declarations: 800,
|
|
@@ -23803,6 +23809,7 @@ async function mapChangeImpact(store, working, base, changes, shapes, until, pro
|
|
|
23803
23809
|
const tracer = new Tracer(graph, memberCalls, new MapShapeUses(graph, shapes.working, until));
|
|
23804
23810
|
const changed = [];
|
|
23805
23811
|
const unclear = [];
|
|
23812
|
+
const unmapped = [];
|
|
23806
23813
|
const removed = [];
|
|
23807
23814
|
const declarations2 = (g, path17) => g.objectsAt(path17).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
|
|
23808
23815
|
const units = (g, path17) => mapMiniprogramTemplate(path17) ? g.objectsAt(path17).filter((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : declarations2(g, path17);
|
|
@@ -23816,17 +23823,21 @@ async function mapChangeImpact(store, working, base, changes, shapes, until, pro
|
|
|
23816
23823
|
if (!unclear.includes(note)) unclear.push(note);
|
|
23817
23824
|
};
|
|
23818
23825
|
for (const file2 of changes.files) {
|
|
23819
|
-
|
|
23820
|
-
const kind = nonCodeKind(file2.path);
|
|
23821
|
-
const objects2 = file2.status === "DELETED" ? [] : graph.objectsAt(file2.path);
|
|
23826
|
+
const objects2 = file2.status === "DELETED" || file2.binary ? [] : graph.objectsAt(file2.path);
|
|
23822
23827
|
if (testCode(file2.path)) {
|
|
23823
|
-
if (file2.status !== "DELETED"
|
|
23828
|
+
if (file2.status !== "DELETED" && !file2.binary)
|
|
23829
|
+
tracer.test(file2.path, void 0, "changed in this diff", 1);
|
|
23824
23830
|
continue;
|
|
23825
23831
|
}
|
|
23826
23832
|
const template = mapMiniprogramTemplate(file2.path);
|
|
23827
|
-
const analyzed = objects2.length > 0 && (mapLanguageOf(file2.path) !== void 0 || template && objects2.some((object2) => object2.parsing === "PARSED"));
|
|
23828
|
-
|
|
23829
|
-
|
|
23833
|
+
const analyzed = file2.status === "DELETED" ? !file2.binary && (mapLanguageOf(file2.path) !== void 0 || template) : objects2.length > 0 && (mapLanguageOf(file2.path) !== void 0 || template && objects2.some((object2) => object2.parsing === "PARSED"));
|
|
23834
|
+
const kind = !analyzed || MAP_MIGRATION_PATH.test(file2.path) ? unmappedKind(file2.path, file2.binary) : void 0;
|
|
23835
|
+
if (kind) {
|
|
23836
|
+
unclear.push(
|
|
23837
|
+
`${file2.path} ${file2.status === "DELETED" ? "deleted" : "changed"} (${kind}): its effects are not mapped`
|
|
23838
|
+
);
|
|
23839
|
+
unmapped.push({ path: file2.path, kind });
|
|
23840
|
+
}
|
|
23830
23841
|
if (!objects2.length) continue;
|
|
23831
23842
|
const hits = /* @__PURE__ */ new Set();
|
|
23832
23843
|
let topLevel = false;
|
|
@@ -24173,6 +24184,7 @@ async function mapChangeImpact(store, working, base, changes, shapes, until, pro
|
|
|
24173
24184
|
tests: [...known.tests].map(([path17, names]) => ({ path: path17, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
|
|
24174
24185
|
})).sort((left, right) => right.tests.length - left.tests.length),
|
|
24175
24186
|
unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
|
|
24187
|
+
unmapped,
|
|
24176
24188
|
removedRoutes,
|
|
24177
24189
|
uncalled,
|
|
24178
24190
|
dependencies: newModuleDependencies(store, cache, working, base, changes.files),
|
|
@@ -24387,6 +24399,22 @@ function routeFragment(label) {
|
|
|
24387
24399
|
const longest = routePath(label).split(/\/(?:\{[^}]*\}|:[^/]+|<[^>]*>|\*)(?=\/|$)/u).sort((left, right) => right.length - left.length)[0];
|
|
24388
24400
|
return longest && longest.replace(/\//gu, "").length >= 4 ? longest : void 0;
|
|
24389
24401
|
}
|
|
24402
|
+
function mapChangesData(changes, impact) {
|
|
24403
|
+
return {
|
|
24404
|
+
base: changes.base,
|
|
24405
|
+
commit: changes.commit,
|
|
24406
|
+
files: changes.files.map(({ path: path17, basePath, status }) => ({
|
|
24407
|
+
path: path17,
|
|
24408
|
+
...basePath !== void 0 && basePath !== path17 ? { basePath } : {},
|
|
24409
|
+
status
|
|
24410
|
+
})),
|
|
24411
|
+
tests: impact.tests,
|
|
24412
|
+
unmapped: impact.unmapped,
|
|
24413
|
+
checkByHand: impact.unclear,
|
|
24414
|
+
truncated: impact.truncated,
|
|
24415
|
+
...impact.untested ? { untested: impact.untested } : {}
|
|
24416
|
+
};
|
|
24417
|
+
}
|
|
24390
24418
|
async function checkMapChanges(input, signal) {
|
|
24391
24419
|
const { index, project, working } = input;
|
|
24392
24420
|
const changes = await readMapChanges(project, input.base, signal);
|
|
@@ -24425,6 +24453,7 @@ async function checkMapChanges(input, signal) {
|
|
|
24425
24453
|
project,
|
|
24426
24454
|
input.tests
|
|
24427
24455
|
);
|
|
24456
|
+
if (input.format === "json") return { text: JSON.stringify(mapChangesData(changes, impact)) };
|
|
24428
24457
|
return {
|
|
24429
24458
|
text: mapChangesText(
|
|
24430
24459
|
changes,
|
|
@@ -25144,7 +25173,8 @@ var LayerMap = class _LayerMap {
|
|
|
25144
25173
|
working: await this.current(signal, hold),
|
|
25145
25174
|
base: input.base ?? "HEAD",
|
|
25146
25175
|
baseVersion: (commit, baseSignal) => this.versionAt(commit, baseSignal, hold),
|
|
25147
|
-
...input.tests ? { tests: input.tests } : {}
|
|
25176
|
+
...input.tests ? { tests: input.tests } : {},
|
|
25177
|
+
...input.format ? { format: input.format } : {}
|
|
25148
25178
|
},
|
|
25149
25179
|
signal
|
|
25150
25180
|
)
|
|
@@ -25812,8 +25842,8 @@ var SETUP_RULE = `mcp__${SERVER}`;
|
|
|
25812
25842
|
var PLUGIN_RULE = `mcp__plugin_${SERVER}_${SERVER}`;
|
|
25813
25843
|
var BEGIN = "<!-- layermap:begin -->";
|
|
25814
25844
|
var END = "<!-- layermap:end -->";
|
|
25815
|
-
var launcherScript = (template, version2) => `// Generated from scripts/launcher.mjs.
|
|
25816
|
-
${template.replace("__VERSION__", JSON.stringify(version2))}`;
|
|
25845
|
+
var launcherScript = (template, version2, args = '["mcp"]') => `// Generated from scripts/launcher.mjs.
|
|
25846
|
+
${template.replace("__VERSION__", JSON.stringify(version2)).replace("__ARGUMENTS__", args)}`;
|
|
25817
25847
|
var PUBLISHED_LAUNCHER = path15.join(packageRoot, "dist", "launcher.mjs");
|
|
25818
25848
|
var launcherFile = (env = process.env) => path15.join(cacheDirectory(env), "server.mjs");
|
|
25819
25849
|
var mcpLaunchCommand = (env = process.env, published = existsSync8(PUBLISHED_LAUNCHER)) => {
|
|
@@ -26126,8 +26156,11 @@ Usage:
|
|
|
26126
26156
|
[--depth N] [--tests] [--unresolved] [--offset N]
|
|
26127
26157
|
layermap search QUERY [--path DIR] [--mode ANY|ALL|LITERAL] [--max N] [--offset N]
|
|
26128
26158
|
layermap refs PATH NAME [--line N] [--path DIR] [--max N] [--cursor C]
|
|
26129
|
-
layermap check [--base REF] [TEST...]
|
|
26130
|
-
|
|
26159
|
+
layermap check [--base REF] [--json] [TEST...]
|
|
26160
|
+
what the uncommitted changes (or those since REF) affect,
|
|
26161
|
+
and what of them the test files given do not run; --json
|
|
26162
|
+
prints the related tests by rank and what the map cannot
|
|
26163
|
+
follow, for a program choosing which tests to run
|
|
26131
26164
|
|
|
26132
26165
|
The project is the Git work tree around the current directory unless --project names one; the MCP
|
|
26133
26166
|
server also maps any other repository a tool call's path names.
|
|
@@ -26169,6 +26202,7 @@ async function main(argv) {
|
|
|
26169
26202
|
mode: { type: "string" },
|
|
26170
26203
|
max: { type: "string" },
|
|
26171
26204
|
cursor: { type: "string" },
|
|
26205
|
+
json: { type: "boolean", default: false },
|
|
26172
26206
|
help: { type: "boolean", short: "h", default: false },
|
|
26173
26207
|
version: { type: "boolean", short: "v", default: false }
|
|
26174
26208
|
}
|
|
@@ -26181,6 +26215,7 @@ async function main(argv) {
|
|
|
26181
26215
|
return 0;
|
|
26182
26216
|
}
|
|
26183
26217
|
if (values.help || !command) return usage(command ? 0 : 1);
|
|
26218
|
+
if (values.json && command !== "check") return usage(1);
|
|
26184
26219
|
const { directory: project, git: git2 } = await projectDirectory(values.project ?? process.cwd());
|
|
26185
26220
|
const cache = cacheDirectory();
|
|
26186
26221
|
const open2 = async (directory) => {
|
|
@@ -26226,6 +26261,16 @@ async function main(argv) {
|
|
|
26226
26261
|
);
|
|
26227
26262
|
return 0;
|
|
26228
26263
|
}
|
|
26264
|
+
if (command === "check" && values.json) {
|
|
26265
|
+
const tests = rest.length ? await checkedTests(project, rest) : void 0;
|
|
26266
|
+
const { text } = await map2.checkChanges(
|
|
26267
|
+
{ base: values.base, ...tests ? { tests } : {}, format: "json" },
|
|
26268
|
+
signal
|
|
26269
|
+
);
|
|
26270
|
+
process.stdout.write(`${text}
|
|
26271
|
+
`);
|
|
26272
|
+
return 0;
|
|
26273
|
+
}
|
|
26229
26274
|
const call = {
|
|
26230
26275
|
explore: [
|
|
26231
26276
|
MAP_TOOL_NAMES.explore,
|
package/dist/launcher.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Runs one LayerMap version in this process: its MCP server, or, for the layermap command of the
|
|
2
|
+
// Claude Code plugin, its command line with the arguments given. The version is installed once into
|
|
2
3
|
// LayerMap's cache, from where every later start runs without npm or a network. The agent starts
|
|
3
4
|
// this in the project, which stays the working directory the server maps; npm runs in the cache,
|
|
4
5
|
// so the project's own npm settings and packages play no part in what gets installed.
|
|
@@ -17,6 +18,7 @@ import path from "node:path";
|
|
|
17
18
|
import { pathToFileURL } from "node:url";
|
|
18
19
|
|
|
19
20
|
const VERSION = __VERSION__;
|
|
21
|
+
const ARGUMENTS = __ARGUMENTS__;
|
|
20
22
|
|
|
21
23
|
// The same directory as cacheDirectory in src/agent/environment.ts.
|
|
22
24
|
const env = process.env;
|
|
@@ -95,7 +97,7 @@ try {
|
|
|
95
97
|
// LayerMap removes a version from its cache once nothing has started it for a week.
|
|
96
98
|
writeFileSync(path.join(home, "last-used"), "");
|
|
97
99
|
const entry = path.join(installed, JSON.parse(readFileSync(manifest, "utf8")).bin.layermap);
|
|
98
|
-
process.argv = [process.argv[0], entry,
|
|
100
|
+
process.argv = [process.argv[0], entry, ...ARGUMENTS];
|
|
99
101
|
await import(pathToFileURL(entry).href);
|
|
100
102
|
} catch (error) {
|
|
101
103
|
process.stderr.write(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
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.
|
|
296
|
+
const tools = await next.start("0.1.40");
|
|
297
297
|
for (const tool of tools) {
|
|
298
298
|
if (registered.has(tool.name)) continue;
|
|
299
299
|
registered.add(tool.name);
|