dsh-session-superagent 0.9.233 → 0.9.235

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,70 @@
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.235] - 2026-11-05 —— 时段写错会静默变成「全天有效」
6
+
7
+ ### ① `activeHours` 格式不对时静默失效
8
+
9
+ `inActiveHours('9-23')` 的正则不匹配 → **直接 `return true`**(全天有效),
10
+ 而 `watch_start` 的回执照样打 `[activeHours=9-23]`。
11
+
12
+ 客户以为设了时段(晚上别叫我),实际**一直在叫**。这种错最难发现 —— 因为「看起来生效了」。
13
+
14
+ 现在创建时先校验,不合法就拒绝并说清正确格式:
15
+
16
+ ```
17
+ watch_start({repo:'o/r', activeHours:'9-23'})
18
+ → [error: activeHours 格式要写成 HH:MM-HH:MM(例如 09:00-23:00),收到的是「9-23」]
19
+ ```
20
+
21
+ `9:00-25:00` 这类越界也拦,并说明「时要在 00-23」。
22
+
23
+ ### ② `watch_start` 的描述只说 GitHub
24
+
25
+ 实际支持 `gitee:` 前缀、gitee.com URL、以及用空格或逗号分隔的多个仓库。
26
+ 描述里没写 = **模型永远不会用**。已补。
27
+
28
+ ### ③ 文档里的 `batchLimit` 默认值写错了
29
+
30
+ `docs/competitive-analysis.md` 说默认 3,代码是 **5**(`DEFAULT_BATCH_LIMIT`)。已对齐。
31
+
32
+ ### 证据
33
+
34
+ ```
35
+ npm test → 378/378(新增:activeHours 格式校验 7 组输入)
36
+ check-docs → 5 项 PASS
37
+ ```
38
+
39
+ ## [0.9.234] - 2026-11-05 —— 多会话下报的是别人的额度;自称只读却写了文件
40
+
41
+ ### ① `watch_status` 的 `session` 段取的是「第一条守的会话」
42
+
43
+ `statusView` 里 `sessionId = list[0].sessionId`。当这台机器上同时挂着**多个会话**的守时,
44
+ `used / cap` 报的是 `list[0]` 那个会话的额度 —— 客户看到「已用 11/12」,
45
+ 其实是**另一个会话**用掉的,自己这边还很宽裕(或者反过来)。
46
+
47
+ 现在优先用**当前会话**的 id;拿不到(纯 CLI 场景)才退回 `list[0]`。
48
+
49
+ ### ② `watch_doctor` 自称 `Read-only`,却往工作目录写文件
50
+
51
+ 它为了验证「隔离工作目录可写」,会写一个 `.dsh-doctor-probe` 再立刻删掉。
52
+ 描述里写的是 `Read-only; prints a checklist.` —— 客户和模型都以为它完全不碰磁盘。
53
+
54
+ 两条路:去掉探针检查,或者如实描述。**选了后者** —— 提前发现「目录不可写」是有价值的
55
+ (第一次唤醒建 worktree 才会失败,那时客户已经在等结果了)。
56
+
57
+ 描述改成:*does not change any watcher config, but it does write one temporary probe file
58
+ inside the isolation workdir (and deletes it immediately) to prove the directory is writable.*
59
+
60
+ 输出里也加了一行 `OK 隔离工作目录可写(写过一个临时探针并已删除)` —— 让客户知道刚才发生了什么。
61
+
62
+ ### 证据
63
+
64
+ ```
65
+ npm test → 377/377
66
+ preflight --fast → 全部通过
67
+ ```
68
+
5
69
  ## [0.9.233] - 2026-11-05 —— 模型照着说明书做,也一定会失败的四条
6
70
 
