dsh-session-superagent 0.9.11 → 0.9.13

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 CHANGED
@@ -2,6 +2,48 @@
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.13] - 2026-11-02 —— 总览加「按仓库」汇总
6
+
7
+ ### 学到的(知识库第 62 条)
8
+ NN/g《Progressive Disclosure》:把细节推迟到第二层,先给概览。
9
+ <https://www.nngroup.com/articles/progressive-disclosure/>
10
+
11
+ ### 问题
12
+ 总览把所有守平铺,守 5 个仓库时客户要一行行读才知道"哪个健康/哪个一直跳过"。仓库越多越像日志。
13
+
14
+ ### 改法
15
+ `summarizeByRepo()` 按仓库聚合,总览顶部多一个「按仓库」小节:
16
+ 状态点 + 仓库名 + 徽章(去重)+ `N 条守(启用 M)` + 最近唤醒 + 未回音 + 报错数。
17
+ 排序:**报错 > 未回音≥2 > 其它**。
18
+
19
+ ### 两个实现坑(都被用例抓到)
20
+ 1. **必须跟随筛选**:用 `visible` 而不是 `watchers`,否则"只看只读"时下面的列表空了、上面还列着别的仓库;
21
+ 2. `repoBadges` 在拆分后的 `gh-format.js` 里,`watch.js` 之前只做了 re-export 没 import ——
22
+ 运行时 `repoBadges is not defined`。
23
+
24
+ ### 测试
25
+ - 新增 1 例。合计 **157 例**。
26
+
27
+ ## [0.9.12] - 2026-11-02 —— "叫醒了没回音"现在有下一步动作
28
+
29
+ ### 学到的(知识库第 61 条)
30
+ AGENTS.md 是"给 agent 看的 README"(<https://agents.md>),要解决的正是"agent 不知道该按什么规则干活"。
31
+
32
+ ### 上一轮的断头路
33
+ 0.9.11 会提示"检查 AGENTS.md",但**提示之后没有下一步** —— 客户还得自己想规则该写什么。
34
+
35
+ ### 改法(克制版)
36
+ 「需要关注」那条提示挂了「看建议规则」按钮,弹层给出可直接粘贴的片段(含"无论做不做都要 ack")。
37
+ **不直接写进客户仓库**:可能覆盖、可能和他们的规范冲突。给可复制的文本,收益 90%、风险 0。
38
+
39
+ ### 一个真实的实现坑
40
+ 弹层最初用**新加的 useState**,整套用例立刻红 ——
41
+ 测试桩的 `useState` 是**按位置取队列**的,中间插一个 state 会让后面全部错位。
42
+ 改成复用已有 `glossary`(`false` 关 / `true` 术语表 / `'rules:owner/name'` 规则弹层),零新增槽位。
43
+
44
+ ### 测试
45
+ - 新增 1 例(未点开不渲染 / 点开后出现规则与 ack 要求 / 有复制动作)。合计 **156 例**。
46
+
5
47
  ## [0.9.11] - 2026-11-02 —— "叫醒了但没回音"现在看得见了
6
48
 
7
49
  ### 学到的(知识库第 60 条)
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: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Version](https://img.shields.io/badge/version-0.9.11-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.13-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
7
7
  [![npm](https://img.shields.io/npm/v/dsh-session-superagent.svg)](https://www.npmjs.com/package/dsh-session-superagent)
8
8
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-plugin-orange.svg)](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.11'
17
+ const CLIENT_VERSION = '0.9.13'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -855,6 +855,7 @@ window.__ModuleLoader__.load({
855
855
  const [reasonFilter, setReasonFilter] = useState(null)
856
856
  // 行内徽章可点:点「只读」就只看只读的守(与跳过原因筛选同一套交互)
857
857
  const [badgeFilter, setBadgeFilter] = useState(null)
858
+ // 建议规则弹层:给"叫醒了没回音"一个下一步动作(只提供可复制的规则,不替客户写仓库文件)
858
859
 
859
860
  const load = useCallback(async () => {
860
861
  try {
@@ -1109,13 +1110,14 @@ window.__ModuleLoader__.load({
1109
1110
  for (const watcher of watchers) {
1110
1111
  // 仓库结构问题(关闭 Issues / 是 fork)比轮询失败更早该说:它注定收不到条目
1111
1112
  const structure = repoStructureNote(watcher.repoAccess)
1112
- // 叫醒了但没回音:守在工作、消息也进去了,但会话没动手(规则缺失或被忽略)
1113
- if (Number(watcher.silentWakes) >= 2) {
1114
- problems.push({
1115
- key: 'silent-' + watcher.repo,
1116
- text: watcher.repo + ' 已连续 ' + watcher.silentWakes + ' 次唤醒后没有回音(没看到 watch_ack)—— 检查这个仓库的 AGENTS.md 有没有给出处理规则',
1117
- })
1118
- }
1113
+ // 叫醒了但没回音:守在工作、消息也进去了,但会话没动手(规则缺失或被忽略)
1114
+ if (Number(watcher.silentWakes) >= 2) {
1115
+ problems.push({
1116
+ key: 'silent-' + watcher.repo,
1117
+ text: watcher.repo + ' 已连续 ' + watcher.silentWakes + ' 次唤醒后没有回音(没看到 watch_ack)—— 检查这个仓库的 AGENTS.md 有没有给出处理规则',
1118
+ action: { label: '看建议规则', onClick: () => setGlossary('rules:' + watcher.repo) },
1119
+ })
1120
+ }
1119
1121
  // 被反复重开的条目:说明"之前判过不做"可能有问题,值得人看一眼
1120
1122
  if (watcher.lastReopened) {
1121
1123
  problems.push({ key: 'r-' + watcher.repo, text: watcher.repo + ' #' + watcher.lastReopened + ' 被重新打开过 —— 之前判"不做"可能不对' })
@@ -1243,14 +1245,28 @@ window.__ModuleLoader__.load({
1243
1245
  },
1244
1246
  h('div', { className: 'dt-row-main' },
1245
1247
  h('div', { className: 'dt-row-title' },
1246
- h(Tag, { tone: event.kind === 'wake' ? 'success' : event.kind === 'wake-failed' ? 'danger' : 'outline' },
1247
- event.kind + (Number(event.count) > 1 ? ' ×' + event.count : '')),
1248
- (Number(event.count) > 1 && event.since)
1249
- ? h('span', { className: 'dt-row-meta' }, '持续 ' + durationText(event.since, event.at))
1248
+ h(Tag, { tone: event.kind === 'wake' ? 'success' : event.kind === 'wake-failed' ? 'danger' : 'outline' },
1249
+ event.kind + (Number(event.count) > 1 ? ' ×' + event.count : '')),
1250
+ (Number(event.count) > 1 && event.since)
1251
+ ? h('span', { className: 'dt-row-meta' }, '持续 ' + durationText(event.since, event.at))
1250
1252
  : null,
1251
1253
  h('span', { className: 'dt-row-meta' }, ageText(event.at))),
1252
1254
  h('div', { className: 'dt-hint' }, watcher.repo + ' · ' + event.text)))))))
1253
1255
 
1256
+ // 按仓库汇总:守多个仓库时先看哪个健康,再看明细(渐进披露)
1257
+ const repoSummary = visible.length === 0 ? null : h(Section, { key: 'repo-summary', title: '按仓库' },
1258
+ h('div', { className: 'dt-rows' }, ...summarizeByRepo(visible).map((group) => h('div', { key: 'repo-' + group.repo, className: 'dt-row' },
1259
+ h('div', { className: 'dt-row-main' },
1260
+ h('div', { className: 'dt-row-title' },
1261
+ h(StateDot, { state: group.errors > 0 ? 'error' : group.silentWakes >= 2 ? 'warning' : 'done' }),
1262
+ h('span', { className: 'dt-row-name' }, group.repo),
1263
+ ...group.badges.map((badge) => h(Tag, { key: 'rb-' + badge.text, tone: badge.tone }, badge.text))),
1264
+ h('div', { className: 'dt-row-meta' },
1265
+ h('span', null, group.count + ' 条守(启用 ' + group.enabled + ')'),
1266
+ h('span', null, group.lastWake ? '最近唤醒 ' + ageText(group.lastWake) : '还没唤醒过'),
1267
+ group.silentWakes > 0 ? h('span', { className: 'dt-error-text' }, '未回音 ' + group.silentWakes + ' 次') : null,
1268
+ group.errors > 0 ? h('span', { className: 'dt-error-text' }, group.errors + ' 条报错') : null))))))
1269
+
1254
1270
  const trigger = h(Section, { title: '新增主理鱼' },
1255
1271
  h('div', { className: 'dt-form' },
1256
1272
  field('仓库', h(Input, { value: form.repo, placeholder: 'owner/name', onChange: (e) => setForm({ ...form, repo: e.target.value }) })),
@@ -1408,19 +1424,50 @@ window.__ModuleLoader__.load({
1408
1424
  return raw
1409
1425
  }
1410
1426
 
1411
- /** 持续时长(与服务端 watch.js:durationText 同语义)。 */
1412
- function durationText(sinceIso, untilIso) {
1413
- const from = Date.parse(String(sinceIso || ''))
1414
- const to = Date.parse(String(untilIso || ''))
1415
- if (!Number.isFinite(from) || !Number.isFinite(to) || to < from) return ''
1416
- const minutes = Math.floor((to - from) / 60000)
1417
- if (minutes < 1) return '不到 1 分钟'
1418
- if (minutes < 60) return minutes + ' 分钟'
1419
- const hours = Math.floor(minutes / 60)
1420
- const rest = minutes % 60
1421
- return rest > 0 ? hours + ' 小时 ' + rest + ' 分' : hours + ' 小时'
1422
- }
1423
-
1427
+ /** 建议追加到仓库 AGENTS.md 的处理规则(只给文本,绝不代写文件)。 */
1428
+ const AGENTS_SNIPPET = [
1429
+ '## 主理鱼(dsh-session-superagent)处理规则',
1430
+ '',
1431
+ '- 收到「【主理鱼】<owner/name> 有 N 条新动态」时,先读完整条目再决定做不做。',
1432
+ '- 做:按【完成标准】三件事写清(改了什么 / 怎么验证 / 回写到哪),改完推分支开 PR。',
1433
+ '- 不做:也要说明理由(例如"已有 PR 在做"),然后照样 ack。',
1434
+ '- **无论做还是不做,最后都要 watch_ack 打标签**,否则下一轮会被再次唤醒。',
1435
+ ].join(String.fromCharCode(10))
1436
+
1437
+ /** 按仓库汇总(与服务端 watch.js:summarizeByRepo 同语义)。 */
1438
+ function summarizeByRepo(list) {
1439
+ const groups = new Map()
1440
+ for (const watcher of Array.isArray(list) ? list : []) {
1441
+ if (!watcher || !watcher.repo) continue
1442
+ const repo = String(watcher.repo)
1443
+ const group = groups.get(repo) || { repo, count: 0, lastWake: null, silentWakes: 0, errors: 0, enabled: 0, badges: [] }
1444
+ group.count += 1
1445
+ if (watcher.enabled !== false) group.enabled += 1
1446
+ if (watcher.lastWake && (!group.lastWake || String(watcher.lastWake) > String(group.lastWake))) group.lastWake = watcher.lastWake
1447
+ group.silentWakes = Math.max(group.silentWakes, Number(watcher.silentWakes) || 0)
1448
+ if (watcher.lastError) group.errors += 1
1449
+ for (const badge of repoBadges(watcher.repoAccess) || []) {
1450
+ if (!group.badges.some((b) => b.text === badge.text)) group.badges.push(badge)
1451
+ }
1452
+ groups.set(repo, group)
1453
+ }
1454
+ const weight = (g) => (g.errors > 0 ? 0 : g.silentWakes >= 2 ? 1 : 2)
1455
+ return [...groups.values()].sort((a, b) => (weight(a) - weight(b)) || a.repo.localeCompare(b.repo))
1456
+ }
1457
+
1458
+ /** 持续时长(与服务端 watch.js:durationText 同语义)。 */
1459
+ function durationText(sinceIso, untilIso) {
1460
+ const from = Date.parse(String(sinceIso || ''))
1461
+ const to = Date.parse(String(untilIso || ''))
1462
+ if (!Number.isFinite(from) || !Number.isFinite(to) || to < from) return ''
1463
+ const minutes = Math.floor((to - from) / 60000)
1464
+ if (minutes < 1) return '不到 1 分钟'
1465
+ if (minutes < 60) return minutes + ' 分钟'
1466
+ const hours = Math.floor(minutes / 60)
1467
+ const rest = minutes % 60
1468
+ return rest > 0 ? hours + ' 小时 ' + rest + ' 分' : hours + ' 小时'
1469
+ }
1470
+
1424
1471
  /** 仓库能力徽章(与服务端 watch.js:repoBadges 同语义)。 */
1425
1472
  function repoBadges(access) {
1426
1473
  if (!access || typeof access !== 'object') return []
@@ -1496,11 +1543,33 @@ window.__ModuleLoader__.load({
1496
1543
  snap.error ? h('div', { className: 'dt-banner dt-danger' }, '读取失败:' + humanizeError(snap.error)) : null,
1497
1544
  snap.loading && !snap.body ? h(Hint, null, '正在读取…') : null,
1498
1545
  tab === 'overview' ? overview : null,
1546
+ tab === 'overview' ? repoSummary : null,
1499
1547
  tab === 'judge' ? judge : null,
1500
1548
  tab === 'judge' ? timeline : null,
1501
1549
  tab === 'trigger' ? trigger : null,
1502
1550
  tab === 'settings' ? settings : null,
1503
- h(Modal, { open: glossary, title: '主理鱼术语表', onClose: () => setGlossary(false) },
1551
+ typeof glossary === 'string' ? h(Modal, {
1552
+ open: true,
1553
+ title: '建议追加到 ' + String(glossary).replace('rules:', '') + ' 的 AGENTS.md',
1554
+ onClose: () => setGlossary(false),
1555
+ },
1556
+ h('p', { className: 'dt-hint' }, '问题通常不是"没叫醒",而是"叫醒了但没动手"。这段规则会明确要求:无论做不做,最后都要 ack。'),
1557
+ h('pre', { className: 'dt-pre' }, AGENTS_SNIPPET),
1558
+ h('div', { className: 'dt-actions' },
1559
+ h(Btn, {
1560
+ size: 'sm',
1561
+ variant: 'primary',
1562
+ onClick: async () => {
1563
+ try {
1564
+ await navigator.clipboard.writeText(AGENTS_SNIPPET)
1565
+ notify('规则已复制,粘贴到 AGENTS.md 末尾即可', 'info')
1566
+ } catch {
1567
+ notify('复制失败:请手动选中上面的文本', 'error')
1568
+ }
1569
+ },
1570
+ }, '复制这段规则'),
1571
+ h(Btn, { size: 'sm', variant: 'ghost', onClick: () => setGlossary(false) }, '关闭'))) : null,
1572
+ h(Modal, { open: glossary === true, title: '主理鱼术语表', onClose: () => setGlossary(false) },
1504
1573
  h(KeyValues, { rows: [
1505
1574
  ['主理鱼', '一条「盯办」绑定:某个仓库 → 某个会话'],
1506
1575
  ['盯', '轮询 issue/PR、按水位去重、冷却期吸收自己的操作'],
package/lib/index.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
 
33
33
  export const name = 'dsh-session-superagent'
34
34
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
35
- export const SERVER_VERSION = '0.9.11'
35
+ export const SERVER_VERSION = '0.9.13'
36
36
  export const inject = ['tools', 'agents', 'webServer']
37
37
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
38
38
  const DEFAULT_SESSION_WAKES = 12
package/lib/watch.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * Kept separate so the behaviour that matters (what counts as news, when a wake
5
5
  * is allowed, what the wake text says) is unit-testable without a DSH host.
6
6
  */
7
+ import { repoBadges } from './gh-format.js'
7
8
 
8
9
  /**
9
10
  * Split items into "report now" and "absorb silently".
@@ -693,3 +694,32 @@ export function silentStreak({ previousWakeAt, lastAckedAt, previousStreak = 0 }
693
694
  if (Number.isFinite(ackAt) && ackAt >= wakeAt) return 0
694
695
  return streak + 1
695
696
  }
697
+
698
+ /**
699
+ * 按仓库汇总:守 5 个仓库时,平铺的列表看不出"哪个健康、哪个一直跳过"。
700
+ *
701
+ * 这是渐进披露(progressive disclosure)在数据层的落实:
702
+ * 先给每仓库一行摘要,细节留在下面的明细里。
703
+ * 出处:https://www.nngroup.com/articles/progressive-disclosure/
704
+ */
705
+ export function summarizeByRepo(watchers) {
706
+ const list = Array.isArray(watchers) ? watchers.filter((w) => w && w.repo) : []
707
+ const groups = new Map()
708
+ for (const watcher of list) {
709
+ const repo = String(watcher.repo)
710
+ const group = groups.get(repo) || { repo, count: 0, lastWake: null, lastPoll: null, silentWakes: 0, errors: 0, enabled: 0, badges: [] }
711
+ group.count += 1
712
+ if (watcher.enabled !== false) group.enabled += 1
713
+ if (watcher.lastWake && (!group.lastWake || String(watcher.lastWake) > String(group.lastWake))) group.lastWake = watcher.lastWake
714
+ if (watcher.lastPoll && (!group.lastPoll || String(watcher.lastPoll) > String(group.lastPoll))) group.lastPoll = watcher.lastPoll
715
+ group.silentWakes = Math.max(group.silentWakes, Number(watcher.silentWakes) || 0)
716
+ if (watcher.lastError) group.errors += 1
717
+ for (const badge of repoBadges(watcher.repoAccess) || []) {
718
+ if (!group.badges.some((b) => b.text === badge.text)) group.badges.push(badge)
719
+ }
720
+ groups.set(repo, group)
721
+ }
722
+ // 有问题的排前面:错误 > 未回音 >= 2 > 其余;同类按仓库名
723
+ const weight = (g) => (g.errors > 0 ? 0 : g.silentWakes >= 2 ? 1 : 2)
724
+ return [...groups.values()].sort((a, b) => (weight(a) - weight(b)) || a.repo.localeCompare(b.repo))
725
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
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",