@cortexkit/aft-opencode 0.35.1 → 0.35.3

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) {
@@ -12064,7 +12064,6 @@ class BinaryBridge {
12064
12064
  if (!snapshot || typeof snapshot !== "object" || Array.isArray(snapshot))
12065
12065
  return;
12066
12066
  this.cachedStatus = snapshot;
12067
- this.logVia("Received status_changed push frame; cached AFT status snapshot");
12068
12067
  for (const listener of this.statusListeners) {
12069
12068
  this.deliverStatusSnapshot(listener, this.cachedStatus);
12070
12069
  }
@@ -12740,6 +12739,35 @@ async function fetchLatestTag() {
12740
12739
  clearTimeout(timeout);
12741
12740
  }
12742
12741
  }
12742
+ // ../aft-bridge/dist/edit-summary.js
12743
+ function formatEditSummary(data) {
12744
+ if (data.rolled_back === true) {
12745
+ return "Edit rolled back: the change produced invalid syntax, so the file was left unchanged.";
12746
+ }
12747
+ if (typeof data.files_modified === "number") {
12748
+ const n = data.files_modified;
12749
+ return `Applied edits to ${n} file${n === 1 ? "" : "s"}.`;
12750
+ }
12751
+ const additions = data.diff?.additions ?? 0;
12752
+ const deletions = data.diff?.deletions ?? 0;
12753
+ const counts = `+${additions}/-${deletions}`;
12754
+ if (data.created === true) {
12755
+ let s2 = `Created file (${counts}).`;
12756
+ if (data.formatted)
12757
+ s2 += " Auto-formatted.";
12758
+ return s2;
12759
+ }
12760
+ let detail = counts;
12761
+ if (typeof data.edits_applied === "number" && data.edits_applied > 1) {
12762
+ detail = `${counts}, ${data.edits_applied} edits`;
12763
+ } else if (typeof data.replacements === "number" && data.replacements > 1) {
12764
+ detail = `${counts}, ${data.replacements} replacements`;
12765
+ }
12766
+ let s = `Edited (${detail}).`;
12767
+ if (data.formatted)
12768
+ s += " Auto-formatted.";
12769
+ return s;
12770
+ }
12743
12771
  // ../aft-bridge/dist/jsonc.js
12744
12772
  function stripJsoncSymbols(value) {
12745
12773
  if (Array.isArray(value)) {
@@ -13127,11 +13155,128 @@ async function ensureStorageMigrated(opts) {
13127
13155
  const stdoutTail = tail(result.stdout);
13128
13156
  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
13157
  }
13158
+ // ../aft-bridge/dist/npm-resolver.js
13159
+ import { readdirSync, statSync as statSync2 } from "node:fs";
13160
+ import { homedir as homedir5 } from "node:os";
13161
+ import { delimiter, dirname as dirname3, isAbsolute, join as join6 } from "node:path";
13162
+ function defaultDeps() {
13163
+ return {
13164
+ platform: process.platform,
13165
+ env: process.env,
13166
+ home: homedir5(),
13167
+ execPath: process.execPath
13168
+ };
13169
+ }
13170
+ function npmBinaryName(platform) {
13171
+ return platform === "win32" ? "npm.cmd" : "npm";
13172
+ }
13173
+ function isFile(p) {
13174
+ try {
13175
+ return statSync2(p).isFile();
13176
+ } catch {
13177
+ return false;
13178
+ }
13179
+ }
13180
+ function npmFromPath(deps) {
13181
+ const name = npmBinaryName(deps.platform);
13182
+ const raw = deps.env.PATH ?? deps.env.Path ?? "";
13183
+ for (const entry of raw.split(delimiter)) {
13184
+ const dir = entry.trim().replace(/^"|"$/g, "");
13185
+ if (!dir || !isAbsolute(dir))
13186
+ continue;
13187
+ if (isFile(join6(dir, name)))
13188
+ return dir;
13189
+ }
13190
+ return null;
13191
+ }
13192
+ function npmAdjacentToNode(deps) {
13193
+ const dir = dirname3(deps.execPath);
13194
+ return isFile(join6(dir, npmBinaryName(deps.platform))) ? dir : null;
13195
+ }
13196
+ function highestVersionedNodeBin(installsDir, name) {
13197
+ let entries;
13198
+ try {
13199
+ entries = readdirSync(installsDir);
13200
+ } catch {
13201
+ return null;
13202
+ }
13203
+ const candidates = entries.filter((v) => isFile(join6(installsDir, v, "bin", name))).sort((a, b) => compareVersionsDesc(a, b));
13204
+ return candidates.length > 0 ? join6(installsDir, candidates[0], "bin") : null;
13205
+ }
13206
+ function compareVersionsDesc(a, b) {
13207
+ const pa = a.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10));
13208
+ const pb = b.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10));
13209
+ for (let i = 0;i < Math.max(pa.length, pb.length); i++) {
13210
+ const na = Number.isFinite(pa[i]) ? pa[i] : -1;
13211
+ const nb = Number.isFinite(pb[i]) ? pb[i] : -1;
13212
+ if (na !== nb)
13213
+ return nb - na;
13214
+ }
13215
+ return b.localeCompare(a);
13216
+ }
13217
+ function wellKnownNpmDirs(deps) {
13218
+ const { platform, env, home } = deps;
13219
+ const name = npmBinaryName(platform);
13220
+ const dirs = [];
13221
+ const push = (dir) => {
13222
+ if (dir && !dirs.includes(dir))
13223
+ dirs.push(dir);
13224
+ };
13225
+ if (platform === "win32") {
13226
+ const programFiles = env.ProgramFiles || "C:\\Program Files";
13227
+ const appData = env.APPDATA;
13228
+ const localAppData = env.LOCALAPPDATA;
13229
+ push(join6(programFiles, "nodejs"));
13230
+ if (appData)
13231
+ push(join6(appData, "npm"));
13232
+ if (localAppData)
13233
+ push(join6(localAppData, "Volta", "bin"));
13234
+ if (env.NVM_SYMLINK)
13235
+ push(env.NVM_SYMLINK);
13236
+ } else {
13237
+ if (env.NVM_BIN)
13238
+ push(env.NVM_BIN);
13239
+ push(highestVersionedNodeBin(join6(home, ".nvm", "versions", "node"), name));
13240
+ push(highestVersionedNodeBin(join6(home, ".local", "share", "mise", "installs", "node"), name));
13241
+ push(highestVersionedNodeBin(join6(home, ".asdf", "installs", "nodejs"), name));
13242
+ push(join6(home, ".volta", "bin"));
13243
+ push(join6(home, ".asdf", "shims"));
13244
+ const systemDirs = deps.systemNpmDirs ?? (platform === "darwin" ? ["/opt/homebrew/bin", "/usr/local/bin"] : ["/usr/local/bin", "/usr/bin", join6(home, ".local", "bin")]);
13245
+ for (const dir of systemDirs)
13246
+ push(dir);
13247
+ }
13248
+ return dirs;
13249
+ }
13250
+ function resolveNpm(deps = defaultDeps()) {
13251
+ const name = npmBinaryName(deps.platform);
13252
+ const onPath = npmFromPath(deps);
13253
+ if (onPath)
13254
+ return { command: join6(onPath, name), binDir: onPath };
13255
+ const adjacent = npmAdjacentToNode(deps);
13256
+ if (adjacent)
13257
+ return { command: join6(adjacent, name), binDir: adjacent };
13258
+ for (const dir of wellKnownNpmDirs(deps)) {
13259
+ const candidate = join6(dir, name);
13260
+ if (isFile(candidate))
13261
+ return { command: candidate, binDir: dir };
13262
+ }
13263
+ return null;
13264
+ }
13265
+ function npmSpawnEnv(resolved, baseEnv = process.env) {
13266
+ if (!resolved.binDir)
13267
+ return { ...baseEnv };
13268
+ const existing = baseEnv.PATH ?? baseEnv.Path ?? "";
13269
+ const next = existing ? `${resolved.binDir}${delimiter}${existing}` : resolved.binDir;
13270
+ return { ...baseEnv, PATH: next };
13271
+ }
13272
+ function isNpmAvailable(deps = defaultDeps()) {
13273
+ return resolveNpm(deps) !== null;
13274
+ }
13130
13275
  // ../aft-bridge/dist/onnx-runtime.js
13131
13276
  import { execFileSync } from "node:child_process";
13132
13277
  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";
13278
+ 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";
13279
+ import { basename, dirname as dirname4, isAbsolute as isAbsolute2, join as join7, relative, resolve, win32 } from "node:path";
13135
13280
  import { Readable as Readable2 } from "node:stream";
13136
13281
  import { pipeline as pipeline2 } from "node:stream/promises";
13137
13282
  var ORT_VERSION = "1.24.4";
@@ -13197,10 +13342,10 @@ function getManualInstallHint() {
13197
13342
  }
