dsh-session-superagent 0.8.63 → 0.8.65

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,41 @@
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.65] - 2026-11-02 —— 关闭 Issues / 是 fork 的仓库,提前说清楚
6
+
7
+ ### 学到的(知识库第 14 条)
8
+ `GET /repos` 自带结构信息:`has_issues` / `fork` / `parent.full_name`(本机实测都在)。
9
+ 主理鱼只认 issue / PR,所以「关闭了 Issues」的仓库注定永远安静 ——
10
+ 客户会以为插件坏了。
11
+
12
+ (诚实标注:想抓 fork 文档正文说明"fork 默认不带 Issues"时页面没给出可读文本,
13
+ 这句按社区常识使用、未取得官方引用;因此对 **自己开了 Issues 的 fork 不提示**,避免误伤。)
14
+
15
+ ### 改了什么
16
+ - `probeAccess` 一并取 `fork / hasIssues / parent`,存进 `entry.repoAccess`;
17
+ - `/state` 回传 `repoAccess`;
18
+ - 面板「需要关注」区新增两条人话提示(**排在轮询失败之前**):
19
+ - `o/r 关闭了 Issues —— 主理鱼只认 issue / PR,这里不会有任何条目可接。`
20
+ - `me/r 是 up/r 的 fork。fork 默认不带 Issues … 确认你要守的是哪一个。`
21
+
22
+ ### 测试
23
+ - 新增 1 例(5 种情况)。合计 **118 例**。
24
+
25
+ ## [0.8.64] - 2026-11-02 —— 只读仓库提前说清楚,别等它吃 403
26
+
27
+ ### 学到的(知识库第 13 条)
28
+ `GET /repos/{owner}/{repo}` 返回 `permissions: { admin, push, pull … }` ——
29
+ 「你对这个仓库能做什么」的权威答案,读之前就知道,不用试一次拿 403。
30
+ <https://docs.github.com/en/rest/repos/repos#get-a-repository>
31
+
32
+ ### 改了什么
33
+ - 新增守时**后台**查一次仓库权限(不阻塞创建),存 `entry.repoAccess`;
34
+ - `push === false` 时唤醒消息多一行 `【权限提示】… 只有读权限 …`;
35
+ - 还没探测到(未知)时**不猜、不提示**。
36
+
37
+ ### 测试
38
+ - 新增 1 例:有写权限不提示 / null 与空对象不提示 / 只读给人话 / 消息里单独成行。合计 **117 例**。
39
+
5
40
  ## [0.8.63] - 2026-11-02 —— 面板显示 token 权限范围,宽 scope 会提醒
6
41
 
