Preface

DeepSeek Harness (DSH) accumulates a large number of persistent sessions during daily use. These sessions usually only grow and never shrink. As the number increases, session_projcache.json expands, causing the web interface to become sluggish. The DSH host currently does not provide an API for deleting or archiving sessions. This plugin fills that gap, and all three indexes are automatically kept in sync.

Features

Archiving and Restoration

The archive operation moves sessions/<ws>/<id>/ to archive-sessions/<ws>/<id>/. Archiving is reversible, does not free disk space, but the session disappears from the list, and the projcache record is cleared. The restore operation moves the archived session back to its original location, and the projection cache is automatically rebuilt through a cold read.

Permanent Deletion and Automatic Policy

Permanent deletion completely removes the archive directory and frees disk space. This operation is irreversible and requires a second confirmation before execution. The automatic policy allows keeping the latest N sessions per workspace. When the limit is exceeded, the oldest non-running sessions are automatically archived.

Ungrouped and Invalid Workspace Management

The plugin explicitly lists _no-cwd sessions as well as sessions whose workspace paths have been deleted, and supports managing these sessions.

Size Management and Sidebar Sync

The size panel displays the projcache size, session counts per workspace, and archive statistics. After archiving, restoring, deleting, or applying the automatic policy, the client immediately notifies the host to re-fetch the session list baseline (sessions.refresh() / workspaces.refresh()). The left sidebar refreshes immediately, without restarting dsh web.

Cross-Volume Support and Distillation Handoff

When the archive area is configured on another disk volume, it automatically falls back to using copy + rm commands to resolve the Windows EXDEV protection issue. Before archiving/deleting, you can one-click copy the wiki-distill distillation instruction, first settling the session into the knowledge base before cleanup, ensuring no knowledge loss.

Installation and Enablement

Use one command to install both the plugin and the menu host dsh-knj-menu:

dsh plugin --profile web add dsh-knj-session-management dsh-knj-menu

Configuration

Add the following configuration to cordis.patch.yml:

- insert:
    - id: dsh-knj-session-management
      name: 'dsh-knj-session-management'
      config:
        maxSessionsPerWorkspace: 60   # 每工作区保留上限,0 关闭自动归档
        enabled: true                 # 自动归档总开关

Notes

  • The DSH host does not provide a session deletion/archiving API. This plugin adds this capability, and all three indexes are automatically kept in sync.
  • The default archive path is $DSH_HOME/profiles/<profile>/dsh-session-archive.
  • This plugin only performs orchestration; distillation itself is completed by the existing wiki-distill skill.
  • The plugin runs with the permissions of the current dsh process. Check the source code and license before installation.

Summary

This plugin solves the data bloat problem caused by DSH sessions only growing over time. It provides full lifecycle management from archiving and restoration to permanent deletion, and helps maintain system health through automatic policies and a size panel.

Directory page: https://www.skillhub.cn/plugins/yangdongzhen590/dsh-knj-session-management
GitHub: https://github.com/yangdongzhen590/dsh-knj-session-management