dsh-session-superagent 0.9.34 → 0.9.36

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,47 @@
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.36] - 2026-11-02 —— 信息密度体检:首屏区块数 ≤ 6 且写进判据
6
+
7
+ ### 学到的(知识库第 84 条)
8
+ 把"信息密度"从感觉变成**可执行的数字**:默认展开的区块数 ≤ 6。
9
+
10
+ ### 体检脚本
11
+ `scripts/audit-density.mjs` 静态解析 `client.js`,数每个 tab 里 `h(Section, …)` 的个数。
12
+
13
+ ### 抓到的两处并修掉
14
+ 1. **judge 页有两个都叫「追溯一条」的区块**(上一轮为"有编号/无编号"写了两个分支,各返回一个 Section)
15
+ → 合并成一个,内部按是否有编号分岔;
16
+ 2. **trigger 页 7 个区块**超过上限 → 把「诊断」并进「版本与更新」(同属排查/维护)。
17
+
18
+ 修完:**最密集一页 6 个区块**,正好压在上限内。
19
+
20
+ ### 门禁
21
+ `preflight --fast` 第 **16** 项:`PASS 信息密度 最密集一页 6 个区块(上限 6)`。
22
+
23
+ ## [0.9.35] - 2026-11-02 —— 「今天明显比平时忙」:阈值故意定高
24
+
25
+ ### 学到的(知识库第 83 条)
26
+ 用历史影响判断时,阈值要故意定高 —— 告警疲劳的代价远大于少提示一次。
27
+
28
+ ### 规则(`busierThanUsual`)
29
+ | 条件 | 结论 |
30
+ |---|---|
31
+ | 历史不足 3 天 / 日均 0 | 不提示(没有基线) |
32
+ | 今天 < 日均 × 2 | 不提示 |
33
+ | 今天 ≥ 日均 × 2 | 「今天明显比平时忙 —— 上限可能不够用」 |
34
+
35
+ 阈值下限写死 1.5 倍(调用方传更小也不会更低)。
36
+
37
+ ### 判断放在服务端
38
+ `/state` 回传 `busy: true/false`,面板只显示 —— 与 0.9.21 一致:**面板不再实现第二份判断逻辑**。
39
+
40
+ ### 为什么宁可不提示
41
+ 真积压已有更硬的信号(`sessionUsage.capped > 0`);历史基线是用来**发现异常**,不是制造焦虑。
42
+
43
+ ### 测试
44
+ - 新增 2 例(阈值 6 种情况;面板 busy=false 不提示 / true 提示且给原因)。合计 **175 例**。
45
+
5
46
  ## [0.9.34] - 2026-11-02 —— 留一份「每天一个数」的极小历史
6
47
 
