@cortexkit/aft-opencode 0.19.4 → 0.19.5

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.
@@ -4,7 +4,22 @@ interface AutoUpdateInstallContext {
4
4
  }
5
5
  export declare function resolveInstallContext(runtimePackageJsonPath?: string | null): AutoUpdateInstallContext | null;
6
6
  export declare function preparePackageUpdate(version: string, packageName?: string, runtimePackageJsonPath?: string | null): string | null;
7
- export declare function runBunInstallSafe(installDir: string, options?: {
7
+ /**
8
+ * Run `npm install` in the install dir to materialize the dependency version
9
+ * we just rewrote into package.json. Earlier versions used `bun install`,
10
+ * but OpenCode itself installs plugins via npm — the install dir always
11
+ * contains `package-lock.json`, never `bun.lock` — so calling npm matches
12
+ * the existing lockfile shape and avoids generating a parallel bun.lock
13
+ * that drifts from OpenCode's view.
14
+ *
15
+ * `--no-audit --no-fund --no-progress` keeps the output minimal and avoids
16
+ * noisy network calls during background auto-updates.
17
+ *
18
+ * The default timeout is 60s — long enough for a typical reinstall over a
19
+ * mediocre network, short enough that a stuck install doesn't pin the plugin
20
+ * process. Caller can override.
21
+ */
22
+ export declare function runNpmInstallSafe(installDir: string, options?: {
8
23
  timeoutMs?: number;
9
24
  signal?: AbortSignal;
10
25
  }): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/hooks/auto-update-checker/cache.ts"],"names":[],"mappings":"AAmBA,UAAU,wBAAwB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB;AA4ED,wBAAgB,qBAAqB,CACnC,sBAAsB,GAAE,MAAM,GAAG,IAAyC,GACzE,wBAAwB,GAAG,IAAI,CAoBjC;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAqB,EAClC,sBAAsB,GAAE,MAAM,GAAG,IAAyC,GACzE,MAAM,GAAG,IAAI,CAwBf;AAED,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GACzD,OAAO,CAAC,OAAO,CAAC,CAyClB"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/hooks/auto-update-checker/cache.ts"],"names":[],"mappings":"AAoBA,UAAU,wBAAwB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB;AA4FD,wBAAgB,qBAAqB,CACnC,sBAAsB,GAAE,MAAM,GAAG,IAAyC,GACzE,wBAAwB,GAAG,IAAI,CAoBjC;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAqB,EAClC,sBAAsB,GAAE,MAAM,GAAG,IAAyC,GACzE,MAAM,GAAG,IAAI,CAwBf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GACzD,OAAO,CAAC,OAAO,CAAC,CAyClB"}
package/dist/index.js CHANGED
@@ -8675,6 +8675,46 @@ function cleanupAbandonedOnnxAttempts(onnxBaseDir, ortDir) {
8675
8675
  warn(`[onnx] failed to sweep ${ortDir}: ${err}`);
8676
8676
  }
8677
8677
  }
