dsh-session-superagent 0.9.177 → 0.9.179
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 +72 -0
- package/README.md +2 -2
- package/client.js +1 -1
- package/lib/gitee.js +11 -4
- package/lib/index.js +21 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,78 @@
|
|
|
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.179] - 2026-11-04 —— 兼容 DSH 0.2.2-rc.1(静态核对)+ Gitee 增量轮询
|
|
6
|
+
|
|
7
|
+
### 一、DSH 0.2.2-rc.1 兼容核对(不装新版也能查)
|
|
8
|
+
`npm dist-tags` 显示 `next = 0.2.2-rc.1`。逐个比对 `.d.ts`(而不是读 release notes):
|
|
9
|
+
|
|
10
|
+
| 检查 | 结果 |
|
|
11
|
+
|---|---|
|
|
12
|
+
| CLI 包 `lib/types/*.d.ts` | 与 0.2.1-rc.5 **逐字相同** |
|
|
13
|
+
| `dsh-web-app`(webServer 服务) | 逐字相同 |
|
|
14
|
+
| `dsh-goal`(goals 服务) | 逐字相同 |
|
|
15
|
+
| cordis 4.0.5 → 4.1.0 | `ctx.effect` / `ctx.on` / `ctx.get` 契约不变;**日志级别数值重排**(INFO/WARN 互换);provision 形状 `{fiber}` → `{ctx,uid}` |
|
|
16
|
+
| Node 引擎 | 新宿主要求 **≥24.9.0**(我们声明 ≥22.19,是下界,没问题) |
|
|
17
|
+
|
|
18
|
+
**改了一处**:`apply()` 先检查 `ctx.tools`,缺了只打一条日志就返回 ——
|
|
19
|
+
即使某个服务改名,也只是"这个插件不工作",不会拖垮整棵插件树。
|
|
20
|
+
|
|
21
|
+
### 二、Gitee 增量轮询(看 Gitee 帮助中心时顺手挖到的)
|
|
22
|
+
Gitee 没有 ETag,之前每轮全量读。实测它**支持 `since`**:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
全量 34 条 → since(24h) 5 条
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
现在按「上次水位 - 30 分钟安全边际」传 `since`;首次轮询仍全量。
|
|
29
|
+
|
|
30
|
+
### 三、关于 `help.gitee.com/ide-plugin`
|
|
31
|
+
那一页是 **IDE 插件**(IDEA / VS / Eclipse / Atom)的集成说明,与守护进程无关 ——
|
|
32
|
+
没有可用的 CLI 或服务端接口可抄。真正的可用面是 Open API v5,`since` 就是从那儿试出来的。
|
|
33
|
+
|
|
34
|
+
### 证据
|
|
35
|
+
```
|
|
36
|
+
node --test → 287/287(新增 since 拼 URL、缺 tools 不抛)
|
|
37
|
+
preflight 全量 → 37/37
|
|
38
|
+
真机:listGiteeItems 全量 34 条 / since 5 条
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## [0.9.178] - 2026-11-04 —— 用真实 Gitee 响应校对:编号是字符串,不是数字
|
|
42
|
+
|
|
43
|
+
### 怎么发现的
|
|
44
|
+
0.9.177 合入后拿**真实** Gitee API 跑了一遍(`oschina/git-osc`,公开仓库):
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
#IKMFKU | open | issue | 显示问题
|
|
48
|
+
#1 | closed | PR | test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
issue 的 `number` 是 **`"IKSQJH"` 这种字符串**(`id` 才是数字 34933085),PR 的 `number` 才是数字。
|
|
52
|
+
|
|
53
|
+
### 原来错在哪
|
|
54
|
+
```js
|
|
55
|
+
number: Number(item.number ?? item.id) || 0 // → NaN → 0
|
|
56
|
+
```
|
|
57
|
+
所有 Gitee issue 的编号都会变成 `0`:去重键相同(永远只有一条)、ack 打不中、唤醒消息里全是 `#0`。
|
|
58
|
+
|
|
59
|
+
### 改法
|
|
60
|
+
- `normalizeGiteeItem`:编号**保持原样转字符串**,不再 `Number()`;
|
|
61
|
+
- `fetchGiteeLastComment` / `addGiteeLabel`:按原样拼 URL(`/issues/IKSQJH/comments`、`/pulls/14/comments`);
|
|
62
|
+
- `watch_ack`:编号不再强制 `Number()` —— 以前 Gitee 的字符串编号会被过滤成空数组,
|
|
63
|
+
报「number is required」,看着像用户没填。
|
|
64
|
+
|
|
65
|
+
### 真机联调结果
|
|
66
|
+
```
|
|
67
|
+
listGiteeItems({ repo:'oschina/git-osc', perPage:5 })
|
|
68
|
+
→ ok:true, partial:null, 10 条(issue + PR 混排,按 updated_at 倒序)
|
|
69
|
+
→ #IKMFKU open issue 显示问题 / #1 closed PR test …
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 证据
|
|
73
|
+
```
|
|
74
|
+
node --test → 285/285(新增 2 条:真机字符串编号 / 字符串编号也能拼出评论与标签 URL)
|
|
75
|
+
```
|
|
76
|
+
|
|
5
77
|
## [0.9.177] - 2026-11-04 —— 兼容 Gitee:同一个插件盯两家
|
|
6
78
|
|
|
7
79
|
### 为什么
|
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
|
|
|
@@ -144,7 +144,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
|
|
|
144
144
|
## 开发
|
|
145
145
|
|
|
146
146
|
```sh
|
|
147
|
-
node --test #
|
|
147
|
+
node --test # 287 项单测
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
### 工具输出:文本给人和 agent,JSON 给程序
|
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.
|
|
17
|
+
const CLIENT_VERSION = '0.9.179'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/gitee.js
CHANGED
|
@@ -34,7 +34,9 @@ export function normalizeGiteeItem(raw, { kind = 'issue' } = {}) {
|
|
|
34
34
|
? item.labels.map((l) => (typeof l === 'string' ? { name: l } : { name: l && l.name })).filter((l) => l.name)
|
|
35
35
|
: []
|
|
36
36
|
const out = {
|
|
37
|
-
|
|
37
|
+
// Gitee 的 issue 编号是字符串(真机样例:number = "IKSQJH",id = 34933085),
|
|
38
|
+
// PR 才是数字(number = 14)。**别转 Number** —— 转了就全变 0,去重和 ack 全部失效。
|
|
39
|
+
number: item.number === 0 || item.number ? String(item.number) : String(item.id || ''),
|
|
38
40
|
title: String(item.title || ''),
|
|
39
41
|
state,
|
|
40
42
|
// Gitee 用 'rejected' 表示「关闭且不修」;state_reason 只有 reopened 会被下游用来警示
|
|
@@ -93,8 +95,12 @@ async function request(path, { token, method = 'GET', body = null, fetchImpl = g
|
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
/** 拉一页 issue + PR(Gitee 两者分属不同端点,缺 token 时公开仓库也能读)。 */
|
|
96
|
-
export async function listGiteeItems({ repo, token = '', perPage = 20, fetchImpl } = {}) {
|
|
97
|
-
|
|
98
|
+
export async function listGiteeItems({ repo, token = '', perPage = 20, since = '', fetchImpl } = {}) {
|
|
99
|
+
// `since` 是 Gitee 少有的、能省流量的手段(没有 ETag 条件请求)。
|
|
100
|
+
// 真机验证:since 传给未来时间 → 返回 [];传今天 → 只返回今天之后更新的。
|
|
101
|
+
// 两个端点都支持,缺了它就只能每轮全量读。
|
|
102
|
+
const sinceQ = since ? '&since=' + encodeURIComponent(String(since)) : ''
|
|
103
|
+
const q = 'state=all&sort=updated&direction=desc&per_page=' + Math.max(1, Math.min(100, Number(perPage) || 20)) + sinceQ
|
|
98
104
|
const [issues, pulls] = await Promise.all([
|
|
99
105
|
request(`/repos/${repo}/issues?${q}`, { token, fetchImpl }),
|
|
100
106
|
request(`/repos/${repo}/pulls?${q}`, { token, fetchImpl }),
|
|
@@ -112,7 +118,8 @@ export async function listGiteeItems({ repo, token = '', perPage = 20, fetchImpl
|
|
|
112
118
|
|
|
113
119
|
/** 某条 issue/PR 的最后一条评论(谁、什么时候)——唤醒消息用它回答「现在是有人在等吗」。 */
|
|
114
120
|
export async function fetchGiteeLastComment({ repo, token = '', item, selfLogin = '', fetchImpl } = {}) {
|
|
115
|
-
|
|
121
|
+
// 编号可能是字符串(issue 形如 IKSQJH)也可能是数字(PR 形如 14):都按原样拼进 URL
|
|
122
|
+
const number = item && item.number != null ? String(item.number) : ''
|
|
116
123
|
if (!number) return null
|
|
117
124
|
const kind = item && item.pull_request ? 'pulls' : 'issues'
|
|
118
125
|
const res = await request(`/repos/${repo}/${kind}/${number}/comments?per_page=1&sort=created&direction=desc`, { token, fetchImpl })
|
package/lib/index.js
CHANGED
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
|
|
43
43
|
export const name = 'dsh-session-superagent'
|
|
44
44
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
45
|
-
export const SERVER_VERSION = '0.9.
|
|
45
|
+
export const SERVER_VERSION = '0.9.179'
|
|
46
46
|
export const inject = ['tools', 'agents', 'webServer']
|
|
47
47
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
48
48
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
@@ -950,7 +950,16 @@ async function pollOnce(ctx, entry, baseMs) {
|
|
|
950
950
|
// Gitee 没有 gh CLI、没有 GraphQL、没有 ETag 条件请求;用 REST v5 拉一页,
|
|
951
951
|
// 在 lib/gitee.js 里归一成和 GitHub 一样的条目形状,下面所有筛选/唤醒逻辑共用。
|
|
952
952
|
if (entry.provider === 'gitee') {
|
|
953
|
-
|
|
953
|
+
// 没有 ETag,就用 `since` 只取「上次水位之后更新过」的条目 —— 省的是每轮的解析与带宽。
|
|
954
|
+
// 安全边际 30 分钟:宁可多读一轮,也不能因为时钟偏差漏掉一条。首次轮询没有水位,仍然全量。
|
|
955
|
+
const sinceIso = (() => {
|
|
956
|
+
const base = entry.cursor || entry.lastPoll
|
|
957
|
+
if (!base) return ''
|
|
958
|
+
const t = Date.parse(base)
|
|
959
|
+
if (!Number.isFinite(t)) return ''
|
|
960
|
+
return new Date(Math.max(0, t - 30 * 60 * 1000)).toISOString()
|
|
961
|
+
})()
|
|
962
|
+
const listed = await listGiteeItems({ repo: entry.repo, token: String(readSecrets().giteeToken || ''), perPage: 20, since: sinceIso })
|
|
954
963
|
entry.lastPoll = new Date().toISOString()
|
|
955
964
|
if (!listed.ok) {
|
|
956
965
|
const status = Number(listed.status) || 0
|
|
@@ -1338,6 +1347,12 @@ async function pollWithItems(ctx, entry, baseMs, parsed) {
|
|
|
1338
1347
|
}
|
|
1339
1348
|
|
|
1340
1349
|
export function apply(ctx) {
|
|
1350
|
+
// 宿主升级(如 0.2.2-rc.1)时最可能变的不是我们的逻辑,而是服务名/形状。
|
|
1351
|
+
// 一条守挂了不该拖垮整个插件树:缺服务就只打一条日志,其余能力继续挂。
|
|
1352
|
+
if (!ctx || !ctx.tools || typeof ctx.tools.register !== 'function') {
|
|
1353
|
+
try { console.error('[session-superagent] 宿主没有提供 tools 服务:插件能力不可用,但不影响宿主') } catch {}
|
|
1354
|
+
return
|
|
1355
|
+
}
|
|
1341
1356
|
const timers = sharedTimers
|
|
1342
1357
|
// 并发闸的唯一事实源:tick 和 HTTP「立刻」拿到的是两个不同的 entry 对象,
|
|
1343
1358
|
// 靠 entry.polling 标记永远对不上(审核专员 probe-c 实证:同一条被唤醒 3 次)。
|
|
@@ -2022,10 +2037,12 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2022
2037
|
format: { type: 'string', description: "'text' (default) or 'json'." },
|
|
2023
2038
|
},
|
|
2024
2039
|
async execute(args) {
|
|
2040
|
+
// 编号允许两种:GitHub 是数字(14),Gitee 的 issue 是字符串(IKSQJH)。
|
|
2041
|
+
// 以前一律 Number(),Gitee 那边会被过滤成空数组,报「number is required」—— 看着像用户没填。
|
|
2025
2042
|
const numbers = String(args.numbers || args.number || '')
|
|
2026
2043
|
.split(',')
|
|
2027
|
-
.map((v) =>
|
|
2028
|
-
.filter((v) =>
|
|
2044
|
+
.map((v) => v.trim())
|
|
2045
|
+
.filter((v) => /^[A-Za-z0-9_-]+$/.test(v))
|
|
2029
2046
|
if (numbers.length === 0) return '[error: number (or numbers) is required]'
|
|
2030
2047
|
const state = readState()
|
|
2031
2048
|
const watchers = Object.values(state.watchers || {})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.179",
|
|
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",
|