layermap 0.1.14 → 0.1.15
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 +4 -2
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/dist/cli.mjs +219 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -140,7 +140,9 @@ and the existing tests related to the change. When the changed code serves sever
|
|
|
140
140
|
or modules), it names each one with its tests, and it names the existing tests the diff rewrote, so
|
|
141
141
|
a change meant for one feature does not quietly change the others. Environment variables and
|
|
142
142
|
configuration keys are linked by name only, which no compiler sees, so when the diff removes one
|
|
143
|
-
from a file, the check names the files that still read or set the old name.
|
|
143
|
+
from a file, the check names the files that still read or set the old name. In the same way, when
|
|
144
|
+
the change reaches a route's handler or renames a route, it names the code and templates that
|
|
145
|
+
request that path: a frontend's fetch, a generated API client, a redirect or a link. It never writes or runs tests. In Claude Code the
|
|
144
146
|
plugin asks the agent once, before it finishes, to run this check if it edited code in the repository
|
|
145
147
|
and has not checked since (changes another session makes in the same work tree do not count); set
|
|
146
148
|
`LAYERMAP_STOP_CHECK=0` to turn that off. Codex and DeepSeek Harness are told to run it.
|
|
@@ -177,7 +179,7 @@ nothing anywhere ([privacy](https://github.com/coffeecoproject/layermap/blob/mai
|
|
|
177
179
|
| `project_explore_map` | A directory, a file, or a declaration's callers and callees (`direction` INCOMING or OUTGOING, `depth` up to 8). |
|
|
178
180
|
| `project_search_map` | Find declarations by words in their names, paths or documentation. |
|
|
179
181
|
| `project_find_references` | Every usage of a declaration, compiled from current source. |
|
|
180
|
-
| `project_check_changes` | What the uncommitted changes (or those since `base`) affect: changed and removed declarations, the routes, jobs and commands they reach, the areas that share the changed code, environment variables and configuration keys it removed that other files still use, what to check by hand, and related tests. |
|
|
182
|
+
| `project_check_changes` | What the uncommitted changes (or those since `base`) affect: changed and removed declarations, the routes, jobs and commands they reach, the areas that share the changed code, environment variables and configuration keys it removed that other files still use, code and templates that request the affected routes, what to check by hand, and related tests. |
|
|
181
183
|
|
|
182
184
|
The same from the command line:
|
|
183
185
|
|
|
Binary file
|
package/dist/cli.mjs
CHANGED
|
@@ -501,15 +501,15 @@ var ProjectEvidencePolicyError = class extends Error {
|
|
|
501
501
|
code;
|
|
502
502
|
};
|
|
503
503
|
var assertProjectEvidencePathNotSensitive = (relativePath) => {
|
|
504
|
-
const
|
|
505
|
-
const basename =
|
|
504
|
+
const segments2 = relativePath.toLowerCase().split("/");
|
|
505
|
+
const basename = segments2.at(-1) ?? "";
|
|
506
506
|
const extension = path3.posix.extname(basename);
|
|
507
507
|
const containsSensitiveSequence = sensitiveSegmentSequences.some(
|
|
508
|
-
(sequence) =>
|
|
509
|
-
(_, start) => sequence.every((segment, offset) =>
|
|
508
|
+
(sequence) => segments2.length >= sequence.length && segments2.some(
|
|
509
|
+
(_, start) => sequence.every((segment, offset) => segments2[start + offset] === segment)
|
|
510
510
|
)
|
|
511
511
|
);
|
|
512
|
-
if (
|
|
512
|
+
if (segments2.some((segment) => sensitiveSegmentSet.has(segment)) || containsSensitiveSequence || sensitiveBasenameSet.has(basename) || basename === ".env" || basename.startsWith(".env.") || // SQLite databases and their journals hold application data, never project source.
|
|
513
513
|
basename.endsWith(".sqlite") || basename.includes(".sqlite-") || sensitiveExtensionSet.has(extension)) {
|
|
514
514
|
throw new ProjectEvidencePolicyError("PROJECT_CONTENT_RESTRICTED");
|
|
515
515
|
}
|
|
@@ -15518,9 +15518,9 @@ var includesInitialEvidencePath = (relativePath, scope) => {
|
|
|
15518
15518
|
))
|
|
15519
15519
|
return false;
|
|
15520
15520
|
if (isProjectEvidenceTraversalExcluded(relativePath)) return false;
|
|
15521
|
-
const
|
|
15522
|
-
if (
|
|
15523
|
-
const basename =
|
|
15521
|
+
const segments2 = relativePath.toLowerCase().split("/");
|
|
15522
|
+
if (segments2.slice(0, -1).some((segment) => excluded.has(segment))) return false;
|
|
15523
|
+
const basename = segments2.at(-1) ?? "";
|
|
15524
15524
|
return extensions.has(path6.posix.extname(basename)) || SOURCE_POLICY.documentationFiles.includes(basename) || SOURCE_POLICY.configurationFiles.includes(basename) || SOURCE_POLICY.workspaceFiles.includes(relativePath);
|
|
15525
15525
|
};
|
|
15526
15526
|
|
|
@@ -20348,11 +20348,11 @@ var CodeIndexQuery = class {
|
|
|
20348
20348
|
if (basePrefix && !file2.startsWith(basePrefix)) continue;
|
|
20349
20349
|
const relativeToBase = basePrefix ? file2.slice(basePrefix.length) : file2;
|
|
20350
20350
|
if (!relativeToBase) continue;
|
|
20351
|
-
const
|
|
20352
|
-
const visibleDepth = Math.min(input.depth,
|
|
20351
|
+
const segments2 = relativeToBase.split("/");
|
|
20352
|
+
const visibleDepth = Math.min(input.depth, segments2.length);
|
|
20353
20353
|
for (let index = 0; index < visibleDepth; index += 1) {
|
|
20354
|
-
const entryPath = [base, ...
|
|
20355
|
-
const kind = index ===
|
|
20354
|
+
const entryPath = [base, ...segments2.slice(0, index + 1)].filter(Boolean).join("/");
|
|
20355
|
+
const kind = index === segments2.length - 1 ? "FILE" : "DIRECTORY";
|
|
20356
20356
|
if (candidates.get(entryPath) !== "DIRECTORY") candidates.set(entryPath, kind);
|
|
20357
20357
|
}
|
|
20358
20358
|
}
|
|
@@ -21956,6 +21956,154 @@ var CodeIndex = class {
|
|
|
21956
21956
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
21957
21957
|
import path9 from "node:path";
|
|
21958
21958
|
|
|
21959
|
+
// src/project-map-clients.ts
|
|
21960
|
+
var CLIENT_FILES = [
|
|
21961
|
+
"ts",
|
|
21962
|
+
"tsx",
|
|
21963
|
+
"mts",
|
|
21964
|
+
"cts",
|
|
21965
|
+
"js",
|
|
21966
|
+
"jsx",
|
|
21967
|
+
"mjs",
|
|
21968
|
+
"cjs",
|
|
21969
|
+
"go",
|
|
21970
|
+
"py",
|
|
21971
|
+
"java",
|
|
21972
|
+
"kt",
|
|
21973
|
+
"html",
|
|
21974
|
+
"htm",
|
|
21975
|
+
"jinja",
|
|
21976
|
+
"jinja2",
|
|
21977
|
+
"j2",
|
|
21978
|
+
"hbs",
|
|
21979
|
+
"ejs",
|
|
21980
|
+
"tmpl",
|
|
21981
|
+
"tpl",
|
|
21982
|
+
"gohtml",
|
|
21983
|
+
"vue",
|
|
21984
|
+
"svelte"
|
|
21985
|
+
].map((extension) => `*.${extension}`);
|
|
21986
|
+
var PARAM = /^(?:\{[^}]*\}|\$\{[^}]*\}|:\w+\??|<[^>]*>|%[sdvqfx]|\[[^\]]+\]|\*{1,2}|\{\{.*\}\})$/u;
|
|
21987
|
+
var MOUNT = /^(?:api|v\d+(?:\.\d+)?|rest|public|internal|backend)$/iu;
|
|
21988
|
+
var LITERAL = /(["'`])((?:\\.|(?!\1)[^\\])*)\1/gu;
|
|
21989
|
+
var MOUNTING = /(?:\b(?:prefix|root_path|base_path|basePath|baseURL|baseUrl)\s*[=:]|\b(?:Group|Route|Mount|mount|use|include_router|PathPrefix|StripPrefix)\s*\()\s*$/u;
|
|
21990
|
+
var LIMIT = Object.freeze({ routes: 40, clients: 5 });
|
|
21991
|
+
var ROUTE = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
|
|
21992
|
+
var segments = (path13) => path13.split("/").filter(Boolean).map((text) => ({ text, param: PARAM.test(text) || /[{}$<>%]/u.test(text) }));
|
|
21993
|
+
var routeSegments = (label) => segments(label.slice(label.indexOf("/")));
|
|
21994
|
+
function requestedPath(literal3, joined) {
|
|
21995
|
+
const match = /^(?:https?:\/\/[^/\s]+|(?:\$\{[^}]*\})+|@\{|redirect:|forward:)?(\/[^\s?#()"'`,;|]*)/u.exec(
|
|
21996
|
+
literal3
|
|
21997
|
+
) ?? void 0;
|
|
21998
|
+
const path13 = match?.[1];
|
|
21999
|
+
if (!path13 || path13.startsWith("//") || path13.length < 3) return void 0;
|
|
22000
|
+
const parts = segments(path13);
|
|
22001
|
+
if (joined && path13.endsWith("/")) parts.push({ text: "*", param: true });
|
|
22002
|
+
return parts;
|
|
22003
|
+
}
|
|
22004
|
+
var same = (route, requested) => route.param || !requested.param && route.text === requested.text;
|
|
22005
|
+
function fit(route, requested) {
|
|
22006
|
+
const shorter = Math.min(route.length, requested.length);
|
|
22007
|
+
if (!shorter) return -1;
|
|
22008
|
+
const routeTail = route.slice(route.length - shorter);
|
|
22009
|
+
const requestedTail = requested.slice(requested.length - shorter);
|
|
22010
|
+
if (!routeTail.every((segment, index) => same(segment, requestedTail[index])))
|
|
22011
|
+
return -1;
|
|
22012
|
+
if (!routeTail.some((segment) => !segment.param && segment.text.length >= 3)) return -1;
|
|
22013
|
+
const extra = [
|
|
22014
|
+
...route.slice(0, route.length - shorter),
|
|
22015
|
+
...requested.slice(0, requested.length - shorter)
|
|
22016
|
+
];
|
|
22017
|
+
return extra.every((segment) => MOUNT.test(segment.text)) || shorter >= 2 ? extra.length : -1;
|
|
22018
|
+
}
|
|
22019
|
+
function routeRegistrations(store, version2) {
|
|
22020
|
+
const routes = /* @__PURE__ */ new Set();
|
|
22021
|
+
const sites2 = /* @__PURE__ */ new Set();
|
|
22022
|
+
for (const row of store.database.prepare(
|
|
22023
|
+
"SELECT relation_json FROM project_map_relations WHERE version_ref = ? AND (json_extract(relation_json, '$.route') IS NOT NULL OR json_extract(relation_json, '$.argument') LIKE '%/%')"
|
|
22024
|
+
).all(version2)) {
|
|
22025
|
+
const relation = JSON.parse(String(row.relation_json));
|
|
22026
|
+
const route = relation.route ?? relation.argument;
|
|
22027
|
+
if (!route || !ROUTE.test(route)) continue;
|
|
22028
|
+
routes.add(route);
|
|
22029
|
+
for (let line = relation.anchor.startLine; line <= relation.anchor.endLine; line++)
|
|
22030
|
+
sites2.add(`${relation.anchor.path}:${line}`);
|
|
22031
|
+
}
|
|
22032
|
+
return { routes, sites: sites2 };
|
|
22033
|
+
}
|
|
22034
|
+
async function routeClients(routes, registrations, git2, options) {
|
|
22035
|
+
const wanted = routes.map((entry) => ({ ...entry, segments: routeSegments(entry.route) })).filter((entry) => entry.segments.some((segment) => !segment.param && segment.text.length >= 3)).slice(0, LIMIT.routes);
|
|
22036
|
+
const known = [.../* @__PURE__ */ new Set([...registrations.routes, ...wanted.map((entry) => entry.route)])].map(
|
|
22037
|
+
(route) => ({ route, segments: routeSegments(route) })
|
|
22038
|
+
);
|
|
22039
|
+
const needles = /* @__PURE__ */ new Set();
|
|
22040
|
+
for (const entry of wanted)
|
|
22041
|
+
for (const segment of entry.segments) if (!segment.param) needles.add(`/${segment.text}`);
|
|
22042
|
+
if (!needles.size) return [];
|
|
22043
|
+
let found;
|
|
22044
|
+
try {
|
|
22045
|
+
found = (await git2.run(
|
|
22046
|
+
[
|
|
22047
|
+
"grep",
|
|
22048
|
+
"-n",
|
|
22049
|
+
"-I",
|
|
22050
|
+
"-F",
|
|
22051
|
+
"--untracked",
|
|
22052
|
+
"--full-name",
|
|
22053
|
+
"--no-color",
|
|
22054
|
+
...[...needles].flatMap((needle) => ["-e", needle]),
|
|
22055
|
+
"--",
|
|
22056
|
+
...CLIENT_FILES
|
|
22057
|
+
],
|
|
22058
|
+
options
|
|
22059
|
+
)).stdout.toString("utf8");
|
|
22060
|
+
} catch (error51) {
|
|
22061
|
+
if (error51 instanceof GitCommandError && !options.signal?.aborted) return [];
|
|
22062
|
+
throw error51;
|
|
22063
|
+
}
|
|
22064
|
+
const clients = /* @__PURE__ */ new Map();
|
|
22065
|
+
for (const hit of found.split("\n")) {
|
|
22066
|
+
const match = /^(.+?):(\d+):(.*)$/u.exec(hit);
|
|
22067
|
+
if (!match) continue;
|
|
22068
|
+
const [, file2 = "", line = "", text = ""] = match;
|
|
22069
|
+
if (mapTestPath(file2) || registrations.sites.has(`${file2}:${line}`)) continue;
|
|
22070
|
+
for (const literal3 of text.matchAll(LITERAL)) {
|
|
22071
|
+
if (MOUNTING.test(text.slice(0, literal3.index))) continue;
|
|
22072
|
+
const after = text.slice((literal3.index ?? 0) + literal3[0].length).trimStart();
|
|
22073
|
+
const requested = requestedPath(literal3[2] ?? "", after.startsWith("+"));
|
|
22074
|
+
if (!requested) continue;
|
|
22075
|
+
const fits = known.map((entry) => ({
|
|
22076
|
+
route: entry.route,
|
|
22077
|
+
extra: fit(entry.segments, requested),
|
|
22078
|
+
literal: entry.segments.filter((segment) => !segment.param).length
|
|
22079
|
+
})).filter((entry) => entry.extra >= 0);
|
|
22080
|
+
const fewest = Math.min(...fits.map((entry) => entry.extra));
|
|
22081
|
+
const named = Math.max(
|
|
22082
|
+
...fits.filter((entry) => entry.extra === fewest).map((entry) => entry.literal)
|
|
22083
|
+
);
|
|
22084
|
+
const mounted = MOUNT.test(requested[0]?.text ?? "");
|
|
22085
|
+
for (const entry of wanted)
|
|
22086
|
+
if (fits.some(
|
|
22087
|
+
(other) => other.route === entry.route && other.extra === fewest && other.literal === named
|
|
22088
|
+
))
|
|
22089
|
+
clients.set(
|
|
22090
|
+
entry.route,
|
|
22091
|
+
(clients.get(entry.route) ?? /* @__PURE__ */ new Map()).set(`${file2}:${line}`, mounted)
|
|
22092
|
+
);
|
|
22093
|
+
}
|
|
22094
|
+
}
|
|
22095
|
+
return wanted.map(({ route, removed }) => {
|
|
22096
|
+
const found2 = [...clients.get(route) ?? []];
|
|
22097
|
+
const mounted = found2.some(([, prefixed]) => prefixed);
|
|
22098
|
+
return {
|
|
22099
|
+
route,
|
|
22100
|
+
removed,
|
|
22101
|
+
clients: found2.filter(([, prefixed]) => prefixed || !mounted).map(([site]) => site)
|
|
22102
|
+
};
|
|
22103
|
+
}).filter((entry) => entry.clients.length);
|
|
22104
|
+
}
|
|
22105
|
+
var routeClientsLine = ({ route, removed, clients }) => `${JSON.stringify(route)}${removed ? " (removed or renamed)" : ""} \u2190 ${clients.slice(0, LIMIT.clients).join(", ")}${clients.length > LIMIT.clients ? `, +${clients.length - LIMIT.clients} more` : ""}`;
|
|
22106
|
+
|
|
21959
22107
|
// src/project-map-names.ts
|
|
21960
22108
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
21961
22109
|
import path8 from "node:path";
|
|
@@ -21976,7 +22124,7 @@ var NAME = /^[A-Za-z_][\w.-]+[A-Za-z0-9]$/u;
|
|
|
21976
22124
|
var UPPER = /^[A-Z][A-Z0-9_]*$/u;
|
|
21977
22125
|
var PLATFORM = /^(?:GITHUB_\w+|RUNNER_\w+|CI|NODE_ENV|PATH|HOME|USER|PWD|SHELL|LANG|LC_\w+|TZ|TERM|TMPDIR|TEMP|TMP|PYTHONPATH|GOPATH|GOOS|GOARCH|JAVA_HOME)$/u;
|
|
21978
22126
|
var HISTORY = /(?:^|\/)(?:CHANGELOG|CHANGES|HISTORY|NEWS|RELEASES?|release[-_ ]?notes)[^/]*$/iu;
|
|
21979
|
-
var
|
|
22127
|
+
var LIMIT2 = Object.freeze({ names: 50, mentions: 5 });
|
|
21980
22128
|
var literal2 = (text) => text.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
21981
22129
|
var wholeName = (name) => new RegExp(`(?<![\\w-])${literal2(name)}(?![\\w-])`, "u");
|
|
21982
22130
|
var quotedName = (name) => new RegExp(
|
|
@@ -22042,7 +22190,7 @@ async function strandedNames(project, diff, files, configuration, git2, options)
|
|
|
22042
22190
|
if (NAME.test(name) && !PLATFORM.test(name) && !from.has(name) && !wholeName(name).test(text))
|
|
22043
22191
|
from.set(name, { path: file2.path, code: !config2 });
|
|
22044
22192
|
}
|
|
22045
|
-
const names = [...from.keys()].slice(0,
|
|
22193
|
+
const names = [...from.keys()].slice(0, LIMIT2.names);
|
|
22046
22194
|
if (!names.length) return [];
|
|
22047
22195
|
const patterns = new Map(
|
|
22048
22196
|
names.map((name) => [name, { whole: wholeName(name), quoted: quotedName(name) }])
|
|
@@ -22101,7 +22249,7 @@ async function strandedNames(project, diff, files, configuration, git2, options)
|
|
|
22101
22249
|
mentions: mentions.get(name) ?? []
|
|
22102
22250
|
}));
|
|
22103
22251
|
}
|
|
22104
|
-
var strandedNameLine = ({ name, from, mentions }) => `${name}, gone from ${from}: ${mentions.slice(0,
|
|
22252
|
+
var strandedNameLine = ({ name, from, mentions }) => `${name}, gone from ${from}: ${mentions.slice(0, LIMIT2.mentions).join(", ")}${mentions.length > LIMIT2.mentions ? `, +${mentions.length - LIMIT2.mentions} more` : ""}`;
|
|
22105
22253
|
|
|
22106
22254
|
// src/project-map-changes.ts
|
|
22107
22255
|
var git = new GitRunner();
|
|
@@ -22238,7 +22386,7 @@ var nonCodeKind = (path13) => NON_CODE.find(([pattern]) => pattern.test(path13))
|
|
|
22238
22386
|
var LIMITS = Object.freeze({ depth: 8, declarations: 800, changed: 200, chain: 3, byName: 40 });
|
|
22239
22387
|
var CALLER_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES"]);
|
|
22240
22388
|
var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
22241
|
-
var
|
|
22389
|
+
var ROUTE2 = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
|
|
22242
22390
|
var areaOf = (file2) => /\.(?:go|java|kt)$/u.test(file2) ? file2.slice(0, file2.lastIndexOf("/") + 1) || "./" : file2;
|
|
22243
22391
|
var Tracer = class {
|
|
22244
22392
|
constructor(graph, memberCalls) {
|
|
@@ -22285,7 +22433,7 @@ var Tracer = class {
|
|
|
22285
22433
|
for (const caller of callers) {
|
|
22286
22434
|
const site = `${caller.relation.anchor.path}:${caller.relation.anchor.startLine}`;
|
|
22287
22435
|
const certain = current.certain && caller.certain;
|
|
22288
|
-
if (caller.relation.argument &&
|
|
22436
|
+
if (caller.relation.argument && ROUTE2.test(caller.relation.argument))
|
|
22289
22437
|
this.entry(caller.relation.argument, true, current, site, certain);
|
|
22290
22438
|
const callerObject = this.graph.object(caller.ref);
|
|
22291
22439
|
if (testCode(callerObject.anchor.path)) {
|
|
@@ -22386,7 +22534,7 @@ var Tracer = class {
|
|
|
22386
22534
|
for (const relation of this.graph.relationsFrom([current.ref])) {
|
|
22387
22535
|
if (relation.kind !== "DECORATED_BY") continue;
|
|
22388
22536
|
const route = relation.route ?? relation.argument;
|
|
22389
|
-
if (!route || !
|
|
22537
|
+
if (!route || !ROUTE2.test(route)) continue;
|
|
22390
22538
|
this.routes.add(current.ref);
|
|
22391
22539
|
this.entry(
|
|
22392
22540
|
route,
|
|
@@ -22489,7 +22637,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22489
22637
|
starts.push(ref);
|
|
22490
22638
|
}
|
|
22491
22639
|
for (const relation of graph.relationsFrom(objects2.map((object2) => object2.id)))
|
|
22492
|
-
if (relation.argument &&
|
|
22640
|
+
if (relation.argument && ROUTE2.test(relation.argument) && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine))
|
|
22493
22641
|
unclear.push(
|
|
22494
22642
|
`the registration of ${JSON.stringify(relation.argument)} at ${relation.anchor.path}:${relation.anchor.startLine} changed; check that the route still reaches the right handler`
|
|
22495
22643
|
);
|
|
@@ -22503,8 +22651,18 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22503
22651
|
if (project) routeTests(project, store, working, [...tracer.entries.values()], tracer);
|
|
22504
22652
|
supportTests(store, working, tracer);
|
|
22505
22653
|
const rewrittenTests = [];
|
|
22654
|
+
const removedRoutes = [];
|
|
22506
22655
|
if (base) {
|
|
22507
22656
|
const before = new MapViewGraph(store, base);
|
|
22657
|
+
const registered = /* @__PURE__ */ new Set();
|
|
22658
|
+
for (const file2 of changes.files)
|
|
22659
|
+
if (file2.status !== "DELETED")
|
|
22660
|
+
for (const route of routesIn(graph, file2.path)) registered.add(route);
|
|
22661
|
+
for (const file2 of changes.files)
|
|
22662
|
+
if (file2.basePath && file2.status !== "ADDED") {
|
|
22663
|
+
for (const route of routesIn(before, file2.basePath))
|
|
22664
|
+
if (!registered.has(route) && !removedRoutes.includes(route)) removedRoutes.push(route);
|
|
22665
|
+
}
|
|
22508
22666
|
for (const file2 of changes.files)
|
|
22509
22667
|
if (file2.basePath && file2.baseText !== void 0 && testCode(file2.basePath)) {
|
|
22510
22668
|
const names = existingTestsChanged(before, graph, file2, project);
|
|
@@ -22574,6 +22732,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22574
22732
|
tests: [...known.tests].map(([path13, names]) => ({ path: path13, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
|
|
22575
22733
|
})).sort((left, right) => right.tests.length - left.tests.length),
|
|
22576
22734
|
unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
|
|
22735
|
+
removedRoutes,
|
|
22577
22736
|
truncated: tracer.truncated
|
|
22578
22737
|
};
|
|
22579
22738
|
}
|
|
@@ -22712,13 +22871,39 @@ var LIST = Object.freeze({
|
|
|
22712
22871
|
tests: 12,
|
|
22713
22872
|
unclear: 20,
|
|
22714
22873
|
stranded: 12,
|
|
22874
|
+
clients: 8,
|
|
22715
22875
|
names: 6,
|
|
22716
22876
|
areas: 8,
|
|
22717
22877
|
areaTests: 3,
|
|
22718
22878
|
areaNames: 3,
|
|
22719
22879
|
through: 2
|
|
22720
22880
|
});
|
|
22721
|
-
function
|
|
22881
|
+
function routesIn(graph, path13) {
|
|
22882
|
+
const routes = /* @__PURE__ */ new Set();
|
|
22883
|
+
for (const relation of graph.relationsFrom(graph.objectsAt(path13).map((object2) => object2.id))) {
|
|
22884
|
+
const route = relation.kind === "DECORATED_BY" ? relation.route ?? relation.argument : relation.argument;
|
|
22885
|
+
if (route && ROUTE2.test(route)) routes.add(route);
|
|
22886
|
+
}
|
|
22887
|
+
return routes;
|
|
22888
|
+
}
|
|
22889
|
+
var routePath = (route) => route.slice(route.indexOf("/"));
|
|
22890
|
+
async function mapRouteClients(project, store, working, impact, signal) {
|
|
22891
|
+
const affected = impact.entries.filter(
|
|
22892
|
+
(entry) => entry.route && entry.certain && entry.chain.length <= 2
|
|
22893
|
+
);
|
|
22894
|
+
if (!affected.length && !impact.removedRoutes.length) return [];
|
|
22895
|
+
const registrations = routeRegistrations(store, working);
|
|
22896
|
+
const served = (route) => registrations.routes.has(route) || [...registrations.routes].some(
|
|
22897
|
+
(other) => !other.startsWith("/") && routePath(other) === routePath(route)
|
|
22898
|
+
);
|
|
22899
|
+
const routes = [
|
|
22900
|
+
...affected.map((entry) => ({ route: entry.label, removed: false })),
|
|
22901
|
+
...impact.removedRoutes.filter((route) => !served(route)).map((route) => ({ route, removed: true }))
|
|
22902
|
+
];
|
|
22903
|
+
if (!routes.length) return [];
|
|
22904
|
+
return routeClients(routes, registrations, git, gitOptions(project, signal));
|
|
22905
|
+
}
|
|
22906
|
+
function mapChangesText(changes, impact, clients = []) {
|
|
22722
22907
|
const files = changes.files.length;
|
|
22723
22908
|
const direct = impact.tests.filter((test) => test.rank < 4);
|
|
22724
22909
|
const indirect = impact.tests.filter((test) => test.rank >= 4);
|
|
@@ -22787,6 +22972,16 @@ Nothing changed against ${changes.base}.`;
|
|
|
22787
22972
|
impact.entries.filter((e) => !e.certain).map(entry),
|
|
22788
22973
|
LIST.entries
|
|
22789
22974
|
);
|
|
22975
|
+
if (clients.length) {
|
|
22976
|
+
list(
|
|
22977
|
+
"REQUESTED BY (code and templates outside the tests that request these routes' paths, found by text)",
|
|
22978
|
+
clients.map(routeClientsLine),
|
|
22979
|
+
LIST.clients
|
|
22980
|
+
);
|
|
22981
|
+
lines.push(
|
|
22982
|
+
"If the change alters what a route accepts or returns, or its path, these callers must change with it. Paths built at run time are not found."
|
|
22983
|
+
);
|
|
22984
|
+
}
|
|
22790
22985
|
list(
|
|
22791
22986
|
"CHECK BY HAND (the map cannot see these)",
|
|
22792
22987
|
[
|
|
@@ -22986,10 +23181,12 @@ var LayerMap = class _LayerMap {
|
|
|
22986
23181
|
const base = changes.files.some(
|
|
22987
23182
|
(file2) => file2.basePath !== void 0 && (file2.baseLines.length || file2.baseText !== void 0)
|
|
22988
23183
|
) ? await this.versionAt(changes.commit, signal) : void 0;
|
|
23184
|
+
const impact = mapChangeImpact(this.store, working, base, changes, this.project);
|
|
22989
23185
|
return {
|
|
22990
23186
|
text: mapChangesText(
|
|
22991
23187
|
changes,
|
|
22992
|
-
|
|
23188
|
+
impact,
|
|
23189
|
+
await mapRouteClients(this.project, this.store, working, impact, signal)
|
|
22993
23190
|
)
|
|
22994
23191
|
};
|
|
22995
23192
|
}
|
|
@@ -23222,7 +23419,7 @@ var mapToolDescriptions = (host) => {
|
|
|
23222
23419
|
return Object.freeze({
|
|
23223
23420
|
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.`,
|
|
23224
23421
|
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.`,
|
|
23225
|
-
check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; 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; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it. It does not run or write tests: run the related ones if the change needs verifying; a failing or rewritten test of a feature the request is not about means the change leaked, so restore the test and narrow the change; 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.`,
|
|
23422
|
+
check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; REQUESTED BY, the code and templates outside the tests that request the path of a route whose handler the change reaches or a route it removed, found by text; EXISTING TESTS CHANGED, the tests that existed before the diff and whose code it changed or removed; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; NAMES STILL USED ELSEWHERE, environment variables and configuration keys the diff removed from a file that other files still read or set, found by text; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it. It does not run or write tests: run the related ones if the change needs verifying; a failing or rewritten test of a feature the request is not about means the change leaked, so restore the test and narrow the change; 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.`,
|
|
23226
23423
|
references: `${lead("references")}Compute usages of a mapped declaration from current source, including aliases, re-exports and non-call references. Select it with symbol {path,name,line?} as printed by project_explore_map or project_search_map (line is its start line when names repeat), or with an entityRef or locator {path,start,kind}. Broader and more expensive than the cached callers in project_explore_map; file or unsupported declarations may lack a reference target. path and kinds filter usage locations before paging. ${host.grantRules}objects contains compact declarations; targetRef and reference ownerRef identify them. ${host.readReference} A file that several compiler contexts read (such as packages of one workspace) lists its references once per context, each with that context's configPath. Continue with nextCursor and unchanged conditions, including after an empty partial page. Filtered exhaustion and missing results do not prove absence.`
|
|
23227
23424
|
});
|
|
23228
23425
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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",
|