@cortexkit/aft 0.53.0 → 0.54.0
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/dist/index.js +406 -367
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -517,8 +517,65 @@ var CONFLICT_HINT = `
|
|
|
517
517
|
[Hint] Use aft_conflicts to see all conflict regions across files in a single call.`, GREP_SEARCH_AFT_SEARCH_HINT = "DO NOT search code by running grep/rg in bash — it is unindexed, unranked, and serial. Use the `aft_search` tool instead (it auto-routes concepts, identifiers, regex, and literals).", GREP_SEARCH_GREP_HINT = "DO NOT search code by running grep/rg in bash — it is unindexed, unranked, and serial. Use the `grep` tool instead (indexed and ranked).", GREP_SEARCH_HINT_PREFIX = "DO NOT search code by running grep/rg in bash —", GREP_SEARCH_FRESHNESS_WINDOW_MS = 60000;
|
|
518
518
|
var init_bash_hints = () => {};
|
|
519
519
|
|
|
520
|
+
// ../aft-bridge/dist/storage-paths.js
|
|
521
|
+
import { homedir as homedir2 } from "node:os";
|
|
522
|
+
import { join as join2, resolve as resolve2 } from "node:path";
|
|
523
|
+
function homeDir() {
|
|
524
|
+
if (process.platform === "win32")
|
|
525
|
+
return process.env.USERPROFILE || process.env.HOME || homedir2();
|
|
526
|
+
return process.env.HOME || homedir2();
|
|
527
|
+
}
|
|
528
|
+
function dataHome() {
|
|
529
|
+
const xdg = process.env.XDG_DATA_HOME;
|
|
530
|
+
if (xdg)
|
|
531
|
+
return xdg;
|
|
532
|
+
if (process.platform === "win32") {
|
|
533
|
+
return process.env.LOCALAPPDATA || process.env.APPDATA || join2(homeDir(), "AppData", "Local");
|
|
534
|
+
}
|
|
535
|
+
return join2(homeDir(), ".local", "share");
|
|
536
|
+
}
|
|
537
|
+
function resolveStoragePath(raw) {
|
|
538
|
+
let expanded = raw;
|
|
539
|
+
if (raw === "~") {
|
|
540
|
+
expanded = homeDir();
|
|
541
|
+
} else if (raw.startsWith("~/") || raw.startsWith("~\\")) {
|
|
542
|
+
expanded = join2(homeDir(), raw.slice(2));
|
|
543
|
+
}
|
|
544
|
+
return resolve2(expanded);
|
|
545
|
+
}
|
|
546
|
+
function resolveCortexKitStorageRoot() {
|
|
547
|
+
const override = process.env.AFT_STORAGE_DIR;
|
|
548
|
+
if (override)
|
|
549
|
+
return resolveStoragePath(override);
|
|
550
|
+
return resolveStoragePath(join2(dataHome(), "cortexkit", "aft"));
|
|
551
|
+
}
|
|
552
|
+
function resolveAftStorageRoot(configuredRoot) {
|
|
553
|
+
if (process.env.AFT_STORAGE_DIR)
|
|
554
|
+
return resolveCortexKitStorageRoot();
|
|
555
|
+
if (configuredRoot)
|
|
556
|
+
return configuredRoot;
|
|
557
|
+
return resolveCortexKitStorageRoot();
|
|
558
|
+
}
|
|
559
|
+
function resolveAftLogPath(filename, configuredRoot) {
|
|
560
|
+
return join2(resolveAftStorageRoot(configuredRoot), "logs", filename);
|
|
561
|
+
}
|
|
562
|
+
var init_storage_paths = () => {};
|
|
563
|
+
|
|
520
564
|
// ../aft-bridge/dist/bash-host-fallback.js
|
|
521
565
|
import { spawn } from "node:child_process";
|
|
566
|
+
import { existsSync } from "node:fs";
|
|
567
|
+
import { delimiter, join as join3 } from "node:path";
|
|
568
|
+
function hostFallbackPathWithShims(env) {
|
|
569
|
+
const storageRoot = env.AFT_STORAGE_DIR ? resolveStoragePath(env.AFT_STORAGE_DIR) : resolveCortexKitStorageRoot();
|
|
570
|
+
const shimsDir = join3(storageRoot, "shims");
|
|
571
|
+
if (!existsSync(join3(shimsDir, "gh")))
|
|
572
|
+
return env.PATH;
|
|
573
|
+
const inherited = env.PATH ?? "";
|
|
574
|
+
const entries = inherited.split(delimiter).filter((entry) => entry.length > 0);
|
|
575
|
+
if (entries[0] === shimsDir)
|
|
576
|
+
return inherited;
|
|
577
|
+
return [shimsDir, ...entries.filter((entry) => entry !== shimsDir)].join(delimiter);
|
|
578
|
+
}
|
|
522
579
|
function bashHostFallbackAskPattern(command, cwd) {
|
|
523
580
|
return `AFT UNAVAILABLE - host fallback execution:
|
|
524
581
|
|
|
@@ -551,11 +608,17 @@ async function runBashHostFallback(options) {
|
|
|
551
608
|
if (options.signal?.aborted) {
|
|
552
609
|
throw new DOMException("The host fallback command was aborted", "AbortError");
|
|
553
610
|
}
|
|
554
|
-
return await new Promise((
|
|
611
|
+
return await new Promise((resolve3, reject) => {
|
|
555
612
|
const child = spawn(options.command, {
|
|
556
613
|
cwd: options.projectRoot,
|
|
557
614
|
shell: true,
|
|
558
|
-
env:
|
|
615
|
+
env: (() => {
|
|
616
|
+
const merged = { ...process.env, ...options.env };
|
|
617
|
+
const path2 = hostFallbackPathWithShims(merged);
|
|
618
|
+
if (path2 !== undefined)
|
|
619
|
+
merged.PATH = path2;
|
|
620
|
+
return merged;
|
|
621
|
+
})(),
|
|
559
622
|
stdio: ["ignore", "pipe", "pipe"],
|
|
560
623
|
detached: process.platform !== "win32",
|
|
561
624
|
windowsHide: true
|
|
@@ -618,7 +681,7 @@ async function runBashHostFallback(options) {
|
|
|
618
681
|
return;
|
|
619
682
|
}
|
|
620
683
|
const exitCode = timedOut ? 124 : code ?? 1;
|
|
621
|
-
|
|
684
|
+
resolve3({
|
|
622
685
|
success: true,
|
|
623
686
|
output: renderOutput(Buffer.concat(chunks), exitCode),
|
|
624
687
|
exit_code: exitCode,
|
|
@@ -629,6 +692,7 @@ async function runBashHostFallback(options) {
|
|
|
629
692
|
}
|
|
630
693
|
var BASH_HOST_FALLBACK_BANNER = "[AFT host fallback - module transport down; no rewrites/compression/background]", BASH_HOST_FALLBACK_MAX_OUTPUT_BYTES, BASH_HOST_FALLBACK_MAX_TIMEOUT_MS, BASH_HOST_FALLBACK_REFUSAL = "AFT transport is down; only foreground execution is available in host fallback";
|
|
631
694
|
var init_bash_host_fallback = __esm(() => {
|
|
695
|
+
init_storage_paths();
|
|
632
696
|
BASH_HOST_FALLBACK_MAX_OUTPUT_BYTES = 100 * 1024;
|
|
633
697
|
BASH_HOST_FALLBACK_MAX_TIMEOUT_MS = 10 * 60 * 1000;
|
|
634
698
|
});
|
|
@@ -670,8 +734,8 @@ var init_command_timeouts = __esm(() => {
|
|
|
670
734
|
import { spawn as spawn2 } from "node:child_process";
|
|
671
735
|
import { createHash } from "node:crypto";
|
|
672
736
|
import { readFileSync } from "node:fs";
|
|
673
|
-
import { homedir as
|
|
674
|
-
import { join as
|
|
737
|
+
import { homedir as homedir3 } from "node:os";
|
|
738
|
+
import { join as join4 } from "node:path";
|
|
675
739
|
import { StringDecoder } from "node:string_decoder";
|
|
676
740
|
function isTerminalBashStatus(status) {
|
|
677
741
|
return typeof status === "string" && TERMINAL_BASH_STATUSES.has(status);
|
|
@@ -1140,7 +1204,7 @@ var init_bridge = __esm(() => {
|
|
|
1140
1204
|
const keepBridgeOnTimeout = passive || options?.keepBridgeOnTimeout === true;
|
|
1141
1205
|
let requestSentAt = Date.now();
|
|
1142
1206
|
const child = this.process;
|
|
1143
|
-
const response = await new Promise((
|
|
1207
|
+
const response = await new Promise((resolve3, reject) => {
|
|
1144
1208
|
const timer = setTimeout(() => {
|
|
1145
1209
|
const entry = this.pending.get(id);
|
|
1146
1210
|
if (!entry)
|
|
@@ -1175,7 +1239,7 @@ var init_bridge = __esm(() => {
|
|
|
1175
1239
|
entry.reject(new Error(`${this.errorPrefix} Request "${command}" (id=${id}) timed out after ${effectiveTimeoutMs}ms`));
|
|
1176
1240
|
this.handleTimeout(requestSessionId);
|
|
1177
1241
|
}, effectiveTimeoutMs);
|
|
1178
|
-
this.pending.set(id, { resolve:
|
|
1242
|
+
this.pending.set(id, { resolve: resolve3, reject, timer, onProgress: options?.onProgress, command });
|
|
1179
1243
|
if (!child?.stdin?.writable) {
|
|
1180
1244
|
this.pending.delete(id);
|
|
1181
1245
|
clearTimeout(timer);
|
|
@@ -1293,15 +1357,15 @@ var init_bridge = __esm(() => {
|
|
|
1293
1357
|
if (this.process) {
|
|
1294
1358
|
const proc = this.process;
|
|
1295
1359
|
this.process = null;
|
|
1296
|
-
return new Promise((
|
|
1360
|
+
return new Promise((resolve3) => {
|
|
1297
1361
|
const forceKillTimer = setTimeout(() => {
|
|
1298
1362
|
proc.kill("SIGKILL");
|
|
1299
|
-
|
|
1363
|
+
resolve3();
|
|
1300
1364
|
}, 5000);
|
|
1301
1365
|
proc.once("exit", () => {
|
|
1302
1366
|
clearTimeout(forceKillTimer);
|
|
1303
1367
|
this.logVia("Process exited during shutdown");
|
|
1304
|
-
|
|
1368
|
+
resolve3();
|
|
1305
1369
|
});
|
|
1306
1370
|
proc.kill("SIGTERM");
|
|
1307
1371
|
});
|
|
@@ -1349,15 +1413,15 @@ var init_bridge = __esm(() => {
|
|
|
1349
1413
|
return;
|
|
1350
1414
|
const proc = this.process;
|
|
1351
1415
|
this.process = null;
|
|
1352
|
-
await new Promise((
|
|
1416
|
+
await new Promise((resolve3) => {
|
|
1353
1417
|
const forceKillTimer = setTimeout(() => {
|
|
1354
1418
|
proc.kill("SIGKILL");
|
|
1355
|
-
|
|
1419
|
+
resolve3();
|
|
1356
1420
|
}, 5000);
|
|
1357
1421
|
proc.once("exit", () => {
|
|
1358
1422
|
clearTimeout(forceKillTimer);
|
|
1359
1423
|
this.logVia("Process exited during coordinated binary replacement");
|
|
1360
|
-
|
|
1424
|
+
resolve3();
|
|
1361
1425
|
});
|
|
1362
1426
|
proc.kill("SIGTERM");
|
|
1363
1427
|
});
|
|
@@ -1387,7 +1451,7 @@ var init_bridge = __esm(() => {
|
|
|
1387
1451
|
})();
|
|
1388
1452
|
const useFastembedBackend = semanticBackend === undefined || semanticBackend === "fastembed" || semanticBackend === "";
|
|
1389
1453
|
const ortDir = typeof this.configOverrides._ort_dylib_dir === "string" && useFastembedBackend ? this.configOverrides._ort_dylib_dir : null;
|
|
1390
|
-
const ortLibraryPath = ortDir == null ? null :
|
|
1454
|
+
const ortLibraryPath = ortDir == null ? null : join4(ortDir, process.platform === "win32" ? "onnxruntime.dll" : process.platform === "darwin" ? "libonnxruntime.dylib" : "libonnxruntime.so");
|
|
1391
1455
|
const envPath = process.platform === "win32" && ortDir ? `${ortDir};${process.env.PATH ?? ""}` : process.env.PATH;
|
|
1392
1456
|
const env = {
|
|
1393
1457
|
...process.env,
|
|
@@ -1395,7 +1459,7 @@ var init_bridge = __esm(() => {
|
|
|
1395
1459
|
};
|
|
1396
1460
|
this.logVia(`bridge.spawnProcess: useFastembedBackend=${useFastembedBackend}, ` + `parentORT=${process.env.ORT_DYLIB_PATH ?? "(unset)"}, ` + `ortLibraryPath=${ortLibraryPath ?? "(none)"}`);
|
|
1397
1461
|
if (useFastembedBackend) {
|
|
1398
|
-
env.FASTEMBED_CACHE_DIR = process.env.FASTEMBED_CACHE_DIR || (typeof this.configOverrides.storage_dir === "string" ?
|
|
1462
|
+
env.FASTEMBED_CACHE_DIR = process.env.FASTEMBED_CACHE_DIR || (typeof this.configOverrides.storage_dir === "string" ? join4(this.configOverrides.storage_dir, "semantic", "models") : join4(homedir3() || "", ".cache", "fastembed"));
|
|
1399
1463
|
if (process.env.ORT_DYLIB_PATH) {
|
|
1400
1464
|
this.logVia(`ORT_DYLIB_PATH inherited from parent env: ${process.env.ORT_DYLIB_PATH}`);
|
|
1401
1465
|
} else if (ortLibraryPath) {
|
|
@@ -1726,34 +1790,34 @@ var init_bridge = __esm(() => {
|
|
|
1726
1790
|
});
|
|
1727
1791
|
|
|
1728
1792
|
// ../aft-bridge/dist/cache-paths.js
|
|
1729
|
-
import { homedir as
|
|
1730
|
-
import { join as
|
|
1731
|
-
function
|
|
1732
|
-
return (process.platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) ||
|
|
1793
|
+
import { homedir as homedir4 } from "node:os";
|
|
1794
|
+
import { join as join5 } from "node:path";
|
|
1795
|
+
function homeDir2(env) {
|
|
1796
|
+
return (process.platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) || homedir4();
|
|
1733
1797
|
}
|
|
1734
1798
|
function getAftCacheRoot(env = process.env) {
|
|
1735
1799
|
if (env.AFT_CACHE_DIR)
|
|
1736
1800
|
return env.AFT_CACHE_DIR;
|
|
1737
1801
|
if (process.platform === "win32") {
|
|
1738
|
-
const base2 = env.LOCALAPPDATA || env.APPDATA ||
|
|
1739
|
-
return
|
|
1802
|
+
const base2 = env.LOCALAPPDATA || env.APPDATA || join5(homeDir2(env), "AppData", "Local");
|
|
1803
|
+
return join5(base2, "aft");
|
|
1740
1804
|
}
|
|
1741
|
-
const base = env.XDG_CACHE_HOME ||
|
|
1742
|
-
return
|
|
1805
|
+
const base = env.XDG_CACHE_HOME || join5(homeDir2(env), ".cache");
|
|
1806
|
+
return join5(base, "aft");
|
|
1743
1807
|
}
|
|
1744
1808
|
function getAftBinaryCacheDir(env = process.env) {
|
|
1745
|
-
return
|
|
1809
|
+
return join5(getAftCacheRoot(env), "bin");
|
|
1746
1810
|
}
|
|
1747
1811
|
function getAftLspPackagesDir(env = process.env) {
|
|
1748
|
-
return
|
|
1812
|
+
return join5(getAftCacheRoot(env), "lsp-packages");
|
|
1749
1813
|
}
|
|
1750
1814
|
function getAftLspBinariesDir(env = process.env) {
|
|
1751
|
-
return
|
|
1815
|
+
return join5(getAftCacheRoot(env), "lsp-binaries");
|
|
1752
1816
|
}
|
|
1753
1817
|
var init_cache_paths = () => {};
|
|
1754
1818
|
|
|
1755
1819
|
// ../aft-bridge/dist/callgraph-format.js
|
|
1756
|
-
import { homedir as
|
|
1820
|
+
import { homedir as homedir5 } from "node:os";
|
|
1757
1821
|
function asRecord(value) {
|
|
1758
1822
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
1759
1823
|
return;
|
|
@@ -1772,7 +1836,7 @@ function asBoolean(value) {
|
|
|
1772
1836
|
return typeof value === "boolean" ? value : undefined;
|
|
1773
1837
|
}
|
|
1774
1838
|
function shortenPath(path2) {
|
|
1775
|
-
const home =
|
|
1839
|
+
const home = homedir5();
|
|
1776
1840
|
if (path2.startsWith(home))
|
|
1777
1841
|
return `~${path2.slice(home.length)}`;
|
|
1778
1842
|
return path2;
|
|
@@ -2140,26 +2204,26 @@ var init_config_keys = __esm(() => {
|
|
|
2140
2204
|
});
|
|
2141
2205
|
|
|
2142
2206
|
// ../aft-bridge/dist/config-tiers.js
|
|
2143
|
-
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
2144
|
-
import { resolve as
|
|
2207
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
2208
|
+
import { resolve as resolve3 } from "node:path";
|
|
2145
2209
|
function readConfigTiers(opts) {
|
|
2146
2210
|
const tiers = [];
|
|
2147
2211
|
try {
|
|
2148
|
-
if (
|
|
2212
|
+
if (existsSync2(opts.userConfigPath)) {
|
|
2149
2213
|
const doc = readFileSync2(opts.userConfigPath, "utf-8");
|
|
2150
2214
|
tiers.push({
|
|
2151
2215
|
tier: "user",
|
|
2152
|
-
source:
|
|
2216
|
+
source: resolve3(opts.userConfigPath),
|
|
2153
2217
|
doc
|
|
2154
2218
|
});
|
|
2155
2219
|
}
|
|
2156
2220
|
} catch {}
|
|
2157
2221
|
try {
|
|
2158
|
-
if (
|
|
2222
|
+
if (existsSync2(opts.projectConfigPath)) {
|
|
2159
2223
|
const doc = readFileSync2(opts.projectConfigPath, "utf-8");
|
|
2160
2224
|
tiers.push({
|
|
2161
2225
|
tier: "project",
|
|
2162
|
-
source:
|
|
2226
|
+
source: resolve3(opts.projectConfigPath),
|
|
2163
2227
|
doc
|
|
2164
2228
|
});
|
|
2165
2229
|
}
|
|
@@ -2198,9 +2262,9 @@ var init_platform = __esm(() => {
|
|
|
2198
2262
|
// ../aft-bridge/dist/downloader.js
|
|
2199
2263
|
import { spawnSync } from "node:child_process";
|
|
2200
2264
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
2201
|
-
import { chmodSync, closeSync, copyFileSync, createWriteStream, existsSync as
|
|
2265
|
+
import { chmodSync, closeSync, copyFileSync, createWriteStream, existsSync as existsSync3, mkdirSync, openSync, readdirSync, readFileSync as readFileSync3, renameSync, rmSync, statSync as statSync2, unlinkSync, writeSync } from "node:fs";
|
|
2202
2266
|
import { hostname } from "node:os";
|
|
2203
|
-
import { join as
|
|
2267
|
+
import { join as join6 } from "node:path";
|
|
2204
2268
|
import { Readable } from "node:stream";
|
|
2205
2269
|
import { pipeline } from "node:stream/promises";
|
|
2206
2270
|
function readBinaryVersion(binaryPath) {
|
|
@@ -2237,8 +2301,8 @@ function getBinaryName() {
|
|
|
2237
2301
|
function getCachedBinaryPath(version) {
|
|
2238
2302
|
if (!version)
|
|
2239
2303
|
return null;
|
|
2240
|
-
const binaryPath =
|
|
2241
|
-
return
|
|
2304
|
+
const binaryPath = join6(getAftBinaryCacheDir(), version, getBinaryName());
|
|
2305
|
+
return existsSync3(binaryPath) ? binaryPath : null;
|
|
2242
2306
|
}
|
|
2243
2307
|
async function downloadBinary(version) {
|
|
2244
2308
|
const archMap = PLATFORM_ARCH_MAP[process.platform] ?? {};
|
|
@@ -2254,16 +2318,16 @@ async function downloadBinary(version) {
|
|
|
2254
2318
|
return null;
|
|
2255
2319
|
}
|
|
2256
2320
|
const tag = rawTag.startsWith("v") ? rawTag : `v${rawTag}`;
|
|
2257
|
-
const versionedCacheDir =
|
|
2321
|
+
const versionedCacheDir = join6(getAftBinaryCacheDir(), tag);
|
|
2258
2322
|
const binaryName = getBinaryName();
|
|
2259
|
-
const binaryPath =
|
|
2260
|
-
if (
|
|
2323
|
+
const binaryPath = join6(versionedCacheDir, binaryName);
|
|
2324
|
+
if (existsSync3(binaryPath) && isExpectedCachedBinary(binaryPath, tag)) {
|
|
2261
2325
|
return binaryPath;
|
|
2262
2326
|
}
|
|
2263
2327
|
const downloadUrl = `https://github.com/${REPO}/releases/download/${tag}/${assetName}`;
|
|
2264
2328
|
const checksumUrl = `https://github.com/${REPO}/releases/download/${tag}/checksums.sha256`;
|
|
2265
2329
|
log(`Downloading AFT binary (${tag}) for ${platformKey}...`);
|
|
2266
|
-
const lockPath =
|
|
2330
|
+
const lockPath = join6(versionedCacheDir, ".download.lock");
|
|
2267
2331
|
let releaseLock = null;
|
|
2268
2332
|
let binaryController = null;
|
|
2269
2333
|
let checksumController = null;
|
|
@@ -2272,7 +2336,7 @@ async function downloadBinary(version) {
|
|
|
2272
2336
|
const tmpPath = `${binaryPath}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
2273
2337
|
const cleanUpPartialDownload = () => {
|
|
2274
2338
|
try {
|
|
2275
|
-
if (
|
|
2339
|
+
if (existsSync3(tmpPath))
|
|
2276
2340
|
unlinkSync(tmpPath);
|
|
2277
2341
|
} catch {}
|
|
2278
2342
|
};
|
|
@@ -2296,12 +2360,12 @@ async function downloadBinary(version) {
|
|
|
2296
2360
|
process.once("SIGINT", handleSigint);
|
|
2297
2361
|
process.once("exit", handleExit);
|
|
2298
2362
|
try {
|
|
2299
|
-
if (!
|
|
2363
|
+
if (!existsSync3(versionedCacheDir)) {
|
|
2300
2364
|
mkdirSync(versionedCacheDir, { recursive: true });
|
|
2301
2365
|
}
|
|
2302
2366
|
releaseLock = await acquireDownloadLock(lockPath);
|
|
2303
2367
|
sweepStaleDownloadTemps(versionedCacheDir, binaryName);
|
|
2304
|
-
if (
|
|
2368
|
+
if (existsSync3(binaryPath) && isExpectedCachedBinary(binaryPath, tag)) {
|
|
2305
2369
|
return binaryPath;
|
|
2306
2370
|
}
|
|
2307
2371
|
binaryController = new AbortController;
|
|
@@ -2366,7 +2430,7 @@ async function downloadBinary(version) {
|
|
|
2366
2430
|
renameSync(tmpPath, binaryPath);
|
|
2367
2431
|
}
|
|
2368
2432
|
try {
|
|
2369
|
-
if (
|
|
2433
|
+
if (existsSync3(tmpPath))
|
|
2370
2434
|
unlinkSync(tmpPath);
|
|
2371
2435
|
} catch {
|
|
2372
2436
|
warn(`Could not clean up temporary download file ${tmpPath} — it can be removed manually.`);
|
|
@@ -2481,7 +2545,7 @@ function sweepStaleDownloadTemps(versionedCacheDir, binaryName) {
|
|
|
2481
2545
|
if (!entry.isFile() || !entry.name.startsWith(tempPrefix) || !entry.name.endsWith(".tmp")) {
|
|
2482
2546
|
continue;
|
|
2483
2547
|
}
|
|
2484
|
-
const tempPath =
|
|
2548
|
+
const tempPath = join6(versionedCacheDir, entry.name);
|
|
2485
2549
|
const ageMs = Date.now() - statSync2(tempPath).mtimeMs;
|
|
2486
2550
|
if (Math.abs(ageMs) > DOWNLOAD_LOCK_STALE_MS)
|
|
2487
2551
|
unlinkSync(tempPath);
|
|
@@ -2530,7 +2594,7 @@ async function acquireDownloadLock(lockPath, timing = {}) {
|
|
|
2530
2594
|
if (Date.now() - startedAt > timeoutMs) {
|
|
2531
2595
|
throw new Error(`Timed out waiting for download lock: ${lockPath}`);
|
|
2532
2596
|
}
|
|
2533
|
-
await new Promise((
|
|
2597
|
+
await new Promise((resolve4) => setTimeout(resolve4, pollIntervalMs));
|
|
2534
2598
|
}
|
|
2535
2599
|
}
|
|
2536
2600
|
}
|
|
@@ -2577,50 +2641,6 @@ var init_downloader = __esm(() => {
|
|
|
2577
2641
|
ensureBinaryInFlight = new Map;
|
|
2578
2642
|
});
|
|
2579
2643
|
|
|
2580
|
-
// ../aft-bridge/dist/storage-paths.js
|
|
2581
|
-
import { homedir as homedir5 } from "node:os";
|
|
2582
|
-
import { join as join5, resolve as resolve3 } from "node:path";
|
|
2583
|
-
function homeDir2() {
|
|
2584
|
-
if (process.platform === "win32")
|
|
2585
|
-
return process.env.USERPROFILE || process.env.HOME || homedir5();
|
|
2586
|
-
return process.env.HOME || homedir5();
|
|
2587
|
-
}
|
|
2588
|
-
function dataHome() {
|
|
2589
|
-
const xdg = process.env.XDG_DATA_HOME;
|
|
2590
|
-
if (xdg)
|
|
2591
|
-
return xdg;
|
|
2592
|
-
if (process.platform === "win32") {
|
|
2593
|
-
return process.env.LOCALAPPDATA || process.env.APPDATA || join5(homeDir2(), "AppData", "Local");
|
|
2594
|
-
}
|
|
2595
|
-
return join5(homeDir2(), ".local", "share");
|
|
2596
|
-
}
|
|
2597
|
-
function resolveStoragePath(raw) {
|
|
2598
|
-
let expanded = raw;
|
|
2599
|
-
if (raw === "~") {
|
|
2600
|
-
expanded = homeDir2();
|
|
2601
|
-
} else if (raw.startsWith("~/") || raw.startsWith("~\\")) {
|
|
2602
|
-
expanded = join5(homeDir2(), raw.slice(2));
|
|
2603
|
-
}
|
|
2604
|
-
return resolve3(expanded);
|
|
2605
|
-
}
|
|
2606
|
-
function resolveCortexKitStorageRoot() {
|
|
2607
|
-
const override = process.env.AFT_STORAGE_DIR;
|
|
2608
|
-
if (override)
|
|
2609
|
-
return resolveStoragePath(override);
|
|
2610
|
-
return resolveStoragePath(join5(dataHome(), "cortexkit", "aft"));
|
|
2611
|
-
}
|
|
2612
|
-
function resolveAftStorageRoot(configuredRoot) {
|
|
2613
|
-
if (process.env.AFT_STORAGE_DIR)
|
|
2614
|
-
return resolveCortexKitStorageRoot();
|
|
2615
|
-
if (configuredRoot)
|
|
2616
|
-
return configuredRoot;
|
|
2617
|
-
return resolveCortexKitStorageRoot();
|
|
2618
|
-
}
|
|
2619
|
-
function resolveAftLogPath(filename, configuredRoot) {
|
|
2620
|
-
return join5(resolveAftStorageRoot(configuredRoot), "logs", filename);
|
|
2621
|
-
}
|
|
2622
|
-
var init_storage_paths = () => {};
|
|
2623
|
-
|
|
2624
2644
|
// ../aft-bridge/dist/durable-log.js
|
|
2625
2645
|
import { appendFile, mkdir, rename, rm, stat } from "node:fs/promises";
|
|
2626
2646
|
import { dirname } from "node:path";
|
|
@@ -4720,7 +4740,7 @@ function projectRootKeyHash(dir) {
|
|
|
4720
4740
|
var init_project_identity = () => {};
|
|
4721
4741
|
|
|
4722
4742
|
// ../aft-bridge/dist/subc-transport.js
|
|
4723
|
-
import { existsSync as
|
|
4743
|
+
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
4724
4744
|
function reconnectBackoffMs(attempt) {
|
|
4725
4745
|
return Math.min(RECONNECT_RETRY_FLOOR_MS * 2 ** Math.min(attempt, 6), RECONNECT_RETRY_CAP_MS);
|
|
4726
4746
|
}
|
|
@@ -5211,7 +5231,7 @@ class SubcTransportPool {
|
|
|
5211
5231
|
this.dormantRoots.delete(root);
|
|
5212
5232
|
return true;
|
|
5213
5233
|
}
|
|
5214
|
-
const reclaimedMarkerPresent =
|
|
5234
|
+
const reclaimedMarkerPresent = existsSync4(`${root}.reclaimed`);
|
|
5215
5235
|
if (reclaimedMarkerPresent) {
|
|
5216
5236
|
this.markRootDormant(root);
|
|
5217
5237
|
return false;
|
|
@@ -6121,9 +6141,9 @@ function stripJsoncSymbols(value) {
|
|
|
6121
6141
|
}
|
|
6122
6142
|
|
|
6123
6143
|
// ../aft-bridge/dist/paths.js
|
|
6124
|
-
import { existsSync as
|
|
6144
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync } from "node:fs";
|
|
6125
6145
|
import { homedir as homedir6 } from "node:os";
|
|
6126
|
-
import { dirname as dirname2, isAbsolute as isAbsolute2, join as
|
|
6146
|
+
import { dirname as dirname2, isAbsolute as isAbsolute2, join as join7, resolve as resolve5 } from "node:path";
|
|
6127
6147
|
function homeDir3() {
|
|
6128
6148
|
if (process.platform === "win32")
|
|
6129
6149
|
return process.env.USERPROFILE || process.env.HOME || homedir6();
|
|
@@ -6133,16 +6153,16 @@ function configHome() {
|
|
|
6133
6153
|
const xdg = process.env.XDG_CONFIG_HOME;
|
|
6134
6154
|
if (xdg && isAbsolute2(xdg))
|
|
6135
6155
|
return xdg;
|
|
6136
|
-
return
|
|
6156
|
+
return join7(homeDir3(), ".config");
|
|
6137
6157
|
}
|
|
6138
6158
|
function legacyOpenCodeConfigDir() {
|
|
6139
6159
|
const envDir = process.env.OPENCODE_CONFIG_DIR?.trim();
|
|
6140
6160
|
if (envDir)
|
|
6141
6161
|
return resolve5(envDir);
|
|
6142
|
-
return
|
|
6162
|
+
return join7(configHome(), "opencode");
|
|
6143
6163
|
}
|
|
6144
6164
|
function legacyPiAgentDir() {
|
|
6145
|
-
return
|
|
6165
|
+
return join7(homeDir3(), ".pi", "agent");
|
|
6146
6166
|
}
|
|
6147
6167
|
function legacySources(basePath, label, harness) {
|
|
6148
6168
|
return [
|
|
@@ -6151,10 +6171,10 @@ function legacySources(basePath, label, harness) {
|
|
|
6151
6171
|
];
|
|
6152
6172
|
}
|
|
6153
6173
|
function resolveCortexKitUserConfigPath() {
|
|
6154
|
-
return
|
|
6174
|
+
return join7(configHome(), "cortexkit", "aft.jsonc");
|
|
6155
6175
|
}
|
|
6156
6176
|
function resolveCortexKitProjectConfigPath(projectDirectory) {
|
|
6157
|
-
return
|
|
6177
|
+
return join7(projectDirectory, ".cortexkit", "aft.jsonc");
|
|
6158
6178
|
}
|
|
6159
6179
|
function resolveCortexKitConfigPaths(projectDirectory) {
|
|
6160
6180
|
return {
|
|
@@ -6165,22 +6185,22 @@ function resolveCortexKitConfigPaths(projectDirectory) {
|
|
|
6165
6185
|
function resolveLegacyAftConfigSources(projectDirectory) {
|
|
6166
6186
|
return {
|
|
6167
6187
|
user: [
|
|
6168
|
-
...legacySources(
|
|
6169
|
-
...legacySources(
|
|
6188
|
+
...legacySources(join7(legacyOpenCodeConfigDir(), "aft"), "OpenCode user", "opencode"),
|
|
6189
|
+
...legacySources(join7(legacyPiAgentDir(), "aft"), "Pi user", "pi")
|
|
6170
6190
|
],
|
|
6171
6191
|
project: [
|
|
6172
|
-
...legacySources(
|
|
6173
|
-
...legacySources(
|
|
6192
|
+
...legacySources(join7(projectDirectory, ".opencode", "aft"), "OpenCode project", "opencode"),
|
|
6193
|
+
...legacySources(join7(projectDirectory, ".pi", "aft"), "Pi project", "pi")
|
|
6174
6194
|
]
|
|
6175
6195
|
};
|
|
6176
6196
|
}
|
|
6177
6197
|
function resolveHarnessStoragePath(storageRoot, harness, ...segments) {
|
|
6178
|
-
return
|
|
6198
|
+
return join7(storageRoot, harness, ...segments);
|
|
6179
6199
|
}
|
|
6180
6200
|
function repairRootScopedStorageFile(storageRoot, harness, fileName) {
|
|
6181
6201
|
const harnessPath = resolveHarnessStoragePath(storageRoot, harness, fileName);
|
|
6182
|
-
const rootPath =
|
|
6183
|
-
if (
|
|
6202
|
+
const rootPath = join7(storageRoot, fileName);
|
|
6203
|
+
if (existsSync5(harnessPath) || !existsSync5(rootPath))
|
|
6184
6204
|
return harnessPath;
|
|
6185
6205
|
try {
|
|
6186
6206
|
mkdirSync2(dirname2(harnessPath), { recursive: true });
|
|
@@ -6194,7 +6214,7 @@ function shouldShowAnnouncement(storageRoot, harness, currentVersion) {
|
|
|
6194
6214
|
const versionFile = repairRootScopedStorageFile(storageRoot, harness, "last_announced_version");
|
|
6195
6215
|
let lastVersion = "";
|
|
6196
6216
|
try {
|
|
6197
|
-
if (
|
|
6217
|
+
if (existsSync5(versionFile)) {
|
|
6198
6218
|
lastVersion = readFileSync4(versionFile, "utf-8").trim();
|
|
6199
6219
|
}
|
|
6200
6220
|
} catch {
|
|
@@ -6267,10 +6287,10 @@ var init_paths = () => {};
|
|
|
6267
6287
|
|
|
6268
6288
|
// ../aft-bridge/dist/resolver.js
|
|
6269
6289
|
import { execSync } from "node:child_process";
|
|
6270
|
-
import { chmodSync as chmodSync2, closeSync as closeSync2, copyFileSync as copyFileSync2, existsSync as
|
|
6290
|
+
import { chmodSync as chmodSync2, closeSync as closeSync2, copyFileSync as copyFileSync2, existsSync as existsSync6, mkdirSync as mkdirSync3, openSync as openSync2, readSync, renameSync as renameSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
6271
6291
|
import { createRequire } from "node:module";
|
|
6272
6292
|
import { homedir as homedir7 } from "node:os";
|
|
6273
|
-
import { join as
|
|
6293
|
+
import { join as join8 } from "node:path";
|
|
6274
6294
|
function copyToVersionedCache(npmBinaryPath, knownVersion) {
|
|
6275
6295
|
try {
|
|
6276
6296
|
const version = knownVersion ?? readBinaryVersion(npmBinaryPath);
|
|
@@ -6278,10 +6298,10 @@ function copyToVersionedCache(npmBinaryPath, knownVersion) {
|
|
|
6278
6298
|
return null;
|
|
6279
6299
|
const tag = version.startsWith("v") ? version : `v${version}`;
|
|
6280
6300
|
const cacheDir = getAftBinaryCacheDir();
|
|
6281
|
-
const versionedDir =
|
|
6301
|
+
const versionedDir = join8(cacheDir, tag);
|
|
6282
6302
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
6283
|
-
const cachedPath =
|
|
6284
|
-
if (
|
|
6303
|
+
const cachedPath = join8(versionedDir, `aft${ext}`);
|
|
6304
|
+
if (existsSync6(cachedPath)) {
|
|
6285
6305
|
const cachedVersion = readBinaryVersion(cachedPath);
|
|
6286
6306
|
if (cachedVersion === version)
|
|
6287
6307
|
return cachedPath;
|
|
@@ -6293,7 +6313,7 @@ function copyToVersionedCache(npmBinaryPath, knownVersion) {
|
|
|
6293
6313
|
if (process.platform !== "win32") {
|
|
6294
6314
|
chmodSync2(tmpPath, 493);
|
|
6295
6315
|
}
|
|
6296
|
-
if (process.platform === "win32" &&
|
|
6316
|
+
if (process.platform === "win32" && existsSync6(cachedPath)) {
|
|
6297
6317
|
try {
|
|
6298
6318
|
unlinkSync2(cachedPath);
|
|
6299
6319
|
} catch {}
|
|
@@ -6313,8 +6333,8 @@ function homeDirFromEnv(env) {
|
|
|
6313
6333
|
return (process.platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) || homedir7();
|
|
6314
6334
|
}
|
|
6315
6335
|
function cachedBinaryPathFromEnv(version, env, ext) {
|
|
6316
|
-
const binaryPath =
|
|
6317
|
-
return
|
|
6336
|
+
const binaryPath = join8(getAftBinaryCacheDir(env), version, `aft${ext}`);
|
|
6337
|
+
return existsSync6(binaryPath) ? binaryPath : null;
|
|
6318
6338
|
}
|
|
6319
6339
|
function isExpectedCachedBinary2(binaryPath, expectedVersion) {
|
|
6320
6340
|
const expected = normalizeBareVersion(expectedVersion);
|
|
@@ -6413,7 +6433,7 @@ function findBinarySyncInner(expectedVersion) {
|
|
|
6413
6433
|
const packageBin = `@cortexkit/aft-${key}/bin/aft${ext}`;
|
|
6414
6434
|
const req = createRequire(import.meta.url);
|
|
6415
6435
|
const resolved = req.resolve(packageBin);
|
|
6416
|
-
if (
|
|
6436
|
+
if (existsSync6(resolved)) {
|
|
6417
6437
|
const npmVersion = readBinaryVersion(resolved);
|
|
6418
6438
|
if (npmVersion === null) {
|
|
6419
6439
|
warn(`npm platform package binary at ${resolved} did not report a version; skipping (continuing to PATH lookup)`);
|
|
@@ -6442,8 +6462,8 @@ function findBinarySyncInner(expectedVersion) {
|
|
|
6442
6462
|
return { path: usable, source: "PATH" };
|
|
6443
6463
|
}
|
|
6444
6464
|
} catch {}
|
|
6445
|
-
const cargoPath =
|
|
6446
|
-
if (
|
|
6465
|
+
const cargoPath = join8(homeDirFromEnv(env), ".cargo", "bin", `aft${ext}`);
|
|
6466
|
+
if (existsSync6(cargoPath)) {
|
|
6447
6467
|
const usable = probeBinaryCandidate(cargoPath, "cargo", expectedVersion);
|
|
6448
6468
|
if (usable)
|
|
6449
6469
|
return { path: usable, source: "cargo" };
|
|
@@ -6491,16 +6511,16 @@ var init_resolver = __esm(() => {
|
|
|
6491
6511
|
|
|
6492
6512
|
// ../aft-bridge/dist/migration.js
|
|
6493
6513
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
6494
|
-
import { closeSync as closeSync3, existsSync as
|
|
6514
|
+
import { closeSync as closeSync3, existsSync as existsSync7, mkdirSync as mkdirSync4, openSync as openSync3, readFileSync as readFileSync5, renameSync as renameSync4, rmSync as rmSync2, statSync as statSync4, unlinkSync as unlinkSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
6495
6515
|
import { homedir as homedir8, tmpdir } from "node:os";
|
|
6496
|
-
import { basename, dirname as dirname3, join as
|
|
6516
|
+
import { basename, dirname as dirname3, join as join9, resolve as resolve6 } from "node:path";
|
|
6497
6517
|
function dataHome2() {
|
|
6498
6518
|
if (process.env.XDG_DATA_HOME)
|
|
6499
6519
|
return process.env.XDG_DATA_HOME;
|
|
6500
6520
|
if (process.platform === "win32") {
|
|
6501
|
-
return process.env.LOCALAPPDATA || process.env.APPDATA ||
|
|
6521
|
+
return process.env.LOCALAPPDATA || process.env.APPDATA || join9(homeDir4(), "AppData", "Local");
|
|
6502
6522
|
}
|
|
6503
|
-
return
|
|
6523
|
+
return join9(homeDir4(), ".local", "share");
|
|
6504
6524
|
}
|
|
6505
6525
|
function homeDir4() {
|
|
6506
6526
|
if (process.platform === "win32")
|
|
@@ -6509,8 +6529,8 @@ function homeDir4() {
|
|
|
6509
6529
|
}
|
|
6510
6530
|
function resolveLegacyStorageRoot(harness) {
|
|
6511
6531
|
if (harness === "pi")
|
|
6512
|
-
return
|
|
6513
|
-
return
|
|
6532
|
+
return join9(homeDir4(), ".pi", "agent", "aft");
|
|
6533
|
+
return join9(dataHome2(), "opencode", "storage", "plugin", "aft");
|
|
6514
6534
|
}
|
|
6515
6535
|
function stripJsoncForParse(input) {
|
|
6516
6536
|
let out = "";
|
|
@@ -6640,7 +6660,7 @@ function acquireConfigMigrationLock(lockDir) {
|
|
|
6640
6660
|
}
|
|
6641
6661
|
function atomicCopyConfigFile(sourcePath, targetPath) {
|
|
6642
6662
|
mkdirSync4(dirname3(targetPath), { recursive: true });
|
|
6643
|
-
const tmpPath =
|
|
6663
|
+
const tmpPath = join9(dirname3(targetPath), `.${basename(targetPath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`);
|
|
6644
6664
|
let fd = null;
|
|
6645
6665
|
try {
|
|
6646
6666
|
fd = openSync3(tmpPath, "wx", 384);
|
|
@@ -6662,7 +6682,7 @@ function atomicCopyConfigFile(sourcePath, targetPath) {
|
|
|
6662
6682
|
}
|
|
6663
6683
|
function atomicWriteConfigFile(targetPath, content) {
|
|
6664
6684
|
mkdirSync4(dirname3(targetPath), { recursive: true });
|
|
6665
|
-
const tmpPath =
|
|
6685
|
+
const tmpPath = join9(dirname3(targetPath), `.${basename(targetPath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`);
|
|
6666
6686
|
let fd = null;
|
|
6667
6687
|
try {
|
|
6668
6688
|
fd = openSync3(tmpPath, "wx", 384);
|
|
@@ -6683,11 +6703,11 @@ function atomicWriteConfigFile(targetPath, content) {
|
|
|
6683
6703
|
}
|
|
6684
6704
|
}
|
|
6685
6705
|
function nonClobberingSidecarPath(desiredPath) {
|
|
6686
|
-
if (!
|
|
6706
|
+
if (!existsSync7(desiredPath))
|
|
6687
6707
|
return desiredPath;
|
|
6688
6708
|
for (let index = 1;index < Number.MAX_SAFE_INTEGER; index++) {
|
|
6689
6709
|
const candidate = `${desiredPath}.${index}`;
|
|
6690
|
-
if (!
|
|
6710
|
+
if (!existsSync7(candidate))
|
|
6691
6711
|
return candidate;
|
|
6692
6712
|
}
|
|
6693
6713
|
throw new Error(`could not find available preservation sidecar path for ${desiredPath}`);
|
|
@@ -6780,7 +6800,7 @@ function visibleConfigMigrationWarning(scope, targetPath, paths, reason) {
|
|
|
6780
6800
|
function migrateAftConfigFile(opts) {
|
|
6781
6801
|
const warnings = [];
|
|
6782
6802
|
const resolvedTarget = resolve6(opts.targetPath);
|
|
6783
|
-
const existingSources = opts.legacySources.filter((source) =>
|
|
6803
|
+
const existingSources = opts.legacySources.filter((source) => existsSync7(source.path) && resolve6(source.path) !== resolvedTarget);
|
|
6784
6804
|
const info = opts.logger?.info ?? opts.logger?.log;
|
|
6785
6805
|
if (existingSources.length === 0) {
|
|
6786
6806
|
return { migrated: false, conflict: false, targetPath: opts.targetPath, warnings };
|
|
@@ -6792,7 +6812,7 @@ function migrateAftConfigFile(opts) {
|
|
|
6792
6812
|
...source,
|
|
6793
6813
|
content: readFileSync5(source.path, "utf-8")
|
|
6794
6814
|
}));
|
|
6795
|
-
if (
|
|
6815
|
+
if (existsSync7(opts.targetPath)) {
|
|
6796
6816
|
const targetContent = readFileSync5(opts.targetPath, "utf-8");
|
|
6797
6817
|
for (const source of sources) {
|
|
6798
6818
|
if (fileSemanticsMatch(source.content, targetContent))
|
|
@@ -6842,12 +6862,12 @@ function spawnErrorLabel(error2) {
|
|
|
6842
6862
|
return [code, error2.message].filter(Boolean).join(": ");
|
|
6843
6863
|
}
|
|
6844
6864
|
function migrationLogPath(newRoot, harness, logger) {
|
|
6845
|
-
const desired =
|
|
6865
|
+
const desired = join9(newRoot, "logs", "migration", `${harness}-${Date.now()}.jsonl`);
|
|
6846
6866
|
try {
|
|
6847
6867
|
mkdirSync4(dirname3(desired), { recursive: true });
|
|
6848
6868
|
return desired;
|
|
6849
6869
|
} catch (err) {
|
|
6850
|
-
const fallback =
|
|
6870
|
+
const fallback = join9(tmpdir(), `aft-migration-${harness}-${Date.now()}.jsonl`);
|
|
6851
6871
|
logger?.warn?.(`Failed to create AFT migration log directory ${dirname3(desired)}: ${err instanceof Error ? err.message : String(err)}. ` + `Using fallback log path ${fallback}.`);
|
|
6852
6872
|
return fallback;
|
|
6853
6873
|
}
|
|
@@ -6857,11 +6877,11 @@ async function ensureStorageMigrated(opts) {
|
|
|
6857
6877
|
const newRoot = resolveCortexKitStorageRoot();
|
|
6858
6878
|
const targetMarker = resolveHarnessStoragePath(newRoot, opts.harness, TARGET_MARKER);
|
|
6859
6879
|
const info = opts.logger?.info ?? opts.logger?.log;
|
|
6860
|
-
if (
|
|
6880
|
+
if (existsSync7(targetMarker)) {
|
|
6861
6881
|
info?.(`AFT storage already migrated for ${opts.harness}; using ${newRoot}`);
|
|
6862
6882
|
return;
|
|
6863
6883
|
}
|
|
6864
|
-
if (!
|
|
6884
|
+
if (!existsSync7(legacyRoot)) {
|
|
6865
6885
|
info?.(`AFT storage migration skipped for ${opts.harness}: no legacy data at ${legacyRoot}; ` + `using ${newRoot} for fresh install`);
|
|
6866
6886
|
return;
|
|
6867
6887
|
}
|
|
@@ -6952,7 +6972,7 @@ var init_migration = __esm(() => {
|
|
|
6952
6972
|
import { execFileSync } from "node:child_process";
|
|
6953
6973
|
import { readdirSync as readdirSync2, statSync as statSync5 } from "node:fs";
|
|
6954
6974
|
import { homedir as homedir9 } from "node:os";
|
|
6955
|
-
import { delimiter, dirname as dirname4, isAbsolute as isAbsolute3, join as
|
|
6975
|
+
import { delimiter as delimiter2, dirname as dirname4, isAbsolute as isAbsolute3, join as join10 } from "node:path";
|
|
6956
6976
|
function defaultDeps() {
|
|
6957
6977
|
return {
|
|
6958
6978
|
platform: process.platform,
|
|
@@ -6974,18 +6994,18 @@ function isFile(p) {
|
|
|
6974
6994
|
function npmFromPath(deps) {
|
|
6975
6995
|
const name = npmBinaryName(deps.platform);
|
|
6976
6996
|
const raw = deps.env.PATH ?? deps.env.Path ?? "";
|
|
6977
|
-
for (const entry of raw.split(
|
|
6997
|
+
for (const entry of raw.split(delimiter2)) {
|
|
6978
6998
|
const dir = entry.trim().replace(/^"|"$/g, "");
|
|
6979
6999
|
if (!dir || !isAbsolute3(dir))
|
|
6980
7000
|
continue;
|
|
6981
|
-
if (isFile(
|
|
7001
|
+
if (isFile(join10(dir, name)))
|
|
6982
7002
|
return dir;
|
|
6983
7003
|
}
|
|
6984
7004
|
return null;
|
|
6985
7005
|
}
|
|
6986
7006
|
function npmAdjacentToNode(deps) {
|
|
6987
7007
|
const dir = dirname4(deps.execPath);
|
|
6988
|
-
return isFile(
|
|
7008
|
+
return isFile(join10(dir, npmBinaryName(deps.platform))) ? dir : null;
|
|
6989
7009
|
}
|
|
6990
7010
|
function highestVersionedNodeBin(installsDir, name) {
|
|
6991
7011
|
let entries;
|
|
@@ -6994,8 +7014,8 @@ function highestVersionedNodeBin(installsDir, name) {
|
|
|
6994
7014
|
} catch {
|
|
6995
7015
|
return null;
|
|
6996
7016
|
}
|
|
6997
|
-
const candidates = entries.filter((v) => isFile(
|
|
6998
|
-
return candidates.length > 0 ?
|
|
7017
|
+
const candidates = entries.filter((v) => isFile(join10(installsDir, v, "bin", name))).sort((a, b) => compareVersionsDesc(a, b));
|
|
7018
|
+
return candidates.length > 0 ? join10(installsDir, candidates[0], "bin") : null;
|
|
6999
7019
|
}
|
|
7000
7020
|
function compareVersionsDesc(a, b) {
|
|
7001
7021
|
const pa = a.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10));
|
|
@@ -7020,22 +7040,22 @@ function wellKnownNpmDirs(deps) {
|
|
|
7020
7040
|
const programFiles = env.ProgramFiles || "C:\\Program Files";
|
|
7021
7041
|
const appData = env.APPDATA;
|
|
7022
7042
|
const localAppData = env.LOCALAPPDATA;
|
|
7023
|
-
push(
|
|
7043
|
+
push(join10(programFiles, "nodejs"));
|
|
7024
7044
|
if (appData)
|
|
7025
|
-
push(
|
|
7045
|
+
push(join10(appData, "npm"));
|
|
7026
7046
|
if (localAppData)
|
|
7027
|
-
push(
|
|
7047
|
+
push(join10(localAppData, "Volta", "bin"));
|
|
7028
7048
|
if (env.NVM_SYMLINK)
|
|
7029
7049
|
push(env.NVM_SYMLINK);
|
|
7030
7050
|
} else {
|
|
7031
7051
|
if (env.NVM_BIN)
|
|
7032
7052
|
push(env.NVM_BIN);
|
|
7033
|
-
push(highestVersionedNodeBin(
|
|
7034
|
-
push(highestVersionedNodeBin(
|
|
7035
|
-
push(highestVersionedNodeBin(
|
|
7036
|
-
push(
|
|
7037
|
-
push(
|
|
7038
|
-
const systemDirs = deps.systemNpmDirs ?? (platform === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : ["/usr/local/bin", "/usr/bin",
|
|
7053
|
+
push(highestVersionedNodeBin(join10(home, ".nvm", "versions", "node"), name));
|
|
7054
|
+
push(highestVersionedNodeBin(join10(home, ".local", "share", "mise", "installs", "node"), name));
|
|
7055
|
+
push(highestVersionedNodeBin(join10(home, ".asdf", "installs", "nodejs"), name));
|
|
7056
|
+
push(join10(home, ".volta", "bin"));
|
|
7057
|
+
push(join10(home, ".asdf", "shims"));
|
|
7058
|
+
const systemDirs = deps.systemNpmDirs ?? (platform === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : ["/usr/local/bin", "/usr/bin", join10(home, ".local", "bin")]);
|
|
7039
7059
|
for (const dir of systemDirs)
|
|
7040
7060
|
push(dir);
|
|
7041
7061
|
}
|
|
@@ -7045,12 +7065,12 @@ function resolveNpm(deps = defaultDeps()) {
|
|
|
7045
7065
|
const name = npmBinaryName(deps.platform);
|
|
7046
7066
|
const onPath = npmFromPath(deps);
|
|
7047
7067
|
if (onPath)
|
|
7048
|
-
return { command:
|
|
7068
|
+
return { command: join10(onPath, name), binDir: onPath };
|
|
7049
7069
|
const adjacent = npmAdjacentToNode(deps);
|
|
7050
7070
|
if (adjacent)
|
|
7051
|
-
return { command:
|
|
7071
|
+
return { command: join10(adjacent, name), binDir: adjacent };
|
|
7052
7072
|
for (const dir of wellKnownNpmDirs(deps)) {
|
|
7053
|
-
const candidate =
|
|
7073
|
+
const candidate = join10(dir, name);
|
|
7054
7074
|
if (isFile(candidate))
|
|
7055
7075
|
return { command: candidate, binDir: dir };
|
|
7056
7076
|
}
|
|
@@ -7060,7 +7080,7 @@ function npmSpawnEnv(resolved, baseEnv = process.env) {
|
|
|
7060
7080
|
if (!resolved.binDir)
|
|
7061
7081
|
return { ...baseEnv };
|
|
7062
7082
|
const existing = baseEnv.PATH ?? baseEnv.Path ?? "";
|
|
7063
|
-
const next = existing ? `${resolved.binDir}${
|
|
7083
|
+
const next = existing ? `${resolved.binDir}${delimiter2}${existing}` : resolved.binDir;
|
|
7064
7084
|
return { ...baseEnv, PATH: next };
|
|
7065
7085
|
}
|
|
7066
7086
|
function isNpmAvailable(deps = defaultDeps()) {
|
|
@@ -7085,8 +7105,8 @@ var init_npm_resolver = () => {};
|
|
|
7085
7105
|
// ../aft-bridge/dist/onnx-runtime.js
|
|
7086
7106
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
7087
7107
|
import { createHash as createHash4 } from "node:crypto";
|
|
7088
|
-
import { chmodSync as chmodSync3, closeSync as closeSync4, copyFileSync as copyFileSync3, createWriteStream as createWriteStream2, existsSync as
|
|
7089
|
-
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute4, join as
|
|
7108
|
+
import { chmodSync as chmodSync3, closeSync as closeSync4, copyFileSync as copyFileSync3, createWriteStream as createWriteStream2, existsSync as existsSync8, lstatSync, mkdirSync as mkdirSync5, openSync as openSync4, readdirSync as readdirSync3, readFileSync as readFileSync6, readlinkSync, realpathSync as realpathSync2, rmSync as rmSync3, statSync as statSync6, symlinkSync, unlinkSync as unlinkSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
7109
|
+
import { basename as basename2, dirname as dirname5, isAbsolute as isAbsolute4, join as join11, relative as relative2, resolve as resolve7, win32 } from "node:path";
|
|
7090
7110
|
import { Readable as Readable2 } from "node:stream";
|
|
7091
7111
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
7092
7112
|
function getPlatformInfo() {
|
|
@@ -7112,11 +7132,11 @@ function getManualInstallHint() {
|
|
|
7112
7132
|
}
|
|
7113
7133
|
async function ensureOnnxRuntime(storageDir) {
|
|
7114
7134
|
const info = getPlatformInfo();
|
|
7115
|
-
const ortVersionDir =
|
|
7135
|
+
const ortVersionDir = join11(storageDir, "onnxruntime", ORT_VERSION);
|
|
7116
7136
|
const libName = info?.libName ?? "libonnxruntime.dylib";
|
|
7117
7137
|
const resolvedOrtDir = resolveCachedOnnxRuntimeDir(ortVersionDir, libName);
|
|
7118
|
-
const libPath =
|
|
7119
|
-
if (
|
|
7138
|
+
const libPath = join11(resolvedOrtDir, libName);
|
|
7139
|
+
if (existsSync8(libPath)) {
|
|
7120
7140
|
const meta = readOnnxInstalledMeta(ortVersionDir);
|
|
7121
7141
|
if (meta?.sha256) {
|
|
7122
7142
|
try {
|
|
@@ -7145,9 +7165,9 @@ async function ensureOnnxRuntime(storageDir) {
|
|
|
7145
7165
|
warn(`ONNX Runtime auto-download not available for ${process.platform}/${process.arch}. Install manually: ${getManualInstallHint()}`);
|
|
7146
7166
|
return null;
|
|
7147
7167
|
}
|
|
7148
|
-
const onnxBaseDir =
|
|
7168
|
+
const onnxBaseDir = join11(storageDir, "onnxruntime");
|
|
7149
7169
|
mkdirSync5(onnxBaseDir, { recursive: true });
|
|
7150
|
-
const lockPath =
|
|
7170
|
+
const lockPath = join11(onnxBaseDir, ONNX_LOCK_FILE);
|
|
7151
7171
|
cleanupAbandonedStagingDirs(onnxBaseDir);
|
|
7152
7172
|
if (!acquireLock(lockPath)) {
|
|
7153
7173
|
warn(`ONNX Runtime install already in progress in another process (lock: ${lockPath}). Skipping.`);
|
|
@@ -7166,7 +7186,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
|
|
|
7166
7186
|
for (const entry of entries) {
|
|
7167
7187
|
if (!entry.startsWith(`${ORT_VERSION}.tmp.`))
|
|
7168
7188
|
continue;
|
|
7169
|
-
const stagingDir =
|
|
7189
|
+
const stagingDir = join11(onnxBaseDir, entry);
|
|
7170
7190
|
const parts = entry.split(".");
|
|
7171
7191
|
const pidStr = parts[parts.length - 2];
|
|
7172
7192
|
const pid = pidStr ? Number.parseInt(pidStr, 10) : NaN;
|
|
@@ -7203,7 +7223,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
|
|
|
7203
7223
|
}
|
|
7204
7224
|
function cleanupIncompleteTargetIfUnowned(ortDir) {
|
|
7205
7225
|
try {
|
|
7206
|
-
if (
|
|
7226
|
+
if (existsSync8(ortDir) && !existsSync8(join11(ortDir, ONNX_INSTALLED_META_FILE))) {
|
|
7207
7227
|
log(`[onnx] removing half-populated install dir ${ortDir} (no meta file)`);
|
|
7208
7228
|
rmSync3(ortDir, { recursive: true, force: true });
|
|
7209
7229
|
}
|
|
@@ -7248,8 +7268,8 @@ function detectOnnxVersion(libDir, libName) {
|
|
|
7248
7268
|
if (version)
|
|
7249
7269
|
return version;
|
|
7250
7270
|
}
|
|
7251
|
-
const base =
|
|
7252
|
-
if (
|
|
7271
|
+
const base = join11(libDir, libName);
|
|
7272
|
+
if (existsSync8(base)) {
|
|
7253
7273
|
try {
|
|
7254
7274
|
const real = realpathSync2(base);
|
|
7255
7275
|
const version = parseOnnxVersionFromPath(real) ?? parseOnnxVersionFromDirectoryPath(real);
|
|
@@ -7280,8 +7300,8 @@ function pathEnvValue() {
|
|
|
7280
7300
|
return process.env.PATH ?? process.env.Path ?? process.env.path ?? "";
|
|
7281
7301
|
}
|
|
7282
7302
|
function pathEntriesForPlatform() {
|
|
7283
|
-
const
|
|
7284
|
-
return pathEnvValue().split(
|
|
7303
|
+
const delimiter3 = process.platform === "win32" ? ";" : ":";
|
|
7304
|
+
return pathEnvValue().split(delimiter3).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => {
|
|
7285
7305
|
if (!entry || entry === "." || entry.includes("\x00"))
|
|
7286
7306
|
return false;
|
|
7287
7307
|
return isAbsolute4(entry) || win32.isAbsolute(entry);
|
|
@@ -7311,10 +7331,10 @@ function directoryContainsLibrary(dir, libName) {
|
|
|
7311
7331
|
}
|
|
7312
7332
|
}
|
|
7313
7333
|
function resolveCachedOnnxRuntimeDir(ortVersionDir, libName) {
|
|
7314
|
-
if (
|
|
7334
|
+
if (existsSync8(join11(ortVersionDir, libName)))
|
|
7315
7335
|
return ortVersionDir;
|
|
7316
|
-
const libSubdir =
|
|
7317
|
-
if (
|
|
7336
|
+
const libSubdir = join11(ortVersionDir, "lib");
|
|
7337
|
+
if (existsSync8(join11(libSubdir, libName)))
|
|
7318
7338
|
return libSubdir;
|
|
7319
7339
|
return ortVersionDir;
|
|
7320
7340
|
}
|
|
@@ -7329,13 +7349,13 @@ function findSystemOnnxRuntime(libName) {
|
|
|
7329
7349
|
} else if (process.platform === "win32") {
|
|
7330
7350
|
const programFiles = process.env.ProgramFiles ?? "C:\\Program Files";
|
|
7331
7351
|
const programFilesX86 = process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
|
7332
|
-
searchPaths.push(
|
|
7352
|
+
searchPaths.push(join11(programFiles, "onnxruntime", "lib"), join11(programFiles, "Microsoft ONNX Runtime", "lib"), join11(programFiles, "Microsoft Machine Learning", "lib"), join11(programFilesX86, "onnxruntime", "lib"), ...(() => {
|
|
7333
7353
|
const nugetPaths = [];
|
|
7334
7354
|
const userProfile = process.env.USERPROFILE ?? "";
|
|
7335
7355
|
if (!userProfile)
|
|
7336
7356
|
return nugetPaths;
|
|
7337
|
-
const nugetPackageDir =
|
|
7338
|
-
if (!
|
|
7357
|
+
const nugetPackageDir = join11(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
|
|
7358
|
+
if (!existsSync8(nugetPackageDir))
|
|
7339
7359
|
return nugetPaths;
|
|
7340
7360
|
try {
|
|
7341
7361
|
for (const entry of readdirSync3(nugetPackageDir, { withFileTypes: true })) {
|
|
@@ -7343,7 +7363,7 @@ function findSystemOnnxRuntime(libName) {
|
|
|
7343
7363
|
continue;
|
|
7344
7364
|
if (entry.name === "__globalPackagesFolder" || entry.name.startsWith("."))
|
|
7345
7365
|
continue;
|
|
7346
|
-
nugetPaths.push(
|
|
7366
|
+
nugetPaths.push(join11(nugetPackageDir, entry.name, "runtimes", "win-x64", "native"), join11(nugetPackageDir, entry.name, "runtimes", "win-arm64", "native"));
|
|
7347
7367
|
}
|
|
7348
7368
|
} catch (err) {
|
|
7349
7369
|
warn(`Failed to scan NuGet ONNX Runtime cache ${nugetPackageDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -7365,11 +7385,11 @@ function findSystemOnnxRuntime(libName) {
|
|
|
7365
7385
|
});
|
|
7366
7386
|
const unknownVersionPaths = [];
|
|
7367
7387
|
for (const dir of uniquePaths) {
|
|
7368
|
-
const libPath =
|
|
7388
|
+
const libPath = join11(dir, libName);
|
|
7369
7389
|
if (process.platform === "win32") {
|
|
7370
7390
|
if (!directoryContainsLibrary(dir, libName))
|
|
7371
7391
|
continue;
|
|
7372
|
-
} else if (!
|
|
7392
|
+
} else if (!existsSync8(libPath)) {
|
|
7373
7393
|
continue;
|
|
7374
7394
|
}
|
|
7375
7395
|
const version = detectOnnxVersion(dir, libName);
|
|
@@ -7435,7 +7455,7 @@ function validateExtractedTree(stagingRoot) {
|
|
|
7435
7455
|
const walk = (dir) => {
|
|
7436
7456
|
const entries = readdirSync3(dir);
|
|
7437
7457
|
for (const entry of entries) {
|
|
7438
|
-
const fullPath =
|
|
7458
|
+
const fullPath = join11(dir, entry);
|
|
7439
7459
|
const lst = lstatSync(fullPath);
|
|
7440
7460
|
if (lst.isSymbolicLink()) {
|
|
7441
7461
|
const linkTarget = readlinkSync(fullPath);
|
|
@@ -7470,7 +7490,7 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
7470
7490
|
const tmpDir = `${targetDir}.tmp.${process.pid}.${Date.now().toString(36)}`;
|
|
7471
7491
|
try {
|
|
7472
7492
|
mkdirSync5(tmpDir, { recursive: true });
|
|
7473
|
-
const archivePath =
|
|
7493
|
+
const archivePath = join11(tmpDir, `onnxruntime.${info.archiveType}`);
|
|
7474
7494
|
await downloadFileWithCap(url, archivePath);
|
|
7475
7495
|
const archiveSha256 = sha256File(archivePath);
|
|
7476
7496
|
log(`ONNX Runtime archive sha256=${archiveSha256}`);
|
|
@@ -7486,8 +7506,8 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
7486
7506
|
unlinkSync4(archivePath);
|
|
7487
7507
|
} catch {}
|
|
7488
7508
|
validateExtractedTree(tmpDir);
|
|
7489
|
-
const extractedDir =
|
|
7490
|
-
if (!
|
|
7509
|
+
const extractedDir = join11(tmpDir, info.assetName, "lib");
|
|
7510
|
+
if (!existsSync8(extractedDir)) {
|
|
7491
7511
|
throw new Error(`Expected directory not found: ${extractedDir}`);
|
|
7492
7512
|
}
|
|
7493
7513
|
mkdirSync5(targetDir, { recursive: true });
|
|
@@ -7495,7 +7515,7 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
7495
7515
|
const realFiles = [];
|
|
7496
7516
|
const symlinks = [];
|
|
7497
7517
|
for (const libFile of libFiles) {
|
|
7498
|
-
const src =
|
|
7518
|
+
const src = join11(extractedDir, libFile);
|
|
7499
7519
|
try {
|
|
7500
7520
|
const stat2 = lstatSync(src);
|
|
7501
7521
|
log(`ORT extract: ${libFile} — isSymlink=${stat2.isSymbolicLink()}, isFile=${stat2.isFile()}, size=${stat2.size}`);
|
|
@@ -7510,7 +7530,7 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
7510
7530
|
}
|
|
7511
7531
|
}
|
|
7512
7532
|
copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks);
|
|
7513
|
-
const libPath =
|
|
7533
|
+
const libPath = join11(targetDir, info.libName);
|
|
7514
7534
|
let libHash = null;
|
|
7515
7535
|
try {
|
|
7516
7536
|
libHash = sha256File(libPath);
|
|
@@ -7535,8 +7555,8 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
7535
7555
|
function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, copyFile = copyFileSync3) {
|
|
7536
7556
|
const requiredLibs = new Set([info.libName]);
|
|
7537
7557
|
for (const libFile of realFiles) {
|
|
7538
|
-
const src =
|
|
7539
|
-
const dst =
|
|
7558
|
+
const src = join11(extractedDir, libFile);
|
|
7559
|
+
const dst = join11(targetDir, libFile);
|
|
7540
7560
|
try {
|
|
7541
7561
|
copyFile(src, dst);
|
|
7542
7562
|
if (process.platform !== "win32") {
|
|
@@ -7552,11 +7572,11 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
|
|
|
7552
7572
|
}
|
|
7553
7573
|
const targetRoot = realpathSync2(targetDir);
|
|
7554
7574
|
for (const link of symlinks) {
|
|
7555
|
-
const dst =
|
|
7575
|
+
const dst = join11(targetDir, link.name);
|
|
7556
7576
|
try {
|
|
7557
7577
|
unlinkSync4(dst);
|
|
7558
7578
|
} catch {}
|
|
7559
|
-
const dstForContainment =
|
|
7579
|
+
const dstForContainment = join11(targetRoot, link.name);
|
|
7560
7580
|
const resolvedTarget = resolve7(dirname5(dstForContainment), link.target);
|
|
7561
7581
|
if (!isPathInsideRoot(targetRoot, resolvedTarget)) {
|
|
7562
7582
|
const message = `ONNX Runtime symlink ${link.name} points outside install dir: ${link.target}`;
|
|
@@ -7577,8 +7597,8 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
|
|
|
7577
7597
|
log(`ORT extract: failed to symlink optional ${link.name}: ${symlinkErr}`);
|
|
7578
7598
|
}
|
|
7579
7599
|
}
|
|
7580
|
-
const requiredPath =
|
|
7581
|
-
if (!
|
|
7600
|
+
const requiredPath = join11(targetDir, info.libName);
|
|
7601
|
+
if (!existsSync8(requiredPath)) {
|
|
7582
7602
|
rmSync3(targetDir, { recursive: true, force: true });
|
|
7583
7603
|
throw new Error(`Required ONNX Runtime library missing after install: ${requiredPath}`);
|
|
7584
7604
|
}
|
|
@@ -7604,13 +7624,13 @@ function writeOnnxInstalledMeta(installDir, version, sha256, archiveSha256) {
|
|
|
7604
7624
|
...sha256 ? { sha256 } : {},
|
|
7605
7625
|
archiveSha256
|
|
7606
7626
|
};
|
|
7607
|
-
writeFileSync3(
|
|
7627
|
+
writeFileSync3(join11(installDir, ONNX_INSTALLED_META_FILE), JSON.stringify(meta), "utf8");
|
|
7608
7628
|
} catch (err) {
|
|
7609
7629
|
log(`[onnx] failed to write installed-meta in ${installDir}: ${err}`);
|
|
7610
7630
|
}
|
|
7611
7631
|
}
|
|
7612
7632
|
function readOnnxInstalledMeta(installDir) {
|
|
7613
|
-
const path2 =
|
|
7633
|
+
const path2 = join11(installDir, ONNX_INSTALLED_META_FILE);
|
|
7614
7634
|
try {
|
|
7615
7635
|
if (!statSync6(path2).isFile())
|
|
7616
7636
|
return null;
|
|
@@ -7748,8 +7768,8 @@ function isProcessAlive2(pid) {
|
|
|
7748
7768
|
}
|
|
7749
7769
|
function cleanupOnnxRuntime(storageDir) {
|
|
7750
7770
|
try {
|
|
7751
|
-
const ortBase =
|
|
7752
|
-
if (
|
|
7771
|
+
const ortBase = join11(storageDir, "onnxruntime");
|
|
7772
|
+
if (existsSync8(ortBase)) {
|
|
7753
7773
|
rmSync3(ortBase, { recursive: true, force: true });
|
|
7754
7774
|
}
|
|
7755
7775
|
} catch {}
|
|
@@ -8054,7 +8074,7 @@ function editModesPresent(record) {
|
|
|
8054
8074
|
const hasSymbol = isNonEmptyString(record.symbol);
|
|
8055
8075
|
if (!hasSymbol) {
|
|
8056
8076
|
delete record.symbol;
|
|
8057
|
-
if (record.content
|
|
8077
|
+
if (isNullOrEmptyString(record.content))
|
|
8058
8078
|
delete record.content;
|
|
8059
8079
|
} else if (record.content === null) {
|
|
8060
8080
|
delete record.content;
|
|
@@ -8083,16 +8103,23 @@ function editModesPresent(record) {
|
|
|
8083
8103
|
function isNonEmptyString(value) {
|
|
8084
8104
|
return typeof value === "string" && value.length > 0;
|
|
8085
8105
|
}
|
|
8106
|
+
function isNullOrEmptyString(value) {
|
|
8107
|
+
return value === null || value === "";
|
|
8108
|
+
}
|
|
8086
8109
|
function isEditSentinelItem(item) {
|
|
8087
8110
|
if (!item || typeof item !== "object" || Array.isArray(item))
|
|
8088
8111
|
return false;
|
|
8089
8112
|
const record = item;
|
|
8090
|
-
|
|
8113
|
+
const oldStringEmpty = hasOwn(record, "oldString") && isNullOrEmptyString(record.oldString);
|
|
8114
|
+
if (!oldStringEmpty)
|
|
8091
8115
|
return false;
|
|
8092
|
-
|
|
8116
|
+
if (record.oldString === null && ["startLine", "endLine"].some((key) => hasOwn(record, key) && record[key] !== null)) {
|
|
8117
|
+
return false;
|
|
8118
|
+
}
|
|
8119
|
+
const newStringEmpty = !hasOwn(record, "newString") || isNullOrEmptyString(record.newString);
|
|
8093
8120
|
if (!newStringEmpty)
|
|
8094
8121
|
return false;
|
|
8095
|
-
return !hasOwn(record, "content") || record.content
|
|
8122
|
+
return !hasOwn(record, "content") || isNullOrEmptyString(record.content);
|
|
8096
8123
|
}
|
|
8097
8124
|
function normalizeEditArraySentinels(record) {
|
|
8098
8125
|
const value = record.edits;
|
|
@@ -8147,6 +8174,18 @@ function parseEditArray(value) {
|
|
|
8147
8174
|
}
|
|
8148
8175
|
function stripLineRangeSentinels(item) {
|
|
8149
8176
|
const hasRangeField = ["startLine", "endLine", "content"].some((key) => hasOwn(item, key));
|
|
8177
|
+
for (const key of [
|
|
8178
|
+
"oldString",
|
|
8179
|
+
"newString",
|
|
8180
|
+
"replaceAll",
|
|
8181
|
+
"occurrence",
|
|
8182
|
+
"startLine",
|
|
8183
|
+
"endLine",
|
|
8184
|
+
"content"
|
|
8185
|
+
]) {
|
|
8186
|
+
if (item[key] === null)
|
|
8187
|
+
delete item[key];
|
|
8188
|
+
}
|
|
8150
8189
|
if (!hasRangeField)
|
|
8151
8190
|
return;
|
|
8152
8191
|
if (item.oldString === "")
|
|
@@ -8925,17 +8964,17 @@ function formatReadFooter(agentSpecifiedRange, data, options) {
|
|
|
8925
8964
|
}
|
|
8926
8965
|
|
|
8927
8966
|
// ../aft-bridge/dist/transport-factory.js
|
|
8928
|
-
import { existsSync as
|
|
8967
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
8929
8968
|
import { homedir as homedir11 } from "node:os";
|
|
8930
|
-
import { isAbsolute as isAbsolute5, join as
|
|
8969
|
+
import { isAbsolute as isAbsolute5, join as join12 } from "node:path";
|
|
8931
8970
|
function resolveConnectionFilePath(raw) {
|
|
8932
8971
|
const trimmed = raw.trim();
|
|
8933
8972
|
if (trimmed.startsWith("~")) {
|
|
8934
|
-
return
|
|
8973
|
+
return join12(homedir11(), trimmed.slice(1).replace(/^[/\\]/, ""));
|
|
8935
8974
|
}
|
|
8936
8975
|
if (isAbsolute5(trimmed))
|
|
8937
8976
|
return trimmed;
|
|
8938
|
-
return
|
|
8977
|
+
return join12(homedir11(), trimmed);
|
|
8939
8978
|
}
|
|
8940
8979
|
function booleanOption(value) {
|
|
8941
8980
|
return typeof value === "boolean" ? value : undefined;
|
|
@@ -9008,7 +9047,7 @@ async function createConcreteAftTransportPool(opts) {
|
|
|
9008
9047
|
consumerIdentity: opts.subcConsumerIdentity,
|
|
9009
9048
|
onBgEventsNudge: opts.onBgEventsNudge,
|
|
9010
9049
|
onBgEventsNudgeRef: opts.onBgEventsNudgeRef,
|
|
9011
|
-
lifecycleDemandCheck: opts.subcLifecycleDemandCheck ?? ((root) =>
|
|
9050
|
+
lifecycleDemandCheck: opts.subcLifecycleDemandCheck ?? ((root) => existsSync9(root))
|
|
9012
9051
|
});
|
|
9013
9052
|
}
|
|
9014
9053
|
return new BridgePool(opts.binaryPath, opts.poolOptions, opts.configOverrides);
|
|
@@ -9273,7 +9312,7 @@ var init_dist2 = __esm(() => {
|
|
|
9273
9312
|
|
|
9274
9313
|
// src/lib/paths.ts
|
|
9275
9314
|
import { homedir as homedir12 } from "node:os";
|
|
9276
|
-
import { join as
|
|
9315
|
+
import { join as join13 } from "node:path";
|
|
9277
9316
|
function getAftBinaryName() {
|
|
9278
9317
|
return process.platform === "win32" ? "aft.exe" : "aft";
|
|
9279
9318
|
}
|
|
@@ -9286,14 +9325,14 @@ function dataHome3() {
|
|
|
9286
9325
|
if (process.env.XDG_DATA_HOME)
|
|
9287
9326
|
return process.env.XDG_DATA_HOME;
|
|
9288
9327
|
if (process.platform === "win32") {
|
|
9289
|
-
return process.env.LOCALAPPDATA || process.env.APPDATA ||
|
|
9328
|
+
return process.env.LOCALAPPDATA || process.env.APPDATA || join13(homeDir5(), "AppData", "Local");
|
|
9290
9329
|
}
|
|
9291
|
-
return
|
|
9330
|
+
return join13(homeDir5(), ".local", "share");
|
|
9292
9331
|
}
|
|
9293
9332
|
function getCortexKitStorageRoot() {
|
|
9294
9333
|
if (process.env.AFT_CACHE_DIR)
|
|
9295
|
-
return
|
|
9296
|
-
return
|
|
9334
|
+
return join13(process.env.AFT_CACHE_DIR, "aft");
|
|
9335
|
+
return join13(dataHome3(), "cortexkit", "aft");
|
|
9297
9336
|
}
|
|
9298
9337
|
var init_paths2 = __esm(() => {
|
|
9299
9338
|
init_dist2();
|
|
@@ -9301,10 +9340,10 @@ var init_paths2 = __esm(() => {
|
|
|
9301
9340
|
|
|
9302
9341
|
// src/lib/binary-probe.ts
|
|
9303
9342
|
import { execSync as execSync2, spawnSync as spawnSync3 } from "node:child_process";
|
|
9304
|
-
import { existsSync as
|
|
9343
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
9305
9344
|
import { createRequire as createRequire2 } from "node:module";
|
|
9306
9345
|
import { homedir as homedir13 } from "node:os";
|
|
9307
|
-
import { join as
|
|
9346
|
+
import { join as join14 } from "node:path";
|
|
9308
9347
|
async function loadPluginVersion() {
|
|
9309
9348
|
try {
|
|
9310
9349
|
const bridge = await Promise.resolve().then(() => (init_dist2(), exports_dist));
|
|
@@ -9356,7 +9395,7 @@ function probeAftBinary(preferredVersion) {
|
|
|
9356
9395
|
const candidates = [];
|
|
9357
9396
|
for (const candidate of aftBinaryCandidates(preferredVersion)) {
|
|
9358
9397
|
try {
|
|
9359
|
-
if (!
|
|
9398
|
+
if (!existsSync10(candidate))
|
|
9360
9399
|
continue;
|
|
9361
9400
|
const result = spawnSync3(candidate, ["--version"], {
|
|
9362
9401
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -9407,7 +9446,7 @@ function pushCandidate(candidates, candidate) {
|
|
|
9407
9446
|
function firstExisting(candidates) {
|
|
9408
9447
|
for (const candidate of candidates) {
|
|
9409
9448
|
try {
|
|
9410
|
-
if (!
|
|
9449
|
+
if (!existsSync10(candidate))
|
|
9411
9450
|
continue;
|
|
9412
9451
|
return candidate;
|
|
9413
9452
|
} catch {}
|
|
@@ -9426,7 +9465,7 @@ function aftBinaryCandidates(preferredVersion) {
|
|
|
9426
9465
|
const candidates = [];
|
|
9427
9466
|
if (preferredVersion) {
|
|
9428
9467
|
const tag = preferredVersion.startsWith("v") ? preferredVersion : `v${preferredVersion}`;
|
|
9429
|
-
pushCandidate(candidates,
|
|
9468
|
+
pushCandidate(candidates, join14(getAftBinaryCacheDir(), tag, getAftBinaryName()));
|
|
9430
9469
|
}
|
|
9431
9470
|
const key = platformKey2();
|
|
9432
9471
|
if (key) {
|
|
@@ -9449,7 +9488,7 @@ function aftBinaryCandidates(preferredVersion) {
|
|
|
9449
9488
|
}
|
|
9450
9489
|
}
|
|
9451
9490
|
} catch {}
|
|
9452
|
-
pushCandidate(candidates,
|
|
9491
|
+
pushCandidate(candidates, join14(homedir13(), ".cargo", "bin", getAftBinaryName()));
|
|
9453
9492
|
return candidates;
|
|
9454
9493
|
}
|
|
9455
9494
|
function findAftBinary(preferredVersion) {
|
|
@@ -9464,10 +9503,10 @@ var init_binary_probe = __esm(async () => {
|
|
|
9464
9503
|
});
|
|
9465
9504
|
|
|
9466
9505
|
// src/lib/fs-util.ts
|
|
9467
|
-
import { existsSync as
|
|
9468
|
-
import { join as
|
|
9506
|
+
import { existsSync as existsSync11, readdirSync as readdirSync4, statSync as statSync7 } from "node:fs";
|
|
9507
|
+
import { join as join15 } from "node:path";
|
|
9469
9508
|
function dirSize(path2) {
|
|
9470
|
-
if (!
|
|
9509
|
+
if (!existsSync11(path2)) {
|
|
9471
9510
|
return 0;
|
|
9472
9511
|
}
|
|
9473
9512
|
const stat2 = statSync7(path2);
|
|
@@ -9479,7 +9518,7 @@ function dirSize(path2) {
|
|
|
9479
9518
|
}
|
|
9480
9519
|
let total = 0;
|
|
9481
9520
|
for (const entry of readdirSync4(path2)) {
|
|
9482
|
-
total += dirSize(
|
|
9521
|
+
total += dirSize(join15(path2, entry));
|
|
9483
9522
|
}
|
|
9484
9523
|
return total;
|
|
9485
9524
|
}
|
|
@@ -17087,9 +17126,9 @@ var require_stringify = __commonJS(function(exports, module) {
|
|
|
17087
17126
|
if (line_breaks_before === null) {
|
|
17088
17127
|
line_breaks_before = inline ? 0 : 1;
|
|
17089
17128
|
}
|
|
17090
|
-
const
|
|
17129
|
+
const delimiter3 = line_breaks_before > 0 ? repeat_line_breaks(line_breaks_before, deeper_gap) : inline ? SPACE : i === 0 ? EMPTY : LF + deeper_gap;
|
|
17091
17130
|
const is_line_comment = type === "LineComment";
|
|
17092
|
-
str +=
|
|
17131
|
+
str += delimiter3 + comment_stringify(value, is_line_comment);
|
|
17093
17132
|
last_comment = comment;
|
|
17094
17133
|
});
|
|
17095
17134
|
const default_line_breaks_after = display_block || last_comment.type === "LineComment" ? 1 : 0;
|
|
@@ -17102,10 +17141,10 @@ var require_stringify = __commonJS(function(exports, module) {
|
|
|
17102
17141
|
replacer = null;
|
|
17103
17142
|
indent = EMPTY;
|
|
17104
17143
|
};
|
|
17105
|
-
var
|
|
17144
|
+
var join16 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(one, gap)), gap) : two ? two.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(two, gap)), gap) : EMPTY;
|
|
17106
17145
|
var join_content = (inside, value, gap) => {
|
|
17107
17146
|
const comment = process_comments(value, PREFIX_BEFORE, gap + indent, true);
|
|
17108
|
-
return
|
|
17147
|
+
return join16(comment, inside, gap);
|
|
17109
17148
|
};
|
|
17110
17149
|
var stringify_string = (holder, key, value) => {
|
|
17111
17150
|
const raw = get_raw_string_literal(holder, key);
|
|
@@ -17127,13 +17166,13 @@ var require_stringify = __commonJS(function(exports, module) {
|
|
|
17127
17166
|
if (i !== 0) {
|
|
17128
17167
|
inside += COMMA;
|
|
17129
17168
|
}
|
|
17130
|
-
const before =
|
|
17169
|
+
const before = join16(after_comma, process_comments(value, BEFORE(i), deeper_gap), deeper_gap);
|
|
17131
17170
|
inside += before || LF + deeper_gap;
|
|
17132
17171
|
inside += stringify(i, value, deeper_gap) || STR_NULL;
|
|
17133
17172
|
inside += process_comments(value, AFTER_VALUE(i), deeper_gap);
|
|
17134
17173
|
after_comma = process_comments(value, AFTER(i), deeper_gap);
|
|
17135
17174
|
}
|
|
17136
|
-
inside +=
|
|
17175
|
+
inside += join16(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
|
|
17137
17176
|
return BRACKET_OPEN + join_content(inside, value, gap) + BRACKET_CLOSE;
|
|
17138
17177
|
};
|
|
17139
17178
|
var object_stringify = (value, gap) => {
|
|
@@ -17154,13 +17193,13 @@ var require_stringify = __commonJS(function(exports, module) {
|
|
|
17154
17193
|
inside += COMMA;
|
|
17155
17194
|
}
|
|
17156
17195
|
first = false;
|
|
17157
|
-
const before =
|
|
17196
|
+
const before = join16(after_comma, process_comments(value, BEFORE(key), deeper_gap), deeper_gap);
|
|
17158
17197
|
inside += before || LF + deeper_gap;
|
|
17159
17198
|
inside += quote(key) + process_comments(value, AFTER_PROP(key), deeper_gap) + COLON + process_comments(value, AFTER_COLON(key), deeper_gap) + SPACE + sv + process_comments(value, AFTER_VALUE(key), deeper_gap);
|
|
17160
17199
|
after_comma = process_comments(value, AFTER(key), deeper_gap);
|
|
17161
17200
|
};
|
|
17162
17201
|
keys.forEach(iteratee);
|
|
17163
|
-
inside +=
|
|
17202
|
+
inside += join16(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
|
|
17164
17203
|
return CURLY_BRACKET_OPEN + join_content(inside, value, gap) + CURLY_BRACKET_CLOSE;
|
|
17165
17204
|
};
|
|
17166
17205
|
function stringify(key, holder, gap) {
|
|
@@ -17253,21 +17292,21 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
17253
17292
|
});
|
|
17254
17293
|
|
|
17255
17294
|
// src/lib/jsonc.ts
|
|
17256
|
-
import { existsSync as
|
|
17295
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync4 } from "node:fs";
|
|
17257
17296
|
import { dirname as dirname6 } from "node:path";
|
|
17258
17297
|
function detectJsoncFile(configDir, baseName) {
|
|
17259
17298
|
const jsoncPath = `${configDir}/${baseName}.jsonc`;
|
|
17260
17299
|
const jsonPath = `${configDir}/${baseName}.json`;
|
|
17261
|
-
if (
|
|
17300
|
+
if (existsSync12(jsoncPath)) {
|
|
17262
17301
|
return { path: jsoncPath, format: "jsonc" };
|
|
17263
17302
|
}
|
|
17264
|
-
if (
|
|
17303
|
+
if (existsSync12(jsonPath)) {
|
|
17265
17304
|
return { path: jsonPath, format: "json" };
|
|
17266
17305
|
}
|
|
17267
17306
|
return { path: jsonPath, format: "none" };
|
|
17268
17307
|
}
|
|
17269
17308
|
function readJsoncFile(path2) {
|
|
17270
|
-
if (!
|
|
17309
|
+
if (!existsSync12(path2)) {
|
|
17271
17310
|
return { value: null };
|
|
17272
17311
|
}
|
|
17273
17312
|
try {
|
|
@@ -17288,7 +17327,7 @@ function writeJsoncFile(path2, value, format = "json") {
|
|
|
17288
17327
|
`);
|
|
17289
17328
|
}
|
|
17290
17329
|
function ensureAftSchemaUrl(path2, format) {
|
|
17291
|
-
const existed =
|
|
17330
|
+
const existed = existsSync12(path2);
|
|
17292
17331
|
if (!existed) {
|
|
17293
17332
|
const writeFormat = format === "jsonc" ? "jsonc" : "json";
|
|
17294
17333
|
writeJsoncFile(path2, { $schema: AFT_SCHEMA_URL }, writeFormat);
|
|
@@ -17341,26 +17380,26 @@ var init_self_version = () => {};
|
|
|
17341
17380
|
|
|
17342
17381
|
// src/adapters/opencode.ts
|
|
17343
17382
|
import { execSync as execSync3 } from "node:child_process";
|
|
17344
|
-
import { existsSync as
|
|
17383
|
+
import { existsSync as existsSync13, readFileSync as readFileSync8, rmSync as rmSync4, statSync as statSync8 } from "node:fs";
|
|
17345
17384
|
import { homedir as homedir14 } from "node:os";
|
|
17346
|
-
import { dirname as dirname7, join as
|
|
17385
|
+
import { dirname as dirname7, join as join16, parse, resolve as resolve8 } from "node:path";
|
|
17347
17386
|
import { fileURLToPath } from "node:url";
|
|
17348
17387
|
function getOpenCodeConfigDir() {
|
|
17349
17388
|
const envDir = process.env.OPENCODE_CONFIG_DIR?.trim();
|
|
17350
17389
|
if (envDir)
|
|
17351
17390
|
return resolve8(envDir);
|
|
17352
|
-
const xdg = process.env.XDG_CONFIG_HOME ||
|
|
17353
|
-
return
|
|
17391
|
+
const xdg = process.env.XDG_CONFIG_HOME || join16(homedir14(), ".config");
|
|
17392
|
+
return join16(xdg, "opencode");
|
|
17354
17393
|
}
|
|
17355
17394
|
function getOpenCodeCacheDir() {
|
|
17356
17395
|
const xdg = process.env.XDG_CACHE_HOME;
|
|
17357
17396
|
if (xdg)
|
|
17358
|
-
return
|
|
17397
|
+
return join16(xdg, "opencode");
|
|
17359
17398
|
if (process.platform === "win32") {
|
|
17360
|
-
const localAppData = process.env.LOCALAPPDATA ??
|
|
17361
|
-
return
|
|
17399
|
+
const localAppData = process.env.LOCALAPPDATA ?? join16(homedir14(), "AppData", "Local");
|
|
17400
|
+
return join16(localAppData, "opencode");
|
|
17362
17401
|
}
|
|
17363
|
-
return
|
|
17402
|
+
return join16(homedir14(), ".cache", "opencode");
|
|
17364
17403
|
}
|
|
17365
17404
|
function hasOpenCodeCli() {
|
|
17366
17405
|
try {
|
|
@@ -17373,16 +17412,16 @@ function hasOpenCodeCli() {
|
|
|
17373
17412
|
function openCodeDesktopAppExists() {
|
|
17374
17413
|
const candidates = [];
|
|
17375
17414
|
if (process.platform === "darwin") {
|
|
17376
|
-
candidates.push("/Applications/OpenCode.app", "/Applications/OpenCode Beta.app",
|
|
17415
|
+
candidates.push("/Applications/OpenCode.app", "/Applications/OpenCode Beta.app", join16(homedir14(), "Applications", "OpenCode.app"), join16(homedir14(), "Applications", "OpenCode Beta.app"));
|
|
17377
17416
|
} else if (process.platform === "win32") {
|
|
17378
|
-
const localAppData = process.env.LOCALAPPDATA ??
|
|
17379
|
-
candidates.push(
|
|
17417
|
+
const localAppData = process.env.LOCALAPPDATA ?? join16(homedir14(), "AppData", "Local");
|
|
17418
|
+
candidates.push(join16(localAppData, "Programs", "opencode"), join16(localAppData, "opencode"));
|
|
17380
17419
|
} else {
|
|
17381
|
-
candidates.push("/opt/OpenCode", "/usr/lib/opencode",
|
|
17420
|
+
candidates.push("/opt/OpenCode", "/usr/lib/opencode", join16(homedir14(), ".local", "share", "applications", "opencode.desktop"));
|
|
17382
17421
|
}
|
|
17383
17422
|
return candidates.some((p) => {
|
|
17384
17423
|
try {
|
|
17385
|
-
return
|
|
17424
|
+
return existsSync13(p);
|
|
17386
17425
|
} catch {
|
|
17387
17426
|
return false;
|
|
17388
17427
|
}
|
|
@@ -17405,13 +17444,13 @@ function pathPointsToOurPlugin(entry) {
|
|
|
17405
17444
|
if (!fsPath)
|
|
17406
17445
|
return false;
|
|
17407
17446
|
try {
|
|
17408
|
-
if (!
|
|
17447
|
+
if (!existsSync13(fsPath))
|
|
17409
17448
|
return false;
|
|
17410
17449
|
let searchDir = statSync8(fsPath).isDirectory() ? fsPath : dirname7(fsPath);
|
|
17411
17450
|
let pkgJsonPath = null;
|
|
17412
17451
|
while (true) {
|
|
17413
|
-
const candidate =
|
|
17414
|
-
if (
|
|
17452
|
+
const candidate = join16(searchDir, "package.json");
|
|
17453
|
+
if (existsSync13(candidate)) {
|
|
17415
17454
|
pkgJsonPath = candidate;
|
|
17416
17455
|
break;
|
|
17417
17456
|
}
|
|
@@ -17442,7 +17481,7 @@ class OpenCodeAdapter {
|
|
|
17442
17481
|
pluginPackageName = PLUGIN_NAME;
|
|
17443
17482
|
pluginEntryWithVersion = PLUGIN_ENTRY;
|
|
17444
17483
|
isInstalled() {
|
|
17445
|
-
if (
|
|
17484
|
+
if (existsSync13(getOpenCodeConfigDir()))
|
|
17446
17485
|
return true;
|
|
17447
17486
|
if (openCodeDesktopAppExists())
|
|
17448
17487
|
return true;
|
|
@@ -17463,7 +17502,7 @@ class OpenCodeAdapter {
|
|
|
17463
17502
|
const configDir = getOpenCodeConfigDir();
|
|
17464
17503
|
const harness = detectJsoncFile(configDir, "opencode");
|
|
17465
17504
|
const aftConfigPath = resolveCortexKitUserConfigPath();
|
|
17466
|
-
const aftConfigExists =
|
|
17505
|
+
const aftConfigExists = existsSync13(aftConfigPath);
|
|
17467
17506
|
const tui = detectJsoncFile(configDir, "tui");
|
|
17468
17507
|
return {
|
|
17469
17508
|
configDir,
|
|
@@ -17581,11 +17620,11 @@ class OpenCodeAdapter {
|
|
|
17581
17620
|
};
|
|
17582
17621
|
}
|
|
17583
17622
|
getPluginCacheInfo() {
|
|
17584
|
-
const path2 =
|
|
17623
|
+
const path2 = join16(getOpenCodeCacheDir(), "packages", PLUGIN_ENTRY);
|
|
17585
17624
|
let cached;
|
|
17586
17625
|
try {
|
|
17587
|
-
const installedPkgPath =
|
|
17588
|
-
if (
|
|
17626
|
+
const installedPkgPath = join16(path2, "node_modules", "@cortexkit", "aft-opencode", "package.json");
|
|
17627
|
+
if (existsSync13(installedPkgPath)) {
|
|
17589
17628
|
const pkg = JSON.parse(readFileSync8(installedPkgPath, "utf-8"));
|
|
17590
17629
|
cached = typeof pkg.version === "string" ? pkg.version : undefined;
|
|
17591
17630
|
}
|
|
@@ -17596,7 +17635,7 @@ class OpenCodeAdapter {
|
|
|
17596
17635
|
path: path2,
|
|
17597
17636
|
cached,
|
|
17598
17637
|
latest: getSelfVersion(),
|
|
17599
|
-
exists:
|
|
17638
|
+
exists: existsSync13(path2)
|
|
17600
17639
|
};
|
|
17601
17640
|
}
|
|
17602
17641
|
getStorageDir() {
|
|
@@ -17645,12 +17684,12 @@ class OpenCodeAdapter {
|
|
|
17645
17684
|
describeStorageSubtrees() {
|
|
17646
17685
|
const storage = this.getStorageDir();
|
|
17647
17686
|
return {
|
|
17648
|
-
index: dirSize(
|
|
17649
|
-
semantic: dirSize(
|
|
17650
|
-
backups: dirSize(
|
|
17651
|
-
url_cache: dirSize(
|
|
17652
|
-
onnxruntime: dirSize(
|
|
17653
|
-
logs: dirSize(
|
|
17687
|
+
index: dirSize(join16(storage, "index")),
|
|
17688
|
+
semantic: dirSize(join16(storage, "semantic")),
|
|
17689
|
+
backups: dirSize(join16(storage, "backups")),
|
|
17690
|
+
url_cache: dirSize(join16(storage, "url_cache")),
|
|
17691
|
+
onnxruntime: dirSize(join16(storage, "onnxruntime")),
|
|
17692
|
+
logs: dirSize(join16(storage, "logs"))
|
|
17654
17693
|
};
|
|
17655
17694
|
}
|
|
17656
17695
|
}
|
|
@@ -17666,20 +17705,20 @@ var init_opencode = __esm(() => {
|
|
|
17666
17705
|
|
|
17667
17706
|
// src/adapters/pi.ts
|
|
17668
17707
|
import { execSync as execSync4, spawnSync as spawnSync4 } from "node:child_process";
|
|
17669
|
-
import { existsSync as
|
|
17708
|
+
import { existsSync as existsSync14, readFileSync as readFileSync9 } from "node:fs";
|
|
17670
17709
|
import { homedir as homedir15 } from "node:os";
|
|
17671
|
-
import { join as
|
|
17710
|
+
import { join as join17, resolve as resolve9 } from "node:path";
|
|
17672
17711
|
function getPiAgentDir() {
|
|
17673
17712
|
const configuredDir = process.env.PI_CODING_AGENT_DIR?.trim();
|
|
17674
17713
|
if (configuredDir)
|
|
17675
17714
|
return resolve9(configuredDir);
|
|
17676
17715
|
const envHome = process.platform === "win32" ? process.env.USERPROFILE : process.env.HOME;
|
|
17677
17716
|
const home = envHome && envHome.length > 0 ? envHome : homedir15();
|
|
17678
|
-
return
|
|
17717
|
+
return join17(home, ".pi", "agent");
|
|
17679
17718
|
}
|
|
17680
17719
|
function readPiExtensionIndex() {
|
|
17681
|
-
const settingsPath =
|
|
17682
|
-
if (
|
|
17720
|
+
const settingsPath = join17(getPiAgentDir(), "settings.json");
|
|
17721
|
+
if (existsSync14(settingsPath)) {
|
|
17683
17722
|
try {
|
|
17684
17723
|
const raw = readFileSync9(settingsPath, "utf-8");
|
|
17685
17724
|
const trimmed = raw.replace(/^\uFEFF/, "");
|
|
@@ -17699,13 +17738,13 @@ function readPiExtensionIndex() {
|
|
|
17699
17738
|
} catch {}
|
|
17700
17739
|
}
|
|
17701
17740
|
const candidates = [
|
|
17702
|
-
|
|
17703
|
-
|
|
17704
|
-
|
|
17705
|
-
|
|
17741
|
+
join17(getPiAgentDir(), "extensions.json"),
|
|
17742
|
+
join17(getPiAgentDir(), "extensions.jsonc"),
|
|
17743
|
+
join17(getPiAgentDir(), "config.json"),
|
|
17744
|
+
join17(getPiAgentDir(), "config.jsonc")
|
|
17706
17745
|
];
|
|
17707
17746
|
for (const path2 of candidates) {
|
|
17708
|
-
if (!
|
|
17747
|
+
if (!existsSync14(path2))
|
|
17709
17748
|
continue;
|
|
17710
17749
|
try {
|
|
17711
17750
|
const { value } = readJsoncFile(path2);
|
|
@@ -17738,15 +17777,15 @@ function piEntryMatchesAft(entry) {
|
|
|
17738
17777
|
} else if (entry.startsWith("/")) {
|
|
17739
17778
|
resolved = entry;
|
|
17740
17779
|
} else if (entry.length > 0) {
|
|
17741
|
-
resolved =
|
|
17780
|
+
resolved = join17(getPiAgentDir(), entry);
|
|
17742
17781
|
}
|
|
17743
17782
|
if (!resolved)
|
|
17744
17783
|
return false;
|
|
17745
17784
|
try {
|
|
17746
|
-
if (!
|
|
17785
|
+
if (!existsSync14(resolved))
|
|
17747
17786
|
return false;
|
|
17748
|
-
const pkgPath =
|
|
17749
|
-
if (!
|
|
17787
|
+
const pkgPath = join17(resolved, "package.json");
|
|
17788
|
+
if (!existsSync14(pkgPath))
|
|
17750
17789
|
return false;
|
|
17751
17790
|
const pkg = JSON.parse(readFileSync9(pkgPath, "utf-8"));
|
|
17752
17791
|
return pkg.name === PLUGIN_NAME2;
|
|
@@ -17794,10 +17833,10 @@ class PiAdapter {
|
|
|
17794
17833
|
const configDir = getPiAgentDir();
|
|
17795
17834
|
const index = readPiExtensionIndex();
|
|
17796
17835
|
const aftConfigPath = resolveCortexKitUserConfigPath();
|
|
17797
|
-
const aftConfigExists =
|
|
17836
|
+
const aftConfigExists = existsSync14(aftConfigPath);
|
|
17798
17837
|
return {
|
|
17799
17838
|
configDir,
|
|
17800
|
-
harnessConfig: index.path ??
|
|
17839
|
+
harnessConfig: index.path ?? join17(configDir, "extensions.json"),
|
|
17801
17840
|
harnessConfigFormat: index.path ? "json" : "none",
|
|
17802
17841
|
aftConfig: aftConfigPath,
|
|
17803
17842
|
aftConfigFormat: aftConfigExists ? "jsonc" : "none"
|
|
@@ -17842,12 +17881,12 @@ class PiAdapter {
|
|
|
17842
17881
|
}
|
|
17843
17882
|
getPluginCacheInfo() {
|
|
17844
17883
|
const candidates = [
|
|
17845
|
-
|
|
17846
|
-
|
|
17847
|
-
|
|
17884
|
+
join17(getPiAgentDir(), "npm", "node_modules", "@cortexkit", "aft-pi", "package.json"),
|
|
17885
|
+
join17(getPiAgentDir(), "node_modules", "@cortexkit", "aft-pi", "package.json"),
|
|
17886
|
+
join17(getPiAgentDir(), "extensions", "node_modules", "@cortexkit", "aft-pi", "package.json")
|
|
17848
17887
|
];
|
|
17849
17888
|
for (const candidate of candidates) {
|
|
17850
|
-
if (!
|
|
17889
|
+
if (!existsSync14(candidate))
|
|
17851
17890
|
continue;
|
|
17852
17891
|
try {
|
|
17853
17892
|
const pkg = JSON.parse(readFileSync9(candidate, "utf-8"));
|
|
@@ -17861,7 +17900,7 @@ class PiAdapter {
|
|
|
17861
17900
|
} catch {}
|
|
17862
17901
|
}
|
|
17863
17902
|
return {
|
|
17864
|
-
path:
|
|
17903
|
+
path: join17(getPiAgentDir(), "npm", "node_modules", "@cortexkit", "aft-pi", "package.json"),
|
|
17865
17904
|
exists: false
|
|
17866
17905
|
};
|
|
17867
17906
|
}
|
|
@@ -17883,12 +17922,12 @@ class PiAdapter {
|
|
|
17883
17922
|
describeStorageSubtrees() {
|
|
17884
17923
|
const storage = this.getStorageDir();
|
|
17885
17924
|
return {
|
|
17886
|
-
index: dirSize(
|
|
17887
|
-
semantic: dirSize(
|
|
17888
|
-
backups: dirSize(
|
|
17889
|
-
url_cache: dirSize(
|
|
17890
|
-
onnxruntime: dirSize(
|
|
17891
|
-
logs: dirSize(
|
|
17925
|
+
index: dirSize(join17(storage, "index")),
|
|
17926
|
+
semantic: dirSize(join17(storage, "semantic")),
|
|
17927
|
+
backups: dirSize(join17(storage, "backups")),
|
|
17928
|
+
url_cache: dirSize(join17(storage, "url_cache")),
|
|
17929
|
+
onnxruntime: dirSize(join17(storage, "onnxruntime")),
|
|
17930
|
+
logs: dirSize(join17(storage, "logs"))
|
|
17892
17931
|
};
|
|
17893
17932
|
}
|
|
17894
17933
|
}
|
|
@@ -19501,21 +19540,21 @@ __export(exports_lsp, {
|
|
|
19501
19540
|
runLspDoctor: () => runLspDoctor,
|
|
19502
19541
|
typescriptPackageWarning: () => typescriptPackageWarning
|
|
19503
19542
|
});
|
|
19504
|
-
import { existsSync as
|
|
19543
|
+
import { existsSync as existsSync15, readdirSync as readdirSync5, statSync as statSync9 } from "node:fs";
|
|
19505
19544
|
import { createRequire as createRequire4 } from "node:module";
|
|
19506
|
-
import { dirname as dirname8, join as
|
|
19545
|
+
import { dirname as dirname8, join as join18, resolve as resolve10 } from "node:path";
|
|
19507
19546
|
function findProjectRootForFile(filePath, fallbackCwd = process.cwd()) {
|
|
19508
19547
|
const resolvedFile = resolve10(fallbackCwd, filePath);
|
|
19509
19548
|
let dir = dirname8(resolvedFile);
|
|
19510
19549
|
try {
|
|
19511
|
-
if (
|
|
19550
|
+
if (existsSync15(resolvedFile) && statSync9(resolvedFile).isDirectory()) {
|
|
19512
19551
|
dir = resolvedFile;
|
|
19513
19552
|
}
|
|
19514
19553
|
} catch {
|
|
19515
19554
|
dir = dirname8(resolvedFile);
|
|
19516
19555
|
}
|
|
19517
19556
|
while (true) {
|
|
19518
|
-
if (PROJECT_ROOT_MARKERS.some((marker) =>
|
|
19557
|
+
if (PROJECT_ROOT_MARKERS.some((marker) => existsSync15(join18(dir, marker)))) {
|
|
19519
19558
|
return dir;
|
|
19520
19559
|
}
|
|
19521
19560
|
const parent = dirname8(dir);
|
|
@@ -19652,9 +19691,9 @@ function parseFileArg(argv) {
|
|
|
19652
19691
|
function buildConfigureParams(adapter, projectRoot) {
|
|
19653
19692
|
const userConfigPath = adapter.detectConfigPaths().aftConfig;
|
|
19654
19693
|
const dir = adapter.kind === "pi" ? ".pi" : ".opencode";
|
|
19655
|
-
const projectJsonc =
|
|
19656
|
-
const projectJson =
|
|
19657
|
-
const projectConfigPath =
|
|
19694
|
+
const projectJsonc = join18(projectRoot, dir, "aft.jsonc");
|
|
19695
|
+
const projectJson = join18(projectRoot, dir, "aft.json");
|
|
19696
|
+
const projectConfigPath = existsSync15(projectJsonc) ? projectJsonc : projectJson;
|
|
19658
19697
|
return {
|
|
19659
19698
|
id: "doctor-lsp-configure",
|
|
19660
19699
|
command: "configure",
|
|
@@ -19667,18 +19706,18 @@ function buildConfigureParams(adapter, projectRoot) {
|
|
|
19667
19706
|
function inferLspPathsExtra(_lsp) {
|
|
19668
19707
|
const paths = new Set;
|
|
19669
19708
|
for (const entry of childDirs(getAftLspPackagesDir())) {
|
|
19670
|
-
paths.add(
|
|
19709
|
+
paths.add(join18(entry, "node_modules", ".bin"));
|
|
19671
19710
|
}
|
|
19672
19711
|
for (const entry of childDirs(getAftLspBinariesDir())) {
|
|
19673
|
-
paths.add(
|
|
19712
|
+
paths.add(join18(entry, "bin"));
|
|
19674
19713
|
}
|
|
19675
19714
|
return [...paths];
|
|
19676
19715
|
}
|
|
19677
19716
|
function childDirs(path2) {
|
|
19678
|
-
if (!
|
|
19717
|
+
if (!existsSync15(path2))
|
|
19679
19718
|
return [];
|
|
19680
19719
|
try {
|
|
19681
|
-
return readdirSync5(path2).map((entry) =>
|
|
19720
|
+
return readdirSync5(path2).map((entry) => join18(path2, entry)).filter((entry) => {
|
|
19682
19721
|
try {
|
|
19683
19722
|
return statSync9(entry).isDirectory();
|
|
19684
19723
|
} catch {
|
|
@@ -19720,7 +19759,7 @@ function typescriptPackageWarning(response) {
|
|
|
19720
19759
|
if (!typescriptServerSpawned || !response.project_root || diagnosticsCount > 0)
|
|
19721
19760
|
return null;
|
|
19722
19761
|
try {
|
|
19723
|
-
createRequire4(
|
|
19762
|
+
createRequire4(join18(response.project_root, "package.json")).resolve("typescript");
|
|
19724
19763
|
return null;
|
|
19725
19764
|
} catch {
|
|
19726
19765
|
return "typescript package not resolvable from project — server will produce no diagnostics";
|
|
@@ -19768,7 +19807,7 @@ __export(exports_doctor_filters, {
|
|
|
19768
19807
|
renderTrustedProjects: () => renderTrustedProjects,
|
|
19769
19808
|
runDoctorFilters: () => runDoctorFilters
|
|
19770
19809
|
});
|
|
19771
|
-
import { existsSync as
|
|
19810
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
19772
19811
|
import { homedir as homedir16 } from "node:os";
|
|
19773
19812
|
import { relative as relative3, resolve as resolve11 } from "node:path";
|
|
19774
19813
|
function printDoctorFiltersHelp() {
|
|
@@ -19811,7 +19850,7 @@ async function runDoctorFilters(options) {
|
|
|
19811
19850
|
log2.error(list.message ?? list.code ?? "list_filters failed");
|
|
19812
19851
|
return 1;
|
|
19813
19852
|
}
|
|
19814
|
-
list.project_dir_exists = list.project_dir ?
|
|
19853
|
+
list.project_dir_exists = list.project_dir ? existsSync16(list.project_dir) : false;
|
|
19815
19854
|
if (mode.kind === "list") {
|
|
19816
19855
|
console.log(renderFilterList(list, projectRoot));
|
|
19817
19856
|
return 0;
|
|
@@ -20010,11 +20049,11 @@ var init_doctor_filters = __esm(async () => {
|
|
|
20010
20049
|
});
|
|
20011
20050
|
|
|
20012
20051
|
// src/lib/binary-cache.ts
|
|
20013
|
-
import { existsSync as
|
|
20014
|
-
import { join as
|
|
20052
|
+
import { existsSync as existsSync17, readdirSync as readdirSync6, statSync as statSync10 } from "node:fs";
|
|
20053
|
+
import { join as join19 } from "node:path";
|
|
20015
20054
|
function getBinaryCacheInfo(activeVersion) {
|
|
20016
20055
|
const path2 = getAftBinaryCacheDir();
|
|
20017
|
-
if (!
|
|
20056
|
+
if (!existsSync17(path2)) {
|
|
20018
20057
|
return {
|
|
20019
20058
|
versions: [],
|
|
20020
20059
|
activeVersion: null,
|
|
@@ -20024,7 +20063,7 @@ function getBinaryCacheInfo(activeVersion) {
|
|
|
20024
20063
|
}
|
|
20025
20064
|
const versions = readdirSync6(path2).filter((entry) => {
|
|
20026
20065
|
try {
|
|
20027
|
-
return statSync10(
|
|
20066
|
+
return statSync10(join19(path2, entry)).isDirectory();
|
|
20028
20067
|
} catch {
|
|
20029
20068
|
return false;
|
|
20030
20069
|
}
|
|
@@ -20122,13 +20161,13 @@ var init_sanitize = __esm(() => {
|
|
|
20122
20161
|
});
|
|
20123
20162
|
|
|
20124
20163
|
// src/lib/bridge-tool-failures.ts
|
|
20125
|
-
import { closeSync as closeSync5, existsSync as
|
|
20164
|
+
import { closeSync as closeSync5, existsSync as existsSync18, openSync as openSync5, readSync as readSync2, statSync as statSync11 } from "node:fs";
|
|
20126
20165
|
function resolveBridgePluginLogPath() {
|
|
20127
20166
|
const isTestEnv = process.env.BUN_TEST === "1" || false;
|
|
20128
20167
|
return resolveAftLogPath(isTestEnv ? "aft-plugin-test.log" : "aft-plugin.log");
|
|
20129
20168
|
}
|
|
20130
20169
|
function tailLogFileBytes(path2, maxBytes) {
|
|
20131
|
-
if (!
|
|
20170
|
+
if (!existsSync18(path2) || maxBytes <= 0)
|
|
20132
20171
|
return "";
|
|
20133
20172
|
let fd = null;
|
|
20134
20173
|
try {
|
|
@@ -20264,15 +20303,15 @@ var init_bridge_tool_failures = __esm(() => {
|
|
|
20264
20303
|
});
|
|
20265
20304
|
|
|
20266
20305
|
// src/lib/build-breaker.ts
|
|
20267
|
-
import { existsSync as
|
|
20268
|
-
import { join as
|
|
20306
|
+
import { existsSync as existsSync19, readdirSync as readdirSync7 } from "node:fs";
|
|
20307
|
+
import { join as join20 } from "node:path";
|
|
20269
20308
|
import { DatabaseSync } from "node:sqlite";
|
|
20270
20309
|
function buildBreakerDatabases(storageRoot) {
|
|
20271
|
-
const callgraphRoot =
|
|
20272
|
-
if (!
|
|
20310
|
+
const callgraphRoot = join20(storageRoot, "callgraph");
|
|
20311
|
+
if (!existsSync19(callgraphRoot))
|
|
20273
20312
|
return [];
|
|
20274
20313
|
try {
|
|
20275
|
-
return readdirSync7(callgraphRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) =>
|
|
20314
|
+
return readdirSync7(callgraphRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join20(callgraphRoot, entry.name, "build-breaker.sqlite")).filter((path2) => existsSync19(path2));
|
|
20276
20315
|
} catch {
|
|
20277
20316
|
return [];
|
|
20278
20317
|
}
|
|
@@ -20348,20 +20387,20 @@ var init_build_breaker = __esm(() => {
|
|
|
20348
20387
|
});
|
|
20349
20388
|
|
|
20350
20389
|
// src/lib/legacy-storage.ts
|
|
20351
|
-
import { existsSync as
|
|
20352
|
-
import { join as
|
|
20390
|
+
import { existsSync as existsSync20, readdirSync as readdirSync8, statSync as statSync12 } from "node:fs";
|
|
20391
|
+
import { join as join21 } from "node:path";
|
|
20353
20392
|
function summarizeLegacyPartitionDuplication(storageRoot) {
|
|
20354
|
-
if (!
|
|
20393
|
+
if (!existsSync20(storageRoot)) {
|
|
20355
20394
|
return { totalPartitions: 0, totalBytes: 0, byHarness: [] };
|
|
20356
20395
|
}
|
|
20357
20396
|
const byHarness = [];
|
|
20358
20397
|
for (const harness of safeReadDir(storageRoot)) {
|
|
20359
|
-
const harnessPath =
|
|
20398
|
+
const harnessPath = join21(storageRoot, harness);
|
|
20360
20399
|
if (!isDirectory(harnessPath))
|
|
20361
20400
|
continue;
|
|
20362
20401
|
const partitions = new Map;
|
|
20363
|
-
collectCallgraphPartitions(
|
|
20364
|
-
collectInspectPartitions(
|
|
20402
|
+
collectCallgraphPartitions(join21(harnessPath, "callgraph"), partitions);
|
|
20403
|
+
collectInspectPartitions(join21(harnessPath, "inspect"), partitions);
|
|
20365
20404
|
if (partitions.size === 0)
|
|
20366
20405
|
continue;
|
|
20367
20406
|
let bytes = 0;
|
|
@@ -20380,7 +20419,7 @@ function collectCallgraphPartitions(domainPath, partitions) {
|
|
|
20380
20419
|
if (!isDirectory(domainPath))
|
|
20381
20420
|
return;
|
|
20382
20421
|
for (const name of safeReadDir(domainPath)) {
|
|
20383
|
-
const path2 =
|
|
20422
|
+
const path2 = join21(domainPath, name);
|
|
20384
20423
|
if (isDirectory(path2)) {
|
|
20385
20424
|
if (!looksLikePartitionKey(name))
|
|
20386
20425
|
continue;
|
|
@@ -20397,7 +20436,7 @@ function collectInspectPartitions(domainPath, partitions) {
|
|
|
20397
20436
|
if (!isDirectory(domainPath))
|
|
20398
20437
|
return;
|
|
20399
20438
|
for (const name of safeReadDir(domainPath)) {
|
|
20400
|
-
const path2 =
|
|
20439
|
+
const path2 = join21(domainPath, name);
|
|
20401
20440
|
if (isDirectory(path2)) {
|
|
20402
20441
|
if (!looksLikePartitionKey(name))
|
|
20403
20442
|
continue;
|
|
@@ -20472,10 +20511,10 @@ var init_legacy_storage = __esm(() => {
|
|
|
20472
20511
|
});
|
|
20473
20512
|
|
|
20474
20513
|
// src/lib/lsp-cache.ts
|
|
20475
|
-
import { existsSync as
|
|
20476
|
-
import { join as
|
|
20514
|
+
import { existsSync as existsSync21, readdirSync as readdirSync9, rmSync as rmSync5, statSync as statSync13 } from "node:fs";
|
|
20515
|
+
import { join as join22 } from "node:path";
|
|
20477
20516
|
function inspectDir(path2) {
|
|
20478
|
-
if (!
|
|
20517
|
+
if (!existsSync21(path2)) {
|
|
20479
20518
|
return { entries: [], totalSize: 0 };
|
|
20480
20519
|
}
|
|
20481
20520
|
const entries = [];
|
|
@@ -20487,7 +20526,7 @@ function inspectDir(path2) {
|
|
|
20487
20526
|
return { entries: [], totalSize: 0 };
|
|
20488
20527
|
}
|
|
20489
20528
|
for (const name of names) {
|
|
20490
|
-
const full =
|
|
20529
|
+
const full = join22(path2, name);
|
|
20491
20530
|
try {
|
|
20492
20531
|
if (!statSync13(full).isDirectory())
|
|
20493
20532
|
continue;
|
|
@@ -20545,8 +20584,8 @@ var init_lsp_cache = __esm(() => {
|
|
|
20545
20584
|
});
|
|
20546
20585
|
|
|
20547
20586
|
// src/lib/onnx.ts
|
|
20548
|
-
import { existsSync as
|
|
20549
|
-
import { basename as basename3, isAbsolute as isAbsolute6, join as
|
|
20587
|
+
import { existsSync as existsSync22, readdirSync as readdirSync10, readlinkSync as readlinkSync2, realpathSync as realpathSync4 } from "node:fs";
|
|
20588
|
+
import { basename as basename3, isAbsolute as isAbsolute6, join as join23, resolve as resolve12, win32 as win322 } from "node:path";
|
|
20550
20589
|
function getOnnxLibraryName() {
|
|
20551
20590
|
if (process.platform === "darwin")
|
|
20552
20591
|
return "libonnxruntime.dylib";
|
|
@@ -20579,8 +20618,8 @@ function pathEnvValue2() {
|
|
|
20579
20618
|
return process.env.PATH ?? process.env.Path ?? process.env.path ?? "";
|
|
20580
20619
|
}
|
|
20581
20620
|
function pathEntriesForPlatform2() {
|
|
20582
|
-
const
|
|
20583
|
-
return pathEnvValue2().split(
|
|
20621
|
+
const delimiter3 = process.platform === "win32" ? ";" : ":";
|
|
20622
|
+
return pathEnvValue2().split(delimiter3).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => {
|
|
20584
20623
|
if (!entry || entry === "." || entry.includes("\x00"))
|
|
20585
20624
|
return false;
|
|
20586
20625
|
return isAbsolute6(entry) || win322.isAbsolute(entry);
|
|
@@ -20617,7 +20656,7 @@ function findIgnoredWindowsSystemOnnxRuntime() {
|
|
|
20617
20656
|
for (const root of windowsRoots) {
|
|
20618
20657
|
if (!root)
|
|
20619
20658
|
continue;
|
|
20620
|
-
const systemDir =
|
|
20659
|
+
const systemDir = join23(root, "System32");
|
|
20621
20660
|
const key = win322.resolve(systemDir).toLowerCase();
|
|
20622
20661
|
if (seen.has(key))
|
|
20623
20662
|
continue;
|
|
@@ -20638,13 +20677,13 @@ function findSystemOnnxRuntime2() {
|
|
|
20638
20677
|
searchPaths.push(...pathEntriesForPlatform2());
|
|
20639
20678
|
const programFiles = process.env.ProgramFiles ?? "C:\\Program Files";
|
|
20640
20679
|
const programFilesX86 = process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
|
20641
|
-
searchPaths.push(
|
|
20680
|
+
searchPaths.push(join23(programFiles, "onnxruntime", "lib"), join23(programFiles, "Microsoft ONNX Runtime", "lib"), join23(programFiles, "Microsoft Machine Learning", "lib"), join23(programFilesX86, "onnxruntime", "lib"), ...(() => {
|
|
20642
20681
|
const nugetPaths = [];
|
|
20643
20682
|
const userProfile = process.env.USERPROFILE ?? "";
|
|
20644
20683
|
if (!userProfile)
|
|
20645
20684
|
return nugetPaths;
|
|
20646
|
-
const nugetPackageDir =
|
|
20647
|
-
if (!
|
|
20685
|
+
const nugetPackageDir = join23(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
|
|
20686
|
+
if (!existsSync22(nugetPackageDir))
|
|
20648
20687
|
return nugetPaths;
|
|
20649
20688
|
try {
|
|
20650
20689
|
for (const entry of readdirSync10(nugetPackageDir, { withFileTypes: true })) {
|
|
@@ -20652,7 +20691,7 @@ function findSystemOnnxRuntime2() {
|
|
|
20652
20691
|
continue;
|
|
20653
20692
|
if (entry.name === "__globalPackagesFolder" || entry.name.startsWith("."))
|
|
20654
20693
|
continue;
|
|
20655
|
-
nugetPaths.push(
|
|
20694
|
+
nugetPaths.push(join23(nugetPackageDir, entry.name, "runtimes", "win-x64", "native"), join23(nugetPackageDir, entry.name, "runtimes", "win-arm64", "native"));
|
|
20656
20695
|
}
|
|
20657
20696
|
} catch {}
|
|
20658
20697
|
return nugetPaths;
|
|
@@ -20684,12 +20723,12 @@ function findSystemOnnxRuntime2() {
|
|
|
20684
20723
|
return unknownVersionPaths[0] ?? null;
|
|
20685
20724
|
}
|
|
20686
20725
|
function findCachedOnnxRuntime(storageDir) {
|
|
20687
|
-
const ortDir =
|
|
20726
|
+
const ortDir = join23(storageDir, "onnxruntime", ONNX_RUNTIME_VERSION);
|
|
20688
20727
|
const libName = getOnnxLibraryName();
|
|
20689
|
-
if (
|
|
20728
|
+
if (existsSync22(join23(ortDir, libName)))
|
|
20690
20729
|
return ortDir;
|
|
20691
|
-
const libSubdir =
|
|
20692
|
-
if (
|
|
20730
|
+
const libSubdir = join23(ortDir, "lib");
|
|
20731
|
+
if (existsSync22(join23(libSubdir, libName)))
|
|
20693
20732
|
return libSubdir;
|
|
20694
20733
|
return null;
|
|
20695
20734
|
}
|
|
@@ -20710,7 +20749,7 @@ function parseOrtVersionFromDirectoryPath(value) {
|
|
|
20710
20749
|
return null;
|
|
20711
20750
|
}
|
|
20712
20751
|
function detectOrtVersion(libDir) {
|
|
20713
|
-
if (!
|
|
20752
|
+
if (!existsSync22(libDir))
|
|
20714
20753
|
return null;
|
|
20715
20754
|
const libName = getOnnxLibraryName();
|
|
20716
20755
|
try {
|
|
@@ -20725,8 +20764,8 @@ function detectOrtVersion(libDir) {
|
|
|
20725
20764
|
if (version)
|
|
20726
20765
|
return version;
|
|
20727
20766
|
}
|
|
20728
|
-
const base =
|
|
20729
|
-
if (
|
|
20767
|
+
const base = join23(libDir, libName);
|
|
20768
|
+
if (existsSync22(base)) {
|
|
20730
20769
|
try {
|
|
20731
20770
|
const real = realpathSync4(base);
|
|
20732
20771
|
const version = parseOrtVersionFromPath(real) ?? parseOrtVersionFromDirectoryPath(real);
|
|
@@ -20761,7 +20800,7 @@ import {
|
|
|
20761
20800
|
accessSync,
|
|
20762
20801
|
closeSync as closeSync6,
|
|
20763
20802
|
constants,
|
|
20764
|
-
existsSync as
|
|
20803
|
+
existsSync as existsSync23,
|
|
20765
20804
|
openSync as openSync6,
|
|
20766
20805
|
readSync as readSync3,
|
|
20767
20806
|
statSync as statSync14
|
|
@@ -20800,7 +20839,7 @@ async function diagnoseHarness(adapter) {
|
|
|
20800
20839
|
const logPath = adapter.getLogFile();
|
|
20801
20840
|
const pluginCache = adapter.getPluginCacheInfo();
|
|
20802
20841
|
const storageAccessible = (() => {
|
|
20803
|
-
if (!
|
|
20842
|
+
if (!existsSync23(storage))
|
|
20804
20843
|
return false;
|
|
20805
20844
|
try {
|
|
20806
20845
|
accessSync(storage, constants.R_OK | constants.W_OK);
|
|
@@ -20825,7 +20864,7 @@ async function diagnoseHarness(adapter) {
|
|
|
20825
20864
|
pluginRegistered: adapter.hasPluginEntry(),
|
|
20826
20865
|
configPaths,
|
|
20827
20866
|
aftConfig: {
|
|
20828
|
-
exists:
|
|
20867
|
+
exists: existsSync23(configPaths.aftConfig),
|
|
20829
20868
|
...aftConfigRead.error ? { parseError: aftConfigRead.error } : {},
|
|
20830
20869
|
enabled: aftEnabled,
|
|
20831
20870
|
...aftEnabledSource ? { enabledSource: aftEnabledSource } : {},
|
|
@@ -20834,7 +20873,7 @@ async function diagnoseHarness(adapter) {
|
|
|
20834
20873
|
pluginCache,
|
|
20835
20874
|
storageDir: {
|
|
20836
20875
|
path: storage,
|
|
20837
|
-
exists:
|
|
20876
|
+
exists: existsSync23(storage),
|
|
20838
20877
|
accessible: storageAccessible,
|
|
20839
20878
|
sizesByKey: describeStorage,
|
|
20840
20879
|
...legacyDuplication.totalPartitions > 0 ? { legacyDuplication } : {}
|
|
@@ -20855,8 +20894,8 @@ async function diagnoseHarness(adapter) {
|
|
|
20855
20894
|
},
|
|
20856
20895
|
logFile: {
|
|
20857
20896
|
path: logPath,
|
|
20858
|
-
exists:
|
|
20859
|
-
sizeKb:
|
|
20897
|
+
exists: existsSync23(logPath),
|
|
20898
|
+
sizeKb: existsSync23(logPath) ? Math.round(statSync14(logPath).size / 1024) : 0
|
|
20860
20899
|
}
|
|
20861
20900
|
};
|
|
20862
20901
|
}
|
|
@@ -21053,7 +21092,7 @@ function formatDiagnosticIssuesSection(report) {
|
|
|
21053
21092
|
return lines;
|
|
21054
21093
|
}
|
|
21055
21094
|
function tailLogFile(path2, lines) {
|
|
21056
|
-
if (!
|
|
21095
|
+
if (!existsSync23(path2))
|
|
21057
21096
|
return "";
|
|
21058
21097
|
if (lines <= 0)
|
|
21059
21098
|
return "";
|
|
@@ -21242,14 +21281,14 @@ var init_issue_body = __esm(() => {
|
|
|
21242
21281
|
});
|
|
21243
21282
|
|
|
21244
21283
|
// src/lib/onnx-fix.ts
|
|
21245
|
-
import { existsSync as
|
|
21246
|
-
import { join as
|
|
21284
|
+
import { existsSync as existsSync24, rmSync as rmSync6 } from "node:fs";
|
|
21285
|
+
import { join as join24 } from "node:path";
|
|
21247
21286
|
function findOnnxFixCandidates(report) {
|
|
21248
21287
|
const candidates = [];
|
|
21249
21288
|
for (const harness of report.harnesses) {
|
|
21250
21289
|
if (!harness.onnxRuntime.required)
|
|
21251
21290
|
continue;
|
|
21252
|
-
const storageOnnxDir =
|
|
21291
|
+
const storageOnnxDir = join24(harness.storageDir.path, "onnxruntime");
|
|
21253
21292
|
const systemTooOld = harness.onnxRuntime.systemPath !== null && harness.onnxRuntime.systemCompatible === false;
|
|
21254
21293
|
const cachedTooOld = harness.onnxRuntime.cachedPath !== null && harness.onnxRuntime.cachedCompatible === false;
|
|
21255
21294
|
const hasCompatibleCached = harness.onnxRuntime.cachedCompatible === true;
|
|
@@ -21258,7 +21297,7 @@ function findOnnxFixCandidates(report) {
|
|
|
21258
21297
|
harness,
|
|
21259
21298
|
reason: `cached ONNX Runtime at ${harness.onnxRuntime.cachedPath} is v${harness.onnxRuntime.cachedVersion}, but AFT requires ${harness.onnxRuntime.requirement}. Clearing it allows an immediate managed download.`,
|
|
21260
21299
|
storageOnnxDir,
|
|
21261
|
-
storageOnnxBytes:
|
|
21300
|
+
storageOnnxBytes: existsSync24(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
21262
21301
|
});
|
|
21263
21302
|
continue;
|
|
21264
21303
|
}
|
|
@@ -21267,7 +21306,7 @@ function findOnnxFixCandidates(report) {
|
|
|
21267
21306
|
harness,
|
|
21268
21307
|
reason: `system ONNX Runtime at ${harness.onnxRuntime.systemPath} is v${harness.onnxRuntime.systemVersion}, but AFT requires ${harness.onnxRuntime.requirement}, and no AFT-managed install is present. AFT will leave the system copy untouched and download v1.24 into managed storage.`,
|
|
21269
21308
|
storageOnnxDir,
|
|
21270
|
-
storageOnnxBytes:
|
|
21309
|
+
storageOnnxBytes: existsSync24(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
21271
21310
|
});
|
|
21272
21311
|
continue;
|
|
21273
21312
|
}
|
|
@@ -21277,7 +21316,7 @@ function findOnnxFixCandidates(report) {
|
|
|
21277
21316
|
harness,
|
|
21278
21317
|
reason: `no compatible ONNX Runtime is installed.${ignoredCopy} AFT will download v1.24 into managed storage.`,
|
|
21279
21318
|
storageOnnxDir,
|
|
21280
|
-
storageOnnxBytes:
|
|
21319
|
+
storageOnnxBytes: existsSync24(storageOnnxDir) ? dirSize(storageOnnxDir) : 0
|
|
21281
21320
|
});
|
|
21282
21321
|
}
|
|
21283
21322
|
}
|
|
@@ -21307,7 +21346,7 @@ async function runOnnxFix(adapters, report, options = {}) {
|
|
|
21307
21346
|
const rmFn = options.rmFn ?? rmSync6;
|
|
21308
21347
|
const ensureFn = options.ensureFn ?? ensureOnnxRuntime;
|
|
21309
21348
|
for (const candidate of candidates) {
|
|
21310
|
-
if (
|
|
21349
|
+
if (existsSync24(candidate.storageOnnxDir)) {
|
|
21311
21350
|
try {
|
|
21312
21351
|
rmFn(candidate.storageOnnxDir, { recursive: true, force: true });
|
|
21313
21352
|
result.cleared += 1;
|
|
@@ -21349,10 +21388,10 @@ var init_onnx_fix = __esm(() => {
|
|
|
21349
21388
|
});
|
|
21350
21389
|
|
|
21351
21390
|
// src/lib/sessions.ts
|
|
21352
|
-
import { existsSync as
|
|
21391
|
+
import { existsSync as existsSync25, readdirSync as readdirSync11, readFileSync as readFileSync10, statSync as statSync15 } from "node:fs";
|
|
21353
21392
|
import { createRequire as createRequire5 } from "node:module";
|
|
21354
21393
|
import { homedir as homedir18 } from "node:os";
|
|
21355
|
-
import { basename as basename4, join as
|
|
21394
|
+
import { basename as basename4, join as join25 } from "node:path";
|
|
21356
21395
|
function listRecentSessions(adapter) {
|
|
21357
21396
|
try {
|
|
21358
21397
|
if (adapter.kind === "opencode")
|
|
@@ -21381,8 +21420,8 @@ function mapOpenCodeSessionRows(rows) {
|
|
|
21381
21420
|
}).filter((session) => session !== null).sort((a3, b) => b.lastActivity - a3.lastActivity).slice(0, MAX_RECENT_SESSIONS);
|
|
21382
21421
|
}
|
|
21383
21422
|
function listRecentOpenCodeSessions() {
|
|
21384
|
-
const dbPath =
|
|
21385
|
-
if (!
|
|
21423
|
+
const dbPath = join25(getXdgDataHome(), "opencode", "opencode.db");
|
|
21424
|
+
if (!existsSync25(dbPath))
|
|
21386
21425
|
return [];
|
|
21387
21426
|
let db = null;
|
|
21388
21427
|
try {
|
|
@@ -21401,10 +21440,10 @@ function listRecentOpenCodeSessions() {
|
|
|
21401
21440
|
}
|
|
21402
21441
|
function getXdgDataHome() {
|
|
21403
21442
|
const xdgDataHome = process.env.XDG_DATA_HOME;
|
|
21404
|
-
return xdgDataHome && xdgDataHome.length > 0 ? xdgDataHome :
|
|
21443
|
+
return xdgDataHome && xdgDataHome.length > 0 ? xdgDataHome : join25(homedir18(), ".local", "share");
|
|
21405
21444
|
}
|
|
21406
21445
|
function listRecentPiSessions() {
|
|
21407
|
-
return listPiSessionsFromDir(
|
|
21446
|
+
return listPiSessionsFromDir(join25(getHomeDir(), ".pi", "agent", "sessions"));
|
|
21408
21447
|
}
|
|
21409
21448
|
function getHomeDir() {
|
|
21410
21449
|
const envHome = process.platform === "win32" ? process.env.USERPROFILE : process.env.HOME;
|
|
@@ -21412,7 +21451,7 @@ function getHomeDir() {
|
|
|
21412
21451
|
}
|
|
21413
21452
|
function listPiSessionsFromDir(sessionsDir) {
|
|
21414
21453
|
try {
|
|
21415
|
-
if (!
|
|
21454
|
+
if (!existsSync25(sessionsDir))
|
|
21416
21455
|
return [];
|
|
21417
21456
|
const files = collectJsonlFiles(sessionsDir).map((filePath) => {
|
|
21418
21457
|
try {
|
|
@@ -21450,7 +21489,7 @@ function collectJsonlFiles(root) {
|
|
|
21450
21489
|
continue;
|
|
21451
21490
|
}
|
|
21452
21491
|
for (const entry of entries) {
|
|
21453
|
-
const path2 =
|
|
21492
|
+
const path2 = join25(dir, entry.name);
|
|
21454
21493
|
if (entry.isDirectory()) {
|
|
21455
21494
|
stack.push(path2);
|
|
21456
21495
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
@@ -21553,7 +21592,7 @@ __export(exports_doctor, {
|
|
|
21553
21592
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
21554
21593
|
import {
|
|
21555
21594
|
chmodSync as chmodSync4,
|
|
21556
|
-
existsSync as
|
|
21595
|
+
existsSync as existsSync26,
|
|
21557
21596
|
mkdirSync as mkdirSync7,
|
|
21558
21597
|
mkdtempSync,
|
|
21559
21598
|
readFileSync as readFileSync11,
|
|
@@ -21563,7 +21602,7 @@ import {
|
|
|
21563
21602
|
writeFileSync as writeFileSync5
|
|
21564
21603
|
} from "node:fs";
|
|
21565
21604
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
21566
|
-
import { join as
|
|
21605
|
+
import { join as join26 } from "node:path";
|
|
21567
21606
|
async function runDoctor(options) {
|
|
21568
21607
|
if (options.issue) {
|
|
21569
21608
|
return runIssueFlow(options.argv);
|
|
@@ -21852,7 +21891,7 @@ function clearOldBinaries() {
|
|
|
21852
21891
|
errors: [],
|
|
21853
21892
|
keptVersion: keepTag
|
|
21854
21893
|
};
|
|
21855
|
-
if (!
|
|
21894
|
+
if (!existsSync26(info.path)) {
|
|
21856
21895
|
log2.info(`Binary cache: nothing to clear at ${info.path}`);
|
|
21857
21896
|
return result;
|
|
21858
21897
|
}
|
|
@@ -21862,7 +21901,7 @@ function clearOldBinaries() {
|
|
|
21862
21901
|
return result;
|
|
21863
21902
|
}
|
|
21864
21903
|
for (const version of stale) {
|
|
21865
|
-
const dir =
|
|
21904
|
+
const dir = join26(info.path, version);
|
|
21866
21905
|
let bytes = 0;
|
|
21867
21906
|
try {
|
|
21868
21907
|
bytes = statSync16(dir).isDirectory() ? dirSize(dir) : 0;
|
|
@@ -22209,7 +22248,7 @@ function ensureStorageDirsForRegisteredPlugins(adapters) {
|
|
|
22209
22248
|
if (!adapter.isInstalled() || !adapter.hasPluginEntry())
|
|
22210
22249
|
continue;
|
|
22211
22250
|
const storageDir = adapter.getStorageDir();
|
|
22212
|
-
if (
|
|
22251
|
+
if (existsSync26(storageDir))
|
|
22213
22252
|
continue;
|
|
22214
22253
|
mkdirSync7(storageDir, { recursive: true });
|
|
22215
22254
|
summary.created += 1;
|
|
@@ -22334,11 +22373,11 @@ function deriveIssueTitleFromBody(body) {
|
|
|
22334
22373
|
function writeIssueReviewFile(body) {
|
|
22335
22374
|
let reviewDir = null;
|
|
22336
22375
|
try {
|
|
22337
|
-
reviewDir = mkdtempSync(
|
|
22376
|
+
reviewDir = mkdtempSync(join26(tmpdir2(), "aft-issue-"));
|
|
22338
22377
|
if (process.platform !== "win32") {
|
|
22339
22378
|
chmodSync4(reviewDir, 448);
|
|
22340
22379
|
}
|
|
22341
|
-
const outPath =
|
|
22380
|
+
const outPath = join26(reviewDir, "issue.md");
|
|
22342
22381
|
writeFileSync5(outPath, `${body}
|
|
22343
22382
|
`, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
22344
22383
|
return { path: outPath, realPath: realpathSync5(outPath) };
|