dsh-session-superagent 0.9.29 → 0.9.30
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 +22 -0
- package/README.md +1 -1
- package/client.js +1 -1
- package/lib/index.js +40 -1
- package/lib/watch.js +32 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
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.30] - 2026-11-02 —— 单条追溯:`watch_trace` 工具 + `trace-item` 脚本
|
|
6
|
+
|
|
7
|
+
### 学到的(知识库第 78 条)
|
|
8
|
+
PostgreSQL 的 `EXPLAIN`:不改变执行,只解释"为什么是这个结果"。
|
|
9
|
+
|
|
10
|
+
### 之前的状态
|
|
11
|
+
同一件事的数据散在三处:`seen[number]`(水位)、`filteredLog`(过滤记录)、`history`(唤醒历史)。
|
|
12
|
+
客户问"#42 为什么没叫醒我",得在脑子里拼 —— 拼错就给错答案。
|
|
13
|
+
|
|
14
|
+
### 做了什么
|
|
15
|
+
`itemTrace(watcher, number)` 拼成一条结论 + 明细:
|
|
16
|
+
`被过滤掉了:已关闭` / `已经唤醒过 N 次` / `已记入水位但没唤醒` / `尝试唤醒过 N 次但都没成功` / `还没轮到它`。
|
|
17
|
+
|
|
18
|
+
两个入口:工具 **`watch_trace`**(agent 直接查)+ 脚本 `node scripts/trace-item.mjs <编号>`
|
|
19
|
+
(支持 `--demo` 和 `--state <path>`)。
|
|
20
|
+
|
|
21
|
+
### 一个真实实现坑
|
|
22
|
+
`String(null) === 'null'` 是真值 → `if (!target)` 拦不住 null 入参,用例当场红。先判入参再转字符串。
|
|
23
|
+
|
|
24
|
+
### 测试
|
|
25
|
+
- 新增 1 例(5 种情况)。合计 **169 例**;工具已进契约快照。
|
|
26
|
+
|
|
5
27
|
## [0.9.29] - 2026-11-02 —— 「多久会叫醒我」现在能算给人看
|
|
6
28
|
|
|
7
29
|
### 学到的(知识库第 77 条)
|
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
|
|
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.30'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/index.js
CHANGED
|
@@ -28,13 +28,14 @@ import {
|
|
|
28
28
|
TRIAGE_SIGNALS, accessNote, buildCommentBatchQuery, classifyGhError, commentSummaryLine, parseCommentBatch, pickSuggestion, repoStructureNote, countReasons, filterReason, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, pushFiltered, normalizeFilters, partitionItems, passesFilters,
|
|
29
29
|
shouldRunCleanup,
|
|
30
30
|
countCapped,
|
|
31
|
+
itemTrace,
|
|
31
32
|
splitBatch,
|
|
32
33
|
mergeFilters, mergePollResult, mergeWakeTexts, pushEvent, silentStreak, msUntilActiveWindow, nextWaketimeAt, pruneSeen, sessionWakesLastHour, pruneWakeTimes, pushHistory, recordReported, staleWorktrees, worktreePlan,
|
|
33
34
|
} from './watch.js'
|
|
34
35
|
|
|
35
36
|
export const name = 'dsh-session-superagent'
|
|
36
37
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
37
|
-
export const SERVER_VERSION = '0.9.
|
|
38
|
+
export const SERVER_VERSION = '0.9.30'
|
|
38
39
|
export const inject = ['tools', 'agents', 'webServer']
|
|
39
40
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
40
41
|
const DEFAULT_SESSION_WAKES = 12
|
|
@@ -1702,6 +1703,44 @@ export function apply(ctx) {
|
|
|
1702
1703
|
},
|
|
1703
1704
|
}))
|
|
1704
1705
|
|
|
1706
|
+
// 单条追溯:agent 被问"这条为什么没叫醒我"时不用猜,直接查
|
|
1707
|
+
ctx.tools.register(defineTool({
|
|
1708
|
+
name: 'watch_trace',
|
|
1709
|
+
description:
|
|
1710
|
+
'Explain what happened to one issue/PR: whether it was filtered (and why), absorbed by the cooldown, already reported, or never seen. Read-only — changes nothing. Use it when the customer asks "why did this not wake me".',
|
|
1711
|
+
parameters: {
|
|
1712
|
+
repo: { type: 'string', description: 'owner/name; defaults to the only watched repo' },
|
|
1713
|
+
number: { type: 'number', description: 'issue or PR number to trace' },
|
|
1714
|
+
},
|
|
1715
|
+
async execute(args) {
|
|
1716
|
+
const state = readState()
|
|
1717
|
+
const all = Object.values(state.watchers || {})
|
|
1718
|
+
const wanted = typeof args.repo === 'string' && args.repo.trim() ? args.repo.trim() : null
|
|
1719
|
+
const list = wanted ? all.filter((entry) => entry && entry.repo === wanted) : all
|
|
1720
|
+
if (list.length === 0) {
|
|
1721
|
+
return '[error: no watcher for that repo — ' + (wanted ? 'nothing is watching ' + wanted : 'run watch_status to see what is watched') + ']'
|
|
1722
|
+
}
|
|
1723
|
+
const number = Number(args.number)
|
|
1724
|
+
if (!Number.isFinite(number)) return '[error: number is required]'
|
|
1725
|
+
const lines = []
|
|
1726
|
+
for (const entry of list) {
|
|
1727
|
+
const trace = itemTrace(entry, number)
|
|
1728
|
+
if (!trace) continue
|
|
1729
|
+
const touched = Boolean(trace.seen || trace.reported || trace.filtered.length || trace.wakes.length)
|
|
1730
|
+
if (!touched) continue
|
|
1731
|
+
lines.push('#' + trace.number + ' @ ' + (trace.repo || '?') + ':' + trace.verdict)
|
|
1732
|
+
if (trace.seen) lines.push(' 水位 seen:' + trace.seen)
|
|
1733
|
+
if (trace.reported) lines.push(' 上次上报:' + trace.reported)
|
|
1734
|
+
for (const item of trace.filtered) lines.push(' 被过滤(' + item.reason + '):' + item.at)
|
|
1735
|
+
for (const item of trace.wakes) lines.push(' 唤醒尝试:' + item.at + ' ' + (item.ok ? '成功' : '失败(' + (item.reason || '未知') + ')'))
|
|
1736
|
+
}
|
|
1737
|
+
if (lines.length === 0) {
|
|
1738
|
+
return '#' + number + ' 在' + (wanted ? ' ' + wanted : '所有守') + ' 里都没有痕迹 —— 可能还没被轮询到,或者编号写错了。'
|
|
1739
|
+
}
|
|
1740
|
+
return lines.join(String.fromCharCode(10))
|
|
1741
|
+
},
|
|
1742
|
+
}))
|
|
1743
|
+
|
|
1705
1744
|
ctx.tools.register(defineTool({
|
|
1706
1745
|
name: 'watch_doctor',
|
|
1707
1746
|
description:
|
package/lib/watch.js
CHANGED
|
@@ -750,3 +750,35 @@ export function splitBatch(fresh, limit = 3, priority) {
|
|
|
750
750
|
const rest = (Array.isArray(fresh) ? fresh : []).filter((item) => !picked.has(item.number))
|
|
751
751
|
return { listed, rest }
|
|
752
752
|
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* 单条条目的追踪:它到底经历了什么(被过滤 / 被冷却吸收 / 上报过 / 还在等)。
|
|
756
|
+
*
|
|
757
|
+
* 客户会问"这条 issue 为什么没叫醒我"。这个问题以前只能靠三处分散的数据
|
|
758
|
+
* (seen 水位、filteredLog、history)自己在脑子里拼 —— 这里拼好并返回结构化结果。
|
|
759
|
+
* 类比 SQL 的 EXPLAIN:不改变行为,只解释"为什么是这个结果"。
|
|
760
|
+
* 出处:https://www.postgresql.org/docs/current/sql-explain.html
|
|
761
|
+
*/
|
|
762
|
+
export function itemTrace(watcher, number) {
|
|
763
|
+
// 注意 String(null) === 'null' —— 先判断入参本身,别让 null 变成一个合法编号
|
|
764
|
+
if (!watcher || number === null || number === undefined || number === '') return null
|
|
765
|
+
const target = String(number).trim()
|
|
766
|
+
if (!target) return null
|
|
767
|
+
const seen = (watcher.seen && watcher.seen[target]) || null
|
|
768
|
+
const reported = (watcher.lastReported && watcher.lastReported[target]) || null
|
|
769
|
+
const filtered = (Array.isArray(watcher.filteredLog) ? watcher.filteredLog : [])
|
|
770
|
+
.filter((entry) => String(entry.number) === target)
|
|
771
|
+
.map((entry) => ({ at: entry.at, reason: entry.reason, title: entry.title }))
|
|
772
|
+
const wakes = (Array.isArray(watcher.history) ? watcher.history : [])
|
|
773
|
+
.filter((entry) => Array.isArray(entry.numbers) && entry.numbers.map(String).includes(target))
|
|
774
|
+
.map((entry) => ({ at: entry.at, ok: Boolean(entry.ok), reason: entry.reason || null }))
|
|
775
|
+
|
|
776
|
+
let verdict
|
|
777
|
+
if (filtered.length > 0 && !seen && !reported) verdict = '被过滤掉了:' + (filtered[filtered.length - 1].reason || '未知原因')
|
|
778
|
+
else if (wakes.some((w) => w.ok)) verdict = '已经唤醒过 ' + wakes.filter((w) => w.ok).length + ' 次'
|
|
779
|
+
else if (seen) verdict = '已记入水位但没唤醒(被吸收/仅观察/或上报前就已存在)'
|
|
780
|
+
else if (wakes.length > 0) verdict = '尝试唤醒过 ' + wakes.length + ' 次但都没成功'
|
|
781
|
+
else verdict = '还没轮到它(可能还没被轮询到,或在批外)'
|
|
782
|
+
|
|
783
|
+
return { number: target, repo: watcher.repo || null, seen, reported, filtered, wakes, verdict }
|
|
784
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.30",
|
|
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",
|