Introduction

Running agents in DeepSeek Harness (DSH) often involves using write/edit to modify files. Once such an operation is executed, the original file content is overwritten. If the model makes a mistake, or if a batch refactor corrupts a critical file, the content before the change is lost and can only be recovered through manual backups or version control.

dsh-snapshot turns this into a plugin: it automatically backs up the file history after every write/edit call, allowing you to restore to any historical version when needed. Below is an introduction to its features, installation methods, and usage notes.

What is it

dsh-snapshot is a host plugin maintained by Hyna-hla for DeepSeek Harness, positioned as “File Snapshots and Undo” with an MIT license. It does two things:

  1. Intercepts write/edit tool calls and automatically backs up the file content to the snapshot repository.
  2. Provides a set of tools to query, restore, purge historical versions, and export the current session as Markdown / JSON.

DSH’s philosophy is “Everything is a plugin,” and dsh-snapshot is integrated into the host via this composition approach.

Core Features

Automatic Backup

After every write/edit tool call, the plugin writes the file’s current content to the snapshot repository, with a path like:

<workspace>\.dsh-snapshots\snap-<b64>.json

Where <b64> is the result of encoding the file path with btoa. Each tracked file corresponds to one JSON file. There are two limits: a maximum of 20 versions per file, and single version content not exceeding 2MB. When the limit is reached, old versions are overwritten to free up space rather than deleted. This is because DSH’s FS service lacks the ability to mkdir/unlink, so the plugin can only overwrite existing files.

Four Tools

  • snapshot_list: Lists the snapshot repository, showing the number of versions and the timestamp of the latest version for each tracked file.
  • snapshot_restore: Restores a file to a specified historical version. It automatically backs up the current content before restoring, meaning the restore operation itself can be undone.
  • snapshot_purge: Clears all historical versions.
  • export_session: Exports the current session as Markdown / JSON.

A typical workflow is: first perform snapshot_list to confirm which versions exist for a file, then use snapshot_restore to restore to a specific version; use snapshot_purge to clear history when it is no longer needed.

Installation and Enablement

The documentation does not provide a one-click install command; it requires manual completion of three steps.

Step 1: Copy the build artifacts into node_modules\dsh-snapshot in the profile, or import them via a file: dependency.

Step 2: Register in cordis.patch.yml. Both id and name should be dsh-snapshot. Configure the two limits in config:

- insert:
    - id: dsh-snapshot
      name: dsh-snapshot
      config:
        maxVersions: 20
        maxContentBytes: 2097152

maxContentBytes is the byte limit for single version content, and 2097152 corresponds to 2MB.

Step 3: Restart DeepSeek Harness; the composition is loaded when the process starts.

After the above steps, the plugin takes effect with the host process.

Two Implementation Details

The first is the sandbox policy. The host root context cannot access the session workspace. When the plugin needs to write snapshots to the workspace, it must pass through sandboxPolicy, specifically by calling sandboxPolicy.resolve({session}) to resolve the policy corresponding to the session. If you are writing a similar plugin yourself, pay attention to this.

The second is the repository organization. The snapshot repository is organized as “one JSON per file,” with the filename being the path encoded with btoa. Versions are added or removed by overwriting rather than deleting, for the reason mentioned above—the FS service does not support mkdir/unlink.

Applicable Scenarios and Notes

It is suitable for scenarios where the model modifies files frequently: batch refactoring, multi-round code or configuration modifications, or simply restoring after an accidental change without manual comparison. It is also suitable for preserving archives after a session ends, as export_session can export the session as Markdown / JSON.

Please note a few points before use:

  1. The plugin runs with the permissions of the current DSH process. It is recommended to read the source code before installing to confirm the behavior meets expectations. The license is MIT; the repository address is at the end of the text.
  2. The limits on the number of versions and single version size are set via maxVersions and maxContentBytes in config, and can be adjusted according to the size of files in your workspace.
  3. snapshot_purge will clear all historical versions. Confirm that these records are no longer needed before executing.

Conclusion

dsh-snapshot solves a very specific problem: agents don’t have an “undo” button when modifying files. It uses automatic backups after every write/edit to turn undoing changes into a single tool call. The implementation is not complex, but it saves a significant amount of troubleshooting time.

  • Plugin Directory Page: https://www.skillhub.cn/plugins/Hyna-hla/dsh-snapshot
  • GitHub Repository: https://github.com/Hyna-hla/dsh-snapshot

The directory page is from a community-maintained independent site and has no official affiliation with DeepSeek or Huanfang; please refer to the source code and documentation in the repository above before installing.