dsh-session-superagent 0.9.225 → 0.9.227

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,96 @@
2
2
 
3
3
  格式参照 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
4
 
5
+ ## [0.9.227] - 2026-11-05 —— 测试把假的守写进了**真实**状态目录
6
+
7
+ ### ① 已经发生过的事故(不是假设)
8
+
9
+ 本机真实状态文件 `~/.dsh/state/session-superagent/watchers.json` 里有 4 条守,其中一条是:
10
+
11
+ ```
12
+ o/parity#session-parity
13
+ ```
14
+
15
+ `o/parity` 是 `test/routes.test.mjs` 里造的**测试仓库**(现实里不存在)。它被 `watch_start`
16
+ 写进了真实状态文件,于是**真机面板上从此一直有一条永远轮询失败的假守**。
17
+
18
+ 根因:那条用例用 `import('../lib/index.js?parity=…')` 加载模块,
19
+ 而模块在**加载那一刻**读 `DSH_SUPERAGENT_STATE` —— env 没设好时就读到了真实的 `~/.dsh/`。
20
+
21
+ ### ② 两条修法
22
+
23
+ - `test/fixtures/tmpdir.mjs` 新增 `assertTempStateDir()`:任何会写状态的用例,动手前先确认
24
+ `DSH_SUPERAGENT_STATE` 指向临时目录,**指错就当场炸**(不再靠调用顺序才对);
25
+ `o/parity` 那条用例已接上。
26
+ - `test/contract-stability.test.mjs` 里的**裸 import** 换成复用同一份实例
27
+ (裸 import 可能拿到别的测试留下的实例,`writeState` 会真的写进去),并加了一道「目录不是临时目录就拒绝写入」的守卫。
28
+
29
+ ### ③ 顺带修好上一轮我自己引入的一个问题
30
+
31
+ 上一轮加的 `afterEach` 还原 env 的钩子插在了**文件顶部** —— 那时 `DSH_SUPERAGENT_STATE` 还没设,
32
+ 所以 afterEach 会把它**删掉**,后面的用例就没了临时目录。守卫一上线就把这个错抓出来了。
33
+ 现在钩子插在 env 设置**之后**。
34
+
35
+ ### 证据
36
+
37
+ ```
38
+ npm test → 370/370
39
+ node --test --experimental-test-isolation=none → 370/370
40
+ 真实状态目录里的 4 条守完好(没被测试动过)
41
+ ```
42
+
43
+ ### 遗留(需要你决定)
44
+
45
+ 真实状态文件里那条 `o/parity#session-parity` **是测试垃圾**,我没有直接删 ——
46
+ 它在你机器上会一直轮询失败。要清就执行:
47
+
48
+ ```bash
49
+ node -e "const fs=require('fs'),os=require('os'),p=require('path').join(os.homedir(),'.dsh','state','session-superagent','watchers.json');const j=JSON.parse(fs.readFileSync(p,'utf8'));delete j.watchers['o/parity#session-parity'];fs.writeFileSync(p,JSON.stringify(j,null,2));console.log('已清')"
50
+ ```
51
+
52
+ ## [0.9.226] - 2026-11-05 —— 文档给的 `node --test` 不是绿色路径
53
+
54
+ ### ① 裸 `node --test` 会真的去 spawn `gh`
55
+
56
+ `test/routes.test.mjs` 里有几条会真起 `gh` 进程。实测:
57
+
58
+ ```
59
+ 带 DSH_SUPERAGENT_OFFLINE=1 → 1123 ms
60
+ 不带 → 146574 ms(两分半)
61
+ timeout 120 node --test → 被 kill 成 pass 355 / fail 1
62
+ ```
63
+
64
+ 而 README / CONTRIBUTING / CHECKLIST 给的都是**裸 `node --test`** ——
65
+ 客户和协作者照着敲,会看到「测试挂了」,其实是在等 `gh` 超时。
66
+
67
+ 新增 `scripts/test.mjs`:带齐环境变量(离线 + 更新离线 + 清掉可能污染的状态目录变量),
68
+ `npm test` 指向它,文档里的命令也全部改成 `npm test`。实测 **1.6 秒**。
69
+
70
+ ### ② 测试改 `process.env` 从不还原
71
+
72
+ 7 个测试文件写 `process.env.DSH_SUPERAGENT_STATE` 却不恢复 ——
73
+ 同一个进程里后跑的用例会拿到前一个的目录。
74
+
75
+ 实测修复前 `node --test --experimental-test-isolation=none` → **10 红**
76
+ (`ENOENT watchers.json`、`TypeError: ... setting 'seen'`、「回调必须被调用」),
77
+ **红哪几条取决于文件加载顺序** —— 这是最阴的一类不稳定。
78
+
79
+ 修法:在改动 env 的测试文件顶部装 `afterEach` 还原(谁改谁收拾)。
80
+ 修复后同一条命令 **370/370 全绿**。
81
+
82
+ ### 一个没做成的尝试(记下来)
83
+
84
+ 我先把 `lib/index.js` 的四个路径常量改成**惰性函数**(每次调用现读 env),
85
+ 结果 `routes.test.mjs` 里靠「改 env → cache-bust 重新 import」的 6 处用法全部失效(2 红)。
86
+ **已回退**,改用测试侧还原。惰性化本身是更彻底的修法,但它要求测试同步改造,不是一轮能安全做完的。
87
+
88
+ ### 证据
89
+
90
+ ```
91
+ npm test → 370/370(1.6 秒)
92
+ node --test --isolation=none → 370/370(修复前 10 红)
93
+ ```
94
+
5
95
  ## [0.9.225] - 2026-11-05 —— 文档里的路径与报错原文,和代码对不上
