dsh-session-superagent 0.9.8 → 0.9.10

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.10] - 2026-11-02 —— 事件带上「持续了多久」
6
+
7
+ ### 补的是上一轮自己记下的缺口
8
+ 0.9.9 合并时把 `at` 更新成最新时间,**首次发生时间被覆盖** ——
9
+ 于是 `×10` 看不出是 10 分钟还是 10 小时。
10
+
11
+ ### 改法
12
+ 每条事件加 `since`(首次发生时间,合并时**不更新**),`at` 仍然更新为最新:
13
+
14
+ | 字段 | 合并时 |
15
+ |---|---|
16
+ | `since` | 不变 |
17
+ | `at` | 更新 |
18
+ | `count` | +1 |
19
+
20
+ `durationText()` 输出人话:`不到 1 分钟` / `42 分钟` / `2 小时` / `2 小时 5 分`;
21
+ 面板显示 `cap-watcher ×10 · 持续 42 分钟`。
22
+
23
+ ### 测试
24
+ - 新增 1 例(since 不被覆盖 / at 更新 / count 累加 / 四种时长文案 / 缺输入与反向时间)。合计 **154 例**。
25
+
26
+ ## [0.9.9] - 2026-11-02 —— 时间线降噪:连续同类事件合并成一条带次数
27
+
28
+ ### 学到的(知识库第 58 条)
29
+ PagerDuty《Alert Grouping》:**同一根因的多次告警要合并**,否则值班的人会被重复信息淹没。
30
+ <https://support.pagerduty.com/docs/alert-grouping>
31
+
32
+ ### 问题(0.9.8 我自己留下的)
33
+ 撞每小时上限时每 60 秒写一条一模一样的 `cap-watcher` —— 一小时 60 条,把 20 条位置占满,
34
+ **真正一次性的事件(唤醒、失败)反而被挤掉**。
35
+
36
+ ### 改法
37
+ `pushEvent`:与上一条 kind 和文案完全相同 → 不新增,只累加 `count` 并更新时间。
38
+ - 不连续就不合并(时序不能被压扁);
39
+ - kind 同文案不同也不合并(会话上限 vs 单守上限要分开看);
40
+ - 合并后仍受 max 限制。
41
+
42
+ 面板显示 `cap-watcher ×10`。
43
+
44
+ ### 测试
45
+ - 新增 1 例(连续 10 次→1 条 count=10 / 夹别的事件→3 条 / kind 同文案不同不合并 / 50 条交错仍剩 20)。合计 **153 例**。
46
+
5
47
  ## [0.9.8] - 2026-11-02 —— 时间线:回答"为什么这一轮没叫醒我"
6
48
 
7
49
  ### 学到的(知识库第 57 条)
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.8-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.10-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.8'
17
+ const CLIENT_VERSION = '0.9.10'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1236,7 +1236,11 @@ window.__ModuleLoader__.load({
1236
1236
  },
1237
1237
  h('div', { className: 'dt-row-main' },
1238
1238
  h('div', { className: 'dt-row-title' },
1239
- h(Tag, { tone: event.kind === 'wake' ? 'success' : event.kind === 'wake-failed' ? 'danger' : 'outline' }, event.kind),
1239
+ h(Tag, { tone: event.kind === 'wake' ? 'success' : event.kind === 'wake-failed' ? 'danger' : 'outline' },
1240
+ event.kind + (Number(event.count) > 1 ? ' ×' + event.count : '')),
1241
+ (Number(event.count) > 1 && event.since)
1242
+ ? h('span', { className: 'dt-row-meta' }, '持续 ' + durationText(event.since, event.at))
1243
+ : null,
1240
1244
  h('span', { className: 'dt-row-meta' }, ageText(event.at))),
1241
1245
  h('div', { className: 'dt-hint' }, watcher.repo + ' · ' + event.text)))))))
1242
1246
 