7
48
  ### 学到的(知识库第 82 条)
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.34-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.36-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.34'
17
+ const CLIENT_VERSION = '0.9.36'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1231,27 +1231,25 @@ window.__ModuleLoader__.load({
1231
1231
  (() => {
1232
1232
  const needle = search.trim()
1233
1233
  const asNumber = /^#?[0-9]+$/.test(needle) ? needle.replace('#', '') : ''
1234
- if (!asNumber) {
1235
- return h(Section, { key: 'trace', title: '追溯一条', hint: '在右上角搜索框输入编号(如 42),这里就能查它经历了什么' },
1236
- h(Hint, null, '追溯会告诉你:它被过滤了、已经唤醒过、还是根本没轮到。'))
1237
- }
1238
1234
  const onlyRepo = watchers.length === 1 ? watchers[0].repo : ''
1239
- return h(Section, { key: 'trace', title: '追溯一条' },
1240
- h('div', { className: 'dt-row-meta' },
1241
- h('button', {
1242
- className: 'dt-textlink',
1243
- type: 'button',
1244
- onClick: async () => {
1245
- try {
1246
- const query = '/trace?number=' + encodeURIComponent(asNumber) + (onlyRepo ? '&repo=' + encodeURIComponent(onlyRepo) : '')
1247
- const payload = await call(query)
1248
- notify(String((payload && payload.text) || '没有结果').split(String.fromCharCode(10)).join(' · '), 'info')
1249
- } catch (error) {
1250
- notify('追溯失败:' + String((error && error.message) || error), 'error')
1251
- }
1252
- },
1253
- }, '追溯 #' + asNumber),
1254
- h('span', { className: 'dt-row-meta' }, onlyRepo ? '(在 ' + onlyRepo + ' 里查)' : '(在所有守里查)')))
1235
+ return h(Section, { key: 'trace', title: '追溯一条', hint: '在右上角搜索框输入编号(如 42),这里就能查它经历了什么' },
1236
+ asNumber
1237
+ ? h('div', { className: 'dt-row-meta' },
1238
+ h('button', {
1239
+ className: 'dt-textlink',
1240
+ type: 'button',
1241
+ onClick: async () => {
1242
+ try {
1243
+ const query = '/trace?number=' + encodeURIComponent(asNumber) + (onlyRepo ? '&repo=' + encodeURIComponent(onlyRepo) : '')
1244
+ const payload = await call(query)
1245
+ notify(String((payload && payload.text) || '没有结果').split(String.fromCharCode(10)).join(' · '), 'info')
1246
+ } catch (error) {
1247
+ notify('追溯失败:' + String((error && error.message) || error), 'error')
1248
+ }
1249
+ },
1250
+ }, '追溯 #' + asNumber),
1251
+ h('span', { className: 'dt-row-meta' }, onlyRepo ? '(在 ' + onlyRepo + ' 里查)' : '(在所有守里查)'))
1252
+ : h(Hint, null, '追溯会告诉你:它被过滤了、已经唤醒过、还是根本没轮到。'))
1255
1253
  })(),
1256
1254
  (() => {
1257
1255
  const counts = new Map()
@@ -1344,7 +1342,12 @@ window.__ModuleLoader__.load({
1344
1342
  const total = watchers.reduce((n, w) => n + (Number(w.daily && w.daily.total) || 0), 0)
1345
1343
  if (total === 0) return null
1346
1344
  const span = Math.max(...watchers.map((w) => Number(w.daily && w.daily.days) || 0))
1347
- return h('span', { className: 'dt-row-meta' }, '过去 ' + span + ' 天:共 ' + total + ' 次(日均 ' + (Math.round((total / Math.max(1, span)) * 10) / 10) + ')')
1345
+ return [
1346
+ h('span', { key: 'hist', className: 'dt-row-meta' }, '过去 ' + span + ' 天:共 ' + total + ' 次(日均 ' + (Math.round((total / Math.max(1, span)) * 10) / 10) + ')'),
1347
+ watchers.some((w) => w.busy)
1348
+ ? h('span', { key: 'busy', className: 'dt-error-text' }, '今天明显比平时忙 —— 上限可能不够用')
1349
+ : null,
1350
+ ]
1348
1351
  })())
1349
1352
  : null,
1350
1353
  visible.length === 0 ? h(Hint, null, '没有符合条件的主理鱼。点上面「全部」看所有守。') : null,
@@ -1426,22 +1429,12 @@ window.__ModuleLoader__.load({
1426
1429
  : null,
1427
1430
  h('div', { className: 'dt-actions' },
1428
1431
  h(Btn, { size: 'sm', variant: 'ghost', onClick: () => checkUpdate(true), disabled: checking }, checking ? '检查中…' : '重新检查')),
1429
- h(Hint, null, '升级要改 profile,装完需要重载一次宿主才会用上新版本 —— 所以这里只给命令,不替你执行。')),
1430
- h(Section, { key: 'diagnose', title: '分诊信号与取舍' },
1431
- h(Hint, null, '一次只处理 N 条时,这些信号的加权决定先后。事实默认展示,判断默认关闭。'),
1432
- h('div', { className: 'dt-rows' }, (body.triageSignals || []).map((sig) => h('div', { key: sig.key, className: 'dt-row' },
1433
- h('div', { className: 'dt-row-main' },
1434
- h('div', { className: 'dt-row-title' },
1435
- h('span', { className: 'dt-row-name' }, sig.label),
1436
- h(Tag, { tone: sig.kind === 'fact' ? 'success' : 'warning' }, sig.kind === 'fact' ? '事实' : '判断'),
1437
- h(Tag, { tone: sig.default ? 'outline' : 'quiet' }, sig.default ? '默认开' : '默认关'),
1438
- h('span', { className: 'dt-row-meta' }, '+' + sig.weight + ' 分')),
1439
- h('div', { className: 'dt-hint' }, sig.why)))))),
1440
- h(Section, { key: 'diagnose', title: '诊断' },
1441
- h(Hint, null, '反馈问题时把这段贴给对方:里面有版本、挂载状态和每条值守的最近错误(凭证已脱敏)。'),
1432
+ h(Hint, null, '升级要改 profile,装完需要重载一次宿主才会用上新版本 —— 所以这里只给命令,不替你执行。'),
1433
+ h(Hint, null, '反馈问题时把下面这份诊断贴给对方:里面有版本、挂载状态和每条守的最近错误(凭证已脱敏)。'),
1442
1434
  h('div', { className: 'dt-actions' },
1443
1435
  h(Btn, {
1444
- size: 'sm', variant: 'outline',
1436
+ size: 'sm',
1437
+ variant: 'outline',
1445
1438
  onClick: async () => {
1446
1439
  try {
1447
1440
  const payload = await call('/diagnose')
@@ -1453,6 +1446,17 @@ window.__ModuleLoader__.load({
1453
1446
  }
1454
1447
  },
1455
1448
  }, '复制诊断信息'))),
1449
+ h(Section, { key: 'diagnose', title: '分诊信号与取舍' },
1450
+ h(Hint, null, '一次只处理 N 条时,这些信号的加权决定先后。事实默认展示,判断默认关闭。'),
1451
+ h('div', { className: 'dt-rows' }, (body.triageSignals || []).map((sig) => h('div', { key: sig.key, className: 'dt-row' },
1452
+ h('div', { className: 'dt-row-main' },
1453
+ h('div', { className: 'dt-row-title' },
1454
+ h('span', { className: 'dt-row-name' }, sig.label),
1455
+ h(Tag, { tone: sig.kind === 'fact' ? 'success' : 'warning' }, sig.kind === 'fact' ? '事实' : '判断'),
1456
+ h(Tag, { tone: sig.default ? 'outline' : 'quiet' }, sig.default ? '默认开' : '默认关'),
1457
+ h('span', { className: 'dt-row-meta' }, '+' + sig.weight + ' 分')),
1458
+ h('div', { className: 'dt-hint' }, sig.why)))))),
1459
+
1456
1460
  h(Section, { key: 'goal', title: '会话 goal' },
1457
1461
  h('textarea', {
1458
1462
  className: 'dt-textarea', rows: 3, value: goalDraft,
package/lib/index.js CHANGED
@@ -28,6 +28,7 @@ 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
  bumpDailyWakes,
31
+ busierThanUsual,
31
32
  countCapped,
32
33
  dailySummary,
33
34
  suggestSessionCap,
@@ -38,7 +39,7 @@ import {
38
39
 
39
40
  export const name = 'dsh-session-superagent'
40
41
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
41
- export const SERVER_VERSION = '0.9.34'
42
+ export const SERVER_VERSION = '0.9.36'
42
43
  export const inject = ['tools', 'agents', 'webServer']
43
44
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
44
45
  const DEFAULT_SESSION_WAKES = 12
@@ -1259,6 +1260,7 @@ export function apply(ctx) {
1259
1260
  events: (w.events ?? []).slice(-20),
1260
1261
  deferReason: w.deferReason ?? null,
1261
1262
  daily: dailySummary(w.dailyWakes),
1263
+ busy: busierThanUsual(dailySummary(w.dailyWakes)),
1262
1264
  silentWakes: w.silentWakes ?? 0,
1263
1265
  note: w.goal ?? '',
1264
1266
  title: sessionTitle(w.sessionId),
package/lib/watch.js CHANGED
@@ -820,10 +820,30 @@ export function bumpDailyWakes(daily, atIso = new Date().toISOString(), keepDays
820
820
  }
821
821
 
822
822
  /** 最近几天的总量与日均(给面板显示用;没有数据就返回 null)。 */
823
- export function dailySummary(daily) {
823
+ export function dailySummary(daily, todayIso = new Date().toISOString()) {
824
824
  const map = (daily && typeof daily === 'object' && !Array.isArray(daily)) ? daily : {}
825
825
  const values = Object.values(map).map(Number).filter((n) => Number.isFinite(n) && n >= 0)
826
826
  if (values.length === 0) return null
827
827
  const total = values.reduce((a, b) => a + b, 0)
828
- return { days: values.length, total, avg: Math.round((total / values.length) * 10) / 10 }
828
+ const day = String(todayIso).slice(0, 10)
829
+ return {
830
+ days: values.length,
831
+ total,
832
+ avg: Math.round((total / values.length) * 10) / 10,
833
+ today: Number(map[day]) || 0,
834
+ }
835
+ }
836
+
837
+ /**
838
+ * 「今天明显比平时忙」:只在有足够历史、且高出很多倍时才提示。
839
+ *
840
+ * 阈值故意保守(默认 2 倍 + 至少 3 天数据)——
841
+ * 拿历史去影响判断,最怕的是频繁误报;宁可少提示,也不要制造噪音。
842
+ */
843
+ export function busierThanUsual(summary, { factor = 2, minDays = 3 } = {}) {
844
+ if (!summary || !Number.isFinite(Number(summary.days)) || summary.days < minDays) return false
845
+ const avg = Number(summary.avg) || 0
846
+ const today = Number(summary.today) || 0
847
+ if (avg <= 0) return false // 历史为 0 时没有可比基线
848
+ return today >= avg * Math.max(1.5, Number(factor) || 2)
829
849
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.34",
3
+ "version": "0.9.36",
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",