- Home
- Plugins
- Sessions & Messages
- dsh-session-cleanup
dsh-session-cleanup
hyein-cbio/dsh-session-cleanup
DeepSeek Harness plugin for interactive session cleanup and /nix, inspired by pi-session-cleanup.
Install
dsh plugin --profile web add github:hyein-cbio/dsh-session-cleanupREADME
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 profile. 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.
Installation
dsh plugin --profile pi-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
Restart the profile. Confirm it loaded:
dsh --profile pi-tui --dump-config | grep session-cleanup
dsh --profile pi-tui
Currently tested on pi-tui. Other terminals or the web profile are not guaranteed. The web profile already has a dedicated session-delete plugin.
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 (pi-tui has one), /session-cleanup opens a multi-select + confirm flow. Without one, it prints the list and you delete by id.
/ autocomplete in pi-tui shows 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>
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.
License
Related plugins
dsh-turn-rewind
anionex/dsh-turn-rewind
dsh-chat-import
nwflower/dsh-chat-import
dsh-suite (plugin-session-export)
whyihaveyou/dsh-suite
dsh-interconnect
chinesezjc/dsh-interconnect