8678
+ var REQUIRED_ORT_MAJOR = 1;
8679
+ var REQUIRED_ORT_MIN_MINOR = 20;
8680
+ function detectOnnxVersion(libDir, libName) {
8681
+ try {
8682
+ const entries = readdirSync(libDir);
8683
+ const barePrefix = libName.replace(/\.(so|dylib|dll)$/, "");
8684
+ for (const entry of entries) {
8685
+ if (!entry.startsWith(barePrefix))
8686
+ continue;
8687
+ const match = entry.match(/\.(\d+\.\d+\.\d+)(?:\.dylib)?$/);
8688
+ if (match)
8689
+ return match[1];
8690
+ }
8691
+ const base = join3(libDir, libName);
8692
+ if (existsSync2(base)) {
8693
+ try {
8694
+ const real = realpathSync(base);
8695
+ const m = real.match(/\.(\d+\.\d+\.\d+)(?:\.dylib)?$/);
8696
+ if (m)
8697
+ return m[1];
8698
+ } catch {}
8699
+ try {
8700
+ const target = readlinkSync(base);
8701
+ const m = target.match(/\.(\d+\.\d+\.\d+)(?:\.dylib)?$/);
8702
+ if (m)
8703
+ return m[1];
8704
+ } catch {}
8705
+ }
8706
+ } catch {}
8707
+ return null;
8708
+ }
8709
+ function isOnnxVersionCompatible(version) {
8710
+ const parts = version.split(".").map((p) => Number.parseInt(p, 10));
8711
+ const [major, minor] = parts;
8712
+ if (!Number.isFinite(major) || !Number.isFinite(minor))
8713
+ return false;
8714
+ if (major !== REQUIRED_ORT_MAJOR)
8715
+ return false;
8716
+ return minor >= REQUIRED_ORT_MIN_MINOR;
8717
+ }
8678
8718
  function findSystemOnnxRuntime(libName) {
8679
8719
  if (!libName)
8680
8720
  return null;
@@ -8685,9 +8725,14 @@ function findSystemOnnxRuntime(libName) {
8685
8725
  searchPaths.push("/usr/lib", "/usr/lib/x86_64-linux-gnu", "/usr/lib/aarch64-linux-gnu", "/usr/local/lib");
8686
8726
  }
8687
8727
  for (const dir of searchPaths) {
8688
- if (existsSync2(join3(dir, libName))) {
8689
- return dir;
8728
+ if (!existsSync2(join3(dir, libName)))
8729
+ continue;
8730
+ const version = detectOnnxVersion(dir, libName);
8731
+ if (version && !isOnnxVersionCompatible(version)) {
8732
+ warn(`Skipping system ONNX Runtime at ${dir} (v${version}); AFT requires ` + `v${REQUIRED_ORT_MAJOR}.${REQUIRED_ORT_MIN_MINOR}+. Falling through to AFT-managed download.`);
8733
+ continue;
8690
8734
  }
8735
+ return dir;
8691
8736
  }
8692
8737
  return null;
8693
8738
  }
@@ -24368,24 +24413,27 @@ function stripPackageNameFromPath(pathValue, packageName) {
24368
24413
  }
24369
24414
  return current;
24370
24415
  }
