dsh-next-prompt 0.5.0 → 0.5.2

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  | 版本 | 主要变化 |
4
4
  | --- | --- |
5
+ | 0.5.2 | 适配 DSH 0.2.1 的插件热更新:卸载时等提示词缓存写完再让新实例加载;缓存的临时文件名不再只带进程号,避免新旧实例同时写盘失败;界面半更新后替换页面里旧版本的样式 |
6
+ | 0.5.1 | 功能不变;改由 GitHub Actions 自动发布,npm 页面会显示来源证明(provenance),可核对安装包确实由本仓库构建 |
5
7
  | 0.5.0 | 改名为 `dsh-next-prompt`(原 `dsh-prompt-prefill`),避免和模型的「回答预填(prefill)」混淆;插件 id、RPC 路径、日志前缀随之改名。新增:关掉 DSH 再打开、切回会话后还原上次的灰字:后台把每个会话最近一条提示词存到 DSH 主目录,之后没有新对话时还原,有新对话、新回合开始或按 Escape 关掉时丢弃;新增配置 `persistSuggestions` |
6
8
  | 0.4.2 | 正确处理 DSH 以 `finish` 片段返回的模型失败:不支持关闭思考时去掉该参数重试,其他错误写进诊断。修复部分模型永远不出灰字 |
7
9
  | 0.4.1 | 后台收不到某个会话的事件时,立刻退回旧做法,不再干等 |
package/README.en.md CHANGED
@@ -14,7 +14,7 @@ Both only fill the input box. **Nothing is ever sent automatically.**
14
14
 
15
15
  > This plugin was called `dsh-prompt-prefill` before 0.5.0. If you installed the old one, run `dsh plugin --profile desktop remove dsh-prompt-prefill` first, then install as below.
16
16
 
17
- Tested on DSH desktop **0.2.0-rc.2** (other versions are untested).
17
+ Tested on DSH desktop **0.2.1-rc.2** and **0.2.0-rc.2** (other versions are untested).
18
18
 
19
19
  ## Install
20
20
 
@@ -22,11 +22,11 @@ Tested on DSH desktop **0.2.0-rc.2** (other versions are untested).
22
22
  dsh plugin --profile desktop add dsh-next-prompt
23
23
  ```
24
24
 
25
- After installing, **fully quit DSH (including the tray icon) and reopen it**. It is best to quit DSH before installing too, otherwise the command waits for DSH to release its file lock.
25
+ From DSH 0.2.1 on, no restart is needed: run the command while DSH is open and the plugin takes effect right away. On earlier versions, **fully quit DSH (including the tray icon) and reopen it** after installing; it is best to quit DSH before installing too, otherwise the command waits for DSH to release its file lock.
26
26
 
27
27
  - Latest code from the repository: `dsh plugin --profile desktop add github:Tleon-H/dsh-next-prompt`
28
28
  - Web version of DSH: replace `--profile desktop` with your own profile (usually `--profile web`)
29
- - Update: `remove` and `add` again, then restart DSH
29
+ - Update: `remove` and `add` again (DSH before 0.2.1 also needs a restart)
30
30
  - Uninstall: `dsh plugin --profile desktop remove dsh-next-prompt`
31
31
 
32
32
  ## Usage
package/README.md CHANGED
@@ -14,7 +14,7 @@ DeepSeek Harness(DSH)桌面端插件,给输入框加两个小功能:
14
14
 
15
15
  > 本插件原名 `dsh-prompt-prefill`,0.5.0 起改名为 `dsh-next-prompt`。装过旧版的话,先 `dsh plugin --profile desktop remove dsh-prompt-prefill`,再按下面的方法安装新版。
16
16
 
17
- 适用版本:DSH 桌面端 **0.2.0-rc.2**(其他版本未验证)。
17
+ 适用版本:DSH 桌面端 **0.2.1-rc.2**、**0.2.0-rc.2**(其他版本未验证)。
18
18
 
19
19
  ## 安装
20
20
 
@@ -22,11 +22,11 @@ DeepSeek Harness(DSH)桌面端插件,给输入框加两个小功能:
22
22
  dsh plugin --profile desktop add dsh-next-prompt
23
23
  ```
24
24
 
25
- 装完后**完全退出 DSH(包括托盘图标)再重新打开**。安装前最好也先退出 DSH,否则命令会等待它释放文件锁。
25
+ DSH 0.2.1 起,装完不用重启,DSH 开着时直接运行命令就行,插件马上生效。更早的版本装完要**完全退出 DSH(包括托盘图标)再重新打开**,安装前最好也先退出 DSH,否则命令会等待它释放文件锁。
26
26
 
27
27
  - 想用仓库最新代码:`dsh plugin --profile desktop add github:Tleon-H/dsh-next-prompt`
28
28
  - 用网页版 DSH:把 `--profile desktop` 换成你自己的 profile(通常是 `--profile web`)
29
- - 更新:先 `remove` 再重新 `add`,然后重启 DSH
29
+ - 更新:先 `remove` 再重新 `add`(0.2.1 之前的 DSH 还要重启)
30
30
  - 卸载:`dsh plugin --profile desktop remove dsh-next-prompt`
31
31
 
32
32
  ## 用法
@@ -54,6 +54,7 @@ dsh-next-prompt/
54
54
  └── test/
