dsh-session-cleanup
Đã xác minhdsh-session-cleanup · v0.1.1 · MIT
DeepSeek Harness plugin for interactive session cleanup and /nix on pi-tui and dsh-tui, inspired by pi-session-cleanup.
Cài đặt
dsh plugin add dsh-session-cleanup Xác nhận layer đã áp bằng dsh --profile default --dump-config — xem hướng dẫn cài plugin.
Mã nguồn
Thẻ
Tác giả
Readme
dsh-session-cleanup
Interactive session cleanup for DeepSeek Harness.
Inspired by pi-session-cleanup, ported to DSH so sessions can be listed and removed through official host services instead of Pi JSONL files.
What this is
This is a DSH plugin, verified on the pi-tui and dsh-tui profiles. It is inspired by MasuRii's Pi extension, but it is not a drop-in Pi package.
On DSH it:
- lists sessions with
sessionPersistence.listSnapshots()+locate() - deletes through the host cleanup chain: stop / flush / detach, then the session directory, projection cache, workspace accounting, and pi2dsh sidecar
- sends the session directory to Trash on macOS, and uses
rm -rfon other platforms
Deletion is the whole session directory (and sidecar), not a single session.jsonl.zstd. The leftover Pi trash/unlink path refuses those DSH artifacts so it cannot leave a hole in persistence.
Supported TUIs
| Profile | Package | Notes |
|---|---|---|
pi-tui |
dsh-pi-tui | Original verification target |
dsh-tui |
@deepseek-harness-tui/dsh-tui | Claude Code-style TUI; /nix quit covers delete-current-and-exit, which that TUI does not do itself |
The web profile is not a target. It already has a dedicated session-delete plugin.
Installation
dsh plugin --profile pi-tui add dsh-session-cleanup
dsh plugin --profile dsh-tui add dsh-session-cleanup
From this repo, or a local checkout, the package must ship compiled JS (lib/dsh-entry.js):
npm run build
dsh plugin --profile pi-tui add file:$PWD
# or
dsh plugin --profile dsh-tui add file:$PWD
Restart the profile. Confirm it loaded:
dsh --profile pi-tui --dump-config | grep session-cleanup
dsh --profile dsh-tui --dump-config | grep session-cleanup
dsh --profile pi-tui # or: dsh --profile dsh-tui
Commands
| Command | Arguments | Description |
|---|---|---|
/session-cleanup |
— | List orphaned sessions (cwd directory is gone) |
/session-cleanup orphaned |
— | Same as default |
/session-cleanup current |
— | Sessions from the current working directory |
/session-cleanup all |
— | All persisted sessions |
/session-cleanup delete |
<id...> |
Delete those session ids after confirmation |
/session-cleanup help |
— | Usage |
/nix |
— | Create a new DSH session, then delete the current one |
/nix agent |
[preset] |
Same, with a selected or named agent preset |
/nix quit |
— | Delete the current session and exit DSH |
/nix help |
— | /nix usage |
With a userQuestions service (both pi-tui and dsh-tui mount one), /session-cleanup opens a multi-select + confirm flow. Without one, it prints the list and you delete by id.
TUI / menus show the argument grammar in the command description. After-space completions (orphaned, quit, …) need a host-side argumentHint hook and are not wired yet.
/nix on DSH
/nix is destructive and asks for confirmation.
/nixcreates a new session withctx.agents.create(orctx.sessions.create) using the current cwd and preset, then deletes the previous session./nix agent [preset]does the same with a DSH agent preset. Without[preset], it opens a picker./nix quitdeletes the current session, disposes the root fiber, andprocess.exit(0).
DSH has no host-level “current session pointer”. After /nix, the TUI may keep showing the old conversation until you resume the new id:
dsh --profile pi-tui --resume <new-id>
dsh --profile dsh-tui --resume <new-id>
Safety
- Active session excluded from the cleanup list
- Confirm before delete
- macOS Trash for session directories; other platforms permanently remove them
- Cleanup order — disk/log removal is confirmed before workspace accounting is stripped
- Both id spellings —
<uuid>andsession-<uuid>
Development
npm run build # emit lib/dsh-entry.js for DSH
npm run test # test suite
npm run check # build + test
Native DSH entry: dsh-entry.ts → lib/dsh-entry.js. That graph does not import Pi packages.
Stock pi2dsh (remote main) is enough for this plugin. A patched pi2dsh is only needed if you load the leftover Pi extension path instead of the native DSH commands.
Attribution
Command names, scopes, and the /nix idea come from pi-session-cleanup (MIT © MasuRii). The DSH port uses DeepSeek Harness persistence, workspace accounting, and agent presets.