dsh-session-superagent 0.8.79 → 0.8.81
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 +35 -0
- package/MAINTENANCE.md +1 -1
- package/README.md +2 -2
- package/client.js +1 -1
- package/lib/index.js +5 -2
- package/lib/watch.js +48 -3
- package/package.json +1 -1
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.81] - 2026-11-02 —— 草稿 PR 要标出来,别当成"有人在推进"
|
|
6
|
+
|
|
7
|
+
### 学到的(知识库第 30 条)
|
|
8
|
+
GraphQL `PullRequest.isDraft`(本机实测 `cli/cli` 前 3 个 open PR 全是 `isDraft: true`)。
|
|
9
|
+
草稿 PR 不触发通知、不能合并 —— 作者明确表示"还没准备好"。
|
|
10
|
+
<https://docs.github.com/en/graphql/reference/objects#pullrequest>
|
|
11
|
+
|
|
12
|
+
### 为什么值得
|
|
13
|
+
上一轮加了「已有 PR 在做」。但如果是草稿,会话可能误判"有人推进,我不用管" —— 漏活。
|
|
14
|
+
现在区分:`已有 PR #20(进行中·草稿)`;合并态即使 `isDraft=true` 也不加后缀(防御性)。
|
|
15
|
+
|
|
16
|
+
### 测试
|
|
17
|
+
- 用例扩充(草稿带后缀 / 合并态不带后缀)。合计 **132 例**。
|
|
18
|
+
|
|
19
|
+
## [0.8.80] - 2026-11-02 —— 「已经有 PR 在做了」:避免重复劳动
|
|
20
|
+
|
|
21
|
+
### 学到的(知识库第 29 条)
|
|
22
|
+
GraphQL `CrossReferencedEvent` 能拿到引用过这条 issue 的 PR;`source` 是 **union**,
|
|
23
|
+
必须 `source { __typename ... on PullRequest { … } }`,否则报
|
|
24
|
+
`Selections can't be made directly on unions`(实测踩到)。
|
|
25
|
+
<https://docs.github.com/en/graphql/reference/objects#crossreferencedevent>
|
|
26
|
+
|
|
27
|
+
### 为什么值得
|
|
28
|
+
评论只能看出"有人在说话",**关联 PR** 才能看出"已经有人在写代码"。
|
|
29
|
+
会话最怕重复劳动:其实已经有人开了 PR,它又从零改一遍。
|
|
30
|
+
|
|
31
|
+
### 改了什么(零额外请求)
|
|
32
|
+
把时间线查询**挂进已有的批量 GraphQL**,解析出关联 PR:
|
|
33
|
+
- 去重、忽略非 PR 引用;
|
|
34
|
+
- 排序 `OPEN > MERGED > CLOSED`;
|
|
35
|
+
- 消息里提示 `已有 PR #20(进行中)` / `已有 PR #21(已合并)` / `等 N 个`。
|
|
36
|
+
|
|
37
|
+
### 测试
|
|
38
|
+
- 新增 1 例(open 优先/去重/忽略 Issue 类型/null 源/各状态文案/等 N 个/消息提醒)。合计 **132 例**。
|
|
39
|
+
|
|
5
40
|
## [0.8.79] - 2026-11-02 —— 「躺了 62 天」:积压看得见
|
|
6
41
|
|
|
7
42
|
### 学到的(知识库第 28 条)
|
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`
|
|
12
|
+
- [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test` 132/132 通过
|
|
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)
|
|
6
|
-
[](https://github.com/MYCF711/dsh-session-superagent/releases)
|
|
7
7
|
[](https://www.npmjs.com/package/dsh-session-superagent)
|
|
8
8
|
[](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 #
|
|
102
|
+
node --test # 132 项单测
|
|
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.
|
|
17
|
+
const CLIENT_VERSION = '0.8.81'
|
|
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.
|
|
33
|
+
export const SERVER_VERSION = '0.8.81'
|
|
34
34
|
export const inject = ['tools', 'agents', 'webServer']
|
|
35
35
|
|
|
36
36
|
/** 仅供测试:读写状态文件(生产代码不要用)。 */
|
|
@@ -691,7 +691,10 @@ async function fetchLastComments(repo, items, maxItems = 3) {
|
|
|
691
691
|
let hit = 0
|
|
692
692
|
for (const item of targets) {
|
|
693
693
|
const info = parsed[String(item.number)]
|
|
694
|
-
if (info)
|
|
694
|
+
if (!info) continue
|
|
695
|
+
if (info.login) mark(item, info)
|
|
696
|
+
if (Array.isArray(info.linked) && info.linked.length > 0) item.linkedPr = info.linked
|
|
697
|
+
hit += 1
|
|
695
698
|
}
|
|
696
699
|
if (hit > 0) return
|
|
697
700
|
} catch { /* 落到 REST 兜底 */ }
|
package/lib/watch.js
CHANGED
|
@@ -105,6 +105,7 @@ export function formatWatchText(repo, fresh, options = {}) {
|
|
|
105
105
|
(stateReasonNote(item) && String(item.state_reason || '') === 'reopened') ? '⚠ ' + stateReasonNote(item) : null,
|
|
106
106
|
assignmentNote(item) || null,
|
|
107
107
|
(item.state === 'open' ? stalenessNote(item) : '') || null,
|
|
108
|
+
linkedPrNote(item.linkedPr) || null,
|
|
108
109
|
item.lastComment
|
|
109
110
|
? '最后评论: ' + commentSummaryLine({
|
|
110
111
|
login: item.lastComment.self ? '' : item.lastComment.login,
|
|
@@ -716,7 +717,10 @@ export function buildCommentBatchQuery(count) {
|
|
|
716
717
|
const n = Math.max(0, Math.min(10, Number(count) || 0))
|
|
717
718
|
const parts = []
|
|
718
719
|
for (let i = 0; i < n; i += 1) {
|
|
719
|
-
parts.push(' i' + i + ': issue(number: $n' + i + ') { number
|
|
720
|
+
parts.push(' i' + i + ': issue(number: $n' + i + ') { number'
|
|
721
|
+
+ ' comments(last: 1) { nodes { author { login } createdAt } }'
|
|
722
|
+
+ ' timelineItems(last: 5, itemTypes: [CROSS_REFERENCED_EVENT]) { nodes { ... on CrossReferencedEvent {'
|
|
723
|
+
+ ' source { __typename ... on PullRequest { number state url isDraft } } } } } }')
|
|
720
724
|
}
|
|
721
725
|
const vars = Array.from({ length: n }, (_, i) => '$n' + i + ': Int!').join(', ')
|
|
722
726
|
return 'query($owner: String!, $name: String!' + (n > 0 ? ', ' + vars : '') + ') {'
|
|
@@ -740,8 +744,13 @@ export function parseCommentBatch(payload) {
|
|
|
740
744
|
const node = Array.isArray(nodes) && nodes.length > 0 ? nodes[nodes.length - 1] : null
|
|
741
745
|
if (!node) continue
|
|
742
746
|
const login = node.author && node.author.login ? String(node.author.login) : ''
|
|
743
|
-
|
|
744
|
-
|
|
747
|
+
const linked = pickLinkedPullRequests(value.timelineItems && value.timelineItems.nodes)
|
|
748
|
+
if (!login && linked.length === 0) continue
|
|
749
|
+
out[String(value.number)] = {
|
|
750
|
+
login,
|
|
751
|
+
at: node.createdAt ? String(node.createdAt) : '',
|
|
752
|
+
linked,
|
|
753
|
+
}
|
|
745
754
|
}
|
|
746
755
|
return out
|
|
747
756
|
}
|
|
@@ -819,3 +828,39 @@ export function stalenessNote(item, options = {}) {
|
|
|
819
828
|
if (days < threshold) return ''
|
|
820
829
|
return '躺了 ' + days + ' 天'
|
|
821
830
|
}
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* 从 cross-reference 时间线里挑出关联的 PR。
|
|
834
|
+
*
|
|
835
|
+
* 依据:`timelineItems(itemTypes: [CROSS_REFERENCED_EVENT])` 会给出引用过这条 issue 的 PR;
|
|
836
|
+
* 注意 `source` 是 union,**必须带 `__typename`** 才能选到 PullRequest 的字段
|
|
837
|
+
* (直接选 `source { number }` 会报 "Selections can't be made directly on unions")。
|
|
838
|
+
* 出处:https://docs.github.com/en/graphql/reference/objects#crossreferencedevent
|
|
839
|
+
*/
|
|
840
|
+
export function pickLinkedPullRequests(nodes) {
|
|
841
|
+
const list = Array.isArray(nodes) ? nodes : []
|
|
842
|
+
const seen = new Set()
|
|
843
|
+
const out = []
|
|
844
|
+
for (const node of list) {
|
|
845
|
+
const source = node && node.source
|
|
846
|
+
if (!source || source.__typename !== 'PullRequest' || !source.number) continue
|
|
847
|
+
if (seen.has(source.number)) continue
|
|
848
|
+
seen.add(source.number)
|
|
849
|
+
out.push({ number: source.number, state: String(source.state || ''), url: String(source.url || ''), draft: source.isDraft === true })
|
|
850
|
+
}
|
|
851
|
+
// open 的排前面(说明真在做),merged 其次,closed 最后
|
|
852
|
+
const rank = { OPEN: 0, MERGED: 1, CLOSED: 2 }
|
|
853
|
+
return out.sort((a, b) => (rank[a.state] ?? 9) - (rank[b.state] ?? 9))
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/** 「已经有 PR 在做了」——避免会话重复干活。 */
|
|
857
|
+
export function linkedPrNote(linked) {
|
|
858
|
+
const list = Array.isArray(linked) ? linked.filter((item) => item && item.number) : []
|
|
859
|
+
if (list.length === 0) return ''
|
|
860
|
+
const first = list[0]
|
|
861
|
+
const stateText = first.state === 'OPEN' ? '进行中' : first.state === 'MERGED' ? '已合并' : first.state === 'CLOSED' ? '已关闭' : String(first.state || '')
|
|
862
|
+
// 草稿 PR 说明"还没准备好":别让会话以为对方在推进
|
|
863
|
+
const draftText = first.state === 'OPEN' && first.draft === true ? '·草稿' : ''
|
|
864
|
+
return '已有 PR #' + first.number + (stateText || draftText ? '(' + stateText + draftText + ')' : '')
|
|
865
|
+
+ (list.length > 1 ? ' 等 ' + list.length + ' 个' : '')
|
|
866
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.81",
|
|
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",
|