@hongyongli/dsh-session-delete 0.0.0-stage → 1.0.1

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,3 +1,116 @@
1
- # Temporary Holding Version
1
+ # @hongyongli/dsh-session-delete
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
+ 版本解绑(version-unbound)版的会话删除插件 —— 行为与
4
+ [`@pepsi-ai/dsh-plugin-session-delete`](https://www.npmjs.com/package/@pepsi-ai/dsh-plugin-session-delete) 0.3.2 一致,
5
+ 只去掉了挪不过去的 dsh 版本限制。
6
+
7
+ ## 为什么要 fork
8
+
9
+ dsh 在装载/安装插件时会调用 `evaluatePluginCompatibility()`(`@deepseek-ai/dsh-app-boot`)。规则是:
10
+
11
+ 1. 清单里有 `engines.dsh` → 只用它判断,peer 全部忽略;
12
+ 2. 没有 `engines.dsh` → **每一个** `@deepseek-ai/dsh` / `@deepseek-ai/dsh-*` 的 `peerDependencies` 范围都要
13
+ 匹配当前 dsh 版本(比较时 `includePrerelease: true`)。
14
+
15
+ 上游 0.3.2 声明了 `"@deepseek-ai/dsh-tools": "^0.1.0-rc.6"`,而这个范围等于 `>=0.1.0-rc.6 <0.2.0-0`。
16
+ 只要 dsh 走到 `0.2.x`,这条就永远不满足 —— 于是每次升级都要重新给一个
17
+ exact-version 豁免(`~/.dsh/profiles/<profile>/compatibility.json` 里那种
18
+ `"<pkg>@<ver>": ["0.2.1-rc.3"]` 记录),否则报
19
+ `Plugin ... is incompatible with dsh ...: requirements {"@deepseek-ai/dsh-tools":"^0.1.0-rc.6"}`。
20
+
21
+ ## 这里怎么改的
22
+
23
+ * 删除 `engines`(也就不存在 `engines.dsh`)。
24
+ * `peerDependencies` 只保留一条 `"@deepseek-ai/dsh-tools": "*"`。
25
+ `*` 在 `includePrerelease` 下匹配任意版本(0.2.1-rc.3、0.3.0-rc.1、1.0.0-alpha…都过),
26
+ 所以版本检查永远为空集;同时这条 peer **必须留着**:宿主对 linked 目录插件的裸包名解析
27
+ 是靠 `readPeerNames()` 命中后路由到 dsh 自带安装的,删掉它 `import ... from '@deepseek-ai/dsh-tools'` 会
28
+ `ERR_MODULE_NOT_FOUND`。
29
+ * 代码逻辑几乎没改,改动只有这几处:
30
+ * client 端对 `@deepseek-ai/dsh-client-ui-primitives` 的 `Modal` / `IconTrashOutline16` 改成
31
+ `try { require(...) } catch {}` + 自带 fallback,这样即使将来 primitives 改名/移除,
32
+ 删除弹窗也还能用;
33
+ * 插件行 id 换成独立的 `session-delete`,与上游的 `chameleon-session-delete` 不冲突;
34
+ * **session id 不再要求 UUID 形状**(见下)。
35
+
36
+ ## 修掉的 bug:Agents Anywhere 新建的会话删不掉
37
+
38
+ 上游 0.3.2 的 `deleteSessionCore()` 第一行是
39
+
40
+ ```js
41
+ const SESSION_ID_RE = /^(session-)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
42
+ if (!SESSION_ID_RE.test(sessionId)) throw new DeleteError(`invalid session id: ${sessionId}`, 400)
43
+ ```
44
+
45
+ 而 Agents Anywhere(手机端)建出来的会话 id 长这样:
46
+
47
+ ```text
48
+ aa_2f10c18041dad707_sess__5Jp6t1EGVfDFA
49
+ ```
50
+
51
+ 不是 UUID → 第一行就抛 400,后面的停 agent、删目录、清 projection cache、清工作区记账一概不执行,
52
+ 侧边栏里却照样列着这个会话,于是"点了删除但删不掉"。
53
+
54
+ **修法不是把正则放宽松**,而是取消形状检查、只校验"它是不是一个安全的单一路径段":
55
+ id 要作为 `~/.dsh/sessions/<workspace-slug>/<id>/` 的一段拼进路径,所以真正该管的是
56
+ 空串 / `.` / `..` / 含 `/` 或 `\` / 控制字符 / 超长(>512)。任何来源新造的 id 形状都能删。
57
+
58
+ 同时补了一个上游没防的坑:上游 `sessionIdVariants()` 会把 `session-` 前缀无条件剥掉,
59
+ 传入 `session-` 本身时会派生出**空串**变体,`path.join(root, slug, '')` 正好是 slug 目录本身
60
+ —— 那一步 `rm -rf` 会把整个工作区的所有会话删光。现在剥离后先过 `isSafeSessionId`,
61
+ `findSessionDirs()` 里还有一道 `path.dirname(candidate) !== slugDir` 的兜底。
62
+
63
+ 回归测试(跑的是 `index.js` 本体,只对两个 import 打桩,用假 `DSH_HOME`):
64
+
65
+ ```bash
66
+ node test/session-id.test.mjs # ALL PASS
67
+ ```
68
+
69
+ 注意:host 侧 JS 走 ESM 模块缓存,改完要**重启 dsh** 才生效;client 侧会热更新。
70
+ 删一个还在运行的 AA 会话前,建议先在手机 Agents Anywhere 里退出那个会话 —— 桥接端
71
+ 可能把它重建回来(本项目内没法阻止)。
72
+
73
+ ## 安装 / 卸载
74
+
75
+ 在本 profile 下用 plugin manager 安装(不要手改 profile 的 `package.json` / `cordis.patch.yml`):
76
+
77
+ ```text
78
+ plugin_manager action=install_bundle target=<本目录绝对路径>
79
+ ```
80
+
81
+ 卸载用 `plugin_manager action=remove_bundle target=@hongyongli/dsh-session-delete`。
82
+
83
+ 装好后本目录是 **被链接** 进 profile 的,别删/别挪这个目录。
84
+
85
+ ## 更新 dsh 之后
86
+
87
+ 不需要做任何事:没有 `engines.dsh`,peer 范围是 `*`,compatibility 检查不会产生任何要求,
88
+ 也就不再需要 exact-version 豁免。
89
+
90
+ ## 发布到 npm + 插件市场
91
+
92
+ 工作区这份的名字固定是 `@hongyongli/dsh-session-delete`(它被 `link:` 进本机 profile,
93
+ 原地改名会逼着 remove/install + 重启 host),所以发布件由脚本**另存一份再改名**:
94
+
95
+ ```bash
96
+ node scripts/release.mjs --name dsh-plugin-session-delete-unbound # 或 --name @you/xxx
97
+ ```
98
+
99
+ 脚本会:只替换包名相关的三处(`package.json` 的 `name`、`client.js` 的 module id、
100
+ `cordis.patch.yml` 的行 `name`,三者必须一致)→ 断言其余文件与验证过的源码**逐字节相同**
101
+ → `pnpm pack` 出 `plugins/dist/*.tgz` → 解包重跑 `test/session-id.test.mjs`
102
+ → 重新生成 `plugins/market/index.json`(format 1,含新包名与本轮 `publishTimestamp`)。
103
+
104
+ 发布(本机没有 npm CLI,用 pnpm;首次需要 `pnpm login`):
105
+
106
+ ```bash
107
+ pnpm login
108
+ pnpm publish plugins/dist/<name>-<version>.tgz --access public --no-git-checks
109
+ ```
110
+
111
+ 之后把 `plugins/market/index.json` 放到一个 https 地址(GitHub raw / gist / 自己的域名,
112
+ 不能带 query string、不能靠 302 跳转),在 dsh 的 **插件 → 实验性插件 → 更多 → 自定义插件市场**
113
+ (bundle `@deepseek-ai/dsh-experimental-plugin-market-bundle`)启用后,于 **发现** 标签页添加该 URL。
114
+
115
+ 注意:市场**不支持升级**,装了旧版只会显示 `update-available`,升级要先卸载再装;
116
+ 索引也**没有签名**,装进去的实际内容由那份 manifest 决定,别加不可信的索引。