dsh-session-superagent 0.9.245 → 0.9.249

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,159 @@
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.249] - 2026-11-05 —— 把「客户实拍」那个 bug 变成一条永久的门禁
6
+
7
+ 0.9.248 修了「设置页左栏点了不换内容」。那一轮修的是**一个地方**;
8
+ 这一轮修的是**这一类**。
9
+
10
+ ### 为什么一个 bug 能活 160 个版本
11
+
12
+ ```js
13
+ node.props.key === settingsSection
14
+ ```
15
+
16
+ 真 React 会把 `key` 从 props 剥掉(它挂在 `element.key` 上),而测试桩把它留在了 props 里。
17
+ **桩比运行时干净,就会掩盖 bug** —— 这不是第一次:
18
+
19
+ | 时间 | 桩里成立、真机不成立 |
20
+ |---|---|
21
+ | T26 | `watcher()` 桩里 `intervalSec: 30` 恒存在、`goal: null` 恒为空、`gh` 不在桩里 |
22
+ | 0.9.248 | `createElement` 保留 `props.key` |
23
+
24
+ ### 新增门禁 `audit-react-semantics.mjs`(已挂进 preflight,第 41 项)
25
+
26
+ 三条判据,全部是「桩里能跑、真机坏」的形状:
27
+
28
+ 1. `client.js` 不许靠 `props.key` 做判断(React 剥掉它);
29
+ 2. `client.js` 不许**改写** props(React 在开发模式下冻结 props);
30
+ 3. 测试桩**必须**按 React 语义剥掉 `key` —— 否则第 1 类 bug 永远测不出来。
31
+
32
+ 扫描前先按行去掉注释(不然解释这个坑的注释自己会被判红)。
33
+
34
+ ### 新增知识库条目
35
+
36
+ `docs/kb/test-harness-must-match-runtime.md` —— 把这次的教训写成了规则:
37
+ **桩要模仿运行时的「坏脾气」,不是模仿它的「好脾气」**。
38
+
39
+ ### 证据
40
+
41
+ ```
42
+ npm test → 387/387
43
+ preflight --fast → React 语义 PASS
44
+ ```
45
+
46
+ ## [0.9.248] - 2026-11-05 —— 客户实拍:设置页左栏点了不换内容
47
+
48
+ ### 客户看到的
49
+
50
+ 截图里左栏高亮已经跳到「会话 goal」,而右边内容还是「来源」。
51
+
52
+ **导航高亮会动、内容不动** —— 说明点击是有效的、状态也变了,只是**查表查不到**。
53
+
54
+ ### 根因:React 会把 `key` 从 props 里剥掉
55
+
56
+ ```js
57
+ const settingsBody = settingsSections.find((node) => node && node.props && node.props.key === settingsSection)
58
+ ```
59
+
60
+ `key` 是 React 的**特殊 prop**:它挂在 `element.key` 上,**不出现在 `props` 里**。
61
+ 所以真机上 `node.props.key` 恒为 `undefined` → find 永远落空 → 回退到 `settingsSections.find(Boolean)` = **第一块(来源)**。
62
+
63
+ 浅色高亮跟着 `settingsSection` 走,内容跟着「找不到就用第一个」走 —— 于是永远停在来源。
64
+
65
+ 改成**按顺序取**(`settingsSections` 与导航 `SETTINGS_SECTIONS` 同序)。
66
+
67
+ ### 为什么 387 条测试一条都没发现
68
+
69
+ **测试桩的 `h()` 把 `key` 留在了 `props` 里** —— 真实 React 不会。于是这段代码在桩里能跑、在真机上是坏的。
70
+
71
+ 这正是 T26 说过的老毛病:**桩比运行时干净,就会掩盖 bug**。
72
+
73
+ 两处都修了:`client.js` 不再依赖 `props.key`;测试桩改成和 React 一致(`key` 单独存放,不进 `props`)。
74
+
75
+ ### 新增用例(会红的那个)
76
+
77
+ 按槽位把 `settingsSection` 设成 source / creds / goal,断言**三块内容各不相同**。
78
+ 修复前 creds 与 goal 都渲染成「来源」。
79
+
80
+ ### 证据
81
+
82
+ ```
83
+ npm test → 387/387
84
+ 修复前:source/creds/goal → 全是「来源」
85
+ 修复后:来源 / 凭证 / 会话 goal
86
+ ```
87
+
88
+ ## [0.9.247] - 2026-11-05 —— 状态文件里一个坏值,整块面板全灭
89
+
90
+ T37 造了 8 种「旧/坏状态文件」喂给当前代码。**三种旧版本形状全部正常兜底**,
91
+ 但两种**坏形状**会让面板直接死掉。
92
+
93
+ ### M1 · `watchers` 里有 `null` → `/state` 与 `/diagnose` 抛异常
94
+
95
+ ```
96
+ watchers 的值 = ["null","object"]
97
+ GET /state → HTTP THREW: Cannot read properties of null (reading 'id')
98
+ GET /diagnose → HTTP THREW: Cannot read properties of null (reading 'repo')
99
+ watch_status → OK(它有 filter(Boolean))
100
+ ```
101
+
102
+ **同一个坏文件,一个入口活着、两个入口死了。** 修法就是给那两个补上 `filter(Boolean)` ——
103
+ 说明这不是「设计问题」,是**漏了一处**。
104
+
105
+ 面板完全打不开的时候,客户连「哪条守坏了」都看不到。
106
+
107
+ ### M2 · `history` / `filteredLog` / `events` 是数字 → `/state` 500,且该守**永久退避**
108
+
109
+ `(w.history ?? []).slice(...)` —— `?? []` 只挡 `null`/`undefined`,挡不住 `42`。
110
+ 轮询路径里 `for (const event of entry.history || [])` 对 `42` 直接抛 `not iterable`,
111
+ 于是这条守每轮都失败、退避到 30 分钟,**再也不会正常唤醒**。
112
+
113
+ 这与 0.9.195(`477b99d`,标题就叫「坏 wakeTimes 崩面板」)修 `pruneWakeTimes` 是**同一个坑** ——
114
+ 当时只修了一处,这几处漏了。
115
+
116
+ 全部改成 `Array.isArray(...) ? ... : []`。
117
+
118
+ ### 新用例(一次抓出我漏掉的第四处)
119
+
120
+ 用例同时造「一个 `null` 守」+「三个字段类型坏掉的守」,然后真跑 `/state` 与 `/diagnose`。
121
+
122
+ **第一次跑就抓到我漏了 `history`** —— 我手改了三处,测试找出第四处。
123
+
124
+ ### 证据
125
+
126
+ ```
127
+ npm test → 386/386(新增:坏状态文件不能让面板崩)
128
+ ```
129
+
130
+ ## [0.9.246] - 2026-11-05 —— npm 上也渲染 README,但图和三份文档不在包里
131
+
132
+ T35 W1:`files` 是白名单,只发 12 个文件。而 **npm 页面会把 README 完整渲染出来** ——
133
+
134
+ - 头图 `assets/icon-180.png` 不在包里 → **破图**(页面最顶上那个位置);
135
+ - `docs/whats-new-0.9.md`、`docs/json-契约.md` 不在包里 → 死链;
136
+ - `UPDATING.md`(升级步骤)、`CHECKLIST.md`、`MAINTENANCE.md` 也不在 → 死链。
137
+
138
+ **客户打开 npm 页面看到的第一屏,就是一张破图。**
139
+
140
+ ### 改法
141
+
142
+ 把这 6 份加进 `files`(合计约 30 KB,比破图便宜),`audit-pack` 的必需清单同步。
143
+
144
+ ### 新增防回归用例
145
+
146
+ 读 README,抽出所有**本仓相对引用**(`src="x.png"` 与 `](x.md)`),逐个断言它们在 `files` 里。
147
+
148
+ 这条用例第一次跑就抓出 3 个漏的(`UPDATING.md` / `CHECKLIST.md` / `MAINTENANCE.md`)——
149
+ 比我肉眼找的还准。
150
+
151
+ ### 证据
152
+
153
+ ```
154
+ npm test → 385/385(新增:README 引用的图片与文档必须打进包)
155
+ npm pack → 20 个文件(原 13)
156
+ ```
157
+
5
158
  ## [0.9.245] - 2026-11-05 —— 两个「只增不减」的缓存
