layermap 0.1.49 → 0.1.51
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/analyzers/project-map-java/java-map.jar +0 -0
- package/analyzers/project-map-worker.mjs +281 -218
- package/dist/cli.mjs +220 -58
- package/package.json +1 -1
- package/pi/layermap.mjs +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -19120,7 +19120,7 @@ var miniprogramEventOf = (target) => {
|
|
|
19120
19120
|
|
|
19121
19121
|
// src/project-map-language-typescript.ts
|
|
19122
19122
|
var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
19123
|
-
id: "typescript-7.0.2-map-
|
|
19123
|
+
id: "typescript-7.0.2-map-v35",
|
|
19124
19124
|
claims: (path20) => /\.[cm]?[jt]sx?$/u.test(path20),
|
|
19125
19125
|
readsRequests: true,
|
|
19126
19126
|
reads: (path20) => path20.endsWith(".json") || path20.endsWith(".wxml") || path20 === "pnpm-workspace.yaml",
|
|
@@ -23096,6 +23096,8 @@ var LIST = Object.freeze({
|
|
|
23096
23096
|
entries: 40,
|
|
23097
23097
|
tests: 12,
|
|
23098
23098
|
unclear: 20,
|
|
23099
|
+
/** Subjects named on the line of one kind of note to check by hand. */
|
|
23100
|
+
grouped: 8,
|
|
23099
23101
|
stranded: 12,
|
|
23100
23102
|
clients: 8,
|
|
23101
23103
|
names: 6,
|
|
@@ -23534,8 +23536,17 @@ var Tracer = class {
|
|
|
23534
23536
|
if (mapTestPath(object2.anchor.path) || this.routes.has(reached.ref)) continue;
|
|
23535
23537
|
if (reached.depth === 0 && !mapMiniprogramTemplate(object2.anchor.path)) {
|
|
23536
23538
|
const uses = this.usesWithoutCalls(reached.ref);
|
|
23539
|
+
const subject = this.where(reached.ref);
|
|
23537
23540
|
this.unclear.push(
|
|
23538
|
-
uses.length ?
|
|
23541
|
+
uses.length ? {
|
|
23542
|
+
text: `${subject} has no callers in the map, and is used without a call: ${uses.join("; ")}`
|
|
23543
|
+
} : mapIsShape(object2) ? {
|
|
23544
|
+
text: `${subject} has no callers in the map, and a search for references found no use: it may be read through reflection, serialization or a value of unknown type, or be unused`,
|
|
23545
|
+
group: { kind: "NO_USE", subject }
|
|
23546
|
+
} : {
|
|
23547
|
+
text: `${subject} has no callers in the map: it may be wired by a framework, called dynamically, or unused`,
|
|
23548
|
+
group: { kind: "NO_CALLERS", subject }
|
|
23549
|
+
}
|
|
23539
23550
|
);
|
|
23540
23551
|
} else if (!mapIsShape(object2) || !reached.used && object2.kind === "PROPERTY")
|
|
23541
23552
|
this.entry(this.where(reached.ref), false, reached, void 0, reached.certain, true);
|
|
@@ -23803,9 +23814,9 @@ var Tracer = class {
|
|
|
23803
23814
|
if (object2.kind !== "METHOD" || !language || /^__\w+__$/u.test(object2.name)) return;
|
|
23804
23815
|
const calls = this.memberCalls.get(`${language}\0${object2.name}`) ?? [];
|
|
23805
23816
|
if (calls.length)
|
|
23806
|
-
this.unclear.push(
|
|
23807
|
-
`${calls.length} calls of a member named ${object2.name} on receivers of unknown type may reach ${this.graph.qualifiedName(ref)}; a text search finds them`
|
|
23808
|
-
);
|
|
23817
|
+
this.unclear.push({
|
|
23818
|
+
text: `${calls.length} calls of a member named ${object2.name} on receivers of unknown type may reach ${this.graph.qualifiedName(ref)}; a text search finds them`
|
|
23819
|
+
});
|
|
23809
23820
|
}
|
|
23810
23821
|
entry(label, route, at, site, certain, top = false) {
|
|
23811
23822
|
if (route) this.handlers.set(label, (this.handlers.get(label) ?? /* @__PURE__ */ new Set()).add(at.ref));
|
|
@@ -24078,49 +24089,121 @@ import path13 from "node:path";
|
|
|
24078
24089
|
// src/project-map-route-paths.ts
|
|
24079
24090
|
import {
|
|
24080
24091
|
isArrowFunction,
|
|
24081
|
-
isAsExpression,
|
|
24092
|
+
isAsExpression as isAsExpression2,
|
|
24082
24093
|
isAwaitExpression,
|
|
24083
|
-
isBinaryExpression,
|
|
24094
|
+
isBinaryExpression as isBinaryExpression2,
|
|
24084
24095
|
isBlock,
|
|
24085
|
-
isCallExpression as
|
|
24086
|
-
isFunctionDeclaration,
|
|
24096
|
+
isCallExpression as isCallExpression5,
|
|
24097
|
+
isFunctionDeclaration as isFunctionDeclaration2,
|
|
24087
24098
|
isFunctionExpression,
|
|
24088
|
-
isIdentifier as
|
|
24089
|
-
isMethodDeclaration as
|
|
24099
|
+
isIdentifier as isIdentifier5,
|
|
24100
|
+
isMethodDeclaration as isMethodDeclaration3,
|
|
24090
24101
|
isModuleBlock,
|
|
24091
24102
|
isNewExpression,
|
|
24092
24103
|
isNoSubstitutionTemplateLiteral as isNoSubstitutionTemplateLiteral2,
|
|
24093
24104
|
isObjectLiteralExpression as isObjectLiteralExpression2,
|
|
24094
|
-
isParenthesizedExpression,
|
|
24095
|
-
isPropertyAccessExpression as
|
|
24096
|
-
isPropertyAssignment as
|
|
24097
|
-
isPropertyDeclaration,
|
|
24105
|
+
isParenthesizedExpression as isParenthesizedExpression2,
|
|
24106
|
+
isPropertyAccessExpression as isPropertyAccessExpression4,
|
|
24107
|
+
isPropertyAssignment as isPropertyAssignment3,
|
|
24108
|
+
isPropertyDeclaration as isPropertyDeclaration2,
|
|
24098
24109
|
isSatisfiesExpression,
|
|
24099
|
-
isShorthandPropertyAssignment,
|
|
24110
|
+
isShorthandPropertyAssignment as isShorthandPropertyAssignment2,
|
|
24100
24111
|
isSourceFile,
|
|
24101
24112
|
isSpreadAssignment,
|
|
24102
|
-
isStringLiteral as
|
|
24113
|
+
isStringLiteral as isStringLiteral5,
|
|
24103
24114
|
isTemplateExpression,
|
|
24104
|
-
isVariableDeclaration,
|
|
24115
|
+
isVariableDeclaration as isVariableDeclaration2,
|
|
24105
24116
|
NodeFlags as NodeFlags2,
|
|
24106
|
-
SyntaxKind as
|
|
24117
|
+
SyntaxKind as SyntaxKind6
|
|
24107
24118
|
} from "typescript/unstable/ast";
|
|
24108
24119
|
import {
|
|
24109
|
-
SymbolFlags,
|
|
24110
24120
|
TypeFlags
|
|
24111
24121
|
} from "typescript/unstable/async";
|
|
24112
24122
|
|
|
24113
|
-
// src/project-map-
|
|
24123
|
+
// src/project-map-resolution.ts
|
|
24124
|
+
import {
|
|
24125
|
+
isBindingElement,
|
|
24126
|
+
isCallExpression as isCallExpression3,
|
|
24127
|
+
isIdentifier as isIdentifier3,
|
|
24128
|
+
isObjectBindingPattern,
|
|
24129
|
+
isPropertyAssignment as isPropertyAssignment2,
|
|
24130
|
+
isShorthandPropertyAssignment,
|
|
24131
|
+
isStringLiteral as isStringLiteral3,
|
|
24132
|
+
SyntaxKind as SyntaxKind4
|
|
24133
|
+
} from "typescript/unstable/ast";
|
|
24134
|
+
import {
|
|
24135
|
+
SignatureKind,
|
|
24136
|
+
SymbolFlags
|
|
24137
|
+
} from "typescript/unstable/async";
|
|
24138
|
+
|
|
24139
|
+
// src/project-map-declarations.ts
|
|
24114
24140
|
import {
|
|
24141
|
+
isAsExpression,
|
|
24142
|
+
isBinaryExpression,
|
|
24115
24143
|
isCallExpression as isCallExpression2,
|
|
24144
|
+
isClassDeclaration,
|
|
24145
|
+
isElementAccessExpression,
|
|
24146
|
+
isEnumDeclaration,
|
|
24147
|
+
isFunctionDeclaration,
|
|
24116
24148
|
isIdentifier as isIdentifier2,
|
|
24117
|
-
|
|
24149
|
+
isInterfaceDeclaration,
|
|
24150
|
+
isMethodDeclaration as isMethodDeclaration2,
|
|
24151
|
+
isParenthesizedExpression,
|
|
24152
|
+
isPrivateIdentifier,
|
|
24118
24153
|
isPropertyAccessExpression as isPropertyAccessExpression2,
|
|
24154
|
+
isPropertyDeclaration,
|
|
24119
24155
|
isStringLiteral as isStringLiteral2,
|
|
24120
|
-
|
|
24156
|
+
isTypeAliasDeclaration,
|
|
24157
|
+
isVariableDeclaration,
|
|
24121
24158
|
SyntaxKind as SyntaxKind2
|
|
24122
24159
|
} from "typescript/unstable/ast";
|
|
24123
24160
|
|
|
24161
|
+
// src/project-map-execution.ts
|
|
24162
|
+
import { SyntaxKind as SyntaxKind3 } from "typescript/unstable/ast";
|
|
24163
|
+
var callableKinds = /* @__PURE__ */ new Set([
|
|
24164
|
+
SyntaxKind3.FunctionDeclaration,
|
|
24165
|
+
SyntaxKind3.FunctionExpression,
|
|
24166
|
+
SyntaxKind3.ArrowFunction,
|
|
24167
|
+
SyntaxKind3.MethodDeclaration,
|
|
24168
|
+
SyntaxKind3.GetAccessor,
|
|
24169
|
+
SyntaxKind3.SetAccessor,
|
|
24170
|
+
SyntaxKind3.Constructor
|
|
24171
|
+
]);
|
|
24172
|
+
var expressionWrappers = /* @__PURE__ */ new Set([
|
|
24173
|
+
SyntaxKind3.ParenthesizedExpression,
|
|
24174
|
+
SyntaxKind3.AsExpression,
|
|
24175
|
+
SyntaxKind3.TypeAssertionExpression,
|
|
24176
|
+
SyntaxKind3.SatisfiesExpression,
|
|
24177
|
+
SyntaxKind3.NonNullExpression
|
|
24178
|
+
]);
|
|
24179
|
+
var choosingOperators = /* @__PURE__ */ new Set([SyntaxKind3.BarBarToken, SyntaxKind3.QuestionQuestionToken]);
|
|
24180
|
+
var assigningOperators = /* @__PURE__ */ new Set([
|
|
24181
|
+
...choosingOperators,
|
|
24182
|
+
SyntaxKind3.AmpersandAmpersandToken,
|
|
24183
|
+
SyntaxKind3.EqualsToken,
|
|
24184
|
+
SyntaxKind3.BarBarEqualsToken,
|
|
24185
|
+
SyntaxKind3.QuestionQuestionEqualsToken
|
|
24186
|
+
]);
|
|
24187
|
+
|
|
24188
|
+
// src/project-map-resolution.ts
|
|
24189
|
+
var memberContainers = /* @__PURE__ */ new Set([
|
|
24190
|
+
SyntaxKind4.InterfaceDeclaration,
|
|
24191
|
+
SyntaxKind4.TypeLiteral,
|
|
24192
|
+
SyntaxKind4.ClassDeclaration,
|
|
24193
|
+
SyntaxKind4.ClassExpression
|
|
24194
|
+
]);
|
|
24195
|
+
|
|
24196
|
+
// src/project-map-routes.ts
|
|
24197
|
+
import {
|
|
24198
|
+
isCallExpression as isCallExpression4,
|
|
24199
|
+
isIdentifier as isIdentifier4,
|
|
24200
|
+
isNoSubstitutionTemplateLiteral,
|
|
24201
|
+
isPropertyAccessExpression as isPropertyAccessExpression3,
|
|
24202
|
+
isStringLiteral as isStringLiteral4,
|
|
24203
|
+
NodeFlags,
|
|
24204
|
+
SyntaxKind as SyntaxKind5
|
|
24205
|
+
} from "typescript/unstable/ast";
|
|
24206
|
+
|
|
24124
24207
|
// src/project-map-route-paths.ts
|
|
24125
24208
|
var MAP_PATH_PARAMETER = "{}";
|
|
24126
24209
|
|
|
@@ -24505,9 +24588,9 @@ async function mapRemovedImpact(input) {
|
|
|
24505
24588
|
for (const { shapes: inRemoved, inside, usedBy } of goneShapes)
|
|
24506
24589
|
for (const shape of inRemoved) {
|
|
24507
24590
|
if (beforeTracer.shapes.unread.has(shape))
|
|
24508
|
-
unclear.push(
|
|
24509
|
-
`${before.object(shape).anchor.path}: ${before.qualifiedName(shape)} was removed, and who used it was not read; search the code for its name`
|
|
24510
|
-
);
|
|
24591
|
+
unclear.push({
|
|
24592
|
+
text: `${before.object(shape).anchor.path}: ${before.qualifiedName(shape)} was removed, and who used it was not read; search the code for its name`
|
|
24593
|
+
});
|
|
24511
24594
|
const now = successors(shape);
|
|
24512
24595
|
for (const { owner, anchor } of beforeTracer.shapes.uses.get(shape) ?? []) {
|
|
24513
24596
|
const place = nowAt(anchor);
|
|
@@ -24526,13 +24609,13 @@ async function mapRemovedImpact(input) {
|
|
|
24526
24609
|
}
|
|
24527
24610
|
}
|
|
24528
24611
|
if (unfollowed.size)
|
|
24529
|
-
unclear.push(
|
|
24530
|
-
`${unfollowed.size} removed fields or types are used on lines the diff left alone, and whether that code now uses what took their place was not read (${[
|
|
24612
|
+
unclear.push({
|
|
24613
|
+
text: `${unfollowed.size} removed fields or types are used on lines the diff left alone, and whether that code now uses what took their place was not read (${[
|
|
24531
24614
|
...unfollowed
|
|
24532
24615
|
].sort().slice(0, LIST.names).join(
|
|
24533
24616
|
", "
|
|
24534
24617
|
)}${unfollowed.size > LIST.names ? ", \u2026" : ""}); project_find_references lists their uses`
|
|
24535
|
-
);
|
|
24618
|
+
});
|
|
24536
24619
|
const lost = /* @__PURE__ */ new Map();
|
|
24537
24620
|
const changedAt = changedInWorkingTree(changes.files);
|
|
24538
24621
|
for (const path20 of input.mappedPaths().filter(mapMiniprogramTemplate)) {
|
|
@@ -24552,9 +24635,9 @@ async function mapRemovedImpact(input) {
|
|
|
24552
24635
|
const event = miniprogramEventOf(relation.target);
|
|
24553
24636
|
const at = `${path20}:${relation.anchor.startLine}`;
|
|
24554
24637
|
if (file2 && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine)) {
|
|
24555
|
-
unclear.push(
|
|
24556
|
-
event ? `${at} binds the ${event.event} event of <${event.tag}>, which it does not emit` : relation.kind === "REFERENCES" ? `${at} puts <${relation.target}>, which its registration does not find` : `${at} binds ${relation.target}, which its page or component does not register`
|
|
24557
|
-
);
|
|
24638
|
+
unclear.push({
|
|
24639
|
+
text: event ? `${at} binds the ${event.event} event of <${event.tag}>, which it does not emit` : relation.kind === "REFERENCES" ? `${at} puts <${relation.target}>, which its registration does not find` : `${at} binds ${relation.target}, which its page or component does not register`
|
|
24640
|
+
});
|
|
24558
24641
|
continue;
|
|
24559
24642
|
}
|
|
24560
24643
|
const reached = event ? links.find((link) => link.kind === "REFERENCES" && link.target === event.tag)?.to : earlier.find((link) => link.to !== void 0)?.to;
|
|
@@ -24658,11 +24741,11 @@ async function mapRemovedImpact(input) {
|
|
|
24658
24741
|
}
|
|
24659
24742
|
uncalled.sort();
|
|
24660
24743
|
if (unknown2.length)
|
|
24661
|
-
unclear.push(
|
|
24662
|
-
`${unknown2.length} fields lost callers the diff removed, and whether others use them was not read (${unknown2.sort().slice(0, LIST.names).join(
|
|
24744
|
+
unclear.push({
|
|
24745
|
+
text: `${unknown2.length} fields lost callers the diff removed, and whether others use them was not read (${unknown2.sort().slice(0, LIST.names).join(
|
|
24663
24746
|
", "
|
|
24664
24747
|
)}${unknown2.length > LIST.names ? ", \u2026" : ""}); project_find_references lists their uses`
|
|
24665
|
-
);
|
|
24748
|
+
});
|
|
24666
24749
|
return {
|
|
24667
24750
|
removed: removed.map(({ declaration, usedBy }) => ({
|
|
24668
24751
|
declaration,
|
|
@@ -24677,6 +24760,43 @@ async function mapRemovedImpact(input) {
|
|
|
24677
24760
|
}
|
|
24678
24761
|
|
|
24679
24762
|
// src/project-map-change-text.ts
|
|
24763
|
+
var GROUPED = {
|
|
24764
|
+
TOP_LEVEL: (count, subjects) => `top-level code of ${count} files changed (imports, constants or registrations): ${subjects}`,
|
|
24765
|
+
UNMAPPED: (count, subjects) => `${count} changed files are of kinds the map does not analyze, so their effects are not mapped: ${subjects}`,
|
|
24766
|
+
NO_CALLERS: (count, subjects) => `${count} changed declarations have no callers in the map: they may be wired by a framework, called dynamically, or unused (${subjects})`,
|
|
24767
|
+
NO_USE: (count, subjects) => `${count} changed fields or types have no callers in the map, and a search for references found no use: they may be read through reflection, serialization or a value of unknown type, or be unused (${subjects})`,
|
|
24768
|
+
REGISTRATION: (count, subjects) => `${count} route registrations changed; check that each route still reaches the right handler: ${subjects}`
|
|
24769
|
+
};
|
|
24770
|
+
function uncertainLines(notes) {
|
|
24771
|
+
const lines = [];
|
|
24772
|
+
const kinds = /* @__PURE__ */ new Map();
|
|
24773
|
+
for (const { text, group } of notes) {
|
|
24774
|
+
if (!group) {
|
|
24775
|
+
lines.push(text);
|
|
24776
|
+
continue;
|
|
24777
|
+
}
|
|
24778
|
+
let same3 = kinds.get(group.kind);
|
|
24779
|
+
if (!same3) {
|
|
24780
|
+
same3 = { kind: group.kind, texts: [], groups: [] };
|
|
24781
|
+
kinds.set(group.kind, same3);
|
|
24782
|
+
lines.push(same3);
|
|
24783
|
+
}
|
|
24784
|
+
same3.texts.push(text);
|
|
24785
|
+
same3.groups.push(group);
|
|
24786
|
+
}
|
|
24787
|
+
return lines.map((line) => {
|
|
24788
|
+
if (typeof line === "string") return line;
|
|
24789
|
+
if (line.texts.length === 1) return line.texts[0];
|
|
24790
|
+
const shown = line.groups.slice(0, LIST.grouped).map(
|
|
24791
|
+
({ subject, route }) => route === void 0 ? subject : `${JSON.stringify(route)} at ${subject}`
|
|
24792
|
+
);
|
|
24793
|
+
const more2 = line.groups.length - shown.length;
|
|
24794
|
+
return GROUPED[line.kind](
|
|
24795
|
+
line.groups.length,
|
|
24796
|
+
`${shown.join(", ")}${more2 > 0 ? `, +${more2} more` : ""}`
|
|
24797
|
+
);
|
|
24798
|
+
});
|
|
24799
|
+
}
|
|
24680
24800
|
function testNames(names, limit2 = LIST.names) {
|
|
24681
24801
|
if (!names.length) return "";
|
|
24682
24802
|
const tests = names.filter((name) => /(?:^|\.)(?:test|Test|should|it_)\w*$/u.test(name));
|
|
@@ -24719,7 +24839,7 @@ Nothing changed against ${changes.base}.`;
|
|
|
24719
24839
|
);
|
|
24720
24840
|
if (compile.missing.length)
|
|
24721
24841
|
lines.push(
|
|
24722
|
-
`PACKAGES NOT FOUND (${compile.missing.slice(0, LIST.names).join(", ")}${compile.missing.length > LIST.names ? `, +${compile.missing.length - LIST.names} more` : ""}): are dependencies installed in this directory?
|
|
24842
|
+
`PACKAGES NOT FOUND (${compile.missing.slice(0, LIST.names).join(", ")}${compile.missing.length > LIST.names ? `, +${compile.missing.length - LIST.names} more` : ""}): are dependencies installed in this directory? Without their types, calls through them (framework page methods among them), their uses and compile errors are not seen, so this report can miss what the change reaches.`
|
|
24723
24843
|
);
|
|
24724
24844
|
if (compile.unchecked.length)
|
|
24725
24845
|
lines.push(
|
|
@@ -24793,7 +24913,26 @@ Nothing changed against ${changes.base}.`;
|
|
|
24793
24913
|
`Decide for each whether it runs the way the project's layers do: code others build on (shared types, storage, utilities) should not import the features or interfaces built on it.${impact.dependencies.some((dependency) => dependency.back) ? " A cycle ties the modules together, so neither can change or be tested alone." : ""} If one runs the wrong way, move what both need into the lower module or pass it in, rather than import upward.`
|
|
24794
24914
|
);
|
|
24795
24915
|
}
|
|
24796
|
-
const
|
|
24916
|
+
const registrations = /* @__PURE__ */ new Map();
|
|
24917
|
+
for (const { group } of impact.unclear)
|
|
24918
|
+
if (group?.route !== void 0)
|
|
24919
|
+
registrations.set(group.route, [...registrations.get(group.route) ?? [], group.subject]);
|
|
24920
|
+
const certain = impact.entries.filter((e) => e.certain).slice(0, LIST.entries);
|
|
24921
|
+
const possible = impact.entries.filter((e) => !e.certain).slice(0, LIST.entries);
|
|
24922
|
+
const marked = new Set(
|
|
24923
|
+
[...certain, ...possible].filter((item) => item.route && !item.removed && registrations.has(item.label)).map((item) => item.label)
|
|
24924
|
+
);
|
|
24925
|
+
const label = (item) => item.route ? JSON.stringify(item.label) : item.label;
|
|
24926
|
+
const entry = (item) => {
|
|
24927
|
+
const changedAt = marked.has(item.label) ? registrations.get(item.label) ?? [] : [];
|
|
24928
|
+
const registered = item.site ? `registered at ${item.site}${changedAt.includes(item.site) ? ", a line the diff changed" : ""}` : "";
|
|
24929
|
+
const elsewhere = changedAt.filter((site) => site !== item.site);
|
|
24930
|
+
const where = [
|
|
24931
|
+
...registered ? [registered] : [],
|
|
24932
|
+
...elsewhere.length ? [`its registration at ${elsewhere.join(", ")} changed`] : []
|
|
24933
|
+
];
|
|
24934
|
+
return `${label(item)}${item.chain.length ? ` \u2192 ${item.chain.join(" \u2192 ")}` : ""}${item.removed ? ` (the diff removes it${item.site ? `; registered at ${item.site} before` : ""})` : where.length ? ` (${where.join("; ")})` : ""}`;
|
|
24935
|
+
};
|
|
24797
24936
|
list(
|
|
24798
24937
|
"AFFECTED ENTRY POINTS (through resolved calls)",
|
|
24799
24938
|
impact.entries.filter((e) => e.certain).map(entry),
|
|
@@ -24804,6 +24943,11 @@ Nothing changed against ${changes.base}.`;
|
|
|
24804
24943
|
impact.entries.filter((e) => !e.certain).map(entry),
|
|
24805
24944
|
LIST.entries
|
|
24806
24945
|
);
|
|
24946
|
+
const listed = new Set([...certain, ...possible].map(entry));
|
|
24947
|
+
if (marked.size)
|
|
24948
|
+
lines.push(
|
|
24949
|
+
"Where the diff changed a route's registration, check that the route still reaches the right handler."
|
|
24950
|
+
);
|
|
24807
24951
|
if (impact.untested) {
|
|
24808
24952
|
const { changed, entries, throughRoutes, routes: routes2, missing, truncated } = impact.untested;
|
|
24809
24953
|
const items = (shown, limit2) => {
|
|
@@ -24818,7 +24962,10 @@ Nothing changed against ${changes.base}.`;
|
|
|
24818
24962
|
` ${changed.length} of ${impact.changed.length} changed declarations are reached by none of the given tests; ${entries.length ? "the entry points above them, then the declarations:" : "the declarations:"}`
|
|
24819
24963
|
);
|
|
24820
24964
|
items(
|
|
24821
|
-
entries.map((item) =>
|
|
24965
|
+
entries.map((item) => {
|
|
24966
|
+
const full = entry(item);
|
|
24967
|
+
return `${listed.has(full) ? `${label(item)} (as listed above)` : full}${item.certain ? "" : " (possibly)"}`;
|
|
24968
|
+
}),
|
|
24822
24969
|
LIST.entries
|
|
24823
24970
|
);
|
|
24824
24971
|
items(changed, LIST.changed);
|
|
@@ -24877,7 +25024,14 @@ Nothing changed against ${changes.base}.`;
|
|
|
24877
25024
|
];
|
|
24878
25025
|
list(
|
|
24879
25026
|
"CHECK BY HAND (the map cannot see these)",
|
|
24880
|
-
[
|
|
25027
|
+
[
|
|
25028
|
+
...incomplete,
|
|
25029
|
+
...uncertainLines(
|
|
25030
|
+
impact.unclear.filter(
|
|
25031
|
+
({ group }) => group?.route === void 0 || !marked.has(group.route)
|
|
25032
|
+
)
|
|
25033
|
+
)
|
|
25034
|
+
],
|
|
24881
25035
|
incomplete.length + LIST.unclear
|
|
24882
25036
|
);
|
|
24883
25037
|
if (direct.length) {
|
|
@@ -24896,7 +25050,7 @@ Nothing changed against ${changes.base}.`;
|
|
|
24896
25050
|
`RELATED TESTS: none call or import the changed code directly; ${indirect.length} test files import it through other modules, which a broader run covers.`
|
|
24897
25051
|
);
|
|
24898
25052
|
lines.push(
|
|
24899
|
-
"Static estimate:
|
|
25053
|
+
"Static estimate: dependency injection, reflection, string dispatch, configuration and the database are not followed, so an empty list does not prove the change safe."
|
|
24900
25054
|
);
|
|
24901
25055
|
if (similar.length) {
|
|
24902
25056
|
const declaration = (item) => `${item.path}: ${item.name} ${item.label}`;
|
|
@@ -25288,8 +25442,9 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
|
|
|
25288
25442
|
let paths;
|
|
25289
25443
|
const pathIndex = () => paths ??= mapPathIndex(mappedPaths());
|
|
25290
25444
|
const topLevelChanged = (path20) => {
|
|
25291
|
-
const
|
|
25292
|
-
if (!unclear.
|
|
25445
|
+
const text = `top-level code of ${path20} changed (imports, constants or registrations)`;
|
|
25446
|
+
if (!unclear.some((note) => note.text === text))
|
|
25447
|
+
unclear.push({ text, group: { kind: "TOP_LEVEL", subject: path20 } });
|
|
25293
25448
|
};
|
|
25294
25449
|
for (const file2 of changes.files) {
|
|
25295
25450
|
const objects2 = file2.status === "DELETED" || file2.binary ? [] : graph.objectsAt(file2.path);
|
|
@@ -25302,9 +25457,11 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
|
|
|
25302
25457
|
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"));
|
|
25303
25458
|
const kind = !analyzed || MAP_MIGRATION_PATH.test(file2.path) ? unmappedKind(file2.path, file2.binary) : void 0;
|
|
25304
25459
|
if (kind) {
|
|
25305
|
-
|
|
25306
|
-
|
|
25307
|
-
|
|
25460
|
+
const deleted = file2.status === "DELETED";
|
|
25461
|
+
unclear.push({
|
|
25462
|
+
text: `${file2.path} ${deleted ? "deleted" : "changed"} (${kind}): its effects are not mapped`,
|
|
25463
|
+
group: { kind: "UNMAPPED", subject: `${file2.path}${deleted ? " deleted" : ""} (${kind})` }
|
|
25464
|
+
});
|
|
25308
25465
|
unmapped.push({ path: file2.path, kind });
|
|
25309
25466
|
}
|
|
25310
25467
|
if (!objects2.length) continue;
|
|
@@ -25322,10 +25479,13 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
|
|
|
25322
25479
|
}
|
|
25323
25480
|
for (const relation of graph.relationsFrom(objects2.map((object2) => object2.id))) {
|
|
25324
25481
|
const route = mapRegisteredRoute(relation);
|
|
25325
|
-
if (route && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine))
|
|
25326
|
-
|
|
25327
|
-
|
|
25328
|
-
|
|
25482
|
+
if (route && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine)) {
|
|
25483
|
+
const site = `${relation.anchor.path}:${relation.anchor.startLine}`;
|
|
25484
|
+
unclear.push({
|
|
25485
|
+
text: `the registration of ${JSON.stringify(route)} at ${site} changed; check that the route still reaches the right handler`,
|
|
25486
|
+
group: { kind: "REGISTRATION", subject: site, route }
|
|
25487
|
+
});
|
|
25488
|
+
}
|
|
25329
25489
|
}
|
|
25330
25490
|
if (analyzed && topLevel && file2.status !== "ADDED") topLevelChanged(file2.path);
|
|
25331
25491
|
importerTests(graph, objects2, tracer, importers);
|
|
@@ -25378,11 +25538,11 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
|
|
|
25378
25538
|
await tracer.release(climbing);
|
|
25379
25539
|
}
|
|
25380
25540
|
if (unfound.length)
|
|
25381
|
-
unclear.push(
|
|
25382
|
-
`no test is found to request ${unfound.length > 1 ? `${unfound.length} routes the change reaches (` : ""}${unfound.slice(0, LIST.names).map((label) => JSON.stringify(label)).join(
|
|
25541
|
+
unclear.push({
|
|
25542
|
+
text: `no test is found to request ${unfound.length > 1 ? `${unfound.length} routes the change reaches (` : ""}${unfound.slice(0, LIST.names).map((label) => JSON.stringify(label)).join(
|
|
25383
25543
|
", "
|
|
25384
25544
|
)}${unfound.length > LIST.names ? ", \u2026" : ""}${unfound.length > 1 ? ")" : ""}: a test requesting ${unfound.length > 1 ? "them" : "it"} in a way the map does not read is not selected`
|
|
25385
|
-
);
|
|
25545
|
+
});
|
|
25386
25546
|
if (tracer.held.size) await unworkedRequests(routeRequests(), tracer, reaching);
|
|
25387
25547
|
if (requests?.unsearched)
|
|
25388
25548
|
incomplete.push(
|
|
@@ -25390,11 +25550,11 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
|
|
|
25390
25550
|
);
|
|
25391
25551
|
const unread = [...tracer.shapes.unread];
|
|
25392
25552
|
if (unread.length)
|
|
25393
|
-
unclear.push(
|
|
25394
|
-
`who uses ${unread.length} fields or types the change reaches was not read, so what they affect is not known (${unread.slice(0, LIST.names).map((ref) => graph.qualifiedName(ref)).join(
|
|
25553
|
+
unclear.push({
|
|
25554
|
+
text: `who uses ${unread.length} fields or types the change reaches was not read, so what they affect is not known (${unread.slice(0, LIST.names).map((ref) => graph.qualifiedName(ref)).join(
|
|
25395
25555
|
", "
|
|
25396
25556
|
)}${unread.length > LIST.names ? ", \u2026" : ""}); project_find_references lists their uses`
|
|
25397
|
-
);
|
|
25557
|
+
});
|
|
25398
25558
|
const untested = tests && await untestedChanges(graph, tracer, memberCalls, starts, changed, tests);
|
|
25399
25559
|
supportTests(store, working, tracer);
|
|
25400
25560
|
const taken = base ? await mapRemovedImpact({
|
|
@@ -25429,7 +25589,9 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
|
|
|
25429
25589
|
through: [...known.through].sort(),
|
|
25430
25590
|
tests: [...known.tests].map(([path20, names]) => ({ path: path20, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
|
|
25431
25591
|
})).sort((left, right) => right.tests.length - left.tests.length),
|
|
25432
|
-
unclear: [
|
|
25592
|
+
unclear: [
|
|
25593
|
+
...new Map([...unclear, ...tracer.unclear].map((note) => [note.text, note])).values()
|
|
25594
|
+
],
|
|
25433
25595
|
incomplete: [
|
|
25434
25596
|
...incomplete,
|
|
25435
25597
|
...tracer.truncated ? [
|
|
@@ -25518,7 +25680,7 @@ function mapChangesData(changes, impact, edges) {
|
|
|
25518
25680
|
tests: impact.tests,
|
|
25519
25681
|
unmapped: impact.unmapped,
|
|
25520
25682
|
incomplete: impact.incomplete,
|
|
25521
|
-
checkByHand: impact.unclear,
|
|
25683
|
+
checkByHand: impact.unclear.map(({ text }) => text),
|
|
25522
25684
|
truncated: impact.truncated,
|
|
25523
25685
|
...impact.untested ? { untested: impact.untested } : {},
|
|
25524
25686
|
edges
|
|
@@ -26379,7 +26541,7 @@ var mapToolDescriptions = (host) => {
|
|
|
26379
26541
|
return Object.freeze({
|
|
26380
26542
|
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.`,
|
|
26381
26543
|
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.`,
|
|
26382
|
-
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, and the code using a field or type, up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path
|
|
26544
|
+
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, and the code using a field or type, up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path, the chain to the change and whether the diff changed its registration; POSSIBLY AFFECTED ones reached only through a call on an interface or base member, or through code that uses a changed field or type; 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; NEW COMPILE ERRORS, what the compiler reports on lines the diff left unchanged and did not report before, in code a tsconfig covers; PACKAGES NOT FOUND, packages the changed code needs that are not installed in this directory, whose types the trace then lacks; 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, and that nothing extends, implements, overrides or wires with a decorator; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed registrations of routes not listed above, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, closest first, the existing test files the diff changed, that call or use the changed code, request a route it reaches, may request one through a path the map does not work out, spell out a stretch of such a route's path in their text, may call it through a receiver of unknown type or through a test support file beside or above them, import a changed file, are named for its module or sit beside it; given tests, NOT REACHED BY THE GIVEN TESTS, the changed declarations none of them calls or requests through a route, or uses when it is a field or type, with the entry points above them, the other tests of the project that run them, and those the given tests may run through a request whose path the map does not work out. 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, removing the old if the new replaces it, or having the existing code use the new where it is the one that can, unless the two are meant to differ, and changing existing code only where it is part of the task while telling the user of the rest; 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.`,
|
|
26383
26545
|
references: `${lead("references")}Compute usages of a mapped declaration from current source, including aliases, re-exports and non-call references. Select it as project_explore_map does, with path (its file) and name as printed by project_explore_map or project_search_map, and line (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. within 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.`
|
|
26384
26546
|
});
|
|
26385
26547
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
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.51");
|
|
297
297
|
for (const tool of tools) {
|
|
298
298
|
if (registered.has(tool.name)) continue;
|
|
299
299
|
registered.add(tool.name);
|