Preface

Each conversation turn in DSH generates a large number of temporary files. These files accumulate in the workspace, consume space, and are often hard to identify, so accidental deletion may lead to data loss. Manual cleanup is both time-consuming and error-prone. The dsh-turn-scratch plugin is designed to solve this problem by providing automatic isolation and cleanup mechanisms that keep the workspace neat and safe.

Introduction

dsh-turn-scratch is a DSH plugin maintained by popujiang, focused on managing the surplus temporary files generated in each DSH turn. Its core logic is to move temporary files out of the workspace, store them in an isolated location, and clean them up after confirmation, thereby preventing them from remaining in the workspace.

Core Features

The plugin mainly provides the following capabilities:

  • Isolate temporary files generated per turn: By default, it does not delete files directly; instead, it moves them to an isolation area first.
  • Safe cross-disk transfer: When the workspace and the isolation area are on different disks, the plugin follows the flow of “copy → verify file count and byte count → record to database → delete original,” ensuring that the original files are not lost even if a crash occurs at any time.
  • Staging area mechanism: It provides a staging area (workDir) where intermediate outputs are written first, keeping the workspace clean from the beginning.
  • Manual restoration and cleanup tools: It provides a series of commands that allow users to view status, restore files manually, mark files for retrieval, or thoroughly clean the isolation area.

Installation and Enablement

To install this plugin, use the official command. Run the following instruction in the terminal:

dsh plugin --profile desktop add "git+https://github.com/popujiang/dsh-turn-scratch.git#v0.3.1"

Configuration Options

After installation, you can adjust the plugin behavior by modifying the cordis.patch.yml file under the profile.

  1. Specifying the isolation storage path (accelerating cross-disk transfer):
    By default, the isolation area may be located on a different disk, which can make file movement slower. If you need faster performance, you can point storeRoot to a path on the same disk as the workspace.
    turn-scratch:
      config:
        storeRoot: "D:/.dsh-turn-scratch"
  1. Disabling the staging area:
    If you do not need the workspace to remain clean throughout the process, you can set workDir to an empty string. The plugin will then operate directly in the workspace, but isolation cleanup will still be performed at the end of the turn.
    turn-scratch:
      config:
        workDir: ""

Common Commands

The plugin provides a set of tool commands for managing the isolation area:

  • scratch_status: View the current isolation status, including which files are being retained and which files have been restored.
  • scratch_restore: Manually restore files from the isolation area back to the workspace.
  • scratch_purge: Clear the isolation area, which performs the actual deletion operation.
  • scratch_mark: Mark specific files as “collectible” so they can be processed at the end of the turn.
  • scratch_workdir: Retrieve the path of the staging area, suitable for writing intermediate outputs during long conversations.

Safety and Notes

  • Default safety policy: The plugin only isolates files by default and does not delete them. Files are actually removed from disk only by manually clearing the isolation area with scratch_purge.
  • Permission restrictions: Due to limited model permissions, it can only perform restore operations, not deletion operations. The final authority over whether files are kept or removed remains with the user.
  • Compatibility: This plugin requires DSH version >=0.1.1-rc.2.

Summary

dsh-turn-scratch solves the problem of DSH workspace clutter by isolating temporary files into a dedicated directory. Its default safety policy (isolate first, delete later) and its safe cross-disk transfer mechanism reduce the risk of accidental data loss. For developers who want to keep their working environment tidy, this is a practical tool.

Plugin details: catalog_url
Source code: github_url