layermap 0.1.53 → 0.1.54
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 +10 -0
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/dist/cli.mjs +567 -455
- package/package.json +1 -1
- package/pi/layermap.mjs +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
10
|
import { realpath as realpath4 } from "node:fs/promises";
|
|
11
|
-
import
|
|
11
|
+
import path20 from "node:path";
|
|
12
12
|
import { parseArgs } from "node:util";
|
|
13
13
|
|
|
14
14
|
// src/agent/call-log.ts
|
|
@@ -34,6 +34,11 @@ function mapCallLog(cache) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// src/agent/command.ts
|
|
38
|
+
import { chmod, lstat as lstat5, mkdir as mkdir3, readFile as readFile6, rename as rename3, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
39
|
+
import { homedir as homedir2 } from "node:os";
|
|
40
|
+
import path17 from "node:path";
|
|
41
|
+
|
|
37
42
|
// src/agent/environment.ts
|
|
38
43
|
import { createHash as createHash6 } from "node:crypto";
|
|
39
44
|
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
@@ -344,9 +349,9 @@ async function gitGrep(git2, search, options) {
|
|
|
344
349
|
}
|
|
345
350
|
const hits = [];
|
|
346
351
|
for (const record2 of found.split("\n")) {
|
|
347
|
-
const [
|
|
348
|
-
if (
|
|
349
|
-
hits.push({ path:
|
|
352
|
+
const [path21, line, text, extra] = record2.split("\0");
|
|
353
|
+
if (path21 && line && text !== void 0 && extra === void 0)
|
|
354
|
+
hits.push({ path: path21, line: Number(line), text });
|
|
350
355
|
}
|
|
351
356
|
return { hits };
|
|
352
357
|
}
|
|
@@ -1370,10 +1375,10 @@ function mergeDefs(...defs) {
|
|
|
1370
1375
|
function cloneDef(schema) {
|
|
1371
1376
|
return mergeDefs(schema._zod.def);
|
|
1372
1377
|
}
|
|
1373
|
-
function getElementAtPath(obj,
|
|
1374
|
-
if (!
|
|
1378
|
+
function getElementAtPath(obj, path21) {
|
|
1379
|
+
if (!path21)
|
|
1375
1380
|
return obj;
|
|
1376
|
-
return
|
|
1381
|
+
return path21.reduce((acc, key) => acc?.[key], obj);
|
|
1377
1382
|
}
|
|
1378
1383
|
function promiseAllObject(promisesObj) {
|
|
1379
1384
|
const keys = Object.keys(promisesObj);
|
|
@@ -1782,11 +1787,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1782
1787
|
}
|
|
1783
1788
|
return false;
|
|
1784
1789
|
}
|
|
1785
|
-
function prefixIssues(
|
|
1790
|
+
function prefixIssues(path21, issues) {
|
|
1786
1791
|
return issues.map((iss) => {
|
|
1787
1792
|
var _a3;
|
|
1788
1793
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1789
|
-
iss.path.unshift(
|
|
1794
|
+
iss.path.unshift(path21);
|
|
1790
1795
|
return iss;
|
|
1791
1796
|
});
|
|
1792
1797
|
}
|
|
@@ -1933,16 +1938,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1933
1938
|
}
|
|
1934
1939
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1935
1940
|
const fieldErrors = { _errors: [] };
|
|
1936
|
-
const processError = (error52,
|
|
1941
|
+
const processError = (error52, path21 = []) => {
|
|
1937
1942
|
for (const issue2 of error52.issues) {
|
|
1938
1943
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1939
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1944
|
+
issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
|
|
1940
1945
|
} else if (issue2.code === "invalid_key") {
|
|
1941
|
-
processError({ issues: issue2.issues }, [...
|
|
1946
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
1942
1947
|
} else if (issue2.code === "invalid_element") {
|
|
1943
|
-
processError({ issues: issue2.issues }, [...
|
|
1948
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
1944
1949
|
} else {
|
|
1945
|
-
const fullpath = [...
|
|
1950
|
+
const fullpath = [...path21, ...issue2.path];
|
|
1946
1951
|
if (fullpath.length === 0) {
|
|
1947
1952
|
fieldErrors._errors.push(mapper(issue2));
|
|
1948
1953
|
} else {
|
|
@@ -1969,17 +1974,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1969
1974
|
}
|
|
1970
1975
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1971
1976
|
const result = { errors: [] };
|
|
1972
|
-
const processError = (error52,
|
|
1977
|
+
const processError = (error52, path21 = []) => {
|
|
1973
1978
|
var _a3, _b;
|
|
1974
1979
|
for (const issue2 of error52.issues) {
|
|
1975
1980
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1976
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1981
|
+
issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
|
|
1977
1982
|
} else if (issue2.code === "invalid_key") {
|
|
1978
|
-
processError({ issues: issue2.issues }, [...
|
|
1983
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
1979
1984
|
} else if (issue2.code === "invalid_element") {
|
|
1980
|
-
processError({ issues: issue2.issues }, [...
|
|
1985
|
+
processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
|
|
1981
1986
|
} else {
|
|
1982
|
-
const fullpath = [...
|
|
1987
|
+
const fullpath = [...path21, ...issue2.path];
|
|
1983
1988
|
if (fullpath.length === 0) {
|
|
1984
1989
|
result.errors.push(mapper(issue2));
|
|
1985
1990
|
continue;
|
|
@@ -2011,8 +2016,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
2011
2016
|
}
|
|
2012
2017
|
function toDotPath(_path) {
|
|
2013
2018
|
const segs = [];
|
|
2014
|
-
const
|
|
2015
|
-
for (const seg of
|
|
2019
|
+
const path21 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
2020
|
+
for (const seg of path21) {
|
|
2016
2021
|
if (typeof seg === "number")
|
|
2017
2022
|
segs.push(`[${seg}]`);
|
|
2018
2023
|
else if (typeof seg === "symbol")
|
|
@@ -14704,13 +14709,13 @@ function resolveRef(ref, ctx) {
|
|
|
14704
14709
|
if (!ref.startsWith("#")) {
|
|
14705
14710
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14706
14711
|
}
|
|
14707
|
-
const
|
|
14708
|
-
if (
|
|
14712
|
+
const path21 = ref.slice(1).split("/").filter(Boolean);
|
|
14713
|
+
if (path21.length === 0) {
|
|
14709
14714
|
return ctx.rootSchema;
|
|
14710
14715
|
}
|
|
14711
14716
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14712
|
-
if (
|
|
14713
|
-
const key =
|
|
14717
|
+
if (path21[0] === defsKey) {
|
|
14718
|
+
const key = path21[1];
|
|
14714
14719
|
if (!key || !ctx.defs[key]) {
|
|
14715
14720
|
throw new Error(`Reference not found: ${ref}`);
|
|
14716
14721
|
}
|
|
@@ -16117,8 +16122,8 @@ var MapAnalysisSchema = external_exports.object({
|
|
|
16117
16122
|
var mapPathAllowed = (relative, prefixes) => prefixes.some(
|
|
16118
16123
|
(prefix) => prefix === "." || relative === prefix || relative.startsWith(`${prefix}/`)
|
|
16119
16124
|
);
|
|
16120
|
-
var mapTestPath = (
|
|
16121
|
-
|
|
16125
|
+
var mapTestPath = (path21) => /(?:^|\/)(?:__tests__|tests?|fixtures?|testFixtures|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
|
|
16126
|
+
path21
|
|
16122
16127
|
);
|
|
16123
16128
|
var mapRunnableTest = (file2) => /_test\.(?:go|py)$|(?:^|\/)test_[^/]*\.py$|(?:\.(?:test|spec)|\.e2e-spec|(?:^|\/)__tests__\/.*)\.[cm]?[jt]sx?$|(?:^|\/)(?:Test|IT)[A-Z]\w*\.(?:java|kt)$|(?:Test|Tests|TestCase|IT|ITCase)\.(?:java|kt)$/u.test(
|
|
16124
16129
|
file2
|
|
@@ -16223,11 +16228,11 @@ var string4 = (value) => {
|
|
|
16223
16228
|
var identity = (id2, reconstructed) => id2 === reconstructed ? [] : [JSON.stringify(id2)];
|
|
16224
16229
|
function encodeMapText(graph) {
|
|
16225
16230
|
const files = /* @__PURE__ */ new Map();
|
|
16226
|
-
const file2 = (
|
|
16227
|
-
let ref = files.get(
|
|
16231
|
+
const file2 = (path21) => {
|
|
16232
|
+
let ref = files.get(path21);
|
|
16228
16233
|
if (!ref) {
|
|
16229
16234
|
ref = `F${files.size + 1}`;
|
|
16230
|
-
files.set(
|
|
16235
|
+
files.set(path21, ref);
|
|
16231
16236
|
}
|
|
16232
16237
|
return ref;
|
|
16233
16238
|
};
|
|
@@ -16275,7 +16280,7 @@ function encodeMapText(graph) {
|
|
|
16275
16280
|
rows2.push(`B ${node(frontier.entityRef)} ${frontier.direction}`);
|
|
16276
16281
|
return [
|
|
16277
16282
|
...header,
|
|
16278
|
-
...[...files].map(([
|
|
16283
|
+
...[...files].map(([path21, ref]) => `${ref} ${JSON.stringify(path21)}`),
|
|
16279
16284
|
...rows2
|
|
16280
16285
|
].join("\n");
|
|
16281
16286
|
}
|
|
@@ -16295,10 +16300,10 @@ function decodeMapText(text) {
|
|
|
16295
16300
|
const at = (value) => {
|
|
16296
16301
|
const match = /^(F[1-9]\d*):(\d+)-(\d+)@(\d+)-(\d+)$/u.exec(value ?? "");
|
|
16297
16302
|
if (!match) return failed();
|
|
16298
|
-
const
|
|
16299
|
-
if (
|
|
16303
|
+
const path21 = files.get(match[1] ?? "");
|
|
16304
|
+
if (path21 === void 0) return failed();
|
|
16300
16305
|
return MapAnchorSchema.parse({
|
|
16301
|
-
path:
|
|
16306
|
+
path: path21,
|
|
16302
16307
|
startLine: Number(match[2]),
|
|
16303
16308
|
endLine: Number(match[3]),
|
|
16304
16309
|
start: Number(match[4]),
|
|
@@ -16375,8 +16380,8 @@ function decodeMapText(text) {
|
|
|
16375
16380
|
var locationSchema = MapAnchorSchema.describe(
|
|
16376
16381
|
"Source location: start/end are zero-based UTF-16 offsets with an exclusive end; line numbers are one-based."
|
|
16377
16382
|
);
|
|
16378
|
-
var location = ({ path:
|
|
16379
|
-
path:
|
|
16383
|
+
var location = ({ path: path21, startLine, endLine, start, end }) => ({
|
|
16384
|
+
path: path21,
|
|
16380
16385
|
startLine,
|
|
16381
16386
|
endLine,
|
|
16382
16387
|
start,
|
|
@@ -16479,11 +16484,11 @@ var MapNavigationObjectsSchema = external_exports.union([
|
|
|
16479
16484
|
),
|
|
16480
16485
|
external_exports.object({ files: external_exports.array(searchFileSchema) }).passthrough().refine((value) => !("format" in value), "Text navigation must decode through its format.").transform(
|
|
16481
16486
|
(value) => value.files.flatMap(
|
|
16482
|
-
({ path:
|
|
16487
|
+
({ path: path21, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
|
|
16483
16488
|
id: id2,
|
|
16484
16489
|
name,
|
|
16485
16490
|
kind,
|
|
16486
|
-
anchor: { path:
|
|
16491
|
+
anchor: { path: path21, startLine, endLine, start, end },
|
|
16487
16492
|
...execution ? { execution } : {}
|
|
16488
16493
|
}))
|
|
16489
16494
|
)
|
|
@@ -16496,10 +16501,10 @@ var mapSearchNavigation = (result) => {
|
|
|
16496
16501
|
for (const [index, object2] of found.entries()) {
|
|
16497
16502
|
const ranking = rankings[index];
|
|
16498
16503
|
if (!ranking) throw new Error("PROJECT_MAP_SEARCH_RANKING_MISSING");
|
|
16499
|
-
const
|
|
16504
|
+
const path21 = object2.anchor.path;
|
|
16500
16505
|
let file2 = files.at(-1);
|
|
16501
|
-
if (file2?.path !==
|
|
16502
|
-
file2 = { path:
|
|
16506
|
+
if (file2?.path !== path21) {
|
|
16507
|
+
file2 = { path: path21, symbols: [] };
|
|
16503
16508
|
files.push(file2);
|
|
16504
16509
|
}
|
|
16505
16510
|
file2.symbols.push({
|
|
@@ -16630,8 +16635,8 @@ var MapViewGraph = class {
|
|
|
16630
16635
|
}
|
|
16631
16636
|
return object2;
|
|
16632
16637
|
}
|
|
16633
|
-
objectsAt(
|
|
16634
|
-
return this.statements.path.all(this.version,
|
|
16638
|
+
objectsAt(path21) {
|
|
16639
|
+
return this.statements.path.all(this.version, path21).map((row) => {
|
|
16635
16640
|
const object2 = MapObjectSchema.parse(JSON.parse(String(row.object_json)));
|
|
16636
16641
|
this.objects.set(object2.id, object2);
|
|
16637
16642
|
return object2;
|
|
@@ -16657,8 +16662,8 @@ var MapViewGraph = class {
|
|
|
16657
16662
|
return this.statements.children.all(this.version, ref).map((row) => String(row.to_ref));
|
|
16658
16663
|
}
|
|
16659
16664
|
/** The declarations of a file other code can name, without the file itself. */
|
|
16660
|
-
declarationsAt(
|
|
16661
|
-
return this.objectsAt(
|
|
16665
|
+
declarationsAt(path21) {
|
|
16666
|
+
return this.objectsAt(path21).filter(
|
|
16662
16667
|
(object2) => !mapIsModule(object2) && this.isAddressable(object2)
|
|
16663
16668
|
);
|
|
16664
16669
|
}
|
|
@@ -16766,8 +16771,8 @@ var MapViewGraph = class {
|
|
|
16766
16771
|
);
|
|
16767
16772
|
}
|
|
16768
16773
|
};
|
|
16769
|
-
function mapSelectDeclarations(graph,
|
|
16770
|
-
const objects2 = graph.objectsAt(
|
|
16774
|
+
function mapSelectDeclarations(graph, path21, name, line) {
|
|
16775
|
+
const objects2 = graph.objectsAt(path21).filter((object2) => !mapIsModule(object2));
|
|
16771
16776
|
const matching = name === void 0 ? objects2 : objects2.filter(
|
|
16772
16777
|
(object2) => object2.name === name || name.includes(".") && graph.qualifiedName(object2.id) === name
|
|
16773
16778
|
);
|
|
@@ -16789,12 +16794,12 @@ function requireMapObject(store, version2, selector, prefixes) {
|
|
|
16789
16794
|
if ([entityRef, locator, symbol2].filter((value) => value !== void 0).length !== 1 || entityRef !== void 0 && !entityRef.length)
|
|
16790
16795
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16791
16796
|
if (symbol2) {
|
|
16792
|
-
const
|
|
16793
|
-
if (!mapPathAllowed(
|
|
16797
|
+
const path21 = normalizeProjectEvidencePath(symbol2.path);
|
|
16798
|
+
if (!mapPathAllowed(path21, prefixes))
|
|
16794
16799
|
throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
|
|
16795
16800
|
const selected = mapSelectDeclarations(
|
|
16796
16801
|
new MapViewGraph(store, version2),
|
|
16797
|
-
|
|
16802
|
+
path21,
|
|
16798
16803
|
symbol2.name,
|
|
16799
16804
|
symbol2.line
|
|
16800
16805
|
);
|
|
@@ -16805,14 +16810,14 @@ function requireMapObject(store, version2, selector, prefixes) {
|
|
|
16805
16810
|
}
|
|
16806
16811
|
let rows2;
|
|
16807
16812
|
if (locator) {
|
|
16808
|
-
const
|
|
16813
|
+
const path21 = normalizeProjectEvidencePath(locator.path);
|
|
16809
16814
|
if (!Number.isSafeInteger(locator.start) || locator.start < 0 || locator.kind !== void 0 && !MapObjectKindSchema.safeParse(locator.kind).success)
|
|
16810
16815
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16811
|
-
if (!mapPathAllowed(
|
|
16816
|
+
if (!mapPathAllowed(path21, prefixes))
|
|
16812
16817
|
throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
|
|
16813
16818
|
rows2 = store.database.prepare(`SELECT object_json FROM project_map_objects
|
|
16814
16819
|
WHERE version_ref = ? AND path = ? AND json_extract(object_json, '$.anchor.start') = ?
|
|
16815
|
-
AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2,
|
|
16820
|
+
AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path21, locator.start, locator.kind ?? null, locator.kind ?? null);
|
|
16816
16821
|
} else {
|
|
16817
16822
|
rows2 = store.database.prepare(
|
|
16818
16823
|
"SELECT object_json FROM project_map_objects WHERE version_ref = ? AND entity_ref = ?"
|
|
@@ -16853,13 +16858,13 @@ function mapQueryPage(count, materialize, navigation, budget) {
|
|
|
16853
16858
|
|
|
16854
16859
|
// src/project-map-query-selection.ts
|
|
16855
16860
|
var mapQuerySelection = (input, knownKinds) => {
|
|
16856
|
-
const
|
|
16861
|
+
const path21 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
|
|
16857
16862
|
const kinds = input.kinds ?? knownKinds;
|
|
16858
16863
|
if (!Array.isArray(kinds) || !kinds.length || kinds.length > knownKinds.length || kinds.some((kind) => !knownKinds.includes(kind)))
|
|
16859
16864
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16860
|
-
return { path:
|
|
16865
|
+
return { path: path21, kinds: [...new Set(kinds)].sort() };
|
|
16861
16866
|
};
|
|
16862
|
-
var mapQueryPathMatches = (
|
|
16867
|
+
var mapQueryPathMatches = (path21, prefix) => prefix === "." || path21 === prefix || path21.startsWith(`${prefix}/`);
|
|
16863
16868
|
var MAP_RELATION_TARGET_JOIN = `LEFT JOIN project_map_unit_objects t ON t.entity_ref = r.to_ref
|
|
16864
16869
|
AND EXISTS (SELECT 1 FROM project_map_version_units target
|
|
16865
16870
|
WHERE target.version_ref = r.version_ref AND target.unit_ref = t.unit_ref AND target.path = t.path)`;
|
|
@@ -16961,7 +16966,7 @@ var declarationKinds = /* @__PURE__ */ new Set([
|
|
|
16961
16966
|
"METHOD",
|
|
16962
16967
|
"TYPE"
|
|
16963
16968
|
]);
|
|
16964
|
-
var fileStem = (
|
|
16969
|
+
var fileStem = (path21) => path21.slice(path21.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
|
|
16965
16970
|
var compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
16966
16971
|
var compareRows = (left, right) => right.ranking.score - left.ranking.score || compareText(left.object.anchor.path, right.object.anchor.path) || compareText(left.object.id, right.object.id);
|
|
16967
16972
|
function mapSearchQuery(input) {
|
|
@@ -16988,10 +16993,10 @@ function mapSearchQuery(input) {
|
|
|
16988
16993
|
}
|
|
16989
16994
|
function rank(object2, documentation, relationCount, query, focus) {
|
|
16990
16995
|
const name = object2.name.toLowerCase();
|
|
16991
|
-
const
|
|
16996
|
+
const path21 = object2.anchor.path.toLowerCase();
|
|
16992
16997
|
const values = {
|
|
16993
16998
|
NAME: [name],
|
|
16994
|
-
PATH: [
|
|
16999
|
+
PATH: [path21],
|
|
16995
17000
|
DOCUMENTATION: documentation.map((text) => text.toLowerCase())
|
|
16996
17001
|
};
|
|
16997
17002
|
const matched = query.terms.map((term) => ({
|
|
@@ -17016,12 +17021,12 @@ function rank(object2, documentation, relationCount, query, focus) {
|
|
|
17016
17021
|
score += 7e3;
|
|
17017
17022
|
signals.push("SYMBOL_CONTAINS");
|
|
17018
17023
|
} else if (matchedFields.includes("NAME")) signals.push("SYMBOL_CONTAINS");
|
|
17019
|
-
if (object2.kind === "FILE" && fileStem(
|
|
17024
|
+
if (object2.kind === "FILE" && fileStem(path21) === normalizedQuery) {
|
|
17020
17025
|
score += 11e3;
|
|
17021
17026
|
signals.push("EXACT_FILE_STEM");
|
|
17022
17027
|
}
|
|
17023
17028
|
if (matchedFields.includes("PATH")) {
|
|
17024
|
-
score +=
|
|
17029
|
+
score += path21.includes(normalizedQuery) ? 2500 : 0;
|
|
17025
17030
|
signals.push("PATH_CONTAINS");
|
|
17026
17031
|
}
|
|
17027
17032
|
if (matchedFields.includes("DOCUMENTATION")) {
|
|
@@ -17036,8 +17041,8 @@ function rank(object2, documentation, relationCount, query, focus) {
|
|
|
17036
17041
|
score += kindWeight[object2.kind] + Math.min(1200, relationCount * 20) + (focus?.score ?? 0);
|
|
17037
17042
|
if (declarationKinds.has(object2.kind)) signals.push("DECLARATION");
|
|
17038
17043
|
if (relationCount > 0) signals.push("GRAPH_CONNECTED");
|
|
17039
|
-
const isTest = mapTestPath(
|
|
17040
|
-
const isGenerated = generatedPath.test(
|
|
17044
|
+
const isTest = mapTestPath(path21);
|
|
17045
|
+
const isGenerated = generatedPath.test(path21);
|
|
17041
17046
|
const hasTestIntent = query.terms.some((term) => testQuery.test(term));
|
|
17042
17047
|
score += isTest ? hasTestIntent ? 1e3 : -5e3 : 300;
|
|
17043
17048
|
score += isGenerated ? -3e3 : 300;
|
|
@@ -17549,13 +17554,13 @@ function utf16Offsets(text) {
|
|
|
17549
17554
|
}
|
|
17550
17555
|
function offsetConverter(files, offsets) {
|
|
17551
17556
|
const converters = /* @__PURE__ */ new Map();
|
|
17552
|
-
return (
|
|
17553
|
-
let convert = converters.get(
|
|
17557
|
+
return (path21, offset) => {
|
|
17558
|
+
let convert = converters.get(path21);
|
|
17554
17559
|
if (!convert) {
|
|
17555
|
-
const text = files[
|
|
17560
|
+
const text = files[path21];
|
|
17556
17561
|
if (text === void 0) return invalid();
|
|
17557
17562
|
convert = offsets === "UTF16" ? (value) => value <= text.length ? value : invalid() : utf16Offsets(text);
|
|
17558
|
-
converters.set(
|
|
17563
|
+
converters.set(path21, convert);
|
|
17559
17564
|
}
|
|
17560
17565
|
return convert(offset);
|
|
17561
17566
|
};
|
|
@@ -17586,7 +17591,7 @@ function mapFactsAnalysis(facts, input, context) {
|
|
|
17586
17591
|
const collect = new MapOutputCollector(output);
|
|
17587
17592
|
const positions = new MapSourcePositions(input.files);
|
|
17588
17593
|
const offset = offsetConverter(input.files, context.offsets);
|
|
17589
|
-
const anchor = (
|
|
17594
|
+
const anchor = (path21, start, end) => positions.span(path21, offset(path21, start), offset(path21, end));
|
|
17590
17595
|
const located = /* @__PURE__ */ new Map();
|
|
17591
17596
|
const canonical = /* @__PURE__ */ new Map();
|
|
17592
17597
|
const bySpan = /* @__PURE__ */ new Map();
|
|
@@ -18166,8 +18171,8 @@ var goWork = /(?:^|\/)go\.work$/u;
|
|
|
18166
18171
|
var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
|
|
18167
18172
|
var GO_MAP_LANGUAGE = Object.freeze({
|
|
18168
18173
|
id: "go-1.24-map-v11",
|
|
18169
|
-
claims: (
|
|
18170
|
-
reads: (
|
|
18174
|
+
claims: (path21) => path21.endsWith(".go"),
|
|
18175
|
+
reads: (path21) => goModule.test(path21) || goWork.test(path21),
|
|
18171
18176
|
// A module path, or the standard library, whose first path element has no dot.
|
|
18172
18177
|
importName: (specifier) => {
|
|
18173
18178
|
const parts = specifier.split("/");
|
|
@@ -18176,7 +18181,7 @@ var GO_MAP_LANGUAGE = Object.freeze({
|
|
|
18176
18181
|
return parts.slice(0, size).join("/");
|
|
18177
18182
|
},
|
|
18178
18183
|
// Go imports a package: the directory of the file.
|
|
18179
|
-
importTarget: (
|
|
18184
|
+
importTarget: (path21) => `${path21.slice(0, path21.lastIndexOf("/") + 1) || "./"}`,
|
|
18180
18185
|
create: () => new GoMapAnalyzer()
|
|
18181
18186
|
});
|
|
18182
18187
|
var GO_GAPS = [
|
|
@@ -18201,8 +18206,8 @@ var goMapAnalysis = (facts, input, configurations) => mapFactsAnalysis(facts, in
|
|
|
18201
18206
|
typeIssues: "GO_TYPE_CHECK_ISSUES",
|
|
18202
18207
|
contract: "Declares a Go interface. This does not establish runtime enforcement or business authority."
|
|
18203
18208
|
});
|
|
18204
|
-
var goLocalModules = (
|
|
18205
|
-
const directive = goWork.test(
|
|
18209
|
+
var goLocalModules = (path21, text) => {
|
|
18210
|
+
const directive = goWork.test(path21) ? "use" : "replace";
|
|
18206
18211
|
const found = [];
|
|
18207
18212
|
let block = false;
|
|
18208
18213
|
for (const raw of text.split("\n")) {
|
|
@@ -18216,37 +18221,37 @@ var goLocalModules = (path20, text) => {
|
|
|
18216
18221
|
const target = directive === "use" ? entry : entry?.split("=>")[1];
|
|
18217
18222
|
const directory = target?.trim().split(/\s+/u)[0]?.replace(/^(["`])(.*)\1$/u, "$2");
|
|
18218
18223
|
if (!directory || !/^\.\.?(?:\/|$)/u.test(directory)) continue;
|
|
18219
|
-
const joined = posix.normalize(posix.join(posix.dirname(
|
|
18224
|
+
const joined = posix.normalize(posix.join(posix.dirname(path21), directory)).replace(/\/$/u, "");
|
|
18220
18225
|
if (joined !== ".." && !joined.startsWith("../")) found.push(joined);
|
|
18221
18226
|
}
|
|
18222
18227
|
return found;
|
|
18223
18228
|
};
|
|
18224
18229
|
var goModuleGroups = (files, text) => {
|
|
18225
|
-
const modules = files.filter((
|
|
18226
|
-
const moduleAt = new Map(modules.map((
|
|
18227
|
-
const parent = new Map(modules.map((
|
|
18228
|
-
const root = (
|
|
18229
|
-
const up = parent.get(
|
|
18230
|
-
return up ===
|
|
18230
|
+
const modules = files.filter((path21) => goModule.test(path21)).sort();
|
|
18231
|
+
const moduleAt = new Map(modules.map((path21) => [posix.dirname(path21), path21]));
|
|
18232
|
+
const parent = new Map(modules.map((path21) => [path21, path21]));
|
|
18233
|
+
const root = (path21) => {
|
|
18234
|
+
const up = parent.get(path21) ?? path21;
|
|
18235
|
+
return up === path21 ? path21 : root(up);
|
|
18231
18236
|
};
|
|
18232
18237
|
const works = [];
|
|
18233
|
-
for (const
|
|
18234
|
-
const linked = goLocalModules(
|
|
18235
|
-
const first = goWork.test(
|
|
18238
|
+
for (const path21 of [...files].filter((file2) => goModule.test(file2) || goWork.test(file2)).sort()) {
|
|
18239
|
+
const linked = goLocalModules(path21, text(path21)).flatMap((dir) => moduleAt.get(dir) ?? []);
|
|
18240
|
+
const first = goWork.test(path21) ? linked[0] : path21;
|
|
18236
18241
|
if (!first) continue;
|
|
18237
|
-
if (goWork.test(
|
|
18242
|
+
if (goWork.test(path21)) works.push([path21, first]);
|
|
18238
18243
|
for (const module of linked) {
|
|
18239
18244
|
const [low = first, high = module] = [root(first), root(module)].sort();
|
|
18240
18245
|
if (low !== high) parent.set(high, low);
|
|
18241
18246
|
}
|
|
18242
18247
|
}
|
|
18243
18248
|
const members = /* @__PURE__ */ new Map();
|
|
18244
|
-
for (const
|
|
18249
|
+
for (const path21 of modules) members.set(root(path21), [...members.get(root(path21)) ?? [], path21]);
|
|
18245
18250
|
const named = new Map(works.reverse().map(([work, module]) => [root(module), work]));
|
|
18246
18251
|
return new Map(
|
|
18247
|
-
modules.map((
|
|
18248
|
-
|
|
18249
|
-
{ configPath: named.get(root(
|
|
18252
|
+
modules.map((path21) => [
|
|
18253
|
+
path21,
|
|
18254
|
+
{ configPath: named.get(root(path21)) ?? root(path21), modules: members.get(root(path21)) ?? [] }
|
|
18250
18255
|
])
|
|
18251
18256
|
);
|
|
18252
18257
|
};
|
|
@@ -18276,28 +18281,28 @@ var GoMapAnalyzer = class {
|
|
|
18276
18281
|
}
|
|
18277
18282
|
async analyze(session, signal) {
|
|
18278
18283
|
const paths = session.readable.map((entry) => entry.path);
|
|
18279
|
-
const groupOf = goModuleGroups(paths, (
|
|
18280
|
-
const moduleOf = (
|
|
18284
|
+
const groupOf = goModuleGroups(paths, (path21) => session.texts[path21] ?? "");
|
|
18285
|
+
const moduleOf = (path21) => {
|
|
18281
18286
|
let best;
|
|
18282
18287
|
for (const modFile of groupOf.keys()) {
|
|
18283
18288
|
const directory = modFile.slice(0, modFile.lastIndexOf("/") + 1);
|
|
18284
|
-
if (
|
|
18289
|
+
if (path21.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
|
|
18285
18290
|
best = modFile;
|
|
18286
18291
|
}
|
|
18287
18292
|
return best;
|
|
18288
18293
|
};
|
|
18289
18294
|
const contexts = /* @__PURE__ */ new Map();
|
|
18290
|
-
for (const
|
|
18291
|
-
if (!this.claims(
|
|
18292
|
-
const module = moduleOf(
|
|
18295
|
+
for (const path21 of paths) {
|
|
18296
|
+
if (!this.claims(path21)) continue;
|
|
18297
|
+
const module = moduleOf(path21);
|
|
18293
18298
|
const group = module ? groupOf.get(module) : void 0;
|
|
18294
18299
|
const configPath = group?.configPath ?? "";
|
|
18295
18300
|
const into = contexts.get(configPath);
|
|
18296
|
-
if (into) into.sources.push(
|
|
18301
|
+
if (into) into.sources.push(path21);
|
|
18297
18302
|
else
|
|
18298
18303
|
contexts.set(configPath, {
|
|
18299
18304
|
configurations: group ? [.../* @__PURE__ */ new Set([...group.modules, configPath])].sort() : [],
|
|
18300
|
-
sources: [
|
|
18305
|
+
sources: [path21]
|
|
18301
18306
|
});
|
|
18302
18307
|
}
|
|
18303
18308
|
for (const [configPath, { configurations, sources }] of [...contexts].sort(
|
|
@@ -18305,11 +18310,11 @@ var GoMapAnalyzer = class {
|
|
|
18305
18310
|
)) {
|
|
18306
18311
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
18307
18312
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18308
|
-
for (const
|
|
18309
|
-
const text = session.texts[
|
|
18313
|
+
for (const path21 of [...sources, ...configurations]) {
|
|
18314
|
+
const text = session.texts[path21];
|
|
18310
18315
|
if (text === void 0)
|
|
18311
18316
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18312
|
-
files[
|
|
18317
|
+
files[path21] = text;
|
|
18313
18318
|
}
|
|
18314
18319
|
const input = {
|
|
18315
18320
|
contextRef: digestValue({
|
|
@@ -18343,8 +18348,8 @@ var GoMapAnalyzer = class {
|
|
|
18343
18348
|
if (!existsSync4(this.resources.compilerPath))
|
|
18344
18349
|
return { pages: references.map(() => null), requiredFiles: [] };
|
|
18345
18350
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18346
|
-
for (const [
|
|
18347
|
-
if (this.claims(
|
|
18351
|
+
for (const [path21, value] of Object.entries(input.files))
|
|
18352
|
+
if (this.claims(path21) || this.reads(path21)) files[path21] = value;
|
|
18348
18353
|
const facts = await this.operation(
|
|
18349
18354
|
{
|
|
18350
18355
|
...input,
|
|
@@ -18373,14 +18378,14 @@ var BUILD_FILES = [
|
|
|
18373
18378
|
"pom.xml"
|
|
18374
18379
|
];
|
|
18375
18380
|
var buildFile = /(?:^|\/)(?:pom\.xml|(?:build|settings)\.gradle(?:\.kts)?)$/u;
|
|
18376
|
-
var directoryOf = (
|
|
18377
|
-
var nameOf = (
|
|
18381
|
+
var directoryOf = (path21) => path21.slice(0, path21.lastIndexOf("/") + 1);
|
|
18382
|
+
var nameOf = (path21) => path21.slice(path21.lastIndexOf("/") + 1);
|
|
18378
18383
|
var DEFAULT_RELEASE = 21;
|
|
18379
18384
|
var platformPackage = /^(?:java|jdk|sun|com\.sun|javax\.(?:annotation\.processing|crypto|imageio|lang\.model|management|naming|net|print|script|security|sound|sql|swing|tools|transaction\.xa|xml))(?:\.|$)/u;
|
|
18380
18385
|
var JAVA_MAP_LANGUAGE = Object.freeze({
|
|
18381
18386
|
id: "javac-lombok-1.18.48-map-v10",
|
|
18382
|
-
claims: (
|
|
18383
|
-
reads: (
|
|
18387
|
+
claims: (path21) => path21.endsWith(".java"),
|
|
18388
|
+
reads: (path21) => buildFile.test(path21),
|
|
18384
18389
|
// A package of the Java platform, or a library named by its first two package segments.
|
|
18385
18390
|
importName: (specifier) => platformPackage.test(specifier) ? "Java standard library" : specifier.split(".").slice(0, 2).join("."),
|
|
18386
18391
|
create: () => new JavaMapAnalyzer()
|
|
@@ -18470,8 +18475,8 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18470
18475
|
// The worker's request for a context: the Java sources and the release.
|
|
18471
18476
|
request(input, buildTexts) {
|
|
18472
18477
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18473
|
-
for (const [
|
|
18474
|
-
if (this.claims(
|
|
18478
|
+
for (const [path21, text] of Object.entries(input.files))
|
|
18479
|
+
if (this.claims(path21)) files[path21] = text;
|
|
18475
18480
|
return {
|
|
18476
18481
|
files,
|
|
18477
18482
|
release: javaRelease(buildTexts, this.resources.runtimeVersion)
|
|
@@ -18486,35 +18491,35 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18486
18491
|
}
|
|
18487
18492
|
async analyze(session, signal) {
|
|
18488
18493
|
this.refreshRuntime();
|
|
18489
|
-
const builds = session.readable.map((entry) => entry.path).filter((
|
|
18490
|
-
for (const
|
|
18491
|
-
const rank2 = (
|
|
18494
|
+
const builds = session.readable.map((entry) => entry.path).filter((path21) => buildFile.test(path21));
|
|
18495
|
+
for (const path21 of builds) session.configuration(path21);
|
|
18496
|
+
const rank2 = (path21) => BUILD_FILES.indexOf(nameOf(path21));
|
|
18492
18497
|
const roots = /* @__PURE__ */ new Map();
|
|
18493
18498
|
const modules = /* @__PURE__ */ new Map();
|
|
18494
|
-
for (const
|
|
18495
|
-
const directory = directoryOf(
|
|
18499
|
+
for (const path21 of builds) {
|
|
18500
|
+
const directory = directoryOf(path21);
|
|
18496
18501
|
const current = modules.get(directory);
|
|
18497
|
-
if (current === void 0 || rank2(
|
|
18498
|
-
const text = session.texts[
|
|
18499
|
-
if (/settings\.gradle(?:\.kts)?$/u.test(
|
|
18502
|
+
if (current === void 0 || rank2(path21) < rank2(current)) modules.set(directory, path21);
|
|
18503
|
+
const text = session.texts[path21] ?? "";
|
|
18504
|
+
if (/settings\.gradle(?:\.kts)?$/u.test(path21) || path21.endsWith("pom.xml") && /<modules>/u.test(text)) {
|
|
18500
18505
|
const root = roots.get(directory);
|
|
18501
|
-
if (root === void 0 || rank2(
|
|
18506
|
+
if (root === void 0 || rank2(path21) < rank2(root)) roots.set(directory, path21);
|
|
18502
18507
|
}
|
|
18503
18508
|
}
|
|
18504
|
-
const configOf = (
|
|
18509
|
+
const configOf = (path21) => {
|
|
18505
18510
|
let outer;
|
|
18506
18511
|
for (const directory of roots.keys())
|
|
18507
|
-
if (
|
|
18512
|
+
if (path21.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
|
|
18508
18513
|
outer = directory;
|
|
18509
18514
|
if (outer !== void 0) return roots.get(outer);
|
|
18510
18515
|
let nearest;
|
|
18511
18516
|
for (const directory of modules.keys())
|
|
18512
|
-
if (
|
|
18517
|
+
if (path21.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
|
|
18513
18518
|
nearest = directory;
|
|
18514
18519
|
return nearest === void 0 ? "" : modules.get(nearest);
|
|
18515
18520
|
};
|
|
18516
|
-
const output = (
|
|
18517
|
-
(directory) =>
|
|
18521
|
+
const output = (path21) => [...modules.keys()].some(
|
|
18522
|
+
(directory) => path21.startsWith(`${directory}build/`) || path21.startsWith(`${directory}target/`)
|
|
18518
18523
|
);
|
|
18519
18524
|
const groups = /* @__PURE__ */ new Map();
|
|
18520
18525
|
for (const entry of session.readable) {
|
|
@@ -18529,13 +18534,13 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18529
18534
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
18530
18535
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18531
18536
|
const rootBuilds = configPath ? BUILD_FILES.map((name) => `${directoryOf(configPath)}${name}`).filter(
|
|
18532
|
-
(
|
|
18537
|
+
(path21) => builds.includes(path21)
|
|
18533
18538
|
) : [];
|
|
18534
|
-
for (const
|
|
18535
|
-
const text = session.texts[
|
|
18539
|
+
for (const path21 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
|
|
18540
|
+
const text = session.texts[path21];
|
|
18536
18541
|
if (text === void 0)
|
|
18537
18542
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18538
|
-
files[
|
|
18543
|
+
files[path21] = text;
|
|
18539
18544
|
}
|
|
18540
18545
|
const input = {
|
|
18541
18546
|
contextRef: digestValue({
|
|
@@ -18577,7 +18582,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18577
18582
|
const prior = JavaStateSchema.safeParse(previous?.state).data;
|
|
18578
18583
|
const incremental = previous && prior?.basis === basis ? {
|
|
18579
18584
|
changed: Object.keys(request.files).filter(
|
|
18580
|
-
(
|
|
18585
|
+
(path21) => digests.get(path21) !== previous.digests.get(path21)
|
|
18581
18586
|
),
|
|
18582
18587
|
state: prior.java
|
|
18583
18588
|
} : void 0;
|
|
@@ -18600,20 +18605,20 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18600
18605
|
]
|
|
18601
18606
|
);
|
|
18602
18607
|
validateMapAnalysis(analysis, input);
|
|
18603
|
-
const
|
|
18608
|
+
const state2 = facts.state && { basis, java: facts.state };
|
|
18604
18609
|
if (!facts.focus) {
|
|
18605
|
-
session.accept(analysis, { state });
|
|
18610
|
+
session.accept(analysis, { state: state2 });
|
|
18606
18611
|
continue;
|
|
18607
18612
|
}
|
|
18608
18613
|
const focus = new Set(facts.focus);
|
|
18609
|
-
if (!incremental || facts.focus.some((
|
|
18614
|
+
if (!incremental || facts.focus.some((path21) => !Object.hasOwn(request.files, path21)) || incremental.changed.some((path21) => !focus.has(path21)))
|
|
18610
18615
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18611
18616
|
analysis.objects = analysis.objects.filter((object2) => focus.has(object2.anchor.path));
|
|
18612
18617
|
analysis.relations = analysis.relations.filter((relation) => focus.has(relation.anchor.path));
|
|
18613
18618
|
analysis.notes = analysis.notes.filter((note) => focus.has(note.anchor.path));
|
|
18614
18619
|
session.accept(analysis, {
|
|
18615
|
-
state,
|
|
18616
|
-
linked: analysis.parsedFiles.filter((
|
|
18620
|
+
state: state2,
|
|
18621
|
+
linked: analysis.parsedFiles.filter((path21) => !focus.has(path21))
|
|
18617
18622
|
});
|
|
18618
18623
|
}
|
|
18619
18624
|
}
|
|
@@ -18928,12 +18933,12 @@ var PYTHON_STANDARD_LIBRARY = /* @__PURE__ */ new Set([
|
|
|
18928
18933
|
// src/project-map-language-python.ts
|
|
18929
18934
|
var CONFIGURATION = ["pyrightconfig.json", "pyproject.toml", "setup.cfg"];
|
|
18930
18935
|
var pythonConfig = /(?:^|\/)(?:pyrightconfig\.json|pyproject\.toml|setup\.cfg)$/u;
|
|
18931
|
-
var directoryOf2 = (
|
|
18936
|
+
var directoryOf2 = (path21) => path21.slice(0, path21.lastIndexOf("/") + 1);
|
|
18932
18937
|
var DEFAULT_PYTHON = { major: 3, minor: 13 };
|
|
18933
18938
|
var PYTHON_MAP_LANGUAGE = Object.freeze({
|
|
18934
18939
|
id: "pyright-1.1.414-map-v14",
|
|
18935
|
-
claims: (
|
|
18936
|
-
reads: (
|
|
18940
|
+
claims: (path21) => /\.pyi?$/u.test(path21),
|
|
18941
|
+
reads: (path21) => pythonConfig.test(path21),
|
|
18937
18942
|
// An absolute import names the standard library or a distribution's top-level package.
|
|
18938
18943
|
importName: (specifier) => {
|
|
18939
18944
|
const top = specifier.split(".", 1)[0] ?? specifier;
|
|
@@ -18989,16 +18994,16 @@ var PythonMapAnalyzer = class {
|
|
|
18989
18994
|
}
|
|
18990
18995
|
async analyze(session, signal) {
|
|
18991
18996
|
const roots = /* @__PURE__ */ new Map();
|
|
18992
|
-
for (const
|
|
18993
|
-
const directory = directoryOf2(
|
|
18997
|
+
for (const path21 of session.readable.map((entry) => entry.path).filter((path22) => pythonConfig.test(path22))) {
|
|
18998
|
+
const directory = directoryOf2(path21);
|
|
18994
18999
|
const current = roots.get(directory);
|
|
18995
19000
|
const rank2 = (file2) => CONFIGURATION.indexOf(file2.slice(directory.length));
|
|
18996
|
-
if (current === void 0 || rank2(
|
|
19001
|
+
if (current === void 0 || rank2(path21) < rank2(current)) roots.set(directory, path21);
|
|
18997
19002
|
}
|
|
18998
|
-
const rootOf = (
|
|
19003
|
+
const rootOf = (path21) => {
|
|
18999
19004
|
let best;
|
|
19000
19005
|
for (const directory of roots.keys())
|
|
19001
|
-
if (
|
|
19006
|
+
if (path21.startsWith(directory) && (best === void 0 || directory.length > best.length))
|
|
19002
19007
|
best = directory;
|
|
19003
19008
|
return best === void 0 ? "" : roots.get(best);
|
|
19004
19009
|
};
|
|
@@ -19013,11 +19018,11 @@ var PythonMapAnalyzer = class {
|
|
|
19013
19018
|
for (const configPath of [...groups.keys()].sort()) {
|
|
19014
19019
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
19015
19020
|
const files = /* @__PURE__ */ Object.create(null);
|
|
19016
|
-
for (const
|
|
19017
|
-
const text = session.texts[
|
|
19021
|
+
for (const path21 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
|
|
19022
|
+
const text = session.texts[path21];
|
|
19018
19023
|
if (text === void 0)
|
|
19019
19024
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
19020
|
-
files[
|
|
19025
|
+
files[path21] = text;
|
|
19021
19026
|
}
|
|
19022
19027
|
const input = {
|
|
19023
19028
|
contextRef: digestValue({
|
|
@@ -19063,8 +19068,8 @@ var PythonMapAnalyzer = class {
|
|
|
19063
19068
|
}
|
|
19064
19069
|
async references(input, references, signal, observe) {
|
|
19065
19070
|
const files = /* @__PURE__ */ Object.create(null);
|
|
19066
|
-
for (const [
|
|
19067
|
-
if (this.claims(
|
|
19071
|
+
for (const [path21, value] of Object.entries(input.files))
|
|
19072
|
+
if (this.claims(path21) || pythonConfig.test(path21)) files[path21] = value;
|
|
19068
19073
|
const facts = await this.operation(
|
|
19069
19074
|
{
|
|
19070
19075
|
...input,
|
|
@@ -19121,9 +19126,9 @@ var miniprogramEventOf = (target) => {
|
|
|
19121
19126
|
// src/project-map-language-typescript.ts
|
|
19122
19127
|
var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
19123
19128
|
id: "typescript-7.0.2-map-v35",
|
|
19124
|
-
claims: (
|
|
19129
|
+
claims: (path21) => /\.[cm]?[jt]sx?$/u.test(path21),
|
|
19125
19130
|
readsRequests: true,
|
|
19126
|
-
reads: (
|
|
19131
|
+
reads: (path21) => path21.endsWith(".json") || path21.endsWith(".wxml") || path21 === "pnpm-workspace.yaml",
|
|
19127
19132
|
create: () => new TypeScriptMapAnalyzer()
|
|
19128
19133
|
});
|
|
19129
19134
|
var WORKERS_AT_ONCE = Math.min(4, availableParallelism());
|
|
@@ -19150,7 +19155,7 @@ var KeptDiscoverySchema = external_exports.object({
|
|
|
19150
19155
|
installed: external_exports.string(),
|
|
19151
19156
|
files: external_exports.array(external_exports.tuple([external_exports.string(), external_exports.string().nullable(), external_exports.string().nullable()]))
|
|
19152
19157
|
}).strict();
|
|
19153
|
-
var sameShape = (left, right) => left.installed === right.installed && left.files.size === right.files.size && [...left.files].every(([
|
|
19158
|
+
var sameShape = (left, right) => left.installed === right.installed && left.files.size === right.files.size && [...left.files].every(([path21, { shape }]) => right.files.get(path21)?.shape === shape);
|
|
19154
19159
|
var stopUnconfirmed = async (runs) => (await Promise.allSettled(runs)).flatMap((settled) => settled.status === "rejected" ? [settled.reason] : []).find((reason) => reason instanceof ProjectMapStopUnconfirmedError);
|
|
19155
19160
|
async function inOrder(tasks, take, signal, sizes) {
|
|
19156
19161
|
const stopping = new AbortController();
|
|
@@ -19314,9 +19319,9 @@ var TypeScriptMapAnalyzer = class {
|
|
|
19314
19319
|
first = void 0;
|
|
19315
19320
|
validateMapAnalysis(analysis, input);
|
|
19316
19321
|
if (!analysis.requiredFiles.length) return analysis;
|
|
19317
|
-
const required2 = analysis.requiredFiles.map((
|
|
19318
|
-
const entry = byPath.get(
|
|
19319
|
-
if (!entry || Object.hasOwn(texts,
|
|
19322
|
+
const required2 = analysis.requiredFiles.map((path21) => {
|
|
19323
|
+
const entry = byPath.get(path21);
|
|
19324
|
+
if (!entry || Object.hasOwn(texts, path21))
|
|
19320
19325
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
19321
19326
|
return entry;
|
|
19322
19327
|
});
|
|
@@ -19336,7 +19341,7 @@ var TypeScriptMapAnalyzer = class {
|
|
|
19336
19341
|
discovered: kept.discovered,
|
|
19337
19342
|
shape: {
|
|
19338
19343
|
installed: kept.installed,
|
|
19339
|
-
files: new Map(kept.files.map(([
|
|
19344
|
+
files: new Map(kept.files.map(([path21, digest, shape2]) => [path21, { digest, shape: shape2 }]))
|
|
19340
19345
|
}
|
|
19341
19346
|
};
|
|
19342
19347
|
const known = kept?.key === configurationKey ? kept.discovered : void 0;
|
|
@@ -19393,7 +19398,7 @@ var TypeScriptMapAnalyzer = class {
|
|
|
19393
19398
|
key: configurationKey,
|
|
19394
19399
|
discovered,
|
|
19395
19400
|
installed: installed.digest,
|
|
19396
|
-
files: [...shape.files].map(([
|
|
19401
|
+
files: [...shape.files].map(([path21, file2]) => [path21, file2.digest, file2.shape])
|
|
19397
19402
|
});
|
|
19398
19403
|
if (!admitted(discovered))
|
|
19399
19404
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
@@ -19445,17 +19450,17 @@ var MAP_LANGUAGES = Object.freeze([
|
|
|
19445
19450
|
]);
|
|
19446
19451
|
var mapAnalyzerSuite = (languages) => languages.map((language) => language.id).sort().join("+");
|
|
19447
19452
|
var PROJECT_MAP_ANALYZER = mapAnalyzerSuite(MAP_LANGUAGES);
|
|
19448
|
-
var mapCodePath = (
|
|
19449
|
-
var languageOf = (
|
|
19450
|
-
var mapReadsRequests = (
|
|
19451
|
-
var mapLanguageOf = (
|
|
19453
|
+
var mapCodePath = (path21) => MAP_LANGUAGES.some((language) => language.claims(path21));
|
|
19454
|
+
var languageOf = (path21) => MAP_LANGUAGES.find((language) => language.claims(path21));
|
|
19455
|
+
var mapReadsRequests = (path21) => languageOf(path21)?.readsRequests === true;
|
|
19456
|
+
var mapLanguageOf = (path21) => languageOf(path21)?.id;
|
|
19452
19457
|
var npmPackage = (specifier) => {
|
|
19453
19458
|
if (specifier.startsWith("node:")) return "node:*";
|
|
19454
19459
|
const parts = specifier.split("/");
|
|
19455
19460
|
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? specifier;
|
|
19456
19461
|
};
|
|
19457
19462
|
var mapExternalImport = (sourcePath, specifier) => languageOf(sourcePath)?.importName?.(specifier) ?? npmPackage(specifier);
|
|
19458
|
-
var mapImportTarget = (
|
|
19463
|
+
var mapImportTarget = (path21) => languageOf(path21)?.importTarget?.(path21) ?? path21;
|
|
19459
19464
|
|
|
19460
19465
|
// src/project-map-view.ts
|
|
19461
19466
|
var MAP_VIEW_FORMAT = "PROJECT_MAP_VIEW_V1";
|
|
@@ -19495,10 +19500,10 @@ var notFound = () => {
|
|
|
19495
19500
|
};
|
|
19496
19501
|
var MAP_KINDS_LEGEND = "kinds f function, c class, m method, p property, v variable, t type, i interface, e enum; numbers are 1-based source lines";
|
|
19497
19502
|
var MAP_DECLARATION_LEGEND = `@n marks where a relationship occurs and +n counts further sites, which project_find_references lists; a quoted path after the sites is the route the call or value is registered under there: its HTTP methods when the registration names them, then its path joined with the prefixes of the routers it is registered on, as far as the same function or file sets them (a prefix added where a router is mounted or passed in is not included); route "\u2026" after a decorator is the full route the decorator maps, its class's path joined with its own. Static relationships are grouped by the declaration that owns them. Callers are direct calls, uses as a value (stored, passed, returned or selected, then usually invoked through that value) and calls through an interface, type or base member that a declaration implements (dispatched from); dispatches to lists the members that implement an interface, type or base member, which a call through it may reach; trace stops names calls whose target is a function value, a member without a mapped implementation or a computed key, which only source reading can follow; possible callers by name are calls elsewhere, in the same language, of a member with a method's name on a receiver of unknown type (an untyped value, or one an unloaded package produced); they may or may not reach that method.`;
|
|
19498
|
-
var within = (
|
|
19499
|
-
var parentDirectory = (
|
|
19500
|
-
const slash =
|
|
19501
|
-
return slash < 0 ? "." :
|
|
19503
|
+
var within = (path21, directory) => directory === "." || path21.startsWith(`${directory}/`);
|
|
19504
|
+
var parentDirectory = (path21) => {
|
|
19505
|
+
const slash = path21.lastIndexOf("/");
|
|
19506
|
+
return slash < 0 ? "." : path21.slice(0, slash);
|
|
19502
19507
|
};
|
|
19503
19508
|
var compareText2 = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
19504
19509
|
var byCount = ([leftName, left], [rightName, right]) => right - left || compareText2(leftName, rightName);
|
|
@@ -19572,7 +19577,7 @@ function pageBlocks(view, head, whole, offset, budget) {
|
|
|
19572
19577
|
if (offset === blocks.length) return materialize(0);
|
|
19573
19578
|
return mapQueryPage(blocks.length - offset, materialize, (page) => page, budget);
|
|
19574
19579
|
}
|
|
19575
|
-
var inModule = (
|
|
19580
|
+
var inModule = (path21, module) => module.direct ? parentDirectory(path21) === module.directory : within(path21, module.directory);
|
|
19576
19581
|
var moduleLabel = (module) => module.direct ? `${module.directory === "." ? "" : `${module.directory}/`}* (files directly here)` : `${module.directory}/`;
|
|
19577
19582
|
function childModules(module, files) {
|
|
19578
19583
|
if (module.direct) return [];
|
|
@@ -19627,9 +19632,9 @@ function mapProjectModules(entries) {
|
|
|
19627
19632
|
(entry) => entry.state === "TEXT" && mapCodePath(entry.path) && !mapTestPath(entry.path)
|
|
19628
19633
|
).map((entry) => entry.path)
|
|
19629
19634
|
);
|
|
19630
|
-
return (
|
|
19631
|
-
if (mapTestPath(
|
|
19632
|
-
const module = modules.find((candidate) => inModule(
|
|
19635
|
+
return (path21) => {
|
|
19636
|
+
if (mapTestPath(path21)) return void 0;
|
|
19637
|
+
const module = modules.find((candidate) => inModule(path21, candidate));
|
|
19633
19638
|
return module && moduleLabel(module);
|
|
19634
19639
|
};
|
|
19635
19640
|
}
|
|
@@ -19727,12 +19732,12 @@ function loadMemberCalls(store, version2) {
|
|
|
19727
19732
|
FROM project_map_relations
|
|
19728
19733
|
WHERE version_ref = ? AND to_ref IS NULL AND json_extract(relation_json, '$.kind') = 'CALLS'
|
|
19729
19734
|
AND json_extract(relation_json, '$.unresolvedReason') IN ('SYMBOL_NOT_RESOLVED', 'SYNTAX_ONLY')`).all(version2)) {
|
|
19730
|
-
const
|
|
19735
|
+
const path21 = String(row.path);
|
|
19731
19736
|
const target = String(row.target);
|
|
19732
19737
|
const name = MEMBER_NAME.exec(target)?.[1];
|
|
19733
|
-
const language = mapLanguageOf(
|
|
19738
|
+
const language = mapLanguageOf(path21);
|
|
19734
19739
|
if (!name || !language) continue;
|
|
19735
|
-
const call = { from: String(row.from_ref), path:
|
|
19740
|
+
const call = { from: String(row.from_ref), path: path21, line: Number(row.line), target };
|
|
19736
19741
|
const key = memberKey(language, name);
|
|
19737
19742
|
const known = calls.get(key);
|
|
19738
19743
|
if (known) known.push(call);
|
|
@@ -19793,10 +19798,10 @@ function loadCoverageNotes(store, version2) {
|
|
|
19793
19798
|
if (!codes.includes(gap.code)) codes.push(gap.code);
|
|
19794
19799
|
files.set(gap.path, codes);
|
|
19795
19800
|
}
|
|
19796
|
-
for (const [
|
|
19801
|
+
for (const [path21, codes] of files)
|
|
19797
19802
|
if (codes.length > 1 && codes.includes("NOT_IN_PARSED_CONTEXT"))
|
|
19798
19803
|
files.set(
|
|
19799
|
-
|
|
19804
|
+
path21,
|
|
19800
19805
|
codes.filter((code) => code !== "NOT_IN_PARSED_CONTEXT")
|
|
19801
19806
|
);
|
|
19802
19807
|
const missing = [...notInstalled].sort();
|
|
@@ -19841,9 +19846,9 @@ function directoryView(facts, imports, coverage, entries, input, directory, pref
|
|
|
19841
19846
|
const visiblePaths = new Set(visible.map((entry) => entry.path));
|
|
19842
19847
|
const code = visible.filter((entry) => entry.state === "TEXT" && mapCodePath(entry.path)).map((entry) => entry.path);
|
|
19843
19848
|
const modules = mapModules(directory, code);
|
|
19844
|
-
const moduleOf = (
|
|
19845
|
-
const outside = (
|
|
19846
|
-
const parts =
|
|
19849
|
+
const moduleOf = (path21) => modules.find((module) => inModule(path21, module));
|
|
19850
|
+
const outside = (path21) => {
|
|
19851
|
+
const parts = path21.split("/");
|
|
19847
19852
|
return `${parts.slice(0, Math.min(2, parts.length - 1)).join("/") || "."}/ (outside)`;
|
|
19848
19853
|
};
|
|
19849
19854
|
const moduleImports = /* @__PURE__ */ new Map();
|
|
@@ -19867,8 +19872,8 @@ function directoryView(facts, imports, coverage, entries, input, directory, pref
|
|
|
19867
19872
|
const blocks = [];
|
|
19868
19873
|
if (modules.length > 1) {
|
|
19869
19874
|
const sizes = /* @__PURE__ */ new Map();
|
|
19870
|
-
for (const
|
|
19871
|
-
const module = moduleOf(
|
|
19875
|
+
for (const path21 of code) {
|
|
19876
|
+
const module = moduleOf(path21);
|
|
19872
19877
|
if (module) increment(sizes, moduleLabel(module));
|
|
19873
19878
|
}
|
|
19874
19879
|
blocks.push(
|
|
@@ -19897,18 +19902,18 @@ function directoryView(facts, imports, coverage, entries, input, directory, pref
|
|
|
19897
19902
|
)}${packages.length > shown.length ? `, +${packages.length - shown.length} more` : ""}`
|
|
19898
19903
|
);
|
|
19899
19904
|
}
|
|
19900
|
-
const lineCount = (
|
|
19901
|
-
const file2 = facts.files.get(
|
|
19902
|
-
const gaps = coverage.files.get(
|
|
19905
|
+
const lineCount = (path21) => {
|
|
19906
|
+
const file2 = facts.files.get(path21);
|
|
19907
|
+
const gaps = coverage.files.get(path21) ?? [];
|
|
19903
19908
|
if (file2?.parsed === false) return `[not parsed${gaps.length ? `: ${gaps.join("; ")}` : ""}]`;
|
|
19904
19909
|
return `${file2 ? `${file2.lines}L` : "?L"}${gaps.length ? ` [${gaps.join("; ")}]` : ""}`;
|
|
19905
19910
|
};
|
|
19906
19911
|
const codeDirectories = /* @__PURE__ */ new Set();
|
|
19907
|
-
for (const
|
|
19908
|
-
for (let parent = parentDirectory(
|
|
19912
|
+
for (const path21 of code)
|
|
19913
|
+
for (let parent = parentDirectory(path21); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
|
|
19909
19914
|
codeDirectories.add(parent);
|
|
19910
|
-
const groupOf = (
|
|
19911
|
-
let group = parentDirectory(
|
|
19915
|
+
const groupOf = (path21) => {
|
|
19916
|
+
let group = parentDirectory(path21);
|
|
19912
19917
|
for (let parent = group; parent !== "." && parent !== directory && !codeDirectories.has(parent); parent = parentDirectory(parent))
|
|
19913
19918
|
group = parent;
|
|
19914
19919
|
return group;
|
|
@@ -19940,11 +19945,11 @@ function directoryView(facts, imports, coverage, entries, input, directory, pref
|
|
|
19940
19945
|
]);
|
|
19941
19946
|
}
|
|
19942
19947
|
const detailed = [
|
|
19943
|
-
...code.map((
|
|
19944
|
-
const declarations2 = (facts.exported.get(
|
|
19948
|
+
...code.map((path21) => {
|
|
19949
|
+
const declarations2 = (facts.exported.get(path21) ?? []).map(({ text: text2 }) => text2);
|
|
19945
19950
|
return [
|
|
19946
|
-
|
|
19947
|
-
`${
|
|
19951
|
+
path21,
|
|
19952
|
+
`${path21} ${lineCount(path21)}${declarations2.length ? `: ${declarations2.join(", ")}` : ""}`
|
|
19948
19953
|
];
|
|
19949
19954
|
}),
|
|
19950
19955
|
...listedOther.map((entry) => [
|
|
@@ -19955,7 +19960,7 @@ function directoryView(facts, imports, coverage, entries, input, directory, pref
|
|
|
19955
19960
|
];
|
|
19956
19961
|
const directories = /* @__PURE__ */ new Map();
|
|
19957
19962
|
for (const entry of [
|
|
19958
|
-
...code.map((
|
|
19963
|
+
...code.map((path21) => ({ path: path21, item: lineCount(path21) })),
|
|
19959
19964
|
...listedOther.map((entry2) => ({
|
|
19960
19965
|
path: entry2.path,
|
|
19961
19966
|
item: entry2.state === "TEXT" ? "" : `(${entry2.state})`
|
|
@@ -19983,10 +19988,10 @@ function directoryView(facts, imports, coverage, entries, input, directory, pref
|
|
|
19983
19988
|
);
|
|
19984
19989
|
const text = visible.filter((entry) => entry.state === "TEXT").length;
|
|
19985
19990
|
const resolution = /* @__PURE__ */ new Map();
|
|
19986
|
-
for (const
|
|
19987
|
-
const counts = facts.calls.get(
|
|
19991
|
+
for (const path21 of code) {
|
|
19992
|
+
const counts = facts.calls.get(path21);
|
|
19988
19993
|
if (!counts) continue;
|
|
19989
|
-
const language = facts.files.get(
|
|
19994
|
+
const language = facts.files.get(path21)?.language ?? "unknown";
|
|
19990
19995
|
const total = resolution.get(language) ?? { resolved: 0, unresolved: 0, external: 0 };
|
|
19991
19996
|
total.resolved += counts.resolved;
|
|
19992
19997
|
total.unresolved += counts.unresolved;
|
|
@@ -20043,8 +20048,8 @@ var DeclarationGroups = class {
|
|
|
20043
20048
|
prefixes;
|
|
20044
20049
|
showTests;
|
|
20045
20050
|
memberCalls;
|
|
20046
|
-
visible(
|
|
20047
|
-
return mapPathAllowed(
|
|
20051
|
+
visible(path21) {
|
|
20052
|
+
return mapPathAllowed(path21, this.prefixes) && (this.showTests || !mapTestPath(path21));
|
|
20048
20053
|
}
|
|
20049
20054
|
entry(object2, imported = false) {
|
|
20050
20055
|
if (mapMiniprogramTemplate(object2.anchor.path)) return "(template)";
|
|
@@ -20089,11 +20094,11 @@ var DeclarationGroups = class {
|
|
|
20089
20094
|
value.lines.push(line);
|
|
20090
20095
|
aggregates.set(key, value);
|
|
20091
20096
|
};
|
|
20092
|
-
const dispatch = (arrow, label, ref2,
|
|
20097
|
+
const dispatch = (arrow, label, ref2, path21, line) => {
|
|
20093
20098
|
const other = graph.object(graph.owner(ref2));
|
|
20094
20099
|
if (owned.has(other.id)) return;
|
|
20095
|
-
if (!this.visible(
|
|
20096
|
-
if (mapPathAllowed(
|
|
20100
|
+
if (!this.visible(path21)) {
|
|
20101
|
+
if (mapPathAllowed(path21, this.prefixes)) omittedTests++;
|
|
20097
20102
|
return;
|
|
20098
20103
|
}
|
|
20099
20104
|
add(arrow, label, other, line);
|
|
@@ -20250,7 +20255,7 @@ var DeclarationGroups = class {
|
|
|
20250
20255
|
else files2.set(call.path, [item]);
|
|
20251
20256
|
}
|
|
20252
20257
|
lines.push(
|
|
20253
|
-
` \u2190 possible callers by name: ${[...files2].map(([
|
|
20258
|
+
` \u2190 possible callers by name: ${[...files2].map(([path21, items]) => `${path21}: ${items.join(", ")}`).join("; ")}${inTests}`
|
|
20254
20259
|
);
|
|
20255
20260
|
} else if (possibleInTests)
|
|
20256
20261
|
lines.push(` \u2190 possible callers by name: ${possibleInTests} in test files (includeTests)`);
|
|
@@ -20286,14 +20291,14 @@ var DeclarationGroups = class {
|
|
|
20286
20291
|
return { lines, neighbors: [...new Set(neighbors)] };
|
|
20287
20292
|
}
|
|
20288
20293
|
};
|
|
20289
|
-
function fileView(store, coverage, graph, input,
|
|
20290
|
-
const entry = store.getEntry(input.version,
|
|
20291
|
-
if (!entry || !mapPathAllowed(
|
|
20292
|
-
const showTests = input.includeTests === true || mapTestPath(
|
|
20293
|
-
const module = mapCodePath(
|
|
20294
|
-
const gaps = coverage.files.get(
|
|
20294
|
+
function fileView(store, coverage, graph, input, path21, prefixes) {
|
|
20295
|
+
const entry = store.getEntry(input.version, path21);
|
|
20296
|
+
if (!entry || !mapPathAllowed(path21, prefixes)) return notFound();
|
|
20297
|
+
const showTests = input.includeTests === true || mapTestPath(path21);
|
|
20298
|
+
const module = mapCodePath(path21) ? graph.objectsAt(path21).find((object2) => mapIsModule(object2)) : mapMiniprogramTemplate(path21) ? graph.objectsAt(path21).find((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : void 0;
|
|
20299
|
+
const gaps = coverage.files.get(path21) ?? [];
|
|
20295
20300
|
const head = [
|
|
20296
|
-
`PROJECT MAP \xB7 FILE ${
|
|
20301
|
+
`PROJECT MAP \xB7 FILE ${path21} \xB7 ${entry.state !== "TEXT" ? entry.state : module ? module.parsing === "NOT_PARSED" ? `not parsed${gaps.length ? ` (${gaps.join("; ")})` : ""}; read it as text` : `${module.anchor.endLine} lines${gaps.length ? ` \xB7 ${gaps.join("; ")}` : ""}` : `${entry.byteLength} bytes, not analyzed; read it as text`}`
|
|
20297
20302
|
];
|
|
20298
20303
|
if (!module || entry.state !== "TEXT")
|
|
20299
20304
|
return pageBlocks("FILE", head, [], input.offset ?? 0, input.outputBudget);
|
|
@@ -20313,7 +20318,7 @@ function fileView(store, coverage, graph, input, path20, prefixes) {
|
|
|
20313
20318
|
tags.set(relation.from, list);
|
|
20314
20319
|
}
|
|
20315
20320
|
const describe3 = (object2) => [
|
|
20316
|
-
`${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path ===
|
|
20321
|
+
`${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path21 ? "" : ` (${object2.anchor.path})`}`,
|
|
20317
20322
|
...tags.get(object2.id) ?? []
|
|
20318
20323
|
].join(" ");
|
|
20319
20324
|
const declarations2 = [];
|
|
@@ -20328,11 +20333,11 @@ function fileView(store, coverage, graph, input, path20, prefixes) {
|
|
|
20328
20333
|
);
|
|
20329
20334
|
}
|
|
20330
20335
|
const elsewhere = /* @__PURE__ */ new Map();
|
|
20331
|
-
for (const object2 of graph.objectsAt(
|
|
20336
|
+
for (const object2 of graph.objectsAt(path21)) {
|
|
20332
20337
|
const parent = mapIsModule(object2) ? void 0 : graph.parent(object2.id);
|
|
20333
20338
|
if (parent === void 0 || !graph.isAddressable(object2)) continue;
|
|
20334
20339
|
const container = graph.object(parent);
|
|
20335
|
-
if (mapIsModule(container) || container.anchor.path ===
|
|
20340
|
+
if (mapIsModule(container) || container.anchor.path === path21) continue;
|
|
20336
20341
|
const into = elsewhere.get(parent);
|
|
20337
20342
|
if (into) into.push(object2);
|
|
20338
20343
|
else elsewhere.set(parent, [object2]);
|
|
@@ -20346,7 +20351,7 @@ function fileView(store, coverage, graph, input, path20, prefixes) {
|
|
|
20346
20351
|
if (declarations2.length) blocks.push(["DECLARATIONS (* exported)", ...declarations2].join("\n"));
|
|
20347
20352
|
const imports = /* @__PURE__ */ new Set();
|
|
20348
20353
|
const external = /* @__PURE__ */ new Set();
|
|
20349
|
-
const fileObjects = graph.objectsAt(
|
|
20354
|
+
const fileObjects = graph.objectsAt(path21).map((object2) => object2.id);
|
|
20350
20355
|
for (const relation of graph.relationsFrom(fileObjects)) {
|
|
20351
20356
|
if (relation.kind !== "IMPORTS") continue;
|
|
20352
20357
|
if (relation.to === void 0) external.add(relation.target);
|
|
@@ -20357,8 +20362,8 @@ function fileView(store, coverage, graph, input, path20, prefixes) {
|
|
|
20357
20362
|
}
|
|
20358
20363
|
const importers = /* @__PURE__ */ new Set();
|
|
20359
20364
|
const testImporters = /* @__PURE__ */ new Set();
|
|
20360
|
-
const imported = mapImportTarget(
|
|
20361
|
-
const packageModules = imported ===
|
|
20365
|
+
const imported = mapImportTarget(path21);
|
|
20366
|
+
const packageModules = imported === path21 ? [module.id] : store.listEntries(input.version).filter((entry2) => mapImportTarget(entry2.path) === imported).flatMap((entry2) => graph.objectsAt(entry2.path).filter((object2) => mapIsModule(object2))).map((object2) => object2.id);
|
|
20362
20367
|
for (const relation of graph.relationsTo(packageModules)) {
|
|
20363
20368
|
if (relation.kind !== "IMPORTS") continue;
|
|
20364
20369
|
const source = relation.anchor.path;
|
|
@@ -20386,16 +20391,16 @@ function fileView(store, coverage, graph, input, path20, prefixes) {
|
|
|
20386
20391
|
if (scope.length) blocks.push(["MODULE SCOPE (top-level statements)", ...scope].join("\n"));
|
|
20387
20392
|
return pageBlocks("FILE", head, blocks, input.offset ?? 0, input.outputBudget);
|
|
20388
20393
|
}
|
|
20389
|
-
function declarationView(graph, input,
|
|
20394
|
+
function declarationView(graph, input, path21, prefixes, memberCalls) {
|
|
20390
20395
|
const requested = input.depth ?? 1;
|
|
20391
20396
|
if (!Number.isSafeInteger(requested) || requested < 1 || requested > MAP_VIEW_LIMITS.directedDepth)
|
|
20392
20397
|
return invalid2();
|
|
20393
20398
|
const both = (input.direction ?? "BOTH") === "BOTH";
|
|
20394
20399
|
const depth = both ? Math.min(requested, MAP_VIEW_LIMITS.bothDepth) : requested;
|
|
20395
20400
|
const { name, line } = input;
|
|
20396
|
-
const selected = mapSelectDeclarations(graph,
|
|
20401
|
+
const selected = mapSelectDeclarations(graph, path21, name, line);
|
|
20397
20402
|
if (!selected.length) return notFound();
|
|
20398
|
-
const showTests = input.includeTests === true || mapTestPath(
|
|
20403
|
+
const showTests = input.includeTests === true || mapTestPath(path21);
|
|
20399
20404
|
const groups = new DeclarationGroups(graph, input, prefixes, showTests, memberCalls);
|
|
20400
20405
|
const blocks = [];
|
|
20401
20406
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -20443,7 +20448,7 @@ function declarationView(graph, input, path20, prefixes, memberCalls) {
|
|
|
20443
20448
|
);
|
|
20444
20449
|
}
|
|
20445
20450
|
const head = [
|
|
20446
|
-
`PROJECT MAP \xB7 DECLARATION ${
|
|
20451
|
+
`PROJECT MAP \xB7 DECLARATION ${path21}${name === void 0 ? "" : ` ${name}`}${line === void 0 ? "" : ` line ${line}`} \xB7 direction ${input.direction ?? "BOTH"} \xB7 depth ${depth}${depth < requested ? ` (BOTH is limited to ${MAP_VIEW_LIMITS.bothDepth})` : ""}${prefixes.includes(".") ? "" : " \xB7 limited to authorized paths"}`,
|
|
20447
20452
|
...truncated ? [`Expansion stopped at ${MAP_VIEW_LIMITS.declarations} declarations.`] : [],
|
|
20448
20453
|
...(input.direction ?? "BOTH") === "OUTGOING" ? [] : [callerCoverage(input.textSearch ?? DEFAULT_TEXT_SEARCH)]
|
|
20449
20454
|
];
|
|
@@ -20571,10 +20576,10 @@ var ProjectMapQuery = class {
|
|
|
20571
20576
|
view(input, signal) {
|
|
20572
20577
|
this.requireReadableMap(input.version, signal);
|
|
20573
20578
|
const { offset, prefixes } = admission(input);
|
|
20574
|
-
const
|
|
20579
|
+
const path21 = normalizeProjectEvidencePath(input.path, true) || ".";
|
|
20575
20580
|
const view = mapView(
|
|
20576
20581
|
this.store,
|
|
20577
|
-
{ ...input, path:
|
|
20582
|
+
{ ...input, path: path21, offset, allowedPathPrefixes: prefixes },
|
|
20578
20583
|
this.views
|
|
20579
20584
|
);
|
|
20580
20585
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
@@ -20775,13 +20780,13 @@ var ProjectMapSourceReader = class _ProjectMapSourceReader {
|
|
|
20775
20780
|
*/
|
|
20776
20781
|
async readAll(expected) {
|
|
20777
20782
|
if (this.signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
20778
|
-
const paths = expected.map(({ path:
|
|
20779
|
-
assertProjectEvidencePathNotSensitive(
|
|
20780
|
-
if (isProjectEvidenceTraversalExcluded(
|
|
20783
|
+
const paths = expected.map(({ path: path21 }) => {
|
|
20784
|
+
assertProjectEvidencePathNotSensitive(path21);
|
|
20785
|
+
if (isProjectEvidenceTraversalExcluded(path21))
|
|
20781
20786
|
throw new ProjectEvidenceError("PROJECT_FILE_NOT_ALLOWED", false);
|
|
20782
|
-
return
|
|
20787
|
+
return path21;
|
|
20783
20788
|
});
|
|
20784
|
-
const results = this.commit ? await this.commit.readAll(paths) : await concurrently(paths, (
|
|
20789
|
+
const results = this.commit ? await this.commit.readAll(paths) : await concurrently(paths, (path21) => this.session.captureFile(path21));
|
|
20785
20790
|
for (const [index, { entry }] of results.entries()) {
|
|
20786
20791
|
const wanted = expected[index];
|
|
20787
20792
|
if (entry.state !== wanted?.state || entry.contentDigest !== wanted.contentDigest || entry.byteLength !== wanted.byteLength)
|
|
@@ -21502,8 +21507,8 @@ var CodeIndexStore = class {
|
|
|
21502
21507
|
}
|
|
21503
21508
|
}
|
|
21504
21509
|
/** Stages what a language keeps of the build for the next one, stored with the version. */
|
|
21505
|
-
appendMapLanguageState(buildRef, language,
|
|
21506
|
-
this.database.prepare("INSERT INTO project_map_staging (build_ref, kind, value_json) VALUES (?, ?, ?)").run(buildRef, "states", canonicalJson({ language, state }));
|
|
21510
|
+
appendMapLanguageState(buildRef, language, state2) {
|
|
21511
|
+
this.database.prepare("INSERT INTO project_map_staging (build_ref, kind, value_json) VALUES (?, ?, ?)").run(buildRef, "states", canonicalJson({ language, state: state2 }));
|
|
21507
21512
|
}
|
|
21508
21513
|
discardMapStage(buildRef) {
|
|
21509
21514
|
this.database.prepare("DELETE FROM project_map_staging WHERE build_ref = ?").run(buildRef);
|
|
@@ -21523,7 +21528,7 @@ var CodeIndexStore = class {
|
|
|
21523
21528
|
const staged = this.stageUnits(buildRef, paths, linked);
|
|
21524
21529
|
const reused = linked ? this.database.prepare(`SELECT path, unit_ref FROM project_map_version_units
|
|
21525
21530
|
WHERE version_ref = ? AND path IN (SELECT value FROM json_each(?))`).all(linked.version, JSON.stringify([...linked.paths])).map((row) => ({ path: String(row.path), unit: String(row.unit_ref) })) : [];
|
|
21526
|
-
if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path:
|
|
21531
|
+
if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path: path21 }) => !paths.has(path21)) || staged.some(({ path: path21 }) => linked?.paths.has(path21)))
|
|
21527
21532
|
throw new MapReplayConflict();
|
|
21528
21533
|
const units = [...staged, ...reused].sort(
|
|
21529
21534
|
(left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
|
|
@@ -21577,7 +21582,7 @@ var CodeIndexStore = class {
|
|
|
21577
21582
|
const member = this.database.prepare(
|
|
21578
21583
|
"INSERT INTO project_map_version_units VALUES (?, ?, ?)"
|
|
21579
21584
|
);
|
|
21580
|
-
for (const { path:
|
|
21585
|
+
for (const { path: path21, unit } of reused) member.run(version2.version, path21, unit);
|
|
21581
21586
|
this.database.prepare("INSERT INTO project_map_coverage VALUES (?, ?)").run(version2.version, canonicalJson(coverage));
|
|
21582
21587
|
}
|
|
21583
21588
|
this.database.exec(`DELETE FROM project_map_publish_objects;
|
|
@@ -21632,7 +21637,7 @@ var CodeIndexStore = class {
|
|
|
21632
21637
|
corrupt2();
|
|
21633
21638
|
}
|
|
21634
21639
|
if (linked) {
|
|
21635
|
-
const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((
|
|
21640
|
+
const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((path21) => !linked.paths.has(path21));
|
|
21636
21641
|
if (database.prepare(`SELECT 1 FROM project_map_objects gone
|
|
21637
21642
|
WHERE gone.version_ref = ? AND gone.path IN (SELECT value FROM json_each(?))
|
|
21638
21643
|
AND gone.entity_ref NOT IN (SELECT entity_ref FROM project_map_publish_objects)
|
|
@@ -21654,17 +21659,17 @@ var CodeIndexStore = class {
|
|
|
21654
21659
|
const units = [];
|
|
21655
21660
|
for (const row of database.prepare(`SELECT path FROM project_map_publish_objects
|
|
21656
21661
|
UNION SELECT path FROM project_map_publish_relations ORDER BY path`).all()) {
|
|
21657
|
-
const
|
|
21658
|
-
const hash2 = createHash4("sha256").update(
|
|
21662
|
+
const path21 = String(row.path);
|
|
21663
|
+
const hash2 = createHash4("sha256").update(path21).update("\0");
|
|
21659
21664
|
for (const [mark, statement] of [
|
|
21660
21665
|
["object", objects2],
|
|
21661
21666
|
["relation", relations],
|
|
21662
21667
|
["note", pathNotes]
|
|
21663
21668
|
])
|
|
21664
|
-
for (const fact of statement.all(
|
|
21669
|
+
for (const fact of statement.all(path21))
|
|
21665
21670
|
for (const value of Object.values(fact))
|
|
21666
21671
|
hash2.update(mark).update("\0").update(String(value)).update("\0");
|
|
21667
|
-
units.push({ path:
|
|
21672
|
+
units.push({ path: path21, unit: hash2.digest("hex") });
|
|
21668
21673
|
}
|
|
21669
21674
|
return units;
|
|
21670
21675
|
}
|
|
@@ -21682,13 +21687,13 @@ var CodeIndexStore = class {
|
|
|
21682
21687
|
"INSERT INTO project_map_unit_notes SELECT ?, * FROM project_map_publish_notes WHERE path = ?"
|
|
21683
21688
|
);
|
|
21684
21689
|
const member = database.prepare("INSERT INTO project_map_version_units VALUES (?, ?, ?)");
|
|
21685
|
-
for (const { path:
|
|
21686
|
-
if (insertUnit.run(unit,
|
|
21687
|
-
unitObjects.run(unit,
|
|
21688
|
-
unitRelations.run(unit,
|
|
21689
|
-
unitNotes.run(unit,
|
|
21690
|
+
for (const { path: path21, unit } of units) {
|
|
21691
|
+
if (insertUnit.run(unit, path21).changes) {
|
|
21692
|
+
unitObjects.run(unit, path21);
|
|
21693
|
+
unitRelations.run(unit, path21);
|
|
21694
|
+
unitNotes.run(unit, path21);
|
|
21690
21695
|
}
|
|
21691
|
-
member.run(version2,
|
|
21696
|
+
member.run(version2, path21, unit);
|
|
21692
21697
|
}
|
|
21693
21698
|
}
|
|
21694
21699
|
/**
|
|
@@ -21735,7 +21740,7 @@ var CodeIndexStore = class {
|
|
|
21735
21740
|
"SELECT result_json FROM project_map_context_results WHERE version_ref = ? AND context_ref = ?"
|
|
21736
21741
|
).get(version2, contextRef);
|
|
21737
21742
|
if (!context || !result) return corrupt2();
|
|
21738
|
-
const { gaps, parsedFiles, state, paths } = JSON.parse(String(result.result_json));
|
|
21743
|
+
const { gaps, parsedFiles, state: state2, paths } = JSON.parse(String(result.result_json));
|
|
21739
21744
|
const analysis = MapAnalysisSchema.parse({
|
|
21740
21745
|
contexts: [JSON.parse(String(context.context_json))],
|
|
21741
21746
|
objects: [],
|
|
@@ -21747,7 +21752,7 @@ var CodeIndexStore = class {
|
|
|
21747
21752
|
});
|
|
21748
21753
|
return {
|
|
21749
21754
|
analysis,
|
|
21750
|
-
...
|
|
21755
|
+
...state2 !== void 0 ? { state: state2 } : {},
|
|
21751
21756
|
...paths !== void 0 ? { paths: external_exports.array(external_exports.string()).parse(paths) } : {}
|
|
21752
21757
|
};
|
|
21753
21758
|
}
|
|
@@ -21951,7 +21956,7 @@ var CodeIndexStore = class {
|
|
|
21951
21956
|
}
|
|
21952
21957
|
}
|
|
21953
21958
|
entry(row) {
|
|
21954
|
-
const
|
|
21959
|
+
const state2 = String(row.entry_state);
|
|
21955
21960
|
if (![
|
|
21956
21961
|
"TEXT",
|
|
21957
21962
|
"TYPE_RESTRICTED",
|
|
@@ -21960,11 +21965,11 @@ var CodeIndexStore = class {
|
|
|
21960
21965
|
"NOT_READABLE",
|
|
21961
21966
|
"SYMLINK",
|
|
21962
21967
|
"UNSUPPORTED_ENTRY"
|
|
21963
|
-
].includes(
|
|
21968
|
+
].includes(state2) || state2 === "TEXT" && typeof row.content_digest !== "string")
|
|
21964
21969
|
return corrupt2();
|
|
21965
21970
|
return Object.freeze({
|
|
21966
21971
|
path: String(row.path),
|
|
21967
|
-
state,
|
|
21972
|
+
state: state2,
|
|
21968
21973
|
byteLength: Number(row.byte_length),
|
|
21969
21974
|
...typeof row.content_digest === "string" ? { contentDigest: row.content_digest } : {}
|
|
21970
21975
|
});
|
|
@@ -21986,19 +21991,19 @@ function replayableContexts(parent, digests, claims) {
|
|
|
21986
21991
|
const { analysis, paths } = parent.shell(ref);
|
|
21987
21992
|
const files = /* @__PURE__ */ new Set([...codeFiles(context, analysis.parsedFiles, claims), ...paths ?? []]);
|
|
21988
21993
|
factFiles.set(ref, files);
|
|
21989
|
-
for (const
|
|
21990
|
-
const refs = sharing.get(
|
|
21994
|
+
for (const path21 of files) {
|
|
21995
|
+
const refs = sharing.get(path21) ?? /* @__PURE__ */ new Set();
|
|
21991
21996
|
refs.add(ref);
|
|
21992
|
-
sharing.set(
|
|
21997
|
+
sharing.set(path21, refs);
|
|
21993
21998
|
}
|
|
21994
21999
|
if (!paths || !contextFiles(context).every(
|
|
21995
|
-
(
|
|
22000
|
+
(path21) => digests.get(path21) !== void 0 && digests.get(path21) === parent.entries.get(path21)
|
|
21996
22001
|
))
|
|
21997
22002
|
analyzed.add(ref);
|
|
21998
22003
|
}
|
|
21999
22004
|
for (const ref of analyzed)
|
|
22000
|
-
for (const
|
|
22001
|
-
for (const other of sharing.get(
|
|
22005
|
+
for (const path21 of factFiles.get(ref) ?? [])
|
|
22006
|
+
for (const other of sharing.get(path21) ?? []) analyzed.add(other);
|
|
22002
22007
|
const replayable = new Set([...parent.contexts.keys()].filter((ref) => !analyzed.has(ref)));
|
|
22003
22008
|
return { replayable, sharing, factFiles };
|
|
22004
22009
|
}
|
|
@@ -22030,8 +22035,8 @@ var ProjectMapAnalyzer = class {
|
|
|
22030
22035
|
languages;
|
|
22031
22036
|
observe;
|
|
22032
22037
|
id;
|
|
22033
|
-
claims(
|
|
22034
|
-
return this.languages.some((language) => language.claims(
|
|
22038
|
+
claims(path21) {
|
|
22039
|
+
return this.languages.some((language) => language.claims(path21));
|
|
22035
22040
|
}
|
|
22036
22041
|
// A context holds one language's code, so its requests are that language's.
|
|
22037
22042
|
async references(input, references, signal, until) {
|
|
@@ -22040,8 +22045,8 @@ var ProjectMapAnalyzer = class {
|
|
|
22040
22045
|
return language?.references ? language.references(input, references, signal, this.observe, until) : { pages: references.map(() => null), requiredFiles: [] };
|
|
22041
22046
|
}
|
|
22042
22047
|
// A context's compiler diagnostics, undefined for a language without a compiler to ask.
|
|
22043
|
-
diagnostics(input,
|
|
22044
|
-
return this.languages.find((language) => language.claims(
|
|
22048
|
+
diagnostics(input, path21, signal) {
|
|
22049
|
+
return this.languages.find((language) => language.claims(path21))?.diagnostics?.(input, signal, this.observe);
|
|
22045
22050
|
}
|
|
22046
22051
|
async analyze(reader, entries, installed, signal, consume, keep, parent) {
|
|
22047
22052
|
const result = {
|
|
@@ -22065,7 +22070,7 @@ var ProjectMapAnalyzer = class {
|
|
|
22065
22070
|
const digests = /* @__PURE__ */ new Map();
|
|
22066
22071
|
for (const entry of entries)
|
|
22067
22072
|
if (entry.contentDigest) digests.set(entry.path, entry.contentDigest);
|
|
22068
|
-
const claims = (
|
|
22073
|
+
const claims = (path21) => this.claims(path21);
|
|
22069
22074
|
const { replayable, sharing, factFiles } = parent ? replayableContexts(parent, digests, claims) : {
|
|
22070
22075
|
replayable: /* @__PURE__ */ new Set(),
|
|
22071
22076
|
sharing: /* @__PURE__ */ new Map(),
|
|
@@ -22077,16 +22082,16 @@ var ProjectMapAnalyzer = class {
|
|
|
22077
22082
|
const linked = /* @__PURE__ */ new Set();
|
|
22078
22083
|
const analyzedFiles = /* @__PURE__ */ new Set();
|
|
22079
22084
|
const stagedPaths = /* @__PURE__ */ new Set();
|
|
22080
|
-
const requestDigest = (request, files2) => digestValue({ request, files: files2.map((
|
|
22085
|
+
const requestDigest = (request, files2) => digestValue({ request, files: files2.map((path21) => [path21, digests.get(path21) ?? null]) });
|
|
22081
22086
|
const replaysDigest = (contextRef2, digest) => parent !== void 0 && replayable.has(contextRef2) && parent.contexts.get(contextRef2)?.requestDigest === digest;
|
|
22082
22087
|
const replays = (contextRef2, request, files2) => replaysDigest(contextRef2, requestDigest(request, files2));
|
|
22083
22088
|
const reuse = (contextRef2, request, files2) => {
|
|
22084
22089
|
const digest = requestDigest(request, files2);
|
|
22085
22090
|
requests.set(contextRef2, digest);
|
|
22086
22091
|
if (!parent || !replaysDigest(contextRef2, digest)) return void 0;
|
|
22087
|
-
const { analysis, state, paths } = parent.shell(contextRef2);
|
|
22092
|
+
const { analysis, state: state2, paths } = parent.shell(contextRef2);
|
|
22088
22093
|
if (!paths) return invalidParent();
|
|
22089
|
-
if (
|
|
22094
|
+
if (state2 !== void 0) states.set(contextRef2, state2);
|
|
22090
22095
|
replayed.set(contextRef2, paths);
|
|
22091
22096
|
this.observe?.({
|
|
22092
22097
|
operation: "REUSE",
|
|
@@ -22098,8 +22103,8 @@ var ProjectMapAnalyzer = class {
|
|
|
22098
22103
|
};
|
|
22099
22104
|
const previous = (contextRef2) => {
|
|
22100
22105
|
if (!parent?.contexts.has(contextRef2)) return void 0;
|
|
22101
|
-
const
|
|
22102
|
-
return
|
|
22106
|
+
const state2 = parent.state(contextRef2);
|
|
22107
|
+
return state2 === void 0 ? void 0 : { state: state2, digests: parent.entries };
|
|
22103
22108
|
};
|
|
22104
22109
|
const decode3 = (value) => {
|
|
22105
22110
|
if (!value?.content) throw new ProjectEvidenceError("PROJECT_MAP_SOURCE_CHANGED", true);
|
|
@@ -22118,7 +22123,7 @@ var ProjectMapAnalyzer = class {
|
|
|
22118
22123
|
const ref = analysis.contexts[0]?.ref ?? "";
|
|
22119
22124
|
if (options?.linked?.length) {
|
|
22120
22125
|
if (!parent || analysis.contexts.length !== 1) return invalidParent();
|
|
22121
|
-
for (const
|
|
22126
|
+
for (const path21 of options.linked) linked.add(path21);
|
|
22122
22127
|
this.observe?.({
|
|
22123
22128
|
operation: "LINK",
|
|
22124
22129
|
phase: "FINISHED",
|
|
@@ -22145,7 +22150,7 @@ var ProjectMapAnalyzer = class {
|
|
|
22145
22150
|
});
|
|
22146
22151
|
for (const file2 of analysis.parsedFiles) parsed.add(file2);
|
|
22147
22152
|
const staged = factPaths(analysis);
|
|
22148
|
-
for (const
|
|
22153
|
+
for (const path21 of staged) stagedPaths.add(path21);
|
|
22149
22154
|
for (const context of analysis.contexts) {
|
|
22150
22155
|
for (const file2 of context.configurationFiles) configurationInputs.add(file2);
|
|
22151
22156
|
if (!replayed.has(context.ref))
|
|
@@ -22154,10 +22159,10 @@ var ProjectMapAnalyzer = class {
|
|
|
22154
22159
|
}
|
|
22155
22160
|
for (const gap of analysis.gaps) result.gaps.push(gap);
|
|
22156
22161
|
const requestDigest2 = requests.get(ref);
|
|
22157
|
-
const
|
|
22162
|
+
const state2 = states.get(ref);
|
|
22158
22163
|
consume(analysis, {
|
|
22159
22164
|
...requestDigest2 ? { requestDigest: requestDigest2 } : {},
|
|
22160
|
-
...
|
|
22165
|
+
...state2 !== void 0 ? { state: state2 } : {},
|
|
22161
22166
|
paths: replayed.get(ref) ?? [.../* @__PURE__ */ new Set([...staged, ...options?.linked ?? []])].sort()
|
|
22162
22167
|
});
|
|
22163
22168
|
};
|
|
@@ -22176,9 +22181,9 @@ var ProjectMapAnalyzer = class {
|
|
|
22176
22181
|
reuse,
|
|
22177
22182
|
replays,
|
|
22178
22183
|
previous,
|
|
22179
|
-
configuration: (
|
|
22184
|
+
configuration: (path21) => configurationInputs.add(path21),
|
|
22180
22185
|
kept: parent?.kept(language.id),
|
|
22181
|
-
keep: (
|
|
22186
|
+
keep: (state2) => keep(language.id, state2),
|
|
22182
22187
|
observe: this.observe
|
|
22183
22188
|
},
|
|
22184
22189
|
signal
|
|
@@ -22215,12 +22220,12 @@ var ProjectMapAnalyzer = class {
|
|
|
22215
22220
|
if (files.objects.length) accept(files);
|
|
22216
22221
|
if (parent && (replayed.size || linked.size)) {
|
|
22217
22222
|
for (const ref of replayed.keys())
|
|
22218
|
-
for (const
|
|
22219
|
-
if (analyzedFiles.has(
|
|
22223
|
+
for (const path21 of factFiles.get(ref) ?? invalidParent())
|
|
22224
|
+
if (analyzedFiles.has(path21) || [...sharing.get(path21) ?? []].some((other) => !replayed.has(other)))
|
|
22220
22225
|
throw new MapReplayConflict();
|
|
22221
|
-
for (const paths of replayed.values()) for (const
|
|
22222
|
-
for (const
|
|
22223
|
-
if (analyzedFiles.has(
|
|
22226
|
+
for (const paths of replayed.values()) for (const path21 of paths) linked.add(path21);
|
|
22227
|
+
for (const path21 of linked)
|
|
22228
|
+
if (analyzedFiles.has(path21) || stagedPaths.has(path21)) throw new MapReplayConflict();
|
|
22224
22229
|
parent.link([...linked]);
|
|
22225
22230
|
}
|
|
22226
22231
|
result.parsedFiles = [...parsed].sort();
|
|
@@ -22257,12 +22262,12 @@ var ProjectMapReferenceQuery = class {
|
|
|
22257
22262
|
return source;
|
|
22258
22263
|
}
|
|
22259
22264
|
// The compiler contexts a file is in.
|
|
22260
|
-
contexts(version2,
|
|
22265
|
+
contexts(version2, path21) {
|
|
22261
22266
|
return this.store.database.prepare(`SELECT DISTINCT c.context_ref, c.context_json
|
|
22262
22267
|
FROM project_map_contexts c, json_each(c.context_json, '$.inputFiles') f
|
|
22263
22268
|
WHERE c.version_ref = ? AND f.value = ?
|
|
22264
22269
|
AND json_extract(c.context_json, '$.mode') != 'SYNTAX_ONLY'
|
|
22265
|
-
ORDER BY c.context_ref`).all(version2,
|
|
22270
|
+
ORDER BY c.context_ref`).all(version2, path21).map((value) => MapContextSchema.parse(JSON.parse(String(value.context_json))));
|
|
22266
22271
|
}
|
|
22267
22272
|
// A context's files as the version captured them.
|
|
22268
22273
|
entries(version2, context) {
|
|
@@ -22297,7 +22302,7 @@ var ProjectMapReferenceQuery = class {
|
|
|
22297
22302
|
* A context's compiler diagnostics: the stored result of a compile of the same inputs, or a
|
|
22298
22303
|
* compile's, stored for the next. Undefined for a language without a compiler to ask.
|
|
22299
22304
|
*/
|
|
22300
|
-
async compileDiagnostics(version2, source, context,
|
|
22305
|
+
async compileDiagnostics(version2, source, context, path21, signal) {
|
|
22301
22306
|
const key = digestValue({
|
|
22302
22307
|
operation: "DIAGNOSTICS",
|
|
22303
22308
|
inputs: this.compileInputs(version2, source, context)
|
|
@@ -22305,7 +22310,7 @@ var ProjectMapReferenceQuery = class {
|
|
|
22305
22310
|
const stored = this.store.compileResults(version2, [key]);
|
|
22306
22311
|
if (stored.has(key)) return MapDiagnosticsSchema.parse(stored.get(key));
|
|
22307
22312
|
const { reader, request } = await this.open(version2, source, context, signal);
|
|
22308
|
-
const result = await this.analyzer.diagnostics(request,
|
|
22313
|
+
const result = await this.analyzer.diagnostics(request, path21, signal);
|
|
22309
22314
|
await reader.assertStable();
|
|
22310
22315
|
if (!result) return void 0;
|
|
22311
22316
|
if (result.requiredFiles.length)
|
|
@@ -22379,7 +22384,7 @@ var ProjectMapReferenceQuery = class {
|
|
|
22379
22384
|
/** The configurations of the contexts a version's files are in. */
|
|
22380
22385
|
contextConfigurations(version2, paths) {
|
|
22381
22386
|
return paths.flatMap(
|
|
22382
|
-
(
|
|
22387
|
+
(path21) => this.contexts(version2, path21).flatMap((context) => context.configPath ?? [])
|
|
22383
22388
|
);
|
|
22384
22389
|
}
|
|
22385
22390
|
/**
|
|
@@ -22405,8 +22410,8 @@ var ProjectMapReferenceQuery = class {
|
|
|
22405
22410
|
unchecked.push(configPath);
|
|
22406
22411
|
continue;
|
|
22407
22412
|
}
|
|
22408
|
-
const [
|
|
22409
|
-
const result =
|
|
22413
|
+
const [path21] = context.rootFiles ?? context.inputFiles;
|
|
22414
|
+
const result = path21 === void 0 ? void 0 : await this.compileDiagnostics(input.version, source, context, path21, signal);
|
|
22410
22415
|
if (!result) continue;
|
|
22411
22416
|
const found = new Map(
|
|
22412
22417
|
result.diagnostics.map((item) => [
|
|
@@ -22437,9 +22442,9 @@ var ProjectMapReferenceQuery = class {
|
|
|
22437
22442
|
const compiles = /* @__PURE__ */ new Map();
|
|
22438
22443
|
for (const ref of input.refs) {
|
|
22439
22444
|
const object2 = requireMapObject(this.store, input.version, { entityRef: ref }, ["."]);
|
|
22440
|
-
const
|
|
22441
|
-
const contexts = contextsOf.get(
|
|
22442
|
-
contextsOf.set(
|
|
22445
|
+
const path21 = object2.anchor.path;
|
|
22446
|
+
const contexts = contextsOf.get(path21) ?? this.contexts(input.version, path21);
|
|
22447
|
+
contextsOf.set(path21, contexts);
|
|
22443
22448
|
const readable = object2.symbolStart === void 0 ? [] : contexts;
|
|
22444
22449
|
found.set(ref, {
|
|
22445
22450
|
uses: [],
|
|
@@ -22499,8 +22504,8 @@ var ProjectMapReferenceQuery = class {
|
|
|
22499
22504
|
);
|
|
22500
22505
|
if (!prefixes.length || prefixes.length > 64)
|
|
22501
22506
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
22502
|
-
const { path:
|
|
22503
|
-
if (
|
|
22507
|
+
const { path: path21, name, line, entityRef, locator } = input;
|
|
22508
|
+
if (path21 === void 0 !== (name === void 0) || line !== void 0 && name === void 0)
|
|
22504
22509
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
22505
22510
|
const selection = mapQuerySelection(
|
|
22506
22511
|
{ path: input.within, kinds: input.kinds },
|
|
@@ -22513,7 +22518,7 @@ var ProjectMapReferenceQuery = class {
|
|
|
22513
22518
|
{
|
|
22514
22519
|
entityRef,
|
|
22515
22520
|
locator,
|
|
22516
|
-
symbol:
|
|
22521
|
+
symbol: path21 !== void 0 && name !== void 0 ? { path: path21, name, ...line === void 0 ? {} : { line } } : void 0
|
|
22517
22522
|
},
|
|
22518
22523
|
prefixes
|
|
22519
22524
|
);
|
|
@@ -22704,7 +22709,7 @@ var CodeIndex = class {
|
|
|
22704
22709
|
{ directory: source.directory.canonicalPath, digest: result.installedDigest },
|
|
22705
22710
|
controller.signal,
|
|
22706
22711
|
(unit, record2) => this.store.appendMapStage(stage, unit, record2),
|
|
22707
|
-
(language,
|
|
22712
|
+
(language, state2) => this.store.appendMapLanguageState(stage, language, state2),
|
|
22708
22713
|
parent && { ...parent, link: (paths) => linked.push(...paths) }
|
|
22709
22714
|
);
|
|
22710
22715
|
await reader.readAll(result.entries);
|
|
@@ -22758,8 +22763,8 @@ var CodeIndex = class {
|
|
|
22758
22763
|
for (const entry of this.store.listEntries(candidate))
|
|
22759
22764
|
if (entry.contentDigest) entries2.set(entry.path, entry.contentDigest);
|
|
22760
22765
|
let changed = 0;
|
|
22761
|
-
for (const [
|
|
22762
|
-
for (const
|
|
22766
|
+
for (const [path21, digest] of digests) if (entries2.get(path21) !== digest) changed++;
|
|
22767
|
+
for (const path21 of entries2.keys()) if (!digests.has(path21)) changed++;
|
|
22763
22768
|
if (!best || changed < best.changed) best = { version: candidate, entries: entries2, changed };
|
|
22764
22769
|
}
|
|
22765
22770
|
if (!best) return void 0;
|
|
@@ -22931,16 +22936,16 @@ var LOADERS = {
|
|
|
22931
22936
|
};
|
|
22932
22937
|
var DECORATED = /\b__decorat(?:orStart|eClass|eParam)\b/u;
|
|
22933
22938
|
var PAIRS = 4e6;
|
|
22934
|
-
var mapErasable = (
|
|
22935
|
-
function erase(text,
|
|
22936
|
-
const loader = LOADERS[
|
|
22939
|
+
var mapErasable = (path21) => !path21.endsWith(".d.ts") && LOADERS[path21.slice(path21.lastIndexOf("."))] !== void 0;
|
|
22940
|
+
function erase(text, path21) {
|
|
22941
|
+
const loader = LOADERS[path21.slice(path21.lastIndexOf("."))];
|
|
22937
22942
|
if (!loader) return void 0;
|
|
22938
22943
|
let code;
|
|
22939
22944
|
let map2;
|
|
22940
22945
|
try {
|
|
22941
22946
|
({ code, map: map2 } = transformSync(text, {
|
|
22942
22947
|
loader,
|
|
22943
|
-
sourcefile:
|
|
22948
|
+
sourcefile: path21,
|
|
22944
22949
|
target: "esnext",
|
|
22945
22950
|
// Lowered, so a decorator shows in the helpers it needs.
|
|
22946
22951
|
supported: { decorators: false },
|
|
@@ -23023,9 +23028,9 @@ function sourceLines(map2, count) {
|
|
|
23023
23028
|
return from;
|
|
23024
23029
|
}
|
|
23025
23030
|
var touches = (region, [start, end]) => region.from <= region.to ? start <= region.to && region.from <= end : start <= region.to && end >= region.from;
|
|
23026
|
-
function mapRuntimeLines(
|
|
23027
|
-
const before = erase(baseText,
|
|
23028
|
-
const after = erase(text,
|
|
23031
|
+
function mapRuntimeLines(path21, baseText, text, hunks) {
|
|
23032
|
+
const before = erase(baseText, path21);
|
|
23033
|
+
const after = erase(text, path21);
|
|
23029
23034
|
if (!before || !after) return void 0;
|
|
23030
23035
|
const regions = hunks.map((hunk) => ({
|
|
23031
23036
|
base: hunk.baseCount ? { from: hunk.baseStart, to: hunk.baseStart + hunk.baseCount - 1 } : { from: hunk.baseStart + 1, to: hunk.baseStart },
|
|
@@ -23239,7 +23244,7 @@ async function readMapChanges(project, base, signal, options = { names: true })
|
|
|
23239
23244
|
...file2,
|
|
23240
23245
|
baseText: (await git.run(["show", `${commit}:${file2.basePath}`], gitOptions(project, signal))).stdout.toString("utf8")
|
|
23241
23246
|
};
|
|
23242
|
-
const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((
|
|
23247
|
+
const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((path21) => path21 && !inExcludedDirectory(path21));
|
|
23243
23248
|
for (const file2 of untracked)
|
|
23244
23249
|
files.push({
|
|
23245
23250
|
path: file2,
|
|
@@ -23368,7 +23373,7 @@ function mapPathNow(files) {
|
|
|
23368
23373
|
(file2) => file2.basePath !== void 0 && file2.status !== "DELETED" ? [[file2.basePath, file2.path]] : []
|
|
23369
23374
|
)
|
|
23370
23375
|
);
|
|
23371
|
-
return (
|
|
23376
|
+
return (path21) => moved.get(path21) ?? path21;
|
|
23372
23377
|
}
|
|
23373
23378
|
var overlaps = (lines, start, end) => lines.some(([from, to]) => from <= end && start <= to);
|
|
23374
23379
|
var workingLine = (file2, line) => {
|
|
@@ -23392,7 +23397,7 @@ var NON_CODE = [
|
|
|
23392
23397
|
[/(?:^|\/)\.env[^/]*$|\.(?:ya?ml|toml|ini|properties|conf|cfg)$/iu, "configuration"],
|
|
23393
23398
|
[/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte|wxml)$/iu, "template"]
|
|
23394
23399
|
];
|
|
23395
|
-
var nonCodeKind = (
|
|
23400
|
+
var nonCodeKind = (path21) => NON_CODE.find(([pattern]) => pattern.test(path21))?.[1];
|
|
23396
23401
|
var UNANALYZED = [
|
|
23397
23402
|
[/\.(?:sh|bash|zsh|fish|ps1|bat|cmd)$/iu, "shell script"],
|
|
23398
23403
|
[/\.(?:css|scss|sass|less|styl|wxss|acss)$/iu, "style sheet"],
|
|
@@ -23400,7 +23405,7 @@ var UNANALYZED = [
|
|
|
23400
23405
|
[/\/$/u, "nested repository"]
|
|
23401
23406
|
];
|
|
23402
23407
|
var DOCUMENTATION = /\.(?:md|mdx|markdown|rst|adoc)$|(?:^|\/)(?:LICENSE|NOTICE)[^/]*$/iu;
|
|
23403
|
-
var unmappedKind = (
|
|
23408
|
+
var unmappedKind = (path21, binary) => nonCodeKind(path21) ?? (binary ? "binary file" : DOCUMENTATION.test(path21) ? void 0 : UNANALYZED.find(([pattern]) => pattern.test(path21))?.[1] ?? "unanalyzed file");
|
|
23404
23409
|
|
|
23405
23410
|
// src/project-map-changes.ts
|
|
23406
23411
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
@@ -23467,7 +23472,7 @@ var LITERAL = /(["'`])((?:\\.|(?!\1)[^\\])*)\1/gu;
|
|
|
23467
23472
|
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;
|
|
23468
23473
|
var LIMIT2 = Object.freeze({ routes: 40, clients: 5 });
|
|
23469
23474
|
var ROUTE = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
|
|
23470
|
-
var segments = (
|
|
23475
|
+
var segments = (path21) => path21.split("/").filter(Boolean).map((text) => ({ text, param: PARAM.test(text) || /[{}$<>%]/u.test(text) }));
|
|
23471
23476
|
function mapRouteLabel(label) {
|
|
23472
23477
|
const match = /^([A-Z]+(?:\|[A-Z]+)*) +(\S.*)$/u.exec(label);
|
|
23473
23478
|
return match ? { methods: (match[1] ?? "").split("|"), path: match[2] ?? "" } : { path: label };
|
|
@@ -23500,10 +23505,10 @@ function requestedPath(literal3, joined) {
|
|
|
23500
23505
|
const match = /^(?:https?:\/\/[^/\s]+|(?:\$\{[^}]*\})+|@\{|redirect:|forward:)?(\/[^\s?#()"'`,;|]*)/u.exec(
|
|
23501
23506
|
literal3
|
|
23502
23507
|
) ?? void 0;
|
|
23503
|
-
const
|
|
23504
|
-
if (!
|
|
23505
|
-
const parts = segments(
|
|
23506
|
-
if (joined &&
|
|
23508
|
+
const path21 = match?.[1];
|
|
23509
|
+
if (!path21 || path21.startsWith("//") || path21.length < 3) return void 0;
|
|
23510
|
+
const parts = segments(path21);
|
|
23511
|
+
if (joined && path21.endsWith("/")) parts.push({ text: "*", param: true });
|
|
23507
23512
|
return parts;
|
|
23508
23513
|
}
|
|
23509
23514
|
var same = (route, requested) => route.param || !requested.param && route.text === requested.text;
|
|
@@ -23665,11 +23670,11 @@ var USED_BY = {
|
|
|
23665
23670
|
OVERRIDES: "overridden"
|
|
23666
23671
|
};
|
|
23667
23672
|
var runsTarget = (relation) => CALLER_KINDS.has(relation.kind) && !relation.event;
|
|
23668
|
-
var changeUnits = (graph,
|
|
23669
|
-
function changedUnits(graph,
|
|
23673
|
+
var changeUnits = (graph, path21) => mapMiniprogramTemplate(path21) ? graph.objectsAt(path21).filter((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : graph.declarationsAt(path21);
|
|
23674
|
+
function changedUnits(graph, path21, lines) {
|
|
23670
23675
|
const refs = /* @__PURE__ */ new Set();
|
|
23671
23676
|
let topLevel = false;
|
|
23672
|
-
const inFile = changeUnits(graph,
|
|
23677
|
+
const inFile = changeUnits(graph, path21);
|
|
23673
23678
|
for (const [from, to] of lines) {
|
|
23674
23679
|
const containing = inFile.filter(
|
|
23675
23680
|
(object2) => object2.anchor.startLine <= to && from <= object2.anchor.endLine
|
|
@@ -24192,12 +24197,12 @@ var Tracer = class {
|
|
|
24192
24197
|
this.mentions.set(route, (this.mentions.get(route) ?? /* @__PURE__ */ new Set()).add(file2));
|
|
24193
24198
|
}
|
|
24194
24199
|
/** A related test file; the closest relation (lowest rank) explains it. */
|
|
24195
|
-
test(
|
|
24196
|
-
if (!mapRunnableTest(
|
|
24197
|
-
const known = this.tests.get(
|
|
24200
|
+
test(path21, name, why, rank2) {
|
|
24201
|
+
if (!mapRunnableTest(path21)) return;
|
|
24202
|
+
const known = this.tests.get(path21) ?? { names: /* @__PURE__ */ new Set(), why, rank: rank2 };
|
|
24198
24203
|
if (rank2 < known.rank) Object.assign(known, { why, rank: rank2 });
|
|
24199
24204
|
if (name && !name.startsWith("<")) known.names.add(name);
|
|
24200
|
-
this.tests.set(
|
|
24205
|
+
this.tests.set(path21, known);
|
|
24201
24206
|
}
|
|
24202
24207
|
};
|
|
24203
24208
|
var entriesOf = /* @__PURE__ */ new WeakMap();
|
|
@@ -24246,19 +24251,19 @@ function findTestEntries(graph, ref) {
|
|
|
24246
24251
|
}
|
|
24247
24252
|
|
|
24248
24253
|
// src/project-map-change-edges.ts
|
|
24249
|
-
var same2 = (
|
|
24254
|
+
var same2 = (path21) => path21;
|
|
24250
24255
|
var compare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
24251
|
-
function linksOf(side,
|
|
24256
|
+
function linksOf(side, path21) {
|
|
24252
24257
|
const imports = /* @__PURE__ */ new Map();
|
|
24253
24258
|
const calls = /* @__PURE__ */ new Map();
|
|
24254
|
-
if (
|
|
24259
|
+
if (path21 === void 0) return { imports, calls };
|
|
24255
24260
|
const { graph } = side;
|
|
24256
|
-
for (const relation of graph.relationsFrom(graph.objectsAt(
|
|
24261
|
+
for (const relation of graph.relationsFrom(graph.objectsAt(path21).map((object2) => object2.id))) {
|
|
24257
24262
|
const line = relation.anchor.startLine;
|
|
24258
|
-
if (relation.to === void 0 || !side.counts(
|
|
24263
|
+
if (relation.to === void 0 || !side.counts(path21, line)) continue;
|
|
24259
24264
|
if (relation.kind === "IMPORTS") {
|
|
24260
24265
|
const target = graph.object(relation.to).anchor.path;
|
|
24261
|
-
if (target ===
|
|
24266
|
+
if (target === path21) continue;
|
|
24262
24267
|
const to = side.pathNow(target);
|
|
24263
24268
|
const found = imports.get(to) ?? { to, lines: [] };
|
|
24264
24269
|
found.lines.push(line);
|
|
@@ -24266,7 +24271,7 @@ function linksOf(side, path20) {
|
|
|
24266
24271
|
} else if (CALLER_KINDS.has(relation.kind)) {
|
|
24267
24272
|
const ref = graph.owner(relation.to);
|
|
24268
24273
|
const owner = graph.object(ref);
|
|
24269
|
-
if (owner.anchor.path ===
|
|
24274
|
+
if (owner.anchor.path === path21 || mapIsModule(owner)) continue;
|
|
24270
24275
|
const to = side.pathNow(owner.anchor.path);
|
|
24271
24276
|
const key = `${to}\0${graph.declarationKey(owner)}`;
|
|
24272
24277
|
const found = calls.get(key) ?? { to, lines: [], ref };
|
|
@@ -24297,17 +24302,17 @@ function mapChangeLinks(store, working, base, files) {
|
|
|
24297
24302
|
counts: always,
|
|
24298
24303
|
pathOf,
|
|
24299
24304
|
declaration: (file2, ref) => {
|
|
24300
|
-
const
|
|
24301
|
-
if (
|
|
24302
|
-
let keys = declared.get(
|
|
24305
|
+
const path21 = pathOf(file2);
|
|
24306
|
+
if (path21 === void 0) return void 0;
|
|
24307
|
+
let keys = declared.get(path21);
|
|
24303
24308
|
if (!keys) {
|
|
24304
24309
|
keys = new Map(
|
|
24305
|
-
changeUnits(baseGraph,
|
|
24310
|
+
changeUnits(baseGraph, path21).map((object2) => [
|
|
24306
24311
|
baseGraph.declarationKey(object2),
|
|
24307
24312
|
object2.id
|
|
24308
24313
|
])
|
|
24309
24314
|
);
|
|
24310
|
-
declared.set(
|
|
24315
|
+
declared.set(path21, keys);
|
|
24311
24316
|
}
|
|
24312
24317
|
return keys.get(graph.declarationKey(graph.object(ref)));
|
|
24313
24318
|
}
|
|
@@ -24317,8 +24322,8 @@ function mapChangeLinks(store, working, base, files) {
|
|
|
24317
24322
|
before = {
|
|
24318
24323
|
graph,
|
|
24319
24324
|
pathNow: same2,
|
|
24320
|
-
counts: (
|
|
24321
|
-
const file2 = changedAt.get(
|
|
24325
|
+
counts: (path21, line) => {
|
|
24326
|
+
const file2 = changedAt.get(path21);
|
|
24322
24327
|
return !file2 || !overlaps(file2.lines, line, line);
|
|
24323
24328
|
},
|
|
24324
24329
|
pathOf: (file2) => file2.status === "ADDED" ? void 0 : file2.path,
|
|
@@ -24352,9 +24357,9 @@ function callersOf(side, ref) {
|
|
|
24352
24357
|
const home = side.graph.object(ref).anchor.path;
|
|
24353
24358
|
const files = /* @__PURE__ */ new Set();
|
|
24354
24359
|
for (const relation of side.graph.relationsTo([ref])) {
|
|
24355
|
-
const
|
|
24356
|
-
if (!CALLER_KINDS.has(relation.kind) ||
|
|
24357
|
-
if (side.counts(
|
|
24360
|
+
const path21 = relation.anchor.path;
|
|
24361
|
+
if (!CALLER_KINDS.has(relation.kind) || path21 === home || mapTestPath(path21)) continue;
|
|
24362
|
+
if (side.counts(path21, relation.anchor.startLine)) files.add(side.pathNow(path21));
|
|
24358
24363
|
}
|
|
24359
24364
|
return [...files].sort();
|
|
24360
24365
|
}
|
|
@@ -24580,10 +24585,10 @@ function importerTests(graph, objects2, tracer, importers) {
|
|
|
24580
24585
|
}
|
|
24581
24586
|
const next = [];
|
|
24582
24587
|
for (const imported of modules)
|
|
24583
|
-
for (const { path:
|
|
24584
|
-
if (mapTestPath(
|
|
24588
|
+
for (const { path: path21, module } of importers.get(imported) ?? [])
|
|
24589
|
+
if (mapTestPath(path21))
|
|
24585
24590
|
tracer.test(
|
|
24586
|
-
|
|
24591
|
+
path21,
|
|
24587
24592
|
void 0,
|
|
24588
24593
|
hop ? "imports a changed file indirectly" : "imports a changed file",
|
|
24589
24594
|
hop ? 4 : 2
|
|
@@ -24608,17 +24613,17 @@ function supportTests(store, version2, tracer) {
|
|
|
24608
24613
|
function mapPathIndex(paths) {
|
|
24609
24614
|
const testsIn = /* @__PURE__ */ new Map();
|
|
24610
24615
|
const under = /* @__PURE__ */ new Map();
|
|
24611
|
-
const add = (map2, key,
|
|
24616
|
+
const add = (map2, key, path21) => {
|
|
24612
24617
|
const found = map2.get(key);
|
|
24613
|
-
if (found) found.push(
|
|
24614
|
-
else map2.set(key, [
|
|
24618
|
+
if (found) found.push(path21);
|
|
24619
|
+
else map2.set(key, [path21]);
|
|
24615
24620
|
};
|
|
24616
|
-
for (const
|
|
24617
|
-
const slash =
|
|
24618
|
-
const directory = slash < 0 ? "" :
|
|
24619
|
-
if (mapTestPath(
|
|
24621
|
+
for (const path21 of paths) {
|
|
24622
|
+
const slash = path21.lastIndexOf("/");
|
|
24623
|
+
const directory = slash < 0 ? "" : path21.slice(0, slash + 1);
|
|
24624
|
+
if (mapTestPath(path21)) add(testsIn, directory, path21);
|
|
24620
24625
|
const name = directory.slice(directory.lastIndexOf("/", directory.length - 2) + 1, -1);
|
|
24621
|
-
if (name) add(under, name,
|
|
24626
|
+
if (name) add(under, name, path21);
|
|
24622
24627
|
}
|
|
24623
24628
|
return { testsIn, under };
|
|
24624
24629
|
}
|
|
@@ -24752,9 +24757,9 @@ async function routeTests(requests, entries, tracer) {
|
|
|
24752
24757
|
}
|
|
24753
24758
|
return requested;
|
|
24754
24759
|
}
|
|
24755
|
-
function wholePath(text,
|
|
24756
|
-
for (let at = text.indexOf(
|
|
24757
|
-
if (!/[\w./-]/u.test(text[at +
|
|
24760
|
+
function wholePath(text, path21) {
|
|
24761
|
+
for (let at = text.indexOf(path21); at >= 0; at = text.indexOf(path21, at + 1))
|
|
24762
|
+
if (!/[\w./-]/u.test(text[at + path21.length] ?? "")) return true;
|
|
24758
24763
|
return false;
|
|
24759
24764
|
}
|
|
24760
24765
|
async function unworkedRequests(requests, tracer, reaching) {
|
|
@@ -24775,14 +24780,14 @@ async function unworkedRequests(requests, tracer, reaching) {
|
|
|
24775
24780
|
}
|
|
24776
24781
|
}
|
|
24777
24782
|
}
|
|
24778
|
-
function sameDirectoryTests(paths,
|
|
24779
|
-
const slash =
|
|
24780
|
-
for (const candidate of paths.testsIn.get(slash < 0 ? "" :
|
|
24783
|
+
function sameDirectoryTests(paths, path21, tracer) {
|
|
24784
|
+
const slash = path21.lastIndexOf("/");
|
|
24785
|
+
for (const candidate of paths.testsIn.get(slash < 0 ? "" : path21.slice(0, slash + 1)) ?? [])
|
|
24781
24786
|
tracer.test(candidate, void 0, "in the same directory", 3);
|
|
24782
24787
|
}
|
|
24783
|
-
function routesIn(graph,
|
|
24788
|
+
function routesIn(graph, path21) {
|
|
24784
24789
|
const routes = /* @__PURE__ */ new Set();
|
|
24785
|
-
for (const relation of graph.relationsFrom(graph.objectsAt(
|
|
24790
|
+
for (const relation of graph.relationsFrom(graph.objectsAt(path21).map((object2) => object2.id))) {
|
|
24786
24791
|
const route = mapRegisteredRoute(relation);
|
|
24787
24792
|
if (route) routes.add(route);
|
|
24788
24793
|
}
|
|
@@ -24820,9 +24825,9 @@ async function mapRemovedImpact(input) {
|
|
|
24820
24825
|
new MapShapeUses(before, input.shapes, input.until)
|
|
24821
24826
|
);
|
|
24822
24827
|
const changedIn2 = changedInBase(changes.files);
|
|
24823
|
-
const pathNow = (
|
|
24824
|
-
const file2 = changedIn2.get(
|
|
24825
|
-
return file2?.status === "DELETED" ? void 0 : file2?.path ??
|
|
24828
|
+
const pathNow = (path21) => {
|
|
24829
|
+
const file2 = changedIn2.get(path21);
|
|
24830
|
+
return file2?.status === "DELETED" ? void 0 : file2?.path ?? path21;
|
|
24826
24831
|
};
|
|
24827
24832
|
const nowAt = (anchor) => {
|
|
24828
24833
|
const file2 = changedIn2.get(anchor.path);
|
|
@@ -24837,11 +24842,11 @@ async function mapRemovedImpact(input) {
|
|
|
24837
24842
|
const samePlace = (anchor, place) => anchor.path === place.path && anchor.startLine === place.startLine && anchor.endLine === place.endLine;
|
|
24838
24843
|
const replaces = (now, removed2) => now.kind === removed2.kind && now.name === removed2.name;
|
|
24839
24844
|
const relationsNow = /* @__PURE__ */ new Map();
|
|
24840
|
-
const relationsIn = (
|
|
24841
|
-
let found = relationsNow.get(
|
|
24845
|
+
const relationsIn = (path21) => {
|
|
24846
|
+
let found = relationsNow.get(path21);
|
|
24842
24847
|
if (!found) {
|
|
24843
|
-
found = graph.relationsFrom(graph.objectsAt(
|
|
24844
|
-
relationsNow.set(
|
|
24848
|
+
found = graph.relationsFrom(graph.objectsAt(path21).map((object2) => object2.id));
|
|
24849
|
+
relationsNow.set(path21, found);
|
|
24845
24850
|
}
|
|
24846
24851
|
return found;
|
|
24847
24852
|
};
|
|
@@ -24950,13 +24955,13 @@ async function mapRemovedImpact(input) {
|
|
|
24950
24955
|
});
|
|
24951
24956
|
const lost = /* @__PURE__ */ new Map();
|
|
24952
24957
|
const changedAt = changedInWorkingTree(changes.files);
|
|
24953
|
-
for (const
|
|
24954
|
-
const template = graph.objectsAt(
|
|
24958
|
+
for (const path21 of input.mappedPaths().filter(mapMiniprogramTemplate)) {
|
|
24959
|
+
const template = graph.objectsAt(path21).find((object2) => mapIsModule(object2));
|
|
24955
24960
|
if (!template) continue;
|
|
24956
24961
|
const broken = graph.relationsFrom(graph.scope(template.id).refs).filter((relation) => relation.to === void 0 && NAMING_KINDS.has(relation.kind));
|
|
24957
24962
|
if (!broken.length) continue;
|
|
24958
|
-
const file2 = changedAt.get(
|
|
24959
|
-
const basePath = file2 ? file2.basePath :
|
|
24963
|
+
const file2 = changedAt.get(path21);
|
|
24964
|
+
const basePath = file2 ? file2.basePath : path21;
|
|
24960
24965
|
const was = basePath === void 0 ? void 0 : before.objectsAt(basePath).find(mapIsModule);
|
|
24961
24966
|
const links = was ? before.relationsFrom(before.scope(was.id).refs) : [];
|
|
24962
24967
|
for (const relation of broken) {
|
|
@@ -24965,7 +24970,7 @@ async function mapRemovedImpact(input) {
|
|
|
24965
24970
|
);
|
|
24966
24971
|
if (earlier.some((link) => link.to === void 0)) continue;
|
|
24967
24972
|
const event = miniprogramEventOf(relation.target);
|
|
24968
|
-
const at = `${
|
|
24973
|
+
const at = `${path21}:${relation.anchor.startLine}`;
|
|
24969
24974
|
if (file2 && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine)) {
|
|
24970
24975
|
unclear.push({
|
|
24971
24976
|
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`
|
|
@@ -24977,7 +24982,7 @@ async function mapRemovedImpact(input) {
|
|
|
24977
24982
|
const object2 = before.object(reached);
|
|
24978
24983
|
const name = mapIsModule(object2) ? `${object2.anchor.path} (template)${event ? `: ${event.event} event` : ""}` : `${object2.anchor.path}: ${before.qualifiedName(reached)} ${mapDeclarationLabel(object2)}`;
|
|
24979
24984
|
const users = lost.get(name) ?? /* @__PURE__ */ new Set();
|
|
24980
|
-
users.add(`${
|
|
24985
|
+
users.add(`${path21} (template)`);
|
|
24981
24986
|
lost.set(name, users);
|
|
24982
24987
|
}
|
|
24983
24988
|
}
|
|
@@ -25020,15 +25025,15 @@ async function mapRemovedImpact(input) {
|
|
|
25020
25025
|
...removed2 ? { removed: true } : {}
|
|
25021
25026
|
});
|
|
25022
25027
|
}
|
|
25023
|
-
for (const [
|
|
25024
|
-
const now = pathNow(
|
|
25028
|
+
for (const [path21, test] of beforeTracer.tests) {
|
|
25029
|
+
const now = pathNow(path21);
|
|
25025
25030
|
if (now === void 0) continue;
|
|
25026
25031
|
tracer.test(now, void 0, test.why, test.rank);
|
|
25027
25032
|
for (const name of test.names) tracer.test(now, name, test.why, test.rank);
|
|
25028
25033
|
}
|
|
25029
25034
|
for (const [area, known] of beforeTracer.areas)
|
|
25030
|
-
for (const [
|
|
25031
|
-
const now = pathNow(
|
|
25035
|
+
for (const [path21, names] of known.tests) {
|
|
25036
|
+
const now = pathNow(path21);
|
|
25032
25037
|
const place = pathNow(area);
|
|
25033
25038
|
if (now !== void 0 && place !== void 0)
|
|
25034
25039
|
tracer.shareArea(place, known.through, now, names);
|
|
@@ -25051,24 +25056,24 @@ async function mapRemovedImpact(input) {
|
|
|
25051
25056
|
for (const ref of called) {
|
|
25052
25057
|
const object2 = before.object(ref);
|
|
25053
25058
|
if (mapIsModule(object2) || mapTestPath(object2.anchor.path) || gone2.has(ref)) continue;
|
|
25054
|
-
const
|
|
25055
|
-
if (
|
|
25059
|
+
const path21 = pathNow(object2.anchor.path);
|
|
25060
|
+
if (path21 === void 0) continue;
|
|
25056
25061
|
const key = before.declarationKey(object2);
|
|
25057
|
-
const now = graph.declarationsAt(
|
|
25062
|
+
const now = graph.declarationsAt(path21).find((candidate) => graph.declarationKey(candidate) === key);
|
|
25058
25063
|
if (!now) continue;
|
|
25059
25064
|
const calls = tracer.callers(now.id).filter((caller) => !caller.uses);
|
|
25060
25065
|
if (outsideTests(calls, graph).length || tracer.usesWithoutCalls(now.id).length) continue;
|
|
25061
25066
|
if (!outsideTests(beforeTracer.callers(ref), before).length) continue;
|
|
25062
|
-
candidates.push({ path:
|
|
25067
|
+
candidates.push({ path: path21, name: before.qualifiedName(ref), now, tested: calls.length > 0 });
|
|
25063
25068
|
}
|
|
25064
25069
|
await tracer.shapes.read(candidates.map(({ now }) => now.id));
|
|
25065
25070
|
const uncalled = [];
|
|
25066
25071
|
const unknown2 = [];
|
|
25067
|
-
for (const { path:
|
|
25072
|
+
for (const { path: path21, name, now, tested } of candidates) {
|
|
25068
25073
|
if (tracer.shapes.unread.has(now.id)) unknown2.push(name);
|
|
25069
25074
|
else if (!tracer.shapes.uses.get(now.id)?.some(({ owner, write }) => !write && !mapTestPath(graph.object(owner).anchor.path))) {
|
|
25070
25075
|
uncalled.push(
|
|
25071
|
-
`${
|
|
25076
|
+
`${path21}: ${name} ${mapDeclarationLabel(now)}${tested ? " (only tests call it now)" : ""}`
|
|
25072
25077
|
);
|
|
25073
25078
|
}
|
|
25074
25079
|
}
|
|
@@ -25435,9 +25440,9 @@ function pathBetween(edges, from, to) {
|
|
|
25435
25440
|
if (via.has(target)) continue;
|
|
25436
25441
|
via.set(target, module);
|
|
25437
25442
|
if (target === to) {
|
|
25438
|
-
const
|
|
25439
|
-
for (let step = module; step !== from; step = via.get(step) ?? from)
|
|
25440
|
-
return [from, ...
|
|
25443
|
+
const path21 = [to];
|
|
25444
|
+
for (let step = module; step !== from; step = via.get(step) ?? from) path21.unshift(step);
|
|
25445
|
+
return [from, ...path21];
|
|
25441
25446
|
}
|
|
25442
25447
|
next.push(target);
|
|
25443
25448
|
}
|
|
@@ -25490,11 +25495,11 @@ function newModuleDependencies(store, cache, working, files, links) {
|
|
|
25490
25495
|
);
|
|
25491
25496
|
}
|
|
25492
25497
|
var MANIFEST = /(?:^|\/)(?:package\.json|go\.mod|pom\.xml|build\.gradle(?:\.kts)?|pyproject\.toml|setup\.py|setup\.cfg)$/u;
|
|
25493
|
-
var directoryOf3 = (
|
|
25498
|
+
var directoryOf3 = (path21) => path21.slice(0, Math.max(path21.lastIndexOf("/"), 0));
|
|
25494
25499
|
var directoryLabel = (directory) => directory ? `${directory}/` : "./";
|
|
25495
25500
|
function mapReuseImports(store, cache, working) {
|
|
25496
25501
|
const roots = store.listEntries(working).filter((entry) => MANIFEST.test(entry.path)).map((entry) => directoryOf3(entry.path)).sort((left, right) => right.length - left.length);
|
|
25497
|
-
const packageOf = (
|
|
25502
|
+
const packageOf = (path21) => roots.find((root) => !root || path21.startsWith(`${root}/`)) ?? "";
|
|
25498
25503
|
const directories = /* @__PURE__ */ new Map();
|
|
25499
25504
|
const packages = /* @__PURE__ */ new Map();
|
|
25500
25505
|
const files = /* @__PURE__ */ new Set();
|
|
@@ -25527,21 +25532,21 @@ function mapReuseImports(store, cache, working) {
|
|
|
25527
25532
|
};
|
|
25528
25533
|
const graph = new MapViewGraph(store, working);
|
|
25529
25534
|
const usedFrom = /* @__PURE__ */ new Map();
|
|
25530
|
-
const used = (
|
|
25531
|
-
let found = usedFrom.get(
|
|
25535
|
+
const used = (path21) => {
|
|
25536
|
+
let found = usedFrom.get(path21);
|
|
25532
25537
|
if (found === void 0) {
|
|
25533
|
-
found = graph.relationsTo(graph.objectsAt(
|
|
25534
|
-
usedFrom.set(
|
|
25538
|
+
found = graph.relationsTo(graph.objectsAt(path21).map((object2) => object2.id)).some((relation) => graph.object(relation.from).anchor.path !== path21);
|
|
25539
|
+
usedFrom.set(path21, found);
|
|
25535
25540
|
}
|
|
25536
25541
|
return found;
|
|
25537
25542
|
};
|
|
25538
|
-
return (
|
|
25539
|
-
const added = [directoryOf3(
|
|
25543
|
+
return (path21, existing) => {
|
|
25544
|
+
const added = [directoryOf3(path21), packageOf(path21)];
|
|
25540
25545
|
const old = [directoryOf3(existing), packageOf(existing)];
|
|
25541
25546
|
const ahead = use("NEW", added, old);
|
|
25542
|
-
if (files.has(`${
|
|
25543
|
-
if (files.has(`${existing}\0${
|
|
25544
|
-
return { ...use("EXISTING", old, added), from: existing, to:
|
|
25547
|
+
if (files.has(`${path21}\0${existing}`)) return ahead;
|
|
25548
|
+
if (files.has(`${existing}\0${path21}`))
|
|
25549
|
+
return { ...use("EXISTING", old, added), from: existing, to: path21 };
|
|
25545
25550
|
const usable = used(existing);
|
|
25546
25551
|
if (usable && ahead.imported) return ahead;
|
|
25547
25552
|
if (directories.get(old[0])?.has(added[0])) return use("EXISTING", old, added);
|
|
@@ -25563,9 +25568,9 @@ var KEYWORDS = new Set(
|
|
|
25563
25568
|
);
|
|
25564
25569
|
var ROWS = `SELECT entity_ref AS id, path, name, kind, object_json AS object
|
|
25565
25570
|
FROM project_map_objects WHERE version_ref = ? AND kind <> 'PROPERTY'`;
|
|
25566
|
-
function rows(store, version2,
|
|
25567
|
-
const statement = store.database.prepare(
|
|
25568
|
-
return (
|
|
25571
|
+
function rows(store, version2, path21) {
|
|
25572
|
+
const statement = store.database.prepare(path21 === void 0 ? ROWS : `${ROWS} AND path = ?`);
|
|
25573
|
+
return (path21 === void 0 ? statement.all(version2) : statement.all(version2, path21)).map((row) => {
|
|
25569
25574
|
const { anchor } = JSON.parse(String(row.object));
|
|
25570
25575
|
return {
|
|
25571
25576
|
id: String(row.id),
|
|
@@ -25607,10 +25612,10 @@ function lineWords(line) {
|
|
|
25607
25612
|
var within2 = (lines, declaration) => lines.some(([from, to]) => from <= declaration.startLine && declaration.endLine <= to);
|
|
25608
25613
|
var copyText = (code) => code.replace(/^export\s+(?:default\s+)?/u, "").replace(/\s+/gu, " ").trim();
|
|
25609
25614
|
async function similarCode(store, working, base, files, read) {
|
|
25610
|
-
const code = (
|
|
25615
|
+
const code = (path21) => mapCodePath(path21) && !mapTestPath(path21) && !MAP_MIGRATION_PATH.test(path21);
|
|
25611
25616
|
const changed = files.filter((file2) => file2.status !== "DELETED" && code(file2.path));
|
|
25612
25617
|
if (!changed.length) return [];
|
|
25613
|
-
const names = (version2,
|
|
25618
|
+
const names = (version2, path21) => new Set(declarations(rows(store, version2, path21)).map((item) => item.qualifiedName));
|
|
25614
25619
|
const movedOut = /* @__PURE__ */ new Set();
|
|
25615
25620
|
if (base !== void 0)
|
|
25616
25621
|
for (const file2 of files) {
|
|
@@ -25642,11 +25647,11 @@ async function similarCode(store, working, base, files, read) {
|
|
|
25642
25647
|
const all = [];
|
|
25643
25648
|
const shortCopies = /* @__PURE__ */ new Map();
|
|
25644
25649
|
const texts = await Promise.all(
|
|
25645
|
-
[...byPath].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(async ([
|
|
25650
|
+
[...byPath].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(async ([path21, inFile]) => {
|
|
25646
25651
|
const found2 = declarations(inFile).filter(
|
|
25647
25652
|
(item) => KINDS2.has(item.kind) && (long(item) ? longAdded : shortNames.has(item.qualifiedName))
|
|
25648
25653
|
);
|
|
25649
|
-
return { found: found2, text: found2.length ? await read(
|
|
25654
|
+
return { found: found2, text: found2.length ? await read(path21) : void 0 };
|
|
25650
25655
|
})
|
|
25651
25656
|
);
|
|
25652
25657
|
for (const { found: found2, text } of texts) {
|
|
@@ -25781,10 +25786,10 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
|
|
|
25781
25786
|
const mappedPaths = () => mapped ??= store.database.prepare("SELECT DISTINCT path FROM project_map_objects WHERE version_ref = ?").all(working).map((row) => String(row.path));
|
|
25782
25787
|
let paths;
|
|
25783
25788
|
const pathIndex = () => paths ??= mapPathIndex(mappedPaths());
|
|
25784
|
-
const topLevelChanged = (
|
|
25785
|
-
const text = `top-level code of ${
|
|
25789
|
+
const topLevelChanged = (path21) => {
|
|
25790
|
+
const text = `top-level code of ${path21} changed (imports, constants or registrations)`;
|
|
25786
25791
|
if (!unclear.some((note) => note.text === text))
|
|
25787
|
-
unclear.push({ text, group: { kind: "TOP_LEVEL", subject:
|
|
25792
|
+
unclear.push({ text, group: { kind: "TOP_LEVEL", subject: path21 } });
|
|
25788
25793
|
};
|
|
25789
25794
|
for (const file2 of changes.files) {
|
|
25790
25795
|
const objects2 = file2.status === "DELETED" || file2.binary ? [] : graph.objectsAt(file2.path);
|
|
@@ -25914,15 +25919,15 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
|
|
|
25914
25919
|
project,
|
|
25915
25920
|
mappedPaths
|
|
25916
25921
|
}) : void 0;
|
|
25917
|
-
for (const
|
|
25922
|
+
for (const path21 of taken?.topLevel ?? []) topLevelChanged(path21);
|
|
25918
25923
|
unclear.push(...taken?.unclear ?? []);
|
|
25919
25924
|
return {
|
|
25920
25925
|
changed,
|
|
25921
25926
|
removed: taken?.removed ?? [],
|
|
25922
25927
|
rewrittenTests: taken?.rewrittenTests ?? [],
|
|
25923
25928
|
entries: [...tracer.entries.values()].sort(entryOrder),
|
|
25924
|
-
tests: [...tracer.tests].map(([
|
|
25925
|
-
path:
|
|
25929
|
+
tests: [...tracer.tests].map(([path21, test]) => ({
|
|
25930
|
+
path: path21,
|
|
25926
25931
|
names: [...test.names].sort(),
|
|
25927
25932
|
why: test.why,
|
|
25928
25933
|
rank: test.rank
|
|
@@ -25932,7 +25937,7 @@ async function mapChangeImpact(store, views, working, base, changes, links, shap
|
|
|
25932
25937
|
areas: [...tracer.areas].map(([area, known]) => ({
|
|
25933
25938
|
area,
|
|
25934
25939
|
through: [...known.through].sort(),
|
|
25935
|
-
tests: [...known.tests].map(([
|
|
25940
|
+
tests: [...known.tests].map(([path21, names]) => ({ path: path21, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
|
|
25936
25941
|
})).sort((left, right) => right.tests.length - left.tests.length),
|
|
25937
25942
|
unclear: [
|
|
25938
25943
|
...new Map([...unclear, ...tracer.unclear].map((note) => [note.text, note])).values()
|
|
@@ -26021,9 +26026,9 @@ function mapChangesData(changes, impact, edges) {
|
|
|
26021
26026
|
return {
|
|
26022
26027
|
base: changes.base,
|
|
26023
26028
|
commit: changes.commit,
|
|
26024
|
-
files: changes.files.map(({ path:
|
|
26025
|
-
path:
|
|
26026
|
-
...basePath !== void 0 && basePath !==
|
|
26029
|
+
files: changes.files.map(({ path: path21, basePath, status }) => ({
|
|
26030
|
+
path: path21,
|
|
26031
|
+
...basePath !== void 0 && basePath !== path21 ? { basePath } : {},
|
|
26027
26032
|
status
|
|
26028
26033
|
})),
|
|
26029
26034
|
tests: impact.tests,
|
|
@@ -26184,7 +26189,7 @@ async function compileBreaks(input, views, changes, base, until, signal, phase,
|
|
|
26184
26189
|
signal
|
|
26185
26190
|
) : { contexts: [], unchecked: [] };
|
|
26186
26191
|
const inBase = changedInBase(changes.files);
|
|
26187
|
-
const named = (
|
|
26192
|
+
const named = (path21, item) => `${path21}\0${item.code}\0${item.span}\0${item.text}`;
|
|
26188
26193
|
const compiled = new Map(before.contexts.map((context) => [context.configPath, context.errors]));
|
|
26189
26194
|
const unchecked = new Set(after.unchecked);
|
|
26190
26195
|
const errors = /* @__PURE__ */ new Set();
|
|
@@ -26805,6 +26810,104 @@ async function pruneNpxInstalls(npx, installed, now) {
|
|
|
26805
26810
|
}
|
|
26806
26811
|
}
|
|
26807
26812
|
|
|
26813
|
+
// src/agent/command.ts
|
|
26814
|
+
var MARK = "// LayerMap's command, written by `layermap setup command`.";
|
|
26815
|
+
var commandScript = (cache) => `#!/usr/bin/env node
|
|
26816
|
+
${MARK}
|
|
26817
|
+
// It runs the newest LayerMap version installed in LayerMap's cache, where each agent's LayerMap
|
|
26818
|
+
// plugin installs the version it starts. \`layermap remove command\` deletes this file.
|
|
26819
|
+
if (typeof process.getBuiltinModule !== "function") {
|
|
26820
|
+
process.stderr.write("layermap: LayerMap needs Node.js 22.22 or later; this is " + process.version + "\\n");
|
|
26821
|
+
process.exit(1);
|
|
26822
|
+
}
|
|
26823
|
+
const fs = process.getBuiltinModule("node:fs");
|
|
26824
|
+
const path = process.getBuiltinModule("node:path");
|
|
26825
|
+
const { pathToFileURL } = process.getBuiltinModule("node:url");
|
|
26826
|
+
const cache = process.env.LAYERMAP_CACHE ? path.resolve(process.env.LAYERMAP_CACHE) : ${JSON.stringify(cache)};
|
|
26827
|
+
const versions = path.join(cache, "versions");
|
|
26828
|
+
const installed = (version) => path.join(versions, version, "node_modules", "layermap");
|
|
26829
|
+
// A version being installed is a directory named .<version>-\u2026, and has no manifest in place yet.
|
|
26830
|
+
const numbers = (version) => version.split(".").map(Number);
|
|
26831
|
+
const newest = (fs.existsSync(versions) ? fs.readdirSync(versions) : [])
|
|
26832
|
+
.filter((name) => /^\\d+\\.\\d+\\.\\d+$/.test(name) && fs.existsSync(path.join(installed(name), "package.json")))
|
|
26833
|
+
.sort((a, b) => {
|
|
26834
|
+
const [left, right] = [numbers(a), numbers(b)];
|
|
26835
|
+
return left[0] - right[0] || left[1] - right[1] || left[2] - right[2];
|
|
26836
|
+
})
|
|
26837
|
+
.at(-1);
|
|
26838
|
+
if (!newest) {
|
|
26839
|
+
process.stderr.write(
|
|
26840
|
+
"layermap: no LayerMap version is installed in " + versions + ". Start a session of an agent that has the LayerMap plugin, which installs its version there, then run this again.\\n",
|
|
26841
|
+
);
|
|
26842
|
+
process.exit(1);
|
|
26843
|
+
}
|
|
26844
|
+
const entry = path.join(
|
|
26845
|
+
installed(newest),
|
|
26846
|
+
JSON.parse(fs.readFileSync(path.join(installed(newest), "package.json"), "utf8")).bin.layermap,
|
|
26847
|
+
);
|
|
26848
|
+
process.argv = [process.argv[0], entry, ...process.argv.slice(2)];
|
|
26849
|
+
import(pathToFileURL(entry).href).catch((error) => {
|
|
26850
|
+
process.stderr.write("layermap: could not start LayerMap " + newest + ": " + (error?.message ?? error) + "\\n");
|
|
26851
|
+
process.exit(1);
|
|
26852
|
+
});
|
|
26853
|
+
`;
|
|
26854
|
+
var commandFile = (env = process.env) => path17.join(env.HOME || homedir2(), ".local", "bin", "layermap");
|
|
26855
|
+
async function state(file2) {
|
|
26856
|
+
const found = await lstat5(file2).catch(() => void 0);
|
|
26857
|
+
if (!found) return "absent";
|
|
26858
|
+
if (!found.isFile()) return "other";
|
|
26859
|
+
return (await readFile6(file2, "utf8")).includes(MARK) ? "own" : "other";
|
|
26860
|
+
}
|
|
26861
|
+
var unsupported = (log2) => {
|
|
26862
|
+
log2(
|
|
26863
|
+
"The layermap command is for macOS and Linux, whose shells run a file in ~/.local/bin; on Windows use `npx layermap`."
|
|
26864
|
+
);
|
|
26865
|
+
return false;
|
|
26866
|
+
};
|
|
26867
|
+
async function setupCommand(options) {
|
|
26868
|
+
const env = options.env ?? process.env;
|
|
26869
|
+
const { log: log2 } = options;
|
|
26870
|
+
if (process.platform === "win32") return unsupported(log2);
|
|
26871
|
+
const file2 = commandFile(env);
|
|
26872
|
+
if (await state(file2) === "other") {
|
|
26873
|
+
log2(
|
|
26874
|
+
`${file2} is there already and is not LayerMap's command: left as it is. Remove it if you do not need it, then run setup again.`
|
|
26875
|
+
);
|
|
26876
|
+
return false;
|
|
26877
|
+
}
|
|
26878
|
+
log2(`write LayerMap's command to ${file2}`);
|
|
26879
|
+
if (options.dryRun) return true;
|
|
26880
|
+
await mkdir3(path17.dirname(file2), { recursive: true });
|
|
26881
|
+
await writeFile2(`${file2}.${process.pid}`, commandScript(cacheDirectory(env)));
|
|
26882
|
+
await chmod(`${file2}.${process.pid}`, 493);
|
|
26883
|
+
await rename3(`${file2}.${process.pid}`, file2);
|
|
26884
|
+
if (!(env.PATH ?? "").split(path17.delimiter).includes(path17.dirname(file2)))
|
|
26885
|
+
log2(`${path17.dirname(file2)} is not on this shell's PATH: add it for the command to be found.`);
|
|
26886
|
+
log2(
|
|
26887
|
+
`Done. \`layermap\` runs the newest LayerMap version installed in ${path17.join(cacheDirectory(env), "versions")}, where each agent's LayerMap plugin installs the version it starts.`
|
|
26888
|
+
);
|
|
26889
|
+
return true;
|
|
26890
|
+
}
|
|
26891
|
+
async function removeCommand(options) {
|
|
26892
|
+
const { log: log2 } = options;
|
|
26893
|
+
if (process.platform === "win32") return unsupported(log2);
|
|
26894
|
+
const file2 = commandFile(options.env ?? process.env);
|
|
26895
|
+
const found = await state(file2);
|
|
26896
|
+
if (found === "other") {
|
|
26897
|
+
log2(`${file2} is not LayerMap's command: left as it is.`);
|
|
26898
|
+
return false;
|
|
26899
|
+
}
|
|
26900
|
+
if (found === "absent") {
|
|
26901
|
+
log2(`${file2} is not there: nothing to remove.`);
|
|
26902
|
+
return true;
|
|
26903
|
+
}
|
|
26904
|
+
log2(`remove LayerMap's command from ${file2}`);
|
|
26905
|
+
if (options.dryRun) return true;
|
|
26906
|
+
await rm2(file2);
|
|
26907
|
+
log2("Removed.");
|
|
26908
|
+
return true;
|
|
26909
|
+
}
|
|
26910
|
+
|
|
26808
26911
|
// src/agent/mcp.ts
|
|
26809
26912
|
import { createInterface } from "node:readline";
|
|
26810
26913
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
@@ -26832,7 +26935,7 @@ var MAP_TOOL_NAMES = Object.freeze({
|
|
|
26832
26935
|
references: "project_find_references",
|
|
26833
26936
|
check: "project_check_changes"
|
|
26834
26937
|
});
|
|
26835
|
-
var mapDirectoryPath = (
|
|
26938
|
+
var mapDirectoryPath = (path21) => path21.length > 1 && path21.endsWith("/") && !path21.endsWith("//") ? path21.slice(0, -1) : path21;
|
|
26836
26939
|
var ProjectMapSearchInputSchema = external_exports.object({
|
|
26837
26940
|
path: external_exports.string().default("."),
|
|
26838
26941
|
query: external_exports.string().min(1).max(256),
|
|
@@ -26904,30 +27007,30 @@ var projectHeading = (project) => `Project ${project} (paths are relative to it)
|
|
|
26904
27007
|
// src/agent/projects.ts
|
|
26905
27008
|
import { existsSync as existsSync7 } from "node:fs";
|
|
26906
27009
|
import { readdir as readdir2, realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
26907
|
-
import
|
|
27010
|
+
import path18 from "node:path";
|
|
26908
27011
|
var escapes = (relative) => {
|
|
26909
|
-
const normal =
|
|
26910
|
-
return normal === ".." || normal.startsWith(`..${
|
|
27012
|
+
const normal = path18.normalize(relative);
|
|
27013
|
+
return normal === ".." || normal.startsWith(`..${path18.sep}`);
|
|
26911
27014
|
};
|
|
26912
27015
|
async function locate(start, given) {
|
|
26913
|
-
if (start.git && !
|
|
27016
|
+
if (start.git && !path18.isAbsolute(given) && !escapes(given))
|
|
26914
27017
|
return { project: start.directory, path: given };
|
|
26915
|
-
const absolute =
|
|
27018
|
+
const absolute = path18.resolve(start.directory, given);
|
|
26916
27019
|
let directory = absolute;
|
|
26917
27020
|
while (!(await stat3(directory).catch(() => void 0))?.isDirectory()) {
|
|
26918
|
-
if (
|
|
26919
|
-
directory =
|
|
27021
|
+
if (path18.dirname(directory) === directory) return void 0;
|
|
27022
|
+
directory = path18.dirname(directory);
|
|
26920
27023
|
}
|
|
26921
|
-
const real =
|
|
27024
|
+
const real = path18.join(await realpath3(directory), path18.relative(directory, absolute));
|
|
26922
27025
|
const { directory: project, git: git2 } = await projectDirectory(directory);
|
|
26923
27026
|
if (!git2) return void 0;
|
|
26924
|
-
const relative =
|
|
27027
|
+
const relative = path18.relative(project, real);
|
|
26925
27028
|
if (escapes(relative)) return void 0;
|
|
26926
|
-
return { project, path: relative ? relative.split(
|
|
27029
|
+
return { project, path: relative ? relative.split(path18.sep).join("/") : "." };
|
|
26927
27030
|
}
|
|
26928
27031
|
async function repositoriesIn(directory) {
|
|
26929
27032
|
const entries = await readdir2(directory, { withFileTypes: true }).catch(() => []);
|
|
26930
|
-
return entries.filter((entry) => entry.isDirectory() && existsSync7(
|
|
27033
|
+
return entries.filter((entry) => entry.isDirectory() && existsSync7(path18.join(directory, entry.name, ".git"))).map((entry) => `${entry.name}/`).sort();
|
|
26931
27034
|
}
|
|
26932
27035
|
async function routeMapCall(start, { name, args }) {
|
|
26933
27036
|
const references = name === MAP_TOOL_NAMES.references;
|
|
@@ -26938,7 +27041,7 @@ async function routeMapCall(start, { name, args }) {
|
|
|
26938
27041
|
if (!located) {
|
|
26939
27042
|
const repositories = start.git ? [] : await repositoriesIn(start.directory);
|
|
26940
27043
|
const such = repositories.length ? `, such as ${repositories.join(", ")}` : "";
|
|
26941
|
-
return named === "." ? `LAYERMAP_NOT_A_GIT_REPOSITORY: This session started in ${start.directory}, which is not in a Git repository. Name a file or directory in one, relative to that folder or absolute${such}.` : `LAYERMAP_NOT_A_GIT_REPOSITORY: ${
|
|
27044
|
+
return named === "." ? `LAYERMAP_NOT_A_GIT_REPOSITORY: This session started in ${start.directory}, which is not in a Git repository. Name a file or directory in one, relative to that folder or absolute${such}.` : `LAYERMAP_NOT_A_GIT_REPOSITORY: ${path18.resolve(start.directory, named)} is not in a Git repository; LayerMap maps Git repositories${start.git ? "" : `. Name a file or directory in one, relative to ${start.directory} or absolute${such}`}.`;
|
|
26942
27045
|
}
|
|
26943
27046
|
if (!references) {
|
|
26944
27047
|
const routed2 = value === void 0 ? args : { ...args, path: located.path };
|
|
@@ -27328,9 +27431,9 @@ ${text}` : text
|
|
|
27328
27431
|
// src/agent/setup.ts
|
|
27329
27432
|
import { execFile } from "node:child_process";
|
|
27330
27433
|
import { existsSync as existsSync8 } from "node:fs";
|
|
27331
|
-
import { mkdir as
|
|
27332
|
-
import { homedir as
|
|
27333
|
-
import
|
|
27434
|
+
import { mkdir as mkdir4, readFile as readFile7, rename as rename4, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
|
|
27435
|
+
import { homedir as homedir3 } from "node:os";
|
|
27436
|
+
import path19 from "node:path";
|
|
27334
27437
|
var SERVER = "layermap";
|
|
27335
27438
|
var SETUP_RULE = `mcp__${SERVER}`;
|
|
27336
27439
|
var PLUGIN_RULE = `mcp__plugin_${SERVER}_${SERVER}`;
|
|
@@ -27338,11 +27441,11 @@ var BEGIN = "<!-- layermap:begin -->";
|
|
|
27338
27441
|
var END = "<!-- layermap:end -->";
|
|
27339
27442
|
var launcherScript = (template, version2, args = '["mcp"]') => `// Generated from scripts/launcher.mjs.
|
|
27340
27443
|
${template.replace("__VERSION__", JSON.stringify(version2)).replace("__ARGUMENTS__", args)}`;
|
|
27341
|
-
var PUBLISHED_LAUNCHER =
|
|
27342
|
-
var launcherFile = (env = process.env) =>
|
|
27444
|
+
var PUBLISHED_LAUNCHER = path19.join(packageRoot, "dist", "launcher.mjs");
|
|
27445
|
+
var launcherFile = (env = process.env) => path19.join(cacheDirectory(env), "server.mjs");
|
|
27343
27446
|
var mcpLaunchCommand = (env = process.env, published = existsSync8(PUBLISHED_LAUNCHER)) => {
|
|
27344
27447
|
if (published) return ["node", launcherFile(env)];
|
|
27345
|
-
const script =
|
|
27448
|
+
const script = path19.resolve(process.argv[1] ?? "");
|
|
27346
27449
|
const execArgv = [];
|
|
27347
27450
|
for (let index = 0; index < process.execArgv.length; index++) {
|
|
27348
27451
|
const argument = process.execArgv[index];
|
|
@@ -27369,7 +27472,7 @@ var run = (command, args, env) => new Promise((resolve) => {
|
|
|
27369
27472
|
);
|
|
27370
27473
|
});
|
|
27371
27474
|
async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
|
|
27372
|
-
const settings = existsSync8(file2) ? JSON.parse(await
|
|
27475
|
+
const settings = existsSync8(file2) ? JSON.parse(await readFile7(file2, "utf8")) : {};
|
|
27373
27476
|
if (typeof settings !== "object" || settings === null || Array.isArray(settings))
|
|
27374
27477
|
throw new Error(`${file2} is not a settings object.`);
|
|
27375
27478
|
settings.permissions ??= {};
|
|
@@ -27378,14 +27481,14 @@ async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
|
|
|
27378
27481
|
throw new Error(`${file2} has permissions.allow that is not a list.`);
|
|
27379
27482
|
if (settings.permissions.allow.includes(rule)) return false;
|
|
27380
27483
|
settings.permissions.allow.push(rule);
|
|
27381
|
-
await
|
|
27382
|
-
await
|
|
27484
|
+
await mkdir4(path19.dirname(file2), { recursive: true });
|
|
27485
|
+
await writeFile3(file2, `${JSON.stringify(settings, null, 2)}
|
|
27383
27486
|
`);
|
|
27384
27487
|
return true;
|
|
27385
27488
|
}
|
|
27386
27489
|
var CODEX_TOOL_TIMEOUT_SEC = 300;
|
|
27387
27490
|
async function configureCodexServer(file2) {
|
|
27388
|
-
const lines = (await
|
|
27491
|
+
const lines = (await readFile7(file2, "utf8")).split("\n");
|
|
27389
27492
|
const header2 = lines.findIndex((line) => line.trim() === `[mcp_servers.${SERVER}]`);
|
|
27390
27493
|
if (header2 < 0) throw new Error(`${file2} has no [mcp_servers.${SERVER}] table.`);
|
|
27391
27494
|
let end = header2 + 1;
|
|
@@ -27401,52 +27504,52 @@ async function configureCodexServer(file2) {
|
|
|
27401
27504
|
const added = Object.entries(wanted).filter(([key]) => !present.has(key)).map(([key, value]) => `${key} = ${value}`);
|
|
27402
27505
|
if (!added.length) return false;
|
|
27403
27506
|
lines.splice(header2 + 1, 0, ...added);
|
|
27404
|
-
await
|
|
27507
|
+
await writeFile3(file2, lines.join("\n"));
|
|
27405
27508
|
return true;
|
|
27406
27509
|
}
|
|
27407
27510
|
async function writeInstructionNote(file2, note = AGENT_MAP_NOTE) {
|
|
27408
27511
|
const block = `${BEGIN}
|
|
27409
27512
|
${note}
|
|
27410
27513
|
${END}`;
|
|
27411
|
-
const text = existsSync8(file2) ? await
|
|
27514
|
+
const text = existsSync8(file2) ? await readFile7(file2, "utf8") : "";
|
|
27412
27515
|
const start = text.indexOf(BEGIN);
|
|
27413
27516
|
const end = text.indexOf(END);
|
|
27414
27517
|
const next = start >= 0 && end > start ? `${text.slice(0, start)}${block}${text.slice(end + END.length)}` : `${text}${text && !text.endsWith("\n") ? "\n" : ""}${text ? "\n" : ""}${block}
|
|
27415
27518
|
`;
|
|
27416
27519
|
if (next === text) return;
|
|
27417
|
-
await
|
|
27418
|
-
await
|
|
27520
|
+
await mkdir4(path19.dirname(file2), { recursive: true });
|
|
27521
|
+
await writeFile3(file2, next);
|
|
27419
27522
|
}
|
|
27420
27523
|
async function removeInstructionNote(file2) {
|
|
27421
27524
|
if (!existsSync8(file2)) return;
|
|
27422
|
-
const text = await
|
|
27525
|
+
const text = await readFile7(file2, "utf8");
|
|
27423
27526
|
const start = text.indexOf(BEGIN);
|
|
27424
27527
|
const end = text.indexOf(END);
|
|
27425
27528
|
if (start < 0 || end < start) return;
|
|
27426
27529
|
const before = text.slice(0, start).replace(/\n\n$/u, "\n");
|
|
27427
27530
|
const rest = `${before}${text.slice(end + END.length).replace(/^\n/u, "")}`;
|
|
27428
|
-
if (!rest.trim()) await
|
|
27429
|
-
else await
|
|
27531
|
+
if (!rest.trim()) await rm3(file2);
|
|
27532
|
+
else await writeFile3(file2, rest);
|
|
27430
27533
|
}
|
|
27431
27534
|
async function disallowInClaudeSettings(file2) {
|
|
27432
27535
|
if (!existsSync8(file2)) return;
|
|
27433
|
-
const settings = JSON.parse(await
|
|
27536
|
+
const settings = JSON.parse(await readFile7(file2, "utf8"));
|
|
27434
27537
|
const allow = settings?.permissions?.allow;
|
|
27435
27538
|
const ours = (rule) => rule === SETUP_RULE || rule === PLUGIN_RULE;
|
|
27436
27539
|
if (!Array.isArray(allow) || !allow.some(ours)) return;
|
|
27437
27540
|
settings.permissions.allow = allow.filter((rule) => !ours(rule));
|
|
27438
27541
|
if (!settings.permissions.allow.length) delete settings.permissions.allow;
|
|
27439
27542
|
if (!Object.keys(settings.permissions).length) delete settings.permissions;
|
|
27440
|
-
await
|
|
27543
|
+
await writeFile3(file2, `${JSON.stringify(settings, null, 2)}
|
|
27441
27544
|
`);
|
|
27442
27545
|
}
|
|
27443
27546
|
var YAML_BEGIN = "# layermap:begin";
|
|
27444
27547
|
var YAML_END = "# layermap:end";
|
|
27445
|
-
var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(
|
|
27548
|
+
var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(path19.delimiter).find((directory) => path19.isAbsolute(directory) && existsSync8(path19.join(directory, "node"))) ?? path19.dirname(process.execPath);
|
|
27446
27549
|
var dshPatchBlock = (command, env) => {
|
|
27447
27550
|
const node = nodeDirectory(env);
|
|
27448
|
-
const [program = "", ...args] = command[0] === "node" ? [
|
|
27449
|
-
const searchPath2 = `${JSON.stringify(`${node}${
|
|
27551
|
+
const [program = "", ...args] = command[0] === "node" ? [path19.join(node, "node"), ...command.slice(1)] : command;
|
|
27552
|
+
const searchPath2 = `${JSON.stringify(`${node}${path19.delimiter}`)} + process.env.PATH`;
|
|
27450
27553
|
return [
|
|
27451
27554
|
`${YAML_BEGIN} (written by \`layermap setup dsh\`; \`layermap remove dsh\` deletes it)`,
|
|
27452
27555
|
"- insert:",
|
|
@@ -27465,7 +27568,7 @@ var dshPatchBlock = (command, env) => {
|
|
|
27465
27568
|
].join("\n");
|
|
27466
27569
|
};
|
|
27467
27570
|
async function writeDshPatch(file2, block) {
|
|
27468
|
-
const text = existsSync8(file2) ? await
|
|
27571
|
+
const text = existsSync8(file2) ? await readFile7(file2, "utf8") : "";
|
|
27469
27572
|
const start = text.indexOf(YAML_BEGIN);
|
|
27470
27573
|
const end = text.indexOf(YAML_END);
|
|
27471
27574
|
let next;
|
|
@@ -27481,49 +27584,49 @@ async function writeDshPatch(file2, block) {
|
|
|
27481
27584
|
`;
|
|
27482
27585
|
}
|
|
27483
27586
|
if (next === text) return;
|
|
27484
|
-
await
|
|
27485
|
-
await
|
|
27587
|
+
await mkdir4(path19.dirname(file2), { recursive: true });
|
|
27588
|
+
await writeFile3(file2, next);
|
|
27486
27589
|
}
|
|
27487
27590
|
async function removeDshPatch(file2) {
|
|
27488
27591
|
if (!existsSync8(file2)) return;
|
|
27489
|
-
const text = await
|
|
27592
|
+
const text = await readFile7(file2, "utf8");
|
|
27490
27593
|
const start = text.indexOf(YAML_BEGIN);
|
|
27491
27594
|
const end = text.indexOf(YAML_END);
|
|
27492
27595
|
if (start < 0 || end < start) return;
|
|
27493
27596
|
const rest = `${text.slice(0, start)}${text.slice(end + YAML_END.length).replace(/^\n/u, "")}`;
|
|
27494
|
-
if (!rest.trim()) return
|
|
27597
|
+
if (!rest.trim()) return rm3(file2);
|
|
27495
27598
|
const content = rest.split("\n").some((line) => line.trim() && !line.trim().startsWith("#"));
|
|
27496
|
-
await
|
|
27599
|
+
await writeFile3(file2, content ? rest : `${rest}${rest.endsWith("\n") ? "" : "\n"}[]
|
|
27497
27600
|
`);
|
|
27498
27601
|
}
|
|
27499
27602
|
var agentFiles = (options) => {
|
|
27500
27603
|
const env = options.env ?? process.env;
|
|
27501
27604
|
if (options.agent === "dsh") {
|
|
27502
|
-
const home = env.DSH_HOME ||
|
|
27605
|
+
const home = env.DSH_HOME || path19.join(homedir3(), ".dsh");
|
|
27503
27606
|
return {
|
|
27504
|
-
settings:
|
|
27505
|
-
instructions:
|
|
27607
|
+
settings: path19.join(home, "cordis.patch.yml"),
|
|
27608
|
+
instructions: path19.join(home, "AGENTS.md")
|
|
27506
27609
|
};
|
|
27507
27610
|
}
|
|
27508
27611
|
if (options.agent === "codex") {
|
|
27509
|
-
const home = env.CODEX_HOME ??
|
|
27510
|
-
return { settings:
|
|
27612
|
+
const home = env.CODEX_HOME ?? path19.join(homedir3(), ".codex");
|
|
27613
|
+
return { settings: path19.join(home, "config.toml"), instructions: path19.join(home, "AGENTS.md") };
|
|
27511
27614
|
}
|
|
27512
27615
|
if (options.scope === "user") {
|
|
27513
|
-
const home = env.CLAUDE_CONFIG_DIR ??
|
|
27616
|
+
const home = env.CLAUDE_CONFIG_DIR ?? path19.join(homedir3(), ".claude");
|
|
27514
27617
|
return {
|
|
27515
|
-
settings:
|
|
27516
|
-
instructions:
|
|
27618
|
+
settings: path19.join(home, "settings.json"),
|
|
27619
|
+
instructions: path19.join(home, "CLAUDE.md")
|
|
27517
27620
|
};
|
|
27518
27621
|
}
|
|
27519
27622
|
const local = options.scope === "local";
|
|
27520
27623
|
return {
|
|
27521
|
-
settings:
|
|
27624
|
+
settings: path19.join(
|
|
27522
27625
|
options.project,
|
|
27523
27626
|
".claude",
|
|
27524
27627
|
local ? "settings.local.json" : "settings.json"
|
|
27525
27628
|
),
|
|
27526
|
-
instructions:
|
|
27629
|
+
instructions: path19.join(options.project, local ? "CLAUDE.local.md" : "CLAUDE.md")
|
|
27527
27630
|
};
|
|
27528
27631
|
};
|
|
27529
27632
|
async function setupAgent(options) {
|
|
@@ -27543,12 +27646,12 @@ async function setupAgent(options) {
|
|
|
27543
27646
|
const writeLauncher = async () => {
|
|
27544
27647
|
if (!published) return;
|
|
27545
27648
|
const file2 = launcherFile(env);
|
|
27546
|
-
await
|
|
27547
|
-
await
|
|
27649
|
+
await mkdir4(path19.dirname(file2), { recursive: true, mode: 448 });
|
|
27650
|
+
await writeFile3(
|
|
27548
27651
|
`${file2}.${process.pid}`,
|
|
27549
|
-
launcherScript(await
|
|
27652
|
+
launcherScript(await readFile7(PUBLISHED_LAUNCHER, "utf8"), options.version)
|
|
27550
27653
|
);
|
|
27551
|
-
await
|
|
27654
|
+
await rename4(`${file2}.${process.pid}`, file2);
|
|
27552
27655
|
};
|
|
27553
27656
|
if (published) log2(`write the launcher of LayerMap ${options.version} to ${launcherFile(env)}`);
|
|
27554
27657
|
if (options.agent === "dsh") {
|
|
@@ -27644,6 +27747,10 @@ Usage:
|
|
|
27644
27747
|
layermap allow claude [--scope user|project|local] [--dry-run]
|
|
27645
27748
|
let the plugin's read-only tools run without a prompt
|
|
27646
27749
|
layermap remove claude|codex|dsh [--scope user|project|local] [--dry-run]
|
|
27750
|
+
layermap setup command [--dry-run] put a layermap command in ~/.local/bin, for shells with no
|
|
27751
|
+
plugin's on their PATH (Codex's commands, a terminal): it
|
|
27752
|
+
runs the newest version the agents' plugins have installed
|
|
27753
|
+
layermap remove command [--dry-run]
|
|
27647
27754
|
layermap mcp [--project DIR] serve the map tools over MCP (stdio)
|
|
27648
27755
|
layermap index [--project DIR] build or update the map now
|
|
27649
27756
|
layermap explore [PATH] [--name NAME] [--line N] [--direction INCOMING|OUTGOING|BOTH]
|
|
@@ -27667,10 +27774,10 @@ var log = (line) => process.stderr.write(`${line}
|
|
|
27667
27774
|
async function checkedTests(project, tests) {
|
|
27668
27775
|
const here = await realpath4(process.cwd());
|
|
27669
27776
|
return tests.map((test) => {
|
|
27670
|
-
const relative =
|
|
27671
|
-
if (!relative || relative === ".." || relative.startsWith(`..${
|
|
27777
|
+
const relative = path20.relative(project, path20.resolve(here, test));
|
|
27778
|
+
if (!relative || relative === ".." || relative.startsWith(`..${path20.sep}`) || path20.isAbsolute(relative))
|
|
27672
27779
|
throw new Error(`${test} is not in ${project}.`);
|
|
27673
|
-
return relative.split(
|
|
27780
|
+
return relative.split(path20.sep).join("/");
|
|
27674
27781
|
});
|
|
27675
27782
|
}
|
|
27676
27783
|
var usage = (code) => {
|
|
@@ -27729,6 +27836,11 @@ async function main(argv) {
|
|
|
27729
27836
|
};
|
|
27730
27837
|
if (command === "setup" || command === "allow" || command === "remove") {
|
|
27731
27838
|
const agent = rest[0];
|
|
27839
|
+
if (agent === "command" && command !== "allow")
|
|
27840
|
+
return await (command === "setup" ? setupCommand : removeCommand)({
|
|
27841
|
+
dryRun: values["dry-run"],
|
|
27842
|
+
log
|
|
27843
|
+
}) ? 0 : 1;
|
|
27732
27844
|
if (agent !== "claude" && agent !== "codex" && agent !== "dsh") return usage(1);
|
|
27733
27845
|
if (!["user", "project", "local"].includes(values.scope)) return usage(1);
|
|
27734
27846
|
const done = await { setup: setupAgent, allow: allowAgent, remove: removeAgent }[command]({
|