24371
- function removeFromBunLock(installDir, packageName) {
24372
- const lockPath = join10(installDir, "bun.lock");
24416
+ function removeFromPackageLock(installDir, packageName) {
24417
+ const lockPath = join10(installDir, "package-lock.json");
24373
24418
  if (!existsSync7(lockPath))
24374
24419
  return false;
24375
24420
  try {
24376
24421
  const lock = import_comment_json3.parse(readFileSync5(lockPath, "utf-8"));
24377
24422
  let modified = false;
24378
- if (lock.workspaces?.[""]?.dependencies?.[packageName]) {
24379
- delete lock.workspaces[""].dependencies[packageName];
24380
- modified = true;
24423
+ if (lock.packages) {
24424
+ const key = `node_modules/${packageName}`;
24425
+ if (lock.packages[key] !== undefined) {
24426
+ delete lock.packages[key];
24427
+ modified = true;
24428
+ }
24381
24429
  }
24382
- if (lock.packages?.[packageName]) {
24383
- delete lock.packages[packageName];
24430
+ if (lock.dependencies?.[packageName]) {
24431
+ delete lock.dependencies[packageName];
24384
24432
  modified = true;
24385
24433
  }
24386
24434
  if (modified) {
24387
24435
  writeFileSync5(lockPath, JSON.stringify(lock, null, 2));
24388
- log2(`[auto-update-checker] Removed from bun.lock: ${packageName}`);
24436
+ log2(`[auto-update-checker] Removed from package-lock.json: ${packageName}`);
24389
24437
  }
24390
24438
  return modified;
24391
24439
  } catch {
@@ -24450,7 +24498,7 @@ function preparePackageUpdate(version2, packageName = PACKAGE_NAME, runtimePacka
24450
24498
  if (!ensureDependencyVersion(installContext.packageJsonPath, packageName, version2))
24451
24499
  return null;
24452
24500
  const packageRemoved = removeInstalledPackage(installContext.installDir, packageName);
24453
- const lockRemoved = removeFromBunLock(installContext.installDir, packageName);
24501
+ const lockRemoved = removeFromPackageLock(installContext.installDir, packageName);
24454
24502
  if (!packageRemoved && !lockRemoved) {
24455
24503
  log2(`[auto-update-checker] No cached package artifacts removed for ${packageName}; continuing with updated dependency spec`);
24456
24504
  }
@@ -24460,12 +24508,12 @@ function preparePackageUpdate(version2, packageName = PACKAGE_NAME, runtimePacka
24460
24508
  return null;
24461
24509
  }
24462
24510
  }
24463
- async function runBunInstallSafe(installDir, options = {}) {
24511
+ async function runNpmInstallSafe(installDir, options = {}) {
24464
24512
  let timeout = null;
24465
24513
  try {
24466
24514
  if (options.signal?.aborted)
24467
24515
  return false;
24468
- const proc = spawn2("bun", ["install"], {
24516
+ const proc = spawn2("npm", ["install", "--no-audit", "--no-fund", "--no-progress"], {
24469
24517
  cwd: installDir,
24470
24518
  stdio: "pipe"
24471
24519
  });
@@ -24490,7 +24538,7 @@ async function runBunInstallSafe(installDir, options = {}) {
24490
24538
  }
24491
24539
  return result;
24492
24540
  } catch (err) {
24493
- warn2(`[auto-update-checker] bun install error: ${String(err)}`);
24541
+ warn2(`[auto-update-checker] npm install error: ${String(err)}`);
24494
24542
  return false;
24495
24543
  } finally {
24496
24544
  if (timeout)
@@ -24605,7 +24653,7 @@ async function runBackgroundUpdateCheck(ctx, options) {
24605
24653
  warn2("[auto-update-checker] Failed to prepare install root for auto-update");
24606
24654
  return;
24607
24655
  }
24608
- const installSuccess = await runBunInstallSafe(installDir, { signal: options.signal });
24656
+ const installSuccess = await runNpmInstallSafe(installDir, { signal: options.signal });
24609
24657
  if (installSuccess) {
24610
24658
  showToast(ctx, "AFT Updated!", `v${currentVersion} \u2192 v${latestVersion}
24611
24659
  Restart OpenCode to apply.`, "success", 8000);
@@ -24613,7 +24661,7 @@ Restart OpenCode to apply.`, "success", 8000);
24613
24661
  return;
24614
24662
  }
24615
24663
  showToast(ctx, `AFT ${latestVersion}`, `v${latestVersion} available, but auto-update failed to install it. Check logs or retry manually.`, "error", 8000);
24616
- warn2("[auto-update-checker] bun install failed; update not installed");
24664
+ warn2("[auto-update-checker] npm install failed; update not installed");
24617
24665
  }
24618
24666
  function showToast(ctx, title, message, variant = "info", duration3 = 3000) {
24619
24667
  ctx.client.tui.showToast({ body: { title, message, variant, duration: duration3 } }).catch(() => {});
@@ -26957,23 +27005,9 @@ function showOutputToUser(context, output) {
26957
27005
  const ctx = context;
26958
27006
  ctx.metadata?.({ metadata: { output } });
26959
27007
  }
26960
- function getEmptyResultHint(pattern, lang) {
26961
- const src = pattern.trim();
26962
- if (lang === "python") {
26963
- if (src.startsWith("class ") && src.endsWith(":")) {
26964
- return `Hint: Python class patterns need a body. Try: "${src.slice(0, -1)}" or "${src}
26965
- $$$"`;
26966
- }
26967
- if ((src.startsWith("def ") || src.startsWith("async def ")) && src.endsWith(":")) {
26968
- return `Hint: Python function patterns need a body. Try adding "\\n $$$" after the colon.`;
26969
- }
26970
- }
26971
- if (["javascript", "typescript", "tsx"].includes(lang)) {
26972
- if (/^(export\s+)?(async\s+)?function\s+\$[A-Z_]+\s*$/i.test(src)) {
26973
- return `Hint: Function patterns need params and body. Try: "function $NAME($$$) { $$$ }"`;
26974
- }
26975
- }
26976
- return null;
27008
+ function extractHint(response) {
27009
+ const hint = response.hint;
27010
+ return typeof hint === "string" && hint.length > 0 ? hint : null;
26977
27011
  }
26978
27012
  var SUPPORTED_LANGS = ["typescript", "tsx", "javascript", "python", "rust", "go"];
26979
27013
  function astTools(ctx) {
@@ -27032,7 +27066,7 @@ Scope warnings:
27032
27066
  ${data.scope_warnings.map((w) => ` ${w}`).join(`
27033
27067
  `)}`;
27034
27068
  }
27035
- const hint = getEmptyResultHint(args.pattern, args.lang);
27069
+ const hint = extractHint(response);
27036
27070
  if (hint) {
27037
27071
  output += `
27038
27072
 
@@ -27137,6 +27171,12 @@ Scope warnings:
27137
27171
  ${data.scope_warnings.map((w) => ` ${w}`).join(`
27138
27172
  `)}`;
27139
27173
  }
27174
+ const hint = extractHint(response);
27175
+ if (hint) {
27176
+ output += `
27177
+
27178
+ ${hint}`;
27179
+ }
27140
27180
  } else {
27141
27181
  output = isDryRun ? `[DRY RUN] Would replace ${matchCount} match(es) in ${filesWithMatches} file(s) (${filesSearched} searched)
27142
27182
 
@@ -28897,7 +28937,7 @@ function lspTools(ctx) {
28897
28937
  ` + `
28898
28938
  ` + `**Reading the response honestly:**
28899
28939
  ` + "- `total: 0, complete: true, lsp_servers_used: [{status: 'pull_ok'}]` \u2192 file is genuinely clean.\n" + "- `total: 0, lsp_servers_used: []` \u2192 **nothing was checked** (no server registered for this extension). Tell the user, don't claim 'no errors'.\n" + "- `lsp_servers_used: [{status: 'binary_not_installed: <name>'}]` \u2192 server matched the extension but its binary isn't on PATH. Tell the user to install it.\n" + "- `lsp_servers_used: [{status: 'no_root_marker (...)'}]` \u2192 server is registered but couldn't find a workspace root marker walking up from this file. The user's project layout doesn't match what the server expects.\n" + "- `complete: false` (directory mode) \u2192 some files in the directory weren't checked; see `unchecked_files`.\n" + `
28900
- ` + "**When this tool gives an unhelpful answer**, run `bunx --bun @cortexkit/aft doctor lsp <filePath>` from a terminal to get a full per-server breakdown (registered servers, binary resolution, root-marker resolution, spawn outcome).",
28940
+ ` + "**When this tool gives an unhelpful answer**, run `npx @cortexkit/aft doctor lsp <filePath>` from a terminal to get a full per-server breakdown (registered servers, binary resolution, root-marker resolution, spawn outcome).",
28901
28941
  args: {
28902
28942
  filePath: z6.string().optional().describe("Path to a file to check. Mutually exclusive with 'directory'. Omit both to dump all cached diagnostics."),
28903
28943
  directory: z6.string().optional().describe("Path to a directory. Returns cached diagnostics + workspace pull from active servers; lists files we have no info for in 'unchecked_files'. Capped at 200 walked files."),
@@ -1 +1 @@
1
- {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/tools/ast.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAyCjD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAgR3E"}
1
+ {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/tools/ast.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAiCjD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA0R3E"}
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.4",
5
+ version: "0.19.5",
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.4",
33
+ "@cortexkit/aft-bridge": "0.19.5",
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.4",
42
- "@cortexkit/aft-darwin-x64": "0.19.4",
43
- "@cortexkit/aft-linux-arm64": "0.19.4",
44
- "@cortexkit/aft-linux-x64": "0.19.4",
45
- "@cortexkit/aft-win32-x64": "0.19.4"
41
+ "@cortexkit/aft-darwin-arm64": "0.19.5",
42
+ "@cortexkit/aft-darwin-x64": "0.19.5",
43
+ "@cortexkit/aft-linux-arm64": "0.19.5",
44
+ "@cortexkit/aft-linux-x64": "0.19.5",
45
+ "@cortexkit/aft-win32-x64": "0.19.5"
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.4",
3
+ "version": "0.19.5",
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.4",
31
+ "@cortexkit/aft-bridge": "0.19.5",
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.4",
40
- "@cortexkit/aft-darwin-x64": "0.19.4",
41
- "@cortexkit/aft-linux-arm64": "0.19.4",
42
- "@cortexkit/aft-linux-x64": "0.19.4",
43
- "@cortexkit/aft-win32-x64": "0.19.4"
39
+ "@cortexkit/aft-darwin-arm64": "0.19.5",
40
+ "@cortexkit/aft-darwin-x64": "0.19.5",
41
+ "@cortexkit/aft-linux-arm64": "0.19.5",
42
+ "@cortexkit/aft-linux-x64": "0.19.5",
43
+ "@cortexkit/aft-win32-x64": "0.19.5"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^22.0.0",