@cortexkit/aft-opencode 0.17.1 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -8
- package/dist/tools/hoisted.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -26893,11 +26893,11 @@ LSP errors detected, please fix:
|
|
|
26893
26893
|
};
|
|
26894
26894
|
}
|
|
26895
26895
|
function getEditDescription(writeToolName) {
|
|
26896
|
-
return `Edit a file by finding and replacing text, or by targeting named symbols.
|
|
26896
|
+
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
26897
|
|
|
26898
26898
|
**Modes** (determined by which parameters you provide):
|
|
26899
26899
|
|
|
26900
|
-
Mode priority: operations > edits > symbol (without oldString) > oldString (find/replace)
|
|
26900
|
+
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
26901
|
|
|
26902
26902
|
1. **Multi-file transaction** \u2014 pass \`operations\` array
|
|
26903
26903
|
Edits across multiple files with checkpoint-based rollback on failure.
|
|
@@ -26960,6 +26960,10 @@ function createEditTool(ctx, writeToolName = "write") {
|
|
|
26960
26960
|
dryRun: z3.boolean().optional().describe("Preview changes without applying (returns diff, default: false)")
|
|
26961
26961
|
},
|
|
26962
26962
|
execute: async (args, context) => {
|
|
26963
|
+
const argsRecord = args;
|
|
26964
|
+
if (argsRecord.startLine !== undefined || argsRecord.endLine !== undefined) {
|
|
26965
|
+
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.");
|
|
26966
|
+
}
|
|
26963
26967
|
if (Array.isArray(args.operations)) {
|
|
26964
26968
|
const ops = args.operations;
|
|
26965
26969
|
const files = ops.map((op) => op.file).filter(Boolean);
|
|
@@ -27022,12 +27026,9 @@ function createEditTool(ctx, writeToolName = "write") {
|
|
|
27022
27026
|
params.replace_all = args.replaceAll;
|
|
27023
27027
|
if (args.occurrence !== undefined)
|
|
27024
27028
|
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
27029
|
} else {
|
|
27030
|
-
|
|
27030
|
+
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.";
|
|
27031
|
+
throw new Error(`edit: no edit mode resolved from arguments.${hint}`);
|
|
27031
27032
|
}
|
|
27032
27033
|
if (args.dryRun)
|
|
27033
27034
|
params.dry_run = true;
|
|
@@ -27427,7 +27428,29 @@ function aftPrefixedTools(ctx) {
|
|
|
27427
27428
|
...aftEditTool,
|
|
27428
27429
|
execute: async (args, context) => {
|
|
27429
27430
|
const argRecord = args;
|
|
27430
|
-
const normalizedArgs = argRecord.mode !== undefined && argRecord.filePath === undefined && typeof argRecord.file === "string" ? { ...argRecord, filePath: argRecord.file } : argRecord;
|
|
27431
|
+
const normalizedArgs = argRecord.mode !== undefined && argRecord.filePath === undefined && typeof argRecord.file === "string" ? { ...argRecord, filePath: argRecord.file } : { ...argRecord };
|
|
27432
|
+
if (normalizedArgs.mode === "write" && typeof normalizedArgs.filePath === "string" && typeof normalizedArgs.content === "string") {
|
|
27433
|
+
const file2 = normalizedArgs.filePath;
|
|
27434
|
+
const filePath = path4.isAbsolute(file2) ? file2 : path4.resolve(context.directory, file2);
|
|
27435
|
+
const relPath = path4.relative(context.worktree, filePath);
|
|
27436
|
+
await context.ask({
|
|
27437
|
+
permission: "edit",
|
|
27438
|
+
patterns: [relPath],
|
|
27439
|
+
always: ["*"],
|
|
27440
|
+
metadata: { filepath: filePath }
|
|
27441
|
+
});
|
|
27442
|
+
const writeParams = {
|
|
27443
|
+
file: filePath,
|
|
27444
|
+
content: normalizedArgs.content,
|
|
27445
|
+
create_dirs: normalizedArgs.create_dirs !== false,
|
|
27446
|
+
diagnostics: true
|
|
27447
|
+
};
|
|
27448
|
+
if (normalizedArgs.dryRun === true || normalizedArgs.dry_run === true) {
|
|
27449
|
+
writeParams.dry_run = true;
|
|
27450
|
+
}
|
|
27451
|
+
const data = await callBridge(ctx, context, "write", writeParams);
|
|
27452
|
+
return JSON.stringify(data);
|
|
27453
|
+
}
|
|
27431
27454
|
return aftEditTool.execute(normalizedArgs, context);
|
|
27432
27455
|
}
|
|
27433
27456
|
},
|
|
@@ -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;
|
|
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;AA41BD;;;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.
|
|
3
|
+
"version": "0.17.2",
|
|
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.
|
|
36
|
-
"@cortexkit/aft-darwin-x64": "0.17.
|
|
37
|
-
"@cortexkit/aft-linux-arm64": "0.17.
|
|
38
|
-
"@cortexkit/aft-linux-x64": "0.17.
|
|
39
|
-
"@cortexkit/aft-win32-x64": "0.17.
|
|
35
|
+
"@cortexkit/aft-darwin-arm64": "0.17.2",
|
|
36
|
+
"@cortexkit/aft-darwin-x64": "0.17.2",
|
|
37
|
+
"@cortexkit/aft-linux-arm64": "0.17.2",
|
|
38
|
+
"@cortexkit/aft-linux-x64": "0.17.2",
|
|
39
|
+
"@cortexkit/aft-win32-x64": "0.17.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^22.0.0",
|