dsh-session-cleaner: Preview and Permanently Clean Up Archived Harness Sessions

Introduction

When running Agents in DeepSeek Harness (DSH), running multiple sessions piles up data in three locations: session logs under <DSH_HOME>/sessions/, projection checkpoints in storages/session_projcache, and files generated by tools or shells in the workspace. After archiving, the sidebar no longer shows these sessions, but disk logs, attachments, session-specific conversations/<timestamp_title>/ directories, and dsh-spill-* spill directories often remain. Manually deleting paths is both slow and prone to errors, such as accidentally deleting attachments still referenced by other sessions, or missing residual directories left by session-archive.

Below is an introduction to the community plugin dsh-session-cleaner (GitHub: THao712/dsh-session-cleaner). It provides a unified interface in Harness Settings → Session Cleanup: first fully previewing candidate paths, then permanently deleting after two confirmations by the Host. It falls under admin-security, with the design focus on “cleaning only archived sessions” and Host-side path validation, rather than a one-click full disk scan.

What is this

dsh-session-cleaner is released by maintainer THao712, license MIT, current package version 1.10.0 (based on package.json), requires DSH >=0.2.2-rc.3. NPM package name is dsh-session-cleaner-thao712; distribution method is GitHub install, does not depend on NPM market packages.

In one sentence: For archived Sessions, permanently delete session logs, checkpoints, optional workspace artifacts, attachments referenced only by these sessions, tool spill directories, etc., after preview, and support independent Conversation Directory Cleanup (handling residual folders under conversations/). Community directory page: skillhub plugin page; Source code and description: GitHub Repository.

Core Features

Session Cleanup: Deletion Scope

For each selected archived session, the plugin cleans the following resources according to options (Host rederives candidates, browser can only submit checked results, cannot arbitrarily specify paths):

  1. Session-specific Directory (Optional, Disabled by default): <workspace>/conversations/<timestamp_title>/ (containing work/, out/, session.json, copies of AGENTS.md, etc.), and remove mappings from conversations/index.json. Check this only when you need to delete the whole directory; if you want to keep out/, use the “Conversation Directory Cleanup” below.
  2. Session Logs: <DSH_HOME>/sessions/<project_directory>/<session_id>/.
  3. Projection Checkpoints: <DSH_HOME>/storages/session_projcache/sessions/<session_id>.json, and synchronize storage domain memory.
  4. Workspace Archive Accounting: Remove from the workspace domain’s archive collection, pinned collection, and project sessionIds; does not delete the entire workspace or other sessions.
  5. Attachments Referenced Only by These Sessions: Image objects, file objects, and hard links; scan other sessions before deleting, keeping those still referenced.
  6. Tool Output Spill Directories: Directories named session-<sha256(id)[0..12]> under dsh-spill-*.
  7. Files Generated by Sessions in Workspace: Explicit paths from write / edit / str_replace_editor / present, and directory scanning of files created within the session time window.
  8. Optional Attachment Request Cache: <DSH_HOME>/cache/attachments/request-images.

Conversation Directory Cleanup (Independent Feature)

Load Conversation Directory is available at the bottom of the same settings page to handle directories under each workspace’s conversations/ (including residual directories without session records). Each directory is optional:

  • Keep out: Delete work/ and copies of AGENTS.md, keep out/, session.json, etc.; other sessions that only reference out/ will not prevent this mode.
  • Delete All: Delete the entire directory and update index.json.

This feature only affects files inside conversations/, it does not delete session logs, projection checkpoints, or attachments; full session records still go through “Session Cleanup”.

Security and Operational Constraints (Summary)

  • Only processes currently archived sessions; running sessions (including those waiting for approval) are rejected for deletion; loaded but idle sessions show “Opened”, files can be deleted first, and accounting is finalized on the next Harness startup via session-cleaner-pending.json.
  • Paths outside the workspace, files still referenced by other sessions, and protected prefixes (like settings.yaml, credential directories, etc.) cannot be deleted; the preview token binds to revision, file identity, and directory listing; changes in content after preview require re-previewing; deletion requires two confirmations and is irreversible.
  • The task writes to session-cleaner-journal.json and history directories; cross-process lock session-cleaner.lock; partial failures can use “Re-preview Remaining Sessions” recovery mode.

Installation and Enablement

Install from GitHub (Original README command, replace <profile> with your profile name):

dsh plugin --profile <profile> add github:THao712/dsh-session-cleaner

Desktop users can also install via the corresponding plugin page on dsh-market. For local development, use bundle pointing to the absolute path of the repository:

plugin_manager install_bundle  target: <仓库绝对路径>

After installation, refresh the Harness page to load the Client bundle, then open Settings → Session Cleanup. The Host route only accepts requests from the currently logged-in page.

Implementation-wise, the Host registers POST /dsh-session-cleaner/api in index.js; the Client’s client.js registers settings.section (id session-cleaner).

Typical Usage

  1. Open Settings → Session Cleanup. The archived list is sorted by Session Log Size in descending order by default; can switch to sort by time, and search by title, ID, or workspace; 100 entries per page, can “Show More”; maximum 200 sessions can be selected at a time.
  2. Click the folder icon on the right side of the session: prioritize opening the session-specific directory of session-archive; if not present, fallback to the working directory or cwd in the logs.
  3. Check the archived sessions to delete and select the cleanup scope (attachments, workspace files, time window scanning, spill directories, image request cache, etc.). Deleting the whole session directory is disabled by default.
  4. Click Preview Cleanup, verify item by item; workspace-external or shared referenced items are disabled. Then click Permanently Delete Selected Items → Confirm Permanent Deletion.
  5. View the result report; refresh the page if the sidebar still shows the deleted sessions.
  6. Conversation Directory Cleanup: Click Load Conversation Directory, check conversations/<directory>, select “Keep out” or “Delete All”, and execute with two confirmations after Preview Directory Cleanup.

Use Cases and Considerations

Suitable for: Maintainers who use DSH for long-term projects, frequently archive trial sessions, and need to free disk space by previewing, or clean up residual directories from session-archive or orphaned conversations/ folders.

Must Note:

  • The plugin reads and writes local files with the current dsh Host process permissions; read the source code and MIT license before installing and evaluate whether to include it in your environment yourself.
  • Harness’s persistence layer does not have a “Delete Session” API; logs and attachments are deleted directly by this plugin; sessions with Agents still running will be rejected, and must be stopped first.
  • Workspace file candidates depend on tool records and creation times; files already existing with edit, new files created by shell that only modify without writing, etc., will not be checked by default, and must be manually confirmed in the preview.
  • Conversation Directory Cleanup cannot fully prove the safety of external processes or uncommitted drafts; directory scanning exceeding limits or insufficient permissions will be marked as “Incomplete”, and full directory deletion will be blocked.

Conclusion

dsh-session-cleaner consolidates session logs, checkpoints, attachments, spill directories, and workspace artifacts that still occupy disk space after archiving into Settings → Session Cleanup: preview first, then double confirmation, and validation of paths and references by the Host. Refer to the repository README for installation commands and details of deletion scope.

The DeepSeek Harness ecosystem advocates “Everything is a Plugin”; directories like skillhub are community sites with no official affiliation with DeepSeek / Hypersphere.

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

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

Xiaoye