dsh-session-manager: Batch Management of DSH Session History

Introduction

DSH saves session logs to disk with every conversation, but its built-in session service does not provide APIs for deletion or archiving. Over time, a large number of historical sessions accumulate in the DSH_HOME/sessions/ directory, consuming disk space and making it difficult to quickly locate or clean up old entries.

dsh-session-manager provides a sidebar panel that enables batch browsing, archiving, deletion, and restoration of DSH historical sessions.

What It Is

This is a session management plugin for DeepSeek Harness (DSH), published by maintainer yueyao. It operates at the filesystem level to archive, delete, and restore historical sessions, filling the functional gap left by DSH’s native session service.

Core Features

The plugin reads DSH session logs and extracts each session’s title (read from the session/title event), actual working directory, source, last update time, and log size, then displays them in the sidebar. Filtering by title, working directory, or ID is supported.

Sub-Agent Filtering

Sub-agent sessions are hidden by default and can be enabled in the UI when needed.

Batch Operations

  • Multi-select: Check one or more sessions in the sidebar, or use “Select All.”
  • Archive: Move selected sessions to the DSH_HOME/archive/sessions/ directory. All data is fully preserved and can be restored at any time.
  • Delete: Permanently delete selected sessions (rm -rf). This operation is irreversible and requires a second confirmation.
  • Restore: Restore archived sessions back to their original working directory.

Session Title Parsing

DSH session logs are zstd-compressed, append-only event streams. The plugin identifies frame boundaries using the magic bytes 28 B5 2F FD, decompresses them, and reads:
- Frame 0: Contains the unencoded cwd (working directory).
- Header frame: The earliest session/title event.
- Trailing frames: Subsequent session/title events (i.e., renames).

The title with the largest seq is taken as the final title. Results are cached per session and invalidated when the log’s mtime or size changes. The initial scan of 170 sessions takes only a few milliseconds.

Agent Tools

The plugin registers four tools with the DSH Agent, which can be used directly in conversation:
- session_manager_list: List all sessions and archives.
- session_manager_archive: Batch archive sessions (pass in ids).
- session_manager_restore: Batch restore archived sessions (pass in ids).
- session_manager_delete: Batch permanently delete sessions (pass in ids).

Installation and Enablement

Install via the DSH plugin manager (with an indexed source in Discover), or simply place the package into the Profile’s node_modules directory.

# Via the DSH plugin manager (assuming a source is configured)
dsh plugin install dsh-session-manager

After installation, the “Sessions” entry will be visible in the DSH sidebar.

Typical Usage

  1. Open Sessions in the sidebar.
  2. Check the sessions you want to archive (Select All can be used).
  3. Choose Archive from the context menu of the selected items, or switch to the Archived tab and choose Restore.
  4. For permanent cleanup, choose Delete and confirm.

Agent usage examples:

// List all sessions
session_manager_list

// Archive sessions with IDs "abc123" and "def456"
session_manager_archive ids: ["abc123", "def456"]

// Restore archived sessions
session_manager_restore ids: ["ghi789"]

// Delete sessions
session_manager_delete ids: ["jkl012"]

Use Cases and Notes

This plugin is suitable for DSH users who frequently need to clean up or archive historical sessions, or who want to manage session lifecycle from the Agent level.

The plugin runs with the permissions of the current DSH process. It is recommended to review the source code and license (MIT) before installing. The directory structure is as follows:

DSH_HOME/sessions/<cwd>/<id>/session.v4.jsonl.zstd   # Active sessions
DSH_HOME/archive/sessions/<cwd>/<id>/...            # Archived sessions
DSH_HOME/archive/sessions-index.json                 # Archive index

Summary

dsh-session-manager fills the gap in DSH’s session management capabilities. Through the sidebar panel and Agent tools, it makes browsing, archiving, deleting, and restoring historical sessions fully actionable. If you have accumulated a large number of sessions in DSH, this plugin can significantly improve management efficiency.

  • Plugin directory page: https://www.skillhub.cn/plugins/yueyao/dsh-session-manager
  • GitHub repository: https://github.com/yueyao/dsh-session-manager
羽毛球分组比赛记分
小程序二维码

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

Xiaoye