nuwa-skill
alchaincyf
你想蒸馏的下一个员工,何必是同事。蒸馏任何人的思维方式——心智模型、决策启发式、表达DNA。Distill how anyone thinks.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:hakulat2023/dsh-session-delete
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
Session deletion for DeepSeek Harness.
DeepSeek Harness can archive a Session, but archiving only hides it — there is no way to get rid of
one. This plugin adds that missing verb: Delete session in the Session row's “…” menu, a
remote.sessionDelete host namespace, and the session_delete / session_restore agent tools.
Deletion is deliberately recoverable: the Session's durable log is moved into a local trash
directory, so a mistake costs a mv, not a conversation.
One deletion performs four steps:
workspace/session-activity waterfall. Live work is refused unless the caller allows a stop;
when it is, workspace/session-stop cancels the turn and the plugin waits (bounded) for the
Session to go idle. A Session still resident in the host process is refused before any side
effect and only deleted after a second, explicit confirmation.<sessionId>-<timestamp>, carrying a trash.json record with the title, cwd, original
directory, byte/file counts, and deletion time. purge: true deletes it outright instead.
A small record is also written under $DSH_HOME/session-delete/entries/ (entry path plus original
directory, no Session content), because macOS refuses to let a process enumerate ~/.Trash
(TCC): without it a trashed Session could not be found again. See
docs/architecture.md.sessionIds), removed from the registry-global archive and pin sets, and its projection-cache
record is deleted.api-session/removed is emitted, so every connected browser drops the row
immediately.The Session directory is located through the persistence backend's own locate(header) when it
offers one, so a backend that changes its on-disk layout does not need a plugin update; otherwise the
plugin falls back to the documented sessions/<projectKey(cwd)>/<encodeSegment(id)> layout.
| DeepSeek Harness | 0.2.x (developed and verified against 0.2.0-rc.2) |
| Node.js | >= 20 |
| Surface | any profile that mounts the Session store, the JSONL persistence backend, the Workspace registry, and the Web client (dsh-web-app / desktop) |
The plugin has no npm dependencies and no build step: the browser half is a hand-written
module in the window.__ModuleLoader__.load({ id, factory }) shape the Web client already consumes,
and the host half imports nothing outside node:*. See
docs/plugin-packaging.md for why that matters for third-party plugins.
The package is a DSH bundle: package.json declares dsh.bundle.patch and dsh.client, and
cordis.patch.yml inserts the host row.
# from a local checkout (this repository)
plugin_manager install_bundle target: /absolute/path/to/dsh-session-delete
# or from GitHub, by tag, with the bundled CLI
dsh plugin --profile desktop add github:hakulat2023/dsh-session-delete#v0.1.0
# or from the registry, once published
dsh plugin --profile desktop add dsh-session-delete
The bundle patch that gets mounted is one row:
- insert:
- id: session-delete
name: dsh-session-delete
After installing, restart the application once. The host half is a Node ESM module and the running process keeps the module generation it already loaded (DSH's own limitation: a replaced package needs a restart to load fresh JavaScript). The browser half is served from disk and only needs a page reload.
Session row → “…” → Delete session → confirm.
| Tool | Arguments | Effect |
|---|---|---|
session_delete |
session_id (required), stop_activity (default true), force (default false), purge (default false) |
Moves the Session to the trash; purge: true deletes the bytes permanently instead. |
session_restore |
session_id (required) |
Moves a trashed Session directory back to its original location. |
remote.sessionDelete.delete({ sessionId, stopActivity?, force?, purge? }) and
remote.sessionDelete.restore({ sessionId }) — the same operations the UI dialog uses.
A trashed Session is an ordinary directory in the platform's trash:
| Platform | Where it went | Notes |
|---|---|---|
| macOS | ~/.Trash/<sessionId>-<timestamp>/ |
Finder shows it; “Put Back” is not offered (Finder did not move it), but session_restore works |
| Linux | $XDG_DATA_HOME/Trash/files/… with its .trashinfo |
the desktop's own “Restore” works as well |
| Windows | the Recycle Bin | the plugin cannot read the bin back, so restore it by hand |
cat ~/.Trash/<sessionId>-*/trash.json # originalDirectory, title, cwd, sizes
session_restore(session_id) puts it back and withdraws both records; the Session reappears in the
list once the Workspace registry next indexes stored headers (a reload, or the next launch).
| Field | Default | Meaning |
|---|---|---|
trash |
"system" |
Destination: "system" uses the platform's own trash, "directory" uses trashRoot, and any other string is taken as an absolute directory. |
trashRoot |
$DSH_HOME/session-trash |
The directory used by trash: directory (and by trashRoot alone, for 0.1 compatibility). |
restoreIndexRoot |
$DSH_HOME/session-delete |
Where the restore records live (entries/<entry name>.json). Metadata only — never Session content. |
# keep the platform trash (the default): nothing to configure
- id: session-delete
name: dsh-session-delete
# or own the destination, e.g. on a machine whose ~/.Trash is undesirable
- id: session-delete
name: dsh-session-delete
config:
trash: directory
trashRoot: /Volumes/big/dsh-session-trash
~/.Trash. Moving in, reading a known entry, and moving it
back out all work; readdir is refused by TCC. That is the only reason a restore record exists —
session_restore follows the record instead of searching the trash. Emptying the trash makes the
record stale, and a stale record is pruned rather than reported as a failure.session_delete reports trashedTo: null and session_restore explains that the folder
has to be restored from the Recycle Bin. A platform without a reachable system trash logs a warning
and falls back to trash: directory.force (the log
is gone; the in-memory copy becomes unusable).AbortSignal; if the work outlives it, the call fails with session/delete-active and
nothing is moved.session/delete-failed and the log is left exactly as it was — the provenance record written
for the attempt is withdrawn.Failure codes surfaced by the Remote namespace: session/not-found, session/delete-live,
session/delete-active, session/delete-failed, session/restore-missing,
session/restore-conflict.
node test/verify.mjs # or: npm test
The self-test needs no DSH runtime, no network, and no dependencies: it builds a temporary session root, drives the real trash logic through a fake host adapter, mounts the real plugin body against a fake Cordis context, and checks the pieces that are easy to get wrong —
~/.Trash naming, the XDG files/info pair and its .trashinfo, and the
PowerShell recycle command;Layout:
| Path | Role |
|---|---|
lib/session-trash.js |
Admission, cleanup and restore over an injected host adapter (unit-testable) |
lib/trash.js |
Platform trash backends: macOS ~/.Trash, the XDG trash, the Recycle Bin, or a directory |
lib/restore-index.js |
The metadata record that makes restore work on a trash that cannot be listed |
lib/index.js |
Host plugin: the sessionDelete service, its Typert binding, and the two agent tools |
lib/typert.host.js |
Hand-written Typert manifest (strict codecs; registered by typert-loader) |
lib/client.js |
Browser half: menu row, confirmation dialog, remote.sessionDelete calls |
cordis.patch.yml |
Bundle patch: inserts the host row |
test/verify.mjs |
The self-test above |
docs/ |
Architecture and packaging notes |
| What | Evidence |
|---|---|
| Real macOS trash | a directory renamed into the real ~/.Trash, read back by path, then renamed out — readdir('~/.Trash') refused throughout (TCC), which is exactly what the restore record covers |
| Delete, in the packaged app | macOS / desktop / DSH 0.2.0-rc.2, after a restart so the host half really was 0.2.0: a disposable Session's 13,241-byte log landed in ~/.Trash/<id>-<timestamp>/ with its trash.json (backend: "macos-trash", title recorded) and a restore record; the original directory, its projection-cache record, and its workspace.json account were gone |
| Restore, in the packaged app | session_restore put the log back and withdrew both records — the directory then held only session.lock and the log |
| Purge, in the packaged app | session_delete(purge: true) reported deleted permanently and left nothing in the trash |
| Client | the Session menu's occupants include session-delete (order 500, active) — once, after the 0.1.1 reload-safety fix |
| Self-test | 32 checks (node test/verify.mjs): the platform backends, an unlistable trash covered only by the restore record, stale records, an unusable destination that must not half-delete a log, the Typert manifest and SRC discovery, lossless-JSON tool results, browser-side re-application |
| CI | Node 20/22/24 × Ubuntu/macOS/Windows |
DeepSeek Harness does not accept external pull requests
at this stage, and explicitly invites plugins to live in their own repositories. This repository
therefore carries the dsh-plugin topic so it can be
discovered; issues and pull requests against this plugin are welcome here.
MIT © 2026 hakulat2023
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: session。