rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
drscrewdriver/dsh-patch-edit-plus
Patch-style file editing for DeepSeek Harness: one apply_patch tool for git/unified diff (default) and Codex apply_patch syntax (opt-in), all-or-nothing application, 0.1.2-rc.1 ~ 0.1.5-rc.2 compatible.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:drscrewdriver/dsh-patch-edit-plus
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 简体中文 | 日本語 | 한국어 | Français | Deutsch | Italiano | Русский | Español
Patch-style file editing for DeepSeek Harness (DSH): one model-facing apply_patch tool that accepts git/unified diff (default) and Codex apply_patch syntax (opt-in), applies every change all-or-nothing, and stays completely out of DSH's way.
| DSH version | Status | Notes |
|---|---|---|
0.2.0-rc.1+ |
✅ supported (this line, v0.3.0+) | Declarative settings: allowCodexPatch is marked .volatile() — the settings form renders automatically and loader/volatile-update re-registers the tool without a remount. No registration call. Delete/Move migrated to the ShellExecutor.execute() + result() foreground API. |
0.1.7-rc.1+ |
↗ maintenance line | Served by the compat/0.1.7 branch / dsh-0.1.7 dist-tag (v0.2.1 there). 0.2.0's shell executor renamed run → execute (introduced between 0.1.2 and 0.1.7), so one codebase cannot serve both lines type-safely. |
0.1.2-rc.1 ~ 0.1.5-rc.2 |
↗ maintenance line | Served by the pre-0.1.7 branch / dsh-0.1.5 dist-tag. 0.1.7 removed the imperative settings APIs the dual-API fallback relied on. |
Settings are declarative on this line: fields marked .volatile() in Config become the settings form; the plugin subscribes to loader/volatile-update instead of receiving registration hooks.
The tool description explicitly routes the model:
edit tool (a patch costs more tokens than a literal edit).apply_patch (no need to echo the whole file).apply_patch (one call, verified atomically).apply_patch.dsh plugin --profile web add <path-to-dsh-patch-edit-plus>
dsh web --dump-config # verify the plugin row appears
# restart DSH
--- a/src/app.ts
+++ b/src/app.ts
@@ -10,4 +10,4 @@ export function main() {
init()
- start(oldPort)
+ start(newPort)
await shutdown()
}
*** Begin Patch
*** Update File: src/app.ts
@@
init()
- start(oldPort)
+ start(newPort)
*** Add File: docs/notes.md
+# Notes
*** Delete File: tmp/junk.txt
*** Move to: src/app.ts (via `*** Move to:` after *** Update File:)
*** End Patch
Enable with allowCodexPatch: true. When a Codex patch arrives while disabled, the tool returns an actionable hint (how to enable or how to retry in unified diff) instead of a generic parse error — Codex syntax is a strong prior for GPT-family models and a silent failure traps them in retry loops.
| Operation | Unified diff | Codex | Execution path |
|---|---|---|---|
| Add | new file mode + /dev/null |
*** Add File: |
ctx.fs.writeText (official intent dance) |
| Update (multi-hunk) | @@ hunks |
@@ hunks |
ctx.fs.writeText |
| Delete | deleted file mode + /dev/null |
*** Delete File: |
ctx.shell (sandbox-aware, env-passed path) |
| Move / rename | rename from/to |
*** Move to: |
ctx.shell |
write tool's intent dance — fs/write-intent waterfall → guarded writeText → fs/observed emit. A bare writeText would silently bypass the gate because DSH providers never dispatch fs/* events themselves.tools.restrict(), never overrides a native tool, registers no global services, and removes everything on unload. Name conflicts with other apply_patch providers (bainianlaoyao/dsh-codex-mode, shuind/dsh-codex-harness, …) are resolved by rename avoidance (apply_patch_1, …_2, …) so DSH never fails to start.| Option | Default | Description |
|---|---|---|
toolName |
apply_patch |
Model-facing tool name. |
conflictPolicy |
rename |
rename / skip / fail when the tool name is taken. |
renameSuffix |
_1 |
Suffix used by rename avoidance. |
allowUnifiedDiff |
true |
Accept git/unified diffs. |
allowCodexPatch |
false |
Accept Codex apply_patch syntax. Also editable in the DSH settings panel; changes take effect immediately, no restart needed. |
deleteBackend |
shell |
shell or none (Delete/Move return a structured error). |
shellDialect |
auto |
auto (pwsh on win32) / posix / pwsh. |
deleteCommand / moveCommand |
built-in | Custom command templates. Paths still arrive only via env (DSH_PATCH_TARGET / DSH_PATCH_SOURCE); never interpolate them into the command string. |
dryRunByDefault |
false |
Treat calls as dry runs unless dryRun: false. |
followSymlinks |
false |
Allow patch paths to traverse symlinks. |
maxFiles |
50 |
Max file sections per patch. |
maxPatchBytes |
524288 |
Max patch text size in bytes. |
maxDiffBytes |
16384 |
Max per-file diff kept in the result metadata (larger diffs are emptied and marked truncated). |
ctx.shell. The sandbox strength is whatever the loaded shell executor enforces (bash-sandbox fences; bash-local does not) — the same risk posture as the native bash tool. Every request carries a sandboxPolicy and reports sandbox facts so "policy denied" is distinguishable from "command failed".apply_patch resolves ctx.sandboxPolicy.resolve({ session }) per call — the session's mode override plus its cwd as the workspace root — exactly like the native write/edit tools, and resolves plan paths against that same root. Without it the enforcing filesystem falls back to the deployment root, which makes in-workspace writes fail as workspace-write denials even in a danger-full-access session. A workspace-write denial surfaces as a PatchError whose message carries the backend text (the structured [sandbox: …] marker and the same-turn escalation fields are not implemented; use the native write/edit tools when you need to escalate).write tool (ctx.fs has no mkdir); the error names the missing directory.trimEnd → trim, deliberately (fuzzy matching is unsafe for destructive ops; it is on the roadmap).npm install
npm run typecheck # against 0.2.0-rc.1 peers (devDependencies)
npm run typecheck:0.2.0 # against real 0.2.0-rc.1 peer packages installed from the registry (dual-baseline proof)
npm test # vitest, 92 tests
npm run lint
npm run build # lib/
npm run verify:source # static safety assertions (intent dance, no node:fs, …)
npm run smoke # load-level smoke against a stub host
Manual verification on a live DSH (dsh plugin --profile web add → restart → call the tool in a session) is intentionally left to the operator.
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。