Introduction¶
In the local development workflow of DeepSeek Harness (DSH), an Agent may modify files, which introduces the risk of accidental errors. Traditional rollback methods (such as manual git checkout) lack a preview mechanism and can easily cause code pollution. The dsh-tauri-turnrewind plugin addresses this pain point by automatically creating a private Git snapshot for every Agent change and implementing a two-phase undo workflow.
What Is This¶
This is a local turn rollback plugin (a TypeScript rewrite, located in packages/, following the workspace plugin specification). It automatically creates a private snapshot for every turn accepted by an Agent and records the snapshot mapping in the ledger. Through the /undo command, users can preview a red/green diff and, after confirmation, roll files back to their state before the turn started.
Core Capabilities¶
- Automatic private snapshots: A private snapshot is created automatically for every Agent change.
- Two-phase undo workflow: First, a preview card is shown (red/green diff +
+x -ybadge); confirmation to execute or cancellation is performed inside the card. The plan expires after 5 minutes; expiration and cancellation only lock execution and do not erase ledger records. - Conflict detection and handling: If files are modified again after preview (a conflict), overwriting is rejected and the user is prompted to preview again. Supports
--skip-conflictsto skip conflicting files, or--forceto overwrite forcefully. - Workspace eligibility guard: The session working directory must be inside a Git worktree; non-Git directories are disabled (the turn is recorded as skipped).
- Self-healing and diagnostics: The snapshot chain self-heals (automatically falls back and rebuilds after the private repo is deleted or corrupted), and supports
--doctorfor read-only diagnostics (Git availability, snapshot repository health, etc.). - Async model: Snapshotting, diffing, and restoration use asynchronous Git subprocesses and do not block the Host event loop.
Usage¶
In a DSH session that has loaded this plugin:
- Basic undo:
By default, the two-phase workflow is entered: first a preview card is output, and confirmation to execute or cancellation is performed inside the card.
/undo
- Specify turn ID:
Specify the full turn ID to undo.
/undo <session-id>:<turn-number>
- View plan (without executing):
Only outputs the file list and classifications, without diff.
/undo --dry-run
/undo --preview
- Handle conflicts:
During confirmation, the disk state is validated again; if files are modified after preview, a strategy can be selected:
/undo --skip-conflicts # 只恢复无冲突文件
/undo --force # 强制覆盖冲突文件
- Other operations:
/undo --cancel <plan-id> # 取消一个待确认的预览计划
/undo --doctor # 只读诊断报告(不能与其他选项组合)
Notes and Constraints¶
- Experimental nature: It is still positioned as an experimental feature; the restore path directly uses Node/Git and has not yet been integrated with a controlled host sandbox/Tauri bridge.
- Git directory mode: The workspace must be inside a Git worktree; non-Git directories are disabled (the turn is recorded as skipped, with reason
TURNREWIND_GIT_REQUIRED). - No history modification: It does not modify the user project’s HEAD, branches, index, stash, or commit history.
- Scope limitation: Only files inside the workspace bound to the current session are processed; files outside the workspace are neither captured nor undone.
- Performance and limits: The per-file snapshot/restoration limit is 64 MB; for large workspaces, no budget-prescan is performed, and snapshot duration and disk usage grow with repository size.
Summary¶
dsh-tauri-turnrewind provides local-level snapshot and rollback capabilities, and the two-phase confirmation mechanism reduces the risk caused by Agent modifications. Currently, this plugin is bundled with the desktop edition; after installation, it can be used without manual configuration. For more details and source code, please visit GitHub.