dsh-del-chat 0.0.0-stage → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +149 -2
- package/README.zh.md +124 -0
- package/client.js +526 -0
- package/cordis.patch.yml +3 -0
- package/docs/DETAIL.md +163 -0
- package/icon.svg +9 -0
- package/index.js +483 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +57 -4
- package/purge-core.js +129 -0
- package/test/host-routes.test.mjs +317 -0
- package/test/purge-core.test.mjs +109 -0
- package/test/smoke.mjs +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SLZ2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,150 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-del-chat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Deleting an archived conversation in DeepSeek Harness, for real.** Archiving a
|
|
4
|
+
Session only hides it from the sidebar — the log stays on disk forever. This plugin
|
|
5
|
+
adds a **Delete archive** item to the sidebar Session context menu and removes an
|
|
6
|
+
archived Session's log, projection cache and Workspace record from disk.
|
|
7
|
+
|
|
8
|
+
<!-- prettier-ignore -->
|
|
9
|
+
| Before | After |
|
|
10
|
+
| ------ | ----- |
|
|
11
|
+
| Session archived, still 2.3 MB of `session.v4.jsonl.zstd` under `~/.dsh/sessions/**` | Log slot and projection cache gone; the sidebar row disappears; the archived id is gone from `workspace.json` |
|
|
12
|
+
|
|
13
|
+
## What it adds
|
|
14
|
+
|
|
15
|
+
One item in the sidebar Session context menu — the menu that carries *Rename*,
|
|
16
|
+
*Fork Session*, *Copy Session ID* and *Unarchive* — rendered in the danger style
|
|
17
|
+
below a separator:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
┌────────────────────────────┐
|
|
21
|
+
│ 重命名 Ctrl+Alt+G │
|
|
22
|
+
│ 分叉会话 Ctrl+Alt+F │
|
|
23
|
+
│ ────────────────────────── │
|
|
24
|
+
│ 复制 Session ID │
|
|
25
|
+
│ 在应用中打开 › │
|
|
26
|
+
│ 取消归档 │
|
|
27
|
+
│ ────────────────────────── │
|
|
28
|
+
│ 🗑 删除归档 │ ← this plugin
|
|
29
|
+
└────────────────────────────┘
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The item only shows up for a Session that is already archived: an unarchived one
|
|
33
|
+
may still be written to and must not be purged, while an archived one can no
|
|
34
|
+
longer be opened, so the header "…" menu can never reach it.
|
|
35
|
+
|
|
36
|
+
Clicking it opens a confirmation dialog that reports the Session id, the size of
|
|
37
|
+
its log and whether a projection cache exists — then the Host half deletes it. The
|
|
38
|
+
Host keeps an independent guard: a Session that was never archived is refused
|
|
39
|
+
(`409`), so the flow is always *archive → inspect → delete*.
|
|
40
|
+
|
|
41
|
+
## Requirements
|
|
42
|
+
|
|
43
|
+
* DeepSeek Harness with the Web client (Desktop app included), plus the
|
|
44
|
+
`workspaceRegistry` and `sessionPersistence` services — both ship with the
|
|
45
|
+
desktop profile.
|
|
46
|
+
* Node 22 or newer on the Host side (the routes use `Request`/`Response`).
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
Ask DSH to install the bundle, or use the **Plugins** page. The bundle is a normal
|
|
51
|
+
DSH bundle whose patch inserts one row:
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
- insert:
|
|
55
|
+
- id: dsh-del-chat
|
|
56
|
+
name: dsh-del-chat
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Install straight from this repository — the bundle is not on npm:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
dsh plugin add git+https://github.com/SLZ2025/dsh-del-chat.git
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Add `#<commit>` to pin a revision. A local checkout installs the same way:
|
|
66
|
+
`dsh plugin add D:\path\to\dsh-del-chat`.
|
|
67
|
+
|
|
68
|
+
Either way, **quit DSH completely and start it again** afterwards. A page refresh
|
|
69
|
+
loads only the client half: the menu item shows up, but the Host routes stay
|
|
70
|
+
unregistered and the dialog says the Host half is not loaded.
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
1. Archive the conversation you want gone — right-click the sidebar row → **归档 /
|
|
75
|
+
Archive**, or the `Ctrl+Shift+A` shortcut on the open Session.
|
|
76
|
+
2. Right-click that (now greyed out) sidebar row and pick **删除归档 / Delete archive**.
|
|
77
|
+
3. Check the numbers in the dialog, then press **永久删除 / Delete permanently**.
|
|
78
|
+
|
|
79
|
+
The `session-<id>/` directory is gone immediately, and the plugin then asks the
|
|
80
|
+
Client to pull the Host-authoritative Session catalog again, so the row leaves
|
|
81
|
+
the sidebar without a reload. (The sidebar draws from that catalog; nothing
|
|
82
|
+
else tells it the row is gone.)
|
|
83
|
+
|
|
84
|
+
## Where the bytes live
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
$DSH_HOME/sessions/<workspace-key>/session-<id>/session.v4.jsonl.zstd deleted
|
|
88
|
+
$DSH_HOME/storages/session_projcache/sessions/session-<id>.json deleted
|
|
89
|
+
$DSH_HOME/attachments/v1/objects/<2hex>/<sha256> kept (content addressed, shared)
|
|
90
|
+
$DSH_HOME/storages/cost-meter/ledger.json kept (third-party ledger)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The Workspace record and the archive mark are removed through the registry's own
|
|
94
|
+
write chain, never by editing `workspace.json`.
|
|
95
|
+
|
|
96
|
+
## How it works
|
|
97
|
+
|
|
98
|
+
See [`docs/DETAIL.md`](docs/DETAIL.md) for the reasoning, the guard table and the
|
|
99
|
+
known costs. In short: the client half registers a data-only menu contribution for
|
|
100
|
+
`session` (it asks the status route once when the menu opens, and only offers the
|
|
101
|
+
item for an archived Session) plus one `shell.overlay` dialog; the Host half
|
|
102
|
+
exposes `GET /plugin/dsh-del-chat/status` and `POST /plugin/dsh-del-chat/purge`,
|
|
103
|
+
checks that the id is archived and that the slot directory really is that Session's
|
|
104
|
+
slot under the persistence root, then deletes. It detaches and unarchives only when
|
|
105
|
+
the Host has already released the Session; while the Session is still resident in
|
|
106
|
+
the Host's in-memory store (a plugin cannot drop that entry) the delete keeps the
|
|
107
|
+
archive mark and settles the workspace record on `session/disposed` instead, so the
|
|
108
|
+
ghost row never reappears under Ungrouped.
|
|
109
|
+
|
|
110
|
+
## Troubleshooting
|
|
111
|
+
|
|
112
|
+
* **The item is missing** — it only appears for archived Sessions. Archive first
|
|
113
|
+
(`Ctrl+Shift+A`), refresh the page so the client half is loaded, then
|
|
114
|
+
right-click the sidebar row.
|
|
115
|
+
* **"The Host half of this plugin is not loaded"** — the plugin is installed but
|
|
116
|
+
the running DSH process predates it. Quit the app completely and start it
|
|
117
|
+
again; `%TEMP%\dsh-del-chat.log` should then contain `[apply]`.
|
|
118
|
+
* **"Only archived Sessions can be deleted permanently"** — archive it first;
|
|
119
|
+
that prerequisite is deliberate.
|
|
120
|
+
* **`log-locked` (`423`)** — the log is still open in another process. Restart DSH
|
|
121
|
+
and retry.
|
|
122
|
+
* **The row is still in the sidebar** — two cases. If it is greyed and still sits in
|
|
123
|
+
its own group, the Host was still holding the Session in memory; it disappears for
|
|
124
|
+
good once the Host releases it (the plugin settles the record then). If it went to
|
|
125
|
+
**Ungrouped**, the Session log still exists: check the dialog numbers and the Host
|
|
126
|
+
log.
|
|
127
|
+
* **Dialog works but nothing is deleted** — check the Host log for
|
|
128
|
+
`delete-failed` and the reported `message`.
|
|
129
|
+
|
|
130
|
+
## Development
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
node --check index.js
|
|
134
|
+
node --check client.js
|
|
135
|
+
node test/purge-core.test.mjs
|
|
136
|
+
node test/host-routes.test.mjs
|
|
137
|
+
node test/smoke.mjs
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`test/purge-core.test.mjs` exercises the filesystem helpers against temporary
|
|
141
|
+
trees; `test/host-routes.test.mjs` drives both routes with a stub Cordis context,
|
|
142
|
+
a stub registry and a temp `DSH_HOME`; `test/smoke.mjs` checks the manifest shape
|
|
143
|
+
and that every module imports.
|
|
144
|
+
|
|
145
|
+
CI runs the same commands on Ubuntu and Windows with Node 22 — see
|
|
146
|
+
[`.github/workflows/ci.yml`](.github/workflows/ci.yml).
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
MIT
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# dsh-del-chat
|
|
2
|
+
|
|
3
|
+
**真删归档对话**。DeepSeek Harness 的「归档」只是把会话从侧栏折起来,日志永远留在磁盘上。
|
|
4
|
+
这个插件在**侧栏会话右键菜单**里加一项 **删除归档**,把已归档会话的日志、投影缓存和
|
|
5
|
+
工作区记录真正从磁盘上删掉。
|
|
6
|
+
|
|
7
|
+
<!-- prettier-ignore -->
|
|
8
|
+
| 之前 | 之后 |
|
|
9
|
+
| ---- | ---- |
|
|
10
|
+
| 会话已归档,`~/.dsh/sessions/**` 里仍躺着 2.3 MB 的 `session.v4.jsonl.zstd` | 日志槽与投影缓存都不在了;侧栏行消失;`workspace.json` 里的归档 id 也清掉 |
|
|
11
|
+
|
|
12
|
+
## 它做了什么
|
|
13
|
+
|
|
14
|
+
加在侧栏会话行右键菜单里(「重命名」「分叉会话」「复制 Session ID」「取消归档」所在的那个
|
|
15
|
+
菜单),红色危险样式、上方带分隔线:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
┌────────────────────────────┐
|
|
19
|
+
│ 重命名 Ctrl+Alt+G │
|
|
20
|
+
│ 分叉会话 Ctrl+Alt+F │
|
|
21
|
+
│ ────────────────────────── │
|
|
22
|
+
│ 复制 Session ID │
|
|
23
|
+
│ 在应用中打开 › │
|
|
24
|
+
│ 取消归档 │
|
|
25
|
+
│ ────────────────────────── │
|
|
26
|
+
│ 🗑 删除归档 │ ← 本插件
|
|
27
|
+
└────────────────────────────┘
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
这一项**只在会话已归档时出现**:没归档的会话菜单里没有它,因为运行中的会话随时可能被写入,
|
|
31
|
+
不应该删;已归档的会话又打不开头部菜单,所以入口放在侧栏。
|
|
32
|
+
|
|
33
|
+
点击后先弹确认框,列出会话 id、日志占用字节、有没有投影缓存,确认后由 Host 侧真正删除。
|
|
34
|
+
Host 侧还有一道独立防线:**没归档过的会话会被 409 拒绝**,所以流程永远是
|
|
35
|
+
「先归档 → 看事实 → 再删除」。
|
|
36
|
+
|
|
37
|
+
## 环境要求
|
|
38
|
+
|
|
39
|
+
* 带 Web 界面(含桌面版)的 DeepSeek Harness,并且 `workspaceRegistry` 与
|
|
40
|
+
`sessionPersistence` 两个服务可用(桌面版 profile 自带)。
|
|
41
|
+
* Host 侧 Node 22 以上(路由用的是 `Request`/`Response`)。
|
|
42
|
+
|
|
43
|
+
## 安装
|
|
44
|
+
|
|
45
|
+
让 DSH 安装这个 bundle,或在 **插件** 页面安装。它的 patch 只插入一行:
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
- insert:
|
|
49
|
+
- id: dsh-del-chat
|
|
50
|
+
name: dsh-del-chat
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
直接从本仓库安装(还没有发布到 npm):
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
dsh plugin add git+https://github.com/SLZ2025/dsh-del-chat.git
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
加 `#<commit>` 可以锁定具体提交。本地 checkout 也一样:
|
|
60
|
+
`dsh plugin add D:\path\to\dsh-del-chat`。
|
|
61
|
+
|
|
62
|
+
装完必须**完全退出 DSH 再重新启动**。刷新网页只会加载客户端部分:菜单项会冒出来,
|
|
63
|
+
但 Host 端路由并没有注册,点下去会提示 Host 端未加载。
|
|
64
|
+
|
|
65
|
+
## 使用
|
|
66
|
+
|
|
67
|
+
1. 先归档要删的会话——侧栏行右键 → **归档**,或在该会话上按 `Ctrl+Shift+A`。
|
|
68
|
+
2. 在侧栏那一行(已变灰)上右键,选 **删除归档**。
|
|
69
|
+
3. 看一眼弹窗里的数字,点 **永久删除**。
|
|
70
|
+
|
|
71
|
+
会话目录会立刻消失,Host 同时广播 `api-session/removed`,侧栏那一行不用刷新页面就会跟着消失。
|
|
72
|
+
|
|
73
|
+
Host 若还把这个会话常驻在内存里,它的目录依然会列出它,而插件拿不到那份 detach 能力;这时插件只保留归档标记、不做 detach,等 `session/disposed` 到来时再补做收尾,这样那一行就不会变成「未分组」里的幽灵行。
|
|
74
|
+
|
|
75
|
+
## 数据删在哪里
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
$DSH_HOME/sessions/<workspace-key>/session-<id>/session.v4.jsonl.zstd 删除
|
|
79
|
+
$DSH_HOME/storages/session_projcache/sessions/session-<id>.json 删除
|
|
80
|
+
$DSH_HOME/attachments/v1/objects/<2hex>/<sha256> 保留(内容寻址,跨会话共享)
|
|
81
|
+
$DSH_HOME/storages/cost-meter/ledger.json 保留(第三方账本)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
工作区记录与归档标记走注册表自己的写链移除,插件不手改 `workspace.json`。
|
|
85
|
+
|
|
86
|
+
## 实现说明
|
|
87
|
+
|
|
88
|
+
见 [`docs/DETAIL.md`](docs/DETAIL.md):设计取舍、防线表与已知代价。简述:客户端注册一条
|
|
89
|
+
针对 `session` 的纯数据菜单贡献(打开菜单时先问一次状态,只有已归档才出现),外加一个
|
|
90
|
+
`shell.overlay` 弹窗;Host 侧暴露
|
|
91
|
+
`GET /plugin/dsh-del-chat/status` 与 `POST /plugin/dsh-del-chat/purge`,先确认该 id 已归档、
|
|
92
|
+
槽目录名确实等于会话 id 且在持久化根内,再 detach、unarchive、删文件。
|
|
93
|
+
|
|
94
|
+
## 常见问题
|
|
95
|
+
|
|
96
|
+
* **菜单里没有这一项** —— 它只对已归档的会话出现。先归档(`Ctrl+Shift+A`),刷新页面
|
|
97
|
+
让客户端半加载,再在侧栏右键。
|
|
98
|
+
* **提示「只有已归档的会话才能彻底删除」** —— 先归档,这个前置条件是故意的。
|
|
99
|
+
* **提示 Host 端插件还没加载** —— 客户端已加载但 Host 半没起来,完全退出 DSH 再启动;
|
|
100
|
+
判据见 `%TEMP%\dsh-del-chat.log` 里的 `[apply]` 行。
|
|
101
|
+
* **`log-locked`(423)** —— 日志还被别的进程占着,重启 DSH 再试。
|
|
102
|
+
* **侧栏还有那一行** —— 分两种情况。如果它还是灰的、并且仍在原来那一组里,说明 Host 内存里还常驻着这个会话(插件的进程里没法把它摘掉),等 Host 释放它之后插件会补做收尾,那一行就彻底消失。如果它跑到了**「未分组」**,说明日志还在:看弹窗数字和 Host 日志。
|
|
103
|
+
* **弹窗正常但没删掉** —— 看 Host 日志里的 `delete-failed` 和返回的 `message`。
|
|
104
|
+
|
|
105
|
+
## 开发
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
node --check index.js
|
|
109
|
+
node --check client.js
|
|
110
|
+
node test/purge-core.test.mjs
|
|
111
|
+
node test/host-routes.test.mjs
|
|
112
|
+
node test/smoke.mjs
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`test/purge-core.test.mjs` 用临时目录树测纯文件操作;`test/host-routes.test.mjs` 用桩
|
|
116
|
+
Cordis 上下文、桩注册表和临时 `DSH_HOME` 驱动两个路由;`test/smoke.mjs` 校验 manifest
|
|
117
|
+
形状并确认各模块可导入。
|
|
118
|
+
|
|
119
|
+
CI 在 Ubuntu 与 Windows + Node 22 上跑同样的命令,见
|
|
120
|
+
[`.github/workflows/ci.yml`](.github/workflows/ci.yml)。
|
|
121
|
+
|
|
122
|
+
## 许可证
|
|
123
|
+
|
|
124
|
+
MIT
|