dsh-session-superagent 0.9.257 → 0.9.259
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 +82 -0
- package/README.md +4 -4
- package/client.js +33 -4
- package/docs/json-/345/245/221/347/272/246.md +11 -0
- package/lib/index.js +48 -13
- package/lib/watch.js +14 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,88 @@
|
|
|
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.259] - 2026-11-05 —— 工具不再只能「暂停」,优先级也不再只有面板能调
|
|
6
|
+
|
|
7
|
+
### ① `watch_stop` 可以真正删除,但默认行为不变
|
|
8
|
+
|
|
9
|
+
新增 `delete: true`:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
watch_stop({ repo: 'owner/name', delete: true })
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- 默认仍然只暂停,文本与 JSON 返回形状完全不变;
|
|
16
|
+
- 显式删除时先清轮询 timer 与 `bootTimers`,再删状态并写 ISO 墓碑,防止迟到快照复活;
|
|
17
|
+
- 回执明确 `deleted:true`;Gitee 前缀同样支持;
|
|
18
|
+
- 显式 `watch_start` 可重建同一仓库,只解除该 id 的墓碑,不影响其他 session。
|
|
19
|
+
|
|
20
|
+
### ② `watch_start` 支持五个优先级开关
|
|
21
|
+
|
|
22
|
+
`priority` 对象支持 `reopened / comments / labels / unassigned / stale`。
|
|
23
|
+
只覆盖显式传入的布尔键,其他已有设置保留;**只改标签不会重置优先级**。
|
|
24
|
+
|
|
25
|
+
### ③ doctor 不再写死 `/6`
|
|
26
|
+
|
|
27
|
+
部分挂载失败按实际的 `routes / (routes + failed.length)` 报告;旧状态没有路由数时显示「未知」,
|
|
28
|
+
不编造一个看似精确的分母。
|
|
29
|
+
|
|
30
|
+
### ④ ack 标签从「隐藏配置」变成可见、可改
|
|
31
|
+
|
|
32
|
+
`/state` 回传真实 `ackLabel`(GitHub/Gitee 各自默认值正确)。
|
|
33
|
+
面板列表显示作者白名单与回执标签,编辑器可修改「已处理标签」。
|
|
34
|
+
|
|
35
|
+
### 证据
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
npm test → 420/420(新增 12 条:删除/重建 4、priority 3、doctor/state 4、面板 ack 1)
|
|
39
|
+
node scripts/contract.mjs --update → 登记 watch_start.priority 与 watch_stop.delete
|
|
40
|
+
node scripts/measure-state.mjs → 20 条守 43.8 KB ≤ 50 KB
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## [0.9.258] - 2026-11-05 —— 新建能一次设好,模型也能看见自己写了什么
|
|
44
|
+
|
|
45
|
+
继续收 T40「两个入口能力不对等」的尾项,并用**真实点击 + 请求体断言**验收,而不是只查字段出现在源码里。
|
|
46
|
+
|
|
47
|
+
### ① 新建表单:四个关键配置不再要求「先建再改」
|
|
48
|
+
|
|
49
|
+
新建主理鱼时现在可以直接设置:
|
|
50
|
+
|
|
51
|
+
- 只理这些人提的(作者白名单,自动去掉 `@`);
|
|
52
|
+
- 这条会话每小时最多被唤醒;
|
|
53
|
+
- 隔离区保留天数;
|
|
54
|
+
- 最多保留几个隔离区。
|
|
55
|
+
|
|
56
|
+
保存后只清空仓库相关内容,**限额与隔离策略保留**,连续添加多个仓库不用反复重填。
|
|
57
|
+
|
|
58
|
+
### ② 编辑表单:看得到,也终于改得到
|
|
59
|
+
|
|
60
|
+
补上「排除这些标签」和「只看指派给谁」两个控件。
|
|
61
|
+
|
|
62
|
+
`filters` 是整块提交的,所以保存体现在同时带上 `labels` / `ignoreLabels` / `assignee` / `allowAuthors`,
|
|
63
|
+
**改其中一项不会把另外几项静默清空**。控件名到 `filters` 的 touched 映射也同步补齐。
|
|
64
|
+
|
|
65
|
+
### ③ HTTP 的间隔与工具同口径
|
|
66
|
+
|
|
67
|
+
`/watch` 以前把 `30.7` 原样存成 `30.7`,工具路径存 `31`。
|
|
68
|
+
现在两边都是**先取整、再夹取到 30–3600 秒**。
|
|
69
|
+
|
|
70
|
+
### ④ `watch_status` 补齐 11 个可写配置字段(T41)
|
|
71
|
+
|
|
72
|
+
模型设完以后终于能自查:`batchLimit`、`maxWakesPerHour`、`sessionMaxWakes`、
|
|
73
|
+
`isolateKeepDays`、`maxIsolated`、`ackLabel`、`workdir`、`priority`、
|
|
74
|
+
`ignoreLabels`、`assignee`、`allowAuthors` 全部回传。
|
|
75
|
+
|
|
76
|
+
数组与 `priority` 返回副本,避免调用方修改视图时反向污染状态;
|
|
77
|
+
重复调用 JSON 完全一致,**不破坏 ETag**。
|
|
78
|
+
字段已登记到 `test/fixtures/contract-stability.json`。
|
|
79
|
+
|
|
80
|
+
### 证据
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
npm test → 408/408(新增:新建真实点击核对请求体、编辑 filters 不丢旧值、HTTP 取整、statusView 4 条)
|
|
84
|
+
node scripts/measure-state.mjs → 20 条守 43.8 KB ≤ 50 KB
|
|
85
|
+
```
|
|
86
|
+
|
|
5
87
|
## [0.9.257] - 2026-11-05 —— 同一个字段,两条路径两种校验
|
|
6
88
|
|
|
7
89
|
T40 剩下的两条「值得修」落地。
|
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)
|
|
@@ -146,7 +146,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
|
|
|
146
146
|
## 开发
|
|
147
147
|
|
|
148
148
|
```sh
|
|
149
|
-
npm test #
|
|
149
|
+
npm test # 420 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
### 工具输出:文本给人和 agent,JSON 给程序
|
|
@@ -206,9 +206,9 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
|
|
|
206
206
|
|
|
207
207
|
|
|
208
208
|
```bash
|
|
209
|
-
npm test #
|
|
209
|
+
npm test # 420 项单测(带离线开关,约 1.6 秒)
|
|
210
210
|
node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
|
|
211
|
-
node scripts/preflight.mjs #
|
|
211
|
+
node scripts/preflight.mjs # 41 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
|
|
212
212
|
node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
|
|
213
213
|
```
|
|
214
214
|
|
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.259'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
|
@@ -629,6 +629,8 @@ window.__ModuleLoader__.load({
|
|
|
629
629
|
if (f.labels && f.labels.length) parts.push('标签: ' + f.labels.join(','))
|
|
630
630
|
if (f.ignoreLabels && f.ignoreLabels.length) parts.push('排除: ' + f.ignoreLabels.join(','))
|
|
631
631
|
if (f.onlyAssigned) parts.push(f.assignee ? '只看指派给 @' + f.assignee : '只看已指派')
|
|
632
|
+
// 设了作者白名单就要能自查;只在编辑器里出现,列表上看不出「到底生效的是谁」。
|
|
633
|
+
if (f.allowAuthors && f.allowAuthors.length) parts.push('作者: ' + f.allowAuthors.join(','))
|
|
632
634
|
return parts.join(' · ')
|
|
633
635
|
}
|
|
634
636
|
|
|
@@ -979,6 +981,8 @@ window.__ModuleLoader__.load({
|
|
|
979
981
|
'cap-watcher': '撞单守上限',
|
|
980
982
|
busy: '会话忙',
|
|
981
983
|
}
|
|
984
|
+
// 新建与编辑共用:同一个输入提示写两份,改一处忘另一处就会漂移(文案门禁会拦)。
|
|
985
|
+
const AUTHOR_LIST_PLACEHOLDER = 'GitHub 登录名,逗号分隔,留空 = 谁都算'
|
|
982
986
|
|
|
983
987
|
const [snap, setSnap] = useState({ loading: true, error: null, body: null })
|
|
984
988
|
const [tab, setTab] = useState('overview')
|
|
@@ -986,6 +990,8 @@ window.__ModuleLoader__.load({
|
|
|
986
990
|
const [form, setForm] = useState({
|
|
987
991
|
repo: '', intervalSec: '60', goal: '', labels: '', onlyAssigned: false,
|
|
988
992
|
activeHours: '', isolated: false, workdir: '',
|
|
993
|
+
// 新建时就要能定:先建再改会多一步,尤其隔离区天数/数量不该先用默认值跑一轮。
|
|
994
|
+
allowAuthors: '', sessionMaxWakes: '', isolateKeepDays: '', maxIsolated: '',
|
|
989
995
|
})
|
|
990
996
|
const [token, setToken] = useState('')
|
|
991
997
|
const [goalDraft, setGoalDraft] = useState('')
|
|
@@ -1106,12 +1112,16 @@ window.__ModuleLoader__.load({
|
|
|
1106
1112
|
intervalSec: Number(draft.intervalSec) || watcher.intervalSec,
|
|
1107
1113
|
filters: {
|
|
1108
1114
|
labels: String(draft.labels || '').split(',').map((v) => v.trim()).filter(Boolean),
|
|
1115
|
+
// filters 整块发送,三个名单都必须带上,否则改标签会顺带清空另外两项。
|
|
1116
|
+
ignoreLabels: String(draft.ignoreLabels || '').split(',').map((v) => v.trim()).filter(Boolean),
|
|
1109
1117
|
onlyAssigned: !!draft.onlyAssigned,
|
|
1110
|
-
|
|
1118
|
+
assignee: String(draft.assignee || '').trim().replace(/^@/, '') || null,
|
|
1111
1119
|
allowAuthors: String(draft.allowAuthors || '').split(',').map((v) => v.trim().replace(/^@/, '')).filter(Boolean),
|
|
1112
1120
|
},
|
|
1113
1121
|
activeHours: draft.activeHours || '',
|
|
1114
1122
|
goal: draft.goal || '',
|
|
1123
|
+
// 自定义 ack 标签是可写配置;未传时服务端保持原值。
|
|
1124
|
+
ackLabel: String(draft.ackLabel || '').trim() || undefined,
|
|
1115
1125
|
isolated: !!draft.isolated,
|
|
1116
1126
|
workdir: draft.workdir || '',
|
|
1117
1127
|
observe: !!draft.observe,
|
|
@@ -1133,7 +1143,9 @@ window.__ModuleLoader__.load({
|
|
|
1133
1143
|
// 而 Toast 照样说「已保存」。这里显式做一次「控件名 → 字段名」的映射。
|
|
1134
1144
|
const CONTROL_TO_FIELD = {
|
|
1135
1145
|
labels: "filters",
|
|
1146
|
+
ignoreLabels: "filters",
|
|
1136
1147
|
onlyAssigned: "filters",
|
|
1148
|
+
assignee: "filters",
|
|
1137
1149
|
allowAuthors: "filters",
|
|
1138
1150
|
priorityReopened: "priority",
|
|
1139
1151
|
priorityComments: "priority",
|
|
@@ -1185,6 +1197,7 @@ window.__ModuleLoader__.load({
|
|
|
1185
1197
|
filters: {
|
|
1186
1198
|
labels: String(form.labels || '').split(',').map((v) => v.trim()).filter(Boolean),
|
|
1187
1199
|
onlyAssigned: !!form.onlyAssigned,
|
|
1200
|
+
allowAuthors: String(form.allowAuthors || '').split(',').map((v) => v.trim().replace(/^@/, '')).filter(Boolean),
|
|
1188
1201
|
},
|
|
1189
1202
|
activeHours: form.activeHours || '',
|
|
1190
1203
|
isolated: !!form.isolated,
|
|
@@ -1192,9 +1205,13 @@ window.__ModuleLoader__.load({
|
|
|
1192
1205
|
observe: !!form.observe,
|
|
1193
1206
|
batchLimit: Number(form.batchLimit) || undefined,
|
|
1194
1207
|
maxWakesPerHour: Number(form.maxWakesPerHour) || undefined,
|
|
1208
|
+
sessionMaxWakes: Number(form.sessionMaxWakes) || undefined,
|
|
1209
|
+
isolateKeepDays: Number(form.isolateKeepDays) || undefined,
|
|
1210
|
+
maxIsolated: Number(form.maxIsolated) || undefined,
|
|
1195
1211
|
}),
|
|
1196
1212
|
})
|
|
1197
|
-
|
|
1213
|
+
// 只清仓库相关的内容;限额、隔离策略保留,连续添加多个仓库时不用重填。
|
|
1214
|
+
setForm({ ...form, repo: '', goal: '', labels: '', onlyAssigned: false, allowAuthors: '' })
|
|
1198
1215
|
// 添加前体检的警告直接说出来:填错仓库名 / 只读 / 归档,这一刻讲最省事
|
|
1199
1216
|
const warnings = (created && Array.isArray(created.warnings)) ? created.warnings : []
|
|
1200
1217
|
if (warnings.length > 0) notify('已添加,但注意:' + warnings.join(' / '), 'error')
|
|
@@ -1278,10 +1295,13 @@ window.__ModuleLoader__.load({
|
|
|
1278
1295
|
setDraft({
|
|
1279
1296
|
intervalSec: String(watcher.intervalSec ?? 60),
|
|
1280
1297
|
labels: (watcher.filters && watcher.filters.labels ? watcher.filters.labels : []).join(','),
|
|
1298
|
+
ignoreLabels: (watcher.filters && watcher.filters.ignoreLabels ? watcher.filters.ignoreLabels : []).join(','),
|
|
1299
|
+
assignee: (watcher.filters && watcher.filters.assignee) || '',
|
|
1281
1300
|
activeHours: watcher.activeHours || '',
|
|
1282
1301
|
// 审核 T26 M2:`watcher.goal` 是**对象**(goalView),当字符串塞进输入框会显示
|
|
1283
1302
|
// [object Object];保存时后端只收 string,于是静默无效而 Toast 说「已保存」。
|
|
1284
1303
|
goal: watcher.note || (typeof watcher.goal === 'string' ? watcher.goal : (watcher.goal && watcher.goal.objective) || ''),
|
|
1304
|
+
ackLabel: watcher.ackLabel || (watcher.provider === 'gitee' ? '主理鱼-已处理' : '主理鱼:已处理'),
|
|
1285
1305
|
onlyAssigned: !!(watcher.filters && watcher.filters.onlyAssigned),
|
|
1286
1306
|
allowAuthors: (watcher.filters && watcher.filters.allowAuthors ? watcher.filters.allowAuthors : []).join(', '),
|
|
1287
1307
|
// 下面这些以前没填 —— 打开一条隔离执行的守再直接保存,会把 isolated 写回 false
|
|
@@ -1313,6 +1333,8 @@ window.__ModuleLoader__.load({
|
|
|
1313
1333
|
watcher.activeHours ? h(Tag, null, '时段 ' + watcher.activeHours) : null,
|
|
1314
1334
|
watcher.isolated ? h(Tag, null, isolationText(watcher)) : null,
|
|
1315
1335
|
filterText(watcher.filters) ? h(Tag, null, filterText(watcher.filters)) : null,
|
|
1336
|
+
// ack 标签决定这条是否还会被叫醒,不能只在工具参数里出现。
|
|
1337
|
+
h(Tag, { tone: 'quiet' }, '回执 ' + (watcher.ackLabel || (watcher.provider === 'gitee' ? '主理鱼-已处理' : '主理鱼:已处理'))),
|
|
1316
1338
|
backoffText(watcher) ? h(Tag, { tone: 'warning' }, backoffText(watcher)) : null),
|
|
1317
1339
|
// 三行,各管一件事:① 是谁 ② 节律与最近结果 ③ 目标
|
|
1318
1340
|
// 原来六段用 ' · ' 串成一行(会话 · 每 60s · 轮询 · 唤醒 · 上次唤醒 · 目标),
|
|
@@ -1387,11 +1409,14 @@ window.__ModuleLoader__.load({
|
|
|
1387
1409
|
? h('div', { className: 'dt-fieldset' },
|
|
1388
1410
|
field('间隔(秒)', h(Input, { value: draft.intervalSec, onChange: (e) => setField({ ...draft, intervalSec: e.target.value }) }), '多长时间检查一次这个仓库,最小 30 秒'),
|
|
1389
1411
|
field('只处理这些标签', h(Input, { value: draft.labels, placeholder: '逗号分隔,留空 = 全部', onChange: (e) => setField({ ...draft, labels: e.target.value }) })),
|
|
1412
|
+
field('排除这些标签', h(Input, { value: draft.ignoreLabels || '', placeholder: '逗号分隔,留空 = 不排除', onChange: (e) => setField({ ...draft, ignoreLabels: e.target.value }) }), '命中任意一个就跳过,优先级高于上面的白名单'),
|
|
1390
1413
|
field('活跃时段', h(HoursField, { value: draft.activeHours, onChange: (next) => setField({ ...draft, activeHours: next }) }), '只在这个时间段内唤醒;窗口外只攒条目,不打扰'),
|
|
1391
1414
|
// 官方原型的 Policy 第一件事是「谁可以给你派活」。单人场景也要:别人随手提的 issue 不该叫醒你。
|
|
1392
|
-
field('只理这些人提的', h(Input, { value: draft.allowAuthors || '', placeholder:
|
|
1415
|
+
field('只理这些人提的', h(Input, { value: draft.allowAuthors || '', placeholder: AUTHOR_LIST_PLACEHOLDER, onChange: (e) => setField({ ...draft, allowAuthors: e.target.value }) }), '不在名单里的人提的 issue/PR 不会叫醒你(Gitee 也可以填)'),
|
|
1393
1416
|
field('目标/规则', h(Input, { value: draft.goal || '', placeholder: '可选,会附在唤醒消息里', onChange: (e) => setField({ ...draft, goal: e.target.value }) })),
|
|
1417
|
+
field('已处理标签', h(Input, { value: draft.ackLabel || '', placeholder: '主理鱼:已处理', onChange: (e) => setField({ ...draft, ackLabel: e.target.value }) }), 'watch_ack 会把同名标签打到 issue/PR 上;改名字等于换一套已处理标记'),
|
|
1394
1418
|
h('label', { className: 'dt-switch-row' }, h(Toggle, { checked: !!draft.onlyAssigned, onChange: (v) => setField({ ...draft, onlyAssigned: v }), label: '只看已指派' }), '只处理已指派给人的条目'),
|
|
1419
|
+
draft.onlyAssigned ? field('只看指派给谁', h(Input, { value: draft.assignee || '', placeholder: 'GitHub 登录名,留空 = 只要有指派就行', onChange: (e) => setField({ ...draft, assignee: e.target.value }) })) : null,
|
|
1395
1420
|
field('单次最多唤醒条数', h(Input, { value: draft.batchLimit || '', placeholder: String(DEFAULTS.batchLimit || 5) + '(1-20)', onChange: (e) => setField({ ...draft, batchLimit: e.target.value }) })),
|
|
1396
1421
|
field('每小时最多唤醒次数', h(Input, { value: draft.maxWakesPerHour || '', placeholder: String(DEFAULTS.maxWakesPerHour || 6) + '(1-60)', onChange: (e) => setField({ ...draft, maxWakesPerHour: e.target.value }) })),
|
|
1397
1422
|
field('这条会话每小时最多被唤醒', h(Input, { value: draft.sessionMaxWakes || '', placeholder: String(DEFAULTS.sessionMaxWakes || 12) + '(1-60)', onChange: (e) => setField({ ...draft, sessionMaxWakes: e.target.value }) }), '跨所有守累计:守 5 个仓库时,光有单守上限挡不住叠加'),
|
|
@@ -1835,13 +1860,17 @@ window.__ModuleLoader__.load({
|
|
|
1835
1860
|
field('间隔(秒)', h(Input, { value: form.intervalSec, onChange: (e) => setForm({ ...form, intervalSec: e.target.value }) })),
|
|
1836
1861
|
field('单次最多唤醒条数', h(Input, { value: form.batchLimit || '', placeholder: String(DEFAULTS.batchLimit || 5) + '(1-20)', onChange: (e) => setForm({ ...form, batchLimit: e.target.value }) })),
|
|
1837
1862
|
field('每小时最多唤醒次数', h(Input, { value: form.maxWakesPerHour || '', placeholder: String(DEFAULTS.maxWakesPerHour || 6) + '(1-60)', onChange: (e) => setForm({ ...form, maxWakesPerHour: e.target.value }) })),
|
|
1863
|
+
field('这条会话每小时最多被唤醒', h(Input, { value: form.sessionMaxWakes || '', placeholder: String(DEFAULTS.sessionMaxWakes || 12) + '(1-60)', onChange: (e) => setForm({ ...form, sessionMaxWakes: e.target.value }) }), '跨所有主理鱼累计,守多个仓库时尤其要设'),
|
|
1838
1864
|
field('只处理这些标签', h(Input, { value: form.labels, placeholder: '逗号分隔,留空 = 全部', onChange: (e) => setForm({ ...form, labels: e.target.value }) })),
|
|
1865
|
+
field('只理这些人提的', h(Input, { value: form.allowAuthors || '', placeholder: AUTHOR_LIST_PLACEHOLDER, onChange: (e) => setForm({ ...form, allowAuthors: e.target.value }) }), '不在名单里的人提的 issue/PR 不会叫醒你'),
|
|
1839
1866
|
field('活跃时段', h(HoursField, { value: form.activeHours, onChange: (next) => setForm({ ...form, activeHours: next }) }), '只在这个时间段内唤醒;不填 = 全天'),
|
|
1840
1867
|
field('目标/规则', h(Input, { value: form.goal || '', placeholder: '可选,会附在唤醒消息里', onChange: (e) => setForm({ ...form, goal: e.target.value }) })),
|
|
1841
1868
|
h('label', { className: 'dt-switch-row' }, h(Toggle, { checked: form.onlyAssigned, onChange: (v) => setForm({ ...form, onlyAssigned: v }), label: '只看已指派' }), '只处理已指派给人的条目'),
|
|
1842
1869
|
h('label', { className: 'dt-switch-row' }, h(Toggle, { checked: !!form.observe, onChange: (v) => setForm({ ...form, observe: v }), label: '仅观察' }), '仅观察(只记录本会唤醒哪几条,不真唤醒)'),
|
|
1843
1870
|
h('label', { className: 'dt-switch-row' }, h(Toggle, { checked: form.isolated, onChange: (v) => setForm({ ...form, isolated: v }), label: '隔离执行' }), ISOLATED_HINT),
|
|
1844
1871
|
form.isolated ? field('隔离工作目录', h(Input, { value: form.workdir, placeholder: '绝对路径,留空 = 当前工作目录', onChange: (e) => setForm({ ...form, workdir: e.target.value }) })) : null,
|
|
1872
|
+
form.isolated ? field('隔离区保留天数', h(Input, { value: form.isolateKeepDays || '', placeholder: String(DEFAULTS.isolateKeepDays || 3) + '(1-30)', onChange: (e) => setForm({ ...form, isolateKeepDays: e.target.value }) }), '每次唤醒前回收这个天数之前的一次性工作区') : null,
|
|
1873
|
+
form.isolated ? field('最多保留几个隔离区', h(Input, { value: form.maxIsolated || '', placeholder: '5(1-50)', onChange: (e) => setForm({ ...form, maxIsolated: e.target.value }) }), '超出就回收最旧的,不影响正在使用的那个') : null,
|
|
1845
1874
|
h('div', { className: 'dt-actions' },
|
|
1846
1875
|
h(Btn, { variant: 'primary', icon: h(Icon, { name: 'plus' }), onClick: addWatcher, disabled: !sessionId || !form.repo.trim() },
|
|
1847
1876
|
sessionId ? '添加到当前会话' : '先打开一个会话'))))
|
|
@@ -38,6 +38,17 @@
|
|
|
38
38
|
| `activeHours` | 稳定 |
|
|
39
39
|
| `labels` | 稳定 |
|
|
40
40
|
| `onlyAssigned` | 稳定 |
|
|
41
|
+
| `batchLimit` | 稳定 |
|
|
42
|
+
| `maxWakesPerHour` | 稳定 |
|
|
43
|
+
| `sessionMaxWakes` | 稳定 |
|
|
44
|
+
| `isolateKeepDays` | 稳定 |
|
|
45
|
+
| `maxIsolated` | 稳定 |
|
|
46
|
+
| `ackLabel` | 稳定 |
|
|
47
|
+
| `workdir` | 稳定 |
|
|
48
|
+
| `priority` | 稳定 |
|
|
49
|
+
| `ignoreLabels` | 稳定 |
|
|
50
|
+
| `assignee` | 稳定 |
|
|
51
|
+
| `allowAuthors` | 稳定 |
|
|
41
52
|
| `deferReason` | 稳定 |
|
|
42
53
|
| `lastDeferred` | 实验 |
|
|
43
54
|
| `silentWakes` | 稳定 |
|
package/lib/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import { decodeBody, truncateUtf8 } from './body.js'
|
|
|
26
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
|
-
effectiveIntervalMs, planWakeSettlement, advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
|
|
29
|
+
effectiveIntervalMs, planWakeSettlement, advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, DEFAULT_PRIORITY, formatWatchText,
|
|
30
30
|
recordPendingWake, clearPending, pendingRetry,
|
|
31
31
|
wakeQuality,
|
|
32
32
|
parseRepoSpec, markGiteeReopened,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
|
|
47
47
|
export const name = 'dsh-session-superagent'
|
|
48
48
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
49
|
-
export const SERVER_VERSION = '0.9.
|
|
49
|
+
export const SERVER_VERSION = '0.9.259'
|
|
50
50
|
export const inject = ['tools', 'agents', 'webServer']
|
|
51
51
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
52
52
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
@@ -70,6 +70,8 @@ const DEFAULT_BATCH_LIMIT = 5
|
|
|
70
70
|
// 出处:https://json-schema.org/understanding-json-schema/reference/annotations
|
|
71
71
|
const DEFAULT_WAKES_PER_HOUR = 6
|
|
72
72
|
const DEFAULT_ISOLATE_KEEP_DAYS = 3
|
|
73
|
+
// watch.js 的 DEFAULT_PRIORITY 是排序规则的事实源;stale 是后加的扩展键,默认同样关闭。
|
|
74
|
+
const DEFAULT_TOOL_PRIORITY = Object.freeze({ ...DEFAULT_PRIORITY, stale: false })
|
|
73
75
|
// 一条会话最多挂多少守:再多轮询压力与上下文都会失控(20 条 × 每 60 秒已很密)
|
|
74
76
|
const MAX_WATCHERS_PER_SESSION = 20
|
|
75
77
|
|
|
@@ -243,7 +245,7 @@ function mergeWatermark(diskEntry, memEntry) {
|
|
|
243
245
|
return out
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
function writeState(state) {
|
|
248
|
+
function writeState(state, options = {}) {
|
|
247
249
|
try {
|
|
248
250
|
mkdirSync(stateDir(), { recursive: true })
|
|
249
251
|
// 合并写:调用方手里的 state 可能是很久以前读的快照(宿主重载、两个实例交替写),
|
|
@@ -251,6 +253,9 @@ function writeState(state) {
|
|
|
251
253
|
// 规则:盘上有、内存里没有的条目一律保留;只有墓碑里的 id 才允许消失。
|
|
252
254
|
const disk = readState()
|
|
253
255
|
const tombstones = { ...(disk.deleted || {}), ...(state.deleted || {}) }
|
|
256
|
+
// 只有显式的 watch_start 才能解除墓碑(用户要求重建同 id 的守)。
|
|
257
|
+
// 普通旧快照写入没有这个选项,仍然不能绕过墓碑把已删守复活。
|
|
258
|
+
for (const id of (Array.isArray(options.revive) ? options.revive : [])) delete tombstones[id]
|
|
254
259
|
const merged = { ...disk, ...state }
|
|
255
260
|
merged.watchers = { ...(disk.watchers || {}) }
|
|
256
261
|
for (const [id, watcher] of Object.entries(state.watchers || {})) {
|
|
@@ -1754,6 +1759,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
1754
1759
|
repo: w.repo,
|
|
1755
1760
|
// 面板要能一眼分出 GitHub / Gitee:否则行内只能靠 id 前缀猜
|
|
1756
1761
|
provider: w.provider === 'gitee' ? 'gitee' : 'github',
|
|
1762
|
+
ackLabel: w.ackLabel || defaultAckLabel(w.provider),
|
|
1757
1763
|
sessionId: w.sessionId,
|
|
1758
1764
|
intervalSec: w.intervalSec,
|
|
1759
1765
|
enabled: isEnabled(w),
|
|
@@ -1997,7 +2003,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
1997
2003
|
json(res, 503, { ok: false, error: '插件实例已失效(当前 handler 跑在已释放的上下文里):请重载 DSH 后再添加' })
|
|
1998
2004
|
return
|
|
1999
2005
|
}
|
|
2000
|
-
|
|
2006
|
+
// 与 watch_start 同口径:先取整再夹取。否则面板存 30.7、工具存 31,同一设置两种结果。
|
|
2007
|
+
const intervalSec = Math.max(30, Math.min(3600, Math.round(Number(body.intervalSec) || 60)))
|
|
2001
2008
|
const state = readState()
|
|
2002
2009
|
state.watchers = state.watchers || {}
|
|
2003
2010
|
// id 里带 provider:同一个 owner/name 在两家可能都存在,混在一起会互相覆盖
|
|
@@ -2581,12 +2588,21 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2581
2588
|
// 0. 挂载状态:面板/HTTP 靠路由,路由注册失败时工具仍然可用 —— 这种「半死」状态
|
|
2582
2589
|
// 光看工具是发现不了的(2026-11-02 真机踩过:duplicate exact route 让六条接口全灭)
|
|
2583
2590
|
if (state.server) {
|
|
2584
|
-
const
|
|
2591
|
+
const routeCount = Number(state.server.routes)
|
|
2592
|
+
const hasRouteCount = state.server.routes !== undefined && state.server.routes !== null && state.server.routes !== ''
|
|
2593
|
+
&& Number.isInteger(routeCount) && routeCount >= 0
|
|
2594
|
+
const mounted = hasRouteCount ? routeCount : null
|
|
2585
2595
|
const failed = Array.isArray(state.server.failed) ? state.server.failed : []
|
|
2586
2596
|
if (state.server.error) {
|
|
2587
2597
|
lines.push(`FAIL 面板接口挂载:${state.server.error}(工具仍可用,但面板会空白;重载一次即可)`)
|
|
2588
2598
|
} else if (failed.length > 0) {
|
|
2589
|
-
|
|
2599
|
+
// routes 是成功的 disposer 数,failed 是实际注册失败数;总数来自这次挂载,不写死。
|
|
2600
|
+
const total = mounted === null ? null : mounted + failed.length
|
|
2601
|
+
lines.push(total === null
|
|
2602
|
+
? `WARN 面板接口部分失败(成功/总数未知):${failed.join(';')}`
|
|
2603
|
+
: `WARN 面板接口部分失败(${mounted}/${total} 成功):${failed.join(';')}`)
|
|
2604
|
+
} else if (mounted === null) {
|
|
2605
|
+
lines.push('WARN 面板接口挂载:路由数未知(旧版本没有记录 routes)')
|
|
2590
2606
|
} else {
|
|
2591
2607
|
lines.push(`OK 面板接口挂载:${mounted} 条,无失败`)
|
|
2592
2608
|
}
|
|
@@ -2800,6 +2816,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2800
2816
|
maxIsolated: { type: 'number', description: 'With isolated: keep at most this many worktrees, oldest removed first (1-50, default 5).' },
|
|
2801
2817
|
goal: { type: 'string', description: 'Optional per-watcher goal appended to the wake message.' },
|
|
2802
2818
|
ackLabel: { type: 'string', description: 'Label used as the handled marker (default 主理鱼:已处理). Two sessions watching the same repo share it unless each sets its own.' },
|
|
2819
|
+
priority: { type: 'object', description: 'Priority switches; only explicitly supplied keys are changed. Boolean keys: reopened, comments, labels, unassigned, stale. Defaults: reopened/comments/labels=true; unassigned/stale=false. additionalProperties are unrestricted.' },
|
|
2803
2820
|
},
|
|
2804
2821
|
async execute(args) {
|
|
2805
2822
|
const toolAgents = agentsService(ctx)
|
|
@@ -2834,6 +2851,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2834
2851
|
intervalSec: 60,
|
|
2835
2852
|
cooldownMs: DEFAULT_COOLDOWN_MS,
|
|
2836
2853
|
ackLabel: defaultAckLabel(provider),
|
|
2854
|
+
priority: { ...DEFAULT_TOOL_PRIORITY },
|
|
2837
2855
|
cursor: null,
|
|
2838
2856
|
seen: {},
|
|
2839
2857
|
lastReported: {},
|
|
@@ -2875,6 +2893,15 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2875
2893
|
if (typeof args.isolateKeepDays === 'number') entry.isolateKeepDays = Math.max(1, Math.min(30, Math.round(args.isolateKeepDays)))
|
|
2876
2894
|
if (typeof args.maxIsolated === 'number') entry.maxIsolated = Math.max(1, Math.min(50, Math.round(args.maxIsolated)))
|
|
2877
2895
|
if (typeof args.ackLabel === 'string' && args.ackLabel.trim()) entry.ackLabel = args.ackLabel.trim().slice(0, 60)
|
|
2896
|
+
// 工具入口与面板一样可以调五个优先级键,但部分更新不能把已有开关重置。
|
|
2897
|
+
if (args.priority && typeof args.priority === 'object' && !Array.isArray(args.priority)) {
|
|
2898
|
+
const current = entry.priority && typeof entry.priority === 'object' && !Array.isArray(entry.priority) ? entry.priority : {}
|
|
2899
|
+
const next = { ...DEFAULT_TOOL_PRIORITY, ...current }
|
|
2900
|
+
for (const key of ['reopened', 'comments', 'labels', 'unassigned', 'stale']) {
|
|
2901
|
+
if (Object.hasOwn(args.priority, key) && typeof args.priority[key] === 'boolean') next[key] = args.priority[key]
|
|
2902
|
+
}
|
|
2903
|
+
entry.priority = next
|
|
2904
|
+
}
|
|
2878
2905
|
// 审核 T40 W12:`watch_start` 的语义是「开始看」,但**静默恢复**一条暂停的守是意外行为。
|
|
2879
2906
|
// 保留恢复语义(幂等),但两件事必须做到:
|
|
2880
2907
|
// ① 如果调用方显式传了 resume:false,就保持原暂停状态(只改配置);
|
|
@@ -2893,7 +2920,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2893
2920
|
}
|
|
2894
2921
|
}
|
|
2895
2922
|
state.watchers[id] = entry
|
|
2896
|
-
|
|
2923
|
+
// 显式 start 同 repo/session 表示要重建;只解除这个 id 的墓碑,不影响其他已删守。
|
|
2924
|
+
writeState(state, { revive: [id] })
|
|
2897
2925
|
stopWatcher(id)
|
|
2898
2926
|
startWatcher(entry)
|
|
2899
2927
|
const flags = []
|
|
@@ -3007,9 +3035,10 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
3007
3035
|
|
|
3008
3036
|
ctx.tools.register(defineTool({
|
|
3009
3037
|
name: 'watch_stop',
|
|
3010
|
-
description: 'Stop watching a repository for the current session.',
|
|
3038
|
+
description: 'Stop watching a repository for the current session. By default this pauses it and keeps its state; pass delete:true to remove it and leave a tombstone.',
|
|
3011
3039
|
parameters: {
|
|
3012
3040
|
repo: { type: 'string', required: true, description: 'owner/name' },
|
|
3041
|
+
delete: { type: 'boolean', description: 'Delete the watcher and persist a tombstone instead of only pausing it (default false).' },
|
|
3013
3042
|
format: { type: 'string', description: "'text' (default) or 'json'." },
|
|
3014
3043
|
},
|
|
3015
3044
|
async execute(args) {
|
|
@@ -3031,13 +3060,19 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
3031
3060
|
const message = 'no watcher for ' + rawRepo + '(试过 ' + candidates.join(' / ') + ')'
|
|
3032
3061
|
return (args && args.format === 'json') ? JSON.stringify({ schemaVersion: 1, ok: false, id, error: message }) : '[error: ' + message + ']'
|
|
3033
3062
|
}
|
|
3063
|
+
// 审核 T36 W2:`stopWatcher()` 同时清 timers 与 bootTimers;删除时必须先停再抹状态,
|
|
3064
|
+
// 否则正在收尾的 tick 可能把刚删的守写回来。
|
|
3065
|
+
stopWatcher(id)
|
|
3066
|
+
if (args.delete === true) {
|
|
3067
|
+
delete state.watchers[id]
|
|
3068
|
+
state.deleted = { ...(state.deleted || {}), [id]: new Date().toISOString() }
|
|
3069
|
+
writeState(state)
|
|
3070
|
+
if (args && args.format === 'json') return JSON.stringify({ schemaVersion: 1, ok: true, id, repo: args.repo, deleted: true })
|
|
3071
|
+
return `deleted ${id}(deleted:true)`
|
|
3072
|
+
}
|
|
3034
3073
|
state.watchers[id].enabled = false
|
|
3035
3074
|
writeState(state)
|
|
3036
|
-
//
|
|
3037
|
-
// 刚建好还没开始轮询的守(首轮错峰等待中)被暂停后,那个 `setTimeout` 仍会 fire,
|
|
3038
|
-
// 于是**已经停掉的守还会再 tick 一次**(含 gh 请求、可能建 worktree)。
|
|
3039
|
-
// `stopWatcher()` 两者都清,直接用它。
|
|
3040
|
-
stopWatcher(id)
|
|
3075
|
+
// 默认 JSON / 文本保持旧形状:只是暂停,不新增 deleted/stopped 字段。
|
|
3041
3076
|
if (args && args.format === 'json') return JSON.stringify({ schemaVersion: 1, ok: true, id, repo: args.repo })
|
|
3042
3077
|
return `stopped ${id}`
|
|
3043
3078
|
},
|
package/lib/watch.js
CHANGED
|
@@ -1151,8 +1151,21 @@ export function statusView(entries, options = {}) {
|
|
|
1151
1151
|
observe: w.observe === true,
|
|
1152
1152
|
isolated: w.isolated === true,
|
|
1153
1153
|
activeHours: w.activeHours || null,
|
|
1154
|
-
labels: (w.filters && Array.isArray(w.filters.labels)) ? w.filters.labels : [],
|
|
1154
|
+
labels: (w.filters && Array.isArray(w.filters.labels)) ? w.filters.labels.slice() : [],
|
|
1155
1155
|
onlyAssigned: Boolean(w.filters && w.filters.onlyAssigned),
|
|
1156
|
+
// 可写配置必须回传,模型才能用 watch_status 自查 watch_start 是否真正生效。
|
|
1157
|
+
batchLimit: w.batchLimit ?? 5,
|
|
1158
|
+
maxWakesPerHour: w.maxWakesPerHour ?? 6,
|
|
1159
|
+
sessionMaxWakes: w.sessionMaxWakes ?? 12,
|
|
1160
|
+
isolateKeepDays: w.isolateKeepDays ?? 3,
|
|
1161
|
+
maxIsolated: w.maxIsolated ?? 5,
|
|
1162
|
+
ackLabel: w.ackLabel ?? DEFAULT_ACK_LABEL,
|
|
1163
|
+
workdir: w.workdir ?? null,
|
|
1164
|
+
// 补齐缺省开关,同时保留面板写入的 stale 等扩展项;拷贝对象避免共享引用。
|
|
1165
|
+
priority: { ...DEFAULT_PRIORITY, ...((w.priority && typeof w.priority === 'object' && !Array.isArray(w.priority)) ? w.priority : {}) },
|
|
1166
|
+
ignoreLabels: (w.filters && Array.isArray(w.filters.ignoreLabels)) ? w.filters.ignoreLabels.slice() : [],
|
|
1167
|
+
assignee: (w.filters && w.filters.assignee) || null,
|
|
1168
|
+
allowAuthors: (w.filters && Array.isArray(w.filters.allowAuthors)) ? w.filters.allowAuthors.slice() : [],
|
|
1156
1169
|
deferReason: w.deferReason || null,
|
|
1157
1170
|
lastDeferred: w.lastDeferred || null,
|
|
1158
1171
|
silentWakes: Number(w.silentWakes) || 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.259",
|
|
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",
|