dsh-session-superagent 0.9.166 → 0.9.167
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 +39 -0
- package/README.md +2 -2
- package/client.js +15 -3
- package/lib/gh-format.js +14 -3
- package/lib/index.js +1 -1
- package/package.json +1 -1
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.167] - 2026-11-04 —— 合入两位外部贡献者的修复(gh 头体切分 / 首帧 304 锁死)
|
|
6
|
+
|
|
7
|
+
> 两个 PR 都来自 **@Betsy20**(first-time contributor)。我逐条复现、核对根因后合入,
|
|
8
|
+
> 并按本仓库的版本节奏重新编号(PR 里写的是 0.9.166 / 0.9.167,而 0.9.166 已被占用)。
|
|
9
|
+
|
|
10
|
+
### PR #2 · `parseGhInclude` 头体分隔只认 LF
|
|
11
|
+
- **现象**:面板持续报「(返回内容不是合法 JSON:可能是代理干扰)」;
|
|
12
|
+
- **根因**:真机 `gh api --include` 是**状态行 LF + 响应头 CRLF**,头体之间是 `
|
|
13
|
+
|
|
14
|
+
`,
|
|
15
|
+
而代码只找 `
|
|
16
|
+
|
|
17
|
+
` → 找不到 → 把「状态行 + 全部响应头 + JSON」整段当 body → 必然解析失败;
|
|
18
|
+
- **我的复现**:
|
|
19
|
+
```
|
|
20
|
+
旧:status=200,body="HTTP/2.0 200 OK
|
|
21
|
+
content-type: application/json
|
|
22
|
+
…"
|
|
23
|
+
JSON.parse → Unexpected token 'H'
|
|
24
|
+
新:status=200,body="{\"total_count\":1,…}" → JSON.parse OK
|
|
25
|
+
```
|
|
26
|
+
- **改法**:两种分隔符都认,取最先出现的那个(`lib/gh-format.js`)。
|
|
27
|
+
|
|
28
|
+
### PR #3 · 首帧 304 把面板锁在「正在读取」
|
|
29
|
+
- **现象**:状态栏写着「1 / 2 主理中」,点开面板却是 0 条 + 空态 + 正在读取,点刷新也没用;
|
|
30
|
+
- **根因**:`stateEtag` 是**模块级**变量 —— 状态栏圆环每 5 秒全量拉 `/state` 会刷新它,
|
|
31
|
+
面板首次挂载带着这个 etag 去问 → 必回 304 → 旧代码 `return null` 从不 `setSnap` → 永久 loading;
|
|
32
|
+
- **改法**:304 时若本地**没有**可渲染的 body,就清掉 etag 重取一次全量;
|
|
33
|
+
- **我对 PR 的一处修正**:原实现用 `hasBodyRef` 在成功后置位("以前拿到过"),
|
|
34
|
+
组件重新挂载后它仍是 true,首帧 304 又会被锁死。改成**每次渲染按当前 `snap.body` 同步** ——
|
|
35
|
+
判断依据是"我现在有没有数据",而不是"我曾经有没有"。
|
|
36
|
+
|
|
37
|
+
### 证据(本地复跑)
|
|
38
|
+
```
|
|
39
|
+
node --test → 266/266(含两位作者各自新增的用例)
|
|
40
|
+
parseGhInclude 复现脚本:CRLF 混合行尾 → body 为纯 JSON,JSON.parse OK
|
|
41
|
+
304 探针:3 次调用(无 etag→200 / etag→304 / 清 etag→200),返回 2 条 watcher
|
|
42
|
+
```
|
|
43
|
+
|
|
5
44
|
## [0.9.166] - 2026-11-04 —— 弹层副行「76 秒前前」:一个重复后缀
|
|
6
45
|
|
|
7
46
|
### 怎么发现的
|
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)
|
|
6
|
-
[](https://github.com/MYCF711/dsh-session-superagent/releases)
|
|
7
7
|
[](https://www.npmjs.com/package/dsh-session-superagent)
|
|
8
8
|
[](https://github.com/topics/dsh-plugin)
|
|
9
9
|
|
|
@@ -123,7 +123,7 @@ dsh plugin install /path/to/dsh-session-superagent
|
|
|
123
123
|
## 开发
|
|
124
124
|
|
|
125
125
|
```sh
|
|
126
|
-
node --test #
|
|
126
|
+
node --test # 266 项单测
|
|
127
127
|
```
|
|
128
128
|
|
|
129
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.
|
|
17
|
+
const CLIENT_VERSION = '0.9.167'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
|
@@ -990,11 +990,23 @@ window.__ModuleLoader__.load({
|
|
|
990
990
|
const [stateFilter, setStateFilter] = useState(null)
|
|
991
991
|
// 建议规则弹层:给"叫醒了没回音"一个下一步动作(只提供可复制的规则,不替客户写仓库文件)
|
|
992
992
|
|
|
993
|
+
// 「我现在手上有没有能渲染的数据」。判断依据必须是**当前 snap**,不是"以前拿到过一次" ——
|
|
994
|
+
// 状态栏圆环每 5 秒全量拉一次 /state 并刷新模块级 stateEtag;面板首次挂载时正好带着这个
|
|
995
|
+
// etag 去问,首帧必然 304。旧代码在 304 分支直接 return、从不 setSnap,于是面板永远停在
|
|
996
|
+
// {loading:true, body:null}:统计条全 0、列表空态、底下还挂着「正在读取…」(真机现象:2 条显示 0 条)。
|
|
997
|
+
const hasBodyRef = useRef(false)
|
|
998
|
+
hasBodyRef.current = Boolean(snap.body)
|
|
999
|
+
|
|
993
1000
|
const load = useCallback(async () => {
|
|
994
1001
|
try {
|
|
995
1002
|
const payload = await call('/state', stateEtag ? { headers: { 'if-none-match': stateEtag } } : undefined)
|
|
996
|
-
// 304:内容没变,别白白重渲染
|
|
997
|
-
if (payload && payload.notModified)
|
|
1003
|
+
// 304:内容没变,别白白重渲染 —— 前提是本地已经有一份能渲染的 body
|
|
1004
|
+
if (payload && payload.notModified) {
|
|
1005
|
+
if (hasBodyRef.current) return null
|
|
1006
|
+
// 本地没有数据:这次 304 是被状态栏的 etag 带出来的,清掉 etag 重取一次全量
|
|
1007
|
+
stateEtag = null
|
|
1008
|
+
return load()
|
|
1009
|
+
}
|
|
998
1010
|
const body = payload
|
|
999
1011
|
setSnap({ loading: false, error: null, body })
|
|
1000
1012
|
return body
|
package/lib/gh-format.js
CHANGED
|
@@ -127,10 +127,21 @@ export function classifyGhError(detail) {
|
|
|
127
127
|
export function parseGhInclude(stdout) {
|
|
128
128
|
const text = String(stdout || '')
|
|
129
129
|
const LF = String.fromCharCode(10)
|
|
130
|
-
const
|
|
131
|
-
|
|
130
|
+
const CR = String.fromCharCode(13)
|
|
131
|
+
// 头/体之间那个空行可能是 "\n\n",也可能是 "\r\n\r\n" —— 取决于 gh 吐响应头时用的行尾。
|
|
132
|
+
// 真机实测(gh 2.103.3 / Windows):状态行以 LF 结尾、响应头以 CRLF 结尾,分隔处因此是
|
|
133
|
+
// "\r\n\r\n",而它里面**没有**连续两个 LF。只找 "\n\n" 会返回 -1,于是把整段输出
|
|
134
|
+
// (状态行 + 响应头 + 正文)当成 body 丢给 JSON.parse,每次都失败 ——
|
|
135
|
+
// 面板显示「(返回内容不是合法 JSON:可能是代理干扰)」,把人往代理上带。
|
|
136
|
+
// 两种分隔符都认,取最先出现的那个。
|
|
137
|
+
let idx = -1
|
|
138
|
+
let sepLen = 0
|
|
139
|
+
for (const sep of [CR + LF + CR + LF, LF + LF]) {
|
|
140
|
+
const at = text.indexOf(sep)
|
|
141
|
+
if (at >= 0 && (idx < 0 || at < idx)) { idx = at; sepLen = sep.length }
|
|
142
|
+
}
|
|
132
143
|
const head = idx < 0 ? text : text.slice(0, idx)
|
|
133
|
-
const body = idx < 0 ? text.trim() : text.slice(idx +
|
|
144
|
+
const body = idx < 0 ? text.trim() : text.slice(idx + sepLen)
|
|
134
145
|
const lines = head.split(LF)
|
|
135
146
|
const statusParts = String(lines[0] || '').split(' ')
|
|
136
147
|
const status = Number(statusParts[1]) || 0
|
package/lib/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
|
|
41
41
|
export const name = 'dsh-session-superagent'
|
|
42
42
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
43
|
-
export const SERVER_VERSION = '0.9.
|
|
43
|
+
export const SERVER_VERSION = '0.9.167'
|
|
44
44
|
export const inject = ['tools', 'agents', 'webServer']
|
|
45
45
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
46
46
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.167",
|
|
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",
|