6
96
 
7
97
  ### ① 状态文件路径写错
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img src="assets/icon-180.png" width="88" height="88" alt="">
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Version](https://img.shields.io/badge/version-0.9.225-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.227-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
7
7
  [![npm](https://img.shields.io/npm/v/dsh-session-superagent.svg)](https://www.npmjs.com/package/dsh-session-superagent)
8
8
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-plugin-orange.svg)](https://github.com/topics/dsh-plugin)
9
9
  [![awesome](https://img.shields.io/badge/awesome-dsh--plugin-%E2%9C%93-success.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
@@ -146,7 +146,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
146
146
  ## 开发
147
147
 
148
148
  ```sh
149
- node --test # 369 项单测
149
+ npm test # 370 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
150
150
  ```
151
151
 
152
152
  ### 工具输出:文本给人和 agent,JSON 给程序
@@ -198,7 +198,7 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
198
198
  ## 验收(不用装宿主也能跑)
199
199
 
200
200
  ```bash
201
- node --test # 369 项单测
201
+ npm test # 370 项单测(带离线开关,约 1.6 秒)
202
202
  node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
203
203
  node scripts/preflight.mjs # 40 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
204
204
  node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
package/client.js CHANGED
@@ -14,7 +14,7 @@ window.__ModuleLoader__.load({
14
14
  const { useCallback, useEffect, useRef, useState } = React
15
15
 
16
16
  // 客户端版本探针:每次模块加载写一次,用来确认浏览器里跑的是哪一版
17
- const CLIENT_VERSION = '0.9.225'
17
+ const CLIENT_VERSION = '0.9.227'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
package/lib/index.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
 
44
44
  export const name = 'dsh-session-superagent'
45
45
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
46
- export const SERVER_VERSION = '0.9.225'
46
+ export const SERVER_VERSION = '0.9.227'
47
47
  export const inject = ['tools', 'agents', 'webServer']
48
48
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
49
49
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.225",
3
+ "version": "0.9.227",
4
4
  "description": "Session-level superagent for DeepSeek Harness: watch a GitHub repository and wake a session when something needs doing. Credentials never reach the model.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -29,8 +29,8 @@
29
29
  "dsh": ">=0.2.1-rc.5"
30
30
  },
31
31
  "scripts": {
32
- "test": "node --test",
33
- "check": "node --test",
32
+ "test": "node scripts/test.mjs",
33
+ "check": "node scripts/test.mjs",
34
34
  "preview:orbit": "node scripts/preview-orbit.mjs",
35
35
  "sync:profile": "node scripts/sync-profile.mjs",
36
36
  "smoke:observe": "node scripts/smoke-observe.mjs",