@cortexkit/aft 0.58.2 → 0.59.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/adapters/opencode.d.ts +5 -0
- package/dist/adapters/opencode.d.ts.map +1 -1
- package/dist/commands/cache.d.ts +7 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/doctor.d.ts +6 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/lsp.d.ts +1 -0
- package/dist/commands/lsp.d.ts.map +1 -1
- package/dist/commands/setup.d.ts +5 -0
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/index.js +1136 -691
- package/dist/lib/aft-bridge.d.ts +16 -0
- package/dist/lib/aft-bridge.d.ts.map +1 -1
- package/dist/lib/config-migration.d.ts.map +1 -1
- package/dist/lib/diagnostics.d.ts.map +1 -1
- package/dist/lib/fs-errors.d.ts.map +1 -1
- package/dist/lib/issue-body.d.ts.map +1 -1
- package/dist/lib/plugin-load.d.ts +3 -5
- package/dist/lib/plugin-load.d.ts.map +1 -1
- package/dist/lib/sanitize.d.ts +2 -0
- package/dist/lib/sanitize.d.ts.map +1 -1
- package/dist/setup/host-generation.d.ts +6 -0
- package/dist/setup/host-generation.d.ts.map +1 -1
- package/dist/setup/opencode-config.d.ts +21 -0
- package/dist/setup/opencode-config.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -109,8 +109,124 @@ var ACTIVE_LOGGER_SYMBOL;
|
|
|
109
109
|
var init_active_logger = __esm(() => {
|
|
110
110
|
ACTIVE_LOGGER_SYMBOL = Symbol.for("aft-bridge-active-logger");
|
|
111
111
|
});
|
|
112
|
+
// ../aft-bridge/dist/path-display.js
|
|
113
|
+
import { homedir } from "node:os";
|
|
114
|
+
import { posix, win32 } from "node:path";
|
|
115
|
+
function shortenHomePath(path, home = homedir(), platform = process.platform) {
|
|
116
|
+
if (!home)
|
|
117
|
+
return path;
|
|
118
|
+
const normalize = (value) => platform === "win32" ? value.replace(/\\/g, "/").toLowerCase() : value;
|
|
119
|
+
const base = normalize(home).replace(/\/+$/, "");
|
|
120
|
+
const target = normalize(path);
|
|
121
|
+
if (target === normalize(home) || target === base)
|
|
122
|
+
return "~";
|
|
123
|
+
return target.startsWith(`${base}/`) ? `~${path.slice(base.length)}` : path;
|
|
124
|
+
}
|
|
125
|
+
function relativePathEscapesRoot(rel, platform = process.platform) {
|
|
126
|
+
return rel === ".." || rel.startsWith("../") || platform === "win32" && rel.startsWith("..\\") || (platform === "win32" ? win32.isAbsolute(rel) : posix.isAbsolute(rel));
|
|
127
|
+
}
|
|
128
|
+
var init_path_display = () => {};
|
|
129
|
+
|
|
112
130
|
// ../aft-bridge/dist/bash-hints.js
|
|
113
|
-
var init_bash_hints = () => {
|
|
131
|
+
var init_bash_hints = __esm(() => {
|
|
132
|
+
init_path_display();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// ../aft-bridge/dist/test-child-environment.js
|
|
136
|
+
import { mkdirSync, realpathSync } from "node:fs";
|
|
137
|
+
import { homedir as homedir2, tmpdir } from "node:os";
|
|
138
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
139
|
+
function toolchainHomes(inherited) {
|
|
140
|
+
const global = globalThis;
|
|
141
|
+
if (!global[TOOLCHAINS]) {
|
|
142
|
+
const home = process.platform === "win32" ? inherited.USERPROFILE || inherited.HOME || homedir2() : inherited.HOME || homedir2();
|
|
143
|
+
global[TOOLCHAINS] = {
|
|
144
|
+
RUSTUP_HOME: inherited.RUSTUP_HOME || join(home, ".rustup"),
|
|
145
|
+
CARGO_HOME: inherited.CARGO_HOME || join(home, ".cargo")
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return global[TOOLCHAINS];
|
|
149
|
+
}
|
|
150
|
+
function createdRoots() {
|
|
151
|
+
const global = globalThis;
|
|
152
|
+
return global[ROOTS] ??= new Set;
|
|
153
|
+
}
|
|
154
|
+
function isolatedAftEnvironment(root, inherited = process.env) {
|
|
155
|
+
const env = { ...inherited };
|
|
156
|
+
const toolchains = toolchainHomes(inherited);
|
|
157
|
+
env.RUSTUP_HOME ||= toolchains.RUSTUP_HOME;
|
|
158
|
+
env.CARGO_HOME ||= toolchains.CARGO_HOME;
|
|
159
|
+
const names = [
|
|
160
|
+
"home",
|
|
161
|
+
"home",
|
|
162
|
+
"local",
|
|
163
|
+
"config",
|
|
164
|
+
"data",
|
|
165
|
+
"state",
|
|
166
|
+
"cache",
|
|
167
|
+
"runtime",
|
|
168
|
+
"storage",
|
|
169
|
+
"aft-cache"
|
|
170
|
+
];
|
|
171
|
+
for (const [index, key] of DIRECTORIES.entries()) {
|
|
172
|
+
env[key] = join(root, names[index]);
|
|
173
|
+
mkdirSync(env[key], { recursive: true });
|
|
174
|
+
}
|
|
175
|
+
delete env.AFT_ALLOW_PRODUCTION_MIGRATION;
|
|
176
|
+
createdRoots().add(resolve(root));
|
|
177
|
+
return env;
|
|
178
|
+
}
|
|
179
|
+
function canonical(path) {
|
|
180
|
+
let ancestor = resolve(path);
|
|
181
|
+
const tail = [];
|
|
182
|
+
while (true) {
|
|
183
|
+
try {
|
|
184
|
+
return join(realpathSync(ancestor), ...tail);
|
|
185
|
+
} catch {
|
|
186
|
+
const parent = dirname(ancestor);
|
|
187
|
+
if (parent === ancestor)
|
|
188
|
+
return resolve(path);
|
|
189
|
+
tail.unshift(relative(parent, ancestor));
|
|
190
|
+
ancestor = parent;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function within(path, root) {
|
|
195
|
+
const tail = relative(canonical(root), canonical(path));
|
|
196
|
+
return tail === "" || !tail.startsWith("..") && !isAbsolute(tail);
|
|
197
|
+
}
|
|
198
|
+
function testChildEnvironment(env) {
|
|
199
|
+
const root = process.env.AFT_TEST_ISOLATION_ROOT;
|
|
200
|
+
if (!root)
|
|
201
|
+
return env;
|
|
202
|
+
const fallback = isolatedAftEnvironment(root, env);
|
|
203
|
+
for (const key of DIRECTORIES) {
|
|
204
|
+
const value = env[key];
|
|
205
|
+
if (value && ([...createdRoots()].some((created) => within(value, created)) || within(value, tmpdir()))) {
|
|
206
|
+
mkdirSync(value, { recursive: true });
|
|
207
|
+
fallback[key] = value;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
fallback.AFT_TEST_ISOLATION_ROOT = root;
|
|
211
|
+
return fallback;
|
|
212
|
+
}
|
|
213
|
+
var DIRECTORIES, ROOTS, TOOLCHAINS;
|
|
214
|
+
var init_test_child_environment = __esm(() => {
|
|
215
|
+
DIRECTORIES = [
|
|
216
|
+
"HOME",
|
|
217
|
+
"USERPROFILE",
|
|
218
|
+
"LOCALAPPDATA",
|
|
219
|
+
"XDG_CONFIG_HOME",
|
|
220
|
+
"XDG_DATA_HOME",
|
|
221
|
+
"XDG_STATE_HOME",
|
|
222
|
+
"XDG_CACHE_HOME",
|
|
223
|
+
"XDG_RUNTIME_DIR",
|
|
224
|
+
"AFT_STORAGE_DIR",
|
|
225
|
+
"AFT_CACHE_DIR"
|
|
226
|
+
];
|
|
227
|
+
ROOTS = Symbol.for("cortexkit.aft.created-test-child-roots");
|
|
228
|
+
TOOLCHAINS = Symbol.for("cortexkit.aft.test-child-toolchain-homes");
|
|
229
|
+
});
|
|
114
230
|
|
|
115
231
|
// ../aft-bridge/dist/child-process.js
|
|
116
232
|
import { execFile as nodeExecFile, execFileSync as nodeExecFileSync, execSync as nodeExecSync, spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process";
|
|
@@ -130,10 +246,19 @@ function withWindowsHidden(args, takesArgv) {
|
|
|
130
246
|
return out;
|
|
131
247
|
}
|
|
132
248
|
function hidden(resolve, takesArgv) {
|
|
133
|
-
return (...args) =>
|
|
249
|
+
return (...args) => {
|
|
250
|
+
const out = withWindowsHidden(args, takesArgv);
|
|
251
|
+
if (process.env.AFT_TEST_ISOLATION_ROOT) {
|
|
252
|
+
const index = takesArgv && (Array.isArray(out[1]) || out[1] == null && out.length > 2) ? 2 : 1;
|
|
253
|
+
const options = out[index];
|
|
254
|
+
options.env = testChildEnvironment(options.env ?? process.env);
|
|
255
|
+
}
|
|
256
|
+
return resolve()(...out);
|
|
257
|
+
};
|
|
134
258
|
}
|
|
135
259
|
var HIDDEN, spawn, spawnSync, execFile, execFileSync, execSync;
|
|
136
260
|
var init_child_process = __esm(() => {
|
|
261
|
+
init_test_child_environment();
|
|
137
262
|
HIDDEN = { windowsHide: true };
|
|
138
263
|
spawn = hidden(() => nodeSpawn, true);
|
|
139
264
|
spawnSync = hidden(() => nodeSpawnSync, true);
|
|
@@ -165,8 +290,8 @@ function withPathPrepended(env, dir, platform = process.platform) {
|
|
|
165
290
|
}
|
|
166
291
|
|
|
167
292
|
// ../aft-bridge/dist/storage-paths.js
|
|
168
|
-
import { homedir, tmpdir } from "node:os";
|
|
169
|
-
import { join, resolve } from "node:path";
|
|
293
|
+
import { homedir as homedir3, tmpdir as tmpdir2 } from "node:os";
|
|
294
|
+
import { join as join2, resolve as resolve2 } from "node:path";
|
|
170
295
|
function environmentValue(context, name) {
|
|
171
296
|
const value = (context.lookup ?? ((key) => process.env[key]))(name);
|
|
172
297
|
return value !== undefined && value.length > 0 ? value : undefined;
|
|
@@ -176,7 +301,7 @@ function storagePlatform(context) {
|
|
|
176
301
|
}
|
|
177
302
|
function homeDir(context) {
|
|
178
303
|
const configured = storagePlatform(context) === "windows" ? environmentValue(context, "USERPROFILE") ?? environmentValue(context, "HOME") : environmentValue(context, "HOME") ?? environmentValue(context, "USERPROFILE");
|
|
179
|
-
return configured ?? context.fallbackHome ??
|
|
304
|
+
return configured ?? context.fallbackHome ?? homedir3();
|
|
180
305
|
}
|
|
181
306
|
function resolveDataHome(context = {}) {
|
|
182
307
|
const xdg = environmentValue(context, "XDG_DATA_HOME");
|
|
@@ -188,21 +313,21 @@ function resolveDataHome(context = {}) {
|
|
|
188
313
|
return localAppData;
|
|
189
314
|
const userProfile = environmentValue(context, "USERPROFILE");
|
|
190
315
|
if (userProfile)
|
|
191
|
-
return
|
|
316
|
+
return join2(userProfile, "AppData", "Local");
|
|
192
317
|
}
|
|
193
318
|
const home = environmentValue(context, "HOME");
|
|
194
319
|
if (home)
|
|
195
|
-
return
|
|
196
|
-
return
|
|
320
|
+
return join2(home, ".local", "share");
|
|
321
|
+
return join2(".local", "share");
|
|
197
322
|
}
|
|
198
323
|
function resolveStoragePath(raw, context = {}) {
|
|
199
324
|
let expanded = raw;
|
|
200
325
|
if (raw === "~") {
|
|
201
326
|
expanded = homeDir(context);
|
|
202
327
|
} else if (raw.startsWith("~/") || raw.startsWith("~\\")) {
|
|
203
|
-
expanded =
|
|
328
|
+
expanded = join2(homeDir(context), raw.slice(2));
|
|
204
329
|
}
|
|
205
|
-
return
|
|
330
|
+
return resolve2(context.currentDirectory ?? process.cwd(), expanded);
|
|
206
331
|
}
|
|
207
332
|
function resolveCortexKitStorageRoot(context = {}) {
|
|
208
333
|
const override = environmentValue(context, "AFT_STORAGE_DIR");
|
|
@@ -210,8 +335,8 @@ function resolveCortexKitStorageRoot(context = {}) {
|
|
|
210
335
|
return resolveStoragePath(override, context);
|
|
211
336
|
const legacyCache = environmentValue(context, "AFT_CACHE_DIR");
|
|
212
337
|
if (legacyCache)
|
|
213
|
-
return
|
|
214
|
-
return resolveStoragePath(
|
|
338
|
+
return join2(resolveStoragePath(legacyCache, context), "aft");
|
|
339
|
+
return resolveStoragePath(join2(resolveDataHome(context), "cortexkit", "aft"), context);
|
|
215
340
|
}
|
|
216
341
|
function resolveAftStorageRoot(configuredRoot, context = {}) {
|
|
217
342
|
if (environmentValue(context, "AFT_STORAGE_DIR")) {
|
|
@@ -222,14 +347,14 @@ function resolveAftStorageRoot(configuredRoot, context = {}) {
|
|
|
222
347
|
return resolveCortexKitStorageRoot(context);
|
|
223
348
|
}
|
|
224
349
|
function resolveAftLogPath(filename, configuredRoot, context = {}) {
|
|
225
|
-
return
|
|
350
|
+
return join2(resolveAftStorageRoot(configuredRoot, context), "logs", filename);
|
|
226
351
|
}
|
|
227
352
|
function isTestEnvironment(context = {}) {
|
|
228
353
|
return environmentValue(context, "BUN_TEST") === "1" || environmentValue(context, "NODE_ENV") === "test";
|
|
229
354
|
}
|
|
230
355
|
function resolvePluginLogPath(context = {}) {
|
|
231
356
|
if (isTestEnvironment(context)) {
|
|
232
|
-
return
|
|
357
|
+
return join2(environmentValue(context, "TMPDIR") ?? tmpdir2(), `aft-plugin-tests-${process.pid}`, "logs", "aft-plugin-test.log");
|
|
233
358
|
}
|
|
234
359
|
return resolveAftLogPath("aft-plugin.log", undefined, context);
|
|
235
360
|
}
|
|
@@ -246,7 +371,7 @@ var init_bash_host_fallback = __esm(() => {
|
|
|
246
371
|
|
|
247
372
|
// ../aft-bridge/dist/binary-identity.js
|
|
248
373
|
import { createHash } from "node:crypto";
|
|
249
|
-
import { createReadStream, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
374
|
+
import { closeSync, createReadStream, openSync, readFileSync, readSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
250
375
|
function bareVersion(version) {
|
|
251
376
|
return version.startsWith("v") ? version.slice(1) : version;
|
|
252
377
|
}
|
|
@@ -311,7 +436,7 @@ function writeSidecarAtomically(binaryPath, identity) {
|
|
|
311
436
|
const tmp = `${sidecar}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
312
437
|
try {
|
|
313
438
|
writeFileSync(tmp, `${JSON.stringify(identity)}
|
|
314
|
-
`, "utf8");
|
|
439
|
+
`, { encoding: "utf8", mode: 384 });
|
|
315
440
|
if (process.platform === "win32") {
|
|
316
441
|
try {
|
|
317
442
|
unlinkSync(sidecar);
|
|
@@ -428,12 +553,50 @@ function peekBinaryContentHash(binaryPath) {
|
|
|
428
553
|
binaryContentHash(binaryPath);
|
|
429
554
|
return null;
|
|
430
555
|
}
|
|
431
|
-
|
|
556
|
+
function digestStamp(path) {
|
|
557
|
+
const s = statSync(path, { bigint: true });
|
|
558
|
+
return `${s.dev}:${s.ino}:${s.size}:${s.mtimeNs}:${s.ctimeNs}`;
|
|
559
|
+
}
|
|
560
|
+
function readStampedFileDigest(path) {
|
|
561
|
+
try {
|
|
562
|
+
const value = JSON.parse(readFileSync(`${path}.digest.json`, "utf8"));
|
|
563
|
+
return value.schema === 1 && value.stamp === digestStamp(path) && typeof value.sha256 === "string" && /^[a-f0-9]{64}$/.test(value.sha256) ? value.sha256 : null;
|
|
564
|
+
} catch {
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function writeStampedFileDigest(path, sha256, verifiedStamp) {
|
|
569
|
+
const sidecar = `${path}.digest.json`;
|
|
570
|
+
const tmp = `${sidecar}.${process.pid}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
571
|
+
try {
|
|
572
|
+
writeFileSync(tmp, JSON.stringify({ schema: 1, stamp: verifiedStamp ?? digestStamp(path), sha256 }), { mode: 384 });
|
|
573
|
+
renameSync(tmp, sidecar);
|
|
574
|
+
} catch {} finally {
|
|
575
|
+
try {
|
|
576
|
+
unlinkSync(tmp);
|
|
577
|
+
} catch {}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
async function cachedFileSha256(path) {
|
|
581
|
+
const known = readStampedFileDigest(path);
|
|
582
|
+
if (known)
|
|
583
|
+
return known;
|
|
584
|
+
const before = digestStamp(path);
|
|
585
|
+
digestWork.asyncHashes += 1;
|
|
586
|
+
digestWork.bytesHashed += Number(statSync(path).size);
|
|
587
|
+
const digest = await sha256File(path);
|
|
588
|
+
if (digestStamp(path) !== before)
|
|
589
|
+
throw new Error(`File changed while hashing: ${path}`);
|
|
590
|
+
writeStampedFileDigest(path, digest, before);
|
|
591
|
+
return digest;
|
|
592
|
+
}
|
|
593
|
+
var SIDECAR_SCHEMA = 1, pendingIdentityWrites, contentHashCache, contentHashInFlight, digestWork;
|
|
432
594
|
var init_binary_identity = __esm(() => {
|
|
433
595
|
init_active_logger();
|
|
434
596
|
pendingIdentityWrites = new Set;
|
|
435
597
|
contentHashCache = new Map;
|
|
436
598
|
contentHashInFlight = new Map;
|
|
599
|
+
digestWork = { syncHashes: 0, asyncHashes: 0, bytesHashed: 0 };
|
|
437
600
|
});
|
|
438
601
|
|
|
439
602
|
// ../aft-bridge/dist/command-timeouts.js
|
|
@@ -449,8 +612,8 @@ var init_command_timeouts = __esm(() => {
|
|
|
449
612
|
var WORKER_SESSION_FIELD = "worker_session";
|
|
450
613
|
|
|
451
614
|
// ../aft-bridge/dist/bridge.js
|
|
452
|
-
import { homedir as
|
|
453
|
-
import { join as
|
|
615
|
+
import { homedir as homedir4 } from "node:os";
|
|
616
|
+
import { join as join3 } from "node:path";
|
|
454
617
|
import { StringDecoder } from "node:string_decoder";
|
|
455
618
|
function isTerminalBashStatus(status) {
|
|
456
619
|
return typeof status === "string" && TERMINAL_BASH_STATUSES.has(status);
|
|
@@ -538,14 +701,13 @@ function coerceConfigureDroppedKeys(value) {
|
|
|
538
701
|
}
|
|
539
702
|
return dropped;
|
|
540
703
|
}
|
|
541
|
-
var DEFAULT_BRIDGE_TIMEOUT_MS = 30000, BRIDGE_HANG_TIMEOUT_THRESHOLD = 2, MAX_STDOUT_BUFFER,
|
|
704
|
+
var DEFAULT_BRIDGE_TIMEOUT_MS = 30000, BRIDGE_HANG_TIMEOUT_THRESHOLD = 2, MAX_STDOUT_BUFFER, MALFORMED_STDOUT_LOG_CHARS = 512, HASHLINE_REGISTRATION_LOG_INTERVAL_MS = 60000, HASHLINE_REGISTRATION_LOG_STATE_LIMIT = 256, TERMINAL_BASH_STATUSES, binaryFingerprintReader, binaryFingerprintAsyncReader, BENIGN_CPUINFO_PROC_CPUINFO_PARSE_FAILURE = "failed to parse processor information from /proc/cpuinfo", BridgeReplacedDuringVersionCheck, BridgeTransportTimeoutError, BridgeTransportUnavailableError, BridgeTransportUnknownOutcomeError, BinaryBridge;
|
|
542
705
|
var init_bridge = __esm(() => {
|
|
543
706
|
init_active_logger();
|
|
544
707
|
init_binary_identity();
|
|
545
708
|
init_child_process();
|
|
546
709
|
init_command_timeouts();
|
|
547
710
|
MAX_STDOUT_BUFFER = 64 * 1024 * 1024;
|
|
548
|
-
STDOUT_BUFFER_COMPACT_THRESHOLD = 64 * 1024;
|
|
549
711
|
TERMINAL_BASH_STATUSES = new Set([
|
|
550
712
|
"completed",
|
|
551
713
|
"failed",
|
|
@@ -602,8 +764,12 @@ var init_bridge = __esm(() => {
|
|
|
602
764
|
outstandingBackgroundTaskIds = new Set;
|
|
603
765
|
nextId = 1;
|
|
604
766
|
processGeneration = 0;
|
|
605
|
-
|
|
606
|
-
|
|
767
|
+
stdoutPending = [];
|
|
768
|
+
stdoutPendingLength = 0;
|
|
769
|
+
stdoutScannedChars = 0;
|
|
770
|
+
__stdoutScannedCharsForTests() {
|
|
771
|
+
return this.stdoutScannedChars;
|
|
772
|
+
}
|
|
607
773
|
stderrBuffer = "";
|
|
608
774
|
stderrTail = [];
|
|
609
775
|
_restartCount = 0;
|
|
@@ -629,6 +795,7 @@ var init_bridge = __esm(() => {
|
|
|
629
795
|
restartResetTimer = null;
|
|
630
796
|
lastChildActivityAt = 0;
|
|
631
797
|
consecutiveRequestTimeouts = 0;
|
|
798
|
+
timeoutRestartAwaitingRecovery = false;
|
|
632
799
|
errorPrefix;
|
|
633
800
|
logger;
|
|
634
801
|
childEnv;
|
|
@@ -872,7 +1039,7 @@ var init_bridge = __esm(() => {
|
|
|
872
1039
|
async sendWithVersionMismatchRetry(command, params, options, canRetryAfterVersionSwap) {
|
|
873
1040
|
try {
|
|
874
1041
|
if (this._retiringDueToBinaryChange) {
|
|
875
|
-
throw new
|
|
1042
|
+
throw new BridgeTransportUnavailableError(`${this.errorPrefix} Bridge is retiring after the on-disk binary changed; retry to respawn on the updated binary`);
|
|
876
1043
|
}
|
|
877
1044
|
if (this._shuttingDown) {
|
|
878
1045
|
throw new BridgeTransportUnavailableError(`${this.errorPrefix} Bridge is shutting down, cannot send "${command}"`);
|
|
@@ -947,7 +1114,7 @@ var init_bridge = __esm(() => {
|
|
|
947
1114
|
}
|
|
948
1115
|
const line = `${JSON.stringify(request)}
|
|
949
1116
|
`;
|
|
950
|
-
const keepBridgeOnTimeout = passive || options?.keepBridgeOnTimeout === true;
|
|
1117
|
+
const keepBridgeOnTimeout = passive || command === "bash_drain_completions" || options?.keepBridgeOnTimeout === true;
|
|
951
1118
|
let requestSentAt = Date.now();
|
|
952
1119
|
const child = this.process;
|
|
953
1120
|
const response = await new Promise((resolve, reject) => {
|
|
@@ -971,7 +1138,8 @@ var init_bridge = __esm(() => {
|
|
|
971
1138
|
const childActiveSinceRequest = this.lastChildActivityAt > requestSentAt;
|
|
972
1139
|
const consecutiveTimeouts = this.consecutiveRequestTimeouts + 1;
|
|
973
1140
|
this.consecutiveRequestTimeouts = consecutiveTimeouts;
|
|
974
|
-
const
|
|
1141
|
+
const restartSuppressed = this.timeoutRestartAwaitingRecovery;
|
|
1142
|
+
const keepWarm = restartSuppressed || childActiveSinceRequest || consecutiveTimeouts < this.hangThreshold;
|
|
975
1143
|
const restartSuffix = keepWarm ? " — bridge kept warm" : " — restarting bridge";
|
|
976
1144
|
const timeoutMsg = `Request "${command}" (id=${id}) timed out after ${effectiveTimeoutMs}ms${restartSuffix}`;
|
|
977
1145
|
if (requestSessionId) {
|
|
@@ -980,7 +1148,7 @@ var init_bridge = __esm(() => {
|
|
|
980
1148
|
this.warnVia(timeoutMsg);
|
|
981
1149
|
}
|
|
982
1150
|
if (keepWarm) {
|
|
983
|
-
entry.reject(new Error(`${this.errorPrefix} request "${command}" timed out after ${effectiveTimeoutMs}ms (bridge busy/under load); bridge kept warm — retry`));
|
|
1151
|
+
entry.reject(new Error(restartSuppressed ? `${this.errorPrefix} request "${command}" timed out after ${effectiveTimeoutMs}ms; automatic timeout restart already attempted; bridge kept warm to finish startup. Retry later or restart the host explicitly if it remains unresponsive. A timed-out mutation may still complete; inspect before repeating it.` : `${this.errorPrefix} request "${command}" timed out after ${effectiveTimeoutMs}ms (bridge busy/under load); bridge kept warm — retry`));
|
|
984
1152
|
return;
|
|
985
1153
|
}
|
|
986
1154
|
entry.reject(new Error(`${this.errorPrefix} Request "${command}" (id=${id}) timed out after ${effectiveTimeoutMs}ms`));
|
|
@@ -1117,7 +1285,7 @@ var init_bridge = __esm(() => {
|
|
|
1117
1285
|
this.spawnedBinaryFingerprint = null;
|
|
1118
1286
|
this.clearRestartResetTimer();
|
|
1119
1287
|
this.configureWarningClients.clear();
|
|
1120
|
-
this.rejectAllPending(new
|
|
1288
|
+
this.rejectAllPending(new BridgeTransportUnknownOutcomeError(`${this.errorPrefix} Bridge shutting down`));
|
|
1121
1289
|
if (this.process) {
|
|
1122
1290
|
const proc = this.process;
|
|
1123
1291
|
this.process = null;
|
|
@@ -1172,7 +1340,7 @@ var init_bridge = __esm(() => {
|
|
|
1172
1340
|
this.lastBinaryFingerprintCheckAt = 0;
|
|
1173
1341
|
this._retiringDueToBinaryChange = false;
|
|
1174
1342
|
this.clearRestartResetTimer();
|
|
1175
|
-
this.rejectAllPending(new
|
|
1343
|
+
this.rejectAllPending(new BridgeTransportUnknownOutcomeError(`${this.errorPrefix} Bridge restarting with updated binary: ${newBinaryPath}`));
|
|
1176
1344
|
if (!this.process)
|
|
1177
1345
|
return;
|
|
1178
1346
|
const proc = this.process;
|
|
@@ -1215,11 +1383,11 @@ var init_bridge = __esm(() => {
|
|
|
1215
1383
|
})();
|
|
1216
1384
|
const useFastembedBackend = semanticBackend === undefined || semanticBackend === "fastembed" || semanticBackend === "";
|
|
1217
1385
|
const ortDir = typeof this.configOverrides._ort_dylib_dir === "string" && useFastembedBackend ? this.configOverrides._ort_dylib_dir : null;
|
|
1218
|
-
const ortLibraryPath = ortDir == null ? null :
|
|
1386
|
+
const ortLibraryPath = ortDir == null ? null : join3(ortDir, this.platform === "win32" ? "onnxruntime.dll" : this.platform === "darwin" ? "libonnxruntime.dylib" : "libonnxruntime.so");
|
|
1219
1387
|
const env = { ...process.env };
|
|
1220
1388
|
this.logVia(`bridge.spawnProcess: useFastembedBackend=${useFastembedBackend}, ` + `parentORT=${process.env.ORT_DYLIB_PATH ?? "(unset)"}, ` + `ortLibraryPath=${ortLibraryPath ?? "(none)"}`);
|
|
1221
1389
|
if (useFastembedBackend) {
|
|
1222
|
-
env.FASTEMBED_CACHE_DIR = process.env.FASTEMBED_CACHE_DIR || (typeof this.configOverrides.storage_dir === "string" ?
|
|
1390
|
+
env.FASTEMBED_CACHE_DIR = process.env.FASTEMBED_CACHE_DIR || (typeof this.configOverrides.storage_dir === "string" ? join3(this.configOverrides.storage_dir, "semantic", "models") : join3(homedir4() || "", ".cache", "fastembed"));
|
|
1223
1391
|
if (process.env.ORT_DYLIB_PATH) {
|
|
1224
1392
|
this.logVia(`ORT_DYLIB_PATH inherited from parent env: ${process.env.ORT_DYLIB_PATH}`);
|
|
1225
1393
|
} else if (ortLibraryPath) {
|
|
@@ -1303,8 +1471,8 @@ var init_bridge = __esm(() => {
|
|
|
1303
1471
|
this.processGeneration += 1;
|
|
1304
1472
|
this.recordSpawnedBinaryFingerprint();
|
|
1305
1473
|
this.lastBinaryFingerprintCheckAt = Date.now();
|
|
1306
|
-
this.
|
|
1307
|
-
this.
|
|
1474
|
+
this.stdoutPending = [];
|
|
1475
|
+
this.stdoutPendingLength = 0;
|
|
1308
1476
|
this.stderrBuffer = "";
|
|
1309
1477
|
this.lastChildActivityAt = 0;
|
|
1310
1478
|
this.consecutiveRequestTimeouts = 0;
|
|
@@ -1362,41 +1530,43 @@ var init_bridge = __esm(() => {
|
|
|
1362
1530
|
${tail}`;
|
|
1363
1531
|
}
|
|
1364
1532
|
onStdoutData(data) {
|
|
1365
|
-
if (this.
|
|
1366
|
-
this.compactStdoutBuffer();
|
|
1367
|
-
}
|
|
1368
|
-
this.stdoutBuffer += data;
|
|
1369
|
-
if (this.stdoutBuffer.length - this.stdoutReadOffset > MAX_STDOUT_BUFFER) {
|
|
1533
|
+
if (this.stdoutPendingLength + data.length > MAX_STDOUT_BUFFER) {
|
|
1370
1534
|
this.handleCrash(new Error(`aft bridge stdout buffer exceeded ${MAX_STDOUT_BUFFER} bytes — killing bridge`));
|
|
1371
1535
|
return;
|
|
1372
1536
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1537
|
+
this.stdoutScannedChars += data.length;
|
|
1538
|
+
const generation = this.processGeneration;
|
|
1539
|
+
let start = 0;
|
|
1540
|
+
let newlineIdx = data.indexOf(`
|
|
1541
|
+
`);
|
|
1542
|
+
while (newlineIdx !== -1) {
|
|
1543
|
+
let line = data.slice(start, newlineIdx);
|
|
1544
|
+
if (this.stdoutPending.length > 0) {
|
|
1545
|
+
this.stdoutPending.push(line);
|
|
1546
|
+
line = this.stdoutPending.join("");
|
|
1547
|
+
this.stdoutPending = [];
|
|
1548
|
+
this.stdoutPendingLength = 0;
|
|
1549
|
+
}
|
|
1550
|
+
start = newlineIdx + 1;
|
|
1551
|
+
line = line.trim();
|
|
1378
1552
|
if (line) {
|
|
1379
1553
|
this.processStdoutLine(line);
|
|
1554
|
+
if (this.processGeneration !== generation)
|
|
1555
|
+
return;
|
|
1380
1556
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
}
|
|
1557
|
+
newlineIdx = data.indexOf(`
|
|
1558
|
+
`, start);
|
|
1384
1559
|
}
|
|
1385
|
-
if (
|
|
1386
|
-
|
|
1387
|
-
this.
|
|
1560
|
+
if (start < data.length) {
|
|
1561
|
+
const rest = start === 0 ? data : data.slice(start);
|
|
1562
|
+
this.stdoutPending.push(rest);
|
|
1563
|
+
this.stdoutPendingLength += rest.length;
|
|
1388
1564
|
}
|
|
1389
1565
|
}
|
|
1390
|
-
compactStdoutBuffer() {
|
|
1391
|
-
if (this.stdoutReadOffset === 0)
|
|
1392
|
-
return;
|
|
1393
|
-
this.stdoutBuffer = this.stdoutBuffer.slice(this.stdoutReadOffset);
|
|
1394
|
-
this.stdoutReadOffset = 0;
|
|
1395
|
-
}
|
|
1396
1566
|
flushStdoutBuffer() {
|
|
1397
|
-
const line = this.
|
|
1398
|
-
this.
|
|
1399
|
-
this.
|
|
1567
|
+
const line = this.stdoutPending.join("").trim();
|
|
1568
|
+
this.stdoutPending = [];
|
|
1569
|
+
this.stdoutPendingLength = 0;
|
|
1400
1570
|
if (!line)
|
|
1401
1571
|
return;
|
|
1402
1572
|
this.processStdoutLine(line);
|
|
@@ -1463,6 +1633,17 @@ var init_bridge = __esm(() => {
|
|
|
1463
1633
|
clearTimeout(entry.timer);
|
|
1464
1634
|
entry.onSettled?.();
|
|
1465
1635
|
this.consecutiveRequestTimeouts = 0;
|
|
1636
|
+
if (response.success !== false && ![
|
|
1637
|
+
"configure",
|
|
1638
|
+
"version",
|
|
1639
|
+
"status",
|
|
1640
|
+
"ping",
|
|
1641
|
+
"bash_drain_completions",
|
|
1642
|
+
"bash_ack_completions",
|
|
1643
|
+
"cancel_request"
|
|
1644
|
+
].includes(entry.command)) {
|
|
1645
|
+
this.timeoutRestartAwaitingRecovery = false;
|
|
1646
|
+
}
|
|
1466
1647
|
this.scheduleRestartCountReset();
|
|
1467
1648
|
this.accountForBashTaskResponse(entry.command, response);
|
|
1468
1649
|
entry.resolve(response);
|
|
@@ -1470,7 +1651,8 @@ var init_bridge = __esm(() => {
|
|
|
1470
1651
|
this.logVia(`Ignoring unknown stdout push frame type: ${response.type}`);
|
|
1471
1652
|
}
|
|
1472
1653
|
} catch (_err) {
|
|
1473
|
-
|
|
1654
|
+
const quoted = line.length > MALFORMED_STDOUT_LOG_CHARS ? `${line.slice(0, MALFORMED_STDOUT_LOG_CHARS)}… (${line.length} chars)` : line;
|
|
1655
|
+
this.warnVia(`Failed to parse stdout line: ${quoted}`);
|
|
1474
1656
|
}
|
|
1475
1657
|
}
|
|
1476
1658
|
accountForBashTaskResponse(command, response) {
|
|
@@ -1487,6 +1669,7 @@ var init_bridge = __esm(() => {
|
|
|
1487
1669
|
}
|
|
1488
1670
|
handleTimeout(trigger, triggeringSessionId) {
|
|
1489
1671
|
this.consecutiveRequestTimeouts = 0;
|
|
1672
|
+
this.timeoutRestartAwaitingRecovery = true;
|
|
1490
1673
|
this.spawnedBinaryFingerprint = null;
|
|
1491
1674
|
const abortedSiblings = Array.from(this.pending, ([requestId, entry]) => ({
|
|
1492
1675
|
request_id: requestId,
|
|
@@ -1573,55 +1756,57 @@ var init_bridge = __esm(() => {
|
|
|
1573
1756
|
});
|
|
1574
1757
|
|
|
1575
1758
|
// ../aft-bridge/dist/cache-paths.js
|
|
1576
|
-
import { homedir as
|
|
1577
|
-
import { join as
|
|
1759
|
+
import { homedir as homedir5 } from "node:os";
|
|
1760
|
+
import { join as join4 } from "node:path";
|
|
1578
1761
|
function homeDir2(env) {
|
|
1579
|
-
return (process.platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) ||
|
|
1762
|
+
return (process.platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) || homedir5();
|
|
1580
1763
|
}
|
|
1581
|
-
function getOpenCodeCacheRoot(env = process.env, home =
|
|
1582
|
-
return
|
|
1764
|
+
function getOpenCodeCacheRoot(env = process.env, home = homedir5()) {
|
|
1765
|
+
return join4(env.XDG_CACHE_HOME || join4(home, ".cache"), "opencode");
|
|
1583
1766
|
}
|
|
1584
|
-
function getOpenCodeConfigRoot(env = process.env, home =
|
|
1585
|
-
return
|
|
1767
|
+
function getOpenCodeConfigRoot(env = process.env, home = homedir5()) {
|
|
1768
|
+
return join4(env.XDG_CONFIG_HOME || join4(home, ".config"), "opencode");
|
|
1586
1769
|
}
|
|
1587
1770
|
function getAftCacheRoot(env = process.env) {
|
|
1588
1771
|
if (env.AFT_CACHE_DIR)
|
|
1589
1772
|
return env.AFT_CACHE_DIR;
|
|
1590
1773
|
if (process.platform === "win32") {
|
|
1591
|
-
const base = env.LOCALAPPDATA || env.APPDATA ||
|
|
1592
|
-
return
|
|
1774
|
+
const base = env.LOCALAPPDATA || env.APPDATA || join4(homeDir2(env), "AppData", "Local");
|
|
1775
|
+
return join4(base, "aft");
|
|
1593
1776
|
}
|
|
1594
|
-
const base = env.XDG_CACHE_HOME ||
|
|
1595
|
-
return
|
|
1777
|
+
const base = env.XDG_CACHE_HOME || join4(homeDir2(env), ".cache");
|
|
1778
|
+
return join4(base, "aft");
|
|
1596
1779
|
}
|
|
1597
1780
|
function getAftBinaryCacheDir(env = process.env) {
|
|
1598
|
-
return
|
|
1781
|
+
return join4(getAftCacheRoot(env), "bin");
|
|
1599
1782
|
}
|
|
1600
1783
|
function getAftLspPackagesDir(env = process.env) {
|
|
1601
|
-
return
|
|
1784
|
+
return join4(getAftCacheRoot(env), "lsp-packages");
|
|
1602
1785
|
}
|
|
1603
1786
|
function getAftLspBinariesDir(env = process.env) {
|
|
1604
|
-
return
|
|
1787
|
+
return join4(getAftCacheRoot(env), "lsp-binaries");
|
|
1605
1788
|
}
|
|
1606
1789
|
var init_cache_paths = () => {};
|
|
1607
1790
|
|
|
1608
1791
|
// ../aft-bridge/dist/callgraph-format.js
|
|
1609
|
-
var init_callgraph_format = () => {
|
|
1792
|
+
var init_callgraph_format = __esm(() => {
|
|
1793
|
+
init_path_display();
|
|
1794
|
+
});
|
|
1610
1795
|
// ../aft-bridge/dist/config-error.js
|
|
1611
|
-
import { homedir as
|
|
1612
|
-
import { isAbsolute, join as
|
|
1796
|
+
import { homedir as homedir6 } from "node:os";
|
|
1797
|
+
import { isAbsolute as isAbsolute2, join as join5 } from "node:path";
|
|
1613
1798
|
function formatConfigErrorMessage(detail) {
|
|
1614
1799
|
const trimmed = detail.trim();
|
|
1615
1800
|
const sentence = /[.!?]$/.test(trimmed) ? trimmed : `${trimmed}.`;
|
|
1616
1801
|
return `${sentence} ${CONFIG_ERROR_RESTART_NOTE}`;
|
|
1617
1802
|
}
|
|
1618
|
-
function resolveSubcConnectionFilePath(raw, home =
|
|
1803
|
+
function resolveSubcConnectionFilePath(raw, home = homedir6()) {
|
|
1619
1804
|
const trimmed = raw.trim();
|
|
1620
1805
|
if (trimmed.startsWith("~"))
|
|
1621
|
-
return
|
|
1622
|
-
if (
|
|
1806
|
+
return join5(home, trimmed.slice(1).replace(/^[/\\]/, ""));
|
|
1807
|
+
if (isAbsolute2(trimmed))
|
|
1623
1808
|
return trimmed;
|
|
1624
|
-
return
|
|
1809
|
+
return join5(home, trimmed);
|
|
1625
1810
|
}
|
|
1626
1811
|
function formatSubcConnectionMissingMessage(raw, resolved) {
|
|
1627
1812
|
return `subc.connection_file is set to "${raw.trim()}" (resolved: ${resolved}) but no subc ` + `connection file exists there. Start the Subconscious daemon, correct the path, ` + `or remove subc.connection_file from your user config to use the standalone bridge.`;
|
|
@@ -1637,7 +1822,7 @@ var init_config_keys = () => {};
|
|
|
1637
1822
|
|
|
1638
1823
|
// ../aft-bridge/dist/config-tiers.js
|
|
1639
1824
|
import { existsSync, readFileSync as readFileSync2 } from "node:fs";
|
|
1640
|
-
import { resolve as
|
|
1825
|
+
import { resolve as resolve3 } from "node:path";
|
|
1641
1826
|
function readConfigTiers(opts) {
|
|
1642
1827
|
const tiers = [];
|
|
1643
1828
|
try {
|
|
@@ -1645,7 +1830,7 @@ function readConfigTiers(opts) {
|
|
|
1645
1830
|
const doc = readFileSync2(opts.userConfigPath, "utf-8");
|
|
1646
1831
|
tiers.push({
|
|
1647
1832
|
tier: "user",
|
|
1648
|
-
source:
|
|
1833
|
+
source: resolve3(opts.userConfigPath),
|
|
1649
1834
|
doc
|
|
1650
1835
|
});
|
|
1651
1836
|
}
|
|
@@ -1655,7 +1840,7 @@ function readConfigTiers(opts) {
|
|
|
1655
1840
|
const doc = readFileSync2(opts.projectConfigPath, "utf-8");
|
|
1656
1841
|
tiers.push({
|
|
1657
1842
|
tier: "project",
|
|
1658
|
-
source:
|
|
1843
|
+
source: resolve3(opts.projectConfigPath),
|
|
1659
1844
|
doc
|
|
1660
1845
|
});
|
|
1661
1846
|
}
|
|
@@ -1757,9 +1942,9 @@ var init_version_probe = __esm(() => {
|
|
|
1757
1942
|
|
|
1758
1943
|
// ../aft-bridge/dist/downloader.js
|
|
1759
1944
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
1760
|
-
import { chmodSync, closeSync, copyFileSync, createWriteStream, existsSync as existsSync2, mkdirSync, openSync, readdirSync, readFileSync as readFileSync3, renameSync as renameSync2, rmSync, statSync as statSync2, unlinkSync as unlinkSync2, writeSync } from "node:fs";
|
|
1945
|
+
import { chmodSync, closeSync as closeSync2, copyFileSync, createWriteStream, existsSync as existsSync2, mkdirSync as mkdirSync2, openSync as openSync2, readdirSync, readFileSync as readFileSync3, renameSync as renameSync2, rmSync, statSync as statSync2, unlinkSync as unlinkSync2, writeSync } from "node:fs";
|
|
1761
1946
|
import { hostname } from "node:os";
|
|
1762
|
-
import { join as
|
|
1947
|
+
import { join as join6 } from "node:path";
|
|
1763
1948
|
import { Readable } from "node:stream";
|
|
1764
1949
|
import { pipeline } from "node:stream/promises";
|
|
1765
1950
|
function expectedVersionFromTag(tag) {
|
|
@@ -1783,7 +1968,7 @@ function getBinaryName() {
|
|
|
1783
1968
|
function getCachedBinaryPath(version) {
|
|
1784
1969
|
if (!version)
|
|
1785
1970
|
return null;
|
|
1786
|
-
const binaryPath =
|
|
1971
|
+
const binaryPath = join6(getAftBinaryCacheDir(), version, getBinaryName());
|
|
1787
1972
|
return existsSync2(binaryPath) ? binaryPath : null;
|
|
1788
1973
|
}
|
|
1789
1974
|
async function downloadBinary(version) {
|
|
@@ -1800,16 +1985,16 @@ async function downloadBinary(version) {
|
|
|
1800
1985
|
return null;
|
|
1801
1986
|
}
|
|
1802
1987
|
const tag = rawTag.startsWith("v") ? rawTag : `v${rawTag}`;
|
|
1803
|
-
const versionedCacheDir =
|
|
1988
|
+
const versionedCacheDir = join6(getAftBinaryCacheDir(), tag);
|
|
1804
1989
|
const binaryName = getBinaryName();
|
|
1805
|
-
const binaryPath =
|
|
1990
|
+
const binaryPath = join6(versionedCacheDir, binaryName);
|
|
1806
1991
|
if (existsSync2(binaryPath) && await isExpectedCachedBinary(binaryPath, tag)) {
|
|
1807
1992
|
return binaryPath;
|
|
1808
1993
|
}
|
|
1809
1994
|
const downloadUrl = `https://github.com/${REPO}/releases/download/${tag}/${assetName}`;
|
|
1810
1995
|
const checksumUrl = `https://github.com/${REPO}/releases/download/${tag}/checksums.sha256`;
|
|
1811
1996
|
log(`Downloading AFT binary (${tag}) for ${platformKey}...`);
|
|
1812
|
-
const lockPath =
|
|
1997
|
+
const lockPath = join6(versionedCacheDir, ".download.lock");
|
|
1813
1998
|
let releaseLock = null;
|
|
1814
1999
|
let binaryController = null;
|
|
1815
2000
|
let checksumController = null;
|
|
@@ -1843,7 +2028,7 @@ async function downloadBinary(version) {
|
|
|
1843
2028
|
process.once("exit", handleExit);
|
|
1844
2029
|
try {
|
|
1845
2030
|
if (!existsSync2(versionedCacheDir)) {
|
|
1846
|
-
|
|
2031
|
+
mkdirSync2(versionedCacheDir, { recursive: true });
|
|
1847
2032
|
}
|
|
1848
2033
|
releaseLock = await acquireDownloadLock(lockPath);
|
|
1849
2034
|
sweepStaleDownloadTemps(versionedCacheDir, binaryName);
|
|
@@ -2033,7 +2218,7 @@ function sweepStaleDownloadTemps(versionedCacheDir, binaryName) {
|
|
|
2033
2218
|
if (!entry.isFile() || !entry.name.startsWith(tempPrefix) || !entry.name.endsWith(".tmp")) {
|
|
2034
2219
|
continue;
|
|
2035
2220
|
}
|
|
2036
|
-
const tempPath =
|
|
2221
|
+
const tempPath = join6(versionedCacheDir, entry.name);
|
|
2037
2222
|
const ageMs = Date.now() - statSync2(tempPath).mtimeMs;
|
|
2038
2223
|
if (Math.abs(ageMs) > DOWNLOAD_LOCK_STALE_MS)
|
|
2039
2224
|
unlinkSync2(tempPath);
|
|
@@ -2048,11 +2233,11 @@ async function acquireDownloadLock(lockPath, timing = {}) {
|
|
|
2048
2233
|
while (true) {
|
|
2049
2234
|
try {
|
|
2050
2235
|
const owner = createDownloadLockOwner();
|
|
2051
|
-
const fd =
|
|
2236
|
+
const fd = openSync2(lockPath, "wx");
|
|
2052
2237
|
try {
|
|
2053
2238
|
writeSync(fd, owner);
|
|
2054
2239
|
} finally {
|
|
2055
|
-
|
|
2240
|
+
closeSync2(fd);
|
|
2056
2241
|
}
|
|
2057
2242
|
return () => {
|
|
2058
2243
|
try {
|
|
@@ -2132,13 +2317,86 @@ var init_downloader = __esm(() => {
|
|
|
2132
2317
|
ensureBinaryInFlight = new Map;
|
|
2133
2318
|
});
|
|
2134
2319
|
|
|
2320
|
+
// ../aft-bridge/dist/private-storage.js
|
|
2321
|
+
import { closeSync as closeSync3, constants, copyFileSync as copyFileSync2, fchmodSync, fstatSync, lstatSync, mkdirSync as mkdirSync3, openSync as openSync3, readSync as readSync2, writeSync as writeSync2 } from "node:fs";
|
|
2322
|
+
import { isAbsolute as isAbsolute3, join as join7, parse, relative as relative2, resolve as resolve4, sep } from "node:path";
|
|
2323
|
+
function privateMkdirSync(path, recursive = true) {
|
|
2324
|
+
mkdirSync3(path, {
|
|
2325
|
+
recursive,
|
|
2326
|
+
...process.platform === "win32" ? {} : { mode: PRIVATE_DIRECTORY_MODE }
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
function privateCopyFileSync(source, destination) {
|
|
2330
|
+
if (process.platform === "win32") {
|
|
2331
|
+
copyFileSync2(source, destination);
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
const input = openSync3(source, "r");
|
|
2335
|
+
let output;
|
|
2336
|
+
try {
|
|
2337
|
+
output = openSync3(destination, "wx", PRIVATE_FILE_MODE);
|
|
2338
|
+
const buffer = Buffer.allocUnsafe(64 * 1024);
|
|
2339
|
+
for (;; ) {
|
|
2340
|
+
const bytes = readSync2(input, buffer);
|
|
2341
|
+
if (bytes === 0)
|
|
2342
|
+
break;
|
|
2343
|
+
let offset = 0;
|
|
2344
|
+
while (offset < bytes)
|
|
2345
|
+
offset += writeSync2(output, buffer, offset, bytes - offset);
|
|
2346
|
+
}
|
|
2347
|
+
} finally {
|
|
2348
|
+
closeSync3(input);
|
|
2349
|
+
if (output !== undefined)
|
|
2350
|
+
closeSync3(output);
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
function openPrivateStorageDir(root, path = root) {
|
|
2354
|
+
const base = resolve4(root);
|
|
2355
|
+
if (!root || base === parse(base).root) {
|
|
2356
|
+
throw new Error(`refusing filesystem root as private storage: ${base}`);
|
|
2357
|
+
}
|
|
2358
|
+
const rel = relative2(base, resolve4(path));
|
|
2359
|
+
if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute3(rel))
|
|
2360
|
+
return;
|
|
2361
|
+
privateMkdirSync(path);
|
|
2362
|
+
if (process.platform === "win32")
|
|
2363
|
+
return;
|
|
2364
|
+
let current = base;
|
|
2365
|
+
for (const component of ["", ...rel.split(sep).filter(Boolean)]) {
|
|
2366
|
+
current = join7(current, component);
|
|
2367
|
+
let fd;
|
|
2368
|
+
try {
|
|
2369
|
+
if (lstatSync(current).isSymbolicLink())
|
|
2370
|
+
return;
|
|
2371
|
+
fd = openSync3(current, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
2372
|
+
if ((fstatSync(fd).mode & 63) !== 0)
|
|
2373
|
+
fchmodSync(fd, PRIVATE_DIRECTORY_MODE);
|
|
2374
|
+
} catch (error) {
|
|
2375
|
+
if (!warned.has(current)) {
|
|
2376
|
+
warned.add(current);
|
|
2377
|
+
process.stderr.write(`[aft] could not tighten private storage ${current}: ${String(error)}; continuing
|
|
2378
|
+
`);
|
|
2379
|
+
}
|
|
2380
|
+
return;
|
|
2381
|
+
} finally {
|
|
2382
|
+
if (fd !== undefined)
|
|
2383
|
+
closeSync3(fd);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
var PRIVATE_FILE_MODE = 384, PRIVATE_DIRECTORY_MODE = 448, warned;
|
|
2388
|
+
var init_private_storage = __esm(() => {
|
|
2389
|
+
warned = new Set;
|
|
2390
|
+
});
|
|
2391
|
+
|
|
2135
2392
|
// ../aft-bridge/dist/durable-log.js
|
|
2136
2393
|
var DEFAULT_LOG_BYTES;
|
|
2137
2394
|
var init_durable_log = __esm(() => {
|
|
2395
|
+
init_private_storage();
|
|
2138
2396
|
init_storage_paths();
|
|
2139
2397
|
DEFAULT_LOG_BYTES = 32 * 1024 * 1024;
|
|
2140
2398
|
});
|
|
2141
|
-
// ../../node_modules/.bun/@cortexkit+subc-client@0.
|
|
2399
|
+
// ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/envelope.js
|
|
2142
2400
|
var MAX_FRAME_BODY_LEN, FrameType, FRAME_TYPE_MAX, Priority, AdmissionClass;
|
|
2143
2401
|
var init_envelope = __esm(() => {
|
|
2144
2402
|
MAX_FRAME_BODY_LEN = 64 * 1024 * 1024;
|
|
@@ -2169,7 +2427,7 @@ var init_envelope = __esm(() => {
|
|
|
2169
2427
|
})(AdmissionClass || (AdmissionClass = {}));
|
|
2170
2428
|
});
|
|
2171
2429
|
|
|
2172
|
-
// ../../node_modules/.bun/@cortexkit+subc-client@0.
|
|
2430
|
+
// ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/socket.js
|
|
2173
2431
|
var WRITE_BORROWED, WRITE_TRACKED_BORROWED;
|
|
2174
2432
|
var init_socket = __esm(() => {
|
|
2175
2433
|
init_envelope();
|
|
@@ -2177,47 +2435,78 @@ var init_socket = __esm(() => {
|
|
|
2177
2435
|
WRITE_TRACKED_BORROWED = Symbol("subc.socket.writeTrackedBorrowed");
|
|
2178
2436
|
});
|
|
2179
2437
|
|
|
2180
|
-
// ../../node_modules/.bun/@cortexkit+subc-client@0.
|
|
2438
|
+
// ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/auth.js
|
|
2181
2439
|
var init_auth = __esm(() => {
|
|
2182
2440
|
init_socket();
|
|
2183
2441
|
});
|
|
2184
2442
|
|
|
2185
|
-
// ../../node_modules/.bun/@cortexkit+subc-client@0.
|
|
2443
|
+
// ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/connection-file.js
|
|
2186
2444
|
var init_connection_file = __esm(() => {
|
|
2187
2445
|
init_envelope();
|
|
2188
2446
|
});
|
|
2189
2447
|
|
|
2190
|
-
// ../../node_modules/.bun/@cortexkit+subc-client@0.
|
|
2448
|
+
// ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/launch-nonce.js
|
|
2449
|
+
var PROCESS_CELL_KEY, U64_MAX, I32_MAX, RedactedLaunchNonce;
|
|
2450
|
+
var init_launch_nonce = __esm(() => {
|
|
2451
|
+
PROCESS_CELL_KEY = Symbol.for("@cortexkit/subc-client/launch-nonce/v1");
|
|
2452
|
+
U64_MAX = (1n << 64n) - 1n;
|
|
2453
|
+
I32_MAX = 2 ** 31 - 1;
|
|
2454
|
+
RedactedLaunchNonce = class RedactedLaunchNonce {
|
|
2455
|
+
source;
|
|
2456
|
+
#value;
|
|
2457
|
+
constructor(value, source) {
|
|
2458
|
+
this.#value = value;
|
|
2459
|
+
this.source = source;
|
|
2460
|
+
Object.freeze(this);
|
|
2461
|
+
}
|
|
2462
|
+
get value() {
|
|
2463
|
+
return this.#value;
|
|
2464
|
+
}
|
|
2465
|
+
toJSON() {
|
|
2466
|
+
return { source: this.source };
|
|
2467
|
+
}
|
|
2468
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
2469
|
+
return `LaunchNonce { value: <${this.#value.length} bytes redacted>, source: "${this.source}" }`;
|
|
2470
|
+
}
|
|
2471
|
+
};
|
|
2472
|
+
});
|
|
2473
|
+
|
|
2474
|
+
// ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/route-handle.js
|
|
2191
2475
|
var connectionToken, reverseRequests;
|
|
2192
2476
|
var init_route_handle = __esm(() => {
|
|
2193
2477
|
connectionToken = new WeakMap;
|
|
2194
2478
|
reverseRequests = new WeakMap;
|
|
2195
2479
|
});
|
|
2196
2480
|
|
|
2197
|
-
// ../../node_modules/.bun/@cortexkit+subc-client@0.
|
|
2481
|
+
// ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/client.js
|
|
2198
2482
|
import { debuglog } from "node:util";
|
|
2199
|
-
var debug, EMPTY_BODY;
|
|
2483
|
+
var debug, EMPTY_BODY, errorFrameFlags, ROUTE_OPEN_ADMISSION_PRESSURE_REASONS;
|
|
2200
2484
|
var init_client = __esm(() => {
|
|
2201
2485
|
init_auth();
|
|
2202
2486
|
init_connection_file();
|
|
2203
2487
|
init_envelope();
|
|
2488
|
+
init_launch_nonce();
|
|
2204
2489
|
init_route_handle();
|
|
2205
2490
|
init_socket();
|
|
2491
|
+
init_launch_nonce();
|
|
2206
2492
|
debug = debuglog("subc-client");
|
|
2207
2493
|
EMPTY_BODY = new Uint8Array(0);
|
|
2494
|
+
errorFrameFlags = new WeakMap;
|
|
2495
|
+
ROUTE_OPEN_ADMISSION_PRESSURE_REASONS = new Set(["open_admission_full", "target_binds_full"]);
|
|
2208
2496
|
});
|
|
2209
2497
|
|
|
2210
|
-
// ../../node_modules/.bun/@cortexkit+subc-client@0.
|
|
2498
|
+
// ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/provider.js
|
|
2211
2499
|
var init_provider = __esm(() => {
|
|
2212
2500
|
init_auth();
|
|
2213
2501
|
init_client();
|
|
2214
2502
|
init_connection_file();
|
|
2215
2503
|
init_envelope();
|
|
2504
|
+
init_launch_nonce();
|
|
2216
2505
|
init_route_handle();
|
|
2217
2506
|
init_socket();
|
|
2218
2507
|
});
|
|
2219
2508
|
|
|
2220
|
-
// ../../node_modules/.bun/@cortexkit+subc-client@0.
|
|
2509
|
+
// ../../node_modules/.bun/@cortexkit+subc-client@0.20.0/node_modules/@cortexkit/subc-client/dist/index.js
|
|
2221
2510
|
var init_dist = __esm(() => {
|
|
2222
2511
|
init_client();
|
|
2223
2512
|
init_route_handle();
|
|
@@ -2225,6 +2514,7 @@ var init_dist = __esm(() => {
|
|
|
2225
2514
|
init_envelope();
|
|
2226
2515
|
init_auth();
|
|
2227
2516
|
init_socket();
|
|
2517
|
+
init_launch_nonce();
|
|
2228
2518
|
init_provider();
|
|
2229
2519
|
});
|
|
2230
2520
|
|
|
@@ -2647,7 +2937,7 @@ var init_lifecycle_registry = __esm(() => {
|
|
|
2647
2937
|
var init_project_identity = () => {};
|
|
2648
2938
|
|
|
2649
2939
|
// ../aft-bridge/dist/subc-transport.js
|
|
2650
|
-
var CALL_DEADLINE_EXPIRED, LOCALLY_SATISFIED_COMMANDS;
|
|
2940
|
+
var CALL_DEADLINE_EXPIRED, LOCALLY_SATISFIED_COMMANDS, dispatchProbes;
|
|
2651
2941
|
var init_subc_transport = __esm(() => {
|
|
2652
2942
|
init_dist();
|
|
2653
2943
|
init_active_logger();
|
|
@@ -2656,6 +2946,7 @@ var init_subc_transport = __esm(() => {
|
|
|
2656
2946
|
init_project_identity();
|
|
2657
2947
|
CALL_DEADLINE_EXPIRED = Symbol("call deadline expired");
|
|
2658
2948
|
LOCALLY_SATISFIED_COMMANDS = new Set(["configure"]);
|
|
2949
|
+
dispatchProbes = new Map;
|
|
2659
2950
|
});
|
|
2660
2951
|
|
|
2661
2952
|
// ../aft-bridge/dist/error-contract.js
|
|
@@ -2686,26 +2977,9 @@ function surfaceDisables(surface) {
|
|
|
2686
2977
|
return;
|
|
2687
2978
|
}
|
|
2688
2979
|
}
|
|
2689
|
-
function parseMinor(version) {
|
|
2690
|
-
const match = /^v?(\d+)\.(\d+)/.exec(version.trim());
|
|
2691
|
-
if (!match)
|
|
2692
|
-
return;
|
|
2693
|
-
return [Number(match[1]), Number(match[2])];
|
|
2694
|
-
}
|
|
2695
|
-
function policyPhaseForVersion(version) {
|
|
2696
|
-
const minor = parseMinor(version);
|
|
2697
|
-
if (!minor)
|
|
2698
|
-
return "window";
|
|
2699
|
-
const [major, min] = minor;
|
|
2700
|
-
const [rejectMajor, rejectMinor] = POLICY_REJECT_FROM_MINOR;
|
|
2701
|
-
return major > rejectMajor || major === rejectMajor && min >= rejectMinor ? "rejecting" : "window";
|
|
2702
|
-
}
|
|
2703
2980
|
function isRecord(value) {
|
|
2704
2981
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2705
2982
|
}
|
|
2706
|
-
function removed(old, replacement) {
|
|
2707
|
-
return `removed_config_key:${old}:use:${replacement}`;
|
|
2708
|
-
}
|
|
2709
2983
|
function hasPath(map, path) {
|
|
2710
2984
|
const dot = path.indexOf(".");
|
|
2711
2985
|
if (dot < 0)
|
|
@@ -2728,12 +3002,89 @@ function falseRuntimeGates(map) {
|
|
|
2728
3002
|
function sortedUnique(names) {
|
|
2729
3003
|
return [...new Set(names)].sort();
|
|
2730
3004
|
}
|
|
2731
|
-
function
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
3005
|
+
function recordRetired(out, prefix, key) {
|
|
3006
|
+
out.legacyInput = true;
|
|
3007
|
+
out.retiredKeys.push(`${prefix}${key}`);
|
|
3008
|
+
}
|
|
3009
|
+
function superseded(out, key, message) {
|
|
3010
|
+
out.warnings.push({ code: "superseded_legacy_config", key, message });
|
|
3011
|
+
}
|
|
3012
|
+
function nestedBool(map, container, leaf) {
|
|
3013
|
+
const inner = map[container];
|
|
3014
|
+
return isRecord(inner) && typeof inner[leaf] === "boolean" ? inner[leaf] : undefined;
|
|
3015
|
+
}
|
|
3016
|
+
function translateGithubAliases(map, prefix, out) {
|
|
3017
|
+
const masterOff = nestedBool(map, "github", "enabled") === false;
|
|
3018
|
+
for (const [alias, leaf, retiredKey] of [
|
|
3019
|
+
["gh_read", "read", "gh_read"],
|
|
3020
|
+
["gh_shim", "shim", "gh_shim.enabled"]
|
|
3021
|
+
]) {
|
|
3022
|
+
const aliasBlock = map[alias];
|
|
3023
|
+
const supplied = alias === "gh_read" ? Object.hasOwn(map, alias) : isRecord(aliasBlock) && Object.hasOwn(aliasBlock, "enabled");
|
|
3024
|
+
if (!supplied)
|
|
3025
|
+
continue;
|
|
3026
|
+
recordRetired(out, prefix, retiredKey);
|
|
3027
|
+
const aliasValue = isRecord(aliasBlock) && typeof aliasBlock.enabled === "boolean" ? aliasBlock.enabled : undefined;
|
|
3028
|
+
if (aliasValue !== undefined) {
|
|
3029
|
+
const canonical = nestedBool(map, "github", leaf);
|
|
3030
|
+
if (canonical !== undefined) {
|
|
3031
|
+
if (canonical !== aliasValue) {
|
|
3032
|
+
superseded(out, `${prefix}${retiredKey}`, `${alias}.enabled=${aliasValue} is ignored because github.${leaf}=${canonical} is set`);
|
|
3033
|
+
}
|
|
3034
|
+
} else if (masterOff) {
|
|
3035
|
+
if (aliasValue) {
|
|
3036
|
+
superseded(out, `${prefix}${retiredKey}`, `${alias}.enabled=true is ignored because github.enabled=false switches github.${leaf} off`);
|
|
3037
|
+
}
|
|
3038
|
+
} else {
|
|
3039
|
+
if (!Object.hasOwn(map, "github"))
|
|
3040
|
+
map.github = {};
|
|
3041
|
+
if (isRecord(map.github))
|
|
3042
|
+
map.github[leaf] = aliasValue;
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
if (alias === "gh_read") {
|
|
3046
|
+
delete map.gh_read;
|
|
3047
|
+
} else if (isRecord(aliasBlock)) {
|
|
3048
|
+
delete aliasBlock.enabled;
|
|
3049
|
+
if (Object.keys(aliasBlock).length === 0)
|
|
3050
|
+
delete map.gh_shim;
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
function takeNested(map, container, leaf) {
|
|
3055
|
+
const inner = map[container];
|
|
3056
|
+
if (!isRecord(inner) || !Object.hasOwn(inner, leaf))
|
|
3057
|
+
return { found: false };
|
|
3058
|
+
const value = inner[leaf];
|
|
3059
|
+
delete inner[leaf];
|
|
3060
|
+
if (Object.keys(inner).length === 0)
|
|
3061
|
+
delete map[container];
|
|
3062
|
+
return { found: true, value };
|
|
3063
|
+
}
|
|
3064
|
+
function translateInspectLspPaths(map, prefix, out) {
|
|
3065
|
+
const ttl = takeNested(map, "idle", "lsp_ttl_minutes");
|
|
3066
|
+
if (ttl.found) {
|
|
3067
|
+
recordRetired(out, prefix, "idle.lsp_ttl_minutes");
|
|
3068
|
+
if (isRecord(map.lsp) && map.lsp.idle_minutes !== undefined) {
|
|
3069
|
+
superseded(out, `${prefix}idle.lsp_ttl_minutes`, "idle.lsp_ttl_minutes is ignored because lsp.idle_minutes is set");
|
|
3070
|
+
} else {
|
|
3071
|
+
const raw = typeof ttl.value === "number" && Number.isSafeInteger(ttl.value) ? ttl.value : LSP_IDLE_MINUTES_DEFAULT;
|
|
3072
|
+
const minutes = Math.min(LSP_IDLE_MINUTES_MAX, Math.max(LSP_IDLE_MINUTES_MIN, raw));
|
|
3073
|
+
if (!Object.hasOwn(map, "lsp"))
|
|
3074
|
+
map.lsp = {};
|
|
3075
|
+
if (isRecord(map.lsp))
|
|
3076
|
+
map.lsp.idle_minutes = minutes;
|
|
3077
|
+
}
|
|
2736
3078
|
}
|
|
3079
|
+
for (const leaf of ["tier2_soft_deadline_ms", "max_drill_down_items"]) {
|
|
3080
|
+
if (takeNested(map, "inspect", leaf).found)
|
|
3081
|
+
recordRetired(out, prefix, `inspect.${leaf}`);
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
function translateBlock(map, userBase, blockLabel, out) {
|
|
3085
|
+
const prefix = blockLabel === "base" ? "" : `${blockLabel}.`;
|
|
3086
|
+
translateGithubAliases(map, prefix, out);
|
|
3087
|
+
translateInspectLspPaths(map, prefix, out);
|
|
2737
3088
|
let explicitList;
|
|
2738
3089
|
const rawList = map.disabled_tools;
|
|
2739
3090
|
if (Array.isArray(rawList) && rawList.every((entry) => typeof entry === "string")) {
|
|
@@ -2741,30 +3092,15 @@ function translateBlock(map, userBase, phase, blockLabel, out) {
|
|
|
2741
3092
|
const host = LEGACY_TOOL_ALIASES[name];
|
|
2742
3093
|
if (host === undefined)
|
|
2743
3094
|
return name;
|
|
2744
|
-
out
|
|
2745
|
-
if (phase === "rejecting")
|
|
2746
|
-
out.errors.push(removed(name, host));
|
|
3095
|
+
recordRetired(out, prefix, name);
|
|
2747
3096
|
return host;
|
|
2748
3097
|
});
|
|
2749
3098
|
}
|
|
2750
|
-
const
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
const gates = falseRuntimeGates(map);
|
|
2754
|
-
if (phase === "rejecting") {
|
|
2755
|
-
for (const path of suppliedPaths) {
|
|
2756
|
-
const replacement = RETIRED_PATHS.find(([old]) => old === path)?.[1] ?? "disabled_tools";
|
|
2757
|
-
out.errors.push(removed(path, replacement));
|
|
2758
|
-
}
|
|
2759
|
-
if (gates.length > 0 && explicitList === undefined) {
|
|
2760
|
-
out.warnings.push({
|
|
2761
|
-
code: "legacy_runtime_gate_runtime_only",
|
|
2762
|
-
key: blockLabel,
|
|
2763
|
-
message: `${gates.join(", ")} now restricts runtime behavior only and no longer removes tool registrations; list tools in disabled_tools to unregister them`
|
|
2764
|
-
});
|
|
2765
|
-
}
|
|
2766
|
-
return;
|
|
3099
|
+
for (const [path] of RETIRED_PATHS) {
|
|
3100
|
+
if (hasPath(map, path))
|
|
3101
|
+
recordRetired(out, prefix, path);
|
|
2767
3102
|
}
|
|
3103
|
+
const gates = falseRuntimeGates(map);
|
|
2768
3104
|
if (explicitList !== undefined)
|
|
2769
3105
|
map.disabled_tools = explicitList;
|
|
2770
3106
|
for (const [leaf, legacy, experimental] of INDEX_INPUTS) {
|
|
@@ -2791,19 +3127,11 @@ function translateBlock(map, userBase, phase, blockLabel, out) {
|
|
|
2791
3127
|
}
|
|
2792
3128
|
if (canonical !== undefined) {
|
|
2793
3129
|
if (canonical !== value) {
|
|
2794
|
-
out
|
|
2795
|
-
code: "superseded_legacy_config",
|
|
2796
|
-
key,
|
|
2797
|
-
message: `${key}=${value} is ignored because indexes.${leaf}=${canonical} is set`
|
|
2798
|
-
});
|
|
3130
|
+
superseded(out, key, `${key}=${value} is ignored because indexes.${leaf}=${canonical} is set`);
|
|
2799
3131
|
}
|
|
2800
3132
|
} else if (chosen !== undefined) {
|
|
2801
3133
|
if (chosen !== value) {
|
|
2802
|
-
out
|
|
2803
|
-
code: "superseded_legacy_config",
|
|
2804
|
-
key,
|
|
2805
|
-
message: `${key}=${value} is ignored because ${legacy}=${chosen} takes precedence`
|
|
2806
|
-
});
|
|
3134
|
+
superseded(out, key, `${key}=${value} is ignored because ${legacy}=${chosen} takes precedence`);
|
|
2807
3135
|
}
|
|
2808
3136
|
} else {
|
|
2809
3137
|
chosen = value;
|
|
@@ -2825,11 +3153,7 @@ function translateBlock(map, userBase, phase, blockLabel, out) {
|
|
|
2825
3153
|
if (!Object.hasOwn(github, leaf))
|
|
2826
3154
|
github[leaf] = false;
|
|
2827
3155
|
else if (github[leaf] === true) {
|
|
2828
|
-
out.
|
|
2829
|
-
code: "superseded_legacy_config",
|
|
2830
|
-
key: "github.enabled",
|
|
2831
|
-
message: `github.enabled=false is ignored for github.${leaf} because github.${leaf}=true is set`
|
|
2832
|
-
});
|
|
3156
|
+
superseded(out, "github.enabled", `github.enabled=false is ignored for github.${leaf} because github.${leaf}=true is set`);
|
|
2833
3157
|
}
|
|
2834
3158
|
}
|
|
2835
3159
|
}
|
|
@@ -2870,21 +3194,19 @@ function translateBlock(map, userBase, phase, blockLabel, out) {
|
|
|
2870
3194
|
message: RETIRED_ENABLED_FALSE_INDEXES_NOTE
|
|
2871
3195
|
});
|
|
2872
3196
|
}
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
for (const name of BASH_GATE_DISABLES)
|
|
2880
|
-
generated.add(name);
|
|
3197
|
+
if (gates.length > 0 && explicitList === undefined) {
|
|
3198
|
+
out.warnings.push({
|
|
3199
|
+
code: "legacy_runtime_gate_runtime_only",
|
|
3200
|
+
key: blockLabel,
|
|
3201
|
+
message: `${gates.join(", ")} now restricts runtime behavior only and no longer removes tool registrations; list tools in disabled_tools to unregister them`
|
|
3202
|
+
});
|
|
2881
3203
|
}
|
|
2882
3204
|
if (explicitList !== undefined) {
|
|
2883
3205
|
if (explicitSurface || generated.size > 0) {
|
|
2884
3206
|
out.warnings.push({
|
|
2885
3207
|
code: "superseded_legacy_config",
|
|
2886
3208
|
key: blockLabel,
|
|
2887
|
-
message: "disabled_tools is set explicitly, so legacy tool_surface/hoist_builtin_tools/enabled
|
|
3209
|
+
message: "disabled_tools is set explicitly, so legacy tool_surface/hoist_builtin_tools/enabled do not change registration",
|
|
2888
3210
|
once: true
|
|
2889
3211
|
});
|
|
2890
3212
|
}
|
|
@@ -2901,29 +3223,22 @@ function translateBlock(map, userBase, phase, blockLabel, out) {
|
|
|
2901
3223
|
}
|
|
2902
3224
|
if (list !== undefined)
|
|
2903
3225
|
map.disabled_tools = list;
|
|
2904
|
-
if (gates.length > 0) {
|
|
2905
|
-
out.warnings.push({
|
|
2906
|
-
code: "legacy_runtime_gate_requires_fix",
|
|
2907
|
-
key: blockLabel,
|
|
2908
|
-
message: `${gates.join(", ")} still removes tool registrations during this release only; run \`npx @cortexkit/aft doctor --fix\` to record the choice in disabled_tools`
|
|
2909
|
-
});
|
|
2910
|
-
}
|
|
2911
3226
|
}
|
|
2912
|
-
function translateConfigDocument(map,
|
|
3227
|
+
function translateConfigDocument(map, tier) {
|
|
2913
3228
|
const out = {
|
|
2914
|
-
errors: [],
|
|
2915
3229
|
warnings: [],
|
|
2916
3230
|
legacyInput: false,
|
|
3231
|
+
retiredKeys: [],
|
|
2917
3232
|
retiredEnabledFalse: false
|
|
2918
3233
|
};
|
|
2919
|
-
translateBlock(map, tier === "user",
|
|
3234
|
+
translateBlock(map, tier === "user", "base", out);
|
|
2920
3235
|
if (isRecord(map.harnesses)) {
|
|
2921
3236
|
for (const [name, block] of Object.entries(map.harnesses)) {
|
|
2922
3237
|
if (isRecord(block))
|
|
2923
|
-
translateBlock(block, false,
|
|
3238
|
+
translateBlock(block, false, `harnesses.${name}`, out);
|
|
2924
3239
|
}
|
|
2925
3240
|
}
|
|
2926
|
-
out.
|
|
3241
|
+
out.retiredKeys = sortedUnique(out.retiredKeys);
|
|
2927
3242
|
return out;
|
|
2928
3243
|
}
|
|
2929
3244
|
function canonicalJson(value) {
|
|
@@ -2950,7 +3265,7 @@ function mergeIndexes(base, override, restricted) {
|
|
|
2950
3265
|
}
|
|
2951
3266
|
return merged;
|
|
2952
3267
|
}
|
|
2953
|
-
var CANONICAL_TOOLS, HOST_TOOL_NAMES, DEFAULT_DISABLED_TOOLS, LEGACY_TOOL_ALIASES,
|
|
3268
|
+
var CANONICAL_TOOLS, HOST_TOOL_NAMES, DEFAULT_DISABLED_TOOLS, LEGACY_TOOL_ALIASES, RETIRED_PATHS, INDEX_INPUTS, LSP_IDLE_MINUTES_DEFAULT = 60, LSP_IDLE_MINUTES_MIN = 5, LSP_IDLE_MINUTES_MAX = 1440, RETIRED_ENABLED_FALSE_INDEXES_NOTE = "enabled: false no longer turns AFT off: it is translated to disabling every tool, but the trigram, semantic and callgraph indexes still build. To keep AFT from indexing this repository, also set indexes.trigram, indexes.semantic and indexes.callgraph to false.", SEMANTIC_COST_NOTICE_DIGEST;
|
|
2954
3269
|
var init_feature_config = __esm(() => {
|
|
2955
3270
|
CANONICAL_TOOLS = [
|
|
2956
3271
|
"aft_callgraph",
|
|
@@ -2996,14 +3311,6 @@ var init_feature_config = __esm(() => {
|
|
|
2996
3311
|
aft_glob: "glob",
|
|
2997
3312
|
aft_bash: "bash"
|
|
2998
3313
|
};
|
|
2999
|
-
BASH_GATE_DISABLES = [
|
|
3000
|
-
"bash",
|
|
3001
|
-
"bash_kill",
|
|
3002
|
-
"bash_status",
|
|
3003
|
-
"bash_watch",
|
|
3004
|
-
"bash_write"
|
|
3005
|
-
];
|
|
3006
|
-
POLICY_REJECT_FROM_MINOR = [0, 59];
|
|
3007
3314
|
RETIRED_PATHS = [
|
|
3008
3315
|
["tool_surface", "disabled_tools"],
|
|
3009
3316
|
["hoist_builtin_tools", "disabled_tools"],
|
|
@@ -3021,14 +3328,6 @@ var init_feature_config = __esm(() => {
|
|
|
3021
3328
|
["callgraph", "callgraph_store", undefined]
|
|
3022
3329
|
];
|
|
3023
3330
|
SEMANTIC_COST_NOTICE_DIGEST = noticeDigest({ notice: "semantic_default_cost_v1" });
|
|
3024
|
-
ConfigRejectedError = class ConfigRejectedError extends Error {
|
|
3025
|
-
errors;
|
|
3026
|
-
constructor(errors, source) {
|
|
3027
|
-
super(`AFT configuration${source ? ` at ${source}` : ""} was rejected: ${errors.join(", ")}. ` + "Run `npx @cortexkit/aft doctor --fix` to migrate removed keys.");
|
|
3028
|
-
this.name = "ConfigRejectedError";
|
|
3029
|
-
this.errors = errors;
|
|
3030
|
-
}
|
|
3031
|
-
};
|
|
3032
3331
|
});
|
|
3033
3332
|
// ../aft-bridge/dist/pool.js
|
|
3034
3333
|
var DEFAULT_IDLE_TIMEOUT_MS, CLEANUP_INTERVAL_MS;
|
|
@@ -3058,6 +3357,7 @@ var init_transport_factory = __esm(() => {
|
|
|
3058
3357
|
// ../aft-bridge/dist/location-lifecycle.js
|
|
3059
3358
|
var LIFECYCLE_STATE, RELEASE_LOCATION;
|
|
3060
3359
|
var init_location_lifecycle = __esm(() => {
|
|
3360
|
+
init_bridge();
|
|
3061
3361
|
init_project_identity();
|
|
3062
3362
|
init_transport_factory();
|
|
3063
3363
|
LIFECYCLE_STATE = Symbol.for("@cortexkit/aft-bridge/location-lifecycle/v1");
|
|
@@ -3073,35 +3373,37 @@ var init_message_detach = __esm(() => {
|
|
|
3073
3373
|
});
|
|
3074
3374
|
|
|
3075
3375
|
// ../aft-bridge/dist/paths.js
|
|
3076
|
-
import { homedir as
|
|
3077
|
-
import { dirname, isAbsolute as
|
|
3376
|
+
import { homedir as homedir7 } from "node:os";
|
|
3377
|
+
import { dirname as dirname2, isAbsolute as isAbsolute4, join as join8, resolve as resolve5 } from "node:path";
|
|
3078
3378
|
function homeDir3() {
|
|
3079
3379
|
if (process.platform === "win32")
|
|
3080
|
-
return process.env.USERPROFILE || process.env.HOME ||
|
|
3081
|
-
return process.env.HOME ||
|
|
3380
|
+
return process.env.USERPROFILE || process.env.HOME || homedir7();
|
|
3381
|
+
return process.env.HOME || homedir7();
|
|
3082
3382
|
}
|
|
3083
3383
|
function configHome() {
|
|
3084
3384
|
const xdg = process.env.XDG_CONFIG_HOME;
|
|
3085
|
-
if (xdg &&
|
|
3385
|
+
if (xdg && isAbsolute4(xdg))
|
|
3086
3386
|
return xdg;
|
|
3087
|
-
return
|
|
3387
|
+
return join8(homeDir3(), ".config");
|
|
3088
3388
|
}
|
|
3089
3389
|
function resolveCortexKitUserConfigPath() {
|
|
3090
|
-
return
|
|
3390
|
+
return join8(configHome(), "cortexkit", "aft.jsonc");
|
|
3091
3391
|
}
|
|
3092
3392
|
function resolveCortexKitProjectConfigPath(projectDirectory) {
|
|
3093
|
-
return
|
|
3393
|
+
return join8(projectDirectory, ".cortexkit", "aft.jsonc");
|
|
3094
3394
|
}
|
|
3095
|
-
var init_paths = () => {
|
|
3395
|
+
var init_paths = __esm(() => {
|
|
3396
|
+
init_private_storage();
|
|
3397
|
+
});
|
|
3096
3398
|
|
|
3097
3399
|
// ../aft-bridge/dist/resolver.js
|
|
3098
|
-
import { closeSync as
|
|
3400
|
+
import { closeSync as closeSync4, existsSync as existsSync3, promises as fsPromises, openSync as openSync4, readFileSync as readFileSync4, readSync as readSync3 } from "node:fs";
|
|
3099
3401
|
function isNativeExecutable(binaryPath) {
|
|
3100
3402
|
let fd = null;
|
|
3101
3403
|
try {
|
|
3102
|
-
fd =
|
|
3404
|
+
fd = openSync4(binaryPath, "r");
|
|
3103
3405
|
const buf = Buffer.alloc(4);
|
|
3104
|
-
const read =
|
|
3406
|
+
const read = readSync3(fd, buf, 0, 4, 0);
|
|
3105
3407
|
if (read < 2)
|
|
3106
3408
|
return false;
|
|
3107
3409
|
const b0 = buf[0];
|
|
@@ -3122,7 +3424,7 @@ function isNativeExecutable(binaryPath) {
|
|
|
3122
3424
|
} finally {
|
|
3123
3425
|
if (fd !== null) {
|
|
3124
3426
|
try {
|
|
3125
|
-
|
|
3427
|
+
closeSync4(fd);
|
|
3126
3428
|
} catch {}
|
|
3127
3429
|
}
|
|
3128
3430
|
}
|
|
@@ -3150,12 +3452,12 @@ var init_migration = __esm(() => {
|
|
|
3150
3452
|
});
|
|
3151
3453
|
|
|
3152
3454
|
// ../aft-bridge/dist/migration-notices.js
|
|
3153
|
-
import {
|
|
3154
|
-
import { homedir as
|
|
3155
|
-
import { dirname as
|
|
3455
|
+
import { readFileSync as readFileSync5, renameSync as renameSync3, rmdirSync, statSync as statSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
3456
|
+
import { homedir as homedir8 } from "node:os";
|
|
3457
|
+
import { dirname as dirname3, join as join9, resolve as resolve6 } from "node:path";
|
|
3156
3458
|
function migrationNoticeStorePath(env = process.env) {
|
|
3157
|
-
const stateHome = env.XDG_STATE_HOME && env.XDG_STATE_HOME.length > 0 ? env.XDG_STATE_HOME :
|
|
3158
|
-
return
|
|
3459
|
+
const stateHome = env.XDG_STATE_HOME && env.XDG_STATE_HOME.length > 0 ? env.XDG_STATE_HOME : join9(homedir8(), ".local", "state");
|
|
3460
|
+
return join9(stateHome, "cortexkit", "aft", "migration-notices.json");
|
|
3159
3461
|
}
|
|
3160
3462
|
function readRecords(storePath) {
|
|
3161
3463
|
try {
|
|
@@ -3167,11 +3469,11 @@ function readRecords(storePath) {
|
|
|
3167
3469
|
}
|
|
3168
3470
|
function withStoreLock(storePath, action) {
|
|
3169
3471
|
const lockPath = `${storePath}.lock`;
|
|
3170
|
-
|
|
3472
|
+
openPrivateStorageDir(dirname3(storePath));
|
|
3171
3473
|
const deadline = Date.now() + 2000;
|
|
3172
3474
|
for (;; ) {
|
|
3173
3475
|
try {
|
|
3174
|
-
|
|
3476
|
+
privateMkdirSync(lockPath, false);
|
|
3175
3477
|
break;
|
|
3176
3478
|
} catch (error) {
|
|
3177
3479
|
if (error.code !== "EEXIST")
|
|
@@ -3194,30 +3496,34 @@ function withStoreLock(storePath, action) {
|
|
|
3194
3496
|
}
|
|
3195
3497
|
}
|
|
3196
3498
|
function clearMigrationNotices(configPath, storePath = migrationNoticeStorePath()) {
|
|
3197
|
-
const prefix = `${
|
|
3499
|
+
const prefix = `${resolve6(configPath)}|`;
|
|
3198
3500
|
withStoreLock(storePath, () => {
|
|
3199
3501
|
const records = readRecords(storePath);
|
|
3200
3502
|
for (const key of Object.keys(records))
|
|
3201
3503
|
if (key.startsWith(prefix))
|
|
3202
3504
|
delete records[key];
|
|
3203
3505
|
writeFileSync2(storePath, `${JSON.stringify(records, null, 2)}
|
|
3204
|
-
`,
|
|
3506
|
+
`, {
|
|
3507
|
+
encoding: "utf8",
|
|
3508
|
+
mode: PRIVATE_FILE_MODE
|
|
3509
|
+
});
|
|
3205
3510
|
});
|
|
3206
3511
|
}
|
|
3207
3512
|
var LOCK_STALE_MS = 1e4;
|
|
3208
3513
|
var init_migration_notices = __esm(() => {
|
|
3209
3514
|
init_feature_config();
|
|
3515
|
+
init_private_storage();
|
|
3210
3516
|
});
|
|
3211
3517
|
|
|
3212
3518
|
// ../aft-bridge/dist/npm-resolver.js
|
|
3213
3519
|
import { readdirSync as readdirSync2, statSync as statSync4 } from "node:fs";
|
|
3214
|
-
import { homedir as
|
|
3215
|
-
import { dirname as
|
|
3520
|
+
import { homedir as homedir9 } from "node:os";
|
|
3521
|
+
import { dirname as dirname4, isAbsolute as isAbsolute5, join as join10 } from "node:path";
|
|
3216
3522
|
function defaultDeps() {
|
|
3217
3523
|
return {
|
|
3218
3524
|
platform: process.platform,
|
|
3219
3525
|
env: process.env,
|
|
3220
|
-
home:
|
|
3526
|
+
home: homedir9(),
|
|
3221
3527
|
execPath: process.execPath
|
|
3222
3528
|
};
|
|
3223
3529
|
}
|
|
@@ -3239,16 +3545,16 @@ function npmFromPath(deps) {
|
|
|
3239
3545
|
const separator = deps.platform === "win32" ? ";" : ":";
|
|
3240
3546
|
for (const entry of raw.split(separator)) {
|
|
3241
3547
|
const dir = entry.trim().replace(/^"|"$/g, "");
|
|
3242
|
-
if (!dir || !
|
|
3548
|
+
if (!dir || !isAbsolute5(dir))
|
|
3243
3549
|
continue;
|
|
3244
|
-
if (isFile(
|
|
3550
|
+
if (isFile(join10(dir, name)))
|
|
3245
3551
|
return dir;
|
|
3246
3552
|
}
|
|
3247
3553
|
return null;
|
|
3248
3554
|
}
|
|
3249
3555
|
function npmAdjacentToNode(deps) {
|
|
3250
|
-
const dir =
|
|
3251
|
-
return isFile(
|
|
3556
|
+
const dir = dirname4(deps.execPath);
|
|
3557
|
+
return isFile(join10(dir, npmBinaryName(deps.platform))) ? dir : null;
|
|
3252
3558
|
}
|
|
3253
3559
|
function highestVersionedNodeBin(installsDir, name) {
|
|
3254
3560
|
let entries;
|
|
@@ -3257,8 +3563,8 @@ function highestVersionedNodeBin(installsDir, name) {
|
|
|
3257
3563
|
} catch {
|
|
3258
3564
|
return null;
|
|
3259
3565
|
}
|
|
3260
|
-
const candidates = entries.filter((v) => isFile(
|
|
3261
|
-
return candidates.length > 0 ?
|
|
3566
|
+
const candidates = entries.filter((v) => isFile(join10(installsDir, v, "bin", name))).sort((a, b) => compareVersionsDesc(a, b));
|
|
3567
|
+
return candidates.length > 0 ? join10(installsDir, candidates[0], "bin") : null;
|
|
3262
3568
|
}
|
|
3263
3569
|
function compareVersionsDesc(a, b) {
|
|
3264
3570
|
const pa = a.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10));
|
|
@@ -3283,22 +3589,22 @@ function wellKnownNpmDirs(deps) {
|
|
|
3283
3589
|
const programFiles = env.ProgramFiles || "C:\\Program Files";
|
|
3284
3590
|
const appData = env.APPDATA;
|
|
3285
3591
|
const localAppData = env.LOCALAPPDATA;
|
|
3286
|
-
push(
|
|
3592
|
+
push(join10(programFiles, "nodejs"));
|
|
3287
3593
|
if (appData)
|
|
3288
|
-
push(
|
|
3594
|
+
push(join10(appData, "npm"));
|
|
3289
3595
|
if (localAppData)
|
|
3290
|
-
push(
|
|
3596
|
+
push(join10(localAppData, "Volta", "bin"));
|
|
3291
3597
|
if (env.NVM_SYMLINK)
|
|
3292
3598
|
push(env.NVM_SYMLINK);
|
|
3293
3599
|
} else {
|
|
3294
3600
|
if (env.NVM_BIN)
|
|
3295
3601
|
push(env.NVM_BIN);
|
|
3296
|
-
push(highestVersionedNodeBin(
|
|
3297
|
-
push(highestVersionedNodeBin(
|
|
3298
|
-
push(highestVersionedNodeBin(
|
|
3299
|
-
push(
|
|
3300
|
-
push(
|
|
3301
|
-
const systemDirs = deps.systemNpmDirs ?? (platform === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : ["/usr/local/bin", "/usr/bin",
|
|
3602
|
+
push(highestVersionedNodeBin(join10(home, ".nvm", "versions", "node"), name));
|
|
3603
|
+
push(highestVersionedNodeBin(join10(home, ".local", "share", "mise", "installs", "node"), name));
|
|
3604
|
+
push(highestVersionedNodeBin(join10(home, ".asdf", "installs", "nodejs"), name));
|
|
3605
|
+
push(join10(home, ".volta", "bin"));
|
|
3606
|
+
push(join10(home, ".asdf", "shims"));
|
|
3607
|
+
const systemDirs = deps.systemNpmDirs ?? (platform === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : ["/usr/local/bin", "/usr/bin", join10(home, ".local", "bin")]);
|
|
3302
3608
|
for (const dir of systemDirs)
|
|
3303
3609
|
push(dir);
|
|
3304
3610
|
}
|
|
@@ -3308,12 +3614,12 @@ function resolveNpm(deps = defaultDeps()) {
|
|
|
3308
3614
|
const name = npmBinaryName(deps.platform);
|
|
3309
3615
|
const onPath = npmFromPath(deps);
|
|
3310
3616
|
if (onPath)
|
|
3311
|
-
return { command:
|
|
3617
|
+
return { command: join10(onPath, name), binDir: onPath };
|
|
3312
3618
|
const adjacent = npmAdjacentToNode(deps);
|
|
3313
3619
|
if (adjacent)
|
|
3314
|
-
return { command:
|
|
3620
|
+
return { command: join10(adjacent, name), binDir: adjacent };
|
|
3315
3621
|
for (const dir of wellKnownNpmDirs(deps)) {
|
|
3316
|
-
const candidate =
|
|
3622
|
+
const candidate = join10(dir, name);
|
|
3317
3623
|
if (isFile(candidate))
|
|
3318
3624
|
return { command: candidate, binDir: dir };
|
|
3319
3625
|
}
|
|
@@ -3474,7 +3780,7 @@ function terminateNpmProcessTree(child, invocation, env = process.env, gracePeri
|
|
|
3474
3780
|
};
|
|
3475
3781
|
child.once("exit", onChildExit);
|
|
3476
3782
|
const systemRoot = env.SystemRoot ?? env.SYSTEMROOT;
|
|
3477
|
-
const taskkill = systemRoot ?
|
|
3783
|
+
const taskkill = systemRoot ? join10(systemRoot, "System32", "taskkill.exe") : "taskkill.exe";
|
|
3478
3784
|
try {
|
|
3479
3785
|
killer = spawn(taskkill, ["/pid", String(child.pid), "/t", "/f"], {
|
|
3480
3786
|
stdio: "ignore",
|
|
@@ -3510,10 +3816,10 @@ var init_npm_resolver = __esm(() => {
|
|
|
3510
3816
|
});
|
|
3511
3817
|
|
|
3512
3818
|
// ../aft-bridge/dist/onnx-probe.js
|
|
3513
|
-
import { closeSync as
|
|
3819
|
+
import { closeSync as closeSync5, existsSync as existsSync4, openSync as openSync5, readSync as readSync4, realpathSync as realpathSync2 } from "node:fs";
|
|
3514
3820
|
function readAt(fd, offset, length) {
|
|
3515
3821
|
const buffer = Buffer.alloc(length);
|
|
3516
|
-
const read =
|
|
3822
|
+
const read = readSync4(fd, buffer, 0, length, offset);
|
|
3517
3823
|
return buffer.subarray(0, read);
|
|
3518
3824
|
}
|
|
3519
3825
|
function cpuTypeForArch(arch) {
|
|
@@ -3587,7 +3893,7 @@ function isUncheckableDependency(path) {
|
|
|
3587
3893
|
function probeOnnxRuntimeLoadable(libPath, arch = process.arch) {
|
|
3588
3894
|
let fd;
|
|
3589
3895
|
try {
|
|
3590
|
-
fd =
|
|
3896
|
+
fd = openSync5(realpathSync2(libPath), "r");
|
|
3591
3897
|
} catch (err) {
|
|
3592
3898
|
return {
|
|
3593
3899
|
loadable: false,
|
|
@@ -3621,7 +3927,7 @@ function probeOnnxRuntimeLoadable(libPath, arch = process.arch) {
|
|
|
3621
3927
|
} catch {
|
|
3622
3928
|
return UNCHECKED;
|
|
3623
3929
|
} finally {
|
|
3624
|
-
|
|
3930
|
+
closeSync5(fd);
|
|
3625
3931
|
}
|
|
3626
3932
|
}
|
|
3627
3933
|
var MH_MAGIC = 4277009102, MH_MAGIC_64 = 4277009103, FAT_MAGIC = 3405691582, LC_LOAD_DYLIB = 12, LC_REEXPORT_DYLIB = 2147483679, LC_LOAD_UPWARD_DYLIB = 2147483683, CPU_TYPE_X86_64 = 16777223, CPU_TYPE_ARM64 = 16777228, MAX_HEADER_BYTES, UNCHECKED;
|
|
@@ -3632,19 +3938,30 @@ var init_onnx_probe = __esm(() => {
|
|
|
3632
3938
|
|
|
3633
3939
|
// ../aft-bridge/dist/tar-executable.js
|
|
3634
3940
|
import { existsSync as existsSync5 } from "node:fs";
|
|
3635
|
-
import { join as
|
|
3941
|
+
import { join as join11 } from "node:path";
|
|
3636
3942
|
function windowsTarExecutable(options = {}) {
|
|
3637
3943
|
const platform = options.platform ?? process.platform;
|
|
3638
3944
|
if (platform !== "win32")
|
|
3639
3945
|
return "tar";
|
|
3640
3946
|
const env = options.env ?? process.env;
|
|
3641
|
-
const systemTar =
|
|
3947
|
+
const systemTar = join11(env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe");
|
|
3642
3948
|
return (options.exists ?? existsSync5)(systemTar) ? systemTar : "tar";
|
|
3643
3949
|
}
|
|
3644
|
-
function execTarExtractionSync(args, timeout) {
|
|
3950
|
+
function execTarExtractionSync(args, timeout, privateStorage = false) {
|
|
3645
3951
|
const executable = windowsTarExecutable();
|
|
3646
3952
|
try {
|
|
3647
|
-
|
|
3953
|
+
if (privateStorage && process.platform !== "win32") {
|
|
3954
|
+
execFileSync("/bin/sh", [
|
|
3955
|
+
"-c",
|
|
3956
|
+
'umask 077; exec "$@"',
|
|
3957
|
+
"aft-extract",
|
|
3958
|
+
executable,
|
|
3959
|
+
"--no-same-permissions",
|
|
3960
|
+
...args.map((arg, index) => index === 0 && !arg.startsWith("-") ? `-${arg}` : arg)
|
|
3961
|
+
], { stdio: "pipe", timeout });
|
|
3962
|
+
} else {
|
|
3963
|
+
execFileSync(executable, args, { stdio: "pipe", timeout });
|
|
3964
|
+
}
|
|
3648
3965
|
} catch (cause) {
|
|
3649
3966
|
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
3650
3967
|
throw new Error(`tar extraction failed using ${executable}: ${detail}`, { cause });
|
|
@@ -3655,9 +3972,9 @@ var init_tar_executable = __esm(() => {
|
|
|
3655
3972
|
});
|
|
3656
3973
|
|
|
3657
3974
|
// ../aft-bridge/dist/onnx-runtime.js
|
|
3658
|
-
import {
|
|
3659
|
-
import { chmodSync as chmodSync2, closeSync as
|
|
3660
|
-
import { basename, dirname as
|
|
3975
|
+
import { randomBytes } from "node:crypto";
|
|
3976
|
+
import { chmodSync as chmodSync2, closeSync as closeSync6, copyFileSync as copyFileSync3, createWriteStream as createWriteStream2, existsSync as existsSync6, lstatSync as lstatSync2, openSync as openSync6, readdirSync as readdirSync3, readFileSync as readFileSync6, readlinkSync, realpathSync as realpathSync3, renameSync as renameSync4, rmSync as rmSync2, statSync as statSync5, symlinkSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
3977
|
+
import { basename, dirname as dirname5, isAbsolute as isAbsolute6, join as join12, relative as relative3, resolve as resolve7, win32 as win322 } from "node:path";
|
|
3661
3978
|
import { Readable as Readable2 } from "node:stream";
|
|
3662
3979
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
3663
3980
|
function getPlatformInfo() {
|
|
@@ -3694,14 +4011,14 @@ function resolveOnnxRuntime(storageDir, seams) {
|
|
|
3694
4011
|
inflightResolutions.set(storageDir, resolution);
|
|
3695
4012
|
return resolution;
|
|
3696
4013
|
}
|
|
3697
|
-
function findCachedOnnxRuntime(ortVersionDir, libName) {
|
|
4014
|
+
async function findCachedOnnxRuntime(ortVersionDir, libName) {
|
|
3698
4015
|
const resolvedOrtDir = resolveCachedOnnxRuntimeDir(ortVersionDir, libName);
|
|
3699
|
-
const libPath =
|
|
4016
|
+
const libPath = join12(resolvedOrtDir, libName);
|
|
3700
4017
|
if (existsSync6(libPath)) {
|
|
3701
4018
|
const meta = readOnnxInstalledMeta(ortVersionDir);
|
|
3702
4019
|
if (meta?.sha256) {
|
|
3703
4020
|
try {
|
|
3704
|
-
const currentHash =
|
|
4021
|
+
const currentHash = await cachedFileSha256(libPath);
|
|
3705
4022
|
if (currentHash !== meta.sha256) {
|
|
3706
4023
|
error(`ONNX Runtime at ${resolvedOrtDir}: TOFU sha256 mismatch — refusing to use ` + `tampered binary. Recorded ${meta.sha256}, current ${currentHash}. ` + `Run \`npx @cortexkit/aft doctor --clear\` to re-download from scratch.`);
|
|
3707
4024
|
} else {
|
|
@@ -3721,9 +4038,9 @@ function findCachedOnnxRuntime(ortVersionDir, libName) {
|
|
|
3721
4038
|
}
|
|
3722
4039
|
async function resolveOnnxRuntimeUncoalesced(storageDir, seams) {
|
|
3723
4040
|
const info = seams.platformInfo !== undefined ? seams.platformInfo : getPlatformInfo();
|
|
3724
|
-
const ortVersionDir =
|
|
4041
|
+
const ortVersionDir = join12(storageDir, "onnxruntime", ORT_VERSION);
|
|
3725
4042
|
const libName = info?.libName ?? "libonnxruntime.dylib";
|
|
3726
|
-
const cached = findCachedOnnxRuntime(ortVersionDir, libName);
|
|
4043
|
+
const cached = await findCachedOnnxRuntime(ortVersionDir, libName);
|
|
3727
4044
|
if (cached)
|
|
3728
4045
|
return cached;
|
|
3729
4046
|
const systemPath = findSystemOnnxRuntime(info?.libName, seams.systemSearchPaths);
|
|
@@ -3735,9 +4052,9 @@ async function resolveOnnxRuntimeUncoalesced(storageDir, seams) {
|
|
|
3735
4052
|
warn(`ONNX Runtime auto-download not available for ${process.platform}/${process.arch}. Install manually: ${getManualInstallHint()}`);
|
|
3736
4053
|
return null;
|
|
3737
4054
|
}
|
|
3738
|
-
const onnxBaseDir =
|
|
3739
|
-
|
|
3740
|
-
const lockPath =
|
|
4055
|
+
const onnxBaseDir = join12(storageDir, "onnxruntime");
|
|
4056
|
+
openPrivateStorageDir(storageDir, onnxBaseDir);
|
|
4057
|
+
const lockPath = join12(onnxBaseDir, ONNX_LOCK_FILE);
|
|
3741
4058
|
const pollMs = seams.lockPollMs ?? LOCK_POLL_MS;
|
|
3742
4059
|
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
3743
4060
|
let announcedWait = false;
|
|
@@ -3752,14 +4069,14 @@ async function resolveOnnxRuntimeUncoalesced(storageDir, seams) {
|
|
|
3752
4069
|
return null;
|
|
3753
4070
|
}
|
|
3754
4071
|
await new Promise((done) => setTimeout(done, pollMs));
|
|
3755
|
-
const published = findCachedOnnxRuntime(ortVersionDir, libName);
|
|
4072
|
+
const published = await findCachedOnnxRuntime(ortVersionDir, libName);
|
|
3756
4073
|
if (published) {
|
|
3757
4074
|
lastInstallFailure = null;
|
|
3758
4075
|
return published;
|
|
3759
4076
|
}
|
|
3760
4077
|
}
|
|
3761
4078
|
try {
|
|
3762
|
-
const published = findCachedOnnxRuntime(ortVersionDir, libName);
|
|
4079
|
+
const published = await findCachedOnnxRuntime(ortVersionDir, libName);
|
|
3763
4080
|
if (published) {
|
|
3764
4081
|
lastInstallFailure = null;
|
|
3765
4082
|
return published;
|
|
@@ -3782,7 +4099,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
|
|
|
3782
4099
|
for (const entry of entries) {
|
|
3783
4100
|
if (!entry.startsWith(`${ORT_VERSION}.tmp.`))
|
|
3784
4101
|
continue;
|
|
3785
|
-
const stagingDir =
|
|
4102
|
+
const stagingDir = join12(onnxBaseDir, entry);
|
|
3786
4103
|
const parts = entry.split(".");
|
|
3787
4104
|
const pidStr = parts[parts.length - 2];
|
|
3788
4105
|
const pid = pidStr ? Number.parseInt(pidStr, 10) : NaN;
|
|
@@ -3819,7 +4136,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
|
|
|
3819
4136
|
}
|
|
3820
4137
|
function cleanupIncompleteTargetIfUnowned(ortDir) {
|
|
3821
4138
|
try {
|
|
3822
|
-
if (existsSync6(ortDir) && !existsSync6(
|
|
4139
|
+
if (existsSync6(ortDir) && !existsSync6(join12(ortDir, ONNX_INSTALLED_META_FILE))) {
|
|
3823
4140
|
log(`[onnx] removing half-populated install dir ${ortDir} (no meta file)`);
|
|
3824
4141
|
rmSync2(ortDir, { recursive: true, force: true });
|
|
3825
4142
|
}
|
|
@@ -3844,14 +4161,14 @@ function parseOnnxVersionFromDirectoryPath(value) {
|
|
|
3844
4161
|
return null;
|
|
3845
4162
|
}
|
|
3846
4163
|
function isPathInsideRoot(root, candidate) {
|
|
3847
|
-
const rel =
|
|
3848
|
-
return rel === "" || !rel.startsWith("../") && !rel.startsWith("..\\") && rel !== ".." && !
|
|
4164
|
+
const rel = relative3(root, candidate);
|
|
4165
|
+
return rel === "" || !rel.startsWith("../") && !rel.startsWith("..\\") && rel !== ".." && !isAbsolute6(rel) && !win322.isAbsolute(rel);
|
|
3849
4166
|
}
|
|
3850
4167
|
function detectOnnxVersion(libDir, libName) {
|
|
3851
4168
|
try {
|
|
3852
4169
|
const entries = readdirSync3(libDir);
|
|
3853
4170
|
try {
|
|
3854
|
-
const resolved = parseOnnxVersionFromPath(
|
|
4171
|
+
const resolved = parseOnnxVersionFromPath(realpathSync3(join12(libDir, libName)));
|
|
3855
4172
|
if (resolved && resolved !== INVALID_ORT_VERSION)
|
|
3856
4173
|
return resolved;
|
|
3857
4174
|
} catch {}
|
|
@@ -3865,10 +4182,10 @@ function detectOnnxVersion(libDir, libName) {
|
|
|
3865
4182
|
if (version)
|
|
3866
4183
|
return version;
|
|
3867
4184
|
}
|
|
3868
|
-
const base =
|
|
4185
|
+
const base = join12(libDir, libName);
|
|
3869
4186
|
if (existsSync6(base)) {
|
|
3870
4187
|
try {
|
|
3871
|
-
const real =
|
|
4188
|
+
const real = realpathSync3(base);
|
|
3872
4189
|
const version = parseOnnxVersionFromPath(real) ?? parseOnnxVersionFromDirectoryPath(real);
|
|
3873
4190
|
if (version)
|
|
3874
4191
|
return version;
|
|
@@ -3905,18 +4222,18 @@ function pathEntriesForPlatform() {
|
|
|
3905
4222
|
return pathEnvValue().split(delimiter).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => {
|
|
3906
4223
|
if (!entry || entry === "." || entry.includes("\x00"))
|
|
3907
4224
|
return false;
|
|
3908
|
-
return
|
|
4225
|
+
return isAbsolute6(entry) || win322.isAbsolute(entry);
|
|
3909
4226
|
});
|
|
3910
4227
|
}
|
|
3911
4228
|
function isWindowsSystem32Directory(dir) {
|
|
3912
4229
|
if (process.platform !== "win32")
|
|
3913
4230
|
return false;
|
|
3914
|
-
const normalizedDir =
|
|
4231
|
+
const normalizedDir = win322.resolve(dir).replace(/[\\/]+$/, "").toLowerCase();
|
|
3915
4232
|
const windowsRoots = [process.env.SystemRoot, process.env.windir, "C:\\Windows"];
|
|
3916
4233
|
return windowsRoots.some((root) => {
|
|
3917
4234
|
if (!root)
|
|
3918
4235
|
return false;
|
|
3919
|
-
return normalizedDir ===
|
|
4236
|
+
return normalizedDir === win322.resolve(root, "System32").replace(/[\\/]+$/, "").toLowerCase();
|
|
3920
4237
|
});
|
|
3921
4238
|
}
|
|
3922
4239
|
function directoryContainsLibrary(dir, libName) {
|
|
@@ -3932,10 +4249,10 @@ function directoryContainsLibrary(dir, libName) {
|
|
|
3932
4249
|
}
|
|
3933
4250
|
}
|
|
3934
4251
|
function resolveCachedOnnxRuntimeDir(ortVersionDir, libName) {
|
|
3935
|
-
if (existsSync6(
|
|
4252
|
+
if (existsSync6(join12(ortVersionDir, libName)))
|
|
3936
4253
|
return ortVersionDir;
|
|
3937
|
-
const libSubdir =
|
|
3938
|
-
if (existsSync6(
|
|
4254
|
+
const libSubdir = join12(ortVersionDir, "lib");
|
|
4255
|
+
if (existsSync6(join12(libSubdir, libName)))
|
|
3939
4256
|
return libSubdir;
|
|
3940
4257
|
return ortVersionDir;
|
|
3941
4258
|
}
|
|
@@ -3950,12 +4267,12 @@ function findSystemOnnxRuntime(libName, searchPathsOverride) {
|
|
|
3950
4267
|
} else if (process.platform === "win32") {
|
|
3951
4268
|
const programFiles = process.env.ProgramFiles ?? "C:\\Program Files";
|
|
3952
4269
|
const programFilesX86 = process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
|
3953
|
-
searchPaths.push(
|
|
4270
|
+
searchPaths.push(join12(programFiles, "onnxruntime", "lib"), join12(programFiles, "Microsoft ONNX Runtime", "lib"), join12(programFiles, "Microsoft Machine Learning", "lib"), join12(programFilesX86, "onnxruntime", "lib"), ...(() => {
|
|
3954
4271
|
const nugetPaths = [];
|
|
3955
4272
|
const userProfile = process.env.USERPROFILE ?? "";
|
|
3956
4273
|
if (!userProfile)
|
|
3957
4274
|
return nugetPaths;
|
|
3958
|
-
const nugetPackageDir =
|
|
4275
|
+
const nugetPackageDir = join12(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
|
|
3959
4276
|
if (!existsSync6(nugetPackageDir))
|
|
3960
4277
|
return nugetPaths;
|
|
3961
4278
|
try {
|
|
@@ -3964,7 +4281,7 @@ function findSystemOnnxRuntime(libName, searchPathsOverride) {
|
|
|
3964
4281
|
continue;
|
|
3965
4282
|
if (entry.name === "__globalPackagesFolder" || entry.name.startsWith("."))
|
|
3966
4283
|
continue;
|
|
3967
|
-
nugetPaths.push(
|
|
4284
|
+
nugetPaths.push(join12(nugetPackageDir, entry.name, "runtimes", "win-x64", "native"), join12(nugetPackageDir, entry.name, "runtimes", "win-arm64", "native"));
|
|
3968
4285
|
}
|
|
3969
4286
|
} catch (err) {
|
|
3970
4287
|
warn(`Failed to scan NuGet ONNX Runtime cache ${nugetPackageDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -3976,7 +4293,7 @@ function findSystemOnnxRuntime(libName, searchPathsOverride) {
|
|
|
3976
4293
|
const normalizeCase = process.platform === "win32" || process.platform === "darwin";
|
|
3977
4294
|
const seen = new Set;
|
|
3978
4295
|
const uniquePaths = searchPaths.filter((p) => {
|
|
3979
|
-
let key =
|
|
4296
|
+
let key = resolve7(p).replace(/[/\\]+$/, "");
|
|
3980
4297
|
if (normalizeCase)
|
|
3981
4298
|
key = key.toLowerCase();
|
|
3982
4299
|
if (seen.has(key))
|
|
@@ -3986,7 +4303,7 @@ function findSystemOnnxRuntime(libName, searchPathsOverride) {
|
|
|
3986
4303
|
});
|
|
3987
4304
|
const unknownVersionPaths = [];
|
|
3988
4305
|
for (const dir of uniquePaths) {
|
|
3989
|
-
const libPath =
|
|
4306
|
+
const libPath = join12(dir, libName);
|
|
3990
4307
|
if (process.platform === "win32") {
|
|
3991
4308
|
if (!directoryContainsLibrary(dir, libName))
|
|
3992
4309
|
continue;
|
|
@@ -4033,7 +4350,7 @@ async function downloadFileWithCap(url, destPath) {
|
|
|
4033
4350
|
if (Number.isFinite(advertised) && advertised > MAX_DOWNLOAD_BYTES2) {
|
|
4034
4351
|
throw new Error(`Content-Length ${advertised} exceeds max ${MAX_DOWNLOAD_BYTES2}`);
|
|
4035
4352
|
}
|
|
4036
|
-
|
|
4353
|
+
privateMkdirSync(dirname5(destPath));
|
|
4037
4354
|
let bytesWritten = 0;
|
|
4038
4355
|
const guard = new TransformStream({
|
|
4039
4356
|
transform(chunk, transformController) {
|
|
@@ -4047,7 +4364,9 @@ async function downloadFileWithCap(url, destPath) {
|
|
|
4047
4364
|
});
|
|
4048
4365
|
const guarded = res.body.pipeThrough(guard);
|
|
4049
4366
|
const nodeStream = Readable2.fromWeb(guarded);
|
|
4050
|
-
await pipeline2(nodeStream, createWriteStream2(destPath
|
|
4367
|
+
await pipeline2(nodeStream, createWriteStream2(destPath, { mode: PRIVATE_FILE_MODE }), {
|
|
4368
|
+
signal: controller.signal
|
|
4369
|
+
});
|
|
4051
4370
|
} catch (err) {
|
|
4052
4371
|
try {
|
|
4053
4372
|
unlinkSync3(destPath);
|
|
@@ -4058,31 +4377,35 @@ async function downloadFileWithCap(url, destPath) {
|
|
|
4058
4377
|
}
|
|
4059
4378
|
}
|
|
4060
4379
|
function validateExtractedTree(stagingRoot) {
|
|
4061
|
-
const realRoot =
|
|
4380
|
+
const realRoot = realpathSync3(stagingRoot);
|
|
4062
4381
|
let totalBytes = 0;
|
|
4063
4382
|
const walk = (dir) => {
|
|
4064
4383
|
const entries = readdirSync3(dir);
|
|
4065
4384
|
for (const entry of entries) {
|
|
4066
|
-
const fullPath =
|
|
4067
|
-
const lst =
|
|
4385
|
+
const fullPath = join12(dir, entry);
|
|
4386
|
+
const lst = lstatSync2(fullPath);
|
|
4068
4387
|
if (lst.isSymbolicLink()) {
|
|
4069
4388
|
const linkTarget = readlinkSync(fullPath);
|
|
4070
|
-
const resolvedTarget =
|
|
4071
|
-
const rel =
|
|
4072
|
-
if (
|
|
4389
|
+
const resolvedTarget = resolve7(dirname5(fullPath), linkTarget);
|
|
4390
|
+
const rel = relative3(realRoot, resolvedTarget);
|
|
4391
|
+
if (relativePathEscapesRoot(rel) || win322.isAbsolute(rel)) {
|
|
4073
4392
|
throw new Error(`extracted symlink ${fullPath} points outside staging root: ${linkTarget}`);
|
|
4074
4393
|
}
|
|
4075
4394
|
continue;
|
|
4076
4395
|
}
|
|
4077
|
-
const rel =
|
|
4078
|
-
if (
|
|
4396
|
+
const rel = relative3(realRoot, fullPath);
|
|
4397
|
+
if (relativePathEscapesRoot(rel) || win322.isAbsolute(rel)) {
|
|
4079
4398
|
throw new Error(`extracted entry ${fullPath} escapes staging root`);
|
|
4080
4399
|
}
|
|
4081
4400
|
if (lst.isDirectory()) {
|
|
4401
|
+
if (process.platform !== "win32")
|
|
4402
|
+
chmodSync2(fullPath, PRIVATE_DIRECTORY_MODE);
|
|
4082
4403
|
walk(fullPath);
|
|
4083
4404
|
continue;
|
|
4084
4405
|
}
|
|
4085
4406
|
if (lst.isFile()) {
|
|
4407
|
+
if (process.platform !== "win32")
|
|
4408
|
+
chmodSync2(fullPath, PRIVATE_FILE_MODE);
|
|
4086
4409
|
totalBytes += lst.size;
|
|
4087
4410
|
if (totalBytes > MAX_EXTRACT_BYTES) {
|
|
4088
4411
|
throw new Error(`extracted size ${totalBytes} exceeds max ${MAX_EXTRACT_BYTES} (decompression bomb defense)`);
|
|
@@ -4096,16 +4419,16 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
4096
4419
|
const url = `https://github.com/${ORT_REPO}/releases/download/v${ORT_VERSION}/${info.assetName}.${info.archiveType === "tgz" ? "tgz" : "zip"}`;
|
|
4097
4420
|
log(`Downloading ONNX Runtime v${ORT_VERSION} for ${process.platform}/${process.arch}...`);
|
|
4098
4421
|
const tmpDir = `${targetDir}.tmp.${process.pid}.${Date.now().toString(36)}${randomBytes(4).toString("hex")}`;
|
|
4099
|
-
const extractionRoot =
|
|
4100
|
-
const stagedInstallDir =
|
|
4422
|
+
const extractionRoot = join12(tmpDir, "extract");
|
|
4423
|
+
const stagedInstallDir = join12(tmpDir, "install");
|
|
4101
4424
|
try {
|
|
4102
|
-
|
|
4103
|
-
const archivePath =
|
|
4425
|
+
privateMkdirSync(extractionRoot);
|
|
4426
|
+
const archivePath = join12(tmpDir, `onnxruntime.${info.archiveType}`);
|
|
4104
4427
|
await downloadFileWithCap(url, archivePath);
|
|
4105
|
-
const archiveSha256 =
|
|
4428
|
+
const archiveSha256 = await sha256File(archivePath);
|
|
4106
4429
|
log(`ONNX Runtime archive sha256=${archiveSha256}`);
|
|
4107
4430
|
if (info.archiveType === "tgz") {
|
|
4108
|
-
execTarExtractionSync(["xzf", archivePath, "-C", extractionRoot], 120000);
|
|
4431
|
+
execTarExtractionSync(["xzf", archivePath, "-C", extractionRoot], 120000, true);
|
|
4109
4432
|
} else {
|
|
4110
4433
|
await extractZipArchive(archivePath, extractionRoot);
|
|
4111
4434
|
}
|
|
@@ -4113,7 +4436,7 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
4113
4436
|
unlinkSync3(archivePath);
|
|
4114
4437
|
} catch {}
|
|
4115
4438
|
validateExtractedTree(extractionRoot);
|
|
4116
|
-
const extractedDir =
|
|
4439
|
+
const extractedDir = join12(extractionRoot, info.assetName, "lib");
|
|
4117
4440
|
if (!existsSync6(extractedDir)) {
|
|
4118
4441
|
throw new Error(`Expected directory not found: ${extractedDir}`);
|
|
4119
4442
|
}
|
|
@@ -4121,9 +4444,9 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
4121
4444
|
const realFiles = [];
|
|
4122
4445
|
const symlinks = [];
|
|
4123
4446
|
for (const libFile of libFiles) {
|
|
4124
|
-
const src =
|
|
4447
|
+
const src = join12(extractedDir, libFile);
|
|
4125
4448
|
try {
|
|
4126
|
-
const stat =
|
|
4449
|
+
const stat = lstatSync2(src);
|
|
4127
4450
|
log(`ORT extract: ${libFile} — isSymlink=${stat.isSymbolicLink()}, isFile=${stat.isFile()}, size=${stat.size}`);
|
|
4128
4451
|
if (stat.isSymbolicLink()) {
|
|
4129
4452
|
symlinks.push({ name: libFile, target: readlinkSync(src) });
|
|
@@ -4136,13 +4459,14 @@ async function downloadOnnxRuntime(info, targetDir) {
|
|
|
4136
4459
|
}
|
|
4137
4460
|
}
|
|
4138
4461
|
copyOnnxLibraries(info, extractedDir, stagedInstallDir, realFiles, symlinks);
|
|
4139
|
-
const libPath =
|
|
4140
|
-
const libHash =
|
|
4462
|
+
const libPath = join12(stagedInstallDir, info.libName);
|
|
4463
|
+
const libHash = await sha256File(libPath);
|
|
4141
4464
|
if (libHash !== info.librarySha256) {
|
|
4142
4465
|
throw new Error(`onnx runtime library hash mismatch at ${libPath}: sha256 ${libHash}, ` + `expected the pinned ${info.librarySha256} for ${info.assetName}`);
|
|
4143
4466
|
}
|
|
4144
4467
|
writeOnnxInstalledMeta(stagedInstallDir, ORT_VERSION, libHash, archiveSha256);
|
|
4145
4468
|
publishOnnxRuntime(stagedInstallDir, targetDir);
|
|
4469
|
+
writeStampedFileDigest(join12(targetDir, info.libName), libHash);
|
|
4146
4470
|
rmSync2(tmpDir, { recursive: true, force: true });
|
|
4147
4471
|
log(`ONNX Runtime v${ORT_VERSION} installed to ${targetDir}`);
|
|
4148
4472
|
return targetDir;
|
|
@@ -4180,16 +4504,19 @@ function publishOnnxRuntime(stagedInstallDir, targetDir) {
|
|
|
4180
4504
|
}
|
|
4181
4505
|
}
|
|
4182
4506
|
}
|
|
4183
|
-
function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, copyFile =
|
|
4507
|
+
function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, copyFile = copyFileSync3) {
|
|
4184
4508
|
const requiredLibs = new Set([info.libName]);
|
|
4185
|
-
|
|
4509
|
+
privateMkdirSync(targetDir);
|
|
4186
4510
|
for (const libFile of realFiles) {
|
|
4187
|
-
const src =
|
|
4188
|
-
const dst =
|
|
4511
|
+
const src = join12(extractedDir, libFile);
|
|
4512
|
+
const dst = join12(targetDir, libFile);
|
|
4189
4513
|
try {
|
|
4190
|
-
copyFile
|
|
4514
|
+
if (copyFile === copyFileSync3)
|
|
4515
|
+
privateCopyFileSync(src, dst);
|
|
4516
|
+
else
|
|
4517
|
+
copyFile(src, dst);
|
|
4191
4518
|
if (process.platform !== "win32") {
|
|
4192
|
-
chmodSync2(dst,
|
|
4519
|
+
chmodSync2(dst, PRIVATE_FILE_MODE);
|
|
4193
4520
|
}
|
|
4194
4521
|
} catch (copyErr) {
|
|
4195
4522
|
if (requiredLibs.has(libFile)) {
|
|
@@ -4199,14 +4526,14 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
|
|
|
4199
4526
|
log(`ORT extract: failed to copy optional ${libFile}: ${copyErr}`);
|
|
4200
4527
|
}
|
|
4201
4528
|
}
|
|
4202
|
-
const targetRoot =
|
|
4529
|
+
const targetRoot = realpathSync3(targetDir);
|
|
4203
4530
|
for (const link of symlinks) {
|
|
4204
|
-
const dst =
|
|
4531
|
+
const dst = join12(targetDir, link.name);
|
|
4205
4532
|
try {
|
|
4206
4533
|
unlinkSync3(dst);
|
|
4207
4534
|
} catch {}
|
|
4208
|
-
const dstForContainment =
|
|
4209
|
-
const resolvedTarget =
|
|
4535
|
+
const dstForContainment = join12(targetRoot, link.name);
|
|
4536
|
+
const resolvedTarget = resolve7(dirname5(dstForContainment), link.target);
|
|
4210
4537
|
if (!isPathInsideRoot(targetRoot, resolvedTarget)) {
|
|
4211
4538
|
const message = `ONNX Runtime symlink ${link.name} points outside install dir: ${link.target}`;
|
|
4212
4539
|
if (requiredLibs.has(link.name)) {
|
|
@@ -4226,7 +4553,7 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
|
|
|
4226
4553
|
log(`ORT extract: failed to symlink optional ${link.name}: ${symlinkErr}`);
|
|
4227
4554
|
}
|
|
4228
4555
|
}
|
|
4229
|
-
const requiredPath =
|
|
4556
|
+
const requiredPath = join12(targetDir, info.libName);
|
|
4230
4557
|
if (!existsSync6(requiredPath)) {
|
|
4231
4558
|
rmSync2(targetDir, { recursive: true, force: true });
|
|
4232
4559
|
throw new Error(`Required ONNX Runtime library missing after install: ${requiredPath}`);
|
|
@@ -4250,13 +4577,16 @@ function writeOnnxInstalledMeta(installDir, version, sha256, archiveSha256) {
|
|
|
4250
4577
|
...sha256 ? { sha256 } : {},
|
|
4251
4578
|
archiveSha256
|
|
4252
4579
|
};
|
|
4253
|
-
writeFileSync3(
|
|
4580
|
+
writeFileSync3(join12(installDir, ONNX_INSTALLED_META_FILE), JSON.stringify(meta), {
|
|
4581
|
+
encoding: "utf8",
|
|
4582
|
+
mode: PRIVATE_FILE_MODE
|
|
4583
|
+
});
|
|
4254
4584
|
} catch (err) {
|
|
4255
4585
|
log(`[onnx] failed to write installed-meta in ${installDir}: ${err}`);
|
|
4256
4586
|
}
|
|
4257
4587
|
}
|
|
4258
4588
|
function readOnnxInstalledMeta(installDir) {
|
|
4259
|
-
const path =
|
|
4589
|
+
const path = join12(installDir, ONNX_INSTALLED_META_FILE);
|
|
4260
4590
|
try {
|
|
4261
4591
|
if (!statSync5(path).isFile())
|
|
4262
4592
|
return null;
|
|
@@ -4274,21 +4604,16 @@ function readOnnxInstalledMeta(installDir) {
|
|
|
4274
4604
|
return null;
|
|
4275
4605
|
}
|
|
4276
4606
|
}
|
|
4277
|
-
function sha256File2(path) {
|
|
4278
|
-
const hash = createHash4("sha256");
|
|
4279
|
-
hash.update(readFileSync6(path));
|
|
4280
|
-
return hash.digest("hex");
|
|
4281
|
-
}
|
|
4282
4607
|
function acquireLock(lockPath) {
|
|
4283
4608
|
const tryClaim = () => {
|
|
4284
4609
|
try {
|
|
4285
|
-
const fd =
|
|
4610
|
+
const fd = openSync6(lockPath, "wx", PRIVATE_FILE_MODE);
|
|
4286
4611
|
try {
|
|
4287
4612
|
writeFileSync3(fd, `${process.pid}
|
|
4288
4613
|
${new Date().toISOString()}
|
|
4289
4614
|
`);
|
|
4290
4615
|
} finally {
|
|
4291
|
-
|
|
4616
|
+
closeSync6(fd);
|
|
4292
4617
|
}
|
|
4293
4618
|
return true;
|
|
4294
4619
|
} catch (err) {
|
|
@@ -4395,9 +4720,12 @@ function isProcessAlive2(pid) {
|
|
|
4395
4720
|
var ORT_VERSION = "1.24.4", ORT_REPO = "microsoft/onnxruntime", MAX_DOWNLOAD_BYTES2, MAX_EXTRACT_BYTES, ONNX_LOCK_FILE = ".aft-onnx-installing", ONNX_INSTALLED_META_FILE = ".aft-onnx-installed", STALE_LOCK_MS, LOCK_WAIT_MS, LOCK_POLL_MS = 1000, ORT_PLATFORM_MAP, lastInstallFailure = null, inflightResolutions, REQUIRED_ORT_MAJOR = 1, REQUIRED_ORT_MIN_MINOR = 20, INVALID_ORT_VERSION = "<invalid>";
|
|
4396
4721
|
var init_onnx_runtime = __esm(() => {
|
|
4397
4722
|
init_active_logger();
|
|
4723
|
+
init_binary_identity();
|
|
4398
4724
|
init_child_process();
|
|
4399
4725
|
init_onnx_probe();
|
|
4726
|
+
init_path_display();
|
|
4400
4727
|
init_platform();
|
|
4728
|
+
init_private_storage();
|
|
4401
4729
|
init_tar_executable();
|
|
4402
4730
|
MAX_DOWNLOAD_BYTES2 = 256 * 1024 * 1024;
|
|
4403
4731
|
MAX_EXTRACT_BYTES = 1 * 1024 * 1024 * 1024;
|
|
@@ -4468,8 +4796,8 @@ var init_path_aliases = __esm(() => {
|
|
|
4468
4796
|
});
|
|
4469
4797
|
|
|
4470
4798
|
// ../aft-bridge/dist/path-lookup.js
|
|
4471
|
-
import { accessSync, constants, statSync as statSync6 } from "node:fs";
|
|
4472
|
-
import { delimiter, resolve as
|
|
4799
|
+
import { accessSync, constants as constants2, statSync as statSync6 } from "node:fs";
|
|
4800
|
+
import { delimiter, resolve as resolve8 } from "node:path";
|
|
4473
4801
|
function executableNames(name, platform) {
|
|
4474
4802
|
if (platform !== "win32")
|
|
4475
4803
|
return [name];
|
|
@@ -4485,12 +4813,12 @@ function findExecutablesOnPath(name, options = {}) {
|
|
|
4485
4813
|
if (!directory)
|
|
4486
4814
|
continue;
|
|
4487
4815
|
for (const candidateName of executableNames(name, platform)) {
|
|
4488
|
-
const candidate =
|
|
4816
|
+
const candidate = resolve8(directory, candidateName);
|
|
4489
4817
|
if (seen.has(candidate))
|
|
4490
4818
|
continue;
|
|
4491
4819
|
seen.add(candidate);
|
|
4492
4820
|
try {
|
|
4493
|
-
accessSync(candidate, platform === "win32" ?
|
|
4821
|
+
accessSync(candidate, platform === "win32" ? constants2.F_OK : constants2.X_OK);
|
|
4494
4822
|
if (statSync6(candidate).isFile())
|
|
4495
4823
|
hits.push(candidate);
|
|
4496
4824
|
} catch {}
|
|
@@ -4536,6 +4864,7 @@ var init_dist2 = __esm(() => {
|
|
|
4536
4864
|
init_onnx_probe();
|
|
4537
4865
|
init_onnx_runtime();
|
|
4538
4866
|
init_path_aliases();
|
|
4867
|
+
init_path_display();
|
|
4539
4868
|
init_path_lookup();
|
|
4540
4869
|
init_paths();
|
|
4541
4870
|
init_platform();
|
|
@@ -4566,8 +4895,8 @@ var init_paths2 = __esm(() => {
|
|
|
4566
4895
|
// src/lib/binary-probe.ts
|
|
4567
4896
|
import { existsSync as existsSync7, readdirSync as readdirSync4 } from "node:fs";
|
|
4568
4897
|
import { createRequire } from "node:module";
|
|
4569
|
-
import { homedir as
|
|
4570
|
-
import { join as
|
|
4898
|
+
import { homedir as homedir10 } from "node:os";
|
|
4899
|
+
import { join as join13 } from "node:path";
|
|
4571
4900
|
async function loadPluginVersion() {
|
|
4572
4901
|
try {
|
|
4573
4902
|
const bridge = await Promise.resolve().then(() => (init_dist2(), {}));
|
|
@@ -4697,7 +5026,7 @@ function newestCachedBinary(cacheDir, binaryName) {
|
|
|
4697
5026
|
const version = entry.match(CACHE_VERSION_DIR)?.[1];
|
|
4698
5027
|
if (!version)
|
|
4699
5028
|
continue;
|
|
4700
|
-
const path =
|
|
5029
|
+
const path = join13(cacheDir, entry, binaryName);
|
|
4701
5030
|
try {
|
|
4702
5031
|
if (!existsSync7(path))
|
|
4703
5032
|
continue;
|
|
@@ -4718,7 +5047,7 @@ function cacheLocation(preferredVersion) {
|
|
|
4718
5047
|
const tag = preferredVersion.startsWith("v") ? preferredVersion : `v${preferredVersion}`;
|
|
4719
5048
|
return {
|
|
4720
5049
|
label,
|
|
4721
|
-
paths: [
|
|
5050
|
+
paths: [join13(cacheDir, tag, binaryName)],
|
|
4722
5051
|
emptyReason: `no ${tag}/${binaryName} under ${cacheDir} (${installedHere})`
|
|
4723
5052
|
};
|
|
4724
5053
|
}
|
|
@@ -4762,7 +5091,7 @@ function pathLocation() {
|
|
|
4762
5091
|
};
|
|
4763
5092
|
}
|
|
4764
5093
|
function cargoLocation() {
|
|
4765
|
-
const path =
|
|
5094
|
+
const path = join13(homedir10(), ".cargo", "bin", getAftBinaryName());
|
|
4766
5095
|
return { label: "cargo install", paths: [path], emptyReason: `no ${path}` };
|
|
4767
5096
|
}
|
|
4768
5097
|
function aftBinarySearchLocations(preferredVersion) {
|
|
@@ -4815,7 +5144,7 @@ var init_binary_probe = __esm(async () => {
|
|
|
4815
5144
|
|
|
4816
5145
|
// src/lib/fs-util.ts
|
|
4817
5146
|
import { existsSync as existsSync8, readdirSync as readdirSync5, statSync as statSync7 } from "node:fs";
|
|
4818
|
-
import { join as
|
|
5147
|
+
import { join as join14 } from "node:path";
|
|
4819
5148
|
function dirSize(path) {
|
|
4820
5149
|
if (!existsSync8(path)) {
|
|
4821
5150
|
return 0;
|
|
@@ -4829,7 +5158,7 @@ function dirSize(path) {
|
|
|
4829
5158
|
}
|
|
4830
5159
|
let total = 0;
|
|
4831
5160
|
for (const entry of readdirSync5(path)) {
|
|
4832
|
-
total += dirSize(
|
|
5161
|
+
total += dirSize(join14(path, entry));
|
|
4833
5162
|
}
|
|
4834
5163
|
return total;
|
|
4835
5164
|
}
|
|
@@ -4847,27 +5176,27 @@ var init_fs_util = () => {};
|
|
|
4847
5176
|
|
|
4848
5177
|
// src/lib/omp-paths.ts
|
|
4849
5178
|
import { existsSync as existsSync9 } from "node:fs";
|
|
4850
|
-
import { homedir as
|
|
4851
|
-
import { join as
|
|
5179
|
+
import { homedir as homedir11 } from "node:os";
|
|
5180
|
+
import { join as join15, resolve as resolve9 } from "node:path";
|
|
4852
5181
|
function envFirstHomeDir() {
|
|
4853
|
-
return process.env.HOME?.trim() ||
|
|
5182
|
+
return process.env.HOME?.trim() || homedir11();
|
|
4854
5183
|
}
|
|
4855
5184
|
function resolveOmpPaths() {
|
|
4856
5185
|
const normalizedProfile = (process.env.OMP_PROFILE ?? process.env.PI_PROFILE)?.trim();
|
|
4857
5186
|
const profile = normalizedProfile && normalizedProfile !== "default" && /^[a-z0-9][a-z0-9._-]{0,63}$/.test(normalizedProfile) ? normalizedProfile : undefined;
|
|
4858
5187
|
const configDirName = process.env.PI_CONFIG_DIR?.trim() || ".omp";
|
|
4859
|
-
const baseConfigRoot =
|
|
4860
|
-
const configRoot = profile ?
|
|
4861
|
-
const defaultAgentDir =
|
|
5188
|
+
const baseConfigRoot = join15(envFirstHomeDir(), configDirName);
|
|
5189
|
+
const configRoot = profile ? join15(baseConfigRoot, "profiles", profile) : baseConfigRoot;
|
|
5190
|
+
const defaultAgentDir = join15(configRoot, "agent");
|
|
4862
5191
|
const configuredAgentDir = profile ? undefined : process.env.PI_CODING_AGENT_DIR?.trim();
|
|
4863
|
-
const agentDir = configuredAgentDir ?
|
|
5192
|
+
const agentDir = configuredAgentDir ? resolve9(configuredAgentDir) : defaultAgentDir;
|
|
4864
5193
|
const canUseXdg = (process.platform === "linux" || process.platform === "darwin") && agentDir === defaultAgentDir;
|
|
4865
5194
|
let dataRoot = configRoot;
|
|
4866
5195
|
if (canUseXdg) {
|
|
4867
5196
|
const xdgDataHome = process.env.XDG_DATA_HOME?.trim();
|
|
4868
5197
|
if (xdgDataHome) {
|
|
4869
|
-
const appRoot =
|
|
4870
|
-
const candidate = profile ?
|
|
5198
|
+
const appRoot = join15(xdgDataHome, "omp");
|
|
5199
|
+
const candidate = profile ? join15(appRoot, "profiles", profile) : appRoot;
|
|
4871
5200
|
if (existsSync9(candidate))
|
|
4872
5201
|
dataRoot = candidate;
|
|
4873
5202
|
}
|
|
@@ -4878,8 +5207,8 @@ function resolveOmpPaths() {
|
|
|
4878
5207
|
agentDir,
|
|
4879
5208
|
dataRoot,
|
|
4880
5209
|
dataAgentRoot,
|
|
4881
|
-
pluginsDir:
|
|
4882
|
-
sessionsRoot:
|
|
5210
|
+
pluginsDir: join15(dataRoot, "plugins"),
|
|
5211
|
+
sessionsRoot: join15(dataAgentRoot, "sessions")
|
|
4883
5212
|
};
|
|
4884
5213
|
}
|
|
4885
5214
|
function getOmpAgentDir() {
|
|
@@ -4889,7 +5218,7 @@ function getOmpPluginsDir() {
|
|
|
4889
5218
|
return resolveOmpPaths().pluginsDir;
|
|
4890
5219
|
}
|
|
4891
5220
|
function getOmpPluginsLockPath() {
|
|
4892
|
-
return
|
|
5221
|
+
return join15(getOmpPluginsDir(), "omp-plugins.lock.json");
|
|
4893
5222
|
}
|
|
4894
5223
|
function getOmpSessionsRoot() {
|
|
4895
5224
|
return resolveOmpPaths().sessionsRoot;
|
|
@@ -4901,21 +5230,21 @@ function getOmpPackageDir() {
|
|
|
4901
5230
|
if (value === "~")
|
|
4902
5231
|
return envFirstHomeDir();
|
|
4903
5232
|
if (value.startsWith("~/") || value.startsWith("~\\")) {
|
|
4904
|
-
return
|
|
5233
|
+
return resolve9(envFirstHomeDir(), value.slice(2));
|
|
4905
5234
|
}
|
|
4906
|
-
return
|
|
5235
|
+
return resolve9(value);
|
|
4907
5236
|
}
|
|
4908
5237
|
var init_omp_paths = () => {};
|
|
4909
5238
|
|
|
4910
5239
|
// src/lib/omp-helpers.ts
|
|
4911
|
-
import { accessSync as accessSync2, constants as
|
|
4912
|
-
import { homedir as
|
|
4913
|
-
import { delimiter as delimiter2, extname, join as
|
|
5240
|
+
import { accessSync as accessSync2, constants as constants3, existsSync as existsSync10, readFileSync as readFileSync7, statSync as statSync8 } from "node:fs";
|
|
5241
|
+
import { homedir as homedir12 } from "node:os";
|
|
5242
|
+
import { delimiter as delimiter2, extname, join as join16, resolve as resolve10 } from "node:path";
|
|
4914
5243
|
function isExecutableFile(path, platform = process.platform) {
|
|
4915
5244
|
try {
|
|
4916
5245
|
if (!existsSync10(path) || !statSync8(path).isFile())
|
|
4917
5246
|
return false;
|
|
4918
|
-
accessSync2(path, platform === "win32" ?
|
|
5247
|
+
accessSync2(path, platform === "win32" ? constants3.F_OK : constants3.X_OK);
|
|
4919
5248
|
return true;
|
|
4920
5249
|
} catch {
|
|
4921
5250
|
return false;
|
|
@@ -4930,7 +5259,7 @@ function findOnPath(name, pathValue = process.env.PATH ?? "", platform = process
|
|
|
4930
5259
|
if (!directory)
|
|
4931
5260
|
continue;
|
|
4932
5261
|
for (const candidateName of executableNames2(name, platform)) {
|
|
4933
|
-
const candidate =
|
|
5262
|
+
const candidate = resolve10(directory, candidateName);
|
|
4934
5263
|
if (isExecutableFile(candidate, platform))
|
|
4935
5264
|
return candidate;
|
|
4936
5265
|
}
|
|
@@ -4942,10 +5271,10 @@ function detectOmpPackageCli() {
|
|
|
4942
5271
|
if (!packageDir || !findOnPath("bun"))
|
|
4943
5272
|
return null;
|
|
4944
5273
|
try {
|
|
4945
|
-
const manifest = JSON.parse(readFileSync7(
|
|
5274
|
+
const manifest = JSON.parse(readFileSync7(join16(packageDir, "package.json"), "utf8"));
|
|
4946
5275
|
if (manifest.name !== OMP_HOST_PACKAGE)
|
|
4947
5276
|
return null;
|
|
4948
|
-
const cli =
|
|
5277
|
+
const cli = join16(packageDir, "dist", "cli.js");
|
|
4949
5278
|
return existsSync10(cli) ? cli : null;
|
|
4950
5279
|
} catch {
|
|
4951
5280
|
return null;
|
|
@@ -4966,13 +5295,13 @@ function getOmpCommandInvocation(ompPath, args) {
|
|
|
4966
5295
|
}
|
|
4967
5296
|
function getOmpFallbackCandidates(platform, home, appData) {
|
|
4968
5297
|
if (platform !== "win32") {
|
|
4969
|
-
return [
|
|
5298
|
+
return [join16(home, ".bun", "bin", "omp"), join16(home, ".local", "bin", "omp")];
|
|
4970
5299
|
}
|
|
4971
5300
|
const npmRoot = appData?.trim();
|
|
4972
5301
|
return [
|
|
4973
|
-
...npmRoot ? [
|
|
4974
|
-
|
|
4975
|
-
|
|
5302
|
+
...npmRoot ? [join16(npmRoot, "npm", "omp.cmd"), join16(npmRoot, "npm", "omp.exe")] : [],
|
|
5303
|
+
join16(home, ".bun", "bin", "omp.exe"),
|
|
5304
|
+
join16(home, ".bun", "bin", "omp.cmd")
|
|
4976
5305
|
];
|
|
4977
5306
|
}
|
|
4978
5307
|
function detectOmpBinary() {
|
|
@@ -4982,7 +5311,7 @@ function detectOmpBinary() {
|
|
|
4982
5311
|
const fromPackage = detectOmpPackageCli();
|
|
4983
5312
|
if (fromPackage)
|
|
4984
5313
|
return { path: fromPackage, source: "package" };
|
|
4985
|
-
const home = process.env.HOME?.trim() ||
|
|
5314
|
+
const home = process.env.HOME?.trim() || homedir12();
|
|
4986
5315
|
const candidate = getOmpFallbackCandidates(process.platform, home, process.env.APPDATA).find((path) => isExecutableFile(path));
|
|
4987
5316
|
return candidate ? { path: candidate, source: "home" } : null;
|
|
4988
5317
|
}
|
|
@@ -5055,7 +5384,7 @@ var init_omp_helpers = __esm(() => {
|
|
|
5055
5384
|
|
|
5056
5385
|
// src/adapters/omp.ts
|
|
5057
5386
|
import { existsSync as existsSync11, readFileSync as readFileSync8 } from "node:fs";
|
|
5058
|
-
import { join as
|
|
5387
|
+
import { join as join17 } from "node:path";
|
|
5059
5388
|
|
|
5060
5389
|
class OmpAdapter {
|
|
5061
5390
|
kind = "omp";
|
|
@@ -5197,12 +5526,12 @@ class OmpAdapter {
|
|
|
5197
5526
|
describeStorageSubtrees() {
|
|
5198
5527
|
const storage = this.getStorageDir();
|
|
5199
5528
|
return {
|
|
5200
|
-
index: dirSize(
|
|
5201
|
-
semantic: dirSize(
|
|
5202
|
-
backups: dirSize(
|
|
5203
|
-
url_cache: dirSize(
|
|
5204
|
-
onnxruntime: dirSize(
|
|
5205
|
-
logs: dirSize(
|
|
5529
|
+
index: dirSize(join17(storage, "index")),
|
|
5530
|
+
semantic: dirSize(join17(storage, "semantic")),
|
|
5531
|
+
backups: dirSize(join17(storage, "backups")),
|
|
5532
|
+
url_cache: dirSize(join17(storage, "url_cache")),
|
|
5533
|
+
onnxruntime: dirSize(join17(storage, "onnxruntime")),
|
|
5534
|
+
logs: dirSize(join17(storage, "logs"))
|
|
5206
5535
|
};
|
|
5207
5536
|
}
|
|
5208
5537
|
readRuntimeEnabled(configPath) {
|
|
@@ -5240,8 +5569,8 @@ var init_omp = __esm(() => {
|
|
|
5240
5569
|
|
|
5241
5570
|
// src/lib/fs-errors.ts
|
|
5242
5571
|
import { existsSync as existsSync12, statSync as statSync9 } from "node:fs";
|
|
5243
|
-
import { homedir as
|
|
5244
|
-
import { dirname as
|
|
5572
|
+
import { homedir as homedir13 } from "node:os";
|
|
5573
|
+
import { dirname as dirname6, resolve as resolve11, sep as sep2 } from "node:path";
|
|
5245
5574
|
function errorCode(error) {
|
|
5246
5575
|
if (typeof error === "object" && error !== null && "code" in error) {
|
|
5247
5576
|
const code = error.code;
|
|
@@ -5271,10 +5600,8 @@ function errorPath(error) {
|
|
|
5271
5600
|
const native = message.match(/\b(?:write|update|create|open|read|mkdir|rename)\s+((?:[A-Za-z]:)?[\\/][^:\n]+?):\s/i);
|
|
5272
5601
|
return native?.[1] ?? null;
|
|
5273
5602
|
}
|
|
5274
|
-
function tildePath(path, home =
|
|
5275
|
-
|
|
5276
|
-
return "~";
|
|
5277
|
-
return path.startsWith(home + sep) ? `~${path.slice(home.length)}` : path;
|
|
5603
|
+
function tildePath(path, home = homedir13()) {
|
|
5604
|
+
return shortenHomePath(path, home);
|
|
5278
5605
|
}
|
|
5279
5606
|
function shellPath(path) {
|
|
5280
5607
|
if (/^[\w@%+=:,./~-]+$/.test(path))
|
|
@@ -5284,10 +5611,10 @@ function shellPath(path) {
|
|
|
5284
5611
|
return `'${path.replace(/'/g, "'\\''")}'`;
|
|
5285
5612
|
}
|
|
5286
5613
|
function describePermissionProblem(target, facts = defaultFacts) {
|
|
5287
|
-
const home =
|
|
5288
|
-
let existing =
|
|
5289
|
-
while (!facts.exists(existing) &&
|
|
5290
|
-
existing =
|
|
5614
|
+
const home = resolve11(facts.home());
|
|
5615
|
+
let existing = resolve11(target);
|
|
5616
|
+
while (!facts.exists(existing) && dirname6(existing) !== existing)
|
|
5617
|
+
existing = dirname6(existing);
|
|
5291
5618
|
const ownerUid = facts.ownerUid(existing);
|
|
5292
5619
|
const me = facts.currentUid();
|
|
5293
5620
|
const shownTarget = tildePath(target, home);
|
|
@@ -5301,8 +5628,8 @@ function describePermissionProblem(target, facts = defaultFacts) {
|
|
|
5301
5628
|
}
|
|
5302
5629
|
let widest = existing;
|
|
5303
5630
|
while (true) {
|
|
5304
|
-
const parent =
|
|
5305
|
-
if (parent === widest || parent === home || !parent.startsWith(home +
|
|
5631
|
+
const parent = dirname6(widest);
|
|
5632
|
+
if (parent === widest || parent === home || !parent.startsWith(home + sep2))
|
|
5306
5633
|
break;
|
|
5307
5634
|
if (facts.ownerUid(parent) !== ownerUid)
|
|
5308
5635
|
break;
|
|
@@ -5352,7 +5679,7 @@ var init_fs_errors = __esm(() => {
|
|
|
5352
5679
|
return false;
|
|
5353
5680
|
}
|
|
5354
5681
|
},
|
|
5355
|
-
home: () =>
|
|
5682
|
+
home: () => homedir13()
|
|
5356
5683
|
};
|
|
5357
5684
|
});
|
|
5358
5685
|
|
|
@@ -13115,7 +13442,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
13115
13442
|
|
|
13116
13443
|
// src/lib/jsonc.ts
|
|
13117
13444
|
import { existsSync as existsSync13, mkdirSync as mkdirSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync4 } from "node:fs";
|
|
13118
|
-
import { dirname as
|
|
13445
|
+
import { dirname as dirname7 } from "node:path";
|
|
13119
13446
|
function detectJsoncFile(configDir, baseName) {
|
|
13120
13447
|
const jsoncPath = `${configDir}/${baseName}.jsonc`;
|
|
13121
13448
|
const jsonPath = `${configDir}/${baseName}.json`;
|
|
@@ -13143,7 +13470,7 @@ function readJsoncFile(path) {
|
|
|
13143
13470
|
}
|
|
13144
13471
|
}
|
|
13145
13472
|
function writeJsoncFile(path, value, format = "json") {
|
|
13146
|
-
mkdirSync4(
|
|
13473
|
+
mkdirSync4(dirname7(path), { recursive: true });
|
|
13147
13474
|
const serialized = format === "jsonc" ? import_comment_json.stringify(value, null, 2) : JSON.stringify(value, null, 2);
|
|
13148
13475
|
writeFileSync4(path, `${serialized}
|
|
13149
13476
|
`);
|
|
@@ -13359,15 +13686,16 @@ function pluginConfigNeedsUpdate(value, version, hasLocalAftEntry = () => false,
|
|
|
13359
13686
|
return !pluginEntryFitsKey(list[local.index], key);
|
|
13360
13687
|
return true;
|
|
13361
13688
|
}
|
|
13362
|
-
function
|
|
13689
|
+
function hostToolPluginDisabled(value, hostTool) {
|
|
13363
13690
|
const list = value?.plugins;
|
|
13364
|
-
return Array.isArray(list) && list.includes(
|
|
13691
|
+
return Array.isArray(list) && list.includes(OPENCODE_HOST_TOOLS[hostTool].disableEntry);
|
|
13365
13692
|
}
|
|
13366
|
-
function
|
|
13693
|
+
function setHostToolPluginDisabled(value, hostTool, disabled) {
|
|
13694
|
+
const entry = OPENCODE_HOST_TOOLS[hostTool].disableEntry;
|
|
13367
13695
|
const existing = Array.isArray(value.plugins) ? value.plugins : null;
|
|
13368
13696
|
const indexes = [];
|
|
13369
13697
|
existing?.forEach((entry, index) => {
|
|
13370
|
-
if (entry ===
|
|
13698
|
+
if (entry === OPENCODE_HOST_TOOLS[hostTool].disableEntry)
|
|
13371
13699
|
indexes.push(index);
|
|
13372
13700
|
});
|
|
13373
13701
|
if (disabled ? indexes.length === 1 : indexes.length === 0)
|
|
@@ -13380,17 +13708,19 @@ function setHostShellPluginDisabled(value, disabled) {
|
|
|
13380
13708
|
list.splice(remove[index], 1);
|
|
13381
13709
|
}
|
|
13382
13710
|
if (disabled && indexes.length === 0)
|
|
13383
|
-
list.push(
|
|
13711
|
+
list.push(entry);
|
|
13384
13712
|
return { changed: true };
|
|
13385
13713
|
}
|
|
13386
|
-
function
|
|
13714
|
+
function aftHostReplacementEnabled(userConfig, hostTool) {
|
|
13387
13715
|
if (!userConfig)
|
|
13388
13716
|
return true;
|
|
13389
13717
|
if (userConfig.enabled === false)
|
|
13390
13718
|
return false;
|
|
13391
13719
|
const disabled = userConfig.disabled_tools;
|
|
13392
|
-
if (Array.isArray(disabled) && disabled.includes(
|
|
13720
|
+
if (Array.isArray(disabled) && disabled.includes(OPENCODE_HOST_TOOLS[hostTool].aftTool))
|
|
13393
13721
|
return false;
|
|
13722
|
+
if (hostTool !== "shell")
|
|
13723
|
+
return true;
|
|
13394
13724
|
const bash = userConfig.bash;
|
|
13395
13725
|
if (bash === false)
|
|
13396
13726
|
return false;
|
|
@@ -13399,30 +13729,35 @@ function aftBashEnabled(userConfig) {
|
|
|
13399
13729
|
}
|
|
13400
13730
|
return true;
|
|
13401
13731
|
}
|
|
13402
|
-
var AFT_OPENCODE_PACKAGE = "@cortexkit/aft-opencode", MODERN_V1_VERSION, EXACT_VERSION, OPENCODE_HOST_SHELL_DISABLE_ENTRY = "-opencode.tool.shell";
|
|
13732
|
+
var AFT_OPENCODE_PACKAGE = "@cortexkit/aft-opencode", MODERN_V1_VERSION, EXACT_VERSION, OPENCODE_HOST_SHELL_DISABLE_ENTRY = "-opencode.tool.shell", OPENCODE_HOST_PATCH_DISABLE_ENTRY = "-opencode.tool.patch", OPENCODE_HOST_TOOLS, OPENCODE_HOST_TOOL_NAMES;
|
|
13403
13733
|
var init_opencode_config = __esm(() => {
|
|
13404
13734
|
init_opencode_version();
|
|
13405
13735
|
MODERN_V1_VERSION = opencode_version_default.trim();
|
|
13406
13736
|
EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
13737
|
+
OPENCODE_HOST_TOOLS = {
|
|
13738
|
+
shell: { aftTool: "bash", disableEntry: OPENCODE_HOST_SHELL_DISABLE_ENTRY },
|
|
13739
|
+
patch: { aftTool: "apply_patch", disableEntry: OPENCODE_HOST_PATCH_DISABLE_ENTRY }
|
|
13740
|
+
};
|
|
13741
|
+
OPENCODE_HOST_TOOL_NAMES = Object.keys(OPENCODE_HOST_TOOLS);
|
|
13407
13742
|
});
|
|
13408
13743
|
|
|
13409
13744
|
// src/setup/host-generation.ts
|
|
13410
|
-
import { createHash as
|
|
13745
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
13411
13746
|
import {
|
|
13412
|
-
closeSync as
|
|
13747
|
+
closeSync as closeSync7,
|
|
13413
13748
|
existsSync as existsSync14,
|
|
13414
13749
|
mkdirSync as mkdirSync5,
|
|
13415
13750
|
mkdtempSync,
|
|
13416
|
-
openSync as
|
|
13751
|
+
openSync as openSync7,
|
|
13417
13752
|
readdirSync as readdirSync6,
|
|
13418
13753
|
readFileSync as readFileSync10,
|
|
13419
|
-
readSync as
|
|
13420
|
-
realpathSync as
|
|
13754
|
+
readSync as readSync5,
|
|
13755
|
+
realpathSync as realpathSync4,
|
|
13421
13756
|
rmSync as rmSync3,
|
|
13422
13757
|
statSync as statSync10
|
|
13423
13758
|
} from "node:fs";
|
|
13424
|
-
import { homedir as
|
|
13425
|
-
import { dirname as
|
|
13759
|
+
import { homedir as homedir14, tmpdir as tmpdir3 } from "node:os";
|
|
13760
|
+
import { dirname as dirname8, join as join18, parse as parse2 } from "node:path";
|
|
13426
13761
|
function findExecutableOnPath2(name, pathValue = process.env.PATH ?? "", platform = process.platform) {
|
|
13427
13762
|
return findExecutableOnPath(name, { pathValue, platform });
|
|
13428
13763
|
}
|
|
@@ -13437,31 +13772,63 @@ function packageMetadataAt(path, expectedName) {
|
|
|
13437
13772
|
function packageMetadataNearExecutable(executable, expectedName) {
|
|
13438
13773
|
let current;
|
|
13439
13774
|
try {
|
|
13440
|
-
current =
|
|
13775
|
+
current = dirname8(realpathSync4(executable));
|
|
13441
13776
|
} catch {
|
|
13442
|
-
current =
|
|
13777
|
+
current = dirname8(executable);
|
|
13443
13778
|
}
|
|
13444
13779
|
while (true) {
|
|
13445
|
-
const direct = packageMetadataAt(
|
|
13780
|
+
const direct = packageMetadataAt(join18(current, "package.json"), expectedName);
|
|
13446
13781
|
if (direct)
|
|
13447
13782
|
return direct;
|
|
13448
|
-
const parent =
|
|
13449
|
-
if (parent === current || current ===
|
|
13783
|
+
const parent = dirname8(current);
|
|
13784
|
+
if (parent === current || current === parse2(current).root)
|
|
13450
13785
|
return null;
|
|
13451
13786
|
current = parent;
|
|
13452
13787
|
}
|
|
13453
13788
|
}
|
|
13789
|
+
function npmLauncherTarget(launcher) {
|
|
13790
|
+
let source;
|
|
13791
|
+
try {
|
|
13792
|
+
if (statSync10(launcher).size > LAUNCHER_MAX_BYTES)
|
|
13793
|
+
return null;
|
|
13794
|
+
source = readFileSync10(launcher, "utf8");
|
|
13795
|
+
} catch {
|
|
13796
|
+
return null;
|
|
13797
|
+
}
|
|
13798
|
+
const operands = [...source.matchAll(CMD_LAUNCHER_PATH)];
|
|
13799
|
+
if (operands.length === 0)
|
|
13800
|
+
operands.push(...source.matchAll(SH_LAUNCHER_PATH));
|
|
13801
|
+
const relativeTarget = operands.at(-1)?.[1];
|
|
13802
|
+
if (!relativeTarget)
|
|
13803
|
+
return null;
|
|
13804
|
+
const target = join18(dirname8(launcher), ...relativeTarget.split(/[\\/]+/).filter(Boolean));
|
|
13805
|
+
try {
|
|
13806
|
+
return statSync10(target).isFile() ? target : null;
|
|
13807
|
+
} catch {
|
|
13808
|
+
return null;
|
|
13809
|
+
}
|
|
13810
|
+
}
|
|
13811
|
+
function hostLaunchPath(executable, platform) {
|
|
13812
|
+
const isBatch = BATCH_FILE.test(executable);
|
|
13813
|
+
const isScript = isBatch || platform === "win32" && !/\.(?:exe|com)$/i.test(executable);
|
|
13814
|
+
if (!isScript)
|
|
13815
|
+
return executable;
|
|
13816
|
+
const target = npmLauncherTarget(executable);
|
|
13817
|
+
if (target)
|
|
13818
|
+
return target;
|
|
13819
|
+
return isBatch ? null : executable;
|
|
13820
|
+
}
|
|
13454
13821
|
function packageVersion(metadata) {
|
|
13455
13822
|
return typeof metadata?.version === "string" && metadata.version.length > 0 ? metadata.version : null;
|
|
13456
13823
|
}
|
|
13457
13824
|
function hashFileBytes(hash, path, size) {
|
|
13458
13825
|
const buffer = Buffer.allocUnsafe(Math.min(Math.max(size, 1), PARTIAL_CONTENT_WINDOW_BYTES));
|
|
13459
|
-
const descriptor =
|
|
13826
|
+
const descriptor = openSync7(path, "r");
|
|
13460
13827
|
try {
|
|
13461
13828
|
if (size <= FULL_CONTENT_HASH_MAX_BYTES) {
|
|
13462
13829
|
let position = 0;
|
|
13463
13830
|
while (position < size) {
|
|
13464
|
-
const read =
|
|
13831
|
+
const read = readSync5(descriptor, buffer, 0, buffer.length, position);
|
|
13465
13832
|
if (read <= 0)
|
|
13466
13833
|
break;
|
|
13467
13834
|
hash.update(buffer.subarray(0, read));
|
|
@@ -13470,19 +13837,19 @@ function hashFileBytes(hash, path, size) {
|
|
|
13470
13837
|
return;
|
|
13471
13838
|
}
|
|
13472
13839
|
hash.update("partial\x00");
|
|
13473
|
-
const head =
|
|
13840
|
+
const head = readSync5(descriptor, buffer, 0, buffer.length, 0);
|
|
13474
13841
|
hash.update(buffer.subarray(0, Math.max(head, 0)));
|
|
13475
13842
|
const tailStart = Math.max(size - PARTIAL_CONTENT_WINDOW_BYTES, 0);
|
|
13476
|
-
const tail =
|
|
13843
|
+
const tail = readSync5(descriptor, buffer, 0, buffer.length, tailStart);
|
|
13477
13844
|
hash.update(buffer.subarray(0, Math.max(tail, 0)));
|
|
13478
13845
|
} finally {
|
|
13479
|
-
|
|
13846
|
+
closeSync7(descriptor);
|
|
13480
13847
|
}
|
|
13481
13848
|
}
|
|
13482
13849
|
function snapshotTree(path) {
|
|
13483
13850
|
if (!existsSync14(path))
|
|
13484
13851
|
return "missing";
|
|
13485
|
-
const hash =
|
|
13852
|
+
const hash = createHash4("sha256");
|
|
13486
13853
|
const visit = (current, relativePath) => {
|
|
13487
13854
|
let info;
|
|
13488
13855
|
try {
|
|
@@ -13494,7 +13861,7 @@ function snapshotTree(path) {
|
|
|
13494
13861
|
hash.update(`${relativePath}\x00${info.mode}\x00${info.size}\x00${info.mtimeMs}\x00`);
|
|
13495
13862
|
if (info.isDirectory()) {
|
|
13496
13863
|
for (const entry of readdirSync6(current).sort()) {
|
|
13497
|
-
visit(
|
|
13864
|
+
visit(join18(current, entry), join18(relativePath, entry));
|
|
13498
13865
|
}
|
|
13499
13866
|
return;
|
|
13500
13867
|
}
|
|
@@ -13510,31 +13877,34 @@ function snapshotTree(path) {
|
|
|
13510
13877
|
return hash.digest("hex");
|
|
13511
13878
|
}
|
|
13512
13879
|
function snapshotOperatorState(operatorHome) {
|
|
13513
|
-
const database =
|
|
13880
|
+
const database = join18(operatorHome, ".local", "share", "opencode", "opencode.db");
|
|
13514
13881
|
return JSON.stringify({
|
|
13515
13882
|
database: snapshotTree(database),
|
|
13516
13883
|
databaseWal: snapshotTree(`${database}-wal`),
|
|
13517
13884
|
databaseShm: snapshotTree(`${database}-shm`),
|
|
13518
|
-
logs: snapshotTree(
|
|
13885
|
+
logs: snapshotTree(join18(operatorHome, ".local", "share", "opencode", "log"))
|
|
13519
13886
|
});
|
|
13520
13887
|
}
|
|
13521
13888
|
function probeCreatedIsolatedState(dataRoot, stateRoot) {
|
|
13522
13889
|
return [dataRoot, stateRoot].some((root) => {
|
|
13523
|
-
const opencodeRoot =
|
|
13524
|
-
const database =
|
|
13525
|
-
return [database, `${database}-wal`, `${database}-shm`,
|
|
13890
|
+
const opencodeRoot = join18(root, "opencode");
|
|
13891
|
+
const database = join18(opencodeRoot, "opencode.db");
|
|
13892
|
+
return [database, `${database}-wal`, `${database}-shm`, join18(opencodeRoot, "log")].some(existsSync14);
|
|
13526
13893
|
});
|
|
13527
13894
|
}
|
|
13528
13895
|
function probeOpenCodeV1Version(executable, options = {}) {
|
|
13529
|
-
const
|
|
13896
|
+
const launchPath = hostLaunchPath(executable, options.platform ?? process.platform);
|
|
13897
|
+
if (launchPath === null)
|
|
13898
|
+
return null;
|
|
13899
|
+
const operatorHome = options.operatorHome ?? homedir14();
|
|
13530
13900
|
const before = snapshotOperatorState(operatorHome);
|
|
13531
|
-
const root = mkdtempSync(
|
|
13532
|
-
const home =
|
|
13533
|
-
const config =
|
|
13534
|
-
const data =
|
|
13535
|
-
const state =
|
|
13536
|
-
const cache =
|
|
13537
|
-
const project =
|
|
13901
|
+
const root = mkdtempSync(join18(options.tempParent ?? tmpdir3(), "aft-opencode-probe-"));
|
|
13902
|
+
const home = join18(root, "home");
|
|
13903
|
+
const config = join18(root, "config");
|
|
13904
|
+
const data = join18(root, "data");
|
|
13905
|
+
const state = join18(root, "state");
|
|
13906
|
+
const cache = join18(root, "cache");
|
|
13907
|
+
const project = join18(root, "project");
|
|
13538
13908
|
for (const directory of [home, config, data, state, cache, project]) {
|
|
13539
13909
|
mkdirSync5(directory, { recursive: true });
|
|
13540
13910
|
}
|
|
@@ -13545,7 +13915,7 @@ function probeOpenCodeV1Version(executable, options = {}) {
|
|
|
13545
13915
|
XDG_DATA_HOME: data,
|
|
13546
13916
|
XDG_STATE_HOME: state,
|
|
13547
13917
|
XDG_CACHE_HOME: cache,
|
|
13548
|
-
TMPDIR:
|
|
13918
|
+
TMPDIR: join18(root, "tmp")
|
|
13549
13919
|
};
|
|
13550
13920
|
mkdirSync5(env.TMPDIR, { recursive: true });
|
|
13551
13921
|
delete env.OPENCODE_CONFIG;
|
|
@@ -13555,7 +13925,7 @@ function probeOpenCodeV1Version(executable, options = {}) {
|
|
|
13555
13925
|
let result;
|
|
13556
13926
|
let probeError;
|
|
13557
13927
|
try {
|
|
13558
|
-
result = (options.spawn ?? spawnSync)(
|
|
13928
|
+
result = (options.spawn ?? spawnSync)(launchPath, ["--standalone", "--version"], {
|
|
13559
13929
|
cwd: project,
|
|
13560
13930
|
encoding: "utf8",
|
|
13561
13931
|
env,
|
|
@@ -13605,7 +13975,7 @@ function isV2Version(version) {
|
|
|
13605
13975
|
}
|
|
13606
13976
|
function resolvedPath(executable) {
|
|
13607
13977
|
try {
|
|
13608
|
-
return
|
|
13978
|
+
return realpathSync4(executable);
|
|
13609
13979
|
} catch {
|
|
13610
13980
|
return executable;
|
|
13611
13981
|
}
|
|
@@ -13614,13 +13984,18 @@ function detectOpenCodeHostGeneration(dependencies = {}) {
|
|
|
13614
13984
|
const findExecutable = dependencies.findExecutable ?? ((name) => findExecutableOnPath2(name, dependencies.path, dependencies.platform));
|
|
13615
13985
|
const openCodeExecutable = findExecutable("opencode");
|
|
13616
13986
|
const openCode2Executable = findExecutable("opencode2");
|
|
13987
|
+
const platform = dependencies.platform ?? process.platform;
|
|
13988
|
+
const hostOf = (executable) => executable === null ? null : hostLaunchPath(executable, platform) ?? executable;
|
|
13989
|
+
const openCodeHost = hostOf(openCodeExecutable);
|
|
13990
|
+
const openCode2Host = hostOf(openCode2Executable);
|
|
13617
13991
|
const evidence = [];
|
|
13618
|
-
const sharedExecutable =
|
|
13619
|
-
if (openCodeExecutable) {
|
|
13620
|
-
const v1Metadata = packageMetadataNearExecutable(
|
|
13621
|
-
const v2Metadata = v2MetadataNearExecutable(
|
|
13992
|
+
const sharedExecutable = openCodeHost !== null && openCode2Host !== null && resolvedPath(openCodeHost) === resolvedPath(openCode2Host);
|
|
13993
|
+
if (openCodeExecutable !== null && openCodeHost !== null) {
|
|
13994
|
+
const v1Metadata = packageMetadataNearExecutable(openCodeHost, "opencode-ai");
|
|
13995
|
+
const v2Metadata = v2MetadataNearExecutable(openCodeHost);
|
|
13622
13996
|
const metadataVersion = packageVersion(v2Metadata) ?? packageVersion(v1Metadata);
|
|
13623
|
-
const
|
|
13997
|
+
const probeVersion = dependencies.probeV1Version ?? ((executable) => probeOpenCodeV1Version(executable, { platform }));
|
|
13998
|
+
const version = metadataVersion ?? probeVersion(openCodeExecutable);
|
|
13624
13999
|
const isV2 = Boolean(v2Metadata) || sharedExecutable || isV2Version(version);
|
|
13625
14000
|
evidence.push({
|
|
13626
14001
|
generation: isV2 ? "v2" : "v1",
|
|
@@ -13630,8 +14005,8 @@ function detectOpenCodeHostGeneration(dependencies = {}) {
|
|
|
13630
14005
|
modernV1: !isV2 && version === MODERN_V1_VERSION
|
|
13631
14006
|
});
|
|
13632
14007
|
}
|
|
13633
|
-
if (openCode2Executable && !sharedExecutable) {
|
|
13634
|
-
const version = packageVersion(v2MetadataNearExecutable(
|
|
14008
|
+
if (openCode2Executable !== null && openCode2Host !== null && !sharedExecutable) {
|
|
14009
|
+
const version = packageVersion(v2MetadataNearExecutable(openCode2Host));
|
|
13635
14010
|
evidence.push({
|
|
13636
14011
|
generation: "v2",
|
|
13637
14012
|
executable: openCode2Executable,
|
|
@@ -13667,10 +14042,14 @@ function formatHostGenerations(detection) {
|
|
|
13667
14042
|
return "V2";
|
|
13668
14043
|
return "unknown";
|
|
13669
14044
|
}
|
|
13670
|
-
var FULL_CONTENT_HASH_MAX_BYTES, PARTIAL_CONTENT_WINDOW_BYTES, V2_PACKAGE_NAMES;
|
|
14045
|
+
var LAUNCHER_MAX_BYTES, CMD_LAUNCHER_PATH, SH_LAUNCHER_PATH, BATCH_FILE, FULL_CONTENT_HASH_MAX_BYTES, PARTIAL_CONTENT_WINDOW_BYTES, V2_PACKAGE_NAMES;
|
|
13671
14046
|
var init_host_generation = __esm(() => {
|
|
13672
14047
|
init_dist2();
|
|
13673
14048
|
init_opencode_config();
|
|
14049
|
+
LAUNCHER_MAX_BYTES = 64 * 1024;
|
|
14050
|
+
CMD_LAUNCHER_PATH = /"%~?dp0%?\\([^"%\r\n]+)"/g;
|
|
14051
|
+
SH_LAUNCHER_PATH = /"\$basedir\/([^"$\r\n]+)"/g;
|
|
14052
|
+
BATCH_FILE = /\.(?:cmd|bat)$/i;
|
|
13674
14053
|
FULL_CONTENT_HASH_MAX_BYTES = 64 * 1024 * 1024;
|
|
13675
14054
|
PARTIAL_CONTENT_WINDOW_BYTES = 1024 * 1024;
|
|
13676
14055
|
V2_PACKAGE_NAMES = ["@opencode/cli", "@opencode-ai/cli"];
|
|
@@ -13678,21 +14057,21 @@ var init_host_generation = __esm(() => {
|
|
|
13678
14057
|
|
|
13679
14058
|
// src/adapters/opencode.ts
|
|
13680
14059
|
import { existsSync as existsSync15, readFileSync as readFileSync11, rmSync as rmSync4, statSync as statSync11 } from "node:fs";
|
|
13681
|
-
import { homedir as
|
|
13682
|
-
import { dirname as
|
|
14060
|
+
import { homedir as homedir15 } from "node:os";
|
|
14061
|
+
import { dirname as dirname9, join as join19, parse as parse3, resolve as resolve12 } from "node:path";
|
|
13683
14062
|
import { fileURLToPath } from "node:url";
|
|
13684
14063
|
function getOpenCodeConfigDir() {
|
|
13685
14064
|
const envDir = process.env.OPENCODE_CONFIG_DIR?.trim();
|
|
13686
14065
|
if (envDir)
|
|
13687
|
-
return
|
|
14066
|
+
return resolve12(envDir);
|
|
13688
14067
|
return getOpenCodeConfigRoot();
|
|
13689
14068
|
}
|
|
13690
14069
|
function getLegacyOpenCodePluginCachePath(primaryPath) {
|
|
13691
14070
|
if (process.platform !== "win32")
|
|
13692
14071
|
return null;
|
|
13693
|
-
const localAppData = process.env.LOCALAPPDATA ??
|
|
13694
|
-
const legacyPath =
|
|
13695
|
-
return
|
|
14072
|
+
const localAppData = process.env.LOCALAPPDATA ?? join19(homedir15(), "AppData", "Local");
|
|
14073
|
+
const legacyPath = join19(localAppData, "opencode", "packages", LEGACY_PLUGIN_ENTRY);
|
|
14074
|
+
return resolve12(legacyPath) === resolve12(primaryPath) ? null : legacyPath;
|
|
13696
14075
|
}
|
|
13697
14076
|
function clearLegacyOpenCodePluginCache(primaryPath) {
|
|
13698
14077
|
const legacyPath = getLegacyOpenCodePluginCachePath(primaryPath);
|
|
@@ -13714,12 +14093,12 @@ function hasOpenCodeCli() {
|
|
|
13714
14093
|
function openCodeDesktopAppExists() {
|
|
13715
14094
|
const candidates = [];
|
|
13716
14095
|
if (process.platform === "darwin") {
|
|
13717
|
-
candidates.push("/Applications/OpenCode.app", "/Applications/OpenCode Beta.app",
|
|
14096
|
+
candidates.push("/Applications/OpenCode.app", "/Applications/OpenCode Beta.app", join19(homedir15(), "Applications", "OpenCode.app"), join19(homedir15(), "Applications", "OpenCode Beta.app"));
|
|
13718
14097
|
} else if (process.platform === "win32") {
|
|
13719
|
-
const localAppData = process.env.LOCALAPPDATA ??
|
|
13720
|
-
candidates.push(
|
|
14098
|
+
const localAppData = process.env.LOCALAPPDATA ?? join19(homedir15(), "AppData", "Local");
|
|
14099
|
+
candidates.push(join19(localAppData, "Programs", "opencode"), join19(localAppData, "opencode"));
|
|
13721
14100
|
} else {
|
|
13722
|
-
candidates.push("/opt/OpenCode", "/usr/lib/opencode",
|
|
14101
|
+
candidates.push("/opt/OpenCode", "/usr/lib/opencode", join19(homedir15(), ".local", "share", "applications", "opencode.desktop"));
|
|
13723
14102
|
}
|
|
13724
14103
|
return candidates.some((p) => {
|
|
13725
14104
|
try {
|
|
@@ -13748,16 +14127,16 @@ function pathPointsToOurPlugin(entry) {
|
|
|
13748
14127
|
try {
|
|
13749
14128
|
if (!existsSync15(fsPath))
|
|
13750
14129
|
return false;
|
|
13751
|
-
let searchDir = statSync11(fsPath).isDirectory() ? fsPath :
|
|
14130
|
+
let searchDir = statSync11(fsPath).isDirectory() ? fsPath : dirname9(fsPath);
|
|
13752
14131
|
let pkgJsonPath = null;
|
|
13753
14132
|
while (true) {
|
|
13754
|
-
const candidate =
|
|
14133
|
+
const candidate = join19(searchDir, "package.json");
|
|
13755
14134
|
if (existsSync15(candidate)) {
|
|
13756
14135
|
pkgJsonPath = candidate;
|
|
13757
14136
|
break;
|
|
13758
14137
|
}
|
|
13759
|
-
const parent =
|
|
13760
|
-
if (parent === searchDir || searchDir ===
|
|
14138
|
+
const parent = dirname9(searchDir);
|
|
14139
|
+
if (parent === searchDir || searchDir === parse3(searchDir).root)
|
|
13761
14140
|
break;
|
|
13762
14141
|
searchDir = parent;
|
|
13763
14142
|
}
|
|
@@ -13925,23 +14304,33 @@ class OpenCodeAdapter {
|
|
|
13925
14304
|
};
|
|
13926
14305
|
}
|
|
13927
14306
|
hostShellState() {
|
|
14307
|
+
return this.hostToolState("shell");
|
|
14308
|
+
}
|
|
14309
|
+
hostToolState(hostTool) {
|
|
13928
14310
|
if (this.configGeneration() !== "v2")
|
|
13929
14311
|
return "not_applicable";
|
|
13930
14312
|
const { value } = readJsoncFile(this.detectConfigPaths().harnessConfig);
|
|
13931
|
-
return
|
|
14313
|
+
return hostToolPluginDisabled(value, hostTool) ? "disabled" : "enabled";
|
|
13932
14314
|
}
|
|
13933
14315
|
aftBashEnabled() {
|
|
14316
|
+
return this.aftHostReplacementEnabled("shell");
|
|
14317
|
+
}
|
|
14318
|
+
aftHostReplacementEnabled(hostTool) {
|
|
13934
14319
|
const { value } = readJsoncFile(this.detectConfigPaths().aftConfig);
|
|
13935
|
-
return
|
|
14320
|
+
return aftHostReplacementEnabled(value, hostTool);
|
|
13936
14321
|
}
|
|
13937
14322
|
setHostShellDisabled(disabled) {
|
|
14323
|
+
return this.setHostToolDisabled("shell", disabled);
|
|
14324
|
+
}
|
|
14325
|
+
setHostToolDisabled(hostTool, disabled) {
|
|
14326
|
+
const { disableEntry, aftTool } = OPENCODE_HOST_TOOLS[hostTool];
|
|
13938
14327
|
const configPath = this.detectConfigPaths().harnessConfig;
|
|
13939
14328
|
const format = this.detectConfigPaths().harnessConfigFormat;
|
|
13940
14329
|
if (this.configGeneration() !== "v2") {
|
|
13941
14330
|
return {
|
|
13942
14331
|
ok: false,
|
|
13943
14332
|
action: "error",
|
|
13944
|
-
message:
|
|
14333
|
+
message: `only OpenCode 2 has a built-in ${hostTool} tool plugin to disable`,
|
|
13945
14334
|
configPath
|
|
13946
14335
|
};
|
|
13947
14336
|
}
|
|
@@ -13949,13 +14338,13 @@ class OpenCodeAdapter {
|
|
|
13949
14338
|
if (!disabled) {
|
|
13950
14339
|
return { ok: true, action: "already_present", message: "no config to change", configPath };
|
|
13951
14340
|
}
|
|
13952
|
-
const failed = this.tryWrite(configPath, () => writeJsoncFile(configPath, { plugins: [
|
|
14341
|
+
const failed = this.tryWrite(configPath, () => writeJsoncFile(configPath, { plugins: [disableEntry] }, "json"));
|
|
13953
14342
|
if (failed)
|
|
13954
14343
|
return failed;
|
|
13955
14344
|
return {
|
|
13956
14345
|
ok: true,
|
|
13957
14346
|
action: "added",
|
|
13958
|
-
message: `Created ${configPath} with ${
|
|
14347
|
+
message: `Created ${configPath} with ${disableEntry} under \`plugins\``,
|
|
13959
14348
|
configPath
|
|
13960
14349
|
};
|
|
13961
14350
|
}
|
|
@@ -13968,12 +14357,12 @@ class OpenCodeAdapter {
|
|
|
13968
14357
|
configPath
|
|
13969
14358
|
};
|
|
13970
14359
|
}
|
|
13971
|
-
const { changed } =
|
|
14360
|
+
const { changed } = setHostToolPluginDisabled(value, hostTool, disabled);
|
|
13972
14361
|
if (!changed) {
|
|
13973
14362
|
return {
|
|
13974
14363
|
ok: true,
|
|
13975
14364
|
action: "already_present",
|
|
13976
|
-
message: disabled ? `${
|
|
14365
|
+
message: disabled ? `${disableEntry} is already set in ${configPath}` : `${disableEntry} is not set in ${configPath}`,
|
|
13977
14366
|
configPath
|
|
13978
14367
|
};
|
|
13979
14368
|
}
|
|
@@ -13983,7 +14372,7 @@ class OpenCodeAdapter {
|
|
|
13983
14372
|
return {
|
|
13984
14373
|
ok: true,
|
|
13985
14374
|
action: disabled ? "added" : "updated",
|
|
13986
|
-
message: disabled ? `Added ${
|
|
14375
|
+
message: disabled ? `Added ${disableEntry} under \`plugins\` in ${configPath}: OpenCode's own ${hostTool} tool is disabled, so agents use AFT's ${aftTool}` : `Removed ${disableEntry} from ${configPath}: OpenCode's own ${hostTool} tool is enabled again`,
|
|
13987
14376
|
configPath
|
|
13988
14377
|
};
|
|
13989
14378
|
}
|
|
@@ -14007,10 +14396,10 @@ class OpenCodeAdapter {
|
|
|
14007
14396
|
const configPath = this.detectConfigPaths().harnessConfig;
|
|
14008
14397
|
const { value } = readJsoncFile(configPath);
|
|
14009
14398
|
const configuredEntry = openCodePluginReadKeys(this.configGeneration()).flatMap((key) => Array.isArray(value?.[key]) ? value[key] : []).map(pluginEntryPackage).find(isAftNpmEntry);
|
|
14010
|
-
const path =
|
|
14399
|
+
const path = join19(getOpenCodeCacheDir(), "packages", configuredEntry ?? PLUGIN_ENTRY);
|
|
14011
14400
|
let cached;
|
|
14012
14401
|
try {
|
|
14013
|
-
const installedPkgPath =
|
|
14402
|
+
const installedPkgPath = join19(path, "node_modules", "@cortexkit", "aft-opencode", "package.json");
|
|
14014
14403
|
if (existsSync15(installedPkgPath)) {
|
|
14015
14404
|
const pkg = JSON.parse(readFileSync11(installedPkgPath, "utf-8"));
|
|
14016
14405
|
cached = typeof pkg.version === "string" ? pkg.version : undefined;
|
|
@@ -14086,12 +14475,12 @@ class OpenCodeAdapter {
|
|
|
14086
14475
|
describeStorageSubtrees() {
|
|
14087
14476
|
const storage = this.getStorageDir();
|
|
14088
14477
|
return {
|
|
14089
|
-
index: dirSize(
|
|
14090
|
-
semantic: dirSize(
|
|
14091
|
-
backups: dirSize(
|
|
14092
|
-
url_cache: dirSize(
|
|
14093
|
-
onnxruntime: dirSize(
|
|
14094
|
-
logs: dirSize(
|
|
14478
|
+
index: dirSize(join19(storage, "index")),
|
|
14479
|
+
semantic: dirSize(join19(storage, "semantic")),
|
|
14480
|
+
backups: dirSize(join19(storage, "backups")),
|
|
14481
|
+
url_cache: dirSize(join19(storage, "url_cache")),
|
|
14482
|
+
onnxruntime: dirSize(join19(storage, "onnxruntime")),
|
|
14483
|
+
logs: dirSize(join19(storage, "logs"))
|
|
14095
14484
|
};
|
|
14096
14485
|
}
|
|
14097
14486
|
}
|
|
@@ -14112,18 +14501,18 @@ var init_opencode = __esm(() => {
|
|
|
14112
14501
|
|
|
14113
14502
|
// src/adapters/pi.ts
|
|
14114
14503
|
import { existsSync as existsSync16, readFileSync as readFileSync12 } from "node:fs";
|
|
14115
|
-
import { homedir as
|
|
14116
|
-
import { join as
|
|
14504
|
+
import { homedir as homedir16 } from "node:os";
|
|
14505
|
+
import { join as join20, resolve as resolve13 } from "node:path";
|
|
14117
14506
|
function getPiAgentDir() {
|
|
14118
14507
|
const configuredDir = process.env.PI_CODING_AGENT_DIR?.trim();
|
|
14119
14508
|
if (configuredDir)
|
|
14120
|
-
return
|
|
14509
|
+
return resolve13(configuredDir);
|
|
14121
14510
|
const envHome = process.platform === "win32" ? process.env.USERPROFILE : process.env.HOME;
|
|
14122
|
-
const home = envHome && envHome.length > 0 ? envHome :
|
|
14123
|
-
return
|
|
14511
|
+
const home = envHome && envHome.length > 0 ? envHome : homedir16();
|
|
14512
|
+
return join20(home, ".pi", "agent");
|
|
14124
14513
|
}
|
|
14125
14514
|
function readPiExtensionIndex() {
|
|
14126
|
-
const settingsPath =
|
|
14515
|
+
const settingsPath = join20(getPiAgentDir(), "settings.json");
|
|
14127
14516
|
if (existsSync16(settingsPath)) {
|
|
14128
14517
|
try {
|
|
14129
14518
|
const raw = readFileSync12(settingsPath, "utf-8");
|
|
@@ -14144,10 +14533,10 @@ function readPiExtensionIndex() {
|
|
|
14144
14533
|
} catch {}
|
|
14145
14534
|
}
|
|
14146
14535
|
const candidates = [
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14536
|
+
join20(getPiAgentDir(), "extensions.json"),
|
|
14537
|
+
join20(getPiAgentDir(), "extensions.jsonc"),
|
|
14538
|
+
join20(getPiAgentDir(), "config.json"),
|
|
14539
|
+
join20(getPiAgentDir(), "config.jsonc")
|
|
14151
14540
|
];
|
|
14152
14541
|
for (const path of candidates) {
|
|
14153
14542
|
if (!existsSync16(path))
|
|
@@ -14183,14 +14572,14 @@ function piEntryMatchesAft(entry) {
|
|
|
14183
14572
|
} else if (entry.startsWith("/")) {
|
|
14184
14573
|
resolved = entry;
|
|
14185
14574
|
} else if (entry.length > 0) {
|
|
14186
|
-
resolved =
|
|
14575
|
+
resolved = join20(getPiAgentDir(), entry);
|
|
14187
14576
|
}
|
|
14188
14577
|
if (!resolved)
|
|
14189
14578
|
return false;
|
|
14190
14579
|
try {
|
|
14191
14580
|
if (!existsSync16(resolved))
|
|
14192
14581
|
return false;
|
|
14193
|
-
const pkgPath =
|
|
14582
|
+
const pkgPath = join20(resolved, "package.json");
|
|
14194
14583
|
if (!existsSync16(pkgPath))
|
|
14195
14584
|
return false;
|
|
14196
14585
|
const pkg = JSON.parse(readFileSync12(pkgPath, "utf-8"));
|
|
@@ -14242,7 +14631,7 @@ class PiAdapter {
|
|
|
14242
14631
|
const aftConfigExists = existsSync16(aftConfigPath);
|
|
14243
14632
|
return {
|
|
14244
14633
|
configDir,
|
|
14245
|
-
harnessConfig: index.path ??
|
|
14634
|
+
harnessConfig: index.path ?? join20(configDir, "extensions.json"),
|
|
14246
14635
|
harnessConfigFormat: index.path ? "json" : "none",
|
|
14247
14636
|
aftConfig: aftConfigPath,
|
|
14248
14637
|
aftConfigFormat: aftConfigExists ? "jsonc" : "none"
|
|
@@ -14287,9 +14676,9 @@ class PiAdapter {
|
|
|
14287
14676
|
}
|
|
14288
14677
|
getPluginCacheInfo() {
|
|
14289
14678
|
const candidates = [
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14679
|
+
join20(getPiAgentDir(), "npm", "node_modules", "@cortexkit", "aft-pi", "package.json"),
|
|
14680
|
+
join20(getPiAgentDir(), "node_modules", "@cortexkit", "aft-pi", "package.json"),
|
|
14681
|
+
join20(getPiAgentDir(), "extensions", "node_modules", "@cortexkit", "aft-pi", "package.json")
|
|
14293
14682
|
];
|
|
14294
14683
|
for (const candidate of candidates) {
|
|
14295
14684
|
if (!existsSync16(candidate))
|
|
@@ -14306,7 +14695,7 @@ class PiAdapter {
|
|
|
14306
14695
|
} catch {}
|
|
14307
14696
|
}
|
|
14308
14697
|
return {
|
|
14309
|
-
path:
|
|
14698
|
+
path: join20(getPiAgentDir(), "npm", "node_modules", "@cortexkit", "aft-pi", "package.json"),
|
|
14310
14699
|
exists: false
|
|
14311
14700
|
};
|
|
14312
14701
|
}
|
|
@@ -14328,12 +14717,12 @@ class PiAdapter {
|
|
|
14328
14717
|
describeStorageSubtrees() {
|
|
14329
14718
|
const storage = this.getStorageDir();
|
|
14330
14719
|
return {
|
|
14331
|
-
index: dirSize(
|
|
14332
|
-
semantic: dirSize(
|
|
14333
|
-
backups: dirSize(
|
|
14334
|
-
url_cache: dirSize(
|
|
14335
|
-
onnxruntime: dirSize(
|
|
14336
|
-
logs: dirSize(
|
|
14720
|
+
index: dirSize(join20(storage, "index")),
|
|
14721
|
+
semantic: dirSize(join20(storage, "semantic")),
|
|
14722
|
+
backups: dirSize(join20(storage, "backups")),
|
|
14723
|
+
url_cache: dirSize(join20(storage, "url_cache")),
|
|
14724
|
+
onnxruntime: dirSize(join20(storage, "onnxruntime")),
|
|
14725
|
+
logs: dirSize(join20(storage, "logs"))
|
|
14337
14726
|
};
|
|
14338
14727
|
}
|
|
14339
14728
|
}
|
|
@@ -15754,11 +16143,11 @@ var init_version = __esm(async () => {
|
|
|
15754
16143
|
|
|
15755
16144
|
// src/lib/cli-logger.ts
|
|
15756
16145
|
import { appendFileSync, mkdirSync as mkdirSync6 } from "node:fs";
|
|
15757
|
-
import { tmpdir as
|
|
15758
|
-
import { dirname as
|
|
16146
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
16147
|
+
import { dirname as dirname10, join as join21 } from "node:path";
|
|
15759
16148
|
function cliLogPath() {
|
|
15760
16149
|
if (isTestEnvironment())
|
|
15761
|
-
return
|
|
16150
|
+
return join21(tmpdir4(), "aft-cli-test.log");
|
|
15762
16151
|
return resolveAftLogPath("aft-cli.log");
|
|
15763
16152
|
}
|
|
15764
16153
|
function write(level, message) {
|
|
@@ -15773,7 +16162,7 @@ function write(level, message) {
|
|
|
15773
16162
|
}
|
|
15774
16163
|
try {
|
|
15775
16164
|
const path = cliLogPath();
|
|
15776
|
-
mkdirSync6(
|
|
16165
|
+
mkdirSync6(dirname10(path), { recursive: true });
|
|
15777
16166
|
appendFileSync(path, `${new Date().toISOString()} ${level.toUpperCase()} ${message}
|
|
15778
16167
|
`);
|
|
15779
16168
|
} catch {}
|
|
@@ -15811,10 +16200,10 @@ var init_cli_logger = __esm(() => {
|
|
|
15811
16200
|
|
|
15812
16201
|
// src/lib/binary-install.ts
|
|
15813
16202
|
import { existsSync as existsSync17 } from "node:fs";
|
|
15814
|
-
import { join as
|
|
16203
|
+
import { join as join22 } from "node:path";
|
|
15815
16204
|
function cachedBinaryFor(version) {
|
|
15816
16205
|
const tag = version.startsWith("v") ? version : `v${version}`;
|
|
15817
|
-
const path =
|
|
16206
|
+
const path = join22(getAftBinaryCacheDir(), tag, getAftBinaryName());
|
|
15818
16207
|
try {
|
|
15819
16208
|
return existsSync17(path) ? path : null;
|
|
15820
16209
|
} catch {
|
|
@@ -15948,7 +16337,7 @@ function loadFeaturePlan(harness, run = runNative) {
|
|
|
15948
16337
|
return {
|
|
15949
16338
|
ok: false,
|
|
15950
16339
|
error: withCliCommands(error),
|
|
15951
|
-
configRejected: result.status === 1 && error.includes("
|
|
16340
|
+
configRejected: result.status === 1 && error.includes("AFT cannot load this configuration"),
|
|
15952
16341
|
missingBinary: result.missingBinary === true
|
|
15953
16342
|
};
|
|
15954
16343
|
}
|
|
@@ -16430,8 +16819,10 @@ async function runSetup(argv, options = {}) {
|
|
|
16430
16819
|
for (const adapter of nextSteps) {
|
|
16431
16820
|
if (!(adapter instanceof OpenCodeAdapter))
|
|
16432
16821
|
continue;
|
|
16433
|
-
|
|
16434
|
-
|
|
16822
|
+
for (const hostTool of OPENCODE_HOST_TOOL_NAMES) {
|
|
16823
|
+
if (await offerHostToolDisable(adapter, hostTool, argv, options) === "failed")
|
|
16824
|
+
anyFailure = true;
|
|
16825
|
+
}
|
|
16435
16826
|
}
|
|
16436
16827
|
for (const adapter of nextSteps)
|
|
16437
16828
|
printNextSteps(adapter);
|
|
@@ -16501,19 +16892,20 @@ async function configureAdapter(adapter, options) {
|
|
|
16501
16892
|
}
|
|
16502
16893
|
return failed ? "failed" : "ok";
|
|
16503
16894
|
}
|
|
16504
|
-
async function
|
|
16505
|
-
if (adapter.
|
|
16895
|
+
async function offerHostToolDisable(adapter, hostTool, argv, options = {}) {
|
|
16896
|
+
if (adapter.hostToolState(hostTool) === "not_applicable")
|
|
16506
16897
|
return "skipped";
|
|
16507
|
-
const
|
|
16898
|
+
const { aftTool } = OPENCODE_HOST_TOOLS[hostTool];
|
|
16899
|
+
const replacementOn = adapter.aftHostReplacementEnabled(hostTool);
|
|
16508
16900
|
const interactive = !argv.includes("--yes") && !argv.includes("-y") && (options.interactive ?? Boolean(process.stdin.isTTY));
|
|
16509
|
-
const disable = interactive ? await (options.confirmHostShell ?? confirm2)(HOST_SHELL_QUESTION
|
|
16510
|
-
const result = adapter.
|
|
16901
|
+
const disable = interactive ? await (options.confirmHostTool ?? (hostTool === "shell" ? options.confirmHostShell : undefined) ?? confirm2)(hostTool === "shell" ? HOST_SHELL_QUESTION : `OpenCode's own ${hostTool} tool: disable it so agents use AFT's ${aftTool}?`, replacementOn) : replacementOn;
|
|
16902
|
+
const result = adapter.setHostToolDisabled(hostTool, disable);
|
|
16511
16903
|
if (!result.ok) {
|
|
16512
16904
|
log2.error(`${adapter.displayName}: ${result.message}`);
|
|
16513
16905
|
return "failed";
|
|
16514
16906
|
}
|
|
16515
16907
|
if (result.action === "already_present") {
|
|
16516
|
-
log2.info(`${adapter.displayName}: OpenCode's own
|
|
16908
|
+
log2.info(`${adapter.displayName}: OpenCode's own ${hostTool} tool is ${disable ? "already disabled" : "enabled"}${disable ? `; agents use AFT's ${aftTool}` : replacementOn ? "" : ` (AFT's ${aftTool} is disabled)`}`);
|
|
16517
16909
|
} else {
|
|
16518
16910
|
log2.success(`${adapter.displayName}: ${result.message}`);
|
|
16519
16911
|
}
|
|
@@ -16569,6 +16961,7 @@ var init_setup = __esm(async () => {
|
|
|
16569
16961
|
init_prompts();
|
|
16570
16962
|
init_self_version();
|
|
16571
16963
|
init_host_generation();
|
|
16964
|
+
init_opencode_config();
|
|
16572
16965
|
await __promiseAll([
|
|
16573
16966
|
init_binary_probe(),
|
|
16574
16967
|
init_feature_plan(),
|
|
@@ -16620,6 +17013,28 @@ var init_backups = __esm(async () => {
|
|
|
16620
17013
|
await init_binary_probe();
|
|
16621
17014
|
});
|
|
16622
17015
|
|
|
17016
|
+
// src/commands/cache.ts
|
|
17017
|
+
function runCache(argv) {
|
|
17018
|
+
const binary = findAftBinary();
|
|
17019
|
+
if (!binary) {
|
|
17020
|
+
console.error(missingAftBinaryMessage(`${CLI} cache`));
|
|
17021
|
+
return 1;
|
|
17022
|
+
}
|
|
17023
|
+
const result = spawnSync(binary, ["cache", ...argv], {
|
|
17024
|
+
stdio: "inherit",
|
|
17025
|
+
env: process.env
|
|
17026
|
+
});
|
|
17027
|
+
if (result.error) {
|
|
17028
|
+
console.error(`aft cache failed to start ${binary}: ${result.error.message}`);
|
|
17029
|
+
return 1;
|
|
17030
|
+
}
|
|
17031
|
+
return result.status ?? 1;
|
|
17032
|
+
}
|
|
17033
|
+
var init_cache = __esm(async () => {
|
|
17034
|
+
init_dist2();
|
|
17035
|
+
await init_binary_probe();
|
|
17036
|
+
});
|
|
17037
|
+
|
|
16623
17038
|
// src/doctor/features.ts
|
|
16624
17039
|
function isOn(feature) {
|
|
16625
17040
|
return feature.effective !== "off";
|
|
@@ -16729,7 +17144,7 @@ var init_features = __esm(() => {
|
|
|
16729
17144
|
|
|
16730
17145
|
// src/doctor/opencode.ts
|
|
16731
17146
|
import { existsSync as existsSync18, readFileSync as readFileSync13 } from "node:fs";
|
|
16732
|
-
import { dirname as
|
|
17147
|
+
import { dirname as dirname11, join as join23 } from "node:path";
|
|
16733
17148
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
16734
17149
|
function isLoadPath(value) {
|
|
16735
17150
|
return OPENCODE_LOAD_PATHS.includes(value);
|
|
@@ -16800,13 +17215,13 @@ function readManifest(path) {
|
|
|
16800
17215
|
}
|
|
16801
17216
|
function manifestFromLocalPath(path) {
|
|
16802
17217
|
let current = path;
|
|
16803
|
-
if (!existsSync18(
|
|
16804
|
-
current =
|
|
17218
|
+
if (!existsSync18(join23(current, "package.json")))
|
|
17219
|
+
current = dirname11(current);
|
|
16805
17220
|
while (true) {
|
|
16806
|
-
const manifest = readManifest(
|
|
17221
|
+
const manifest = readManifest(join23(current, "package.json"));
|
|
16807
17222
|
if (manifest)
|
|
16808
17223
|
return manifest;
|
|
16809
|
-
const parent =
|
|
17224
|
+
const parent = dirname11(current);
|
|
16810
17225
|
if (parent === current)
|
|
16811
17226
|
return null;
|
|
16812
17227
|
current = parent;
|
|
@@ -16816,7 +17231,7 @@ function pluginManifest(entry, cachePath) {
|
|
|
16816
17231
|
const localRoot = localPluginRoot(entry);
|
|
16817
17232
|
if (localRoot)
|
|
16818
17233
|
return manifestFromLocalPath(localRoot);
|
|
16819
|
-
return readManifest(
|
|
17234
|
+
return readManifest(join23(cachePath, "node_modules", "@cortexkit", "aft-opencode", "package.json"));
|
|
16820
17235
|
}
|
|
16821
17236
|
function pinProblem(entry, pinned) {
|
|
16822
17237
|
return `the plugin entry ${entry} ${describePluginEntry(entry)}; run \`${CLI} doctor --fix\` to pin it to ${pinned}`;
|
|
@@ -16916,6 +17331,36 @@ function isResponseForRequest(parsed, expectedIds) {
|
|
|
16916
17331
|
return false;
|
|
16917
17332
|
return expectedIds.has(id);
|
|
16918
17333
|
}
|
|
17334
|
+
function createNdjsonLineSplitter(onLine) {
|
|
17335
|
+
let pending = [];
|
|
17336
|
+
let scannedChars = 0;
|
|
17337
|
+
return {
|
|
17338
|
+
push(chunk) {
|
|
17339
|
+
scannedChars += chunk.length;
|
|
17340
|
+
let start = 0;
|
|
17341
|
+
let newline = chunk.indexOf(`
|
|
17342
|
+
`);
|
|
17343
|
+
while (newline !== -1) {
|
|
17344
|
+
let line = chunk.slice(start, newline);
|
|
17345
|
+
if (pending.length > 0) {
|
|
17346
|
+
pending.push(line);
|
|
17347
|
+
line = pending.join("");
|
|
17348
|
+
pending = [];
|
|
17349
|
+
}
|
|
17350
|
+
start = newline + 1;
|
|
17351
|
+
if (onLine(line.trim()) === true)
|
|
17352
|
+
return;
|
|
17353
|
+
newline = chunk.indexOf(`
|
|
17354
|
+
`, start);
|
|
17355
|
+
}
|
|
17356
|
+
if (start < chunk.length)
|
|
17357
|
+
pending.push(start === 0 ? chunk : chunk.slice(start));
|
|
17358
|
+
},
|
|
17359
|
+
get scannedChars() {
|
|
17360
|
+
return scannedChars;
|
|
17361
|
+
}
|
|
17362
|
+
};
|
|
17363
|
+
}
|
|
16919
17364
|
async function sendAftRequest(binaryPath, request) {
|
|
16920
17365
|
const responses = await sendAftRequests(binaryPath, [request]);
|
|
16921
17366
|
const response = responses[0];
|
|
@@ -16930,7 +17375,7 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
16930
17375
|
});
|
|
16931
17376
|
const responses = [];
|
|
16932
17377
|
const noiseLines = [];
|
|
16933
|
-
let
|
|
17378
|
+
let noiseLineCount = 0;
|
|
16934
17379
|
let stderr = "";
|
|
16935
17380
|
let settled = false;
|
|
16936
17381
|
const finish = (fn) => {
|
|
@@ -16941,18 +17386,23 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
16941
17386
|
fn();
|
|
16942
17387
|
};
|
|
16943
17388
|
const expectedIds = new Set(requests.map((req) => req.id));
|
|
17389
|
+
const recordNoise = (line) => {
|
|
17390
|
+
noiseLineCount += 1;
|
|
17391
|
+
if (noiseLines.length < MAX_NOISE_LINES_IN_ERROR)
|
|
17392
|
+
noiseLines.push(line);
|
|
17393
|
+
};
|
|
16944
17394
|
const handleLine = (line) => {
|
|
16945
17395
|
if (!line)
|
|
16946
17396
|
return;
|
|
16947
17397
|
if (!line.startsWith("{")) {
|
|
16948
|
-
|
|
17398
|
+
recordNoise(line);
|
|
16949
17399
|
return;
|
|
16950
17400
|
}
|
|
16951
17401
|
let parsed;
|
|
16952
17402
|
try {
|
|
16953
17403
|
parsed = JSON.parse(line);
|
|
16954
17404
|
} catch {
|
|
16955
|
-
|
|
17405
|
+
recordNoise(line);
|
|
16956
17406
|
return;
|
|
16957
17407
|
}
|
|
16958
17408
|
if (!isResponseForRequest(parsed, expectedIds)) {
|
|
@@ -16964,20 +17414,15 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
16964
17414
|
finish(() => resolve(responses));
|
|
16965
17415
|
}
|
|
16966
17416
|
};
|
|
17417
|
+
const stdoutLines = createNdjsonLineSplitter((line) => {
|
|
17418
|
+
handleLine(line);
|
|
17419
|
+
return settled;
|
|
17420
|
+
});
|
|
16967
17421
|
child.stdout.setEncoding("utf-8");
|
|
16968
17422
|
child.stdout.on("data", (chunk) => {
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
`);
|
|
16973
|
-
if (newline === -1)
|
|
16974
|
-
break;
|
|
16975
|
-
const line = stdout.slice(0, newline).trim();
|
|
16976
|
-
stdout = stdout.slice(newline + 1);
|
|
16977
|
-
handleLine(line);
|
|
16978
|
-
if (settled)
|
|
16979
|
-
break;
|
|
16980
|
-
}
|
|
17423
|
+
if (settled)
|
|
17424
|
+
return;
|
|
17425
|
+
stdoutLines.push(chunk);
|
|
16981
17426
|
});
|
|
16982
17427
|
child.stderr.setEncoding("utf-8");
|
|
16983
17428
|
child.stderr.on("data", (chunk) => {
|
|
@@ -16989,7 +17434,7 @@ async function sendAftRequests(binaryPath, requests) {
|
|
|
16989
17434
|
child.on("close", (code) => {
|
|
16990
17435
|
if (settled)
|
|
16991
17436
|
return;
|
|
16992
|
-
finish(() => reject(buildBridgeError({ binaryPath, code, stderr, noiseLines, responses })));
|
|
17437
|
+
finish(() => reject(buildBridgeError({ binaryPath, code, stderr, noiseLines, noiseLineCount, responses })));
|
|
16993
17438
|
});
|
|
16994
17439
|
child.stdin.on("error", () => {});
|
|
16995
17440
|
try {
|
|
@@ -17007,14 +17452,14 @@ function buildBridgeError(ctx) {
|
|
|
17007
17452
|
if (ctx.responses.length > 0) {
|
|
17008
17453
|
parts.push(`Got ${ctx.responses.length} valid response(s) before exit.`);
|
|
17009
17454
|
}
|
|
17010
|
-
if (ctx.
|
|
17455
|
+
if (ctx.noiseLineCount > 0) {
|
|
17011
17456
|
parts.push(`
|
|
17012
|
-
The binary printed ${ctx.
|
|
17457
|
+
The binary printed ${ctx.noiseLineCount} non-JSON line(s) to stdout — this usually means ` + "the resolved binary isn't an AFT release binary (wrapper script, panic output, or unrelated tool):");
|
|
17013
17458
|
const sample = ctx.noiseLines.slice(0, MAX_NOISE_LINES_IN_ERROR).map((line) => ` | ${line}`);
|
|
17014
17459
|
parts.push(sample.join(`
|
|
17015
17460
|
`));
|
|
17016
|
-
if (ctx.
|
|
17017
|
-
parts.push(` | (… ${ctx.
|
|
17461
|
+
if (ctx.noiseLineCount > MAX_NOISE_LINES_IN_ERROR) {
|
|
17462
|
+
parts.push(` | (… ${ctx.noiseLineCount - MAX_NOISE_LINES_IN_ERROR} more line(s) omitted)`);
|
|
17018
17463
|
}
|
|
17019
17464
|
parts.push(`
|
|
17020
17465
|
Try: ${CLI} doctor (full diagnostics) or check ~/.cache/aft/bin/ for the right binary.`);
|
|
@@ -17035,7 +17480,7 @@ var init_aft_bridge = __esm(() => {
|
|
|
17035
17480
|
|
|
17036
17481
|
// src/lib/binary-cache.ts
|
|
17037
17482
|
import { existsSync as existsSync19, readdirSync as readdirSync7, statSync as statSync12 } from "node:fs";
|
|
17038
|
-
import { join as
|
|
17483
|
+
import { join as join24 } from "node:path";
|
|
17039
17484
|
function getBinaryCacheInfo(activeVersion) {
|
|
17040
17485
|
const path = getAftBinaryCacheDir();
|
|
17041
17486
|
if (!existsSync19(path)) {
|
|
@@ -17048,7 +17493,7 @@ function getBinaryCacheInfo(activeVersion) {
|
|
|
17048
17493
|
}
|
|
17049
17494
|
const versions = readdirSync7(path).filter((entry) => {
|
|
17050
17495
|
try {
|
|
17051
|
-
return statSync12(
|
|
17496
|
+
return statSync12(join24(path, entry)).isDirectory();
|
|
17052
17497
|
} catch {
|
|
17053
17498
|
return false;
|
|
17054
17499
|
}
|
|
@@ -17068,14 +17513,14 @@ var init_binary_cache = __esm(() => {
|
|
|
17068
17513
|
});
|
|
17069
17514
|
|
|
17070
17515
|
// src/lib/sanitize.ts
|
|
17071
|
-
import { realpathSync as
|
|
17072
|
-
import { homedir as
|
|
17516
|
+
import { realpathSync as realpathSync5 } from "node:fs";
|
|
17517
|
+
import { homedir as homedir17, userInfo } from "node:os";
|
|
17073
17518
|
function escapeRegex(value) {
|
|
17074
17519
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
17075
17520
|
}
|
|
17076
17521
|
function safeRealpath(p) {
|
|
17077
17522
|
try {
|
|
17078
|
-
return
|
|
17523
|
+
return realpathSync5(p);
|
|
17079
17524
|
} catch {
|
|
17080
17525
|
return null;
|
|
17081
17526
|
}
|
|
@@ -17105,7 +17550,7 @@ function redactSecrets(content) {
|
|
|
17105
17550
|
}
|
|
17106
17551
|
function sanitizeContent(content) {
|
|
17107
17552
|
const username = userInfo().username;
|
|
17108
|
-
const home =
|
|
17553
|
+
const home = homedir17();
|
|
17109
17554
|
let sanitized = redactSecrets(content);
|
|
17110
17555
|
const cwd = process.cwd();
|
|
17111
17556
|
for (const candidate of new Set([cwd, safeRealpath(cwd)])) {
|
|
@@ -17122,7 +17567,7 @@ function sanitizeContent(content) {
|
|
|
17122
17567
|
sanitized = sanitized.replace(/([A-Za-z]:\\Users\\)[^\\"'\s]+/g, "$1<USER>");
|
|
17123
17568
|
sanitized = sanitized.replace(/([A-Za-z]:\/Users\/)[^/\s"']+/g, "$1<USER>");
|
|
17124
17569
|
if (username) {
|
|
17125
|
-
sanitized = sanitized
|
|
17570
|
+
sanitized = redactUsername(sanitized, username);
|
|
17126
17571
|
}
|
|
17127
17572
|
return sanitized;
|
|
17128
17573
|
}
|
|
@@ -17138,6 +17583,11 @@ function sanitizeValue(value) {
|
|
|
17138
17583
|
}
|
|
17139
17584
|
return value;
|
|
17140
17585
|
}
|
|
17586
|
+
function redactUsername(content, username) {
|
|
17587
|
+
if (!username)
|
|
17588
|
+
return content;
|
|
17589
|
+
return content.replace(new RegExp(`(?<![\\p{L}\\p{N}_])${escapeRegex(username)}(?![\\p{L}\\p{N}_])`, "gu"), "<USER>");
|
|
17590
|
+
}
|
|
17141
17591
|
var SECRET_PLACEHOLDER = "<REDACTED_SECRET>", URL_CREDENTIAL_PLACEHOLDER = "***", KEY_NAME = "[A-Za-z_][A-Za-z0-9_.-]*", SENSITIVE_KEY_WORD, SEGMENTED_KEY_WORD, CAMEL_CASE_KEY_WORD, JWT_PATTERN, AWS_ACCESS_KEY_ID_PATTERN, CREDENTIAL_QUERY_PATTERN, KEY_QUERY_PATTERN, quotedSensitiveKeyValuePattern, unquotedSensitiveKeyValuePattern, bareSensitiveKeyValuePattern;
|
|
17142
17592
|
var init_sanitize = __esm(() => {
|
|
17143
17593
|
SENSITIVE_KEY_WORD = /(?:token|password|secret|api[_-]?key|passwd|pwd|credential)/i;
|
|
@@ -17153,7 +17603,7 @@ var init_sanitize = __esm(() => {
|
|
|
17153
17603
|
});
|
|
17154
17604
|
|
|
17155
17605
|
// src/lib/bridge-tool-failures.ts
|
|
17156
|
-
import { closeSync as
|
|
17606
|
+
import { closeSync as closeSync8, existsSync as existsSync20, openSync as openSync8, readSync as readSync6, statSync as statSync13 } from "node:fs";
|
|
17157
17607
|
function resolveBridgePluginLogPath() {
|
|
17158
17608
|
return resolvePluginLogPath();
|
|
17159
17609
|
}
|
|
@@ -17167,16 +17617,16 @@ function tailLogFileBytes(path, maxBytes) {
|
|
|
17167
17617
|
return "";
|
|
17168
17618
|
const readLength = Math.min(size, maxBytes);
|
|
17169
17619
|
const position = size - readLength;
|
|
17170
|
-
fd =
|
|
17620
|
+
fd = openSync8(path, "r");
|
|
17171
17621
|
const buffer = Buffer.allocUnsafe(readLength);
|
|
17172
|
-
const bytesRead =
|
|
17622
|
+
const bytesRead = readSync6(fd, buffer, 0, readLength, position);
|
|
17173
17623
|
return buffer.subarray(0, bytesRead).toString("utf-8").trim();
|
|
17174
17624
|
} catch {
|
|
17175
17625
|
return "";
|
|
17176
17626
|
} finally {
|
|
17177
17627
|
if (fd !== null) {
|
|
17178
17628
|
try {
|
|
17179
|
-
|
|
17629
|
+
closeSync8(fd);
|
|
17180
17630
|
} catch {}
|
|
17181
17631
|
}
|
|
17182
17632
|
}
|
|
@@ -17296,7 +17746,7 @@ var init_bridge_tool_failures = __esm(() => {
|
|
|
17296
17746
|
// src/lib/build-breaker.ts
|
|
17297
17747
|
import { existsSync as existsSync21, readdirSync as readdirSync8 } from "node:fs";
|
|
17298
17748
|
import { createRequire as createRequire3 } from "node:module";
|
|
17299
|
-
import { join as
|
|
17749
|
+
import { join as join25 } from "node:path";
|
|
17300
17750
|
function loadDatabaseSync() {
|
|
17301
17751
|
const require2 = createRequire3(import.meta.url);
|
|
17302
17752
|
try {
|
|
@@ -17310,11 +17760,11 @@ function loadDatabaseSync() {
|
|
|
17310
17760
|
}
|
|
17311
17761
|
}
|
|
17312
17762
|
function buildBreakerDatabases(storageRoot) {
|
|
17313
|
-
const callgraphRoot =
|
|
17763
|
+
const callgraphRoot = join25(storageRoot, "callgraph");
|
|
17314
17764
|
if (!existsSync21(callgraphRoot))
|
|
17315
17765
|
return [];
|
|
17316
17766
|
try {
|
|
17317
|
-
return readdirSync8(callgraphRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) =>
|
|
17767
|
+
return readdirSync8(callgraphRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join25(callgraphRoot, entry.name, "build-breaker.sqlite")).filter((path) => existsSync21(path));
|
|
17318
17768
|
} catch {
|
|
17319
17769
|
return [];
|
|
17320
17770
|
}
|
|
@@ -17450,21 +17900,10 @@ function previewConfigMigration(targets) {
|
|
|
17450
17900
|
if (!raw)
|
|
17451
17901
|
continue;
|
|
17452
17902
|
const translated = structuredClone(raw);
|
|
17453
|
-
const translation = translateConfigDocument(translated,
|
|
17454
|
-
|
|
17455
|
-
if (!translation.legacyInput && translation.errors.length === 0 && !retiredGithub)
|
|
17903
|
+
const translation = translateConfigDocument(translated, target.tier);
|
|
17904
|
+
if (!translation.legacyInput)
|
|
17456
17905
|
continue;
|
|
17457
17906
|
const changes = diffConfig(raw, translated);
|
|
17458
|
-
for (const code of translation.errors) {
|
|
17459
|
-
const match = /^removed_config_key:([^:]+):use:(.+)$/.exec(code);
|
|
17460
|
-
if (match)
|
|
17461
|
-
changes.push({
|
|
17462
|
-
kind: "changed",
|
|
17463
|
-
key: match[1],
|
|
17464
|
-
before: undefined,
|
|
17465
|
-
after: `→ ${match[2]}`
|
|
17466
|
-
});
|
|
17467
|
-
}
|
|
17468
17907
|
previews.push({ ...target, changes });
|
|
17469
17908
|
}
|
|
17470
17909
|
return previews;
|
|
@@ -17477,9 +17916,6 @@ function describeConfigChange(change) {
|
|
|
17477
17916
|
return `removed ${change.key} (was ${show(change.before)})`;
|
|
17478
17917
|
if (change.kind === "added")
|
|
17479
17918
|
return `added ${change.key}: ${show(change.after)}`;
|
|
17480
|
-
if (change.before === undefined && typeof change.after === "string" && change.after.startsWith("→ ")) {
|
|
17481
|
-
return `replaced ${change.key} with ${change.after.slice(2)}`;
|
|
17482
|
-
}
|
|
17483
17919
|
return `changed ${change.key}: ${show(change.before)} → ${show(change.after)}`;
|
|
17484
17920
|
}
|
|
17485
17921
|
var import_comment_json2;
|
|
@@ -17490,19 +17926,19 @@ var init_config_migration = __esm(() => {
|
|
|
17490
17926
|
|
|
17491
17927
|
// src/lib/legacy-storage.ts
|
|
17492
17928
|
import { existsSync as existsSync23, readdirSync as readdirSync9, statSync as statSync14 } from "node:fs";
|
|
17493
|
-
import { join as
|
|
17929
|
+
import { join as join26 } from "node:path";
|
|
17494
17930
|
function summarizeLegacyPartitionDuplication(storageRoot) {
|
|
17495
17931
|
if (!existsSync23(storageRoot)) {
|
|
17496
17932
|
return { totalPartitions: 0, totalBytes: 0, byHarness: [] };
|
|
17497
17933
|
}
|
|
17498
17934
|
const byHarness = [];
|
|
17499
17935
|
for (const harness of safeReadDir(storageRoot)) {
|
|
17500
|
-
const harnessPath =
|
|
17936
|
+
const harnessPath = join26(storageRoot, harness);
|
|
17501
17937
|
if (!isDirectory(harnessPath))
|
|
17502
17938
|
continue;
|
|
17503
17939
|
const partitions = new Map;
|
|
17504
|
-
collectCallgraphPartitions(
|
|
17505
|
-
collectInspectPartitions(
|
|
17940
|
+
collectCallgraphPartitions(join26(harnessPath, "callgraph"), partitions);
|
|
17941
|
+
collectInspectPartitions(join26(harnessPath, "inspect"), partitions);
|
|
17506
17942
|
if (partitions.size === 0)
|
|
17507
17943
|
continue;
|
|
17508
17944
|
let bytes = 0;
|
|
@@ -17521,7 +17957,7 @@ function collectCallgraphPartitions(domainPath, partitions) {
|
|
|
17521
17957
|
if (!isDirectory(domainPath))
|
|
17522
17958
|
return;
|
|
17523
17959
|
for (const name of safeReadDir(domainPath)) {
|
|
17524
|
-
const path =
|
|
17960
|
+
const path = join26(domainPath, name);
|
|
17525
17961
|
if (isDirectory(path)) {
|
|
17526
17962
|
if (!looksLikePartitionKey(name))
|
|
17527
17963
|
continue;
|
|
@@ -17538,7 +17974,7 @@ function collectInspectPartitions(domainPath, partitions) {
|
|
|
17538
17974
|
if (!isDirectory(domainPath))
|
|
17539
17975
|
return;
|
|
17540
17976
|
for (const name of safeReadDir(domainPath)) {
|
|
17541
|
-
const path =
|
|
17977
|
+
const path = join26(domainPath, name);
|
|
17542
17978
|
if (isDirectory(path)) {
|
|
17543
17979
|
if (!looksLikePartitionKey(name))
|
|
17544
17980
|
continue;
|
|
@@ -17614,7 +18050,7 @@ var init_legacy_storage = __esm(() => {
|
|
|
17614
18050
|
|
|
17615
18051
|
// src/lib/lsp-cache.ts
|
|
17616
18052
|
import { existsSync as existsSync24, readdirSync as readdirSync10, rmSync as rmSync5, statSync as statSync15 } from "node:fs";
|
|
17617
|
-
import { join as
|
|
18053
|
+
import { join as join27 } from "node:path";
|
|
17618
18054
|
function inspectDir(path) {
|
|
17619
18055
|
if (!existsSync24(path)) {
|
|
17620
18056
|
return { entries: [], totalSize: 0 };
|
|
@@ -17628,7 +18064,7 @@ function inspectDir(path) {
|
|
|
17628
18064
|
return { entries: [], totalSize: 0 };
|
|
17629
18065
|
}
|
|
17630
18066
|
for (const name of names) {
|
|
17631
|
-
const full =
|
|
18067
|
+
const full = join27(path, name);
|
|
17632
18068
|
try {
|
|
17633
18069
|
if (!statSync15(full).isDirectory())
|
|
17634
18070
|
continue;
|
|
@@ -17686,8 +18122,8 @@ var init_lsp_cache = __esm(() => {
|
|
|
17686
18122
|
});
|
|
17687
18123
|
|
|
17688
18124
|
// src/lib/onnx.ts
|
|
17689
|
-
import { existsSync as existsSync25, readdirSync as readdirSync11, readlinkSync as readlinkSync2, realpathSync as
|
|
17690
|
-
import { basename as basename2, isAbsolute as
|
|
18125
|
+
import { existsSync as existsSync25, readdirSync as readdirSync11, readlinkSync as readlinkSync2, realpathSync as realpathSync6 } from "node:fs";
|
|
18126
|
+
import { basename as basename2, isAbsolute as isAbsolute7, join as join28, resolve as resolve14, win32 as win323 } from "node:path";
|
|
17691
18127
|
function getOnnxLibraryName() {
|
|
17692
18128
|
if (process.platform === "darwin")
|
|
17693
18129
|
return "libonnxruntime.dylib";
|
|
@@ -17723,18 +18159,18 @@ function pathEntriesForPlatform2() {
|
|
|
17723
18159
|
return pathEnvValue2().split(delimiter).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => {
|
|
17724
18160
|
if (!entry || entry === "." || entry.includes("\x00"))
|
|
17725
18161
|
return false;
|
|
17726
|
-
return
|
|
18162
|
+
return isAbsolute7(entry) || win323.isAbsolute(entry);
|
|
17727
18163
|
});
|
|
17728
18164
|
}
|
|
17729
18165
|
function isWindowsSystem32Directory2(dir) {
|
|
17730
18166
|
if (process.platform !== "win32")
|
|
17731
18167
|
return false;
|
|
17732
|
-
const normalizedDir =
|
|
18168
|
+
const normalizedDir = win323.resolve(dir).replace(/[\\/]+$/, "").toLowerCase();
|
|
17733
18169
|
const windowsRoots = [process.env.SystemRoot, process.env.windir, "C:\\Windows"];
|
|
17734
18170
|
return windowsRoots.some((root) => {
|
|
17735
18171
|
if (!root)
|
|
17736
18172
|
return false;
|
|
17737
|
-
return normalizedDir ===
|
|
18173
|
+
return normalizedDir === win323.resolve(root, "System32").replace(/[\\/]+$/, "").toLowerCase();
|
|
17738
18174
|
});
|
|
17739
18175
|
}
|
|
17740
18176
|
function directoryContainsLibrary2(dir, libName) {
|
|
@@ -17757,8 +18193,8 @@ function findIgnoredWindowsSystemOnnxRuntime() {
|
|
|
17757
18193
|
for (const root of windowsRoots) {
|
|
17758
18194
|
if (!root)
|
|
17759
18195
|
continue;
|
|
17760
|
-
const systemDir =
|
|
17761
|
-
const key =
|
|
18196
|
+
const systemDir = join28(root, "System32");
|
|
18197
|
+
const key = win323.resolve(systemDir).toLowerCase();
|
|
17762
18198
|
if (seen.has(key))
|
|
17763
18199
|
continue;
|
|
17764
18200
|
seen.add(key);
|
|
@@ -17779,12 +18215,12 @@ function inspectSystemOnnxRuntime(searchPathsOverride) {
|
|
|
17779
18215
|
searchPaths.push(...pathEntriesForPlatform2());
|
|
17780
18216
|
const programFiles = process.env.ProgramFiles ?? "C:\\Program Files";
|
|
17781
18217
|
const programFilesX86 = process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
|
17782
|
-
searchPaths.push(
|
|
18218
|
+
searchPaths.push(join28(programFiles, "onnxruntime", "lib"), join28(programFiles, "Microsoft ONNX Runtime", "lib"), join28(programFiles, "Microsoft Machine Learning", "lib"), join28(programFilesX86, "onnxruntime", "lib"), ...(() => {
|
|
17783
18219
|
const nugetPaths = [];
|
|
17784
18220
|
const userProfile = process.env.USERPROFILE ?? "";
|
|
17785
18221
|
if (!userProfile)
|
|
17786
18222
|
return nugetPaths;
|
|
17787
|
-
const nugetPackageDir =
|
|
18223
|
+
const nugetPackageDir = join28(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
|
|
17788
18224
|
if (!existsSync25(nugetPackageDir))
|
|
17789
18225
|
return nugetPaths;
|
|
17790
18226
|
try {
|
|
@@ -17793,7 +18229,7 @@ function inspectSystemOnnxRuntime(searchPathsOverride) {
|
|
|
17793
18229
|
continue;
|
|
17794
18230
|
if (entry.name === "__globalPackagesFolder" || entry.name.startsWith("."))
|
|
17795
18231
|
continue;
|
|
17796
|
-
nugetPaths.push(
|
|
18232
|
+
nugetPaths.push(join28(nugetPackageDir, entry.name, "runtimes", "win-x64", "native"), join28(nugetPackageDir, entry.name, "runtimes", "win-arm64", "native"));
|
|
17797
18233
|
}
|
|
17798
18234
|
} catch {}
|
|
17799
18235
|
return nugetPaths;
|
|
@@ -17803,7 +18239,7 @@ function inspectSystemOnnxRuntime(searchPathsOverride) {
|
|
|
17803
18239
|
const seen = new Set;
|
|
17804
18240
|
const unknownVersionPaths = [];
|
|
17805
18241
|
for (const dir of searchPaths) {
|
|
17806
|
-
let key =
|
|
18242
|
+
let key = resolve14(dir).replace(/[/\\]+$/, "");
|
|
17807
18243
|
if (normalizeCase)
|
|
17808
18244
|
key = key.toLowerCase();
|
|
17809
18245
|
if (seen.has(key))
|
|
@@ -17812,7 +18248,7 @@ function inspectSystemOnnxRuntime(searchPathsOverride) {
|
|
|
17812
18248
|
if (!directoryContainsLibrary2(dir, libName))
|
|
17813
18249
|
continue;
|
|
17814
18250
|
if (process.platform !== "win32") {
|
|
17815
|
-
const probe = probeOnnxRuntimeLoadable(
|
|
18251
|
+
const probe = probeOnnxRuntimeLoadable(join28(dir, libName));
|
|
17816
18252
|
if (!probe.loadable) {
|
|
17817
18253
|
ignored ??= { path: dir, reason: `unloadable: ${probe.reason} — ignored` };
|
|
17818
18254
|
continue;
|
|
@@ -17832,12 +18268,12 @@ function inspectSystemOnnxRuntime(searchPathsOverride) {
|
|
|
17832
18268
|
return { path: unknownVersionPaths[0] ?? null, ignored };
|
|
17833
18269
|
}
|
|
17834
18270
|
function findCachedOnnxRuntime2(storageDir) {
|
|
17835
|
-
const ortDir =
|
|
18271
|
+
const ortDir = join28(storageDir, "onnxruntime", ONNX_RUNTIME_VERSION);
|
|
17836
18272
|
const libName = getOnnxLibraryName();
|
|
17837
|
-
if (existsSync25(
|
|
18273
|
+
if (existsSync25(join28(ortDir, libName)))
|
|
17838
18274
|
return ortDir;
|
|
17839
|
-
const libSubdir =
|
|
17840
|
-
if (existsSync25(
|
|
18275
|
+
const libSubdir = join28(ortDir, "lib");
|
|
18276
|
+
if (existsSync25(join28(libSubdir, libName)))
|
|
17841
18277
|
return libSubdir;
|
|
17842
18278
|
return null;
|
|
17843
18279
|
}
|
|
@@ -17862,7 +18298,7 @@ function detectOrtVersion(libDir) {
|
|
|
17862
18298
|
return null;
|
|
17863
18299
|
const libName = getOnnxLibraryName();
|
|
17864
18300
|
try {
|
|
17865
|
-
const resolved = parseOrtVersionFromPath(
|
|
18301
|
+
const resolved = parseOrtVersionFromPath(realpathSync6(join28(libDir, libName)));
|
|
17866
18302
|
if (resolved && resolved !== INVALID_ORT_VERSION2)
|
|
17867
18303
|
return resolved;
|
|
17868
18304
|
} catch {}
|
|
@@ -17878,10 +18314,10 @@ function detectOrtVersion(libDir) {
|
|
|
17878
18314
|
if (version)
|
|
17879
18315
|
return version;
|
|
17880
18316
|
}
|
|
17881
|
-
const base =
|
|
18317
|
+
const base = join28(libDir, libName);
|
|
17882
18318
|
if (existsSync25(base)) {
|
|
17883
18319
|
try {
|
|
17884
|
-
const real =
|
|
18320
|
+
const real = realpathSync6(base);
|
|
17885
18321
|
const version = parseOrtVersionFromPath(real) ?? parseOrtVersionFromDirectoryPath(real);
|
|
17886
18322
|
if (version)
|
|
17887
18323
|
return version;
|
|
@@ -17942,7 +18378,6 @@ function indexesOf(block) {
|
|
|
17942
18378
|
}
|
|
17943
18379
|
function evaluatePluginLoad(input) {
|
|
17944
18380
|
const blockers = [];
|
|
17945
|
-
const phase = policyPhaseForVersion(input.pluginVersion);
|
|
17946
18381
|
const tiers = [
|
|
17947
18382
|
{ path: input.userConfigPath, tier: "user" }
|
|
17948
18383
|
];
|
|
@@ -17970,20 +18405,7 @@ function evaluatePluginLoad(input) {
|
|
|
17970
18405
|
if (!value)
|
|
17971
18406
|
continue;
|
|
17972
18407
|
const translated = structuredClone(value);
|
|
17973
|
-
|
|
17974
|
-
if (translation.errors.length > 0) {
|
|
17975
|
-
const removed = translation.errors.map((code) => code.replace(/^removed_config_key:([^:]+):use:(.+)$/, "$1 → $2")).join(", ");
|
|
17976
|
-
const scope = tier === "project" ? " in this project" : "";
|
|
17977
|
-
const toolCallError = formatConfigErrorMessage(new ConfigRejectedError(translation.errors, path).message);
|
|
17978
|
-
blockers.push({
|
|
17979
|
-
code: "config_rejected",
|
|
17980
|
-
path,
|
|
17981
|
-
message: `${failsEveryToolCall(toolCallError, scope)} (removed keys: ${removed})`,
|
|
17982
|
-
toolCallError,
|
|
17983
|
-
remediation: `Run \`${CLI} doctor --fix\` to migrate the file, then restart the host.`,
|
|
17984
|
-
fixable: true
|
|
17985
|
-
});
|
|
17986
|
-
}
|
|
18408
|
+
translateConfigDocument(translated, tier);
|
|
17987
18409
|
loaded[tier] = withHarness(translated, input.harness);
|
|
17988
18410
|
}
|
|
17989
18411
|
const subc = loaded.user && isRecord3(loaded.user.subc) ? loaded.user.subc : null;
|
|
@@ -18022,11 +18444,11 @@ var init_plugin_load = __esm(() => {
|
|
|
18022
18444
|
// src/lib/diagnostics.ts
|
|
18023
18445
|
import {
|
|
18024
18446
|
accessSync as accessSync3,
|
|
18025
|
-
closeSync as
|
|
18026
|
-
constants as
|
|
18447
|
+
closeSync as closeSync9,
|
|
18448
|
+
constants as constants4,
|
|
18027
18449
|
existsSync as existsSync27,
|
|
18028
|
-
openSync as
|
|
18029
|
-
readSync as
|
|
18450
|
+
openSync as openSync9,
|
|
18451
|
+
readSync as readSync7,
|
|
18030
18452
|
statSync as statSync16
|
|
18031
18453
|
} from "node:fs";
|
|
18032
18454
|
async function collectDiagnostics(adapters) {
|
|
@@ -18066,7 +18488,7 @@ async function diagnoseHarness(adapter) {
|
|
|
18066
18488
|
if (!existsSync27(storage))
|
|
18067
18489
|
return false;
|
|
18068
18490
|
try {
|
|
18069
|
-
accessSync3(storage,
|
|
18491
|
+
accessSync3(storage, constants4.R_OK | constants4.W_OK);
|
|
18070
18492
|
return true;
|
|
18071
18493
|
} catch {
|
|
18072
18494
|
return false;
|
|
@@ -18077,8 +18499,7 @@ async function diagnoseHarness(adapter) {
|
|
|
18077
18499
|
const pluginLoad = evaluatePluginLoad({
|
|
18078
18500
|
userConfigPath: configPaths.aftConfig,
|
|
18079
18501
|
projectDirectory: process.cwd(),
|
|
18080
|
-
harness: adapter.kind === "opencode" ? "opencode" : "pi"
|
|
18081
|
-
pluginVersion: pluginCache.cached ?? getSelfVersion()
|
|
18502
|
+
harness: adapter.kind === "opencode" ? "opencode" : "pi"
|
|
18082
18503
|
});
|
|
18083
18504
|
const semanticEnabled = aftEnabled && pluginLoad.onnxRequired;
|
|
18084
18505
|
const systemInspection = inspectSystemOnnxRuntime();
|
|
@@ -18370,7 +18791,7 @@ function tailLogFile(path, lines) {
|
|
|
18370
18791
|
let fd = null;
|
|
18371
18792
|
try {
|
|
18372
18793
|
const size = statSync16(path).size;
|
|
18373
|
-
fd =
|
|
18794
|
+
fd = openSync9(path, "r");
|
|
18374
18795
|
const chunks = [];
|
|
18375
18796
|
let position = size;
|
|
18376
18797
|
let newlineCount = 0;
|
|
@@ -18378,7 +18799,7 @@ function tailLogFile(path, lines) {
|
|
|
18378
18799
|
const readLength = Math.min(chunkSize, position);
|
|
18379
18800
|
position -= readLength;
|
|
18380
18801
|
const buffer = Buffer.allocUnsafe(readLength);
|
|
18381
|
-
const bytesRead =
|
|
18802
|
+
const bytesRead = readSync7(fd, buffer, 0, readLength, position);
|
|
18382
18803
|
const chunk = bytesRead === readLength ? buffer : buffer.subarray(0, bytesRead);
|
|
18383
18804
|
chunks.unshift(chunk);
|
|
18384
18805
|
for (let i = chunk.length - 1;i >= 0; i -= 1) {
|
|
@@ -18393,7 +18814,7 @@ function tailLogFile(path, lines) {
|
|
|
18393
18814
|
} finally {
|
|
18394
18815
|
if (fd !== null) {
|
|
18395
18816
|
try {
|
|
18396
|
-
|
|
18817
|
+
closeSync9(fd);
|
|
18397
18818
|
} catch {}
|
|
18398
18819
|
}
|
|
18399
18820
|
}
|
|
@@ -18490,29 +18911,44 @@ function capBodyToGithubLimit(body, maxBytes = MAX_GITHUB_BODY_BYTES) {
|
|
|
18490
18911
|
const head = body.slice(0, logBlockStart);
|
|
18491
18912
|
const log = body.slice(logBlockStart, logBlockEnd);
|
|
18492
18913
|
const tail = body.slice(logBlockEnd);
|
|
18493
|
-
const overheadBytes = Buffer.byteLength(head, "utf8") + Buffer.byteLength(tail, "utf8");
|
|
18494
18914
|
const truncationMarker = `[truncated for GitHub 64KB limit — older log lines dropped]
|
|
18495
18915
|
`;
|
|
18496
|
-
const markerBytes = Buffer.byteLength(truncationMarker, "utf8");
|
|
18497
|
-
const logBudget = maxBytes - overheadBytes - markerBytes;
|
|
18498
|
-
if (logBudget <= 0) {
|
|
18499
|
-
return `${head}${truncationMarker}${tail}`;
|
|
18500
|
-
}
|
|
18501
18916
|
const lines = log.split(`
|
|
18502
18917
|
`);
|
|
18503
|
-
let
|
|
18504
|
-
let
|
|
18505
|
-
|
|
18506
|
-
|
|
18507
|
-
const
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
|
|
18512
|
-
|
|
18513
|
-
|
|
18918
|
+
let inFence = false;
|
|
18919
|
+
let fence = "";
|
|
18920
|
+
const payload = [];
|
|
18921
|
+
for (let i = 0;i < lines.length; i++) {
|
|
18922
|
+
const delimiter = lines[i].match(/^\s*(`{3,}|~{3,})/);
|
|
18923
|
+
if (delimiter) {
|
|
18924
|
+
if (!inFence) {
|
|
18925
|
+
inFence = true;
|
|
18926
|
+
fence = delimiter[1];
|
|
18927
|
+
} else if (delimiter[1][0] === fence[0] && delimiter[1].length >= fence.length)
|
|
18928
|
+
inFence = false;
|
|
18929
|
+
} else if (inFence || lines[i] && !/^#{1,6} /.test(lines[i])) {
|
|
18930
|
+
payload.push(i);
|
|
18931
|
+
}
|
|
18932
|
+
}
|
|
18933
|
+
const removed = new Set;
|
|
18934
|
+
const render = () => `${head}${truncationMarker}${lines.filter((_, i) => !removed.has(i)).join(`
|
|
18935
|
+
`)}${tail}`;
|
|
18936
|
+
let size = Buffer.byteLength(render(), "utf8");
|
|
18937
|
+
for (const index of payload) {
|
|
18938
|
+
if (size <= maxBytes)
|
|
18939
|
+
break;
|
|
18940
|
+
const excess = size - maxBytes;
|
|
18941
|
+
const bytes = Buffer.byteLength(lines[index], "utf8");
|
|
18942
|
+
if (index === payload.at(-1) && bytes > excess) {
|
|
18943
|
+
const kept = truncateToByteBudget(lines[index], bytes - excess);
|
|
18944
|
+
size -= bytes - Buffer.byteLength(kept, "utf8");
|
|
18945
|
+
lines[index] = kept;
|
|
18946
|
+
} else {
|
|
18947
|
+
removed.add(index);
|
|
18948
|
+
size -= bytes + 1;
|
|
18949
|
+
}
|
|
18514
18950
|
}
|
|
18515
|
-
return
|
|
18951
|
+
return render();
|
|
18516
18952
|
}
|
|
18517
18953
|
function findNextTopLevelHeading(body, startIdx) {
|
|
18518
18954
|
const idx = body.indexOf(`
|
|
@@ -18548,13 +18984,13 @@ var init_issue_body = __esm(() => {
|
|
|
18548
18984
|
// src/lib/onnx-fix.ts
|
|
18549
18985
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
18550
18986
|
import { existsSync as existsSync28, mkdirSync as mkdirSync7, renameSync as renameSync5, rmSync as rmSync6 } from "node:fs";
|
|
18551
|
-
import { isAbsolute as
|
|
18987
|
+
import { isAbsolute as isAbsolute8, join as join29, relative as relative4 } from "node:path";
|
|
18552
18988
|
function findOnnxFixCandidates(report) {
|
|
18553
18989
|
const candidates = [];
|
|
18554
18990
|
for (const harness of report.harnesses) {
|
|
18555
18991
|
if (!harness.onnxRuntime.required)
|
|
18556
18992
|
continue;
|
|
18557
|
-
const storageOnnxDir =
|
|
18993
|
+
const storageOnnxDir = join29(harness.storageDir.path, "onnxruntime");
|
|
18558
18994
|
const systemTooOld = harness.onnxRuntime.systemPath !== null && harness.onnxRuntime.systemCompatible === false;
|
|
18559
18995
|
const cachedTooOld = harness.onnxRuntime.cachedPath !== null && harness.onnxRuntime.cachedCompatible === false;
|
|
18560
18996
|
const hasCompatibleCached = harness.onnxRuntime.cachedCompatible === true;
|
|
@@ -18593,15 +19029,15 @@ function findOnnxFixCandidates(report) {
|
|
|
18593
19029
|
async function installManagedReplacement(candidate, ensureFn, rmFn) {
|
|
18594
19030
|
const suffix = `${process.pid}.${Date.now().toString(36)}.${randomBytes2(6).toString("hex")}`;
|
|
18595
19031
|
const stagingStorageDir = `${candidate.harness.storageDir.path}.onnx-fix.tmp.${suffix}`;
|
|
18596
|
-
const stagedOnnxDir =
|
|
19032
|
+
const stagedOnnxDir = join29(stagingStorageDir, "onnxruntime");
|
|
18597
19033
|
const backupDir = `${candidate.storageOnnxDir}.backup.${suffix}`;
|
|
18598
19034
|
try {
|
|
18599
19035
|
const stagedInstalledPath = await ensureFn(stagingStorageDir);
|
|
18600
19036
|
if (!stagedInstalledPath || !existsSync28(stagedInstalledPath)) {
|
|
18601
19037
|
throw new Error("managed ONNX Runtime download was unavailable");
|
|
18602
19038
|
}
|
|
18603
|
-
const installedRelativePath =
|
|
18604
|
-
if (
|
|
19039
|
+
const installedRelativePath = relative4(stagedOnnxDir, stagedInstalledPath);
|
|
19040
|
+
if (isAbsolute8(installedRelativePath) || installedRelativePath === ".." || installedRelativePath.startsWith("../") || installedRelativePath.startsWith("..\\")) {
|
|
18605
19041
|
throw new Error(`managed ONNX Runtime was installed outside staging: ${stagedInstalledPath}`);
|
|
18606
19042
|
}
|
|
18607
19043
|
mkdirSync7(candidate.harness.storageDir.path, { recursive: true });
|
|
@@ -18629,7 +19065,7 @@ async function installManagedReplacement(candidate, ensureFn, rmFn) {
|
|
|
18629
19065
|
}
|
|
18630
19066
|
}
|
|
18631
19067
|
return {
|
|
18632
|
-
installedPath:
|
|
19068
|
+
installedPath: join29(candidate.storageOnnxDir, installedRelativePath),
|
|
18633
19069
|
clearedPrevious: hadPrevious && cleanupError === undefined,
|
|
18634
19070
|
cleanupError
|
|
18635
19071
|
};
|
|
@@ -18696,7 +19132,7 @@ var init_onnx_fix = __esm(() => {
|
|
|
18696
19132
|
});
|
|
18697
19133
|
|
|
18698
19134
|
// src/lib/session-log.ts
|
|
18699
|
-
import { closeSync as
|
|
19135
|
+
import { closeSync as closeSync10, openSync as openSync10, readSync as readSync8, statSync as statSync17 } from "node:fs";
|
|
18700
19136
|
function readSessionLog(path, session, maxBytes = MAX_SCAN_BYTES) {
|
|
18701
19137
|
const lines = [];
|
|
18702
19138
|
const errors = [];
|
|
@@ -18734,7 +19170,7 @@ function readSessionLog(path, session, maxBytes = MAX_SCAN_BYTES) {
|
|
|
18734
19170
|
break;
|
|
18735
19171
|
let fd;
|
|
18736
19172
|
try {
|
|
18737
|
-
fd =
|
|
19173
|
+
fd = openSync10(file, "r");
|
|
18738
19174
|
let position = statSync17(file).size;
|
|
18739
19175
|
let suffix = Buffer.alloc(0);
|
|
18740
19176
|
while (position > 0 && remaining > 0 && (lines.length < 200 || errors.length < 20)) {
|
|
@@ -18742,7 +19178,7 @@ function readSessionLog(path, session, maxBytes = MAX_SCAN_BYTES) {
|
|
|
18742
19178
|
position -= length;
|
|
18743
19179
|
remaining -= length;
|
|
18744
19180
|
const chunk = Buffer.allocUnsafe(length);
|
|
18745
|
-
const count =
|
|
19181
|
+
const count = readSync8(fd, chunk, 0, length, position);
|
|
18746
19182
|
const bytes = Buffer.concat([chunk.subarray(0, count), suffix]);
|
|
18747
19183
|
let end = bytes.length;
|
|
18748
19184
|
for (let i = bytes.length - 1;i >= 0; i -= 1) {
|
|
@@ -18761,7 +19197,7 @@ function readSessionLog(path, session, maxBytes = MAX_SCAN_BYTES) {
|
|
|
18761
19197
|
boundHit = true;
|
|
18762
19198
|
} catch {} finally {
|
|
18763
19199
|
if (fd !== undefined)
|
|
18764
|
-
|
|
19200
|
+
closeSync10(fd);
|
|
18765
19201
|
}
|
|
18766
19202
|
}
|
|
18767
19203
|
return { lines: lines.reverse(), errors: errors.reverse(), boundHit };
|
|
@@ -18777,8 +19213,8 @@ var init_session_log = __esm(() => {
|
|
|
18777
19213
|
// src/lib/sessions.ts
|
|
18778
19214
|
import { existsSync as existsSync29, readdirSync as readdirSync12, readFileSync as readFileSync16, statSync as statSync18 } from "node:fs";
|
|
18779
19215
|
import { createRequire as createRequire4 } from "node:module";
|
|
18780
|
-
import { homedir as
|
|
18781
|
-
import { basename as basename3, join as
|
|
19216
|
+
import { homedir as homedir18 } from "node:os";
|
|
19217
|
+
import { basename as basename3, join as join30 } from "node:path";
|
|
18782
19218
|
function listRecentSessions(adapter) {
|
|
18783
19219
|
try {
|
|
18784
19220
|
if (adapter.kind === "opencode")
|
|
@@ -18812,7 +19248,7 @@ function mapOpenCodeSessionRows(rows) {
|
|
|
18812
19248
|
}).filter((session) => session !== null).sort((a, b) => b.lastActivity - a.lastActivity).slice(0, MAX_RECENT_SESSIONS);
|
|
18813
19249
|
}
|
|
18814
19250
|
function listRecentOpenCodeSessions() {
|
|
18815
|
-
const dbPath =
|
|
19251
|
+
const dbPath = join30(getXdgDataHome(), "opencode", "opencode.db");
|
|
18816
19252
|
if (!existsSync29(dbPath))
|
|
18817
19253
|
return [];
|
|
18818
19254
|
let db = null;
|
|
@@ -18832,14 +19268,14 @@ function listRecentOpenCodeSessions() {
|
|
|
18832
19268
|
}
|
|
18833
19269
|
function getXdgDataHome() {
|
|
18834
19270
|
const xdgDataHome = process.env.XDG_DATA_HOME;
|
|
18835
|
-
return xdgDataHome && xdgDataHome.length > 0 ? xdgDataHome :
|
|
19271
|
+
return xdgDataHome && xdgDataHome.length > 0 ? xdgDataHome : join30(homedir18(), ".local", "share");
|
|
18836
19272
|
}
|
|
18837
19273
|
function listRecentPiSessions() {
|
|
18838
|
-
return listPiSessionsFromDir(
|
|
19274
|
+
return listPiSessionsFromDir(join30(getHomeDir(), ".pi", "agent", "sessions"));
|
|
18839
19275
|
}
|
|
18840
19276
|
function getHomeDir() {
|
|
18841
19277
|
const envHome = process.platform === "win32" ? process.env.USERPROFILE : process.env.HOME;
|
|
18842
|
-
return envHome && envHome.length > 0 ? envHome :
|
|
19278
|
+
return envHome && envHome.length > 0 ? envHome : homedir18();
|
|
18843
19279
|
}
|
|
18844
19280
|
function listPiSessionsFromDir(sessionsDir) {
|
|
18845
19281
|
try {
|
|
@@ -18881,7 +19317,7 @@ function collectJsonlFiles(root) {
|
|
|
18881
19317
|
continue;
|
|
18882
19318
|
}
|
|
18883
19319
|
for (const entry of entries) {
|
|
18884
|
-
const path =
|
|
19320
|
+
const path = join30(dir, entry.name);
|
|
18885
19321
|
if (entry.isDirectory()) {
|
|
18886
19322
|
stack.push(path);
|
|
18887
19323
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
@@ -18986,13 +19422,13 @@ import {
|
|
|
18986
19422
|
mkdirSync as mkdirSync8,
|
|
18987
19423
|
mkdtempSync as mkdtempSync2,
|
|
18988
19424
|
readFileSync as readFileSync17,
|
|
18989
|
-
realpathSync as
|
|
19425
|
+
realpathSync as realpathSync7,
|
|
18990
19426
|
rmSync as rmSync7,
|
|
18991
19427
|
statSync as statSync19,
|
|
18992
19428
|
writeFileSync as writeFileSync5
|
|
18993
19429
|
} from "node:fs";
|
|
18994
|
-
import { tmpdir as
|
|
18995
|
-
import { join as
|
|
19430
|
+
import { tmpdir as tmpdir5 } from "node:os";
|
|
19431
|
+
import { join as join31 } from "node:path";
|
|
18996
19432
|
function openCodeAdapter(adapters) {
|
|
18997
19433
|
return adapters.find((adapter) => adapter.kind === "opencode");
|
|
18998
19434
|
}
|
|
@@ -19132,9 +19568,11 @@ async function runDoctor(options) {
|
|
|
19132
19568
|
}
|
|
19133
19569
|
if (opencodeSkew)
|
|
19134
19570
|
log2.error(` ${opencodeSkew.message} ${opencodeSkew.remediation}`);
|
|
19135
|
-
const
|
|
19136
|
-
|
|
19137
|
-
|
|
19571
|
+
for (const hostTool of OPENCODE_HOST_TOOL_NAMES) {
|
|
19572
|
+
const line = hostToolDoctorLine(opencodeAdapter, hostTool);
|
|
19573
|
+
if (line)
|
|
19574
|
+
log2[line.level](` ${line.text}`);
|
|
19575
|
+
}
|
|
19138
19576
|
}
|
|
19139
19577
|
const blockers = h.pluginLoad?.blockers ?? [];
|
|
19140
19578
|
if (h.pluginRegistered && blockers.length > 0) {
|
|
@@ -19411,7 +19849,7 @@ function clearOldBinaries() {
|
|
|
19411
19849
|
return result;
|
|
19412
19850
|
}
|
|
19413
19851
|
for (const version of stale) {
|
|
19414
|
-
const dir =
|
|
19852
|
+
const dir = join31(info.path, version);
|
|
19415
19853
|
let bytes = 0;
|
|
19416
19854
|
try {
|
|
19417
19855
|
bytes = statSync19(dir).isDirectory() ? dirSize(dir) : 0;
|
|
@@ -19434,34 +19872,35 @@ function clearOldBinaries() {
|
|
|
19434
19872
|
}
|
|
19435
19873
|
return result;
|
|
19436
19874
|
}
|
|
19437
|
-
function
|
|
19875
|
+
function hostToolDoctorLine(adapter, hostTool) {
|
|
19438
19876
|
if (!(adapter instanceof OpenCodeAdapter))
|
|
19439
19877
|
return null;
|
|
19440
|
-
const
|
|
19878
|
+
const { disableEntry, aftTool } = OPENCODE_HOST_TOOLS[hostTool];
|
|
19879
|
+
const state = adapter.hostToolState(hostTool);
|
|
19441
19880
|
if (state === "not_applicable")
|
|
19442
19881
|
return null;
|
|
19443
19882
|
if (state === "disabled") {
|
|
19444
19883
|
return {
|
|
19445
19884
|
level: "info",
|
|
19446
|
-
text: `OpenCode's own
|
|
19885
|
+
text: `OpenCode's own ${hostTool} tool: disabled (${disableEntry} is set); agents use AFT's ${aftTool}`
|
|
19447
19886
|
};
|
|
19448
19887
|
}
|
|
19449
|
-
if (!adapter.
|
|
19888
|
+
if (!adapter.aftHostReplacementEnabled(hostTool)) {
|
|
19450
19889
|
return {
|
|
19451
19890
|
level: "info",
|
|
19452
|
-
text:
|
|
19891
|
+
text: `OpenCode's own ${hostTool} tool: enabled (AFT's ${aftTool} is disabled, so it stays)`
|
|
19453
19892
|
};
|
|
19454
19893
|
}
|
|
19455
19894
|
return {
|
|
19456
19895
|
level: "warn",
|
|
19457
|
-
text: `OpenCode's own
|
|
19896
|
+
text: `OpenCode's own ${hostTool} tool: enabled beside AFT's ${aftTool} — run \`${CLI} doctor --fix\` or \`${CLI} setup\` to disable it (${disableEntry})`
|
|
19458
19897
|
};
|
|
19459
19898
|
}
|
|
19460
|
-
function
|
|
19899
|
+
function hostToolFixTargets(adapters) {
|
|
19461
19900
|
const adapter = openCodeAdapter(adapters);
|
|
19462
19901
|
if (!(adapter instanceof OpenCodeAdapter))
|
|
19463
|
-
return
|
|
19464
|
-
return adapter.
|
|
19902
|
+
return [];
|
|
19903
|
+
return OPENCODE_HOST_TOOL_NAMES.filter((hostTool) => adapter.hostToolState(hostTool) === "enabled" && adapter.aftHostReplacementEnabled(hostTool)).map((hostTool) => ({ adapter, hostTool }));
|
|
19465
19904
|
}
|
|
19466
19905
|
function findPluginUpdateTargets(adapters, report) {
|
|
19467
19906
|
const adaptersByKind = new Map(adapters.map((a) => [a.kind, a]));
|
|
@@ -19570,7 +20009,7 @@ async function runDoctorNpmInstall(npm, installDir) {
|
|
|
19570
20009
|
});
|
|
19571
20010
|
}
|
|
19572
20011
|
function installedPluginVersion(installDir) {
|
|
19573
|
-
const manifest =
|
|
20012
|
+
const manifest = join31(installDir, "node_modules", ...AFT_OPENCODE_PACKAGE.split("/"), "package.json");
|
|
19574
20013
|
try {
|
|
19575
20014
|
const pkg = JSON.parse(readFileSync17(manifest, "utf-8"));
|
|
19576
20015
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
@@ -19692,11 +20131,11 @@ function buildDoctorFixPlan(adapters, report) {
|
|
|
19692
20131
|
message: `Will ${hasTuiEntry ? "update" : "add"} ${adapter.pluginEntryWithVersion} ${hasTuiEntry ? "in" : "to"} ${harness.configPaths.tuiConfig} (TUI sidebar)`
|
|
19693
20132
|
});
|
|
19694
20133
|
}
|
|
19695
|
-
const
|
|
19696
|
-
|
|
20134
|
+
for (const { adapter, hostTool } of hostToolFixTargets(adapters)) {
|
|
20135
|
+
const { disableEntry, aftTool } = OPENCODE_HOST_TOOLS[hostTool];
|
|
19697
20136
|
items.push({
|
|
19698
20137
|
kind: "plugin",
|
|
19699
|
-
message: `Will add ${
|
|
20138
|
+
message: `Will add ${disableEntry} to ${adapter.detectConfigPaths().harnessConfig} so agents use AFT's ${aftTool} instead of OpenCode's own ${hostTool} tool`
|
|
19700
20139
|
});
|
|
19701
20140
|
}
|
|
19702
20141
|
for (const target of findPluginUpdateTargets(adapters, report)) {
|
|
@@ -19844,9 +20283,8 @@ async function runFixFlow(argv, detectOpenCodeHost, resolveAdapters = resolveAda
|
|
|
19844
20283
|
}
|
|
19845
20284
|
}
|
|
19846
20285
|
const pluginEntrySummary = configWritesRefused ? { changed: 0, errors: 0 } : await fixPluginEntries(adapters);
|
|
19847
|
-
const
|
|
19848
|
-
|
|
19849
|
-
const result = hostShellTarget.setHostShellDisabled(true);
|
|
20286
|
+
for (const { adapter, hostTool } of configWritesRefused ? [] : hostToolFixTargets(adapters)) {
|
|
20287
|
+
const result = adapter.setHostToolDisabled(hostTool, true);
|
|
19850
20288
|
if (result.ok) {
|
|
19851
20289
|
if (result.action !== "already_present")
|
|
19852
20290
|
log2.success(`OpenCode: ${result.message}`);
|
|
@@ -20205,14 +20643,14 @@ function deriveIssueTitleFromBody(body) {
|
|
|
20205
20643
|
function writeIssueReviewFile(body) {
|
|
20206
20644
|
let reviewDir = null;
|
|
20207
20645
|
try {
|
|
20208
|
-
reviewDir = mkdtempSync2(
|
|
20646
|
+
reviewDir = mkdtempSync2(join31(tmpdir5(), "aft-issue-"));
|
|
20209
20647
|
if (process.platform !== "win32") {
|
|
20210
20648
|
chmodSync3(reviewDir, 448);
|
|
20211
20649
|
}
|
|
20212
|
-
const outPath =
|
|
20650
|
+
const outPath = join31(reviewDir, "issue.md");
|
|
20213
20651
|
writeFileSync5(outPath, `${body}
|
|
20214
20652
|
`, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
20215
|
-
return { path: outPath, realPath:
|
|
20653
|
+
return { path: outPath, realPath: realpathSync7(outPath) };
|
|
20216
20654
|
} catch (err) {
|
|
20217
20655
|
if (reviewDir) {
|
|
20218
20656
|
try {
|
|
@@ -20225,7 +20663,7 @@ function writeIssueReviewFile(body) {
|
|
|
20225
20663
|
}
|
|
20226
20664
|
function readReviewedIssueFile(reviewFile) {
|
|
20227
20665
|
try {
|
|
20228
|
-
const realPath =
|
|
20666
|
+
const realPath = realpathSync7(reviewFile.path);
|
|
20229
20667
|
if (realPath !== reviewFile.realPath) {
|
|
20230
20668
|
log2.error(`Review file path changed before filing; refusing to read ${reviewFile.path}.`);
|
|
20231
20669
|
return null;
|
|
@@ -20438,24 +20876,24 @@ var init_doctor = __esm(async () => {
|
|
|
20438
20876
|
// src/commands/lsp.ts
|
|
20439
20877
|
import { existsSync as existsSync31, readdirSync as readdirSync13, statSync as statSync20 } from "node:fs";
|
|
20440
20878
|
import { createRequire as createRequire5 } from "node:module";
|
|
20441
|
-
import { dirname as
|
|
20879
|
+
import { dirname as dirname12, join as join32, resolve as resolve15 } from "node:path";
|
|
20442
20880
|
function findProjectRootForFile(filePath, fallbackCwd = process.cwd()) {
|
|
20443
|
-
const resolvedFile =
|
|
20444
|
-
let dir =
|
|
20881
|
+
const resolvedFile = resolve15(fallbackCwd, filePath);
|
|
20882
|
+
let dir = dirname12(resolvedFile);
|
|
20445
20883
|
try {
|
|
20446
20884
|
if (existsSync31(resolvedFile) && statSync20(resolvedFile).isDirectory()) {
|
|
20447
20885
|
dir = resolvedFile;
|
|
20448
20886
|
}
|
|
20449
20887
|
} catch {
|
|
20450
|
-
dir =
|
|
20888
|
+
dir = dirname12(resolvedFile);
|
|
20451
20889
|
}
|
|
20452
20890
|
while (true) {
|
|
20453
|
-
if (PROJECT_ROOT_MARKERS.some((marker) => existsSync31(
|
|
20891
|
+
if (PROJECT_ROOT_MARKERS.some((marker) => existsSync31(join32(dir, marker)))) {
|
|
20454
20892
|
return dir;
|
|
20455
20893
|
}
|
|
20456
|
-
const parent =
|
|
20894
|
+
const parent = dirname12(dir);
|
|
20457
20895
|
if (parent === dir)
|
|
20458
|
-
return
|
|
20896
|
+
return resolve15(fallbackCwd);
|
|
20459
20897
|
dir = parent;
|
|
20460
20898
|
}
|
|
20461
20899
|
}
|
|
@@ -20486,7 +20924,7 @@ async function runLspDoctor(options) {
|
|
|
20486
20924
|
log2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
|
|
20487
20925
|
return 1;
|
|
20488
20926
|
}
|
|
20489
|
-
const resolvedFile =
|
|
20927
|
+
const resolvedFile = resolve15(file);
|
|
20490
20928
|
const projectRoot = findProjectRootForFile(resolvedFile);
|
|
20491
20929
|
const config = buildConfigureParams(adapter, projectRoot);
|
|
20492
20930
|
const inspectRequest = {
|
|
@@ -20599,10 +21037,10 @@ function buildConfigureParams(adapter, projectRoot) {
|
|
|
20599
21037
|
function inferLspPathsExtra(_lsp) {
|
|
20600
21038
|
const paths = new Set;
|
|
20601
21039
|
for (const entry of childDirs(getAftLspPackagesDir())) {
|
|
20602
|
-
paths.add(
|
|
21040
|
+
paths.add(join32(entry, "node_modules", ".bin"));
|
|
20603
21041
|
}
|
|
20604
21042
|
for (const entry of childDirs(getAftLspBinariesDir())) {
|
|
20605
|
-
paths.add(
|
|
21043
|
+
paths.add(join32(entry, "bin"));
|
|
20606
21044
|
}
|
|
20607
21045
|
return [...paths];
|
|
20608
21046
|
}
|
|
@@ -20610,7 +21048,7 @@ function childDirs(path) {
|
|
|
20610
21048
|
if (!existsSync31(path))
|
|
20611
21049
|
return [];
|
|
20612
21050
|
try {
|
|
20613
|
-
return readdirSync13(path).map((entry) =>
|
|
21051
|
+
return readdirSync13(path).map((entry) => join32(path, entry)).filter((entry) => {
|
|
20614
21052
|
try {
|
|
20615
21053
|
return statSync20(entry).isDirectory();
|
|
20616
21054
|
} catch {
|
|
@@ -20622,11 +21060,13 @@ function childDirs(path) {
|
|
|
20622
21060
|
}
|
|
20623
21061
|
}
|
|
20624
21062
|
function formatBinary(server) {
|
|
21063
|
+
const names = server.binary_names?.length ? server.binary_names : [server.binary_name];
|
|
21064
|
+
const alternatives = names.length > 1 ? `; candidates: ${names.join(" or ")}` : "";
|
|
20625
21065
|
if (!server.binary_path) {
|
|
20626
21066
|
const locations = server.kind === "python" || server.kind === "ty" ? "workspace virtualenv, node_modules/.bin, lsp_paths_extra, or PATH" : "node_modules/.bin, lsp_paths_extra, or PATH";
|
|
20627
|
-
return `${
|
|
21067
|
+
return `${names.join(" or ")} (NOT FOUND in ${locations})`;
|
|
20628
21068
|
}
|
|
20629
|
-
return `${server.binary_path} (found via ${server.binary_source})`;
|
|
21069
|
+
return `${server.binary_path} (found via ${server.binary_source}${alternatives})`;
|
|
20630
21070
|
}
|
|
20631
21071
|
function formatWorkspaceRoot(server) {
|
|
20632
21072
|
if (!server.workspace_root) {
|
|
@@ -20652,7 +21092,7 @@ function typescriptPackageWarning(response) {
|
|
|
20652
21092
|
if (!typescriptServerSpawned || !response.project_root || diagnosticsCount > 0)
|
|
20653
21093
|
return null;
|
|
20654
21094
|
try {
|
|
20655
|
-
createRequire5(
|
|
21095
|
+
createRequire5(join32(response.project_root, "package.json")).resolve("typescript");
|
|
20656
21096
|
return null;
|
|
20657
21097
|
} catch {
|
|
20658
21098
|
return "typescript package not resolvable from project — server will produce no diagnostics";
|
|
@@ -20693,8 +21133,7 @@ var init_lsp = __esm(async () => {
|
|
|
20693
21133
|
|
|
20694
21134
|
// src/commands/doctor-filters.ts
|
|
20695
21135
|
import { existsSync as existsSync32 } from "node:fs";
|
|
20696
|
-
import {
|
|
20697
|
-
import { relative as relative3, resolve as resolve14 } from "node:path";
|
|
21136
|
+
import { relative as relative5, resolve as resolve16 } from "node:path";
|
|
20698
21137
|
function printDoctorFiltersHelp() {
|
|
20699
21138
|
console.log(`Usage: ${CLI} doctor filters [--show <name>] [trust|untrust]`);
|
|
20700
21139
|
console.log("");
|
|
@@ -20729,7 +21168,7 @@ async function runDoctorFilters(options) {
|
|
|
20729
21168
|
log2.error("Could not find the aft binary in the cache, platform package, PATH, or ~/.cargo/bin.");
|
|
20730
21169
|
return 1;
|
|
20731
21170
|
}
|
|
20732
|
-
const projectRoot =
|
|
21171
|
+
const projectRoot = resolve16(process.cwd());
|
|
20733
21172
|
const list = await listFilters(binary, adapter, projectRoot, options.sendRequests ?? sendAftRequests);
|
|
20734
21173
|
if (!list.success) {
|
|
20735
21174
|
log2.error(list.message ?? list.code ?? "list_filters failed");
|
|
@@ -20911,14 +21350,13 @@ function truncate(value) {
|
|
|
20911
21350
|
return value.length <= 80 ? value : `${value.slice(0, 77)}…`;
|
|
20912
21351
|
}
|
|
20913
21352
|
function formatHome(path) {
|
|
20914
|
-
|
|
20915
|
-
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
21353
|
+
return shortenHomePath(path);
|
|
20916
21354
|
}
|
|
20917
21355
|
function formatProjectPath(path, projectRoot) {
|
|
20918
21356
|
if (!path)
|
|
20919
21357
|
return "";
|
|
20920
|
-
const rel =
|
|
20921
|
-
return rel
|
|
21358
|
+
const rel = relative5(projectRoot, path);
|
|
21359
|
+
return relativePathEscapesRoot(rel) || rel === "" ? path : `./${rel}`;
|
|
20922
21360
|
}
|
|
20923
21361
|
function formatSourcePath(path, projectRoot) {
|
|
20924
21362
|
if (!path)
|
|
@@ -20926,6 +21364,7 @@ function formatSourcePath(path, projectRoot) {
|
|
|
20926
21364
|
return formatProjectPath(path, projectRoot);
|
|
20927
21365
|
}
|
|
20928
21366
|
var init_doctor_filters = __esm(async () => {
|
|
21367
|
+
init_dist2();
|
|
20929
21368
|
init_aft_bridge();
|
|
20930
21369
|
init_harness_select();
|
|
20931
21370
|
init_prompts();
|
|
@@ -20949,6 +21388,7 @@ function printHelp() {
|
|
|
20949
21388
|
console.log(" setup --answers <file> Save feature choices from an answers file");
|
|
20950
21389
|
console.log(" index Build one configured index snapshot (no scheduler)");
|
|
20951
21390
|
console.log(" backups purge Remove undo backups by --path and/or --session (dry run unless --yes)");
|
|
21391
|
+
console.log(" cache prune-legacy Delete legacy index caches past their rollback window (dry run unless --yes)");
|
|
20952
21392
|
console.log(" doctor Check and fix configuration issues");
|
|
20953
21393
|
console.log(" doctor --profile [seconds] Profile a running AFT daemon");
|
|
20954
21394
|
console.log(" doctor lsp <file> Inspect LSP setup for one file");
|
|
@@ -20969,6 +21409,7 @@ function printHelp() {
|
|
|
20969
21409
|
console.log(` ${CLI} setup`);
|
|
20970
21410
|
console.log(` ${CLI} index`);
|
|
20971
21411
|
console.log(` ${CLI} backups purge --path ./build --yes`);
|
|
21412
|
+
console.log(` ${CLI} cache prune-legacy`);
|
|
20972
21413
|
console.log(` ${CLI} doctor`);
|
|
20973
21414
|
console.log(` ${CLI} doctor --profile 4`);
|
|
20974
21415
|
console.log(` ${CLI} doctor lsp ./src/main.py`);
|
|
@@ -20994,6 +21435,10 @@ async function main() {
|
|
|
20994
21435
|
await init_backups();
|
|
20995
21436
|
return runBackups(args);
|
|
20996
21437
|
}
|
|
21438
|
+
if (command === "cache") {
|
|
21439
|
+
await init_cache();
|
|
21440
|
+
return runCache(args);
|
|
21441
|
+
}
|
|
20997
21442
|
if (command === "doctor") {
|
|
20998
21443
|
if (args.includes("--profile")) {
|
|
20999
21444
|
await init_doctor();
|