layermap 0.1.44 → 0.1.46
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 -1
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/analyzers/project-map-worker.mjs +25 -2
- package/dist/cli.mjs +219 -54
- package/package.json +1 -1
- package/pi/layermap.mjs +1 -1
package/README.md
CHANGED
|
@@ -225,7 +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
|
|
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
229
|
```
|
|
230
230
|
|
|
231
231
|
## FAQ
|
|
Binary file
|
|
@@ -4896,6 +4896,9 @@ function isImportDeclaration(node) {
|
|
|
4896
4896
|
return false;
|
|
4897
4897
|
}
|
|
4898
4898
|
}
|
|
4899
|
+
function isExternalModuleReference(node) {
|
|
4900
|
+
return node.kind === SyntaxKind.ExternalModuleReference;
|
|
4901
|
+
}
|
|
4899
4902
|
function isNamespaceImport(node) {
|
|
4900
4903
|
return node.kind === SyntaxKind.NamespaceImport;
|
|
4901
4904
|
}
|
|
@@ -4995,6 +4998,12 @@ function isJsxClosingElement(node) {
|
|
|
4995
4998
|
function isSourceFile(node) {
|
|
4996
4999
|
return node.kind === SyntaxKind.SourceFile;
|
|
4997
5000
|
}
|
|
5001
|
+
function isImportEqualsDeclaration(node) {
|
|
5002
|
+
return node.kind === SyntaxKind.ImportEqualsDeclaration;
|
|
5003
|
+
}
|
|
5004
|
+
function isExportDeclaration(node) {
|
|
5005
|
+
return node.kind === SyntaxKind.ExportDeclaration;
|
|
5006
|
+
}
|
|
4998
5007
|
function isImportClause(node) {
|
|
4999
5008
|
return node.kind === SyntaxKind.ImportClause;
|
|
5000
5009
|
}
|
|
@@ -30827,7 +30836,13 @@ function mapRequireBinding(node) {
|
|
|
30827
30836
|
if (!isVariableDeclaration(node) || !node.initializer) return false;
|
|
30828
30837
|
let value = unwrap(node.initializer);
|
|
30829
30838
|
while (isPropertyAccessExpression(value)) value = unwrap(value.expression);
|
|
30830
|
-
return
|
|
30839
|
+
return mapRequiredModule(value) !== void 0;
|
|
30840
|
+
}
|
|
30841
|
+
function mapRequiredModule(node) {
|
|
30842
|
+
if (!isCallExpression(node) || !isIdentifier(node.expression) || node.expression.text !== "require" || node.arguments.length !== 1)
|
|
30843
|
+
return void 0;
|
|
30844
|
+
const name = node.arguments[0];
|
|
30845
|
+
return isStringLiteral(name) ? name : void 0;
|
|
30831
30846
|
}
|
|
30832
30847
|
var unwrap = (node) => isParenthesizedExpression(node) || isAsExpression(node) ? unwrap(node.expression) : node;
|
|
30833
30848
|
var isExports = (node) => isIdentifier(node) && node.text === "exports" || isPropertyAccessExpression(node) && isIdentifier(node.expression) && node.expression.text === "module" && node.name.text === "exports";
|
|
@@ -31994,6 +32009,14 @@ var NOT_STATE_READS = /* @__PURE__ */ new Set([
|
|
|
31994
32009
|
SyntaxKind.JsxSelfClosingElement,
|
|
31995
32010
|
SyntaxKind.JsxClosingElement
|
|
31996
32011
|
]);
|
|
32012
|
+
function importedModule(node) {
|
|
32013
|
+
if (isImportDeclaration(node) || isExportDeclaration(node)) return node.moduleSpecifier;
|
|
32014
|
+
if (isImportEqualsDeclaration(node))
|
|
32015
|
+
return isExternalModuleReference(node.moduleReference) ? node.moduleReference.expression : void 0;
|
|
32016
|
+
if (isCallExpression(node) && node.expression.kind === SyntaxKind.ImportKeyword)
|
|
32017
|
+
return node.arguments[0];
|
|
32018
|
+
return mapRequiredModule(node);
|
|
32019
|
+
}
|
|
31997
32020
|
function moduleStateNames(file2) {
|
|
31998
32021
|
const names = /* @__PURE__ */ new Set();
|
|
31999
32022
|
const namespaces = /* @__PURE__ */ new Set();
|
|
@@ -32197,7 +32220,7 @@ async function extractProjectMap(project, input, trace, read, installed) {
|
|
|
32197
32220
|
truncated: false
|
|
32198
32221
|
});
|
|
32199
32222
|
let reference;
|
|
32200
|
-
const moduleSpecifier =
|
|
32223
|
+
const moduleSpecifier = importedModule(node);
|
|
32201
32224
|
if (moduleSpecifier && (isStringLiteral(moduleSpecifier) || isNoSubstitutionTemplateLiteral(moduleSpecifier))) {
|
|
32202
32225
|
reference = {
|
|
32203
32226
|
node,
|
package/dist/cli.mjs
CHANGED
|
@@ -19071,7 +19071,7 @@ var miniprogramEventOf = (target) => {
|
|
|
19071
19071
|
|
|
19072
19072
|
// src/project-map-language-typescript.ts
|
|
19073
19073
|
var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
19074
|
-
id: "typescript-7.0.2-map-
|
|
19074
|
+
id: "typescript-7.0.2-map-v32",
|
|
19075
19075
|
claims: (path19) => /\.[cm]?[jt]sx?$/u.test(path19),
|
|
19076
19076
|
readsRequests: true,
|
|
19077
19077
|
reads: (path19) => path19.endsWith(".json") || path19.endsWith(".wxml") || path19 === "pnpm-workspace.yaml",
|
|
@@ -19655,7 +19655,7 @@ function loadDirectoryFacts(store, version2) {
|
|
|
19655
19655
|
]);
|
|
19656
19656
|
}
|
|
19657
19657
|
for (const list of exported.values()) list.sort((left, right) => left.start - right.start);
|
|
19658
|
-
const
|
|
19658
|
+
const imports = loadImports(store, version2);
|
|
19659
19659
|
const calls = /* @__PURE__ */ new Map();
|
|
19660
19660
|
for (const row of store.database.prepare(`SELECT path, count(*) AS total, sum(to_ref IS NOT NULL) AS resolved,
|
|
19661
19661
|
sum(to_ref IS NULL AND json_extract(relation_json, '$.unresolvedReason')
|
|
@@ -19671,7 +19671,7 @@ function loadDirectoryFacts(store, version2) {
|
|
|
19671
19671
|
unresolved: Number(row.total) - resolved - external
|
|
19672
19672
|
});
|
|
19673
19673
|
}
|
|
19674
|
-
return { files, calls, exported, imports
|
|
19674
|
+
return { files, calls, exported, imports };
|
|
19675
19675
|
}
|
|
19676
19676
|
var MEMBER_NAME = /\.([A-Za-z_$][\w$]*)$/u;
|
|
19677
19677
|
var memberKey = (language, name) => `${language}\0${name}`;
|
|
@@ -20302,7 +20302,7 @@ function fileView(store, coverage, graph, input, path19, prefixes) {
|
|
|
20302
20302
|
` ${graph.qualifiedName(parent)} (${graph.object(parent).anchor.path}): ${list.sort((left, right) => left.anchor.start - right.anchor.start).map((object2) => `${object2.name} ${mapDeclarationLabel(object2)}`).join(", ")}`
|
|
20303
20303
|
);
|
|
20304
20304
|
if (declarations2.length) blocks.push(["DECLARATIONS (* exported)", ...declarations2].join("\n"));
|
|
20305
|
-
const
|
|
20305
|
+
const imports = /* @__PURE__ */ new Set();
|
|
20306
20306
|
const external = /* @__PURE__ */ new Set();
|
|
20307
20307
|
const fileObjects = graph.objectsAt(path19).map((object2) => object2.id);
|
|
20308
20308
|
for (const relation of graph.relationsFrom(fileObjects)) {
|
|
@@ -20310,7 +20310,7 @@ function fileView(store, coverage, graph, input, path19, prefixes) {
|
|
|
20310
20310
|
if (relation.to === void 0) external.add(relation.target);
|
|
20311
20311
|
else {
|
|
20312
20312
|
const target = graph.object(relation.to).anchor.path;
|
|
20313
|
-
if (mapPathAllowed(target, prefixes))
|
|
20313
|
+
if (mapPathAllowed(target, prefixes)) imports.add(mapImportTarget(target));
|
|
20314
20314
|
}
|
|
20315
20315
|
}
|
|
20316
20316
|
const importers = /* @__PURE__ */ new Set();
|
|
@@ -20323,7 +20323,7 @@ function fileView(store, coverage, graph, input, path19, prefixes) {
|
|
|
20323
20323
|
if (!mapPathAllowed(source, prefixes)) continue;
|
|
20324
20324
|
(!showTests && mapTestPath(source) ? testImporters : importers).add(source);
|
|
20325
20325
|
}
|
|
20326
|
-
if (
|
|
20326
|
+
if (imports.size) blocks.push(`IMPORTS \u2192 ${[...imports].sort(compareText2).join(", ")}`);
|
|
20327
20327
|
if (external.size)
|
|
20328
20328
|
blocks.push(`UNRESOLVED IMPORTS: ${[...external].sort(compareText2).join(", ")}`);
|
|
20329
20329
|
if (importers.size || testImporters.size)
|
|
@@ -22935,11 +22935,11 @@ function parseMapDiff(text) {
|
|
|
22935
22935
|
const names = line.slice("diff --git ".length);
|
|
22936
22936
|
const half = (names.length - 1) / 2;
|
|
22937
22937
|
const [from, to] = [names.slice(0, half), names.slice(half + 1)];
|
|
22938
|
-
const
|
|
22938
|
+
const same3 = from.startsWith("a/") && to.startsWith("b/") && from.slice(2) === to.slice(2) ? from.slice(2) : void 0;
|
|
22939
22939
|
const match = /^a\/(.+) b\/(.+)$/u.exec(names);
|
|
22940
22940
|
current = {
|
|
22941
|
-
path:
|
|
22942
|
-
basePath:
|
|
22941
|
+
path: same3 ?? match?.[2] ?? names,
|
|
22942
|
+
basePath: same3 ?? match?.[1] ?? names,
|
|
22943
22943
|
status: "MODIFIED",
|
|
22944
22944
|
lines: [],
|
|
22945
22945
|
baseLines: [],
|
|
@@ -22989,6 +22989,14 @@ function addHunk(file2, line) {
|
|
|
22989
22989
|
}
|
|
22990
22990
|
var changedInWorkingTree = (files) => new Map(files.map((file2) => [file2.path, file2]));
|
|
22991
22991
|
var changedInBase = (files) => new Map(files.flatMap((file2) => file2.basePath ? [[file2.basePath, file2]] : []));
|
|
22992
|
+
function mapPathNow(files) {
|
|
22993
|
+
const moved = new Map(
|
|
22994
|
+
files.flatMap(
|
|
22995
|
+
(file2) => file2.basePath !== void 0 && file2.status !== "DELETED" ? [[file2.basePath, file2.path]] : []
|
|
22996
|
+
)
|
|
22997
|
+
);
|
|
22998
|
+
return (path19) => moved.get(path19) ?? path19;
|
|
22999
|
+
}
|
|
22992
23000
|
var overlaps = (lines, start, end) => lines.some(([from, to]) => from <= end && start <= to);
|
|
22993
23001
|
var workingLine = (file2, line) => {
|
|
22994
23002
|
let shift = 0;
|
|
@@ -23023,10 +23031,6 @@ var unmappedKind = (path19, binary) => nonCodeKind(path19) ?? (binary ? "binary
|
|
|
23023
23031
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
23024
23032
|
import path13 from "node:path";
|
|
23025
23033
|
|
|
23026
|
-
// src/project-map-change-tests.ts
|
|
23027
|
-
import { readFile as readFile2 } from "node:fs/promises";
|
|
23028
|
-
import path12 from "node:path";
|
|
23029
|
-
|
|
23030
23034
|
// src/project-map-change-types.ts
|
|
23031
23035
|
var LIMITS = Object.freeze({
|
|
23032
23036
|
depth: 8,
|
|
@@ -23277,6 +23281,19 @@ var USED_BY = {
|
|
|
23277
23281
|
var runsTarget = (relation) => CALLER_KINDS.has(relation.kind) && !relation.event;
|
|
23278
23282
|
var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
23279
23283
|
var changeUnits = (graph, path19) => mapMiniprogramTemplate(path19) ? graph.objectsAt(path19).filter((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : graph.declarationsAt(path19);
|
|
23284
|
+
function changedUnits(graph, path19, lines) {
|
|
23285
|
+
const refs = /* @__PURE__ */ new Set();
|
|
23286
|
+
let topLevel = false;
|
|
23287
|
+
const inFile = changeUnits(graph, path19);
|
|
23288
|
+
for (const [from, to] of lines) {
|
|
23289
|
+
const containing = inFile.filter(
|
|
23290
|
+
(object2) => object2.anchor.startLine <= to && from <= object2.anchor.endLine
|
|
23291
|
+
);
|
|
23292
|
+
if (!containing.length && from <= to) topLevel = true;
|
|
23293
|
+
for (const object2 of mapInnermost(containing)) refs.add(object2.id);
|
|
23294
|
+
}
|
|
23295
|
+
return { refs, topLevel };
|
|
23296
|
+
}
|
|
23280
23297
|
var callerFrom = (ref, relation, certain) => ({
|
|
23281
23298
|
ref,
|
|
23282
23299
|
anchor: relation.anchor,
|
|
@@ -23834,6 +23851,179 @@ function findTestEntries(graph, ref) {
|
|
|
23834
23851
|
return found.length ? found : kept;
|
|
23835
23852
|
}
|
|
23836
23853
|
|
|
23854
|
+
// src/project-map-change-edges.ts
|
|
23855
|
+
var same2 = (path19) => path19;
|
|
23856
|
+
var compare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
23857
|
+
function linksOf(side, path19) {
|
|
23858
|
+
const imports = /* @__PURE__ */ new Map();
|
|
23859
|
+
const calls = /* @__PURE__ */ new Map();
|
|
23860
|
+
if (path19 === void 0) return { imports, calls };
|
|
23861
|
+
const { graph } = side;
|
|
23862
|
+
for (const relation of graph.relationsFrom(graph.objectsAt(path19).map((object2) => object2.id))) {
|
|
23863
|
+
const line = relation.anchor.startLine;
|
|
23864
|
+
if (relation.to === void 0 || !side.counts(path19, line)) continue;
|
|
23865
|
+
if (IMPORT_KINDS2.has(relation.kind)) {
|
|
23866
|
+
const target = graph.object(relation.to).anchor.path;
|
|
23867
|
+
if (target === path19) continue;
|
|
23868
|
+
const to = side.pathNow(target);
|
|
23869
|
+
const found = imports.get(to) ?? { to, lines: [] };
|
|
23870
|
+
found.lines.push(line);
|
|
23871
|
+
imports.set(to, found);
|
|
23872
|
+
} else if (CALLER_KINDS.has(relation.kind)) {
|
|
23873
|
+
const ref = graph.owner(relation.to);
|
|
23874
|
+
const owner = graph.object(ref);
|
|
23875
|
+
if (owner.anchor.path === path19 || mapIsModule(owner)) continue;
|
|
23876
|
+
const to = side.pathNow(owner.anchor.path);
|
|
23877
|
+
const key = `${to}\0${graph.declarationKey(owner)}`;
|
|
23878
|
+
const found = calls.get(key) ?? { to, lines: [], ref };
|
|
23879
|
+
found.lines.push(line);
|
|
23880
|
+
calls.set(key, found);
|
|
23881
|
+
}
|
|
23882
|
+
}
|
|
23883
|
+
return { imports, calls };
|
|
23884
|
+
}
|
|
23885
|
+
function mapChangeLinks(store, working, base, files) {
|
|
23886
|
+
const graph = new MapViewGraph(store, working);
|
|
23887
|
+
const always = () => true;
|
|
23888
|
+
const now = {
|
|
23889
|
+
graph,
|
|
23890
|
+
pathNow: same2,
|
|
23891
|
+
counts: always,
|
|
23892
|
+
pathOf: (file2) => file2.status === "DELETED" ? void 0 : file2.path,
|
|
23893
|
+
declaration: (_, ref) => ref
|
|
23894
|
+
};
|
|
23895
|
+
let before;
|
|
23896
|
+
if (base !== void 0) {
|
|
23897
|
+
const baseGraph = new MapViewGraph(store, base);
|
|
23898
|
+
const pathOf = (file2) => file2.status === "ADDED" ? void 0 : file2.basePath;
|
|
23899
|
+
const declared = /* @__PURE__ */ new Map();
|
|
23900
|
+
before = {
|
|
23901
|
+
graph: baseGraph,
|
|
23902
|
+
pathNow: mapPathNow(files),
|
|
23903
|
+
counts: always,
|
|
23904
|
+
pathOf,
|
|
23905
|
+
declaration: (file2, ref) => {
|
|
23906
|
+
const path19 = pathOf(file2);
|
|
23907
|
+
if (path19 === void 0) return void 0;
|
|
23908
|
+
let keys = declared.get(path19);
|
|
23909
|
+
if (!keys) {
|
|
23910
|
+
keys = new Map(
|
|
23911
|
+
changeUnits(baseGraph, path19).map((object2) => [
|
|
23912
|
+
baseGraph.declarationKey(object2),
|
|
23913
|
+
object2.id
|
|
23914
|
+
])
|
|
23915
|
+
);
|
|
23916
|
+
declared.set(path19, keys);
|
|
23917
|
+
}
|
|
23918
|
+
return keys.get(graph.declarationKey(graph.object(ref)));
|
|
23919
|
+
}
|
|
23920
|
+
};
|
|
23921
|
+
} else {
|
|
23922
|
+
const changedAt = changedInWorkingTree(files);
|
|
23923
|
+
before = {
|
|
23924
|
+
graph,
|
|
23925
|
+
pathNow: same2,
|
|
23926
|
+
counts: (path19, line) => {
|
|
23927
|
+
const file2 = changedAt.get(path19);
|
|
23928
|
+
return !file2 || !overlaps(file2.lines, line, line);
|
|
23929
|
+
},
|
|
23930
|
+
pathOf: (file2) => file2.status === "ADDED" ? void 0 : file2.path,
|
|
23931
|
+
// A declaration lying wholly in added lines is new.
|
|
23932
|
+
declaration: (file2, ref) => {
|
|
23933
|
+
const { anchor } = graph.object(ref);
|
|
23934
|
+
return file2.status === "ADDED" || file2.lines.some(([from, to]) => from <= anchor.startLine && anchor.endLine <= to) ? void 0 : ref;
|
|
23935
|
+
}
|
|
23936
|
+
};
|
|
23937
|
+
}
|
|
23938
|
+
return {
|
|
23939
|
+
now,
|
|
23940
|
+
before,
|
|
23941
|
+
files: files.map((file2) => ({
|
|
23942
|
+
file: file2,
|
|
23943
|
+
now: linksOf(now, now.pathOf(file2)),
|
|
23944
|
+
before: linksOf(before, before.pathOf(file2))
|
|
23945
|
+
}))
|
|
23946
|
+
};
|
|
23947
|
+
}
|
|
23948
|
+
function exportedTop(graph, ref) {
|
|
23949
|
+
let top = graph.object(ref);
|
|
23950
|
+
for (const at of graph.lineage(ref)) {
|
|
23951
|
+
const object2 = graph.object(at);
|
|
23952
|
+
if (mapIsModule(object2)) break;
|
|
23953
|
+
top = object2;
|
|
23954
|
+
}
|
|
23955
|
+
return top.exported;
|
|
23956
|
+
}
|
|
23957
|
+
function callersOf(side, ref) {
|
|
23958
|
+
const home = side.graph.object(ref).anchor.path;
|
|
23959
|
+
const files = /* @__PURE__ */ new Set();
|
|
23960
|
+
for (const relation of side.graph.relationsTo([ref])) {
|
|
23961
|
+
const path19 = relation.anchor.path;
|
|
23962
|
+
if (!CALLER_KINDS.has(relation.kind) || path19 === home || mapTestPath(path19)) continue;
|
|
23963
|
+
if (side.counts(path19, relation.anchor.startLine)) files.add(side.pathNow(path19));
|
|
23964
|
+
}
|
|
23965
|
+
return [...files].sort();
|
|
23966
|
+
}
|
|
23967
|
+
function mapChangeEdges(links) {
|
|
23968
|
+
const { now, before } = links;
|
|
23969
|
+
const imports = [];
|
|
23970
|
+
const calls = [];
|
|
23971
|
+
const declarations2 = [];
|
|
23972
|
+
let truncated = false;
|
|
23973
|
+
const first = ({ lines }) => Math.min(...lines);
|
|
23974
|
+
for (const linked of links.files) {
|
|
23975
|
+
const { file: file2 } = linked;
|
|
23976
|
+
if (file2.binary || mapTestPath(file2.path)) continue;
|
|
23977
|
+
for (const [to, sites2] of linked.now.imports)
|
|
23978
|
+
if (!linked.before.imports.has(to))
|
|
23979
|
+
imports.push({ from: file2.path, to, line: first(sites2), change: "ADDED" });
|
|
23980
|
+
for (const [to, sites2] of linked.before.imports)
|
|
23981
|
+
if (!linked.now.imports.has(to))
|
|
23982
|
+
imports.push({ from: file2.path, to, line: first(sites2), change: "REMOVED" });
|
|
23983
|
+
for (const [key, sites2] of linked.now.calls)
|
|
23984
|
+
if (!linked.before.calls.has(key))
|
|
23985
|
+
calls.push({
|
|
23986
|
+
from: file2.path,
|
|
23987
|
+
line: first(sites2),
|
|
23988
|
+
to: sites2.to,
|
|
23989
|
+
declaration: now.graph.qualifiedName(sites2.ref),
|
|
23990
|
+
exported: exportedTop(now.graph, sites2.ref)
|
|
23991
|
+
});
|
|
23992
|
+
if (now.pathOf(file2) === void 0 || before.pathOf(file2) === void 0) continue;
|
|
23993
|
+
for (const ref of changedUnits(now.graph, file2.path, file2.lines).refs) {
|
|
23994
|
+
const object2 = now.graph.object(ref);
|
|
23995
|
+
if (mapIsModule(object2)) continue;
|
|
23996
|
+
const was = before.declaration(file2, ref);
|
|
23997
|
+
if (was === void 0) continue;
|
|
23998
|
+
if (declarations2.length >= LIMITS.changed) {
|
|
23999
|
+
truncated = true;
|
|
24000
|
+
break;
|
|
24001
|
+
}
|
|
24002
|
+
declarations2.push({
|
|
24003
|
+
path: file2.path,
|
|
24004
|
+
declaration: now.graph.qualifiedName(ref),
|
|
24005
|
+
line: object2.anchor.startLine,
|
|
24006
|
+
exported: exportedTop(now.graph, ref),
|
|
24007
|
+
callersBefore: callersOf(before, was),
|
|
24008
|
+
callersAfter: callersOf(now, ref)
|
|
24009
|
+
});
|
|
24010
|
+
}
|
|
24011
|
+
}
|
|
24012
|
+
const order = (left, right) => compare(left.from, right.from) || left.line - right.line || compare(left.to, right.to);
|
|
24013
|
+
return {
|
|
24014
|
+
imports: imports.sort(order),
|
|
24015
|
+
calls: calls.sort(order),
|
|
24016
|
+
declarations: declarations2.sort(
|
|
24017
|
+
(left, right) => compare(left.path, right.path) || left.line - right.line
|
|
24018
|
+
),
|
|
24019
|
+
truncated
|
|
24020
|
+
};
|
|
24021
|
+
}
|
|
24022
|
+
|
|
24023
|
+
// src/project-map-change-tests.ts
|
|
24024
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
24025
|
+
import path12 from "node:path";
|
|
24026
|
+
|
|
23837
24027
|
// src/project-map-route-paths.ts
|
|
23838
24028
|
import {
|
|
23839
24029
|
isArrowFunction,
|
|
@@ -24693,17 +24883,6 @@ Nothing changed against ${changes.base}.`;
|
|
|
24693
24883
|
}
|
|
24694
24884
|
|
|
24695
24885
|
// src/project-map-dependencies.ts
|
|
24696
|
-
var IMPORT_KINDS3 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
24697
|
-
function imports(graph, path19) {
|
|
24698
|
-
const found = [];
|
|
24699
|
-
for (const relation of graph.relationsFrom(graph.objectsAt(path19).map((object2) => object2.id)))
|
|
24700
|
-
if (IMPORT_KINDS3.has(relation.kind) && relation.to !== void 0)
|
|
24701
|
-
found.push({
|
|
24702
|
-
target: graph.object(relation.to).anchor.path,
|
|
24703
|
-
line: relation.anchor.startLine
|
|
24704
|
-
});
|
|
24705
|
-
return found;
|
|
24706
|
-
}
|
|
24707
24886
|
function pathBetween(edges, from, to) {
|
|
24708
24887
|
const via = /* @__PURE__ */ new Map([[from, from]]);
|
|
24709
24888
|
for (let frontier = [from]; frontier.length; ) {
|
|
@@ -24723,7 +24902,7 @@ function pathBetween(edges, from, to) {
|
|
|
24723
24902
|
}
|
|
24724
24903
|
return void 0;
|
|
24725
24904
|
}
|
|
24726
|
-
function newModuleDependencies(store, cache, working,
|
|
24905
|
+
function newModuleDependencies(store, cache, working, files, links) {
|
|
24727
24906
|
const entries = store.listEntries(working);
|
|
24728
24907
|
const moduleOf = mapProjectModules(entries);
|
|
24729
24908
|
const now = /* @__PURE__ */ new Map();
|
|
@@ -24744,18 +24923,10 @@ function newModuleDependencies(store, cache, working, base, files) {
|
|
|
24744
24923
|
add(now, row.source, row.target);
|
|
24745
24924
|
add(before, row.source, row.target);
|
|
24746
24925
|
}
|
|
24747
|
-
const
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
const
|
|
24751
|
-
for (const { target, line } of current) add(now, file2.path, target, `${file2.path}:${line}`);
|
|
24752
|
-
if (!file2.basePath || file2.status === "ADDED") continue;
|
|
24753
|
-
if (baseGraph)
|
|
24754
|
-
for (const { target } of imports(baseGraph, file2.basePath)) add(before, file2.path, target);
|
|
24755
|
-
else
|
|
24756
|
-
for (const { target, line } of current)
|
|
24757
|
-
if (!file2.lines.some(([from, to]) => from <= line && line <= to))
|
|
24758
|
-
add(before, file2.path, target);
|
|
24926
|
+
for (const { file: file2, now: after, before: had } of links) {
|
|
24927
|
+
for (const [target, { lines }] of after.imports)
|
|
24928
|
+
for (const line of lines) add(now, file2.path, target, `${file2.path}:${line}`);
|
|
24929
|
+
for (const target of had.imports.keys()) add(before, file2.path, target);
|
|
24759
24930
|
}
|
|
24760
24931
|
const added = new Set(files.filter((file2) => file2.status === "ADDED").map((file2) => file2.path));
|
|
24761
24932
|
const kept = /* @__PURE__ */ new Set();
|
|
@@ -25033,7 +25204,7 @@ async function similarCode(store, working, base, files, read) {
|
|
|
25033
25204
|
}
|
|
25034
25205
|
|
|
25035
25206
|
// src/project-map-changes.ts
|
|
25036
|
-
async function mapChangeImpact(store, working, base, changes, shapes, until, project, tests) {
|
|
25207
|
+
async function mapChangeImpact(store, working, base, changes, links, shapes, until, project, tests) {
|
|
25037
25208
|
const graph = new MapViewGraph(store, working);
|
|
25038
25209
|
const cache = new MapViewCache();
|
|
25039
25210
|
const memberCalls = cache.memberCalls(store, working);
|
|
@@ -25087,16 +25258,7 @@ async function mapChangeImpact(store, working, base, changes, shapes, until, pro
|
|
|
25087
25258
|
unmapped.push({ path: file2.path, kind });
|
|
25088
25259
|
}
|
|
25089
25260
|
if (!objects2.length) continue;
|
|
25090
|
-
const hits
|
|
25091
|
-
let topLevel = false;
|
|
25092
|
-
const inFile = changeUnits(graph, file2.path);
|
|
25093
|
-
for (const [from, to] of file2.lines) {
|
|
25094
|
-
const containing = inFile.filter(
|
|
25095
|
-
(object2) => object2.anchor.startLine <= to && from <= object2.anchor.endLine
|
|
25096
|
-
);
|
|
25097
|
-
if (!containing.length && from <= to) topLevel = true;
|
|
25098
|
-
for (const object2 of mapInnermost(containing)) hits.add(object2.id);
|
|
25099
|
-
}
|
|
25261
|
+
const { refs: hits, topLevel } = changedUnits(graph, file2.path, file2.lines);
|
|
25100
25262
|
for (const ref of hits) {
|
|
25101
25263
|
if (changedCount++ >= LIMITS.changed) {
|
|
25102
25264
|
tracer.truncated = true;
|
|
@@ -25227,7 +25389,7 @@ async function mapChangeImpact(store, working, base, changes, shapes, until, pro
|
|
|
25227
25389
|
unmapped,
|
|
25228
25390
|
removedRoutes: taken?.removedRoutes ?? [],
|
|
25229
25391
|
uncalled: taken?.uncalled ?? [],
|
|
25230
|
-
dependencies: newModuleDependencies(store, cache, working,
|
|
25392
|
+
dependencies: newModuleDependencies(store, cache, working, changes.files, links.files),
|
|
25231
25393
|
...untested ? { untested } : {},
|
|
25232
25394
|
truncated: tracer.truncated
|
|
25233
25395
|
};
|
|
@@ -25294,7 +25456,7 @@ async function untestedChanges(graph, tracer, memberCalls, starts, changed, test
|
|
|
25294
25456
|
truncated: unreached.length > 0 && (truncated || above.truncated)
|
|
25295
25457
|
};
|
|
25296
25458
|
}
|
|
25297
|
-
function mapChangesData(changes, impact) {
|
|
25459
|
+
function mapChangesData(changes, impact, edges) {
|
|
25298
25460
|
return {
|
|
25299
25461
|
base: changes.base,
|
|
25300
25462
|
commit: changes.commit,
|
|
@@ -25308,7 +25470,8 @@ function mapChangesData(changes, impact) {
|
|
|
25308
25470
|
incomplete: impact.incomplete,
|
|
25309
25471
|
checkByHand: impact.unclear,
|
|
25310
25472
|
truncated: impact.truncated,
|
|
25311
|
-
...impact.untested ? { untested: impact.untested } : {}
|
|
25473
|
+
...impact.untested ? { untested: impact.untested } : {},
|
|
25474
|
+
edges
|
|
25312
25475
|
};
|
|
25313
25476
|
}
|
|
25314
25477
|
async function checkMapChanges(input, signal) {
|
|
@@ -25338,11 +25501,13 @@ async function checkMapChanges(input, signal) {
|
|
|
25338
25501
|
);
|
|
25339
25502
|
};
|
|
25340
25503
|
const until = mapShapeDeadline();
|
|
25504
|
+
const links = mapChangeLinks(index.store, working, base, changes.files);
|
|
25341
25505
|
const impact = await mapChangeImpact(
|
|
25342
25506
|
index.store,
|
|
25343
25507
|
working,
|
|
25344
25508
|
base,
|
|
25345
25509
|
changes,
|
|
25510
|
+
links,
|
|
25346
25511
|
{
|
|
25347
25512
|
working: usesIn(working, input.source),
|
|
25348
25513
|
base: usesIn(base ?? working, { ...input.source, kind: "COMMIT", commit: changes.commit })
|
|
@@ -25351,7 +25516,7 @@ async function checkMapChanges(input, signal) {
|
|
|
25351
25516
|
project,
|
|
25352
25517
|
input.tests
|
|
25353
25518
|
);
|
|
25354
|
-
const data = mapChangesData(changes, impact);
|
|
25519
|
+
const data = mapChangesData(changes, impact, mapChangeEdges(links));
|
|
25355
25520
|
if (input.format === "json") return { text: JSON.stringify(data), data };
|
|
25356
25521
|
return {
|
|
25357
25522
|
data,
|
|
@@ -25378,8 +25543,8 @@ function reusable(store, working, similar) {
|
|
|
25378
25543
|
if (!similar.length) return [];
|
|
25379
25544
|
const importsFor = mapReuseImports(store, new MapViewCache(), working);
|
|
25380
25545
|
return similar.flatMap((item) => {
|
|
25381
|
-
const
|
|
25382
|
-
return
|
|
25546
|
+
const imports = importsFor(item.path, item.like.path);
|
|
25547
|
+
return imports ? [{ ...item, imports }] : [];
|
|
25383
25548
|
});
|
|
25384
25549
|
}
|
|
25385
25550
|
async function mapRouteClients(project, store, working, impact, signal) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.46",
|
|
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.46");
|
|
297
297
|
for (const tool of tools) {
|
|
298
298
|
if (registered.has(tool.name)) continue;
|
|
299
299
|
registered.add(tool.name);
|