6
159
 
7
160
  T36 的「值得修」里有两条属于同一类:**内存里的东西没人回收**。
package/CHECKLIST.md ADDED
@@ -0,0 +1,26 @@
1
+ # CHECKLIST —— 两张表,两个交付门
2
+
3
+ ## A 表 · 代码交付前
4
+
5
+ - [ ] `npm test` 全绿,且新增行为有测试
6
+ - [ ] 所有返回字符串都过 `redact()`(新增输出路径重点查)
7
+ - [ ] 写操作仍要求 `confirm: true`
8
+ - [ ] 唤醒仍受 `agent.status === 'idle'` 约束
9
+ - [ ] 唤醒失败时不推进水位(`entry.seen` 不动)
10
+ - [ ] `package.json` 的 `files` 覆盖所有要发布的文件(`lib` + 文档 + patch)
11
+ - [ ] 没有把本地路径、个人 token、机器名写进仓库
12
+
13
+ ## B 表 · 发版前
14
+
15
+ - [ ] 从最新 `main` 起功能分支
16
+ - [ ] `CHANGELOG.md` 增加条目,`package.json` bump 版本
17
+ - [ ] 本地 `npm test` 通过
18
+ - [ ] PR 合并到 `main`
19
+ - [ ] 打 annotated tag `vX.Y.Z` 并推送
20
+ - [ ] 创建 GitHub Release,说明取自 CHANGELOG
21
+ - [ ] 安装验证:`dsh plugin --profile <p> add github:MYCF711/dsh-session-superagent`
22
+
23
+ ## 发完之后
24
+
25
+ - [ ] 在测试仓库 `watch_start` 跑一轮,确认唤醒可达
26
+ - [ ] 记录一次真实运行的观察结果到本仓库 issue
package/MAINTENANCE.md ADDED
@@ -0,0 +1,78 @@
1
+ # MAINTENANCE.md —— 维护台账(给接手的 agent 看)
2
+
3
+ > 接手前先读这一页,再按 [AGENTS.md](./AGENTS.md) 的「先定位你在哪一步」读对应文档。
4
+ > **每次干完活必须更新「二、当前状态」与「三、下一步」** —— 这页不是历史,是交接单。
5
+ >
6
+ > 形态参照 `MYCF711/magpie-plugin-scaffold` 的维护台账,本地化成这个仓库的真实命令与数字。
7
+
8
+ ## 一、身份
9
+
10
+ | 项 | 值 |
11
+ |---|---|
12
+ | 仓库 | `MYCF711/dsh-session-superagent` |
13
+ | npm 包名 | `dsh-session-superagent` |
14
+ | 当前版本 | `0.9.168`(npm 已发布 / tag `v0.9.168` / GitHub Release 为 Latest) |
15
+ | 形态 | DSH 插件:7 个工具 + 自带 `cordis.patch.yml` + 客户端面板与状态栏圆环 |
16
+ | 目标宿主 | DeepSeek Harness ≥ 0.2.1-rc.5;Node ≥ 22.19;需已登录 `gh` CLI |
17
+
18
+ ## 二、当前状态(2026-11-04)
19
+
20
+ ```text
21
+ 分支 main(HEAD 4a0e370)
22
+ 版本 0.9.168;tag v0.9.168(远端已推);release v0.9.168 = Latest
23
+ 工作区 clean;安装副本 %DSH_HOME%\profiles\desktop\node_modules\... = 0.9.168
24
+ ```
25
+
26
+ | 资产 | 数量 |
27
+ |---|---:|
28
+ | `node --test` | 267 例全过 |
29
+ | `scripts/preflight.mjs` | 37 项全 PASS(`--fast` 36 项) |
30
+ | `scripts/ui-audit.mjs` | 11/11,100 分(写死颜色 0 / 自造 token 0) |
31
+ | `docs/kb` | 177 篇 / 9 板块(`check-docs` 五项 PASS,含总数校验) |
32
+ | `scripts/` | 52 个门禁与工装脚本 |
33
+ | GitHub Release | 35 个(v0.9.136–v0.9.170 已补,其余待按批次回填) |
34
+ | CI / 分支保护 | `ci`(Node 22/24,actions 已到 v7);main 已开 required check + 禁强推禁删;dependabot PR #8 已走通合并 |
35
+
36
+ 已验证(本轮实测):
37
+
38
+ - `node --test` → 267/267;preflight 全量 37/37;ui-audit 11/11 = 100;`check-docs` 五项 PASS;
39
+ - `sync-profile --check` → 缺失 0 / 断链 0 / 陈旧 0;安装副本 `package.json` = 0.9.169;
40
+ - `npm publish` → `+ dsh-session-superagent@0.9.169`;`git push` → 见 `git log --oneline -1`;
41
+ - 外部 PR:#2 / #3 / #5 / #6 已处理(#2 #3 → 0.9.167,#6 → 0.9.168,#5 按重复关闭);
42
+ #7(`ghConfigDir`)留在 open 等作者按三条意见改完。
43
+
44
+ 未验证(不能写成"通过"):
45
+
46
+ - **真机走查 22 项**(`docs/真机走查清单-弹层.md`)—— 需要人在界面上按 Tab/Escape、看两套主题;
47
+ - 连续 24 小时运行的误唤醒率、限流表现;
48
+ - 键盘 Tab 顺序无自动化手段(只有静态断言)。
49
+
50
+ ## 三、下一步
51
+
52
+ 按价值排序,**不要一次混着做**:
53
+
54
+ 1. 回填剩余 GitHub Release(`node scripts/release-gh.mjs`,用户要求"之前的慢慢改");
55
+ 2. 收掉 `diagnoseBadBody()` 的盲区:本地切分错误不该被报成"网络/代理问题";
56
+ 3. PR #7(`ghConfigDir`)等作者改完三条后复核合入;
57
+ 4. 真机走查 22 项(需要用户配合,或按用户截图逐条对照)。
58
+
59
+ ## 四、硬约束
60
+
61
+ 1. **不重启、不关闭宿主的 DSH**;需要重启才生效的改动(服务端部分)只提示用户,自己不执行。
62
+ 2. **凭证永不出插件**:所有返回必须过 `redact()`;新增输出路径要补测试;
63
+ **路径也不回显**(Windows 反斜杠曾让掩码整段漏出)。
64
+ 3. **不修改用户 profile 的 `bundles`**;本项目只随包带 `cordis.patch.yml`。
65
+ 4. **没跑过的写成"未验证"**,不写"通过";"包含"式断言不算验证过(见 AGENTS 坑 7)。
66
+ 5. **发布三处必须一致**:`package.json` / `lib/index.js` / `client.js` / README 徽章 / CHANGELOG
67
+ (`test/meta.test.mjs` 会拦),外加 **tag 与 Release 标题只写版本号**。
68
+ 6. **不代改他人 PR**:给意见让对方改,改完我复核合入。
69
+ 7. **标准写在文档里不算数**:新加的检查必须接进 `preflight` 或 CI,否则就是「标准悬空」
70
+ (写好了没人调用 = 没写)。见 [docs/维护标准.md](./docs/维护标准.md)。
71
+
72
+ ## 五、给接手者的最短路径
73
+
74
+ 1. 读本文件 + [AGENTS.md](./AGENTS.md) 的两张表(定位 / 坑);
75
+ 2. `git status` + `git log --oneline -5` + `node --test` 核实现状(**别信本文件的数字,跑一遍**);
76
+ 3. 按 AGENTS 定位表读对应专档,别通读;
77
+ 4. 改完跑 `node scripts/preflight.mjs`(全量)再交付;
78
+ 5. 发版按 [UPDATING.md](./UPDATING.md),最后回来更新本文件的「当前状态」。
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.245-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.249-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
- npm test # 384 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
149
+ npm test # 387 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
150
150
  ```
151
151
 
152
152
  ### 工具输出:文本给人和 agent,JSON 给程序
@@ -206,7 +206,7 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
206
206
 
207
207
 
208
208
  ```bash
