dsh-session-manager 0.1.1 → 0.4.0

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/README.md CHANGED
@@ -1,113 +1,131 @@
1
- # dsh-session-manager — 会话管理器(删除 + 归档管理)
1
+ # dsh-session-manager — conversation manager for DeepSeek Harness
2
+
3
+ English | [中文](README.zh.md)
2
4
 
3
5
  [![npm version](https://img.shields.io/npm/v/dsh-session-manager)](https://www.npmjs.com/package/dsh-session-manager)
4
- [![GitHub](https://img.shields.io/badge/GitHub-repo-blue)](https://github.com/hkkz9522/dsh-session-manager)
6
+ [![GitHub](https://img.shields.io/badge/GitHub-repository-blue)](https://github.com/hkkz9522/dsh-session-manager)
5
7
  [![CI](https://github.com/hkkz9522/dsh-session-manager/actions/workflows/ci.yml/badge.svg)](https://github.com/hkkz9522/dsh-session-manager/actions/workflows/ci.yml)
6
8
 
7
- 为 DeepSeek Harness Web 增加两件官方缺失的能力:
9
+ A DeepSeek Harness (DSH) plugin for managing conversations safely from the Web UI.
10
+ It adds archive management, permanent deletion, cross-workspace moves, and
11
+ **per-conversation Agent preset migration**.
12
+
13
+ ## Features
14
+
15
+ - **Archive and unarchive** conversations.
16
+ - **Delete conversations** with an explicit irreversible-action confirmation.
17
+ - **Move to workspace** while preserving conversation history, title, archive state,
18
+ and derived-session relationships. The session's working directory is updated to
19
+ the target workspace.
20
+ - **Migrate Agent preset for one conversation at a time.** This repairs a conversation
21
+ when its original preset was renamed or removed.
22
+ - **Session manager** in the sidebar for browsing active and archived conversations,
23
+ with per-row Open, Archive/Unarchive, Move, Delete, and Migrate preset actions.
24
+ - Header actions for the current conversation: Archive/Unarchive, Move to workspace,
25
+ and a red Delete conversation action.
8
26
 
9
- 1. **删除对话**(删除前二次确认):物理删除会话 —— 停止并销毁对应 agent、清空
10
- 会话存储条目(所有标签页同步移除该行)、删除磁盘上的 JSONL 会话目录、
11
- 清理工作区记账与归档集合。
12
- 2. **归档管理**:移入归档(官方已有 `workspace.archiveSession`)与 **移出归档**
13
- (官方 rc.6 没有 unarchive API,本插件在 host 端补齐,走 workspace registry
14
- 自己的持久化队列,`host/archived-sessions-changed` 帧自动同步所有客户端)。
27
+ ## Where to find the UI
15
28
 
16
- ## 特性
29
+ - **Conversation header:** archive/unarchive, move to workspace, and delete.
30
+ - **Sidebar footer → Session manager:** browse all conversations, including archived
31
+ ones, and perform actions for an individual conversation.
32
+ - **Session manager row → Migrate preset:** change the Agent preset for that one
33
+ conversation only. There is no bulk migration action.
17
34
 
18
- - 🗑 **删除会话**:会话头部「删除会话…」按钮 + 管理面板每行删除,全部带二次确认
19
- - 📦 **归档 / 移出归档**:会话头部按钮 + 管理面板逐行操作
20
- - 📋 **会话管理面板**(侧边栏底部入口):全部 / 未归档 / 已归档 过滤(已归档会话
21
- 侧边栏默认不可见,只有这里能找回),每行「打开 / 归档 / 移出归档 / 删除」
22
- - 🏷 状态徽标:已归档 / 运行中 / 当前会话;相对时间与工作区目录
23
- - ⚠️ 删除确认弹窗展示会话标题与“不可撤销”警告;会话运行中会提示“删除将立即中断它”
35
+ ## Agent preset migration
24
36
 
25
- ## UI 入口
37
+ Use this when a conversation can no longer resume because its original preset no
38
+ longer exists, for example after removing a custom preset such as
39
+ `router-standard`.
26
40
 
27
- | 位置 | 内容 |
28
- |---|---|
29
- | 会话头部(当前会话标题旁) | 「归档 / 移出归档」与「删除会话…」(红色,二次确认弹窗)两个文字按钮 |
30
- | 侧边栏底部 | 「会话管理」按钮:打开完整管理面板 |
41
+ 1. Open **Session manager**.
42
+ 2. Locate the conversation and select **Migrate preset**.
43
+ 3. Choose one of the currently available target presets and confirm.
31
44
 
32
- ## 安装
45
+ The plugin determines the conversation's effective preset from its latest
46
+ `agent-preset/selected` event when present; otherwise it uses the session header.
47
+ It safely updates the relevant stored value, releases any live persistence owner,
48
+ and refreshes the session list. If the migrated conversation is open, reopen it
49
+ before continuing the chat.
33
50
 
34
- ### 从 npm 安装(推荐)
51
+ > A preset migration changes conversation metadata only. It does not alter message
52
+ > history, files, or the selected workspace.
53
+
54
+ ## Install
55
+
56
+ ### From npm
35
57
 
36
58
  ```powershell
37
- dsh plugin --profile web add dsh-session-manager
59
+ dsh plugin --profile web add npm:dsh-session-manager
38
60
  ```
39
61
 
40
- 重启 web 后生效(profile bundle 自动装配,`lib/` 即运行时产物,无需构建)。
41
-
42
- ### 从 GitHub 安装(备用)
62
+ ### From GitHub
43
63
 
44
64
  ```powershell
45
65
  dsh plugin --profile web add github:hkkz9522/dsh-session-manager
46
66
  ```
47
67
 
48
- ### 本地开发 / 运行时注入
68
+ Restart DSH Web after installation. If a browser still has an older client bundle,
69
+ perform a hard refresh (`Ctrl+Shift+R`).
49
70
 
50
- 克隆本仓库后,在已常驻 [dsh-super-injector](https://github.com/yjh051108/dsh-super-injector)
51
- 的 web 会话中注入(注入即生效,免重启):
71
+ ### Local development / runtime injection
52
72
 
73
+ ```text
74
+ dev_inject_plugin {"dir": "<absolute path to this repository>"}
53
75
  ```
54
- dev_inject_plugin {"dir": "<仓库目录绝对路径>"}
55
- ```
56
-
57
- ## 卸载
58
76
 
59
- - 若通过 `dsh plugin add` 装配:从 `~/.dsh/profiles/web/package.json` 的
60
- `dependencies` 与 `dsh.profile.bundles` 中移除对应条目,重启。
61
- - 若通过运行时注入安装:`dev_uninject_plugin {"name": "dsh-session-manager"}`
77
+ ## HTTP API
62
78
 
63
- ## 兼容性(升级 DSH 后)
79
+ The Web UI uses the following local endpoints. They are primarily useful for
80
+ integration and diagnostics.
64
81
 
65
- - **客户端 UI** 只使用官方插件面(slot 契约 `conversation.session.header.actions` /
66
- `sidebar.footer.action`、标准工具包 `useSessions` / `useWorkspaces` / `t`、locale、
67
- client bundle 格式),升级大概率无缝。
68
- - **host 端** 不 import 任何 `@deepseek-ai` 包(仅 node 内置模块),升级不会在
69
- 加载期失败;删除 / 移出归档用到了少数 rc.6 未公开的内部结构(已做防御性访问),
70
- 若未来版本重构这些内部实现,会表现为运行时操作报错而非崩溃,按报错适配即可。
71
- - `peerDependencies` 仅声明 `cordis` 范围,不硬编码 DSH 版本。
72
- - 建议升级后自检一次:新建空白会话并删除(端到端 30 秒),或运行
73
- `node scripts/smoke-test.mjs`(对两个 host 端点的只读冒烟检查,不触碰真实会话)。
82
+ ```text
83
+ POST /session-manager/api/delete { sessionId }
84
+ POST /session-manager/api/unarchive { sessionId }
85
+ GET /session-manager/api/workspaces
86
+ POST /session-manager/api/move { sessionId, targetWorkspaceId }
87
+ GET /session-manager/api/preset-scan?sessionId=<sessionId>
88
+ POST /session-manager/api/preset-migrate { sessionId, toPreset }
89
+ ```
74
90
 
75
- ## 开发与维护
91
+ Example: migrate one conversation to `standard`.
76
92
 
77
- - **无构建步骤**:`lib/` 即运行时产物(host 为 ESM,client 为 loader factory 格式手写 bundle)。
78
- - **冒烟测试**:`node scripts/smoke-test.mjs [baseUrl]`(需运行中的 dsh web)。
79
- - **CI**(`.github/workflows/ci.yml`):`node --check` 两个文件 + `npm pack --dry-run`
80
- 校验发布包内容。
81
- - 变更记录见 [CHANGELOG.md](./CHANGELOG.md)。
93
+ ```bash
94
+ curl -s -X POST http://127.0.0.1:3080/session-manager/api/preset-migrate \
95
+ -H 'content-type: application/json' \
96
+ -d '{"sessionId":"session-...","toPreset":"standard"}'
97
+ ```
82
98
 
83
- ## 实现说明
99
+ ## Safety and behavior
84
100
 
85
- - **host 端**(`lib/index.js`):cordis 插件,注入
86
- `webServer / workspaceRegistry / sessions / agents / sessionPersistence`,
87
- 注册两条 HTTP 端点:
88
- - `POST /session-manager/api/delete { sessionId }`
89
- - `POST /session-manager/api/unarchive { sessionId }`
90
- - **client 端**(`lib/client.js`):loader factory 格式手写 bundle(无构建步骤),
91
- 注册两个 slot:
92
- - `conversation.session.header.actions`(每会话操作 + 删除确认)
93
- - `sidebar.footer.action`(会话管理面板入口)
101
+ - **Deletion is permanent.** The confirmation dialog is intentional.
102
+ - Moving a running conversation interrupts and closes it first, then refreshes the
103
+ sidebar automatically. Open it from the target workspace to continue.
104
+ - Moving a conversation changes its stored `cwd`; subsequent tool calls run in the
105
+ target workspace.
106
+ - Subagent and transient blank-session placeholders are excluded from destructive
107
+ or migration operations.
108
+ - File rewrites use temporary files and atomic replacement where supported to avoid
109
+ partial session artifacts.
94
110
 
95
- 删除 live 会话的顺序:`agent.cancel`(中断运行)→ `agent.scope.dispose`(安静销毁
96
- agent fiber,3s 上限)→ 从 agents 注册表移除僵尸条目 → `sessions.flush` → 会话
97
- store 条目 detach(触发 `session/disposed` → 各端移除行)→ 工作区记账清理 →
98
- 归档集合清理 → 删除磁盘目录。
111
+ ## Compatibility and development
99
112
 
100
- ## 风险与边界
113
+ - The plugin is a Cordis plugin and declares `cordis >=4.0.0-rc <5` as a peer
114
+ dependency.
115
+ - `lib/index.js` is the host-side ESM plugin and `lib/client.js` is the Web client
116
+ bundle. There is no build step.
117
+ - Before submitting changes, run:
101
118
 
102
- - 删除是不可逆操作(文件物理删除),UI 已做二次确认。
103
- - live 会话删除依赖 host 内部结构(会话 store / agent registry 的实例字段),
104
- 未来 DSH 版本若重构这些内部实现可能需要同步适配(代码均做了防御性访问)。
105
- - 已归档会话若其磁盘文件已被外部删除,移出归档只会把它放回列表(行可能不显示)。
119
+ ```powershell
120
+ node --check lib/client.js
121
+ node --check lib/index.js
122
+ git diff --check
123
+ node scripts/smoke-test.mjs
124
+ npm pack --dry-run
125
+ ```
106
126
 
107
- ## 开源许可
127
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
108
128
 
109
- 本项目基于 [MIT License](./LICENSE) 开源。
129
+ ## License
110
130
 
111
- 你可以自由地使用、修改、复制、分发本项目(包括商业用途),但需保留版权声明与
112
- 本许可文本;项目按“现状”提供,作者不对其适用性、可靠性或特定用途的适配性作任何
113
- 明示或默示的担保。完整条款见 [LICENSE](./LICENSE)。
131
+ [MIT](LICENSE)
package/README.zh.md ADDED
@@ -0,0 +1,117 @@
1
+ # dsh-session-manager — DeepSeek Harness 会话管理器
2
+
3
+ [English](README.md) | 中文
4
+
5
+ [![npm version](https://img.shields.io/npm/v/dsh-session-manager)](https://www.npmjs.com/package/dsh-session-manager)
6
+ [![GitHub](https://img.shields.io/badge/GitHub-仓库-blue)](https://github.com/hkkz9522/dsh-session-manager)
7
+ [![CI](https://github.com/hkkz9522/dsh-session-manager/actions/workflows/ci.yml/badge.svg)](https://github.com/hkkz9522/dsh-session-manager/actions/workflows/ci.yml)
8
+
9
+ 用于管理 DeepSeek Harness(DSH)Web 对话的插件。它提供归档管理、永久删除、
10
+ 跨工作区移动,以及**按单条对话迁移 Agent 预设**的能力。
11
+
12
+ ## 功能
13
+
14
+ - **归档 / 移出归档**对话。
15
+ - **删除会话**:带不可逆操作的二次确认。
16
+ - **移动至工作区**:保留历史、标题、归档状态和派生会话关系,同时把会话的
17
+ 工作目录更新为目标工作区。
18
+ - **单条对话迁移 Agent 预设**:当原预设被改名或删除,导致会话无法恢复时,可
19
+ 单独修复该对话。
20
+ - **会话管理窗口**:在侧边栏中浏览未归档和已归档会话,并对每一行执行打开、
21
+ 归档 / 移出归档、移动、删除、迁移预设。
22
+ - 当前对话标题区域提供归档 / 移出归档、移动至工作区和红色的删除会话按钮。
23
+
24
+ ## UI 入口
25
+
26
+ - **对话标题右侧**:归档 / 移出归档、移动至工作区、删除会话。
27
+ - **侧边栏底部 → 会话管理**:查看全部会话(含归档会话)并操作每一条会话。
28
+ - **会话管理的会话行 → 迁移预设**:只迁移当前这一条会话;不再提供批量迁移。
29
+
30
+ ## Agent 预设迁移
31
+
32
+ 当对话无法恢复,且报错表明原 Agent 预设不存在时(例如删掉了
33
+ `router-standard`),可以使用单条迁移功能。
34
+
35
+ 1. 打开**会话管理**。
36
+ 2. 找到目标对话,点击**迁移预设**。
37
+ 3. 从当前可用的预设中选择目标预设并确认。
38
+
39
+ 插件会优先读取最后一条 `agent-preset/selected` 事件中的有效预设;若不存在该
40
+ 事件,则读取会话 header 中的预设。迁移时会安全改写对应的持久化记录、释放可能残留
41
+ 的 live persistence owner,并刷新会话列表。若该会话当前打开,请在迁移后重新打开
42
+ 再继续对话。
43
+
44
+ > 迁移预设只会修改会话元数据,不会改写历史消息、文件或当前工作区。
45
+
46
+ ## 安装
47
+
48
+ ### 从 npm 安装
49
+
50
+ ```powershell
51
+ dsh plugin --profile web add npm:dsh-session-manager
52
+ ```
53
+
54
+ ### 从 GitHub 安装
55
+
56
+ ```powershell
57
+ dsh plugin --profile web add github:hkkz9522/dsh-session-manager
58
+ ```
59
+
60
+ 安装后重启 DSH Web。若浏览器仍加载旧的客户端代码,请使用 `Ctrl+Shift+R` 强制刷新。
61
+
62
+ ### 本地开发 / 运行时注入
63
+
64
+ ```text
65
+ dev_inject_plugin {"dir": "<本仓库的绝对路径>"}
66
+ ```
67
+
68
+ ## HTTP API
69
+
70
+ 以下本地接口供 Web UI 使用,也可用于集成和排查:
71
+
72
+ ```text
73
+ POST /session-manager/api/delete { sessionId }
74
+ POST /session-manager/api/unarchive { sessionId }
75
+ GET /session-manager/api/workspaces
76
+ POST /session-manager/api/move { sessionId, targetWorkspaceId }
77
+ GET /session-manager/api/preset-scan?sessionId=<sessionId>
78
+ POST /session-manager/api/preset-migrate { sessionId, toPreset }
79
+ ```
80
+
81
+ 示例:将一条对话迁移到 `standard` 预设。
82
+
83
+ ```bash
84
+ curl -s -X POST http://127.0.0.1:3080/session-manager/api/preset-migrate \
85
+ -H 'content-type: application/json' \
86
+ -d '{"sessionId":"session-...","toPreset":"standard"}'
87
+ ```
88
+
89
+ ## 安全与行为说明
90
+
91
+ - **删除不可恢复**,因此界面始终要求确认。
92
+ - 移动正在运行的对话时,插件会先中断并关闭该会话,然后自动刷新侧边栏;请在
93
+ 目标工作区重新打开会话后继续。
94
+ - 移动会改写会话保存的 `cwd`,之后的工具调用将在目标工作区执行。
95
+ - subagent 会话和临时空白会话占位不会参与删除、移动或预设迁移。
96
+ - 文件改写使用临时文件和原子替换(环境支持时),避免产生部分写入的会话工件。
97
+
98
+ ## 兼容性与开发
99
+
100
+ - 本插件是 Cordis 插件,声明的 peer dependency 为 `cordis >=4.0.0-rc <5`。
101
+ - `lib/index.js` 是 host 端 ESM 插件,`lib/client.js` 是 Web 客户端 bundle,
102
+ 无需构建步骤。
103
+ - 提交修改前请运行:
104
+
105
+ ```powershell
106
+ node --check lib/client.js
107
+ node --check lib/index.js
108
+ git diff --check
109
+ node scripts/smoke-test.mjs
110
+ npm pack --dry-run
111
+ ```
112
+
113
+ 发布记录见 [CHANGELOG.md](CHANGELOG.md)。
114
+
115
+ ## 开源许可
116
+
117
+ [MIT](LICENSE)