dsh-session-superagent 0.9.252 → 0.9.255

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,143 @@
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.255] - 2026-11-05 —— 叫醒之后没有回执,那条就静默消失了
6
+
7
+ ### 问题(《为什么做这个产品》里排第二的缺口)
8
+
9
+ `seen` 水位线一旦前移,同一条只要**内容没再更新**,就**永远不会再被提起**。
10
+
11
+ 于是这个真实场景没有出路:
12
+
13
+ ```
14
+ 叫醒 → 会话开始干 → 中途被打断 / 换个话题 / 宿主重启 → 没有 ack
15
+ → 下一轮轮询:没有新变化 → 这条再也不会出现 → 活干到一半就没了
16
+ ```
17
+
18
+ 官方原型用 Ticket 的 `open → ended` 状态机表达「这条还在进行中」。我们不做完整状态机,
19
+ 只补最要命的那一条:**提过但没回执的,下一轮再提一次**。
20
+
21
+ ### 三条硬约束(全部来自「不打断」)
22
+
23
+ | 约束 | 值 | 为什么 |
24
+ |---|---|---|
25
+ | 次数上限 | 2 次 | 提满了就放弃,不再打扰 |
26
+ | 冷却期 | 10 分钟 | 刚提过的那一轮不提,别紧接着又提 |
27
+ | 只提还开着的 | — | 关掉了就说明不用干了 |
28
+
29
+ 而且**不挤掉新条目**:先排新的,有位置才给重提的。
30
+
31
+ 唤醒消息里标出来,否则会话会以为是新事件:
32
+
33
+ ```
34
+ #7 [open] 修登录流程的空指针 — @alice … ↻ 上一轮提过,还没回执(第 2 次)
35
+ ```
36
+
37
+ ### 顺带修掉一个会静默失效的坑
38
+
39
+ `POLL_RESULT_FIELDS` 是**手维护的落盘白名单** —— 加字段忘了加它,就是「算出来了但没存」。
40
+ 这轮新增的 `acked` / `pending` 两处都补了进去,并加了一条用例直接断言它们在白名单里。
41
+
42
+ (这个坑在 0.9.194 已经踩过一次,那次一次漏了 13 个字段。)
43
+
44
+ ### 证据
45
+
46
+ ```
47
+ npm test → 397/397(新增:冷却期/次数上限/关掉的不提/ack 后不提/消息要标出「第几次」)
48
+ ```
49
+
50
+ ## [0.9.254] - 2026-11-05 —— 上一轮那个功能,其实一行都没生效
51
+
52
+ T40 把「工具能做的 vs 面板能做的」对了一遍,第一刀就砍在上一轮:
53
+
54
+ ### M2 · `allowAuthors` 两条路都是死的
55
+
56
+ 0.9.252 给面板加了「只理这些人提的」输入框,提示写着「不在名单里的人提的 issue/PR **不会叫醒你**」。
57
+
58
+ 而 `mergeFilters()` 里**没有这个键** —— `watch_start`(工具)和 `/watch`(面板)**都走它**,
59
+ 于是两条路都把它静默丢成 `[]`。**功能等于不存在,而 394 条用例全绿。**
60
+
61
+ 原因很典型:我的用例只测了 `filterReason` / `normalizeFilters` 这两个**纯函数**,
62
+ 没有一条走 `watch_start → mergeFilters → 状态文件` 的真实链路。
63
+ **断言强度和实现强度不匹配。**
64
+
65
+ 已修,并补了一条**真的读状态文件**的用例。
66
+
67
+ ### M1 · 同一个上限,两个入口给出相反答案
68
+
69
+ `/watch` 的 20 条上限把**已暂停**的守也算进去,而工具侧只数在跑的。
70
+ 于是 20 条全停之后:面板回 `429 一条会话最多挂 20 条守`(还不给路),模型却能建。
71
+
72
+ 这正是 0.9.233 在工具路径上修过的**同一个死结**,HTTP 路径漏了。已同步,并在报错里说清怎么办。
73
+
74
+ ### M3 · Gitee 编号连「追溯」按钮都不生成
75
+
76
+ 面板追溯只认 `^#?[0-9]+$`,而 Gitee 的编号是 `IKSQJH` 这种字符串 ——
77
+ **「这条为什么没叫醒我」正是这个产品的核心诉求**,在 Gitee 仓库上却用不了。
78
+
79
+ 已放宽到字母数字(工具 `watch_trace` 早就支持了)。
80
+
81
+ ### 一个教训
82
+
83
+ 三个 bug 有两个是「两条路径同一件事、只改了一条」:上限、`mergeFilters`。
84
+ **只要一个能力有两个入口,就必须有跨入口的用例** —— 纯函数单测挡不住这类分叉。
85
+
86
+ ### 证据
87
+
88
+ ```
89
+ npm test → 394/394(新增:allowAuthors 走真实链路读状态文件;停一条后能再加)
90
+ ```
91
+
92
+ ## [0.9.253] - 2026-11-05 —— 从初衷往回看:叫醒之后,我们什么都没记
93
+
94
+ ### 先想清楚为什么做这个产品
95
+
96
+ 新增 `docs/为什么做这个产品.md`。核心判断:
97
+
98
+ > 同类产品都在回答「**代码写得不够快**」(CodeRabbit 评审、Devin 交付、各种 issue bot 开 PR)。
99
+ > 对一个人盯几个仓库的开发者,瓶颈**不是写代码** —— 是**注意力**和**上下文**。
100
+ >
101
+ > 所以这个产品只做一件事:**把仓库的动态,翻译成这个会话里可以直接开工的任务。**
102
+
103
+ 三条不变量(以后每个功能都拿它来对):
104
+
105
+ | 诉求 | 判据 |
106
+ |---|---|
107
+ | **不打断** | 会让唤醒变多的功能,收益必须大到值得 |
108
+ | **不留手尾** | 唤醒消息本身要是一份能直接开工的任务书 |
109
+ | **不失控** | 任何「自动做掉」的能力,都要先回答「做错了谁负责、怎么撤回」 |
110
+
111
+ 同时把官方原型的对比落成 `docs/对比-官方原型.md`。
112
+
113
+ ### 按这份文档排优先级,最大的缺口是「叫醒之后」
114
+
115
+ 我们记了「这条被叫醒过」,但**没记「怎么处理的」**。
116
+ 于是同一条被重开时,会话只能**重新判一遍** —— 直接违背诉求 2。
117
+
118
+ ### 改法:`watch_ack` 加 `note`
119
+
120
+ ```
121
+ watch_ack({ number: 7, note: '已修,见 #57' })
122
+ ```
123
+
124
+ 下次这条再被叫醒,唤醒消息里会带上:
125
+
126
+ ```
127
+ #7 [open] 修登录流程的空指针 — @alice (issue) https://x/7 未认领
128
+ ↩ 上次处理(2026-11-01):已修,见 #57
129
+ ```
130
+
131
+ - 有界:只留最近 **20** 条(超了丢最旧的,别让状态文件又变成 T36 那个无底洞);
132
+ - 没记过就不显示,不硬编;
133
+ - 文本回执也会说「记下了:…」,免得模型以为没存。
134
+
135
+ ### 证据
136
+
137
+ ```
138
+ npm test → 393/393(新增:上次处理的话要原样带回、没记过不硬编)
139
+ wake-samples → 最长行仍 120 字符
140
+ ```
141
+
5
142
  ## [0.9.252] - 2026-11-05 —— 抄官方原型最该抄的那一条:谁可以给你派活