209
- npm test # 384 项单测(带离线开关,约 1.6 秒)
209
+ npm test # 387 项单测(带离线开关,约 1.6 秒)
210
210
  node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
211
211
  node scripts/preflight.mjs # 40 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
212
212
  node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
package/UPDATING.md ADDED
@@ -0,0 +1,73 @@
1
+ # 更新与发布
2
+
3
+ ## 铁律
4
+
5
+ 1. 默认分支只接受通过门禁的 PR;`main` 永远可安装。
6
+ 2. **发版三步缺一不可**:`npm publish` + `git tag` + `GitHub Release`。
7
+ 只发 npm 不发 Release,客户打开仓库「发布」看到的是旧版本 —— 等于假装没在更新(0.9.168 之前就是这样,页面停在 v0.8.11)。
8
+ 3. **Release 标题只写版本号**(`v0.9.168`),说明放正文。标题带中文描述会让列表不可扫读。
9
+
10
+ ## 发一个版本(标准流程)
11
+
12
+ ```bash
13
+ # 1) 改代码 + 补测试
14
+ npm test
15
+
16
+ # 2) bump 版本 + 写 CHANGELOG
17
+ # 语义化:修 bug → patch;加能力 → minor;改默认行为 / 改 patch 行 id → major
18
+ # 五处必须一起改:package.json / lib/index.js / client.js / README 徽章 / CHANGELOG
19
+ node scripts/check-maintenance.mjs # 会告诉你哪处没对齐
20
+
21
+ # 3) 全量门禁(不是 --fast)
22
+ node scripts/preflight.mjs
23
+
24
+ # 4) 提交,**commit 与 tag 一起推**
25
+ # 先推 commit 再补 tag,CI 会在「维护一致性」那一步红(tag 还不存在)—— 实测过一次。
26
+ git add -A && git commit -m "fix: ..."
27
+ git tag v<版本> && git push origin main v<版本>
28
+
29
+ # 5) 建 Release(标题自动是纯版本号;tag 已在,只补 Release)
30
+ node scripts/release-gh.mjs --latest
31
+
32
+ # 6) 发 npm
33
+ npm publish
34
+
35
+ # 7) 同步到本机安装副本(用户重启后生效)
36
+ node scripts/sync-profile.mjs
37
+
38
+ # 8) 看 CI 有没有绿(PR 会跳过维护一致性,main 上必须绿)
39
+ gh run list --workflow ci --limit 3
40
+ ```
41
+
42
+ 历史遗留版本要补 Release 时用 `node scripts/release-gh.mjs`(不带 `--latest`),
43
+ 它会按 CHANGELOG 顺序回填;`--dry-run` 可以先看要做多少事。
44
+
45
+ ## 发布后必须核对
46
+
47
+ ```bash
48
+ node scripts/check-maintenance.mjs # 六项:CHANGELOG / tag / 四处版本一致
49
+ gh release view v<版本> --repo MYCF711/dsh-session-superagent --json name,isLatest
50
+ node -e "console.log(require('<安装副本>/package.json').version)"
51
+ ```
52
+
53
+ ## 用户怎么升级
54
+
55
+ ```bash
56
+ dsh plugin --profile <p> update dsh-session-superagent
57
+ ```
58
+
59
+ 升级走的是**装的时候那条来源**:从 npm 装的就重新解析 npm 的 latest;从 `file:` 或 github 规格装的按那条重解析。
60
+
61
+ 分不清当时怎么装的就直接重新 add 一次覆盖:
62
+
63
+ ```bash
64
+ dsh plugin --profile <p> add dsh-session-superagent@latest
65
+ ```
66
+
67
+ **服务端改动(`lib/`)要重启宿主才生效;`client.js` 改动刷新即可。**
68
+ 面板报「代码已更新到 X,但宿主还在跑 Y」时,就是这一条没做。
69
+
70
+ ## 兼容性
71
+
72
+ 插件依赖宿主内部 API(`ctx.tools`、`ctx.agents`)。升级到新的 DSH 内部 API 视为 **major**,
73
+ 因为旧宿主可能不再提供同样的服务。
Binary file
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.245'
17
+ const CLIENT_VERSION = '0.9.249'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1951,8 +1951,11 @@ window.__ModuleLoader__.load({
1951
1951
  { key: 'diagnose', title: '分诊信号' }, // 与卡片标题「分诊信号与取舍」同名:导航与标题不同名会让人以为是两块东西
1952
1952
  { key: 'goal', title: '会话 goal' },
1953
1953
  ]
1954
- const settingsBody = settingsSections.find((node) => node && node.props && node.props.key === settingsSection)
1955
- || settingsSections.find(Boolean)
1954
+ // 审核(客户实拍):**React 会把 `key` 从 props 里剥掉** —— `node.props.key` 在真机上是
1955
+ // undefined,于是 find 永远落空、回退到第一个分区。表现就是:点左栏导航高亮会动,
1956
+ // 右边内容永远是「来源」。按**顺序**取(settingsSections 与 SETTINGS_SECTIONS 同序)。
1957
+ const settingsIndex = Math.max(0, SETTINGS_SECTIONS.findIndex((item) => item.key === settingsSection))
1958
+ const settingsBody = settingsSections[settingsIndex] || settingsSections.find(Boolean) || null
1956
1959
  const settings = h('div', { className: 'dt-settings' },
1957
1960
  h('nav', { className: 'dt-settings-nav', 'aria-label': '设置分区' },
1958
1961
  SETTINGS_SECTIONS.map((item) => h('button', {
package/docs/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # 文档索引
2
+
3
+ 按「什么时候读」排,不按重要程度:
4
+
5
+ | 文档 | 什么时候读 |
6
+ |---|---|
7
+ | [README](../README.md) | 第一次接触这个插件:它做什么、怎么装、界面在哪、故障排查 |
8
+ | [01-架构](01-架构.md) | 要改服务端逻辑:分层、11 步轮询管线、状态文件与落盘规则 |
9
+ | [design-system](design-system.md) | 要改界面:35 个设计 token、常用组件类、加页面的检查清单 |
10
+ | [official-gui-ia](official-gui-ia.md) | 想知道「官方原版长什么样、我们砍了什么、为什么」 |
11
+ | [awesome-submission](awesome-submission.md) | 要提交到 awesome-dsh-plugin:现成的 YAML、图标、核对结论 |
12
+ | [competitive-analysis](competitive-analysis.md) | 想知道和 Sweep / CodeRabbit 这类工具的差别 |
13
+ | [deepseek-papers](deepseek-papers.md) | 想知道设计取舍背后的研究依据 |
14
+ | [真机验证清单](真机验证清单.md) | 重启后三条命令 + 三个动作,5 分钟确认新代码在跑 |
15
+ | [首次唤醒走查](首次唤醒走查.md) | 新客户照着走一遍:7 步 + 每步该看到什么 |
16
+ | [kb/](kb/README.md) | 每轮外部学习沉淀:出处 / 做法 / 我们能怎么用 / 是否已落地 |
17
+ | [optimization-plan](optimization-plan.md) | 要挑活时:11 项 UI/可靠性/客户体验指标 + 当前分数 + 下一批目标 |
18
+ | [ui-inventory](ui-inventory.md) | 要改界面时:渲染面 → 页签 → 二级 → 三级 → 官方原语对照,逐条标差异 |
19
+ | [review-2026-11-01](review-2026-11-01.md) | 历次严格审核的结论与遗留项(含每项的闭环状态) |
20
+
21
+ 仓库根部还有三份「维护用」的:`MAINTENANCE.md`(维护者视角的现状与门禁)、
22
+ `HANDOFF.md`(会话交接:坑列表、验证台账、下一步)、`CHECKLIST.md`(发布前逐条打勾)。
23
+
24
+ ## 时效性
25
+
26
+ - `README` / `01-架构` / `design-system` / `HANDOFF` / `optimization-plan` / `ui-inventory` 随代码更新,**以代码为准**;
27
+ - `official-gui-ia` 是对官方 0.1.0 的考古快照,不会跟随官方变化;
28
+ - `review-*` 是当时的事实记录,不追改(后续闭环写在表格里,不改原文结论);
29
+ - `awesome-submission` 里的门槛时间点会过期,提交前重新核对 `contributing.md`。
@@ -0,0 +1,168 @@
1
+ # JSON 契约(由 `scripts/render-contract.mjs` 生成,不要手改)
2
+
3
+ 所有工具都支持 `format: 'json'`,返回带 `schemaVersion` 的对象(当前 `1`)。
4
+
5
+ **稳定性**:`稳定` = 不会无故改名或删除;`实验` = 可能变化,请容忍缺失。
6
+
7
+ ## watch_status
8
+
9
+ **顶层**
10
+
11
+ | 字段 | 稳定性 |
12
+ |---|---|
13
+ | `schemaVersion` | 稳定 |
14
+ | `session` | 稳定 |
15
+ | `watchers` | 稳定 |
16
+
17
+ **`session`**
18
+
19
+ | 字段 | 稳定性 |
20
+ |---|---|
21
+ | `id` | 稳定 |
22
+ | `used` | 稳定 |
23
+ | `cap` | 稳定 |
24
+ | `capped` | 稳定 |
25
+ | `suggest` | 稳定 |
26
+
27
+ **`watchers[]` 每条**
28
+
29
+ | 字段 | 稳定性 |
30
+ |---|---|
31
+ | `repo` | 稳定 |
32
+ | `provider` | 稳定 |
33
+ | `sessionId` | 稳定 |
34
+ | `enabled` | 稳定 |
35
+ | `intervalSec` | 稳定 |
36
+ | `observe` | 稳定 |
37
+ | `isolated` | 稳定 |
38
+ | `activeHours` | 稳定 |
39
+ | `labels` | 稳定 |
40
+ | `onlyAssigned` | 稳定 |
41
+ | `deferReason` | 稳定 |
42
+ | `lastDeferred` | 实验 |
43
+ | `silentWakes` | 稳定 |
44
+ | `cursor` | 实验 |
45
+ | `lastPoll` | 稳定 |
46
+ | `lastWake` | 稳定 |
47
+ | `lastError` | 稳定 |
48
+ | `lastErrorKind` | 稳定 |
49
+
50
+ ## watch_doctor
51
+
52
+ **顶层**
53
+
54
+ | 字段 | 稳定性 |
55
+ |---|---|
56
+ | `schemaVersion` | 稳定 |
57
+ | `checks` | 稳定 |
58
+
59
+ **`checks[]` 每条**
60
+
61
+ | 字段 | 稳定性 |
62
+ |---|---|
63
+ | `status` | 稳定 |
64
+ | `text` | 稳定 |
65
+
66
+ ## watch_trace
67
+
68
+ **顶层**
69
+
70
+ | 字段 | 稳定性 |
71
+ |---|---|
72
+ | `schemaVersion` | 稳定 |
73
+ | `number` | 稳定 |
74
+ | `results` | 稳定 |
75
+
76
+ **`results[]` 每条**
77
+
78
+ | 字段 | 稳定性 |
79
+ |---|---|
80
+ | `number` | 稳定 |
81
+ | `repo` | 稳定 |
82
+ | `seen` | 稳定 |
83
+ | `reported` | 稳定 |
84
+ | `filtered` | 稳定 |
85
+ | `wakes` | 稳定 |
86
+ | `verdict` | 稳定 |
87
+ | `absorbed` | 稳定 |
88
+
89
+ **`filteredItem`**
90
+
91
+ | 字段 | 稳定性 |
92
+ |---|---|
93
+ | `at` | 稳定 |
94
+ | `reason` | 稳定 |
95
+ | `title` | 实验 |
96
+
97
+ **`wakeItem`**
98
+
99
+ | 字段 | 稳定性 |
100
+ |---|---|
101
+ | `at` | 稳定 |
102
+ | `ok` | 稳定 |
103
+ | `reason` | 稳定 |
104
+
105
+ **`absorbedItem`**
106
+
107
+ | 字段 | 稳定性 |
108
+ |---|---|
109
+ | `at` | 稳定 |
110
+ | `title` | 实验 |
111
+
112
+ ## watch_start
113
+
114
+ **顶层**
115
+
116
+ | 字段 | 稳定性 |
117
+ |---|---|
118
+ | `schemaVersion` | 稳定 |
119
+ | `ok` | 稳定 |
120
+ | `repo` | 稳定 |
121
+ | `sessionId` | 稳定 |
122
+ | `id` | 稳定 |
123
+ | `intervalSec` | 稳定 |
124
+ | `flags` | 稳定 |
125
+ | `filters` | 稳定 |
126
+ | `updated` | 稳定 |
127
+ | `observe` | 稳定 |
128
+ | `isolated` | 稳定 |
129
+ | `activeHours` | 稳定 |
130
+ | `repos` | 稳定 |
131
+
132
+ **`reposItem`**
133
+
134
+ | 字段 | 稳定性 |
135
+ |---|---|
136
+ | `repo` | 稳定 |
137
+ | `id` | 稳定 |
138
+ | `updated` | 稳定 |
139
+
140
+ ## watch_stop
141
+
142
+ **顶层**
143
+
144
+ | 字段 | 稳定性 |
145
+ |---|---|
146
+ | `schemaVersion` | 稳定 |
147
+ | `ok` | 稳定 |
148
+ | `id` | 稳定 |
149
+ | `repo` | 稳定 |
150
+
151
+ ## watch_ack
152
+
153
+ **顶层**
154
+
155
+ | 字段 | 稳定性 |
156
+ |---|---|
157
+ | `schemaVersion` | 稳定 |
158
+ | `ok` | 稳定 |
159
+ | `repo` | 稳定 |
160
+ | `label` | 稳定 |
161
+ | `acked` | 稳定 |
162
+ | `at` | 稳定 |
163
+ | `labelNote` | 稳定 |
164
+
165
+ ---
166
+
167
+ 新增字段必须登记在 `test/fixtures/contract-stability.json`,否则 `node --test` 会红;
168
+ 这份文档由清单生成,跑 `node scripts/render-contract.mjs --write` 刷新。
@@ -0,0 +1,55 @@
1
+ # 0.9 已发布:你会感知到的变化(面向使用者,不是给开发者看的 CHANGELOG)
2
+
3
+ > 从 0.8.38 到 0.9.0 有六十多个版本。下面只挑**你打开面板、或收到唤醒时能感觉到**的变化。
4
+ > 逐版本的完整记录看 [CHANGELOG](../CHANGELOG.md);每条背后的调研与取舍看 [docs/kb](kb/README.md)。
5
+
6
+ ## 一、更省、更稳(你不用做什么,但会更少出问题)
7
+
8
+ | 以前 | 现在 |
9
+ |---|---|
10
+ | 每轮都整份拉 issue 列表 | **没变化时 GitHub 回 304,不计入速率限制**([条件请求](kb/github-conditional-requests.md)) |
11
+ | 多条守同时到点,一起打 API | **首轮抖动错峰**,不再同一毫秒发车([jitter](kb/polling-jitter.md)) |
12
+ | 额度快用完仍按间隔撞墙 | **剩余 < 500 时自动推迟到额度重置**,面板写明原因([额度自适应](kb/rate-limit-adaptive.md)) |
13
+ | 被 GitHub 限流后继续重试 | **按 `Retry-After` 等**,不瞎猜([secondary 限流](kb/rate-limit-secondary.md)) |
14
+ | 状态文件写坏 = 所有守消失 | **自动从 `.bak` 恢复**,坏的留证([状态恢复](kb/state-crash-safety.md)) |
15
+ | 面板每 5 秒整份重拉 | 我们自己的接口也上了 **ETag/304**([我们自己的接口](kb/etag-on-our-own-api.md)) |
16
+ | 不在活跃时段也照常打 GitHub | **时段判断移到拉数据之前**,夜里基本零请求([时段前移](kb/active-hours-before-fetch.md)) |
17
+ | 被每小时上限挡住时只写"已攒 N 条" | 现在写**「约 43 分钟后可再唤醒」**([等待可见](kb/wake-cap-wait-visibility.md)) |
18
+ | 隔离区只按天数回收,最多能堆几百个 | 再加**数量线:最多留 5 个**([数量线](kb/worktree-count-cap.md)) |
19
+ | 报错是一行英文原始串 | 服务端 12/12 归类 + 面板把 `Failed to fetch` 也翻成人话([错误人话](kb/humanize-errors.md)) |
20
+
21
+ ## 二、唤醒消息更像"任务书"
22
+
23
+ 以前只有一个条目列表。现在每条会带上:
24
+
25
+ - **最后是谁在说话**(并且能区分「我上一轮留的」—— 那不代表有人在处理);
26
+ - **已有 PR #N(进行中·草稿·有冲突·等 review·CI 失败)** —— 避免重复劳动;
27
+ - **⚠ 被重新打开过** —— 说明之前判"不做"可能不对;
28
+ - **未认领** / **躺了 62 天** —— 积压一眼可见;
29
+ - **为什么是这几条**:本轮共 N 条变化、按什么取前 K 条、跳过了什么;
30
+ - **完成标准**:改了什么 / 怎么验证 / 回写到哪,三条可逐条核对。
31
+
32
+ ## 三、面板上能看见的东西变多了
33
+
34
+ - **跳过原因累计 + 点开看明细**:回答"我加了标签,为什么一条都没叫醒";
35
+ - **只读 / 已归档 / 无 Issues / fork / 私有** 徽章,且可点筛选;
36
+ - **隔离区占用**(几个、多大),保留天数可配;
37
+ - **分诊信号与取舍**表:哪些是事实、哪些是我们的判断、默认开不开;
38
+ - **设置 → 版本与更新 → 复制诊断信息**:一段脱敏文本,报障时贴给对方就够;
39
+ - **第一次打开有三步引导**;已经有守但没唤醒过时,会明确告诉你"在等",并指向「立刻」。
40
+
41
+ ## 四、安全
42
+
43
+ - Windows 上 `chmod 0600` 其实无效,**改用 ACL 只留当前用户**([Windows 权限](kb/windows-secrets-perms.md));
44
+ - 面板显示 **token 的权限范围**,带 `delete:packages` 这类用不到的宽权限会提示换细粒度 token。
45
+
46
+ ## 五、这次升级要注意的一件事
47
+
48
+ 服务端改动**需要重启宿主**才生效。重启后核对:
49
+
50
+ ```bash
51
+ curl -s http://127.0.0.1:65466/session-superagent/state | head -c 160
52
+ # 期望 "serverVersion":"0.9.0" 且响应头带 etag
53
+ ```
54
+
55
+ 如果 `serverVersion` 还是旧值,说明仍在跑老代码 —— 重启一次即可,不用重装。
package/lib/index.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
 
45
45
  export const name = 'dsh-session-superagent'
46
46
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
47
- export const SERVER_VERSION = '0.9.245'
47
+ export const SERVER_VERSION = '0.9.249'
48
48
  export const inject = ['tools', 'agents', 'webServer']
49
49
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
50
50
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
@@ -1467,7 +1467,8 @@ async function pollWithItems(ctx, entry, baseMs, parsed) {
1467
1467
  // 这条以前被叫醒过吗?history 里一直有数据,但消息从没用过
1468
1468
  seenBefore: (() => {
1469
1469
  const map = {}
1470
- for (const event of entry.history || []) {
1470
+ // 审核 T37 M2:`|| []` 挡不住 `42`(不是 iterable)—— 会让这条守永久退避。
1471
+ for (const event of (Array.isArray(entry.history) ? entry.history : [])) {
1471
1472
  for (const n of event.numbers || []) map[String(n)] = map[String(n)] || event.at
1472
1473
  }
1473
1474
  return map
@@ -1716,7 +1717,10 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1716
1717
  const url = new URL(String(req.url || '/'), 'http://127.0.0.1')
1717
1718
  const focusSession = url.searchParams.get('sessionId') || ''
1718
1719
  const state = readState()
1719
- const allWatchers = Object.values(state.watchers || {})
1720
+ // 审核 T37 M1:状态文件里只要有一个 `null` 值(手改、旧版写坏、半截写入),
1721
+ // `/state` 就会在 `w.id` 上抛 —— **整个面板全灭**。`watch_status` 早就有 filter(Boolean),
1722
+ // 这里漏了同一个过滤。
1723
+ const allWatchers = Object.values(state.watchers || {}).filter(Boolean)
1720
1724
  // 只有 GitHub 守才需要 `gh`:全 Gitee 的客户看到「gh 未登录」是纯噪音,
1721
1725
  // 而且那两条探测每次都要 spawn 一个进程(面板 5 秒一刷)。
1722
1726
  const needsGh = allWatchers.some((w) => w && w.provider !== 'gitee')
@@ -1746,7 +1750,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1746
1750
  nextAt: w.nextAt ?? null,
1747
1751
  lastDeferred: w.lastDeferred ?? null,
1748
1752
  observe: w.observe === true,
1749
- filteredLog: (w.filteredLog ?? []).slice(-5),
1753
+ // 审核 T37 M2:`?? []` 只挡 null/undefined —— 字段是数字时 `.slice` 不是函数,`/state` 直接 500。
1754
+ filteredLog: (Array.isArray(w.filteredLog) ? w.filteredLog : []).slice(-5),
1750
1755
  filterCounts: w.filterCounts ?? {},
1751
1756
  repoAccess: w.repoAccess ?? null,
1752
1757
  lastReopened: w.lastReopened ?? null,
@@ -1757,8 +1762,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1757
1762
  activeHours: w.activeHours ?? null,
1758
1763
  isolateKeepDays: w.isolateKeepDays ?? DEFAULT_ISOLATE_KEEP_DAYS,
1759
1764
  maxIsolated: w.maxIsolated ?? 5,
1760
- history: (w.history ?? []).slice(-5),
1761
- events: (w.events ?? []).slice(-perWatcherEvents),
1765
+ history: (Array.isArray(w.history) ? w.history : []).slice(-5),
1766
+ events: (Array.isArray(w.events) ? w.events : []).slice(-perWatcherEvents),
1762
1767
  // 同一个仓库被别的会话也守着:客户该知道「还有谁在看」
1763
1768
  otherSessions: allWatchers.filter((peer) => peer && peer.repo === w.repo && peer.sessionId !== w.sessionId).map((peer) => peer.sessionId),
1764
1769
  // 分类放在服务端做一次:面板按 kind 给「下一步」按钮,不用自己解析中文
@@ -2129,7 +2134,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2129
2134
  + ' base=' + String(mounted.base || '-')
2130
2135
  + ' at=' + String(mounted.at || '-'))
2131
2136
  if ((mounted.failed || []).length > 0) lines.push('挂载失败: ' + mounted.failed.join('; '))
2132
- const entries = Object.values(state.watchers || {})
2137
+ // 审核 T37 M1:同 `/state` —— 一个 null 值就会让整份诊断抛异常。
2138
+ const entries = Object.values(state.watchers || {}).filter(Boolean)
2133
2139
  lines.push('值守: ' + entries.length + ' 条')
2134
2140
  for (const entry of entries) {
2135
2141
  lines.push('- ' + entry.repo
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.245",
3
+ "version": "0.9.249",
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",
@@ -23,7 +23,13 @@
23
23
  "CHANGELOG.md",
24
24
  "LICENSE",
25
25
  "client.js",
26
- "bin/check.mjs"
26
+ "bin/check.mjs",
27
+ "assets/icon-180.png",
28
+ "docs/whats-new-0.9.md",
29
+ "docs/json-契约.md",
30
+ "UPDATING.md",
31
+ "CHECKLIST.md",
32
+ "MAINTENANCE.md"
27
33
  ],
28
34
  "engines": {
29
35
  "node": ">=22.19.0",