layermap 0.1.27 → 0.1.28
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 +3 -1
- package/analyzers/project-map-go-worker.mjs +1 -0
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/analyzers/project-map-java-worker.mjs +1 -0
- package/analyzers/project-map-python-worker.mjs +1 -0
- package/analyzers/project-map-worker.mjs +428 -192
- package/dist/cli.mjs +410 -368
- package/package.json +1 -1
- package/pi/layermap.mjs +15 -2
package/dist/cli.mjs
CHANGED
|
@@ -16,14 +16,14 @@ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:f
|
|
|
16
16
|
import { mkdir, readdir, readFile as readFile2, rename, rm, stat, utimes, writeFile } from "node:fs/promises";
|
|
17
17
|
import { createRequire } from "node:module";
|
|
18
18
|
import { homedir } from "node:os";
|
|
19
|
-
import
|
|
19
|
+
import path12 from "node:path";
|
|
20
20
|
import { fileURLToPath } from "node:url";
|
|
21
21
|
|
|
22
22
|
// src/layermap.ts
|
|
23
23
|
import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
|
|
24
24
|
import { mkdirSync, statSync } from "node:fs";
|
|
25
25
|
import { lstat as lstat3, realpath as realpath2 } from "node:fs/promises";
|
|
26
|
-
import
|
|
26
|
+
import path11 from "node:path";
|
|
27
27
|
import { DatabaseSync } from "@photostructure/sqlite";
|
|
28
28
|
|
|
29
29
|
// src/capture-policy.ts
|
|
@@ -428,6 +428,7 @@ var allowedTextExtensions = Object.freeze([
|
|
|
428
428
|
".ts",
|
|
429
429
|
".tsx",
|
|
430
430
|
".txt",
|
|
431
|
+
".wxml",
|
|
431
432
|
".xml",
|
|
432
433
|
".yaml",
|
|
433
434
|
".yml"
|
|
@@ -1304,10 +1305,10 @@ function mergeDefs(...defs) {
|
|
|
1304
1305
|
function cloneDef(schema) {
|
|
1305
1306
|
return mergeDefs(schema._zod.def);
|
|
1306
1307
|
}
|
|
1307
|
-
function getElementAtPath(obj,
|
|
1308
|
-
if (!
|
|
1308
|
+
function getElementAtPath(obj, path15) {
|
|
1309
|
+
if (!path15)
|
|
1309
1310
|
return obj;
|
|
1310
|
-
return
|
|
1311
|
+
return path15.reduce((acc, key) => acc?.[key], obj);
|
|
1311
1312
|
}
|
|
1312
1313
|
function promiseAllObject(promisesObj) {
|
|
1313
1314
|
const keys = Object.keys(promisesObj);
|
|
@@ -1716,11 +1717,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1716
1717
|
}
|
|
1717
1718
|
return false;
|
|
1718
1719
|
}
|
|
1719
|
-
function prefixIssues(
|
|
1720
|
+
function prefixIssues(path15, issues) {
|
|
1720
1721
|
return issues.map((iss) => {
|
|
1721
1722
|
var _a3;
|
|
1722
1723
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1723
|
-
iss.path.unshift(
|
|
1724
|
+
iss.path.unshift(path15);
|
|
1724
1725
|
return iss;
|
|
1725
1726
|
});
|
|
1726
1727
|
}
|
|
@@ -1867,16 +1868,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1867
1868
|
}
|
|
1868
1869
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1869
1870
|
const fieldErrors = { _errors: [] };
|
|
1870
|
-
const processError = (error52,
|
|
1871
|
+
const processError = (error52, path15 = []) => {
|
|
1871
1872
|
for (const issue2 of error52.issues) {
|
|
1872
1873
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1873
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1874
|
+
issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
|
|
1874
1875
|
} else if (issue2.code === "invalid_key") {
|
|
1875
|
-
processError({ issues: issue2.issues }, [...
|
|
1876
|
+
processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
|
|
1876
1877
|
} else if (issue2.code === "invalid_element") {
|
|
1877
|
-
processError({ issues: issue2.issues }, [...
|
|
1878
|
+
processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
|
|
1878
1879
|
} else {
|
|
1879
|
-
const fullpath = [...
|
|
1880
|
+
const fullpath = [...path15, ...issue2.path];
|
|
1880
1881
|
if (fullpath.length === 0) {
|
|
1881
1882
|
fieldErrors._errors.push(mapper(issue2));
|
|
1882
1883
|
} else {
|
|
@@ -1903,17 +1904,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1903
1904
|
}
|
|
1904
1905
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1905
1906
|
const result = { errors: [] };
|
|
1906
|
-
const processError = (error52,
|
|
1907
|
+
const processError = (error52, path15 = []) => {
|
|
1907
1908
|
var _a3, _b;
|
|
1908
1909
|
for (const issue2 of error52.issues) {
|
|
1909
1910
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1910
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1911
|
+
issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
|
|
1911
1912
|
} else if (issue2.code === "invalid_key") {
|
|
1912
|
-
processError({ issues: issue2.issues }, [...
|
|
1913
|
+
processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
|
|
1913
1914
|
} else if (issue2.code === "invalid_element") {
|
|
1914
|
-
processError({ issues: issue2.issues }, [...
|
|
1915
|
+
processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
|
|
1915
1916
|
} else {
|
|
1916
|
-
const fullpath = [...
|
|
1917
|
+
const fullpath = [...path15, ...issue2.path];
|
|
1917
1918
|
if (fullpath.length === 0) {
|
|
1918
1919
|
result.errors.push(mapper(issue2));
|
|
1919
1920
|
continue;
|
|
@@ -1945,8 +1946,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1945
1946
|
}
|
|
1946
1947
|
function toDotPath(_path) {
|
|
1947
1948
|
const segs = [];
|
|
1948
|
-
const
|
|
1949
|
-
for (const seg of
|
|
1949
|
+
const path15 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1950
|
+
for (const seg of path15) {
|
|
1950
1951
|
if (typeof seg === "number")
|
|
1951
1952
|
segs.push(`[${seg}]`);
|
|
1952
1953
|
else if (typeof seg === "symbol")
|
|
@@ -14638,13 +14639,13 @@ function resolveRef(ref, ctx) {
|
|
|
14638
14639
|
if (!ref.startsWith("#")) {
|
|
14639
14640
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14640
14641
|
}
|
|
14641
|
-
const
|
|
14642
|
-
if (
|
|
14642
|
+
const path15 = ref.slice(1).split("/").filter(Boolean);
|
|
14643
|
+
if (path15.length === 0) {
|
|
14643
14644
|
return ctx.rootSchema;
|
|
14644
14645
|
}
|
|
14645
14646
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14646
|
-
if (
|
|
14647
|
-
const key =
|
|
14647
|
+
if (path15[0] === defsKey) {
|
|
14648
|
+
const key = path15[1];
|
|
14648
14649
|
if (!key || !ctx.defs[key]) {
|
|
14649
14650
|
throw new Error(`Reference not found: ${ref}`);
|
|
14650
14651
|
}
|
|
@@ -15540,7 +15541,8 @@ var sourceExtensions = Object.freeze([
|
|
|
15540
15541
|
".sql",
|
|
15541
15542
|
".swift",
|
|
15542
15543
|
".ts",
|
|
15543
|
-
".tsx"
|
|
15544
|
+
".tsx",
|
|
15545
|
+
".wxml"
|
|
15544
15546
|
]);
|
|
15545
15547
|
var excludedSegments = Object.freeze([
|
|
15546
15548
|
"node_modules",
|
|
@@ -15957,8 +15959,8 @@ var MapAnalysisSchema = external_exports.object({
|
|
|
15957
15959
|
var mapPathAllowed = (relative, prefixes) => prefixes.some(
|
|
15958
15960
|
(prefix) => prefix === "." || relative === prefix || relative.startsWith(`${prefix}/`)
|
|
15959
15961
|
);
|
|
15960
|
-
var mapTestPath = (
|
|
15961
|
-
|
|
15962
|
+
var mapTestPath = (path15) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
|
|
15963
|
+
path15
|
|
15962
15964
|
);
|
|
15963
15965
|
|
|
15964
15966
|
// src/project-map-reference-types.ts
|
|
@@ -16042,11 +16044,11 @@ var string4 = (value) => {
|
|
|
16042
16044
|
var identity = (id2, reconstructed) => id2 === reconstructed ? [] : [JSON.stringify(id2)];
|
|
16043
16045
|
function encodeMapText(graph) {
|
|
16044
16046
|
const files = /* @__PURE__ */ new Map();
|
|
16045
|
-
const file2 = (
|
|
16046
|
-
let ref = files.get(
|
|
16047
|
+
const file2 = (path15) => {
|
|
16048
|
+
let ref = files.get(path15);
|
|
16047
16049
|
if (!ref) {
|
|
16048
16050
|
ref = `F${files.size + 1}`;
|
|
16049
|
-
files.set(
|
|
16051
|
+
files.set(path15, ref);
|
|
16050
16052
|
}
|
|
16051
16053
|
return ref;
|
|
16052
16054
|
};
|
|
@@ -16094,7 +16096,7 @@ function encodeMapText(graph) {
|
|
|
16094
16096
|
rows2.push(`B ${node(frontier.entityRef)} ${frontier.direction}`);
|
|
16095
16097
|
return [
|
|
16096
16098
|
...header,
|
|
16097
|
-
...[...files].map(([
|
|
16099
|
+
...[...files].map(([path15, ref]) => `${ref} ${JSON.stringify(path15)}`),
|
|
16098
16100
|
...rows2
|
|
16099
16101
|
].join("\n");
|
|
16100
16102
|
}
|
|
@@ -16114,10 +16116,10 @@ function decodeMapText(text) {
|
|
|
16114
16116
|
const at = (value) => {
|
|
16115
16117
|
const match = /^(F[1-9]\d*):(\d+)-(\d+)@(\d+)-(\d+)$/u.exec(value ?? "");
|
|
16116
16118
|
if (!match) return failed();
|
|
16117
|
-
const
|
|
16118
|
-
if (
|
|
16119
|
+
const path15 = files.get(match[1] ?? "");
|
|
16120
|
+
if (path15 === void 0) return failed();
|
|
16119
16121
|
return MapAnchorSchema.parse({
|
|
16120
|
-
path:
|
|
16122
|
+
path: path15,
|
|
16121
16123
|
startLine: Number(match[2]),
|
|
16122
16124
|
endLine: Number(match[3]),
|
|
16123
16125
|
start: Number(match[4]),
|
|
@@ -16194,8 +16196,8 @@ function decodeMapText(text) {
|
|
|
16194
16196
|
var locationSchema = MapAnchorSchema.describe(
|
|
16195
16197
|
"Source location: start/end are zero-based UTF-16 offsets with an exclusive end; line numbers are one-based."
|
|
16196
16198
|
);
|
|
16197
|
-
var location = ({ path:
|
|
16198
|
-
path:
|
|
16199
|
+
var location = ({ path: path15, startLine, endLine, start, end }) => ({
|
|
16200
|
+
path: path15,
|
|
16199
16201
|
startLine,
|
|
16200
16202
|
endLine,
|
|
16201
16203
|
start,
|
|
@@ -16298,11 +16300,11 @@ var MapNavigationObjectsSchema = external_exports.union([
|
|
|
16298
16300
|
),
|
|
16299
16301
|
external_exports.object({ files: external_exports.array(searchFileSchema) }).passthrough().refine((value) => !("format" in value), "Text navigation must decode through its format.").transform(
|
|
16300
16302
|
(value) => value.files.flatMap(
|
|
16301
|
-
({ path:
|
|
16303
|
+
({ path: path15, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
|
|
16302
16304
|
id: id2,
|
|
16303
16305
|
name,
|
|
16304
16306
|
kind,
|
|
16305
|
-
anchor: { path:
|
|
16307
|
+
anchor: { path: path15, startLine, endLine, start, end },
|
|
16306
16308
|
...execution ? { execution } : {}
|
|
16307
16309
|
}))
|
|
16308
16310
|
)
|
|
@@ -16315,10 +16317,10 @@ var mapSearchNavigation = (result) => {
|
|
|
16315
16317
|
for (const [index, object2] of found.entries()) {
|
|
16316
16318
|
const ranking = rankings[index];
|
|
16317
16319
|
if (!ranking) throw new Error("PROJECT_MAP_SEARCH_RANKING_MISSING");
|
|
16318
|
-
const
|
|
16320
|
+
const path15 = object2.anchor.path;
|
|
16319
16321
|
let file2 = files.at(-1);
|
|
16320
|
-
if (file2?.path !==
|
|
16321
|
-
file2 = { path:
|
|
16322
|
+
if (file2?.path !== path15) {
|
|
16323
|
+
file2 = { path: path15, symbols: [] };
|
|
16322
16324
|
files.push(file2);
|
|
16323
16325
|
}
|
|
16324
16326
|
file2.symbols.push({
|
|
@@ -16444,8 +16446,8 @@ var MapViewGraph = class {
|
|
|
16444
16446
|
}
|
|
16445
16447
|
return object2;
|
|
16446
16448
|
}
|
|
16447
|
-
objectsAt(
|
|
16448
|
-
return this.statements.path.all(this.version,
|
|
16449
|
+
objectsAt(path15) {
|
|
16450
|
+
return this.statements.path.all(this.version, path15).map((row) => {
|
|
16449
16451
|
const object2 = MapObjectSchema.parse(JSON.parse(String(row.object_json)));
|
|
16450
16452
|
this.objects.set(object2.id, object2);
|
|
16451
16453
|
return object2;
|
|
@@ -16564,8 +16566,8 @@ var MapViewGraph = class {
|
|
|
16564
16566
|
);
|
|
16565
16567
|
}
|
|
16566
16568
|
};
|
|
16567
|
-
function mapSelectDeclarations(graph,
|
|
16568
|
-
const objects2 = graph.objectsAt(
|
|
16569
|
+
function mapSelectDeclarations(graph, path15, name, line) {
|
|
16570
|
+
const objects2 = graph.objectsAt(path15).filter((object2) => !mapIsModule(object2));
|
|
16569
16571
|
const matching = name === void 0 ? objects2 : objects2.filter(
|
|
16570
16572
|
(object2) => object2.name === name || name.includes(".") && graph.qualifiedName(object2.id) === name
|
|
16571
16573
|
);
|
|
@@ -16587,12 +16589,12 @@ function requireMapObject(store, version2, selector, prefixes) {
|
|
|
16587
16589
|
if ([entityRef, locator, symbol2].filter((value) => value !== void 0).length !== 1 || entityRef !== void 0 && !entityRef.length)
|
|
16588
16590
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16589
16591
|
if (symbol2) {
|
|
16590
|
-
const
|
|
16591
|
-
if (!mapPathAllowed(
|
|
16592
|
+
const path15 = normalizeProjectEvidencePath(symbol2.path);
|
|
16593
|
+
if (!mapPathAllowed(path15, prefixes))
|
|
16592
16594
|
throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
|
|
16593
16595
|
const selected = mapSelectDeclarations(
|
|
16594
16596
|
new MapViewGraph(store, version2),
|
|
16595
|
-
|
|
16597
|
+
path15,
|
|
16596
16598
|
symbol2.name,
|
|
16597
16599
|
symbol2.line
|
|
16598
16600
|
);
|
|
@@ -16603,14 +16605,14 @@ function requireMapObject(store, version2, selector, prefixes) {
|
|
|
16603
16605
|
}
|
|
16604
16606
|
let rows2;
|
|
16605
16607
|
if (locator) {
|
|
16606
|
-
const
|
|
16608
|
+
const path15 = normalizeProjectEvidencePath(locator.path);
|
|
16607
16609
|
if (!Number.isSafeInteger(locator.start) || locator.start < 0 || locator.kind !== void 0 && !MapObjectKindSchema.safeParse(locator.kind).success)
|
|
16608
16610
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16609
|
-
if (!mapPathAllowed(
|
|
16611
|
+
if (!mapPathAllowed(path15, prefixes))
|
|
16610
16612
|
throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
|
|
16611
16613
|
rows2 = store.database.prepare(`SELECT object_json FROM project_map_objects
|
|
16612
16614
|
WHERE version_ref = ? AND path = ? AND json_extract(object_json, '$.anchor.start') = ?
|
|
16613
|
-
AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2,
|
|
16615
|
+
AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path15, locator.start, locator.kind ?? null, locator.kind ?? null);
|
|
16614
16616
|
} else {
|
|
16615
16617
|
rows2 = store.database.prepare(
|
|
16616
16618
|
"SELECT object_json FROM project_map_objects WHERE version_ref = ? AND entity_ref = ?"
|
|
@@ -16651,13 +16653,13 @@ function mapQueryPage(count, materialize, navigation, budget) {
|
|
|
16651
16653
|
|
|
16652
16654
|
// src/project-map-query-selection.ts
|
|
16653
16655
|
var mapQuerySelection = (input, knownKinds) => {
|
|
16654
|
-
const
|
|
16656
|
+
const path15 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
|
|
16655
16657
|
const kinds = input.kinds ?? knownKinds;
|
|
16656
16658
|
if (!Array.isArray(kinds) || !kinds.length || kinds.length > knownKinds.length || kinds.some((kind) => !knownKinds.includes(kind)))
|
|
16657
16659
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16658
|
-
return { path:
|
|
16660
|
+
return { path: path15, kinds: [...new Set(kinds)].sort() };
|
|
16659
16661
|
};
|
|
16660
|
-
var mapQueryPathMatches = (
|
|
16662
|
+
var mapQueryPathMatches = (path15, prefix) => prefix === "." || path15 === prefix || path15.startsWith(`${prefix}/`);
|
|
16661
16663
|
var mapQueryPathSql = (column) => `(? = '.' OR ${column} = ? OR substr(${column}, 1, length(?) + 1) = ? || '/')`;
|
|
16662
16664
|
|
|
16663
16665
|
// src/project-map-search-focus.ts
|
|
@@ -16755,7 +16757,7 @@ var declarationKinds = /* @__PURE__ */ new Set([
|
|
|
16755
16757
|
"METHOD",
|
|
16756
16758
|
"TYPE"
|
|
16757
16759
|
]);
|
|
16758
|
-
var fileStem = (
|
|
16760
|
+
var fileStem = (path15) => path15.slice(path15.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
|
|
16759
16761
|
var compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
16760
16762
|
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);
|
|
16761
16763
|
function mapSearchQuery(input) {
|
|
@@ -16782,10 +16784,10 @@ function mapSearchQuery(input) {
|
|
|
16782
16784
|
}
|
|
16783
16785
|
function rank(object2, documentation, relationCount, query, focus) {
|
|
16784
16786
|
const name = object2.name.toLowerCase();
|
|
16785
|
-
const
|
|
16787
|
+
const path15 = object2.anchor.path.toLowerCase();
|
|
16786
16788
|
const values = {
|
|
16787
16789
|
NAME: [name],
|
|
16788
|
-
PATH: [
|
|
16790
|
+
PATH: [path15],
|
|
16789
16791
|
DOCUMENTATION: documentation.map((text) => text.toLowerCase())
|
|
16790
16792
|
};
|
|
16791
16793
|
const matched = query.terms.map((term) => ({
|
|
@@ -16810,12 +16812,12 @@ function rank(object2, documentation, relationCount, query, focus) {
|
|
|
16810
16812
|
score += 7e3;
|
|
16811
16813
|
signals.push("SYMBOL_CONTAINS");
|
|
16812
16814
|
} else if (matchedFields.includes("NAME")) signals.push("SYMBOL_CONTAINS");
|
|
16813
|
-
if (object2.kind === "FILE" && fileStem(
|
|
16815
|
+
if (object2.kind === "FILE" && fileStem(path15) === normalizedQuery) {
|
|
16814
16816
|
score += 11e3;
|
|
16815
16817
|
signals.push("EXACT_FILE_STEM");
|
|
16816
16818
|
}
|
|
16817
16819
|
if (matchedFields.includes("PATH")) {
|
|
16818
|
-
score +=
|
|
16820
|
+
score += path15.includes(normalizedQuery) ? 2500 : 0;
|
|
16819
16821
|
signals.push("PATH_CONTAINS");
|
|
16820
16822
|
}
|
|
16821
16823
|
if (matchedFields.includes("DOCUMENTATION")) {
|
|
@@ -16830,8 +16832,8 @@ function rank(object2, documentation, relationCount, query, focus) {
|
|
|
16830
16832
|
score += kindWeight[object2.kind] + Math.min(1200, relationCount * 20) + (focus?.score ?? 0);
|
|
16831
16833
|
if (declarationKinds.has(object2.kind)) signals.push("DECLARATION");
|
|
16832
16834
|
if (relationCount > 0) signals.push("GRAPH_CONNECTED");
|
|
16833
|
-
const isTest = mapTestPath(
|
|
16834
|
-
const isGenerated = generatedPath.test(
|
|
16835
|
+
const isTest = mapTestPath(path15);
|
|
16836
|
+
const isGenerated = generatedPath.test(path15);
|
|
16835
16837
|
const hasTestIntent = query.terms.some((term) => testQuery.test(term));
|
|
16836
16838
|
score += isTest ? hasTestIntent ? 1e3 : -5e3 : 300;
|
|
16837
16839
|
score += isGenerated ? -3e3 : 300;
|
|
@@ -17315,13 +17317,13 @@ function utf16Offsets(text) {
|
|
|
17315
17317
|
}
|
|
17316
17318
|
function offsetConverter(files, offsets) {
|
|
17317
17319
|
const converters = /* @__PURE__ */ new Map();
|
|
17318
|
-
return (
|
|
17319
|
-
let convert = converters.get(
|
|
17320
|
+
return (path15, offset) => {
|
|
17321
|
+
let convert = converters.get(path15);
|
|
17320
17322
|
if (!convert) {
|
|
17321
|
-
const text = files[
|
|
17323
|
+
const text = files[path15];
|
|
17322
17324
|
if (text === void 0) return invalid();
|
|
17323
17325
|
convert = offsets === "UTF16" ? (value) => value <= text.length ? value : invalid() : utf16Offsets(text);
|
|
17324
|
-
converters.set(
|
|
17326
|
+
converters.set(path15, convert);
|
|
17325
17327
|
}
|
|
17326
17328
|
return convert(offset);
|
|
17327
17329
|
};
|
|
@@ -17352,7 +17354,7 @@ function mapFactsAnalysis(facts, input, context) {
|
|
|
17352
17354
|
const collect = new MapOutputCollector(output);
|
|
17353
17355
|
const positions = new MapSourcePositions(input.files);
|
|
17354
17356
|
const offset = offsetConverter(input.files, context.offsets);
|
|
17355
|
-
const anchor = (
|
|
17357
|
+
const anchor = (path15, start, end) => positions.span(path15, offset(path15, start), offset(path15, end));
|
|
17356
17358
|
const located = /* @__PURE__ */ new Map();
|
|
17357
17359
|
const canonical = /* @__PURE__ */ new Map();
|
|
17358
17360
|
const bySpan = /* @__PURE__ */ new Map();
|
|
@@ -17532,6 +17534,7 @@ var PhaseSchema = external_exports.enum([
|
|
|
17532
17534
|
"RELATION_SYMBOLS",
|
|
17533
17535
|
"RELATION_TARGETS",
|
|
17534
17536
|
"IMPLEMENTATIONS",
|
|
17537
|
+
"MINIPROGRAM_TEMPLATES",
|
|
17535
17538
|
"DECLARATION_SYMBOLS",
|
|
17536
17539
|
"DOCUMENTATION",
|
|
17537
17540
|
"CONFIG_DIAGNOSTICS",
|
|
@@ -17918,8 +17921,8 @@ var goModule = /(?:^|\/)go\.mod$/u;
|
|
|
17918
17921
|
var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
|
|
17919
17922
|
var GO_MAP_LANGUAGE = Object.freeze({
|
|
17920
17923
|
id: "go-1.24-map-v9",
|
|
17921
|
-
claims: (
|
|
17922
|
-
reads: (
|
|
17924
|
+
claims: (path15) => path15.endsWith(".go"),
|
|
17925
|
+
reads: (path15) => goModule.test(path15),
|
|
17923
17926
|
// A module path, or the standard library, whose first path element has no dot.
|
|
17924
17927
|
importName: (specifier) => {
|
|
17925
17928
|
const parts = specifier.split("/");
|
|
@@ -17928,7 +17931,7 @@ var GO_MAP_LANGUAGE = Object.freeze({
|
|
|
17928
17931
|
return parts.slice(0, size).join("/");
|
|
17929
17932
|
},
|
|
17930
17933
|
// Go imports a package: the directory of the file.
|
|
17931
|
-
importTarget: (
|
|
17934
|
+
importTarget: (path15) => `${path15.slice(0, path15.lastIndexOf("/") + 1) || "./"}`,
|
|
17932
17935
|
create: () => new GoMapAnalyzer()
|
|
17933
17936
|
});
|
|
17934
17937
|
var GO_GAPS = [
|
|
@@ -17974,12 +17977,12 @@ var GoMapAnalyzer = class {
|
|
|
17974
17977
|
}
|
|
17975
17978
|
}
|
|
17976
17979
|
async analyze(session, signal) {
|
|
17977
|
-
const modules = session.readable.map((entry) => entry.path).filter((
|
|
17978
|
-
const moduleOf = (
|
|
17980
|
+
const modules = session.readable.map((entry) => entry.path).filter((path15) => goModule.test(path15)).sort();
|
|
17981
|
+
const moduleOf = (path15) => {
|
|
17979
17982
|
let best;
|
|
17980
17983
|
for (const modFile of modules) {
|
|
17981
17984
|
const directory = modFile.slice(0, modFile.lastIndexOf("/") + 1);
|
|
17982
|
-
if (
|
|
17985
|
+
if (path15.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
|
|
17983
17986
|
best = modFile;
|
|
17984
17987
|
}
|
|
17985
17988
|
return best;
|
|
@@ -17995,11 +17998,11 @@ var GoMapAnalyzer = class {
|
|
|
17995
17998
|
for (const modFile of [...groups.keys()].sort()) {
|
|
17996
17999
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
17997
18000
|
const files = /* @__PURE__ */ Object.create(null);
|
|
17998
|
-
for (const
|
|
17999
|
-
const text = session.texts[
|
|
18001
|
+
for (const path15 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
|
|
18002
|
+
const text = session.texts[path15];
|
|
18000
18003
|
if (text === void 0)
|
|
18001
18004
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18002
|
-
files[
|
|
18005
|
+
files[path15] = text;
|
|
18003
18006
|
}
|
|
18004
18007
|
const input = {
|
|
18005
18008
|
contextRef: digestValue({
|
|
@@ -18034,8 +18037,8 @@ var GoMapAnalyzer = class {
|
|
|
18034
18037
|
if (text === void 0 || !existsSync3(this.resources.compilerPath))
|
|
18035
18038
|
throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
|
|
18036
18039
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18037
|
-
for (const [
|
|
18038
|
-
if (this.claims(
|
|
18040
|
+
for (const [path15, value] of Object.entries(input.files))
|
|
18041
|
+
if (this.claims(path15) || goModule.test(path15)) files[path15] = value;
|
|
18039
18042
|
const facts = await this.operation(
|
|
18040
18043
|
{
|
|
18041
18044
|
...input,
|
|
@@ -18065,14 +18068,14 @@ var BUILD_FILES = [
|
|
|
18065
18068
|
"pom.xml"
|
|
18066
18069
|
];
|
|
18067
18070
|
var buildFile = /(?:^|\/)(?:pom\.xml|(?:build|settings)\.gradle(?:\.kts)?)$/u;
|
|
18068
|
-
var directoryOf = (
|
|
18069
|
-
var nameOf = (
|
|
18071
|
+
var directoryOf = (path15) => path15.slice(0, path15.lastIndexOf("/") + 1);
|
|
18072
|
+
var nameOf = (path15) => path15.slice(path15.lastIndexOf("/") + 1);
|
|
18070
18073
|
var DEFAULT_RELEASE = 21;
|
|
18071
18074
|
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;
|
|
18072
18075
|
var JAVA_MAP_LANGUAGE = Object.freeze({
|
|
18073
18076
|
id: "javac-lombok-1.18.48-map-v8",
|
|
18074
|
-
claims: (
|
|
18075
|
-
reads: (
|
|
18077
|
+
claims: (path15) => path15.endsWith(".java"),
|
|
18078
|
+
reads: (path15) => buildFile.test(path15),
|
|
18076
18079
|
// A package of the Java platform, or a library named by its first two package segments.
|
|
18077
18080
|
importName: (specifier) => platformPackage.test(specifier) ? "Java standard library" : specifier.split(".").slice(0, 2).join("."),
|
|
18078
18081
|
create: () => new JavaMapAnalyzer()
|
|
@@ -18162,12 +18165,12 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18162
18165
|
// The worker's request for a context: the Java sources, the release and which are tests.
|
|
18163
18166
|
request(input, buildTexts) {
|
|
18164
18167
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18165
|
-
for (const [
|
|
18166
|
-
if (this.claims(
|
|
18168
|
+
for (const [path15, text] of Object.entries(input.files))
|
|
18169
|
+
if (this.claims(path15)) files[path15] = text;
|
|
18167
18170
|
return {
|
|
18168
18171
|
files,
|
|
18169
18172
|
release: javaRelease(buildTexts, this.resources.runtimeVersion),
|
|
18170
|
-
tests: Object.keys(files).filter((
|
|
18173
|
+
tests: Object.keys(files).filter((path15) => mapTestPath(path15))
|
|
18171
18174
|
};
|
|
18172
18175
|
}
|
|
18173
18176
|
// The build files of a context's root directory, which declare its Java version.
|
|
@@ -18179,35 +18182,35 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18179
18182
|
}
|
|
18180
18183
|
async analyze(session, signal) {
|
|
18181
18184
|
this.refreshRuntime();
|
|
18182
|
-
const builds = session.readable.map((entry) => entry.path).filter((
|
|
18183
|
-
for (const
|
|
18184
|
-
const rank2 = (
|
|
18185
|
+
const builds = session.readable.map((entry) => entry.path).filter((path15) => buildFile.test(path15));
|
|
18186
|
+
for (const path15 of builds) session.configuration(path15);
|
|
18187
|
+
const rank2 = (path15) => BUILD_FILES.indexOf(nameOf(path15));
|
|
18185
18188
|
const roots = /* @__PURE__ */ new Map();
|
|
18186
18189
|
const modules = /* @__PURE__ */ new Map();
|
|
18187
|
-
for (const
|
|
18188
|
-
const directory = directoryOf(
|
|
18190
|
+
for (const path15 of builds) {
|
|
18191
|
+
const directory = directoryOf(path15);
|
|
18189
18192
|
const current = modules.get(directory);
|
|
18190
|
-
if (current === void 0 || rank2(
|
|
18191
|
-
const text = session.texts[
|
|
18192
|
-
if (/settings\.gradle(?:\.kts)?$/u.test(
|
|
18193
|
+
if (current === void 0 || rank2(path15) < rank2(current)) modules.set(directory, path15);
|
|
18194
|
+
const text = session.texts[path15] ?? "";
|
|
18195
|
+
if (/settings\.gradle(?:\.kts)?$/u.test(path15) || path15.endsWith("pom.xml") && /<modules>/u.test(text)) {
|
|
18193
18196
|
const root = roots.get(directory);
|
|
18194
|
-
if (root === void 0 || rank2(
|
|
18197
|
+
if (root === void 0 || rank2(path15) < rank2(root)) roots.set(directory, path15);
|
|
18195
18198
|
}
|
|
18196
18199
|
}
|
|
18197
|
-
const configOf = (
|
|
18200
|
+
const configOf = (path15) => {
|
|
18198
18201
|
let outer;
|
|
18199
18202
|
for (const directory of roots.keys())
|
|
18200
|
-
if (
|
|
18203
|
+
if (path15.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
|
|
18201
18204
|
outer = directory;
|
|
18202
18205
|
if (outer !== void 0) return roots.get(outer);
|
|
18203
18206
|
let nearest;
|
|
18204
18207
|
for (const directory of modules.keys())
|
|
18205
|
-
if (
|
|
18208
|
+
if (path15.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
|
|
18206
18209
|
nearest = directory;
|
|
18207
18210
|
return nearest === void 0 ? "" : modules.get(nearest);
|
|
18208
18211
|
};
|
|
18209
|
-
const output = (
|
|
18210
|
-
(directory) =>
|
|
18212
|
+
const output = (path15) => [...modules.keys()].some(
|
|
18213
|
+
(directory) => path15.startsWith(`${directory}build/`) || path15.startsWith(`${directory}target/`)
|
|
18211
18214
|
);
|
|
18212
18215
|
const groups = /* @__PURE__ */ new Map();
|
|
18213
18216
|
for (const entry of session.readable) {
|
|
@@ -18222,13 +18225,13 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18222
18225
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
18223
18226
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18224
18227
|
const rootBuilds = configPath ? BUILD_FILES.map((name) => `${directoryOf(configPath)}${name}`).filter(
|
|
18225
|
-
(
|
|
18228
|
+
(path15) => builds.includes(path15)
|
|
18226
18229
|
) : [];
|
|
18227
|
-
for (const
|
|
18228
|
-
const text = session.texts[
|
|
18230
|
+
for (const path15 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
|
|
18231
|
+
const text = session.texts[path15];
|
|
18229
18232
|
if (text === void 0)
|
|
18230
18233
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18231
|
-
files[
|
|
18234
|
+
files[path15] = text;
|
|
18232
18235
|
}
|
|
18233
18236
|
const input = {
|
|
18234
18237
|
contextRef: digestValue({
|
|
@@ -18271,7 +18274,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18271
18274
|
const prior = JavaStateSchema.safeParse(previous?.state).data;
|
|
18272
18275
|
const incremental = previous && prior?.basis === basis ? {
|
|
18273
18276
|
changed: Object.keys(request.files).filter(
|
|
18274
|
-
(
|
|
18277
|
+
(path15) => digests.get(path15) !== previous.digests.get(path15)
|
|
18275
18278
|
),
|
|
18276
18279
|
state: prior.java
|
|
18277
18280
|
} : void 0;
|
|
@@ -18300,14 +18303,14 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18300
18303
|
continue;
|
|
18301
18304
|
}
|
|
18302
18305
|
const focus = new Set(facts.focus);
|
|
18303
|
-
if (!incremental || facts.focus.some((
|
|
18306
|
+
if (!incremental || facts.focus.some((path15) => !Object.hasOwn(request.files, path15)) || incremental.changed.some((path15) => !focus.has(path15)))
|
|
18304
18307
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18305
18308
|
analysis.objects = analysis.objects.filter((object2) => focus.has(object2.anchor.path));
|
|
18306
18309
|
analysis.relations = analysis.relations.filter((relation) => focus.has(relation.anchor.path));
|
|
18307
18310
|
analysis.notes = analysis.notes.filter((note) => focus.has(note.anchor.path));
|
|
18308
18311
|
session.accept(analysis, {
|
|
18309
18312
|
state,
|
|
18310
|
-
linked: analysis.parsedFiles.filter((
|
|
18313
|
+
linked: analysis.parsedFiles.filter((path15) => !focus.has(path15))
|
|
18311
18314
|
});
|
|
18312
18315
|
}
|
|
18313
18316
|
}
|
|
@@ -18619,12 +18622,12 @@ var PYTHON_STANDARD_LIBRARY = /* @__PURE__ */ new Set([
|
|
|
18619
18622
|
// src/project-map-language-python.ts
|
|
18620
18623
|
var CONFIGURATION = ["pyrightconfig.json", "pyproject.toml", "setup.cfg"];
|
|
18621
18624
|
var pythonConfig = /(?:^|\/)(?:pyrightconfig\.json|pyproject\.toml|setup\.cfg)$/u;
|
|
18622
|
-
var directoryOf2 = (
|
|
18625
|
+
var directoryOf2 = (path15) => path15.slice(0, path15.lastIndexOf("/") + 1);
|
|
18623
18626
|
var DEFAULT_PYTHON = { major: 3, minor: 13 };
|
|
18624
18627
|
var PYTHON_MAP_LANGUAGE = Object.freeze({
|
|
18625
18628
|
id: "pyright-1.1.414-map-v13",
|
|
18626
|
-
claims: (
|
|
18627
|
-
reads: (
|
|
18629
|
+
claims: (path15) => /\.pyi?$/u.test(path15),
|
|
18630
|
+
reads: (path15) => pythonConfig.test(path15),
|
|
18628
18631
|
// An absolute import names the standard library or a distribution's top-level package.
|
|
18629
18632
|
importName: (specifier) => {
|
|
18630
18633
|
const top = specifier.split(".", 1)[0] ?? specifier;
|
|
@@ -18676,21 +18679,21 @@ var PythonMapAnalyzer = class {
|
|
|
18676
18679
|
return {
|
|
18677
18680
|
root: input.configPath ? directoryOf2(input.configPath).replace(/\/$/u, "") : "",
|
|
18678
18681
|
pythonVersion: pythonVersion(input.files, input.configPath),
|
|
18679
|
-
tests: Object.keys(input.files).filter((
|
|
18682
|
+
tests: Object.keys(input.files).filter((path15) => this.claims(path15) && mapTestPath(path15))
|
|
18680
18683
|
};
|
|
18681
18684
|
}
|
|
18682
18685
|
async analyze(session, signal) {
|
|
18683
18686
|
const roots = /* @__PURE__ */ new Map();
|
|
18684
|
-
for (const
|
|
18685
|
-
const directory = directoryOf2(
|
|
18687
|
+
for (const path15 of session.readable.map((entry) => entry.path).filter((path16) => pythonConfig.test(path16))) {
|
|
18688
|
+
const directory = directoryOf2(path15);
|
|
18686
18689
|
const current = roots.get(directory);
|
|
18687
18690
|
const rank2 = (file2) => CONFIGURATION.indexOf(file2.slice(directory.length));
|
|
18688
|
-
if (current === void 0 || rank2(
|
|
18691
|
+
if (current === void 0 || rank2(path15) < rank2(current)) roots.set(directory, path15);
|
|
18689
18692
|
}
|
|
18690
|
-
const rootOf = (
|
|
18693
|
+
const rootOf = (path15) => {
|
|
18691
18694
|
let best;
|
|
18692
18695
|
for (const directory of roots.keys())
|
|
18693
|
-
if (
|
|
18696
|
+
if (path15.startsWith(directory) && (best === void 0 || directory.length > best.length))
|
|
18694
18697
|
best = directory;
|
|
18695
18698
|
return best === void 0 ? "" : roots.get(best);
|
|
18696
18699
|
};
|
|
@@ -18705,11 +18708,11 @@ var PythonMapAnalyzer = class {
|
|
|
18705
18708
|
for (const configPath of [...groups.keys()].sort()) {
|
|
18706
18709
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
18707
18710
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18708
|
-
for (const
|
|
18709
|
-
const text = session.texts[
|
|
18711
|
+
for (const path15 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
|
|
18712
|
+
const text = session.texts[path15];
|
|
18710
18713
|
if (text === void 0)
|
|
18711
18714
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18712
|
-
files[
|
|
18715
|
+
files[path15] = text;
|
|
18713
18716
|
}
|
|
18714
18717
|
const input = {
|
|
18715
18718
|
contextRef: digestValue({
|
|
@@ -18757,8 +18760,8 @@ var PythonMapAnalyzer = class {
|
|
|
18757
18760
|
if (input.files[reference.targetPath] === void 0)
|
|
18758
18761
|
throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
|
|
18759
18762
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18760
|
-
for (const [
|
|
18761
|
-
if (this.claims(
|
|
18763
|
+
for (const [path15, value] of Object.entries(input.files))
|
|
18764
|
+
if (this.claims(path15) || pythonConfig.test(path15)) files[path15] = value;
|
|
18762
18765
|
const facts = await this.operation(
|
|
18763
18766
|
{
|
|
18764
18767
|
...input,
|
|
@@ -18775,11 +18778,36 @@ var PythonMapAnalyzer = class {
|
|
|
18775
18778
|
}
|
|
18776
18779
|
};
|
|
18777
18780
|
|
|
18781
|
+
// src/project-map-miniprogram.ts
|
|
18782
|
+
import path8 from "node:path";
|
|
18783
|
+
import {
|
|
18784
|
+
isCallExpression,
|
|
18785
|
+
isExpressionStatement,
|
|
18786
|
+
isIdentifier,
|
|
18787
|
+
isMethodDeclaration,
|
|
18788
|
+
isObjectLiteralExpression,
|
|
18789
|
+
isPropertyAssignment,
|
|
18790
|
+
isStringLiteral
|
|
18791
|
+
} from "typescript/unstable/ast";
|
|
18792
|
+
var mapMiniprogramTemplate = (file2) => file2.endsWith(".wxml");
|
|
18793
|
+
var templateOf = (script) => script.replace(/\.[cm]?[jt]sx?$/u, ".wxml");
|
|
18794
|
+
var miniprogramTemplateOf = (script, inventory) => /\.[cm]?[jt]sx?$/u.test(script) && inventory.has(templateOf(script)) ? templateOf(script) : void 0;
|
|
18795
|
+
function miniprogramConfiguration(template, inventory) {
|
|
18796
|
+
const own = template.replace(/\.wxml$/u, ".json");
|
|
18797
|
+
const configuration = inventory.has(own) ? { own } : {};
|
|
18798
|
+
for (let directory = path8.posix.dirname(template); ; directory = path8.posix.dirname(directory)) {
|
|
18799
|
+
const root = directory === "." ? "" : directory;
|
|
18800
|
+
const app = path8.posix.join(root, "app.json");
|
|
18801
|
+
if (inventory.has(app)) return { ...configuration, app, root };
|
|
18802
|
+
if (!root) return configuration;
|
|
18803
|
+
}
|
|
18804
|
+
}
|
|
18805
|
+
|
|
18778
18806
|
// src/project-map-language-typescript.ts
|
|
18779
18807
|
var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
18780
|
-
id: "typescript-7.0.2-map-
|
|
18781
|
-
claims: (
|
|
18782
|
-
reads: (
|
|
18808
|
+
id: "typescript-7.0.2-map-v19",
|
|
18809
|
+
claims: (path15) => /\.[cm]?[jt]sx?$/u.test(path15),
|
|
18810
|
+
reads: (path15) => path15.endsWith(".json") || path15.endsWith(".wxml") || path15 === "pnpm-workspace.yaml",
|
|
18783
18811
|
create: () => new TypeScriptMapAnalyzer()
|
|
18784
18812
|
});
|
|
18785
18813
|
var CONFIGURATIONS_KEPT = 4;
|
|
@@ -18826,6 +18854,7 @@ var TypeScriptMapAnalyzer = class {
|
|
|
18826
18854
|
const { entries, texts: unitTexts, observe } = session;
|
|
18827
18855
|
const byPath = new Map(session.readable.map((entry) => [entry.path, entry]));
|
|
18828
18856
|
const inventory = [...byPath.keys()];
|
|
18857
|
+
const inventorySet = new Set(inventory);
|
|
18829
18858
|
const parsed = /* @__PURE__ */ new Set();
|
|
18830
18859
|
const syntaxFailed = /* @__PURE__ */ new Set();
|
|
18831
18860
|
const accept = (analysis) => {
|
|
@@ -18850,6 +18879,15 @@ var TypeScriptMapAnalyzer = class {
|
|
|
18850
18879
|
const text = unitTexts[file2];
|
|
18851
18880
|
if (text !== void 0) texts[file2] = text;
|
|
18852
18881
|
}
|
|
18882
|
+
for (const file2 of Object.keys(texts)) {
|
|
18883
|
+
const template = miniprogramTemplateOf(file2, inventorySet);
|
|
18884
|
+
if (!template) continue;
|
|
18885
|
+
const { own, app } = miniprogramConfiguration(template, inventorySet);
|
|
18886
|
+
for (const read of [template, own, app]) {
|
|
18887
|
+
const text = read === void 0 ? void 0 : unitTexts[read];
|
|
18888
|
+
if (read !== void 0 && text !== void 0) texts[read] = text;
|
|
18889
|
+
}
|
|
18890
|
+
}
|
|
18853
18891
|
const contextRef = digestValue({
|
|
18854
18892
|
analyzer: this.id,
|
|
18855
18893
|
configPath: configPath ?? null,
|
|
@@ -18891,9 +18929,9 @@ var TypeScriptMapAnalyzer = class {
|
|
|
18891
18929
|
accept(analysis);
|
|
18892
18930
|
return;
|
|
18893
18931
|
}
|
|
18894
|
-
const required2 = analysis.requiredFiles.map((
|
|
18895
|
-
const entry = byPath.get(
|
|
18896
|
-
if (!entry || Object.hasOwn(texts,
|
|
18932
|
+
const required2 = analysis.requiredFiles.map((path15) => {
|
|
18933
|
+
const entry = byPath.get(path15);
|
|
18934
|
+
if (!entry || Object.hasOwn(texts, path15))
|
|
18897
18935
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18898
18936
|
return entry;
|
|
18899
18937
|
});
|
|
@@ -18951,16 +18989,16 @@ var MAP_LANGUAGES = Object.freeze([
|
|
|
18951
18989
|
]);
|
|
18952
18990
|
var mapAnalyzerSuite = (languages) => languages.map((language) => language.id).sort().join("+");
|
|
18953
18991
|
var PROJECT_MAP_ANALYZER = mapAnalyzerSuite(MAP_LANGUAGES);
|
|
18954
|
-
var mapCodePath = (
|
|
18955
|
-
var languageOf = (
|
|
18956
|
-
var mapLanguageOf = (
|
|
18992
|
+
var mapCodePath = (path15) => MAP_LANGUAGES.some((language) => language.claims(path15));
|
|
18993
|
+
var languageOf = (path15) => MAP_LANGUAGES.find((language) => language.claims(path15));
|
|
18994
|
+
var mapLanguageOf = (path15) => languageOf(path15)?.id;
|
|
18957
18995
|
var npmPackage = (specifier) => {
|
|
18958
18996
|
if (specifier.startsWith("node:")) return "node:*";
|
|
18959
18997
|
const parts = specifier.split("/");
|
|
18960
18998
|
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? specifier;
|
|
18961
18999
|
};
|
|
18962
19000
|
var mapExternalImport = (sourcePath, specifier) => languageOf(sourcePath)?.importName?.(specifier) ?? npmPackage(specifier);
|
|
18963
|
-
var mapImportTarget = (
|
|
19001
|
+
var mapImportTarget = (path15) => languageOf(path15)?.importTarget?.(path15) ?? path15;
|
|
18964
19002
|
|
|
18965
19003
|
// src/project-map-view.ts
|
|
18966
19004
|
var MAP_VIEW_FORMAT = "PROJECT_MAP_VIEW_V1";
|
|
@@ -18999,10 +19037,10 @@ var notFound = () => {
|
|
|
18999
19037
|
};
|
|
19000
19038
|
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";
|
|
19001
19039
|
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.`;
|
|
19002
|
-
var within = (
|
|
19003
|
-
var parentDirectory = (
|
|
19004
|
-
const slash =
|
|
19005
|
-
return slash < 0 ? "." :
|
|
19040
|
+
var within = (path15, directory) => directory === "." || path15.startsWith(`${directory}/`);
|
|
19041
|
+
var parentDirectory = (path15) => {
|
|
19042
|
+
const slash = path15.lastIndexOf("/");
|
|
19043
|
+
return slash < 0 ? "." : path15.slice(0, slash);
|
|
19006
19044
|
};
|
|
19007
19045
|
var compareText2 = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
19008
19046
|
var byCount = ([leftName, left], [rightName, right]) => right - left || compareText2(leftName, rightName);
|
|
@@ -19076,7 +19114,7 @@ function pageBlocks(view, head, whole, offset, budget) {
|
|
|
19076
19114
|
if (offset === blocks.length) return materialize(0);
|
|
19077
19115
|
return mapQueryPage(blocks.length - offset, materialize, (page) => page, budget);
|
|
19078
19116
|
}
|
|
19079
|
-
var inModule = (
|
|
19117
|
+
var inModule = (path15, module) => module.direct ? parentDirectory(path15) === module.directory : within(path15, module.directory);
|
|
19080
19118
|
var moduleLabel = (module) => module.direct ? `${module.directory === "." ? "" : `${module.directory}/`}* (files directly here)` : `${module.directory}/`;
|
|
19081
19119
|
function childModules(module, files) {
|
|
19082
19120
|
if (module.direct) return [];
|
|
@@ -19131,9 +19169,9 @@ function mapProjectModules(entries) {
|
|
|
19131
19169
|
(entry) => entry.state === "TEXT" && mapCodePath(entry.path) && !mapTestPath(entry.path)
|
|
19132
19170
|
).map((entry) => entry.path)
|
|
19133
19171
|
);
|
|
19134
|
-
return (
|
|
19135
|
-
if (mapTestPath(
|
|
19136
|
-
const module = modules.find((candidate) => inModule(
|
|
19172
|
+
return (path15) => {
|
|
19173
|
+
if (mapTestPath(path15)) return void 0;
|
|
19174
|
+
const module = modules.find((candidate) => inModule(path15, candidate));
|
|
19137
19175
|
return module && moduleLabel(module);
|
|
19138
19176
|
};
|
|
19139
19177
|
}
|
|
@@ -19245,12 +19283,12 @@ function loadMemberCalls(store, version2) {
|
|
|
19245
19283
|
FROM project_map_relations
|
|
19246
19284
|
WHERE version_ref = ? AND to_ref IS NULL AND json_extract(relation_json, '$.kind') = 'CALLS'
|
|
19247
19285
|
AND json_extract(relation_json, '$.unresolvedReason') IN ('SYMBOL_NOT_RESOLVED', 'SYNTAX_ONLY')`).all(version2)) {
|
|
19248
|
-
const
|
|
19286
|
+
const path15 = String(row.path);
|
|
19249
19287
|
const target = String(row.target);
|
|
19250
19288
|
const name = MEMBER_NAME.exec(target)?.[1];
|
|
19251
|
-
const language = mapLanguageOf(
|
|
19289
|
+
const language = mapLanguageOf(path15);
|
|
19252
19290
|
if (!name || !language) continue;
|
|
19253
|
-
const call = { from: String(row.from_ref), path:
|
|
19291
|
+
const call = { from: String(row.from_ref), path: path15, line: Number(row.line), target };
|
|
19254
19292
|
const key = memberKey(language, name);
|
|
19255
19293
|
const known = calls.get(key);
|
|
19256
19294
|
if (known) known.push(call);
|
|
@@ -19300,15 +19338,15 @@ function loadCoverageNotes(store, version2) {
|
|
|
19300
19338
|
if (limit) limits.add(limit);
|
|
19301
19339
|
continue;
|
|
19302
19340
|
}
|
|
19303
|
-
if (!mapCodePath(gap.path)) continue;
|
|
19341
|
+
if (!mapCodePath(gap.path) && !mapMiniprogramTemplate(gap.path)) continue;
|
|
19304
19342
|
const codes = files.get(gap.path) ?? [];
|
|
19305
19343
|
if (!codes.includes(gap.code)) codes.push(gap.code);
|
|
19306
19344
|
files.set(gap.path, codes);
|
|
19307
19345
|
}
|
|
19308
|
-
for (const [
|
|
19346
|
+
for (const [path15, codes] of files)
|
|
19309
19347
|
if (codes.length > 1 && codes.includes("NOT_IN_PARSED_CONTEXT"))
|
|
19310
19348
|
files.set(
|
|
19311
|
-
|
|
19349
|
+
path15,
|
|
19312
19350
|
codes.filter((code) => code !== "NOT_IN_PARSED_CONTEXT")
|
|
19313
19351
|
);
|
|
19314
19352
|
return { files, limits: [...limits] };
|
|
@@ -19348,9 +19386,9 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19348
19386
|
const visiblePaths = new Set(visible.map((entry) => entry.path));
|
|
19349
19387
|
const code = visible.filter((entry) => entry.state === "TEXT" && mapCodePath(entry.path)).map((entry) => entry.path);
|
|
19350
19388
|
const modules = mapModules(directory, code);
|
|
19351
|
-
const moduleOf = (
|
|
19352
|
-
const outside = (
|
|
19353
|
-
const parts =
|
|
19389
|
+
const moduleOf = (path15) => modules.find((module) => inModule(path15, module));
|
|
19390
|
+
const outside = (path15) => {
|
|
19391
|
+
const parts = path15.split("/");
|
|
19354
19392
|
return `${parts.slice(0, Math.min(2, parts.length - 1)).join("/") || "."}/ (outside)`;
|
|
19355
19393
|
};
|
|
19356
19394
|
const moduleImports = /* @__PURE__ */ new Map();
|
|
@@ -19375,8 +19413,8 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19375
19413
|
const blocks = [];
|
|
19376
19414
|
if (modules.length > 1) {
|
|
19377
19415
|
const sizes = /* @__PURE__ */ new Map();
|
|
19378
|
-
for (const
|
|
19379
|
-
const module = moduleOf(
|
|
19416
|
+
for (const path15 of code) {
|
|
19417
|
+
const module = moduleOf(path15);
|
|
19380
19418
|
if (module) increment(sizes, moduleLabel(module));
|
|
19381
19419
|
}
|
|
19382
19420
|
blocks.push(
|
|
@@ -19405,18 +19443,18 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19405
19443
|
)}${packages.length > shown.length ? `, +${packages.length - shown.length} more` : ""}`
|
|
19406
19444
|
);
|
|
19407
19445
|
}
|
|
19408
|
-
const lineCount = (
|
|
19409
|
-
const file2 = facts.files.get(
|
|
19410
|
-
const gaps = coverage.files.get(
|
|
19446
|
+
const lineCount = (path15) => {
|
|
19447
|
+
const file2 = facts.files.get(path15);
|
|
19448
|
+
const gaps = coverage.files.get(path15) ?? [];
|
|
19411
19449
|
if (file2?.parsed === false) return `[not parsed${gaps.length ? `: ${gaps.join("; ")}` : ""}]`;
|
|
19412
19450
|
return `${file2 ? `${file2.lines}L` : "?L"}${gaps.length ? ` [${gaps.join("; ")}]` : ""}`;
|
|
19413
19451
|
};
|
|
19414
19452
|
const codeDirectories = /* @__PURE__ */ new Set();
|
|
19415
|
-
for (const
|
|
19416
|
-
for (let parent = parentDirectory(
|
|
19453
|
+
for (const path15 of code)
|
|
19454
|
+
for (let parent = parentDirectory(path15); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
|
|
19417
19455
|
codeDirectories.add(parent);
|
|
19418
|
-
const groupOf = (
|
|
19419
|
-
let group = parentDirectory(
|
|
19456
|
+
const groupOf = (path15) => {
|
|
19457
|
+
let group = parentDirectory(path15);
|
|
19420
19458
|
for (let parent = group; parent !== "." && parent !== directory && !codeDirectories.has(parent); parent = parentDirectory(parent))
|
|
19421
19459
|
group = parent;
|
|
19422
19460
|
return group;
|
|
@@ -19448,11 +19486,11 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19448
19486
|
]);
|
|
19449
19487
|
}
|
|
19450
19488
|
const detailed = [
|
|
19451
|
-
...code.map((
|
|
19452
|
-
const declarations2 = (facts.exported.get(
|
|
19489
|
+
...code.map((path15) => {
|
|
19490
|
+
const declarations2 = (facts.exported.get(path15) ?? []).map(({ text: text2 }) => text2);
|
|
19453
19491
|
return [
|
|
19454
|
-
|
|
19455
|
-
`${
|
|
19492
|
+
path15,
|
|
19493
|
+
`${path15} ${lineCount(path15)}${declarations2.length ? `: ${declarations2.join(", ")}` : ""}`
|
|
19456
19494
|
];
|
|
19457
19495
|
}),
|
|
19458
19496
|
...listedOther.map((entry) => [
|
|
@@ -19463,7 +19501,7 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19463
19501
|
];
|
|
19464
19502
|
const directories = /* @__PURE__ */ new Map();
|
|
19465
19503
|
for (const entry of [
|
|
19466
|
-
...code.map((
|
|
19504
|
+
...code.map((path15) => ({ path: path15, item: lineCount(path15) })),
|
|
19467
19505
|
...listedOther.map((entry2) => ({
|
|
19468
19506
|
path: entry2.path,
|
|
19469
19507
|
item: entry2.state === "TEXT" ? "" : `(${entry2.state})`
|
|
@@ -19491,10 +19529,10 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19491
19529
|
);
|
|
19492
19530
|
const text = visible.filter((entry) => entry.state === "TEXT").length;
|
|
19493
19531
|
const resolution = /* @__PURE__ */ new Map();
|
|
19494
|
-
for (const
|
|
19495
|
-
const counts = facts.calls.get(
|
|
19532
|
+
for (const path15 of code) {
|
|
19533
|
+
const counts = facts.calls.get(path15);
|
|
19496
19534
|
if (!counts) continue;
|
|
19497
|
-
const language = facts.files.get(
|
|
19535
|
+
const language = facts.files.get(path15)?.language ?? "unknown";
|
|
19498
19536
|
const total = resolution.get(language) ?? { resolved: 0, unresolved: 0, external: 0 };
|
|
19499
19537
|
total.resolved += counts.resolved;
|
|
19500
19538
|
total.unresolved += counts.unresolved;
|
|
@@ -19537,6 +19575,7 @@ var INCOMING = {
|
|
|
19537
19575
|
DECORATED_BY: "decorates"
|
|
19538
19576
|
};
|
|
19539
19577
|
var IMPORT_KINDS = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
19578
|
+
var shows = (relation) => relation.kind === "REFERENCES" && mapMiniprogramTemplate(relation.anchor.path);
|
|
19540
19579
|
var callerCoverage = (textSearch) => `Calls through dependency injection, framework routing, reflection or computed names are not mapped, so a complete view is not a complete caller list; confirm impact with project_find_references or ${textSearch}.`;
|
|
19541
19580
|
var SPECIAL_METHOD = /^__\w+__$/u;
|
|
19542
19581
|
var DeclarationGroups = class {
|
|
@@ -19552,10 +19591,11 @@ var DeclarationGroups = class {
|
|
|
19552
19591
|
prefixes;
|
|
19553
19592
|
showTests;
|
|
19554
19593
|
memberCalls;
|
|
19555
|
-
visible(
|
|
19556
|
-
return mapPathAllowed(
|
|
19594
|
+
visible(path15) {
|
|
19595
|
+
return mapPathAllowed(path15, this.prefixes) && (this.showTests || !mapTestPath(path15));
|
|
19557
19596
|
}
|
|
19558
19597
|
entry(object2, imported = false) {
|
|
19598
|
+
if (mapMiniprogramTemplate(object2.anchor.path)) return "(template)";
|
|
19559
19599
|
if (mapIsModule(object2)) return imported ? "(file)" : "(module scope)";
|
|
19560
19600
|
return `${this.graph.qualifiedName(object2.id)} ${mapDeclarationLabel(object2)}`;
|
|
19561
19601
|
}
|
|
@@ -19597,11 +19637,11 @@ var DeclarationGroups = class {
|
|
|
19597
19637
|
value.lines.push(line);
|
|
19598
19638
|
aggregates.set(key, value);
|
|
19599
19639
|
};
|
|
19600
|
-
const dispatch = (arrow, label, ref2,
|
|
19640
|
+
const dispatch = (arrow, label, ref2, path15, line) => {
|
|
19601
19641
|
const other = graph.object(graph.owner(ref2));
|
|
19602
19642
|
if (owned.has(other.id)) return;
|
|
19603
|
-
if (!this.visible(
|
|
19604
|
-
if (mapPathAllowed(
|
|
19643
|
+
if (!this.visible(path15)) {
|
|
19644
|
+
if (mapPathAllowed(path15, this.prefixes)) omittedTests++;
|
|
19605
19645
|
return;
|
|
19606
19646
|
}
|
|
19607
19647
|
add(arrow, label, other, line);
|
|
@@ -19665,7 +19705,7 @@ var DeclarationGroups = class {
|
|
|
19665
19705
|
else
|
|
19666
19706
|
add(
|
|
19667
19707
|
"\u2192",
|
|
19668
|
-
OUTGOING[relation.kind] ?? relation.kind.toLowerCase(),
|
|
19708
|
+
shows(relation) ? "shows" : OUTGOING[relation.kind] ?? relation.kind.toLowerCase(),
|
|
19669
19709
|
other,
|
|
19670
19710
|
relation.anchor.startLine,
|
|
19671
19711
|
relation.argument
|
|
@@ -19690,7 +19730,7 @@ var DeclarationGroups = class {
|
|
|
19690
19730
|
if (mapPathAllowed(relation.anchor.path, this.prefixes)) omittedTests++;
|
|
19691
19731
|
continue;
|
|
19692
19732
|
}
|
|
19693
|
-
const label = relation.kind === "CALLS" && focus.kind === "CLASS" ? "instantiated by" : INCOMING[relation.kind] ?? relation.kind.toLowerCase();
|
|
19733
|
+
const label = relation.kind === "CALLS" && focus.kind === "CLASS" ? "instantiated by" : shows(relation) ? "shown by" : INCOMING[relation.kind] ?? relation.kind.toLowerCase();
|
|
19694
19734
|
add(
|
|
19695
19735
|
"\u2190",
|
|
19696
19736
|
label,
|
|
@@ -19758,7 +19798,7 @@ var DeclarationGroups = class {
|
|
|
19758
19798
|
else files2.set(call.path, [item]);
|
|
19759
19799
|
}
|
|
19760
19800
|
lines.push(
|
|
19761
|
-
` \u2190 possible callers by name: ${[...files2].map(([
|
|
19801
|
+
` \u2190 possible callers by name: ${[...files2].map(([path15, items]) => `${path15}: ${items.join(", ")}`).join("; ")}${inTests}`
|
|
19762
19802
|
);
|
|
19763
19803
|
} else if (possibleInTests)
|
|
19764
19804
|
lines.push(` \u2190 possible callers by name: ${possibleInTests} in test files (includeTests)`);
|
|
@@ -19790,18 +19830,18 @@ var DeclarationGroups = class {
|
|
|
19790
19830
|
);
|
|
19791
19831
|
}
|
|
19792
19832
|
if (omittedTests) lines.push(` omitted: ${omittedTests} test relationships (includeTests)`);
|
|
19793
|
-
const neighbors = [...aggregates.values()].map((aggregate) => aggregate.other).filter((other) => !mapIsModule(other)).map((other) => other.id);
|
|
19833
|
+
const neighbors = [...aggregates.values()].map((aggregate) => aggregate.other).filter((other) => !mapIsModule(other) || mapMiniprogramTemplate(other.anchor.path)).map((other) => other.id);
|
|
19794
19834
|
return { lines, neighbors: [...new Set(neighbors)] };
|
|
19795
19835
|
}
|
|
19796
19836
|
};
|
|
19797
|
-
function fileView(store, coverage, graph, input,
|
|
19798
|
-
const entry = store.getEntry(input.version,
|
|
19799
|
-
if (!entry || !mapPathAllowed(
|
|
19800
|
-
const showTests = input.includeTests === true || mapTestPath(
|
|
19801
|
-
const module = mapCodePath(
|
|
19802
|
-
const gaps = coverage.files.get(
|
|
19837
|
+
function fileView(store, coverage, graph, input, path15, prefixes) {
|
|
19838
|
+
const entry = store.getEntry(input.version, path15);
|
|
19839
|
+
if (!entry || !mapPathAllowed(path15, prefixes)) return notFound();
|
|
19840
|
+
const showTests = input.includeTests === true || mapTestPath(path15);
|
|
19841
|
+
const module = mapCodePath(path15) ? graph.objectsAt(path15).find((object2) => mapIsModule(object2)) : mapMiniprogramTemplate(path15) ? graph.objectsAt(path15).find((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : void 0;
|
|
19842
|
+
const gaps = coverage.files.get(path15) ?? [];
|
|
19803
19843
|
const head = [
|
|
19804
|
-
`PROJECT MAP \xB7 FILE ${
|
|
19844
|
+
`PROJECT MAP \xB7 FILE ${path15} \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`}`
|
|
19805
19845
|
];
|
|
19806
19846
|
if (!module || entry.state !== "TEXT")
|
|
19807
19847
|
return pageBlocks("FILE", head, [], input.offset ?? 0, input.outputBudget);
|
|
@@ -19821,7 +19861,7 @@ function fileView(store, coverage, graph, input, path14, prefixes) {
|
|
|
19821
19861
|
tags.set(relation.from, list);
|
|
19822
19862
|
}
|
|
19823
19863
|
const describe3 = (object2) => [
|
|
19824
|
-
`${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path ===
|
|
19864
|
+
`${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path15 ? "" : ` (${object2.anchor.path})`}`,
|
|
19825
19865
|
...tags.get(object2.id) ?? []
|
|
19826
19866
|
].join(" ");
|
|
19827
19867
|
const declarations2 = [];
|
|
@@ -19836,11 +19876,11 @@ function fileView(store, coverage, graph, input, path14, prefixes) {
|
|
|
19836
19876
|
);
|
|
19837
19877
|
}
|
|
19838
19878
|
const elsewhere = /* @__PURE__ */ new Map();
|
|
19839
|
-
for (const object2 of graph.objectsAt(
|
|
19879
|
+
for (const object2 of graph.objectsAt(path15)) {
|
|
19840
19880
|
const parent = mapIsModule(object2) ? void 0 : graph.parent(object2.id);
|
|
19841
19881
|
if (parent === void 0 || !graph.isAddressable(object2)) continue;
|
|
19842
19882
|
const container = graph.object(parent);
|
|
19843
|
-
if (mapIsModule(container) || container.anchor.path ===
|
|
19883
|
+
if (mapIsModule(container) || container.anchor.path === path15) continue;
|
|
19844
19884
|
const into = elsewhere.get(parent);
|
|
19845
19885
|
if (into) into.push(object2);
|
|
19846
19886
|
else elsewhere.set(parent, [object2]);
|
|
@@ -19854,7 +19894,7 @@ function fileView(store, coverage, graph, input, path14, prefixes) {
|
|
|
19854
19894
|
if (declarations2.length) blocks.push(["DECLARATIONS (* exported)", ...declarations2].join("\n"));
|
|
19855
19895
|
const imports2 = /* @__PURE__ */ new Set();
|
|
19856
19896
|
const external = /* @__PURE__ */ new Set();
|
|
19857
|
-
const fileObjects = graph.objectsAt(
|
|
19897
|
+
const fileObjects = graph.objectsAt(path15).map((object2) => object2.id);
|
|
19858
19898
|
for (const relation of graph.relationsFrom(fileObjects)) {
|
|
19859
19899
|
if (!IMPORT_KINDS.has(relation.kind)) continue;
|
|
19860
19900
|
if (relation.to === void 0) external.add(relation.target);
|
|
@@ -19865,8 +19905,8 @@ function fileView(store, coverage, graph, input, path14, prefixes) {
|
|
|
19865
19905
|
}
|
|
19866
19906
|
const importers = /* @__PURE__ */ new Set();
|
|
19867
19907
|
const testImporters = /* @__PURE__ */ new Set();
|
|
19868
|
-
const imported = mapImportTarget(
|
|
19869
|
-
const packageModules = imported ===
|
|
19908
|
+
const imported = mapImportTarget(path15);
|
|
19909
|
+
const packageModules = imported === path15 ? [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);
|
|
19870
19910
|
for (const relation of graph.relationsTo(packageModules)) {
|
|
19871
19911
|
if (!IMPORT_KINDS.has(relation.kind)) continue;
|
|
19872
19912
|
const source = relation.anchor.path;
|
|
@@ -19894,16 +19934,16 @@ function fileView(store, coverage, graph, input, path14, prefixes) {
|
|
|
19894
19934
|
if (scope.length) blocks.push(["MODULE SCOPE (top-level statements)", ...scope].join("\n"));
|
|
19895
19935
|
return pageBlocks("FILE", head, blocks, input.offset ?? 0, input.outputBudget);
|
|
19896
19936
|
}
|
|
19897
|
-
function declarationView(graph, input,
|
|
19937
|
+
function declarationView(graph, input, path15, prefixes, memberCalls) {
|
|
19898
19938
|
const requested = input.depth ?? 1;
|
|
19899
19939
|
if (!Number.isSafeInteger(requested) || requested < 1 || requested > MAP_VIEW_LIMITS.directedDepth)
|
|
19900
19940
|
return invalid2();
|
|
19901
19941
|
const both = (input.direction ?? "BOTH") === "BOTH";
|
|
19902
19942
|
const depth = both ? Math.min(requested, MAP_VIEW_LIMITS.bothDepth) : requested;
|
|
19903
19943
|
const { name, line } = input;
|
|
19904
|
-
const selected = mapSelectDeclarations(graph,
|
|
19944
|
+
const selected = mapSelectDeclarations(graph, path15, name, line);
|
|
19905
19945
|
if (!selected.length) return notFound();
|
|
19906
|
-
const showTests = input.includeTests === true || mapTestPath(
|
|
19946
|
+
const showTests = input.includeTests === true || mapTestPath(path15);
|
|
19907
19947
|
const groups = new DeclarationGroups(graph, input, prefixes, showTests, memberCalls);
|
|
19908
19948
|
const blocks = [];
|
|
19909
19949
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -19951,7 +19991,7 @@ function declarationView(graph, input, path14, prefixes, memberCalls) {
|
|
|
19951
19991
|
);
|
|
19952
19992
|
}
|
|
19953
19993
|
const head = [
|
|
19954
|
-
`PROJECT MAP \xB7 DECLARATION ${
|
|
19994
|
+
`PROJECT MAP \xB7 DECLARATION ${path15}${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"}`,
|
|
19955
19995
|
...truncated ? [`Expansion stopped at ${MAP_VIEW_LIMITS.declarations} declarations.`] : [],
|
|
19956
19996
|
...(input.direction ?? "BOTH") === "OUTGOING" ? [] : [callerCoverage(input.textSearch ?? DEFAULT_TEXT_SEARCH)]
|
|
19957
19997
|
];
|
|
@@ -20078,10 +20118,10 @@ var ProjectMapQuery = class {
|
|
|
20078
20118
|
view(input, signal) {
|
|
20079
20119
|
this.requireReadableMap(input.version, signal);
|
|
20080
20120
|
const { offset, prefixes } = admission(input);
|
|
20081
|
-
const
|
|
20121
|
+
const path15 = normalizeProjectEvidencePath(input.path, true) || ".";
|
|
20082
20122
|
const view = mapView(
|
|
20083
20123
|
this.store,
|
|
20084
|
-
{ ...input, path:
|
|
20124
|
+
{ ...input, path: path15, offset, allowedPathPrefixes: prefixes },
|
|
20085
20125
|
this.views
|
|
20086
20126
|
);
|
|
20087
20127
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
@@ -20281,13 +20321,13 @@ var ProjectMapSourceReader = class _ProjectMapSourceReader {
|
|
|
20281
20321
|
*/
|
|
20282
20322
|
async readAll(expected) {
|
|
20283
20323
|
if (this.signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
20284
|
-
const paths = expected.map(({ path:
|
|
20285
|
-
assertProjectEvidencePathNotSensitive(
|
|
20286
|
-
if (isProjectEvidenceTraversalExcluded(
|
|
20324
|
+
const paths = expected.map(({ path: path15 }) => {
|
|
20325
|
+
assertProjectEvidencePathNotSensitive(path15);
|
|
20326
|
+
if (isProjectEvidenceTraversalExcluded(path15))
|
|
20287
20327
|
throw new ProjectEvidenceError("PROJECT_FILE_NOT_ALLOWED", false);
|
|
20288
|
-
return
|
|
20328
|
+
return path15;
|
|
20289
20329
|
});
|
|
20290
|
-
const results = this.commit ? await this.commit.readAll(paths) : await concurrently(paths, (
|
|
20330
|
+
const results = this.commit ? await this.commit.readAll(paths) : await concurrently(paths, (path15) => this.session.captureFile(path15));
|
|
20291
20331
|
for (const [index, { entry }] of results.entries()) {
|
|
20292
20332
|
const wanted = expected[index];
|
|
20293
20333
|
if (entry.state !== wanted?.state || entry.contentDigest !== wanted.contentDigest || entry.byteLength !== wanted.byteLength)
|
|
@@ -20998,7 +21038,7 @@ var CodeIndexStore = class {
|
|
|
20998
21038
|
const staged = this.stageUnits(buildRef, paths, linked);
|
|
20999
21039
|
const reused = linked ? this.database.prepare(`SELECT path, unit_ref FROM project_map_version_units
|
|
21000
21040
|
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) })) : [];
|
|
21001
|
-
if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path:
|
|
21041
|
+
if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path: path15 }) => !paths.has(path15)) || staged.some(({ path: path15 }) => linked?.paths.has(path15)))
|
|
21002
21042
|
throw new MapReplayConflict();
|
|
21003
21043
|
const units = [...staged, ...reused].sort(
|
|
21004
21044
|
(left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
|
|
@@ -21049,7 +21089,7 @@ var CodeIndexStore = class {
|
|
|
21049
21089
|
const member = this.database.prepare(
|
|
21050
21090
|
"INSERT INTO project_map_version_units VALUES (?, ?, ?)"
|
|
21051
21091
|
);
|
|
21052
|
-
for (const { path:
|
|
21092
|
+
for (const { path: path15, unit } of reused) member.run(version2.version, path15, unit);
|
|
21053
21093
|
this.database.prepare("INSERT INTO project_map_coverage VALUES (?, ?)").run(version2.version, canonicalJson(coverage));
|
|
21054
21094
|
}
|
|
21055
21095
|
this.database.exec("COMMIT");
|
|
@@ -21113,7 +21153,7 @@ var CodeIndexStore = class {
|
|
|
21113
21153
|
corrupt2();
|
|
21114
21154
|
}
|
|
21115
21155
|
if (linked) {
|
|
21116
|
-
const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((
|
|
21156
|
+
const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((path15) => !linked.paths.has(path15));
|
|
21117
21157
|
if (database.prepare(`SELECT 1 FROM project_map_objects gone
|
|
21118
21158
|
WHERE gone.version_ref = ? AND gone.path IN (SELECT value FROM json_each(?))
|
|
21119
21159
|
AND gone.entity_ref NOT IN (SELECT entity_ref FROM project_map_publish_objects)
|
|
@@ -21138,17 +21178,17 @@ var CodeIndexStore = class {
|
|
|
21138
21178
|
const units = [];
|
|
21139
21179
|
for (const row of database.prepare(`SELECT path FROM project_map_publish_objects
|
|
21140
21180
|
UNION SELECT path FROM project_map_publish_relations ORDER BY path`).all()) {
|
|
21141
|
-
const
|
|
21142
|
-
const hash2 = createHash3("sha256").update(
|
|
21181
|
+
const path15 = String(row.path);
|
|
21182
|
+
const hash2 = createHash3("sha256").update(path15).update("\0");
|
|
21143
21183
|
for (const [mark, statement] of [
|
|
21144
21184
|
["object", objects2],
|
|
21145
21185
|
["relation", relations],
|
|
21146
21186
|
["note", pathNotes]
|
|
21147
21187
|
])
|
|
21148
|
-
for (const fact of statement.all(
|
|
21188
|
+
for (const fact of statement.all(path15))
|
|
21149
21189
|
for (const value of Object.values(fact))
|
|
21150
21190
|
hash2.update(mark).update("\0").update(String(value)).update("\0");
|
|
21151
|
-
units.push({ path:
|
|
21191
|
+
units.push({ path: path15, unit: hash2.digest("hex") });
|
|
21152
21192
|
}
|
|
21153
21193
|
return units;
|
|
21154
21194
|
}
|
|
@@ -21166,13 +21206,13 @@ var CodeIndexStore = class {
|
|
|
21166
21206
|
"INSERT INTO project_map_unit_notes SELECT ?, * FROM project_map_publish_notes WHERE path = ?"
|
|
21167
21207
|
);
|
|
21168
21208
|
const member = database.prepare("INSERT INTO project_map_version_units VALUES (?, ?, ?)");
|
|
21169
|
-
for (const { path:
|
|
21170
|
-
if (insertUnit.run(unit,
|
|
21171
|
-
unitObjects.run(unit,
|
|
21172
|
-
unitRelations.run(unit,
|
|
21173
|
-
unitNotes.run(unit,
|
|
21209
|
+
for (const { path: path15, unit } of units) {
|
|
21210
|
+
if (insertUnit.run(unit, path15).changes) {
|
|
21211
|
+
unitObjects.run(unit, path15);
|
|
21212
|
+
unitRelations.run(unit, path15);
|
|
21213
|
+
unitNotes.run(unit, path15);
|
|
21174
21214
|
}
|
|
21175
|
-
member.run(version2,
|
|
21215
|
+
member.run(version2, path15, unit);
|
|
21176
21216
|
}
|
|
21177
21217
|
}
|
|
21178
21218
|
/**
|
|
@@ -21428,21 +21468,21 @@ var contextFiles = (context) => [
|
|
|
21428
21468
|
function replayableContexts(parent, digests) {
|
|
21429
21469
|
const sharing = /* @__PURE__ */ new Map();
|
|
21430
21470
|
for (const [ref, { context }] of parent.contexts)
|
|
21431
|
-
for (const
|
|
21432
|
-
const refs = sharing.get(
|
|
21471
|
+
for (const path15 of contextFiles(context)) {
|
|
21472
|
+
const refs = sharing.get(path15) ?? /* @__PURE__ */ new Set();
|
|
21433
21473
|
refs.add(ref);
|
|
21434
|
-
sharing.set(
|
|
21474
|
+
sharing.set(path15, refs);
|
|
21435
21475
|
}
|
|
21436
21476
|
const unchanged = /* @__PURE__ */ new Set();
|
|
21437
21477
|
for (const [ref, { context }] of parent.contexts)
|
|
21438
21478
|
if (contextFiles(context).every(
|
|
21439
|
-
(
|
|
21479
|
+
(path15) => digests.get(path15) !== void 0 && digests.get(path15) === parent.entries.get(path15)
|
|
21440
21480
|
))
|
|
21441
21481
|
unchanged.add(ref);
|
|
21442
21482
|
const replayable = /* @__PURE__ */ new Set();
|
|
21443
21483
|
for (const [ref, { context }] of parent.contexts)
|
|
21444
21484
|
if (unchanged.has(ref) && contextFiles(context).every(
|
|
21445
|
-
(
|
|
21485
|
+
(path15) => [...sharing.get(path15) ?? []].every((other) => unchanged.has(other))
|
|
21446
21486
|
))
|
|
21447
21487
|
replayable.add(ref);
|
|
21448
21488
|
return { replayable, sharing };
|
|
@@ -21475,8 +21515,8 @@ var ProjectMapAnalyzer = class {
|
|
|
21475
21515
|
languages;
|
|
21476
21516
|
observe;
|
|
21477
21517
|
id;
|
|
21478
|
-
claims(
|
|
21479
|
-
return this.languages.some((language) => language.claims(
|
|
21518
|
+
claims(path15) {
|
|
21519
|
+
return this.languages.some((language) => language.claims(path15));
|
|
21480
21520
|
}
|
|
21481
21521
|
references(input, reference, signal) {
|
|
21482
21522
|
const language = this.languages.find((language2) => language2.claims(reference.targetPath));
|
|
@@ -21516,7 +21556,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21516
21556
|
const reuse = (contextRef2, request, files2) => {
|
|
21517
21557
|
const digest = digestValue({
|
|
21518
21558
|
request,
|
|
21519
|
-
files: files2.map((
|
|
21559
|
+
files: files2.map((path15) => [path15, digests.get(path15) ?? null])
|
|
21520
21560
|
});
|
|
21521
21561
|
requests.set(contextRef2, digest);
|
|
21522
21562
|
if (!parent || !replayable.has(contextRef2)) return void 0;
|
|
@@ -21555,7 +21595,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21555
21595
|
const ref = analysis.contexts[0]?.ref ?? "";
|
|
21556
21596
|
if (options?.linked?.length) {
|
|
21557
21597
|
if (!parent || analysis.contexts.length !== 1) return invalidParent();
|
|
21558
|
-
for (const
|
|
21598
|
+
for (const path15 of options.linked) linked.add(path15);
|
|
21559
21599
|
this.observe?.({
|
|
21560
21600
|
operation: "LINK",
|
|
21561
21601
|
phase: "FINISHED",
|
|
@@ -21582,7 +21622,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21582
21622
|
});
|
|
21583
21623
|
for (const file2 of analysis.parsedFiles) parsed.add(file2);
|
|
21584
21624
|
const staged = factPaths(analysis);
|
|
21585
|
-
for (const
|
|
21625
|
+
for (const path15 of staged) stagedPaths.add(path15);
|
|
21586
21626
|
for (const context of analysis.contexts) {
|
|
21587
21627
|
for (const file2 of context.configurationFiles) configurationInputs.add(file2);
|
|
21588
21628
|
if (!replayed.has(context.ref))
|
|
@@ -21611,7 +21651,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21611
21651
|
accept,
|
|
21612
21652
|
reuse,
|
|
21613
21653
|
previous,
|
|
21614
|
-
configuration: (
|
|
21654
|
+
configuration: (path15) => configurationInputs.add(path15),
|
|
21615
21655
|
observe: this.observe
|
|
21616
21656
|
},
|
|
21617
21657
|
signal
|
|
@@ -21648,12 +21688,12 @@ var ProjectMapAnalyzer = class {
|
|
|
21648
21688
|
if (files.objects.length) accept(files);
|
|
21649
21689
|
if (parent && (replayed.size || linked.size)) {
|
|
21650
21690
|
for (const ref of replayed.keys())
|
|
21651
|
-
for (const
|
|
21652
|
-
if (analyzedFiles.has(
|
|
21691
|
+
for (const path15 of contextFiles(parent.contexts.get(ref)?.context ?? invalidParent()))
|
|
21692
|
+
if (analyzedFiles.has(path15) || [...sharing.get(path15) ?? []].some((other) => !replayed.has(other)))
|
|
21653
21693
|
throw new MapReplayConflict();
|
|
21654
|
-
for (const paths of replayed.values()) for (const
|
|
21655
|
-
for (const
|
|
21656
|
-
if (analyzedFiles.has(
|
|
21694
|
+
for (const paths of replayed.values()) for (const path15 of paths) linked.add(path15);
|
|
21695
|
+
for (const path15 of linked)
|
|
21696
|
+
if (analyzedFiles.has(path15) || stagedPaths.has(path15)) throw new MapReplayConflict();
|
|
21657
21697
|
parent.link([...linked]);
|
|
21658
21698
|
}
|
|
21659
21699
|
result.parsedFiles = [...parsed].sort();
|
|
@@ -21948,8 +21988,8 @@ var CodeIndex = class {
|
|
|
21948
21988
|
for (const entry of this.store.listEntries(candidate))
|
|
21949
21989
|
if (entry.contentDigest) entries2.set(entry.path, entry.contentDigest);
|
|
21950
21990
|
let changed = 0;
|
|
21951
|
-
for (const [
|
|
21952
|
-
for (const
|
|
21991
|
+
for (const [path15, digest] of digests) if (entries2.get(path15) !== digest) changed++;
|
|
21992
|
+
for (const path15 of entries2.keys()) if (!digests.has(path15)) changed++;
|
|
21953
21993
|
if (!best || changed < best.changed) best = { version: candidate, entries: entries2, changed };
|
|
21954
21994
|
}
|
|
21955
21995
|
if (!best) return void 0;
|
|
@@ -22090,7 +22130,7 @@ var CodeIndex = class {
|
|
|
22090
22130
|
// src/project-map-changes.ts
|
|
22091
22131
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
22092
22132
|
import { readFile } from "node:fs/promises";
|
|
22093
|
-
import
|
|
22133
|
+
import path10 from "node:path";
|
|
22094
22134
|
|
|
22095
22135
|
// src/project-map-clients.ts
|
|
22096
22136
|
var CLIENT_FILES = [
|
|
@@ -22125,16 +22165,16 @@ var LITERAL = /(["'`])((?:\\.|(?!\1)[^\\])*)\1/gu;
|
|
|
22125
22165
|
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;
|
|
22126
22166
|
var LIMIT = Object.freeze({ routes: 40, clients: 5 });
|
|
22127
22167
|
var ROUTE = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
|
|
22128
|
-
var segments = (
|
|
22168
|
+
var segments = (path15) => path15.split("/").filter(Boolean).map((text) => ({ text, param: PARAM.test(text) || /[{}$<>%]/u.test(text) }));
|
|
22129
22169
|
var routeSegments = (label) => segments(label.slice(label.indexOf("/")));
|
|
22130
22170
|
function requestedPath(literal3, joined) {
|
|
22131
22171
|
const match = /^(?:https?:\/\/[^/\s]+|(?:\$\{[^}]*\})+|@\{|redirect:|forward:)?(\/[^\s?#()"'`,;|]*)/u.exec(
|
|
22132
22172
|
literal3
|
|
22133
22173
|
) ?? void 0;
|
|
22134
|
-
const
|
|
22135
|
-
if (!
|
|
22136
|
-
const parts = segments(
|
|
22137
|
-
if (joined &&
|
|
22174
|
+
const path15 = match?.[1];
|
|
22175
|
+
if (!path15 || path15.startsWith("//") || path15.length < 3) return void 0;
|
|
22176
|
+
const parts = segments(path15);
|
|
22177
|
+
if (joined && path15.endsWith("/")) parts.push({ text: "*", param: true });
|
|
22138
22178
|
return parts;
|
|
22139
22179
|
}
|
|
22140
22180
|
var same = (route, requested) => route.param || !requested.param && route.text === requested.text;
|
|
@@ -22242,9 +22282,9 @@ var routeClientsLine = ({ route, removed, clients }) => `${JSON.stringify(route)
|
|
|
22242
22282
|
|
|
22243
22283
|
// src/project-map-dependencies.ts
|
|
22244
22284
|
var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
22245
|
-
function imports(graph,
|
|
22285
|
+
function imports(graph, path15) {
|
|
22246
22286
|
const found = [];
|
|
22247
|
-
for (const relation of graph.relationsFrom(graph.objectsAt(
|
|
22287
|
+
for (const relation of graph.relationsFrom(graph.objectsAt(path15).map((object2) => object2.id)))
|
|
22248
22288
|
if (IMPORT_KINDS2.has(relation.kind) && relation.to !== void 0)
|
|
22249
22289
|
found.push({
|
|
22250
22290
|
target: graph.object(relation.to).anchor.path,
|
|
@@ -22261,9 +22301,9 @@ function pathBetween(edges, from, to) {
|
|
|
22261
22301
|
if (via.has(target)) continue;
|
|
22262
22302
|
via.set(target, module);
|
|
22263
22303
|
if (target === to) {
|
|
22264
|
-
const
|
|
22265
|
-
for (let step = module; step !== from; step = via.get(step) ?? from)
|
|
22266
|
-
return [from, ...
|
|
22304
|
+
const path15 = [to];
|
|
22305
|
+
for (let step = module; step !== from; step = via.get(step) ?? from) path15.unshift(step);
|
|
22306
|
+
return [from, ...path15];
|
|
22267
22307
|
}
|
|
22268
22308
|
next.push(target);
|
|
22269
22309
|
}
|
|
@@ -22326,7 +22366,7 @@ function newModuleDependencies(store, cache, working, base, files) {
|
|
|
22326
22366
|
|
|
22327
22367
|
// src/project-map-names.ts
|
|
22328
22368
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
22329
|
-
import
|
|
22369
|
+
import path9 from "node:path";
|
|
22330
22370
|
var CONFIG_KEY = /^\s*(?:export\s+|-\s+)?["']?([A-Za-z_][\w.-]*)["']?\s*(?:=|:(?:\s|$))/u;
|
|
22331
22371
|
var CODE_READS = [
|
|
22332
22372
|
// process.env.NAME, import.meta.env.NAME
|
|
@@ -22402,7 +22442,7 @@ async function strandedNames(project, diff, files, configuration, git2, options)
|
|
|
22402
22442
|
} else for (const name of codeReads(line, file2.path)) names2.add(name);
|
|
22403
22443
|
let text;
|
|
22404
22444
|
try {
|
|
22405
|
-
text = readFileSync2(
|
|
22445
|
+
text = readFileSync2(path9.join(project, file2.path), "utf8");
|
|
22406
22446
|
} catch {
|
|
22407
22447
|
continue;
|
|
22408
22448
|
}
|
|
@@ -22483,9 +22523,9 @@ var KEYWORDS = new Set(
|
|
|
22483
22523
|
);
|
|
22484
22524
|
var ROWS = `SELECT entity_ref AS id, path, name, kind, object_json AS object
|
|
22485
22525
|
FROM project_map_objects WHERE version_ref = ? AND kind <> 'PROPERTY'`;
|
|
22486
|
-
function rows(store, version2,
|
|
22487
|
-
const statement = store.database.prepare(
|
|
22488
|
-
return (
|
|
22526
|
+
function rows(store, version2, path15) {
|
|
22527
|
+
const statement = store.database.prepare(path15 === void 0 ? ROWS : `${ROWS} AND path = ?`);
|
|
22528
|
+
return (path15 === void 0 ? statement.all(version2) : statement.all(version2, path15)).map((row) => {
|
|
22489
22529
|
const { anchor } = JSON.parse(String(row.object));
|
|
22490
22530
|
return {
|
|
22491
22531
|
id: String(row.id),
|
|
@@ -22526,10 +22566,10 @@ function lineWords(line) {
|
|
|
22526
22566
|
}
|
|
22527
22567
|
var within2 = (lines, declaration) => lines.some(([from, to]) => from <= declaration.startLine && declaration.endLine <= to);
|
|
22528
22568
|
async function similarCode(store, working, base, files, read) {
|
|
22529
|
-
const code = (
|
|
22569
|
+
const code = (path15) => mapCodePath(path15) !== void 0 && !mapTestPath(path15);
|
|
22530
22570
|
const changed = files.filter((file2) => file2.status !== "DELETED" && code(file2.path));
|
|
22531
22571
|
if (!changed.length) return [];
|
|
22532
|
-
const names = (version2,
|
|
22572
|
+
const names = (version2, path15) => new Set(declarations(rows(store, version2, path15)).map((item) => item.qualifiedName));
|
|
22533
22573
|
const movedOut = /* @__PURE__ */ new Set();
|
|
22534
22574
|
if (base !== void 0)
|
|
22535
22575
|
for (const file2 of files) {
|
|
@@ -22555,10 +22595,10 @@ async function similarCode(store, working, base, files, read) {
|
|
|
22555
22595
|
}
|
|
22556
22596
|
const all = [];
|
|
22557
22597
|
await Promise.all(
|
|
22558
|
-
[...byPath].map(async ([
|
|
22598
|
+
[...byPath].map(async ([path15, inFile]) => {
|
|
22559
22599
|
const found2 = declarations(inFile).filter(eligible);
|
|
22560
22600
|
if (!found2.length) return;
|
|
22561
|
-
const text = await read(
|
|
22601
|
+
const text = await read(path15);
|
|
22562
22602
|
if (text === void 0) return;
|
|
22563
22603
|
const lines = text.split("\n").map(lineWords);
|
|
22564
22604
|
for (const declaration of found2) {
|
|
@@ -22692,9 +22732,9 @@ async function readMapChanges(project, base, signal) {
|
|
|
22692
22732
|
...file2,
|
|
22693
22733
|
baseText: (await git.run(["show", `${commit}:${file2.basePath}`], gitOptions(project, signal))).stdout.toString("utf8")
|
|
22694
22734
|
};
|
|
22695
|
-
const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((
|
|
22696
|
-
for (const
|
|
22697
|
-
files.push({ path:
|
|
22735
|
+
const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((path15) => path15 && !inExcludedDirectory(path15));
|
|
22736
|
+
for (const path15 of untracked)
|
|
22737
|
+
files.push({ path: path15, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
|
|
22698
22738
|
const stranded = await strandedNames(
|
|
22699
22739
|
project,
|
|
22700
22740
|
diff,
|
|
@@ -22770,9 +22810,9 @@ var NON_CODE = [
|
|
|
22770
22810
|
],
|
|
22771
22811
|
[/(?:^|\/)migrations?\/|\.sql$/iu, "database migration or schema"],
|
|
22772
22812
|
[/(?:^|\/)\.env[^/]*$|\.(?:ya?ml|toml|ini|properties|conf|cfg)$/iu, "configuration"],
|
|
22773
|
-
[/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte)$/iu, "template"]
|
|
22813
|
+
[/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte|wxml)$/iu, "template"]
|
|
22774
22814
|
];
|
|
22775
|
-
var nonCodeKind = (
|
|
22815
|
+
var nonCodeKind = (path15) => NON_CODE.find(([pattern]) => pattern.test(path15))?.[1];
|
|
22776
22816
|
var LIMITS = Object.freeze({ depth: 8, declarations: 800, changed: 200, chain: 3, byName: 40 });
|
|
22777
22817
|
var CALLER_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES"]);
|
|
22778
22818
|
var NAMING_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES", "EXTENDS", "IMPLEMENTS"]);
|
|
@@ -22804,9 +22844,10 @@ var Tracer = class {
|
|
|
22804
22844
|
/** Test support files that call the changed code; the tests beside and below them may use it. */
|
|
22805
22845
|
support = /* @__PURE__ */ new Set();
|
|
22806
22846
|
name = (ref) => this.graph.qualifiedName(ref);
|
|
22847
|
+
// A module is named by its path alone.
|
|
22807
22848
|
where = (ref) => {
|
|
22808
22849
|
const object2 = this.graph.object(ref);
|
|
22809
|
-
return `${object2.anchor.path}: ${this.name(ref)}`;
|
|
22850
|
+
return mapIsModule(object2) ? object2.anchor.path : `${object2.anchor.path}: ${this.name(ref)}`;
|
|
22810
22851
|
};
|
|
22811
22852
|
/** Follows callers up from the given declarations, recording entry points and tests. */
|
|
22812
22853
|
trace(starts) {
|
|
@@ -22877,7 +22918,7 @@ var Tracer = class {
|
|
|
22877
22918
|
if (this.callerCount.get(reached.ref) !== 0) continue;
|
|
22878
22919
|
const object2 = this.graph.object(reached.ref);
|
|
22879
22920
|
if (testCode(object2.anchor.path) || this.routes.has(reached.ref)) continue;
|
|
22880
|
-
if (reached.depth === 0) {
|
|
22921
|
+
if (reached.depth === 0 && !mapMiniprogramTemplate(object2.anchor.path)) {
|
|
22881
22922
|
const uses = this.usesWithoutCalls(reached.ref);
|
|
22882
22923
|
this.unclear.push(
|
|
22883
22924
|
uses.length ? `${this.where(reached.ref)} has no callers in the map, and is used without a call: ${uses.join("; ")}` : `${this.where(reached.ref)} has no callers in the map: it may be wired by a framework, called dynamically, or unused`
|
|
@@ -22979,7 +23020,7 @@ var Tracer = class {
|
|
|
22979
23020
|
}
|
|
22980
23021
|
entry(label, route, at, site, certain, top = false) {
|
|
22981
23022
|
const chain = [];
|
|
22982
|
-
let step = top
|
|
23023
|
+
let step = !top ? at : at.via ? this.reached.get(at.via) : void 0;
|
|
22983
23024
|
for (; step && chain.length < LIMITS.chain; ) {
|
|
22984
23025
|
chain.push(this.name(step.ref));
|
|
22985
23026
|
step = step.via ? this.reached.get(step.via) : void 0;
|
|
@@ -22998,12 +23039,12 @@ var Tracer = class {
|
|
|
22998
23039
|
this.areas.set(area, known);
|
|
22999
23040
|
}
|
|
23000
23041
|
/** A related test file; the closest relation (lowest rank) explains it. */
|
|
23001
|
-
test(
|
|
23002
|
-
if (!mapRunnableTest(
|
|
23003
|
-
const known = this.tests.get(
|
|
23042
|
+
test(path15, name, why, rank2) {
|
|
23043
|
+
if (!mapRunnableTest(path15)) return;
|
|
23044
|
+
const known = this.tests.get(path15) ?? { names: /* @__PURE__ */ new Set(), why, rank: rank2 };
|
|
23004
23045
|
if (rank2 < known.rank) Object.assign(known, { why, rank: rank2 });
|
|
23005
23046
|
if (name && !name.startsWith("<")) known.names.add(name);
|
|
23006
|
-
this.tests.set(
|
|
23047
|
+
this.tests.set(path15, known);
|
|
23007
23048
|
}
|
|
23008
23049
|
};
|
|
23009
23050
|
var mapRunnableTest = (file2) => /_test\.(?:go|py)$|(?:^|\/)test_[^/]*\.py$|\.(?:test|spec)\.[cm]?[jt]sx?$|(?:Test|Tests|IT)\.(?:java|kt)$/u.test(
|
|
@@ -23016,14 +23057,14 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23016
23057
|
const changed = [];
|
|
23017
23058
|
const unclear = [];
|
|
23018
23059
|
const removed = [];
|
|
23019
|
-
const declarations2 = (g,
|
|
23060
|
+
const declarations2 = (g, path15) => g.objectsAt(path15).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
|
|
23020
23061
|
let changedCount = 0;
|
|
23021
23062
|
const starts = [];
|
|
23022
23063
|
const importers = /* @__PURE__ */ new Map();
|
|
23023
23064
|
let mapped;
|
|
23024
23065
|
const mappedPaths = () => mapped ??= store.database.prepare("SELECT DISTINCT path FROM project_map_objects WHERE version_ref = ?").all(working).map((row) => String(row.path));
|
|
23025
|
-
const topLevelChanged = (
|
|
23026
|
-
const note = `top-level code of ${
|
|
23066
|
+
const topLevelChanged = (path15) => {
|
|
23067
|
+
const note = `top-level code of ${path15} changed (imports, constants or registrations)`;
|
|
23027
23068
|
if (!unclear.includes(note)) unclear.push(note);
|
|
23028
23069
|
};
|
|
23029
23070
|
for (const file2 of changes.files) {
|
|
@@ -23034,13 +23075,14 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23034
23075
|
if (file2.status !== "DELETED") tracer.test(file2.path, void 0, "changed in this diff", 1);
|
|
23035
23076
|
continue;
|
|
23036
23077
|
}
|
|
23037
|
-
const
|
|
23078
|
+
const template = mapMiniprogramTemplate(file2.path);
|
|
23079
|
+
const analyzed = objects2.length > 0 && (mapLanguageOf(file2.path) !== void 0 || template && objects2.some((object2) => object2.parsing === "PARSED"));
|
|
23038
23080
|
if (!analyzed && file2.status !== "DELETED" && kind)
|
|
23039
23081
|
unclear.push(`${file2.path} changed (${kind}): its effects are not mapped`);
|
|
23040
23082
|
if (!objects2.length) continue;
|
|
23041
23083
|
const hits = /* @__PURE__ */ new Set();
|
|
23042
23084
|
let topLevel = false;
|
|
23043
|
-
const inFile = declarations2(graph, file2.path);
|
|
23085
|
+
const inFile = template ? objects2.filter((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : declarations2(graph, file2.path);
|
|
23044
23086
|
for (const [from, to] of file2.lines) {
|
|
23045
23087
|
const containing = inFile.filter(
|
|
23046
23088
|
(object2) => object2.anchor.startLine <= to && from <= object2.anchor.endLine
|
|
@@ -23059,7 +23101,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23059
23101
|
}
|
|
23060
23102
|
const object2 = graph.object(ref);
|
|
23061
23103
|
changed.push(
|
|
23062
|
-
`${file2.path}: ${graph.qualifiedName(ref)} ${mapDeclarationLabel(object2)}${file2.status === "ADDED" ? " (new file)" : ""}`
|
|
23104
|
+
`${file2.path}${template ? " (template)" : `: ${graph.qualifiedName(ref)} ${mapDeclarationLabel(object2)}`}${file2.status === "ADDED" ? " (new file)" : ""}`
|
|
23063
23105
|
);
|
|
23064
23106
|
starts.push(ref);
|
|
23065
23107
|
}
|
|
@@ -23162,18 +23204,18 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23162
23204
|
beforeTracer.trace(gone);
|
|
23163
23205
|
for (const entry of beforeTracer.entries.values())
|
|
23164
23206
|
if (!tracer.entries.has(entry.label)) tracer.entries.set(entry.label, entry);
|
|
23165
|
-
for (const [
|
|
23166
|
-
const known = tracer.tests.get(
|
|
23207
|
+
for (const [path15, test] of beforeTracer.tests) {
|
|
23208
|
+
const known = tracer.tests.get(path15);
|
|
23167
23209
|
if (known) for (const name of test.names) known.names.add(name);
|
|
23168
|
-
else tracer.tests.set(
|
|
23210
|
+
else tracer.tests.set(path15, test);
|
|
23169
23211
|
}
|
|
23170
23212
|
for (const [area, known] of beforeTracer.areas) {
|
|
23171
23213
|
const now = tracer.areas.get(area);
|
|
23172
23214
|
if (!now) tracer.areas.set(area, known);
|
|
23173
23215
|
else {
|
|
23174
23216
|
for (const name of known.through) now.through.add(name);
|
|
23175
|
-
for (const [
|
|
23176
|
-
now.tests.set(
|
|
23217
|
+
for (const [path15, names] of known.tests)
|
|
23218
|
+
now.tests.set(path15, /* @__PURE__ */ new Set([...now.tests.get(path15) ?? [], ...names]));
|
|
23177
23219
|
}
|
|
23178
23220
|
}
|
|
23179
23221
|
unclear.push(...beforeTracer.unclear.filter((line) => !line.includes("has no callers")));
|
|
@@ -23198,10 +23240,10 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23198
23240
|
for (const ref of called) {
|
|
23199
23241
|
const object2 = before.object(ref);
|
|
23200
23242
|
if (mapIsModule(object2) || testCode(object2.anchor.path) || gone.includes(ref)) continue;
|
|
23201
|
-
const
|
|
23202
|
-
if (
|
|
23243
|
+
const path15 = moved.has(object2.anchor.path) ? moved.get(object2.anchor.path) : object2.anchor.path;
|
|
23244
|
+
if (path15 === void 0) continue;
|
|
23203
23245
|
const name = before.qualifiedName(ref);
|
|
23204
|
-
const now = declarations2(graph,
|
|
23246
|
+
const now = declarations2(graph, path15).find(
|
|
23205
23247
|
(candidate) => candidate.kind === object2.kind && graph.qualifiedName(candidate.id) === name
|
|
23206
23248
|
);
|
|
23207
23249
|
if (!now || outsideTests(tracer.callers(now.id), graph).length || tracer.usesWithoutCalls(now.id).length)
|
|
@@ -23209,7 +23251,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23209
23251
|
if (!outsideTests(beforeTracer.callers(ref), before).length) continue;
|
|
23210
23252
|
const tested = tracer.callers(now.id).length > 0;
|
|
23211
23253
|
uncalled.push(
|
|
23212
|
-
`${
|
|
23254
|
+
`${path15}: ${name} ${mapDeclarationLabel(now)}${tested ? " (only tests call it now)" : ""}`
|
|
23213
23255
|
);
|
|
23214
23256
|
}
|
|
23215
23257
|
uncalled.sort();
|
|
@@ -23221,8 +23263,8 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23221
23263
|
entries: [...tracer.entries.values()].sort(
|
|
23222
23264
|
(left, right) => Number(right.certain) - Number(left.certain) || Number(right.route) - Number(left.route) || (left.label < right.label ? -1 : left.label > right.label ? 1 : 0)
|
|
23223
23265
|
),
|
|
23224
|
-
tests: [...tracer.tests].map(([
|
|
23225
|
-
path:
|
|
23266
|
+
tests: [...tracer.tests].map(([path15, test]) => ({
|
|
23267
|
+
path: path15,
|
|
23226
23268
|
names: [...test.names].sort(),
|
|
23227
23269
|
why: test.why,
|
|
23228
23270
|
rank: test.rank
|
|
@@ -23232,7 +23274,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23232
23274
|
areas: [...tracer.areas].map(([area, known]) => ({
|
|
23233
23275
|
area,
|
|
23234
23276
|
through: [...known.through].sort(),
|
|
23235
|
-
tests: [...known.tests].map(([
|
|
23277
|
+
tests: [...known.tests].map(([path15, names]) => ({ path: path15, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
|
|
23236
23278
|
})).sort((left, right) => right.tests.length - left.tests.length),
|
|
23237
23279
|
unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
|
|
23238
23280
|
removedRoutes,
|
|
@@ -23247,7 +23289,7 @@ function existingTestsChanged(before, after, file2, project) {
|
|
|
23247
23289
|
let workingLines = [];
|
|
23248
23290
|
if (file2.status !== "DELETED" && project)
|
|
23249
23291
|
try {
|
|
23250
|
-
workingLines = readFileSync3(
|
|
23292
|
+
workingLines = readFileSync3(path10.join(project, file2.path), "utf8").split("\n");
|
|
23251
23293
|
} catch {
|
|
23252
23294
|
}
|
|
23253
23295
|
const key = (graph, object2) => `${object2.kind}\0${graph.qualifiedName(object2.id)}`;
|
|
@@ -23286,10 +23328,10 @@ function importerTests(graph, objects2, tracer, importers) {
|
|
|
23286
23328
|
}
|
|
23287
23329
|
const next = [];
|
|
23288
23330
|
for (const imported of modules)
|
|
23289
|
-
for (const { path:
|
|
23290
|
-
if (testCode(
|
|
23331
|
+
for (const { path: path15, module } of importers.get(imported) ?? [])
|
|
23332
|
+
if (testCode(path15))
|
|
23291
23333
|
tracer.test(
|
|
23292
|
-
|
|
23334
|
+
path15,
|
|
23293
23335
|
void 0,
|
|
23294
23336
|
hop ? "imports a changed file indirectly" : "imports a changed file",
|
|
23295
23337
|
hop ? 4 : 2
|
|
@@ -23339,7 +23381,7 @@ function routeTests(project, store, version2, entries, tracer) {
|
|
|
23339
23381
|
if (!mapRunnableTest(candidate)) continue;
|
|
23340
23382
|
let text;
|
|
23341
23383
|
try {
|
|
23342
|
-
text = readFileSync3(
|
|
23384
|
+
text = readFileSync3(path10.join(project, candidate), "utf8");
|
|
23343
23385
|
} catch {
|
|
23344
23386
|
continue;
|
|
23345
23387
|
}
|
|
@@ -23357,9 +23399,9 @@ function routeTests(project, store, version2, entries, tracer) {
|
|
|
23357
23399
|
}
|
|
23358
23400
|
}
|
|
23359
23401
|
}
|
|
23360
|
-
function sameDirectoryTests(paths,
|
|
23361
|
-
const slash =
|
|
23362
|
-
const directory = slash < 0 ? "" :
|
|
23402
|
+
function sameDirectoryTests(paths, path15, tracer) {
|
|
23403
|
+
const slash = path15.lastIndexOf("/");
|
|
23404
|
+
const directory = slash < 0 ? "" : path15.slice(0, slash + 1);
|
|
23363
23405
|
for (const candidate of paths) {
|
|
23364
23406
|
if (!candidate.startsWith(directory)) continue;
|
|
23365
23407
|
if (candidate.slice(directory.length).includes("/") || !mapTestPath(candidate)) continue;
|
|
@@ -23390,9 +23432,9 @@ var LIST = Object.freeze({
|
|
|
23390
23432
|
similar: 10,
|
|
23391
23433
|
similarNames: 3
|
|
23392
23434
|
});
|
|
23393
|
-
function routesIn(graph,
|
|
23435
|
+
function routesIn(graph, path15) {
|
|
23394
23436
|
const routes = /* @__PURE__ */ new Set();
|
|
23395
|
-
for (const relation of graph.relationsFrom(graph.objectsAt(
|
|
23437
|
+
for (const relation of graph.relationsFrom(graph.objectsAt(path15).map((object2) => object2.id))) {
|
|
23396
23438
|
const route = relation.kind === "DECORATED_BY" ? relation.route ?? relation.argument : relation.argument;
|
|
23397
23439
|
if (route && ROUTE2.test(route)) routes.add(route);
|
|
23398
23440
|
}
|
|
@@ -23417,7 +23459,7 @@ async function checkMapChanges(input, signal) {
|
|
|
23417
23459
|
working,
|
|
23418
23460
|
base,
|
|
23419
23461
|
changes.files,
|
|
23420
|
-
(file2) => readFile(
|
|
23462
|
+
(file2) => readFile(path10.join(project, file2), "utf8").catch(() => void 0)
|
|
23421
23463
|
)
|
|
23422
23464
|
)
|
|
23423
23465
|
};
|
|
@@ -23643,7 +23685,7 @@ CREATE INDEX layermap_commit_version ON layermap_commit_versions(version_ref);
|
|
|
23643
23685
|
`;
|
|
23644
23686
|
var schemaVersion = (database) => Number(database.prepare("PRAGMA user_version").get()?.user_version ?? 0);
|
|
23645
23687
|
function openMapDatabase(file2) {
|
|
23646
|
-
mkdirSync(
|
|
23688
|
+
mkdirSync(path11.dirname(file2), { recursive: true, mode: 448 });
|
|
23647
23689
|
const database = new DatabaseSync(file2);
|
|
23648
23690
|
try {
|
|
23649
23691
|
database.exec(BUSY_TIMEOUT);
|
|
@@ -23680,7 +23722,7 @@ function openMapDatabase(file2) {
|
|
|
23680
23722
|
throw error51;
|
|
23681
23723
|
}
|
|
23682
23724
|
}
|
|
23683
|
-
var mapDatabasePath = (cacheDirectory2, canonicalProject) =>
|
|
23725
|
+
var mapDatabasePath = (cacheDirectory2, canonicalProject) => path11.join(
|
|
23684
23726
|
cacheDirectory2,
|
|
23685
23727
|
"projects",
|
|
23686
23728
|
createHash4("sha256").update(canonicalProject).digest("hex").slice(0, 24),
|
|
@@ -23970,25 +24012,25 @@ var LayerMap = class _LayerMap {
|
|
|
23970
24012
|
|
|
23971
24013
|
// src/agent/environment.ts
|
|
23972
24014
|
var packageRoot = (() => {
|
|
23973
|
-
for (let directory =
|
|
23974
|
-
const manifest =
|
|
24015
|
+
for (let directory = path12.dirname(fileURLToPath(import.meta.url)); ; ) {
|
|
24016
|
+
const manifest = path12.join(directory, "package.json");
|
|
23975
24017
|
if (existsSync5(manifest) && JSON.parse(readFileSync4(manifest, "utf8")).name === "layermap")
|
|
23976
24018
|
return directory;
|
|
23977
|
-
if (
|
|
23978
|
-
directory =
|
|
24019
|
+
if (path12.dirname(directory) === directory) throw new Error("LayerMap cannot find its package.");
|
|
24020
|
+
directory = path12.dirname(directory);
|
|
23979
24021
|
}
|
|
23980
24022
|
})();
|
|
23981
|
-
var packageVersion = async () => JSON.parse(await readFile2(
|
|
24023
|
+
var packageVersion = async () => JSON.parse(await readFile2(path12.join(packageRoot, "package.json"), "utf8")).version;
|
|
23982
24024
|
var cacheDirectory = (env = process.env) => {
|
|
23983
|
-
if (env.LAYERMAP_CACHE) return
|
|
23984
|
-
if (process.platform === "darwin") return
|
|
24025
|
+
if (env.LAYERMAP_CACHE) return path12.resolve(env.LAYERMAP_CACHE);
|
|
24026
|
+
if (process.platform === "darwin") return path12.join(homedir(), "Library", "Caches", "layermap");
|
|
23985
24027
|
if (process.platform === "win32")
|
|
23986
|
-
return
|
|
23987
|
-
env.LOCALAPPDATA ||
|
|
24028
|
+
return path12.join(
|
|
24029
|
+
env.LOCALAPPDATA || path12.join(homedir(), "AppData", "Local"),
|
|
23988
24030
|
"layermap",
|
|
23989
24031
|
"Cache"
|
|
23990
24032
|
);
|
|
23991
|
-
return
|
|
24033
|
+
return path12.join(env.XDG_CACHE_HOME || path12.join(homedir(), ".cache"), "layermap");
|
|
23992
24034
|
};
|
|
23993
24035
|
var projectDirectory = (directory) => new Promise(
|
|
23994
24036
|
(resolve) => execFile(
|
|
@@ -23996,7 +24038,7 @@ var projectDirectory = (directory) => new Promise(
|
|
|
23996
24038
|
["rev-parse", "--show-toplevel"],
|
|
23997
24039
|
{ cwd: directory, timeout: 1e4 },
|
|
23998
24040
|
(error51, stdout) => resolve(
|
|
23999
|
-
error51 ? { directory:
|
|
24041
|
+
error51 ? { directory: path12.resolve(directory), git: false } : { directory: stdout.trim(), git: true }
|
|
24000
24042
|
)
|
|
24001
24043
|
)
|
|
24002
24044
|
);
|
|
@@ -24006,7 +24048,7 @@ var relativeTo = (directory, value) => Object.fromEntries(
|
|
|
24006
24048
|
Object.fromEntries(
|
|
24007
24049
|
Object.entries(resources).map(([key, field]) => [
|
|
24008
24050
|
key,
|
|
24009
|
-
key.endsWith("Path") && typeof field === "string" && field.startsWith(directory) ?
|
|
24051
|
+
key.endsWith("Path") && typeof field === "string" && field.startsWith(directory) ? path12.relative(directory, field) : field
|
|
24010
24052
|
])
|
|
24011
24053
|
)
|
|
24012
24054
|
])
|
|
@@ -24017,7 +24059,7 @@ var resolvePlaceholder = (field) => {
|
|
|
24017
24059
|
createRequire(import.meta.url).resolve("typescript/package.json")
|
|
24018
24060
|
);
|
|
24019
24061
|
const native = `@typescript/typescript-${process.platform}-${process.arch}/package.json`;
|
|
24020
|
-
return
|
|
24062
|
+
return path12.join(path12.dirname(compiler.resolve(native)), "lib", executableName("tsc"));
|
|
24021
24063
|
}
|
|
24022
24064
|
const resolved = field.replaceAll("{platform}", process.platform).replaceAll("{arch}", process.arch);
|
|
24023
24065
|
return field.includes("{platform}") ? executableName(resolved) : resolved;
|
|
@@ -24029,24 +24071,24 @@ var absoluteIn = (directory, value) => Object.fromEntries(
|
|
|
24029
24071
|
Object.entries(resources).map(([key, field]) => {
|
|
24030
24072
|
if (!key.endsWith("Path") || typeof field !== "string") return [key, field];
|
|
24031
24073
|
const resolved = resolvePlaceholder(field);
|
|
24032
|
-
return [key,
|
|
24074
|
+
return [key, path12.isAbsolute(resolved) ? resolved : path12.join(directory, resolved)];
|
|
24033
24075
|
})
|
|
24034
24076
|
)
|
|
24035
24077
|
])
|
|
24036
24078
|
);
|
|
24037
24079
|
var readAnalyzers = async (directory) => {
|
|
24038
|
-
const file2 =
|
|
24080
|
+
const file2 = path12.join(directory, "analyzers.json");
|
|
24039
24081
|
if (!existsSync5(file2)) return void 0;
|
|
24040
24082
|
const analyzers = absoluteIn(directory, JSON.parse(await readFile2(file2, "utf8")));
|
|
24041
24083
|
return analyzers.java.runtimePath ? analyzers : { ...analyzers, java: { ...analyzers.java, ...discoverJavaRuntime() } };
|
|
24042
24084
|
};
|
|
24043
24085
|
var sourceDigest = async () => {
|
|
24044
|
-
const hash2 = createHash5("sha256").update(await readFile2(
|
|
24086
|
+
const hash2 = createHash5("sha256").update(await readFile2(path12.join(packageRoot, "package.json")));
|
|
24045
24087
|
for (const part of ["src", "go-map", "java-map", "scripts"]) {
|
|
24046
|
-
const directory =
|
|
24088
|
+
const directory = path12.join(packageRoot, part);
|
|
24047
24089
|
if (!existsSync5(directory)) continue;
|
|
24048
24090
|
for (const entry of (await readdir(directory, { recursive: true })).sort()) {
|
|
24049
|
-
const file2 =
|
|
24091
|
+
const file2 = path12.join(directory, entry);
|
|
24050
24092
|
const info = await stat(file2);
|
|
24051
24093
|
if (info.isFile()) hash2.update(`${part}/${entry}\0${info.size}\0${info.mtimeMs}\0`);
|
|
24052
24094
|
}
|
|
@@ -24054,11 +24096,11 @@ var sourceDigest = async () => {
|
|
|
24054
24096
|
return hash2.digest("hex").slice(0, 16);
|
|
24055
24097
|
};
|
|
24056
24098
|
async function resolveAnalyzers(cache, log2, env = process.env) {
|
|
24057
|
-
for (const directory2 of [env.LAYERMAP_ANALYZERS,
|
|
24058
|
-
const analyzers = directory2 && await readAnalyzers(
|
|
24099
|
+
for (const directory2 of [env.LAYERMAP_ANALYZERS, path12.join(packageRoot, "analyzers")]) {
|
|
24100
|
+
const analyzers = directory2 && await readAnalyzers(path12.resolve(directory2));
|
|
24059
24101
|
if (analyzers) return analyzers;
|
|
24060
24102
|
}
|
|
24061
|
-
const directory =
|
|
24103
|
+
const directory = path12.join(cache, "analyzers", await sourceDigest());
|
|
24062
24104
|
const built = await readAnalyzers(directory);
|
|
24063
24105
|
if (built) return built;
|
|
24064
24106
|
log2("Building the language analyzers (once per LayerMap version)...");
|
|
@@ -24074,73 +24116,73 @@ async function resolveAnalyzers(cache, log2, env = process.env) {
|
|
|
24074
24116
|
python: parser.pythonResources,
|
|
24075
24117
|
java: parser.javaResources
|
|
24076
24118
|
});
|
|
24077
|
-
await writeFile(
|
|
24119
|
+
await writeFile(path12.join(staging, "analyzers.json"), `${JSON.stringify(stored, null, 2)}
|
|
24078
24120
|
`);
|
|
24079
24121
|
await rename(staging, directory).catch(() => rm(staging, { recursive: true, force: true }));
|
|
24080
24122
|
return await readAnalyzers(directory);
|
|
24081
24123
|
}
|
|
24082
24124
|
var DAY = 24 * 60 * 60 * 1e3;
|
|
24083
24125
|
async function pruneCache(cache, project, now = Date.now(), installed = packageRoot, env = process.env) {
|
|
24084
|
-
const used =
|
|
24085
|
-
await mkdir(
|
|
24126
|
+
const used = path12.join(path12.dirname(mapDatabasePath(cache, project)), "last-used");
|
|
24127
|
+
await mkdir(path12.dirname(used), { recursive: true, mode: 448 });
|
|
24086
24128
|
await writeFile(used, "");
|
|
24087
24129
|
await utimes(used, now / 1e3, now / 1e3);
|
|
24088
|
-
const projects =
|
|
24130
|
+
const projects = path12.join(cache, "projects");
|
|
24089
24131
|
for (const name of await readdir(projects).catch(() => [])) {
|
|
24090
|
-
const directory =
|
|
24091
|
-
const marker =
|
|
24132
|
+
const directory = path12.join(projects, name);
|
|
24133
|
+
const marker = path12.join(directory, "last-used");
|
|
24092
24134
|
const last = (await stat(existsSync5(marker) ? marker : directory).catch(() => void 0))?.mtimeMs;
|
|
24093
24135
|
if (last !== void 0 && now - last > 30 * DAY)
|
|
24094
24136
|
await rm(directory, { recursive: true, force: true });
|
|
24095
24137
|
}
|
|
24096
|
-
const builds =
|
|
24138
|
+
const builds = path12.join(cache, "analyzers");
|
|
24097
24139
|
const current = await sourceDigest();
|
|
24098
24140
|
for (const name of await readdir(builds).catch(() => [])) {
|
|
24099
24141
|
if (name === current) continue;
|
|
24100
|
-
const built = (await stat(
|
|
24142
|
+
const built = (await stat(path12.join(builds, name)).catch(() => void 0))?.mtimeMs;
|
|
24101
24143
|
if (built !== void 0 && now - built > (name.includes(".") ? DAY / 24 : DAY))
|
|
24102
|
-
await rm(
|
|
24144
|
+
await rm(path12.join(builds, name), { recursive: true, force: true });
|
|
24103
24145
|
}
|
|
24104
|
-
const own =
|
|
24105
|
-
const versions =
|
|
24106
|
-
const launched =
|
|
24146
|
+
const own = path12.dirname(path12.dirname(installed));
|
|
24147
|
+
const versions = path12.join(cache, "versions");
|
|
24148
|
+
const launched = path12.dirname(own) === versions;
|
|
24107
24149
|
if (launched) await pruneVersions(versions, own, now);
|
|
24108
|
-
const npx = launched ?
|
|
24109
|
-
env.npm_config_cache || (process.platform === "win32" ?
|
|
24150
|
+
const npx = launched ? path12.join(
|
|
24151
|
+
env.npm_config_cache || (process.platform === "win32" ? path12.join(env.LOCALAPPDATA || path12.join(homedir(), "AppData", "Local"), "npm-cache") : path12.join(homedir(), ".npm")),
|
|
24110
24152
|
"_npx"
|
|
24111
|
-
) :
|
|
24112
|
-
if (
|
|
24153
|
+
) : path12.dirname(own);
|
|
24154
|
+
if (path12.basename(path12.dirname(installed)) === "node_modules" && path12.basename(npx) === "_npx")
|
|
24113
24155
|
await pruneNpxInstalls(npx, installed, now);
|
|
24114
24156
|
}
|
|
24115
24157
|
async function pruneVersions(versions, own, now) {
|
|
24116
|
-
const used =
|
|
24158
|
+
const used = path12.join(own, "last-used");
|
|
24117
24159
|
await writeFile(used, "");
|
|
24118
24160
|
await utimes(used, now / 1e3, now / 1e3);
|
|
24119
24161
|
for (const name of await readdir(versions).catch(() => [])) {
|
|
24120
|
-
const directory =
|
|
24121
|
-
const marker =
|
|
24162
|
+
const directory = path12.join(versions, name);
|
|
24163
|
+
const marker = path12.join(directory, "last-used");
|
|
24122
24164
|
const last = (await stat(existsSync5(marker) ? marker : directory).catch(() => void 0))?.mtimeMs;
|
|
24123
24165
|
if (last !== void 0 && now - last > (name.startsWith(".") ? DAY / 24 : 7 * DAY))
|
|
24124
24166
|
await rm(directory, { recursive: true, force: true });
|
|
24125
24167
|
}
|
|
24126
24168
|
}
|
|
24127
24169
|
async function pruneNpxInstalls(npx, installed, now) {
|
|
24128
|
-
const own =
|
|
24170
|
+
const own = path12.dirname(path12.dirname(installed));
|
|
24129
24171
|
const manifest = async (file2) => JSON.parse(await readFile2(file2, "utf8").catch(() => "{}"));
|
|
24130
24172
|
const parts = (version2) => version2?.split(".").map(Number) ?? [];
|
|
24131
|
-
const current = parts((await manifest(
|
|
24173
|
+
const current = parts((await manifest(path12.join(installed, "package.json"))).version);
|
|
24132
24174
|
const older = (version2) => {
|
|
24133
24175
|
for (let index = 0; index < 3; index++)
|
|
24134
24176
|
if (version2[index] !== current[index]) return (version2[index] ?? 0) < (current[index] ?? 0);
|
|
24135
24177
|
return false;
|
|
24136
24178
|
};
|
|
24137
24179
|
for (const name of await readdir(npx).catch(() => [])) {
|
|
24138
|
-
const directory =
|
|
24180
|
+
const directory = path12.join(npx, name);
|
|
24139
24181
|
if (directory === own) continue;
|
|
24140
|
-
const requested = (await manifest(
|
|
24182
|
+
const requested = (await manifest(path12.join(directory, "package.json"))).dependencies ?? {};
|
|
24141
24183
|
if (Object.keys(requested).join() !== "layermap") continue;
|
|
24142
24184
|
const version2 = parts(
|
|
24143
|
-
(await manifest(
|
|
24185
|
+
(await manifest(path12.join(directory, "node_modules", "layermap", "package.json"))).version
|
|
24144
24186
|
);
|
|
24145
24187
|
if (version2.length !== 3 || version2.some(Number.isNaN) || !older(version2)) continue;
|
|
24146
24188
|
const at = (await stat(directory).catch(() => void 0))?.mtimeMs;
|
|
@@ -24161,7 +24203,7 @@ var projectHeading = (project) => `Project ${project} (paths are relative to it)
|
|
|
24161
24203
|
// src/agent/projects.ts
|
|
24162
24204
|
import { existsSync as existsSync6 } from "node:fs";
|
|
24163
24205
|
import { readdir as readdir2, realpath as realpath3, stat as stat2 } from "node:fs/promises";
|
|
24164
|
-
import
|
|
24206
|
+
import path13 from "node:path";
|
|
24165
24207
|
|
|
24166
24208
|
// src/tools.ts
|
|
24167
24209
|
var AGENT_MAP_TOOL_HOST = Object.freeze({
|
|
@@ -24185,7 +24227,7 @@ var MAP_TOOL_NAMES = Object.freeze({
|
|
|
24185
24227
|
references: "project_find_references",
|
|
24186
24228
|
check: "project_check_changes"
|
|
24187
24229
|
});
|
|
24188
|
-
var mapDirectoryPath = (
|
|
24230
|
+
var mapDirectoryPath = (path15) => path15.length > 1 && path15.endsWith("/") && !path15.endsWith("//") ? path15.slice(0, -1) : path15;
|
|
24189
24231
|
var ProjectMapSearchInputSchema = external_exports.object({
|
|
24190
24232
|
path: external_exports.string().default("."),
|
|
24191
24233
|
query: external_exports.string().min(1).max(256),
|
|
@@ -24249,28 +24291,28 @@ var mapToolDescriptions = (host) => {
|
|
|
24249
24291
|
|
|
24250
24292
|
// src/agent/projects.ts
|
|
24251
24293
|
var escapes = (relative) => {
|
|
24252
|
-
const normal =
|
|
24253
|
-
return normal === ".." || normal.startsWith(`..${
|
|
24294
|
+
const normal = path13.normalize(relative);
|
|
24295
|
+
return normal === ".." || normal.startsWith(`..${path13.sep}`);
|
|
24254
24296
|
};
|
|
24255
24297
|
async function locate(start, given) {
|
|
24256
|
-
if (start.git && !
|
|
24298
|
+
if (start.git && !path13.isAbsolute(given) && !escapes(given))
|
|
24257
24299
|
return { project: start.directory, path: given };
|
|
24258
|
-
const absolute =
|
|
24300
|
+
const absolute = path13.resolve(start.directory, given);
|
|
24259
24301
|
let directory = absolute;
|
|
24260
24302
|
while (!(await stat2(directory).catch(() => void 0))?.isDirectory()) {
|
|
24261
|
-
if (
|
|
24262
|
-
directory =
|
|
24303
|
+
if (path13.dirname(directory) === directory) return void 0;
|
|
24304
|
+
directory = path13.dirname(directory);
|
|
24263
24305
|
}
|
|
24264
|
-
const real =
|
|
24306
|
+
const real = path13.join(await realpath3(directory), path13.relative(directory, absolute));
|
|
24265
24307
|
const { directory: project, git: git2 } = await projectDirectory(directory);
|
|
24266
24308
|
if (!git2) return void 0;
|
|
24267
|
-
const relative =
|
|
24309
|
+
const relative = path13.relative(project, real);
|
|
24268
24310
|
if (escapes(relative)) return void 0;
|
|
24269
|
-
return { project, path: relative ? relative.split(
|
|
24311
|
+
return { project, path: relative ? relative.split(path13.sep).join("/") : "." };
|
|
24270
24312
|
}
|
|
24271
24313
|
async function repositoriesIn(directory) {
|
|
24272
24314
|
const entries = await readdir2(directory, { withFileTypes: true }).catch(() => []);
|
|
24273
|
-
return entries.filter((entry) => entry.isDirectory() && existsSync6(
|
|
24315
|
+
return entries.filter((entry) => entry.isDirectory() && existsSync6(path13.join(directory, entry.name, ".git"))).map((entry) => `${entry.name}/`).sort();
|
|
24274
24316
|
}
|
|
24275
24317
|
async function routeMapCall(start, { name, args }) {
|
|
24276
24318
|
const holder = ["symbol", "locator"].find(
|
|
@@ -24282,7 +24324,7 @@ async function routeMapCall(start, { name, args }) {
|
|
|
24282
24324
|
if (!located) {
|
|
24283
24325
|
const repositories = start.git ? [] : await repositoriesIn(start.directory);
|
|
24284
24326
|
const such = repositories.length ? `, such as ${repositories.join(", ")}` : "";
|
|
24285
|
-
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: ${
|
|
24327
|
+
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: ${path13.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}`}.`;
|
|
24286
24328
|
}
|
|
24287
24329
|
if (!holder)
|
|
24288
24330
|
return {
|
|
@@ -24588,7 +24630,7 @@ import { execFile as execFile2 } from "node:child_process";
|
|
|
24588
24630
|
import { existsSync as existsSync7 } from "node:fs";
|
|
24589
24631
|
import { mkdir as mkdir2, readFile as readFile3, rename as rename2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
24590
24632
|
import { homedir as homedir2 } from "node:os";
|
|
24591
|
-
import
|
|
24633
|
+
import path14 from "node:path";
|
|
24592
24634
|
var SERVER = "layermap";
|
|
24593
24635
|
var SETUP_RULE = `mcp__${SERVER}`;
|
|
24594
24636
|
var PLUGIN_RULE = `mcp__plugin_${SERVER}_${SERVER}`;
|
|
@@ -24596,11 +24638,11 @@ var BEGIN = "<!-- layermap:begin -->";
|
|
|
24596
24638
|
var END = "<!-- layermap:end -->";
|
|
24597
24639
|
var launcherScript = (template, version2) => `// Generated from scripts/launcher.mjs.
|
|
24598
24640
|
${template.replace("__VERSION__", JSON.stringify(version2))}`;
|
|
24599
|
-
var PUBLISHED_LAUNCHER =
|
|
24600
|
-
var launcherFile = (env = process.env) =>
|
|
24641
|
+
var PUBLISHED_LAUNCHER = path14.join(packageRoot, "dist", "launcher.mjs");
|
|
24642
|
+
var launcherFile = (env = process.env) => path14.join(cacheDirectory(env), "server.mjs");
|
|
24601
24643
|
var mcpLaunchCommand = (env = process.env, published = existsSync7(PUBLISHED_LAUNCHER)) => {
|
|
24602
24644
|
if (published) return ["node", launcherFile(env)];
|
|
24603
|
-
const script =
|
|
24645
|
+
const script = path14.resolve(process.argv[1] ?? "");
|
|
24604
24646
|
const execArgv = [];
|
|
24605
24647
|
for (let index = 0; index < process.execArgv.length; index++) {
|
|
24606
24648
|
const argument = process.execArgv[index];
|
|
@@ -24636,7 +24678,7 @@ async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
|
|
|
24636
24678
|
throw new Error(`${file2} has permissions.allow that is not a list.`);
|
|
24637
24679
|
if (settings.permissions.allow.includes(rule)) return false;
|
|
24638
24680
|
settings.permissions.allow.push(rule);
|
|
24639
|
-
await mkdir2(
|
|
24681
|
+
await mkdir2(path14.dirname(file2), { recursive: true });
|
|
24640
24682
|
await writeFile2(file2, `${JSON.stringify(settings, null, 2)}
|
|
24641
24683
|
`);
|
|
24642
24684
|
return true;
|
|
@@ -24671,7 +24713,7 @@ ${END}`;
|
|
|
24671
24713
|
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}
|
|
24672
24714
|
`;
|
|
24673
24715
|
if (next === text) return;
|
|
24674
|
-
await mkdir2(
|
|
24716
|
+
await mkdir2(path14.dirname(file2), { recursive: true });
|
|
24675
24717
|
await writeFile2(file2, next);
|
|
24676
24718
|
}
|
|
24677
24719
|
async function removeInstructionNote(file2) {
|
|
@@ -24699,11 +24741,11 @@ async function disallowInClaudeSettings(file2) {
|
|
|
24699
24741
|
}
|
|
24700
24742
|
var YAML_BEGIN = "# layermap:begin";
|
|
24701
24743
|
var YAML_END = "# layermap:end";
|
|
24702
|
-
var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(
|
|
24744
|
+
var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(path14.delimiter).find((directory) => path14.isAbsolute(directory) && existsSync7(path14.join(directory, "node"))) ?? path14.dirname(process.execPath);
|
|
24703
24745
|
var dshPatchBlock = (command, env) => {
|
|
24704
24746
|
const node = nodeDirectory(env);
|
|
24705
|
-
const [program = "", ...args] = command[0] === "node" ? [
|
|
24706
|
-
const searchPath2 = `${JSON.stringify(`${node}${
|
|
24747
|
+
const [program = "", ...args] = command[0] === "node" ? [path14.join(node, "node"), ...command.slice(1)] : command;
|
|
24748
|
+
const searchPath2 = `${JSON.stringify(`${node}${path14.delimiter}`)} + process.env.PATH`;
|
|
24707
24749
|
return [
|
|
24708
24750
|
`${YAML_BEGIN} (written by \`layermap setup dsh\`; \`layermap remove dsh\` deletes it)`,
|
|
24709
24751
|
"- insert:",
|
|
@@ -24738,7 +24780,7 @@ async function writeDshPatch(file2, block) {
|
|
|
24738
24780
|
`;
|
|
24739
24781
|
}
|
|
24740
24782
|
if (next === text) return;
|
|
24741
|
-
await mkdir2(
|
|
24783
|
+
await mkdir2(path14.dirname(file2), { recursive: true });
|
|
24742
24784
|
await writeFile2(file2, next);
|
|
24743
24785
|
}
|
|
24744
24786
|
async function removeDshPatch(file2) {
|
|
@@ -24756,31 +24798,31 @@ async function removeDshPatch(file2) {
|
|
|
24756
24798
|
var agentFiles = (options) => {
|
|
24757
24799
|
const env = options.env ?? process.env;
|
|
24758
24800
|
if (options.agent === "dsh") {
|
|
24759
|
-
const home = env.DSH_HOME ||
|
|
24801
|
+
const home = env.DSH_HOME || path14.join(homedir2(), ".dsh");
|
|
24760
24802
|
return {
|
|
24761
|
-
settings:
|
|
24762
|
-
instructions:
|
|
24803
|
+
settings: path14.join(home, "cordis.patch.yml"),
|
|
24804
|
+
instructions: path14.join(home, "AGENTS.md")
|
|
24763
24805
|
};
|
|
24764
24806
|
}
|
|
24765
24807
|
if (options.agent === "codex") {
|
|
24766
|
-
const home = env.CODEX_HOME ??
|
|
24767
|
-
return { settings:
|
|
24808
|
+
const home = env.CODEX_HOME ?? path14.join(homedir2(), ".codex");
|
|
24809
|
+
return { settings: path14.join(home, "config.toml"), instructions: path14.join(home, "AGENTS.md") };
|
|
24768
24810
|
}
|
|
24769
24811
|
if (options.scope === "user") {
|
|
24770
|
-
const home = env.CLAUDE_CONFIG_DIR ??
|
|
24812
|
+
const home = env.CLAUDE_CONFIG_DIR ?? path14.join(homedir2(), ".claude");
|
|
24771
24813
|
return {
|
|
24772
|
-
settings:
|
|
24773
|
-
instructions:
|
|
24814
|
+
settings: path14.join(home, "settings.json"),
|
|
24815
|
+
instructions: path14.join(home, "CLAUDE.md")
|
|
24774
24816
|
};
|
|
24775
24817
|
}
|
|
24776
24818
|
const local = options.scope === "local";
|
|
24777
24819
|
return {
|
|
24778
|
-
settings:
|
|
24820
|
+
settings: path14.join(
|
|
24779
24821
|
options.project,
|
|
24780
24822
|
".claude",
|
|
24781
24823
|
local ? "settings.local.json" : "settings.json"
|
|
24782
24824
|
),
|
|
24783
|
-
instructions:
|
|
24825
|
+
instructions: path14.join(options.project, local ? "CLAUDE.local.md" : "CLAUDE.md")
|
|
24784
24826
|
};
|
|
24785
24827
|
};
|
|
24786
24828
|
async function setupAgent(options) {
|
|
@@ -24800,7 +24842,7 @@ async function setupAgent(options) {
|
|
|
24800
24842
|
const writeLauncher = async () => {
|
|
24801
24843
|
if (!published) return;
|
|
24802
24844
|
const file2 = launcherFile(env);
|
|
24803
|
-
await mkdir2(
|
|
24845
|
+
await mkdir2(path14.dirname(file2), { recursive: true, mode: 448 });
|
|
24804
24846
|
await writeFile2(
|
|
24805
24847
|
`${file2}.${process.pid}`,
|
|
24806
24848
|
launcherScript(await readFile3(PUBLISHED_LAUNCHER, "utf8"), options.version)
|