6
143
 
7
144
  ### 背景
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.252-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.255-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 # 392 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
149
+ npm test # 397 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
150
150
  ```
151
151
 
152
152
  ### 工具输出:文本给人和 agent,JSON 给程序
@@ -206,7 +206,7 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
206
206
 
207
207
 
208
208
  ```bash
209
- npm test # 392 项单测(带离线开关,约 1.6 秒)
209
+ npm test # 397 项单测(带离线开关,约 1.6 秒)
210
210
  node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
211
211
  node scripts/preflight.mjs # 40 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
212
212
  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.252'
17
+ const CLIENT_VERSION = '0.9.255'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1632,9 +1632,11 @@ window.__ModuleLoader__.load({
1632
1632
  },
1633
1633
  (() => {
1634
1634
  const needle = search.trim()
1635
- const asNumber = /^#?[0-9]+$/.test(needle) ? needle.replace('#', '') : ''
1635
+ // 审核 T40 M3:以前只认纯数字 —— Gitee 的编号是 IKSQJH 这种字符串,
1636
+ // 于是**连追溯按钮都不生成**。而「这条为什么没叫醒我」正是这个产品的核心诉求。
1637
+ const asNumber = /^#?[A-Za-z0-9_-]+$/.test(needle) ? needle.replace(/^#/, '') : ''
1636
1638
  const onlyRepo = watchers.length === 1 ? watchers[0].repo : ''
1637
- return h(Section, { key: 'trace', title: '追溯一条', hint: '在右上角搜索框输入编号(如 42),就能查它经历了什么:被过滤、已唤醒,还是根本没轮到' },
1639
+ return h(Section, { key: 'trace', title: '追溯一条', hint: '在右上角搜索框输入编号(GitHub 如 42,Gitee 如 IKSQJH),就能查它经历了什么:被过滤、已唤醒,还是根本没轮到' },
1638
1640
  asNumber
1639
1641
  ? h('div', { className: 'dt-row-meta' },
1640
1642
  h('button', {
package/docs/README.md CHANGED
@@ -1,29 +1,31 @@
1
- # 文档索引
2
-
3
- 按「什么时候读」排,不按重要程度:
4
-
5
- | 文档 | 什么时候读 |
6
- |---|---|
7
- | [README](../README.md) | 第一次接触这个插件:它做什么、怎么装、界面在哪、故障排查 |
8
- | [01-架构](01-架构.md) | 要改服务端逻辑:分层、11 步轮询管线、状态文件与落盘规则 |
9
- | [design-system](design-system.md) | 要改界面:35 个设计 token、常用组件类、加页面的检查清单 |
10
- | [official-gui-ia](official-gui-ia.md) | 想知道「官方原版长什么样、我们砍了什么、为什么」 |
11
- | [awesome-submission](awesome-submission.md) | 要提交到 awesome-dsh-plugin:现成的 YAML、图标、核对结论 |
12
- | [competitive-analysis](competitive-analysis.md) | 想知道和 Sweep / CodeRabbit 这类工具的差别 |
13
- | [deepseek-papers](deepseek-papers.md) | 想知道设计取舍背后的研究依据 |
14
- | [真机验证清单](真机验证清单.md) | 重启后三条命令 + 三个动作,5 分钟确认新代码在跑 |
15
- | [首次唤醒走查](首次唤醒走查.md) | 新客户照着走一遍:7 步 + 每步该看到什么 |
16
- | [kb/](kb/README.md) | 每轮外部学习沉淀:出处 / 做法 / 我们能怎么用 / 是否已落地 |
17
- | [optimization-plan](optimization-plan.md) | 要挑活时:11 项 UI/可靠性/客户体验指标 + 当前分数 + 下一批目标 |
18
- | [ui-inventory](ui-inventory.md) | 要改界面时:渲染面 → 页签 → 二级 → 三级 → 官方原语对照,逐条标差异 |
19
- | [review-2026-11-01](review-2026-11-01.md) | 历次严格审核的结论与遗留项(含每项的闭环状态) |
20
-
21
- 仓库根部还有三份「维护用」的:`MAINTENANCE.md`(维护者视角的现状与门禁)、
22
- `HANDOFF.md`(会话交接:坑列表、验证台账、下一步)、`CHECKLIST.md`(发布前逐条打勾)。
23
-
24
- ## 时效性
25
-
26
- - `README` / `01-架构` / `design-system` / `HANDOFF` / `optimization-plan` / `ui-inventory` 随代码更新,**以代码为准**;
27
- - `official-gui-ia` 是对官方 0.1.0 的考古快照,不会跟随官方变化;
28
- - `review-*` 是当时的事实记录,不追改(后续闭环写在表格里,不改原文结论);
29
- - `awesome-submission` 里的门槛时间点会过期,提交前重新核对 `contributing.md`。
1
+ # 文档索引
2
+
3
+ 按「什么时候读」排,不按重要程度:
4
+
5
+ | 文档 | 什么时候读 |
6
+ |---|---|
7
+ | [README](../README.md) | 第一次接触这个插件:它做什么、怎么装、界面在哪、故障排查 |
8
+ | [01-架构](01-架构.md) | 要改服务端逻辑:分层、11 步轮询管线、状态文件与落盘规则 |
9
+ | [design-system](design-system.md) | 要改界面:35 个设计 token、常用组件类、加页面的检查清单 |
10
+ | [official-gui-ia](official-gui-ia.md) | 想知道「官方原版长什么样、我们砍了什么、为什么」 |
11
+ | [awesome-submission](awesome-submission.md) | 要提交到 awesome-dsh-plugin:现成的 YAML、图标、核对结论 |
12
+ | [为什么做这个产品](为什么做这个产品.md) | **动任何功能之前先读**:谁在痛、三条不变量(不打断 / 不留手尾 / 不失控)、明确不做什么 |
13
+ | [对比-官方原型](对比-官方原型.md) | 想知道和官方 `dsh-superagent-prototype` 的功能差距、哪些该抄哪些不该 |
14
+ | [competitive-analysis](competitive-analysis.md) | 想知道和 Sweep / CodeRabbit 这类工具的差别 |
15
+ | [deepseek-papers](deepseek-papers.md) | 想知道设计取舍背后的研究依据 |
16
+ | [真机验证清单](真机验证清单.md) | 重启后三条命令 + 三个动作,5 分钟确认新代码在跑 |
17
+ | [首次唤醒走查](首次唤醒走查.md) | 新客户照着走一遍:7 步 + 每步该看到什么 |
18
+ | [kb/](kb/README.md) | 每轮外部学习沉淀:出处 / 做法 / 我们能怎么用 / 是否已落地 |
19
+ | [optimization-plan](optimization-plan.md) | 要挑活时:11 项 UI/可靠性/客户体验指标 + 当前分数 + 下一批目标 |
20
+ | [ui-inventory](ui-inventory.md) | 要改界面时:渲染面 → 页签 → 二级 → 三级 → 官方原语对照,逐条标差异 |
21
+ | [review-2026-11-01](review-2026-11-01.md) | 历次严格审核的结论与遗留项(含每项的闭环状态) |
22
+
23
+ 仓库根部还有三份「维护用」的:`MAINTENANCE.md`(维护者视角的现状与门禁)、
24
+ `HANDOFF.md`(会话交接:坑列表、验证台账、下一步)、`CHECKLIST.md`(发布前逐条打勾)。
25
+
26
+ ## 时效性
27
+
28
+ - `README` / `01-架构` / `design-system` / `HANDOFF` / `optimization-plan` / `ui-inventory` 随代码更新,**以代码为准**;
29
+ - `official-gui-ia` 是对官方 0.1.0 的考古快照,不会跟随官方变化;
30
+ - `review-*` 是当时的事实记录,不追改(后续闭环写在表格里,不改原文结论);
31
+ - `awesome-submission` 里的门槛时间点会过期,提交前重新核对 `contributing.md`。
package/lib/index.js CHANGED
@@ -27,6 +27,7 @@ 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
29
  effectiveIntervalMs, planWakeSettlement, advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
30
+ recordPendingWake, clearPending, pendingRetry,
30
31
  parseRepoSpec, markGiteeReopened,
31
32
  TRIAGE_SIGNALS, accessNote, wakeCriteria, sessionMissingVerdict, buildCommentBatchQuery, classifyGhError, commentSummaryLine, parseCommentBatch, pickSuggestion, repoStructureNote, countReasons, filterReason, formatGhCall, diagnoseEmptyBody, diagnoseBadBody, isAuthBroken, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, enterActiveHoursDefer, recordOtherError, permanentBackoffMs, RETRY_BUDGET_ATTEMPTS, RETRY_SLOW_CAP_MINUTES, pushAbsorbed, pushFiltered, normalizeFilters, partitionItems, passesFilters,
32
33
  shouldRunCleanup,
@@ -44,7 +45,7 @@ import {
44
45
 
45
46
  export const name = 'dsh-session-superagent'
46
47
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
47
- export const SERVER_VERSION = '0.9.252'
48
+ export const SERVER_VERSION = '0.9.255'
48
49
  export const inject = ['tools', 'agents', 'webServer']
49
50
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
50
51
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
@@ -1389,7 +1390,19 @@ async function pollWithItems(ctx, entry, baseMs, parsed) {
1389
1390
  // 审核 T21:这里原来有个从没用过的 const limit(死代码),且兜底值写成 || 3,
1390
1391
  // 与创建时的 batchLimit=5 口径分裂。统一成 5,并删掉死变量。
1391
1392
  const batchLimit = Math.max(1, Number(entry.batchLimit) || 5)
1393
+ // 「提过但没回执」的条目再提一次:水位线不会因为「没 ack」而回退,所以它们平时永远不会再出现。
1394
+ // 并进这一轮,但**不挤掉新条目**:先排新条目,剩下的位置才给重提的。
1395
+ const pendingResult = pendingRetry(entry.pending, items, {})
1396
+ if (pendingResult.stillPending && Object.keys(pendingResult.stillPending).length !== Object.keys(entry.pending || {}).length) {
1397
+ entry.pending = pendingResult.stillPending
1398
+ }
1392
1399
  const { listed, rest } = splitBatch(fresh, batchLimit, entry.priorityOrder || entry.priority)
1400
+ if (pendingResult.retry.length > 0 && listed.length < batchLimit) {
1401
+ const room = batchLimit - listed.length
1402
+ const numbersAlready = new Set(listed.map((item) => String(item.number)))
1403
+ const extra = pendingResult.retry.filter((item) => !numbersAlready.has(String(item.number))).slice(0, room)
1404
+ listed.push(...extra)
1405
+ }
1393
1406
  // 暂停/删除可能发生在这一轮轮询期间:以盘上为准
1394
1407
  const liveEntry = (readState().watchers || {})[entry.id]
1395
1408
  if (!liveEntry || !isEnabled(liveEntry)) {
@@ -1473,6 +1486,8 @@ async function pollWithItems(ctx, entry, baseMs, parsed) {
1473
1486
  }
1474
1487
  return map
1475
1488
  })(),
1489
+ // 上次 ack 时留的话(watch_ack 的 note):同一条再被叫醒时一并带回
1490
+ acked: entry.acked && typeof entry.acked === 'object' ? entry.acked : null,
1476
1491
  })
1477
1492
  entry.lastWakeCount = fresh.length
1478
1493
  entry.lastBatch = listed.map((item) => item.number)
@@ -1505,6 +1520,11 @@ async function pollWithItems(ctx, entry, baseMs, parsed) {
1505
1520
  entry.seen = settled.seen
1506
1521
  entry.lastReported = settled.lastReported
1507
1522
  entry.cursor = settled.cursor
1523
+ // 「叫醒未回执」跟踪(Ticket 状态机的最小版):提过的条目记下来,
1524
+ // 下一轮若仍开着且没 ack,会再提一次(有次数上限与冷却期,见 pendingRetry)。
1525
+ try {
1526
+ entry.pending = recordPendingWake(entry.pending, listed.map((item) => item.number))
1527
+ } catch { /* 记账失败不影响唤醒 */ }
1508
1528
  commitEtag()
1509
1529
  } else {
1510
1530
  // 保留水位,下一轮重试这次事件
@@ -1983,9 +2003,12 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
1983
2003
  // 审核 T19:新建没有任何上限 —— 100 次 POST 就是 100 条守(每条一个定时器)。
1984
2004
  // 工具路径早就有 MAX_WATCHERS_PER_SESSION,HTTP 路径漏了;这里再补一个全局上限。
1985
2005
  if (created) {
1986
- const mine = Object.values(state.watchers).filter((w) => w && w.sessionId === sessionId)
2006
+ // 审核 T40 M1:这里以前把**已暂停**的守也算进上限 —— 而工具侧只数在跑的。
2007
+ // 结果:20 条全停之后,面板回 429「最多挂 20 条」(且不给路),模型却能建。
2008
+ // 同一会话两个入口给出相反答案。0.9.233 在工具路径上修过同一个死结,这条路漏了。
2009
+ const mine = Object.values(state.watchers).filter((w) => w && w.sessionId === sessionId && w.enabled !== false)
1987
2010
  if (mine.length >= MAX_WATCHERS_PER_SESSION) {
1988
- return json(res, 429, { error: '一条会话最多挂 ' + MAX_WATCHERS_PER_SESSION + ' 条守' })
2011
+ return json(res, 429, { error: '一条会话最多同时挂 ' + MAX_WATCHERS_PER_SESSION + ' 条在跑的守(现在 ' + mine.length + ' 条)—— 先暂停或删除不用的' })
1989
2012
  }
1990
2013
  if (Object.keys(state.watchers).length >= MAX_WATCHERS_TOTAL) {
1991
2014
  return json(res, 429, { error: '全局最多 ' + MAX_WATCHERS_TOTAL + ' 条守' })
@@ -2332,6 +2355,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2332
2355
  number: { type: ['number', 'string'], description: 'issue or PR number(Gitee 的编号是字符串,如 IKSQJH)' },
2333
2356
  numbers: { type: 'string', description: '逗号分隔的多个编号,如 "12,13,14"(number 与 numbers 至少填一个)' },
2334
2357
  label: { type: 'string', description: 'ack label, default 主理鱼:已处理' },
2358
+ note: { type: 'string', description: '可选:一句话记下这条最后怎么处理的(如「已修,见 #57」「不修,上游已修」)。下次这条再被叫醒时会带回来,省得会话重新判一遍。' },
2335
2359
  format: { type: 'string', description: "'text' (default) or 'json'." },
2336
2360
  },
2337
2361
  async execute(args) {
@@ -2414,6 +2438,18 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2414
2438
  // 打标签本身就是一次外部更新,把光标推到当下,避免自己把自己叫醒
2415
2439
  live.cursor = nowIso
2416
2440
  live.lastAcked = { numbers: results, label, at: nowIso }
2441
+ // 回执到了,这条路走通了 —— 不用再提
2442
+ live.pending = clearPending(live.pending, results)
2443
+ // 「叫醒之后」的闭环(见 docs/为什么做这个产品.md 诉求 2):
2444
+ // 以前只记「叫醒过」,不记「怎么处理的」—— 同一条被重开时会话只能重新判一遍。
2445
+ // 有界:只留最近 20 条,超出丢最旧的。
2446
+ const note = typeof args.note === 'string' ? args.note.trim().slice(0, 200) : ''
2447
+ if (note) {
2448
+ const acked = { ...(live.acked || {}) }
2449
+ for (const number of results) acked[String(number)] = { at: nowIso, note }
2450
+ const keep = Object.entries(acked).sort((a, b) => String(b[1].at).localeCompare(String(a[1].at))).slice(0, 20)
2451
+ live.acked = Object.fromEntries(keep)
2452
+ }
2417
2453
  writeState(latest)
2418
2454
  }
2419
2455
  if (args && args.format === 'json') {
@@ -2421,6 +2457,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2421
2457
  return JSON.stringify({ schemaVersion: 1, ok: true, repo: entry.repo, label, acked: results, at: nowIso, labelNote: labelNote || null })
2422
2458
  }
2423
2459
  return `acked ${entry.repo} #${results.join(' #')} with label "${label}"` + labelNote
2460
+ + (typeof args.note === 'string' && args.note.trim() ? '|记下了:' + args.note.trim().slice(0, 200) : '')
2424
2461
  },
2425
2462
  }))
2426
2463
 
package/lib/watch.js CHANGED
@@ -159,6 +159,14 @@ export function formatWatchText(repo, fresh, options = {}) {
159
159
  (options.seenBefore && options.seenBefore[String(item.number)])
160
160
  ? '⏰ 之前叫醒过(' + String(options.seenBefore[String(item.number)]).slice(0, 10) + ')'
161
161
  : null,
162
+ // Ticket 「open」状态的最小版:这条上一轮提过,但没等到回执
163
+ (item.retryOf ? '↻ 上一轮提过,还没回执(第 ' + (Number(item.retryOf.tries) + 1) + ' 次)' : null),
164
+ // 诉求 2「不留手尾」:同一条被重开/再叫醒时,告诉会话上次是怎么处理的,
165
+ // 别让它重新判一遍。(数据来自 watch_ack 的 note,见 INDEX 的 acked)
166
+ (options.acked && options.acked[String(item.number)])
167
+ ? '↩ 上次处理(' + String(options.acked[String(item.number)].at).slice(0, 10) + '):'
168
+ + String(options.acked[String(item.number)].note)
169
+ : null,
162
170
  item.lastComment
163
171
  ? '最后评论: ' + commentSummaryLine({
164
172
  login: item.lastComment.self ? '' : item.lastComment.login,
@@ -650,6 +658,9 @@ export const POLL_RESULT_FIELDS = [
650
658
  'etag', 'needsReauth', 'lastErrorAt', 'deferReason', 'silentWakes', 'prevWakeAt',
651
659
  'dailyWakes', 'absorbedLog', 'filterCounts', 'repoAccess', 'sessionMissingSince',
652
660
  'minIntervalSec', 'lastCleanupAt',
661
+ // 「叫醒之后」的两块记录:漏了它们,ack 留的话和「提过没回执」都会在写盘时被静默丢掉
662
+ //(这个白名单是手维护的 —— 加字段忘了加这里,功能就静默失效)
663
+ 'acked', 'pending',
653
664
  ]
654
665
 
655
666
  /**
@@ -695,6 +706,11 @@ export function mergeFilters(base, patch) {
695
706
  if ('skipClosed' in patch) next.skipClosed = patch.skipClosed !== false
696
707
  if ('onlyAssigned' in patch) next.onlyAssigned = patch.onlyAssigned === true
697
708
  if ('assignee' in patch) next.assignee = normalizeFilters({ assignee: patch.assignee }).assignee
709
+ // 审核 T40 M2:`allowAuthors` 加进 normalizeFilters 时漏了这里 ——
710
+ // 而 watch_start(工具)和 /watch(面板)**都走 mergeFilters**,于是这个字段两条路都被静默丢弃,
711
+ // 面板上还写着「不在名单里的人提的 issue/PR 不会叫醒你」。功能等于不存在,而测试全绿
712
+ //(用例只测了 filterReason/normalizeFilters,没走真实链路)。
713
+ if ('allowAuthors' in patch) next.allowAuthors = normalizeFilters({ allowAuthors: patch.allowAuthors }).allowAuthors
698
714
  return next
699
715
  }
700
716
 
@@ -1350,3 +1366,58 @@ export function validateActiveHours(spec) {
1350
1366
  }
1351
1367
  return { ok: true, normalized: text }
1352
1368
  }
1369
+
1370
+ /**
1371
+ * 「叫醒未回执」的条目(Ticket 状态机的最小版)。
1372
+ *
1373
+ * 问题:`seen` 水位线一旦前移,同一条只要内容没再更新就**永远不会再被提起**。
1374
+ * 于是「叫醒了 → 会话干到一半被打断 → 没有 ack」这一条就**静默消失**了。
1375
+ * 而官方原型用 Ticket 的 `open → ended` 状态机表达「这条还在进行中」。
1376
+ *
1377
+ * 我们不做完整状态机,只补这一条最要命的:**提过但没回执的,下一轮再提一次**。
1378
+ *
1379
+ * 三条硬约束(都来自「不打断」):
1380
+ * 1. 有次数上限(默认 2 次),提满了就放弃,不再打扰;
1381
+ * 2. 冷却期:刚提过的那一轮不提(默认 10 分钟),别紧接着又提;
1382
+ * 3. 只提**还开着**的条目 —— 关掉了就说明不用干了。
1383
+ */
1384
+ export function recordPendingWake(pending, numbers, at = new Date().toISOString()) {
1385
+ const map = { ...(pending && typeof pending === 'object' ? pending : {}) }
1386
+ for (const n of numbers || []) {
1387
+ const key = String(n)
1388
+ const prev = map[key]
1389
+ map[key] = { first: (prev && prev.first) || at, at, tries: ((prev && prev.tries) || 0) + 1 }
1390
+ }
1391
+ return map
1392
+ }
1393
+
1394
+ /** ack 之后清掉(这条路走通了,不用再提)。 */
1395
+ export function clearPending(pending, numbers) {
1396
+ const map = { ...(pending && typeof pending === 'object' ? pending : {}) }
1397
+ for (const n of numbers || []) delete map[String(n)]
1398
+ return map
1399
+ }
1400
+
1401
+ /**
1402
+ * 这一轮该不该把「提过但没回执」的条目再提一次。
1403
+ * @returns {{ retry: Array<object>, stillPending: object }} retry 是要并进批次的条目
1404
+ */
1405
+ export function pendingRetry(pending, items, options = {}) {
1406
+ const { maxTries = 2, cooldownMs = 10 * 60 * 1000, now = Date.now() } = options
1407
+ const map = pending && typeof pending === 'object' ? pending : {}
1408
+ const byNumber = new Map((items || []).map((item) => [String(item && item.number), item]))
1409
+ const retry = []
1410
+ const stillPending = { ...map }
1411
+ for (const [key, record] of Object.entries(map)) {
1412
+ const item = byNumber.get(key)
1413
+ // 条目已经不在这一页了(关了/删了):不再提,也不清(可能只是翻页没包含它)
1414
+ if (!item) continue
1415
+ if (item.state && item.state !== 'open') { delete stillPending[key]; continue }
1416
+ const tries = Number(record && record.tries) || 0
1417
+ if (tries >= maxTries) { delete stillPending[key]; continue }
1418
+ const at = Date.parse(String((record && record.at) || ''))
1419
+ if (Number.isFinite(at) && now - at < cooldownMs) continue
1420
+ retry.push({ ...item, retryOf: { tries, first: record && record.first, at: record && record.at } })
1421
+ }
1422
+ return { retry, stillPending }
1423
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.252",
3
+ "version": "0.9.255",
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",