dsh-session-superagent 0.9.30 → 0.9.32

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,45 @@
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.32] - 2026-11-02 —— 文档标识符门禁 + README 补全三层限制
6
+
7
+ ### 学到的(知识库第 80 条)
8
+ 文档里的标识符(工具名、路由)会漂移,能自动查的那一半先查掉。
9
+
10
+ ### 新增:`scripts/audit-claims-consistency.mjs`
11
+ 从 `lib/index.js` 抽真实工具名与路由,扫 5 份文档里提到的同名标识符,对不上就 FAIL。
12
+ ```
13
+ 工具 6 个:watch_ack watch_trace watch_doctor watch_start watch_status watch_stop
14
+ 路由 9 条
15
+ PASS 文档里提到的工具名都真实存在
16
+ PASS 文档里提到的路由都真实存在
17
+ ```
18
+ **这次没抓到漂移** —— 说明最近的重构都同步改了文档。门禁的价值是"以后忘改会红"。
19
+
20
+ ### 顺手补的真缺口
21
+ README 原来只写「会话级 12 次/小时」,**漏了单守 6 次/小时与冷却期 3 分钟** ——
22
+ 客户看到"6 次"会以为是会话级。现在三层并列写清(数字与代码常量一致)。
23
+
24
+ ### 门禁
25
+ `preflight --fast` 第 **15** 项:`PASS 文档标识符 6 个工具 / 9 条路由都对得上`。
26
+
27
+ ## [0.9.31] - 2026-11-02 —— 面板也能追溯了(`/trace` 路由,路由面 8 → 9)
28
+
29
+ ### 做了什么
30
+ - 新增 `GET /session-superagent/trace?repo=&number=`:返回结论 + 水位 + 上次上报 + 过滤原因 + 唤醒历史;
31
+ - 面板「判定」页新增「追溯一条」:在右上角搜索框输入编号(如 `42`),点「追溯 #42」把结论显示在提示区。
32
+
33
+ ### 为什么走服务端而不是在客户端再算一遍
34
+ 客户端本地算需要 `seen` / `lastReported` —— 那是**大字段**,而既有用例明确要求
35
+ `/state` 不回传服务端自己用的字段(面板每 5 秒拉一次,省的是真流量)。
36
+ 所以走 `/trace`,按需请求、只回传结论。**同时避免了第三份重复实现**(服务端有 `itemTrace`,客户端不需要再有)。
37
+
38
+ ### 连带改动
39
+ 路由面从 8 条变 9 条:相关用例(跨实例接管 / 撞车重放 / 卸载 / 路由清单)与 preflight 的期望值一并更新。
40
+
41
+ ### 测试
42
+ - 新增 1 例(未输入时给提示、输入编号后出现追溯按钮、单守时说明在哪个仓库查)。合计 **170 例**。
43
+
5
44
  ## [0.9.30] - 2026-11-02 —— 单条追溯:`watch_trace` 工具 + `trace-item` 脚本
6
45
 
7
46
  ### 学到的(知识库第 78 条)
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.30-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.32-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
 
@@ -106,9 +106,12 @@ dsh plugin install /path/to/dsh-session-superagent
106
106
  - 宿主重启后 watcher 从状态文件恢复;会话不在则不注入(会记 `lastError`)。
107
107
  - **服务端改动要重启宿主才生效**(客户端热重载会生效,别被"界面上有新功能"骗了;
108
108
  面板顶部会在版本不一致时直接提示)。
109
- - 每小时唤醒上限是**滑动窗口**:6 次若集中在开头几分钟,下一次要等约 1 小时
110
- (面板会写「约 X 分钟后可再唤醒」)。默认上限下,**会话级 12 次/小时**:
111
- 守 3 个活跃仓库时约能处理 12 条/小时,其余攒到下一小时(离线模拟实测,见 docs/kb)。
109
+ - **三层频率限制**(都是滑动窗口,不是整点重置):
110
+ 单条守 **6 次/小时** → 一条守一小时最多叫醒你 6 次;
111
+ 整条会话 **12 次/小时**(跨所有守累计);
112
+ 冷却期 **3 分钟**(只吸收你自己刚操作过的条目,别人提交的不受影响)。
113
+ 6 次若集中在开头几分钟,下一次要等约 1 小时(面板会写「约 X 分钟后可再唤醒」)。
114
+ 离线模拟实测:守 3 个活跃仓库时约能处理 12 条/小时,其余攒到下一小时。
112
115
  - 隔离执行会在仓库下留 `.dsh-zhuli/` 副本:默认**最多 5 个**、超 3 天回收;
113
116
  副本体积≈该仓库工作树大小。开隔离区时会自动把它写进 `.git/info/exclude`,
