dsh-cache-cleaner: Releasing Rebuildable Cache for DeepSeek Harness

Introduction

DeepSeek Harness (DSH) allocates disk space for derivative data such as request images, session projection caches, prepared shells, Chromium caches, downloaded installers, and plugin build caches. None of this data is user data, and all of it can be rebuilt on demand. However, it is scattered across the DSH home directory, system temp directories, the Electron userData directory, and individual plugin directories, which can easily lead to excessive disk usage or accidental deletion that breaks a running application.

The dsh-cache-cleaner plugin provides a fixed, auditable list of 12 cache targets, clearly delineating what is “safe to clean” from what is “not.” It also offers preview and dry-run capabilities before any cleanup, ensuring safety while freeing disk space.

Plugin Positioning

This is a DeepSeek Harness plugin designed to clean rebuildable caches of the DSH core, the desktop client, and installed plugins. It was developed by maintainer you112358 and categorized under Client. The plugin does not touch user data; every entry that can be cleaned is regenerable on demand.

Core Features

  • 12 cache targets grouped into four categories: DSH Core, Temp Spill, Desktop Client, and Plugin Caches & Uninstall Leftovers.
  • Three entry points: Agent tool, Settings page, and HTTP routes — all invoking the same Host service.
  • Two cleanup strategies: clean only entries untouched for 7+ days, or clean everything; temp targets retain entries newer than 6 hours by default.
  • Safety mechanisms: whitelisted root directories, protected subtrees, no symlink following, report-locked-files-instead-of-force-deleting, and dry-run support before cleanup.
  • Zero dependencies: the Host half uses pure ESM with node:fs / node:os / node:path; the Client half is a React component registered into a settings slot.
  • Agent output is a compact Markdown report (size, file count, skipped entries, restart hint).

Installation & Enablement

This plugin is a DSH Bundle. Install it from a local checkout directory (a symlink can be used for easier later modifications):

git clone https://github.com/you112358/dsh-cache-cleaner.git

Run the following in a DSH session:

plugin_manager action=install_bundle target=<absolute path to the cloned dsh-cache-cleaner directory>

cordis.patch.yml will insert an entry named dsh-cache-cleaner. No restart is needed to start scanning; however, to clean caches held by the client, a restart is recommended.

Uninstall command:

plugin_manager action=remove_bundle target=dsh-cache-cleaner

Typical Usage

Settings Page

Navigate to Settings → Cache Cleaner and follow these steps:

  1. Select “Only 7+ days old” or “Everything” — the list immediately re-scans with the chosen strategy.
  2. Review the groups. Each row shows size, file count, decoded path, description, and badges (e.g., “app restart recommended”, “only 7+ days old”, “N newer skipped”).
  3. Click “Clean selected.” The first click activates the button; clicking again within 6 seconds executes the deletion. The page reports freed space, removed files/directories, skipped entries, and errors.

Agent Tool

Scan all caches (default strategy):

{ "ids": null }

Preview cleaning only 7+ day entries for two specific targets:

{ "ids": ["dsh-prepared-shells", "dsh-updater-cache"], "dryRun": true, "olderThanHours": 168 }

Delete specified temp targets (including the newest entries):

{ "ids": ["dsh-temp-subprocess", "dsh-temp-spill", "dsh-temp-misc"], "olderThanHours": null }

The clean tool returns a Markdown report along with structured totals (freedBytes, removedFiles, removedDirs, skipped, fresh).

HTTP Routes

The settings page communicates with the Host via the following routes:

POST /dsh-cache-cleaner/api/scan   { "olderThanHours": 168 | null | omit, "ids"?: string[] }
POST /dsh-cache-cleaner/api/clean  { "ids": string[], "dryRun"?: boolean, "olderThanHours"?: 168 | null }

Requests must pass the Connection’s Host/Origin validation and browser authentication (otherwise a 401 is returned). Only POST is accepted. Responses are either { "ok": true, "value": … } or { "ok": false, "error": { "code", "message" } }.

Cleanup Options

Option Settings Page olderThanHours Scope
Only 7+ days old Only 7+ days old 168 Clean only entries untouched for the last 7 days
Everything Everything null Clean all entries, including caches written seconds ago
Target default Tool/route default Omit Use each target’s own cutoff rule (temp targets: 6 hours; others: no default)

“Everything” does not expand the target list — it is limited to the declared root directories. Protected subtrees are always protected. Files held by running processes are marked as skipped and never force-deleted.

Cleanup Targets

Except for uninstall leftovers, the settings page selects rows with data by default. The target list is as follows:

id Group Scope Restart Required
dsh-request-images DSH Core ~/.dsh/cache/attachments/request-images No
dsh-prepared-shells DSH Core ~/.dsh/dsh-ops/shells/niubash-prepared No
dsh-temp-subprocess Temp %TEMP%/dsh-subprocess-* No
dsh-temp-spill Temp %TEMP%/dsh-spill-* No
dsh-temp-misc Temp Other %TEMP%/dsh-* leftovers No
dsh-electron-http-cache Desktop Client Desktop client HTTP cache Yes
dsh-electron-code-cache Desktop Client Desktop client code cache Yes
dsh-electron-gpu-cache Desktop Client GPU/shader cache Yes
dsh-electron-logs Desktop Client Desktop client logs No
dsh-updater-cache Desktop Client Downloaded installers / blockmaps No
plugin-caches Plugin Plugin caches discovered from active configuration No
plugin-leftovers Plugin Leftover data from uninstalled plugins (disabled by default) No

The Desktop Client and Updater rows correspond to standard Electron userData and updater locations. On platforms where these directories do not exist, the corresponding rows remain empty. Chromium network cache logs remain open while the client is running and cannot be cleaned from within the client. Quit the client first, then run the terminal helper to clean; the cache will be rebuilt on demand:

node scripts/clean-cli.mjs dsh-electron-http-cache --all

Plugin Cache Scanning Rules

The plugin cache row is not a fixed list. Instead, caches are discovered at scan time from the active configuration (DSH_PROFILE_DIR):

  1. Declared caches: A plugin may add a dsh.cache field to its package.json, supporting a string, an array, or { "path": …, "mode": "contents" | "entry" }. Paths can be absolute, start with ~, or be relative to the plugin’s data directory. Declared paths must be a subdirectory of the plugin’s own data root (e.g., ~/.<name>, %LOCALAPPDATA%/<name>, %LOCALAPPDATA%/dsh-<name>, <DSH_HOME>/<name>). Paths inside installers or in other locations are rejected.
  2. Conventional caches: Directories directly named cache, .cache, compile-cache, logs, or tmp under the aforementioned data root.

Use Cases & Notes

This plugin is suitable for scenarios where you need to manage disk usage during DSH or agent development, especially in long-running environments with many plugins.

Note: The plugin runs with the current DSH process’s permissions. It is recommended to review the source code and license before installing. The content in this article is compiled from the GitHub README and community directory resources, and does not constitute an official recommendation.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye