dsh-session-superagent 0.9.214 → 0.9.216
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 +77 -0
- package/README.md +2 -2
- package/client.js +38 -6
- package/lib/gh-format.js +12 -0
- package/lib/index.js +5 -9
- package/lib/watch.js +13 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,83 @@
|
|
|
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.216] - 2026-11-05 —— 面板死交互审计:改了标签/优先级,弹「已保存」,其实一个字节都没发
|
|
6
|
+
|
|
7
|
+
### ① M1 · 这是我在 0.9.203 引入的回归
|
|
8
|
+
|
|
9
|
+
那一版为了修 lost update,把保存改成「只发改过的字段」,用 `touchedRef` 过滤。
|
|
10
|
+
但 `touchedRef` 收的是**控件名**(`labels` / `onlyAssigned` / `priorityReopened`…),
|
|
11
|
+
而 body 的键是**字段名**(`filters` / `priority`)—— **两套名字对不上**,于是:
|
|
12
|
+
|
|
13
|
+
> 改「只处理这些标签」「只看已指派」或五个优先级开关 → 点保存 → 弹出「已保存:owner/name」→
|
|
14
|
+
> 编辑器收起 → 再展开,**全部弹回原样**。
|
|
15
|
+
|
|
16
|
+
同一屏的「间隔」「目标/规则」「仅观察」却正常(它们的控件名恰好等于字段名),
|
|
17
|
+
所以客户会以为「就是这几个开关坏了」。
|
|
18
|
+
|
|
19
|
+
已加显式映射 `CONTROL_TO_FIELD`。连带结论:`priority` 五项此前**没有任何可达的写入口**(新增表单也没有)。
|
|
20
|
+
|
|
21
|
+
### ② M2 · `setDeferFilter` 根本没定义
|
|
22
|
+
|
|
23
|
+
筛选胶囊的 ✕ 与「全部清除」都调它,而组件里叫 `setReasonFilter` —— 两处 `onClick` 直接抛
|
|
24
|
+
`ReferenceError`:点 ✕ 毫无反应,「全部清除」也清不掉这一条。
|
|
25
|
+
|
|
26
|
+
### ③ M3 · 只改 token 会静默解绑 gh 账号目录
|
|
27
|
+
|
|
28
|
+
`ghDir` 初值恒为空串且从不回填服务端值,于是保存时无条件下发 `ghConfigDir: ""`,
|
|
29
|
+
服务端当「显式清空」,**已绑定的 gh 账号目录被解绑** —— 评论改回宿主账号,客户不知道为什么。
|
|
30
|
+
|
|
31
|
+
现在只有**填了东西**才发;要解绑有单独的「解绑 gh 账号目录」按钮。
|
|
32
|
+
|
|
33
|
+
### ④ M4 · 「看建议规则」按钮永不渲染
|
|
34
|
+
|
|
35
|
+
`item.action` 构造了却没人消费,而 `AGENTS.md` 建议弹层的唯一入口就是它。
|
|
36
|
+
|
|
37
|
+
### 证据
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
node --test → 368/368(新增 3 条:映射存在 / 无未定义 setter / action 被渲染)
|
|
41
|
+
ui-audit → 11/11(100 分)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## [0.9.215] - 2026-11-05 —— 把「测试在自己算」的两个函数抽出来,断言才真的在断言
|
|
45
|
+
|
|
46
|
+
### ① `effectiveIntervalMs` 从 `index.js` 挪到 `watch.js`
|
|
47
|
+
|
|
48
|
+
T23 指出 `routes.test.mjs` 那条断言其实在**算测试自己的 `Math.max`** —— `effectiveIntervalMs()` 一次没被调用。
|
|
49
|
+
写反、写成 `Math.min`、忘了乘 1000(60 毫秒轮询 = 疯转),测试全都绿。
|
|
50
|
+
|
|
51
|
+
它是纯函数,挪进 `watch.js` 之后可以直接 import:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
effectiveIntervalMs({ minIntervalSec: 120 }, 60000) === 120000 ← 乘了 1000
|
|
55
|
+
effectiveIntervalMs({ minIntervalSec: 10 }, 300000) === 300000 ← 自己更大时用自己的
|
|
56
|
+
effectiveIntervalMs({ minIntervalSec: 'abc' }, 60000) === 60000 ← 坏值不产出 NaN
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### ② `isOfflineMode()` 从 `run()` 闭包里抽出来
|
|
60
|
+
|
|
61
|
+
`route-resilience.test.mjs` 那条叫「设了 OFFLINE 就不再调 gh」的用例,
|
|
62
|
+
**实际只测了两个跟离线无关的纯函数** —— 删掉短路照样绿。
|
|
63
|
+
|
|
64
|
+
现在离线判定是纯函数,真值表可以真断言 —— 尤其是 `'0'` / `'false'` 不该被当成离线这个坑:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
'1' / 'true' / ' ON ' → true
|
|
68
|
+
'0' / 'false' / 未设 → false
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### ③ 为什么值得单独立一条
|
|
72
|
+
|
|
73
|
+
这两条都属于同一类:**测试通过「重算一遍」来假装验证实现**。
|
|
74
|
+
它比没有测试更糟 —— 看覆盖率是绿的,看代码是真没测。
|
|
75
|
+
|
|
76
|
+
### 证据
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
node --test → 365/365(新增:effectiveIntervalMs 真实用法 6 组断言)
|
|
80
|
+
```
|
|
81
|
+
|
|
5
82
|
## [0.9.214] - 2026-11-05 —— 覆盖率高 ≠ 测试有效:5 条「其实测不出东西」的断言
|
|
6
83
|
|
|
7
84
|
### ① 先说结论
|
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
|
[](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
|
|
@@ -145,7 +145,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
|
|
|
145
145
|
## 开发
|
|
146
146
|
|
|
147
147
|
```sh
|
|
148
|
-
node --test #
|
|
148
|
+
node --test # 368 项单测
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
### 工具输出:文本给人和 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.216'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
|
@@ -1118,8 +1118,24 @@ window.__ModuleLoader__.load({
|
|
|
1118
1118
|
maxWakesPerHour: Number(draft.maxWakesPerHour) || undefined,
|
|
1119
1119
|
sessionMaxWakes: Number(draft.sessionMaxWakes) || undefined,
|
|
1120
1120
|
}
|
|
1121
|
-
|
|
1121
|
+
// 审核 T24 M1:touchedRef 里是**控件名**(labels / onlyAssigned / priorityReopened…),
|
|
1122
|
+
// 而 full 的键是**字段名**(filters / priority)—— 两套名字对不上,这几个控件就永远发不出去,
|
|
1123
|
+
// 而 Toast 照样说「已保存」。这里显式做一次「控件名 → 字段名」的映射。
|
|
1124
|
+
const CONTROL_TO_FIELD = {
|
|
1125
|
+
labels: "filters",
|
|
1126
|
+
onlyAssigned: "filters",
|
|
1127
|
+
priorityReopened: "priority",
|
|
1128
|
+
priorityComments: "priority",
|
|
1129
|
+
priorityLabels: "priority",
|
|
1130
|
+
priorityUnassigned: "priority",
|
|
1131
|
+
priorityStale: "priority",
|
|
1132
|
+
}
|
|
1133
|
+
const wanted = new Set()
|
|
1122
1134
|
for (const key of touchedRef.current) {
|
|
1135
|
+
wanted.add(CONTROL_TO_FIELD[key] || key)
|
|
1136
|
+
}
|
|
1137
|
+
const out = { repo: full.repo, sessionId: full.sessionId }
|
|
1138
|
+
for (const key of wanted) {
|
|
1123
1139
|
if (Object.prototype.hasOwnProperty.call(full, key)) out[key] = full[key]
|
|
1124
1140
|
}
|
|
1125
1141
|
return out
|
|
@@ -1172,14 +1188,22 @@ window.__ModuleLoader__.load({
|
|
|
1172
1188
|
const payload = {}
|
|
1173
1189
|
if (token.trim()) payload.token = token.trim()
|
|
1174
1190
|
if (giteeToken.trim()) payload.giteeToken = giteeToken.trim()
|
|
1191
|
+
// 审核 T24 M3:这里以前无条件带 "ghConfigDir" —— ghDir 初值恒为空串且从不回填服务端值,
|
|
1192
|
+
// 于是「只改 token」也会发 ghConfigDir:"",服务端把它当「显式清空」,
|
|
1193
|
+
// 已绑定的 gh 账号目录被静默解绑(评论改回宿主账号)。
|
|
1194
|
+
// 现在只有**填了东西**才发;要解绑请用旁边的「清除」按钮(它显式发空串)。
|
|
1175
1195
|
if (ghDir.trim()) payload.ghConfigDir = ghDir.trim()
|
|
1176
|
-
else if (ghDir === '') payload.ghConfigDir = '' // 显式清空 = 回到宿主账号
|
|
1177
1196
|
await call('/credentials', { method: 'POST', body: JSON.stringify(payload) })
|
|
1178
1197
|
setToken('')
|
|
1179
1198
|
setGhDir('')
|
|
1180
1199
|
setGiteeToken('')
|
|
1181
1200
|
}, '凭证已保存')
|
|
1182
1201
|
|
|
1202
|
+
/** 显式解绑 gh 账号目录(T24 M3:不能在「只改 token」时顺带清掉)。 */
|
|
1203
|
+
const clearGhDir = () => run(async () => {
|
|
1204
|
+
await call('/credentials', { method: 'POST', body: JSON.stringify({ ghConfigDir: '' }) })
|
|
1205
|
+
}, '已解绑 gh 账号目录(评论改回宿主账号)')
|
|
1206
|
+
|
|
1183
1207
|
const saveGoal = () => run(async () => {
|
|
1184
1208
|
await call('/goal', { method: 'POST', body: JSON.stringify({ sessionId, objective: goalDraft }) })
|
|
1185
1209
|
setGoalTouched(false)
|
|
@@ -1467,7 +1491,7 @@ window.__ModuleLoader__.load({
|
|
|
1467
1491
|
if (stateFilter) chips.push({ label: STATE_TEXT[stateFilter], clear: () => setStateFilter(null) })
|
|
1468
1492
|
if (needle) chips.push({ label: '搜索「' + needle + '」', clear: () => setSearch('') })
|
|
1469
1493
|
if (problemsOnly) chips.push({ label: '有问题', clear: () => setProblemsOnly(false) })
|
|
1470
|
-
if (deferFilter) chips.push({ label: '暂停原因「' + (DEFER_LABELS[deferFilter] || deferFilter) + '」', clear: () =>
|
|
1494
|
+
if (deferFilter) chips.push({ label: '暂停原因「' + (DEFER_LABELS[deferFilter] || deferFilter) + '」', clear: () => setReasonFilter(null) })
|
|
1471
1495
|
if (chips.length === 0) return null
|
|
1472
1496
|
return h('div', { className: 'dt-row-meta', key: 'filter-summary' },
|
|
1473
1497
|
(() => {
|
|
@@ -1481,7 +1505,7 @@ window.__ModuleLoader__.load({
|
|
|
1481
1505
|
chips.length > 1
|
|
1482
1506
|
? h(Pill, {
|
|
1483
1507
|
key: '__all', onClick: () => {
|
|
1484
|
-
setBadgeFilter(null); setStateFilter(null); setSearch(''); setProblemsOnly(false);
|
|
1508
|
+
setBadgeFilter(null); setStateFilter(null); setSearch(''); setProblemsOnly(false); setReasonFilter(null)
|
|
1485
1509
|
},
|
|
1486
1510
|
}, '全部清除')
|
|
1487
1511
|
: null)
|
|
@@ -1521,7 +1545,11 @@ window.__ModuleLoader__.load({
|
|
|
1521
1545
|
// 排序:会丢消息的(失败/没回音)排前面;静态提示(仓库归档、只读)排后面
|
|
1522
1546
|
(() => { problems.sort((a, b) => ((a.rank ?? 9) - (b.rank ?? 9)) || String(a.text).localeCompare(String(b.text))); return problems.length > 0 })()
|
|
1523
1547
|
? h(Section, { key: 'problems', title: '需要关注', count: problems.length },
|
|
1524
|
-
|
|
1548
|
+
// 审核 T24 M4:以前只渲染 item.text,构造好的 item.action(「看建议规则」)没人消费 ——
|
|
1549
|
+
// 于是那个按钮永不出现,而 AGENTS.md 建议弹层唯一的入口就是它。
|
|
1550
|
+
h('ul', { className: 'dt-plain-list' }, problems.map((item) => h('li', { key: item.key, className: 'dt-danger' },
|
|
1551
|
+
item.text,
|
|
1552
|
+
item.action ? h(Btn, { variant: 'link', size: 'sm', 'aria-label': item.action.label, onClick: item.action.onClick }, item.action.label) : null))))
|
|
1525
1553
|
: null,
|
|
1526
1554
|
// 中间态:已经有守、但一次都没唤醒过 —— 这不是"没配置",是"在等"
|
|
1527
1555
|
(watchers.length > 0 && watchers.every((w) => !w.lastWake))
|
|
@@ -1802,6 +1830,10 @@ window.__ModuleLoader__.load({
|
|
|
1802
1830
|
field('Token', h(Input, { type: 'password', value: token, placeholder: 'ghp_… / github_pat_…(留空不改)', onChange: (e) => setToken(e.target.value) })),
|
|
1803
1831
|
field('Gitee 令牌', h(Input, { type: 'password', value: giteeToken, placeholder: '私人令牌(留空不改);只盯 GitHub 可以不管' , onChange: (e) => setGiteeToken(e.target.value) })),
|
|
1804
1832
|
field('gh 账号目录', h(Input, { value: ghDir, placeholder: '绝对路径(留空 = 用宿主账号)', onChange: (e) => setGhDir(e.target.value) })),
|
|
1833
|
+
// 解绑要**显式**:以前只改 token 时会顺带把已绑定的目录清掉,客户不知道评论为什么换回了宿主账号。
|
|
1834
|
+
credentials.ghConfigDir === 'configured'
|
|
1835
|
+
? h('div', { className: 'dt-actions' }, h(Btn, { variant: 'ghost', size: 'sm', onClick: clearGhDir }, '解绑 gh 账号目录'))
|
|
1836
|
+
: null,
|
|
1805
1837
|
h('div', { className: 'dt-actions' }, h(Btn, { variant: 'primary', onClick: saveCredentials }, '保存凭证')),
|
|
1806
1838
|
h(Hint, null, '不填也能用:插件直接复用已登录的 gh CLI。填了 gh 账号目录,插件就用那个目录里的账号发言(git push 仍用会话自己的身份,唤醒消息里会提醒会话)。')),
|
|
1807
1839
|
h(Section, { key: 'update', title: '版本与更新' },
|
package/lib/gh-format.js
CHANGED
|
@@ -596,3 +596,15 @@ export function quotaDeferText(remaining, resumeInMs, now = Date.now()) {
|
|
|
596
596
|
text: '额度紧张(剩余 ' + String(remaining) + '),已推迟到 ' + hhmm + ' UTC',
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* 离线模式判定(`DSH_SUPERAGENT_OFFLINE`)。
|
|
602
|
+
*
|
|
603
|
+
* 审核 T23:以前这条判断是内联的 `process.env.DSH_SUPERAGENT_OFFLINE === '1'`,
|
|
604
|
+
* 藏在 `lib/index.js` 的 `run()` 闭包里 —— 测试只能「跑整套用例看快不快」来间接证明。
|
|
605
|
+
* 抽成纯函数后可以真的断言它的真值表(尤其是 `'0'` / `'false'` 不该被当成离线)。
|
|
606
|
+
*/
|
|
607
|
+
export function isOfflineMode(env = process.env) {
|
|
608
|
+
const raw = String((env && env.DSH_SUPERAGENT_OFFLINE) || '').trim().toLowerCase()
|
|
609
|
+
return raw === '1' || raw === 'true' || raw === 'yes' || raw === 'on'
|
|
610
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -23,10 +23,10 @@ import { zstdDecompressSync } from 'node:zlib'
|
|
|
23
23
|
|
|
24
24
|
import { redact } from './redact.js'
|
|
25
25
|
import { decodeBody, truncateUtf8 } from './body.js'
|
|
26
|
-
import { quotaDeferText } from './gh-format.js'
|
|
26
|
+
import { quotaDeferText, isOfflineMode } from './gh-format.js'
|
|
27
27
|
import { listGiteeItems, fetchGiteeLastComment, addGiteeLabel, ensureGiteeLabel, giteeWhoami, giteeRepo, mapGiteeRepoAccess, DEFAULT_ACK_LABEL_GITEE, giteeLabels, giteeHasLabel, isValidGiteeLabel, suggestGiteeLabel } from './gitee.js'
|
|
28
28
|
import {
|
|
29
|
-
planWakeSettlement, advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
|
|
29
|
+
effectiveIntervalMs, planWakeSettlement, advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
|
|
30
30
|
parseRepoSpec, markGiteeReopened,
|
|
31
31
|
TRIAGE_SIGNALS, accessNote, wakeCriteria, sessionMissingVerdict, buildCommentBatchQuery, classifyGhError, commentSummaryLine, parseCommentBatch, pickSuggestion, repoStructureNote, countReasons, filterReason, formatGhCall, diagnoseEmptyBody, diagnoseBadBody, isAuthBroken, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, enterActiveHoursDefer, recordOtherError, permanentBackoffMs, RETRY_BUDGET_ATTEMPTS, RETRY_SLOW_CAP_MINUTES, pushAbsorbed, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
32
32
|
shouldRunCleanup,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
|
|
44
44
|
export const name = 'dsh-session-superagent'
|
|
45
45
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
46
|
-
export const SERVER_VERSION = '0.9.
|
|
46
|
+
export const SERVER_VERSION = '0.9.216'
|
|
47
47
|
export const inject = ['tools', 'agents', 'webServer']
|
|
48
48
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
49
49
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
@@ -478,11 +478,6 @@ function noteEvent(entry, kind, text) {
|
|
|
478
478
|
} catch { /* 观测失败不能影响主流程 */ }
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
-
// 实际间隔:自己的配置与 GitHub 要求的 x-poll-interval 取大者
|
|
482
|
-
function effectiveIntervalMs(entry, baseMs) {
|
|
483
|
-
const floor = (Number(entry.minIntervalSec) || 0) * 1000
|
|
484
|
-
return Math.max(Number(baseMs) || 0, floor)
|
|
485
|
-
}
|
|
486
481
|
|
|
487
482
|
function bumpFailure(entry, baseMs) {
|
|
488
483
|
entry.consecutiveFailures = (Number(entry.consecutiveFailures) || 0) + 1
|
|
@@ -613,7 +608,8 @@ function run(file, args, options = {}) {
|
|
|
613
608
|
return
|
|
614
609
|
}
|
|
615
610
|
}
|
|
616
|
-
|
|
611
|
+
// 离线判定抽成纯函数(有单测),见 isOfflineMode。
|
|
612
|
+
if (file === 'gh' && isOfflineMode()) {
|
|
617
613
|
resolve({ code: 0, stdout: offlineGhReply(args), stderr: '' })
|
|
618
614
|
return
|
|
619
615
|
}
|
package/lib/watch.js
CHANGED
|
@@ -1244,3 +1244,16 @@ export function planWakeSettlement(entry, { ok, reason, fresh = [], firstSync =
|
|
|
1244
1244
|
error: null,
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* 实际轮询间隔:自己的配置与 GitHub 要求的 `x-poll-interval` 取**大者**。
|
|
1250
|
+
*
|
|
1251
|
+
* 审核 T23:这个函数以前在 `lib/index.js` 里(不导出),于是测试只能自己算一遍
|
|
1252
|
+
* `Math.max(base, minIntervalSec * 1000)` —— **断言的是测试自己的算术**,
|
|
1253
|
+
* `Math.max` 写反、写成 `Math.min`、或者忘了乘 1000,测试全都绿。
|
|
1254
|
+
* 挪到这里(纯函数、可直接 import)之后,才能真正测它。
|
|
1255
|
+
*/
|
|
1256
|
+
export function effectiveIntervalMs(entry, baseMs) {
|
|
1257
|
+
const floor = (Number(entry && entry.minIntervalSec) || 0) * 1000
|
|
1258
|
+
return Math.max(Number(baseMs) || 0, floor)
|
|
1259
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.216",
|
|
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",
|