dsh-session-superagent 0.9.76 → 0.9.78
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 +35 -0
- package/README.md +2 -2
- package/client.js +1 -1
- package/lib/index.js +24 -3
- package/lib/watch.js +16 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,41 @@
|
|
|
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.78] - 2026-11-02 —— trace 能指名"被冷却期吸收",不再三合一猜
|
|
6
|
+
|
|
7
|
+
### 为什么改
|
|
8
|
+
客户问「这条为什么没叫醒我」,`watch_trace` 原来给的是:
|
|
9
|
+
```
|
|
10
|
+
已记入水位但没唤醒(被吸收/仅观察/或上报前就已存在)
|
|
11
|
+
```
|
|
12
|
+
**三种可能糊在一起** —— 等于没说。根因是"被吸收"这件事从来没被记下来。
|
|
13
|
+
|
|
14
|
+
### 改法
|
|
15
|
+
1. `pushAbsorbed()`:吸收时写一条有界日志(`{at, number, title}`,最多 50 条);
|
|
16
|
+
2. `itemTrace` 读它,结论改成 `被冷却期吸收了(<时间>)—— 那一批刚唤醒过,等下一轮`;
|
|
17
|
+
3. 文本列 `被冷却期吸收:<时间>`;JSON 的 `results[]` 多了 `absorbed` 字段;
|
|
18
|
+
4. `contract-stability.json` 登记 `absorbed: stable` —— **新增字段必须登记这条规矩当场生效**(用例先红了一次)。
|
|
19
|
+
|
|
20
|
+
### 测试
|
|
21
|
+
- 新增 1 例:造吸收记录 → 结论必须含「被冷却期吸收」、不得出现三合一说法、JSON 有明细。合计 **195 例**。
|
|
22
|
+
|
|
23
|
+
## [0.9.77] - 2026-11-02 —— doctor 补两项:定时器丢了、隔离目录不可写
|
|
24
|
+
|
|
25
|
+
### 为什么要补
|
|
26
|
+
`watch_doctor` 原来只检查:版本、挂载、gh 登录、仓库可访问、ack 标签、隔离目录**是否存在**。
|
|
27
|
+
两类真实故障它看不见:
|
|
28
|
+
|
|
29
|
+
1. **定时器丢了**:进程被挂起、`setInterval` 被清掉后,`lastPoll` 会一直是几小时前,
|
|
30
|
+
但面板上一切显示"运行中、正常";
|
|
31
|
+
2. **隔离目录存在但不可写**:权限/磁盘问题下,第一次唤醒建 worktree 就会失败。
|
|
32
|
+
|
|
33
|
+
### 改法
|
|
34
|
+
- 停滞:`age > max(3×interval, 5min)` 时报 `WARN … 已经 N 分钟没轮询过`;
|
|
35
|
+
- 可写:在 `workdir` 里写一个探针文件再删,失败报 `FAIL 隔离工作目录不可写(EPERM/EACCES/ENOSPC)`。
|
|
36
|
+
|
|
37
|
+
### 测试
|
|
38
|
+
- 新增 1 例:造一个 2 小时没轮询的守,`watch_doctor` 输出必须包含「没轮询过」。合计 **194 例**。
|
|
39
|
+
|
|
5
40
|
## [0.9.76] - 2026-11-02 —— 只有一条变化时,不再解释"为什么是这几条"
|
|
6
41
|
|
|
7
42
|
### 为什么改
|
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
|
|
|
@@ -121,7 +121,7 @@ dsh plugin install /path/to/dsh-session-superagent
|
|
|
121
121
|
## 开发
|
|
122
122
|
|
|
123
123
|
```sh
|
|
124
|
-
node --test #
|
|
124
|
+
node --test # 195 项单测
|
|
125
125
|
```
|
|
126
126
|
|
|
127
127
|
### 工具输出:文本给人和 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.78'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import { redact } from './redact.js'
|
|
|
25
25
|
import { decodeBody } from './body.js'
|
|
26
26
|
import {
|
|
27
27
|
advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
|
|
28
|
-
TRIAGE_SIGNALS, accessNote, buildCommentBatchQuery, classifyGhError, commentSummaryLine, parseCommentBatch, pickSuggestion, repoStructureNote, countReasons, filterReason, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
28
|
+
TRIAGE_SIGNALS, accessNote, buildCommentBatchQuery, classifyGhError, commentSummaryLine, parseCommentBatch, pickSuggestion, repoStructureNote, countReasons, filterReason, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, pushAbsorbed, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
29
29
|
shouldRunCleanup,
|
|
30
30
|
bumpDailyWakes,
|
|
31
31
|
busierThanUsual,
|
|
@@ -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.78'
|
|
44
44
|
export const inject = ['tools', 'agents', 'webServer']
|
|
45
45
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
46
46
|
const DEFAULT_SESSION_WAKES = 12
|
|
@@ -921,6 +921,8 @@ async function pollOnce(ctx, entry, baseMs) {
|
|
|
921
921
|
if (absorbed.length > 0) {
|
|
922
922
|
entry.seen = advanceSeen(entry.seen, absorbed)
|
|
923
923
|
entry.lastAbsorbed = absorbed.length
|
|
924
|
+
// 记下来才能回答「这条为什么没叫醒我」—— 以前只能说「被吸收/仅观察/或早就有」三合一
|
|
925
|
+
entry.absorbedLog = pushAbsorbed(entry.absorbedLog, absorbed, entry.lastPoll)
|
|
924
926
|
const newestAbsorbed = newestUpdatedAt(absorbed)
|
|
925
927
|
if (!entry.cursor || Date.parse(newestAbsorbed) > Date.parse(entry.cursor)) entry.cursor = newestAbsorbed
|
|
926
928
|
}
|
|
@@ -1793,6 +1795,7 @@ export function apply(ctx) {
|
|
|
1793
1795
|
if (trace.seen) lines.push(' 水位 seen:' + trace.seen)
|
|
1794
1796
|
if (trace.reported) lines.push(' 上次上报:' + trace.reported)
|
|
1795
1797
|
for (const item of trace.filtered) lines.push(' 被过滤(' + item.reason + '):' + item.at)
|
|
1798
|
+
for (const item of trace.absorbed || []) lines.push(' 被冷却期吸收:' + item.at)
|
|
1796
1799
|
for (const item of trace.wakes) lines.push(' 唤醒尝试:' + item.at + ' ' + (item.ok ? '成功' : '失败(' + (item.reason || '未知') + ')'))
|
|
1797
1800
|
}
|
|
1798
1801
|
if (args && args.format === 'json') {
|
|
@@ -1886,10 +1889,28 @@ export function apply(ctx) {
|
|
|
1886
1889
|
else {
|
|
1887
1890
|
const gitRes = await run('git', ['-C', wd, 'rev-parse', '--is-inside-work-tree'], { timeoutMs: 15000 })
|
|
1888
1891
|
lines.push(`${gitRes.code === 0 ? 'OK ' : 'FAIL'} 隔离工作目录 ${wd}:${gitRes.code === 0 ? '是 git 仓库' : '不是 git 仓库'}`)
|
|
1892
|
+
// 目录在但不可写时,第一次唤醒建 worktree 就会失败(真机上更常见的是权限/磁盘)
|
|
1893
|
+
const probe = join(wd, '.dsh-doctor-probe')
|
|
1894
|
+
try {
|
|
1895
|
+
writeFileSync(probe, String(Date.now()))
|
|
1896
|
+
rmSync(probe, { force: true })
|
|
1897
|
+
} catch (error) {
|
|
1898
|
+
lines.push(`FAIL 隔离工作目录不可写:${wd}(${String((error && error.code) || error).slice(0, 40)})`)
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
// 5. 轮询停滞:定时器丢了或进程被挂起时,面板上一切「正常」,其实早就不看了
|
|
1904
|
+
if (entry.enabled !== false && entry.lastPoll) {
|
|
1905
|
+
const intervalMs = (Number(entry.intervalSec) || 60) * 1000
|
|
1906
|
+
const staleMs = Math.max(intervalMs * 3, 5 * 60 * 1000)
|
|
1907
|
+
const age = Date.now() - Date.parse(entry.lastPoll)
|
|
1908
|
+
if (Number.isFinite(age) && age > staleMs) {
|
|
1909
|
+
lines.push(`WARN ${entry.repo} 已经 ${Math.round(age / 60000)} 分钟没轮询过(预期每 ${Math.round(intervalMs / 1000)} 秒)—— 定时器可能丢了`)
|
|
1889
1910
|
}
|
|
1890
1911
|
}
|
|
1891
1912
|
|
|
1892
|
-
//
|
|
1913
|
+
// 6. 最近一次状态
|
|
1893
1914
|
const last = entry.lastError ? `错误:${entry.lastError}` : entry.lastDeferred ? `等待:${entry.lastDeferred}` : '正常'
|
|
1894
1915
|
lines.push(`INFO ${entry.enabled === false ? '已暂停' : '运行中'} · 上次轮询 ${entry.lastPoll || '无'} · ${last}`)
|
|
1895
1916
|
}
|
package/lib/watch.js
CHANGED
|
@@ -256,6 +256,16 @@ export function pushFiltered(log, record, max = 5) {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
/** 单次唤醒最多带几条;其余留到下一轮,别让一次唤醒把上下文撑爆。 */
|
|
259
|
+
/** 记一条「被冷却期吸收」:只有记下来,客户问「这条为什么没叫醒我」才答得准。 */
|
|
260
|
+
export function pushAbsorbed(log, items, at, max = 50) {
|
|
261
|
+
const list = Array.isArray(log) ? log.slice() : []
|
|
262
|
+
for (const item of items ?? []) {
|
|
263
|
+
list.push({ at, number: String(item.number), title: String(item.title || '').slice(0, 80) })
|
|
264
|
+
}
|
|
265
|
+
return list.slice(-Math.max(1, max))
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
259
269
|
/**
|
|
260
270
|
* 优先级:一次只能处理 N 条时,该先处理哪 N 条。
|
|
261
271
|
*
|
|
@@ -786,6 +796,9 @@ export function itemTrace(watcher, number) {
|
|
|
786
796
|
const filtered = (Array.isArray(watcher.filteredLog) ? watcher.filteredLog : [])
|
|
787
797
|
.filter((entry) => String(entry.number) === target)
|
|
788
798
|
.map((entry) => ({ at: entry.at, reason: entry.reason, title: entry.title }))
|
|
799
|
+
const absorbed = (Array.isArray(watcher.absorbedLog) ? watcher.absorbedLog : [])
|
|
800
|
+
.filter((entry) => String(entry.number) === target)
|
|
801
|
+
.map((entry) => ({ at: entry.at, title: entry.title }))
|
|
789
802
|
const wakes = (Array.isArray(watcher.history) ? watcher.history : [])
|
|
790
803
|
.filter((entry) => Array.isArray(entry.numbers) && entry.numbers.map(String).includes(target))
|
|
791
804
|
.map((entry) => ({ at: entry.at, ok: Boolean(entry.ok), reason: entry.reason || null }))
|
|
@@ -793,11 +806,12 @@ export function itemTrace(watcher, number) {
|
|
|
793
806
|
let verdict
|
|
794
807
|
if (filtered.length > 0 && !seen && !reported) verdict = '被过滤掉了:' + (filtered[filtered.length - 1].reason || '未知原因')
|
|
795
808
|
else if (wakes.some((w) => w.ok)) verdict = '已经唤醒过 ' + wakes.filter((w) => w.ok).length + ' 次'
|
|
796
|
-
else if (
|
|
809
|
+
else if (absorbed.length > 0) verdict = '被冷却期吸收了(' + (absorbed[absorbed.length - 1].at || '未知时间') + ')—— 那一批刚唤醒过,等下一轮'
|
|
810
|
+
else if (seen) verdict = '已记入水位但没唤醒(仅观察,或上报前就已存在)'
|
|
797
811
|
else if (wakes.length > 0) verdict = '尝试唤醒过 ' + wakes.length + ' 次但都没成功'
|
|
798
812
|
else verdict = '还没轮到它(可能还没被轮询到,或在批外)'
|
|
799
813
|
|
|
800
|
-
return { number: target, repo: watcher.repo || null, seen, reported, filtered, wakes, verdict }
|
|
814
|
+
return { number: target, repo: watcher.repo || null, seen, reported, filtered, absorbed, wakes, verdict }
|
|
801
815
|
}
|
|
802
816
|
|
|
803
817
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.78",
|
|
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",
|