dsh-session-superagent 0.9.115 → 0.9.118

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,93 @@
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.118] - 2026-11-03 —— 单测从 101 秒降到 1.6 秒:它们一直在等一个不可能的 gh 响应
6
+
7
+ ### 现场
8
+ 真机重启后跑 `node --test`,**101 秒**才结束(之前 9 秒)。逐文件计时立刻定位:
9
+
10
+ ```
11
+ 103571 ms test/routes.test.mjs
12
+ 42290 ms test/contract-stability.test.mjs
13
+ ```
14
+
15
+ 根因不是用例写错,而是**环境**:`gh auth status` 显示
16
+
17
+ ```
18
+ X Failed to log in to github.com account MYCF711 (keyring)
19
+ - The token in keyring is invalid.
20
+ ```
21
+
22
+ 于是每个调用 `gh api` 的用例都要等到超时(`watch_start` 的仓库体检、`watch_ack` 打标签)。
23
+
24
+ ### 改法
25
+ 加一个**离线模式** `DSH_SUPERAGENT_OFFLINE=1`:`run()` 遇到 `gh` 直接返回固定内容,不 spawn。
26
+ `preflight` 在跑子进程时开启它(生产不会设这个变量)。
27
+
28
+ ### 证据
29
+ ```
30
+ 改前:node --test → 101.4 秒
31
+ 改后:DSH_SUPERAGENT_OFFLINE=1 node --test → 1.65 秒(225/225 通过)
32
+ ```
33
+
34
+ ### 顺带
35
+ README「已知限制」补一条:凭证失效时的表现与"不会自己恢复、需要重新登录"。
36
+
37
+ ## [0.9.117] - 2026-11-03 —— 真机重启后发现:时段外那条「异常」永远不会自己好
38
+
39
+ ### 现场(重启后实测)
40
+ ```
41
+ 插件版本: 0.9.116
42
+ 值守: 1 条 | 启用 | 间隔 120s | 失败 4 | 错误: gh: HTTP 304(没归类的错误…)
43
+ 上次轮询: 2026-11-02T14:30:50.655Z(5.4 小时前)
44
+ lastDeferred: 不在活跃时段(09:00-23:00),597 分钟后开始
45
+ nextAt: 2026-11-03T01:00:00.114Z(= 本地 09:00)
46
+ ```
47
+
48
+ 问题很清楚:这条守的活跃时段是 **09:00–23:00**,此刻 03:53 —— **不在时段内,不会轮询**,
49
+ 所以那条旧错误(`gh: HTTP 304`)就永远挂着,面板上的红点和「异常」计数也一直在。
50
+ 而它其实**不是"现在"的事实**:这 5 小时里根本没有请求发生过。
51
+
52
+ ### 改法
53
+ 抽出 `enterActiveHoursDefer()`,时段外进入等待时顺手清掉瞬时状态:
54
+ `lastError` / `lastErrorAt` / `consecutiveFailures` 归零(`nextAt` / `lastDeferred` 照常写)。
55
+
56
+ ### 为什么不是"面板上忽略它"
57
+ 因为 `watch_doctor`、`watch_status`、`/state` 三个出口都会读 `lastError`。
58
+ **在数据源头清掉,比在每个出口各写一遍"如果是时段外就别显示"可靠得多。**
59
+
60
+ ### 测试
61
+ 新增 1 例:进入时段外等待后,错误与失败计数都归零、`nextAt` 指向未来、`lastDeferred` 写明多久后开始。
62
+ 合计 **224 例**。
63
+
64
+ ## [0.9.116] - 2026-11-03 —— 404 不等于"不存在";顺便修掉一个"凌晨才红"的用例
65
+
66
+ ### 学到什么(出处)
67
+ GitHub《Troubleshooting the REST API》:
68
+ > If you make a request to access a private resource and your request isn't properly authenticated,
69
+ > you will receive a `404 Not Found` response. GitHub uses `404` instead of `403` **to avoid confirming
70
+ > the existence of private repositories.**
71
+
72
+ 出处:<https://docs.github.com/en/rest/using-the-rest-api/troubleshooting-the-rest-api#404-not-found-for-an-existing-resource>
73
+
74
+ 也就是说:**404 既可能是"不存在",也可能是"没权限"**,而且这两种情况的修复动作完全不同。
75
+
76
+ ### 改了什么
77
+ 1. `notfound` 的提示改写为:`(不存在或没权限 —— 私有仓库无权限也回 404:查 owner/name 与 token)`(47 字符,未超门禁 60);
78
+ 2. `repo_here` 工具失败时也走 `formatGhCall()`(与 `github` 工具一致,0.9.115 漏了它)。
79
+
80
+ ### 顺带抓到一个"凌晨才红"的用例
81
+ `顶部四个计数必须加得上总数` 里把时段写死成 `03:00-04:00`:
82
+ - 白天跑 → 该守在窗口外,计数里出现「时段外」,用例绿;
83
+ - **凌晨 3 点跑 → 该守就在窗口内**,`时段外` 这一项消失,`value('时段外')` 得到 `NaN`,用例红。
84
+
85
+ 改成 `outsideWindow()`:从当前小时 +6 开始、长度 1 小时,任何时刻都在窗口外。
86
+
87
+ ### 证据
88
+ ```
89
+ node --test → 223/223(此前凌晨跑会 221/223)
90
+ ```
91
+
5
92
  ## [0.9.115] - 2026-11-03 —— `github` 工具失败时也带「下一步」和机器可读的 kind
6
93
 
7
94
  ### 为什么
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.115-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.118-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
 
@@ -99,7 +99,8 @@ dsh plugin install /path/to/dsh-session-superagent
99
99
 
100
100
  ## 已知限制
101
101
 
102
- - 依赖 `gh` CLI 已登录;需要 GitHub 账号权限。
102
+ - 依赖 `gh` CLI 已登录;需要 GitHub 账号权限。
103
+ - 凭证失效时(例如 keyring 里的 token 过期)会显示「gh 登录失效:跑 gh auth login」;轮询会按退避重试,但**不会**自己恢复,需要你重新登录。
103
104
  - 轮询而非 webhook:延迟等于轮询间隔。
104
105
  - 一条会话可以守多个仓库(每条守独立配置间隔/过滤/时段),但**同一会话同一时刻只处理一批**:
105
106
  多仓库同时有动静时按每小时上限排队。
@@ -122,7 +123,7 @@ dsh plugin install /path/to/dsh-session-superagent
122
123
  ## 开发
123
124
 
124
125
  ```sh
125
- node --test # 223 项单测
126
+ node --test # 225 项单测
126
127
  ```
127
128
 
128
129
  ### 工具输出:文本给人和 agent,JSON 给程序
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.115'
17
+ const CLIENT_VERSION = '0.9.118'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。