@alexpeng/dsh-custom-plugin 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,96 @@ All notable changes to this project are documented here. The format loosely
4
4
  follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions
5
5
  follow [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## 0.6.0 — not yet published
8
+
9
+ ### Changed
10
+
11
+ - **Built against dsh 0.2.0-rc.2, and the declared range now names it.** Every
12
+ `@deepseek-ai/dsh-*` devDependency moved to 0.2.0-rc.2 and the source
13
+ type-checked against that release's own published types with no source
14
+ changes. The gate-relevant peer became
15
+ `@deepseek-ai/dsh-tools >=0.1.7-rc.2 <0.2.0-0 || >=0.2.0-rc.2 <0.2.0-rc.3`,
16
+ and `engines.dsh` was set to the same range. That spelling is load-bearing:
17
+ `^0.1.7-rc.2` desugars to `>=0.1.7-rc.2 <0.2.0-0`, and every `0.2.0-rc.N`
18
+ sorts above `0.2.0-0`, so no caret form can admit a verified prerelease — and
19
+ `^0.2.0-rc.2` would additionally admit 0.2.0 stable plus every later 0.2.x,
20
+ which is exactly the unverified support this range exists to withhold.
21
+ 0.2.0-rc.1 is left out on purpose: the bundle is now built for rc.2.
22
+ - `pnpm smoke`'s two range checks were rewritten, because both encoded the old
23
+ premise that a peer range is a single caret pin. They now assert what is
24
+ actually load-bearing: the installed build target must **satisfy** the peer
25
+ range (same comparator and `includePrerelease` semantics dsh's own gate uses),
26
+ a range that admits every version is rejected as stating no support at all,
27
+ and `engines.dsh` must admit the same versions as the peer range across ten
28
+ probed releases. `semver` became a devDependency to make the first check
29
+ possible. Verified by mutation: a stale range, a `*` range, and a diverging
30
+ `engines.dsh` each turn the gate red.
31
+ - The desktop release line pins its shell and runtime together, so dsh Desktop
32
+ always ships one exact dsh version — this is why 0.2.0-rc.2 stopped being a
33
+ speculative target: any Desktop install *is* that runtime.
34
+
35
+ ### Added
36
+
37
+ - `tests/loopback.spec.ts`: the request-level fence had never had a unit test —
38
+ only the live probe script exercised it. Twelve tests now pin the two header
39
+ shapes dsh Desktop's shell produces (`web-document.ts` deletes `host`,
40
+ `origin`, `cookie` and `sec-fetch-site` before forwarding; the WebSocket
41
+ upgrade rewrites `Origin` to the Host authority), plus the rejections a
42
+ forged Origin, a cross-site marker, and a non-loopback socket must still get.
43
+ - README (both languages) gained an "On dsh Desktop" section: how the shell
44
+ routes requests, why the profile is managed by Desktop's own `dsh` command,
45
+ and which part still needs a window and a login.
46
+
47
+ ### Fixed
48
+
49
+ - **A second dsh host could read a half-written state document.** The atomic
50
+ replace wrote to one shared temp name, `custom-plugin-state.json.tmp`, while
51
+ the queue that serializes saves lives inside a single process. dsh Desktop
52
+ owns `$DSH_HOME/profiles/desktop` and the Web profile owns `profiles/web`,
53
+ but both hosts read and write the same
54
+ `$DSH_HOME/custom-plugin-state.json`, so two hosts saving at the same moment
55
+ wrote and renamed that one temp file against each other — the Windows
56
+ EPERM/EBUSY shape this queue was built to stop, reachable across processes.
57
+ Temp names are now qualified by the writing pid (both the state document and
58
+ the pre-import recovery backup), and a failed turn deletes its own temp
59
+ instead of leaving a per-pid file behind. Building that cleanup surfaced a
60
+ second bug: `rm` was used in the new `catch` but never imported, so a failed
61
+ save reported `ReferenceError` instead of the real rename error and left the
62
+ temp file on disk.
63
+
64
+ ### Verified
65
+
66
+ - **dsh 0.2.0-rc.2, the version Desktop ships.** Confirmed from the installed
67
+ app's own bytes, not the repository: `resources/app.asar/dsh/desktop-runtime.json`
68
+ records `release.version 0.2.0-rc.2`, `node 24.18.1`, `pnpm 11.7.0`, and lists
69
+ `@deepseek-ai/dsh 0.2.0-rc.2` with `@deepseek-ai/cordis 4.0.4` (the version
70
+ this package's cordis peer already names) among its shared packages.
71
+ - 0.5.0 on that runtime behaved as predicted: `dsh plugin --profile web add`
72
+ refused it, naming `peerDependencies {"@deepseek-ai/dsh-tools":"^0.1.7-rc.2"}`,
73
+ and rolled the profile back. With the exemption granted, 18 of 19 live host
74
+ probes passed, 0 failed.
75
+ - **0.6.0 installs on 0.2.0-rc.2 with no exemption at all** (`plugin add` exit
76
+ 0, profile kept), and the same 18-pass/1-skip/0-fail result holds there and on
77
+ 0.1.7-rc.2 — boot graph 66 module rows on 0.2.0-rc.2 and 65 on 0.1.7-rc.2, our
78
+ row served, all
79
+ five `dsh.client.inject` targets present, Mermaid engine loaded locally, UTF-8
80
+ state round trip restored. The single skip is the session-dependent probe; a
81
+ credential-free scratch home holds no session.
82
+ - The rebuild of `pnpm-lock.yaml` (required: the old lockfile cached a
83
+ `minimumReleaseAge` policy snapshot that no longer matched the allow-list, so
84
+ every install was rejected) also moved the dev tree's `mermaid` from 11.17.0
85
+ to 11.17.2. That is inside the declared `^11.6.0`, and the scratch profiles
86
+ used for the live probes resolved 11.17.2 themselves, so the measured Mermaid
87
+ engine is the version an installing user gets.
88
+ - The installed `lib/client.js` is byte-identical to the repository build
89
+ (207762 bytes, sha256 prefix `f559cd7f1bd8a49a`). The *served* bundle is 49
90
+ bytes larger because dsh's composite `/plugins/??…` route joins modules with
91
+ `;\n` and rewrites the `sourceMappingURL` — so byte identity is asserted at
92
+ the installed file, never at the HTTP response.
93
+ - 126 unit tests pass, typecheck is clean, `pnpm smoke` and `check:readme` are
94
+ green. Not verified: opening the plugin inside a real Desktop window (needs a
95
+ login), the desktop profile's own composition, and the per-turn chips.
96
+
7
97
  ## 0.5.0 — 2026-09-28
8
98
 
9
99
  ### Changed
@@ -171,6 +261,20 @@ refuted by measurement and are recorded below so nobody re-litigates them.
171
261
  release, including a stable nobody has reviewed — the very failure this
172
262
  upgrade exists to prevent. What stays unverified there (branch / Mermaid /
173
263
  LaTeX chips) is unverified here too: those need a real model reply.
264
+ - Accepted and published: a human walked the isolated 0.1.7-rc.2 profile in a
265
+ browser (personalization panel, prompts into the composer, project folders, the
266
+ timeline rail, quote reply, export entries, `Ctrl+K`) and reported it behaving.
267
+ The same person then ran 0.5.0 on their own machine — dsh upgraded to
268
+ 0.1.7-rc.2, plugin updated through the in-app market — and reported it
269
+ behaving there too. That install's `lib/client.js` is md5
270
+ `6639a0aebbe7d0eed32b0c2c5c50c544`, 207762 bytes: byte-identical to the repo
271
+ build this section describes, so the chain "what was verified = what was
272
+ published = what a user runs" is closed at both ends.
273
+ Not covered by either pass, in this or any release until someone runs it with a
274
+ key: the per-turn chips (branch, Mermaid render, LaTeX/MathML) and the real
275
+ balance figures, all of which need an actual model reply. `0.5.0` was then
276
+ published to npm, and the tarball pulled back from the registry was verified
277
+ byte-identical to the `lib/` this section describes (34 files, 215634 B).
174
278
  - Retracted after re-measurement, so the record does not carry them: "the
175
279
  `slots.inject(key, fn)` service method does not exist in 0.1.7" (it is
176
280
  declared at `dsh-client-ui-renderer`'s registry interface, and all eight
package/README.i18n.yaml CHANGED
@@ -3,5 +3,5 @@
3
3
  # after editing either side, bring the other along and re-record the hashes:
4
4
  # git hash-object --path README.md README.md
5
5
  # git hash-object --path README.zh.md README.zh.md
6
- README.md: 4660041579f0afb622e515c4531bb47f3f8369da
7
- README.zh.md: f0f82dfa0fb26dd9661c8394da11fe56203924c3
6
+ README.md: cc76977b752647e342987111d810cd8a76d7edb6
7
+ README.zh.md: 7778594e06ac0c7a96708de71040a90a2367eb7a
package/README.md CHANGED
@@ -120,7 +120,8 @@ The `custom_plugin_status` tool reports appearance config, today's per-model usa
120
120
 
121
121
  | plugin release | dsh it was built and verified against | status |
122
122
  | --- | --- | --- |
123
- | 0.5.x | dsh 0.1.7-rc.2 (declared range `>=0.1.7-rc.2 <0.2.0`) | current |
123
+ | 0.6.x | dsh 0.1.7-rc.2 and dsh 0.2.0-rc.2 (peer range names both; see Install) | this release |
124
+ | 0.5.x | dsh 0.1.7-rc.2 (peer range `>=0.1.7-rc.2 <0.2.0-0`) | fine on 0.1.x; refused on any 0.2.x host, including dsh Desktop |
124
125
  | 0.4.2 | dsh 0.1.1-rc.1 … 0.1.6 era | superseded; do not expect it to work on 0.1.7+ |
125
126
 
126
127
  0.1.7 changed the plugin-facing contracts this suite depends on (session
@@ -136,7 +137,7 @@ report their service as missing rather than throwing.
136
137
 
137
138
  ## Install
138
139
 
139
- Prerequisites: Node 22+, pnpm, and the `dsh` CLI (the official `@deepseek-ai/dsh` npm package; `npx @deepseek-ai/dsh` stands in for `dsh` when it is not installed globally). This release targets **dsh 0.1.7-rc.2 through the rest of 0.1.x** — dsh checks a bundle's `@deepseek-ai/dsh-*` peer ranges against its own version at install and startup, and skips a bundle that does not match, so `package.json` declares a range whose floor is the release this package was actually built and verified against. It does not yet support 0.2.x: `^0.1.7-rc.2` excludes it, and `dsh plugin add` against 0.2.0-rc.1 rejects the install and rolls the profile back. What has been measured there, with dsh's exact-version exemption granted: the source typechecks against 0.2.0-rc.1's own published types, 111/111 unit tests pass, all 19 live host probes pass, and the browser surfaces behave the same as on 0.1.7 — eight slot registrations, the timeline rail, prompt insertion into the composer, `Ctrl+K` palette with title search, and quote-reply writing a blockquote. What stays unverified there is what stays unverified here: the per-turn chips (branch, Mermaid render, LaTeX) need a real model reply, so a credential-free scratch home cannot reach them. The range is not widened for a different reason — `^0.2.0-rc.1` would silently admit every 0.2.x release, including a future stable nobody has looked at, which is the same mistake this upgrade exists to stop. On an older dsh, install the matching older plugin release instead of granting a compatibility exemption.
140
+ Prerequisites: Node 22+, pnpm, and the `dsh` CLI (the official `@deepseek-ai/dsh` npm package; `npx @deepseek-ai/dsh` stands in for `dsh` when it is not installed globally). This release targets **dsh 0.1.7-rc.2 through the rest of 0.1.x, plus 0.2.0-rc.2** — dsh checks a bundle's `@deepseek-ai/dsh-*` peer ranges against its own version at install and startup, and skips a bundle that does not match, so `package.json` names only the releases this package was actually built and verified against. 0.6.0 is type-checked and built against 0.2.0-rc.2, and the same artifact was run through the live host probes on both runtime lines: 18 of 19 probes pass on 0.2.0-rc.2 (boot graph of 66 module rows) and on 0.1.7-rc.2 (65 rows), the one skip being the probe that needs a real session. What stays unverified is what was always unverified: the per-turn chips (branch, Mermaid render, LaTeX) need a real model reply, so a credential-free scratch home cannot reach them, and slot rendering still needs a browser pass. The range deliberately excludes 0.2.0-rc.1 (a superseded prerelease), 0.2.0-rc.3 and later prereleases nobody has looked at, and 0.2.0 stable until someone does. Range spelling matters here: `^0.1.7-rc.2` desugars to `>=0.1.7-rc.2 <0.2.0-0`, and every `0.2.0-rc.N` sorts *above* `0.2.0-0`, so a verified prerelease has to be named in its own clause — `pnpm smoke` checks that the build target actually satisfies the declared range and that `engines.dsh` admits the same versions. On an older dsh, install the matching older plugin release (`0.5.0` targets 0.1.7-rc.2) rather than granting a compatibility exemption.
140
141
 
141
142
  ### From npm
142
143
 
@@ -147,6 +148,42 @@ dsh plugin --profile web add @alexpeng/dsh-custom-plugin
147
148
 
148
149
  The registry tarball ships prebuilt output — no source build on the installing machine.
149
150
 
151
+ ### On dsh Desktop
152
+
153
+ dsh Desktop is an Electron shell around the same Web application, and it bundles
154
+ **exactly dsh 0.2.0-rc.2** — the desktop release line pins the shell and the
155
+ runtime together, so a Desktop install is always a 0.2.x runtime. 0.6.0 names
156
+ that version in its peer range and installs there with no compatibility
157
+ exemption; 0.5.0 did not, and was refused with the same message a 0.2.x Web
158
+ profile prints.
159
+
160
+ Measured against 0.2.0-rc.2: the boot graph carries our row and all five inject
161
+ targets, the Mermaid engine loads locally, and the host probes score the same
162
+ there as on 0.1.7-rc.2. The desktop request path does not disturb this plugin's
163
+ access fence either — the shell forwards renderer requests to its own Host after
164
+ deleting `host`, `origin`, `sec-fetch-site` and `cookie`, then attaches its own
165
+ credential, which is the shape the loopback fence accepts (that fence now has
166
+ unit tests, which it never had before). What has *not* been done is opening this
167
+ plugin inside a Desktop window; that pass belongs to whoever installs it, and it
168
+ needs your login.
169
+
170
+ Managing the desktop profile takes the `dsh` command that ships with Desktop, not
171
+ the npm one — the public CLI refuses the reserved `desktop` profile:
172
+
173
+ 1. Start Desktop once so the profile exists, then quit it fully (closing the
174
+ window only hides it; on Windows use the tray).
175
+ 2. `dsh plugin --profile desktop add @alexpeng/dsh-custom-plugin`
176
+ 3. Reopen Desktop. The in-app Plugin Manager installs and updates against the
177
+ same profile using Desktop's own bundled pnpm, if you would rather not open a
178
+ terminal.
179
+
180
+ Appearance, prompt library, project folders, stars and usage all live in
181
+ `$DSH_HOME/custom-plugin-state.json`, which Desktop and Web share by design —
182
+ each keeps its own `profiles/<name>` for code, never for that file — so
183
+ switching between the two shows the same data. Both hosts can therefore write it
184
+ at once, which is why the state replace names its temp file after the writing
185
+ process.
186
+
150
187
  ### From GitHub (source install)
151
188
 
152
189
  ```sh
package/README.zh.md CHANGED
@@ -120,7 +120,8 @@ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天
120
120
 
121
121
  | 插件版本 | 构建并实测过的 dsh | 状态 |
122
122
  | --- | --- | --- |
123
- | 0.5.x | dsh 0.1.7-rc.2(声明范围 `>=0.1.7-rc.2 <0.2.0`) | 当前 |
123
+ | 0.6.x | dsh 0.1.7-rc.2 与 dsh 0.2.0-rc.2(peer 范围两个都写进去了,见「安装」) | 本版本 |
124
+ | 0.5.x | dsh 0.1.7-rc.2(peer 范围 `>=0.1.7-rc.2 <0.2.0-0`) | 在 0.1.x 上没问题;任何 0.2.x 宿主都会拒绝它,dsh 桌面版也算 |
124
125
  | 0.4.2 | dsh 0.1.1-rc.1 … 0.1.6 时代 | 已被取代,在 0.1.7+ 上不要指望可用 |
125
126
 
126
127
  0.1.7 改掉了本套件依赖的插件侧契约(会话导航归 `ctx.uiWorkspace`、会话列表不再提供
@@ -132,7 +133,7 @@ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天
132
133
 
133
134
  ## 安装
134
135
 
135
- 前置:Node 22+、pnpm,以及 `dsh` CLI(官方 npm 包 `@deepseek-ai/dsh`;未全局安装时,可用 `npx @deepseek-ai/dsh` 代替 `dsh`)。本版本面向 **dsh 0.1.7-rc.2 及其后的 0.1.x**:dsh 在安装与启动时会用自身版本校验 bundle 的 `@deepseek-ai/dsh-*` peer 范围,不匹配的 bundle 会被整包跳过,所以 `package.json` 声明的范围以下界为准——下界才是本包实际构建并实测过的那个版本。0.2.x 暂不在支持范围内:`^0.1.7-rc.2` 把它排除在外,`dsh plugin add` 在 0.2.0-rc.1 上会直接拒绝安装并回滚 profile。已实测到的部分(授予 dsh 的精确版本豁免后):源码能通过 0.2.0-rc.1 自己发布的类型检查、111 个单测全过、19 条活体探针全过,浏览器侧与 0.1.7 表现一致——八个槽位注册、时间线轨、提示词写入输入框、`Ctrl+K` 面板带标题检索、引用回复把 blockquote 写进输入框。验不到的部分也和 0.1.7 一样:回合内的 chips(分叉、Mermaid 渲染、LaTeX)需要一次真实的模型回复,无凭据的临时家目录跑不出来。不收编范围还有另一个理由:`^0.2.0-rc.1` 会静默放行整个 0.2.x,包括一个谁都没看过的正式版——而这正是这次升级要止住的错误。仍在旧版 dsh 的用户请安装对应的旧版插件,而不是授予兼容性豁免。
136
+ 前置:Node 22+、pnpm,以及 `dsh` CLI(官方 npm 包 `@deepseek-ai/dsh`;未全局安装时,可用 `npx @deepseek-ai/dsh` 代替 `dsh`)。本版本面向 **dsh 0.1.7-rc.2 及其后的 0.1.x,外加 0.2.0-rc.2**:dsh 在安装与启动时会用自身版本校验 bundle 的 `@deepseek-ai/dsh-*` peer 范围,不匹配的 bundle 会被整包跳过,所以 `package.json` 只写出本包实际构建并实测过的那些版本。0.6.0 是针对 0.2.0-rc.2 做类型检查与构建的,同一个产物在两条运行时线上都跑过活体宿主探针:0.2.0-rc.2(boot 图 66 行)与 0.1.7-rc.2(65 行)各 19 项里 18 项通过,跳过的那项需要真实会话。验不到的部分和以往一样:回合内的 chips(分叉、Mermaid 渲染、LaTeX)需要一次真实的模型回复,无凭据的临时家目录跑不出来,槽位渲染也仍要在浏览器里过一遍。范围刻意不收 0.2.0-rc.1(已被取代的预发布版)、0.2.0-rc.3 及之后谁都没看过的预发布版,以及尚未验证的 0.2.0 正式版。范围的写法在这里有讲究:`^0.1.7-rc.2` 展开成 `>=0.1.7-rc.2 <0.2.0-0`,而每一个 `0.2.0-rc.N` 都排在 `0.2.0-0` **之上**,所以实测过的预发布版本必须单独写成一段——`pnpm smoke` 会检查构建目标确实落在声明范围里,并且 `engines.dsh` 与它放行同一批版本。仍在旧版 dsh 的用户请安装对应的旧版插件(0.5.0 面向 0.1.7-rc.2),而不是授予兼容性豁免。
136
137
 
137
138
  ### 从 npm 安装
138
139
 
@@ -143,6 +144,35 @@ dsh plugin --profile web add @alexpeng/dsh-custom-plugin
143
144
 
144
145
  registry 上是预构建产物,安装端无需从源码构建。
145
146
 
147
+ ### 在 dsh 桌面版上
148
+
149
+ dsh 桌面版是同一套 Web 应用外面的一层 Electron 壳,随包携带**正好是 dsh
150
+ 0.2.0-rc.2**——桌面发布线把壳和运行时钉成同一个版本,所以桌面端拿到的永远是
151
+ 0.2.x 运行时。0.6.0 的 peer 范围把这个版本写了进去,因此在桌面版上安装不需要任
152
+ 何兼容性豁免;0.5.0 需要,它给出的拒绝信息和 0.2.x 的 Web profile 完全一样。
153
+
154
+ 对 0.2.0-rc.2 的实测:boot 图里有我们那一行、五个 inject 目标都在、Mermaid 引
155
+ 擎本地加载,宿主侧探针的成绩与在 0.1.7-rc.2 上的一致。桌面版的请求路径也不碰本
156
+ 插件的访问围栏——壳在把渲染进程的请求转发给它自己的 Host 之前会删掉 `host`、
157
+ `origin`、`sec-fetch-site`、`cookie`,再挂上它自己的凭证,而 loopback 围栏接受
158
+ 的正是这个形状(这条围栏此前只有实跑脚本覆盖,如今有了单测)。没做的是在真的桌
159
+ 面窗口里打开这个插件;那一遍验收归装它的人,而且要用你的登录。
160
+
161
+ 管桌面 profile 要用桌面版自带的 `dsh` 命令,不是 npm 装的那个——公开 CLI 拒绝
162
+ 保留的 `desktop` profile:
163
+
164
+ 1. 先启动一次桌面版让 profile 建立,然后完全退出(关窗口只是隐藏;Windows 上
165
+ 从托盘退出)。
166
+ 2. `dsh plugin --profile desktop add @alexpeng/dsh-custom-plugin`
167
+ 3. 重新打开桌面版。应用内的插件管理器也用桌面版自带的 pnpm 在同一个 profile 上
168
+ 安装和更新,不想开终端就用它。
169
+
170
+ 外观、提示词库、项目文件夹、星标和用量都存在
171
+ `$DSH_HOME/custom-plugin-state.json`,这个文件按设计由桌面版和 Web 共享——两
172
+ 边各自持有自己的 `profiles/<名字>`,那里面只放代码不放这个文件——所以在两者
173
+ 之间切换看到的是同一份数据。两个宿主因此可能同时写它,这就是状态替换把临时文
174
+ 件按写入进程的 pid 命名的原因。
175
+
146
176
  ### 从 GitHub 安装(源码安装)
147
177
 
148
178
  ```sh
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
2
2
  import { defineTool } from "@deepseek-ai/dsh-tools";
3
3
  import { dirname, isAbsolute, join } from "node:path";
4
4
  import { homedir } from "node:os";
5
- import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
5
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
6
6
  import { readFileSync } from "node:fs";
7
7
  //#region src/dsh-home.ts
8
8
  /**
@@ -328,11 +328,22 @@ async function loadStateFile(state, home = dshHome()) {
328
328
  pruneUsage(state.usage);
329
329
  return statePath;
330
330
  }
331
- /** In-flight save per state path: concurrent saves queue instead of racing
332
- * on the shared .tmp file. Two writers renaming one temp file is the Windows
331
+ /** In-flight save per state path: concurrent saves queue instead of racing on
332
+ * the rename order. Two writers renaming one temp file is the Windows
333
333
  * EPERM/EBUSY source; queuing also coalesces naturally, because each turn
334
334
  * serializes the live document when it runs, not when it was requested. */
335
335
  const saveQueues = /* @__PURE__ */ new Map();
336
+ /**
337
+ * Temp name for an atomic replace, qualified by the writing process.
338
+ *
339
+ * The queue above is per-process, but `$DSH_HOME` is not: dsh Web and dsh
340
+ * Desktop both run hosts against one home (separate profiles, one `$DSH_HOME`),
341
+ * so a fixed temp name would let the two hosts write and rename the same file
342
+ * and hand each other a partially written document.
343
+ */
344
+ function tempPathFor(target, pid = process.pid) {
345
+ return `${target}.${pid}.tmp`;
346
+ }
336
347
  /** Atomically persist the state document. Saves to the same path are
337
348
  * serialized: a caller awaits its own turn's completion, a failed turn never
338
349
  * poisons the queue behind it. */
@@ -340,9 +351,14 @@ function saveStateFile(state, home = dshHome()) {
340
351
  const statePath = join(home, STATE_FILE);
341
352
  const turn = (saveQueues.get(statePath) ?? Promise.resolve()).catch(() => {}).then(async () => {
342
353
  await mkdir(dirname(statePath), { recursive: true });
343
- const tmpPath = statePath + ".tmp";
344
- await writeFile(tmpPath, JSON.stringify(state), "utf8");
345
- await rename(tmpPath, statePath);
354
+ const tmpPath = tempPathFor(statePath);
355
+ try {
356
+ await writeFile(tmpPath, JSON.stringify(state), "utf8");
357
+ await rename(tmpPath, statePath);
358
+ } catch (error) {
359
+ await rm(tmpPath, { force: true }).catch(() => {});
360
+ throw error;
361
+ }
346
362
  });
347
363
  saveQueues.set(statePath, turn);
348
364
  return turn.finally(() => {
@@ -1007,7 +1023,7 @@ function importedState(current, backup, mode) {
1007
1023
  }
1008
1024
  async function writeRecoveryBackup(path, state) {
1009
1025
  const target = path + ".backup.json";
1010
- const temporary = target + ".tmp";
1026
+ const temporary = tempPathFor(target);
1011
1027
  await writeFile(temporary, JSON.stringify(createBackup(state), null, 2), "utf8");
1012
1028
  await rename(temporary, target);
1013
1029
  return target;
@@ -22,6 +22,15 @@ export declare function normalizePrompt(raw: unknown): PromptItem | null;
22
22
  export declare function mergeState(target: CustomPluginState, raw: unknown): void;
23
23
  /** Load and merge the persisted document into `state`. */
24
24
  export declare function loadStateFile(state: CustomPluginState, home?: string): Promise<string>;
25
+ /**
26
+ * Temp name for an atomic replace, qualified by the writing process.
27
+ *
28
+ * The queue above is per-process, but `$DSH_HOME` is not: dsh Web and dsh
29
+ * Desktop both run hosts against one home (separate profiles, one `$DSH_HOME`),
30
+ * so a fixed temp name would let the two hosts write and rename the same file
31
+ * and hand each other a partially written document.
32
+ */
33
+ export declare function tempPathFor(target: string, pid?: number): string;
25
34
  /** Atomically persist the state document. Saves to the same path are
26
35
  * serialized: a caller awaits its own turn's completion, a failed turn never
27
36
  * poisons the queue behind it. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alexpeng/dsh-custom-plugin",
3
3
  "description": "Custom convenience suite for the dsh web GUI: appearance, timeline, folders, prompts, session export/search, Mermaid, quote reply, usage analytics, local budget, key-free backups, and a Ctrl/Cmd+K command palette; dual-face plugin mounted without dsh source changes.",
4
- "version": "0.5.0",
4
+ "version": "0.6.0",
5
5
  "type": "module",
6
6
  "icon": "./icon.svg",
7
7
  "main": "lib/index.js",
@@ -45,7 +45,7 @@
45
45
  "homepage": "https://github.com/AlexPeng07/dsh-custom-plugin#readme",
46
46
  "engines": {
47
47
  "node": ">=22",
48
- "dsh": ">=0.1.7-rc.2 <0.2.0"
48
+ "dsh": ">=0.1.7-rc.2 <0.2.0-0 || >=0.2.0-rc.2 <0.2.0-rc.3"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsc -p tsconfig.build.json && tsdown",
@@ -61,28 +61,29 @@
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@deepseek-ai/cordis": "^4.0.4",
64
- "@deepseek-ai/dsh-tools": "^0.1.7-rc.2"
64
+ "@deepseek-ai/dsh-tools": ">=0.1.7-rc.2 <0.2.0-0 || >=0.2.0-rc.2 <0.2.0-rc.3"
65
65
  },
66
66
  "dependencies": {
67
67
  "mermaid": "^11.6.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@deepseek-ai/cordis": "^4.0.4",
71
- "@deepseek-ai/dsh-attachment": "^0.1.7-rc.2",
72
- "@deepseek-ai/dsh-client-store": "^0.1.7-rc.2",
73
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.7-rc.2",
74
- "@deepseek-ai/dsh-client-ui-theme": "^0.1.7-rc.2",
75
- "@deepseek-ai/dsh-host-webserver": "^0.1.7-rc.2",
76
- "@deepseek-ai/dsh-llm": "^0.1.7-rc.2",
77
- "@deepseek-ai/dsh-session": "^0.1.7-rc.2",
78
- "@deepseek-ai/dsh-session-query": "^0.1.7-rc.2",
79
- "@deepseek-ai/dsh-tools": "^0.1.7-rc.2",
71
+ "@deepseek-ai/dsh-attachment": "0.2.0-rc.2",
72
+ "@deepseek-ai/dsh-client-store": "0.2.0-rc.2",
73
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
74
+ "@deepseek-ai/dsh-client-ui-theme": "0.2.0-rc.2",
75
+ "@deepseek-ai/dsh-host-webserver": "0.2.0-rc.2",
76
+ "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
77
+ "@deepseek-ai/dsh-session": "0.2.0-rc.2",
78
+ "@deepseek-ai/dsh-session-query": "0.2.0-rc.2",
79
+ "@deepseek-ai/dsh-tools": "0.2.0-rc.2",
80
80
  "@types/node": "^22.20.0",
81
81
  "@types/react": "~18.3.1",
82
82
  "@types/react-dom": "^18.3.5",
83
83
  "puppeteer-core": "^25.8.0",
84
84
  "react": "^18.3.1",
85
85
  "react-dom": "^18.3.1",
86
+ "semver": "^7.8.5",
86
87
  "tsdown": "0.22.2",
87
88
  "typescript": "~5.7.2",
88
89
  "vitest": "^3.0.0"