From e3d32cde429420a78bdba8b84ee2a29e1fe73645 Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Tue, 27 Oct 2026 22:58:01 +0800 Subject: [PATCH] chore(release): prepare v0.28.2 - bump package.json / dsh.plugin.json / SIDEBAR_SERVICE_VERSION to 0.28.2 - CHANGELOG: v0.28.2 (cold cwd from the stored workspace header) with the measured numbers; CHANGELOG_EN mirrors it - README / README_ZH: install commands and installer args target 0.28.2; Recent Updates trimmed to v0.28.2 / v0.28.1 / v0.28.0 - AGENTS + external-plugin-guide: current stable version is v0.28.2 - plan record: 40,157,518-byte session benchmark (1 header read, 0 full reads, 3 ms, +0.3 MB RSS; pre-fix 6 calls = 6 full reads, +1.0 GB peak) --- AGENTS.md | 2 +- CHANGELOG.md | 3 +- CHANGELOG_EN.md | 3 +- README.md | 24 +++++++-------- README_ZH.md | 24 +++++++-------- docs/external-plugin-guide.md | 4 +-- ...026-10-27-workspace-cwd-over-cold-reads.md | 29 +++++++++++++++++-- dsh.plugin.json | 2 +- package.json | 2 +- src/client/service.ts | 2 +- 10 files changed, 61 insertions(+), 34 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e2f77520..14b35226 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -42,7 +42,7 @@ - **当前基线 DSH 0.2.1-rc.1(v0.28.0 正式版起)**。13 条 `@deepseek-ai/dsh-*` peer 下限均为 `^0.2.1-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.28.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)。按本仓库先例**不写运行时兼容层**。 +- 支持线(用户侧):DSH **0.2.1-rc.1+** 使用插件 **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**(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` / 自建信任例外。 diff --git a/CHANGELOG.md b/CHANGELOG.md index f1363d7c..6279ab82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,11 @@ > 本文档收录 dsh-better-sidebar 的完整发布历史(最新版摘要见 [README](README_ZH.md);同步发布于 [GitHub Releases](https://github.com/omdsh-dev/DSH-better-sidebar/releases))。 -### Unreleased +### v0.28.2 - 🛡 **冷会话(detached)的 cwd 改读工作区地址,不再整份解码会话日志**:`sessionQuery.observeSession(..., { projectionMode: 'all' })` 为拿一个 `workingDirectory` 要解码整份 zstd 日志并水合全部投影;而启动期真正并发的是 **fs-watch 每监视目录一帧**、`/sidebar/file|html` 每资源一次、`/sidebar/upload|write` 每次一次——它们都绕过 0.28.1 只覆盖 `/sidebar/api` 的 `cwdOf()` 单飞,所以 39 MB 级会话在 130–180 ms 里被并发整读数十次(0.28.0 的 44 次 OOM、0.28.1 的 36 次是同一路径,不是「去重失效」)。现在 detached 会话的 cwd 走 `sessionPersistence.stat` 的 **header-only** 读(只读第一个 zstd 帧)+ 进程内 memo/在飞去重,`activeWorktreeRootOf` 对 detached 会话直接返回该地址;宿主 attach 后仍跟随 `working_directory` 与 linked worktree。 - 代价:会话 attach 之前,侧边栏根是原始项目目录而非 agent 最后所在的子目录 / worktree;attach 后下一次 5 s 轮询切回。 + - 📏 **实测(40,157,518 字节会话,本机重建)**:12 个 `session.cwd` + 36 个绕过入口调用并发 → **1 次 header 读、0 次整读、3 ms、RSS +0.3 MB**;同产物用修复前代码(`43db17f`)跑 6 个绕过入口并发 → 6 次整读、峰值 RSS +1002 MB(外推 36 次 ≈ 6.0 GB,与事故 6.2 GB 峰值吻合)。单次整读成本 467 ms / +501.6 MB。方法与边界见[记录](docs/plans/2026-10-27-workspace-cwd-over-cold-reads.md) §5.2。 - 🧪 测试:`tests/smoke.spec.ts` 重写该组 8 例(header 优先于陈旧提示、header 只读一次、12 并发共享一次 header 读、无 `stat`/`stat` 失败回落客户端提示、live committed 优先、相对 cwd 拒绝为 `bad-request`、`defaultDirectory` 与进程 cwd 兜底)。机制与取舍见 [记录](docs/plans/2026-10-27-workspace-cwd-over-cold-reads.md)。 ### v0.28.1 diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index 64905975..fbebd5e3 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -4,10 +4,11 @@ > > 📝 The Chinese [CHANGELOG](./CHANGELOG.md) is the authoritative, item-by-item record; this file carries the English summaries and has historically lagged behind it. Where the two disagree, the Chinese one is current. -### Unreleased +### v0.28.2 - 🛡 **A detached session's cwd now comes from its stored workspace address instead of decoding the whole session log.** `sessionQuery.observeSession(..., { projectionMode: 'all' })` decodes the entire zstd artifact and hydrates every projection to answer with one `workingDirectory` string. The real startup fan-out never went through the 0.28.1 `cwdOf()` single-flight (which only covers `/sidebar/api`): the fs-watch socket sends **one frame per watched directory**, and `/sidebar/file|html` resolve cwd per resource, `/sidebar/upload|write` per call — so a 39 MB session was fully decoded dozens of times inside 130–180 ms (the 44-read OOM on 0.28.0 and the 36 reads reported against 0.28.1 are the same path, not a broken dedupe). The cold cwd now uses `sessionPersistence.stat` — a **header-only** read (first zstd frame) with a process-level memo and same-session in-flight sharing — and `activeWorktreeRootOf` returns that address for detached sessions. Once the host attaches the session, the committed `working_directory` and linked-worktree following resume as before. - Cost: until the session is attached, the sidebar roots at the original project rather than the agent's last directory/worktree; the next 5 s poll corrects it after attach. + - 📏 **Measured (40,157,518-byte session, rebuilt locally)**: 12 `session.cwd` + 36 bypass-entry calls concurrently → **1 header read, 0 full reads, 3 ms, +0.3 MB RSS**; the same artifact on the pre-fix build (`43db17f`) with 6 concurrent bypass calls → 6 full reads, +1002 MB peak RSS (≈6.0 GB extrapolated for 36, matching the 6.2 GB incident peak). One full read costs 467 ms / +501.6 MB. Method and limits: [record](docs/plans/2026-10-27-workspace-cwd-over-cold-reads.md) §5.2. - 🧪 `tests/smoke.spec.ts` rewrote that group of 8 cases. Rationale and trade-offs: [record](docs/plans/2026-10-27-workspace-cwd-over-cold-reads.md). ### v0.28.1 diff --git a/README.md b/README.md index b4321c87..aa69fdaf 100644 --- a/README.md +++ b/README.md @@ -44,14 +44,14 @@ 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+**. -> **Compatibility warning — match the plugin to the host line.** As of 2026-10-26, DSH's npm `latest` is **0.2.1-rc.2**, so the command above installs the compatible v0.28.1. 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-10-26, DSH's npm `latest` is **0.2.1-rc.2**, so the command above installs the compatible v0.28.2. 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.
Pick the plugin version for your DSH version | Your DSH version | Install command | | --- | --- | -| **0.2.1-rc.1+** | `dsh plugin --profile web add dsh-better-sidebar@0.28.1` | +| **0.2.1-rc.1+** | `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 +70,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.28.1 +1. Confirm DSH is 0.2.1-rc.1 or newer, then run dsh plugin --profile web add dsh-better-sidebar@0.28.2 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.28.1` (macOS / Linux / Windows Git Bash; `./scripts/install.ps1 -Version 0.28.1` for native Windows). It handles installation + bundle registration. +**One-line script** — clone this repo and run `bash scripts/install.sh 0.28.2` (macOS / Linux / Windows Git Bash; `./scripts/install.ps1 -Version 0.28.2` for native Windows). It handles installation + bundle registration. **Updating**: just re-run the install command, then hard-refresh the browser. @@ -92,12 +92,19 @@ 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.28.1`. | +| `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.28.2`. |
## 🆕 Recent Updates +**v0.28.2 — large-session cold-read fix** + +- **Root cause fixed**: a detached session's cwd no longer decodes the whole session log — it reads the workspace address stored in the header (first zstd frame only, header-only), memoized per session with in-flight sharing; `activeWorktreeRootOf` no longer folds the stored log for a detached session +- **Why 0.28.1 missed it**: the single-flight only covered `/sidebar/api`, while the real startup fan-out is one fs-watch frame per watched directory and one cwd resolution per `/sidebar/file|html` resource — a 39 MB session was still fully decoded dozens of times in parallel +- **Behavior**: an attached session still follows `working_directory` and linked worktrees; before attach the sidebar roots at the original project and the next 5 s poll switches back +- **Measured (40.2 MB session, local)**: 12 routes + 36 bypass-entry calls concurrently → 1 header read, 0 full reads, 3 ms, +0.3 MB RSS; pre-fix, 6 bypass calls were 6 full reads with a +1.0 GB peak (≈6 GB extrapolated for 36) + **v0.28.1 — UX and reliability patch** - **OOM fix**: cold cwd reads shared by the twelve `/sidebar/*` routes are merged per session and client hint, so a session-switch burst no longer decodes the same large session log N times in parallel @@ -115,13 +122,6 @@ If something fails, check the FAQ table in https://github.com/omdsh-dev/DSH-bett - 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) -**v0.27.0** - full release history at [Releases](https://github.com/omdsh-dev/DSH-better-sidebar/releases) · [CHANGELOG](./CHANGELOG_EN.md) - -- **Git page rebuilt**: Source Control groups, a read-only commit graph with branch filtering, and a shared Commit details / Content / Diff pane -- **Accurate change tracking**: separate staged/unstaged counts, nested-repository discovery, session-relative paths, PTC file operations and long polling -- **Selection stays in place**: fixed the integration regression that displaced selected files and drew stray borders; added real-host layout coverage -- **Side Chat**: new child sessions seed from the latest summarizing compaction instead of copying the full parent log - ## 🔌 Plugin Ecosystem `ctx.betterSidebar` offers two extension points to every plugin — `registerTab` / `registerFileViewer`; the built-in 6 tabs + 4 viewers use the very same API. The GitHub topic [`dsh-better-sidebar`](https://github.com/topics/dsh-better-sidebar) already lists **30+ ecosystem plugins**; the full integration guide is at **[docs/external-plugin-guide.md](./docs/external-plugin-guide.md)**. diff --git a/README_ZH.md b/README_ZH.md index 8dfa0657..aa7b255b 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -44,14 +44,14 @@ dsh plugin --profile web add dsh-better-sidebar@latest 装完**硬刷新浏览器**(Cmd/Ctrl+Shift+R)即可。要求 DSH **0.2.1-rc.1+**。 -> **兼容性警告:插件版本必须与宿主线匹配。** 截至 2026-10-26,DSH 的 npm `latest` 是 **0.2.1-rc.2**,上方命令安装的 v0.28.1 与之兼容。仍停留在 **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-10-26,DSH 的 npm `latest` 是 **0.2.1-rc.2**,上方命令安装的 v0.28.2 与之兼容。仍停留在 **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` 标签不是同一支持线。
按 DSH 版本选插件版本 | 你的 DSH 版本 | 安装命令 | | --- | --- | -| **0.2.1-rc.1+** | `dsh plugin --profile web add dsh-better-sidebar@0.28.1` | +| **0.2.1-rc.1+** | `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 +70,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.28.1 +1. 先确认 DSH 为 0.2.1-rc.1 或更新版本,再执行 dsh plugin --profile web add dsh-better-sidebar@0.28.2 2. 完成后提醒我硬刷新浏览器(Cmd/Ctrl+Shift+R) 遇到报错先查 https://github.com/omdsh-dev/DSH-better-sidebar README 的常见问题表。 ``` -**一键脚本**——克隆本仓库后执行 `bash scripts/install.sh 0.28.1`(macOS / Linux / Windows Git Bash;Windows 原生用 `./scripts/install.ps1 -Version 0.28.1`),自动完成安装 + bundle 注册。 +**一键脚本**——克隆本仓库后执行 `bash scripts/install.sh 0.28.2`(macOS / Linux / Windows Git Bash;Windows 原生用 `./scripts/install.ps1 -Version 0.28.2`),自动完成安装 + bundle 注册。 **更新**:重跑一次安装命令即可,然后硬刷新浏览器。 @@ -92,12 +92,19 @@ 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.28.1`。 | +| 提示 `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.28.2`。 |
## 🆕 最近更新 +**v0.28.2 — 大会话冷读修复** + +- **根因修复**:detached 会话的 cwd 不再解码整份会话日志——改读存储在 header 里的工作区地址(只读第一个 zstd 帧,header-only),按会话做进程内缓存与在飞去重;`activeWorktreeRootOf` 对 detached 会话不再折持久化日志 +- **为什么 0.28.1 没修好**:单飞只覆盖 `/sidebar/api`,而启动期真正并发的是 fs-watch 每个监视目录一帧、`/sidebar/file|html` 每资源一次——39 MB 级会话仍被并发整读数十次 +- **行为**:会话 attach 后仍跟随 `working_directory` 与 linked worktree;attach 之前侧边栏根是原始项目目录,下一次 5 s 轮询自动切回 +- **实测(40.2 MB 会话,本机)**:12 路由 + 36 个绕过入口并发 → 1 次 header 读、0 次整读、3 ms、RSS +0.3 MB;修复前 6 个入口并发即 6 次整读、峰值 +1.0 GB(外推 36 次 ≈ 6 GB) + **v0.28.1 — UX 与可靠性补丁** - **OOM 修复**:12 条 `/sidebar/*` 路由共享的冷 cwd 读取按「会话 + 客户端提示」合并,切换会话的并发突发不再并行解码同一份大会话日志 @@ -115,13 +122,6 @@ dsh plugin --profile web add dsh-better-sidebar@latest - 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) -**v0.27.0** - 完整发布历史见 [Releases](https://github.com/omdsh-dev/DSH-better-sidebar/releases) · [CHANGELOG](./CHANGELOG.md) - -- **Git 页面重做**:Source Control 分组、支持分支筛选的只读提交图,以及共用的「提交详情 / 内容 / 差异」预览区 -- **变更追踪修正**:暂存和未暂存行数分离、嵌套仓库发现、按会话解析路径、PTC 文件操作可见与长轮询 -- **选中行不再错位**:修复整合时引入的文件行漂移和异常边框,新增真实挂载布局回归 -- **侧边对话**:从最近一次 summarizing compaction 构造子会话,不再全量复制父日志 - ## 🔌 插件生态 `ctx.betterSidebar` 向所有插件开放 `registerTab` / `registerFileViewer` 两个扩展点,内置 6 tab + 4 viewer 与第三方插件走同一套 API。GitHub topic [`dsh-better-sidebar`](https://github.com/topics/dsh-better-sidebar) 下已有 **30+ 生态插件**;完整接入文档见 **[docs/external-plugin-guide.md](./docs/external-plugin-guide.md)**。 diff --git a/docs/external-plugin-guide.md b/docs/external-plugin-guide.md index c3962872..50813ae0 100644 --- a/docs/external-plugin-guide.md +++ b/docs/external-plugin-guide.md @@ -2,8 +2,8 @@ > 面向 **消费插件开发者**:如何让你的插件向 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.1 正式版**(13 条 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.1**(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` 安装、不按宿主版本选版本。 +> 适用版本:**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 正式版**(13 条 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 的测试数字替代。 > 权威代码:`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.2)。 diff --git a/docs/plans/2026-10-27-workspace-cwd-over-cold-reads.md b/docs/plans/2026-10-27-workspace-cwd-over-cold-reads.md index 2470e0aa..cf4cf385 100644 --- a/docs/plans/2026-10-27-workspace-cwd-over-cold-reads.md +++ b/docs/plans/2026-10-27-workspace-cwd-over-cold-reads.md @@ -45,9 +45,34 @@ ## 五、验证 -**已执行**:`pnpm typecheck` 通过;`pnpm exec vitest run tests/smoke.spec.ts tests/active-worktree.spec.ts` → 89 passed,1 failed(`serves a home-relative media path`,`mkdir $HOME/.dsh-sidebar-selftest-*` 被本会话文件沙箱拒绝;在未改动的 `dev` 上同样失败,判为环境限制)。 +### 5.1 门禁(已执行) -**未执行**:没有 39.9 MB 真机会话,未在本机复现「36 → ?」的读次数变化。可证伪预测:同一场景下 `readStableSnapshot` 的调用数应降到 **每个冷会话 ≤1 次**(header 读不走该函数时直接归零),且 fs-watch 帧不再触发任何整份读。 +`pnpm typecheck` / `eslint`(改动文件)/ `pnpm build` 通过;`pnpm test` → 2834 passed,2 个失败均非本改动(`serves a home-relative media path` 因沙箱禁止写 `$HOME`,在未改动的 `dev` 上同样失败;`fs-watch` 一条并行负载下的 flake,单跑 3/3 通过);CI 三条 lane(`ci` / `ci-windows` / `plugin-mount`)全绿。 + +### 5.2 40 MB 越大会话实测(2026-10-27,本机) + +**造会话**:用宿主真实的 `@deepseek-ai/dsh-session` + `dsh-session-persistence-jsonl`(cordis 插件方式挂载)在 `/tmp` 建 scratch root,底下放一份本机真实的 13.8 MB 会话(`session.v4.jsonl.zstd`,13 382 条真实事件),再用写句柄追加 580 条合成 `user/message` 事件,扩到 **40,157,518 字节**(事故样本 39,886,933 字节)。 + +**新代码(合并后的 `lib/index.js`)**:把插件挂在 detached 场景(`ctx.sessions.get` 恒 undefined),持久化用**真实**后端并包一层计数,然后并发发起 **12 个 `session.cwd` API 调用 + 36 个 `/sidebar/file` 调用**(后者与被 fs-watch 每帧走的 `sessionCwdOf` 是同一入口,且同样不经过 `cwdOf()` 单飞): + +| 指标 | 结果 | +| --- | --- | +| `sessionPersistence.stat` 调用 | **1** | +| `sessionPersistence.open` 调用(整份解码) | **0** | +| 48 个并发调用总耗时 | **3 ms** | +| RSS 增量 | **+0.3 MB** | +| 解析结果 | 正确(header 的 workspace 地址) | + +**旧代码(`43db17f`,0.28.1)对照**:同一份产物、同样的绕过入口路径,6 个并发调用 → **6 次 `observeSession`**(每次一次完整 `open`+`read`),耗时 2.19 s,峰值 RSS +1,002 MB;按 6 倍外推,报告里的 36 次并发 ≈ **36 次整读、约 6.0 GB 峰值**——与 2026-10-19 事故记录的外置 watcher 峰值 6.2 GB 吻合。 + +**单次整读成本**:同一份产物 `open()` + `read()` 一次 = 467 ms、RSS +501.6 MB(13 962 条事件)。 + +### 5.3 未做 + +- 没有用桌面壳(dsh-tauri)做端到端复跑;本轮是在真实持久化/真实产物上的进程内测量,UI 侧只验证到路由层。 +- 未提供事故方那份 39,886,933 字节样本,用的是同量级的本地重建产物。 + +可证伪预测(仍成立):同场景下 `readStableSnapshot` 对同一会话的调用数应为 0(新路径只走 `stat` 的 header 读),fs-watch 帧不再触发任何整份读。 ## 六、留下的读取面(不在本次范围) diff --git a/dsh.plugin.json b/dsh.plugin.json index 56887056..7969d0d6 100644 --- a/dsh.plugin.json +++ b/dsh.plugin.json @@ -1,6 +1,6 @@ { "id": "dsh-external/dsh-better-sidebar", - "version": "0.28.1", + "version": "0.28.2", "main": "./lib/index.js", "description": "更好用的右侧边栏——文件树、编辑器、文件变动、任务和侧边对话都收在这一栏里,每个会话互不干扰。暴露服务供其他插件注册侧边栏页面与文件预览器", "engines": { diff --git a/package.json b/package.json index 4f1739af..466636cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dsh-better-sidebar", - "version": "0.28.1", + "version": "0.28.2", "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": { diff --git a/src/client/service.ts b/src/client/service.ts index 8072a32b..86a517ec 100644 --- a/src/client/service.ts +++ b/src/client/service.ts @@ -836,7 +836,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.28.1' +export const SIDEBAR_SERVICE_VERSION = '0.28.2' /** * Monotonic capability list consumers use to gate new API usage (features