@@ -1397,6 +1401,19 @@ window.__ModuleLoader__.load({
1397
1401
  return raw
1398
1402
  }
1399
1403
 
1404
+ /** 持续时长(与服务端 watch.js:durationText 同语义)。 */
1405
+ function durationText(sinceIso, untilIso) {
1406
+ const from = Date.parse(String(sinceIso || ''))
1407
+ const to = Date.parse(String(untilIso || ''))
1408
+ if (!Number.isFinite(from) || !Number.isFinite(to) || to < from) return ''
1409
+ const minutes = Math.floor((to - from) / 60000)
1410
+ if (minutes < 1) return '不到 1 分钟'
1411
+ if (minutes < 60) return minutes + ' 分钟'
1412
+ const hours = Math.floor(minutes / 60)
1413
+ const rest = minutes % 60
1414
+ return rest > 0 ? hours + ' 小时 ' + rest + ' 分' : hours + ' 小时'
1415
+ }
1416
+
1400
1417
  /** 仓库能力徽章(与服务端 watch.js:repoBadges 同语义)。 */
1401
1418
  function repoBadges(access) {
1402
1419
  if (!access || typeof access !== 'object') return []
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.8'
35
+ export const SERVER_VERSION = '0.9.10'
36
36
  export const inject = ['tools', 'agents', 'webServer']
37
37
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
38
38
  const DEFAULT_SESSION_WAKES = 12
package/lib/watch.js CHANGED
@@ -632,11 +632,41 @@ export function shouldRunCleanup({ count = 0, keepCount = 5, lastRunAt = 0, now
632
632
  */
633
633
  export function pushEvent(events, event, max = 20) {
634
634
  const list = Array.isArray(events) ? events.slice() : []
635
- if (!event || typeof event !== 'object' || !event.kind) return list.slice(-max)
636
- list.push({
637
- at: event.at || new Date().toISOString(),
635
+ const limit = Math.max(1, Number(max) || 20)
636
+ if (!event || typeof event !== 'object' || !event.kind) return list.slice(-limit)
637
+ const at = event.at || new Date().toISOString()
638
+ const next = {
639
+ at,
640
+ // since:首次发生时间。合并时**不更新**,这样"这事从什么时候开始"仍然查得到。
641
+ since: at,
638
642
  kind: String(event.kind).slice(0, 24),
639
643
  text: String(event.text || '').slice(0, 160),
640
- })
641
- return list.slice(-Math.max(1, Number(max) || 20))
644
+ }
645
+ // 连续同一条事件合并成一条带次数 —— 否则"撞上限"这种每轮都一样的记录会刷满 20 条,
646
+ // 把真正有用的一次性事件挤掉(噪声淹没信号是这个界面最不该犯的错)。
647
+ const last = list[list.length - 1]
648
+ if (last && last.kind === next.kind && last.text === next.text) {
649
+ last.at = next.at
650
+ last.count = (Number(last.count) || 1) + 1
651
+ if (!last.since) last.since = last.at // 老数据补一个,免得显示成"持续 0 分钟"
652
+ return list.slice(-limit)
653
+ }
654
+ list.push(next)
655
+ return list.slice(-limit)
656
+ }
657
+
658
+ /**
659
+ * "持续了多久":合并事件时 at 是最新、since 是首次,两者之差就是这个状态持续的时间。
660
+ * 面板上写「×10 · 持续 42 分钟」比只写「×10」有用得多 —— 前者能回答"卡了多久"。
661
+ */
662
+ export function durationText(sinceIso, untilIso) {
663
+ const from = Date.parse(String(sinceIso || ''))
664
+ const to = Date.parse(String(untilIso || ''))
665
+ if (!Number.isFinite(from) || !Number.isFinite(to) || to < from) return ''
666
+ const minutes = Math.floor((to - from) / 60000)
667
+ if (minutes < 1) return '不到 1 分钟'
668
+ if (minutes < 60) return minutes + ' 分钟'
669
+ const hours = Math.floor(minutes / 60)
670
+ const rest = minutes % 60
671
+ return rest > 0 ? hours + ' 小时 ' + rest + ' 分' : hours + ' 小时'
642
672
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
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",