chore(dsh): 适配 DSH 0.2.2-rc.1(基线/peer/CI/脚本/文档 + AgentModel 与 PTC 类型变化)

This commit is contained in:
Menghuan1918 committed 2026-11-04 22:13:07 +08:00
1 parent 09b83cc6aa
commit 7a4a15292e
25 files changed
+844 -679

No files matched your search

+2 -2
View File
@@ -171,14 +171,14 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Pin the exact 0.2.1-rc.1 host CLI; never use a dist-tag.
# Pin the exact 0.2.2-rc.1 host CLI; never use a dist-tag.
# Keep peer resolution ON: do not add --legacy-peer-deps; it skips boot peers.
# The lanes speak the slash-only RPC dialect (tests/e2e/host-protocol.ts).
# NODE_OPTIONS below preserves the heap budget needed for prerelease peer resolution.
- name: Install dsh CLI (pinned)
env:
NODE_OPTIONS: --max-old-space-size=4096
run: npm install -g @deepseek-ai/dsh@0.2.1-rc.1
run: npm install -g @deepseek-ai/dsh@0.2.2-rc.1
# lib/ is gitignored; the tarball is produced from this build.
- name: Build and pack the npm tarball
+4 -4
View File
@@ -31,7 +31,7 @@
本地:`pnpm build && pnpm pack && pnpm exec playwright install chromium && pnpm test:mount`。
- **钉版写精确版本号,绝不写 dist-tag**(`alpha` / `latest` / `next` 的指向与候选版经常不一致);默认与 CI 同为 `@deepseek-ai/dsh@0.2.1-rc.1`。
- **钉版写精确版本号,绝不写 dist-tag**(`alpha` / `latest` / `next` 的指向与候选版经常不一致);默认与 CI 同为 `@deepseek-ai/dsh@0.2.2-rc.1`。
- 该步骤需要 `NODE_OPTIONS=--max-old-space-size=4096`(浮动的传递依赖会组出混合 peer 图 → ERESOLVE 后 OOM);**不要加 `--legacy-peer-deps`**(会跳掉 boot 必需的 peer,CLI 直接 `ERR_MODULE_NOT_FOUND`)。
- 本机 npm registry 是 npmmirror、对新预发布滞后:装不到时 `pnpm install --registry https://registry.npmjs.org`。
- Windows lane 跑 `pnpm test:windows`(`--maxWorkers=1`),`vitest.config.ts` 的 `testTimeout: 30_000` 与它配套。e2e spec 命名 `*.e2e.ts` + vitest `exclude` 双保险;**改 `exclude` 必须保留默认排除项**。
@@ -40,14 +40,14 @@
## 3. DSH 版本适配
- **当前基线 DSH 0.2.1-rc.1(v0.28.0 正式版起)**。**v0.30.0 起 14 条** `@deepseek-ai/dsh-*` peer(新增 `dsh-client-ui-input-trigger`,划选引用 chip 用它的 `ctx.inputTriggers`)下限均为 `^0.2.1-rc.1` 浮动 caret 范围、**绝不钉精确版本**(只有 devDependencies 精确钉);本包不声明 `package.json#engines.dsh`,因此走 peer 兼容性检查;宿主对声明了该字段的包优先且仅按它判定,不读 peer。`dsh.plugin.json#engines.dsh` 不参与这一规则。`tests/market-manifest.spec.ts` 钉住这条形状。
- **当前基线 DSH 0.2.2-rc.1(v0.30.0 起)**。**v0.30.0 起 14 条** `@deepseek-ai/dsh-*` peer(新增 `dsh-client-ui-input-trigger`,划选引用 chip 用它的 `ctx.inputTriggers`)下限均为 `^0.2.2-rc.1` 浮动 caret 范围、**绝不钉精确版本**(只有 devDependencies 精确钉);本包不声明 `package.json#engines.dsh`,因此走 peer 兼容性检查;宿主对声明了该字段的包优先且仅按它判定,不读 peer。`dsh.plugin.json#engines.dsh` 不参与这一规则。`tests/market-manifest.spec.ts` 钉住这条形状。
- **0.x caret 不跨 minor,但可跨 patch**:`^0.1.7-rc.1` 对 `0.2.0-rc.1` 判定为 false → 整行 `disabled`、插件静默不加载。**抬基线必须同批抬 peer 下限。**
- 支持线(用户侧):DSH **0.2.1-rc.1+** 使用插件 **v0.29.0**;0.2.1-alpha.5 用户固定 **v0.28.0-alpha.0**;0.2.0-rc.2 用户固定 **v0.26.1**(v0.27.0 尚未发布);0.2.0-rc.1 用户固定 v0.24.1;0.1.7 线的最后支持版是 **v0.22.1**(v0.23.0 从未发布到 npm)。按本仓库先例**不写运行时兼容层**。
- 支持线(用户侧):DSH **0.2.2-rc.1+** 使用插件 **v0.30.0**;DSH **0.2.1-rc.1+(含 npm `latest` 0.2.1-rc.5)** 固定 **v0.28.2**——v0.29.0 从未发布到 npm,0.2.1 线不要再抬;0.2.1-alpha.5 用户固定 **v0.28.0-alpha.0**;0.2.0-rc.2 用户固定 **v0.26.1**(v0.27.0 尚未发布);0.2.0-rc.1 用户固定 v0.24.1;0.1.7 线的最后支持版是 **v0.22.1**(v0.23.0 从未发布到 npm)。按本仓库先例**不写运行时兼容层**。
- **抬基线动作清单**:① `pnpm peers check`,把失配的传递 peer 提升进 devDependencies;② 扫宿主包产物的**裸 import 差集**(`pnpm peers check` 看不到这类失败,0.1.7 线是 `zustand` / `immer`);③ 对消费的宿主包做类型面 diff(重点 `ui-primitives` / `dsh-session` / `sidebar-right`),确认导出只增不减;④ 复查会话格式版本、`SUBAGENT_DESCRIPTOR_VERSION`、web profile 的 inject 列表;⑤ 同批同步 CI 钉版、`scripts/e2e-common.sh`、**`scripts/install.sh` / `scripts/install.ps1`(随包发布、会直接给用户 npx 命令)** 与 README / 指南的版本行。
- **用户 profile 自己的 `overrides: '@deepseek-ai/dsh-*'` 要同批抬**,否则旧包遮蔽 bundle → 预检禁用 `config-editor` → `settings` 行永久 `pending`;先看宿主日志的 `disabling profile plugin row` 与 `pending (waiting for service: …)`。
- **沿用 alpha.5 的删除契约**:不再依赖 `@deepseek-ai/dsh-invariants`、`ctx.invariants` 或上游 `/invariant` 子路径,也不发布本插件的 invariant companion;HTTP/WS 准入统一调用 `ctx.connection.requestRejection(req)`,仅 `undefined` 放行,不恢复 `webRuntime` / 自建信任例外。
- **v0.28.0 正式版接管 npm `latest`**:宿主 npm `latest` 此时仍指向 `0.2.0-rc.2`,不满足本插件 RC 基线;用户已明确接受这一分离,所有安装文档必须显著提醒旧宿主固定 `v0.26.1`,不要用浮动 `latest`。发布 workflow 沿用现有版本号规则,无需改动。
- **本次 RC 适配不改功能实现**:alpha.5 → rc.1 上游完整树差异共 355 项,全部为 `package.json`,源码零变化;同步版本、peer、伴随依赖与文档,重新获取 RC 验证证据,不沿用 alpha 测试数字。
- **本次 0.2.1 → 0.2.2 适配有真实代码改动**(不是纯版本同步):`dsh-agent` 用 agent 自有的 `AgentModel`(`agent.model`,`select()` 同时落盘并作用于下一步)替换了可安装的 `ModelSelectionRef` + `installModelSelection(ctx, ref)`,sidechat 的模型选择随之改写;`dsh-tools` 移除了 PTC(`tool/ptc-dispatch*`)的事件**类型声明**(运行期仍记录,`known-event-types` 仍在),只有测试要按擦除形状追加;图标从内联 `<path>` 变成 sprite `<use href="#dsw-icon-…">`,按图元的断言要跟着改。逐项证据见 [0.2.2 适配记录](docs/plans/2026-11-04-dsh-0.2.2-rc.1-adaptation.md)。
- 动设置面 / sidechat / 原生 tab 之前,先读 [docs/host-contracts.md](docs/host-contracts.md)(原 §3.4 的 1–13 条按原编号都在那里)。
---
+2
View File
@@ -4,6 +4,8 @@
### 未发布
- 🧭 **适配 DSH 0.2.2-rc.1(本版 peer 下限抬到 `^0.2.2-rc.1`)**:宿主把模型选择从可安装的 `ModelSelectionRef` 换成 agent 自有的 `AgentModel`——`agent.model.select()` 同时落盘并作用于下一步,侧边对话的线程模型选择随之改写(不再自己 install 一份 ref);`dsh-tools` 移除了 PTC(`tool/ptc-dispatch*`)的事件**类型声明**(运行期仍记录),宿主图标由内联 `<path>` 改为 sprite `<use href="#dsw-icon-…">`。**支持线随之移动**:0.x 的 caret 不跨 minor,因此 DSH 0.2.1 线(`0.2.1-rc.1 ~ rc.5`,即当前的宿主 npm `latest`)请继续固定插件 **v0.28.2**(`v0.29.0` 从未发布到 npm),0.2.2-rc.1+ 请用 **v0.30.0**。
- 🧪 验证:`typecheck` + 全量 `vitest` + `plugin-mount`(真实 0.2.2-rc.1 宿主 + Chromium);逐项证据见 [0.2.2 适配记录](docs/plans/2026-11-04-dsh-0.2.2-rc.1-adaptation.md)。
- 🧭 **安装脚本会先查 profile 自带的 `@deepseek-ai/dsh-*` 副本是否混版**([#1107](https://github.com/omdsh-dev/DSH-better-sidebar/issues/1107)):profile 里自己装的宿主包会抢在 DSH 安装之前被解析,本插件静态 import 的 `dsh-subagent` 因此绑到混搭版本;混版缺导出时整只宿主只报 `DesktopHostFatalError: required plugins did not activate`,看不到是哪个包缺了什么。`scripts/install.sh` / `scripts/install.ps1` 现在装完会运行随包发布的 `scripts/check-profile-host-tree.mjs`(按 DSH 自己的 profile 解析规则:只看 profile 内的副本、只判定 `dsh-subagent` 精确声明的 `dsh-attachment` peer)——混版就打印两份版本号与修复命令并退出,不再提示重启。README 常见问题补了同一条修复路径(从 profile 的 `package.json` / overrides 移除 `@deepseek-ai/dsh-*` 后 `pnpm install`,或把两份副本对齐到同一版本)。
- 🧪 测试:新增 `tests/install-host-tree.spec.ts`(6 例,真跑发布脚本:混版退出码 1 并给出两份版本;配对一致 / 只有 subagent 副本 / profile 之外的旧副本被忽略 / 未装插件均放行;并钉住两个安装脚本都调用它、脚本随包发布)。
- 🧵 **父会话进行中开的侧边对话不再写出一份永久不可读的子会话日志**([#1109](https://github.com/omdsh-dev/DSH-better-sidebar/issues/1109)):父会话压缩过之后,种子是围绕最后一个压缩检查点按**重编号**复制的,而继承来的 `session-log-deepseek/delivery-accepted` 的 `throughSeq` 是绝对 seq——重编号后它仍指向父会话的位置,于是子会话里出现「水位线不早于它自己的标记」,宿主 v4 读取器直接判日志损坏(`SessionFormatError: delivery throughSeq must precede its marker`):该子会话从此再也读不出来,连带父会话 `includeDescendants` 导出失败。现在重编号会把这条水位线一起重映射;水位线落在被丢弃的区间(子会话侧没有对应事件)时,该记录整条丢弃而不是伪造一个水位线。**已损坏的历史日志不会被修复**,只是不再产生新的。
+2
View File
@@ -6,6 +6,8 @@
### Unreleased
- 🧭 **Adapted to DSH 0.2.2-rc.1 (peer floors move to `^0.2.2-rc.1`)**: the host replaced the installable `ModelSelectionRef` with an agent-owned `AgentModel` — `agent.model.select()` records the choice durably and applies it to the next step, so the side-chat thread model selection rides the agent's own handle instead of an installed ref. `dsh-tools` dropped the PTC (`tool/ptc-dispatch*`) event **type declarations** (the runtime still records them), and host icons switched from inline `<path>` to sprite `<use href="#dsw-icon-…">`. **The support line moves with it**: a 0.x caret never spans a minor, so DSH 0.2.1 hosts (`0.2.1-rc.1 ~ rc.5`, today's npm `latest`) keep pinning plugin **v0.28.2** (`v0.29.0` was never published), while 0.2.2-rc.1+ takes **v0.30.0**.
- 🧪 Verified by `typecheck`, the full `vitest` suite, and `plugin-mount` against a real 0.2.2-rc.1 host in Chromium; see the [0.2.2 adaptation record](docs/plans/2026-11-04-dsh-0.2.2-rc.1-adaptation.md).
- 🧭 **The installers now verify that a profile's own `@deepseek-ai/dsh-*` copies belong to one host version** ([#1107](https://github.com/omdsh-dev/DSH-better-sidebar/issues/1107)): profile-installed host packages resolve ahead of the DSH installation, so the `dsh-subagent` this plugin imports statically binds to a mixed set; a missing export then takes the whole host down with `DesktopHostFatalError: required plugins did not activate`, never naming the package. `scripts/install.sh` / `scripts/install.ps1` now run the shipped `scripts/check-profile-host-tree.mjs` after installing (mirroring DSH's own profile resolution: profile-local copies only, and only the exact `dsh-attachment` peer `dsh-subagent` declares) — a torn pair prints both versions plus the repair and stops instead of telling you to restart. The README FAQ documents the same repair (remove `@deepseek-ai/dsh-*` from the profile's `package.json` / overrides and `pnpm install`, or align both copies).
- 🧪 New `tests/install-host-tree.spec.ts` (6 cases, running the shipped script: a torn pair exits 1 with both versions; a matching pair, a subagent-only copy, a stale copy above the profile, and an absent plugin all pass; both installers are pinned to call it and the script is pinned into `files`).
- 🧵 **A side chat opened while the parent is mid-turn no longer persists an unreadable child session log** ([#1109](https://github.com/omdsh-dev/DSH-better-sidebar/issues/1109)): once the parent has compacted, the seed is copied around its last compaction checkpoint with **renumbered** seqs, but the inherited `session-log-deepseek/delivery-accepted` `throughSeq` is an absolute seq — it still named the parent's position, so the child carried a watermark that did not precede its own marker. The host's v4 reader treats such a log as corrupt (`SessionFormatError: delivery throughSeq must precede its marker`): the child can never be read again, which also breaks the parent's `includeDescendants` export. The rebase now remaps the watermark, and drops the record entirely when the watermark fell inside the dropped span (there is no child-side equivalent, and inventing one would claim a delivery that never happened). **Already-corrupt logs are not repaired**; only new ones are prevented.
+10 -9
View File
@@ -7,7 +7,7 @@
<a href="https://github.com/omdsh-dev/DSH-better-sidebar/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/omdsh-dev/DSH-better-sidebar/actions/workflows/ci.yml/badge.svg" /></a>
<a href="https://github.com/omdsh-dev/DSH-better-sidebar/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/omdsh-dev/DSH-better-sidebar" /></a>
<a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" /></a>
<a href="https://www.npmjs.com/package/@deepseek-ai/dsh?activeTab=versions"><img alt="Supported DSH versions: 0.2.1-rc.1+" src="https://img.shields.io/badge/DSH-0.2.1--rc.1%2B-4d6bfe" /></a>
<a href="https://www.npmjs.com/package/@deepseek-ai/dsh?activeTab=versions"><img alt="Supported DSH versions: 0.2.2-rc.1+" src="https://img.shields.io/badge/DSH-0.2.2--rc.1%2B-4d6bfe" /></a>
</div>
<div align="center">
@@ -42,16 +42,17 @@ With the `dsh-context` plugin installed, three places offer a one-click jump int
dsh plugin --profile web add dsh-better-sidebar@latest
```
Then **hard-refresh the browser** (Cmd/Ctrl+Shift+R). Requires DSH **0.2.1-rc.1+**.
Then **hard-refresh the browser** (Cmd/Ctrl+Shift+R). Requires DSH **0.2.2-rc.1+**.
> **Compatibility warning — match the plugin to the host line.** As of 2026-10-28, DSH's npm `latest` is **0.2.1-rc.2**, so the command above installs the compatible v0.29.0. Hosts still on **0.2.0-rc.2** must pin `dsh-better-sidebar@0.26.1` (and should upgrade the host to `0.2.1-rc.2` first); DSH 0.2.1-alpha.5 users must pin `dsh-better-sidebar@0.28.0-alpha.0`. The marketplace installer picks the plugin's `latest` regardless of host version, so an old host gets a version-rejection error — upgrade the host or pin the version explicitly. The two packages' `latest` tags are independent.
> **Compatibility warning — match the plugin to the host line.** As of 2026-11-04, DSH's npm `latest` is **0.2.1-rc.5** and `next` is **0.2.2-rc.1**. **v0.30.0 requires DSH 0.2.2-rc.1+**; hosts on the 0.2.1 line (**0.2.1-rc.1 ~ rc.5**, i.e. today's `latest`) must pin `dsh-better-sidebar@0.28.2` — v0.29.0 was never published to npm. DSH 0.2.1-alpha.5 users must pin `dsh-better-sidebar@0.28.0-alpha.0`, and hosts still on **0.2.0-rc.2** must pin `dsh-better-sidebar@0.26.1`. A 0.x caret never spans a minor version, so one plugin build cannot serve two host lines. The marketplace installer picks the plugin's `latest` regardless of host version, so an old host gets a version-rejection error — upgrade the host or pin the version explicitly. The two packages' `latest` tags are independent.
<details>
<summary><b>Pick the plugin version for your DSH version</b></summary>
| Your DSH version | Install command |
| --- | --- |
| **0.2.1-rc.1+** | `dsh plugin --profile web add dsh-better-sidebar@0.29.0` |
| **0.2.2-rc.1+** | `dsh plugin --profile web add dsh-better-sidebar@0.30.0` |
| **0.2.1-rc.1 ~ 0.2.1-rc.5** | `dsh plugin --profile web add dsh-better-sidebar@0.28.2` |
| **0.2.1-alpha.5** | `dsh plugin --profile web add dsh-better-sidebar@0.28.0-alpha.0` |
| **0.2.0-rc.2** | `dsh plugin --profile web add dsh-better-sidebar@0.26.1` |
| **0.2.0-rc.1** | `dsh plugin --profile web add dsh-better-sidebar@0.24.1` |
@@ -70,12 +71,12 @@ Always pin **exact versions** for older releases (`latest` moves forward with ea
```text
Install the dsh-better-sidebar plugin (a sidebar workbench for DSH):
1. Confirm DSH is 0.2.1-rc.1 or newer, then run dsh plugin --profile web add dsh-better-sidebar@0.29.0
1. Confirm DSH is 0.2.2-rc.1 or newer, then run dsh plugin --profile web add dsh-better-sidebar@0.30.0
2. Remind me to hard-refresh the browser (Cmd/Ctrl+Shift+R) afterwards
If something fails, check the FAQ table in https://github.com/omdsh-dev/DSH-better-sidebar README first.
```
**One-line script** — clone this repo and run `bash scripts/install.sh 0.29.0` (macOS / Linux / Windows Git Bash; `./scripts/install.ps1 -Version 0.29.0` for native Windows). It handles installation + bundle registration.
**One-line script** — clone this repo and run `bash scripts/install.sh 0.30.0` (macOS / Linux / Windows Git Bash; `./scripts/install.ps1 -Version 0.30.0` for native Windows). It handles installation + bundle registration.
**Updating**: just re-run the install command, then hard-refresh the browser.
@@ -93,7 +94,7 @@ If something fails, check the FAQ table in https://github.com/omdsh-dev/DSH-bett
| **Two sidebars** on the page | Double mounting. Remove the legacy manual mount line (`- insert: ... better-sidebar ...`) from `~/.dsh/profiles/web/cordis.patch.yml`; aggregate packages mounting this package under a different id are auto-yielded, no action needed. |
| Settings values gone after upgrade | Since DSH 0.1.7, preferences live on this plugin's mount row in the profile (default entry id `better-sidebar`). The plugin migrates your old `settings.yaml` values once on first start and never overwrites newer values. |
| Terminal unavailable | Terminals are provided by **DSH itself** (this plugin ships no PTY) — see DSH docs; "host provides no terminal capability" in the bottom terminal means this deployment has no terminal controller mounted. |
| `dsh: command not found` | Install DSH first; or use `npx -y --package @deepseek-ai/dsh@0.2.1-rc.1 dsh plugin --profile web add dsh-better-sidebar@0.29.0`. |
| `dsh: command not found` | Install DSH first; or use `npx -y --package @deepseek-ai/dsh@0.2.2-rc.1 dsh plugin --profile web add dsh-better-sidebar@0.30.0`. |
</details>
@@ -122,9 +123,9 @@ If something fails, check the FAQ table in https://github.com/omdsh-dev/DSH-bett
- **Markdown links**: local destinations normalize Windows backslashes, so `C:\ws\_analysis\report.md` opens instead of a bare ENOENT
- **Sidebar**: the bottom-workbench toggle stays visible while the right panel is open; the macOS dock fallback avoids the traffic lights; a content-stable tab scope ends needless full-file re-reads; closing a side-chat tab archives its session
**v0.28.0 — stable plugin release for DSH 0.2.1-rc.1+**
**v0.28.0 — stable plugin release for DSH 0.2.2-rc.1+**
- Move all 13 DSH peer floors to `^0.2.1-rc.1`; retain the alpha.0 functionality without runtime changes
- Move all 13 DSH peer floors to `^0.2.2-rc.1`; retain the alpha.0 functionality without runtime changes
- The upstream alpha.5 → rc.1 full-tree diff contains 355 files, all `package.json`; no source changes
- DSH 0.2.0-rc.2 hosts stay on plugin v0.26.1; DSH 0.2.1-alpha.5 hosts stay on v0.28.0-alpha.0
- Validation: [RC adaptation record](./docs/plans/2026-10-17-dsh-0.2.1-rc.1-adaptation.md)
+10 -9
View File
@@ -7,7 +7,7 @@
<a href="https://github.com/omdsh-dev/DSH-better-sidebar/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/omdsh-dev/DSH-better-sidebar/actions/workflows/ci.yml/badge.svg" /></a>
<a href="https://github.com/omdsh-dev/DSH-better-sidebar/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/omdsh-dev/DSH-better-sidebar" /></a>
<a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" /></a>
<a href="https://www.npmjs.com/package/@deepseek-ai/dsh?activeTab=versions"><img alt="支持的 DSH 版本:0.2.1-rc.1+" src="https://img.shields.io/badge/DSH-0.2.1--rc.1%2B-4d6bfe" /></a>
<a href="https://www.npmjs.com/package/@deepseek-ai/dsh?activeTab=versions"><img alt="支持的 DSH 版本:0.2.2-rc.1+" src="https://img.shields.io/badge/DSH-0.2.2--rc.1%2B-4d6bfe" /></a>
</div>
<div align="center">
@@ -42,16 +42,17 @@
dsh plugin --profile web add dsh-better-sidebar@latest
```
装完**硬刷新浏览器**(Cmd/Ctrl+Shift+R)即可。要求 DSH **0.2.1-rc.1+**。
装完**硬刷新浏览器**(Cmd/Ctrl+Shift+R)即可。要求 DSH **0.2.2-rc.1+**。
> **兼容性警告:插件版本必须与宿主线匹配。** 截至 2026-10-28,DSH 的 npm `latest` 是 **0.2.1-rc.2**,上方命令安装的 v0.29.0 与之兼容。仍停留在 **0.2.0-rc.2** 的宿主必须固定 `dsh-better-sidebar@0.26.1`(并建议先升级宿主到 `0.2.1-rc.2`);DSH 0.2.1-alpha.5 用户固定 `dsh-better-sidebar@0.28.0-alpha.0`。市场安装器按插件的 `latest` 安装、不按宿主版本选版本,旧宿主会收到版本拒绝错误——请升级宿主或显式固定版本。两个包的 `latest` 标签不是同一支持线。
> **兼容性警告:插件版本必须与宿主线匹配。** 截至 2026-11-04,DSH 的 npm `latest` 是 **0.2.1-rc.5**、`next` 是 **0.2.2-rc.1**。**v0.30.0 要求 DSH 0.2.2-rc.1+**;仍停在 0.2.1 线(**0.2.1-rc.1 ~ rc.5**,也就是今天的 `latest`)的宿主必须固定 `dsh-better-sidebar@0.28.2`——v0.29.0 从未发布到 npm。DSH 0.2.1-alpha.5 用户固定 `dsh-better-sidebar@0.28.0-alpha.0`,**0.2.0-rc.2** 宿主固定 `dsh-better-sidebar@0.26.1`。0.x 的 caret 不跨 minor,因此一个构建无法同时服务两条宿主线。市场安装器按插件的 `latest` 安装、不按宿主版本选版本,旧宿主会收到版本拒绝错误——请升级宿主或显式固定版本。两个包的 `latest` 标签不是同一支持线。
<details>
<summary><b>按 DSH 版本选插件版本</b></summary>
| 你的 DSH 版本 | 安装命令 |
| --- | --- |
| **0.2.1-rc.1+** | `dsh plugin --profile web add dsh-better-sidebar@0.29.0` |
| **0.2.2-rc.1+** | `dsh plugin --profile web add dsh-better-sidebar@0.30.0` |
| **0.2.1-rc.1 ~ 0.2.1-rc.5** | `dsh plugin --profile web add dsh-better-sidebar@0.28.2` |
| **0.2.1-alpha.5** | `dsh plugin --profile web add dsh-better-sidebar@0.28.0-alpha.0` |
| **0.2.0-rc.2** | `dsh plugin --profile web add dsh-better-sidebar@0.26.1` |
| **0.2.0-rc.1** | `dsh plugin --profile web add dsh-better-sidebar@0.24.1` |
@@ -70,12 +71,12 @@ dsh plugin --profile web add dsh-better-sidebar@latest
```text
帮我安装 dsh-better-sidebar 插件(DSH 侧边栏工作台),步骤:
1. 先确认 DSH 为 0.2.1-rc.1 或更新版本,再执行 dsh plugin --profile web add dsh-better-sidebar@0.29.0
1. 先确认 DSH 为 0.2.2-rc.1 或更新版本,再执行 dsh plugin --profile web add dsh-better-sidebar@0.30.0
2. 完成后提醒我硬刷新浏览器(Cmd/Ctrl+Shift+R)
遇到报错先查 https://github.com/omdsh-dev/DSH-better-sidebar README 的常见问题表。
```
**一键脚本**——克隆本仓库后执行 `bash scripts/install.sh 0.29.0`(macOS / Linux / Windows Git Bash;Windows 原生用 `./scripts/install.ps1 -Version 0.29.0`),自动完成安装 + bundle 注册。
**一键脚本**——克隆本仓库后执行 `bash scripts/install.sh 0.30.0`(macOS / Linux / Windows Git Bash;Windows 原生用 `./scripts/install.ps1 -Version 0.30.0`),自动完成安装 + bundle 注册。
**更新**:重跑一次安装命令即可,然后硬刷新浏览器。
@@ -93,7 +94,7 @@ dsh plugin --profile web add dsh-better-sidebar@latest
| 页面出现**两个侧边栏** | 双挂载。删掉 `~/.dsh/profiles/web/cordis.patch.yml` 里旧的手动挂载行(`- insert: ... better-sidebar ...`);聚合包以不同 id 挂载本包时会自动退让,无需处理。 |
| 升级后设置页的值去哪了 | DSH 0.1.7 起偏好写在 profile 里本插件的挂载行上(默认 entry id `better-sidebar`),插件首次启动会把旧 `settings.yaml` 里的配置一次性回迁,不会覆盖新设的值。 |
| 终端无法使用 | 终端由 **DSH 自身**提供(本插件不自带 PTY),请查 DSH 侧文档;底部终端显示「宿主未提供终端能力」= 这个部署没挂终端控制器。 |
| 提示 `dsh: command not found` | 先安装 DSH;或用 `npx -y --package @deepseek-ai/dsh@0.2.1-rc.1 dsh plugin --profile web add dsh-better-sidebar@0.29.0`。 |
| 提示 `dsh: command not found` | 先安装 DSH;或用 `npx -y --package @deepseek-ai/dsh@0.2.2-rc.1 dsh plugin --profile web add dsh-better-sidebar@0.30.0`。 |
</details>
@@ -122,9 +123,9 @@ dsh plugin --profile web add dsh-better-sidebar@latest
- **Markdown 链接**:本地 destination 的 Windows 反斜杠归一,`C:\ws\_analysis\report.md` 不再报裸 ENOENT
- **侧栏**:右栏展开时底部工作台入口常显;macOS 兜底入口避开红绿灯;页签 scope 按内容稳定,消除无谓的整文件重读;关闭侧聊页签时归档其会话
**v0.28.0 — 面向 DSH 0.2.1-rc.1+ 的插件正式版**
**v0.28.0 — 面向 DSH 0.2.2-rc.1+ 的插件正式版**
- 13 条 DSH peer 下限前移到 `^0.2.1-rc.1`,沿用 alpha.0 的功能实现,不增加运行时改动
- 13 条 DSH peer 下限前移到 `^0.2.2-rc.1`,沿用 alpha.0 的功能实现,不增加运行时改动
- 上游 alpha.5 → rc.1 完整树差异共 355 个文件,全部为 `package.json`,源码零变化
- DSH 0.2.0-rc.2 宿主固定插件 v0.26.1;DSH 0.2.1-alpha.5 宿主固定 v0.28.0-alpha.0
- 验证:[RC 适配记录](./docs/plans/2026-10-17-dsh-0.2.1-rc.1-adaptation.md)
+4 -4
View File
@@ -2,9 +2,9 @@
> 面向 **消费插件开发者**:如何让你的插件向 better-sidebar 注册新的侧边栏页面(tab)和文件类型预览器。
>
> 适用版本:**v0.4.0+**(`ctx.betterSidebar` 服务);声明式设置 **v0.4.1+**;text/number 设置行 **v0.11.0+**;badge/生命周期/定向打开/插件设置/版本探测 **v0.12.0+**;select 设置行(`settingSelect`)与外链认领(`urlTarget`)**v0.13.0+**;统一 `@deepseek-ai/cordis` 类型基底 **v0.15.2+**;路由前缀安全解析(`hostRouteUrl`)**v0.25.0+**。当前版本 **v0.28.2 正式版**(14 条 DSH peer 下限 `^0.2.1-rc.1`,仅支持 DSH **0.2.1-rc.1+**;0.2.1-alpha.5 请固定 v0.28.0-alpha.0,0.2.0-rc.2 请固定 v0.26.1(v0.27.0 尚未发布),0.2.0-rc.1 请用 v0.24.1,0.1.7 线请用 v0.22.1——caret 范围跨 minor 不成立,`^0.1.7-rc.1` 会被 0.2.0 宿主的启动预检静默禁用)。**v0.19.0 移除了自绘右侧面板与自由窗口**(见 §0、§11);**自 v0.20.0 开发线起**(**注意:0.20.0 从未发布到 npm,这些变更全部落在 v0.21.1**)插件**移除了自带的终端**(宿主 0.1.6 的 `ui-sidebar-terminal` 取代,见 §4.4)、**移除了终端固定(pin)**,并在 0.1.7 上**把浏览器视图与只读文件预览整体让给宿主**(`ui-sidebar-browser` / `ui-sidebar-documentpreview`,见 §4.4、§5.4)、**收敛了外链接管**(见 §4.1)、**重写了设置接入面**(`SettingsForms`,见 §8.2)、**给文件树加了实时刷新**(见 §10);同时**删除了轮尾产物行接管**(DSH 0.1.6 把 `conversation.chat.turnTail` 从 chain 改成只能追加的 list,替换语义不复存在)。
> **版本对照提醒**:当前正式版为 **v0.28.2**(DSH 0.2.1-rc.1+;宿主 npm `latest` 已为 0.2.1-rc.2)。仍停留在 DSH 0.2.0-rc.2 的宿主必须固定插件 v0.26.1;DSH 0.2.1-alpha.5 固定 v0.28.0-alpha.0。市场安装器按插件 `latest` 安装、不按宿主版本选版本。
> 本次 alpha.5 → rc.1 上游完整树差异 355 项全部为 `package.json`、源码零变化,因此不改功能实现;伴随依赖为 Cordis peer `^4.0.5` / dev `4.0.5`、group `1.0.5`、schemastery `~3.18.5`、include `1.0.10`。RC 验证单独记录于 [适配记录](plans/2026-10-17-dsh-0.2.1-rc.1-adaptation.md),不以已发布 alpha 的测试数字替代。
> 适用版本:**v0.4.0+**(`ctx.betterSidebar` 服务);声明式设置 **v0.4.1+**;text/number 设置行 **v0.11.0+**;badge/生命周期/定向打开/插件设置/版本探测 **v0.12.0+**;select 设置行(`settingSelect`)与外链认领(`urlTarget`)**v0.13.0+**;统一 `@deepseek-ai/cordis` 类型基底 **v0.15.2+**;路由前缀安全解析(`hostRouteUrl`)**v0.25.0+**。当前版本 **v0.30.0**(14 条 DSH peer 下限 `^0.2.2-rc.1`,仅支持 DSH **0.2.2-rc.1+**;0.2.1 线(0.2.1-rc.1 ~ rc.5)请固定 v0.28.2;0.2.1-alpha.5 请固定 v0.28.0-alpha.0,0.2.0-rc.2 请固定 v0.26.1(v0.27.0 尚未发布),0.2.0-rc.1 请用 v0.24.1,0.1.7 线请用 v0.22.1——caret 范围跨 minor 不成立,`^0.1.7-rc.1` 会被 0.2.0 宿主的启动预检静默禁用)。**v0.19.0 移除了自绘右侧面板与自由窗口**(见 §0、§11);**自 v0.20.0 开发线起**(**注意:0.20.0 从未发布到 npm,这些变更全部落在 v0.21.1**)插件**移除了自带的终端**(宿主 0.1.6 的 `ui-sidebar-terminal` 取代,见 §4.4)、**移除了终端固定(pin)**,并在 0.1.7 上**把浏览器视图与只读文件预览整体让给宿主**(`ui-sidebar-browser` / `ui-sidebar-documentpreview`,见 §4.4、§5.4)、**收敛了外链接管**(见 §4.1)、**重写了设置接入面**(`SettingsForms`,见 §8.2)、**给文件树加了实时刷新**(见 §10);同时**删除了轮尾产物行接管**(DSH 0.1.6 把 `conversation.chat.turnTail` 从 chain 改成只能追加的 list,替换语义不复存在)。
> **版本对照提醒**:当前版本 **v0.30.0**(DSH 0.2.2-rc.1+)。0.x 的 caret 不跨 minor,因此 0.2.1 线(0.2.1-rc.1 ~ 0.2.1-rc.5,即今天的宿主 npm `latest`)必须固定插件 **v0.28.2**——v0.29.0 从未发布;DSH 0.2.1-alpha.5 固定 v0.28.0-alpha.0,0.2.0-rc.2 固定 v0.26.1。市场安装器按插件 `latest` 安装、不按宿主版本选版本。
> 上一次 alpha.5 → rc.1 适配只动了 `package.json`(完整树差异 355 项,源码零变化);**本次 0.2.1 → 0.2.2 有真实代码改动**(`AgentModel` 取代可安装的 `ModelSelectionRef`、PTC 事件类型声明被移除、宿主图标改为 sprite),逐项记录见 [0.2.2 适配记录](plans/2026-11-04-dsh-0.2.2-rc.1-adaptation.md);伴随依赖仍为 Cordis peer `^4.0.5` / dev `4.0.5`、group `1.0.5`、schemastery `~3.18.5`、include `1.0.10`。
> 权威代码:`src/client/service.ts`(服务实现)、`src/client/builtins/`(内置 6 tab + 3 viewer 参考实现)、`lib/types/client/service.d.ts`(类型声明)。
> alpha.5 已删除 `@deepseek-ai/dsh-invariants` 与上游 `/invariant` 子路径;本插件同步移除 invariant companion,不提供替代注册服务。HTTP/WS 准入遵循宿主 Connection(见 §6)。
> 当前目录语义:**已 attach** 的会话里,文件 / Git / 终端与新建 sidechat 跟随会话 `working_directory`(live 读 `ctx.workingDirectory.get(session)`);**cold / detached** 会话读存储 header(`ctx.sessionPersistence.stat(id)`,只读第一个 zstd 帧,不解码日志;进程内 memo + 在飞去重),`activeWorktreeRootOf` 对 detached 直接返回该工作区地址。不要为取一个 cwd 调 `ctx.sessionQuery.observeSession`:它会解码整份会话日志并水合全部投影,启动期 fs-watch 每目录一帧的扇出会把它放大成数十次整读(详见 [2026-10-27 记录](plans/2026-10-27-workspace-cwd-over-cold-reads.md))。linked worktree 仍按 base 目录记账;新 sidechat seed 尾部盖章当前 cwd,防止继承历史目录覆盖它。
@@ -97,7 +97,7 @@ import type {} from 'dsh-better-sidebar' // 触发 declare module '@deepseek-ai
> ⚠️ **计划上架 DSH 插件市场**的插件还须遵守市场 manifest 约束(`dependencies`/`peerDependencies`/`optionalDependencies` 一律不得出现 `cordis`、`scripts` 不得含 install 类钩子),详见 [AGENTS.md](../AGENTS.md) 硬约束一节。
> 📌 本插件自己的 DSH peer 下限自 v0.28.0 起统一为 `^0.2.1-rc.1`(**v0.30.0 起 14 条**——新增 `@deepseek-ai/dsh-client-ui-input-trigger`,划选引用 chip 的点击与发送展开走它的 `ctx.inputTriggers` 服务,见 §7.2)。宿主预检按名字为 `@deepseek-ai/dsh` 或 `@deepseek-ai/dsh-` 开头的 peer 判定兼容性,所以**只加在 devDependencies 里是不够的**。
> 📌 本插件自己的 DSH peer 下限自 v0.30.0 起统一为 `^0.2.2-rc.1`(**v0.30.0 起 14 条**——新增 `@deepseek-ai/dsh-client-ui-input-trigger`,划选引用 chip 的点击与发送展开走它的 `ctx.inputTriggers` 服务,见 §7.2)。宿主预检按名字为 `@deepseek-ai/dsh` 或 `@deepseek-ai/dsh-` 开头的 peer 判定兼容性,所以**只加在 devDependencies 里是不够的**。
### 2.3 类型导入路径
+4 -4
View File
@@ -2,11 +2,11 @@
> 从 `AGENTS.md` §3 移出的深度参考(原 §3.4 第 1–13 条与 0.1.5–0.1.7 历史线中仍然生效的部分)。
> **编号保持不变**:代码、测试与文档里写的「AGENTS.md §3.4 第 N 条」就是本文第 N 条。
> 历史版本已不在支持线内(当前基线 DSH 0.2.1-rc.1,见 [AGENTS.md](../AGENTS.md) §3);逐条适配过程见 [docs/plans/](plans/) 与 [CHANGELOG.md](../CHANGELOG.md)。
> 历史版本已不在支持线内(当前基线 DSH 0.2.2-rc.1,见 [AGENTS.md](../AGENTS.md) §3);逐条适配过程见 [docs/plans/](plans/) 与 [CHANGELOG.md](../CHANGELOG.md)。
当前适配约束:HTTP/WS 均由 `ctx.connection.requestRejection(req)` 裁决 Host/Origin 与浏览器认证,只有 `undefined` 放行,不读取已删除的 `webRuntime`。alpha.5 同时移除了 `@deepseek-ai/dsh-invariants`、`ctx.invariants` 和上游 `/invariant` 子路径;本插件不再发布 invariant companion。
本次 RC 适配只更新版本与依赖声明,不改变上述行为。alpha.5 → rc.1 上游完整树差异共 355 项、全部为 `package.json`,源码零变化;本次验证见 [RC 适配记录](plans/2026-10-17-dsh-0.2.1-rc.1-adaptation.md),不复用历史 alpha 测试数字。
上一次 alpha.5 → rc.1 适配只更新版本与依赖声明(上游源码零变化);**本次 0.2.1 → 0.2.2 有真实契约变化**:`dsh-agent` 的模型选择从可安装的 `ModelSelectionRef` 改为 agent 自有的 `AgentModel`(`agent.model.select()` 同时落盘并作用于下一步),`dsh-tools` 移除了 PTC 事件(`tool/ptc-dispatch*`)的类型声明但运行期仍记录,宿主图标由内联 `<path>` 改为 sprite `<use href="#dsw-icon-…">`。逐项证据见 [0.2.2 适配记录](plans/2026-11-04-dsh-0.2.2-rc.1-adaptation.md)。
## A. 0.1.5–0.1.7 引入、至今仍是现行约束的行为
@@ -45,12 +45,12 @@
10. **自定义种子必须带 fork 标记对(`meta.isSeeded: true` + `inheritedEventCount`),且 create 后必须 `inbox.clear()`、冷恢复必须按 id 精确清扫——标记对必要但不充分**:dsh-session 契约规定「只给 seed 不标 isSeeded,种子算重放历史而非继承前缀」——缺标记时 `Session.ownEvents()` 含整个种子,子会话的 inbox 折重放种子里的 `agent/inbox/spliced`,**继承父会话切割时刻未领取的 inbox 输入**。**但运行时 inbox 不走 `ownEvents()`**:`ReactLoopInbox.current()` → `ctx.sessionProjections.stateOf()` → `SessionProjectionRegistry.cellFor` 折的是 `snapshotEvents()` **全量日志(含继承种子前缀)**,且标准 inbox 投影的 `init` 忽略 `inheritedEventCount`、注册表 `session/created` 急切初始化跳过一切种子会话(seq ≠ 0)——种子里的 `agent/inbox/spliced` 会原样重放进子会话 live inbox。因此 sidechat 宿主 `agents.create` 成功后、任何 inject/followup 之前必须 `handle.agent.inbox.clear()`(durable 补偿 splice 是 own 事件,冷恢复折存储日志同样归零)。**幽灵的来源比「父会话排队」更宽**:父会话 mid-turn 且工具有未返回调用时,种子被截断在 `turn/start` 之前,而 inbox 的「领取」splice 发生在 `turn/start` **之后** → **父会话本轮开头已领取的输入**在种子折叠里仍是 pending;`clear()` 是唯一能一次清干净的硬围栏(create 时本线程自己不可能有排队输入)。**冷恢复不能沿用 `clear()`**(会误杀「用户在线程里排队、宿主重启后尚未领取」的合法输入):改为 `dropInheritedGhosts`——`inheritedPendingIds(log, inheritedEventCount)` 只折继承前缀得到幽灵 id 集合,再逐个 `agent.inbox.remove(id)`,精确且幂等(`src/sidechat-core.ts` 纯函数,`tests/sidechat-core.spec.ts` / `tests/sidechat-routes.spec.ts` 守护)。宿主 `session.fork`(api-session-controller)的调用即规范形态(注意:宿主自己的 `fork` **没有**这一步补偿,同窗口有同样的暴露面);回归由 `tests/sidechat-seed-validation.spec.ts`(真实 `Session.create` + 对 `ownEvents()` 跑 inbox 折 + **真实 `SessionProjectionRegistry`** 折全量日志钉住上游洞与 clear 补偿)守护。**压缩种子的重编号必须连绝对 seq 引用一起重映射**:`session-log-deepseek/delivery-accepted` 的 `throughSeq` 是绝对 seq,v4 读取器要求它早于自己的标记(`delivery throughSeq must precede its marker`),漏映射会让子会话日志永久不可读、连带父会话 `includeDescendants` 导出失败(#1109);水位线落在被丢弃区间时整条记录丢弃(`src/sidechat-core.ts` 的 `rebaseEvent`,`tests/sidechat-compaction-seed.spec.ts` 守护)。**模型选择同为 agent 作用域**:`sidechat.model` 必须同时落 `session.append('model/selection', …)`(宿主 `selectForNextRequest` 的同一形状)与 `installModelSelection(agent.ctx, ref)`(`@deepseek-ai/dsh-agent` 公开导出),否则控制器缓存的 per-agent selection 永不回读投影;resume 后也要按日志里的有效选择重装(`src/sidechat-routes.ts` 的 `ensureModelSelection`)。**上游 0.2.0 新增的 `buildForkSeed` 与本插件手工的 `buildSidechatInheritance` 职责重叠,但收益不明确**(插件另有 dangling-tool-call 退回结构化快照的自有需求),暂不替换。
11. **`dsh.plugin.json` 从来不是 DSH 契约**(全树 grep 0 命中):DSH 真正读的是 `package.json` 的 `dsh.bundle.patch` + `dsh.client`(`platform`/`inject`/`immediately`/`external`)+ `exports["./client"]`。`dsh.plugin.json` 与 `lib/client-registry.js` 只服务第三方 registry(社区市场)通道,`tests/manifest-consistency.spec.ts` 守护的是这条通道的形状,不是 DSH 契约。**不要混淆两个 manifest 的 `engines.dsh`**:当前宿主的兼容性检查优先读取 `package.json#engines.dsh`,存在时由它独立裁决;本插件未声明此字段,仍由 14 条 DSH peer 决定兼容性。`dsh.plugin.json#engines.dsh` 只是第三方 registry 元数据,不能替代 package 字段;`dsh.manifestVersion` 也不是版本兼容性开关。`dsh.bundle.patch` 有形状校验(非法值会 `throw`,引导期跳过该 bundle),本插件是合法的单字符串。
**插件展示元数据**(Plugins 页与 `plugin_manager` 列表,v0.21.1 起已采纳)三条硬规则:`package.json#icon` 必须是**包内相对路径**且写进 `files`(36×36、纯填充无描边、**双色渐变**——与 DSH 自带 `PluginArtwork*` 同风格,单色版在 30px 行内尺寸下会读成一块纯色板);`locale/en.json` 是发现基线(缺它整个目录都不读,`meta.title` / `description` 在这里);`exports` 必须暴露 `./locale/*.json` 与 `./package.json`。**所有失败都是静默的**——元数据有问题只会退化成一行纯文字,没有任何报错;`tests/plugin-meta.spec.ts` 守护「声明了就必须发布出去」。plugin-manager 侧另有**多 registry 回退**(配置源 → `fallbackRegistries`,默认含 `registry.npmmirror.com`;`network`/`timeout`/`not-found`/`no-matching-version` 会自动问下一个源;`registry` 入参只存在于 Web 对话框与 `plugin_manager` 工具,**CLI 没有 registry flag**)。
12. **宿主版本兼容性是启动期硬约束**:当前宿主先读插件 `package.json#engines.dsh`;字段存在时只按该范围判定,DSH peer 不再拓宽或收窄结果。字段缺席时回退检查名字为 `@deepseek-ai/dsh` 或以 `@deepseek-ai/dsh-` 开头的 peer,按 `semver.satisfies(宿主版本, range, { includePrerelease: true })` 判定。本插件刻意不新增该字段,仍由 14 条 DSH peer 的 `^0.2.1-rc.1` 支持线约束,optional peer 没有豁免。`engines` 非对象或 `engines.dsh` 非字符串会导致兼容性清单不可读并拒绝加载;`workspace:` 仅在 peer 中有效。安装与 profile 启动拒绝可能禁用整行,需读 `disabling profile plugin` 日志;拒绝记录字段已由 `peers` 改为 `requirements`,其中 key 为 `engines.dsh` 或回退检查的 peer 包名。`pnpm peers check` 校验的是 dev 依赖树,不能证明宿主启动预检通过。[官方升级指南](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-alpha.5/docs/upgrade-guide/v0.2.1-alpha.3/plugin-engines-dsh/guide.md)。
12. **宿主版本兼容性是启动期硬约束**:当前宿主先读插件 `package.json#engines.dsh`;字段存在时只按该范围判定,DSH peer 不再拓宽或收窄结果。字段缺席时回退检查名字为 `@deepseek-ai/dsh` 或以 `@deepseek-ai/dsh-` 开头的 peer,按 `semver.satisfies(宿主版本, range, { includePrerelease: true })` 判定。本插件刻意不新增该字段,仍由 14 条 DSH peer 的 `^0.2.2-rc.1` 支持线约束,optional peer 没有豁免。`engines` 非对象或 `engines.dsh` 非字符串会导致兼容性清单不可读并拒绝加载;`workspace:` 仅在 peer 中有效。安装与 profile 启动拒绝可能禁用整行,需读 `disabling profile plugin` 日志;拒绝记录字段已由 `peers` 改为 `requirements`,其中 key 为 `engines.dsh` 或回退检查的 peer 包名。`pnpm peers check` 校验的是 dev 依赖树,不能证明宿主启动预检通过。[官方升级指南](https://github.com/deepseek-ai/deepseek-harness/blob/dsh-v0.2.1-alpha.5/docs/upgrade-guide/v0.2.1-alpha.3/plugin-engines-dsh/guide.md)。
13. **会话地址的基准是会话 header cwd,相对路径不得中途换基准(#947 / #950;同族 #952)**:`dsh-resource://file/session/<sid>/<path>` 的相对路径,宿主构造端(`ui-chat` 的 `fileAddressFor(sessionId, sessions.list.byId[sid].cwd, path)`)与解析端(`api-workspace-files` → `sessions.get(sid).header.cwd`)都取会话存储的 header cwd;插件自 #802 起让 fs 路由跟随**活动 worktree 根**,两者在「会话 header cwd 是主检出、agent 在 linked worktree 里干活」时不同 → 地址路径被活动根**再拼一次**:翻倍 ENOENT(#947),或静默读到另一检出的同名文件(#950,可保存写回、更危险)。规则:**构造端**(`native/surface.ts` 的 `fileAddress`、`sidebar-file.ts` 的 `openClaimedNativeFile`)与**消费端**(`fileParamsOf(info, base)`)都经 `src/client/address-base.ts` 的 `addressBaseOf(ctx, sessionId)` 取基准,并在消费边界把地址路径解析成**绝对路径**(绝对路径在任何基准下都一样);只有用户/插件**意图**的相对路径(文件树、路径输入框、文档内链接、`openSidebarFile` 的 `options.cwd`)才走活动根(`useSessionRoot`)。同族第二处是**采纳判定**:工作区**内部**的 linked worktree 只有属于**同一仓库**(`--git-common-dir` 相等)才算「会话搬走了」,嵌套仓库(含 bare 仓库的 main/local 检出)的 worktree 不再抢根(#952)。判定与基准都按**新增可选入参**向前兼容:`activeWorktreeRootOf` 多一个 `ignorePin` 选项(给「显式根」的读取路径用,见 `src/session-root.ts`),既有调用方零改动。回归 `tests/worktree-address.spec.ts` / `tests/active-worktree.spec.ts`;设计与实测见 [docs/plans/2026-10-14-worktree-root-and-address-base.md](plans/2026-10-14-worktree-root-and-address-base.md)。
## C. 未保存草稿与宿主关闭路径(#1072 / #1071,2026-11-04)
- **宿主没有「关闭前可确认」的钩子**。`@deepseek-ai/dsh-client-ui-sidebar-right` 0.2.1-rc.1 的 `SidebarRightTabDefinition`(`lib/types/client/tab-registry.d.ts`)是纯静态的类型描述,没有 `onClose` / `beforeClose`;唯一的前置回调是 `ctx.sidebarRight.registerCloseHandler(kind, handler)`(`lib/types/client/service.d.ts` 的 `SidebarRightCloseHandler`),契约是「同步清理,失败则保留页签」,没有「用户取消」这一返回形态:要阻止关闭只能 `throw`。宿主自己的 terminal tab 就只用它做资源清理(`dsh-client-ui-sidebar-terminal/lib/client.js`)。
- **宿主没有「关闭前可确认」的钩子**。`@deepseek-ai/dsh-client-ui-sidebar-right` 0.2.2-rc.1 的 `SidebarRightTabDefinition`(`lib/types/client/tab-registry.d.ts`)是纯静态的类型描述,没有 `onClose` / `beforeClose`;唯一的前置回调是 `ctx.sidebarRight.registerCloseHandler(kind, handler)`(`lib/types/client/service.d.ts` 的 `SidebarRightCloseHandler`),契约是「同步清理,失败则保留页签」,没有「用户取消」这一返回形态:要阻止关闭只能 `throw`。宿主自己的 terminal tab 就只用它做资源清理(`dsh-client-ui-sidebar-terminal/lib/client.js`)。
- 显式关闭(页签条 × / 中键 / 上下文菜单 / `page.close` / `replaceTab`)都汇到 `lib/client.js` 的 `removeAfterCleanup`,但异常只在 seat 的 `closeTab` 里被捕获并打印 `Sidebar tab close failed:`;`replaceTab` 与公共 `ctx.sidebarRight.close()` **没有捕获**,用异常冒充「用户取消」会把错误抛进无关调用方。故插件不把它当确认通道,只当 flush 点。
- **桌面壳的 Cmd+Q 在页面之外**。macOS Desktop(`DSH Tauri.app`,内置 Electron 44.7.0)的主进程 `Contents/Resources/runtime/darwin-arm64/main.cjs` 订阅了 `app.on('before-quit')`:`preventDefault()` 后经 IPC 发 `app.exitRequested`,由壳自行完成退出;页面拿不到可取消的 quit 事件。壳内**没有** `will-prevent-unload` 处理(runtime 目录与壳可执行文件 grep 0 命中),因此若关闭最终走 `webContents.close()`,Electron 对 `beforeunload` 返回值的默认语义是**静默取消关闭**——这是 #1071「有脏草稿时 Cmd+Q 偶发退不掉、也没有确认框」的合理机制,但尚无 instrumentation 证据,不当作已证实根因。插件无法区分「被静默取消」与「页面成功拦截」,因此**不移除** `Sidebar.tsx` 的 `beforeunload`(浏览器刷新仍需要它);该 guard 现在会先 flush 草稿备份再拦截。
- **插件侧结论**:不伪造拦截,改为**降低损失**——`src/client/editor-draft-backup.ts` 在草稿变脏时按 1 s 节流写 `localStorage`(key = `sessionId::path`;单条 200k 字符、总计 600k 字符、最多 8 条、FIFO 淘汰),并在原生 `registerCloseHandler('editor')` 与 `beforeunload` 里立即 flush;重开同一文件由 `TextEditor` 提示恢复。保存成功、确认丢弃、确认刷新 / 就地换文件都会删除对应备份。
@@ -0,0 +1,66 @@
# 2026-11-04 DSH 0.2.1-rc.1 → 0.2.2-rc.1 适配
> 目标:把插件基线抬到 DSH **0.2.2-rc.1**(npm `next`),让 14 条 peer / devDeps / CI 钉版 / 安装脚本 / 文档与之一致,并把上游真实的契约变化改到位——**不是只改版本号**。
## 1. 结论
| 项 | 改动前 | 改动后 |
| --- | --- | --- |
| 宿主基线 | `0.2.1-rc.1` | **`0.2.2-rc.1`** |
| 14 条 DSH peer | `^0.2.1-rc.1` | **`^0.2.2-rc.1`**(caret 不跨 minor,只能整线抬) |
| devDependencies 精确钉 | `0.2.1-rc.1` × 29 | `0.2.2-rc.1` × 29 |
| 插件版本 | 0.29.0(从未发布到 npm) | **0.30.0** |
| 传递 peer | `@deepseek-ai/cordis-plugin-group` 1.0.5 | **~1.1.0**(`dsh-app-boot@0.2.2-rc.1` 要求) |
| CI / 安装脚本 / e2e 回落 | `@deepseek-ai/dsh@0.2.1-rc.1` | **`@deepseek-ai/dsh@0.2.2-rc.1`** |
## 2. 上游差异与证据
### 2.1 真实代码改动(必须改代码,改版本号不够)
1. **模型选择换成了 agent 自有的 `AgentModel`**(`@deepseek-ai/dsh-agent`)
- 0.2.1:`ModelSelectionRef`(`{ current, assembled }`,可变)+ `installModelSelection(ctx, ref)` 把它装成 prompt / request 瀑布。
- 0.2.2:`Agent` 新增只读 `agent.model: Model`,`select(selection)` **同时** 落盘 `model/selection` 并作用于下一步;`installModelSelection(ctx)` 只剩安装投影服务、返回 disposer。`ModelSelectionRef` 类型已不存在(`dsh-agent/lib/types/model-selection.d.ts`)。
- 改法([src/sidechat-routes.ts](../src/sidechat-routes.ts)):`ensureModelSelection` 返回 `Agent['model']`,首次认领时用线程日志里的选择 seed 一次,之后 `sidechat.model` 直接 `select()`;不再 install,也不再持有自建 ref。
2. **PTC 事件类型声明被移除**(`@deepseek-ai/dsh-tools`)
- 0.2.2 的 `dsh-tools` 产物里 **0 处** `tool/ptc-dispatch*`;`SessionStore.append` 因为没有登记项直接抛 `Cannot read properties of undefined (reading 'publicationEntry')`。
- `dsh-session` 的 `known-event-types` **仍保留**这两个名字,所以**读取**旧会话(0.2.1 记录的日志)不受影响——插件的文件操作折叠(`src/client/changes/ops.ts`)继续识别它们。
- 改法:生产读取路径**不动**;`tests/changes-ops-route.spec.ts` 里"用真实 store append PTC 对"的用例删除(0.2.2 无法产生该事件),并在原地写明理由、指向 `tests/changes-ops.spec.ts` 里已有的合成事件覆盖。
### 2.2 宿主内部形状变化(只改测试)
| 现象 | 证据 | 处理 |
| --- | --- | --- |
| 本地链接的 `title` 不再等于原始 destination | `ui-primitives/lib/index.js parseFileLink` 自己解析 `#L8-L15` / `:37` / `:12:5`,文件按钮 `title: file.path` | `sidechat-view.spec` 按宿主解析后的 title 定位,仍断言点击后 `openTab({path,line})` |
| 归档按钮的 hover 提示取不到 | 0.2.2 Tooltip 走 `onPointerEnter` 且检查 `matchMedia('(any-hover: hover)')` | `tooltipOf` 改派发 `pointerover` + stub `matchMedia`;**用户侧行为未变**(锚点是 enabled wrapper) |
| 图标断言取不到内联 `<path>` | `productIcon` 渲染 `<svg data-icon="dsw-icon-…"><use href="#…">` | 断言改到 sprite id(stage=plus、unstage 仍是插件内联 minus),12px 尺寸断言保留 |
| `WorkingDirectoryService.get` 抛 `stateOf` undefined | 0.2.2 把投影注册挪进 `[Service.init]()`,`get()` 读 `register` 返回的 handle | spec 的 fake `register` 返回 `{stateOf}`,并 `await lifecycle[Service.init]!()`;断言未改 |
### 2.3 不变的部分(已核)
- `SESSION_FORMAT_VERSION` = **4**(0.2.1 与 0.2.2 相同);
- `SUBAGENT_DESCRIPTOR_VERSION` = **3**(相同);
- `dsh-session` 的导出面逐项一致。
## 3. 门禁结果
| 门禁 | 结果 |
| --- | --- |
| `pnpm typecheck` | 通过 |
| 全量 `vitest` | **3025 passed / 17 skipped**;另有 3 条与负载相关的 flake(`tests/fs-watch.spec.ts` = 已登记的 #868;`tests/tasks-page.spec.tsx` 的 rAF 合并两条),隔离复跑全绿 |
| `pnpm peers check` | 只剩**既有**的第三方失配:`@huanlin/dsh-plugin-better-locale@0.1.0` 仍钉 `^0.1.0-rc.8`(0.2.1 线上就存在,非本次引入) |
| `plugin-mount`(真实 **0.2.2-rc.1** 宿主 + Chromium) | **20 passed / 6 skipped**,插件挂载、tab 扫掠、原生条目替换、文件树/编辑器 chunk 全绿 |
## 4. 支持线影响(重要)
- 0.x 的 caret 不跨 minor,**一个构建无法同时服务两条宿主线**:
- DSH **0.2.2-rc.1+** → 插件 **v0.30.0**;
- DSH **0.2.1-rc.1 ~ rc.5**(也就是当前的宿主 npm `latest`)→ 固定 **v0.28.2**(v0.29.0 从未发布到 npm)。
- 本次适配**不改发版流程**:`dev` 合入 `main` 后打 `v0.30.0` tag 即可。
- 用户侧 profile 的 `overrides: '@deepseek-ai/dsh-*'` 若存在,必须同批抬到 0.2.2,否则旧副本遮蔽 bundle(见 AGENTS §3)。
## 5. 刻意没做的事
- **不写运行时兼容层**(仓库先例):`ModelSelectionRef` 与 `AgentModel` 同时存在只会让 0.2.1 线更难判断;
- 不删 `use-markdown-surface.ts` 里被宿主抢先解析后变成死路径的 `splitTrailingLineSpec`:`path-line.ts` 仍被原生 tab 地址(`CMakeLists.txt:131`)使用,删它属于无关清理;
- 不动 `docs/plans/` 里的历史适配记录(它们的版本号是当时的事实)。
+2 -2
View File
@@ -1,10 +1,10 @@
{
"id": "dsh-external/dsh-better-sidebar",
"version": "0.29.0",
"version": "0.30.0",
"main": "./lib/index.js",
"description": "更好用的右侧边栏——文件树、编辑器、文件变动、任务和侧边对话都收在这一栏里,每个会话互不干扰。暴露服务供其他插件注册侧边栏页面与文件预览器",
"engines": {
"dsh": ">=0.2.1-rc.1"
"dsh": ">=0.2.2-rc.1"
},
"contributes": {
"tools": [],
+45 -45
View File
@@ -1,6 +1,6 @@
{
"name": "dsh-better-sidebar",
"version": "0.29.0",
"version": "0.30.0",
"description": "Better Sidebar for DSH — file tree, editor, changes, tasks and side chat in one column, separate for every conversation. Also exposes a service other plugins use to register sidebar tabs and file viewers.",
"type": "module",
"repository": {
@@ -94,20 +94,20 @@
"license": "MIT",
"peerDependencies": {
"@deepseek-ai/cordis": "^4.0.5",
"@deepseek-ai/dsh-agent": "^0.2.1-rc.1",
"@deepseek-ai/dsh-client-locale": "^0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-input-trigger": "^0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-sidebar-right": "^0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.1",
"@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.1",
"@deepseek-ai/dsh-llm": "^0.2.1-rc.1",
"@deepseek-ai/dsh-session": "^0.2.1-rc.1",
"@deepseek-ai/dsh-settings": "^0.2.1-rc.1",
"@deepseek-ai/dsh-subagent": "^0.2.1-rc.1",
"@deepseek-ai/dsh-tools": "^0.2.1-rc.1",
"@deepseek-ai/dsh-agent": "^0.2.2-rc.1",
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-input-trigger": "^0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-sidebar-right": "^0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.1",
"@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.1",
"@deepseek-ai/dsh-llm": "^0.2.2-rc.1",
"@deepseek-ai/dsh-session": "^0.2.2-rc.1",
"@deepseek-ai/dsh-settings": "^0.2.2-rc.1",
"@deepseek-ai/dsh-subagent": "^0.2.2-rc.1",
"@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
"@huanlin/dsh-plugin-better-locale": "^0.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
@@ -157,37 +157,37 @@
},
"devDependencies": {
"@deepseek-ai/cordis": "4.0.5",
"@deepseek-ai/cordis-plugin-group": "1.0.5",
"@deepseek-ai/cordis-plugin-group": "~1.1.0",
"@deepseek-ai/cordis-plugin-include": "1.0.10",
"@deepseek-ai/dsh-agent": "0.2.1-rc.1",
"@deepseek-ai/dsh-agent-loop": "0.2.1-rc.1",
"@deepseek-ai/dsh-attachment": "0.2.1-rc.1",
"@deepseek-ai/dsh-client-locale": "0.2.1-rc.1",
"@deepseek-ai/dsh-client-store": "0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-input-trigger": "0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-settings": "0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.1-rc.1",
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.1",
"@deepseek-ai/dsh-host-webserver": "0.2.1-rc.1",
"@deepseek-ai/dsh-llm": "0.2.1-rc.1",
"@deepseek-ai/dsh-ptc-runtime": "0.2.1-rc.1",
"@deepseek-ai/dsh-sandbox": "0.2.1-rc.1",
"@deepseek-ai/dsh-sandbox-policy": "0.2.1-rc.1",
"@deepseek-ai/dsh-scope": "0.2.1-rc.1",
"@deepseek-ai/dsh-session": "0.2.1-rc.1",
"@deepseek-ai/dsh-session-persistence": "0.2.1-rc.1",
"@deepseek-ai/dsh-session-projection": "0.2.1-rc.1",
"@deepseek-ai/dsh-settings": "0.2.1-rc.1",
"@deepseek-ai/dsh-subagent": "0.2.1-rc.1",
"@deepseek-ai/dsh-system-prompt": "0.2.1-rc.1",
"@deepseek-ai/dsh-tools": "0.2.1-rc.1",
"@deepseek-ai/dsh-user-approval": "0.2.1-rc.1",
"@deepseek-ai/dsh-util-code-language": "0.2.1-rc.1",
"@deepseek-ai/dsh-util-time": "0.2.1-rc.1",
"@deepseek-ai/dsh-util-workspace-path": "0.2.1-rc.1",
"@deepseek-ai/dsh-working-directory": "0.2.1-rc.1",
"@deepseek-ai/dsh-agent": "0.2.2-rc.1",
"@deepseek-ai/dsh-agent-loop": "0.2.2-rc.1",
"@deepseek-ai/dsh-attachment": "0.2.2-rc.1",
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.1",
"@deepseek-ai/dsh-client-store": "0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-input-trigger": "0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.2-rc.1",
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.1",
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.1",
"@deepseek-ai/dsh-llm": "0.2.2-rc.1",
"@deepseek-ai/dsh-ptc-runtime": "0.2.2-rc.1",
"@deepseek-ai/dsh-sandbox": "0.2.2-rc.1",
"@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.1",
"@deepseek-ai/dsh-scope": "0.2.2-rc.1",
"@deepseek-ai/dsh-session": "0.2.2-rc.1",
"@deepseek-ai/dsh-session-persistence": "0.2.2-rc.1",
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.1",
"@deepseek-ai/dsh-settings": "0.2.2-rc.1",
"@deepseek-ai/dsh-subagent": "0.2.2-rc.1",
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1",
"@deepseek-ai/dsh-tools": "0.2.2-rc.1",
"@deepseek-ai/dsh-user-approval": "0.2.2-rc.1",
"@deepseek-ai/dsh-util-code-language": "0.2.2-rc.1",
"@deepseek-ai/dsh-util-time": "0.2.2-rc.1",
"@deepseek-ai/dsh-util-workspace-path": "0.2.2-rc.1",
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.1",
"@cordisjs/plugin-loader": "^1.0.0-rc.5",
"@eslint/js": "^10.0.1",
"@huanlin/dsh-plugin-better-locale": "^0.1.0",
+559 -508
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -44,7 +44,7 @@ e2e_require_cmd() {
# 回退的 npx 版本是显式钉死的:不钉就会解析 npm 的 dist-tag,可能静默挂到
# 插件不支持的宿主上。**必须写精确版本,不能写 `@next`/`@alpha` 等 dist-tag**。
# 该版本必须与 package.json 的 DSH peer 基线同步。
DSH_NPX_SPEC="${DSH_NPX_SPEC:-@deepseek-ai/dsh@0.2.1-rc.1}"
DSH_NPX_SPEC="${DSH_NPX_SPEC:-@deepseek-ai/dsh@0.2.2-rc.1}"
e2e_resolve_dsh_cmd() {
local explicit="${DSH_CMD}"
if ! command -v "$DSH_CMD" >/dev/null 2>&1; then
@@ -66,7 +66,7 @@ e2e_resolve_dsh_cmd() {
# 己在挂什么),只告警。
e2e_check_dsh_version() {
local explicit="$1" actual expected
expected="${DSH_EXPECT_VERSION:-0.2.1-rc.1}"
expected="${DSH_EXPECT_VERSION:-0.2.2-rc.1}"
# `dsh --version` 冷启动要走 npx,给足预算;拿不到版本就只告警。
actual="$($DSH_CMD --version 2>/dev/null | tr -d '[:space:]' | head -c 64 || true)"
case "$actual" in
@@ -165,7 +165,7 @@ EOF
# 后台启动 dsh web(--port 0 = OS 分配,避免端口冲突;keyless 可起)。
# `--no-open` 是必须的:宿主默认会在启动后打开系统浏览器,本地反复跑这条
# lane 会不断弹窗(CI 是无头环境不受影响,本地开发机不是)。基线宿主
# 0.2.1-rc.1 的 web app 已提供该 flag(@deepseek-ai/dsh-web-app/lib/startup.js)。
# 0.2.2-rc.1 的 web app 已提供该 flag(@deepseek-ai/dsh-web-app/lib/startup.js)。
# $1 = stdout 日志;$2 = stderr 日志(缺省合并进 $1:mount lane 单文件,
# aggregate lane 分 out/err 两个文件)。写入全局 SERVER_PID。
e2e_start_dsh_web() {
+1 -1
View File
@@ -29,7 +29,7 @@ assert(hostRootOption, '--host-root is required (directory containing node_modul
const hostRoot = resolve(hostRootOption)
const tools = join(hostRoot, 'node_modules')
const hostPackage = JSON.parse(readFileSync(join(tools, '@deepseek-ai/dsh/package.json'), 'utf8'))
assert.equal(hostPackage.version, '0.2.1-rc.1', 'preinstalled host must be 0.2.1-rc.1')
assert.equal(hostPackage.version, '0.2.2-rc.1', 'preinstalled host must be 0.2.2-rc.1')
const channel = option('--channel')
const require = createRequire(join(root, 'package.json'))
const { chromium, request, expect } = require('@playwright/test')
+2 -2
View File
@@ -28,7 +28,7 @@
# 环境变量(均可省略):
# DSH_HOME 默认 %USERPROFILE%\.dsh
# REGISTRY 默认 https://registry.npmjs.org
# DSH_CMD 默认优先 PATH 上的 dsh,缺省回退 npx -y --package @deepseek-ai/dsh@0.2.1-rc.1
# DSH_CMD 默认优先 PATH 上的 dsh,缺省回退 npx -y --package @deepseek-ai/dsh@0.2.2-rc.1
#
# 说明:
# - pnpm 11 的 minimumReleaseAge 会拒绝发布 <24h 的新版本。脚本会预写
@@ -174,7 +174,7 @@ Ensure-WorkspaceSettings
if ($CLI -eq 'dsh') {
$cliArgs = @('plugin', '--profile', $Profile, 'add', "$PKG@$SPEC")
} else {
$cliArgs = @('-y', '--package', '@deepseek-ai/dsh@0.2.1-rc.1', 'dsh', 'plugin', '--profile', $Profile, 'add', "$PKG@$SPEC")
$cliArgs = @('-y', '--package', '@deepseek-ai/dsh@0.2.2-rc.1', 'dsh', 'plugin', '--profile', $Profile, 'add', "$PKG@$SPEC")
}
Say "执行 $CLI plugin --profile $Profile add $PKG@$SPEC ..."
$addOut = & $CLI @cliArgs 2>&1
+2 -2
View File
@@ -24,7 +24,7 @@
# 环境(均可省略,脚本会自动探测):
# DSH_HOME 默认 ~/.dsh(Windows Git Bash 下回退 $USERPROFILE/.dsh)
# REGISTRY 默认 https://registry.npmjs.org(发布源;装依赖仍走 pnpm 配置)
# DSH_CMD 默认优先用 PATH 上的 `dsh`,缺省回退 npx -y --package @deepseek-ai/dsh@0.2.1-rc.1
# DSH_CMD 默认优先用 PATH 上的 `dsh`,缺省回退 npx -y --package @deepseek-ai/dsh@0.2.2-rc.1
#
# 说明:
# - pnpm 11 的 minimumReleaseAge 会拒绝发布 <24h 的新版本。脚本会预写
@@ -140,7 +140,7 @@ dsh_cli() {
if command -v "$DSH_CMD" >/dev/null 2>&1; then
printf '%s' "$DSH_CMD"
elif command -v npx >/dev/null 2>&1; then
printf 'npx -y --package @deepseek-ai/dsh@0.2.1-rc.1 dsh'
printf 'npx -y --package @deepseek-ai/dsh@0.2.2-rc.1 dsh'
else
die "未找到 dsh 或 npx。请先安装 DSH(并确保 Node/npm 可用),或用 DSH_CMD 指定 dsh 路径。"
fi
+1 -1
View File
@@ -860,7 +860,7 @@ export function matchUrlTarget(tabs: readonly TabDescriptor[], url: URL): TabDes
* The plugin version this service instance reports. Keep in lockstep with
* `package.json`'s version — `tests/service.spec.ts` asserts the pair.
*/
export const SIDEBAR_SERVICE_VERSION = '0.29.0'
export const SIDEBAR_SERVICE_VERSION = '0.30.0'
/**
* Monotonic capability list consumers use to gate new API usage (features
+14 -19
View File
@@ -27,11 +27,9 @@ import { randomUUID } from 'node:crypto'
import { createUserMessage, ReasoningEffortId, type ContentBlock, type UserMessage } from '@deepseek-ai/dsh-llm'
import type { MessageId } from '@deepseek-ai/dsh-llm/brand'
import {
installModelSelection,
type Agent,
type AgentSetup,
type CreateAgentOptions,
type ModelSelectionRef,
type ResumeAgentOptions,
} from '@deepseek-ai/dsh-agent'
import { snapshotSubagentDescriptor } from '@deepseek-ai/dsh-subagent'
@@ -167,14 +165,14 @@ const threadDisposers = new Map<string, () => Promise<void>>()
* prompt is then delivered alone, a logged degradation). */
const pendingSnapshots = new Map<string, string>()
/** Per-thread model-selection refs installed on the live agent. The host's
* own composer commits a model switch by appending `model/selection` AND
* installing this agent-scoped ref (`SessionController.selectForNextRequest`);
* the ref is what prompt assembly and request routing actually read, because
* the controller caches one selection object per agent and never re-reads the
* projection. A subagent-origin thread never passes through the controller's
* fence, so the plugin installs the same seam itself. */
const threadModelRefs = new Map<string, ModelSelectionRef>()
/** One live agent's model seam (`agent.model`). DSH 0.2.2 replaced the
* installable `ModelSelectionRef` with an agent-owned `AgentModel` whose
* `select()` records the choice durably and applies it to the next step, so
* the plugin no longer installs anything: it holds the agent's own handle.
* The map only remembers which threads this module has already claimed, so a
* resumed thread is not re-seeded from a stale log every route. */
type AgentModelHandle = Agent['model']
const threadModelRefs = new Map<string, AgentModelHandle>()
/** The host model catalog service's structural face (dsh-api-session-controller
* is not a plugin peer; only `modelCatalog()` is read, and its shape is
@@ -494,17 +492,14 @@ function brandedSelection(selection: SidechatModelSelection): {
* @param childId - thread identity (the ref's key).
* @returns the installed (or already installed) ref.
*/
function ensureModelSelection(agent: Agent, childId: string): ModelSelectionRef {
function ensureModelSelection(agent: Agent, childId: string): AgentModelHandle {
const existing = threadModelRefs.get(childId)
if (existing !== undefined) return existing
const model = agent.model
const selection = selectionOf(agent)
const ref: ModelSelectionRef = {
current: selection === undefined ? undefined : brandedSelection(selection),
assembled: undefined,
}
installModelSelection(agent.ctx, ref)
threadModelRefs.set(childId, ref)
return ref
if (selection !== undefined) model.select(brandedSelection(selection))
threadModelRefs.set(childId, model)
return model
}
/** Resolve the thread's live agent, cold-resuming the persisted session under
@@ -983,7 +978,7 @@ export function buildSidechatApi(ctx: Context, live?: AssistantLiveBuffer, signa
// the durable intent lands in the log, and the agent-scoped ref is what
// prompt assembly and request routing read for the NEXT step.
agent.session.append('model/selection', brandedSelection(selection))
ensureModelSelection(agent, childId).current = brandedSelection(selection)
ensureModelSelection(agent, childId).select(brandedSelection(selection))
return { accepted: true as const, selection }
},
}
+9 -28
View File
@@ -41,34 +41,15 @@ describe('changes.ops waiting form', () => {
}
})
it('ships the PTC sub-call pair, not just the plain tool pair', async () => {
const runtime = new CordisContext()
const fiber = await runtime.plugin(SessionStore)
const session = runtime.sessions.create()
const changesOps = createChangesOpsApi(runtime as Context)
try {
const at = () => ({
turn: 0,
step: 0,
rootCallId: ToolCallId('root'),
parentCallId: ToolCallId('root'),
subCallId: ToolCallId('root:ptc:1'),
name: 'write',
})
session.append('tool/ptc-dispatch-start', { ...at(), arguments: { file_path: 'notes.txt', content: 'x' } })
session.append('tool/ptc-dispatch', {
...at(),
arguments: { file_path: 'notes.txt', content: 'x' },
isError: false,
content: [{ type: 'text', text: 'written' }],
})
const answer = await changesOps({ sessionId: session.id })
expect(answer.events.map(event => event.type))
.toEqual(['tool/ptc-dispatch-start', 'tool/ptc-dispatch'])
} finally {
await fiber.dispose()
}
})
// The PTC sub-call pair (`tool/ptc-dispatch-start` + `tool/ptc-dispatch`) can
// no longer be produced here: DSH 0.2.2 dropped both from the session event
// TYPE map and from the store's append registry, so `SessionStore.append`
// rejects them outright. The READER still has to understand them — logs
// recorded on 0.2.1 keep those events, and `dsh-session`'s known-event-types
// table still names them — but that contract belongs to the fold, which is
// fed synthetic events directly in `tests/changes-ops.spec.ts` ("keeps PTC
// sub-calls ..."). This route-level copy tested the store, not our filter, so
// it is gone rather than faked.
it('ends the empty-window wait when the client disconnects', async () => {
const runtime = new CordisContext()
+7 -4
View File
@@ -31,6 +31,9 @@ const MAIN = 'C:/repo/main'
/** The unstage artwork the SCM rows draw (the horizontal half of the host's Plus). */
const MINUS_GLYPH = 'M2 8H14'
/** The host's own Plus, a document-sprite reference since DSH 0.2.2 (it used
* to be inline `<path>` artwork, so only the sprite id identifies it now). */
const PLUS_ICON = '#dsw-icon-plus-outline-regular'
/** One synthetic tool/call + tool/result pair (write of one file). */
function writeEvents(seq: number, path: string): Array<{ type: string; seq: number; time: number; data: Record<string, unknown> }> {
@@ -635,13 +638,13 @@ describe('ChangesTab', () => {
}
// A stage affordance that drew the unstage glyph is the #941 regression:
// the two directions must not share artwork (vscode: $(add) vs $(remove)).
// Unstage is the horizontal half alone; staging adds the vertical stroke
// (the host's Plus) — the two directions must not share one glyph.
// Unstage is the plugin's own horizontal half; staging is the host's Plus
// sprite — the two directions must not share one glyph.
const stage = iconOf(t('stage'))
const unstage = iconOf(t('unstage'))
expect(unstage).toContain(MINUS_GLYPH)
expect(unstage).not.toContain('M8 2V14')
expect(stage).toContain('M8 2V14')
expect(unstage).not.toContain(PLUS_ICON)
expect(stage).toContain(PLUS_ICON)
} finally {
act(() => { root.unmount() })
container.remove()
+1 -1
View File
@@ -5,7 +5,7 @@
import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
const baseline = '0.2.1-rc.1'
const baseline = '0.2.2-rc.1'
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
const bash = readFileSync(new URL('../scripts/install.sh', import.meta.url), 'utf8')
const powershell = readFileSync(new URL('../scripts/install.ps1', import.meta.url), 'utf8')
+18 -5
View File
@@ -12,6 +12,20 @@ setupReactAct()
afterEach(() => { vi.restoreAllMocks() })
const CWD = 'C:/repo'
const store = createSidebarStore()
/** The unstage artwork the SCM rows draw (the plugin's own inline horizontal half). */
const MINUS_GLYPH = 'M2 8H14'
/** The host's own Plus, a document-sprite reference since DSH 0.2.2 (it used
* to be inline `<path>` artwork, so only the sprite id identifies it now). */
const PLUS_ICON = '#dsw-icon-plus-outline-regular'
/** One action button's artwork as the DOM carries it: the host's icons are
* sprite references (`<use href="#dsw-icon-…">`), the plugin's minus is still
* inline artwork, so both shapes have to be readable. */
const glyphOf = (button: HTMLButtonElement): string => {
const svg = button.querySelector('svg')!
const sprite = svg.getAttribute('data-icon')
if (sprite !== null) return `#${sprite}`
return [...svg.querySelectorAll('path')].map(path => path.getAttribute('d')).join(' ')
}
const tracked = (): GitStatusResult => ({
isRepo: true, branch: 'main', root: CWD, upstream: 'origin/main', ahead: 1, behind: 0,
entries: [{ path: 'src/partial.ts', xy: 'MD' }, { path: 'new.ts', xy: '??' }],
@@ -125,17 +139,16 @@ it('keeps directory/all actions inside their group, including Merge directory fo
expect(action.querySelector('svg')!.getAttribute('width')).toBe('12')
expect(action.querySelector('svg')!.getAttribute('height')).toBe('12')
// Staging and unstaging must not share artwork: a staged row's action
// unstages (the minus), every other row's stages (the host's Plus).
const glyphs = [...action.querySelectorAll('svg path')].map(path => path.getAttribute('d'))
// unstages (the plugin's minus), every other row's stages (the host's
// Plus sprite).
const stagedRow = row.closest('[data-group]')!.getAttribute('data-group') === 'staged'
expect(glyphs).toEqual(stagedRow ? ['M2 8H14'] : ['M8 2V14', 'M2 8H14'])
expect(glyphOf(action)).toBe(stagedRow ? MINUS_GLYPH : PLUS_ICON)
}
for (const name of ['merge', 'staged', 'unstaged']) {
const headerAction = group(name).firstElementChild!.querySelector<HTMLButtonElement>(`button[aria-label="${t(name === 'staged' ? 'unstageAll' : 'stageAll')}"]`)!
expect(headerAction.querySelector('svg')!.getAttribute('width')).toBe('12')
expect(headerAction.querySelector('svg')!.getAttribute('height')).toBe('12')
expect([...headerAction.querySelectorAll('svg path')].map(path => path.getAttribute('d')))
.toEqual(name === 'staged' ? ['M2 8H14'] : ['M8 2V14', 'M2 8H14'])
expect(glyphOf(headerAction)).toBe(name === 'staged' ? MINUS_GLYPH : PLUS_ICON)
}
await click(dir('merge'))
expect(dir('merge').getAttribute('aria-expanded')).toBe('false')
+1 -1
View File
@@ -142,7 +142,7 @@ describe('DSH community-market manifest compatibility', () => {
const dshPeers = Object.keys(peers).filter(name => name === '@deepseek-ai/dsh' || name.startsWith('@deepseek-ai/dsh-'))
expect(dshPeers.length).toBeGreaterThan(10)
for (const name of dshPeers) {
expect(peers[name], name).toMatch(/^\^0\.2\.1-rc\.1$/)
expect(peers[name], name).toMatch(/^\^0\.2\.2-rc\.1$/)
}
})
})
+27 -14
View File
@@ -9,6 +9,7 @@
*/
import { describe, expect, it, vi } from 'vitest'
import { resolve } from 'node:path'
import { Service } from '@deepseek-ai/cordis'
import WorkingDirectoryService from '@deepseek-ai/dsh-working-directory'
import { Session, SessionLogOffset, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session'
import type { SessionEvent, SessionHeader, SessionId } from '@deepseek-ai/dsh-session'
@@ -43,8 +44,10 @@ function agent(id: string, over: {
model: over.model ?? 'model-x',
...(over.reasoningEffort !== undefined ? { reasoningEffort: over.reasoningEffort } : {}),
},
// The agent-scoped context `installModelSelection` binds its prompt /
// request waterfalls to; the fake records the listeners' existence only.
// DSH 0.2.2 moved the model seam onto the agent itself (`agent.model`),
// so the fake records the selections the plugin applies instead of the
// waterfall listeners the old installable ref registered.
model: { current: vi.fn(() => undefined), select: vi.fn() },
ctx: { on: vi.fn((_event: string, _listener: unknown) => () => {}) },
session: {
id,
@@ -168,21 +171,29 @@ describe('sidechat.start', () => {
apply(state: string | null, event: SessionEvent): string | null
}
let registered: DirectoryProjection | undefined
// Capture the REAL alpha.5 unit contributed by the host service. These
// context seams do not run system-prompt assembly, fs checks, or notices.
/** Fold one session's log through the captured unit — what the registry's
* reader evaluates for this projection key. */
const stateOf = (session: { header: { cwd?: string }; snapshotEvents(): SessionEvent[] }): string | null => {
if (registered === undefined) throw new Error('working-directory unit not registered')
return session.snapshotEvents().reduce((cwd, event) => registered!.apply(cwd, event), registered.init(session.header))
}
// Capture the REAL host unit. These context seams do not run system-prompt
// assembly, fs checks, or notices. DSH 0.2.2 moved that registration into
// the service's cordis init and reads the state back through the HANDLE
// `register` now returns (0.2.1 registered from the constructor and read
// `sessionProjections.stateOf(session, key)`), so the fake registry has to
// hand one out and the spec has to drive the lifecycle step itself.
const workingDirectory = new WorkingDirectoryService({
reflect: { provide: () => {} },
sessionProjections: {
register: (definition: DirectoryProjection) => { registered = definition },
stateOf: (session: { header: { cwd?: string }; snapshotEvents(): SessionEvent[] }) => {
if (registered === undefined) throw new Error('working-directory unit not registered')
return session.snapshotEvents().reduce((cwd, event) => registered!.apply(cwd, event), registered.init(session.header))
},
register: (definition: DirectoryProjection) => { registered = definition; return { stateOf } },
},
systemPrompt: { context: () => {}, getContextOrder: () => 0 },
on: () => {},
effect: () => {},
} as never, {})
const lifecycle = workingDirectory as unknown as Record<symbol, () => Promise<void>>
await lifecycle[Service.init]!()
expect(workingDirectory.get(parent.session as never)).toBe(current)
const services = happyServices(parent, agent('child'))
await buildSidechatApi(ctxWith({ ...services, workingDirectory }))['sidechat.start']({ sessionId: 'parent' })
@@ -1032,13 +1043,15 @@ describe('sidechat.models and sidechat.model', () => {
model: 'm2',
reasoningEffort: 'high',
})
// The selection seam is installed ONCE per agent: the second switch of the
// same thread only mutates the ref.
const listeners = child.ctx.on.mock.calls.length
expect(listeners).toBeGreaterThan(0)
// The thread is claimed once: the first switch both SEEDS the agent's model
// from the thread's recorded selection and applies the requested one, so
// the second switch adds exactly one more select — no re-seed, no second
// install — which is what the removed "install once" listener count proved.
const selections = child.model.select.mock.calls.length
expect(selections).toBe(2)
await api['sidechat.model']({ childId: 'child-model', provider: 'p2', model: 'm2' })
expect(child.session.append).toHaveBeenCalledTimes(2)
expect(child.ctx.on.mock.calls.length).toBe(listeners)
expect(child.model.select.mock.calls.length).toBe(selections + 1)
})
it('rejects an unavailable model with a bad-request', async () => {
+48 -11
View File
@@ -210,20 +210,50 @@ function stubResizeObserver(): () => void {
}
}
/** jsdom ships no `matchMedia`, and the 0.2.2 host Tooltip gates its hover
* handler on a hover-capable pointer (`(any-hover: hover)`), so the spec has
* to declare one before any bubble can open. */
function stubHoverCapable(): () => void {
const original = Object.getOwnPropertyDescriptor(window, 'matchMedia')
Object.defineProperty(window, 'matchMedia', {
configurable: true,
value: (query: string) => ({
matches: true,
media: query,
onchange: null,
addEventListener: () => {},
removeEventListener: () => {},
addListener: () => {},
removeListener: () => {},
dispatchEvent: () => false,
}),
})
return () => {
if (original === undefined) Reflect.deleteProperty(window, 'matchMedia')
else Object.defineProperty(window, 'matchMedia', original)
}
}
/** Open a composer-bar control's hover bubble and return its text. */
async function tooltipOf(control: HTMLElement): Promise<string> {
const restore = stubResizeObserver()
const restoreObserver = stubResizeObserver()
const restoreHover = stubHoverCapable()
try {
const anchor = control.parentElement
if (anchor === null) throw new Error('the control is missing its hover anchor')
await act(async () => {
anchor.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }))
// DSH 0.2.2's Tooltip opens on POINTER enter (React derives
// `onPointerEnter` from a bubbling `pointerover`) and rejects touch;
// 0.2.1's listened to mouse enter, which is why this used to dispatch
// `mouseover` and now opens nothing at all.
anchor.dispatchEvent(new PointerEvent('pointerover', { bubbles: true, pointerType: 'mouse' }))
// ComposerTip's 120 ms hover delay (TIP_DELAY_MS).
await new Promise(resolve => setTimeout(resolve, 180))
})
return document.body.querySelector('[role="tooltip"]')?.textContent ?? ''
} finally {
restore()
restoreHover()
restoreObserver()
}
}
@@ -381,11 +411,12 @@ describe('SideChatView rendering', () => {
})
it.each([
['src/Foo.java:37-58', '/p/src/Foo.java', 37],
['E:/Code/project/Foo.java:37', 'E:\\Code\\project\\Foo.java', 37],
['E:/Code/my project/目录/Foo(1).java:12:5', 'E:\\Code\\my project\\目录\\Foo(1).java', 12],
['src/main.ts#L8-L15', '/p/src/main.ts', 8],
])('renders and opens a source link to %s at its first referenced line', async (destination, path, line) => {
// destination · the file button's title · the absolute path openTab takes · line
['src/Foo.java:37-58', 'src/Foo.java', '/p/src/Foo.java', 37],
['E:/Code/project/Foo.java:37', 'E:/Code/project/Foo.java', 'E:\\Code\\project\\Foo.java', 37],
['E:/Code/my project/目录/Foo(1).java:12:5', 'E:/Code/my project/目录/Foo(1).java', 'E:\\Code\\my project\\目录\\Foo(1).java', 12],
['src/main.ts#L8-L15', 'src/main.ts', '/p/src/main.ts', 8],
])('renders and opens a source link to %s at its first referenced line', async (destination, title, path, line) => {
eventsValue = EVENTS.map(event => event.type === 'assistant/message'
? {
...event,
@@ -404,9 +435,15 @@ describe('SideChatView rendering', () => {
))
try {
await act(async () => {})
const link = [...container.querySelectorAll<HTMLButtonElement>('button')]
.find(button => button.title === destination.split('#')[0])
expect(link).not.toBeUndefined()
// DSH 0.2.2's MarkdownText parses the line location ITSELF — both the
// GitHub fragment (`#L8-L15`) and the `:37` / `:12:5` suffixes — and
// titles the file button with the PATH it parsed, so the location is no
// longer part of the destination the plugin sees (0.2.1 carried it
// verbatim, which is what `path-line.ts` still splits for native tab
// addresses). The titled button with the link glyph is the host's own
// file-link shape; the click below is the contract we own.
const link = container.querySelector<HTMLButtonElement>(`button[title="${title}"]`)
expect(link).not.toBeNull()
expect(link?.querySelector('svg')).not.toBeNull()
expect(container.textContent).not.toContain(`(<${destination}`)
act(() => { link?.click() })