layermap 0.1.46 → 0.1.48
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/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/go/win32-arm64/go-map.exe +0 -0
- package/analyzers/go/win32-x64/go-map.exe +0 -0
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/analyzers/project-map-java-worker.mjs +0 -1
- package/analyzers/project-map-python-worker.mjs +10 -10
- package/analyzers/project-map-worker.mjs +5 -7
- package/dist/cli.mjs +97 -61
- package/package.json +1 -1
- package/pi/layermap.mjs +1 -1
package/README.md
CHANGED
|
@@ -226,6 +226,7 @@ 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
228
|
npx layermap check --json # as JSON: related tests by rank, what the map cannot follow, the imports and calls it changes between files
|
|
229
|
+
npx layermap imports --json # every import of the project as it is now, test files apart: file and line, the file imported, and why the rest reach no file
|
|
229
230
|
```
|
|
230
231
|
|
|
231
232
|
## FAQ
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -14755,7 +14755,6 @@ process.once(
|
|
|
14755
14755
|
operation: message.operation,
|
|
14756
14756
|
files: message.files,
|
|
14757
14757
|
release: message.release,
|
|
14758
|
-
tests: message.tests,
|
|
14759
14758
|
lombok: path3.join(path3.dirname(message.compilerPath), "lombok.jar"),
|
|
14760
14759
|
...message.targets ? { targets: message.targets } : {},
|
|
14761
14760
|
...message.incremental ? { incremental: message.incremental } : {}
|
|
@@ -120972,10 +120972,9 @@ function docstring(statements) {
|
|
|
120972
120972
|
return inner.length === 1 && inner[0]?.nodeType === 48 /* StringList */ ? inner[0] : void 0;
|
|
120973
120973
|
}
|
|
120974
120974
|
var Extraction = class {
|
|
120975
|
-
constructor(source, evaluator
|
|
120975
|
+
constructor(source, evaluator) {
|
|
120976
120976
|
this.source = source;
|
|
120977
120977
|
this.evaluator = evaluator;
|
|
120978
|
-
this.tests = tests;
|
|
120979
120978
|
this.facts = { files: [], objects: [], relations: [], notes: [], typeErrors: 0 };
|
|
120980
120979
|
// Objects by the start of their declaring name, per file.
|
|
120981
120980
|
this.byName = /* @__PURE__ */ new Map();
|
|
@@ -121055,9 +121054,6 @@ var Extraction = class {
|
|
|
121055
121054
|
end: end(node)
|
|
121056
121055
|
});
|
|
121057
121056
|
}
|
|
121058
|
-
isTest(path3) {
|
|
121059
|
-
return this.tests.has(path3);
|
|
121060
|
-
}
|
|
121061
121057
|
// Declarations a name refers to, with imports followed to what they import. An import that
|
|
121062
121058
|
// resolves nowhere stays an alias declaration.
|
|
121063
121059
|
declarations(name) {
|
|
@@ -121852,8 +121848,12 @@ var Relater = class extends ParseTreeWalker {
|
|
|
121852
121848
|
}
|
|
121853
121849
|
imports(module, site, from) {
|
|
121854
121850
|
const specifier = `${".".repeat(module.d.leadingDots)}${module.d.nameParts.map((part) => part.d.value).join(".")}`;
|
|
121855
|
-
const
|
|
121856
|
-
|
|
121851
|
+
const fact = {
|
|
121852
|
+
kind: "IMPORTS",
|
|
121853
|
+
from: this.top(this.executing),
|
|
121854
|
+
start: site.start,
|
|
121855
|
+
end: end(site)
|
|
121856
|
+
};
|
|
121857
121857
|
const result = getImportInfo(module, this.x.source.program.analyzerNodeInfoReader);
|
|
121858
121858
|
const resolved2 = result?.isImportFound ? result.resolvedUris.at(-1) : void 0;
|
|
121859
121859
|
const path3 = resolved2 && !resolved2.isEmpty() ? this.x.source.pathOf(resolved2) : void 0;
|
|
@@ -121945,10 +121945,10 @@ function implementations(x2) {
|
|
|
121945
121945
|
}
|
|
121946
121946
|
}
|
|
121947
121947
|
}
|
|
121948
|
-
function extractPython(source
|
|
121948
|
+
function extractPython(source) {
|
|
121949
121949
|
const evaluator = source.program.evaluator;
|
|
121950
121950
|
if (!evaluator) throw new Error("PROJECT_MAP_ANALYSIS_FAILED");
|
|
121951
|
-
const x2 = new Extraction(source, evaluator
|
|
121951
|
+
const x2 = new Extraction(source, evaluator);
|
|
121952
121952
|
const modules = [];
|
|
121953
121953
|
for (const path3 of source.paths) {
|
|
121954
121954
|
const uri = source.uriOf(path3);
|
|
@@ -122118,7 +122118,7 @@ process.once(
|
|
|
122118
122118
|
process.send?.({ result: findPythonReferences(source, message.targets) });
|
|
122119
122119
|
} else {
|
|
122120
122120
|
trace.phase = "TRAVERSAL";
|
|
122121
|
-
process.send?.({ result: extractPython(source
|
|
122121
|
+
process.send?.({ result: extractPython(source) });
|
|
122122
122122
|
}
|
|
122123
122123
|
} finally {
|
|
122124
122124
|
trace.phase = "DISPOSE";
|
|
@@ -30122,8 +30122,7 @@ var MapRelationKindSchema = external_exports.enum([
|
|
|
30122
30122
|
"IMPLEMENTS",
|
|
30123
30123
|
// A member that implements or overrides the target member, so calls to it may dispatch here.
|
|
30124
30124
|
"OVERRIDES",
|
|
30125
|
-
"DECORATED_BY"
|
|
30126
|
-
"TEST_IMPORTS"
|
|
30125
|
+
"DECORATED_BY"
|
|
30127
30126
|
]);
|
|
30128
30127
|
var MapObjectLocatorSchema = external_exports.object({
|
|
30129
30128
|
path: external_exports.string().min(1),
|
|
@@ -30185,7 +30184,6 @@ var MAP_RELATION_PRIORITY = Object.freeze({
|
|
|
30185
30184
|
CALLS: 0,
|
|
30186
30185
|
WRITES: 0,
|
|
30187
30186
|
IMPORTS: 0,
|
|
30188
|
-
TEST_IMPORTS: 0,
|
|
30189
30187
|
EXTENDS: 0,
|
|
30190
30188
|
IMPLEMENTS: 0,
|
|
30191
30189
|
OVERRIDES: 0,
|
|
@@ -31991,7 +31989,6 @@ function isMapWrite(node) {
|
|
|
31991
31989
|
|
|
31992
31990
|
// src/project-map-extract.ts
|
|
31993
31991
|
var key = (node) => `${node.getSourceFile().fileName}:${node.pos}:${node.kind}`;
|
|
31994
|
-
var IMPORT_RELATIONS = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
31995
31992
|
var declares = (node) => Boolean(mapExecutionDeclaration(node) || mapDeclarationKind(node, true) && mapDeclarationName(node));
|
|
31996
31993
|
var declarationName = (node) => {
|
|
31997
31994
|
const execution = mapExecutionDeclaration(node);
|
|
@@ -32225,7 +32222,7 @@ async function extractProjectMap(project, input, trace, read, installed) {
|
|
|
32225
32222
|
reference = {
|
|
32226
32223
|
node,
|
|
32227
32224
|
lookup: moduleSpecifier,
|
|
32228
|
-
kind:
|
|
32225
|
+
kind: "IMPORTS",
|
|
32229
32226
|
target: moduleSpecifier.text
|
|
32230
32227
|
};
|
|
32231
32228
|
} else if (isCallExpression(node) || isNewExpression(node)) {
|
|
@@ -32667,7 +32664,7 @@ async function extractProjectMap(project, input, trace, read, installed) {
|
|
|
32667
32664
|
if (name) notInstalled.add(name);
|
|
32668
32665
|
}
|
|
32669
32666
|
for (const relation of output.relations) {
|
|
32670
|
-
if (
|
|
32667
|
+
if (relation.kind !== "IMPORTS" || relation.unresolvedReason !== "SYMBOL_NOT_RESOLVED")
|
|
32671
32668
|
continue;
|
|
32672
32669
|
const name = mapPackageOf(relation.target);
|
|
32673
32670
|
if (name && !installed(relation.anchor.path, name)) notInstalled.add(name);
|
|
@@ -33027,7 +33024,8 @@ process.once(
|
|
|
33027
33024
|
allowJs: true,
|
|
33028
33025
|
jsx: "preserve",
|
|
33029
33026
|
target: "esnext",
|
|
33030
|
-
module: "
|
|
33027
|
+
module: "preserve",
|
|
33028
|
+
moduleResolution: "bundler",
|
|
33031
33029
|
noResolve: message.syntaxOnly
|
|
33032
33030
|
},
|
|
33033
33031
|
files: (message.rootFiles ?? (message.syntaxOnly ? Object.keys(message.files) : message.inventory)).filter((file2) => /\.[cm]?[jt]sx?$/u.test(file2))
|
package/dist/cli.mjs
CHANGED
|
@@ -15955,8 +15955,7 @@ var MapRelationKindSchema = external_exports.enum([
|
|
|
15955
15955
|
"IMPLEMENTS",
|
|
15956
15956
|
// A member that implements or overrides the target member, so calls to it may dispatch here.
|
|
15957
15957
|
"OVERRIDES",
|
|
15958
|
-
"DECORATED_BY"
|
|
15959
|
-
"TEST_IMPORTS"
|
|
15958
|
+
"DECORATED_BY"
|
|
15960
15959
|
]);
|
|
15961
15960
|
var MapObjectLocatorSchema = external_exports.object({
|
|
15962
15961
|
path: external_exports.string().min(1),
|
|
@@ -16018,7 +16017,6 @@ var MAP_RELATION_PRIORITY = Object.freeze({
|
|
|
16018
16017
|
CALLS: 0,
|
|
16019
16018
|
WRITES: 0,
|
|
16020
16019
|
IMPORTS: 0,
|
|
16021
|
-
TEST_IMPORTS: 0,
|
|
16022
16020
|
EXTENDS: 0,
|
|
16023
16021
|
IMPLEMENTS: 0,
|
|
16024
16022
|
OVERRIDES: 0,
|
|
@@ -16855,7 +16853,6 @@ var relationWeight = {
|
|
|
16855
16853
|
WRITES: 1200,
|
|
16856
16854
|
READS: 900,
|
|
16857
16855
|
IMPORTS: 800,
|
|
16858
|
-
TEST_IMPORTS: 700,
|
|
16859
16856
|
EXTENDS: 900,
|
|
16860
16857
|
IMPLEMENTS: 900,
|
|
16861
16858
|
OVERRIDES: 900,
|
|
@@ -16863,6 +16860,7 @@ var relationWeight = {
|
|
|
16863
16860
|
REFERENCES: 500,
|
|
16864
16861
|
CONTAINS: 250
|
|
16865
16862
|
};
|
|
16863
|
+
var TEST_IMPORT_WEIGHT = 700;
|
|
16866
16864
|
function mapSearchFocus(store, version2, refs, scope, signal) {
|
|
16867
16865
|
const found = /* @__PURE__ */ new Map();
|
|
16868
16866
|
if (!refs.length) return found;
|
|
@@ -16873,7 +16871,7 @@ function mapSearchFocus(store, version2, refs, scope, signal) {
|
|
|
16873
16871
|
throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
|
|
16874
16872
|
for (const ref of refs) found.set(ref, { distance: 0, score: 1800 });
|
|
16875
16873
|
let frontier = new Set(refs);
|
|
16876
|
-
const edges = store.database.prepare(`SELECT r.from_ref, r.to_ref,
|
|
16874
|
+
const edges = store.database.prepare(`SELECT r.from_ref, r.to_ref, r.path,
|
|
16877
16875
|
json_extract(r.relation_json, '$.kind') AS kind
|
|
16878
16876
|
FROM project_map_relations r
|
|
16879
16877
|
JOIN project_map_objects f ON f.version_ref = r.version_ref AND f.entity_ref = r.from_ref
|
|
@@ -16893,7 +16891,8 @@ function mapSearchFocus(store, version2, refs, scope, signal) {
|
|
|
16893
16891
|
assertMapSearchActive(signal);
|
|
16894
16892
|
const from = String(row.from_ref);
|
|
16895
16893
|
const to = String(row.to_ref);
|
|
16896
|
-
const
|
|
16894
|
+
const kind = String(row.kind);
|
|
16895
|
+
const weight = kind === "IMPORTS" && mapTestPath(String(row.path)) ? TEST_IMPORT_WEIGHT : relationWeight[kind];
|
|
16897
16896
|
if (weight === void 0)
|
|
16898
16897
|
throw new ProjectEvidenceError("PROJECT_EVIDENCE_STORE_CORRUPT", false);
|
|
16899
16898
|
for (const [parent, neighbor] of [
|
|
@@ -17306,6 +17305,36 @@ function mapPageFrontier(frontier, rows2) {
|
|
|
17306
17305
|
return frontier.filter(({ entityRef }) => visible.has(entityRef)).map((node) => ({ ...node }));
|
|
17307
17306
|
}
|
|
17308
17307
|
|
|
17308
|
+
// src/project-map-imports.ts
|
|
17309
|
+
function loadMapImports(store, version2) {
|
|
17310
|
+
return store.database.prepare(`SELECT DISTINCT r.path AS source, t.path AS target,
|
|
17311
|
+
json_extract(r.relation_json, '$.anchor.startLine') AS line,
|
|
17312
|
+
json_extract(r.relation_json, '$.target') AS specifier,
|
|
17313
|
+
json_extract(r.relation_json, '$.unresolvedReason') AS reason
|
|
17314
|
+
FROM project_map_relations r NOT INDEXED
|
|
17315
|
+
${MAP_RELATION_TARGET_JOIN}
|
|
17316
|
+
WHERE r.version_ref = ? AND json_extract(r.relation_json, '$.kind') = 'IMPORTS'
|
|
17317
|
+
ORDER BY source, line, target, specifier`).all(version2).map((row) => {
|
|
17318
|
+
const site = {
|
|
17319
|
+
source: String(row.source),
|
|
17320
|
+
line: Number(row.line),
|
|
17321
|
+
specifier: String(row.specifier)
|
|
17322
|
+
};
|
|
17323
|
+
return row.target === null ? { ...site, target: null, reason: String(row.reason) } : { ...site, target: String(row.target) };
|
|
17324
|
+
});
|
|
17325
|
+
}
|
|
17326
|
+
function mapProjectImports(rows2) {
|
|
17327
|
+
const imports = [];
|
|
17328
|
+
const unresolved = [];
|
|
17329
|
+
for (const row of rows2) {
|
|
17330
|
+
if (mapTestPath(row.source)) continue;
|
|
17331
|
+
const { source: from, line, specifier } = row;
|
|
17332
|
+
if (row.target === null) unresolved.push({ from, line, specifier, reason: row.reason });
|
|
17333
|
+
else if (row.target !== from) imports.push({ from, line, to: row.target, specifier });
|
|
17334
|
+
}
|
|
17335
|
+
return { imports, unresolved };
|
|
17336
|
+
}
|
|
17337
|
+
|
|
17309
17338
|
// src/project-map-language-go.ts
|
|
17310
17339
|
import { existsSync as existsSync4 } from "node:fs";
|
|
17311
17340
|
import { posix } from "node:path";
|
|
@@ -18113,7 +18142,7 @@ var goModule = /(?:^|\/)go\.mod$/u;
|
|
|
18113
18142
|
var goWork = /(?:^|\/)go\.work$/u;
|
|
18114
18143
|
var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
|
|
18115
18144
|
var GO_MAP_LANGUAGE = Object.freeze({
|
|
18116
|
-
id: "go-1.24-map-
|
|
18145
|
+
id: "go-1.24-map-v11",
|
|
18117
18146
|
claims: (path19) => path19.endsWith(".go"),
|
|
18118
18147
|
reads: (path19) => goModule.test(path19) || goWork.test(path19),
|
|
18119
18148
|
// A module path, or the standard library, whose first path element has no dot.
|
|
@@ -18326,7 +18355,7 @@ var nameOf = (path19) => path19.slice(path19.lastIndexOf("/") + 1);
|
|
|
18326
18355
|
var DEFAULT_RELEASE = 21;
|
|
18327
18356
|
var platformPackage = /^(?:java|jdk|sun|com\.sun|javax\.(?:annotation\.processing|crypto|imageio|lang\.model|management|naming|net|print|script|security|sound|sql|swing|tools|transaction\.xa|xml))(?:\.|$)/u;
|
|
18328
18357
|
var JAVA_MAP_LANGUAGE = Object.freeze({
|
|
18329
|
-
id: "javac-lombok-1.18.48-map-
|
|
18358
|
+
id: "javac-lombok-1.18.48-map-v10",
|
|
18330
18359
|
claims: (path19) => path19.endsWith(".java"),
|
|
18331
18360
|
reads: (path19) => buildFile.test(path19),
|
|
18332
18361
|
// A package of the Java platform, or a library named by its first two package segments.
|
|
@@ -18415,15 +18444,14 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18415
18444
|
observe?.({ ...event, phase: "FINISHED", elapsedMs: performance.now() - start });
|
|
18416
18445
|
}
|
|
18417
18446
|
}
|
|
18418
|
-
// The worker's request for a context: the Java sources
|
|
18447
|
+
// The worker's request for a context: the Java sources and the release.
|
|
18419
18448
|
request(input, buildTexts) {
|
|
18420
18449
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18421
18450
|
for (const [path19, text] of Object.entries(input.files))
|
|
18422
18451
|
if (this.claims(path19)) files[path19] = text;
|
|
18423
18452
|
return {
|
|
18424
18453
|
files,
|
|
18425
|
-
release: javaRelease(buildTexts, this.resources.runtimeVersion)
|
|
18426
|
-
tests: Object.keys(files).filter((path19) => mapTestPath(path19))
|
|
18454
|
+
release: javaRelease(buildTexts, this.resources.runtimeVersion)
|
|
18427
18455
|
};
|
|
18428
18456
|
}
|
|
18429
18457
|
// The build files of a context's root directory, which declare its Java version.
|
|
@@ -18507,7 +18535,6 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18507
18535
|
{
|
|
18508
18536
|
configPath: configPath || null,
|
|
18509
18537
|
release: request.release,
|
|
18510
|
-
tests: request.tests,
|
|
18511
18538
|
runtime,
|
|
18512
18539
|
built: existsSync5(this.resources.compilerPath),
|
|
18513
18540
|
lombokConfig
|
|
@@ -18881,7 +18908,7 @@ var pythonConfig = /(?:^|\/)(?:pyrightconfig\.json|pyproject\.toml|setup\.cfg)$/
|
|
|
18881
18908
|
var directoryOf2 = (path19) => path19.slice(0, path19.lastIndexOf("/") + 1);
|
|
18882
18909
|
var DEFAULT_PYTHON = { major: 3, minor: 13 };
|
|
18883
18910
|
var PYTHON_MAP_LANGUAGE = Object.freeze({
|
|
18884
|
-
id: "pyright-1.1.414-map-
|
|
18911
|
+
id: "pyright-1.1.414-map-v14",
|
|
18885
18912
|
claims: (path19) => /\.pyi?$/u.test(path19),
|
|
18886
18913
|
reads: (path19) => pythonConfig.test(path19),
|
|
18887
18914
|
// An absolute import names the standard library or a distribution's top-level package.
|
|
@@ -18934,8 +18961,7 @@ var PythonMapAnalyzer = class {
|
|
|
18934
18961
|
request(input) {
|
|
18935
18962
|
return {
|
|
18936
18963
|
root: input.configPath ? directoryOf2(input.configPath).replace(/\/$/u, "") : "",
|
|
18937
|
-
pythonVersion: pythonVersion(input.files, input.configPath)
|
|
18938
|
-
tests: Object.keys(input.files).filter((path19) => this.claims(path19) && mapTestPath(path19))
|
|
18964
|
+
pythonVersion: pythonVersion(input.files, input.configPath)
|
|
18939
18965
|
};
|
|
18940
18966
|
}
|
|
18941
18967
|
async analyze(session, signal) {
|
|
@@ -19071,7 +19097,7 @@ var miniprogramEventOf = (target) => {
|
|
|
19071
19097
|
|
|
19072
19098
|
// src/project-map-language-typescript.ts
|
|
19073
19099
|
var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
19074
|
-
id: "typescript-7.0.2-map-
|
|
19100
|
+
id: "typescript-7.0.2-map-v34",
|
|
19075
19101
|
claims: (path19) => /\.[cm]?[jt]sx?$/u.test(path19),
|
|
19076
19102
|
readsRequests: true,
|
|
19077
19103
|
reads: (path19) => path19.endsWith(".json") || path19.endsWith(".wxml") || path19 === "pnpm-workspace.yaml",
|
|
@@ -19224,7 +19250,8 @@ var TypeScriptMapAnalyzer = class {
|
|
|
19224
19250
|
contextRef,
|
|
19225
19251
|
// What the context is. What it read is the previous analysis's input files, which
|
|
19226
19252
|
// replaying requires to be unchanged; the files given to it may be more than it reads,
|
|
19227
|
-
// since discovery
|
|
19253
|
+
// since discovery's inferred project also holds the files it moves to the tsconfig that
|
|
19254
|
+
// holds them, as a tsconfig.test.json holds the tests.
|
|
19228
19255
|
request: {
|
|
19229
19256
|
configPath: configPath ?? null,
|
|
19230
19257
|
rootFiles: rootFiles ?? null,
|
|
@@ -19574,19 +19601,6 @@ function mapProjectModules(entries) {
|
|
|
19574
19601
|
return module && moduleLabel(module);
|
|
19575
19602
|
};
|
|
19576
19603
|
}
|
|
19577
|
-
function loadImports(store, version2) {
|
|
19578
|
-
return store.database.prepare(`SELECT r.path AS source, t.path AS target,
|
|
19579
|
-
json_extract(r.relation_json, '$.target') AS specifier, count(*) AS count
|
|
19580
|
-
FROM project_map_relations r NOT INDEXED
|
|
19581
|
-
${MAP_RELATION_TARGET_JOIN}
|
|
19582
|
-
WHERE r.version_ref = ? AND json_extract(r.relation_json, '$.kind') IN ('IMPORTS', 'TEST_IMPORTS')
|
|
19583
|
-
GROUP BY source, target, specifier`).all(version2).map((row) => ({
|
|
19584
|
-
source: String(row.source),
|
|
19585
|
-
target: row.target === null ? null : String(row.target),
|
|
19586
|
-
specifier: String(row.specifier),
|
|
19587
|
-
count: Number(row.count)
|
|
19588
|
-
}));
|
|
19589
|
-
}
|
|
19590
19604
|
function loadDirectoryFacts(store, version2) {
|
|
19591
19605
|
const files = /* @__PURE__ */ new Map();
|
|
19592
19606
|
const declarations2 = [];
|
|
@@ -19655,7 +19669,6 @@ function loadDirectoryFacts(store, version2) {
|
|
|
19655
19669
|
]);
|
|
19656
19670
|
}
|
|
19657
19671
|
for (const list of exported.values()) list.sort((left, right) => left.start - right.start);
|
|
19658
|
-
const imports = loadImports(store, version2);
|
|
19659
19672
|
const calls = /* @__PURE__ */ new Map();
|
|
19660
19673
|
for (const row of store.database.prepare(`SELECT path, count(*) AS total, sum(to_ref IS NOT NULL) AS resolved,
|
|
19661
19674
|
sum(to_ref IS NULL AND json_extract(relation_json, '$.unresolvedReason')
|
|
@@ -19671,7 +19684,7 @@ function loadDirectoryFacts(store, version2) {
|
|
|
19671
19684
|
unresolved: Number(row.total) - resolved - external
|
|
19672
19685
|
});
|
|
19673
19686
|
}
|
|
19674
|
-
return { files, calls, exported
|
|
19687
|
+
return { files, calls, exported };
|
|
19675
19688
|
}
|
|
19676
19689
|
var MEMBER_NAME = /\.([A-Za-z_$][\w$]*)$/u;
|
|
19677
19690
|
var memberKey = (language, name) => `${language}\0${name}`;
|
|
@@ -19763,7 +19776,7 @@ function loadCoverageNotes(store, version2) {
|
|
|
19763
19776
|
}
|
|
19764
19777
|
var MapViewCache = class {
|
|
19765
19778
|
facts = new VersionCache(loadDirectoryFacts);
|
|
19766
|
-
importRows = new VersionCache(
|
|
19779
|
+
importRows = new VersionCache(loadMapImports);
|
|
19767
19780
|
calls = new VersionCache(loadMemberCalls);
|
|
19768
19781
|
coverage = new VersionCache(loadCoverageNotes);
|
|
19769
19782
|
directoryFacts(store, version2) {
|
|
@@ -19785,7 +19798,7 @@ var MapViewCache = class {
|
|
|
19785
19798
|
this.coverage.clear();
|
|
19786
19799
|
}
|
|
19787
19800
|
};
|
|
19788
|
-
function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
19801
|
+
function directoryView(facts, imports, coverage, entries, input, directory, prefixes) {
|
|
19789
19802
|
const showTests = input.includeTests === true || mapTestPath(`${directory}/`);
|
|
19790
19803
|
const inScope = entries.filter(
|
|
19791
19804
|
(entry) => within(entry.path, directory) && mapPathAllowed(entry.path, prefixes)
|
|
@@ -19804,20 +19817,19 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19804
19817
|
const moduleImports = /* @__PURE__ */ new Map();
|
|
19805
19818
|
const external = /* @__PURE__ */ new Map();
|
|
19806
19819
|
let unresolvedLocal = 0;
|
|
19807
|
-
for (const
|
|
19808
|
-
const { source, target, specifier, count } = row;
|
|
19820
|
+
for (const { source, target, specifier } of imports) {
|
|
19809
19821
|
const from = visiblePaths.has(source) ? moduleOf(source) : void 0;
|
|
19810
19822
|
if (!from) continue;
|
|
19811
19823
|
if (target === null) {
|
|
19812
|
-
if (specifier.startsWith(".") || specifier.startsWith("/")) unresolvedLocal
|
|
19813
|
-
else increment(external, mapExternalImport(source, specifier)
|
|
19824
|
+
if (specifier.startsWith(".") || specifier.startsWith("/")) unresolvedLocal++;
|
|
19825
|
+
else increment(external, mapExternalImport(source, specifier));
|
|
19814
19826
|
continue;
|
|
19815
19827
|
}
|
|
19816
19828
|
if (!mapPathAllowed(target, prefixes) || !showTests && mapTestPath(target)) continue;
|
|
19817
19829
|
const to = within(target, directory) ? moduleOf(target) : void 0;
|
|
19818
19830
|
if (to === from) continue;
|
|
19819
19831
|
const edges = moduleImports.get(moduleLabel(from)) ?? /* @__PURE__ */ new Map();
|
|
19820
|
-
increment(edges, to ? moduleLabel(to) : outside(target)
|
|
19832
|
+
increment(edges, to ? moduleLabel(to) : outside(target));
|
|
19821
19833
|
moduleImports.set(moduleLabel(from), edges);
|
|
19822
19834
|
}
|
|
19823
19835
|
const blocks = [];
|
|
@@ -19973,8 +19985,7 @@ var OUTGOING = {
|
|
|
19973
19985
|
CALLS: "calls",
|
|
19974
19986
|
REFERENCES: "uses as value",
|
|
19975
19987
|
WRITES: "writes",
|
|
19976
|
-
IMPORTS: "imports"
|
|
19977
|
-
TEST_IMPORTS: "test imports"
|
|
19988
|
+
IMPORTS: "imports"
|
|
19978
19989
|
};
|
|
19979
19990
|
var INCOMING = {
|
|
19980
19991
|
CALLS: "called by",
|
|
@@ -19984,7 +19995,6 @@ var INCOMING = {
|
|
|
19984
19995
|
IMPLEMENTS: "implemented by",
|
|
19985
19996
|
DECORATED_BY: "decorates"
|
|
19986
19997
|
};
|
|
19987
|
-
var IMPORT_KINDS = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
19988
19998
|
var shows = (relation) => relation.kind === "REFERENCES" && mapMiniprogramTemplate(relation.anchor.path);
|
|
19989
19999
|
var callerCoverage = (textSearch) => `Calls through dependency injection, framework routing, reflection or computed names are not mapped, so a complete view is not a complete caller list; confirm impact with project_find_references or ${textSearch}.`;
|
|
19990
20000
|
var SPECIAL_METHOD = /^__\w+__$/u;
|
|
@@ -20085,7 +20095,7 @@ var DeclarationGroups = class {
|
|
|
20085
20095
|
stops.set(key, value);
|
|
20086
20096
|
if (relation.to === void 0) continue;
|
|
20087
20097
|
}
|
|
20088
|
-
if (
|
|
20098
|
+
if (relation.kind === "IMPORTS" && mapIsModule(graph.object(relation.from))) continue;
|
|
20089
20099
|
if (relation.to === void 0) {
|
|
20090
20100
|
if (relation.kind === "DECORATED_BY")
|
|
20091
20101
|
tags.push(decoratorTag(relation.target, relation.argument, relation.route));
|
|
@@ -20115,7 +20125,7 @@ var DeclarationGroups = class {
|
|
|
20115
20125
|
else
|
|
20116
20126
|
add(
|
|
20117
20127
|
"\u2192",
|
|
20118
|
-
relation.event ? `calls via ${relation.event} event` : shows(relation) ? "shows" : OUTGOING[relation.kind] ?? relation.kind.toLowerCase(),
|
|
20128
|
+
relation.event ? `calls via ${relation.event} event` : shows(relation) ? "shows" : relation.kind === "IMPORTS" && mapTestPath(relation.anchor.path) ? "test imports" : OUTGOING[relation.kind] ?? relation.kind.toLowerCase(),
|
|
20119
20129
|
other,
|
|
20120
20130
|
relation.anchor.startLine,
|
|
20121
20131
|
relation.argument
|
|
@@ -20133,7 +20143,7 @@ var DeclarationGroups = class {
|
|
|
20133
20143
|
);
|
|
20134
20144
|
continue;
|
|
20135
20145
|
}
|
|
20136
|
-
if (!incoming || relation.kind === "CONTAINS" ||
|
|
20146
|
+
if (!incoming || relation.kind === "CONTAINS" || relation.kind === "IMPORTS") continue;
|
|
20137
20147
|
const other = graph.object(graph.owner(relation.from));
|
|
20138
20148
|
if (owned.has(other.id)) continue;
|
|
20139
20149
|
if (!this.visible(relation.anchor.path)) {
|
|
@@ -20306,7 +20316,7 @@ function fileView(store, coverage, graph, input, path19, prefixes) {
|
|
|
20306
20316
|
const external = /* @__PURE__ */ new Set();
|
|
20307
20317
|
const fileObjects = graph.objectsAt(path19).map((object2) => object2.id);
|
|
20308
20318
|
for (const relation of graph.relationsFrom(fileObjects)) {
|
|
20309
|
-
if (
|
|
20319
|
+
if (relation.kind !== "IMPORTS") continue;
|
|
20310
20320
|
if (relation.to === void 0) external.add(relation.target);
|
|
20311
20321
|
else {
|
|
20312
20322
|
const target = graph.object(relation.to).anchor.path;
|
|
@@ -20318,7 +20328,7 @@ function fileView(store, coverage, graph, input, path19, prefixes) {
|
|
|
20318
20328
|
const imported = mapImportTarget(path19);
|
|
20319
20329
|
const packageModules = imported === path19 ? [module.id] : store.listEntries(input.version).filter((entry2) => mapImportTarget(entry2.path) === imported).flatMap((entry2) => graph.objectsAt(entry2.path).filter((object2) => mapIsModule(object2))).map((object2) => object2.id);
|
|
20320
20330
|
for (const relation of graph.relationsTo(packageModules)) {
|
|
20321
|
-
if (
|
|
20331
|
+
if (relation.kind !== "IMPORTS") continue;
|
|
20322
20332
|
const source = relation.anchor.path;
|
|
20323
20333
|
if (!mapPathAllowed(source, prefixes)) continue;
|
|
20324
20334
|
(!showTests && mapTestPath(source) ? testImporters : importers).add(source);
|
|
@@ -20424,6 +20434,7 @@ function mapView(store, input, cache = new MapViewCache()) {
|
|
|
20424
20434
|
const coverage = cache.coverageNotes(store, input.version);
|
|
20425
20435
|
return entry ? fileView(store, coverage, graph, input, input.path, prefixes) : directoryView(
|
|
20426
20436
|
cache.directoryFacts(store, input.version),
|
|
20437
|
+
cache.imports(store, input.version),
|
|
20427
20438
|
coverage,
|
|
20428
20439
|
store.listEntries(input.version),
|
|
20429
20440
|
input,
|
|
@@ -23279,7 +23290,6 @@ var USED_BY = {
|
|
|
23279
23290
|
OVERRIDES: "overridden"
|
|
23280
23291
|
};
|
|
23281
23292
|
var runsTarget = (relation) => CALLER_KINDS.has(relation.kind) && !relation.event;
|
|
23282
|
-
var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
23283
23293
|
var changeUnits = (graph, path19) => mapMiniprogramTemplate(path19) ? graph.objectsAt(path19).filter((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : graph.declarationsAt(path19);
|
|
23284
23294
|
function changedUnits(graph, path19, lines) {
|
|
23285
23295
|
const refs = /* @__PURE__ */ new Set();
|
|
@@ -23862,7 +23872,7 @@ function linksOf(side, path19) {
|
|
|
23862
23872
|
for (const relation of graph.relationsFrom(graph.objectsAt(path19).map((object2) => object2.id))) {
|
|
23863
23873
|
const line = relation.anchor.startLine;
|
|
23864
23874
|
if (relation.to === void 0 || !side.counts(path19, line)) continue;
|
|
23865
|
-
if (
|
|
23875
|
+
if (relation.kind === "IMPORTS") {
|
|
23866
23876
|
const target = graph.object(relation.to).anchor.path;
|
|
23867
23877
|
if (target === path19) continue;
|
|
23868
23878
|
const to = side.pathNow(target);
|
|
@@ -24105,7 +24115,7 @@ function importerTests(graph, objects2, tracer, importers) {
|
|
|
24105
24115
|
const unread = modules.filter((module) => !importers.has(module));
|
|
24106
24116
|
for (const module of unread) importers.set(module, []);
|
|
24107
24117
|
for (const relation of graph.relationsTo(unread)) {
|
|
24108
|
-
if (
|
|
24118
|
+
if (relation.kind !== "IMPORTS" || !relation.to) continue;
|
|
24109
24119
|
const importer = graph.object(relation.from);
|
|
24110
24120
|
importers.get(relation.to)?.push({
|
|
24111
24121
|
path: relation.anchor.path,
|
|
@@ -25204,10 +25214,9 @@ async function similarCode(store, working, base, files, read) {
|
|
|
25204
25214
|
}
|
|
25205
25215
|
|
|
25206
25216
|
// src/project-map-changes.ts
|
|
25207
|
-
async function mapChangeImpact(store, working, base, changes, links, shapes, until, project, tests) {
|
|
25217
|
+
async function mapChangeImpact(store, views, working, base, changes, links, shapes, until, project, tests) {
|
|
25208
25218
|
const graph = new MapViewGraph(store, working);
|
|
25209
|
-
const
|
|
25210
|
-
const memberCalls = cache.memberCalls(store, working);
|
|
25219
|
+
const memberCalls = views.memberCalls(store, working);
|
|
25211
25220
|
const tracer = new Tracer(
|
|
25212
25221
|
graph,
|
|
25213
25222
|
memberCalls,
|
|
@@ -25349,7 +25358,7 @@ async function mapChangeImpact(store, working, base, changes, links, shapes, unt
|
|
|
25349
25358
|
supportTests(store, working, tracer);
|
|
25350
25359
|
const taken = base ? await mapRemovedImpact({
|
|
25351
25360
|
store,
|
|
25352
|
-
cache,
|
|
25361
|
+
cache: views,
|
|
25353
25362
|
base,
|
|
25354
25363
|
graph,
|
|
25355
25364
|
tracer,
|
|
@@ -25389,7 +25398,7 @@ async function mapChangeImpact(store, working, base, changes, links, shapes, unt
|
|
|
25389
25398
|
unmapped,
|
|
25390
25399
|
removedRoutes: taken?.removedRoutes ?? [],
|
|
25391
25400
|
uncalled: taken?.uncalled ?? [],
|
|
25392
|
-
dependencies: newModuleDependencies(store,
|
|
25401
|
+
dependencies: newModuleDependencies(store, views, working, changes.files, links.files),
|
|
25393
25402
|
...untested ? { untested } : {},
|
|
25394
25403
|
truncated: tracer.truncated
|
|
25395
25404
|
};
|
|
@@ -25502,8 +25511,10 @@ async function checkMapChanges(input, signal) {
|
|
|
25502
25511
|
};
|
|
25503
25512
|
const until = mapShapeDeadline();
|
|
25504
25513
|
const links = mapChangeLinks(index.store, working, base, changes.files);
|
|
25514
|
+
const views = new MapViewCache();
|
|
25505
25515
|
const impact = await mapChangeImpact(
|
|
25506
25516
|
index.store,
|
|
25517
|
+
views,
|
|
25507
25518
|
working,
|
|
25508
25519
|
base,
|
|
25509
25520
|
changes,
|
|
@@ -25526,6 +25537,7 @@ async function checkMapChanges(input, signal) {
|
|
|
25526
25537
|
await mapRouteClients(project, index.store, working, impact, signal),
|
|
25527
25538
|
reusable(
|
|
25528
25539
|
index.store,
|
|
25540
|
+
views,
|
|
25529
25541
|
working,
|
|
25530
25542
|
await similarCode(
|
|
25531
25543
|
index.store,
|
|
@@ -25535,13 +25547,13 @@ async function checkMapChanges(input, signal) {
|
|
|
25535
25547
|
(file2) => readFile3(path13.join(project, file2), "utf8").catch(() => void 0)
|
|
25536
25548
|
)
|
|
25537
25549
|
),
|
|
25538
|
-
changes.files.length ? await compileBreaks(input, changes, base, until, signal) : void 0
|
|
25550
|
+
changes.files.length ? await compileBreaks(input, views, changes, base, until, signal) : void 0
|
|
25539
25551
|
)
|
|
25540
25552
|
};
|
|
25541
25553
|
}
|
|
25542
|
-
function reusable(store, working, similar) {
|
|
25554
|
+
function reusable(store, views, working, similar) {
|
|
25543
25555
|
if (!similar.length) return [];
|
|
25544
|
-
const importsFor = mapReuseImports(store,
|
|
25556
|
+
const importsFor = mapReuseImports(store, views, working);
|
|
25545
25557
|
return similar.flatMap((item) => {
|
|
25546
25558
|
const imports = importsFor(item.path, item.like.path);
|
|
25547
25559
|
return imports ? [{ ...item, imports }] : [];
|
|
@@ -25563,7 +25575,7 @@ async function mapRouteClients(project, store, working, impact, signal) {
|
|
|
25563
25575
|
if (!routes.length) return { routes: [] };
|
|
25564
25576
|
return routeClients(routes, registrations, git, gitOptions(project, signal));
|
|
25565
25577
|
}
|
|
25566
|
-
async function compileBreaks(input, changes, base, until, signal) {
|
|
25578
|
+
async function compileBreaks(input, views, changes, base, until, signal) {
|
|
25567
25579
|
const { index, working } = input;
|
|
25568
25580
|
const present = changes.files.filter((file2) => file2.status !== "DELETED").map((file2) => file2.path);
|
|
25569
25581
|
const gone2 = changes.files.flatMap((file2) => file2.basePath ? [file2.basePath] : []);
|
|
@@ -25582,7 +25594,6 @@ async function compileBreaks(input, changes, base, until, signal) {
|
|
|
25582
25594
|
signal
|
|
25583
25595
|
);
|
|
25584
25596
|
const missing = new Set(after.contexts.flatMap((context) => context.missing));
|
|
25585
|
-
const views = new MapViewCache();
|
|
25586
25597
|
const { notInstalled } = views.coverageNotes(index.store, working);
|
|
25587
25598
|
if (notInstalled.length) {
|
|
25588
25599
|
for (const { source, target, specifier } of views.imports(index.store, working))
|
|
@@ -25991,6 +26002,12 @@ var LayerMap = class _LayerMap {
|
|
|
25991
26002
|
)
|
|
25992
26003
|
);
|
|
25993
26004
|
}
|
|
26005
|
+
/** Every import of the directory as it is now, by file of the project, test files apart. */
|
|
26006
|
+
imports(signal) {
|
|
26007
|
+
return this.using(
|
|
26008
|
+
async (hold) => mapProjectImports(loadMapImports(this.store, await this.current(signal, hold)))
|
|
26009
|
+
);
|
|
26010
|
+
}
|
|
25994
26011
|
/**
|
|
25995
26012
|
* What the working tree's changes against a commit (HEAD by default) affect: the changed and
|
|
25996
26013
|
* removed declarations, the entry points and tests their callers reach, and what the map cannot
|
|
@@ -27001,6 +27018,9 @@ Usage:
|
|
|
27001
27018
|
and what of them the test files given do not run; --json
|
|
27002
27019
|
prints the related tests by rank and what the map cannot
|
|
27003
27020
|
follow, for a program choosing which tests to run
|
|
27021
|
+
layermap imports [--json] every import of the project as it is now, test files
|
|
27022
|
+
apart: the file and line importing, the file imported,
|
|
27023
|
+
and the imports with no file of the project, with why
|
|
27004
27024
|
|
|
27005
27025
|
The project is the Git work tree around the current directory unless --project names one; the MCP
|
|
27006
27026
|
server also maps any other repository a tool call's path names.
|
|
@@ -27055,7 +27075,7 @@ async function main(argv) {
|
|
|
27055
27075
|
return 0;
|
|
27056
27076
|
}
|
|
27057
27077
|
if (values.help || !command) return usage(command ? 0 : 1);
|
|
27058
|
-
if (values.json && command !== "check") return usage(1);
|
|
27078
|
+
if (values.json && command !== "check" && command !== "imports") return usage(1);
|
|
27059
27079
|
const { directory: project, git: git2 } = await projectDirectory(values.project ?? process.cwd());
|
|
27060
27080
|
const cache = cacheDirectory();
|
|
27061
27081
|
const open3 = async (directory) => {
|
|
@@ -27111,6 +27131,22 @@ async function main(argv) {
|
|
|
27111
27131
|
`);
|
|
27112
27132
|
return 0;
|
|
27113
27133
|
}
|
|
27134
|
+
if (command === "imports") {
|
|
27135
|
+
const imports = await map2.imports(signal);
|
|
27136
|
+
process.stdout.write(
|
|
27137
|
+
values.json ? `${JSON.stringify(imports)}
|
|
27138
|
+
` : [
|
|
27139
|
+
`IMPORTS (${imports.imports.length})`,
|
|
27140
|
+
...imports.imports.map((item) => `${item.from}:${item.line} \u2192 ${item.to}`),
|
|
27141
|
+
`UNRESOLVED IMPORTS (${imports.unresolved.length})`,
|
|
27142
|
+
...imports.unresolved.map(
|
|
27143
|
+
(item) => `${item.from}:${item.line} ${item.specifier} ${item.reason}`
|
|
27144
|
+
),
|
|
27145
|
+
""
|
|
27146
|
+
].join("\n")
|
|
27147
|
+
);
|
|
27148
|
+
return 0;
|
|
27149
|
+
}
|
|
27114
27150
|
const call = {
|
|
27115
27151
|
explore: [
|
|
27116
27152
|
MAP_TOOL_NAMES.explore,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
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.48");
|
|
297
297
|
for (const tool of tools) {
|
|
298
298
|
if (registered.has(tool.name)) continue;
|
|
299
299
|
registered.add(tool.name);
|