@cortexkit/aft-opencode 0.17.1 → 0.17.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
@@ -26867,6 +26867,18 @@ LSP errors detected, please fix:
26867
26867
  }
26868
26868
  }
26869
26869
  }
26870
+ const pendingServers = data.lsp_pending_servers;
26871
+ const exitedServers = data.lsp_exited_servers;
26872
+ if (pendingServers && pendingServers.length > 0) {
26873
+ output += `
26874
+
26875
+ Note: LSP server(s) did not respond in time: ${pendingServers.join(", ")}. Diagnostics may be incomplete; rerun lsp_diagnostics later for a fresh check.`;
26876
+ }
26877
+ if (exitedServers && exitedServers.length > 0) {
26878
+ output += `
26879
+
26880
+ Note: LSP server(s) exited during this edit: ${exitedServers.join(", ")}. Their diagnostics could not be collected.`;
26881
+ }
26870
26882
  const diff = data.diff;
26871
26883
  const callID = getCallID(context);
26872
26884
  if (callID) {
@@ -26893,11 +26905,11 @@ LSP errors detected, please fix:
26893
26905
  };
26894
26906
  }
26895
26907
  function getEditDescription(writeToolName) {
26896
- return `Edit a file by finding and replacing text, or by targeting named symbols.
26908
+ return `Edit a file by finding and replacing text, or by targeting named symbols. To write or overwrite a whole file, use the \`${writeToolName}\` tool \u2014 \`edit\` requires an explicit edit mode and will not silently overwrite a file from \`content\` alone.
26897
26909
 
26898
26910
  **Modes** (determined by which parameters you provide):
26899
26911
 
26900
- Mode priority: operations > edits > symbol (without oldString) > oldString (find/replace) > content-only (${writeToolName})
26912
+ Mode priority: operations > edits > symbol (without oldString) > oldString (find/replace). If none match, the call is rejected \u2014 there is no implicit "write" fallback.
26901
26913
 
26902
26914
  1. **Multi-file transaction** \u2014 pass \`operations\` array
26903
26915
  Edits across multiple files with checkpoint-based rollback on failure.
@@ -26960,6 +26972,10 @@ function createEditTool(ctx, writeToolName = "write") {
26960
26972
  dryRun: z3.boolean().optional().describe("Preview changes without applying (returns diff, default: false)")
26961
26973
  },
26962
26974
  execute: async (args, context) => {
26975
+ const argsRecord = args;
26976
+ if (argsRecord.startLine !== undefined || argsRecord.endLine !== undefined) {
26977
+ throw new Error("edit: 'startLine'/'endLine' are not top-level parameters. For line-range edits, nest them inside the `edits` array: `edits: [{ startLine: N, endLine: M, content: \"...\" }]`. For find/replace, use `oldString`/`newString` instead.");
26978
+ }
26963
26979
  if (Array.isArray(args.operations)) {
26964
26980
  const ops = args.operations;
26965
26981
  const files = ops.map((op) => op.file).filter(Boolean);
@@ -27022,12 +27038,9 @@ function createEditTool(ctx, writeToolName = "write") {
27022
27038
  params.replace_all = args.replaceAll;
27023
27039
  if (args.occurrence !== undefined)
27024
27040
  params.occurrence = args.occurrence;
27025
- } else if (typeof args.content === "string") {
27026
- command = "write";
27027
- params.content = args.content;
27028
- params.create_dirs = true;
27029
27041
  } else {
27030
- throw new Error("Provide 'oldString' + 'newString', 'symbol' + 'content', 'edits' array, or 'content' for write");
27042
+ const hint = typeof args.content === "string" ? ` To write the whole file, use the '${writeToolName}' tool. To edit existing content, provide 'oldString' (and optionally 'newString'), 'symbol' + 'content', or an 'edits' array.` : " Provide 'oldString' (+ optional 'newString'), 'symbol' + 'content', 'edits' array, or 'operations' array.";
27043
+ throw new Error(`edit: no edit mode resolved from arguments.${hint}`);
27031
27044
  }
27032
27045
  if (args.dryRun)
27033
27046
  params.dry_run = true;
@@ -27073,6 +27086,18 @@ LSP errors detected, please fix:
27073
27086
  ${diagLines}`;
27074
27087
  }
27075
27088
  }
27089
+ const pendingServers = data.lsp_pending_servers;
27090
+ const exitedServers = data.lsp_exited_servers;
27091
+ if (pendingServers && pendingServers.length > 0) {
27092
+ result += `
27093
+
27094
+ Note: LSP server(s) did not respond in time: ${pendingServers.join(", ")}. Diagnostics may be incomplete; rerun lsp_diagnostics later for a fresh check.`;
27095
+ }
27096
+ if (exitedServers && exitedServers.length > 0) {
27097
+ result += `
27098
+
27099
+ Note: LSP server(s) exited during this edit: ${exitedServers.join(", ")}. Their diagnostics could not be collected.`;
27100
+ }
27076
27101
  }
27077
27102
  return result;
27078
27103
  }
@@ -27427,7 +27452,29 @@ function aftPrefixedTools(ctx) {
27427
27452
  ...aftEditTool,
27428
27453
  execute: async (args, context) => {
27429
27454
  const argRecord = args;
27430
- const normalizedArgs = argRecord.mode !== undefined && argRecord.filePath === undefined && typeof argRecord.file === "string" ? { ...argRecord, filePath: argRecord.file } : argRecord;
27455
+ const normalizedArgs = argRecord.mode !== undefined && argRecord.filePath === undefined && typeof argRecord.file === "string" ? { ...argRecord, filePath: argRecord.file } : { ...argRecord };
27456
+ if (normalizedArgs.mode === "write" && typeof normalizedArgs.filePath === "string" && typeof normalizedArgs.content === "string") {
27457
+ const file2 = normalizedArgs.filePath;
27458
+ const filePath = path4.isAbsolute(file2) ? file2 : path4.resolve(context.directory, file2);
27459
+ const relPath = path4.relative(context.worktree, filePath);
27460
+ await context.ask({
27461
+ permission: "edit",
27462
+ patterns: [relPath],
27463
+ always: ["*"],
27464
+ metadata: { filepath: filePath }
27465
+ });
27466
+ const writeParams = {
27467
+ file: filePath,
27468
+ content: normalizedArgs.content,
27469
+ create_dirs: normalizedArgs.create_dirs !== false,
27470
+ diagnostics: true
27471
+ };
27472
+ if (normalizedArgs.dryRun === true || normalizedArgs.dry_run === true) {
27473
+ writeParams.dry_run = true;
27474
+ }
27475
+ const data = await callBridge(ctx, context, "write", writeParams);
27476
+ return JSON.stringify(data);
27477
+ }
27431
27478
  return aftEditTool.execute(normalizedArgs, context);
27432
27479
  }
27433
27480
  },
@@ -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;AAcjD,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,GAAI,IAAI,MAAM,EAAE,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAChD,CAAC;AA+QtC;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CA4IjE;AA00BD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAS/E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAuBnF"}
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;AAcjD,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,GAAI,IAAI,MAAM,EAAE,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAChD,CAAC;AA+QtC;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CA4IjE;AAo3BD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAS/E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAmEnF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft-opencode",
3
- "version": "0.17.1",
3
+ "version": "0.17.3",
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",
@@ -32,11 +32,11 @@
32
32
  "zod": "^4.1.8"
33
33
  },
34
34
  "optionalDependencies": {
35
- "@cortexkit/aft-darwin-arm64": "0.17.1",
36
- "@cortexkit/aft-darwin-x64": "0.17.1",
37
- "@cortexkit/aft-linux-arm64": "0.17.1",
38
- "@cortexkit/aft-linux-x64": "0.17.1",
39
- "@cortexkit/aft-win32-x64": "0.17.1"
35
+ "@cortexkit/aft-darwin-arm64": "0.17.3",
36
+ "@cortexkit/aft-darwin-x64": "0.17.3",
37
+ "@cortexkit/aft-linux-arm64": "0.17.3",
38
+ "@cortexkit/aft-linux-x64": "0.17.3",
39
+ "@cortexkit/aft-win32-x64": "0.17.3"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "^22.0.0",