dsh-plugin-delete-session 0.0.0-stage → 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+
5
+ ## [1.0.8] - 2026-10-18
6
+
7
+ ### Fixed
8
+
9
+ - Deleting a session restored into the **Ungrouped** bucket no longer leaves a
10
+ ghost row in the sidebar. After the log is moved to the recycle bin, the plugin
11
+ unregisters the exact live Session and idle Agent from the Host registries;
12
+ `session/disposed` removes the row from the API/sidebar and releases the JSONL
13
+ writer.
14
+ - Purging a deleted session, purging expired entries, and restoring an expired
15
+ entry now clean up the same stale live/archive state when no durable log
16
+ remains.
17
+ - A successful delete no longer depends on restarting DSH to make an ungrouped
18
+ row disappear.
19
+
20
+ ### Verified
21
+
22
+ - `node test/host.test.mjs` covers the reported flow: delete, restore, delete
23
+ again while the restored session is live, plus archive/detach/flush rollback.
24
+ - `node test/trash.test.mjs` covers copy/restore/conflict/expiry/path and
25
+ metadata validation.
26
+
27
+ ## [1.0.0] - 2026-10-18
28
+
29
+ - Initial public release: delete confirmation, immediate removal, 7-day recycle
30
+ bin, undo, restore, permanent delete, and running-turn refusal.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 yycf1
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.en.md ADDED
@@ -0,0 +1,132 @@
1
+ # Session Trash · Delete sessions in DeepSeek Harness
2
+
3
+ [中文](README.md) · [Changelog](CHANGELOG.md) · [Publishing](docs/PUBLISHING.md)
4
+
5
+ A community plugin for DeepSeek Harness (DSH) that adds a real **Delete conversation** action: confirm once, the session leaves the sidebar immediately, and a copy stays in a local recycle bin for **7 days** with undo/restore. After the retention window the copy is purged.
6
+
7
+ > Not an official DeepSeek project. DSH's native Archive action is unchanged: archive hides a session, delete moves its log.
8
+
9
+ ![Session Trash icon](icon.svg)
10
+
11
+ ## Features
12
+
13
+ - **Delete conversation** in every session's `...` menu, with a confirmation dialog.
14
+ - **Immediate removal** from the sidebar, including sessions in the **Ungrouped** bucket.
15
+ - **7-day recycle bin** at `$DSH_HOME/session-trash/`; the log is copied before the original is removed.
16
+ - **Undo / restore** from the post-delete toast or the sidebar recycle-bin button.
17
+ - **Delete permanently** from the recycle bin without waiting for expiry.
18
+ - **Only a genuinely running turn is refused**, immediately and without cancelling it. Idle resident sessions can be deleted.
19
+ - **Fail-safe**: archive, workspace detach, flush, and copy failures abort before touching the original log and roll back the archive marker.
20
+ - **Same toast position/style** as DSH's archive notice, using the shared `Toast` primitive.
21
+
22
+ ## Install
23
+
24
+ ### npm (recommended, once released)
25
+
26
+ ```sh
27
+ dsh plugin --profile web add dsh-plugin-delete-session
28
+ ```
29
+
30
+ Fully quit and reopen DSH after installation (the Host half is an ESM module; a page refresh does not reload it), then press `Ctrl+Shift+R`.
31
+
32
+ ### From GitHub source
33
+
34
+ ```sh
35
+ dsh plugin --profile web add github:yycf1/dsh-plugin-delete-session
36
+ ```
37
+
38
+ This is plain JavaScript; no build script is required. Restart DSH after installation.
39
+
40
+ ### Browse inside DSH
41
+
42
+ This repository also publishes a DSH plugin-market index:
43
+
44
+ ```text
45
+ https://yycf1.github.io/dsh-plugin-delete-session/index.json
46
+ ```
47
+
48
+ Open **Settings → Plugins → Experimental plugins → Custom plugin market**, add the index URL, then install from **Discover**. The plugin is also submitted to DSH Plugin Hub (dsh-plugin.org).
49
+
50
+ ## Usage
51
+
52
+ 1. Open the `...` menu of a session and choose **Delete conversation**.
53
+ 2. Confirm. The row disappears and a toast with **Undo** appears.
54
+ 3. Click **Undo**, or open the recycle-bin button at the bottom of the sidebar to **Restore** any unexpired copy.
55
+ 4. Use **Delete permanently** in the recycle bin to skip the remaining window.
56
+
57
+ The global content-addressed attachment store is shared and is not deleted.
58
+
59
+ ## Configuration
60
+
61
+ The default `cordis.patch.yml` row is:
62
+
63
+ ```yaml
64
+ - insert:
65
+ - id: dsh-plugin-delete-session
66
+ name: 'dsh-plugin-delete-session'
67
+ config:
68
+ retentionDays: 7
69
+ ```
70
+
71
+ | Field | Default | Meaning |
72
+ |---|---|---|
73
+ | `retentionDays` | `7` | Recycle-bin retention (1–3650 days). |
74
+ | `trashRoot` | `$DSH_HOME/session-trash` | Recycle-bin directory. |
75
+ | `sessionsRoot` | persistence `root`, else `$DSH_HOME/sessions` | Session-log root. |
76
+ | `projectionCacheDir` | `$DSH_HOME/storages/session_projcache/sessions` | Projection-cache directory. |
77
+ | `homeDir` | `$DSH_HOME`, else `~/.dsh` | Base data directory when paths are omitted. |
78
+ | `purgeIntervalMs` | `3600000` | Expiry sweep interval (minimum 60 s). |
79
+
80
+ Override the row `config` in the profile patch to change retention. A patch replaces the complete row config, so repeat any other fields you need.
81
+
82
+ ## How it works
83
+
84
+ Delete sequence:
85
+
86
+ 1. Refuse immediately if the Agent's status is `running`.
87
+ 2. Archive with `{ stopActivity: true }` to stop background work and hide the row.
88
+ 3. Re-check the running state to close the race.
89
+ 4. Detach the session from its workspace account.
90
+ 5. Flush session persistence.
91
+ 6. Copy the log directory, projection cache, and `meta.json` into the recycle bin.
92
+ 7. Remove the original files.
93
+ 8. Unregister the deleted live Session/Agent from the Host registries. `session/disposed` makes the sidebar/API remove the row and releases the JSONL writer.
94
+
95
+ Restore copies the log back, replaces the derived projection cache, unarchives, and reattaches the session to its original workspace. It refuses to overwrite an existing destination and rolls back a partial copy.
96
+
97
+ An hourly sweep (also run at startup) purges expired entries and stale archive markers whose log and trash copy are both gone.
98
+
99
+ ## Safety and limitations
100
+
101
+ - **Internal DSH APIs**: `ctx.sessions.retireScope`, `sessions.detachEntered`, `agents.detachEntered`, and the `Toast` primitive. A DSH upgrade may require an update. Tested with DSH `0.2.1-rc.2`.
102
+ - **The idle Agent's underlying scope** remains until the process exits because DSH exposes no public Agent-close API. Its registrations are removed, so it is unreachable from the sidebar/session API and writes no more logs. Restart releases it.
103
+ - **Single-process assumption**: recycle-bin mutations are serialized inside one DSH process. Do not run multiple DSH instances sharing the same `$DSH_HOME`.
104
+ - **Windows first**: developed and tested primarily on Windows; other platforms have not had full GUI verification.
105
+ - A running turn is not cancelled by delete. Stop it first.
106
+ - A restored session returns to the front of its workspace, not its previous manual position.
107
+ - No Agent tool is registered; models cannot delete sessions on their own.
108
+
109
+ ## Development
110
+
111
+ Plain ESM, no build step:
112
+
113
+ ```sh
114
+ node --check index.js
115
+ node --check client.js
116
+ node test/host.test.mjs
117
+ node test/trash.test.mjs
118
+ ```
119
+
120
+ ## Compatibility
121
+
122
+ - DSH: `>=0.2.1-rc.2 <0.3.0`
123
+ - Platform: Windows verified; macOS/Linux not fully verified
124
+ - Runtime: DSH Desktop or a DSH profile with the Web UI
125
+
126
+ ## License
127
+
128
+ [MIT](LICENSE) © 2026 yycf1
129
+
130
+ ## Disclaimer
131
+
132
+ Community project, not affiliated with DeepSeek AI. Deleting moves local session files; test on a small session first and keep the recycle bin until you are sure.
package/README.md CHANGED
@@ -1,3 +1,135 @@
1
- # Temporary Holding Version
1
+ # Session Trash · DSH 删除对话与回收站
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [English](README.en.md) · [更新记录](CHANGELOG.md) · [发布说明](docs/PUBLISHING.md)
4
+
5
+ 给 DeepSeek Harness(DSH)桌面端补上真正的**删除对话**:确认后立即从侧栏移除,同时把会话日志放进本地回收站保留 **7 天**;期间可以一键撤销或恢复,逾期自动永久删除。
6
+
7
+ > 这是一个社区插件,不是 DeepSeek 官方项目。DSH 原生的“归档”保持不变;归档只是隐藏,删除才会移走日志。
8
+
9
+ ![Session Trash icon](icon.svg)
10
+
11
+ ## 功能
12
+
13
+ - **删除对话**:每个会话的 `...` 菜单新增红色“删除对话”,确认框显示标题和保留天数。
14
+ - **立即消失**:删除成功后侧栏行立即移除,包括“未分组”会话;不需要刷新或重启。
15
+ - **7 天回收站**:日志、投影缓存和元数据先完整复制到 `$DSH_HOME/session-trash/`,复制成功后才删除原文件。
16
+ - **撤销 / 恢复**:删除提示条内嵌“撤销”;侧栏底部的回收站按钮可以恢复任意未过期会话。
17
+ - **彻底删除**:回收站里可立即永久删除,不必等 7 天。
18
+ - **只拦真正运行中的任务**:Agent 回合处于 `running` 时立即拒绝删除,不归档、不取消、不等待;空闲但仍驻留内存的会话可以正常删除。
19
+ - **失败安全**:归档、从工作区摘除、flush、复制任一步失败都会在动原文件之前中止并回滚;不会出现“原文件删了、回收站也没有”的状态。
20
+ - **与归档一致的提示**:复用 DSH 的 `Toast` 原语,位置和样式与“会话已归档,可撤销”一致。
21
+
22
+ ## 安装
23
+
24
+ ### 从 npm 安装(推荐,发布后)
25
+
26
+ ```sh
27
+ dsh plugin --profile web add dsh-plugin-delete-session
28
+ ```
29
+
30
+ 安装后**完全退出并重新打开 DSH**(Host 半是 ESM 模块,刷新页面不会重新加载它),再按 `Ctrl+Shift+R` 刷新页面。
31
+
32
+ ### 从 GitHub 源码安装
33
+
34
+ ```sh
35
+ dsh plugin --profile web add github:yycf1/dsh-plugin-delete-session
36
+ ```
37
+
38
+ 这是纯 JavaScript 包,不需要构建授权。安装后同样需要完整重启 DSH。
39
+
40
+ ### 在 DSH 内浏览
41
+
42
+ 本仓库同时发布了一个符合 DSH 插件市场格式的索引:
43
+
44
+ ```text
45
+ https://yycf1.github.io/dsh-plugin-delete-session/index.json
46
+ ```
47
+
48
+ 打开 **设置 → 插件 → 实验性插件 → 自定义插件市场**,添加上面的索引地址,即可在“发现”中查看并安装。也可以在 DSH Plugin Hub(dsh-plugin.org)搜索本插件。
49
+
50
+ ## 使用
51
+
52
+ 1. 在左侧会话列表找到目标对话,打开 `...` 菜单;
53
+ 2. 点击 **删除对话**,确认;
54
+ 3. 会话立即从列表消失,顶部出现带“撤销”的提示;
55
+ 4. 7 天内点击提示里的“撤销”,或打开侧栏底部的回收站点击“恢复”;
56
+ 5. 在回收站点击“彻底删除”可立即永久删除。
57
+
58
+ 删除的是会话日志和它的投影缓存;全局附件库按内容寻址共享,不会被删除。
59
+
60
+ ## 配置
61
+
62
+ 默认配置在 `cordis.patch.yml`:
63
+
64
+ ```yaml
65
+ - insert:
66
+ - id: dsh-plugin-delete-session
67
+ name: 'dsh-plugin-delete-session'
68
+ config:
69
+ retentionDays: 7
70
+ ```
71
+
72
+ | 字段 | 默认值 | 说明 |
73
+ |---|---|---|
74
+ | `retentionDays` | `7` | 回收站保留天数(1–3650)。 |
75
+ | `trashRoot` | `$DSH_HOME/session-trash` | 回收站目录。 |
76
+ | `sessionsRoot` | session-persistence 的 `root`,否则 `$DSH_HOME/sessions` | 会话日志根目录。 |
77
+ | `projectionCacheDir` | `$DSH_HOME/storages/session_projcache/sessions` | 投影缓存目录。 |
78
+ | `homeDir` | `$DSH_HOME`,否则 `~/.dsh` | 未显式给出路径时使用的数据目录。 |
79
+ | `purgeIntervalMs` | `3600000` | 自动清理间隔(最小 60 秒)。 |
80
+
81
+ 在 profile 的 `cordis.patch.yml` 中覆盖 `config` 可以修改保留天数;patch 会替换整行配置,因此请同时写出需要保留的其他字段。
82
+
83
+ ## 工作原理
84
+
85
+ 删除顺序:
86
+
87
+ 1. 检查 Agent 是否正在 `running`;是则**立即**拒绝;
88
+ 2. `workspaceRegistry.archiveSession(id, { stopActivity: true })`,停止后台任务并让归档集合隐藏该行;
89
+ 3. 归档后再次检查运行状态,防止竞态;
90
+ 4. 从 workspace 摘除持久化归属;
91
+ 5. `sessionPersistence.flush()`,确保最新消息已落盘;
92
+ 6. 把日志目录、投影缓存和 `meta.json` 复制到回收站;
93
+ 7. 删除原文件;
94
+ 8. 摘除 Host 中仍驻留的 live Session/Agent 注册,触发 `session/disposed`,让侧栏和 API 立即移除该行,并释放日志 writer。
95
+
96
+ 恢复顺序:复制回原位置 → 覆盖派生的投影缓存 → 取消归档 → 重新挂到原 workspace。目标位置已有数据时拒绝覆盖,并回滚本次复制。
97
+
98
+ 过期清理每小时运行一次,启动时也会运行;没有日志、没有回收站副本的陈旧归档标记会被清理。
99
+
100
+ ## 安全与已知限制
101
+
102
+ - **依赖 DSH 内部接口**:`ctx.sessions.retireScope`、`sessions.detachEntered`、`agents.detachEntered`、`@deepseek-ai/dsh-client-ui-primitives` 的 `Toast`。DSH 升级后可能需要适配;本版本在 `0.2.1-rc.2` 上测试。
103
+ - **空闲 Agent 的底层 scope** 仍会保留到本次进程结束(DSH 没有公开的 Agent close 接口);它已被摘除注册,不能从侧栏或 session API 访问,也不会再写日志。重启后彻底释放。
104
+ - **单进程假设**:回收站操作在单个 DSH 进程内串行;不要同时运行多个共享同一 `$DSH_HOME` 的 DSH 实例。
105
+ - **Windows 优先**:开发和测试主要在 Windows 上完成;其他平台未做完整 GUI 验证。
106
+ - **运行中的回合不会被删除顺手取消**:请先停止任务,这是数据安全选择。
107
+ - 删除后恢复的会话会出现在 workspace 最前面,不保留原手动排序位置。
108
+ - 本插件没有注册 Agent 工具,模型不能自行删除对话;删除只通过 GUI 暴露。
109
+
110
+ ## 开发与测试
111
+
112
+ 仓库是普通 ESM 包,无构建步骤:
113
+
114
+ ```sh
115
+ node --check index.js
116
+ node --check client.js
117
+ node test/host.test.mjs
118
+ node test/trash.test.mjs
119
+ ```
120
+
121
+ 测试覆盖删除、恢复、彻底删除、运行中拒绝、归档/detach/flush 失败回滚、未分组 live 清理、路径校验、元数据校验和过期清理。
122
+
123
+ ## 兼容性
124
+
125
+ - DSH:`>=0.2.1-rc.2 <0.3.0`
126
+ - 平台:Windows 已验证;macOS/Linux 未完整验证
127
+ - 运行时:DSH Desktop 或带 Web UI 的 DSH profile
128
+
129
+ ## 许可证
130
+
131
+ [MIT](LICENSE) © 2026 yycf1
132
+
133
+ ## 免责声明
134
+
135
+ 本项目为社区插件,与 DeepSeek AI 无隶属关系。删除操作会移动本地会话文件;请先在小范围会话上验证,并保留回收站直到确认不再需要。