Skip to content

[Tool] Add ApplyPatchTool - multi-file patch operations #235

Description

@omatheusmesmo

Motivation

When performing refactors, renames, or multi-file changes, the agent must make multiple sequential writeFile/fileEdit calls. A patch tool allows atomic-ish multi-file operations in a single tool call.

Two of three reference projects have this as a core tool.

What the tool should do

Apply a structured patch that can add, update, delete, and move files in a single call.

Reference implementations

opencode (TypeScript)

  • Custom patch format with Begin Patch / End Patch markers
  • Supports: Add File, Update File, Delete File, Move File
  • LSP diagnostics for all modified files
  • Formatter integration

openclaw (TypeScript)

  • OpenAI-style patch envelopes (Begin Patch / End Patch)
  • Workspace-only restriction by default
  • Sandbox bridge support

hermes-agent (Python)

  • V4A patch format support (compatible with Codex, Cline)
  • V4A supports: Update File, Add File, Delete File, Move File
  • Fuzzy matching within update hunks

Requirements

  1. Add new file - Create a file with specified content
  2. Update existing file - Apply text replacements (like FileEditTool but within a patch)
  3. Delete file - Remove a file
  4. Move/rename file - Move from one path to another
  5. Workspace confinement - All paths must be within workspace root
  6. Diff preview - Return unified diff for each modified file

Suggested location

client/runtime/src/main/java/dev/omatheusmesmo/qlawkus/tool/shell/ApplyPatchTool.java

Config properties

  • qlawkus.file.patch.enabled (boolean, default true)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttoolingTools and utilities

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions