dsh-session-superagent 0.8.69 → 0.8.70

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,26 @@
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.8.70] - 2026-11-02 —— 唤醒消息补「最后是谁在说话」
6
+
7
+ ### 学到的(知识库第 19 条)
8
+ 评论是**独立资源**(issue 对象只带 `comments` 计数),要"最后一条评论是谁"必须单独取一次
9
+ —— 这是有成本的信息。`sort=created&direction=desc&per_page=1` 一次拿到。
10
+ <https://docs.github.com/en/rest/issues/comments#list-issue-comments>
11
+
12
+ ### 为什么值得
13
+ 会话被叫醒后第一件事是判断「是不是已经有人处理了」。我们原来只给 issue 作者 + 更新时间,
14
+ 但**更新时间可能是我自己打标签引起的**,作者永远是开 issue 的人 —— 真正该看的是最后一条评论。
15
+
16
+ ### 改了什么(成本受控)
17
+ - 只对批次**前 3 条**且 `comments > 0` 的条目取;
18
+ - 并发取、单条 12 秒超时;
19
+ - 失败**静默省略**该行,绝不阻断唤醒;
20
+ - 消息里呈现 `最后评论: @helper 2026-11-02T07:00:00Z`。
21
+
22
+ ### 测试
23
+ - 新增 1 例:null / 空对象 / 只有 login / 完整信息 / 出现在消息里。合计 **123 例**。
24
+
5
25
  ## [0.8.69] - 2026-11-02 —— 填错仓库名时给个"是不是想填 X"
6
26
 
7
27
  ### 学到的(知识库第 18 条,实测数字)
package/MAINTENANCE.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## 二、当前状态(2026-11-01)
11
11
 
