Hosted tool for applying Codex apply_patch edits to files.
Options
:base_path- Base directory for file paths (defaults to CWD):approval- Approval callback for reviewing changes before applying:dry_run- If true, only validate without applying changes
Approval Callback
The approval callback can be:
A function with arity 1-3:
fn changes -> :ok | {:deny, reason} end- A module implementing
review_patch/2
Examples
# Basic usage (*** Begin Patch format)
args = %{"input" => patch_content}
{:ok, result} = ApplyPatchTool.invoke(args, %{base_path: "/project"})
# With approval
context = %{
metadata: %{
approval: fn changes, _ctx -> :ok end
}
}
{:ok, result} = ApplyPatchTool.invoke(args, context)
# Dry run to validate
{:ok, result} = ApplyPatchTool.invoke(args, %{dry_run: true})
Summary
Functions
Applies hunks to file content.
Parses an apply_patch or unified diff patch string into a list of file changes.
Functions
Applies hunks to file content.
Returns {:ok, new_content} or {:error, reason}.
Parses an apply_patch or unified diff patch string into a list of file changes.