7
71
  ### ① `watch_stop` 停不掉 Gitee 守(最危险的一条)
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.233-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.235-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
  [![awesome](https://img.shields.io/badge/awesome-dsh--plugin-%E2%9C%93-success.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
@@ -146,7 +146,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
146
146
  ## 开发
147
147
 
148
148
  ```sh
149
- npm test # 377 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
149
+ npm test # 378 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
150
150
  ```
151
151
 
152
152
  ### 工具输出:文本给人和 agent,JSON 给程序
@@ -198,7 +198,7 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
198
198
  ## 验收(不用装宿主也能跑)
199
199
 
200
200
  ```bash
201
- npm test # 377 项单测(带离线开关,约 1.6 秒)
201
+ npm test # 378 项单测(带离线开关,约 1.6 秒)
202
202
  node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
203
203
  node scripts/preflight.mjs # 40 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
204
204
  node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
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.233'
17
+ const CLIENT_VERSION = '0.9.235'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
package/lib/index.js CHANGED
@@ -39,11 +39,12 @@ import {
39
39
  itemTrace,
40
40
  splitBatch,
41
41
  mergeFilters, mergePollResult, mergeWakeTexts, pushEvent, silentStreak, msUntilActiveWindow, nextWaketimeAt, pruneSeen, sessionWakesLastHour, pruneWakeTimes, pushHistory, recordReported, staleWorktrees, worktreePlan,
42
+ validateActiveHours,
42
43
  } from './watch.js'
43
44
 
44
45
  export const name = 'dsh-session-superagent'
45
46
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
46
- export const SERVER_VERSION = '0.9.233'
47
+ export const SERVER_VERSION = '0.9.235'
47
48
  export const inject = ['tools', 'agents', 'webServer']
48
49
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
49
50
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
@@ -2448,7 +2449,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2448
2449
  ctx.tools.register(defineTool({
2449
2450
  name: 'watch_doctor',
2450
2451
  description:
2451
- 'Self-check the watchers: gh login, repo access, ack label existence, isolation workdir. Read-only; prints a checklist.',
2452
+ 'Self-check the watchers: gh login, repo access, ack label existence, isolation workdir. Prints a checklist. It does not change any watcher config, but it does write one temporary probe file inside the isolation workdir (and deletes it immediately) to prove the directory is writable.',
2452
2453
  parameters: {
2453
2454
  repo: { type: 'string', description: 'only check this owner/name; default = every watcher' },
2454
2455
  format: { type: 'string', description: "'text' (default) or 'json'." },
@@ -2589,10 +2590,13 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2589
2590
  const gitRes = await run('git', ['-C', wd, 'rev-parse', '--is-inside-work-tree'], { timeoutMs: 15000 })
2590
2591
  lines.push(`${gitRes.code === 0 ? 'OK ' : 'FAIL'} 隔离工作目录 ${wd}:${gitRes.code === 0 ? '是 git 仓库' : '不是 git 仓库'}`)
2591
2592
  // 目录在但不可写时,第一次唤醒建 worktree 就会失败(真机上更常见的是权限/磁盘)
2593
+ // 审核 T32:这里确实会**写一个探针文件**(再立刻删)。
2594
+ // 以前描述写「Read-only」,客户和模型都以为它完全不碰磁盘 —— 已改成如实描述。
2592
2595
  const probe = join(wd, '.dsh-doctor-probe')
2593
2596
  try {
2594
2597
  writeFileSync(probe, String(Date.now()))
2595
2598
  rmSync(probe, { force: true })
2599
+ lines.push(`OK 隔离工作目录可写(写过一个临时探针并已删除)`)
2596
2600
  } catch (error) {
2597
2601
  lines.push(`FAIL 隔离工作目录不可写:${wd}(${String((error && error.code) || error).slice(0, 40)})`)
2598
2602
  }
@@ -2678,9 +2682,9 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2678
2682
 
2679
2683
  ctx.tools.register(defineTool({
2680
2684
  name: 'watch_start',
2681
- description: 'Watch a GitHub repository and wake THIS session when its issues or pull requests change. Idempotent per (repo, session). Default interval 60 s, minimum 30 s.',
2685
+ description: 'Watch a repository and wake THIS session when its issues or pull requests change. Works with GitHub (owner/name) and Gitee (prefix with gitee:, e.g. gitee:owner/name; a gitee.com URL also works). Pass several repos in one call separated by spaces or commas to create several watchers at once. Idempotent per (repo, session). Default interval 60 s, minimum 30 s.',
2682
2686
  parameters: {
2683
- repo: { type: 'string', description: 'owner/name. Omit to infer from the current working directory.' },
2687
+ repo: { type: 'string', description: 'owner/name (GitHub) 或 gitee:owner/name(Gitee);多个用空格或逗号分隔。Omit to infer from the current working directory.' },
2684
2688
  intervalSec: { type: 'number', description: 'Polling interval in seconds, clamped to 30-3600, default 60.' },
2685
2689
  labels: { type: 'array', items: { type: 'string' }, description: 'Only handle items carrying one of these labels (whitelist).' },
2686
2690
  ignoreLabels: { type: 'array', items: { type: 'string' }, description: 'Skip items carrying any of these labels.' },
@@ -2753,7 +2757,13 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2753
2757
  if (!existsSync(workdir)) return toolError(args, 'workdir does not exist: ' + workdir)
2754
2758
  entry.workdir = workdir
2755
2759
  }
2756
- if (typeof args.activeHours === 'string') entry.activeHours = args.activeHours.trim() || null
2760
+ // 审核 T32:以前格式写错(`9-23`)会**静默变成全天有效**,回执照样打 [activeHours=9-23]。
2761
+ // 现在先校验,不合法就拒绝并说清正确格式 —— 宁可当场报错,也不要「以为设了其实没设」。
2762
+ if (typeof args.activeHours === 'string') {
2763
+ const hoursCheck = validateActiveHours(args.activeHours)
2764
+ if (!hoursCheck.ok) return toolError(args, 'activeHours ' + hoursCheck.reason)
2765
+ entry.activeHours = hoursCheck.normalized || null
2766
+ }
2757
2767
  if (typeof args.batchLimit === 'number') entry.batchLimit = Math.max(1, Math.min(20, Math.round(args.batchLimit)))
2758
2768
  if (typeof args.maxWakesPerHour === 'number') entry.maxWakesPerHour = Math.max(1, Math.min(60, Math.round(args.maxWakesPerHour)))
2759
2769
  // 面板能改的三项,工具也要能改 —— 否则被问"把隔离区最多留 3 个"时 agent 无从下手
@@ -2833,8 +2843,13 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2833
2843
  const state = readState()
2834
2844
  const list = Object.values(state.watchers || {})
2835
2845
  if (!list.length) return args && args.format === 'json' ? JSON.stringify({ schemaVersion: 1, session: null, watchers: [] }) : '(no watchers)'
2846
+ // 审核 T32:`session` 段以前取 `list[0].sessionId` —— 多个会话的守混在一起时,
2847
+ // `used / cap` 报的是**别人**的额度。现在优先用当前会话;拿不到才退回 list[0]。
2848
+ const wsAgents = agentsService(ctx)
2849
+ const wsAgent = wsAgents && typeof wsAgents.currentInitiator === 'function' ? wsAgents.currentInitiator() : undefined
2850
+ const wsSessionId = (wsAgent && wsAgent.id) || undefined
2836
2851
  // 同一份数据:结构化视图 -> 文本只是它的一种渲染,两边永远对得上
2837
- const view = statusView(list)
2852
+ const view = statusView(list, wsSessionId ? { sessionId: wsSessionId } : {})
2838
2853
  if (args && args.format === 'json') return JSON.stringify(view, null, 2)
2839
2854
  // 默认只写「这条守是什么」;只有当它需要你注意时才追加原因。
2840
2855
  // 以前每行都带 lastPoll/lastWake/err=-,十条守就是十行长日志。
package/lib/watch.js CHANGED
@@ -1281,3 +1281,27 @@ export function effectiveIntervalMs(entry, baseMs) {
1281
1281
  const floor = (Number(entry && entry.minIntervalSec) || 0) * 1000
1282
1282
  return Math.max(Number(baseMs) || 0, floor)
1283
1283
  }
1284
+
1285
+ /**
1286
+ * `activeHours` 格式校验(审核 T32)。
1287
+ *
1288
+ * 以前格式写错(`9-23`、`09:00~23:00`、`9:00-25:00`)时 `inActiveHours` 直接 `return true` ——
1289
+ * **静默变成「全天有效」**,而工具回执照样打 `[activeHours=9-23]`。
1290
+ * 客户以为设了时段,实际一直开着。
1291
+ *
1292
+ * 现在创建时先校验:合法返回 `{ ok: true }`,不合法返回 `{ ok: false, reason }`,
1293
+ * 由调用方**拒绝**并说清正确格式。
1294
+ */
1295
+ export function validateActiveHours(spec) {
1296
+ if (spec === null || spec === undefined || spec === '') return { ok: true, empty: true }
1297
+ const text = String(spec).trim()
1298
+ const m = text.match(/^(\d{1,2}):(\d{2})\s*-\s*(\d{1,2}):(\d{2})$/)
1299
+ if (!m) {
1300
+ return { ok: false, reason: '格式要写成 HH:MM-HH:MM(例如 09:00-23:00),收到的是「' + text + '」' }
1301
+ }
1302
+ const bad = [m[1], m[2], m[3], m[4]].map(Number)
1303
+ if (bad[0] > 23 || bad[2] > 23 || bad[1] > 59 || bad[3] > 59) {
1304
+ return { ok: false, reason: '时要在 00-23、分要在 00-59(格式 HH:MM-HH:MM,例如 09:00-23:00),收到的是「' + text + '」' }
1305
+ }
1306
+ return { ok: true, normalized: text }
1307
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.233",
3
+ "version": "0.9.235",
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",