55
55
  ├── core.test.mjs 纯逻辑
56
56
  ├── host.test.mjs 后台:路由与安全校验、回合事件、模型失败与重试、诊断
57
+ ├── cache.test.mjs 后台:提示词缓存的上限,以及热更新时新旧实例共用缓存文件
57
58
  └── client.test.mjs 界面:自带微型 React 与 DOM,覆盖按键、时机、会话切换与生命周期
58
59
  ```
59
60
 
@@ -85,3 +86,8 @@ git push --follow-tags
85
86
  9. 回答出错或中途停止:不出现灰字。
86
87
  10. 输入框为空时按 `↑`:填入上一次发送的内容;有字时按 `↑`,光标正常上移。
87
88
  11. 有灰字时完全退出 DSH 再打开,切回这个会话:灰字还在,且诊断里没有新的生成记录;按 `Escape` 关掉后再重开,不再出现。
89
+
90
+ DSH 0.2.1 起桌面端默认开启插件热更新:`dsh plugin` 安装、删除或更新后,后台半不用重启就会换成新代码(旧实例先卸载,新实例再加载,两者在同一个进程里)。界面半在浏览器页面里另有一套加载方式;0.2.1-rc.2 Windows 真机上不刷新窗口也生效了。改动后再过一遍:
91
+
92
+ 12. DSH 开着时 `remove` 再 `add` 本插件:命令不卡住;不重启 DSH,发一条消息等回答完,能出灰字。若不出,先刷新窗口再试,还不行再重启 DSH,并记下需要哪一步。
93
+ 13. 有灰字时按第 12 条更新一次,再切回这个会话:灰字能还原;`plugin-data/dsh-next-prompt/` 下没有残留的 `.tmp` 文件。
package/lib/cache.js CHANGED
@@ -11,6 +11,7 @@
11
11
  * @module dsh-next-prompt/cache
12
12
  */
13
13
 
14
+ import { randomUUID } from 'node:crypto'
14
15
  import { mkdir, rename, writeFile } from 'node:fs/promises'
15
16
  import { readFileSync } from 'node:fs'
16
17
  import { homedir } from 'node:os'
@@ -81,7 +82,9 @@ export function createSuggestionCache({ file, logger, maxEntries = MAX_CACHED_SE
81
82
  if (!dirty) return
82
83
  dirty = false
83
84
  const body = JSON.stringify({ format: FORMAT, sessions: Object.fromEntries(load()) })
84
- const temp = `${file}.${process.pid}.tmp`
85
+ // 临时文件名不能只带 pid:DSH 热更新插件时,新旧两个实例在同一进程里,
86
+ // 旧实例还没写完、新实例又开始写,就会写进同一个临时文件。
87
+ const temp = `${file}.${process.pid}.${randomUUID()}.tmp`
85
88
  try {
86
89
  await mkdir(dirname(file), { recursive: true, mode: 0o700 })
87
90
  await writeFile(temp, body, { mode: 0o600 })
package/lib/client.js CHANGED
@@ -92,7 +92,11 @@ window.__ModuleLoader__.load({
92
92
 
93
93
  if (typeof document !== 'undefined') {
94
94
  try {
95
- if (document.querySelector(`style[data-plugin-css=${JSON.stringify(ID)}]`) === null) {
95
+ // 已有标签时改写内容而不是跳过:插件更新后页面里可能还留着旧版本的样式。
96
+ const existing = document.querySelector(`style[data-plugin-css=${JSON.stringify(ID)}]`)
97
+ if (existing !== null) {
98
+ if (existing.textContent !== CSS) existing.textContent = CSS
99
+ } else {
96
100
  const tag = document.createElement('style')
97
101
  tag.dataset.plugin = ID
98
102
  tag.dataset.pluginCss = ID
package/lib/index.js CHANGED
@@ -647,7 +647,9 @@ function registerRoute(ctx, config) {
647
647
  return { ok: true, candidate: entry.candidate, source: 'cache', verified: true }
648
648
  }
649
649
 
650
- if (cache !== undefined) ctx.effect(() => () => { void cache.flush() }, 'dsh-next-prompt: 提示词缓存')
650
+ // 卸载时返回写盘的 promise,DSH 会等它完成:热更新时新实例紧接着读这个文件,
651
+ // 旧实例最后一次写还没落盘的话,新实例会读到旧内容。
652
+ if (cache !== undefined) ctx.effect(() => () => cache.flush(), 'dsh-next-prompt: 提示词缓存')
651
653
 
652
654
  /*
653
655
  * ---------------- 回合跟踪:由宿主监听回合结束 ----------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-next-prompt",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "DeepSeek Harness 插件:Agent 回答结束后在输入框预填一条灰色的下一句建议,按 Tab 或 → 采纳;输入框为空时按 ↑ 填入上一次发送的内容。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -45,7 +45,7 @@
45
45
  "url": "https://github.com/Tleon-H/dsh-next-prompt/issues"
46
46
  },
47
47
  "scripts": {
48
- "test": "node --test test/core.test.mjs test/host.test.mjs test/client.test.mjs",
48
+ "test": "node --test test/core.test.mjs test/host.test.mjs test/cache.test.mjs test/client.test.mjs",
49
49
  "prepublishOnly": "npm test"
50
50
  },
51
51
  "engines": {