Skip to content

feat: add ApplyPatch support for OpenCode#41

Merged
Cannon07 merged 2 commits intomainfrom
feat/apply-patch-support
Apr 19, 2026
Merged

feat: add ApplyPatch support for OpenCode#41
Cannon07 merged 2 commits intomainfrom
feat/apply-patch-support

Conversation

@Cannon07
Copy link
Copy Markdown
Owner

@Cannon07 Cannon07 commented Apr 19, 2026

Summary

  • Adds apply-patch.lua parser for the custom patch format (*** Begin Patch / *** Update File: / *** Add File: / *** Delete File:) used by models like GPT 5.4 in OpenCode
  • Wires ApplyPatch handling into core-pre-tool.sh (compute per-file diffs) and core-post-tool.sh (close diffs on accept)
  • Updates OpenCode adapter to pass patch_text from both patchText and patch field names
  • Adds debug config option to README and apply-patch.lua to architecture diagram
  • Includes 5 unit tests exercising the parser directly via nvim --headless -l

Test plan

  • All 27 tests pass (bash tests/run.sh) — 5 new + 22 existing
  • Manually tested with GPT 5.4 in OpenCode — single-file and multi-file patches show diffs correctly
  • Existing Edit/Write/MultiEdit/Bash workflows unaffected (all additive, gated behind ApplyPatch tool name)

Cannon07 and others added 2 commits April 20, 2026 02:24
Handle the custom patch format (*** Begin Patch / *** Update File / *** Add
File / *** Delete File) used by models like GPT 5.4 in OpenCode. Adds
apply-patch.lua to parse the format and compute per-file diffs, wires it
into core-pre-tool.sh and core-post-tool.sh, and updates the OpenCode
adapter to pass patch_text from both field name variants.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests the *** Begin Patch format parser directly via nvim --headless,
covering update, add, delete, multi-file, and multi-hunk scenarios.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Cannon07 Cannon07 merged commit 54a4dd5 into main Apr 19, 2026
2 checks passed
@Cannon07 Cannon07 deleted the feat/apply-patch-support branch April 19, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant