layermap 0.1.13 → 0.1.14
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 +6 -3
- package/analyzers/go/win32-arm64/go-map.exe +0 -0
- package/analyzers/go/win32-x64/go-map.exe +0 -0
- package/analyzers/project-map-go-worker.mjs +64 -26
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/analyzers/project-map-java-worker.mjs +62 -28
- package/analyzers/project-map-python-worker.mjs +42 -41
- package/analyzers/project-map-worker.mjs +218 -200
- package/dist/cli.mjs +476 -388
- package/package.json +3 -2
package/dist/cli.mjs
CHANGED
|
@@ -12,28 +12,96 @@ import { parseArgs } from "node:util";
|
|
|
12
12
|
// src/agent/environment.ts
|
|
13
13
|
import { execFile } from "node:child_process";
|
|
14
14
|
import { createHash as createHash5 } from "node:crypto";
|
|
15
|
-
import { existsSync as
|
|
15
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
16
16
|
import { mkdir, readdir, readFile, 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 path11 from "node:path";
|
|
20
20
|
import { fileURLToPath } from "node:url";
|
|
21
21
|
|
|
22
22
|
// src/layermap.ts
|
|
23
23
|
import { createHash as createHash4 } from "node:crypto";
|
|
24
24
|
import { mkdirSync } from "node:fs";
|
|
25
25
|
import { lstat as lstat2, realpath as realpath2 } from "node:fs/promises";
|
|
26
|
-
import
|
|
26
|
+
import path10 from "node:path";
|
|
27
27
|
import { DatabaseSync } from "@photostructure/sqlite";
|
|
28
28
|
|
|
29
29
|
// src/capture-policy.ts
|
|
30
|
-
import
|
|
30
|
+
import path3 from "node:path";
|
|
31
31
|
|
|
32
32
|
// src/file-universe.ts
|
|
33
|
-
import
|
|
33
|
+
import path2 from "node:path";
|
|
34
34
|
|
|
35
35
|
// src/git-runner.ts
|
|
36
36
|
import { spawn } from "node:child_process";
|
|
37
|
+
|
|
38
|
+
// src/platform.ts
|
|
39
|
+
import { spawnSync } from "node:child_process";
|
|
40
|
+
import { existsSync } from "node:fs";
|
|
41
|
+
import path from "node:path";
|
|
42
|
+
var executableName = (name, platform = process.platform) => platform === "win32" ? `${name}.exe` : name;
|
|
43
|
+
var searchPath = (env) => env.PATH ?? Object.entries(env).find(([name]) => name.toUpperCase() === "PATH")?.[1] ?? "";
|
|
44
|
+
function findOnPath(files, env, platform) {
|
|
45
|
+
const join = platform === "win32" ? path.win32.join : path.posix.join;
|
|
46
|
+
for (const directory of searchPath(env).split(platform === "win32" ? ";" : ":"))
|
|
47
|
+
for (const file2 of files)
|
|
48
|
+
if (directory && existsSync(join(directory, file2))) return join(directory, file2);
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
var findExecutable = (name, env = process.env, platform = process.platform) => findOnPath([executableName(name, platform)], env, platform);
|
|
52
|
+
var CMD_META = /([()\][%!^"`<>&|;, *?])/gu;
|
|
53
|
+
var cmdArgument = (value) => `"${value.replace(/(\\*)"/gu, '$1$1\\"').replace(/(\\*)$/u, "$1$1")}"`.replace(CMD_META, "^$1").replace(CMD_META, "^$1");
|
|
54
|
+
function commandInvocation(command, args, env = process.env, platform = process.platform) {
|
|
55
|
+
if (platform !== "win32") return { file: command, args: [...args] };
|
|
56
|
+
const program = findOnPath([`${command}.exe`, `${command}.cmd`, `${command}.bat`], env, platform);
|
|
57
|
+
if (!program || program.toLowerCase().endsWith(".exe"))
|
|
58
|
+
return { file: program ?? command, args: [...args] };
|
|
59
|
+
return cmdInvocation(program, args, env.ComSpec ?? process.env.ComSpec ?? "cmd.exe");
|
|
60
|
+
}
|
|
61
|
+
function cmdInvocation(script, args, comspec = "cmd.exe") {
|
|
62
|
+
const line = [script.replace(CMD_META, "^$1"), ...args.map(cmdArgument)].join(" ");
|
|
63
|
+
return { file: comspec, args: ["/d", "/s", "/c", `"${line}"`], windowsVerbatimArguments: true };
|
|
64
|
+
}
|
|
65
|
+
var WINDOWS_SYSTEM = [
|
|
66
|
+
"SystemRoot",
|
|
67
|
+
"windir",
|
|
68
|
+
"SystemDrive",
|
|
69
|
+
"TEMP",
|
|
70
|
+
"TMP",
|
|
71
|
+
"USERPROFILE",
|
|
72
|
+
"LOCALAPPDATA",
|
|
73
|
+
"APPDATA",
|
|
74
|
+
"PATHEXT",
|
|
75
|
+
"ComSpec"
|
|
76
|
+
];
|
|
77
|
+
function childEnvironment(variables, platform = process.platform, env = process.env) {
|
|
78
|
+
if (platform !== "win32") return variables;
|
|
79
|
+
const system = {};
|
|
80
|
+
for (const name of WINDOWS_SYSTEM) if (env[name] !== void 0) system[name] = env[name];
|
|
81
|
+
return { ...system, ...variables };
|
|
82
|
+
}
|
|
83
|
+
function stopProcessTree(pid, signal, platform = process.platform) {
|
|
84
|
+
if (platform !== "win32") {
|
|
85
|
+
process.kill(-pid, signal);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const taskkill = path.win32.join(
|
|
89
|
+
process.env.SystemRoot ?? "C:\\Windows",
|
|
90
|
+
"System32",
|
|
91
|
+
"taskkill.exe"
|
|
92
|
+
);
|
|
93
|
+
spawnSync(taskkill, ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
94
|
+
}
|
|
95
|
+
function processTreeGone(pid, platform = process.platform) {
|
|
96
|
+
try {
|
|
97
|
+
process.kill(platform === "win32" ? pid : -pid, 0);
|
|
98
|
+
return false;
|
|
99
|
+
} catch (error51) {
|
|
100
|
+
return error51.code === "ESRCH" ? true : void 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// src/git-runner.ts
|
|
37
105
|
var CONSTRAINED_CONFIG = [
|
|
38
106
|
"-c",
|
|
39
107
|
"core.fsmonitor=false",
|
|
@@ -66,8 +134,27 @@ var GitCommandStopUnconfirmedError = class extends GitCommandError {
|
|
|
66
134
|
this.name = "GitCommandStopUnconfirmedError";
|
|
67
135
|
}
|
|
68
136
|
};
|
|
137
|
+
function gitEnvironment() {
|
|
138
|
+
const windows = process.platform === "win32";
|
|
139
|
+
return childEnvironment({
|
|
140
|
+
LANG: process.env.LANG ?? "C",
|
|
141
|
+
LC_ALL: "C",
|
|
142
|
+
PATH: windows ? process.env.PATH ?? "" : "/usr/bin:/bin",
|
|
143
|
+
...windows ? {} : { TMPDIR: process.env.TMPDIR ?? "/tmp" },
|
|
144
|
+
GIT_ATTR_NOSYSTEM: "1",
|
|
145
|
+
GIT_CONFIG_COUNT: "0",
|
|
146
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
147
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
148
|
+
GIT_OPTIONAL_LOCKS: "0",
|
|
149
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
150
|
+
GIT_PAGER: "cat",
|
|
151
|
+
PAGER: "cat",
|
|
152
|
+
...windows ? {} : { GIT_ASKPASS: "/usr/bin/false", SSH_ASKPASS: "/usr/bin/false" }
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
var defaultGit = () => process.platform === "win32" ? findExecutable("git") ?? "git.exe" : "/usr/bin/git";
|
|
69
156
|
var GitRunner = class {
|
|
70
|
-
constructor(executable =
|
|
157
|
+
constructor(executable = defaultGit()) {
|
|
71
158
|
this.executable = executable;
|
|
72
159
|
}
|
|
73
160
|
executable;
|
|
@@ -82,22 +169,8 @@ var GitRunner = class {
|
|
|
82
169
|
return new Promise((resolve, reject) => {
|
|
83
170
|
const child = spawn(this.executable, finalArgs, {
|
|
84
171
|
cwd: options.cwd,
|
|
85
|
-
env:
|
|
86
|
-
|
|
87
|
-
LC_ALL: "C",
|
|
88
|
-
PATH: "/usr/bin:/bin",
|
|
89
|
-
TMPDIR: process.env.TMPDIR ?? "/tmp",
|
|
90
|
-
GIT_ATTR_NOSYSTEM: "1",
|
|
91
|
-
GIT_CONFIG_COUNT: "0",
|
|
92
|
-
GIT_CONFIG_NOSYSTEM: "1",
|
|
93
|
-
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
94
|
-
GIT_OPTIONAL_LOCKS: "0",
|
|
95
|
-
GIT_TERMINAL_PROMPT: "0",
|
|
96
|
-
GIT_PAGER: "cat",
|
|
97
|
-
PAGER: "cat",
|
|
98
|
-
GIT_ASKPASS: "/usr/bin/false",
|
|
99
|
-
SSH_ASKPASS: "/usr/bin/false"
|
|
100
|
-
},
|
|
172
|
+
env: gitEnvironment(),
|
|
173
|
+
windowsHide: true,
|
|
101
174
|
stdio: ["pipe", "pipe", "pipe"]
|
|
102
175
|
});
|
|
103
176
|
const stdout = [];
|
|
@@ -217,8 +290,8 @@ var parseFileUniverse = (output) => {
|
|
|
217
290
|
const records = output.toString("utf8").split("\0");
|
|
218
291
|
for (const record2 of records) {
|
|
219
292
|
if (record2.length === 0) continue;
|
|
220
|
-
const normalized =
|
|
221
|
-
if (normalized !== record2 || normalized === "." || normalized === ".." || normalized.startsWith("../") ||
|
|
293
|
+
const normalized = path2.posix.normalize(record2);
|
|
294
|
+
if (normalized !== record2 || normalized === "." || normalized === ".." || normalized.startsWith("../") || path2.posix.isAbsolute(normalized) || normalized.includes("\\")) {
|
|
222
295
|
throw new ProjectEvidenceFileUniverseError("PROJECT_FILE_UNIVERSE_INVALID");
|
|
223
296
|
}
|
|
224
297
|
files.add(normalized);
|
|
@@ -430,7 +503,7 @@ var ProjectEvidencePolicyError = class extends Error {
|
|
|
430
503
|
var assertProjectEvidencePathNotSensitive = (relativePath) => {
|
|
431
504
|
const segments = relativePath.toLowerCase().split("/");
|
|
432
505
|
const basename = segments.at(-1) ?? "";
|
|
433
|
-
const extension =
|
|
506
|
+
const extension = path3.posix.extname(basename);
|
|
434
507
|
const containsSensitiveSequence = sensitiveSegmentSequences.some(
|
|
435
508
|
(sequence) => segments.length >= sequence.length && segments.some(
|
|
436
509
|
(_, start) => sequence.every((segment, offset) => segments[start + offset] === segment)
|
|
@@ -443,8 +516,8 @@ var assertProjectEvidencePathNotSensitive = (relativePath) => {
|
|
|
443
516
|
};
|
|
444
517
|
var isProjectEvidenceTraversalExcluded = (relativePath) => relativePath.toLowerCase().split("/").some((segment) => traversalExcludedSegmentSet.has(segment));
|
|
445
518
|
var isProjectEvidenceTextPath = (relativePath) => {
|
|
446
|
-
const basename =
|
|
447
|
-
const extension =
|
|
519
|
+
const basename = path3.posix.basename(relativePath).toLowerCase();
|
|
520
|
+
const extension = path3.posix.extname(basename);
|
|
448
521
|
if (allowedTextBasenameSet.has(basename)) return true;
|
|
449
522
|
return extension ? allowedTextExtensionSet.has(extension) : allowedExtensionlessNameSet.has(basename);
|
|
450
523
|
};
|
|
@@ -453,7 +526,7 @@ var isProjectEvidenceTextPath = (relativePath) => {
|
|
|
453
526
|
import { createHash as createHash2 } from "node:crypto";
|
|
454
527
|
|
|
455
528
|
// src/core.ts
|
|
456
|
-
import
|
|
529
|
+
import path4 from "node:path";
|
|
457
530
|
|
|
458
531
|
// node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
459
532
|
var external_exports = {};
|
|
@@ -1221,10 +1294,10 @@ function mergeDefs(...defs) {
|
|
|
1221
1294
|
function cloneDef(schema) {
|
|
1222
1295
|
return mergeDefs(schema._zod.def);
|
|
1223
1296
|
}
|
|
1224
|
-
function getElementAtPath(obj,
|
|
1225
|
-
if (!
|
|
1297
|
+
function getElementAtPath(obj, path13) {
|
|
1298
|
+
if (!path13)
|
|
1226
1299
|
return obj;
|
|
1227
|
-
return
|
|
1300
|
+
return path13.reduce((acc, key) => acc?.[key], obj);
|
|
1228
1301
|
}
|
|
1229
1302
|
function promiseAllObject(promisesObj) {
|
|
1230
1303
|
const keys = Object.keys(promisesObj);
|
|
@@ -1633,11 +1706,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1633
1706
|
}
|
|
1634
1707
|
return false;
|
|
1635
1708
|
}
|
|
1636
|
-
function prefixIssues(
|
|
1709
|
+
function prefixIssues(path13, issues) {
|
|
1637
1710
|
return issues.map((iss) => {
|
|
1638
1711
|
var _a3;
|
|
1639
1712
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1640
|
-
iss.path.unshift(
|
|
1713
|
+
iss.path.unshift(path13);
|
|
1641
1714
|
return iss;
|
|
1642
1715
|
});
|
|
1643
1716
|
}
|
|
@@ -1784,16 +1857,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1784
1857
|
}
|
|
1785
1858
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1786
1859
|
const fieldErrors = { _errors: [] };
|
|
1787
|
-
const processError = (error52,
|
|
1860
|
+
const processError = (error52, path13 = []) => {
|
|
1788
1861
|
for (const issue2 of error52.issues) {
|
|
1789
1862
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1790
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1863
|
+
issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
|
|
1791
1864
|
} else if (issue2.code === "invalid_key") {
|
|
1792
|
-
processError({ issues: issue2.issues }, [...
|
|
1865
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
1793
1866
|
} else if (issue2.code === "invalid_element") {
|
|
1794
|
-
processError({ issues: issue2.issues }, [...
|
|
1867
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
1795
1868
|
} else {
|
|
1796
|
-
const fullpath = [...
|
|
1869
|
+
const fullpath = [...path13, ...issue2.path];
|
|
1797
1870
|
if (fullpath.length === 0) {
|
|
1798
1871
|
fieldErrors._errors.push(mapper(issue2));
|
|
1799
1872
|
} else {
|
|
@@ -1820,17 +1893,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1820
1893
|
}
|
|
1821
1894
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1822
1895
|
const result = { errors: [] };
|
|
1823
|
-
const processError = (error52,
|
|
1896
|
+
const processError = (error52, path13 = []) => {
|
|
1824
1897
|
var _a3, _b;
|
|
1825
1898
|
for (const issue2 of error52.issues) {
|
|
1826
1899
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1827
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1900
|
+
issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
|
|
1828
1901
|
} else if (issue2.code === "invalid_key") {
|
|
1829
|
-
processError({ issues: issue2.issues }, [...
|
|
1902
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
1830
1903
|
} else if (issue2.code === "invalid_element") {
|
|
1831
|
-
processError({ issues: issue2.issues }, [...
|
|
1904
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
1832
1905
|
} else {
|
|
1833
|
-
const fullpath = [...
|
|
1906
|
+
const fullpath = [...path13, ...issue2.path];
|
|
1834
1907
|
if (fullpath.length === 0) {
|
|
1835
1908
|
result.errors.push(mapper(issue2));
|
|
1836
1909
|
continue;
|
|
@@ -1862,8 +1935,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1862
1935
|
}
|
|
1863
1936
|
function toDotPath(_path) {
|
|
1864
1937
|
const segs = [];
|
|
1865
|
-
const
|
|
1866
|
-
for (const seg of
|
|
1938
|
+
const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1939
|
+
for (const seg of path13) {
|
|
1867
1940
|
if (typeof seg === "number")
|
|
1868
1941
|
segs.push(`[${seg}]`);
|
|
1869
1942
|
else if (typeof seg === "symbol")
|
|
@@ -14555,13 +14628,13 @@ function resolveRef(ref, ctx) {
|
|
|
14555
14628
|
if (!ref.startsWith("#")) {
|
|
14556
14629
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14557
14630
|
}
|
|
14558
|
-
const
|
|
14559
|
-
if (
|
|
14631
|
+
const path13 = ref.slice(1).split("/").filter(Boolean);
|
|
14632
|
+
if (path13.length === 0) {
|
|
14560
14633
|
return ctx.rootSchema;
|
|
14561
14634
|
}
|
|
14562
14635
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14563
|
-
if (
|
|
14564
|
-
const key =
|
|
14636
|
+
if (path13[0] === defsKey) {
|
|
14637
|
+
const key = path13[1];
|
|
14565
14638
|
if (!key || !ctx.defs[key]) {
|
|
14566
14639
|
throw new Error(`Reference not found: ${ref}`);
|
|
14567
14640
|
}
|
|
@@ -14989,14 +15062,14 @@ var ProjectEvidencePathError = class extends Error {
|
|
|
14989
15062
|
code;
|
|
14990
15063
|
};
|
|
14991
15064
|
var normalizeProjectEvidencePath = (value, allowRoot = false) => {
|
|
14992
|
-
if (value.includes("\0") ||
|
|
15065
|
+
if (value.includes("\0") || path4.isAbsolute(value) || value.includes("\\")) {
|
|
14993
15066
|
throw new ProjectEvidencePathError("PROJECT_PATH_INVALID");
|
|
14994
15067
|
}
|
|
14995
15068
|
if (value === ".") {
|
|
14996
15069
|
if (allowRoot) return "";
|
|
14997
15070
|
throw new ProjectEvidencePathError("PROJECT_PATH_INVALID");
|
|
14998
15071
|
}
|
|
14999
|
-
const normalized =
|
|
15072
|
+
const normalized = path4.posix.normalize(value);
|
|
15000
15073
|
if (normalized.length === 0 || normalized !== value || normalized === ".." || normalized.startsWith("../") || value.split("/").some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
15001
15074
|
throw new ProjectEvidencePathError("PROJECT_PATH_INVALID");
|
|
15002
15075
|
}
|
|
@@ -15148,14 +15221,14 @@ var CodeCommitReader = class _CodeCommitReader {
|
|
|
15148
15221
|
// src/code-worktree-reader.ts
|
|
15149
15222
|
import { constants as fsConstants } from "node:fs";
|
|
15150
15223
|
import { lstat, open, realpath } from "node:fs/promises";
|
|
15151
|
-
import
|
|
15224
|
+
import path5 from "node:path";
|
|
15152
15225
|
var fileSystemErrorCode = (error51) => {
|
|
15153
15226
|
if (typeof error51 !== "object" || error51 === null || !("code" in error51)) return void 0;
|
|
15154
15227
|
return typeof error51.code === "string" ? error51.code : void 0;
|
|
15155
15228
|
};
|
|
15156
15229
|
var isInsideRoot = (root, candidate) => {
|
|
15157
|
-
const relative =
|
|
15158
|
-
return relative === "" || !relative.startsWith(`..${
|
|
15230
|
+
const relative = path5.relative(root, candidate);
|
|
15231
|
+
return relative === "" || !relative.startsWith(`..${path5.sep}`) && relative !== "..";
|
|
15159
15232
|
};
|
|
15160
15233
|
var stablePathFingerprint = (stats) => [
|
|
15161
15234
|
stats.dev,
|
|
@@ -15198,7 +15271,7 @@ var StableProjectCaptureSession = class _StableProjectCaptureSession {
|
|
|
15198
15271
|
}
|
|
15199
15272
|
async captureFile(relativePath) {
|
|
15200
15273
|
this.assertNotAborted();
|
|
15201
|
-
const absolutePath =
|
|
15274
|
+
const absolutePath = path5.join(this.root, ...relativePath.split("/"));
|
|
15202
15275
|
const stats = await this.inspectPath(absolutePath, true);
|
|
15203
15276
|
const fingerprint = stablePathFingerprint(stats);
|
|
15204
15277
|
const byteLength = stats.isDirectory() ? 0 : Number(stats.size);
|
|
@@ -15320,11 +15393,11 @@ var StableProjectCaptureSession = class _StableProjectCaptureSession {
|
|
|
15320
15393
|
if (!isInsideRoot(this.root, absolutePath)) {
|
|
15321
15394
|
throw new ProjectEvidenceError("PROJECT_PATH_OUTSIDE_ROOT", false);
|
|
15322
15395
|
}
|
|
15323
|
-
const relative =
|
|
15324
|
-
const components = relative === "" ? [] : relative.split(
|
|
15396
|
+
const relative = path5.relative(this.root, absolutePath);
|
|
15397
|
+
const components = relative === "" ? [] : relative.split(path5.sep);
|
|
15325
15398
|
const paths = [
|
|
15326
15399
|
this.root,
|
|
15327
|
-
...components.map((_, index) =>
|
|
15400
|
+
...components.map((_, index) => path5.join(this.root, ...components.slice(0, index + 1)))
|
|
15328
15401
|
];
|
|
15329
15402
|
let finalStats;
|
|
15330
15403
|
for (const [index, currentPath] of paths.entries()) {
|
|
@@ -15365,7 +15438,7 @@ var StableProjectCaptureSession = class _StableProjectCaptureSession {
|
|
|
15365
15438
|
};
|
|
15366
15439
|
|
|
15367
15440
|
// src/source-scope.ts
|
|
15368
|
-
import
|
|
15441
|
+
import path6 from "node:path";
|
|
15369
15442
|
var InitialEvidenceScopeSchema = external_exports.object({
|
|
15370
15443
|
pathPrefixes: external_exports.array(ProjectEvidenceGrantPathPrefixSchema).min(1).max(64)
|
|
15371
15444
|
}).strict();
|
|
@@ -15448,7 +15521,7 @@ var includesInitialEvidencePath = (relativePath, scope) => {
|
|
|
15448
15521
|
const segments = relativePath.toLowerCase().split("/");
|
|
15449
15522
|
if (segments.slice(0, -1).some((segment) => excluded.has(segment))) return false;
|
|
15450
15523
|
const basename = segments.at(-1) ?? "";
|
|
15451
|
-
return extensions.has(
|
|
15524
|
+
return extensions.has(path6.posix.extname(basename)) || SOURCE_POLICY.documentationFiles.includes(basename) || SOURCE_POLICY.configurationFiles.includes(basename) || SOURCE_POLICY.workspaceFiles.includes(relativePath);
|
|
15452
15525
|
};
|
|
15453
15526
|
|
|
15454
15527
|
// src/code-index-capture.ts
|
|
@@ -15801,8 +15874,8 @@ var MapAnalysisSchema = external_exports.object({
|
|
|
15801
15874
|
var mapPathAllowed = (relative, prefixes) => prefixes.some(
|
|
15802
15875
|
(prefix) => prefix === "." || relative === prefix || relative.startsWith(`${prefix}/`)
|
|
15803
15876
|
);
|
|
15804
|
-
var mapTestPath = (
|
|
15805
|
-
|
|
15877
|
+
var mapTestPath = (path13) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
|
|
15878
|
+
path13
|
|
15806
15879
|
);
|
|
15807
15880
|
|
|
15808
15881
|
// src/project-map-reference-types.ts
|
|
@@ -15886,11 +15959,11 @@ var string4 = (value) => {
|
|
|
15886
15959
|
var identity = (id2, reconstructed) => id2 === reconstructed ? [] : [JSON.stringify(id2)];
|
|
15887
15960
|
function encodeMapText(graph) {
|
|
15888
15961
|
const files = /* @__PURE__ */ new Map();
|
|
15889
|
-
const file2 = (
|
|
15890
|
-
let ref = files.get(
|
|
15962
|
+
const file2 = (path13) => {
|
|
15963
|
+
let ref = files.get(path13);
|
|
15891
15964
|
if (!ref) {
|
|
15892
15965
|
ref = `F${files.size + 1}`;
|
|
15893
|
-
files.set(
|
|
15966
|
+
files.set(path13, ref);
|
|
15894
15967
|
}
|
|
15895
15968
|
return ref;
|
|
15896
15969
|
};
|
|
@@ -15938,7 +16011,7 @@ function encodeMapText(graph) {
|
|
|
15938
16011
|
rows.push(`B ${node(frontier.entityRef)} ${frontier.direction}`);
|
|
15939
16012
|
return [
|
|
15940
16013
|
...header,
|
|
15941
|
-
...[...files].map(([
|
|
16014
|
+
...[...files].map(([path13, ref]) => `${ref} ${JSON.stringify(path13)}`),
|
|
15942
16015
|
...rows
|
|
15943
16016
|
].join("\n");
|
|
15944
16017
|
}
|
|
@@ -15958,10 +16031,10 @@ function decodeMapText(text) {
|
|
|
15958
16031
|
const at = (value) => {
|
|
15959
16032
|
const match = /^(F[1-9]\d*):(\d+)-(\d+)@(\d+)-(\d+)$/u.exec(value ?? "");
|
|
15960
16033
|
if (!match) return failed();
|
|
15961
|
-
const
|
|
15962
|
-
if (
|
|
16034
|
+
const path13 = files.get(match[1] ?? "");
|
|
16035
|
+
if (path13 === void 0) return failed();
|
|
15963
16036
|
return MapAnchorSchema.parse({
|
|
15964
|
-
path:
|
|
16037
|
+
path: path13,
|
|
15965
16038
|
startLine: Number(match[2]),
|
|
15966
16039
|
endLine: Number(match[3]),
|
|
15967
16040
|
start: Number(match[4]),
|
|
@@ -16038,8 +16111,8 @@ function decodeMapText(text) {
|
|
|
16038
16111
|
var locationSchema = MapAnchorSchema.describe(
|
|
16039
16112
|
"Source location: start/end are zero-based UTF-16 offsets with an exclusive end; line numbers are one-based."
|
|
16040
16113
|
);
|
|
16041
|
-
var location = ({ path:
|
|
16042
|
-
path:
|
|
16114
|
+
var location = ({ path: path13, startLine, endLine, start, end }) => ({
|
|
16115
|
+
path: path13,
|
|
16043
16116
|
startLine,
|
|
16044
16117
|
endLine,
|
|
16045
16118
|
start,
|
|
@@ -16142,11 +16215,11 @@ var MapNavigationObjectsSchema = external_exports.union([
|
|
|
16142
16215
|
),
|
|
16143
16216
|
external_exports.object({ files: external_exports.array(searchFileSchema) }).passthrough().refine((value) => !("format" in value), "Text navigation must decode through its format.").transform(
|
|
16144
16217
|
(value) => value.files.flatMap(
|
|
16145
|
-
({ path:
|
|
16218
|
+
({ path: path13, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
|
|
16146
16219
|
id: id2,
|
|
16147
16220
|
name,
|
|
16148
16221
|
kind,
|
|
16149
|
-
anchor: { path:
|
|
16222
|
+
anchor: { path: path13, startLine, endLine, start, end },
|
|
16150
16223
|
...execution ? { execution } : {}
|
|
16151
16224
|
}))
|
|
16152
16225
|
)
|
|
@@ -16159,10 +16232,10 @@ var mapSearchNavigation = (result) => {
|
|
|
16159
16232
|
for (const [index, object2] of found.entries()) {
|
|
16160
16233
|
const ranking = rankings[index];
|
|
16161
16234
|
if (!ranking) throw new Error("PROJECT_MAP_SEARCH_RANKING_MISSING");
|
|
16162
|
-
const
|
|
16235
|
+
const path13 = object2.anchor.path;
|
|
16163
16236
|
let file2 = files.at(-1);
|
|
16164
|
-
if (file2?.path !==
|
|
16165
|
-
file2 = { path:
|
|
16237
|
+
if (file2?.path !== path13) {
|
|
16238
|
+
file2 = { path: path13, symbols: [] };
|
|
16166
16239
|
files.push(file2);
|
|
16167
16240
|
}
|
|
16168
16241
|
file2.symbols.push({
|
|
@@ -16288,8 +16361,8 @@ var MapViewGraph = class {
|
|
|
16288
16361
|
}
|
|
16289
16362
|
return object2;
|
|
16290
16363
|
}
|
|
16291
|
-
objectsAt(
|
|
16292
|
-
return this.statements.path.all(this.version,
|
|
16364
|
+
objectsAt(path13) {
|
|
16365
|
+
return this.statements.path.all(this.version, path13).map((row) => {
|
|
16293
16366
|
const object2 = MapObjectSchema.parse(JSON.parse(String(row.object_json)));
|
|
16294
16367
|
this.objects.set(object2.id, object2);
|
|
16295
16368
|
return object2;
|
|
@@ -16408,8 +16481,8 @@ var MapViewGraph = class {
|
|
|
16408
16481
|
);
|
|
16409
16482
|
}
|
|
16410
16483
|
};
|
|
16411
|
-
function mapSelectDeclarations(graph,
|
|
16412
|
-
const objects2 = graph.objectsAt(
|
|
16484
|
+
function mapSelectDeclarations(graph, path13, name, line) {
|
|
16485
|
+
const objects2 = graph.objectsAt(path13).filter((object2) => !mapIsModule(object2));
|
|
16413
16486
|
const matching = name === void 0 ? objects2 : objects2.filter(
|
|
16414
16487
|
(object2) => object2.name === name || name.includes(".") && graph.qualifiedName(object2.id) === name
|
|
16415
16488
|
);
|
|
@@ -16431,12 +16504,12 @@ function requireMapObject(store, version2, selector, prefixes) {
|
|
|
16431
16504
|
if ([entityRef, locator, symbol2].filter((value) => value !== void 0).length !== 1 || entityRef !== void 0 && !entityRef.length)
|
|
16432
16505
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16433
16506
|
if (symbol2) {
|
|
16434
|
-
const
|
|
16435
|
-
if (!mapPathAllowed(
|
|
16507
|
+
const path13 = normalizeProjectEvidencePath(symbol2.path);
|
|
16508
|
+
if (!mapPathAllowed(path13, prefixes))
|
|
16436
16509
|
throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
|
|
16437
16510
|
const selected = mapSelectDeclarations(
|
|
16438
16511
|
new MapViewGraph(store, version2),
|
|
16439
|
-
|
|
16512
|
+
path13,
|
|
16440
16513
|
symbol2.name,
|
|
16441
16514
|
symbol2.line
|
|
16442
16515
|
);
|
|
@@ -16447,14 +16520,14 @@ function requireMapObject(store, version2, selector, prefixes) {
|
|
|
16447
16520
|
}
|
|
16448
16521
|
let rows;
|
|
16449
16522
|
if (locator) {
|
|
16450
|
-
const
|
|
16523
|
+
const path13 = normalizeProjectEvidencePath(locator.path);
|
|
16451
16524
|
if (!Number.isSafeInteger(locator.start) || locator.start < 0 || locator.kind !== void 0 && !MapObjectKindSchema.safeParse(locator.kind).success)
|
|
16452
16525
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16453
|
-
if (!mapPathAllowed(
|
|
16526
|
+
if (!mapPathAllowed(path13, prefixes))
|
|
16454
16527
|
throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
|
|
16455
16528
|
rows = store.database.prepare(`SELECT object_json FROM project_map_objects
|
|
16456
16529
|
WHERE version_ref = ? AND path = ? AND json_extract(object_json, '$.anchor.start') = ?
|
|
16457
|
-
AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2,
|
|
16530
|
+
AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path13, locator.start, locator.kind ?? null, locator.kind ?? null);
|
|
16458
16531
|
} else {
|
|
16459
16532
|
rows = store.database.prepare(
|
|
16460
16533
|
"SELECT object_json FROM project_map_objects WHERE version_ref = ? AND entity_ref = ?"
|
|
@@ -16495,13 +16568,13 @@ function mapQueryPage(count, materialize, navigation, budget) {
|
|
|
16495
16568
|
|
|
16496
16569
|
// src/project-map-query-selection.ts
|
|
16497
16570
|
var mapQuerySelection = (input, knownKinds) => {
|
|
16498
|
-
const
|
|
16571
|
+
const path13 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
|
|
16499
16572
|
const kinds = input.kinds ?? knownKinds;
|
|
16500
16573
|
if (!Array.isArray(kinds) || !kinds.length || kinds.length > knownKinds.length || kinds.some((kind) => !knownKinds.includes(kind)))
|
|
16501
16574
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16502
|
-
return { path:
|
|
16575
|
+
return { path: path13, kinds: [...new Set(kinds)].sort() };
|
|
16503
16576
|
};
|
|
16504
|
-
var mapQueryPathMatches = (
|
|
16577
|
+
var mapQueryPathMatches = (path13, prefix) => prefix === "." || path13 === prefix || path13.startsWith(`${prefix}/`);
|
|
16505
16578
|
var mapQueryPathSql = (column) => `(? = '.' OR ${column} = ? OR substr(${column}, 1, length(?) + 1) = ? || '/')`;
|
|
16506
16579
|
|
|
16507
16580
|
// src/project-map-search-focus.ts
|
|
@@ -16599,7 +16672,7 @@ var declarationKinds = /* @__PURE__ */ new Set([
|
|
|
16599
16672
|
"METHOD",
|
|
16600
16673
|
"TYPE"
|
|
16601
16674
|
]);
|
|
16602
|
-
var fileStem = (
|
|
16675
|
+
var fileStem = (path13) => path13.slice(path13.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
|
|
16603
16676
|
var compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
16604
16677
|
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);
|
|
16605
16678
|
function mapSearchQuery(input) {
|
|
@@ -16626,10 +16699,10 @@ function mapSearchQuery(input) {
|
|
|
16626
16699
|
}
|
|
16627
16700
|
function rank(object2, documentation, relationCount, query, focus) {
|
|
16628
16701
|
const name = object2.name.toLowerCase();
|
|
16629
|
-
const
|
|
16702
|
+
const path13 = object2.anchor.path.toLowerCase();
|
|
16630
16703
|
const values = {
|
|
16631
16704
|
NAME: [name],
|
|
16632
|
-
PATH: [
|
|
16705
|
+
PATH: [path13],
|
|
16633
16706
|
DOCUMENTATION: documentation.map((text) => text.toLowerCase())
|
|
16634
16707
|
};
|
|
16635
16708
|
const matched = query.terms.map((term) => ({
|
|
@@ -16654,12 +16727,12 @@ function rank(object2, documentation, relationCount, query, focus) {
|
|
|
16654
16727
|
score += 7e3;
|
|
16655
16728
|
signals.push("SYMBOL_CONTAINS");
|
|
16656
16729
|
} else if (matchedFields.includes("NAME")) signals.push("SYMBOL_CONTAINS");
|
|
16657
|
-
if (object2.kind === "FILE" && fileStem(
|
|
16730
|
+
if (object2.kind === "FILE" && fileStem(path13) === normalizedQuery) {
|
|
16658
16731
|
score += 11e3;
|
|
16659
16732
|
signals.push("EXACT_FILE_STEM");
|
|
16660
16733
|
}
|
|
16661
16734
|
if (matchedFields.includes("PATH")) {
|
|
16662
|
-
score +=
|
|
16735
|
+
score += path13.includes(normalizedQuery) ? 2500 : 0;
|
|
16663
16736
|
signals.push("PATH_CONTAINS");
|
|
16664
16737
|
}
|
|
16665
16738
|
if (matchedFields.includes("DOCUMENTATION")) {
|
|
@@ -16674,8 +16747,8 @@ function rank(object2, documentation, relationCount, query, focus) {
|
|
|
16674
16747
|
score += kindWeight[object2.kind] + Math.min(1200, relationCount * 20) + (focus?.score ?? 0);
|
|
16675
16748
|
if (declarationKinds.has(object2.kind)) signals.push("DECLARATION");
|
|
16676
16749
|
if (relationCount > 0) signals.push("GRAPH_CONNECTED");
|
|
16677
|
-
const isTest = mapTestPath(
|
|
16678
|
-
const isGenerated = generatedPath.test(
|
|
16750
|
+
const isTest = mapTestPath(path13);
|
|
16751
|
+
const isGenerated = generatedPath.test(path13);
|
|
16679
16752
|
const hasTestIntent = query.terms.some((term) => testQuery.test(term));
|
|
16680
16753
|
score += isTest ? hasTestIntent ? 1e3 : -5e3 : 300;
|
|
16681
16754
|
score += isGenerated ? -3e3 : 300;
|
|
@@ -16974,7 +17047,7 @@ function mapPageFrontier(frontier, rows) {
|
|
|
16974
17047
|
}
|
|
16975
17048
|
|
|
16976
17049
|
// src/project-map-language-go.ts
|
|
16977
|
-
import { existsSync as
|
|
17050
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
16978
17051
|
|
|
16979
17052
|
// src/project-map-analysis-validation.ts
|
|
16980
17053
|
function validateMapAnalysis(analysis, input) {
|
|
@@ -17159,13 +17232,13 @@ function utf16Offsets(text) {
|
|
|
17159
17232
|
}
|
|
17160
17233
|
function offsetConverter(files, offsets) {
|
|
17161
17234
|
const converters = /* @__PURE__ */ new Map();
|
|
17162
|
-
return (
|
|
17163
|
-
let convert = converters.get(
|
|
17235
|
+
return (path13, offset) => {
|
|
17236
|
+
let convert = converters.get(path13);
|
|
17164
17237
|
if (!convert) {
|
|
17165
|
-
const text = files[
|
|
17238
|
+
const text = files[path13];
|
|
17166
17239
|
if (text === void 0) return invalid();
|
|
17167
17240
|
convert = offsets === "UTF16" ? (value) => value <= text.length ? value : invalid() : utf16Offsets(text);
|
|
17168
|
-
converters.set(
|
|
17241
|
+
converters.set(path13, convert);
|
|
17169
17242
|
}
|
|
17170
17243
|
return convert(offset);
|
|
17171
17244
|
};
|
|
@@ -17196,7 +17269,7 @@ function mapFactsAnalysis(facts, input, context) {
|
|
|
17196
17269
|
const collect = new MapOutputCollector(output);
|
|
17197
17270
|
const positions = new MapSourcePositions(input.files);
|
|
17198
17271
|
const offset = offsetConverter(input.files, context.offsets);
|
|
17199
|
-
const anchor = (
|
|
17272
|
+
const anchor = (path13, start, end) => positions.span(path13, offset(path13, start), offset(path13, end));
|
|
17200
17273
|
const located = /* @__PURE__ */ new Map();
|
|
17201
17274
|
const canonical = /* @__PURE__ */ new Map();
|
|
17202
17275
|
const bySpan = /* @__PURE__ */ new Map();
|
|
@@ -17361,8 +17434,8 @@ function mapReferencesPage(facts, files, reference, offsets) {
|
|
|
17361
17434
|
|
|
17362
17435
|
// src/project-map-process.ts
|
|
17363
17436
|
import { execFileSync, spawn as spawn2 } from "node:child_process";
|
|
17364
|
-
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
17365
|
-
import
|
|
17437
|
+
import { existsSync as existsSync2, readFileSync, realpathSync } from "node:fs";
|
|
17438
|
+
import path7 from "node:path";
|
|
17366
17439
|
|
|
17367
17440
|
// src/project-map-failure.ts
|
|
17368
17441
|
var PhaseSchema = external_exports.enum([
|
|
@@ -17487,24 +17560,24 @@ var ProjectMapStopUnconfirmedError = class extends ProjectEvidenceError {
|
|
|
17487
17560
|
}
|
|
17488
17561
|
};
|
|
17489
17562
|
var installedMapParserResources = () => {
|
|
17490
|
-
const directory =
|
|
17563
|
+
const directory = path7.dirname(path7.resolve(process.argv[1] ?? "."));
|
|
17491
17564
|
return {
|
|
17492
|
-
workerPath:
|
|
17493
|
-
compilerPath:
|
|
17565
|
+
workerPath: path7.join(directory, "project-map-worker.mjs"),
|
|
17566
|
+
compilerPath: path7.join(directory, "project-map-native/tsc")
|
|
17494
17567
|
};
|
|
17495
17568
|
};
|
|
17496
17569
|
var installedPythonMapResources = () => {
|
|
17497
|
-
const directory =
|
|
17570
|
+
const directory = path7.dirname(path7.resolve(process.argv[1] ?? "."));
|
|
17498
17571
|
return {
|
|
17499
|
-
workerPath:
|
|
17500
|
-
compilerPath:
|
|
17572
|
+
workerPath: path7.join(directory, "project-map-python-worker.mjs"),
|
|
17573
|
+
compilerPath: path7.join(directory, "project-map-python/typeshed")
|
|
17501
17574
|
};
|
|
17502
17575
|
};
|
|
17503
17576
|
function discoverJavaRuntime(env = process.env) {
|
|
17504
17577
|
const homes = [env.LAYERMAP_JAVA_HOME, env.JAVA_HOME];
|
|
17505
|
-
for (const directory of (env.PATH ?? "").split(
|
|
17506
|
-
const java =
|
|
17507
|
-
if (directory &&
|
|
17578
|
+
for (const directory of (env.PATH ?? env.Path ?? "").split(path7.delimiter)) {
|
|
17579
|
+
const java = path7.join(directory, executableName("java"));
|
|
17580
|
+
if (directory && existsSync2(java)) homes.push(path7.dirname(path7.dirname(realpathSync(java))));
|
|
17508
17581
|
}
|
|
17509
17582
|
homes.push(
|
|
17510
17583
|
...["/opt/homebrew/opt", "/usr/local/opt"].flatMap(
|
|
@@ -17512,7 +17585,7 @@ function discoverJavaRuntime(env = process.env) {
|
|
|
17512
17585
|
(formula) => `${prefix}/${formula}/libexec/openjdk.jdk/Contents/Home`
|
|
17513
17586
|
)
|
|
17514
17587
|
),
|
|
17515
|
-
...env.HOME ? [
|
|
17588
|
+
...env.HOME ? [path7.join(env.HOME, ".sdkman/candidates/java/current")] : []
|
|
17516
17589
|
);
|
|
17517
17590
|
if (process.platform === "darwin")
|
|
17518
17591
|
try {
|
|
@@ -17527,11 +17600,12 @@ function discoverJavaRuntime(env = process.env) {
|
|
|
17527
17600
|
}
|
|
17528
17601
|
for (const home of homes) {
|
|
17529
17602
|
if (!home) continue;
|
|
17530
|
-
const runtimePath =
|
|
17531
|
-
if (!
|
|
17603
|
+
const runtimePath = path7.join(home, "bin", executableName("java"));
|
|
17604
|
+
if (!existsSync2(runtimePath) || !existsSync2(path7.join(home, "bin", executableName("javac"))))
|
|
17605
|
+
continue;
|
|
17532
17606
|
let release = "";
|
|
17533
17607
|
try {
|
|
17534
|
-
release = readFileSync(
|
|
17608
|
+
release = readFileSync(path7.join(home, "release"), "utf8");
|
|
17535
17609
|
} catch {
|
|
17536
17610
|
continue;
|
|
17537
17611
|
}
|
|
@@ -17542,28 +17616,26 @@ function discoverJavaRuntime(env = process.env) {
|
|
|
17542
17616
|
return void 0;
|
|
17543
17617
|
}
|
|
17544
17618
|
var installedJavaMapResources = () => {
|
|
17545
|
-
const directory =
|
|
17546
|
-
const compilerPath =
|
|
17619
|
+
const directory = path7.dirname(path7.resolve(process.argv[1] ?? "."));
|
|
17620
|
+
const compilerPath = path7.join(directory, "project-map-java/java-map.jar");
|
|
17547
17621
|
return {
|
|
17548
|
-
workerPath:
|
|
17622
|
+
workerPath: path7.join(directory, "project-map-java-worker.mjs"),
|
|
17549
17623
|
compilerPath,
|
|
17550
17624
|
// A build without a JDK leaves no analyzer to run, whatever runtime this machine has.
|
|
17551
|
-
...
|
|
17625
|
+
...existsSync2(compilerPath) ? discoverJavaRuntime() : {}
|
|
17552
17626
|
};
|
|
17553
17627
|
};
|
|
17554
17628
|
var installedGoMapResources = () => {
|
|
17555
|
-
const directory =
|
|
17629
|
+
const directory = path7.dirname(path7.resolve(process.argv[1] ?? "."));
|
|
17556
17630
|
return {
|
|
17557
|
-
workerPath:
|
|
17558
|
-
compilerPath:
|
|
17631
|
+
workerPath: path7.join(directory, "project-map-go-worker.mjs"),
|
|
17632
|
+
compilerPath: path7.join(directory, "project-map-go/go-map")
|
|
17559
17633
|
};
|
|
17560
17634
|
};
|
|
17561
17635
|
function runMapOperation(resources, input, schema, signal, observeTiming) {
|
|
17562
|
-
if (process.platform === "win32")
|
|
17563
|
-
return Promise.reject(new ProjectEvidenceError("PROJECT_MAP_PLATFORM_UNSUPPORTED", false));
|
|
17564
17636
|
if (signal.aborted)
|
|
17565
17637
|
return Promise.reject(new ProjectEvidenceError("PROJECT_READ_CANCELLED", true));
|
|
17566
|
-
if (!
|
|
17638
|
+
if (!path7.isAbsolute(resources.workerPath) || !path7.isAbsolute(resources.compilerPath)) {
|
|
17567
17639
|
return Promise.reject(
|
|
17568
17640
|
new ProjectEvidenceError("PROJECT_MAP_PARSER_CONFIGURATION_INVALID", false)
|
|
17569
17641
|
);
|
|
@@ -17584,14 +17656,15 @@ function runMapOperation(resources, input, schema, signal, observeTiming) {
|
|
|
17584
17656
|
return new Promise((resolve, reject) => {
|
|
17585
17657
|
const child = spawn2(process.execPath, [...resources.execArgv ?? [], resources.workerPath], {
|
|
17586
17658
|
detached: true,
|
|
17659
|
+
windowsHide: true,
|
|
17587
17660
|
stdio: ["ignore", "pipe", "pipe", "ipc"],
|
|
17588
|
-
env: {
|
|
17661
|
+
env: childEnvironment({
|
|
17589
17662
|
PATH: "/usr/bin:/bin",
|
|
17590
17663
|
LANG: "C",
|
|
17591
17664
|
HOME: process.env.HOME,
|
|
17592
17665
|
TMPDIR: process.env.TMPDIR,
|
|
17593
17666
|
ELECTRON_RUN_AS_NODE: "1"
|
|
17594
|
-
}
|
|
17667
|
+
})
|
|
17595
17668
|
});
|
|
17596
17669
|
let result;
|
|
17597
17670
|
let resultAt;
|
|
@@ -17613,7 +17686,7 @@ function runMapOperation(resources, input, schema, signal, observeTiming) {
|
|
|
17613
17686
|
const kill = (value) => {
|
|
17614
17687
|
if (!child.pid) return;
|
|
17615
17688
|
try {
|
|
17616
|
-
|
|
17689
|
+
stopProcessTree(child.pid, value);
|
|
17617
17690
|
} catch {
|
|
17618
17691
|
}
|
|
17619
17692
|
};
|
|
@@ -17731,11 +17804,7 @@ function runMapOperation(resources, input, schema, signal, observeTiming) {
|
|
|
17731
17804
|
const drained = async () => {
|
|
17732
17805
|
const until = Date.now() + PROJECT_MAP_LIMITS.stopMs;
|
|
17733
17806
|
while (child.pid) {
|
|
17734
|
-
|
|
17735
|
-
process.kill(-child.pid, 0);
|
|
17736
|
-
} catch (error51) {
|
|
17737
|
-
if (error51.code === "ESRCH") return true;
|
|
17738
|
-
}
|
|
17807
|
+
if (processTreeGone(child.pid)) return true;
|
|
17739
17808
|
if (Date.now() >= until) return false;
|
|
17740
17809
|
await new Promise((resolve2) => setTimeout(resolve2, 20));
|
|
17741
17810
|
}
|
|
@@ -17766,8 +17835,8 @@ var goModule = /(?:^|\/)go\.mod$/u;
|
|
|
17766
17835
|
var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
|
|
17767
17836
|
var GO_MAP_LANGUAGE = Object.freeze({
|
|
17768
17837
|
id: "go-1.24-map-v9",
|
|
17769
|
-
claims: (
|
|
17770
|
-
reads: (
|
|
17838
|
+
claims: (path13) => path13.endsWith(".go"),
|
|
17839
|
+
reads: (path13) => goModule.test(path13),
|
|
17771
17840
|
// A module path, or the standard library, whose first path element has no dot.
|
|
17772
17841
|
importName: (specifier) => {
|
|
17773
17842
|
const parts = specifier.split("/");
|
|
@@ -17776,7 +17845,7 @@ var GO_MAP_LANGUAGE = Object.freeze({
|
|
|
17776
17845
|
return parts.slice(0, size).join("/");
|
|
17777
17846
|
},
|
|
17778
17847
|
// Go imports a package: the directory of the file.
|
|
17779
|
-
importTarget: (
|
|
17848
|
+
importTarget: (path13) => `${path13.slice(0, path13.lastIndexOf("/") + 1) || "./"}`,
|
|
17780
17849
|
create: () => new GoMapAnalyzer()
|
|
17781
17850
|
});
|
|
17782
17851
|
var GO_GAPS = [
|
|
@@ -17822,12 +17891,12 @@ var GoMapAnalyzer = class {
|
|
|
17822
17891
|
}
|
|
17823
17892
|
}
|
|
17824
17893
|
async analyze(session, signal) {
|
|
17825
|
-
const modules = session.readable.map((entry) => entry.path).filter((
|
|
17826
|
-
const moduleOf = (
|
|
17894
|
+
const modules = session.readable.map((entry) => entry.path).filter((path13) => goModule.test(path13)).sort();
|
|
17895
|
+
const moduleOf = (path13) => {
|
|
17827
17896
|
let best;
|
|
17828
17897
|
for (const modFile of modules) {
|
|
17829
17898
|
const directory = modFile.slice(0, modFile.lastIndexOf("/") + 1);
|
|
17830
|
-
if (
|
|
17899
|
+
if (path13.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
|
|
17831
17900
|
best = modFile;
|
|
17832
17901
|
}
|
|
17833
17902
|
return best;
|
|
@@ -17843,11 +17912,11 @@ var GoMapAnalyzer = class {
|
|
|
17843
17912
|
for (const modFile of [...groups.keys()].sort()) {
|
|
17844
17913
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
17845
17914
|
const files = /* @__PURE__ */ Object.create(null);
|
|
17846
|
-
for (const
|
|
17847
|
-
const text = session.texts[
|
|
17915
|
+
for (const path13 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
|
|
17916
|
+
const text = session.texts[path13];
|
|
17848
17917
|
if (text === void 0)
|
|
17849
17918
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
17850
|
-
files[
|
|
17919
|
+
files[path13] = text;
|
|
17851
17920
|
}
|
|
17852
17921
|
const input = {
|
|
17853
17922
|
contextRef: digestValue({
|
|
@@ -17859,7 +17928,7 @@ var GoMapAnalyzer = class {
|
|
|
17859
17928
|
inventory: Object.keys(files).sort(),
|
|
17860
17929
|
syntaxOnly: false
|
|
17861
17930
|
};
|
|
17862
|
-
const built =
|
|
17931
|
+
const built = existsSync3(this.resources.compilerPath);
|
|
17863
17932
|
const reused = session.reuse(input.contextRef, { modFile, built }, Object.keys(files));
|
|
17864
17933
|
if (reused) {
|
|
17865
17934
|
session.accept(reused);
|
|
@@ -17879,11 +17948,11 @@ var GoMapAnalyzer = class {
|
|
|
17879
17948
|
}
|
|
17880
17949
|
async references(input, reference, signal, observe) {
|
|
17881
17950
|
const text = input.files[reference.targetPath];
|
|
17882
|
-
if (text === void 0 || !
|
|
17951
|
+
if (text === void 0 || !existsSync3(this.resources.compilerPath))
|
|
17883
17952
|
throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
|
|
17884
17953
|
const files = /* @__PURE__ */ Object.create(null);
|
|
17885
|
-
for (const [
|
|
17886
|
-
if (this.claims(
|
|
17954
|
+
for (const [path13, value] of Object.entries(input.files))
|
|
17955
|
+
if (this.claims(path13) || goModule.test(path13)) files[path13] = value;
|
|
17887
17956
|
const facts = await this.operation(
|
|
17888
17957
|
{
|
|
17889
17958
|
...input,
|
|
@@ -17904,7 +17973,7 @@ var GoMapAnalyzer = class {
|
|
|
17904
17973
|
};
|
|
17905
17974
|
|
|
17906
17975
|
// src/project-map-language-java.ts
|
|
17907
|
-
import { existsSync as
|
|
17976
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
17908
17977
|
var BUILD_FILES = [
|
|
17909
17978
|
"settings.gradle.kts",
|
|
17910
17979
|
"settings.gradle",
|
|
@@ -17913,14 +17982,14 @@ var BUILD_FILES = [
|
|
|
17913
17982
|
"pom.xml"
|
|
17914
17983
|
];
|
|
17915
17984
|
var buildFile = /(?:^|\/)(?:pom\.xml|(?:build|settings)\.gradle(?:\.kts)?)$/u;
|
|
17916
|
-
var directoryOf = (
|
|
17917
|
-
var nameOf = (
|
|
17985
|
+
var directoryOf = (path13) => path13.slice(0, path13.lastIndexOf("/") + 1);
|
|
17986
|
+
var nameOf = (path13) => path13.slice(path13.lastIndexOf("/") + 1);
|
|
17918
17987
|
var DEFAULT_RELEASE = 21;
|
|
17919
17988
|
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;
|
|
17920
17989
|
var JAVA_MAP_LANGUAGE = Object.freeze({
|
|
17921
17990
|
id: "javac-lombok-1.18.48-map-v8",
|
|
17922
|
-
claims: (
|
|
17923
|
-
reads: (
|
|
17991
|
+
claims: (path13) => path13.endsWith(".java"),
|
|
17992
|
+
reads: (path13) => buildFile.test(path13),
|
|
17924
17993
|
// A package of the Java platform, or a library named by its first two package segments.
|
|
17925
17994
|
importName: (specifier) => platformPackage.test(specifier) ? "Java standard library" : specifier.split(".").slice(0, 2).join("."),
|
|
17926
17995
|
create: () => new JavaMapAnalyzer()
|
|
@@ -17983,7 +18052,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
17983
18052
|
// The runtime found at startup may be gone since (an upgraded JDK replaces its directory).
|
|
17984
18053
|
refreshRuntime() {
|
|
17985
18054
|
const { runtimePath } = this.resources;
|
|
17986
|
-
if (runtimePath && !
|
|
18055
|
+
if (runtimePath && !existsSync4(runtimePath)) {
|
|
17987
18056
|
const { runtimePath: _gone, runtimeVersion: _version, ...rest } = this.resources;
|
|
17988
18057
|
this.resources = { ...rest, ...discoverJavaRuntime() };
|
|
17989
18058
|
}
|
|
@@ -18010,12 +18079,12 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18010
18079
|
// The worker's request for a context: the Java sources, the release and which are tests.
|
|
18011
18080
|
request(input, buildTexts) {
|
|
18012
18081
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18013
|
-
for (const [
|
|
18014
|
-
if (this.claims(
|
|
18082
|
+
for (const [path13, text] of Object.entries(input.files))
|
|
18083
|
+
if (this.claims(path13)) files[path13] = text;
|
|
18015
18084
|
return {
|
|
18016
18085
|
files,
|
|
18017
18086
|
release: javaRelease(buildTexts, this.resources.runtimeVersion),
|
|
18018
|
-
tests: Object.keys(files).filter((
|
|
18087
|
+
tests: Object.keys(files).filter((path13) => mapTestPath(path13))
|
|
18019
18088
|
};
|
|
18020
18089
|
}
|
|
18021
18090
|
// The build files of a context's root directory, which declare its Java version.
|
|
@@ -18027,35 +18096,35 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18027
18096
|
}
|
|
18028
18097
|
async analyze(session, signal) {
|
|
18029
18098
|
this.refreshRuntime();
|
|
18030
|
-
const builds = session.readable.map((entry) => entry.path).filter((
|
|
18031
|
-
for (const
|
|
18032
|
-
const rank2 = (
|
|
18099
|
+
const builds = session.readable.map((entry) => entry.path).filter((path13) => buildFile.test(path13));
|
|
18100
|
+
for (const path13 of builds) session.configuration(path13);
|
|
18101
|
+
const rank2 = (path13) => BUILD_FILES.indexOf(nameOf(path13));
|
|
18033
18102
|
const roots = /* @__PURE__ */ new Map();
|
|
18034
18103
|
const modules = /* @__PURE__ */ new Map();
|
|
18035
|
-
for (const
|
|
18036
|
-
const directory = directoryOf(
|
|
18104
|
+
for (const path13 of builds) {
|
|
18105
|
+
const directory = directoryOf(path13);
|
|
18037
18106
|
const current = modules.get(directory);
|
|
18038
|
-
if (current === void 0 || rank2(
|
|
18039
|
-
const text = session.texts[
|
|
18040
|
-
if (/settings\.gradle(?:\.kts)?$/u.test(
|
|
18107
|
+
if (current === void 0 || rank2(path13) < rank2(current)) modules.set(directory, path13);
|
|
18108
|
+
const text = session.texts[path13] ?? "";
|
|
18109
|
+
if (/settings\.gradle(?:\.kts)?$/u.test(path13) || path13.endsWith("pom.xml") && /<modules>/u.test(text)) {
|
|
18041
18110
|
const root = roots.get(directory);
|
|
18042
|
-
if (root === void 0 || rank2(
|
|
18111
|
+
if (root === void 0 || rank2(path13) < rank2(root)) roots.set(directory, path13);
|
|
18043
18112
|
}
|
|
18044
18113
|
}
|
|
18045
|
-
const configOf = (
|
|
18114
|
+
const configOf = (path13) => {
|
|
18046
18115
|
let outer;
|
|
18047
18116
|
for (const directory of roots.keys())
|
|
18048
|
-
if (
|
|
18117
|
+
if (path13.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
|
|
18049
18118
|
outer = directory;
|
|
18050
18119
|
if (outer !== void 0) return roots.get(outer);
|
|
18051
18120
|
let nearest;
|
|
18052
18121
|
for (const directory of modules.keys())
|
|
18053
|
-
if (
|
|
18122
|
+
if (path13.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
|
|
18054
18123
|
nearest = directory;
|
|
18055
18124
|
return nearest === void 0 ? "" : modules.get(nearest);
|
|
18056
18125
|
};
|
|
18057
|
-
const output = (
|
|
18058
|
-
(directory) =>
|
|
18126
|
+
const output = (path13) => [...modules.keys()].some(
|
|
18127
|
+
(directory) => path13.startsWith(`${directory}build/`) || path13.startsWith(`${directory}target/`)
|
|
18059
18128
|
);
|
|
18060
18129
|
const groups = /* @__PURE__ */ new Map();
|
|
18061
18130
|
for (const entry of session.readable) {
|
|
@@ -18070,13 +18139,13 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18070
18139
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
18071
18140
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18072
18141
|
const rootBuilds = configPath ? BUILD_FILES.map((name) => `${directoryOf(configPath)}${name}`).filter(
|
|
18073
|
-
(
|
|
18142
|
+
(path13) => builds.includes(path13)
|
|
18074
18143
|
) : [];
|
|
18075
|
-
for (const
|
|
18076
|
-
const text = session.texts[
|
|
18144
|
+
for (const path13 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
|
|
18145
|
+
const text = session.texts[path13];
|
|
18077
18146
|
if (text === void 0)
|
|
18078
18147
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18079
|
-
files[
|
|
18148
|
+
files[path13] = text;
|
|
18080
18149
|
}
|
|
18081
18150
|
const input = {
|
|
18082
18151
|
contextRef: digestValue({
|
|
@@ -18101,7 +18170,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18101
18170
|
release: request.release,
|
|
18102
18171
|
tests: request.tests,
|
|
18103
18172
|
runtime,
|
|
18104
|
-
built:
|
|
18173
|
+
built: existsSync4(this.resources.compilerPath),
|
|
18105
18174
|
lombokConfig
|
|
18106
18175
|
},
|
|
18107
18176
|
Object.keys(files)
|
|
@@ -18119,7 +18188,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18119
18188
|
const prior = JavaStateSchema.safeParse(previous?.state).data;
|
|
18120
18189
|
const incremental = previous && prior?.basis === basis ? {
|
|
18121
18190
|
changed: Object.keys(request.files).filter(
|
|
18122
|
-
(
|
|
18191
|
+
(path13) => digests.get(path13) !== previous.digests.get(path13)
|
|
18123
18192
|
),
|
|
18124
18193
|
state: prior.java
|
|
18125
18194
|
} : void 0;
|
|
@@ -18136,7 +18205,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18136
18205
|
this.resources.runtimeVersion,
|
|
18137
18206
|
[
|
|
18138
18207
|
...this.resources.runtimePath ? [] : [
|
|
18139
|
-
|
|
18208
|
+
existsSync4(this.resources.compilerPath) ? "JAVA_RUNTIME_UNAVAILABLE" : "JAVA_ANALYZER_NOT_BUILT"
|
|
18140
18209
|
],
|
|
18141
18210
|
...lombokConfig ? ["LOMBOK_CONFIG_NOT_APPLIED"] : []
|
|
18142
18211
|
]
|
|
@@ -18148,14 +18217,14 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18148
18217
|
continue;
|
|
18149
18218
|
}
|
|
18150
18219
|
const focus = new Set(facts.focus);
|
|
18151
|
-
if (!incremental || facts.focus.some((
|
|
18220
|
+
if (!incremental || facts.focus.some((path13) => !Object.hasOwn(request.files, path13)) || incremental.changed.some((path13) => !focus.has(path13)))
|
|
18152
18221
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18153
18222
|
analysis.objects = analysis.objects.filter((object2) => focus.has(object2.anchor.path));
|
|
18154
18223
|
analysis.relations = analysis.relations.filter((relation) => focus.has(relation.anchor.path));
|
|
18155
18224
|
analysis.notes = analysis.notes.filter((note) => focus.has(note.anchor.path));
|
|
18156
18225
|
session.accept(analysis, {
|
|
18157
18226
|
state,
|
|
18158
|
-
linked: analysis.parsedFiles.filter((
|
|
18227
|
+
linked: analysis.parsedFiles.filter((path13) => !focus.has(path13))
|
|
18159
18228
|
});
|
|
18160
18229
|
}
|
|
18161
18230
|
}
|
|
@@ -18467,12 +18536,12 @@ var PYTHON_STANDARD_LIBRARY = /* @__PURE__ */ new Set([
|
|
|
18467
18536
|
// src/project-map-language-python.ts
|
|
18468
18537
|
var CONFIGURATION = ["pyrightconfig.json", "pyproject.toml", "setup.cfg"];
|
|
18469
18538
|
var pythonConfig = /(?:^|\/)(?:pyrightconfig\.json|pyproject\.toml|setup\.cfg)$/u;
|
|
18470
|
-
var directoryOf2 = (
|
|
18539
|
+
var directoryOf2 = (path13) => path13.slice(0, path13.lastIndexOf("/") + 1);
|
|
18471
18540
|
var DEFAULT_PYTHON = { major: 3, minor: 13 };
|
|
18472
18541
|
var PYTHON_MAP_LANGUAGE = Object.freeze({
|
|
18473
18542
|
id: "pyright-1.1.414-map-v13",
|
|
18474
|
-
claims: (
|
|
18475
|
-
reads: (
|
|
18543
|
+
claims: (path13) => /\.pyi?$/u.test(path13),
|
|
18544
|
+
reads: (path13) => pythonConfig.test(path13),
|
|
18476
18545
|
// An absolute import names the standard library or a distribution's top-level package.
|
|
18477
18546
|
importName: (specifier) => {
|
|
18478
18547
|
const top = specifier.split(".", 1)[0] ?? specifier;
|
|
@@ -18524,21 +18593,21 @@ var PythonMapAnalyzer = class {
|
|
|
18524
18593
|
return {
|
|
18525
18594
|
root: input.configPath ? directoryOf2(input.configPath).replace(/\/$/u, "") : "",
|
|
18526
18595
|
pythonVersion: pythonVersion(input.files, input.configPath),
|
|
18527
|
-
tests: Object.keys(input.files).filter((
|
|
18596
|
+
tests: Object.keys(input.files).filter((path13) => this.claims(path13) && mapTestPath(path13))
|
|
18528
18597
|
};
|
|
18529
18598
|
}
|
|
18530
18599
|
async analyze(session, signal) {
|
|
18531
18600
|
const roots = /* @__PURE__ */ new Map();
|
|
18532
|
-
for (const
|
|
18533
|
-
const directory = directoryOf2(
|
|
18601
|
+
for (const path13 of session.readable.map((entry) => entry.path).filter((path14) => pythonConfig.test(path14))) {
|
|
18602
|
+
const directory = directoryOf2(path13);
|
|
18534
18603
|
const current = roots.get(directory);
|
|
18535
18604
|
const rank2 = (file2) => CONFIGURATION.indexOf(file2.slice(directory.length));
|
|
18536
|
-
if (current === void 0 || rank2(
|
|
18605
|
+
if (current === void 0 || rank2(path13) < rank2(current)) roots.set(directory, path13);
|
|
18537
18606
|
}
|
|
18538
|
-
const rootOf = (
|
|
18607
|
+
const rootOf = (path13) => {
|
|
18539
18608
|
let best;
|
|
18540
18609
|
for (const directory of roots.keys())
|
|
18541
|
-
if (
|
|
18610
|
+
if (path13.startsWith(directory) && (best === void 0 || directory.length > best.length))
|
|
18542
18611
|
best = directory;
|
|
18543
18612
|
return best === void 0 ? "" : roots.get(best);
|
|
18544
18613
|
};
|
|
@@ -18553,11 +18622,11 @@ var PythonMapAnalyzer = class {
|
|
|
18553
18622
|
for (const configPath of [...groups.keys()].sort()) {
|
|
18554
18623
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
18555
18624
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18556
|
-
for (const
|
|
18557
|
-
const text = session.texts[
|
|
18625
|
+
for (const path13 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
|
|
18626
|
+
const text = session.texts[path13];
|
|
18558
18627
|
if (text === void 0)
|
|
18559
18628
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18560
|
-
files[
|
|
18629
|
+
files[path13] = text;
|
|
18561
18630
|
}
|
|
18562
18631
|
const input = {
|
|
18563
18632
|
contextRef: digestValue({
|
|
@@ -18605,8 +18674,8 @@ var PythonMapAnalyzer = class {
|
|
|
18605
18674
|
if (input.files[reference.targetPath] === void 0)
|
|
18606
18675
|
throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
|
|
18607
18676
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18608
|
-
for (const [
|
|
18609
|
-
if (this.claims(
|
|
18677
|
+
for (const [path13, value] of Object.entries(input.files))
|
|
18678
|
+
if (this.claims(path13) || pythonConfig.test(path13)) files[path13] = value;
|
|
18610
18679
|
const facts = await this.operation(
|
|
18611
18680
|
{
|
|
18612
18681
|
...input,
|
|
@@ -18626,8 +18695,8 @@ var PythonMapAnalyzer = class {
|
|
|
18626
18695
|
// src/project-map-language-typescript.ts
|
|
18627
18696
|
var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
18628
18697
|
id: "typescript-7.0.2-map-v17",
|
|
18629
|
-
claims: (
|
|
18630
|
-
reads: (
|
|
18698
|
+
claims: (path13) => /\.[cm]?[jt]sx?$/u.test(path13),
|
|
18699
|
+
reads: (path13) => path13.endsWith(".json") || path13 === "pnpm-workspace.yaml",
|
|
18631
18700
|
create: () => new TypeScriptMapAnalyzer()
|
|
18632
18701
|
});
|
|
18633
18702
|
var CONFIGURATIONS_KEPT = 4;
|
|
@@ -18739,9 +18808,9 @@ var TypeScriptMapAnalyzer = class {
|
|
|
18739
18808
|
accept(analysis);
|
|
18740
18809
|
return;
|
|
18741
18810
|
}
|
|
18742
|
-
const required2 = analysis.requiredFiles.map((
|
|
18743
|
-
const entry = byPath.get(
|
|
18744
|
-
if (!entry || Object.hasOwn(texts,
|
|
18811
|
+
const required2 = analysis.requiredFiles.map((path13) => {
|
|
18812
|
+
const entry = byPath.get(path13);
|
|
18813
|
+
if (!entry || Object.hasOwn(texts, path13))
|
|
18745
18814
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18746
18815
|
return entry;
|
|
18747
18816
|
});
|
|
@@ -18799,16 +18868,16 @@ var MAP_LANGUAGES = Object.freeze([
|
|
|
18799
18868
|
]);
|
|
18800
18869
|
var mapAnalyzerSuite = (languages) => languages.map((language) => language.id).sort().join("+");
|
|
18801
18870
|
var PROJECT_MAP_ANALYZER = mapAnalyzerSuite(MAP_LANGUAGES);
|
|
18802
|
-
var mapCodePath = (
|
|
18803
|
-
var languageOf = (
|
|
18804
|
-
var mapLanguageOf = (
|
|
18871
|
+
var mapCodePath = (path13) => MAP_LANGUAGES.some((language) => language.claims(path13));
|
|
18872
|
+
var languageOf = (path13) => MAP_LANGUAGES.find((language) => language.claims(path13));
|
|
18873
|
+
var mapLanguageOf = (path13) => languageOf(path13)?.id;
|
|
18805
18874
|
var npmPackage = (specifier) => {
|
|
18806
18875
|
if (specifier.startsWith("node:")) return "node:*";
|
|
18807
18876
|
const parts = specifier.split("/");
|
|
18808
18877
|
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? specifier;
|
|
18809
18878
|
};
|
|
18810
18879
|
var mapExternalImport = (sourcePath, specifier) => languageOf(sourcePath)?.importName?.(specifier) ?? npmPackage(specifier);
|
|
18811
|
-
var mapImportTarget = (
|
|
18880
|
+
var mapImportTarget = (path13) => languageOf(path13)?.importTarget?.(path13) ?? path13;
|
|
18812
18881
|
|
|
18813
18882
|
// src/project-map-view.ts
|
|
18814
18883
|
var MAP_VIEW_FORMAT = "PROJECT_MAP_VIEW_V1";
|
|
@@ -18847,10 +18916,10 @@ var notFound = () => {
|
|
|
18847
18916
|
};
|
|
18848
18917
|
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";
|
|
18849
18918
|
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.`;
|
|
18850
|
-
var within = (
|
|
18851
|
-
var parentDirectory = (
|
|
18852
|
-
const slash =
|
|
18853
|
-
return slash < 0 ? "." :
|
|
18919
|
+
var within = (path13, directory) => directory === "." || path13.startsWith(`${directory}/`);
|
|
18920
|
+
var parentDirectory = (path13) => {
|
|
18921
|
+
const slash = path13.lastIndexOf("/");
|
|
18922
|
+
return slash < 0 ? "." : path13.slice(0, slash);
|
|
18854
18923
|
};
|
|
18855
18924
|
var compareText2 = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
18856
18925
|
var byCount = ([leftName, left], [rightName, right]) => right - left || compareText2(leftName, rightName);
|
|
@@ -18924,7 +18993,7 @@ function pageBlocks(view, head, whole, offset, budget) {
|
|
|
18924
18993
|
if (offset === blocks.length) return materialize(0);
|
|
18925
18994
|
return mapQueryPage(blocks.length - offset, materialize, (page) => page, budget);
|
|
18926
18995
|
}
|
|
18927
|
-
var inModule = (
|
|
18996
|
+
var inModule = (path13, module) => module.direct ? parentDirectory(path13) === module.directory : within(path13, module.directory);
|
|
18928
18997
|
var moduleLabel = (module) => module.direct ? `${module.directory === "." ? "" : `${module.directory}/`}* (files directly here)` : `${module.directory}/`;
|
|
18929
18998
|
function childModules(module, files) {
|
|
18930
18999
|
if (module.direct) return [];
|
|
@@ -19077,12 +19146,12 @@ function loadMemberCalls(store, version2) {
|
|
|
19077
19146
|
FROM project_map_relations
|
|
19078
19147
|
WHERE version_ref = ? AND to_ref IS NULL AND json_extract(relation_json, '$.kind') = 'CALLS'
|
|
19079
19148
|
AND json_extract(relation_json, '$.unresolvedReason') IN ('SYMBOL_NOT_RESOLVED', 'SYNTAX_ONLY')`).all(version2)) {
|
|
19080
|
-
const
|
|
19149
|
+
const path13 = String(row.path);
|
|
19081
19150
|
const target = String(row.target);
|
|
19082
19151
|
const name = MEMBER_NAME.exec(target)?.[1];
|
|
19083
|
-
const language = mapLanguageOf(
|
|
19152
|
+
const language = mapLanguageOf(path13);
|
|
19084
19153
|
if (!name || !language) continue;
|
|
19085
|
-
const call = { from: String(row.from_ref), path:
|
|
19154
|
+
const call = { from: String(row.from_ref), path: path13, line: Number(row.line), target };
|
|
19086
19155
|
const key = memberKey(language, name);
|
|
19087
19156
|
const known = calls.get(key);
|
|
19088
19157
|
if (known) known.push(call);
|
|
@@ -19137,10 +19206,10 @@ function loadCoverageNotes(store, version2) {
|
|
|
19137
19206
|
if (!codes.includes(gap.code)) codes.push(gap.code);
|
|
19138
19207
|
files.set(gap.path, codes);
|
|
19139
19208
|
}
|
|
19140
|
-
for (const [
|
|
19209
|
+
for (const [path13, codes] of files)
|
|
19141
19210
|
if (codes.length > 1 && codes.includes("NOT_IN_PARSED_CONTEXT"))
|
|
19142
19211
|
files.set(
|
|
19143
|
-
|
|
19212
|
+
path13,
|
|
19144
19213
|
codes.filter((code) => code !== "NOT_IN_PARSED_CONTEXT")
|
|
19145
19214
|
);
|
|
19146
19215
|
return { files, limits: [...limits] };
|
|
@@ -19175,9 +19244,9 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19175
19244
|
const visiblePaths = new Set(visible.map((entry) => entry.path));
|
|
19176
19245
|
const code = visible.filter((entry) => entry.state === "TEXT" && mapCodePath(entry.path)).map((entry) => entry.path);
|
|
19177
19246
|
const modules = mapModules(directory, code);
|
|
19178
|
-
const moduleOf = (
|
|
19179
|
-
const outside = (
|
|
19180
|
-
const parts =
|
|
19247
|
+
const moduleOf = (path13) => modules.find((module) => inModule(path13, module));
|
|
19248
|
+
const outside = (path13) => {
|
|
19249
|
+
const parts = path13.split("/");
|
|
19181
19250
|
return `${parts.slice(0, Math.min(2, parts.length - 1)).join("/") || "."}/ (outside)`;
|
|
19182
19251
|
};
|
|
19183
19252
|
const moduleImports = /* @__PURE__ */ new Map();
|
|
@@ -19202,8 +19271,8 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19202
19271
|
const blocks = [];
|
|
19203
19272
|
if (modules.length > 1) {
|
|
19204
19273
|
const sizes = /* @__PURE__ */ new Map();
|
|
19205
|
-
for (const
|
|
19206
|
-
const module = moduleOf(
|
|
19274
|
+
for (const path13 of code) {
|
|
19275
|
+
const module = moduleOf(path13);
|
|
19207
19276
|
if (module) increment(sizes, moduleLabel(module));
|
|
19208
19277
|
}
|
|
19209
19278
|
blocks.push(
|
|
@@ -19232,18 +19301,18 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19232
19301
|
)}${packages.length > shown.length ? `, +${packages.length - shown.length} more` : ""}`
|
|
19233
19302
|
);
|
|
19234
19303
|
}
|
|
19235
|
-
const lineCount = (
|
|
19236
|
-
const file2 = facts.files.get(
|
|
19237
|
-
const gaps = coverage.files.get(
|
|
19304
|
+
const lineCount = (path13) => {
|
|
19305
|
+
const file2 = facts.files.get(path13);
|
|
19306
|
+
const gaps = coverage.files.get(path13) ?? [];
|
|
19238
19307
|
if (file2?.parsed === false) return `[not parsed${gaps.length ? `: ${gaps.join("; ")}` : ""}]`;
|
|
19239
19308
|
return `${file2 ? `${file2.lines}L` : "?L"}${gaps.length ? ` [${gaps.join("; ")}]` : ""}`;
|
|
19240
19309
|
};
|
|
19241
19310
|
const codeDirectories = /* @__PURE__ */ new Set();
|
|
19242
|
-
for (const
|
|
19243
|
-
for (let parent = parentDirectory(
|
|
19311
|
+
for (const path13 of code)
|
|
19312
|
+
for (let parent = parentDirectory(path13); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
|
|
19244
19313
|
codeDirectories.add(parent);
|
|
19245
|
-
const groupOf = (
|
|
19246
|
-
let group = parentDirectory(
|
|
19314
|
+
const groupOf = (path13) => {
|
|
19315
|
+
let group = parentDirectory(path13);
|
|
19247
19316
|
for (let parent = group; parent !== "." && parent !== directory && !codeDirectories.has(parent); parent = parentDirectory(parent))
|
|
19248
19317
|
group = parent;
|
|
19249
19318
|
return group;
|
|
@@ -19275,11 +19344,11 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19275
19344
|
]);
|
|
19276
19345
|
}
|
|
19277
19346
|
const detailed = [
|
|
19278
|
-
...code.map((
|
|
19279
|
-
const declarations = (facts.exported.get(
|
|
19347
|
+
...code.map((path13) => {
|
|
19348
|
+
const declarations = (facts.exported.get(path13) ?? []).map(({ text: text2 }) => text2);
|
|
19280
19349
|
return [
|
|
19281
|
-
|
|
19282
|
-
`${
|
|
19350
|
+
path13,
|
|
19351
|
+
`${path13} ${lineCount(path13)}${declarations.length ? `: ${declarations.join(", ")}` : ""}`
|
|
19283
19352
|
];
|
|
19284
19353
|
}),
|
|
19285
19354
|
...listedOther.map((entry) => [
|
|
@@ -19290,7 +19359,7 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19290
19359
|
];
|
|
19291
19360
|
const directories = /* @__PURE__ */ new Map();
|
|
19292
19361
|
for (const entry of [
|
|
19293
|
-
...code.map((
|
|
19362
|
+
...code.map((path13) => ({ path: path13, item: lineCount(path13) })),
|
|
19294
19363
|
...listedOther.map((entry2) => ({
|
|
19295
19364
|
path: entry2.path,
|
|
19296
19365
|
item: entry2.state === "TEXT" ? "" : `(${entry2.state})`
|
|
@@ -19318,10 +19387,10 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19318
19387
|
);
|
|
19319
19388
|
const text = visible.filter((entry) => entry.state === "TEXT").length;
|
|
19320
19389
|
const resolution = /* @__PURE__ */ new Map();
|
|
19321
|
-
for (const
|
|
19322
|
-
const counts = facts.calls.get(
|
|
19390
|
+
for (const path13 of code) {
|
|
19391
|
+
const counts = facts.calls.get(path13);
|
|
19323
19392
|
if (!counts) continue;
|
|
19324
|
-
const language = facts.files.get(
|
|
19393
|
+
const language = facts.files.get(path13)?.language ?? "unknown";
|
|
19325
19394
|
const total = resolution.get(language) ?? { resolved: 0, unresolved: 0, external: 0 };
|
|
19326
19395
|
total.resolved += counts.resolved;
|
|
19327
19396
|
total.unresolved += counts.unresolved;
|
|
@@ -19379,8 +19448,8 @@ var DeclarationGroups = class {
|
|
|
19379
19448
|
prefixes;
|
|
19380
19449
|
showTests;
|
|
19381
19450
|
memberCalls;
|
|
19382
|
-
visible(
|
|
19383
|
-
return mapPathAllowed(
|
|
19451
|
+
visible(path13) {
|
|
19452
|
+
return mapPathAllowed(path13, this.prefixes) && (this.showTests || !mapTestPath(path13));
|
|
19384
19453
|
}
|
|
19385
19454
|
entry(object2, imported = false) {
|
|
19386
19455
|
if (mapIsModule(object2)) return imported ? "(file)" : "(module scope)";
|
|
@@ -19424,11 +19493,11 @@ var DeclarationGroups = class {
|
|
|
19424
19493
|
value.lines.push(line);
|
|
19425
19494
|
aggregates.set(key, value);
|
|
19426
19495
|
};
|
|
19427
|
-
const dispatch = (arrow, label, ref2,
|
|
19496
|
+
const dispatch = (arrow, label, ref2, path13, line) => {
|
|
19428
19497
|
const other = graph.object(graph.owner(ref2));
|
|
19429
19498
|
if (owned.has(other.id)) return;
|
|
19430
|
-
if (!this.visible(
|
|
19431
|
-
if (mapPathAllowed(
|
|
19499
|
+
if (!this.visible(path13)) {
|
|
19500
|
+
if (mapPathAllowed(path13, this.prefixes)) omittedTests++;
|
|
19432
19501
|
return;
|
|
19433
19502
|
}
|
|
19434
19503
|
add(arrow, label, other, line);
|
|
@@ -19585,7 +19654,7 @@ var DeclarationGroups = class {
|
|
|
19585
19654
|
else files2.set(call.path, [item]);
|
|
19586
19655
|
}
|
|
19587
19656
|
lines.push(
|
|
19588
|
-
` \u2190 possible callers by name: ${[...files2].map(([
|
|
19657
|
+
` \u2190 possible callers by name: ${[...files2].map(([path13, items]) => `${path13}: ${items.join(", ")}`).join("; ")}${inTests}`
|
|
19589
19658
|
);
|
|
19590
19659
|
} else if (possibleInTests)
|
|
19591
19660
|
lines.push(` \u2190 possible callers by name: ${possibleInTests} in test files (includeTests)`);
|
|
@@ -19621,14 +19690,14 @@ var DeclarationGroups = class {
|
|
|
19621
19690
|
return { lines, neighbors: [...new Set(neighbors)] };
|
|
19622
19691
|
}
|
|
19623
19692
|
};
|
|
19624
|
-
function fileView(store, coverage, graph, input,
|
|
19625
|
-
const entry = store.getEntry(input.version,
|
|
19626
|
-
if (!entry || !mapPathAllowed(
|
|
19627
|
-
const showTests = input.includeTests === true || mapTestPath(
|
|
19628
|
-
const module = mapCodePath(
|
|
19629
|
-
const gaps = coverage.files.get(
|
|
19693
|
+
function fileView(store, coverage, graph, input, path13, prefixes) {
|
|
19694
|
+
const entry = store.getEntry(input.version, path13);
|
|
19695
|
+
if (!entry || !mapPathAllowed(path13, prefixes)) return notFound();
|
|
19696
|
+
const showTests = input.includeTests === true || mapTestPath(path13);
|
|
19697
|
+
const module = mapCodePath(path13) ? graph.objectsAt(path13).find((object2) => mapIsModule(object2)) : void 0;
|
|
19698
|
+
const gaps = coverage.files.get(path13) ?? [];
|
|
19630
19699
|
const head = [
|
|
19631
|
-
`PROJECT MAP \xB7 FILE ${
|
|
19700
|
+
`PROJECT MAP \xB7 FILE ${path13} \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`}`
|
|
19632
19701
|
];
|
|
19633
19702
|
if (!module || entry.state !== "TEXT")
|
|
19634
19703
|
return pageBlocks("FILE", head, [], input.offset ?? 0, input.outputBudget);
|
|
@@ -19648,7 +19717,7 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
|
|
|
19648
19717
|
tags.set(relation.from, list);
|
|
19649
19718
|
}
|
|
19650
19719
|
const describe3 = (object2) => [
|
|
19651
|
-
`${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path ===
|
|
19720
|
+
`${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path13 ? "" : ` (${object2.anchor.path})`}`,
|
|
19652
19721
|
...tags.get(object2.id) ?? []
|
|
19653
19722
|
].join(" ");
|
|
19654
19723
|
const declarations = [];
|
|
@@ -19663,11 +19732,11 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
|
|
|
19663
19732
|
);
|
|
19664
19733
|
}
|
|
19665
19734
|
const elsewhere = /* @__PURE__ */ new Map();
|
|
19666
|
-
for (const object2 of graph.objectsAt(
|
|
19735
|
+
for (const object2 of graph.objectsAt(path13)) {
|
|
19667
19736
|
const parent = mapIsModule(object2) ? void 0 : graph.parent(object2.id);
|
|
19668
19737
|
if (parent === void 0 || !graph.isAddressable(object2)) continue;
|
|
19669
19738
|
const container = graph.object(parent);
|
|
19670
|
-
if (mapIsModule(container) || container.anchor.path ===
|
|
19739
|
+
if (mapIsModule(container) || container.anchor.path === path13) continue;
|
|
19671
19740
|
const into = elsewhere.get(parent);
|
|
19672
19741
|
if (into) into.push(object2);
|
|
19673
19742
|
else elsewhere.set(parent, [object2]);
|
|
@@ -19681,7 +19750,7 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
|
|
|
19681
19750
|
if (declarations.length) blocks.push(["DECLARATIONS (* exported)", ...declarations].join("\n"));
|
|
19682
19751
|
const imports = /* @__PURE__ */ new Set();
|
|
19683
19752
|
const external = /* @__PURE__ */ new Set();
|
|
19684
|
-
const fileObjects = graph.objectsAt(
|
|
19753
|
+
const fileObjects = graph.objectsAt(path13).map((object2) => object2.id);
|
|
19685
19754
|
for (const relation of graph.relationsFrom(fileObjects)) {
|
|
19686
19755
|
if (!IMPORT_KINDS.has(relation.kind)) continue;
|
|
19687
19756
|
if (relation.to === void 0) external.add(relation.target);
|
|
@@ -19692,8 +19761,8 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
|
|
|
19692
19761
|
}
|
|
19693
19762
|
const importers = /* @__PURE__ */ new Set();
|
|
19694
19763
|
const testImporters = /* @__PURE__ */ new Set();
|
|
19695
|
-
const imported = mapImportTarget(
|
|
19696
|
-
const packageModules = imported ===
|
|
19764
|
+
const imported = mapImportTarget(path13);
|
|
19765
|
+
const packageModules = imported === path13 ? [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);
|
|
19697
19766
|
for (const relation of graph.relationsTo(packageModules)) {
|
|
19698
19767
|
if (!IMPORT_KINDS.has(relation.kind)) continue;
|
|
19699
19768
|
const source = relation.anchor.path;
|
|
@@ -19721,16 +19790,16 @@ function fileView(store, coverage, graph, input, path12, prefixes) {
|
|
|
19721
19790
|
if (scope.length) blocks.push(["MODULE SCOPE (top-level statements)", ...scope].join("\n"));
|
|
19722
19791
|
return pageBlocks("FILE", head, blocks, input.offset ?? 0, input.outputBudget);
|
|
19723
19792
|
}
|
|
19724
|
-
function declarationView(graph, input,
|
|
19793
|
+
function declarationView(graph, input, path13, prefixes, memberCalls) {
|
|
19725
19794
|
const requested = input.depth ?? 1;
|
|
19726
19795
|
if (!Number.isSafeInteger(requested) || requested < 1 || requested > MAP_VIEW_LIMITS.directedDepth)
|
|
19727
19796
|
return invalid2();
|
|
19728
19797
|
const both = (input.direction ?? "BOTH") === "BOTH";
|
|
19729
19798
|
const depth = both ? Math.min(requested, MAP_VIEW_LIMITS.bothDepth) : requested;
|
|
19730
19799
|
const { name, line } = input;
|
|
19731
|
-
const selected = mapSelectDeclarations(graph,
|
|
19800
|
+
const selected = mapSelectDeclarations(graph, path13, name, line);
|
|
19732
19801
|
if (!selected.length) return notFound();
|
|
19733
|
-
const showTests = input.includeTests === true || mapTestPath(
|
|
19802
|
+
const showTests = input.includeTests === true || mapTestPath(path13);
|
|
19734
19803
|
const groups = new DeclarationGroups(graph, input, prefixes, showTests, memberCalls);
|
|
19735
19804
|
const blocks = [];
|
|
19736
19805
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -19778,7 +19847,7 @@ function declarationView(graph, input, path12, prefixes, memberCalls) {
|
|
|
19778
19847
|
);
|
|
19779
19848
|
}
|
|
19780
19849
|
const head = [
|
|
19781
|
-
`PROJECT MAP \xB7 DECLARATION ${
|
|
19850
|
+
`PROJECT MAP \xB7 DECLARATION ${path13}${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"}`,
|
|
19782
19851
|
...truncated ? [`Expansion stopped at ${MAP_VIEW_LIMITS.declarations} declarations.`] : [],
|
|
19783
19852
|
...(input.direction ?? "BOTH") === "OUTGOING" ? [] : [callerCoverage(input.textSearch ?? DEFAULT_TEXT_SEARCH)]
|
|
19784
19853
|
];
|
|
@@ -19905,10 +19974,10 @@ var ProjectMapQuery = class {
|
|
|
19905
19974
|
view(input, signal) {
|
|
19906
19975
|
this.requireReadableMap(input.version, signal);
|
|
19907
19976
|
const { offset, prefixes } = admission(input);
|
|
19908
|
-
const
|
|
19977
|
+
const path13 = normalizeProjectEvidencePath(input.path, true) || ".";
|
|
19909
19978
|
const view = mapView(
|
|
19910
19979
|
this.store,
|
|
19911
|
-
{ ...input, path:
|
|
19980
|
+
{ ...input, path: path13, offset, allowedPathPrefixes: prefixes },
|
|
19912
19981
|
this.views
|
|
19913
19982
|
);
|
|
19914
19983
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
@@ -20813,7 +20882,7 @@ var CodeIndexStore = class {
|
|
|
20813
20882
|
const staged = this.stageUnits(buildRef, paths, linked);
|
|
20814
20883
|
const reused = linked ? this.database.prepare(`SELECT path, unit_ref FROM project_map_version_units
|
|
20815
20884
|
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) })) : [];
|
|
20816
|
-
if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path:
|
|
20885
|
+
if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path: path13 }) => !paths.has(path13)) || staged.some(({ path: path13 }) => linked?.paths.has(path13)))
|
|
20817
20886
|
throw new MapReplayConflict();
|
|
20818
20887
|
const units = [...staged, ...reused].sort(
|
|
20819
20888
|
(left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
|
|
@@ -20864,7 +20933,7 @@ var CodeIndexStore = class {
|
|
|
20864
20933
|
const member = this.database.prepare(
|
|
20865
20934
|
"INSERT INTO project_map_version_units VALUES (?, ?, ?)"
|
|
20866
20935
|
);
|
|
20867
|
-
for (const { path:
|
|
20936
|
+
for (const { path: path13, unit } of reused) member.run(version2.version, path13, unit);
|
|
20868
20937
|
this.database.prepare("INSERT INTO project_map_coverage VALUES (?, ?)").run(version2.version, canonicalJson(coverage));
|
|
20869
20938
|
}
|
|
20870
20939
|
this.database.exec("COMMIT");
|
|
@@ -20928,7 +20997,7 @@ var CodeIndexStore = class {
|
|
|
20928
20997
|
corrupt2();
|
|
20929
20998
|
}
|
|
20930
20999
|
if (linked) {
|
|
20931
|
-
const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((
|
|
21000
|
+
const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((path13) => !linked.paths.has(path13));
|
|
20932
21001
|
if (database.prepare(`SELECT 1 FROM project_map_objects gone
|
|
20933
21002
|
WHERE gone.version_ref = ? AND gone.path IN (SELECT value FROM json_each(?))
|
|
20934
21003
|
AND gone.entity_ref NOT IN (SELECT entity_ref FROM project_map_publish_objects)
|
|
@@ -20953,17 +21022,17 @@ var CodeIndexStore = class {
|
|
|
20953
21022
|
const units = [];
|
|
20954
21023
|
for (const row of database.prepare(`SELECT path FROM project_map_publish_objects
|
|
20955
21024
|
UNION SELECT path FROM project_map_publish_relations ORDER BY path`).all()) {
|
|
20956
|
-
const
|
|
20957
|
-
const hash2 = createHash3("sha256").update(
|
|
21025
|
+
const path13 = String(row.path);
|
|
21026
|
+
const hash2 = createHash3("sha256").update(path13).update("\0");
|
|
20958
21027
|
for (const [mark, statement] of [
|
|
20959
21028
|
["object", objects2],
|
|
20960
21029
|
["relation", relations],
|
|
20961
21030
|
["note", pathNotes]
|
|
20962
21031
|
])
|
|
20963
|
-
for (const fact of statement.all(
|
|
21032
|
+
for (const fact of statement.all(path13))
|
|
20964
21033
|
for (const value of Object.values(fact))
|
|
20965
21034
|
hash2.update(mark).update("\0").update(String(value)).update("\0");
|
|
20966
|
-
units.push({ path:
|
|
21035
|
+
units.push({ path: path13, unit: hash2.digest("hex") });
|
|
20967
21036
|
}
|
|
20968
21037
|
return units;
|
|
20969
21038
|
}
|
|
@@ -20981,13 +21050,13 @@ var CodeIndexStore = class {
|
|
|
20981
21050
|
"INSERT INTO project_map_unit_notes SELECT ?, * FROM project_map_publish_notes WHERE path = ?"
|
|
20982
21051
|
);
|
|
20983
21052
|
const member = database.prepare("INSERT INTO project_map_version_units VALUES (?, ?, ?)");
|
|
20984
|
-
for (const { path:
|
|
20985
|
-
if (insertUnit.run(unit,
|
|
20986
|
-
unitObjects.run(unit,
|
|
20987
|
-
unitRelations.run(unit,
|
|
20988
|
-
unitNotes.run(unit,
|
|
21053
|
+
for (const { path: path13, unit } of units) {
|
|
21054
|
+
if (insertUnit.run(unit, path13).changes) {
|
|
21055
|
+
unitObjects.run(unit, path13);
|
|
21056
|
+
unitRelations.run(unit, path13);
|
|
21057
|
+
unitNotes.run(unit, path13);
|
|
20989
21058
|
}
|
|
20990
|
-
member.run(version2,
|
|
21059
|
+
member.run(version2, path13, unit);
|
|
20991
21060
|
}
|
|
20992
21061
|
}
|
|
20993
21062
|
/** Earlier versions of a project's scope built by the same analyzer, most recent first. */
|
|
@@ -21228,21 +21297,21 @@ var contextFiles = (context) => [
|
|
|
21228
21297
|
function replayableContexts(parent, digests) {
|
|
21229
21298
|
const sharing = /* @__PURE__ */ new Map();
|
|
21230
21299
|
for (const [ref, { context }] of parent.contexts)
|
|
21231
|
-
for (const
|
|
21232
|
-
const refs = sharing.get(
|
|
21300
|
+
for (const path13 of contextFiles(context)) {
|
|
21301
|
+
const refs = sharing.get(path13) ?? /* @__PURE__ */ new Set();
|
|
21233
21302
|
refs.add(ref);
|
|
21234
|
-
sharing.set(
|
|
21303
|
+
sharing.set(path13, refs);
|
|
21235
21304
|
}
|
|
21236
21305
|
const unchanged = /* @__PURE__ */ new Set();
|
|
21237
21306
|
for (const [ref, { context }] of parent.contexts)
|
|
21238
21307
|
if (contextFiles(context).every(
|
|
21239
|
-
(
|
|
21308
|
+
(path13) => digests.get(path13) !== void 0 && digests.get(path13) === parent.entries.get(path13)
|
|
21240
21309
|
))
|
|
21241
21310
|
unchanged.add(ref);
|
|
21242
21311
|
const replayable = /* @__PURE__ */ new Set();
|
|
21243
21312
|
for (const [ref, { context }] of parent.contexts)
|
|
21244
21313
|
if (unchanged.has(ref) && contextFiles(context).every(
|
|
21245
|
-
(
|
|
21314
|
+
(path13) => [...sharing.get(path13) ?? []].every((other) => unchanged.has(other))
|
|
21246
21315
|
))
|
|
21247
21316
|
replayable.add(ref);
|
|
21248
21317
|
return { replayable, sharing };
|
|
@@ -21275,8 +21344,8 @@ var ProjectMapAnalyzer = class {
|
|
|
21275
21344
|
languages;
|
|
21276
21345
|
observe;
|
|
21277
21346
|
id;
|
|
21278
|
-
claims(
|
|
21279
|
-
return this.languages.some((language) => language.claims(
|
|
21347
|
+
claims(path13) {
|
|
21348
|
+
return this.languages.some((language) => language.claims(path13));
|
|
21280
21349
|
}
|
|
21281
21350
|
references(input, reference, signal) {
|
|
21282
21351
|
const language = this.languages.find((language2) => language2.claims(reference.targetPath));
|
|
@@ -21316,7 +21385,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21316
21385
|
const reuse = (contextRef2, request, files2) => {
|
|
21317
21386
|
const digest = digestValue({
|
|
21318
21387
|
request,
|
|
21319
|
-
files: files2.map((
|
|
21388
|
+
files: files2.map((path13) => [path13, digests.get(path13) ?? null])
|
|
21320
21389
|
});
|
|
21321
21390
|
requests.set(contextRef2, digest);
|
|
21322
21391
|
if (!parent || !replayable.has(contextRef2)) return void 0;
|
|
@@ -21356,7 +21425,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21356
21425
|
const ref = analysis.contexts[0]?.ref ?? "";
|
|
21357
21426
|
if (options?.linked?.length) {
|
|
21358
21427
|
if (!parent || analysis.contexts.length !== 1) return invalidParent();
|
|
21359
|
-
for (const
|
|
21428
|
+
for (const path13 of options.linked) linked.add(path13);
|
|
21360
21429
|
this.observe?.({
|
|
21361
21430
|
operation: "LINK",
|
|
21362
21431
|
phase: "FINISHED",
|
|
@@ -21383,7 +21452,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21383
21452
|
});
|
|
21384
21453
|
for (const file2 of analysis.parsedFiles) parsed.add(file2);
|
|
21385
21454
|
const staged = factPaths(analysis);
|
|
21386
|
-
for (const
|
|
21455
|
+
for (const path13 of staged) stagedPaths.add(path13);
|
|
21387
21456
|
for (const context of analysis.contexts) {
|
|
21388
21457
|
for (const file2 of context.configurationFiles) configurationInputs.add(file2);
|
|
21389
21458
|
if (!replayed.has(context.ref))
|
|
@@ -21412,7 +21481,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21412
21481
|
accept,
|
|
21413
21482
|
reuse,
|
|
21414
21483
|
previous,
|
|
21415
|
-
configuration: (
|
|
21484
|
+
configuration: (path13) => configurationInputs.add(path13),
|
|
21416
21485
|
observe: this.observe
|
|
21417
21486
|
},
|
|
21418
21487
|
signal
|
|
@@ -21449,12 +21518,12 @@ var ProjectMapAnalyzer = class {
|
|
|
21449
21518
|
if (files.objects.length) accept(files);
|
|
21450
21519
|
if (parent && (replayed.size || linked.size)) {
|
|
21451
21520
|
for (const ref of replayed.keys())
|
|
21452
|
-
for (const
|
|
21453
|
-
if (analyzedFiles.has(
|
|
21521
|
+
for (const path13 of contextFiles(parent.contexts.get(ref)?.context ?? invalidParent()))
|
|
21522
|
+
if (analyzedFiles.has(path13) || [...sharing.get(path13) ?? []].some((other) => !replayed.has(other)))
|
|
21454
21523
|
throw new MapReplayConflict();
|
|
21455
|
-
for (const paths of replayed.values()) for (const
|
|
21456
|
-
for (const
|
|
21457
|
-
if (analyzedFiles.has(
|
|
21524
|
+
for (const paths of replayed.values()) for (const path13 of paths) linked.add(path13);
|
|
21525
|
+
for (const path13 of linked)
|
|
21526
|
+
if (analyzedFiles.has(path13) || stagedPaths.has(path13)) throw new MapReplayConflict();
|
|
21458
21527
|
parent.link([...linked]);
|
|
21459
21528
|
}
|
|
21460
21529
|
result.parsedFiles = [...parsed].sort();
|
|
@@ -21744,8 +21813,8 @@ var CodeIndex = class {
|
|
|
21744
21813
|
for (const entry of this.store.listEntries(candidate))
|
|
21745
21814
|
if (entry.contentDigest) entries2.set(entry.path, entry.contentDigest);
|
|
21746
21815
|
let changed = 0;
|
|
21747
|
-
for (const [
|
|
21748
|
-
for (const
|
|
21816
|
+
for (const [path13, digest] of digests) if (entries2.get(path13) !== digest) changed++;
|
|
21817
|
+
for (const path13 of entries2.keys()) if (!digests.has(path13)) changed++;
|
|
21749
21818
|
if (!best || changed < best.changed) best = { version: candidate, entries: entries2, changed };
|
|
21750
21819
|
}
|
|
21751
21820
|
if (!best) return void 0;
|
|
@@ -21885,11 +21954,11 @@ var CodeIndex = class {
|
|
|
21885
21954
|
|
|
21886
21955
|
// src/project-map-changes.ts
|
|
21887
21956
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
21888
|
-
import
|
|
21957
|
+
import path9 from "node:path";
|
|
21889
21958
|
|
|
21890
21959
|
// src/project-map-names.ts
|
|
21891
21960
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
21892
|
-
import
|
|
21961
|
+
import path8 from "node:path";
|
|
21893
21962
|
var CONFIG_KEY = /^\s*(?:export\s+|-\s+)?["']?([A-Za-z_][\w.-]*)["']?\s*(?:=|:(?:\s|$))/u;
|
|
21894
21963
|
var CODE_READS = [
|
|
21895
21964
|
// process.env.NAME, import.meta.env.NAME
|
|
@@ -21965,7 +22034,7 @@ async function strandedNames(project, diff, files, configuration, git2, options)
|
|
|
21965
22034
|
} else for (const name of codeReads(line, file2.path)) names2.add(name);
|
|
21966
22035
|
let text;
|
|
21967
22036
|
try {
|
|
21968
|
-
text = readFileSync2(
|
|
22037
|
+
text = readFileSync2(path8.join(project, file2.path), "utf8");
|
|
21969
22038
|
} catch {
|
|
21970
22039
|
continue;
|
|
21971
22040
|
}
|
|
@@ -22086,8 +22155,8 @@ async function readMapChanges(project, base, signal) {
|
|
|
22086
22155
|
baseText: (await git.run(["show", `${commit}:${file2.basePath}`], gitOptions(project, signal))).stdout.toString("utf8")
|
|
22087
22156
|
};
|
|
22088
22157
|
const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter(Boolean);
|
|
22089
|
-
for (const
|
|
22090
|
-
files.push({ path:
|
|
22158
|
+
for (const path13 of untracked)
|
|
22159
|
+
files.push({ path: path13, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
|
|
22091
22160
|
const stranded = await strandedNames(
|
|
22092
22161
|
project,
|
|
22093
22162
|
diff,
|
|
@@ -22165,7 +22234,7 @@ var NON_CODE = [
|
|
|
22165
22234
|
[/(?:^|\/)\.env[^/]*$|\.(?:ya?ml|toml|ini|properties|conf|cfg)$/iu, "configuration"],
|
|
22166
22235
|
[/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte)$/iu, "template"]
|
|
22167
22236
|
];
|
|
22168
|
-
var nonCodeKind = (
|
|
22237
|
+
var nonCodeKind = (path13) => NON_CODE.find(([pattern]) => pattern.test(path13))?.[1];
|
|
22169
22238
|
var LIMITS = Object.freeze({ depth: 8, declarations: 800, changed: 200, chain: 3, byName: 40 });
|
|
22170
22239
|
var CALLER_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES"]);
|
|
22171
22240
|
var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
@@ -22360,12 +22429,12 @@ var Tracer = class {
|
|
|
22360
22429
|
this.areas.set(area, known);
|
|
22361
22430
|
}
|
|
22362
22431
|
/** A related test file; the closest relation (lowest rank) explains it. */
|
|
22363
|
-
test(
|
|
22364
|
-
if (!mapRunnableTest(
|
|
22365
|
-
const known = this.tests.get(
|
|
22432
|
+
test(path13, name, why, rank2) {
|
|
22433
|
+
if (!mapRunnableTest(path13)) return;
|
|
22434
|
+
const known = this.tests.get(path13) ?? { names: /* @__PURE__ */ new Set(), why, rank: rank2 };
|
|
22366
22435
|
if (rank2 < known.rank) Object.assign(known, { why, rank: rank2 });
|
|
22367
22436
|
if (name && !name.startsWith("<")) known.names.add(name);
|
|
22368
|
-
this.tests.set(
|
|
22437
|
+
this.tests.set(path13, known);
|
|
22369
22438
|
}
|
|
22370
22439
|
};
|
|
22371
22440
|
var mapRunnableTest = (file2) => /_test\.(?:go|py)$|(?:^|\/)test_[^/]*\.py$|\.(?:test|spec)\.[cm]?[jt]sx?$|(?:Test|Tests|IT)\.(?:java|kt)$/u.test(
|
|
@@ -22378,7 +22447,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22378
22447
|
const changed = [];
|
|
22379
22448
|
const unclear = [];
|
|
22380
22449
|
const removed = [];
|
|
22381
|
-
const declarations = (g,
|
|
22450
|
+
const declarations = (g, path13) => g.objectsAt(path13).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
|
|
22382
22451
|
let changedCount = 0;
|
|
22383
22452
|
const starts = [];
|
|
22384
22453
|
for (const file2 of changes.files) {
|
|
@@ -22466,18 +22535,18 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22466
22535
|
beforeTracer.trace(gone);
|
|
22467
22536
|
for (const entry of beforeTracer.entries.values())
|
|
22468
22537
|
if (!tracer.entries.has(entry.label)) tracer.entries.set(entry.label, entry);
|
|
22469
|
-
for (const [
|
|
22470
|
-
const known = tracer.tests.get(
|
|
22538
|
+
for (const [path13, test] of beforeTracer.tests) {
|
|
22539
|
+
const known = tracer.tests.get(path13);
|
|
22471
22540
|
if (known) for (const name of test.names) known.names.add(name);
|
|
22472
|
-
else tracer.tests.set(
|
|
22541
|
+
else tracer.tests.set(path13, test);
|
|
22473
22542
|
}
|
|
22474
22543
|
for (const [area, known] of beforeTracer.areas) {
|
|
22475
22544
|
const now = tracer.areas.get(area);
|
|
22476
22545
|
if (!now) tracer.areas.set(area, known);
|
|
22477
22546
|
else {
|
|
22478
22547
|
for (const name of known.through) now.through.add(name);
|
|
22479
|
-
for (const [
|
|
22480
|
-
now.tests.set(
|
|
22548
|
+
for (const [path13, names] of known.tests)
|
|
22549
|
+
now.tests.set(path13, /* @__PURE__ */ new Set([...now.tests.get(path13) ?? [], ...names]));
|
|
22481
22550
|
}
|
|
22482
22551
|
}
|
|
22483
22552
|
unclear.push(...beforeTracer.unclear.filter((line) => !line.includes("has no callers")));
|
|
@@ -22491,8 +22560,8 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22491
22560
|
entries: [...tracer.entries.values()].sort(
|
|
22492
22561
|
(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)
|
|
22493
22562
|
),
|
|
22494
|
-
tests: [...tracer.tests].map(([
|
|
22495
|
-
path:
|
|
22563
|
+
tests: [...tracer.tests].map(([path13, test]) => ({
|
|
22564
|
+
path: path13,
|
|
22496
22565
|
names: [...test.names].sort(),
|
|
22497
22566
|
why: test.why,
|
|
22498
22567
|
rank: test.rank
|
|
@@ -22502,7 +22571,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
22502
22571
|
areas: [...tracer.areas].map(([area, known]) => ({
|
|
22503
22572
|
area,
|
|
22504
22573
|
through: [...known.through].sort(),
|
|
22505
|
-
tests: [...known.tests].map(([
|
|
22574
|
+
tests: [...known.tests].map(([path13, names]) => ({ path: path13, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
|
|
22506
22575
|
})).sort((left, right) => right.tests.length - left.tests.length),
|
|
22507
22576
|
unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
|
|
22508
22577
|
truncated: tracer.truncated
|
|
@@ -22514,7 +22583,7 @@ function existingTestsChanged(before, after, file2, project) {
|
|
|
22514
22583
|
let workingLines = [];
|
|
22515
22584
|
if (file2.status !== "DELETED" && project)
|
|
22516
22585
|
try {
|
|
22517
|
-
workingLines = readFileSync3(
|
|
22586
|
+
workingLines = readFileSync3(path9.join(project, file2.path), "utf8").split("\n");
|
|
22518
22587
|
} catch {
|
|
22519
22588
|
}
|
|
22520
22589
|
const key = (graph, object2) => `${object2.kind}\0${graph.qualifiedName(object2.id)}`;
|
|
@@ -22601,7 +22670,7 @@ function routeTests(project, store, version2, entries, tracer) {
|
|
|
22601
22670
|
if (!mapRunnableTest(candidate)) continue;
|
|
22602
22671
|
let text;
|
|
22603
22672
|
try {
|
|
22604
|
-
text = readFileSync3(
|
|
22673
|
+
text = readFileSync3(path9.join(project, candidate), "utf8");
|
|
22605
22674
|
} catch {
|
|
22606
22675
|
continue;
|
|
22607
22676
|
}
|
|
@@ -22619,9 +22688,9 @@ function routeTests(project, store, version2, entries, tracer) {
|
|
|
22619
22688
|
}
|
|
22620
22689
|
}
|
|
22621
22690
|
}
|
|
22622
|
-
function sameDirectoryTests(store, version2,
|
|
22623
|
-
const slash =
|
|
22624
|
-
const directory = slash < 0 ? "" :
|
|
22691
|
+
function sameDirectoryTests(store, version2, path13, tracer) {
|
|
22692
|
+
const slash = path13.lastIndexOf("/");
|
|
22693
|
+
const directory = slash < 0 ? "" : path13.slice(0, slash + 1);
|
|
22625
22694
|
for (const row of store.database.prepare(
|
|
22626
22695
|
"SELECT DISTINCT path FROM project_map_objects WHERE version_ref = ? AND path LIKE ? ESCAPE '\\'"
|
|
22627
22696
|
).all(version2, `${directory.replace(/[\\%_]/gu, (c) => `\\${c}`)}%`)) {
|
|
@@ -22753,7 +22822,7 @@ Nothing changed against ${changes.base}.`;
|
|
|
22753
22822
|
var SCHEMA_VERSION = 2;
|
|
22754
22823
|
var KEEP_VERSIONS = 3;
|
|
22755
22824
|
function openMapDatabase(file2) {
|
|
22756
|
-
mkdirSync(
|
|
22825
|
+
mkdirSync(path10.dirname(file2), { recursive: true, mode: 448 });
|
|
22757
22826
|
const database = new DatabaseSync(file2);
|
|
22758
22827
|
try {
|
|
22759
22828
|
database.exec("PRAGMA busy_timeout = 30000;");
|
|
@@ -22790,7 +22859,7 @@ function openMapDatabase(file2) {
|
|
|
22790
22859
|
throw error51;
|
|
22791
22860
|
}
|
|
22792
22861
|
}
|
|
22793
|
-
var mapDatabasePath = (cacheDirectory2, canonicalProject) =>
|
|
22862
|
+
var mapDatabasePath = (cacheDirectory2, canonicalProject) => path10.join(
|
|
22794
22863
|
cacheDirectory2,
|
|
22795
22864
|
"projects",
|
|
22796
22865
|
createHash4("sha256").update(canonicalProject).digest("hex").slice(0, 24),
|
|
@@ -22940,19 +23009,25 @@ var LayerMap = class _LayerMap {
|
|
|
22940
23009
|
|
|
22941
23010
|
// src/agent/environment.ts
|
|
22942
23011
|
var packageRoot = (() => {
|
|
22943
|
-
for (let directory =
|
|
22944
|
-
const manifest =
|
|
22945
|
-
if (
|
|
23012
|
+
for (let directory = path11.dirname(fileURLToPath(import.meta.url)); ; ) {
|
|
23013
|
+
const manifest = path11.join(directory, "package.json");
|
|
23014
|
+
if (existsSync5(manifest) && JSON.parse(readFileSync4(manifest, "utf8")).name === "layermap")
|
|
22946
23015
|
return directory;
|
|
22947
|
-
if (
|
|
22948
|
-
directory =
|
|
23016
|
+
if (path11.dirname(directory) === directory) throw new Error("LayerMap cannot find its package.");
|
|
23017
|
+
directory = path11.dirname(directory);
|
|
22949
23018
|
}
|
|
22950
23019
|
})();
|
|
22951
|
-
var packageVersion = async () => JSON.parse(await readFile(
|
|
23020
|
+
var packageVersion = async () => JSON.parse(await readFile(path11.join(packageRoot, "package.json"), "utf8")).version;
|
|
22952
23021
|
var cacheDirectory = (env = process.env) => {
|
|
22953
|
-
if (env.LAYERMAP_CACHE) return
|
|
22954
|
-
if (process.platform === "darwin") return
|
|
22955
|
-
|
|
23022
|
+
if (env.LAYERMAP_CACHE) return path11.resolve(env.LAYERMAP_CACHE);
|
|
23023
|
+
if (process.platform === "darwin") return path11.join(homedir(), "Library", "Caches", "layermap");
|
|
23024
|
+
if (process.platform === "win32")
|
|
23025
|
+
return path11.join(
|
|
23026
|
+
env.LOCALAPPDATA || path11.join(homedir(), "AppData", "Local"),
|
|
23027
|
+
"layermap",
|
|
23028
|
+
"Cache"
|
|
23029
|
+
);
|
|
23030
|
+
return path11.join(env.XDG_CACHE_HOME || path11.join(homedir(), ".cache"), "layermap");
|
|
22956
23031
|
};
|
|
22957
23032
|
var projectDirectory = (directory) => new Promise(
|
|
22958
23033
|
(resolve) => execFile(
|
|
@@ -22960,7 +23035,7 @@ var projectDirectory = (directory) => new Promise(
|
|
|
22960
23035
|
["rev-parse", "--show-toplevel"],
|
|
22961
23036
|
{ cwd: directory, timeout: 1e4 },
|
|
22962
23037
|
(error51, stdout) => resolve(
|
|
22963
|
-
error51 ? { directory:
|
|
23038
|
+
error51 ? { directory: path11.resolve(directory), git: false } : { directory: stdout.trim(), git: true }
|
|
22964
23039
|
)
|
|
22965
23040
|
)
|
|
22966
23041
|
);
|
|
@@ -22970,7 +23045,7 @@ var relativeTo = (directory, value) => Object.fromEntries(
|
|
|
22970
23045
|
Object.fromEntries(
|
|
22971
23046
|
Object.entries(resources).map(([key, field]) => [
|
|
22972
23047
|
key,
|
|
22973
|
-
key.endsWith("Path") && typeof field === "string" && field.startsWith(directory) ?
|
|
23048
|
+
key.endsWith("Path") && typeof field === "string" && field.startsWith(directory) ? path11.relative(directory, field) : field
|
|
22974
23049
|
])
|
|
22975
23050
|
)
|
|
22976
23051
|
])
|
|
@@ -22981,9 +23056,10 @@ var resolvePlaceholder = (field) => {
|
|
|
22981
23056
|
createRequire(import.meta.url).resolve("typescript/package.json")
|
|
22982
23057
|
);
|
|
22983
23058
|
const native = `@typescript/typescript-${process.platform}-${process.arch}/package.json`;
|
|
22984
|
-
return
|
|
23059
|
+
return path11.join(path11.dirname(compiler.resolve(native)), "lib", executableName("tsc"));
|
|
22985
23060
|
}
|
|
22986
|
-
|
|
23061
|
+
const resolved = field.replaceAll("{platform}", process.platform).replaceAll("{arch}", process.arch);
|
|
23062
|
+
return field.includes("{platform}") ? executableName(resolved) : resolved;
|
|
22987
23063
|
};
|
|
22988
23064
|
var absoluteIn = (directory, value) => Object.fromEntries(
|
|
22989
23065
|
Object.entries(value).map(([language, resources]) => [
|
|
@@ -22992,24 +23068,24 @@ var absoluteIn = (directory, value) => Object.fromEntries(
|
|
|
22992
23068
|
Object.entries(resources).map(([key, field]) => {
|
|
22993
23069
|
if (!key.endsWith("Path") || typeof field !== "string") return [key, field];
|
|
22994
23070
|
const resolved = resolvePlaceholder(field);
|
|
22995
|
-
return [key,
|
|
23071
|
+
return [key, path11.isAbsolute(resolved) ? resolved : path11.join(directory, resolved)];
|
|
22996
23072
|
})
|
|
22997
23073
|
)
|
|
22998
23074
|
])
|
|
22999
23075
|
);
|
|
23000
23076
|
var readAnalyzers = async (directory) => {
|
|
23001
|
-
const file2 =
|
|
23002
|
-
if (!
|
|
23077
|
+
const file2 = path11.join(directory, "analyzers.json");
|
|
23078
|
+
if (!existsSync5(file2)) return void 0;
|
|
23003
23079
|
const analyzers = absoluteIn(directory, JSON.parse(await readFile(file2, "utf8")));
|
|
23004
23080
|
return analyzers.java.runtimePath ? analyzers : { ...analyzers, java: { ...analyzers.java, ...discoverJavaRuntime() } };
|
|
23005
23081
|
};
|
|
23006
23082
|
var sourceDigest = async () => {
|
|
23007
|
-
const hash2 = createHash5("sha256").update(await readFile(
|
|
23083
|
+
const hash2 = createHash5("sha256").update(await readFile(path11.join(packageRoot, "package.json")));
|
|
23008
23084
|
for (const part of ["src", "go-map", "java-map", "scripts"]) {
|
|
23009
|
-
const directory =
|
|
23010
|
-
if (!
|
|
23085
|
+
const directory = path11.join(packageRoot, part);
|
|
23086
|
+
if (!existsSync5(directory)) continue;
|
|
23011
23087
|
for (const entry of (await readdir(directory, { recursive: true })).sort()) {
|
|
23012
|
-
const file2 =
|
|
23088
|
+
const file2 = path11.join(directory, entry);
|
|
23013
23089
|
const info = await stat(file2);
|
|
23014
23090
|
if (info.isFile()) hash2.update(`${part}/${entry}\0${info.size}\0${info.mtimeMs}\0`);
|
|
23015
23091
|
}
|
|
@@ -23017,11 +23093,11 @@ var sourceDigest = async () => {
|
|
|
23017
23093
|
return hash2.digest("hex").slice(0, 16);
|
|
23018
23094
|
};
|
|
23019
23095
|
async function resolveAnalyzers(cache, log2, env = process.env) {
|
|
23020
|
-
for (const directory2 of [env.LAYERMAP_ANALYZERS,
|
|
23021
|
-
const analyzers = directory2 && await readAnalyzers(
|
|
23096
|
+
for (const directory2 of [env.LAYERMAP_ANALYZERS, path11.join(packageRoot, "analyzers")]) {
|
|
23097
|
+
const analyzers = directory2 && await readAnalyzers(path11.resolve(directory2));
|
|
23022
23098
|
if (analyzers) return analyzers;
|
|
23023
23099
|
}
|
|
23024
|
-
const directory =
|
|
23100
|
+
const directory = path11.join(cache, "analyzers", await sourceDigest());
|
|
23025
23101
|
const built = await readAnalyzers(directory);
|
|
23026
23102
|
if (built) return built;
|
|
23027
23103
|
log2("Building the language analyzers (once per LayerMap version)...");
|
|
@@ -23037,32 +23113,32 @@ async function resolveAnalyzers(cache, log2, env = process.env) {
|
|
|
23037
23113
|
python: parser.pythonResources,
|
|
23038
23114
|
java: parser.javaResources
|
|
23039
23115
|
});
|
|
23040
|
-
await writeFile(
|
|
23116
|
+
await writeFile(path11.join(staging, "analyzers.json"), `${JSON.stringify(stored, null, 2)}
|
|
23041
23117
|
`);
|
|
23042
23118
|
await rename(staging, directory).catch(() => rm(staging, { recursive: true, force: true }));
|
|
23043
23119
|
return await readAnalyzers(directory);
|
|
23044
23120
|
}
|
|
23045
23121
|
var DAY = 24 * 60 * 60 * 1e3;
|
|
23046
23122
|
async function pruneCache(cache, project, now = Date.now()) {
|
|
23047
|
-
const used =
|
|
23048
|
-
await mkdir(
|
|
23123
|
+
const used = path11.join(path11.dirname(mapDatabasePath(cache, project)), "last-used");
|
|
23124
|
+
await mkdir(path11.dirname(used), { recursive: true, mode: 448 });
|
|
23049
23125
|
await writeFile(used, "");
|
|
23050
23126
|
await utimes(used, now / 1e3, now / 1e3);
|
|
23051
|
-
const projects =
|
|
23127
|
+
const projects = path11.join(cache, "projects");
|
|
23052
23128
|
for (const name of await readdir(projects).catch(() => [])) {
|
|
23053
|
-
const directory =
|
|
23054
|
-
const marker =
|
|
23055
|
-
const last = (await stat(
|
|
23129
|
+
const directory = path11.join(projects, name);
|
|
23130
|
+
const marker = path11.join(directory, "last-used");
|
|
23131
|
+
const last = (await stat(existsSync5(marker) ? marker : directory).catch(() => void 0))?.mtimeMs;
|
|
23056
23132
|
if (last !== void 0 && now - last > 30 * DAY)
|
|
23057
23133
|
await rm(directory, { recursive: true, force: true });
|
|
23058
23134
|
}
|
|
23059
|
-
const builds =
|
|
23135
|
+
const builds = path11.join(cache, "analyzers");
|
|
23060
23136
|
const current = await sourceDigest();
|
|
23061
23137
|
for (const name of await readdir(builds).catch(() => [])) {
|
|
23062
23138
|
if (name === current) continue;
|
|
23063
|
-
const built = (await stat(
|
|
23139
|
+
const built = (await stat(path11.join(builds, name)).catch(() => void 0))?.mtimeMs;
|
|
23064
23140
|
if (built !== void 0 && now - built > (name.includes(".") ? DAY / 24 : DAY))
|
|
23065
|
-
await rm(
|
|
23141
|
+
await rm(path11.join(builds, name), { recursive: true, force: true });
|
|
23066
23142
|
}
|
|
23067
23143
|
}
|
|
23068
23144
|
|
|
@@ -23092,7 +23168,7 @@ var MAP_TOOL_NAMES = Object.freeze({
|
|
|
23092
23168
|
references: "project_find_references",
|
|
23093
23169
|
check: "project_check_changes"
|
|
23094
23170
|
});
|
|
23095
|
-
var mapDirectoryPath = (
|
|
23171
|
+
var mapDirectoryPath = (path13) => path13.length > 1 && path13.endsWith("/") && !path13.endsWith("//") ? path13.slice(0, -1) : path13;
|
|
23096
23172
|
var ProjectMapSearchInputSchema = external_exports.object({
|
|
23097
23173
|
path: external_exports.string().default("."),
|
|
23098
23174
|
query: external_exports.string().min(1).max(256),
|
|
@@ -23384,19 +23460,25 @@ function serveMcp(options) {
|
|
|
23384
23460
|
|
|
23385
23461
|
// src/agent/setup.ts
|
|
23386
23462
|
import { execFile as execFile2 } from "node:child_process";
|
|
23387
|
-
import { existsSync as
|
|
23463
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
23388
23464
|
import { mkdir as mkdir2, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
23389
23465
|
import { homedir as homedir2 } from "node:os";
|
|
23390
|
-
import
|
|
23466
|
+
import path12 from "node:path";
|
|
23391
23467
|
var SERVER = "layermap";
|
|
23392
23468
|
var SETUP_RULE = `mcp__${SERVER}`;
|
|
23393
23469
|
var PLUGIN_RULE = `mcp__plugin_${SERVER}_${SERVER}`;
|
|
23394
23470
|
var BEGIN = "<!-- layermap:begin -->";
|
|
23395
23471
|
var END = "<!-- layermap:end -->";
|
|
23396
|
-
var mcpLaunchCommand = (version2) => {
|
|
23397
|
-
const script =
|
|
23398
|
-
if (script.includes(`${
|
|
23399
|
-
return [
|
|
23472
|
+
var mcpLaunchCommand = (version2, platform = process.platform) => {
|
|
23473
|
+
const script = path12.resolve(process.argv[1] ?? "");
|
|
23474
|
+
if (script.includes(`${path12.sep}_npx${path12.sep}`))
|
|
23475
|
+
return [
|
|
23476
|
+
...platform === "win32" ? ["cmd", "/c"] : [],
|
|
23477
|
+
"npx",
|
|
23478
|
+
"-y",
|
|
23479
|
+
`layermap@${version2}`,
|
|
23480
|
+
"mcp"
|
|
23481
|
+
];
|
|
23400
23482
|
const execArgv = [];
|
|
23401
23483
|
for (let index = 0; index < process.execArgv.length; index++) {
|
|
23402
23484
|
const argument = process.execArgv[index];
|
|
@@ -23408,16 +23490,22 @@ var mcpLaunchCommand = (version2) => {
|
|
|
23408
23490
|
}
|
|
23409
23491
|
return [process.execPath, ...execArgv, script, "mcp"];
|
|
23410
23492
|
};
|
|
23411
|
-
var run = (command, args, env) => new Promise(
|
|
23412
|
-
(
|
|
23413
|
-
|
|
23414
|
-
|
|
23415
|
-
|
|
23493
|
+
var run = (command, args, env) => new Promise((resolve) => {
|
|
23494
|
+
const invocation = commandInvocation(command, args, env);
|
|
23495
|
+
execFile2(
|
|
23496
|
+
invocation.file,
|
|
23497
|
+
invocation.args,
|
|
23498
|
+
{
|
|
23499
|
+
env,
|
|
23500
|
+
timeout: 6e4,
|
|
23501
|
+
windowsHide: true,
|
|
23502
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
23503
|
+
},
|
|
23416
23504
|
(error51, stdout, stderr) => resolve({ ok: !error51, output: `${stdout}${stderr}`.trim() })
|
|
23417
|
-
)
|
|
23418
|
-
);
|
|
23505
|
+
);
|
|
23506
|
+
});
|
|
23419
23507
|
async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
|
|
23420
|
-
const settings =
|
|
23508
|
+
const settings = existsSync6(file2) ? JSON.parse(await readFile2(file2, "utf8")) : {};
|
|
23421
23509
|
if (typeof settings !== "object" || settings === null || Array.isArray(settings))
|
|
23422
23510
|
throw new Error(`${file2} is not a settings object.`);
|
|
23423
23511
|
settings.permissions ??= {};
|
|
@@ -23426,7 +23514,7 @@ async function allowInClaudeSettings(file2, rule = SETUP_RULE) {
|
|
|
23426
23514
|
throw new Error(`${file2} has permissions.allow that is not a list.`);
|
|
23427
23515
|
if (settings.permissions.allow.includes(rule)) return false;
|
|
23428
23516
|
settings.permissions.allow.push(rule);
|
|
23429
|
-
await mkdir2(
|
|
23517
|
+
await mkdir2(path12.dirname(file2), { recursive: true });
|
|
23430
23518
|
await writeFile2(file2, `${JSON.stringify(settings, null, 2)}
|
|
23431
23519
|
`);
|
|
23432
23520
|
return true;
|
|
@@ -23454,17 +23542,17 @@ async function writeInstructionNote(file2, note = AGENT_MAP_NOTE) {
|
|
|
23454
23542
|
const block = `${BEGIN}
|
|
23455
23543
|
${note}
|
|
23456
23544
|
${END}`;
|
|
23457
|
-
const text =
|
|
23545
|
+
const text = existsSync6(file2) ? await readFile2(file2, "utf8") : "";
|
|
23458
23546
|
const start = text.indexOf(BEGIN);
|
|
23459
23547
|
const end = text.indexOf(END);
|
|
23460
23548
|
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}
|
|
23461
23549
|
`;
|
|
23462
23550
|
if (next === text) return;
|
|
23463
|
-
await mkdir2(
|
|
23551
|
+
await mkdir2(path12.dirname(file2), { recursive: true });
|
|
23464
23552
|
await writeFile2(file2, next);
|
|
23465
23553
|
}
|
|
23466
23554
|
async function removeInstructionNote(file2) {
|
|
23467
|
-
if (!
|
|
23555
|
+
if (!existsSync6(file2)) return;
|
|
23468
23556
|
const text = await readFile2(file2, "utf8");
|
|
23469
23557
|
const start = text.indexOf(BEGIN);
|
|
23470
23558
|
const end = text.indexOf(END);
|
|
@@ -23475,7 +23563,7 @@ async function removeInstructionNote(file2) {
|
|
|
23475
23563
|
else await writeFile2(file2, rest);
|
|
23476
23564
|
}
|
|
23477
23565
|
async function disallowInClaudeSettings(file2) {
|
|
23478
|
-
if (!
|
|
23566
|
+
if (!existsSync6(file2)) return;
|
|
23479
23567
|
const settings = JSON.parse(await readFile2(file2, "utf8"));
|
|
23480
23568
|
const allow = settings?.permissions?.allow;
|
|
23481
23569
|
const ours = (rule) => rule === SETUP_RULE || rule === PLUGIN_RULE;
|
|
@@ -23488,14 +23576,14 @@ async function disallowInClaudeSettings(file2) {
|
|
|
23488
23576
|
}
|
|
23489
23577
|
var YAML_BEGIN = "# layermap:begin";
|
|
23490
23578
|
var YAML_END = "# layermap:end";
|
|
23491
|
-
var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(
|
|
23492
|
-
(directory) =>
|
|
23493
|
-
) ??
|
|
23579
|
+
var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(path12.delimiter).find(
|
|
23580
|
+
(directory) => path12.isAbsolute(directory) && existsSync6(path12.join(directory, "node")) && existsSync6(path12.join(directory, "npx"))
|
|
23581
|
+
) ?? path12.dirname(process.execPath);
|
|
23494
23582
|
var dshPatchBlock = (command, env) => {
|
|
23495
23583
|
const node = nodeDirectory(env);
|
|
23496
|
-
const npx =
|
|
23497
|
-
const [program = "", ...args] = command[0] === "npx" &&
|
|
23498
|
-
const
|
|
23584
|
+
const npx = path12.join(node, "npx");
|
|
23585
|
+
const [program = "", ...args] = command[0] === "npx" && existsSync6(npx) ? [npx, ...command.slice(1)] : command;
|
|
23586
|
+
const searchPath2 = `${JSON.stringify(`${node}${path12.delimiter}`)} + process.env.PATH`;
|
|
23499
23587
|
return [
|
|
23500
23588
|
`${YAML_BEGIN} (written by \`layermap setup dsh\`; \`layermap remove dsh\` deletes it)`,
|
|
23501
23589
|
"- insert:",
|
|
@@ -23507,14 +23595,14 @@ var dshPatchBlock = (command, env) => {
|
|
|
23507
23595
|
` command: ${JSON.stringify(program)}`,
|
|
23508
23596
|
` args: ${JSON.stringify(args)}`,
|
|
23509
23597
|
" env:",
|
|
23510
|
-
` PATH: !!js ${JSON.stringify(
|
|
23598
|
+
` PATH: !!js ${JSON.stringify(searchPath2)}`,
|
|
23511
23599
|
" cwd: !!js process.cwd()",
|
|
23512
23600
|
" toolCallTimeoutMs: 120000",
|
|
23513
23601
|
YAML_END
|
|
23514
23602
|
].join("\n");
|
|
23515
23603
|
};
|
|
23516
23604
|
async function writeDshPatch(file2, block) {
|
|
23517
|
-
const text =
|
|
23605
|
+
const text = existsSync6(file2) ? await readFile2(file2, "utf8") : "";
|
|
23518
23606
|
const start = text.indexOf(YAML_BEGIN);
|
|
23519
23607
|
const end = text.indexOf(YAML_END);
|
|
23520
23608
|
let next;
|
|
@@ -23530,11 +23618,11 @@ async function writeDshPatch(file2, block) {
|
|
|
23530
23618
|
`;
|
|
23531
23619
|
}
|
|
23532
23620
|
if (next === text) return;
|
|
23533
|
-
await mkdir2(
|
|
23621
|
+
await mkdir2(path12.dirname(file2), { recursive: true });
|
|
23534
23622
|
await writeFile2(file2, next);
|
|
23535
23623
|
}
|
|
23536
23624
|
async function removeDshPatch(file2) {
|
|
23537
|
-
if (!
|
|
23625
|
+
if (!existsSync6(file2)) return;
|
|
23538
23626
|
const text = await readFile2(file2, "utf8");
|
|
23539
23627
|
const start = text.indexOf(YAML_BEGIN);
|
|
23540
23628
|
const end = text.indexOf(YAML_END);
|
|
@@ -23548,31 +23636,31 @@ async function removeDshPatch(file2) {
|
|
|
23548
23636
|
var agentFiles = (options) => {
|
|
23549
23637
|
const env = options.env ?? process.env;
|
|
23550
23638
|
if (options.agent === "dsh") {
|
|
23551
|
-
const home = env.DSH_HOME ||
|
|
23639
|
+
const home = env.DSH_HOME || path12.join(homedir2(), ".dsh");
|
|
23552
23640
|
return {
|
|
23553
|
-
settings:
|
|
23554
|
-
instructions:
|
|
23641
|
+
settings: path12.join(home, "cordis.patch.yml"),
|
|
23642
|
+
instructions: path12.join(home, "AGENTS.md")
|
|
23555
23643
|
};
|
|
23556
23644
|
}
|
|
23557
23645
|
if (options.agent === "codex") {
|
|
23558
|
-
const home = env.CODEX_HOME ??
|
|
23559
|
-
return { settings:
|
|
23646
|
+
const home = env.CODEX_HOME ?? path12.join(homedir2(), ".codex");
|
|
23647
|
+
return { settings: path12.join(home, "config.toml"), instructions: path12.join(home, "AGENTS.md") };
|
|
23560
23648
|
}
|
|
23561
23649
|
if (options.scope === "user") {
|
|
23562
|
-
const home = env.CLAUDE_CONFIG_DIR ??
|
|
23650
|
+
const home = env.CLAUDE_CONFIG_DIR ?? path12.join(homedir2(), ".claude");
|
|
23563
23651
|
return {
|
|
23564
|
-
settings:
|
|
23565
|
-
instructions:
|
|
23652
|
+
settings: path12.join(home, "settings.json"),
|
|
23653
|
+
instructions: path12.join(home, "CLAUDE.md")
|
|
23566
23654
|
};
|
|
23567
23655
|
}
|
|
23568
23656
|
const local = options.scope === "local";
|
|
23569
23657
|
return {
|
|
23570
|
-
settings:
|
|
23658
|
+
settings: path12.join(
|
|
23571
23659
|
options.project,
|
|
23572
23660
|
".claude",
|
|
23573
23661
|
local ? "settings.local.json" : "settings.json"
|
|
23574
23662
|
),
|
|
23575
|
-
instructions:
|
|
23663
|
+
instructions: path12.join(options.project, local ? "CLAUDE.local.md" : "CLAUDE.md")
|
|
23576
23664
|
};
|
|
23577
23665
|
};
|
|
23578
23666
|
async function setupAgent(options) {
|