dsh-session-superagent 0.8.74 → 0.8.75

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.75] - 2026-11-02 —— 一次 N 条时,先处理更该处理的
6
+
7
+ ### 学到的(知识库第 24 条)
8
+ GitHub 列表支持 `sort=created|updated|comments`,但那是"热度/时间"维度;
9
+ 我们要的是"**哪条更该现在处理**",所以在本地排。权重可解释、可测:
10
+ <https://docs.github.com/en/rest/issues/issues#list-repository-issues>
11
+
12
+ | 信号 | 权重 |
13
+ |---|---|
14
+ | 被重开(`state_reason=reopened`) | **100** |
15
+ | 有人评论 | 10 |
16
+ | 有标签 | 5 |
17
+
18
+ ### 关键实现细节
19
+ **稳定排序**:分数相同保持 GitHub 给的 updated 顺序。否则同一批条目每次顺序都可能不同,
20
+ 客户会以为数据在乱跳 —— 用例专门验了"多次调用顺序一致"。
21
+
22
+ ### 测试
23
+ - 新增 1 例(单项权重、组合 115、重开第一/有评论第二、稳定排序)。合计 **127 例**。
24
+
5
25
  ## [0.8.74] - 2026-11-02 —— 「判过不做」又被重开的条目,要显眼
6
26
 
7
27
  ### 学到的(知识库第 23 条)
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` 126/126 通过
12
+ - [x] 七个工具可用(github / repo_here / watch_start / watch_status / watch_stop / watch_ack / watch_doctor),`node --test` 127/127 通过
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.74-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.8.75-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 # 126 项单测
102
+ node --test # 127 项单测
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.74'
17
+ const CLIENT_VERSION = '0.8.75'
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.74'
33
+ export const SERVER_VERSION = '0.8.75'
34
34
  export const inject = ['tools', 'agents', 'webServer']
35
35
 
36
36
  /** 仅供测试:读写状态文件(生产代码不要用)。 */
package/lib/watch.js CHANGED
@@ -235,10 +235,37 @@ export function pushFiltered(log, record, max = 5) {
235
235
  }
236
236
 
237
237
  /** 单次唤醒最多带几条;其余留到下一轮,别让一次唤醒把上下文撑爆。 */
238
+ /**
239
+ * 优先级:一次只能处理 N 条时,该先处理哪 N 条。
240
+ *
241
+ * 依据:GitHub 的 issue 列表支持 `sort=created|updated|comments`(服务端排序),
242
+ * 但它排的是"哪条更热",我们要的是"哪条更该现在处理"——两者不同,所以在本地排。
243
+ * 出处:https://docs.github.com/en/rest/issues/issues#list-repository-issues
244
+ *
245
+ * 权重(简单、可解释、可测):
246
+ * 被重开 100 —— 之前判过"不做"被推翻,最该看
247
+ * 有人评论 10 —— 说明在等回应
248
+ * 命中我们的标签 5
249
+ * 其余按 GitHub 的 updated 顺序(稳定排序保持原相对次序)
250
+ */
251
+ export function priorityScore(item) {
252
+ if (!item || typeof item !== 'object') return 0
253
+ let score = 0
254
+ if (String(item.state_reason || '') === 'reopened') score += 100
255
+ if (Number(item.comments) > 0) score += 10
256
+ if (Array.isArray(item.labels) && item.labels.length > 0) score += 5
257
+ return score
258
+ }
259
+
238
260
  export function batchFresh(fresh, limit = 3) {
239
- const list = fresh ?? []
261
+ const list = Array.isArray(fresh) ? fresh.slice() : []
240
262
  const n = Math.max(1, Number(limit) || 3)
241
- return list.slice(0, n)
263
+ // 稳定排序:分数相同就保持 GitHub 给的 updated 顺序
264
+ const ranked = list
265
+ .map((item, index) => ({ item, index, score: priorityScore(item) }))
266
+ .sort((a, b) => (b.score - a.score) || (a.index - b.index))
267
+ .map((entry) => entry.item)
268
+ return ranked.slice(0, n)
242
269
  }
243
270
 
244
271
  /** 连续失败指数退避:30s → 60 → 120 → … 上限 30 分钟;成功即复位。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.8.74",
3
+ "version": "0.8.75",
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",