@cortexkit/aft-opencode 0.35.1 → 0.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7637,9 +7637,9 @@ var require_stringify = __commonJS((exports, module) => {
7637
7637
  if (line_breaks_before === null) {
7638
7638
  line_breaks_before = inline ? 0 : 1;
7639
7639
  }
7640
- const delimiter = line_breaks_before > 0 ? repeat_line_breaks(line_breaks_before, deeper_gap) : inline ? SPACE : i === 0 ? EMPTY : LF + deeper_gap;
7640
+ const delimiter2 = line_breaks_before > 0 ? repeat_line_breaks(line_breaks_before, deeper_gap) : inline ? SPACE : i === 0 ? EMPTY : LF + deeper_gap;
7641
7641
  const is_line_comment = type === "LineComment";
7642
- str += delimiter + comment_stringify(value, is_line_comment);
7642
+ str += delimiter2 + comment_stringify(value, is_line_comment);
7643
7643
  last_comment = comment;
7644
7644
  });
7645
7645
  const default_line_breaks_after = display_block || last_comment.type === "LineComment" ? 1 : 0;
@@ -7652,10 +7652,10 @@ var require_stringify = __commonJS((exports, module) => {
7652
7652
  replacer = null;
7653
7653
  indent = EMPTY;
7654
7654
  };
7655
- var join8 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(one, gap)), gap) : two ? two.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(two, gap)), gap) : EMPTY;
7655
+ var join9 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(one, gap)), gap) : two ? two.trimRight() + repeat_line_breaks(Math.max(1, count_trailing_line_breaks(two, gap)), gap) : EMPTY;
7656
7656
  var join_content = (inside, value, gap) => {
7657
7657
  const comment = process_comments(value, PREFIX_BEFORE, gap + indent, true);
7658
- return join8(comment, inside, gap);
7658
+ return join9(comment, inside, gap);
7659
7659
  };
