dsh-session-superagent 0.8.49 → 0.8.51
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 +38 -0
- package/MAINTENANCE.md +1 -1
- package/README.md +14 -2
- package/client.js +1 -1
- package/lib/index.js +17 -4
- package/lib/watch.js +28 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
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.8.51] - 2026-11-02 —— 条件请求:没变化不计入速率限制
|
|
6
|
+
|
|
7
|
+
### 学到了什么(新知识库 `docs/kb/` 的第一条)
|
|
8
|
+
GitHub 官方最佳实践原文:*"Make authenticated conditional requests, so that unchanged data does not
|
|
9
|
+
count against your primary rate limit."*
|
|
10
|
+
出处:<https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api>
|
|
11
|
+
|
|
12
|
+
主理鱼每 N 秒拉一次 issue 列表,**大多数轮次其实什么都没变** —— 全量拉属于纯浪费,还占额度。
|
|
13
|
+
|
|
14
|
+
### 改了什么
|
|
15
|
+
- 每条 watcher 记住 `etag`;下一轮带 `-H 'If-None-Match: <etag>'`;
|
|
16
|
+
- 收到 **304** 当「本轮无变化」:不解析、不记失败、**不动退避**(退避是给失败的,304 是成功);
|
|
17
|
+
- `gh api --include` 会输出「状态行 + 头 + 空行 + 正文」,新增纯函数 `parseGhInclude` 解析,
|
|
18
|
+
用例覆盖 200 / 304 / 纯正文三种形态。
|
|
19
|
+
|
|
20
|
+
### 效果
|
|
21
|
+
没变化时:网络传输从「20 条 issue 的 JSON」降到「一个空响应」,且**不计入 rate limit**。
|
|
22
|
+
|
|
23
|
+
### 附带
|
|
24
|
+
- 新建 `docs/kb/`(入口索引 + 按主题分组),本轮第一条 `github-conditional-requests.md`;
|
|
25
|
+
- 小时级定时任务改为「先学一条 → 再改一处 → 报三段」,作为保底。
|
|
26
|
+
|
|
27
|
+
### 测试
|
|
28
|
+
- 合计 **104 例**;UI 体检 11/11。
|
|
29
|
+
|
|
30
|
+
## [0.8.50] - 2026-11-02 —— 双主题预览进「一键命令 + 门禁」
|
|
31
|
+
|
|
32
|
+
以前 `render-preview.mjs` 是个内部脚本,没人知道它存在;现在:
|
|
33
|
+
|
|
34
|
+
- `pnpm run preview:themes` → 生成 `preview-themes.html`,浏览器直接打开就能看**浅色 + 深色**两套界面;
|
|
35
|
+
- `preflight` 新增第 8 项「双主题预览可渲染」:真的跑一遍脚本,检查输出里有两套主题、≥18 块场景 ——
|
|
36
|
+
这条命令坏掉就等于失去了离线验收界面的手段,所以值得守。
|
|
37
|
+
- README 新增「验收(不用装宿主也能跑)」小节,把四条命令列出来。
|
|
38
|
+
|
|
39
|
+
### 为什么值得
|
|
40
|
+
「某个主题下颜色写死/漏 token」这类问题,单测永远是绿的;只有把两套主题都渲染出来才看得见。
|
|
41
|
+
它也是给客户看的:任何人跑一条命令就能自查界面,而不用听我一句「已经对齐了」。
|
|
42
|
+
|
|
5
43
|
## [0.8.49] - 2026-11-02 —— 故障排查表补齐最近七个真实事故
|
|
6
44
|
|
|
7
45
|
都是这轮迭代里真踩到的,写进 README 的表里,客户/未来的我看一眼能对上号:
|
package/MAINTENANCE.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## 二、当前状态(2026-11-01)
|
|
11
11
|
|
|
12
|
-
- [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test`
|
|
12
|
+
- [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test` 104/104 通过
|
|
13
13
|
- [x] 自回声抑制(逐条水位)
|
|
14
14
|
- [x] 仅空闲注入(避免草稿回放)
|
|
15
15
|
- [x] 唤醒失败不推进水位
|
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
|
|
|
@@ -99,7 +99,7 @@ dsh plugin install /path/to/dsh-session-superagent
|
|
|
99
99
|
## 开发
|
|
100
100
|
|
|
101
101
|
```sh
|
|
102
|
-
node --test #
|
|
102
|
+
node --test # 104 项单测
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
版本与发布流程见 [UPDATING.md](UPDATING.md),交付门见 [CHECKLIST.md](CHECKLIST.md),接手台账见 [MAINTENANCE.md](MAINTENANCE.md)。
|
|
@@ -133,6 +133,18 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
|
|
|
133
133
|
**本机复现不了客户的问题**:`EOF` / 超时 / 代理这类错误取决于客户的网络,本机能访问同一个仓库不代表客户能。
|
|
134
134
|
遇到这种情况,先按上面的三样收集信息,再判断是环境还是代码。
|
|
135
135
|
|
|
136
|
+
## 验收(不用装宿主也能跑)
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
node --test # 103 例单测
|
|
140
|
+
node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
|
|
141
|
+
node scripts/preflight.mjs # 8 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
|
|
142
|
+
node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`preview.html` 里每个界面都会渲染**浅色 + 深色**两遍(9 个场景 × 2),
|
|
146
|
+
用来发现「某个主题下颜色写死 / 漏 token」这类问题 —— 这类 bug 在单测里是绿的。
|
|
147
|
+
|
|
136
148
|
## 故障排查(都是真实踩过的)
|
|
137
149
|
|
|
138
150
|
| 症状 | 原因 | 处理 |
|
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.8.
|
|
17
|
+
const CLIENT_VERSION = '0.8.51'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/index.js
CHANGED
|
@@ -24,13 +24,13 @@ import { redact } from './redact.js'
|
|
|
24
24
|
import { decodeBody } from './body.js'
|
|
25
25
|
import {
|
|
26
26
|
advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
|
|
27
|
-
classifyGhError, filterReason, hasAckLabel, inActiveHours, newestUpdatedAt, nextDelayMs, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
27
|
+
classifyGhError, filterReason, hasAckLabel, parseGhInclude, inActiveHours, newestUpdatedAt, nextDelayMs, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
28
28
|
mergeFilters, mergePollResult, pruneSeen, pruneWakeTimes, pushHistory, recordReported, staleWorktrees, worktreePlan,
|
|
29
29
|
} from './watch.js'
|
|
30
30
|
|
|
31
31
|
export const name = 'dsh-session-superagent'
|
|
32
32
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
33
|
-
export const SERVER_VERSION = '0.8.
|
|
33
|
+
export const SERVER_VERSION = '0.8.51'
|
|
34
34
|
export const inject = ['tools', 'agents', 'webServer']
|
|
35
35
|
|
|
36
36
|
/** 仅供测试:读写状态文件(生产代码不要用)。 */
|
|
@@ -437,7 +437,10 @@ function wake(ctx, sessionId, text) {
|
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
async function pollOnce(ctx, entry, baseMs) {
|
|
440
|
-
|
|
440
|
+
// 条件请求:带上上次的 ETag,没变化时 GitHub 回 304,且**不计入**速率限制
|
|
441
|
+
const args = ['api', '--include', `repos/${entry.repo}/issues?state=all&sort=updated&direction=desc&per_page=20`]
|
|
442
|
+
if (entry.etag) args.push('-H', 'If-None-Match: ' + entry.etag)
|
|
443
|
+
const res = await run('gh', args, { timeoutMs: 45000, env: ghEnv() })
|
|
441
444
|
entry.lastPoll = new Date().toISOString()
|
|
442
445
|
if (res.code !== 0) {
|
|
443
446
|
const detail = redact(res.stderr).slice(0, 240)
|
|
@@ -447,8 +450,18 @@ async function pollOnce(ctx, entry, baseMs) {
|
|
|
447
450
|
bumpFailure(entry, baseMs)
|
|
448
451
|
return
|
|
449
452
|
}
|
|
453
|
+
const parsed = parseGhInclude(res.stdout)
|
|
454
|
+
if (parsed.status === 304) {
|
|
455
|
+
// 没变化:不解析、不算失败、不重置退避,只记一笔
|
|
456
|
+
entry.lastError = null
|
|
457
|
+
entry.consecutiveFailures = 0
|
|
458
|
+
entry.nextAt = null
|
|
459
|
+
entry.lastDeferred = '未变化(304,不计入速率限制)'
|
|
460
|
+
return
|
|
461
|
+
}
|
|
462
|
+
if (parsed.etag) entry.etag = parsed.etag
|
|
450
463
|
let items
|
|
451
|
-
try { items = JSON.parse(
|
|
464
|
+
try { items = JSON.parse(parsed.body) } catch { entry.lastError = 'bad json'; bumpFailure(entry, baseMs); return }
|
|
452
465
|
if (!Array.isArray(items)) { entry.lastError = 'unexpected payload'; bumpFailure(entry, baseMs); return }
|
|
453
466
|
|
|
454
467
|
entry.lastError = null
|
package/lib/watch.js
CHANGED
|
@@ -417,3 +417,31 @@ export function classifyGhError(detail) {
|
|
|
417
417
|
}
|
|
418
418
|
return { kind: 'other', short, hint: '' }
|
|
419
419
|
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* 解析 `gh api --include` 的输出:状态行 / 响应头 / 空行 / 正文。
|
|
423
|
+
*
|
|
424
|
+
* 为什么用它而不是直接 `gh api`:GitHub 官方文档明确说
|
|
425
|
+
* 「Make authenticated conditional requests, so that unchanged data does not count against
|
|
426
|
+
* your primary rate limit」—— 带上 If-None-Match 后,没变化时拿 304,
|
|
427
|
+
* 304 **不计入**速率限制。对一个每 N 秒轮询的工具,这是最直接的省额度手段。
|
|
428
|
+
*
|
|
429
|
+
* 出处:https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api
|
|
430
|
+
*/
|
|
431
|
+
export function parseGhInclude(stdout) {
|
|
432
|
+
const text = String(stdout || '')
|
|
433
|
+
const LF = String.fromCharCode(10)
|
|
434
|
+
const blank = LF + LF
|
|
435
|
+
const idx = text.indexOf(blank)
|
|
436
|
+
const head = idx < 0 ? text : text.slice(0, idx)
|
|
437
|
+
const body = idx < 0 ? text.trim() : text.slice(idx + blank.length)
|
|
438
|
+
const lines = head.split(LF)
|
|
439
|
+
// 状态行形如 `HTTP/2.0 200 OK`
|
|
440
|
+
const statusParts = String(lines[0] || '').split(' ')
|
|
441
|
+
const status = Number(statusParts[1]) || 0
|
|
442
|
+
let etag = null
|
|
443
|
+
for (const line of lines) {
|
|
444
|
+
if (line.toLowerCase().startsWith('etag:')) etag = line.slice(5).trim()
|
|
445
|
+
}
|
|
446
|
+
return { status, etag, body }
|
|
447
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.51",
|
|
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",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"sync:profile:check": "node scripts/sync-profile.mjs --check",
|
|
36
36
|
"sync:profile:repair": "node scripts/sync-profile.mjs --repair",
|
|
37
37
|
"preview": "node scripts/render-preview.mjs",
|
|
38
|
-
"preflight": "node scripts/preflight.mjs"
|
|
38
|
+
"preflight": "node scripts/preflight.mjs",
|
|
39
|
+
"preview:themes": "node scripts/render-preview.mjs preview-themes.html"
|
|
39
40
|
},
|
|
40
41
|
"keywords": [
|
|
41
42
|
"dsh",
|