Introduction¶
DeepSeek Harness (DSH) adopts a plugin-based architecture. In file editing scenarios, the native edit tool is more efficient for single-line modifications; however, when handling large files, cross-file batch changes, or adding/deleting files, line-by-line editing is not only inefficient but also difficult to make atomic. The dsh-patch-edit-plus plugin wraps a unified apply_patch tool, giving the model the ability to process Git unified diff and Codex apply_patch syntax, and ensures that all changes are applied in an “all-or-nothing” manner.
Plugin Overview¶
This plugin provides DSH with a single model interface: the apply_patch tool.
- Core functionality: Supports git/unified diff (enabled by default) and Codex
apply_patchsyntax (optional). - Execution mode: Applies patches atomically; if any step fails, the entire patch is rolled back, with zero bytes written.
- Compatibility: Supports DSH 0.2.0-rc.1 and later.
- Design principle: After plugin registration, execution is fully managed by DSH. The plugin does not interfere with the core flow and automatically cleans up resources when unloaded.
Installation and Configuration¶
Add the plugin using the official installation command, then verify the configuration and restart DSH.
dsh plugin --profile web add <path-to-dsh-patch-edit-plus>
dsh web --dump-config # Verify that the plugin line appears
# Restart DSH
In the DSH settings panel, you can adjust the following key configuration items:
| Configuration Item | Default Value | Description |
|---|---|---|
allowCodexPatch |
false |
Whether to accept Codex apply_patch syntax |
conflictPolicy |
rename |
Handling strategy for tool name conflicts (rename / skip / fail) |
deleteBackend |
shell |
Backend implementation for delete/move operations (shell / none) |
shellDialect |
auto |
Shell script dialect (auto / posix / pwsh) |
maxFiles |
50 |
Maximum number of files allowed in a single patch |
maxPatchBytes |
524288 |
Maximum byte size of patch text |
Typical Usage¶
The model can choose to use Unified Diff or Codex syntax depending on the scenario.
1. Unified Diff Syntax (Default)¶
Suitable for standard Git patch format.
--- a/src/app.ts
+++ b/src/app.ts
@@ -10,4 +10,4 @@ export function main() {
init()
- start(oldPort)
+ start(newPort)
await shutdown()
}
2. Codex apply_patch Syntax (Optional)¶
Enable by setting allowCodexPatch: true. This syntax allows multiple operations to be mixed within a single patch block.
*** Begin Patch
*** Update File: src/app.ts
@@
init()
- start(oldPort)
+ start(newPort)
*** Add File: docs/notes.md
*** Delete File: tmp/junk.txt
*** End Patch
Applicable Scenarios and Cautions¶
Applicable Scenarios¶
- Minor modifications in large files: No need to echo the entire file content.
- Batch changes across multiple files: Modify multiple files in a single call.
- Adding files / deleting / renaming: These operations are handled uniformly by
apply_patch.
Key Limitations¶
- Sandbox dependency: Delete and move operations are executed through
ctx.shell; the strength of the sandbox depends on the loaded shell executor (for example,bash-sandboxfences;bash-localis not subject to this restriction). - Permission policy: Every write and delete operation checks the session-level policy (
ctx.sandboxPolicy.resolve({ session })), ensuring safety inworkspace-writemode. - Directory creation: Parent directories are not automatically created when adding files; ensure the directory already exists.
- Exact matching: Fuzzy matching or offset-based matching is not supported; hunk positions must be exact.
- Binary files: Binary patches are rejected.
- Line-ending fidelity: CRLF files are written back as CRLF.
Conclusion¶
The dsh-patch-edit-plus plugin solves the atomicity challenge for batch file editing in DSH through a unified apply_patch interface while maintaining compatibility with native tools. With appropriate configuration, it can help balance security and development efficiency.