12
- - [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test` 122/122 通过
12
+ - [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test` 123/123 通过
13
13
  - [x] 自回声抑制(逐条水位)
14
14
  - [x] 仅空闲注入(避免草稿回放)
15
15
  - [x] 唤醒失败不推进水位
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.8.69-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.8.70-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
 
@@ -99,7 +99,7 @@ dsh plugin install /path/to/dsh-session-superagent
99
99
  ## 开发
100
100
 
101
101
  ```sh
102
- node --test # 122 项单测
102
+ node --test # 123 项单测
103
103
  ```
104
104
 
105
105
  版本与发布流程见 [UPDATING.md](UPDATING.md),交付门见 [CHECKLIST.md](CHECKLIST.md),接手台账见 [MAINTENANCE.md](MAINTENANCE.md)。
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.8.69'
17
+ const CLIENT_VERSION = '0.8.70'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
package/lib/index.js CHANGED
@@ -24,13 +24,13 @@ import { redact } from './redact.js'
24
24
  import { decodeBody } from './body.js'
25
25
  import {
26
26
  advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, formatWatchText,
27
- accessNote, classifyGhError, pickSuggestion, repoStructureNote, countReasons, filterReason, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, pushFiltered, normalizeFilters, partitionItems, passesFilters,
27
+ accessNote, classifyGhError, commentSummaryLine, pickSuggestion, repoStructureNote, countReasons, filterReason, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, pushFiltered, normalizeFilters, partitionItems, passesFilters,
28
28
  mergeFilters, mergePollResult, pruneSeen, pruneWakeTimes, pushHistory, recordReported, staleWorktrees, worktreePlan,
29
29
  } from './watch.js'
30
30
 
31
31
  export const name = 'dsh-session-superagent'
32
32
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
33
- export const SERVER_VERSION = '0.8.69'
33
+ export const SERVER_VERSION = '0.8.70'
34
34
  export const inject = ['tools', 'agents', 'webServer']
35
35
 
36
36
  /** 仅供测试:读写状态文件(生产代码不要用)。 */
@@ -647,6 +647,25 @@ function dirSize(path, depth) {
647
647
  return total
648
648
  }
649
649
 
650
+
651
+ /**
652
+ * 取一批 issue 的「最后评论」。并发跑、短超时、最多 3 条、失败静默 ——
653
+ * 多出来的 API 调用只在这几种条件下发生,别让它变成常态开销。
654
+ */
655
+ async function fetchLastComments(repo, items, maxItems = 3) {
656
+ const targets = (items || []).filter((item) => Number(item.comments) > 0).slice(0, maxItems)
657
+ if (targets.length === 0) return
658
+ await Promise.all(targets.map(async (item) => {
659
+ try {
660
+ const res = await run('gh', ['api', `repos/${repo}/issues/${item.number}/comments?per_page=1&sort=created&direction=desc`,
661
+ '--jq', '.[0] | {login: .user.login, at: .created_at}'], { timeoutMs: 12000, env: ghEnv() })
662
+ if (res.code !== 0) return
663
+ const parsed = JSON.parse(res.stdout)
664
+ if (parsed && parsed.login) item.lastComment = { login: parsed.login, at: parsed.at }
665
+ } catch { /* 少一行信息,不阻断唤醒 */ }
666
+ }))
667
+ }
668
+
650
669
  async function pollOnce(ctx, entry, baseMs) {
651
670
  // 条件请求:带上上次的 ETag,没变化时 GitHub 回 304,且**不计入**速率限制
652
671
  const args = ['api', '--include', `repos/${entry.repo}/issues?state=all&sort=updated&direction=desc&per_page=20`]
@@ -788,6 +807,8 @@ async function pollOnce(ctx, entry, baseMs) {
788
807
 
789
808
  const isolation = await prepareIsolation(entry)
790
809
  if (isolation && isolation.dir) entry.lastWorktree = isolation.dir
810
+ // 批次前几条补「最后是谁在说话」(最多 3 条,失败静默)
811
+ await fetchLastComments(entry.repo, listed)
791
812
  const result = wake(ctx, entry.sessionId, formatWatchText(entry.repo, listed, {
792
813
  more: rest.length,
793
814
  restNumbers: rest.map((item) => item.number),
package/lib/watch.js CHANGED
@@ -102,6 +102,7 @@ export function formatWatchText(repo, fresh, options = {}) {
102
102
  labels.length > 0 ? `标签: ${labels.join(', ')}` : null,
103
103
  (item.assignees ?? []).length > 0 ? `指派: ${item.assignees.map((a) => '@' + a.login).join(' ')}` : null,
104
104
  item.html_url,
105
+ item.lastComment ? '最后评论: ' + commentSummaryLine(item.lastComment) : null,
105
106
  ].filter(Boolean).join(' ')
106
107
  return `#${item.number} [${item.state}] ${item.title} — @${who} ${tail}`
107
108
  })
@@ -639,3 +640,21 @@ export function pickSuggestion(query, candidates) {
639
640
  const contains = list.find((name) => name.toLowerCase().includes(exactName) && exactName.length >= 4)
640
641
  return contains || null
641
642
  }
643
+
644
+ /**
645
+ * 「最后是谁在说话」:一条 issue 的最后评论者与时间。
646
+ *
647
+ * 为什么要它:会话被叫醒后第一件事就是判断「是不是已经有人处理了」。
648
+ * 只给 issue 作者和更新时间不够 —— 更新时间可能是我自己打的标签引起的。
649
+ *
650
+ * 代价:每条 issue 一次 `GET /issues/{n}/comments`,所以只在**评论数 > 0** 且**批次前几条**里取,
651
+ * 失败就静默省略(宁可少一行,不要拖慢唤醒)。
652
+ * 出处:https://docs.github.com/en/rest/issues/comments#list-issue-comments
653
+ */
654
+ export function commentSummaryLine(lastComment) {
655
+ if (!lastComment || typeof lastComment !== 'object') return ''
656
+ const who = lastComment.login ? '@' + String(lastComment.login) : ''
657
+ const when = lastComment.at ? String(lastComment.at) : ''
658
+ if (!who && !when) return ''
659
+ return [who, when].filter(Boolean).join(' ')
660
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.8.69",
3
+ "version": "0.8.70",
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",