メインコンテンツへスキップ
H

dsh-session-cleanup

hyein-cbio/dsh-session-cleanup

DeepSeek Harness plugin for interactive session cleanup and /nix, inspired by pi-session-cleanup.

インストール

dsh plugin --profile web add github:hyein-cbio/dsh-session-cleanup

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 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 -rf on 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

CommandArgumentsDescription
/session-cleanupList orphaned sessions (cwd directory is gone)
/session-cleanup orphanedSame as default
/session-cleanup currentSessions from the current working directory
/session-cleanup allAll persisted sessions
/session-cleanup delete<id...>Delete those session ids after confirmation
/session-cleanup helpUsage
/nixCreate a new DSH session, then delete the current one
/nix agent[preset]Same, with a selected or named agent preset
/nix quitDelete 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.

  • /nix creates a new session with ctx.agents.create (or ctx.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 quit deletes the current session, disposes the root fiber, and process.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

  1. Active session excluded from the cleanup list
  2. Confirm before delete
  3. macOS Trash for session directories; other platforms permanently remove them
  4. Cleanup order — disk/log removal is confirmed before workspace accounting is stripped
  5. Both id spellings<uuid> and session-<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.tslib/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

MIT

関連プラグイン