7
42
  ### 学到的(知识库第 12 条)
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` 116/116 通过
12
+ - [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test` 118/118 通过
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.63-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.8.65-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 # 116 项单测
102
+ node --test # 118 项单测
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.63'
17
+ const CLIENT_VERSION = '0.8.65'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1057,6 +1057,9 @@ window.__ModuleLoader__.load({
1057
1057
 
1058
1058
  const problems = []
1059
1059
  for (const watcher of watchers) {
1060
+ // 仓库结构问题(关闭 Issues / 是 fork)比轮询失败更早该说:它注定收不到条目
1061
+ const structure = repoStructureNote(watcher.repoAccess)
1062
+ if (structure) problems.push({ key: 's-' + watcher.repo, text: structure })
1060
1063
  if (watcher.lastError) problems.push({ key: 'e-' + watcher.repo, text: watcher.repo + ' 轮询失败:' + watcher.lastError })
1061
1064
  else if (watcher.lastDeferred) problems.push({ key: 'd-' + watcher.repo, text: watcher.repo + ' 暂停唤醒:' + watcher.lastDeferred })
1062
1065
  }
@@ -1276,6 +1279,17 @@ window.__ModuleLoader__.load({
1276
1279
  return () => { alive = false }
1277
1280
  }, [])
1278
1281
 
1282
+ /** 仓库结构提示(与服务端 watch.js:repoStructureNote 同语义;客户端要独立一份,不能跨包 import)。 */
1283
+ function repoStructureNote(access) {
1284
+ if (!access || typeof access !== 'object') return ''
1285
+ const repo = String(access.repo || '这个仓库')
1286
+ if (access.hasIssues === false) return repo + ' 关闭了 Issues —— 主理鱼只认 issue / PR,这里不会有任何条目可接。'
1287
+ if (access.fork === true && access.parent && access.hasIssues !== true) {
1288
+ return repo + ' 是 ' + String(access.parent) + ' 的 fork。fork 默认不带 Issues,issue 大多落在上游 —— 确认你要守的是哪一个。'
1289
+ }
1290
+ return ''
1291
+ }
1292
+
1279
1293
  /** 人话字节数:客户看的是"3.2 MB",不是 3355443。 */
1280
1294
  function bytesText(n) {
1281
1295
  const value = Number(n) || 0
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
- classifyGhError, countReasons, filterReason, hasAckLabel, jitterMs, parseGhInclude, retryAfterMs, throttleDelayMs, inActiveHours, newestUpdatedAt, nextDelayMs, pushFiltered, normalizeFilters, partitionItems, passesFilters,
27
+ accessNote, classifyGhError, 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.63'
33
+ export const SERVER_VERSION = '0.8.65'
34
34
  export const inject = ['tools', 'agents', 'webServer']
35
35
 
36
36
  /** 仅供测试:读写状态文件(生产代码不要用)。 */
@@ -738,6 +738,8 @@ async function pollOnce(ctx, entry, baseMs) {
738
738
  isolation,
739
739
  // entry.goal 之前只写不读:现在真的进唤醒消息
740
740
  goal: entry.goal || '',
741
+ // 只读仓库要在任务书里直说,否则会话会去试写然后吃 403
742
+ access: accessNote(entry.repoAccess),
741
743
  // 完成标准要可观测(Given-When-Then 的思路):三件事缺一不算完成
742
744
  criteria: [
743
745
  '改了什么:文件清单 + 一句话为什么(别只写"已修复")',
@@ -783,6 +785,27 @@ export function apply(ctx) {
783
785
  // 跨模块实例共享:旧实例还没跑完的那轮,新实例不能同时再跑一遍。
784
786
  const inFlight = sharedInFlight
785
787
 
788
+ /** 后台查一次仓库权限:push=false 说明只能读,回写评论/标签都会 403。 */
789
+ const probeAccess = async (entry) => {
790
+ try {
791
+ const res = await run('gh', ['api', 'repos/' + entry.repo, '--jq',
792
+ '{push: .permissions.push, private: .private, fork: .fork, hasIssues: .has_issues, parent: (.parent.full_name // null)}'],
793
+ { timeoutMs: 20000, env: ghEnv() })
794
+ if (res.code !== 0) return
795
+ const info = JSON.parse(res.stdout)
796
+ entry.repoAccess = {
797
+ repo: entry.repo,
798
+ push: info.push === true,
799
+ private: info.private === true,
800
+ fork: info.fork === true,
801
+ hasIssues: info.hasIssues !== false,
802
+ parent: info.parent || null,
803
+ checkedAt: new Date().toISOString(),
804
+ }
805
+ persistEntry(entry)
806
+ } catch { /* 探测失败不影响主流程 */ }
807
+ }
808
+
786
809
  const startWatcher = (entry) => {
787
810
  if (timers.has(entry.id)) return
788
811
  const every = Math.max(30, Number(entry.intervalSec) || 60) * 1000
@@ -928,6 +951,7 @@ export function apply(ctx) {
928
951
  observe: w.observe === true,
929
952
  filteredLog: (w.filteredLog ?? []).slice(-5),
930
953
  filterCounts: w.filterCounts ?? {},
954
+ repoAccess: w.repoAccess ?? null,
931
955
  lastBatch: w.lastBatch ?? [],
932
956
  isolated: w.isolated === true,
933
957
  workdir: w.workdir ?? null,
@@ -1084,6 +1108,8 @@ export function apply(ctx) {
1084
1108
  // 编辑已有 watcher 时,间隔/配置变化要立刻生效:startWatcher 会因为 timer 已存在而直接返回
1085
1109
  if (entry.enabled) {
1086
1110
  stopWatcher(id)
1111
+ probeAccess(entry).catch(() => {})
1112
+
1087
1113
  startWatcher(entry)
1088
1114
  }
1089
1115
  json(res, 200, { ok: true, id, repo, intervalSec, enabled: entry.enabled })
package/lib/watch.js CHANGED
@@ -133,6 +133,7 @@ export function formatWatchText(repo, fresh, options = {}) {
133
133
  })()
134
134
  // 完成标准要「可观测」:只说"做好它"等于没说。
135
135
  // 依据:Given-When-Then 的核心是把验收写成可观察的结果(martinfowler.com/bliki/GivenWhenThen.html)。
136
+ const accessLine = options.access ? String.fromCharCode(10) + '【权限提示】' + options.access : ''
136
137
  const criteria = Array.isArray(options.criteria) ? options.criteria.filter(Boolean).slice(0, 4) : []
137
138
  const criteriaLine = criteria.length > 0
138
139
  ? String.fromCharCode(10) + '【完成标准】' + String.fromCharCode(10)
@@ -145,6 +146,7 @@ export function formatWatchText(repo, fresh, options = {}) {
145
146
  moreLine +
146
147
  isoLine +
147
148
  goalLine +
149
+ accessLine +
148
150
  criteriaLine +
149
151
  '\n\n先读仓库 AGENTS.md 的判断规则,再决定「修 / 回 / 待定」。完成标准 = 有测试结果:没跑测试不算完成,跑不了就写清原因;做完一条就写回 GitHub,并调用 watch_ack 打上已处理标签,不要扩大范围。'
150
152
  )
@@ -552,3 +554,40 @@ export function countReasons(counts, reason, { maxKinds = 12 } = {}) {
552
554
  const entries = Object.entries(map).sort((a, b) => b[1] - a[1]).slice(0, maxKinds)
553
555
  return Object.fromEntries(entries)
554
556
  }
557
+
558
+ /**
559
+ * 仓库权限提示:只读仓库上我们**没法**回写结果(评论、打标签都会 403)。
560
+ *
561
+ * 依据:`GET /repos/{owner}/{repo}` 返回 `permissions.push`,官方文档里这个对象就是
562
+ * "你有没有写权限"的权威来源。事先知道,比跑到一半才发现 403 好。
563
+ * 出处:https://docs.github.com/en/rest/repos/repos#get-a-repository
564
+ */
565
+ export function accessNote(repoAccess) {
566
+ if (!repoAccess || typeof repoAccess !== 'object') return ''
567
+ if (repoAccess.push === true) return ''
568
+ if (repoAccess.push === false) {
569
+ return '你对 ' + String(repoAccess.repo || '这个仓库') + ' 只有读权限:能看、能被叫醒,但没法回写评论或打标签 —— '
570
+ + '要么换有写权限的 token,要么把结论写在本地/PR 描述里。'
571
+ }
572
+ return ''
573
+ }
574
+
575
+ /**
576
+ * 仓库结构提示:主理鱼只认 issue/PR,所以「这个仓库没有 issue」要提前说。
577
+ *
578
+ * 依据:`GET /repos/{owner}/{repo}` 返回 `has_issues` / `fork` / `parent.full_name`
579
+ * (本机实测这三个字段都在:`{fork, has_issues, parent, private}`)。
580
+ * 出处:https://docs.github.com/en/rest/repos/repos#get-a-repository
581
+ */
582
+ export function repoStructureNote(repoAccess) {
583
+ if (!repoAccess || typeof repoAccess !== 'object') return ''
584
+ const repo = String(repoAccess.repo || '这个仓库')
585
+ if (repoAccess.hasIssues === false) {
586
+ return repo + ' 关闭了 Issues —— 主理鱼只认 issue / PR,这里不会有任何条目可接。'
587
+ }
588
+ if (repoAccess.fork === true && repoAccess.parent && repoAccess.hasIssues !== true) {
589
+ return repo + ' 是 ' + String(repoAccess.parent) + ' 的 fork。fork 默认不带 Issues,'
590
+ + 'issue 大多落在上游 —— 确认你要守的是哪一个(守上游就把仓库填成 ' + String(repoAccess.parent) + ')。'
591
+ }
592
+ return ''
593
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.8.63",
3
+ "version": "0.8.65",
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",