Preface¶
DeepSeek Harness (DSH) uses the local disk to store session logs, projection caches, spilled tool outputs, and attachments. When running multiple tasks, it becomes difficult to answer two questions: how many bytes does each task occupy, and which files can be deleted without corrupting usage statistics and context recomputation. Manually digging through ~/.dsh and the system temp directory is time-consuming and risks accidentally deleting spill paths that are still being referenced.
The dsh-space-optimizer (maintained by wojiao42) introduced below provides an “Optimize Space” entry at the bottom of the Web sidebar. Opening it reveals a read-only scanned space ledger; reclamation only happens after explicit confirmation, and it only handles orphaned junk and task-level optimizable auxiliary artifacts, never trimming session logs.
What is this¶
dsh-space-optimizer is a DSH bundle plugin: The Host side provides a local ledger and reclamation API, while the client injects into @deepseek-ai/dsh-client-ui-sidebar, mounting a button in the same row as the token cost badge under sidebar.footer.action.
In one sentence: Per-task disk-space ledger for DeepSeek Harness—see the disk usage per task, how much is optimizable, and the orphaned junk not belonging to any task; verify and then check items individually for confirmation.
Current version 1.0.5 (see the repo’s package.json), License MIT. Community directory page: skillhub.cn/plugins/wojiao42/dsh-space-optimizer; Source code: github.com/wojiao42/dsh-space-optimizer.
Core Features¶
Space Ledger¶
Clicking “Optimize Space” summarizes at the top of the panel, similar to:
Occupied 5.0 MB · Optimizable 3.0 MB · Orphaned Junk 8.3 MB · Reclaimed 11.7 MB
The Tasks section lists sessions row by row (the current task is pinned to the top and marked). The meanings of the main columns are as follows:
| Column | Meaning |
|---|---|
| Occupied | Bytes exclusively occupied by the task on disk (logs + projection cache + optimizable items) |
| Log | The current generation of ~/.dsh/sessions/<project>/<session>/session.v4.jsonl.zstd |
| Temp Spill | Spilled large tool outputs (%TEMP%\dsh-spill-<id>\session-<hash>\) |
| Optimizable | Temp Spill + superseded old generations |
| Referenced Attachments | Attachments referenced by the task; shared ones are marked, counted only once in the total |
Labels include Current, Running, Subtask (origin: subagent). Running and Current tasks cannot be selected—temp files might still be read.
The Orphaned Junk section lists items not belonging to any task, such as: plugin market directory caches, orphaned temp files, invalid projection caches, and orphaned attachment objects. The README contains a full explanation of the determination conditions for each category.
What can be optimized, what cannot be touched¶
Session logs are the source of truth: projections like dsh-token-meter, dsh-client-ui-chat, dsh-session-stats all rely on the complete event stream; the ledger only counts log size and provides no slimming methods.
Only three types of auxiliary artifacts can be safely optimized:
- Spilled large tool outputs (Temp Spill)
- Superseded old format / old generation logs
- Unreferenced attachments (only become orphaned junk after task deletion or reference disconnection)
Cleaning up task-level “Temp Spill” will not destroy the conversation body, but the log stores the spill path. After deletion, only the summary remains for the full text of that large tool output segment—therefore, task-level items are not checked by default and require manual confirmation.
Default Selection and Safety Design¶
- Scan is strictly read-only: No bytes are modified until “Confirm Optimize” is clicked.
- Orphaned junk is checked by default; task-level items are not checked by default.
- Paths do not leave the Host: The renderer process only sends back
targetId. During reclamation, the Host rescans and only deletes targets that still exist; “clear everything” is not accepted, targets must be explicitly listed. - The reclamation route requires a custom header
x-space-optimizerand rejects cross-site simple POSTs, reducing the risk of being triggered accidentally by web pages. - If a session log cannot be read, the “orphaned” category of attachments abandons reclamation entirely, and the reason is marked in the UI.
The plugin accesses the local file system with the permissions of the current DSH Host process; it is recommended to read the source code and the MIT license before installation to ensure it complies with your environment policy.
Installation and Activation¶
The official README provides the following installation method for the Web profile (replace OWNER with the repo owner wojiao42):
dsh plugin --profile web add github:wojiao42/dsh-space-optimizer
Refresh the page after installation; “Optimize Space” should appear at the bottom of the sidebar. Uninstall:
dsh plugin --profile web remove dsh-space-optimizer
The DSH ecosystem adopts the “everything is a plugin” philosophy; community directories like skillhub.cn are independent sites and have no official affiliation with DeepSeek / High-Flyer. The installation commands in this article are based on the GitHub README.
Typical Usage¶
- Run the above
dsh plugin --profile web add …and refresh the Web client. - Click “Optimize Space” at the bottom of the sidebar and wait about 1–2 seconds for the scan to complete (the README measured ~170 ms for 9 tasks).
- Verify the occupancy and optimizable items row by row; orphaned junk is usually checked, task-level spills etc. need to be checked manually.
- Look at the bottom “N items selected · X reclaimable”, click “Confirm Optimize” after verifying; once done, it displays “Reclaimed X (N files)”.
If you are not confident, you can just scan without confirming—the interface will not write to the disk.
If you need to perform read-only verification in the terminal (the script README states it will never delete files):
node tools/space-report.mjs
# or JSON output
node tools/space-report.mjs --json
(Needs to be executed in the plugin source directory; when installed via dsh plugin add github:…, the path is located inside the profile’s node_modules.)
Host-side Configurable Settings¶
The Host side apply(ctx, config) supports the following fields (all from the README):
| Field | Default | Description |
|---|---|---|
home |
$DSH_HOME |
Harness home directory |
tempDir |
System temp directory | Location to scan for dsh-* spills |
minIdleHours |
24 |
How long temp files without session attribution must be idle to be considered expired |
marketCacheMinAgeHours |
1 |
Minimum age for market cache (the cache itself has a 6-hour TTL) |
Use Cases and Precautions¶
Who is it for
- Users who run multiple tasks and subtasks long-term and want to see disk usage clearly before deciding whether to clean up.
- Users who need to regularly reclaim orphaned junk like orphaned spills, old generations, and market caches under
%TEMP%, but do not want to manually delete things in~/.dsh.
Things to be aware of during use
- The “Optimizable” amount for most tasks is very small: the bulk is session logs (README says around the 0.8 MB/task magnitude), which cannot be safely trimmed; the plugin’s primary value is a transparent ledger, followed by space reclamation.
- Reclamation does not go to the recycle bin; it is unrecoverable; items related to running/current tasks have selection disabled.
- Attachments are content-addressed; when shared by multiple tasks, each row will be marked, and total occupancy will not be a simple sum of the “Occupied” column of each task.
- The plugin makes no external network requests; scanning and reclamation are local file operations.
- Changing Host code (
index.js/lib/) requires restarting the Harness; clientclient.jscan be hot-swapped via the sidebar plugin switch (see README “How to make code changes take effect”).
Conclusion¶
dsh-space-optimizer puts “how much each task occupies, what is orphaned junk, and what needs your own nod” into a ledger in the sidebar, and adheres to the design principles of not trimming session logs, secondary confirmation before reclamation, and explicit targets. If you are accumulating sessions and tool outputs in the DSH Web sidebar long-term, you can install the plugin first just for scanning, then select items for reclamation as needed.