2a367bf043
Slots a new "apply_patch" variant alongside the existing edit modes
(replace, patch, hashline, chunk, vim). The mode accepts a single input
string containing a Codex *** Begin Patch / *** End Patch envelope,
parses it with a new lenient parser (heredoc-tolerant), and fans each
file-op out to the existing executePatchSingle so LSP writethrough,
plan-mode guards, fs-cache invalidation and diagnostics are shared
with the patch mode.
Exposes both tool shapes from the spec: the JSON function-tool variant
(§1.2, {input: string}) and the OpenAI custom-tool / Lark-grammar
"freeform" variant (§1.1, raw patch string). The edit tool advertises
a Lark grammar via customFormat and a wire name via customWireName;
openai-responses emits it as a grammar-constrained custom tool when a
model opts in with applyPatchToolType: "freeform" in models.json.
custom_tool_call / custom_tool_call_output are plumbed end-to-end
through the shared responses code (emission, streaming, history
replay), and the agent-loop dispatcher matches tool calls by either
name or customWireName so returned calls route correctly.
Also threads preview/diff rendering for apply_patch through the TUI
(tool-execution + edit renderer) so streaming patches show per-file
diffs like the other edit modes.
Default edit mode is unchanged (hashline); opt in via edit.mode or
PI_EDIT_VARIANT=apply_patch.
20 lines
578 B
Plaintext
20 lines
578 B
Plaintext
start: begin_patch hunk+ end_patch
|
|
begin_patch: "*** Begin Patch" LF
|
|
end_patch: "*** End Patch" LF?
|
|
|
|
hunk: add_hunk | delete_hunk | update_hunk
|
|
add_hunk: "*** Add File: " filename LF add_line+
|
|
delete_hunk: "*** Delete File: " filename LF
|
|
update_hunk: "*** Update File: " filename LF change_move? change?
|
|
|
|
filename: /(.+)/
|
|
add_line: "+" /(.*)/ LF -> line
|
|
|
|
change_move: "*** Move to: " filename LF
|
|
change: (change_context | change_line)+ eof_line?
|
|
change_context: ("@@" | "@@ " /(.+)/) LF
|
|
change_line: ("+" | "-" | " ") /(.*)/ LF
|
|
eof_line: "*** End of File" LF
|
|
|
|
%import common.LF
|