7660
7660
  var stringify_string = (holder, key, value) => {
7661
7661
  const raw = get_raw_string_literal(holder, key);
@@ -7677,13 +7677,13 @@ var require_stringify = __commonJS((exports, module) => {
7677
7677
  if (i !== 0) {
7678
7678
  inside += COMMA;
7679
7679
  }
7680
- const before = join8(after_comma, process_comments(value, BEFORE(i), deeper_gap), deeper_gap);
7680
+ const before = join9(after_comma, process_comments(value, BEFORE(i), deeper_gap), deeper_gap);
7681
7681
  inside += before || LF + deeper_gap;
7682
7682
  inside += stringify(i, value, deeper_gap) || STR_NULL;
7683
7683
  inside += process_comments(value, AFTER_VALUE(i), deeper_gap);
7684
7684
  after_comma = process_comments(value, AFTER(i), deeper_gap);
7685
7685
  }
7686
- inside += join8(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
7686
+ inside += join9(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
7687
7687
  return BRACKET_OPEN + join_content(inside, value, gap) + BRACKET_CLOSE;
7688
7688
  };
7689
7689
  var object_stringify = (value, gap) => {
@@ -7704,13 +7704,13 @@ var require_stringify = __commonJS((exports, module) => {
7704
7704
  inside += COMMA;
7705
7705
  }
7706
7706
  first = false;
7707
- const before = join8(after_comma, process_comments(value, BEFORE(key), deeper_gap), deeper_gap);
7707
+ const before = join9(after_comma, process_comments(value, BEFORE(key), deeper_gap), deeper_gap);
7708
7708
  inside += before || LF + deeper_gap;
7709
7709
  inside += quote(key) + process_comments(value, AFTER_PROP(key), deeper_gap) + COLON + process_comments(value, AFTER_COLON(key), deeper_gap) + SPACE + sv + process_comments(value, AFTER_VALUE(key), deeper_gap);
7710
7710
  after_comma = process_comments(value, AFTER(key), deeper_gap);
7711
7711
  };
7712
7712
  keys.forEach(iteratee);
7713
- inside += join8(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
7713
+ inside += join9(after_comma, process_comments(value, PREFIX_AFTER, deeper_gap), deeper_gap);
7714
7714
  return CURLY_BRACKET_OPEN + join_content(inside, value, gap) + CURLY_BRACKET_CLOSE;
7715
7715
  };
7716
7716
  function stringify(key, holder, gap) {
@@ -12740,6 +12740,35 @@ async function fetchLatestTag() {
12740
12740
  clearTimeout(timeout);
12741
12741
  }
12742
12742
  }
12743
+ // ../aft-bridge/dist/edit-summary.js
12744
+ function formatEditSummary(data) {
12745
+ if (data.rolled_back === true) {
12746
+ return "Edit rolled back: the change produced invalid syntax, so the file was left unchanged.";
12747
+ }
12748
+ if (typeof data.files_modified === "number") {
12749
+ const n = data.files_modified;
12750
+ return `Applied edits to ${n} file${n === 1 ? "" : "s"}.`;
12751
+ }
12752
+ const additions = data.diff?.additions ?? 0;
12753
+ const deletions = data.diff?.deletions ?? 0;
12754
+ const counts = `+${additions}/-${deletions}`;
12755
+ if (data.created === true) {
12756
+ let s2 = `Created file (${counts}).`;
12757
+ if (data.formatted)
12758
+ s2 += " Auto-formatted.";
12759
+ return s2;
12760
+ }
12761
+ let detail = counts;
12762
+ if (typeof data.edits_applied === "number" && data.edits_applied > 1) {
12763
+ detail = `${counts}, ${data.edits_applied} edits`;
12764
+ } else if (typeof data.replacements === "number" && data.replacements > 1) {
12765
+ detail = `${counts}, ${data.replacements} replacements`;
12766
+ }
12767
+ let s = `Edited (${detail}).`;
12768
+ if (data.formatted)
12769
+ s += " Auto-formatted.";
12770
+ return s;
12771
+ }
12743
12772
  // ../aft-bridge/dist/jsonc.js
12744
12773
  function stripJsoncSymbols(value) {
12745
12774
  if (Array.isArray(value)) {
@@ -13127,11 +13156,128 @@ async function ensureStorageMigrated(opts) {
13127
13156
  const stdoutTail = tail(result.stdout);
13128
13157
  throw new Error(`AFT storage migration failed (${detail}). ` + `Harness: ${opts.harness}. Legacy: ${legacyRoot}. Target: ${newRoot}. ` + `See log: ${logPath}. ` + `Plugin load aborted to prevent legacy/new state divergence.` + (stderrTail ? ` Stderr tail: ${stderrTail}` : "") + (stdoutTail ? ` Stdout tail: ${stdoutTail}` : ""));
13129
13158
  }
13159
+ // ../aft-bridge/dist/npm-resolver.js
13160
+ import { readdirSync, statSync as statSync2 } from "node:fs";
13161
+ import { homedir as homedir5 } from "node:os";
13162
+ import { delimiter, dirname as dirname3, isAbsolute, join as join6 } from "node:path";
13163
+ function defaultDeps() {
13164
+ return {
13165
+ platform: process.platform,
13166
+ env: process.env,
13167
+ home: homedir5(),
13168
+ execPath: process.execPath
13169
+ };
13170
+ }
13171
+ function npmBinaryName(platform) {
13172
+ return platform === "win32" ? "npm.cmd" : "npm";
13173
+ }
13174
+ function isFile(p) {
13175
+ try {
13176
+ return statSync2(p).isFile();
13177
+ } catch {
13178
+ return false;
13179
+ }
13180
+ }
13181
+ function npmFromPath(deps) {
13182
+ const name = npmBinaryName(deps.platform);
13183
+ const raw = deps.env.PATH ?? deps.env.Path ?? "";
13184
+ for (const entry of raw.split(delimiter)) {
13185
+ const dir = entry.trim().replace(/^"|"$/g, "");
13186
+ if (!dir || !isAbsolute(dir))
13187
+ continue;
13188
+ if (isFile(join6(dir, name)))
13189
+ return dir;
13190
+ }
13191
+ return null;
13192
+ }
13193
+ function npmAdjacentToNode(deps) {
13194
+ const dir = dirname3(deps.execPath);
13195
+ return isFile(join6(dir, npmBinaryName(deps.platform))) ? dir : null;
13196
+ }
13197
+ function highestVersionedNodeBin(installsDir, name) {
13198
+ let entries;
13199
+ try {
13200
+ entries = readdirSync(installsDir);
13201
+ } catch {
13202
+ return null;
13203
+ }
13204
+ const candidates = entries.filter((v) => isFile(join6(installsDir, v, "bin", name))).sort((a, b) => compareVersionsDesc(a, b));
13205
+ return candidates.length > 0 ? join6(installsDir, candidates[0], "bin") : null;
13206
+ }
13207
+ function compareVersionsDesc(a, b) {
13208
+ const pa = a.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10));
13209
+ const pb = b.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10));
13210
+ for (let i = 0;i < Math.max(pa.length, pb.length); i++) {
13211
+ const na = Number.isFinite(pa[i]) ? pa[i] : -1;
13212
+ const nb = Number.isFinite(pb[i]) ? pb[i] : -1;
13213
+ if (na !== nb)
13214
+ return nb - na;
13215
+ }
13216
+ return b.localeCompare(a);
13217
+ }
13218
+ function wellKnownNpmDirs(deps) {
13219
+ const { platform, env, home } = deps;
13220
+ const name = npmBinaryName(platform);
13221
+ const dirs = [];
13222
+ const push = (dir) => {
13223
+ if (dir && !dirs.includes(dir))
13224
+ dirs.push(dir);
13225
+ };
13226
+ if (platform === "win32") {
13227
+ const programFiles = env.ProgramFiles || "C:\\Program Files";
13228
+ const appData = env.APPDATA;
13229
+ const localAppData = env.LOCALAPPDATA;
13230
+ push(join6(programFiles, "nodejs"));
13231
+ if (appData)
13232
+ push(join6(appData, "npm"));
13233
+ if (localAppData)
13234
+ push(join6(localAppData, "Volta", "bin"));
13235
+ if (env.NVM_SYMLINK)
13236
+ push(env.NVM_SYMLINK);
13237
+ } else {
13238
+ if (env.NVM_BIN)
13239
+ push(env.NVM_BIN);
13240
+ push(highestVersionedNodeBin(join6(home, ".nvm", "versions", "node"), name));
13241
+ push(highestVersionedNodeBin(join6(home, ".local", "share", "mise", "installs", "node"), name));
13242
+ push(highestVersionedNodeBin(join6(home, ".asdf", "installs", "nodejs"), name));
13243
+ push(join6(home, ".volta", "bin"));
13244
+ push(join6(home, ".asdf", "shims"));
13245
+ const systemDirs = deps.systemNpmDirs ?? (platform === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : ["/usr/local/bin", "/usr/bin", join6(home, ".local", "bin")]);
13246
+ for (const dir of systemDirs)
13247
+ push(dir);
13248
+ }
13249
+ return dirs;
13250
+ }
13251
+ function resolveNpm(deps = defaultDeps()) {
13252
+ const name = npmBinaryName(deps.platform);
13253
+ const onPath = npmFromPath(deps);
13254
+ if (onPath)
13255
+ return { command: join6(onPath, name), binDir: onPath };
13256
+ const adjacent = npmAdjacentToNode(deps);
13257
+ if (adjacent)
13258
+ return { command: join6(adjacent, name), binDir: adjacent };
13259
+ for (const dir of wellKnownNpmDirs(deps)) {
13260
+ const candidate = join6(dir, name);
13261
+ if (isFile(candidate))
13262
+ return { command: candidate, binDir: dir };
13263
+ }
13264
+ return null;
13265
+ }
13266
+ function npmSpawnEnv(resolved, baseEnv = process.env) {
13267
+ if (!resolved.binDir)
13268
+ return { ...baseEnv };
13269
+ const existing = baseEnv.PATH ?? baseEnv.Path ?? "";
13270
+ const next = existing ? `${resolved.binDir}${delimiter}${existing}` : resolved.binDir;
13271
+ return { ...baseEnv, PATH: next };
13272
+ }
13273
+ function isNpmAvailable(deps = defaultDeps()) {
13274
+ return resolveNpm(deps) !== null;
13275
+ }
13130
13276
  // ../aft-bridge/dist/onnx-runtime.js
13131
13277
  import { execFileSync } from "node:child_process";
13132
13278
  import { createHash as createHash2 } from "node:crypto";
13133
- import { chmodSync as chmodSync3, closeSync as closeSync3, copyFileSync as copyFileSync3, createWriteStream as createWriteStream2, existsSync as existsSync5, lstatSync, mkdirSync as mkdirSync5, openSync as openSync3, readdirSync, readFileSync as readFileSync3, readlinkSync, realpathSync, rmSync as rmSync2, statSync as statSync2, symlinkSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync2 } from "node:fs";
13134
- import { basename, dirname as dirname3, isAbsolute, join as join6, relative, resolve, win32 } from "node:path";
13279
+ import { chmodSync as chmodSync3, closeSync as closeSync3, copyFileSync as copyFileSync3, createWriteStream as createWriteStream2, existsSync as existsSync5, lstatSync, mkdirSync as mkdirSync5, openSync as openSync3, readdirSync as readdirSync2, readFileSync as readFileSync3, readlinkSync, realpathSync, rmSync as rmSync2, statSync as statSync3, symlinkSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync2 } from "node:fs";
13280
+ import { basename, dirname as dirname4, isAbsolute as isAbsolute2, join as join7, relative, resolve, win32 } from "node:path";
13135
13281
  import { Readable as Readable2 } from "node:stream";
13136
13282
  import { pipeline as pipeline2 } from "node:stream/promises";
13137
13283
  var ORT_VERSION = "1.24.4";
@@ -13197,10 +13343,10 @@ function getManualInstallHint() {
13197
13343
  }
13198
13344
  async function ensureOnnxRuntime(storageDir) {
13199
13345
  const info = getPlatformInfo();
13200
- const ortVersionDir = join6(storageDir, "onnxruntime", ORT_VERSION);
13346
+ const ortVersionDir = join7(storageDir, "onnxruntime", ORT_VERSION);
13201
13347
  const libName = info?.libName ?? "libonnxruntime.dylib";
13202
13348
  const resolvedOrtDir = resolveCachedOnnxRuntimeDir(ortVersionDir, libName);
13203
- const libPath = join6(resolvedOrtDir, libName);
13349
+ const libPath = join7(resolvedOrtDir, libName);
13204
13350
  if (existsSync5(libPath)) {
13205
13351
  const meta = readOnnxInstalledMeta(ortVersionDir);
13206
13352
  if (meta?.sha256) {
@@ -13230,9 +13376,9 @@ async function ensureOnnxRuntime(storageDir) {
13230
13376
  warn(`ONNX Runtime auto-download not available for ${process.platform}/${process.arch}. Install manually: ${getManualInstallHint()}`);
13231
13377
  return null;
13232
13378
  }
13233
- const onnxBaseDir = join6(storageDir, "onnxruntime");
13379
+ const onnxBaseDir = join7(storageDir, "onnxruntime");
13234
13380
  mkdirSync5(onnxBaseDir, { recursive: true });
13235
- const lockPath = join6(onnxBaseDir, ONNX_LOCK_FILE);
13381
+ const lockPath = join7(onnxBaseDir, ONNX_LOCK_FILE);
13236
13382
  cleanupAbandonedStagingDirs(onnxBaseDir);
13237
13383
  if (!acquireLock(lockPath)) {
13238
13384
  warn(`ONNX Runtime install already in progress in another process (lock: ${lockPath}). Skipping.`);
@@ -13247,11 +13393,11 @@ async function ensureOnnxRuntime(storageDir) {
13247
13393
  }
13248
13394
  function cleanupAbandonedStagingDirs(onnxBaseDir) {
13249
13395
  try {
13250
- const entries = readdirSync(onnxBaseDir);
13396
+ const entries = readdirSync2(onnxBaseDir);
13251
13397
  for (const entry of entries) {
13252
13398
  if (!entry.startsWith(`${ORT_VERSION}.tmp.`))
13253
13399
  continue;
13254
- const stagingDir = join6(onnxBaseDir, entry);
13400
+ const stagingDir = join7(onnxBaseDir, entry);
13255
13401
  const parts = entry.split(".");
13256
13402
  const pidStr = parts[parts.length - 2];
13257
13403
  const pid = pidStr ? Number.parseInt(pidStr, 10) : NaN;
@@ -13263,7 +13409,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
13263
13409
  abandoned = true;
13264
13410
  } else {
13265
13411
  try {
13266
- const ageMs = Date.now() - statSync2(stagingDir).mtimeMs;
13412
+ const ageMs = Date.now() - statSync3(stagingDir).mtimeMs;
13267
13413
  abandoned = ageMs > STALE_LOCK_MS;
13268
13414
  } catch {
13269
13415
  abandoned = true;
@@ -13288,7 +13434,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
13288
13434
  }
13289
13435
  function cleanupIncompleteTargetIfUnowned(ortDir) {
13290
13436
  try {
13291
- if (existsSync5(ortDir) && !existsSync5(join6(ortDir, ONNX_INSTALLED_META_FILE))) {
13437
+ if (existsSync5(ortDir) && !existsSync5(join7(ortDir, ONNX_INSTALLED_META_FILE))) {
13292
13438
  log(`[onnx] removing half-populated install dir ${ortDir} (no meta file)`);
13293
13439
  rmSync2(ortDir, { recursive: true, force: true });
13294
13440
  }
@@ -13317,11 +13463,11 @@ function parseOnnxVersionFromDirectoryPath(value) {
13317
13463
  }
13318
13464
  function isPathInsideRoot(root, candidate) {
13319
13465
  const rel = relative(root, candidate);
13320
- return rel === "" || !rel.startsWith("../") && !rel.startsWith("..\\") && rel !== ".." && !isAbsolute(rel) && !win32.isAbsolute(rel);
13466
+ return rel === "" || !rel.startsWith("../") && !rel.startsWith("..\\") && rel !== ".." && !isAbsolute2(rel) && !win32.isAbsolute(rel);
13321
13467
  }
13322
13468
  function detectOnnxVersion(libDir, libName) {
13323
13469
  try {
13324
- const entries = readdirSync(libDir);
13470
+ const entries = readdirSync2(libDir);
13325
13471
  const barePrefix = libName.replace(/\.(so|dylib|dll)$/, "");
13326
13472
  const expectedPrefix = process.platform === "win32" ? barePrefix.toLowerCase() : barePrefix;
13327
13473
  for (const entry of entries) {
@@ -13332,7 +13478,7 @@ function detectOnnxVersion(libDir, libName) {
13332
13478
  if (version)
13333
13479
  return version;
13334
13480
  }
13335
- const base = join6(libDir, libName);
13481
+ const base = join7(libDir, libName);
13336
13482
  if (existsSync5(base)) {
13337
13483
  try {
13338
13484
  const real = realpathSync(base);
@@ -13364,16 +13510,16 @@ function pathEnvValue() {
13364
13510
  return process.env.PATH ?? process.env.Path ?? process.env.path ?? "";
13365
13511
  }
13366
13512
  function pathEntriesForPlatform() {
13367
- const delimiter = process.platform === "win32" ? ";" : ":";
13368
- return pathEnvValue().split(delimiter).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => {
13513
+ const delimiter2 = process.platform === "win32" ? ";" : ":";
13514
+ return pathEnvValue().split(delimiter2).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => {
13369
13515
  if (!entry || entry === "." || entry.includes("\x00"))
13370
13516
  return false;
13371
- return isAbsolute(entry) || win32.isAbsolute(entry);
13517
+ return isAbsolute2(entry) || win32.isAbsolute(entry);
13372
13518
  });
13373
13519
  }
13374
13520
  function directoryContainsLibrary(dir, libName) {
13375
13521
  try {
13376
- const entries = readdirSync(dir);
13522
+ const entries = readdirSync2(dir);
13377
13523
  if (process.platform === "win32") {
13378
13524
  const expected = libName.toLowerCase();
13379
13525
  return entries.some((entry) => entry.toLowerCase() === expected);
@@ -13384,10 +13530,10 @@ function directoryContainsLibrary(dir, libName) {
13384
13530
  }
13385
13531
  }
13386
13532
  function resolveCachedOnnxRuntimeDir(ortVersionDir, libName) {
13387
- if (existsSync5(join6(ortVersionDir, libName)))
13533
+ if (existsSync5(join7(ortVersionDir, libName)))
13388
13534
  return ortVersionDir;
13389
- const libSubdir = join6(ortVersionDir, "lib");
13390
- if (existsSync5(join6(libSubdir, libName)))
13535
+ const libSubdir = join7(ortVersionDir, "lib");
13536
+ if (existsSync5(join7(libSubdir, libName)))
13391
13537
  return libSubdir;
13392
13538
  return ortVersionDir;
13393
13539
  }
@@ -13402,21 +13548,21 @@ function findSystemOnnxRuntime(libName) {
13402
13548
  } else if (process.platform === "win32") {
13403
13549
  const programFiles = process.env.ProgramFiles ?? "C:\\Program Files";
13404
13550
  const programFilesX86 = process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
13405
- searchPaths.push(join6(programFiles, "onnxruntime", "lib"), join6(programFiles, "Microsoft ONNX Runtime", "lib"), join6(programFiles, "Microsoft Machine Learning", "lib"), join6(programFilesX86, "onnxruntime", "lib"), ...(() => {
13551
+ searchPaths.push(join7(programFiles, "onnxruntime", "lib"), join7(programFiles, "Microsoft ONNX Runtime", "lib"), join7(programFiles, "Microsoft Machine Learning", "lib"), join7(programFilesX86, "onnxruntime", "lib"), ...(() => {
13406
13552
  const nugetPaths = [];
13407
13553
  const userProfile = process.env.USERPROFILE ?? "";
13408
13554
  if (!userProfile)
13409
13555
  return nugetPaths;
13410
- const nugetPackageDir = join6(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
13556
+ const nugetPackageDir = join7(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
13411
13557
  if (!existsSync5(nugetPackageDir))
13412
13558
  return nugetPaths;
13413
13559
  try {
13414
- for (const entry of readdirSync(nugetPackageDir, { withFileTypes: true })) {
13560
+ for (const entry of readdirSync2(nugetPackageDir, { withFileTypes: true })) {
13415
13561
  if (!entry.isDirectory())
13416
13562
  continue;
13417
13563
  if (entry.name === "__globalPackagesFolder" || entry.name.startsWith("."))
13418
13564
  continue;
13419
- nugetPaths.push(join6(nugetPackageDir, entry.name, "runtimes", "win-x64", "native"), join6(nugetPackageDir, entry.name, "runtimes", "win-arm64", "native"));
13565
+ nugetPaths.push(join7(nugetPackageDir, entry.name, "runtimes", "win-x64", "native"), join7(nugetPackageDir, entry.name, "runtimes", "win-arm64", "native"));
13420
13566
  }
13421
13567
  } catch (err) {
13422
13568
  warn(`Failed to scan NuGet ONNX Runtime cache ${nugetPackageDir}: ${err instanceof Error ? err.message : String(err)}`);
@@ -13438,7 +13584,7 @@ function findSystemOnnxRuntime(libName) {
13438
13584
  });
13439
13585
  const unknownVersionPaths = [];
13440
13586
  for (const dir of uniquePaths) {
13441
- const libPath = join6(dir, libName);
13587
+ const libPath = join7(dir, libName);
13442
13588
  if (process.platform === "win32") {
13443
13589
  if (!directoryContainsLibrary(dir, libName))
13444
13590
  continue;
@@ -13474,7 +13620,7 @@ async function downloadFileWithCap(url, destPath) {
13474
13620
  if (Number.isFinite(advertised) && advertised > MAX_DOWNLOAD_BYTES2) {
13475
13621
  throw new Error(`Content-Length ${advertised} exceeds max ${MAX_DOWNLOAD_BYTES2}`);
13476
13622
  }
13477
- mkdirSync5(dirname3(destPath), { recursive: true });
13623
+ mkdirSync5(dirname4(destPath), { recursive: true });
13478
13624
  let bytesWritten = 0;
13479
13625
  const guard = new TransformStream({
13480
13626
  transform(chunk, transformController) {
@@ -13502,21 +13648,21 @@ function validateExtractedTree(stagingRoot) {
13502
13648
  const realRoot = realpathSync(stagingRoot);
13503
13649
  let totalBytes = 0;
13504
13650
  const walk = (dir) => {
13505
- const entries = readdirSync(dir);
13651
+ const entries = readdirSync2(dir);
13506
13652
  for (const entry of entries) {
13507
- const fullPath = join6(dir, entry);
13653
+ const fullPath = join7(dir, entry);
13508
13654
  const lst = lstatSync(fullPath);
13509
13655
  if (lst.isSymbolicLink()) {
13510
13656
  const linkTarget = readlinkSync(fullPath);
13511
- const resolvedTarget = resolve(dirname3(fullPath), linkTarget);
13657
+ const resolvedTarget = resolve(dirname4(fullPath), linkTarget);
13512
13658
  const rel2 = relative(realRoot, resolvedTarget);
13513
- if (rel2.startsWith("..") || isAbsolute(rel2) || win32.isAbsolute(rel2)) {
13659
+ if (rel2.startsWith("..") || isAbsolute2(rel2) || win32.isAbsolute(rel2)) {
13514
13660
  throw new Error(`extracted symlink ${fullPath} points outside staging root: ${linkTarget}`);
13515
13661
  }
13516
13662
  continue;
13517
13663
  }
13518
13664
  const rel = relative(realRoot, fullPath);
13519
- if (rel.startsWith("..") || isAbsolute(rel) || win32.isAbsolute(rel)) {
13665
+ if (rel.startsWith("..") || isAbsolute2(rel) || win32.isAbsolute(rel)) {
13520
13666
  throw new Error(`extracted entry ${fullPath} escapes staging root`);
13521
13667
  }
13522
13668
  if (lst.isDirectory()) {
@@ -13539,7 +13685,7 @@ async function downloadOnnxRuntime(info, targetDir) {
13539
13685
  const tmpDir = `${targetDir}.tmp.${process.pid}.${Date.now().toString(36)}`;
13540
13686
  try {
13541
13687
  mkdirSync5(tmpDir, { recursive: true });
13542
- const archivePath = join6(tmpDir, `onnxruntime.${info.archiveType}`);
13688
+ const archivePath = join7(tmpDir, `onnxruntime.${info.archiveType}`);
13543
13689
  await downloadFileWithCap(url, archivePath);
13544
13690
  const archiveSha256 = sha256File(archivePath);
13545
13691
  log(`ONNX Runtime archive sha256=${archiveSha256}`);
@@ -13555,16 +13701,16 @@ async function downloadOnnxRuntime(info, targetDir) {
13555
13701
  unlinkSync3(archivePath);
13556
13702
  } catch {}
13557
13703
  validateExtractedTree(tmpDir);
13558
- const extractedDir = join6(tmpDir, info.assetName, "lib");
13704
+ const extractedDir = join7(tmpDir, info.assetName, "lib");
13559
13705
  if (!existsSync5(extractedDir)) {
13560
13706
  throw new Error(`Expected directory not found: ${extractedDir}`);
13561
13707
  }
13562
13708
  mkdirSync5(targetDir, { recursive: true });
13563
- const libFiles = readdirSync(extractedDir).filter((f) => f.startsWith("libonnxruntime") || f.startsWith("onnxruntime"));
13709
+ const libFiles = readdirSync2(extractedDir).filter((f) => f.startsWith("libonnxruntime") || f.startsWith("onnxruntime"));
13564
13710
  const realFiles = [];
13565
13711
  const symlinks = [];
13566
13712
  for (const libFile of libFiles) {
13567
- const src = join6(extractedDir, libFile);
13713
+ const src = join7(extractedDir, libFile);
13568
13714
  try {
13569
13715
  const stat = lstatSync(src);
13570
13716
  log(`ORT extract: ${libFile} — isSymlink=${stat.isSymbolicLink()}, isFile=${stat.isFile()}, size=${stat.size}`);
@@ -13579,7 +13725,7 @@ async function downloadOnnxRuntime(info, targetDir) {
13579
13725
  }
13580
13726
  }
13581
13727
  copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks);
13582
- const libPath = join6(targetDir, info.libName);
13728
+ const libPath = join7(targetDir, info.libName);
13583
13729
  let libHash = null;
13584
13730
  try {
13585
13731
  libHash = sha256File(libPath);
@@ -13604,8 +13750,8 @@ async function downloadOnnxRuntime(info, targetDir) {
13604
13750
  function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, copyFile = copyFileSync3) {
13605
13751
  const requiredLibs = new Set([info.libName]);
13606
13752
  for (const libFile of realFiles) {
13607
- const src = join6(extractedDir, libFile);
13608
- const dst = join6(targetDir, libFile);
13753
+ const src = join7(extractedDir, libFile);
13754
+ const dst = join7(targetDir, libFile);
13609
13755
  try {
13610
13756
  copyFile(src, dst);
13611
13757
  if (process.platform !== "win32") {
@@ -13621,12 +13767,12 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
13621
13767
  }
13622
13768
  const targetRoot = realpathSync(targetDir);
13623
13769
  for (const link of symlinks) {
13624
- const dst = join6(targetDir, link.name);
13770
+ const dst = join7(targetDir, link.name);
13625
13771
  try {
13626
13772
  unlinkSync3(dst);
13627
13773
  } catch {}
13628
- const dstForContainment = join6(targetRoot, link.name);
13629
- const resolvedTarget = resolve(dirname3(dstForContainment), link.target);
13774
+ const dstForContainment = join7(targetRoot, link.name);
13775
+ const resolvedTarget = resolve(dirname4(dstForContainment), link.target);
13630
13776
  if (!isPathInsideRoot(targetRoot, resolvedTarget)) {
13631
13777
  const message = `ONNX Runtime symlink ${link.name} points outside install dir: ${link.target}`;
13632
13778
  if (requiredLibs.has(link.name)) {
@@ -13646,7 +13792,7 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
13646
13792
  log(`ORT extract: failed to symlink optional ${link.name}: ${symlinkErr}`);
13647
13793
  }
13648
13794
  }
13649
- const requiredPath = join6(targetDir, info.libName);
13795
+ const requiredPath = join7(targetDir, info.libName);
13650
13796
  if (!existsSync5(requiredPath)) {
13651
13797
  rmSync2(targetDir, { recursive: true, force: true });
13652
13798
  throw new Error(`Required ONNX Runtime library missing after install: ${requiredPath}`);
@@ -13673,15 +13819,15 @@ function writeOnnxInstalledMeta(installDir, version, sha256, archiveSha256) {
13673
13819
  ...sha256 ? { sha256 } : {},
13674
13820
  archiveSha256
13675
13821
  };
13676
- writeFileSync2(join6(installDir, ONNX_INSTALLED_META_FILE), JSON.stringify(meta), "utf8");
13822
+ writeFileSync2(join7(installDir, ONNX_INSTALLED_META_FILE), JSON.stringify(meta), "utf8");
13677
13823
  } catch (err) {
13678
13824
  log(`[onnx] failed to write installed-meta in ${installDir}: ${err}`);
13679
13825
  }
13680
13826
  }
13681
13827
  function readOnnxInstalledMeta(installDir) {
13682
- const path = join6(installDir, ONNX_INSTALLED_META_FILE);
13828
+ const path = join7(installDir, ONNX_INSTALLED_META_FILE);
13683
13829
  try {
13684
- if (!statSync2(path).isFile())
13830
+ if (!statSync3(path).isFile())
13685
13831
  return null;
13686
13832
  const raw = readFileSync3(path, "utf8");
13687
13833
  const parsed = JSON.parse(raw);
@@ -13732,7 +13878,7 @@ ${new Date().toISOString()}
13732
13878
  const parsed = Number.parseInt(firstLine, 10);
13733
13879
  if (Number.isFinite(parsed) && parsed > 0)
13734
13880
  owningPid = parsed;
13735
- lockMtimeMs = statSync2(lockPath).mtimeMs;
13881
+ lockMtimeMs = statSync3(lockPath).mtimeMs;
13736
13882
  } catch {
13737
13883
  return tryClaim();
13738
13884
  }
@@ -15032,8 +15178,8 @@ function formatDuration(completion) {
15032
15178
 
15033
15179
  // src/config.ts
15034
15180
  import { existsSync as existsSync6, readFileSync as readFileSync4, renameSync as renameSync4, unlinkSync as unlinkSync4, writeFileSync as writeFileSync3 } from "node:fs";
15035
- import { homedir as homedir5 } from "node:os";
15036
- import { join as join8 } from "node:path";
15181
+ import { homedir as homedir6 } from "node:os";
15182
+ import { join as join9 } from "node:path";
15037
15183
  var import_comment_json = __toESM(require_src2(), 1);
15038
15184
 
15039
15185
  // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
@@ -16620,8 +16766,8 @@ function emoji() {
16620
16766
  }
16621
16767
  var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
16622
16768
  var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
16623
- var mac = (delimiter) => {
16624
- const escapedDelim = escapeRegex(delimiter ?? ":");
16769
+ var mac = (delimiter2) => {
16770
+ const escapedDelim = escapeRegex(delimiter2 ?? ":");
16625
16771
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
16626
16772
  };
16627
16773
  var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
@@ -29228,17 +29374,17 @@ function getOpenCodeConfigDir() {
29228
29374
  if (envDir) {
29229
29375
  return envDir;
29230
29376
  }
29231
- const xdgConfig = process.env.XDG_CONFIG_HOME || join8(homedir5(), ".config");
29232
- return join8(xdgConfig, "opencode");
29377
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join9(homedir6(), ".config");
29378
+ return join9(xdgConfig, "opencode");
29233
29379
  }
29234
29380
  function loadAftConfig(projectDirectory) {
29235
29381
  const configDir = getOpenCodeConfigDir();
29236
- const userBasePath = join8(configDir, "aft");
29382
+ const userBasePath = join9(configDir, "aft");
29237
29383
  migrateAftConfigFile(`${userBasePath}.jsonc`);
29238
29384
  migrateAftConfigFile(`${userBasePath}.json`);
29239
29385
  const userDetected = detectConfigFile(userBasePath);
29240
29386
  const userConfigPath = userDetected.format !== "none" ? userDetected.path : `${userBasePath}.json`;
29241
- const projectBasePath = join8(projectDirectory, ".opencode", "aft");
29387
+ const projectBasePath = join9(projectDirectory, ".opencode", "aft");
29242
29388
  migrateAftConfigFile(`${projectBasePath}.jsonc`);
29243
29389
  migrateAftConfigFile(`${projectBasePath}.json`);
29244
29390
  const projectDetected = detectConfigFile(projectBasePath);
@@ -29264,8 +29410,8 @@ function loadAftConfig(projectDirectory) {
29264
29410
 
29265
29411
  // src/notifications.ts
29266
29412
  import { existsSync as existsSync7, readFileSync as readFileSync5 } from "node:fs";
29267
- import { homedir as homedir6, platform } from "node:os";
29268
- import { join as join9 } from "node:path";
29413
+ import { homedir as homedir7, platform } from "node:os";
29414
+ import { join as join10 } from "node:path";
29269
29415
  function isTuiMode() {
29270
29416
  return process.env.OPENCODE_CLIENT === "cli";
29271
29417
  }
@@ -29286,17 +29432,17 @@ var WARNING_MARKER = `${AFT_MARKER} ⚠️`;
29286
29432
  var STATUS_MARKER = `${AFT_MARKER} ✅`;
29287
29433
  function getDesktopStatePath() {
29288
29434
  const os2 = platform();
29289
- const home = homedir6();
29435
+ const home = homedir7();
29290
29436
  if (os2 === "darwin") {
29291
- return join9(home, "Library", "Application Support", "ai.opencode.desktop", "opencode.global.dat");
29437
+ return join10(home, "Library", "Application Support", "ai.opencode.desktop", "opencode.global.dat");
29292
29438
  }
29293
29439
  if (os2 === "linux") {
29294
- const xdgConfig = process.env.XDG_CONFIG_HOME || join9(home, ".config");
29295
- return join9(xdgConfig, "ai.opencode.desktop", "opencode.global.dat");
29440
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join10(home, ".config");
29441
+ return join10(xdgConfig, "ai.opencode.desktop", "opencode.global.dat");
29296
29442
  }
29297
29443
  if (os2 === "win32") {
29298
- const appData = process.env.APPDATA || join9(home, "AppData", "Roaming");
29299
- return join9(appData, "ai.opencode.desktop", "opencode.global.dat");
29444
+ const appData = process.env.APPDATA || join10(home, "AppData", "Roaming");
29445
+ return join10(appData, "ai.opencode.desktop", "opencode.global.dat");
29300
29446
  }
29301
29447
  return null;
29302
29448
  }
@@ -29760,43 +29906,43 @@ import {
29760
29906
  rmSync as rmSync4,
29761
29907
  writeFileSync as writeFileSync6
29762
29908
  } from "node:fs";
29763
- import { dirname as dirname6 } from "node:path";
29909
+ import { dirname as dirname7 } from "node:path";
29764
29910
 
29765
29911
  // src/hooks/auto-update-checker/cache.ts
29766
- var import_comment_json3 = __toESM(require_src2(), 1);
29767
29912
  import { spawn as spawn2 } from "node:child_process";
29768
29913
  import { cpSync, existsSync as existsSync9, mkdtempSync, readFileSync as readFileSync7, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
29769
29914
  import { tmpdir as tmpdir3 } from "node:os";
29770
- import { basename as basename2, dirname as dirname5, join as join12 } from "node:path";
29915
+ import { basename as basename2, dirname as dirname6, join as join13 } from "node:path";
29916
+ var import_comment_json3 = __toESM(require_src2(), 1);
29771
29917
 
29772
29918
  // src/hooks/auto-update-checker/checker.ts
29773
29919
  var import_comment_json2 = __toESM(require_src2(), 1);
29774
- import { existsSync as existsSync8, readFileSync as readFileSync6, statSync as statSync3, writeFileSync as writeFileSync4 } from "node:fs";
29775
- import { homedir as homedir8 } from "node:os";
29776
- import { dirname as dirname4, isAbsolute as isAbsolute2, join as join11, resolve as resolve2 } from "node:path";
29920
+ import { existsSync as existsSync8, readFileSync as readFileSync6, statSync as statSync4, writeFileSync as writeFileSync4 } from "node:fs";
29921
+ import { homedir as homedir9 } from "node:os";
29922
+ import { dirname as dirname5, isAbsolute as isAbsolute3, join as join12, resolve as resolve2 } from "node:path";
29777
29923
  import { fileURLToPath } from "node:url";
29778
29924
 
29779
29925
  // src/hooks/auto-update-checker/constants.ts
29780
- import { homedir as homedir7, platform as platform2 } from "node:os";
29781
- import { join as join10 } from "node:path";
29926
+ import { homedir as homedir8, platform as platform2 } from "node:os";
29927
+ import { join as join11 } from "node:path";
29782
29928
  var PACKAGE_NAME = "@cortexkit/aft-opencode";
29783
29929
  var NPM_REGISTRY_URL = "https://registry.npmjs.org";
29784
29930
  var NPM_FETCH_TIMEOUT = 1e4;
29785
29931
  function getOpenCodeCacheRoot() {
29786
29932
  if (platform2() === "win32") {
29787
- return join10(process.env.LOCALAPPDATA ?? homedir7(), "opencode");
29933
+ return join11(process.env.LOCALAPPDATA ?? homedir8(), "opencode");
29788
29934
  }
29789
- return join10(homedir7(), ".cache", "opencode");
29935
+ return join11(homedir8(), ".cache", "opencode");
29790
29936
  }
29791
29937
  function getOpenCodeConfigRoot() {
29792
29938
  if (platform2() === "win32") {
29793
- return join10(process.env.APPDATA ?? join10(homedir7(), "AppData", "Roaming"), "opencode");
29939
+ return join11(process.env.APPDATA ?? join11(homedir8(), "AppData", "Roaming"), "opencode");
29794
29940
  }
29795
- return join10(process.env.XDG_CONFIG_HOME ?? join10(homedir7(), ".config"), "opencode");
29941
+ return join11(process.env.XDG_CONFIG_HOME ?? join11(homedir8(), ".config"), "opencode");
29796
29942
  }
29797
- var CACHE_DIR = join10(getOpenCodeCacheRoot(), "packages");
29798
- var USER_OPENCODE_CONFIG = join10(getOpenCodeConfigRoot(), "opencode.json");
29799
- var USER_OPENCODE_CONFIG_JSONC = join10(getOpenCodeConfigRoot(), "opencode.jsonc");
29943
+ var CACHE_DIR = join11(getOpenCodeCacheRoot(), "packages");
29944
+ var USER_OPENCODE_CONFIG = join11(getOpenCodeConfigRoot(), "opencode.json");
29945
+ var USER_OPENCODE_CONFIG_JSONC = join11(getOpenCodeConfigRoot(), "opencode.jsonc");
29800
29946
 
29801
29947
  // src/hooks/auto-update-checker/types.ts
29802
29948
  var NpmPackageEnvelopeSchema = exports_external.object({
@@ -29854,8 +30000,8 @@ function extractChannel(version2) {
29854
30000
  }
29855
30001
  function getConfigPaths(directory) {
29856
30002
  return [
29857
- join11(directory, ".opencode", "opencode.json"),
29858
- join11(directory, ".opencode", "opencode.jsonc"),
30003
+ join12(directory, ".opencode", "opencode.json"),
30004
+ join12(directory, ".opencode", "opencode.jsonc"),
29859
30005
  USER_OPENCODE_CONFIG,
29860
30006
  USER_OPENCODE_CONFIG_JSONC
29861
30007
  ];
@@ -29868,9 +30014,9 @@ function resolvePathPluginSpec(spec, configPath) {
29868
30014
  return spec.replace(/^file:\/\//, "");
29869
30015
  }
29870
30016
  }
29871
- if (isAbsolute2(spec) || /^[A-Za-z]:[\\/]/.test(spec))
30017
+ if (isAbsolute3(spec) || /^[A-Za-z]:[\\/]/.test(spec))
29872
30018
  return spec;
29873
- return resolve2(dirname4(configPath), spec);
30019
+ return resolve2(dirname5(configPath), spec);
29874
30020
  }
29875
30021
  function getLocalDevPath(directory) {
29876
30022
  for (const configPath of getConfigPaths(directory)) {
@@ -29882,7 +30028,7 @@ function getLocalDevPath(directory) {
29882
30028
  for (const entry of plugins) {
29883
30029
  if (entry === PACKAGE_NAME || entry.startsWith(`${PACKAGE_NAME}@`))
29884
30030
  continue;
29885
- if (entry.startsWith("file://") || entry.startsWith(".") || isAbsolute2(entry)) {
30031
+ if (entry.startsWith("file://") || entry.startsWith(".") || isAbsolute3(entry)) {
29886
30032
  const localPath = resolvePathPluginSpec(entry, configPath);
29887
30033
  const pkgPath = findPackageJsonUp(localPath);
29888
30034
  if (!pkgPath)
@@ -29898,10 +30044,10 @@ function getLocalDevPath(directory) {
29898
30044
  }
29899
30045
  function findPackageJsonUp(startPath) {
29900
30046
  try {
29901
- const stat = statSync3(startPath);
29902
- let dir = stat.isDirectory() ? startPath : dirname4(startPath);
30047
+ const stat = statSync4(startPath);
30048
+ let dir = stat.isDirectory() ? startPath : dirname5(startPath);
29903
30049
  for (let i = 0;i < 10; i++) {
29904
- const pkgPath = join11(dir, "package.json");
30050
+ const pkgPath = join12(dir, "package.json");
29905
30051
  if (existsSync8(pkgPath)) {
29906
30052
  try {
29907
30053
  const pkg = PackageJsonSchema.safeParse(JSON.parse(readFileSync6(pkgPath, "utf-8")));
@@ -29909,7 +30055,7 @@ function findPackageJsonUp(startPath) {
29909
30055
  return pkgPath;
29910
30056
  } catch {}
29911
30057
  }
29912
- const parent = dirname4(dir);
30058
+ const parent = dirname5(dir);
29913
30059
  if (parent === dir)
29914
30060
  break;
29915
30061
  dir = parent;
@@ -29933,7 +30079,7 @@ function getLocalDevVersion(directory) {
29933
30079
  }
29934
30080
  function getCurrentRuntimePackageJsonPath(currentModuleUrl = import.meta.url) {
29935
30081
  try {
29936
- return findPackageJsonUp(dirname4(fileURLToPath(currentModuleUrl)));
30082
+ return findPackageJsonUp(dirname5(fileURLToPath(currentModuleUrl)));
29937
30083
  } catch (err) {
29938
30084
  warn2(`[auto-update-checker] Failed to resolve runtime package path: ${String(err)}`);
29939
30085
  return null;
@@ -29962,7 +30108,7 @@ function findPluginEntry(directory) {
29962
30108
  }
29963
30109
  var cachedPackageVersion = null;
29964
30110
  function getSpecCachePackageJsonPath(spec) {
29965
- return join11(CACHE_DIR, spec, "node_modules", PACKAGE_NAME, "package.json");
30111
+ return join12(CACHE_DIR, spec, "node_modules", PACKAGE_NAME, "package.json");
29966
30112
  }
29967
30113
  function getCachedVersion(spec) {
29968
30114
  if (!spec && cachedPackageVersion)
@@ -29971,7 +30117,7 @@ function getCachedVersion(spec) {
29971
30117
  getCurrentRuntimePackageJsonPath(),
29972
30118
  spec ? getSpecCachePackageJsonPath(spec) : null,
29973
30119
  getSpecCachePackageJsonPath(`${PACKAGE_NAME}@latest`),
29974
- join11(homedir8(), ".cache", "opencode", "node_modules", PACKAGE_NAME, "package.json")
30120
+ join12(homedir9(), ".cache", "opencode", "node_modules", PACKAGE_NAME, "package.json")
29975
30121
  ].filter(isString);
29976
30122
  for (const packageJsonPath of candidates) {
29977
30123
  try {
@@ -30019,10 +30165,10 @@ async function getLatestVersion(channel = "latest", options = {}) {
30019
30165
  // src/hooks/auto-update-checker/cache.ts
30020
30166
  var pendingSnapshots = new Map;
30021
30167
  function createAutoUpdateSnapshot(installDir, packageJsonPath, packageName) {
30022
- const packageDir = join12(installDir, "node_modules", packageName);
30023
- const lockfilePath = join12(installDir, "package-lock.json");
30024
- const tempDir = mkdtempSync(join12(tmpdir3(), "aft-auto-update-"));
30025
- const stagedPackageDir = existsSync9(packageDir) ? join12(tempDir, "package") : null;
30168
+ const packageDir = join13(installDir, "node_modules", packageName);
30169
+ const lockfilePath = join13(installDir, "package-lock.json");
30170
+ const tempDir = mkdtempSync(join13(tmpdir3(), "aft-auto-update-"));
30171
+ const stagedPackageDir = existsSync9(packageDir) ? join13(tempDir, "package") : null;
30026
30172
  if (stagedPackageDir)
30027
30173
  cpSync(packageDir, stagedPackageDir, { recursive: true });
30028
30174
  return {
@@ -30058,12 +30204,12 @@ function stripPackageNameFromPath(pathValue, packageName) {
30058
30204
  for (const segment of [...packageName.split("/")].reverse()) {
30059
30205
  if (basename2(current) !== segment)
30060
30206
  return null;
30061
- current = dirname5(current);
30207
+ current = dirname6(current);
30062
30208
  }
30063
30209
  return current;
30064
30210
  }
30065
30211
  function removeFromPackageLock(installDir, packageName) {
30066
- const lockPath = join12(installDir, "package-lock.json");
30212
+ const lockPath = join13(installDir, "package-lock.json");
30067
30213
  if (!existsSync9(lockPath))
30068
30214
  return false;
30069
30215
  try {
@@ -30112,7 +30258,7 @@ function ensureDependencyVersion(packageJsonPath, packageName, version2) {
30112
30258
  }
30113
30259
  }
30114
30260
  function removeInstalledPackage(installDir, packageName) {
30115
- const packageDir = join12(installDir, "node_modules", packageName);
30261
+ const packageDir = join13(installDir, "node_modules", packageName);
30116
30262
  if (!existsSync9(packageDir))
30117
30263
  return false;
30118
30264
  rmSync3(packageDir, { recursive: true, force: true });
@@ -30121,19 +30267,19 @@ function removeInstalledPackage(installDir, packageName) {
30121
30267
  }
30122
30268
  function resolveInstallContext(runtimePackageJsonPath = getCurrentRuntimePackageJsonPath()) {
30123
30269
  if (runtimePackageJsonPath) {
30124
- const packageDir = dirname5(runtimePackageJsonPath);
30270
+ const packageDir = dirname6(runtimePackageJsonPath);
30125
30271
  const nodeModulesDir = stripPackageNameFromPath(packageDir, PACKAGE_NAME);
30126
30272
  if (nodeModulesDir && basename2(nodeModulesDir) === "node_modules") {
30127
- const installDir = dirname5(nodeModulesDir);
30128
- const packageJsonPath = join12(installDir, "package.json");
30273
+ const installDir = dirname6(nodeModulesDir);
30274
+ const packageJsonPath = join13(installDir, "package.json");
30129
30275
  if (existsSync9(packageJsonPath))
30130
30276
  return { installDir, packageJsonPath };
30131
30277
  }
30132
30278
  return null;
30133
30279
  }
30134
- const legacyPackageJsonPath = join12(dirname5(CACHE_DIR), "package.json");
30280
+ const legacyPackageJsonPath = join13(dirname6(CACHE_DIR), "package.json");
30135
30281
  if (existsSync9(legacyPackageJsonPath)) {
30136
- return { installDir: dirname5(CACHE_DIR), packageJsonPath: legacyPackageJsonPath };
30282
+ return { installDir: dirname6(CACHE_DIR), packageJsonPath: legacyPackageJsonPath };
30137
30283
  }
30138
30284
  return null;
30139
30285
  }
@@ -30169,10 +30315,16 @@ async function runNpmInstallSafe(installDir, options = {}) {
30169
30315
  try {
30170
30316
  if (options.signal?.aborted)
30171
30317
  return { ok: false, reason: "aborted" };
30172
- const npmBin = process.platform === "win32" ? "npm.cmd" : "npm";
30173
- const proc = spawn2(npmBin, ["install", "--no-audit", "--no-fund", "--no-progress", "--ignore-scripts"], {
30318
+ const npm = resolveNpm();
30319
+ if (!npm) {
30320
+ const reason = "npm not found on PATH or in known version-manager locations";
30321
+ warnNpmInstallFailure(reason, stderrTail);
30322
+ return { ok: false, reason };
30323
+ }
30324
+ const proc = spawn2(npm.command, ["install", "--no-audit", "--no-fund", "--no-progress", "--ignore-scripts"], {
30174
30325
  cwd: installDir,
30175
- stdio: ["ignore", "pipe", "pipe"]
30326
+ stdio: ["ignore", "pipe", "pipe"],
30327
+ env: npmSpawnEnv(npm)
30176
30328
  });
30177
30329
  proc.stderr?.on("data", (chunk) => {
30178
30330
  stderrTail += chunk.toString("utf8");
@@ -30301,7 +30453,7 @@ function claimCheckSlot(storageDir, intervalMs) {
30301
30453
  try {
30302
30454
  if (hasRecentCheckTimestamp(file2, intervalMs))
30303
30455
  return null;
30304
- mkdirSync6(dirname6(file2), { recursive: true });
30456
+ mkdirSync6(dirname7(file2), { recursive: true });
30305
30457
  const lockPath = `${file2}.lock`;
30306
30458
  let lockFd;
30307
30459
  try {
@@ -30411,6 +30563,11 @@ async function runBackgroundUpdateCheck(ctx, options) {
30411
30563
  log2("[auto-update-checker] Auto-update disabled, notification only");
30412
30564
  return;
30413
30565
  }
30566
+ if (!isNpmAvailable()) {
30567
+ showToast(ctx, `AFT ${latestVersion} available`, `v${latestVersion} is ready, but npm was not found so it can't auto-install. Run \`npx @cortexkit/aft doctor --fix\` from a terminal, or launch OpenCode from a shell where npm is on PATH.`, "warning", 1e4);
30568
+ warn2("[auto-update-checker] npm not found on PATH or known version-manager locations; skipping destructive auto-update steps");
30569
+ return;
30570
+ }
30414
30571
  const installDir = preparePackageUpdate(latestVersion, PACKAGE_NAME);
30415
30572
  if (!installDir) {
30416
30573
  showToast(ctx, `AFT ${latestVersion}`, `v${latestVersion} available. Auto-update could not prepare the active install.`, "warning", 8000);
@@ -30441,8 +30598,8 @@ function showToast(ctx, title, message, variant = "info", duration3 = 3000) {
30441
30598
  // src/lsp-auto-install.ts
30442
30599
  import { spawn as spawn3 } from "node:child_process";
30443
30600
  import { createHash as createHash4 } from "node:crypto";
30444
- import { createReadStream, mkdirSync as mkdirSync8, readFileSync as readFileSync11, renameSync as renameSync6, rmSync as rmSync5, statSync as statSync5 } from "node:fs";
30445
- import { join as join15 } from "node:path";
30601
+ import { createReadStream, mkdirSync as mkdirSync8, readFileSync as readFileSync11, renameSync as renameSync6, rmSync as rmSync5, statSync as statSync6 } from "node:fs";
30602
+ import { join as join16 } from "node:path";
30446
30603
 
30447
30604
  // src/lsp-cache.ts
30448
30605
  import {
@@ -30450,40 +30607,40 @@ import {
30450
30607
  mkdirSync as mkdirSync7,
30451
30608
  openSync as openSync5,
30452
30609
  readFileSync as readFileSync9,
30453
- statSync as statSync4,
30610
+ statSync as statSync5,
30454
30611
  unlinkSync as unlinkSync5,
30455
30612
  writeFileSync as writeFileSync7
30456
30613
  } from "node:fs";
30457
- import { homedir as homedir9 } from "node:os";
30458
- import { join as join13 } from "node:path";
30614
+ import { homedir as homedir10 } from "node:os";
30615
+ import { join as join14 } from "node:path";
30459
30616
  function aftCacheBase() {
30460
30617
  const override = process.env.AFT_CACHE_DIR;
30461
30618
  if (override && override.length > 0)
30462
30619
  return override;
30463
30620
  if (process.platform === "win32") {
30464
30621
  const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
30465
- const base2 = localAppData || join13(homedir9(), "AppData", "Local");
30466
- return join13(base2, "aft");
30622
+ const base2 = localAppData || join14(homedir10(), "AppData", "Local");
30623
+ return join14(base2, "aft");
30467
30624
  }
30468
- const base = process.env.XDG_CACHE_HOME || join13(homedir9(), ".cache");
30469
- return join13(base, "aft");
30625
+ const base = process.env.XDG_CACHE_HOME || join14(homedir10(), ".cache");
30626
+ return join14(base, "aft");
30470
30627
  }
30471
30628
  function lspCacheRoot() {
30472
- return join13(aftCacheBase(), "lsp-packages");
30629
+ return join14(aftCacheBase(), "lsp-packages");
30473
30630
  }
30474
30631
  function lspPackageDir(npmPackage) {
30475
- return join13(lspCacheRoot(), encodeURIComponent(npmPackage));
30632
+ return join14(lspCacheRoot(), encodeURIComponent(npmPackage));
30476
30633
  }
30477
30634
  function lspBinaryPath(npmPackage, binary) {
30478
- return join13(lspPackageDir(npmPackage), "node_modules", ".bin", binary);
30635
+ return join14(lspPackageDir(npmPackage), "node_modules", ".bin", binary);
30479
30636
  }
30480
30637
  function lspBinDir(npmPackage) {
30481
- return join13(lspPackageDir(npmPackage), "node_modules", ".bin");
30638
+ return join14(lspPackageDir(npmPackage), "node_modules", ".bin");
30482
30639
  }
30483
30640
  function isInstalled(npmPackage, binary) {
30484
30641
  for (const candidate of lspBinaryCandidates(binary)) {
30485
30642
  try {
30486
- if (statSync4(join13(lspBinDir(npmPackage), candidate)).isFile())
30643
+ if (statSync5(join14(lspBinDir(npmPackage), candidate)).isFile())
30487
30644
  return true;
30488
30645
  } catch {}
30489
30646
  }
@@ -30503,15 +30660,15 @@ function writeInstalledMetaIn(installDir, version2, sha256) {
30503
30660
  installedAt: new Date().toISOString(),
30504
30661
  ...sha256 ? { sha256 } : {}
30505
30662
  };
30506
- writeFileSync7(join13(installDir, INSTALLED_META_FILE), JSON.stringify(meta3), "utf8");
30663
+ writeFileSync7(join14(installDir, INSTALLED_META_FILE), JSON.stringify(meta3), "utf8");
30507
30664
  } catch (err) {
30508
30665
  log2(`[lsp-cache] failed to write installed-meta in ${installDir}: ${err}`);
30509
30666
  }
30510
30667
  }
30511
30668
  function readInstalledMetaIn(installDir) {
30512
- const path2 = join13(installDir, INSTALLED_META_FILE);
30669
+ const path2 = join14(installDir, INSTALLED_META_FILE);
30513
30670
  try {
30514
- if (!statSync4(path2).isFile())
30671
+ if (!statSync5(path2).isFile())
30515
30672
  return null;
30516
30673
  const raw = readFileSync9(path2, "utf8");
30517
30674
  const parsed = JSON.parse(raw);
@@ -30533,7 +30690,7 @@ function readInstalledMeta(packageKey) {
30533
30690
  return readInstalledMetaIn(lspPackageDir(packageKey));
30534
30691
  }
30535
30692
  function lockPath(npmPackage) {
30536
- return join13(lspPackageDir(npmPackage), ".aft-installing");
30693
+ return join14(lspPackageDir(npmPackage), ".aft-installing");
30537
30694
  }
30538
30695
  var STALE_LOCK_MS2 = 30 * 60 * 1000;
30539
30696
  function acquireInstallLock(lockKey) {
@@ -30568,7 +30725,7 @@ ${new Date().toISOString()}
30568
30725
  const parsed = Number.parseInt(firstLine, 10);
30569
30726
  if (Number.isFinite(parsed) && parsed > 0)
30570
30727
  owningPid = parsed;
30571
- lockMtimeMs = statSync4(lock).mtimeMs;
30728
+ lockMtimeMs = statSync5(lock).mtimeMs;
30572
30729
  } catch {
30573
30730
  return tryClaim();
30574
30731
  }
@@ -30640,7 +30797,7 @@ async function withInstallLock(lockKey, task) {
30640
30797
  }
30641
30798
  var VERSION_CHECK_FILE = ".aft-version-check";
30642
30799
  function readVersionCheck(npmPackage) {
30643
- const file2 = join13(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
30800
+ const file2 = join14(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
30644
30801
  try {
30645
30802
  const raw = readFileSync9(file2, "utf8");
30646
30803
  const parsed = JSON.parse(raw);
@@ -30657,7 +30814,7 @@ function readVersionCheck(npmPackage) {
30657
30814
  }
30658
30815
  function writeVersionCheck(npmPackage, latest) {
30659
30816
  mkdirSync7(lspPackageDir(npmPackage), { recursive: true });
30660
- const file2 = join13(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
30817
+ const file2 = join14(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
30661
30818
  const record2 = {
30662
30819
  last_checked: new Date().toISOString(),
30663
30820
  latest_eligible: latest
@@ -30819,8 +30976,8 @@ var NPM_LSP_TABLE = [
30819
30976
  ];
30820
30977
 
30821
30978
  // src/lsp-project-relevance.ts
30822
- import { existsSync as existsSync11, readdirSync as readdirSync2, readFileSync as readFileSync10 } from "node:fs";
30823
- import { join as join14 } from "node:path";
30979
+ import { existsSync as existsSync11, readdirSync as readdirSync3, readFileSync as readFileSync10 } from "node:fs";
30980
+ import { join as join15 } from "node:path";
30824
30981
  var MAX_WALK_DIRS = 200;
30825
30982
  var MAX_WALK_DEPTH = 4;
30826
30983
  var NOISE_DIRS = new Set([
@@ -30837,7 +30994,7 @@ function hasRootMarker(projectRoot, rootMarkers) {
30837
30994
  if (!rootMarkers)
30838
30995
  return false;
30839
30996
  for (const marker of rootMarkers) {
30840
- if (existsSync11(join14(projectRoot, marker)))
30997
+ if (existsSync11(join15(projectRoot, marker)))
30841
30998
  return true;
30842
30999
  }
30843
31000
  return false;
@@ -30861,7 +31018,7 @@ function hasPackageJsonDep(projectRoot, depNames) {
30861
31018
  }
30862
31019
  function readPackageJson(projectRoot) {
30863
31020
  try {
30864
- const raw = readFileSync10(join14(projectRoot, "package.json"), "utf8");
31021
+ const raw = readFileSync10(join15(projectRoot, "package.json"), "utf8");
30865
31022
  const parsed = JSON.parse(raw);
30866
31023
  if (typeof parsed !== "object" || parsed === null)
30867
31024
  return null;
@@ -30884,14 +31041,14 @@ function relevantExtensionsInProject(projectRoot, extToServer) {
30884
31041
  visitedDirs += 1;
30885
31042
  let entries;
30886
31043
  try {
30887
- entries = readdirSync2(current.dir, { withFileTypes: true });
31044
+ entries = readdirSync3(current.dir, { withFileTypes: true });
30888
31045
  } catch {
30889
31046
  continue;
30890
31047
  }
30891
31048
  for (const entry of entries) {
30892
31049
  if (entry.isDirectory()) {
30893
31050
  if (current.depth < MAX_WALK_DEPTH && !NOISE_DIRS.has(entry.name.toLowerCase())) {
30894
- queue.push({ dir: join14(current.dir, entry.name), depth: current.depth + 1 });
31051
+ queue.push({ dir: join15(current.dir, entry.name), depth: current.depth + 1 });
30895
31052
  }
30896
31053
  continue;
30897
31054
  }
@@ -31025,10 +31182,16 @@ function runInstall(spec, version2, cwd, signal) {
31025
31182
  resolve3(false);
31026
31183
  return;
31027
31184
  }
31028
- const npmBin = process.platform === "win32" ? "npm.cmd" : "npm";
31029
- const child = spawn3(npmBin, ["install", "--no-save", "--ignore-scripts", "--silent", target], {
31185
+ const npm = resolveNpm();
31186
+ if (!npm) {
31187
+ warn2(`[lsp] npm not found on PATH or known locations; cannot install ${target}`);
31188
+ resolve3(false);
31189
+ return;
31190
+ }
31191
+ const child = spawn3(npm.command, ["install", "--no-save", "--ignore-scripts", "--silent", target], {
31030
31192
  stdio: ["ignore", "pipe", "pipe"],
31031
- cwd
31193
+ cwd,
31194
+ env: npmSpawnEnv(npm)
31032
31195
  });
31033
31196
  child.unref();
31034
31197
  let stderrBuf = "";
@@ -31155,7 +31318,7 @@ function hashInstalledBinary(spec) {
31155
31318
  let pathToHash = null;
31156
31319
  for (const p of candidates) {
31157
31320
  try {
31158
- if (statSync5(p).isFile()) {
31321
+ if (statSync6(p).isFile()) {
31159
31322
  pathToHash = p;
31160
31323
  break;
31161
31324
  }
@@ -31181,7 +31344,7 @@ function installedBinaryPath(spec) {
31181
31344
  ] : [lspBinaryPath(spec.npm, spec.binary)];
31182
31345
  for (const candidate of candidates) {
31183
31346
  try {
31184
- if (statSync5(candidate).isFile())
31347
+ if (statSync6(candidate).isFile())
31185
31348
  return candidate;
31186
31349
  } catch {}
31187
31350
  }
@@ -31192,10 +31355,10 @@ function sha256OfFileSync(path2) {
31192
31355
  }
31193
31356
  function quarantineCachedNpmInstall(spec, reason) {
31194
31357
  const packageDir = lspPackageDir(spec.npm);
31195
- const dest = join15(packageDir, "..", ".quarantine", encodeURIComponent(spec.npm), `${Date.now()}`);
31358
+ const dest = join16(packageDir, "..", ".quarantine", encodeURIComponent(spec.npm), `${Date.now()}`);
31196
31359
  warn2(`[lsp] tofu_mismatch ${spec.npm}: ${reason}; quarantining ${packageDir} -> ${dest}`);
31197
31360
  try {
31198
- mkdirSync8(join15(dest, ".."), { recursive: true });
31361
+ mkdirSync8(join16(dest, ".."), { recursive: true });
31199
31362
  rmSync5(dest, { recursive: true, force: true });
31200
31363
  renameSync6(packageDir, dest);
31201
31364
  } catch (err) {
@@ -31281,17 +31444,17 @@ import {
31281
31444
  existsSync as existsSync12,
31282
31445
  lstatSync as lstatSync2,
31283
31446
  mkdirSync as mkdirSync9,
31284
- readdirSync as readdirSync3,
31447
+ readdirSync as readdirSync4,
31285
31448
  readFileSync as readFileSync12,
31286
31449
  readlinkSync as readlinkSync2,
31287
31450
  realpathSync as realpathSync3,
31288
31451
  renameSync as renameSync7,
31289
31452
  rmSync as rmSync6,
31290
- statSync as statSync6,
31453
+ statSync as statSync7,
31291
31454
  unlinkSync as unlinkSync6,
31292
31455
  writeFileSync as writeFileSync8
31293
31456
  } from "node:fs";
31294
- import { dirname as dirname7, join as join16, relative as relative2, resolve as resolve3 } from "node:path";
31457
+ import { dirname as dirname8, join as join17, relative as relative2, resolve as resolve3 } from "node:path";
31295
31458
  import { Readable as Readable3 } from "node:stream";
31296
31459
  import { pipeline as pipeline3 } from "node:stream/promises";
31297
31460
 
@@ -31381,26 +31544,26 @@ function detectHostPlatform() {
31381
31544
 
31382
31545
  // src/lsp-github-install.ts
31383
31546
  function ghCacheRoot() {
31384
- return join16(aftCacheBase(), "lsp-binaries");
31547
+ return join17(aftCacheBase(), "lsp-binaries");
31385
31548
  }
31386
31549
  function ghPackageDir(spec) {
31387
- return join16(ghCacheRoot(), spec.id);
31550
+ return join17(ghCacheRoot(), spec.id);
31388
31551
  }
31389
31552
  function ghBinDir(spec) {
31390
- return join16(ghPackageDir(spec), "bin");
31553
+ return join17(ghPackageDir(spec), "bin");
31391
31554
  }
31392
31555
  function ghExtractDir(spec) {
31393
- return join16(ghPackageDir(spec), "extracted");
31556
+ return join17(ghPackageDir(spec), "extracted");
31394
31557
  }
31395
31558
  var INSTALLED_META_FILE2 = ".aft-installed";
31396
31559
  function ghBinaryPath(spec, platform3) {
31397
31560
  const ext = platform3 === "win32" ? ".exe" : "";
31398
- return join16(ghBinDir(spec), `${spec.binary}${ext}`);
31561
+ return join17(ghBinDir(spec), `${spec.binary}${ext}`);
31399
31562
  }
31400
31563
  function isGithubInstalled(spec, platform3) {
31401
31564
  for (const candidate of ghBinaryCandidates(spec, platform3)) {
31402
31565
  try {
31403
- if (statSync6(join16(ghBinDir(spec), candidate)).isFile())
31566
+ if (statSync7(join17(ghBinDir(spec), candidate)).isFile())
31404
31567
  return true;
31405
31568
  } catch {}
31406
31569
  }
@@ -31413,8 +31576,8 @@ function ghBinaryCandidates(spec, platform3) {
31413
31576
  }
31414
31577
  function readGithubInstalledMetaIn(installDir) {
31415
31578
  try {
31416
- const path2 = join16(installDir, INSTALLED_META_FILE2);
31417
- if (!statSync6(path2).isFile())
31579
+ const path2 = join17(installDir, INSTALLED_META_FILE2);
31580
+ if (!statSync7(path2).isFile())
31418
31581
  return null;
31419
31582
  const parsed = JSON.parse(readFileSync12(path2, "utf8"));
31420
31583
  if (typeof parsed.version !== "string" || parsed.version.length === 0)
@@ -31440,7 +31603,7 @@ function writeGithubInstalledMetaIn(installDir, version2, binarySha256, archiveS
31440
31603
  binarySha256,
31441
31604
  ...archiveSha256 ? { archiveSha256 } : {}
31442
31605
  };
31443
- writeFileSync8(join16(installDir, INSTALLED_META_FILE2), JSON.stringify(meta3), "utf8");
31606
+ writeFileSync8(join17(installDir, INSTALLED_META_FILE2), JSON.stringify(meta3), "utf8");
31444
31607
  } catch (err) {
31445
31608
  warn2(`[lsp] failed to write github installed metadata in ${installDir}: ${err}`);
31446
31609
  }
@@ -31633,7 +31796,7 @@ async function downloadFile(url2, destPath, fetchImpl, assetSize, signal) {
31633
31796
  if (Number.isFinite(advertised) && advertised > MAX_DOWNLOAD_BYTES3) {
31634
31797
  throw new Error(`Content-Length ${advertised} exceeds max ${MAX_DOWNLOAD_BYTES3}`);
31635
31798
  }
31636
- mkdirSync9(dirname7(destPath), { recursive: true });
31799
+ mkdirSync9(dirname8(destPath), { recursive: true });
31637
31800
  let bytesWritten = 0;
31638
31801
  const guard = new TransformStream({
31639
31802
  transform(chunk, controller) {
@@ -31684,12 +31847,12 @@ function validateExtraction(stagingRoot) {
31684
31847
  const walk = (dir) => {
31685
31848
  let entries;
31686
31849
  try {
31687
- entries = readdirSync3(dir);
31850
+ entries = readdirSync4(dir);
31688
31851
  } catch (err) {
31689
31852
  throw new Error(`failed to read staging dir ${dir}: ${err}`);
31690
31853
  }
31691
31854
  for (const entry of entries) {
31692
- const full = join16(dir, entry);
31855
+ const full = join17(dir, entry);
31693
31856
  let lst;
31694
31857
  try {
31695
31858
  lst = lstatSync2(full);
@@ -31777,10 +31940,10 @@ function extractArchiveSafely(archivePath, destDir, archiveType) {
31777
31940
  }
31778
31941
  function quarantineCachedGithubInstall(spec, reason) {
31779
31942
  const packageDir = ghPackageDir(spec);
31780
- const dest = join16(ghCacheRoot(), ".quarantine", encodeURIComponent(spec.id), `${Date.now()}`);
31943
+ const dest = join17(ghCacheRoot(), ".quarantine", encodeURIComponent(spec.id), `${Date.now()}`);
31781
31944
  warn2(`[lsp] tofu_mismatch ${spec.id}: ${reason}; quarantining ${packageDir} -> ${dest}`);
31782
31945
  try {
31783
- mkdirSync9(dirname7(dest), { recursive: true });
31946
+ mkdirSync9(dirname8(dest), { recursive: true });
31784
31947
  rmSync6(dest, { recursive: true, force: true });
31785
31948
  renameSync7(packageDir, dest);
31786
31949
  } catch (err) {
@@ -31790,9 +31953,9 @@ function quarantineCachedGithubInstall(spec, reason) {
31790
31953
  function validateCachedGithubInstall(spec, platform3) {
31791
31954
  const packageDir = ghPackageDir(spec);
31792
31955
  const meta3 = readGithubInstalledMetaIn(packageDir);
31793
- const binaryPath = ghBinaryCandidates(spec, platform3).map((candidate) => join16(ghBinDir(spec), candidate)).find((candidate) => {
31956
+ const binaryPath = ghBinaryCandidates(spec, platform3).map((candidate) => join17(ghBinDir(spec), candidate)).find((candidate) => {
31794
31957
  try {
31795
- return statSync6(candidate).isFile();
31958
+ return statSync7(candidate).isFile();
31796
31959
  } catch {
31797
31960
  return false;
31798
31961
  }
@@ -31868,7 +32031,7 @@ async function downloadAndInstall(spec, tag, assets, platform3, arch, fetchImpl,
31868
32031
  }
31869
32032
  const pkgDir = ghPackageDir(spec);
31870
32033
  const extractDir = ghExtractDir(spec);
31871
- const archivePath = join16(pkgDir, expected.name);
32034
+ const archivePath = join17(pkgDir, expected.name);
31872
32035
  log2(`[lsp] downloading ${spec.id} ${tag} → ${matchingAsset.url}`);
31873
32036
  try {
31874
32037
  await downloadFile(matchingAsset.url, archivePath, fetchImpl, matchingAsset.size, signal);
@@ -31908,13 +32071,13 @@ async function downloadAndInstall(spec, tag, assets, platform3, arch, fetchImpl,
31908
32071
  unlinkSync6(archivePath);
31909
32072
  } catch {}
31910
32073
  }
31911
- const innerBinaryPath = join16(extractDir, spec.binaryPathInArchive(platform3, arch, version2));
32074
+ const innerBinaryPath = join17(extractDir, spec.binaryPathInArchive(platform3, arch, version2));
31912
32075
  if (!existsSync12(innerBinaryPath)) {
31913
32076
  error2(`[lsp] ${spec.id}: extracted binary not found at ${innerBinaryPath}`);
31914
32077
  return null;
31915
32078
  }
31916
32079
  const targetBinary = ghBinaryPath(spec, platform3);
31917
- mkdirSync9(dirname7(targetBinary), { recursive: true });
32080
+ mkdirSync9(dirname8(targetBinary), { recursive: true });
31918
32081
  try {
31919
32082
  copyFileSync4(innerBinaryPath, targetBinary);
31920
32083
  if (platform3 !== "win32") {
@@ -32242,18 +32405,18 @@ function writeTerminal(terminal, data) {
32242
32405
  import { randomBytes as randomBytes2 } from "node:crypto";
32243
32406
  import { mkdirSync as mkdirSync10, renameSync as renameSync8, unlinkSync as unlinkSync7, writeFileSync as writeFileSync9 } from "node:fs";
32244
32407
  import { createServer } from "node:http";
32245
- import { dirname as dirname8, join as join18 } from "node:path";
32408
+ import { dirname as dirname9, join as join19 } from "node:path";
32246
32409
 
32247
32410
  // src/shared/rpc-utils.ts
32248
32411
  import { createHash as createHash6 } from "node:crypto";
32249
- import { join as join17 } from "node:path";
32412
+ import { join as join18 } from "node:path";
32250
32413
  function projectHash(directory) {
32251
32414
  const normalized = directory.replace(/\/+$/, "");
32252
32415
  return createHash6("sha256").update(normalized).digest("hex").slice(0, 16);
32253
32416
  }
32254
32417
  function rpcPortFileDir(storageDir, directory) {
32255
32418
  const hash2 = projectHash(directory);
32256
- return join17(storageDir, "rpc", hash2, "ports");
32419
+ return join18(storageDir, "rpc", hash2, "ports");
32257
32420
  }
32258
32421
 
32259
32422
  // src/shared/rpc-server.ts
@@ -32268,7 +32431,7 @@ class AftRpcServer {
32268
32431
  constructor(storageDir, directory) {
32269
32432
  this.portsDir = rpcPortFileDir(storageDir, directory);
32270
32433
  this.instanceId = randomBytes2(8).toString("hex");
32271
- this.portFilePath = join18(this.portsDir, `${this.instanceId}.json`);
32434
+ this.portFilePath = join19(this.portsDir, `${this.instanceId}.json`);
32272
32435
  }
32273
32436
  handle(method, handler) {
32274
32437
  this.handlers.set(method, handler);
@@ -32290,7 +32453,7 @@ class AftRpcServer {
32290
32453
  this.token = randomBytes2(32).toString("hex");
32291
32454
  this.server = server;
32292
32455
  try {
32293
- const dir = dirname8(this.portFilePath);
32456
+ const dir = dirname9(this.portFilePath);
32294
32457
  mkdirSync10(dir, { recursive: true, mode: 448 });
32295
32458
  const tmpPath = `${this.portFilePath}.tmp`;
32296
32459
  writeFileSync9(tmpPath, JSON.stringify({ port: this.port, token: this.token }), {
@@ -32625,20 +32788,20 @@ function formatStatusMarkdown(status) {
32625
32788
  // src/shared/tui-config.ts
32626
32789
  var import_comment_json4 = __toESM(require_src2(), 1);
32627
32790
  import { existsSync as existsSync13, mkdirSync as mkdirSync11, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "node:fs";
32628
- import { dirname as dirname9, join as join20 } from "node:path";
32791
+ import { dirname as dirname10, join as join21 } from "node:path";
32629
32792
 
32630
32793
  // src/shared/opencode-config-dir.ts
32631
- import { homedir as homedir10 } from "node:os";
32632
- import { join as join19, resolve as resolve4 } from "node:path";
32794
+ import { homedir as homedir11 } from "node:os";
32795
+ import { join as join20, resolve as resolve4 } from "node:path";
32633
32796
  function getCliConfigDir() {
32634
32797
  const envConfigDir = process.env.OPENCODE_CONFIG_DIR?.trim();
32635
32798
  if (envConfigDir) {
32636
32799
  return resolve4(envConfigDir);
32637
32800
  }
32638
32801
  if (process.platform === "win32") {
32639
- return join19(homedir10(), ".config", "opencode");
32802
+ return join20(homedir11(), ".config", "opencode");
32640
32803
  }
32641
- return join19(process.env.XDG_CONFIG_HOME || join19(homedir10(), ".config"), "opencode");
32804
+ return join20(process.env.XDG_CONFIG_HOME || join20(homedir11(), ".config"), "opencode");
32642
32805
  }
32643
32806
  function getOpenCodeConfigDir2(_options) {
32644
32807
  return getCliConfigDir();
@@ -32647,10 +32810,10 @@ function getOpenCodeConfigPaths(options) {
32647
32810
  const configDir = getOpenCodeConfigDir2(options);
32648
32811
  return {
32649
32812
  configDir,
32650
- configJson: join19(configDir, "opencode.json"),
32651
- configJsonc: join19(configDir, "opencode.jsonc"),
32652
- packageJson: join19(configDir, "package.json"),
32653
- omoConfig: join19(configDir, "magic-context.jsonc")
32813
+ configJson: join20(configDir, "opencode.json"),
32814
+ configJsonc: join20(configDir, "opencode.jsonc"),
32815
+ packageJson: join20(configDir, "package.json"),
32816
+ omoConfig: join20(configDir, "magic-context.jsonc")
32654
32817
  };
32655
32818
  }
32656
32819
 
@@ -32659,8 +32822,8 @@ var PLUGIN_NAME = "@cortexkit/aft-opencode";
32659
32822
  var PLUGIN_ENTRY = `${PLUGIN_NAME}@latest`;
32660
32823
  function resolveTuiConfigPath() {
32661
32824
  const configDir = getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
32662
- const jsoncPath = join20(configDir, "tui.jsonc");
32663
- const jsonPath = join20(configDir, "tui.json");
32825
+ const jsoncPath = join21(configDir, "tui.jsonc");
32826
+ const jsonPath = join21(configDir, "tui.json");
32664
32827
  if (existsSync13(jsoncPath))
32665
32828
  return jsoncPath;
32666
32829
  if (existsSync13(jsonPath))
@@ -32680,7 +32843,7 @@ function ensureTuiPluginEntry() {
32680
32843
  }
32681
32844
  plugins.push(PLUGIN_ENTRY);
32682
32845
  config2.plugin = plugins;
32683
- mkdirSync11(dirname9(configPath), { recursive: true });
32846
+ mkdirSync11(dirname10(configPath), { recursive: true });
32684
32847
  writeFileSync10(configPath, `${import_comment_json4.stringify(config2, null, 2)}
32685
32848
  `);
32686
32849
  log2(`[aft-plugin] added TUI plugin entry to ${configPath}`);
@@ -32768,6 +32931,7 @@ import { tool as tool3 } from "@opencode-ai/plugin";
32768
32931
 
32769
32932
  // src/tools/_shared.ts
32770
32933
  import * as fs3 from "node:fs";
32934
+ import * as os2 from "node:os";
32771
32935
  import * as path2 from "node:path";
32772
32936
  import { tool as tool2 } from "@opencode-ai/plugin";
32773
32937
  var z2 = tool2.schema;
@@ -32880,8 +33044,19 @@ async function resolveProjectRoot(ctx, runtime) {
32880
33044
  }
32881
33045
  return projectRootFor(runtime);
32882
33046
  }
33047
+ function expandTilde(input) {
33048
+ if (!input || !input.startsWith("~"))
33049
+ return input;
33050
+ if (input === "~")
33051
+ return os2.homedir();
33052
+ if (input.startsWith("~/") || input.startsWith(`~${path2.sep}`)) {
33053
+ return path2.resolve(os2.homedir(), input.slice(2));
33054
+ }
33055
+ return input;
33056
+ }
32883
33057
  function resolvePathFromProjectRoot(projectRoot, target) {
32884
- return path2.isAbsolute(target) ? target : path2.resolve(projectRoot, target);
33058
+ const expanded = expandTilde(target);
33059
+ return path2.isAbsolute(expanded) ? expanded : path2.resolve(projectRoot, expanded);
32885
33060
  }
32886
33061
  async function resolvePathArg(ctx, runtime, target) {
32887
33062
  return resolvePathFromProjectRoot(await resolveProjectRoot(ctx, runtime), target);
@@ -34962,7 +35137,7 @@ function createEditTool(ctx, writeToolName = "write") {
34962
35137
  if (response.success === false) {
34963
35138
  throw new Error(response.message ?? "transaction failed");
34964
35139
  }
34965
- return JSON.stringify(response);
35140
+ return formatEditSummary(response);
34966
35141
  }
34967
35142
  const file2 = args.filePath;
34968
35143
  if (!file2)
@@ -35049,12 +35224,7 @@ function createEditTool(ctx, writeToolName = "write") {
35049
35224
  });
35050
35225
  }
35051
35226
  }
35052
- const agentData = { ...data };
35053
- if (agentData.diff && typeof agentData.diff === "object") {
35054
- const d = agentData.diff;
35055
- agentData.diff = { additions: d.additions ?? 0, deletions: d.deletions ?? 0 };
35056
- }
35057
- let result = JSON.stringify(agentData);
35227
+ let result = formatEditSummary(data);
35058
35228
  const globSkipNote = formatGlobSkipReasonsNote(data.format_skip_reasons);
35059
35229
  if (globSkipNote)
35060
35230
  result += `
@@ -36597,18 +36767,7 @@ function safetyTools(ctx) {
36597
36767
 
36598
36768
  // src/tools/search.ts
36599
36769
  import * as fs7 from "node:fs";
36600
- import * as os2 from "node:os";
36601
36770
  import * as path6 from "node:path";
36602
- function expandTilde(input) {
36603
- if (!input || !input.startsWith("~"))
36604
- return input;
36605
- if (input === "~")
36606
- return os2.homedir();
36607
- if (input.startsWith("~/") || input.startsWith(`~${path6.sep}`)) {
36608
- return path6.resolve(os2.homedir(), input.slice(2));
36609
- }
36610
- return input;
36611
- }
36612
36771
  function arg2(schema) {
36613
36772
  return schema;
36614
36773
  }
@@ -36822,6 +36981,14 @@ function semanticHonestyNote(response) {
36822
36981
  notes.push("partial/incomplete");
36823
36982
  return notes.length > 0 ? `Search status: ${notes.join("; ")}.` : undefined;
36824
36983
  }
36984
+ function extraHonestyNote(response) {
36985
+ const notes = [];
36986
+ if (response.fully_degraded === true)
36987
+ notes.push("fully degraded");
36988
+ if (response.complete === false)
36989
+ notes.push("partial/incomplete");
36990
+ return notes.length > 0 ? `Search status: ${notes.join("; ")}.` : undefined;
36991
+ }
36825
36992
  function arg3(schema) {
36826
36993
  return schema;
36827
36994
  }
@@ -36873,24 +37040,12 @@ function semanticTools(ctx) {
36873
37040
  const code = typeof response.code === "string" && response.code.length > 0 ? response.code : undefined;
36874
37041
  throw new Error(code ? `semantic_search: ${code} — ${message}` : message);
36875
37042
  }
36876
- const honestyNote = semanticHonestyNote(response);
36877
- if (typeof response.text === "string" && response.status === "disabled" && Array.isArray(response.results) && response.results.length === 0) {
36878
- return honestyNote ? `${response.text}
36879
- ${honestyNote}` : response.text;
36880
- }
36881
- const structured = JSON.stringify(response, null, 2);
36882
37043
  if (typeof response.text === "string" && response.text.length > 0) {
36883
- const display = honestyNote ? `${response.text}
36884
- ${honestyNote}` : response.text;
36885
- return `${display}
36886
-
36887
- Structured response:
36888
- ${structured}`;
37044
+ const note = extraHonestyNote(response);
37045
+ return note ? `${response.text}
37046
+ ${note}` : response.text;
36889
37047
  }
36890
- return honestyNote ? `${honestyNote}
36891
-
36892
- Structured response:
36893
- ${structured}` : structured;
37048
+ return semanticHonestyNote(response) ?? "No results.";
36894
37049
  }
36895
37050
  };
36896
37051
  return {