@cortexkit/aft-opencode 0.19.0 → 0.19.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"bg-notifications.d.ts","sourceRoot":"","sources":["../src/bg-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,KAAK,cAAc,GAAG;IACpB,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,kBAAkB,EAAE,YAAY,EAAE,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACrC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,wBAAwB,EAAE,MAAM,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kBAAkB,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,YAAY,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5E,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAa,CAAC;AAG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AAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAgB/E;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,WAAW,EAAE,OAAO,GACnB,YAAY,EAAE,CAoBhB;AAED,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,YAAY,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,EAChD,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GACtC,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAsB,uBAAuB,CAC3C,YAAY,EAAE,YAAY,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAC/C,OAAO,CAAC,IAAI,CAAC,CAEf;AA2ED,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAE/D;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CASjF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAcnE;AAED,wBAAgB,kCAAkC,IAAI,IAAI,CAKzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA+JlD;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,MAAM,EAAE,MA2oBb,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA+JlD;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,MAAM,EAAE,MA4sBb,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/dist/index.js CHANGED
@@ -7847,6 +7847,9 @@ import { join } from "path";
7847
7847
  var DEFAULT_BRIDGE_TIMEOUT_MS = 30000;
7848
7848
  var SEMANTIC_TIMEOUT_SAFETY_MARGIN_MS = 5000;
7849
7849
  var MAX_STDOUT_BUFFER = 64 * 1024 * 1024;
7850
+ function tagStderrLine(line) {
7851
+ return /^\[aft(-\w+)?\] /.test(line) ? line : `[aft] ${line}`;
7852
+ }
7850
7853
  function compareSemver(a, b) {
7851
7854
  const [aMain, aPre] = a.split("-", 2);
7852
7855
  const [bMain, bPre] = b.split("-", 2);
@@ -8167,9 +8170,9 @@ class BinaryBridge {
8167
8170
  for (const line of lines) {
8168
8171
  if (!line)
8169
8172
  continue;
8170
- const stripped = line.replace(/^\[aft\]\s*/, "");
8171
- log(`[aft] ${stripped}`);
8172
- this.pushStderrLine(stripped);
8173
+ const tagged = tagStderrLine(line);
8174
+ log(tagged);
8175
+ this.pushStderrLine(tagged);
8173
8176
  }
8174
8177
  });
8175
8178
  child.on("error", (err) => {
@@ -8507,7 +8510,7 @@ var MAX_DOWNLOAD_BYTES = 256 * 1024 * 1024;
8507
8510
  var MAX_EXTRACT_BYTES = 1 * 1024 * 1024 * 1024;
8508
8511
  var ONNX_LOCK_FILE = ".aft-onnx-installing";
8509
8512
  var ONNX_INSTALLED_META_FILE = ".aft-onnx-installed";
8510
- var STALE_LOCK_MS = 30 * 60 * 1000;
8513
+ var STALE_LOCK_MS = 5 * 60 * 1000;
8511
8514
  var ORT_PLATFORM_MAP = {
8512
8515
  darwin: {
8513
8516
  arm64: {
@@ -8595,6 +8598,7 @@ async function ensureOnnxRuntime(storageDir) {
8595
8598
  const onnxBaseDir = join3(storageDir, "onnxruntime");
8596
8599
  mkdirSync2(onnxBaseDir, { recursive: true });
8597
8600
  const lockPath = join3(onnxBaseDir, ONNX_LOCK_FILE);
8601
+ cleanupAbandonedOnnxAttempts(onnxBaseDir, ortDir);
8598
8602
  if (!acquireLock(lockPath)) {
8599
8603
  warn(`ONNX Runtime install already in progress in another process (lock: ${lockPath}). Skipping.`);
8600
8604
  return null;
@@ -8605,6 +8609,51 @@ async function ensureOnnxRuntime(storageDir) {
8605
8609
  releaseLock(lockPath);
8606
8610
  }
8607
8611
  }
8612
+ function cleanupAbandonedOnnxAttempts(onnxBaseDir, ortDir) {
8613
+ try {
8614
+ const entries = readdirSync(onnxBaseDir);
8615
+ const ortDirBaseName = ortDir.slice(onnxBaseDir.length + 1);
8616
+ for (const entry of entries) {
8617
+ if (!entry.startsWith(`${ortDirBaseName}.tmp.`))
8618
+ continue;
8619
+ const stagingDir = join3(onnxBaseDir, entry);
8620
+ const parts = entry.split(".");
8621
+ const pidStr = parts[parts.length - 2];
8622
+ const pid = pidStr ? Number.parseInt(pidStr, 10) : NaN;
8623
+ let abandoned = false;
8624
+ if (Number.isFinite(pid) && pid > 0) {
8625
+ if (process.platform === "win32") {
8626
+ try {
8627
+ const ageMs = Date.now() - statSync(stagingDir).mtimeMs;
8628
+ abandoned = ageMs > STALE_LOCK_MS;
8629
+ } catch {
8630
+ abandoned = true;
8631
+ }
8632
+ } else {
8633
+ abandoned = !isProcessAlive(pid);
8634
+ }
8635
+ } else {
8636
+ abandoned = true;
8637
+ }
8638
+ if (abandoned) {
8639
+ log(`[onnx] removing abandoned staging dir ${stagingDir}`);
8640
+ try {
8641
+ rmSync(stagingDir, { recursive: true, force: true });
8642
+ } catch (err) {
8643
+ warn(`[onnx] failed to remove ${stagingDir}: ${err}`);
8644
+ }
8645
+ }
8646
+ }
8647
+ } catch {}
8648
+ try {
8649
+ if (existsSync2(ortDir) && !existsSync2(join3(ortDir, ONNX_INSTALLED_META_FILE))) {
8650
+ log(`[onnx] removing half-populated install dir ${ortDir} (no meta file)`);
8651
+ rmSync(ortDir, { recursive: true, force: true });
8652
+ }
8653
+ } catch (err) {
8654
+ warn(`[onnx] failed to sweep ${ortDir}: ${err}`);
8655
+ }
8656
+ }
8608
8657
  function findSystemOnnxRuntime(libName) {
8609
8658
  if (!libName)
8610
8659
  return null;
@@ -9016,9 +9065,19 @@ class BridgePool {
9016
9065
  await Promise.allSettled(shutdowns);
9017
9066
  log(`Binary path updated to ${newPath}. All bridges cleared \u2014 next calls will use the new binary.`);
9018
9067
  }
9068
+ setConfigureOverride(key, value) {
9069
+ if (value === undefined) {
9070
+ delete this.configOverrides[key];
9071
+ } else {
9072
+ this.configOverrides[key] = value;
9073
+ }
9074
+ }
9019
9075
  get size() {
9020
9076
  return this.bridges.size;
9021
9077
  }
9078
+ _testGetConfigOverrides() {
9079
+ return { ...this.configOverrides };
9080
+ }
9022
9081
  }
9023
9082
  function normalizeKey(projectRoot) {
9024
9083
  const stripped = projectRoot.replace(/[/\\]+$/, "");
@@ -9266,15 +9325,24 @@ async function assertPublicUrl(url, allowPrivate, dnsLookup = lookup) {
9266
9325
  if (addresses.length === 0) {
9267
9326
  throw new Error(`Failed to resolve URL host ${url.hostname}`);
9268
9327
  }
9269
- return addresses[0].address;
9328
+ const ipv4 = addresses.find((entry) => entry.family === 4 || entry.family === "IPv4" || typeof entry.address === "string" && isIP(entry.address) === 4);
9329
+ const chosen = ipv4 ?? addresses[0];
9330
+ if (!chosen || typeof chosen.address !== "string" || chosen.address.length === 0) {
9331
+ throw new Error(`DNS lookup for ${url.hostname} returned no usable address (got: ${JSON.stringify(addresses)})`);
9332
+ }
9333
+ return chosen.address;
9270
9334
  }
9271
9335
  function createPinnedDispatcher(validatedIp) {
9272
- return new Agent({
9273
- connect: {
9274
- lookup: (_hostname, _opts, callback) => {
9275
- callback(null, validatedIp, validatedIp.includes(":") ? 6 : 4);
9276
- }
9336
+ const family = validatedIp.includes(":") ? 6 : 4;
9337
+ const pinnedLookup = (_hostname, opts, callback) => {
9338
+ if (opts?.all) {
9339
+ callback(null, [{ address: validatedIp, family }]);
9340
+ } else {
9341
+ callback(null, validatedIp, family);
9277
9342
  }
9343
+ };
9344
+ return new Agent({
9345
+ connect: { lookup: pinnedLookup }
9278
9346
  });
9279
9347
  }
9280
9348
  function resolveRedirectUrl(currentUrl, location) {
@@ -9304,7 +9372,19 @@ async function fetchWithRedirects(startUrl, allowPrivate, deps = {}) {
9304
9372
  }
9305
9373
  });
9306
9374
  } catch (err) {
9307
- throw new Error(`Failed to fetch ${currentUrl.href}: ${err.message}`);
9375
+ const error2 = err;
9376
+ const cause = error2.cause;
9377
+ const causeCode = cause?.code ?? error2.code;
9378
+ const causeMsg = cause?.message ?? "";
9379
+ const detail = causeCode ? causeMsg ? `${causeCode}: ${causeMsg}` : causeCode : error2.message ?? "unknown error";
9380
+ warn(`URL fetch failed: ${currentUrl.href} \u2014 ${detail}`, {
9381
+ outerMessage: error2.message,
9382
+ causeName: cause?.name,
9383
+ causeCode,
9384
+ causeErrno: cause?.errno,
9385
+ causeSyscall: cause?.syscall
9386
+ });
9387
+ throw new Error(`Failed to fetch ${currentUrl.href}: ${detail}`);
9308
9388
  } finally {
9309
9389
  clearTimeout(timer);
9310
9390
  }
@@ -9447,6 +9527,56 @@ function cleanupUrlCache(storageDir) {
9447
9527
  log(`URL cache cleanup: removed ${removed} stale entries`);
9448
9528
  }
9449
9529
  }
9530
+ // ../aft-bridge/dist/zoom-format.js
9531
+ function formatZoomText(targetLabel, response) {
9532
+ const range = response.range;
9533
+ const startLine = range?.start_line ?? 1;
9534
+ const endLine = range?.end_line ?? startLine;
9535
+ const kind = response.kind ?? "symbol";
9536
+ const name = response.name ?? "";
9537
+ const contentText = typeof response.content === "string" ? response.content : "";
9538
+ const ctxBefore = Array.isArray(response.context_before) ? response.context_before : [];
9539
+ const ctxAfter = Array.isArray(response.context_after) ? response.context_after : [];
9540
+ const header = kind === "lines" ? `${targetLabel}:${startLine}-${endLine}` : `${targetLabel}:${startLine}-${endLine} [${kind} ${name}]`.trimEnd();
9541
+ const contentLines = contentText.split(`
9542
+ `);
9543
+ if (contentLines.length > 0 && contentLines[contentLines.length - 1] === "") {
9544
+ contentLines.pop();
9545
+ }
9546
+ const lastDisplayedLine = endLine + ctxAfter.length;
9547
+ const gutterWidth = String(Math.max(lastDisplayedLine, 1)).length;
9548
+ const fmt = (lineNo2, text) => `${String(lineNo2).padStart(gutterWidth)}: ${text}`;
9549
+ const out = [header, ""];
9550
+ let lineNo = startLine - ctxBefore.length;
9551
+ for (const text of ctxBefore) {
9552
+ out.push(fmt(lineNo, text));
9553
+ lineNo += 1;
9554
+ }
9555
+ for (const text of contentLines) {
9556
+ out.push(fmt(lineNo, text));
9557
+ lineNo += 1;
9558
+ }
9559
+ for (const text of ctxAfter) {
9560
+ out.push(fmt(lineNo, text));
9561
+ lineNo += 1;
9562
+ }
9563
+ const callsOut = response.annotations?.calls_out ?? [];
9564
+ const calledBy = response.annotations?.called_by ?? [];
9565
+ if (callsOut.length > 0) {
9566
+ out.push("", "\u2500\u2500\u2500\u2500 calls_out");
9567
+ for (const ref of callsOut) {
9568
+ out.push(` ${ref.name} (line ${ref.line})`);
9569
+ }
9570
+ }
9571
+ if (calledBy.length > 0) {
9572
+ out.push("", "\u2500\u2500\u2500\u2500 called_by");
9573
+ for (const ref of calledBy) {
9574
+ out.push(` ${ref.name} (line ${ref.line})`);
9575
+ }
9576
+ }
9577
+ return out.join(`
9578
+ `);
9579
+ }
9450
9580
  // src/logger.ts
9451
9581
  import * as fs from "fs";
9452
9582
  import * as os from "os";
@@ -9696,8 +9826,6 @@ async function handleIdleBgCompletions(drainContext) {
9696
9826
  }
9697
9827
  async function triggerWakeIfPending(drainContext, skipDrain) {
9698
9828
  const state = stateFor(drainContext.sessionID);
9699
- if (state.wakeFiredThisIdle)
9700
- return;
9701
9829
  if (drainContext.isActive?.())
9702
9830
  return;
9703
9831
  if (!skipDrain && state.outstandingTaskIds.size > 0) {
@@ -27409,7 +27537,7 @@ function createBashTool(ctx) {
27409
27537
  const callID2 = getCallID(context);
27410
27538
  const taskId = data.task_id;
27411
27539
  trackBgTask(context.sessionID, taskId);
27412
- const startedLine = `Background task started: ${taskId}`;
27540
+ const startedLine = `Background task started: ${taskId}. A completion reminder will be delivered automatically; don't poll bash_status.`;
27413
27541
  const metadataPayload2 = { description, output: startedLine, status: "running", taskId };
27414
27542
  metadata?.(metadataPayload2);
27415
27543
  if (callID2) {
@@ -27479,6 +27607,10 @@ function createBashStatusTool(ctx) {
27479
27607
  if (preview && status !== "running") {
27480
27608
  text += `
27481
27609
  ${preview.slice(0, 2000)}`;
27610
+ }
27611
+ if (status === "running") {
27612
+ text += `
27613
+ A completion reminder will be delivered automatically; don't poll.`;
27482
27614
  }
27483
27615
  return text;
27484
27616
  }
@@ -28553,10 +28685,7 @@ function createMoveTool(ctx) {
28553
28685
  };
28554
28686
  }
28555
28687
  function hoistedTools(ctx) {
28556
- return {
28557
- bash: createBashTool(ctx),
28558
- bash_status: createBashStatusTool(ctx),
28559
- bash_kill: createBashKillTool(ctx),
28688
+ const tools = {
28560
28689
  read: createReadTool(ctx),
28561
28690
  write: createWriteTool(ctx, "edit"),
28562
28691
  edit: createEditTool(ctx, "write"),
@@ -28564,6 +28693,18 @@ function hoistedTools(ctx) {
28564
28693
  aft_delete: createDeleteTool(ctx),
28565
28694
  aft_move: createMoveTool(ctx)
28566
28695
  };
28696
+ const bashRewrite = ctx.config.experimental?.bash?.rewrite === true;
28697
+ const bashCompress = ctx.config.experimental?.bash?.compress === true;
28698
+ const bashBackground = ctx.config.experimental?.bash?.background === true;
28699
+ const anyBashExperimental = bashRewrite || bashCompress || bashBackground;
28700
+ if (anyBashExperimental) {
28701
+ tools.bash = createBashTool(ctx);
28702
+ }
28703
+ if (bashBackground) {
28704
+ tools.bash_status = createBashStatusTool(ctx);
28705
+ tools.bash_kill = createBashKillTool(ctx);
28706
+ }
28707
+ return tools;
28567
28708
  }
28568
28709
  function formatError2(error50) {
28569
28710
  return error50 instanceof Error ? error50.message : String(error50);
@@ -28871,6 +29012,7 @@ Provide exactly ONE of 'filePath' or 'url'. Pass either 'symbol' for a single lo
28871
29012
  const file2 = hasUrl ? await fetchUrlToTempFile(args.url, ctx.storageDir, {
28872
29013
  allowPrivate: ctx.config.url_fetch_allow_private === true
28873
29014
  }) : args.filePath;
29015
+ const targetLabel = (hasUrl ? args.url : args.filePath) ?? file2;
28874
29016
  if (Array.isArray(args.symbols) && args.symbols.length > 0) {
28875
29017
  const results = await Promise.all(args.symbols.map((sym) => {
28876
29018
  const params2 = { file: file2, symbol: sym };
@@ -28881,7 +29023,7 @@ Provide exactly ONE of 'filePath' or 'url'. Pass either 'symbol' for a single lo
28881
29023
  message: err instanceof Error ? err.message : String(err)
28882
29024
  }));
28883
29025
  }));
28884
- return JSON.stringify(formatZoomBatchResult(args.symbols, results), null, 2);
29026
+ return formatZoomBatchResult(targetLabel, args.symbols, results).text;
28885
29027
  }
28886
29028
  const params = { file: file2 };
28887
29029
  if (typeof args.symbol === "string")
@@ -28892,45 +29034,36 @@ Provide exactly ONE of 'filePath' or 'url'. Pass either 'symbol' for a single lo
28892
29034
  if (data.success === false) {
28893
29035
  throw new Error(data.message || "zoom failed");
28894
29036
  }
28895
- return JSON.stringify(data);
29037
+ return formatZoomText(targetLabel, data);
28896
29038
  }
28897
29039
  }
28898
29040
  };
28899
29041
  }
28900
- function formatZoomBatchResult(symbols, responses) {
29042
+ function formatZoomBatchResult(targetLabel, symbols, responses) {
28901
29043
  const entries = symbols.map((name, index) => {
28902
29044
  const response = responses[index] ?? { success: false, message: "missing zoom response" };
28903
29045
  if (response.success === false) {
28904
29046
  const message = typeof response.message === "string" && response.message.length > 0 ? response.message : "zoom failed";
28905
29047
  return { name, success: false, error: message };
28906
29048
  }
28907
- return { name, success: true, content: zoomResponseContent(response) };
29049
+ return { name, success: true, content: formatZoomText(targetLabel, response) };
28908
29050
  });
28909
29051
  const complete = entries.every((entry) => entry.success);
28910
- const lines = [];
29052
+ const sections = [];
28911
29053
  if (!complete) {
28912
- lines.push("Incomplete zoom results: one or more symbols failed.");
29054
+ sections.push("Incomplete zoom results: one or more symbols failed.");
28913
29055
  }
28914
29056
  for (const entry of entries) {
28915
29057
  if (entry.success) {
28916
- lines.push(`Symbol "${entry.name}":
28917
- ${entry.content ?? ""}`.trimEnd());
29058
+ sections.push(entry.content ?? "");
28918
29059
  } else {
28919
- lines.push(`Symbol "${entry.name}" not found: ${entry.error ?? "zoom failed"}`);
29060
+ sections.push(`Symbol "${entry.name}" not found: ${entry.error ?? "zoom failed"}`);
28920
29061
  }
28921
29062
  }
28922
- return { complete, symbols: entries, text: lines.join(`
29063
+ return { complete, symbols: entries, text: sections.join(`
28923
29064
 
28924
29065
  `) };
28925
29066
  }
28926
- function zoomResponseContent(response) {
28927
- if (typeof response.content === "string")
28928
- return response.content;
28929
- if (typeof response.text === "string")
28930
- return response.text;
28931
- const { success: _success2, ...rest } = response;
28932
- return JSON.stringify(rest, null, 2);
28933
- }
28934
29067
  function formatOutlineText(response) {
28935
29068
  const text = response.text ?? "";
28936
29069
  const skipped = response.skipped_files;
@@ -29478,7 +29611,7 @@ function buildWorkflowHints(opts) {
29478
29611
  }
29479
29612
  if (hasBash) {
29480
29613
  if (hasBgBash) {
29481
- sections.push(`**Long-running commands** (builds, installs, full test suites): \`${bashName}({ background: true })\` returns immediately with a \`taskId\`. Check progress with \`${bashStatusName}({ taskId })\`.`);
29614
+ sections.push(`**Long-running commands** (builds, installs, full test suites): \`${bashName}({ background: true })\` returns immediately with a \`taskId\`. A completion reminder is delivered automatically \u2014 do not poll \`${bashStatusName}({ taskId })\`. Use \`${bashStatusName}\` only after the reminder arrives, or to inspect a task you already know is complete.`);
29482
29615
  } else {
29483
29616
  sections.push(`**Long-running bash commands**: foreground \`${bashName}\` times out after 30 seconds. Pass \`timeout\` in milliseconds to extend it for commands you know will take longer.`);
29484
29617
  }
@@ -29610,17 +29743,13 @@ var plugin = async (input) => {
29610
29743
  const isFastembedSemanticBackend = (aftConfig.semantic?.backend ?? "fastembed") === "fastembed";
29611
29744
  const dataHome = process.env.XDG_DATA_HOME || join18(homedir10(), ".local", "share");
29612
29745
  configOverrides.storage_dir = join18(dataHome, "opencode", "storage", "plugin", "aft");
29746
+ let onnxRuntimePromise = null;
29613
29747
  if (aftConfig.semantic_search && isFastembedSemanticBackend) {
29614
29748
  const storageDir2 = configOverrides.storage_dir;
29615
- const ortDylibDir = await ensureOnnxRuntime(storageDir2).catch((err) => {
29749
+ onnxRuntimePromise = ensureOnnxRuntime(storageDir2).catch((err) => {
29616
29750
  warn2(`ONNX Runtime setup failed: ${err instanceof Error ? err.message : String(err)}. Semantic search will be unavailable.`);
29617
29751
  return null;
29618
29752
  });
29619
- if (ortDylibDir) {
29620
- configOverrides._ort_dylib_dir = ortDylibDir;
29621
- } else if (!isOrtAutoDownloadSupported()) {
29622
- warn2(`Semantic search requires ONNX Runtime. Install: ${getManualInstallHint()}`);
29623
- }
29624
29753
  }
29625
29754
  try {
29626
29755
  const lspAutoInstall = aftConfig.lsp?.auto_install ?? true;
@@ -29742,8 +29871,26 @@ ${lines}
29742
29871
  storageDir: configOverrides.storage_dir
29743
29872
  };
29744
29873
  setSharedBridgePool(pool);
29874
+ if (onnxRuntimePromise) {
29875
+ onnxRuntimePromise.then((ortDylibDir) => {
29876
+ if (ortDylibDir) {
29877
+ pool.setConfigureOverride("_ort_dylib_dir", ortDylibDir);
29878
+ log2(`ONNX Runtime ready at ${ortDylibDir}; new bridges will load semantic backend.`);
29879
+ } else if (!isOrtAutoDownloadSupported()) {
29880
+ log2(`ONNX Runtime auto-download not supported on ${process.platform}/${process.arch}.`);
29881
+ }
29882
+ }, (err) => {
29883
+ warn2(`ONNX Runtime resolution rejected unexpectedly: ${err}`);
29884
+ });
29885
+ }
29745
29886
  (async () => {
29746
29887
  try {
29888
+ if (onnxRuntimePromise) {
29889
+ await Promise.race([
29890
+ onnxRuntimePromise,
29891
+ new Promise((resolve9) => setTimeout(() => resolve9(null), 60000))
29892
+ ]);
29893
+ }
29747
29894
  const bridge = pool.getBridge(input.directory);
29748
29895
  await bridge.send("status", {}, { configureWarningClient: input.client });
29749
29896
  } catch (err) {
@@ -29833,13 +29980,13 @@ Install: ${getManualInstallHint()}`);
29833
29980
  sendFeatureAnnouncement(notifyOpts, ANNOUNCEMENT_VERSION, ANNOUNCEMENT_FEATURES, storageDir).catch(() => {});
29834
29981
  }, 8000);
29835
29982
  }
29836
- if (aftConfig.semantic_search && isFastembedSemanticBackend && !configOverrides._ort_dylib_dir) {
29837
- setTimeout(() => {
29838
- if (!configOverrides._ort_dylib_dir && !isOrtAutoDownloadSupported()) {
29983
+ if (onnxRuntimePromise) {
29984
+ onnxRuntimePromise.then((ortDylibDir) => {
29985
+ if (!ortDylibDir && !isOrtAutoDownloadSupported()) {
29839
29986
  sendWarning(notifyOpts, `Semantic search requires ONNX Runtime.
29840
29987
  Install: ${getManualInstallHint()}`).catch(() => {});
29841
29988
  }
29842
- }, 5000);
29989
+ }, () => {});
29843
29990
  } else {
29844
29991
  cleanupWarnings(notifyOpts).catch(() => {});
29845
29992
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAsDjD,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CAoJjE;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CA4BvE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CAmBrE"}
1
+ {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAsDjD,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CA6JjE;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CAqCvE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CAmBrE"}
@@ -18,7 +18,15 @@ export declare const _buildUnifiedDiffForTest: (fp: string, before: string, afte
18
18
  export declare function createReadTool(ctx: PluginContext): ToolDefinition;
19
19
  /**
20
20
  * Returns hoisted tools keyed by opencode's built-in names.
21
- * Overrides: read, write, edit, apply_patch.
21
+ * Overrides: read, write, edit, apply_patch (always when hoisting is on).
22
+ *
23
+ * Bash hoisting is opt-in: `bash`, `bash_status`, and `bash_kill` are only
24
+ * registered when at least one `experimental.bash.*` flag is enabled
25
+ * (rewrite, compress, or background). When all flags are off, opencode's
26
+ * native bash stays in place — users without bash experimentals get zero
27
+ * AFT code in their bash path. `bash_status` and `bash_kill` register
28
+ * specifically when `experimental.bash.background` is true, since those
29
+ * tools only have meaning for background tasks.
22
30
  */
23
31
  export declare function hoistedTools(ctx: PluginContext): Record<string, ToolDefinition>;
24
32
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"hoisted.d.ts","sourceRoot":"","sources":["../../src/tools/hoisted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAkEjD,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,GAAI,IAAI,MAAM,EAAE,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAChD,CAAC;AAqRtC;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CAgJjE;AAqgCD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAY/E;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAmEnF"}
1
+ {"version":3,"file":"hoisted.d.ts","sourceRoot":"","sources":["../../src/tools/hoisted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAkEjD,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,GAAI,IAAI,MAAM,EAAE,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAChD,CAAC;AAqRtC;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CAgJjE;AAqgCD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA0B/E;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAmEnF"}
@@ -15,7 +15,13 @@ interface ZoomBatchResult {
15
15
  * Tool definitions for code reading commands: outline + zoom.
16
16
  */
17
17
  export declare function readingTools(ctx: PluginContext): Record<string, ToolDefinition>;
18
- /** Exported for regression tests. */
19
- export declare function formatZoomBatchResult(symbols: string[], responses: Record<string, unknown>[]): ZoomBatchResult;
18
+ /**
19
+ * Format multi-symbol zoom results as plain text. Successful entries use
20
+ * `formatZoomText` (line-numbered, no JSON escapes); failures render as
21
+ * `Symbol "name" not found: <reason>`. Sections are blank-line separated.
22
+ *
23
+ * Exported for regression tests.
24
+ */
25
+ export declare function formatZoomBatchResult(targetLabel: string, symbols: string[], responses: Record<string, unknown>[]): ZoomBatchResult;
20
26
  export {};
21
27
  //# sourceMappingURL=reading.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reading.d.ts","sourceRoot":"","sources":["../../src/tools/reading.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAwJ/E;AAED,qCAAqC;AACrC,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACnC,eAAe,CA0BjB"}
1
+ {"version":3,"file":"reading.d.ts","sourceRoot":"","sources":["../../src/tools/reading.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA2J/E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACnC,eAAe,CAyBjB"}
package/dist/tui.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // package.json
3
3
  var package_default = {
4
4
  name: "@cortexkit/aft-opencode",
5
- version: "0.19.0",
5
+ version: "0.19.1",
6
6
  type: "module",
7
7
  description: "OpenCode plugin for Agent File Tools (AFT) \u2014 tree-sitter and lsp powered code analysis",
8
8
  main: "dist/index.js",
@@ -30,7 +30,7 @@ var package_default = {
30
30
  },
31
31
  dependencies: {
32
32
  "@clack/prompts": "^1.2.0",
33
- "@cortexkit/aft-bridge": "0.19.0",
33
+ "@cortexkit/aft-bridge": "0.19.1",
34
34
  "@opencode-ai/plugin": "^1.2.26",
35
35
  "@opencode-ai/sdk": "^1.2.26",
36
36
  "comment-json": "^4.6.2",
@@ -38,11 +38,11 @@ var package_default = {
38
38
  zod: "^4.1.8"
39
39
  },
40
40
  optionalDependencies: {
41
- "@cortexkit/aft-darwin-arm64": "0.19.0",
42
- "@cortexkit/aft-darwin-x64": "0.19.0",
43
- "@cortexkit/aft-linux-arm64": "0.19.0",
44
- "@cortexkit/aft-linux-x64": "0.19.0",
45
- "@cortexkit/aft-win32-x64": "0.19.0"
41
+ "@cortexkit/aft-darwin-arm64": "0.19.1",
42
+ "@cortexkit/aft-darwin-x64": "0.19.1",
43
+ "@cortexkit/aft-linux-arm64": "0.19.1",
44
+ "@cortexkit/aft-linux-x64": "0.19.1",
45
+ "@cortexkit/aft-win32-x64": "0.19.1"
46
46
  },
47
47
  devDependencies: {
48
48
  "@types/node": "^22.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft-opencode",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Agent File Tools (AFT) — tree-sitter and lsp powered code analysis",
6
6
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@clack/prompts": "^1.2.0",
31
- "@cortexkit/aft-bridge": "0.19.0",
31
+ "@cortexkit/aft-bridge": "0.19.1",
32
32
  "@opencode-ai/plugin": "^1.2.26",
33
33
  "@opencode-ai/sdk": "^1.2.26",
34
34
  "comment-json": "^4.6.2",
@@ -36,11 +36,11 @@
36
36
  "zod": "^4.1.8"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@cortexkit/aft-darwin-arm64": "0.19.0",
40
- "@cortexkit/aft-darwin-x64": "0.19.0",
41
- "@cortexkit/aft-linux-arm64": "0.19.0",
42
- "@cortexkit/aft-linux-x64": "0.19.0",
43
- "@cortexkit/aft-win32-x64": "0.19.0"
39
+ "@cortexkit/aft-darwin-arm64": "0.19.1",
40
+ "@cortexkit/aft-darwin-x64": "0.19.1",
41
+ "@cortexkit/aft-linux-arm64": "0.19.1",
42
+ "@cortexkit/aft-linux-x64": "0.19.1",
43
+ "@cortexkit/aft-win32-x64": "0.19.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^22.0.0",