dsh-session-superagent 0.8.70 → 0.8.71

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,24 @@
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.71] - 2026-11-02 —— 「最后一条是我发的」不能当成"有人在处理"
6
+
7
+ ### 学到的(知识库第 20 条)
8
+ REST 用 `GET /user` 表示"我是谁"(GraphQL 叫 `viewer`)。本机实测 `gh api user --jq .login` 可用。
9
+ <https://docs.github.com/en/rest/users/users#get-the-authenticated-user>
10
+
11
+ ### 为什么这是要命的 bug 级歧义
12
+ 上一轮加了「最后评论: @helper 时间」。可如果最后一条**是我们自己**在上一轮留下的,
13
+ 会话会误判成"已经有人在处理",于是什么都不做 —— **最坏的一种静默失效**。
14
+
15
+ ### 改了什么
16
+ - 取评论时同时拿 `/user`(**缓存 10 分钟**),比较后标记 `self`;
17
+ - 消息里呈现 `最后评论: 我(上一轮留的) 2026-11-02T06:00:00Z`;
18
+ - 大小写不敏感;拿不到"我是谁"时**照常显示 @login**,不猜。
19
+
20
+ ### 测试
21
+ - 新增 1 例(4 种情况)。合计 **124 例**。
22
+
5
23
  ## [0.8.70] - 2026-11-02 —— 唤醒消息补「最后是谁在说话」
6
24
 
7
25
  ### 学到的(知识库第 19 条)
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` 123/123 通过
12
+ - [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test` 124/124 通过
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.70-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.8.71-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 # 123 项单测
102
+ node --test # 124 项单测
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.70'
17
+ const CLIENT_VERSION = '0.8.71'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
package/lib/index.js CHANGED
@@ -30,7 +30,7 @@ import {
30
30
 
31
31
  export const name = 'dsh-session-superagent'
32
32
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
33
- export const SERVER_VERSION = '0.8.70'
33
+ export const SERVER_VERSION = '0.8.71'
34
34
  export const inject = ['tools', 'agents', 'webServer']
35
35
 
36
36
  /** 仅供测试:读写状态文件(生产代码不要用)。 */
@@ -652,16 +652,32 @@ function dirSize(path, depth) {
652
652
  * 取一批 issue 的「最后评论」。并发跑、短超时、最多 3 条、失败静默 ——
653
653
  * 多出来的 API 调用只在这几种条件下发生,别让它变成常态开销。
654
654
  */
655
+
656
+ /** 当前 token 对应的账号(判断"最后一条评论是不是我们自己发的")。缓存 10 分钟。 */
657
+ let viewerCache = { at: 0, login: null }
658
+ async function viewerLogin() {
659
+ if (viewerCache.login && Date.now() - viewerCache.at < 10 * 60 * 1000) return viewerCache.login
660
+ try {
661
+ const res = await run('gh', ['api', 'user', '--jq', '.login'], { timeoutMs: 12000, env: ghEnv() })
662
+ if (res.code === 0) {
663
+ const login = String(res.stdout || '').trim()
664
+ if (login) { viewerCache = { at: Date.now(), login }; return login }
665
+ }
666
+ } catch {}
667
+ return viewerCache.login
668
+ }
669
+
655
670
  async function fetchLastComments(repo, items, maxItems = 3) {
656
671
  const targets = (items || []).filter((item) => Number(item.comments) > 0).slice(0, maxItems)
657
672
  if (targets.length === 0) return
673
+ const me = await viewerLogin()
658
674
  await Promise.all(targets.map(async (item) => {
659
675
  try {
660
676
  const res = await run('gh', ['api', `repos/${repo}/issues/${item.number}/comments?per_page=1&sort=created&direction=desc`,
661
677
  '--jq', '.[0] | {login: .user.login, at: .created_at}'], { timeoutMs: 12000, env: ghEnv() })
662
678
  if (res.code !== 0) return
663
679
  const parsed = JSON.parse(res.stdout)
664
- if (parsed && parsed.login) item.lastComment = { login: parsed.login, at: parsed.at }
680
+ if (parsed && parsed.login) item.lastComment = { login: parsed.login, at: parsed.at, self: Boolean(me && String(parsed.login).toLowerCase() === me.toLowerCase()) }
665
681
  } catch { /* 少一行信息,不阻断唤醒 */ }
666
682
  }))
667
683
  }
package/lib/watch.js CHANGED
@@ -102,7 +102,12 @@ 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
+ item.lastComment
106
+ ? '最后评论: ' + commentSummaryLine({
107
+ login: item.lastComment.self ? '' : item.lastComment.login,
108
+ at: item.lastComment.at,
109
+ }, null) + (item.lastComment.self ? '我(上一轮留的)' : '')
110
+ : null,
106
111
  ].filter(Boolean).join(' ')
107
112
  return `#${item.number} [${item.state}] ${item.title} — @${who} ${tail}`
108
113
  })
@@ -651,9 +656,14 @@ export function pickSuggestion(query, candidates) {
651
656
  * 失败就静默省略(宁可少一行,不要拖慢唤醒)。
652
657
  * 出处:https://docs.github.com/en/rest/issues/comments#list-issue-comments
653
658
  */
654
- export function commentSummaryLine(lastComment) {
659
+ export function commentSummaryLine(lastComment, viewer) {
655
660
  if (!lastComment || typeof lastComment !== 'object') return ''
656
- const who = lastComment.login ? '@' + String(lastComment.login) : ''
661
+ const login = lastComment.login ? String(lastComment.login) : ''
662
+ // 最后一条是"我们自己"发的,意义完全不同:那不是"有人在处理",而是上一轮留下的痕迹。
663
+ // 依据:GET /user 返回当前 token 对应的账号(本机实测:`gh api user --jq .login` → 我们的账号名)。
664
+ // 出处:https://docs.github.com/en/rest/users/users#get-the-authenticated-user
665
+ const isSelf = Boolean(login && viewer && login.toLowerCase() === String(viewer).toLowerCase())
666
+ const who = login ? (isSelf ? '我(上一轮留的)' : '@' + login) : ''
657
667
  const when = lastComment.at ? String(lastComment.at) : ''
658
668
  if (!who && !when) return ''
659
669
  return [who, when].filter(Boolean).join(' ')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.8.70",
3
+ "version": "0.8.71",
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",