13198
13343
  async function ensureOnnxRuntime(storageDir) {
13199
13344
  const info = getPlatformInfo();
13200
- const ortVersionDir = join6(storageDir, "onnxruntime", ORT_VERSION);
13345
+ const ortVersionDir = join7(storageDir, "onnxruntime", ORT_VERSION);
13201
13346
  const libName = info?.libName ?? "libonnxruntime.dylib";
13202
13347
  const resolvedOrtDir = resolveCachedOnnxRuntimeDir(ortVersionDir, libName);
13203
- const libPath = join6(resolvedOrtDir, libName);
13348
+ const libPath = join7(resolvedOrtDir, libName);
13204
13349
  if (existsSync5(libPath)) {
13205
13350
  const meta = readOnnxInstalledMeta(ortVersionDir);
13206
13351
  if (meta?.sha256) {
@@ -13230,9 +13375,9 @@ async function ensureOnnxRuntime(storageDir) {
13230
13375
  warn(`ONNX Runtime auto-download not available for ${process.platform}/${process.arch}. Install manually: ${getManualInstallHint()}`);
13231
13376
  return null;
13232
13377
  }
13233
- const onnxBaseDir = join6(storageDir, "onnxruntime");
13378
+ const onnxBaseDir = join7(storageDir, "onnxruntime");
13234
13379
  mkdirSync5(onnxBaseDir, { recursive: true });
13235
- const lockPath = join6(onnxBaseDir, ONNX_LOCK_FILE);
13380
+ const lockPath = join7(onnxBaseDir, ONNX_LOCK_FILE);
13236
13381
  cleanupAbandonedStagingDirs(onnxBaseDir);
13237
13382
  if (!acquireLock(lockPath)) {
13238
13383
  warn(`ONNX Runtime install already in progress in another process (lock: ${lockPath}). Skipping.`);
@@ -13247,11 +13392,11 @@ async function ensureOnnxRuntime(storageDir) {
13247
13392
  }
13248
13393
  function cleanupAbandonedStagingDirs(onnxBaseDir) {
13249
13394
  try {
13250
- const entries = readdirSync(onnxBaseDir);
13395
+ const entries = readdirSync2(onnxBaseDir);
13251
13396
  for (const entry of entries) {
13252
13397
  if (!entry.startsWith(`${ORT_VERSION}.tmp.`))
13253
13398
  continue;
13254
- const stagingDir = join6(onnxBaseDir, entry);
13399
+ const stagingDir = join7(onnxBaseDir, entry);
13255
13400
  const parts = entry.split(".");
13256
13401
  const pidStr = parts[parts.length - 2];
13257
13402
  const pid = pidStr ? Number.parseInt(pidStr, 10) : NaN;
@@ -13263,7 +13408,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
13263
13408
  abandoned = true;
13264
13409
  } else {
13265
13410
  try {
13266
- const ageMs = Date.now() - statSync2(stagingDir).mtimeMs;
13411
+ const ageMs = Date.now() - statSync3(stagingDir).mtimeMs;
13267
13412
  abandoned = ageMs > STALE_LOCK_MS;
13268
13413
  } catch {
13269
13414
  abandoned = true;
@@ -13288,7 +13433,7 @@ function cleanupAbandonedStagingDirs(onnxBaseDir) {
13288
13433
  }
13289
13434
  function cleanupIncompleteTargetIfUnowned(ortDir) {
13290
13435
  try {
13291
- if (existsSync5(ortDir) && !existsSync5(join6(ortDir, ONNX_INSTALLED_META_FILE))) {
13436
+ if (existsSync5(ortDir) && !existsSync5(join7(ortDir, ONNX_INSTALLED_META_FILE))) {
13292
13437
  log(`[onnx] removing half-populated install dir ${ortDir} (no meta file)`);
13293
13438
  rmSync2(ortDir, { recursive: true, force: true });
13294
13439
  }
@@ -13317,11 +13462,11 @@ function parseOnnxVersionFromDirectoryPath(value) {
13317
13462
  }
13318
13463
  function isPathInsideRoot(root, candidate) {
13319
13464
  const rel = relative(root, candidate);
13320
- return rel === "" || !rel.startsWith("../") && !rel.startsWith("..\\") && rel !== ".." && !isAbsolute(rel) && !win32.isAbsolute(rel);
13465
+ return rel === "" || !rel.startsWith("../") && !rel.startsWith("..\\") && rel !== ".." && !isAbsolute2(rel) && !win32.isAbsolute(rel);
13321
13466
  }
13322
13467
  function detectOnnxVersion(libDir, libName) {
13323
13468
  try {
13324
- const entries = readdirSync(libDir);
13469
+ const entries = readdirSync2(libDir);
13325
13470
  const barePrefix = libName.replace(/\.(so|dylib|dll)$/, "");
13326
13471
  const expectedPrefix = process.platform === "win32" ? barePrefix.toLowerCase() : barePrefix;
13327
13472
  for (const entry of entries) {
@@ -13332,7 +13477,7 @@ function detectOnnxVersion(libDir, libName) {
13332
13477
  if (version)
13333
13478
  return version;
13334
13479
  }
13335
- const base = join6(libDir, libName);
13480
+ const base = join7(libDir, libName);
13336
13481
  if (existsSync5(base)) {
13337
13482
  try {
13338
13483
  const real = realpathSync(base);
@@ -13364,16 +13509,16 @@ function pathEnvValue() {
13364
13509
  return process.env.PATH ?? process.env.Path ?? process.env.path ?? "";
13365
13510
  }
13366
13511
  function pathEntriesForPlatform() {
13367
- const delimiter = process.platform === "win32" ? ";" : ":";
13368
- return pathEnvValue().split(delimiter).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => {
13512
+ const delimiter2 = process.platform === "win32" ? ";" : ":";
13513
+ return pathEnvValue().split(delimiter2).map((entry) => entry.trim().replace(/^"|"$/g, "")).filter((entry) => {
13369
13514
  if (!entry || entry === "." || entry.includes("\x00"))
13370
13515
  return false;
13371
- return isAbsolute(entry) || win32.isAbsolute(entry);
13516
+ return isAbsolute2(entry) || win32.isAbsolute(entry);
13372
13517
  });
13373
13518
  }
13374
13519
  function directoryContainsLibrary(dir, libName) {
13375
13520
  try {
13376
- const entries = readdirSync(dir);
13521
+ const entries = readdirSync2(dir);
13377
13522
  if (process.platform === "win32") {
13378
13523
  const expected = libName.toLowerCase();
13379
13524
  return entries.some((entry) => entry.toLowerCase() === expected);
@@ -13384,10 +13529,10 @@ function directoryContainsLibrary(dir, libName) {
13384
13529
  }
13385
13530
  }
13386
13531
  function resolveCachedOnnxRuntimeDir(ortVersionDir, libName) {
13387
- if (existsSync5(join6(ortVersionDir, libName)))
13532
+ if (existsSync5(join7(ortVersionDir, libName)))
13388
13533
  return ortVersionDir;
13389
- const libSubdir = join6(ortVersionDir, "lib");
13390
- if (existsSync5(join6(libSubdir, libName)))
13534
+ const libSubdir = join7(ortVersionDir, "lib");
13535
+ if (existsSync5(join7(libSubdir, libName)))
13391
13536
  return libSubdir;
13392
13537
  return ortVersionDir;
13393
13538
  }
@@ -13402,21 +13547,21 @@ function findSystemOnnxRuntime(libName) {
13402
13547
  } else if (process.platform === "win32") {
13403
13548
  const programFiles = process.env.ProgramFiles ?? "C:\\Program Files";
13404
13549
  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"), ...(() => {
13550
+ searchPaths.push(join7(programFiles, "onnxruntime", "lib"), join7(programFiles, "Microsoft ONNX Runtime", "lib"), join7(programFiles, "Microsoft Machine Learning", "lib"), join7(programFilesX86, "onnxruntime", "lib"), ...(() => {
13406
13551
  const nugetPaths = [];
13407
13552
  const userProfile = process.env.USERPROFILE ?? "";
13408
13553
  if (!userProfile)
13409
13554
  return nugetPaths;
13410
- const nugetPackageDir = join6(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
13555
+ const nugetPackageDir = join7(userProfile, ".nuget", "packages", "microsoft.ml.onnxruntime");
13411
13556
  if (!existsSync5(nugetPackageDir))
13412
13557
  return nugetPaths;
13413
13558
  try {
13414
- for (const entry of readdirSync(nugetPackageDir, { withFileTypes: true })) {
13559
+ for (const entry of readdirSync2(nugetPackageDir, { withFileTypes: true })) {
13415
13560
  if (!entry.isDirectory())
13416
13561
  continue;
13417
13562
  if (entry.name === "__globalPackagesFolder" || entry.name.startsWith("."))
13418
13563
  continue;
13419
- nugetPaths.push(join6(nugetPackageDir, entry.name, "runtimes", "win-x64", "native"), join6(nugetPackageDir, entry.name, "runtimes", "win-arm64", "native"));
13564
+ nugetPaths.push(join7(nugetPackageDir, entry.name, "runtimes", "win-x64", "native"), join7(nugetPackageDir, entry.name, "runtimes", "win-arm64", "native"));
13420
13565
  }
13421
13566
  } catch (err) {
13422
13567
  warn(`Failed to scan NuGet ONNX Runtime cache ${nugetPackageDir}: ${err instanceof Error ? err.message : String(err)}`);
@@ -13438,7 +13583,7 @@ function findSystemOnnxRuntime(libName) {
13438
13583
  });
13439
13584
  const unknownVersionPaths = [];
13440
13585
  for (const dir of uniquePaths) {
13441
- const libPath = join6(dir, libName);
13586
+ const libPath = join7(dir, libName);
13442
13587
  if (process.platform === "win32") {
13443
13588
  if (!directoryContainsLibrary(dir, libName))
13444
13589
  continue;
@@ -13474,7 +13619,7 @@ async function downloadFileWithCap(url, destPath) {
13474
13619
  if (Number.isFinite(advertised) && advertised > MAX_DOWNLOAD_BYTES2) {
13475
13620
  throw new Error(`Content-Length ${advertised} exceeds max ${MAX_DOWNLOAD_BYTES2}`);
13476
13621
  }
13477
- mkdirSync5(dirname3(destPath), { recursive: true });
13622
+ mkdirSync5(dirname4(destPath), { recursive: true });
13478
13623
  let bytesWritten = 0;
13479
13624
  const guard = new TransformStream({
13480
13625
  transform(chunk, transformController) {
@@ -13502,21 +13647,21 @@ function validateExtractedTree(stagingRoot) {
13502
13647
  const realRoot = realpathSync(stagingRoot);
13503
13648
  let totalBytes = 0;
13504
13649
  const walk = (dir) => {
13505
- const entries = readdirSync(dir);
13650
+ const entries = readdirSync2(dir);
13506
13651
  for (const entry of entries) {
13507
- const fullPath = join6(dir, entry);
13652
+ const fullPath = join7(dir, entry);
13508
13653
  const lst = lstatSync(fullPath);
13509
13654
  if (lst.isSymbolicLink()) {
13510
13655
  const linkTarget = readlinkSync(fullPath);
13511
- const resolvedTarget = resolve(dirname3(fullPath), linkTarget);
13656
+ const resolvedTarget = resolve(dirname4(fullPath), linkTarget);
13512
13657
  const rel2 = relative(realRoot, resolvedTarget);
13513
- if (rel2.startsWith("..") || isAbsolute(rel2) || win32.isAbsolute(rel2)) {
13658
+ if (rel2.startsWith("..") || isAbsolute2(rel2) || win32.isAbsolute(rel2)) {
13514
13659
  throw new Error(`extracted symlink ${fullPath} points outside staging root: ${linkTarget}`);
13515
13660
  }
13516
13661
  continue;
13517
13662
  }
13518
13663
  const rel = relative(realRoot, fullPath);
13519
- if (rel.startsWith("..") || isAbsolute(rel) || win32.isAbsolute(rel)) {
13664
+ if (rel.startsWith("..") || isAbsolute2(rel) || win32.isAbsolute(rel)) {
13520
13665
  throw new Error(`extracted entry ${fullPath} escapes staging root`);
13521
13666
  }
13522
13667
  if (lst.isDirectory()) {
@@ -13539,7 +13684,7 @@ async function downloadOnnxRuntime(info, targetDir) {
13539
13684
  const tmpDir = `${targetDir}.tmp.${process.pid}.${Date.now().toString(36)}`;
13540
13685
  try {
13541
13686
  mkdirSync5(tmpDir, { recursive: true });
13542
- const archivePath = join6(tmpDir, `onnxruntime.${info.archiveType}`);
13687
+ const archivePath = join7(tmpDir, `onnxruntime.${info.archiveType}`);
13543
13688
  await downloadFileWithCap(url, archivePath);
13544
13689
  const archiveSha256 = sha256File(archivePath);
13545
13690
  log(`ONNX Runtime archive sha256=${archiveSha256}`);
@@ -13555,16 +13700,16 @@ async function downloadOnnxRuntime(info, targetDir) {
13555
13700
  unlinkSync3(archivePath);
13556
13701
  } catch {}
13557
13702
  validateExtractedTree(tmpDir);
13558
- const extractedDir = join6(tmpDir, info.assetName, "lib");
13703
+ const extractedDir = join7(tmpDir, info.assetName, "lib");
13559
13704
  if (!existsSync5(extractedDir)) {
13560
13705
  throw new Error(`Expected directory not found: ${extractedDir}`);
13561
13706
  }
13562
13707
  mkdirSync5(targetDir, { recursive: true });
13563
- const libFiles = readdirSync(extractedDir).filter((f) => f.startsWith("libonnxruntime") || f.startsWith("onnxruntime"));
13708
+ const libFiles = readdirSync2(extractedDir).filter((f) => f.startsWith("libonnxruntime") || f.startsWith("onnxruntime"));
13564
13709
  const realFiles = [];
13565
13710
  const symlinks = [];
13566
13711
  for (const libFile of libFiles) {
13567
- const src = join6(extractedDir, libFile);
13712
+ const src = join7(extractedDir, libFile);
13568
13713
  try {
13569
13714
  const stat = lstatSync(src);
13570
13715
  log(`ORT extract: ${libFile} — isSymlink=${stat.isSymbolicLink()}, isFile=${stat.isFile()}, size=${stat.size}`);
@@ -13579,7 +13724,7 @@ async function downloadOnnxRuntime(info, targetDir) {
13579
13724
  }
13580
13725
  }
13581
13726
  copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks);
13582
- const libPath = join6(targetDir, info.libName);
13727
+ const libPath = join7(targetDir, info.libName);
13583
13728
  let libHash = null;
13584
13729
  try {
13585
13730
  libHash = sha256File(libPath);
@@ -13604,8 +13749,8 @@ async function downloadOnnxRuntime(info, targetDir) {
13604
13749
  function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, copyFile = copyFileSync3) {
13605
13750
  const requiredLibs = new Set([info.libName]);
13606
13751
  for (const libFile of realFiles) {
13607
- const src = join6(extractedDir, libFile);
13608
- const dst = join6(targetDir, libFile);
13752
+ const src = join7(extractedDir, libFile);
13753
+ const dst = join7(targetDir, libFile);
13609
13754
  try {
13610
13755
  copyFile(src, dst);
13611
13756
  if (process.platform !== "win32") {
@@ -13621,12 +13766,12 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
13621
13766
  }
13622
13767
  const targetRoot = realpathSync(targetDir);
13623
13768
  for (const link of symlinks) {
13624
- const dst = join6(targetDir, link.name);
13769
+ const dst = join7(targetDir, link.name);
13625
13770
  try {
13626
13771
  unlinkSync3(dst);
13627
13772
  } catch {}
13628
- const dstForContainment = join6(targetRoot, link.name);
13629
- const resolvedTarget = resolve(dirname3(dstForContainment), link.target);
13773
+ const dstForContainment = join7(targetRoot, link.name);
13774
+ const resolvedTarget = resolve(dirname4(dstForContainment), link.target);
13630
13775
  if (!isPathInsideRoot(targetRoot, resolvedTarget)) {
13631
13776
  const message = `ONNX Runtime symlink ${link.name} points outside install dir: ${link.target}`;
13632
13777
  if (requiredLibs.has(link.name)) {
@@ -13646,7 +13791,7 @@ function copyOnnxLibraries(info, extractedDir, targetDir, realFiles, symlinks, c
13646
13791
  log(`ORT extract: failed to symlink optional ${link.name}: ${symlinkErr}`);
13647
13792
  }
13648
13793
  }
13649
- const requiredPath = join6(targetDir, info.libName);
13794
+ const requiredPath = join7(targetDir, info.libName);
13650
13795
  if (!existsSync5(requiredPath)) {
13651
13796
  rmSync2(targetDir, { recursive: true, force: true });
13652
13797
  throw new Error(`Required ONNX Runtime library missing after install: ${requiredPath}`);
@@ -13673,15 +13818,15 @@ function writeOnnxInstalledMeta(installDir, version, sha256, archiveSha256) {
13673
13818
  ...sha256 ? { sha256 } : {},
13674
13819
  archiveSha256
13675
13820
  };
13676
- writeFileSync2(join6(installDir, ONNX_INSTALLED_META_FILE), JSON.stringify(meta), "utf8");
13821
+ writeFileSync2(join7(installDir, ONNX_INSTALLED_META_FILE), JSON.stringify(meta), "utf8");
13677
13822
  } catch (err) {
13678
13823
  log(`[onnx] failed to write installed-meta in ${installDir}: ${err}`);
13679
13824
  }
13680
13825
  }
13681
13826
  function readOnnxInstalledMeta(installDir) {
13682
- const path = join6(installDir, ONNX_INSTALLED_META_FILE);
13827
+ const path = join7(installDir, ONNX_INSTALLED_META_FILE);
13683
13828
  try {
13684
- if (!statSync2(path).isFile())
13829
+ if (!statSync3(path).isFile())
13685
13830
  return null;
13686
13831
  const raw = readFileSync3(path, "utf8");
13687
13832
  const parsed = JSON.parse(raw);
@@ -13732,7 +13877,7 @@ ${new Date().toISOString()}
13732
13877
  const parsed = Number.parseInt(firstLine, 10);
13733
13878
  if (Number.isFinite(parsed) && parsed > 0)
13734
13879
  owningPid = parsed;
13735
- lockMtimeMs = statSync2(lockPath).mtimeMs;
13880
+ lockMtimeMs = statSync3(lockPath).mtimeMs;
13736
13881
  } catch {
13737
13882
  return tryClaim();
13738
13883
  }
@@ -15032,8 +15177,8 @@ function formatDuration(completion) {
15032
15177
 
15033
15178
  // src/config.ts
15034
15179
  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";
15180
+ import { homedir as homedir6 } from "node:os";
15181
+ import { join as join9 } from "node:path";
15037
15182
  var import_comment_json = __toESM(require_src2(), 1);
15038
15183
 
15039
15184
  // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
@@ -16620,8 +16765,8 @@ function emoji() {
16620
16765
  }
16621
16766
  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
16767
  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 ?? ":");
16768
+ var mac = (delimiter2) => {
16769
+ const escapedDelim = escapeRegex(delimiter2 ?? ":");
16625
16770
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
16626
16771
  };
16627
16772
  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 +29373,17 @@ function getOpenCodeConfigDir() {
29228
29373
  if (envDir) {
29229
29374
  return envDir;
29230
29375
  }
29231
- const xdgConfig = process.env.XDG_CONFIG_HOME || join8(homedir5(), ".config");
29232
- return join8(xdgConfig, "opencode");
29376
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join9(homedir6(), ".config");
29377
+ return join9(xdgConfig, "opencode");
29233
29378
  }
29234
29379
  function loadAftConfig(projectDirectory) {
29235
29380
  const configDir = getOpenCodeConfigDir();
29236
- const userBasePath = join8(configDir, "aft");
29381
+ const userBasePath = join9(configDir, "aft");
29237
29382
  migrateAftConfigFile(`${userBasePath}.jsonc`);
29238
29383
  migrateAftConfigFile(`${userBasePath}.json`);
29239
29384
  const userDetected = detectConfigFile(userBasePath);
29240
29385
  const userConfigPath = userDetected.format !== "none" ? userDetected.path : `${userBasePath}.json`;
29241
- const projectBasePath = join8(projectDirectory, ".opencode", "aft");
29386
+ const projectBasePath = join9(projectDirectory, ".opencode", "aft");
29242
29387
  migrateAftConfigFile(`${projectBasePath}.jsonc`);
29243
29388
  migrateAftConfigFile(`${projectBasePath}.json`);
29244
29389
  const projectDetected = detectConfigFile(projectBasePath);
@@ -29264,8 +29409,8 @@ function loadAftConfig(projectDirectory) {
29264
29409
 
29265
29410
  // src/notifications.ts
29266
29411
  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";
29412
+ import { homedir as homedir7, platform } from "node:os";
29413
+ import { join as join10 } from "node:path";
29269
29414
  function isTuiMode() {
29270
29415
  return process.env.OPENCODE_CLIENT === "cli";
29271
29416
  }
@@ -29286,17 +29431,17 @@ var WARNING_MARKER = `${AFT_MARKER} ⚠️`;
29286
29431
  var STATUS_MARKER = `${AFT_MARKER} ✅`;
29287
29432
  function getDesktopStatePath() {
29288
29433
  const os2 = platform();
29289
- const home = homedir6();
29434
+ const home = homedir7();
29290
29435
  if (os2 === "darwin") {
29291
- return join9(home, "Library", "Application Support", "ai.opencode.desktop", "opencode.global.dat");
29436
+ return join10(home, "Library", "Application Support", "ai.opencode.desktop", "opencode.global.dat");
29292
29437
  }
29293
29438
  if (os2 === "linux") {
29294
- const xdgConfig = process.env.XDG_CONFIG_HOME || join9(home, ".config");
29295
- return join9(xdgConfig, "ai.opencode.desktop", "opencode.global.dat");
29439
+ const xdgConfig = process.env.XDG_CONFIG_HOME || join10(home, ".config");
29440
+ return join10(xdgConfig, "ai.opencode.desktop", "opencode.global.dat");
29296
29441
  }
29297
29442
  if (os2 === "win32") {
29298
- const appData = process.env.APPDATA || join9(home, "AppData", "Roaming");
29299
- return join9(appData, "ai.opencode.desktop", "opencode.global.dat");
29443
+ const appData = process.env.APPDATA || join10(home, "AppData", "Roaming");
29444
+ return join10(appData, "ai.opencode.desktop", "opencode.global.dat");
29300
29445
  }
29301
29446
  return null;
29302
29447
  }
@@ -29760,43 +29905,43 @@ import {
29760
29905
  rmSync as rmSync4,
29761
29906
  writeFileSync as writeFileSync6
29762
29907
  } from "node:fs";
29763
- import { dirname as dirname6 } from "node:path";
29908
+ import { dirname as dirname7 } from "node:path";
29764
29909
 
29765
29910
  // src/hooks/auto-update-checker/cache.ts
29766
- var import_comment_json3 = __toESM(require_src2(), 1);
29767
29911
  import { spawn as spawn2 } from "node:child_process";
29768
29912
  import { cpSync, existsSync as existsSync9, mkdtempSync, readFileSync as readFileSync7, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
29769
29913
  import { tmpdir as tmpdir3 } from "node:os";
29770
- import { basename as basename2, dirname as dirname5, join as join12 } from "node:path";
29914
+ import { basename as basename2, dirname as dirname6, join as join13 } from "node:path";
29915
+ var import_comment_json3 = __toESM(require_src2(), 1);
29771
29916
 
29772
29917
  // src/hooks/auto-update-checker/checker.ts
29773
29918
  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";
29919
+ import { existsSync as existsSync8, readFileSync as readFileSync6, statSync as statSync4, writeFileSync as writeFileSync4 } from "node:fs";
29920
+ import { homedir as homedir9 } from "node:os";
29921
+ import { dirname as dirname5, isAbsolute as isAbsolute3, join as join12, resolve as resolve2 } from "node:path";
29777
29922
  import { fileURLToPath } from "node:url";
29778
29923
 
29779
29924
  // 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";
29925
+ import { homedir as homedir8, platform as platform2 } from "node:os";
29926
+ import { join as join11 } from "node:path";
29782
29927
  var PACKAGE_NAME = "@cortexkit/aft-opencode";
29783
29928
  var NPM_REGISTRY_URL = "https://registry.npmjs.org";
29784
29929
  var NPM_FETCH_TIMEOUT = 1e4;
29785
29930
  function getOpenCodeCacheRoot() {
29786
29931
  if (platform2() === "win32") {
29787
- return join10(process.env.LOCALAPPDATA ?? homedir7(), "opencode");
29932
+ return join11(process.env.LOCALAPPDATA ?? homedir8(), "opencode");
29788
29933
  }
29789
- return join10(homedir7(), ".cache", "opencode");
29934
+ return join11(homedir8(), ".cache", "opencode");
29790
29935
  }
29791
29936
  function getOpenCodeConfigRoot() {
29792
29937
  if (platform2() === "win32") {
29793
- return join10(process.env.APPDATA ?? join10(homedir7(), "AppData", "Roaming"), "opencode");
29938
+ return join11(process.env.APPDATA ?? join11(homedir8(), "AppData", "Roaming"), "opencode");
29794
29939
  }
29795
- return join10(process.env.XDG_CONFIG_HOME ?? join10(homedir7(), ".config"), "opencode");
29940
+ return join11(process.env.XDG_CONFIG_HOME ?? join11(homedir8(), ".config"), "opencode");
29796
29941
  }
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");
29942
+ var CACHE_DIR = join11(getOpenCodeCacheRoot(), "packages");
29943
+ var USER_OPENCODE_CONFIG = join11(getOpenCodeConfigRoot(), "opencode.json");
29944
+ var USER_OPENCODE_CONFIG_JSONC = join11(getOpenCodeConfigRoot(), "opencode.jsonc");
29800
29945
 
29801
29946
  // src/hooks/auto-update-checker/types.ts
29802
29947
  var NpmPackageEnvelopeSchema = exports_external.object({
@@ -29854,8 +29999,8 @@ function extractChannel(version2) {
29854
29999
  }
29855
30000
  function getConfigPaths(directory) {
29856
30001
  return [
29857
- join11(directory, ".opencode", "opencode.json"),
29858
- join11(directory, ".opencode", "opencode.jsonc"),
30002
+ join12(directory, ".opencode", "opencode.json"),
30003
+ join12(directory, ".opencode", "opencode.jsonc"),
29859
30004
  USER_OPENCODE_CONFIG,
29860
30005
  USER_OPENCODE_CONFIG_JSONC
29861
30006
  ];
@@ -29868,9 +30013,9 @@ function resolvePathPluginSpec(spec, configPath) {
29868
30013
  return spec.replace(/^file:\/\//, "");
29869
30014
  }
29870
30015
  }
29871
- if (isAbsolute2(spec) || /^[A-Za-z]:[\\/]/.test(spec))
30016
+ if (isAbsolute3(spec) || /^[A-Za-z]:[\\/]/.test(spec))
29872
30017
  return spec;
29873
- return resolve2(dirname4(configPath), spec);
30018
+ return resolve2(dirname5(configPath), spec);
29874
30019
  }
29875
30020
  function getLocalDevPath(directory) {
29876
30021
  for (const configPath of getConfigPaths(directory)) {
@@ -29882,7 +30027,7 @@ function getLocalDevPath(directory) {
29882
30027
  for (const entry of plugins) {
29883
30028
  if (entry === PACKAGE_NAME || entry.startsWith(`${PACKAGE_NAME}@`))
29884
30029
  continue;
29885
- if (entry.startsWith("file://") || entry.startsWith(".") || isAbsolute2(entry)) {
30030
+ if (entry.startsWith("file://") || entry.startsWith(".") || isAbsolute3(entry)) {
29886
30031
  const localPath = resolvePathPluginSpec(entry, configPath);
29887
30032
  const pkgPath = findPackageJsonUp(localPath);
29888
30033
  if (!pkgPath)
@@ -29898,10 +30043,10 @@ function getLocalDevPath(directory) {
29898
30043
  }
29899
30044
  function findPackageJsonUp(startPath) {
29900
30045
  try {
29901
- const stat = statSync3(startPath);
29902
- let dir = stat.isDirectory() ? startPath : dirname4(startPath);
30046
+ const stat = statSync4(startPath);
30047
+ let dir = stat.isDirectory() ? startPath : dirname5(startPath);
29903
30048
  for (let i = 0;i < 10; i++) {
29904
- const pkgPath = join11(dir, "package.json");
30049
+ const pkgPath = join12(dir, "package.json");
29905
30050
  if (existsSync8(pkgPath)) {
29906
30051
  try {
29907
30052
  const pkg = PackageJsonSchema.safeParse(JSON.parse(readFileSync6(pkgPath, "utf-8")));
@@ -29909,7 +30054,7 @@ function findPackageJsonUp(startPath) {
29909
30054
  return pkgPath;
29910
30055
  } catch {}
29911
30056
  }
29912
- const parent = dirname4(dir);
30057
+ const parent = dirname5(dir);
29913
30058
  if (parent === dir)
29914
30059
  break;
29915
30060
  dir = parent;
@@ -29933,7 +30078,7 @@ function getLocalDevVersion(directory) {
29933
30078
  }
29934
30079
  function getCurrentRuntimePackageJsonPath(currentModuleUrl = import.meta.url) {
29935
30080
  try {
29936
- return findPackageJsonUp(dirname4(fileURLToPath(currentModuleUrl)));
30081
+ return findPackageJsonUp(dirname5(fileURLToPath(currentModuleUrl)));
29937
30082
  } catch (err) {
29938
30083
  warn2(`[auto-update-checker] Failed to resolve runtime package path: ${String(err)}`);
29939
30084
  return null;
@@ -29962,7 +30107,7 @@ function findPluginEntry(directory) {
29962
30107
  }
29963
30108
  var cachedPackageVersion = null;
29964
30109
  function getSpecCachePackageJsonPath(spec) {
29965
- return join11(CACHE_DIR, spec, "node_modules", PACKAGE_NAME, "package.json");
30110
+ return join12(CACHE_DIR, spec, "node_modules", PACKAGE_NAME, "package.json");
29966
30111
  }
29967
30112
  function getCachedVersion(spec) {
29968
30113
  if (!spec && cachedPackageVersion)
@@ -29971,7 +30116,7 @@ function getCachedVersion(spec) {
29971
30116
  getCurrentRuntimePackageJsonPath(),
29972
30117
  spec ? getSpecCachePackageJsonPath(spec) : null,
29973
30118
  getSpecCachePackageJsonPath(`${PACKAGE_NAME}@latest`),
29974
- join11(homedir8(), ".cache", "opencode", "node_modules", PACKAGE_NAME, "package.json")
30119
+ join12(homedir9(), ".cache", "opencode", "node_modules", PACKAGE_NAME, "package.json")
29975
30120
  ].filter(isString);
29976
30121
  for (const packageJsonPath of candidates) {
29977
30122
  try {
@@ -30019,10 +30164,10 @@ async function getLatestVersion(channel = "latest", options = {}) {
30019
30164
  // src/hooks/auto-update-checker/cache.ts
30020
30165
  var pendingSnapshots = new Map;
30021
30166
  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;
30167
+ const packageDir = join13(installDir, "node_modules", packageName);
30168
+ const lockfilePath = join13(installDir, "package-lock.json");
30169
+ const tempDir = mkdtempSync(join13(tmpdir3(), "aft-auto-update-"));
30170
+ const stagedPackageDir = existsSync9(packageDir) ? join13(tempDir, "package") : null;
30026
30171
  if (stagedPackageDir)
30027
30172
  cpSync(packageDir, stagedPackageDir, { recursive: true });
30028
30173
  return {
@@ -30058,12 +30203,12 @@ function stripPackageNameFromPath(pathValue, packageName) {
30058
30203
  for (const segment of [...packageName.split("/")].reverse()) {
30059
30204
  if (basename2(current) !== segment)
30060
30205
  return null;
30061
- current = dirname5(current);
30206
+ current = dirname6(current);
30062
30207
  }
30063
30208
  return current;
30064
30209
  }
30065
30210
  function removeFromPackageLock(installDir, packageName) {
30066
- const lockPath = join12(installDir, "package-lock.json");
30211
+ const lockPath = join13(installDir, "package-lock.json");
30067
30212
  if (!existsSync9(lockPath))
30068
30213
  return false;
30069
30214
  try {
@@ -30112,7 +30257,7 @@ function ensureDependencyVersion(packageJsonPath, packageName, version2) {
30112
30257
  }
30113
30258
  }
30114
30259
  function removeInstalledPackage(installDir, packageName) {
30115
- const packageDir = join12(installDir, "node_modules", packageName);
30260
+ const packageDir = join13(installDir, "node_modules", packageName);
30116
30261
  if (!existsSync9(packageDir))
30117
30262
  return false;
30118
30263
  rmSync3(packageDir, { recursive: true, force: true });
@@ -30121,19 +30266,19 @@ function removeInstalledPackage(installDir, packageName) {
30121
30266
  }
30122
30267
  function resolveInstallContext(runtimePackageJsonPath = getCurrentRuntimePackageJsonPath()) {
30123
30268
  if (runtimePackageJsonPath) {
30124
- const packageDir = dirname5(runtimePackageJsonPath);
30269
+ const packageDir = dirname6(runtimePackageJsonPath);
30125
30270
  const nodeModulesDir = stripPackageNameFromPath(packageDir, PACKAGE_NAME);
30126
30271
  if (nodeModulesDir && basename2(nodeModulesDir) === "node_modules") {
30127
- const installDir = dirname5(nodeModulesDir);
30128
- const packageJsonPath = join12(installDir, "package.json");
30272
+ const installDir = dirname6(nodeModulesDir);
30273
+ const packageJsonPath = join13(installDir, "package.json");
30129
30274
  if (existsSync9(packageJsonPath))
30130
30275
  return { installDir, packageJsonPath };
30131
30276
  }
30132
30277
  return null;
30133
30278
  }
30134
- const legacyPackageJsonPath = join12(dirname5(CACHE_DIR), "package.json");
30279
+ const legacyPackageJsonPath = join13(dirname6(CACHE_DIR), "package.json");
30135
30280
  if (existsSync9(legacyPackageJsonPath)) {
30136
- return { installDir: dirname5(CACHE_DIR), packageJsonPath: legacyPackageJsonPath };
30281
+ return { installDir: dirname6(CACHE_DIR), packageJsonPath: legacyPackageJsonPath };
30137
30282
  }
30138
30283
  return null;
30139
30284
  }
@@ -30169,10 +30314,16 @@ async function runNpmInstallSafe(installDir, options = {}) {
30169
30314
  try {
30170
30315
  if (options.signal?.aborted)
30171
30316
  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"], {
30317
+ const npm = resolveNpm();
30318
+ if (!npm) {
30319
+ const reason = "npm not found on PATH or in known version-manager locations";
30320
+ warnNpmInstallFailure(reason, stderrTail);
30321
+ return { ok: false, reason };
30322
+ }
30323
+ const proc = spawn2(npm.command, ["install", "--no-audit", "--no-fund", "--no-progress", "--ignore-scripts"], {
30174
30324
  cwd: installDir,
30175
- stdio: ["ignore", "pipe", "pipe"]
30325
+ stdio: ["ignore", "pipe", "pipe"],
30326
+ env: npmSpawnEnv(npm)
30176
30327
  });
30177
30328
  proc.stderr?.on("data", (chunk) => {
30178
30329
  stderrTail += chunk.toString("utf8");
@@ -30301,7 +30452,7 @@ function claimCheckSlot(storageDir, intervalMs) {
30301
30452
  try {
30302
30453
  if (hasRecentCheckTimestamp(file2, intervalMs))
30303
30454
  return null;
30304
- mkdirSync6(dirname6(file2), { recursive: true });
30455
+ mkdirSync6(dirname7(file2), { recursive: true });
30305
30456
  const lockPath = `${file2}.lock`;
30306
30457
  let lockFd;
30307
30458
  try {
@@ -30411,6 +30562,11 @@ async function runBackgroundUpdateCheck(ctx, options) {
30411
30562
  log2("[auto-update-checker] Auto-update disabled, notification only");
30412
30563
  return;
30413
30564
  }
30565
+ if (!isNpmAvailable()) {
30566
+ 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);
30567
+ warn2("[auto-update-checker] npm not found on PATH or known version-manager locations; skipping destructive auto-update steps");
30568
+ return;
30569
+ }
30414
30570
  const installDir = preparePackageUpdate(latestVersion, PACKAGE_NAME);
30415
30571
  if (!installDir) {
30416
30572
  showToast(ctx, `AFT ${latestVersion}`, `v${latestVersion} available. Auto-update could not prepare the active install.`, "warning", 8000);
@@ -30441,8 +30597,17 @@ function showToast(ctx, title, message, variant = "info", duration3 = 3000) {
30441
30597
  // src/lsp-auto-install.ts
30442
30598
  import { spawn as spawn3 } from "node:child_process";
30443
30599
  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";
30600
+ import {
30601
+ createReadStream,
30602
+ existsSync as existsSync12,
30603
+ mkdirSync as mkdirSync8,
30604
+ readFileSync as readFileSync11,
30605
+ renameSync as renameSync6,
30606
+ rmSync as rmSync5,
30607
+ statSync as statSync6,
30608
+ writeFileSync as writeFileSync8
30609
+ } from "node:fs";
30610
+ import { join as join16 } from "node:path";
30446
30611
 
30447
30612
  // src/lsp-cache.ts
30448
30613
  import {
@@ -30450,40 +30615,40 @@ import {
30450
30615
  mkdirSync as mkdirSync7,
30451
30616
  openSync as openSync5,
30452
30617
  readFileSync as readFileSync9,
30453
- statSync as statSync4,
30618
+ statSync as statSync5,
30454
30619
  unlinkSync as unlinkSync5,
30455
30620
  writeFileSync as writeFileSync7
30456
30621
  } from "node:fs";
30457
- import { homedir as homedir9 } from "node:os";
30458
- import { join as join13 } from "node:path";
30622
+ import { homedir as homedir10 } from "node:os";
30623
+ import { join as join14 } from "node:path";
30459
30624
  function aftCacheBase() {
30460
30625
  const override = process.env.AFT_CACHE_DIR;
30461
30626
  if (override && override.length > 0)
30462
30627
  return override;
30463
30628
  if (process.platform === "win32") {
30464
30629
  const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA;
30465
- const base2 = localAppData || join13(homedir9(), "AppData", "Local");
30466
- return join13(base2, "aft");
30630
+ const base2 = localAppData || join14(homedir10(), "AppData", "Local");
30631
+ return join14(base2, "aft");
30467
30632
  }
30468
- const base = process.env.XDG_CACHE_HOME || join13(homedir9(), ".cache");
30469
- return join13(base, "aft");
30633
+ const base = process.env.XDG_CACHE_HOME || join14(homedir10(), ".cache");
30634
+ return join14(base, "aft");
30470
30635
  }
30471
30636
  function lspCacheRoot() {
30472
- return join13(aftCacheBase(), "lsp-packages");
30637
+ return join14(aftCacheBase(), "lsp-packages");
30473
30638
  }
30474
30639
  function lspPackageDir(npmPackage) {
30475
- return join13(lspCacheRoot(), encodeURIComponent(npmPackage));
30640
+ return join14(lspCacheRoot(), encodeURIComponent(npmPackage));
30476
30641
  }
30477
30642
  function lspBinaryPath(npmPackage, binary) {
30478
- return join13(lspPackageDir(npmPackage), "node_modules", ".bin", binary);
30643
+ return join14(lspPackageDir(npmPackage), "node_modules", ".bin", binary);
30479
30644
  }
30480
30645
  function lspBinDir(npmPackage) {
30481
- return join13(lspPackageDir(npmPackage), "node_modules", ".bin");
30646
+ return join14(lspPackageDir(npmPackage), "node_modules", ".bin");
30482
30647
  }
30483
30648
  function isInstalled(npmPackage, binary) {
30484
30649
  for (const candidate of lspBinaryCandidates(binary)) {
30485
30650
  try {
30486
- if (statSync4(join13(lspBinDir(npmPackage), candidate)).isFile())
30651
+ if (statSync5(join14(lspBinDir(npmPackage), candidate)).isFile())
30487
30652
  return true;
30488
30653
  } catch {}
30489
30654
  }
@@ -30503,15 +30668,15 @@ function writeInstalledMetaIn(installDir, version2, sha256) {
30503
30668
  installedAt: new Date().toISOString(),
30504
30669
  ...sha256 ? { sha256 } : {}
30505
30670
  };
30506
- writeFileSync7(join13(installDir, INSTALLED_META_FILE), JSON.stringify(meta3), "utf8");
30671
+ writeFileSync7(join14(installDir, INSTALLED_META_FILE), JSON.stringify(meta3), "utf8");
30507
30672
  } catch (err) {
30508
30673
  log2(`[lsp-cache] failed to write installed-meta in ${installDir}: ${err}`);
30509
30674
  }
30510
30675
  }
30511
30676
  function readInstalledMetaIn(installDir) {
30512
- const path2 = join13(installDir, INSTALLED_META_FILE);
30677
+ const path2 = join14(installDir, INSTALLED_META_FILE);
30513
30678
  try {
30514
- if (!statSync4(path2).isFile())
30679
+ if (!statSync5(path2).isFile())
30515
30680
  return null;
30516
30681
  const raw = readFileSync9(path2, "utf8");
30517
30682
  const parsed = JSON.parse(raw);
@@ -30533,7 +30698,7 @@ function readInstalledMeta(packageKey) {
30533
30698
  return readInstalledMetaIn(lspPackageDir(packageKey));
30534
30699
  }
30535
30700
  function lockPath(npmPackage) {
30536
- return join13(lspPackageDir(npmPackage), ".aft-installing");
30701
+ return join14(lspPackageDir(npmPackage), ".aft-installing");
30537
30702
  }
30538
30703
  var STALE_LOCK_MS2 = 30 * 60 * 1000;
30539
30704
  function acquireInstallLock(lockKey) {
@@ -30568,7 +30733,7 @@ ${new Date().toISOString()}
30568
30733
  const parsed = Number.parseInt(firstLine, 10);
30569
30734
  if (Number.isFinite(parsed) && parsed > 0)
30570
30735
  owningPid = parsed;
30571
- lockMtimeMs = statSync4(lock).mtimeMs;
30736
+ lockMtimeMs = statSync5(lock).mtimeMs;
30572
30737
  } catch {
30573
30738
  return tryClaim();
30574
30739
  }
@@ -30640,7 +30805,7 @@ async function withInstallLock(lockKey, task) {
30640
30805
  }
30641
30806
  var VERSION_CHECK_FILE = ".aft-version-check";
30642
30807
  function readVersionCheck(npmPackage) {
30643
- const file2 = join13(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
30808
+ const file2 = join14(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
30644
30809
  try {
30645
30810
  const raw = readFileSync9(file2, "utf8");
30646
30811
  const parsed = JSON.parse(raw);
@@ -30657,7 +30822,7 @@ function readVersionCheck(npmPackage) {
30657
30822
  }
30658
30823
  function writeVersionCheck(npmPackage, latest) {
30659
30824
  mkdirSync7(lspPackageDir(npmPackage), { recursive: true });
30660
- const file2 = join13(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
30825
+ const file2 = join14(lspPackageDir(npmPackage), VERSION_CHECK_FILE);
30661
30826
  const record2 = {
30662
30827
  last_checked: new Date().toISOString(),
30663
30828
  latest_eligible: latest
@@ -30819,8 +30984,8 @@ var NPM_LSP_TABLE = [
30819
30984
  ];
30820
30985
 
30821
30986
  // 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";
30987
+ import { existsSync as existsSync11, readdirSync as readdirSync3, readFileSync as readFileSync10 } from "node:fs";
30988
+ import { join as join15 } from "node:path";
30824
30989
  var MAX_WALK_DIRS = 200;
30825
30990
  var MAX_WALK_DEPTH = 4;
30826
30991
  var NOISE_DIRS = new Set([
@@ -30837,7 +31002,7 @@ function hasRootMarker(projectRoot, rootMarkers) {
30837
31002
  if (!rootMarkers)
30838
31003
  return false;
30839
31004
  for (const marker of rootMarkers) {
30840
- if (existsSync11(join14(projectRoot, marker)))
31005
+ if (existsSync11(join15(projectRoot, marker)))
30841
31006
  return true;
30842
31007
  }
30843
31008
  return false;
@@ -30861,7 +31026,7 @@ function hasPackageJsonDep(projectRoot, depNames) {
30861
31026
  }
30862
31027
  function readPackageJson(projectRoot) {
30863
31028
  try {
30864
- const raw = readFileSync10(join14(projectRoot, "package.json"), "utf8");
31029
+ const raw = readFileSync10(join15(projectRoot, "package.json"), "utf8");
30865
31030
  const parsed = JSON.parse(raw);
30866
31031
  if (typeof parsed !== "object" || parsed === null)
30867
31032
  return null;
@@ -30884,14 +31049,14 @@ function relevantExtensionsInProject(projectRoot, extToServer) {
30884
31049
  visitedDirs += 1;
30885
31050
  let entries;
30886
31051
  try {
30887
- entries = readdirSync2(current.dir, { withFileTypes: true });
31052
+ entries = readdirSync3(current.dir, { withFileTypes: true });
30888
31053
  } catch {
30889
31054
  continue;
30890
31055
  }
30891
31056
  for (const entry of entries) {
30892
31057
  if (entry.isDirectory()) {
30893
31058
  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 });
31059
+ queue.push({ dir: join15(current.dir, entry.name), depth: current.depth + 1 });
30895
31060
  }
30896
31061
  continue;
30897
31062
  }
@@ -31016,6 +31181,17 @@ async function resolveTargetVersion(spec, config2, fetchImpl = fetch) {
31016
31181
  writeVersionCheck(spec.npm, probe.version);
31017
31182
  return { version: probe.version, pinned: false, probe };
31018
31183
  }
31184
+ function ensureInstallAnchor(cwd) {
31185
+ try {
31186
+ const stub = join16(cwd, "package.json");
31187
+ if (!existsSync12(stub)) {
31188
+ writeFileSync8(stub, `${JSON.stringify({ name: "aft-lsp-cache", version: "0.0.0", private: true })}
31189
+ `);
31190
+ }
31191
+ } catch (err) {
31192
+ warn2(`[lsp] could not write package.json stub in ${cwd}: ${err}`);
31193
+ }
31194
+ }
31019
31195
  function runInstall(spec, version2, cwd, signal) {
31020
31196
  return new Promise((resolve3) => {
31021
31197
  const target = `${spec.npm}@${version2}`;
@@ -31025,10 +31201,17 @@ function runInstall(spec, version2, cwd, signal) {
31025
31201
  resolve3(false);
31026
31202
  return;
31027
31203
  }
31028
- const npmBin = process.platform === "win32" ? "npm.cmd" : "npm";
31029
- const child = spawn3(npmBin, ["install", "--no-save", "--ignore-scripts", "--silent", target], {
31204
+ const npm = resolveNpm();
31205
+ if (!npm) {
31206
+ warn2(`[lsp] npm not found on PATH or known locations; cannot install ${target}`);
31207
+ resolve3(false);
31208
+ return;
31209
+ }
31210
+ ensureInstallAnchor(cwd);
31211
+ const child = spawn3(npm.command, ["install", "--no-save", "--ignore-scripts", "--silent", target], {
31030
31212
  stdio: ["ignore", "pipe", "pipe"],
31031
- cwd
31213
+ cwd,
31214
+ env: npmSpawnEnv(npm)
31032
31215
  });
31033
31216
  child.unref();
31034
31217
  let stderrBuf = "";
@@ -31155,7 +31338,7 @@ function hashInstalledBinary(spec) {
31155
31338
  let pathToHash = null;
31156
31339
  for (const p of candidates) {
31157
31340
  try {
31158
- if (statSync5(p).isFile()) {
31341
+ if (statSync6(p).isFile()) {
31159
31342
  pathToHash = p;
31160
31343
  break;
31161
31344
  }
@@ -31181,7 +31364,7 @@ function installedBinaryPath(spec) {
31181
31364
  ] : [lspBinaryPath(spec.npm, spec.binary)];
31182
31365
  for (const candidate of candidates) {
31183
31366
  try {
31184
- if (statSync5(candidate).isFile())
31367
+ if (statSync6(candidate).isFile())
31185
31368
  return candidate;
31186
31369
  } catch {}
31187
31370
  }
@@ -31192,10 +31375,10 @@ function sha256OfFileSync(path2) {
31192
31375
  }
31193
31376
  function quarantineCachedNpmInstall(spec, reason) {
31194
31377
  const packageDir = lspPackageDir(spec.npm);
31195
- const dest = join15(packageDir, "..", ".quarantine", encodeURIComponent(spec.npm), `${Date.now()}`);
31378
+ const dest = join16(packageDir, "..", ".quarantine", encodeURIComponent(spec.npm), `${Date.now()}`);
31196
31379
  warn2(`[lsp] tofu_mismatch ${spec.npm}: ${reason}; quarantining ${packageDir} -> ${dest}`);
31197
31380
  try {
31198
- mkdirSync8(join15(dest, ".."), { recursive: true });
31381
+ mkdirSync8(join16(dest, ".."), { recursive: true });
31199
31382
  rmSync5(dest, { recursive: true, force: true });
31200
31383
  renameSync6(packageDir, dest);
31201
31384
  } catch (err) {
@@ -31278,20 +31461,20 @@ import {
31278
31461
  copyFileSync as copyFileSync4,
31279
31462
  createReadStream as createReadStream2,
31280
31463
  createWriteStream as createWriteStream3,
31281
- existsSync as existsSync12,
31464
+ existsSync as existsSync13,
31282
31465
  lstatSync as lstatSync2,
31283
31466
  mkdirSync as mkdirSync9,
31284
- readdirSync as readdirSync3,
31467
+ readdirSync as readdirSync4,
31285
31468
  readFileSync as readFileSync12,
31286
31469
  readlinkSync as readlinkSync2,
31287
31470
  realpathSync as realpathSync3,
31288
31471
  renameSync as renameSync7,
31289
31472
  rmSync as rmSync6,
31290
- statSync as statSync6,
31473
+ statSync as statSync7,
31291
31474
  unlinkSync as unlinkSync6,
31292
- writeFileSync as writeFileSync8
31475
+ writeFileSync as writeFileSync9
31293
31476
  } from "node:fs";
31294
- import { dirname as dirname7, join as join16, relative as relative2, resolve as resolve3 } from "node:path";
31477
+ import { dirname as dirname8, join as join17, relative as relative2, resolve as resolve3 } from "node:path";
31295
31478
  import { Readable as Readable3 } from "node:stream";
31296
31479
  import { pipeline as pipeline3 } from "node:stream/promises";
31297
31480
 
@@ -31381,26 +31564,26 @@ function detectHostPlatform() {
31381
31564
 
31382
31565
  // src/lsp-github-install.ts
31383
31566
  function ghCacheRoot() {
31384
- return join16(aftCacheBase(), "lsp-binaries");
31567
+ return join17(aftCacheBase(), "lsp-binaries");
31385
31568
  }
31386
31569
  function ghPackageDir(spec) {
31387
- return join16(ghCacheRoot(), spec.id);
31570
+ return join17(ghCacheRoot(), spec.id);
31388
31571
  }
31389
31572
  function ghBinDir(spec) {
31390
- return join16(ghPackageDir(spec), "bin");
31573
+ return join17(ghPackageDir(spec), "bin");
31391
31574
  }
31392
31575
  function ghExtractDir(spec) {
31393
- return join16(ghPackageDir(spec), "extracted");
31576
+ return join17(ghPackageDir(spec), "extracted");
31394
31577
  }
31395
31578
  var INSTALLED_META_FILE2 = ".aft-installed";
31396
31579
  function ghBinaryPath(spec, platform3) {
31397
31580
  const ext = platform3 === "win32" ? ".exe" : "";
31398
- return join16(ghBinDir(spec), `${spec.binary}${ext}`);
31581
+ return join17(ghBinDir(spec), `${spec.binary}${ext}`);
31399
31582
  }
31400
31583
  function isGithubInstalled(spec, platform3) {
31401
31584
  for (const candidate of ghBinaryCandidates(spec, platform3)) {
31402
31585
  try {
31403
- if (statSync6(join16(ghBinDir(spec), candidate)).isFile())
31586
+ if (statSync7(join17(ghBinDir(spec), candidate)).isFile())
31404
31587
  return true;
31405
31588
  } catch {}
31406
31589
  }
@@ -31413,8 +31596,8 @@ function ghBinaryCandidates(spec, platform3) {
31413
31596
  }
31414
31597
  function readGithubInstalledMetaIn(installDir) {
31415
31598
  try {
31416
- const path2 = join16(installDir, INSTALLED_META_FILE2);
31417
- if (!statSync6(path2).isFile())
31599
+ const path2 = join17(installDir, INSTALLED_META_FILE2);
31600
+ if (!statSync7(path2).isFile())
31418
31601
  return null;
31419
31602
  const parsed = JSON.parse(readFileSync12(path2, "utf8"));
31420
31603
  if (typeof parsed.version !== "string" || parsed.version.length === 0)
@@ -31440,7 +31623,7 @@ function writeGithubInstalledMetaIn(installDir, version2, binarySha256, archiveS
31440
31623
  binarySha256,
31441
31624
  ...archiveSha256 ? { archiveSha256 } : {}
31442
31625
  };
31443
- writeFileSync8(join16(installDir, INSTALLED_META_FILE2), JSON.stringify(meta3), "utf8");
31626
+ writeFileSync9(join17(installDir, INSTALLED_META_FILE2), JSON.stringify(meta3), "utf8");
31444
31627
  } catch (err) {
31445
31628
  warn2(`[lsp] failed to write github installed metadata in ${installDir}: ${err}`);
31446
31629
  }
@@ -31633,7 +31816,7 @@ async function downloadFile(url2, destPath, fetchImpl, assetSize, signal) {
31633
31816
  if (Number.isFinite(advertised) && advertised > MAX_DOWNLOAD_BYTES3) {
31634
31817
  throw new Error(`Content-Length ${advertised} exceeds max ${MAX_DOWNLOAD_BYTES3}`);
31635
31818
  }
31636
- mkdirSync9(dirname7(destPath), { recursive: true });
31819
+ mkdirSync9(dirname8(destPath), { recursive: true });
31637
31820
  let bytesWritten = 0;
31638
31821
  const guard = new TransformStream({
31639
31822
  transform(chunk, controller) {
@@ -31684,12 +31867,12 @@ function validateExtraction(stagingRoot) {
31684
31867
  const walk = (dir) => {
31685
31868
  let entries;
31686
31869
  try {
31687
- entries = readdirSync3(dir);
31870
+ entries = readdirSync4(dir);
31688
31871
  } catch (err) {
31689
31872
  throw new Error(`failed to read staging dir ${dir}: ${err}`);
31690
31873
  }
31691
31874
  for (const entry of entries) {
31692
- const full = join16(dir, entry);
31875
+ const full = join17(dir, entry);
31693
31876
  let lst;
31694
31877
  try {
31695
31878
  lst = lstatSync2(full);
@@ -31777,10 +31960,10 @@ function extractArchiveSafely(archivePath, destDir, archiveType) {
31777
31960
  }
31778
31961
  function quarantineCachedGithubInstall(spec, reason) {
31779
31962
  const packageDir = ghPackageDir(spec);
31780
- const dest = join16(ghCacheRoot(), ".quarantine", encodeURIComponent(spec.id), `${Date.now()}`);
31963
+ const dest = join17(ghCacheRoot(), ".quarantine", encodeURIComponent(spec.id), `${Date.now()}`);
31781
31964
  warn2(`[lsp] tofu_mismatch ${spec.id}: ${reason}; quarantining ${packageDir} -> ${dest}`);
31782
31965
  try {
31783
- mkdirSync9(dirname7(dest), { recursive: true });
31966
+ mkdirSync9(dirname8(dest), { recursive: true });
31784
31967
  rmSync6(dest, { recursive: true, force: true });
31785
31968
  renameSync7(packageDir, dest);
31786
31969
  } catch (err) {
@@ -31790,9 +31973,9 @@ function quarantineCachedGithubInstall(spec, reason) {
31790
31973
  function validateCachedGithubInstall(spec, platform3) {
31791
31974
  const packageDir = ghPackageDir(spec);
31792
31975
  const meta3 = readGithubInstalledMetaIn(packageDir);
31793
- const binaryPath = ghBinaryCandidates(spec, platform3).map((candidate) => join16(ghBinDir(spec), candidate)).find((candidate) => {
31976
+ const binaryPath = ghBinaryCandidates(spec, platform3).map((candidate) => join17(ghBinDir(spec), candidate)).find((candidate) => {
31794
31977
  try {
31795
- return statSync6(candidate).isFile();
31978
+ return statSync7(candidate).isFile();
31796
31979
  } catch {
31797
31980
  return false;
31798
31981
  }
@@ -31868,7 +32051,7 @@ async function downloadAndInstall(spec, tag, assets, platform3, arch, fetchImpl,
31868
32051
  }
31869
32052
  const pkgDir = ghPackageDir(spec);
31870
32053
  const extractDir = ghExtractDir(spec);
31871
- const archivePath = join16(pkgDir, expected.name);
32054
+ const archivePath = join17(pkgDir, expected.name);
31872
32055
  log2(`[lsp] downloading ${spec.id} ${tag} → ${matchingAsset.url}`);
31873
32056
  try {
31874
32057
  await downloadFile(matchingAsset.url, archivePath, fetchImpl, matchingAsset.size, signal);
@@ -31908,13 +32091,13 @@ async function downloadAndInstall(spec, tag, assets, platform3, arch, fetchImpl,
31908
32091
  unlinkSync6(archivePath);
31909
32092
  } catch {}
31910
32093
  }
31911
- const innerBinaryPath = join16(extractDir, spec.binaryPathInArchive(platform3, arch, version2));
31912
- if (!existsSync12(innerBinaryPath)) {
32094
+ const innerBinaryPath = join17(extractDir, spec.binaryPathInArchive(platform3, arch, version2));
32095
+ if (!existsSync13(innerBinaryPath)) {
31913
32096
  error2(`[lsp] ${spec.id}: extracted binary not found at ${innerBinaryPath}`);
31914
32097
  return null;
31915
32098
  }
31916
32099
  const targetBinary = ghBinaryPath(spec, platform3);
31917
- mkdirSync9(dirname7(targetBinary), { recursive: true });
32100
+ mkdirSync9(dirname8(targetBinary), { recursive: true });
31918
32101
  try {
31919
32102
  copyFileSync4(innerBinaryPath, targetBinary);
31920
32103
  if (platform3 !== "win32") {
@@ -31993,7 +32176,7 @@ function runGithubAutoInstall(relevantServers, config2, fetchImpl = fetch) {
31993
32176
  if (!host) {
31994
32177
  for (const spec of GITHUB_LSP_TABLE) {
31995
32178
  try {
31996
- if (existsSync12(ghBinDir(spec))) {
32179
+ if (existsSync13(ghBinDir(spec))) {
31997
32180
  cachedBinDirs.push(ghBinDir(spec));
31998
32181
  }
31999
32182
  } catch {}
@@ -32240,20 +32423,20 @@ function writeTerminal(terminal, data) {
32240
32423
 
32241
32424
  // src/shared/rpc-server.ts
32242
32425
  import { randomBytes as randomBytes2 } from "node:crypto";
32243
- import { mkdirSync as mkdirSync10, renameSync as renameSync8, unlinkSync as unlinkSync7, writeFileSync as writeFileSync9 } from "node:fs";
32426
+ import { mkdirSync as mkdirSync10, renameSync as renameSync8, unlinkSync as unlinkSync7, writeFileSync as writeFileSync10 } from "node:fs";
32244
32427
  import { createServer } from "node:http";
32245
- import { dirname as dirname8, join as join18 } from "node:path";
32428
+ import { dirname as dirname9, join as join19 } from "node:path";
32246
32429
 
32247
32430
  // src/shared/rpc-utils.ts
32248
32431
  import { createHash as createHash6 } from "node:crypto";
32249
- import { join as join17 } from "node:path";
32432
+ import { join as join18 } from "node:path";
32250
32433
  function projectHash(directory) {
32251
32434
  const normalized = directory.replace(/\/+$/, "");
32252
32435
  return createHash6("sha256").update(normalized).digest("hex").slice(0, 16);
32253
32436
  }
32254
32437
  function rpcPortFileDir(storageDir, directory) {
32255
32438
  const hash2 = projectHash(directory);
32256
- return join17(storageDir, "rpc", hash2, "ports");
32439
+ return join18(storageDir, "rpc", hash2, "ports");
32257
32440
  }
32258
32441
 
32259
32442
  // src/shared/rpc-server.ts
@@ -32268,7 +32451,7 @@ class AftRpcServer {
32268
32451
  constructor(storageDir, directory) {
32269
32452
  this.portsDir = rpcPortFileDir(storageDir, directory);
32270
32453
  this.instanceId = randomBytes2(8).toString("hex");
32271
- this.portFilePath = join18(this.portsDir, `${this.instanceId}.json`);
32454
+ this.portFilePath = join19(this.portsDir, `${this.instanceId}.json`);
32272
32455
  }
32273
32456
  handle(method, handler) {
32274
32457
  this.handlers.set(method, handler);
@@ -32290,10 +32473,10 @@ class AftRpcServer {
32290
32473
  this.token = randomBytes2(32).toString("hex");
32291
32474
  this.server = server;
32292
32475
  try {
32293
- const dir = dirname8(this.portFilePath);
32476
+ const dir = dirname9(this.portFilePath);
32294
32477
  mkdirSync10(dir, { recursive: true, mode: 448 });
32295
32478
  const tmpPath = `${this.portFilePath}.tmp`;
32296
- writeFileSync9(tmpPath, JSON.stringify({ port: this.port, token: this.token }), {
32479
+ writeFileSync10(tmpPath, JSON.stringify({ port: this.port, token: this.token }), {
32297
32480
  encoding: "utf-8",
32298
32481
  mode: 384
32299
32482
  });
@@ -32469,6 +32652,20 @@ function readCompression(value) {
32469
32652
  session: readCompressionAggregate(compression.session)
32470
32653
  };
32471
32654
  }
32655
+ function readStatusBar(value) {
32656
+ if (typeof value !== "object" || value === null)
32657
+ return;
32658
+ const bar = asRecord(value);
32659
+ return {
32660
+ errors: readNumber(bar.errors),
32661
+ warnings: readNumber(bar.warnings),
32662
+ dead_code: readNumber(bar.dead_code),
32663
+ unused_exports: readNumber(bar.unused_exports),
32664
+ duplicates: readNumber(bar.duplicates),
32665
+ todos: readNumber(bar.todos),
32666
+ tier2_stale: readBoolean(bar.tier2_stale)
32667
+ };
32668
+ }
32472
32669
  function formatFlag(enabled) {
32473
32670
  return enabled ? "enabled" : "disabled";
32474
32671
  }
@@ -32562,6 +32759,7 @@ function coerceAftStatus(response) {
32562
32759
  checkpoints: readNumber(session.checkpoints)
32563
32760
  },
32564
32761
  compression: readCompression(response.compression),
32762
+ status_bar: readStatusBar(response.status_bar),
32565
32763
  message: readString(response.message, "")
32566
32764
  };
32567
32765
  }
@@ -32617,6 +32815,10 @@ function formatStatusMarkdown(status) {
32617
32815
  if (status.storage_dir ?? status.disk.storage_dir) {
32618
32816
  lines.push(`- **Storage dir:** \`${status.storage_dir ?? status.disk.storage_dir}\``);
32619
32817
  }
32818
+ if (status.status_bar) {
32819
+ const sb = status.status_bar;
32820
+ lines.push("", `### Code Health${sb.tier2_stale ? " (~ stale)" : ""}`, `- **Errors:** ${formatCount(sb.errors)}`, `- **Warnings:** ${formatCount(sb.warnings)}`, `- **Duplicates:** ${formatCount(sb.duplicates)}`, `- **TODOs:** ${formatCount(sb.todos)}`);
32821
+ }
32620
32822
  lines.push("", "### Current session", `- **ID:** \`${status.session.id}\``, `- **Tracked files:** ${formatCount(status.session.tracked_files)}`, `- **Checkpoints:** ${formatCount(status.session.checkpoints)}`, `- **Project checkpoints (all sessions):** ${formatCount(status.checkpoints_total)}`);
32621
32823
  return lines.join(`
32622
32824
  `);
@@ -32624,21 +32826,21 @@ function formatStatusMarkdown(status) {
32624
32826
 
32625
32827
  // src/shared/tui-config.ts
32626
32828
  var import_comment_json4 = __toESM(require_src2(), 1);
32627
- 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";
32829
+ import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync13, writeFileSync as writeFileSync11 } from "node:fs";
32830
+ import { dirname as dirname10, join as join21 } from "node:path";
32629
32831
 
32630
32832
  // 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";
32833
+ import { homedir as homedir11 } from "node:os";
32834
+ import { join as join20, resolve as resolve4 } from "node:path";
32633
32835
  function getCliConfigDir() {
32634
32836
  const envConfigDir = process.env.OPENCODE_CONFIG_DIR?.trim();
32635
32837
  if (envConfigDir) {
32636
32838
  return resolve4(envConfigDir);
32637
32839
  }
32638
32840
  if (process.platform === "win32") {
32639
- return join19(homedir10(), ".config", "opencode");
32841
+ return join20(homedir11(), ".config", "opencode");
32640
32842
  }
32641
- return join19(process.env.XDG_CONFIG_HOME || join19(homedir10(), ".config"), "opencode");
32843
+ return join20(process.env.XDG_CONFIG_HOME || join20(homedir11(), ".config"), "opencode");
32642
32844
  }
32643
32845
  function getOpenCodeConfigDir2(_options) {
32644
32846
  return getCliConfigDir();
@@ -32647,10 +32849,10 @@ function getOpenCodeConfigPaths(options) {
32647
32849
  const configDir = getOpenCodeConfigDir2(options);
32648
32850
  return {
32649
32851
  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")
32852
+ configJson: join20(configDir, "opencode.json"),
32853
+ configJsonc: join20(configDir, "opencode.jsonc"),
32854
+ packageJson: join20(configDir, "package.json"),
32855
+ omoConfig: join20(configDir, "magic-context.jsonc")
32654
32856
  };
32655
32857
  }
32656
32858
 
@@ -32659,11 +32861,11 @@ var PLUGIN_NAME = "@cortexkit/aft-opencode";
32659
32861
  var PLUGIN_ENTRY = `${PLUGIN_NAME}@latest`;
32660
32862
  function resolveTuiConfigPath() {
32661
32863
  const configDir = getOpenCodeConfigPaths({ binary: "opencode" }).configDir;
32662
- const jsoncPath = join20(configDir, "tui.jsonc");
32663
- const jsonPath = join20(configDir, "tui.json");
32664
- if (existsSync13(jsoncPath))
32864
+ const jsoncPath = join21(configDir, "tui.jsonc");
32865
+ const jsonPath = join21(configDir, "tui.json");
32866
+ if (existsSync14(jsoncPath))
32665
32867
  return jsoncPath;
32666
- if (existsSync13(jsonPath))
32868
+ if (existsSync14(jsonPath))
32667
32869
  return jsonPath;
32668
32870
  return jsonPath;
32669
32871
  }
@@ -32671,7 +32873,7 @@ function ensureTuiPluginEntry() {
32671
32873
  try {
32672
32874
  const configPath = resolveTuiConfigPath();
32673
32875
  let config2 = {};
32674
- if (existsSync13(configPath)) {
32876
+ if (existsSync14(configPath)) {
32675
32877
  config2 = import_comment_json4.parse(readFileSync13(configPath, "utf-8")) ?? {};
32676
32878
  }
32677
32879
  const plugins = Array.isArray(config2.plugin) ? config2.plugin.filter((value) => typeof value === "string") : [];
@@ -32680,8 +32882,8 @@ function ensureTuiPluginEntry() {
32680
32882
  }
32681
32883
  plugins.push(PLUGIN_ENTRY);
32682
32884
  config2.plugin = plugins;
32683
- mkdirSync11(dirname9(configPath), { recursive: true });
32684
- writeFileSync10(configPath, `${import_comment_json4.stringify(config2, null, 2)}
32885
+ mkdirSync11(dirname10(configPath), { recursive: true });
32886
+ writeFileSync11(configPath, `${import_comment_json4.stringify(config2, null, 2)}
32685
32887
  `);
32686
32888
  log2(`[aft-plugin] added TUI plugin entry to ${configPath}`);
32687
32889
  return true;
@@ -32768,6 +32970,7 @@ import { tool as tool3 } from "@opencode-ai/plugin";
32768
32970
 
32769
32971
  // src/tools/_shared.ts
32770
32972
  import * as fs3 from "node:fs";
32973
+ import * as os2 from "node:os";
32771
32974
  import * as path2 from "node:path";
32772
32975
  import { tool as tool2 } from "@opencode-ai/plugin";
32773
32976
  var z2 = tool2.schema;
@@ -32880,8 +33083,19 @@ async function resolveProjectRoot(ctx, runtime) {
32880
33083
  }
32881
33084
  return projectRootFor(runtime);
32882
33085
  }
33086
+ function expandTilde(input) {
33087
+ if (!input || !input.startsWith("~"))
33088
+ return input;
33089
+ if (input === "~")
33090
+ return os2.homedir();
33091
+ if (input.startsWith("~/") || input.startsWith(`~${path2.sep}`)) {
33092
+ return path2.resolve(os2.homedir(), input.slice(2));
33093
+ }
33094
+ return input;
33095
+ }
32883
33096
  function resolvePathFromProjectRoot(projectRoot, target) {
32884
- return path2.isAbsolute(target) ? target : path2.resolve(projectRoot, target);
33097
+ const expanded = expandTilde(target);
33098
+ return path2.isAbsolute(expanded) ? expanded : path2.resolve(projectRoot, expanded);
32885
33099
  }
32886
33100
  async function resolvePathArg(ctx, runtime, target) {
32887
33101
  return resolvePathFromProjectRoot(await resolveProjectRoot(ctx, runtime), target);
@@ -34962,7 +35176,7 @@ function createEditTool(ctx, writeToolName = "write") {
34962
35176
  if (response.success === false) {
34963
35177
  throw new Error(response.message ?? "transaction failed");
34964
35178
  }
34965
- return JSON.stringify(response);
35179
+ return formatEditSummary(response);
34966
35180
  }
34967
35181
  const file2 = args.filePath;
34968
35182
  if (!file2)
@@ -35049,12 +35263,7 @@ function createEditTool(ctx, writeToolName = "write") {
35049
35263
  });
35050
35264
  }
35051
35265
  }
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);
35266
+ let result = formatEditSummary(data);
35058
35267
  const globSkipNote = formatGlobSkipReasonsNote(data.format_skip_reasons);
35059
35268
  if (globSkipNote)
35060
35269
  result += `
@@ -36597,18 +36806,7 @@ function safetyTools(ctx) {
36597
36806
 
36598
36807
  // src/tools/search.ts
36599
36808
  import * as fs7 from "node:fs";
36600
- import * as os2 from "node:os";
36601
36809
  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
36810
  function arg2(schema) {
36613
36811
  return schema;
36614
36812
  }
@@ -36822,6 +37020,14 @@ function semanticHonestyNote(response) {
36822
37020
  notes.push("partial/incomplete");
36823
37021
  return notes.length > 0 ? `Search status: ${notes.join("; ")}.` : undefined;
36824
37022
  }
37023
+ function extraHonestyNote(response) {
37024
+ const notes = [];
37025
+ if (response.fully_degraded === true)
37026
+ notes.push("fully degraded");
37027
+ if (response.complete === false)
37028
+ notes.push("partial/incomplete");
37029
+ return notes.length > 0 ? `Search status: ${notes.join("; ")}.` : undefined;
37030
+ }
36825
37031
  function arg3(schema) {
36826
37032
  return schema;
36827
37033
  }
@@ -36873,24 +37079,12 @@ function semanticTools(ctx) {
36873
37079
  const code = typeof response.code === "string" && response.code.length > 0 ? response.code : undefined;
36874
37080
  throw new Error(code ? `semantic_search: ${code} — ${message}` : message);
36875
37081
  }
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
37082
  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}`;
37083
+ const note = extraHonestyNote(response);
37084
+ return note ? `${response.text}
37085
+ ${note}` : response.text;
36889
37086
  }
36890
- return honestyNote ? `${honestyNote}
36891
-
36892
- Structured response:
36893
- ${structured}` : structured;
37087
+ return semanticHonestyNote(response) ?? "No results.";
36894
37088
  }
36895
37089
  };
36896
37090
  return {
@@ -37117,14 +37311,12 @@ var PLUGIN_VERSION = (() => {
37117
37311
  return "0.0.0";
37118
37312
  }
37119
37313
  })();
37120
- var ANNOUNCEMENT_VERSION = "0.35.0";
37314
+ var ANNOUNCEMENT_VERSION = "0.35.3";
37121
37315
  var ANNOUNCEMENT_FEATURES = [
37122
- "Leaner semantic indexing local embedding now uses about half the CPU and a fraction of the peak memory, with no change to results and no re-index needed.",
37123
- "New IDE-style status bar on tool results live LSP errors/warnings plus dead-code, unused-export, duplicate, and TODO counts at a glance.",
37124
- "`aft_inspect` is more accurate (dead-code reachability, duplicate collapse, ranked findings) and a background scheduler keeps its counts fresh during long sessions.",
37125
- "The TUI sidebar is now collapsible click the `AFT` header to toggle a condensed view.",
37126
- "`npx @cortexkit/aft --version` reports CLI, binary, and per-harness versions; `doctor --issue` can scope its report to a single session.",
37127
- "New SCSS support and `.inc` files parsed as PHP."
37316
+ "Code Health in the TUI sidebar and `/aft-status`: live LSP errors and warnings plus duplicate and TODO counts, shown as at-a-glance traffic lights when the sidebar is collapsed.",
37317
+ "The semantic index now recovers on its own from a transient embedding-backend blip (a restarted local server, or a model still loading) instead of getting stuck on `failed`.",
37318
+ "Fixed a background codebase-scan crash on very deep or minified files.",
37319
+ "More reliable LSP auto-install when a parent directory has its own `package.json`."
37128
37320
  ];
37129
37321
  var ANNOUNCEMENT_FOOTER = "Join us on Discord: https://discord.gg/DSa65w8wuf";
37130
37322
  var plugin = async (input) => initializePluginForDirectory(input);