-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Bug: docs list built-in tool as patch, source registers it as apply_patch #19941
Description
Description
The Tools documentation lists a built-in tool called patch in the Built-in section. The actual registered tool ID in the source is apply_patch. This causes plugin hooks that check input.tool === "patch" to silently never fire — no error, no warning.
Additionally, the docs don't describe the apply_patch args shape or path format, which differs significantly from edit/write.
Tool name mismatch
Docs say: patch
Source (packages/opencode/src/tool/apply_patch.ts):
export const ApplyPatchTool = Tool.define("apply_patch", { ... })A plugin author following the docs and writing:
"tool.execute.before": async (input, output) => {
if (input.tool === "patch") { /* never runs */ }
}gets silent failure. The correct name is "apply_patch".
apply_patch args shape (undocumented)
apply_patch has a different args shape than edit/write and the docs don't mention it:
// edit / write — filePath is directly available:
output.args.filePath // absolute path
// apply_patch — no filePath; paths are embedded in patchText as relative paths:
output.args.patchText // must parse marker lines to extract pathsMarker lines in patchText (paths are relative to project root):
*** Add File: src/new-file.ts
*** Update File: src/existing.ts
*** Move to: src/renamed.ts
*** Delete File: src/obsolete.ts
Resolved internally via path.resolve(Instance.directory, hunk.path).
OpenCode version
1.3.6
Steps to reproduce
- Read the Tools docs — note tool is listed as
patch - Write a plugin with
if (input.tool === "patch") { ... } - Trigger any file edit with a GPT-5-series model
- Observe: the branch never executes, no error thrown
Verified via:
- GitHub source (
devbranch):Tool.define("apply_patch", ...)insrc/tool/apply_patch.ts - Compiled binary string search (v1.3.6)
- Live logging plugin test confirming
input.toolvalues
Operating System
macOS