114
117
  所以**不会污染 `git status`**、也不会误提交。
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.30'
17
+ const CLIENT_VERSION = '0.9.32'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1228,6 +1228,31 @@ window.__ModuleLoader__.load({
1228
1228
  count: watchers.reduce((n, w) => n + (w.history || []).length, 0),
1229
1229
  action: h(InfoTip, { text: '每轮判定都会记一条:唤醒、仅观察,或跳过及其原因。只存最近若干条。' }),
1230
1230
  },
1231
+ (() => {
1232
+ const needle = search.trim()
1233
+ const asNumber = /^#?[0-9]+$/.test(needle) ? needle.replace('#', '') : ''
1234
+ if (!asNumber) {
1235
+ return h(Section, { key: 'trace', title: '追溯一条', hint: '在右上角搜索框输入编号(如 42),这里就能查它经历了什么' },
1236
+ h(Hint, null, '追溯会告诉你:它被过滤了、已经唤醒过、还是根本没轮到。'))
1237
+ }
1238
+ const onlyRepo = watchers.length === 1 ? watchers[0].repo : ''
1239
+ return h(Section, { key: 'trace', title: '追溯一条' },
1240
+ h('div', { className: 'dt-row-meta' },
1241
+ h('button', {
1242
+ className: 'dt-textlink',
1243
+ type: 'button',
1244
+ onClick: async () => {
1245
+ try {
1246
+ const query = '/trace?number=' + encodeURIComponent(asNumber) + (onlyRepo ? '&repo=' + encodeURIComponent(onlyRepo) : '')
1247
+ const payload = await call(query)
1248
+ notify(String((payload && payload.text) || '没有结果').split(String.fromCharCode(10)).join(' · '), 'info')
1249
+ } catch (error) {
1250
+ notify('追溯失败:' + String((error && error.message) || error), 'error')
1251
+ }
1252
+ },
1253
+ }, '追溯 #' + asNumber),
1254
+ h('span', { className: 'dt-row-meta' }, onlyRepo ? '(在 ' + onlyRepo + ' 里查)' : '(在所有守里查)')))
1255
+ })(),
1231
1256
  (() => {
1232
1257
  const counts = new Map()
1233
1258
  for (const w of watchers) if (w.deferReason) counts.set(w.deferReason, (counts.get(w.deferReason) || 0) + 1)
package/lib/index.js CHANGED
@@ -35,7 +35,7 @@ import {
35
35
 
36
36
  export const name = 'dsh-session-superagent'
37
37
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
38
- export const SERVER_VERSION = '0.9.30'
38
+ export const SERVER_VERSION = '0.9.32'
39
39
  export const inject = ['tools', 'agents', 'webServer']
40
40
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
41
41
  const DEFAULT_SESSION_WAKES = 12
@@ -1526,6 +1526,36 @@ export function apply(ctx) {
1526
1526
  },
1527
1527
  })
1528
1528
 
1529
+ // 单条追溯:面板点「追溯」时来问。只回传结论与明细,不回传 seen/lastReported 这类大字段。
1530
+ addRoute({
1531
+ kind: 'exact',
1532
+ path: '/session-superagent/trace',
1533
+ handler: async (req, res) => {
1534
+ if (req.method !== 'GET') return json(res, 405, { error: 'method not allowed' })
1535
+ const url = new URL(String(req.url || '/'), 'http://127.0.0.1')
1536
+ const repo = url.searchParams.get('repo') || ''
1537
+ const number = url.searchParams.get('number') || ''
1538
+ const state = readState()
1539
+ const list = Object.values(state.watchers || {}).filter((entry) => !repo || entry.repo === repo)
1540
+ const lines = []
1541
+ for (const entry of list) {
1542
+ const trace = itemTrace(entry, number)
1543
+ if (!trace) continue
1544
+ const touched = Boolean(trace.seen || trace.reported || trace.filtered.length || trace.wakes.length)
1545
+ if (!touched) continue
1546
+ lines.push('#' + trace.number + ' @ ' + (trace.repo || '?') + ':' + trace.verdict)
1547
+ if (trace.seen) lines.push('水位 ' + trace.seen)
1548
+ if (trace.reported) lines.push('上次上报 ' + trace.reported)
1549
+ for (const item of trace.filtered) lines.push('被过滤(' + (item.reason || '未知') + ')' + item.at)
1550
+ for (const item of trace.wakes) lines.push('唤醒尝试 ' + item.at + ' ' + (item.ok ? '成功' : '失败(' + (item.reason || '未知') + ')'))
1551
+ }
1552
+ const text = lines.length > 0
1553
+ ? lines.join(String.fromCharCode(10))
1554
+ : '#' + number + ' 在' + (repo || '所有守') + ' 里都没有痕迹 —— 可能还没被轮询到,或者编号写错了。'
1555
+ json(res, 200, { ok: true, text })
1556
+ },
1557
+ })
1558
+
1529
1559
  // 版本检查(只读;面板「设置」页那一行「有新版本」靠它)
1530
1560
  addRoute({
1531
1561
  kind: 'exact',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.30",
3
+ "version": "0.9.32",
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",