dsh-session-superagent 0.9.251 → 0.9.252

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,56 @@
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.252] - 2026-11-05 —— 抄官方原型最该抄的那一条:谁可以给你派活
6
+
7
+ ### 背景
8
+
9
+ 把官方原型 [`deepseek-ai/dsh-superagent-prototype`](https://github.com/deepseek-ai/dsh-superagent-prototype)
10
+ (TypeScript / 12,390 行)逐个模块对了一遍,最大的结构差距是它的 **Policy 层**:
11
+
12
+ > 「谁可以给你派活」—— 不在名单里的人提的请求,直接丢弃。
13
+
14
+ 我们原来的模型是「**有变化就叫醒**」,从不问「**是谁提的**」。
15
+
16
+ ### 这一轮做的(Policy 的最小版)
17
+
18
+ `filters.allowAuthors` —— 只理名单里的人:
19
+
20
+ ```js
21
+ { allowAuthors: ['alice', 'bob'] } // 空数组 = 谁都算(保持老行为)
22
+ ```
23
+
24
+ - 大小写不敏感、允许带 `@` 前缀(客户从 GitHub 页面上复制就是 `@alice`);
25
+ - 被挡下时**说清原因**:`作者不在名单: @bob` —— 这样 `/state` 的「需要关注」和 `watch_trace`
26
+ 都能解释「这条为什么没叫醒我」;
27
+ - **三处入口都接上了**:`watch_start` 参数、面板编辑表单、`/state` 的过滤原因。
28
+
29
+ ### 一个容易踩的坑(已避开)
30
+
31
+ 面板保存 `filters` 是**整块**发出去的。如果只加输入框、不把 `allowAuthors` 放进保存体,
32
+ 客户**改一次标签就会把作者名单清空**,而 Toast 照样说「已保存」。
33
+
34
+ 所以 `draft` 初始化、保存体、`touchedRef` 的「控件名 → 字段名」映射三处一起改了,
35
+ 并加了一条用例守「打开编辑器时已有名单要显示在输入框里」。
36
+
37
+ ### 没抄的部分(写清理由)
38
+
39
+ 官方还有:飞书渠道、Source 抽象、Ticket 状态机、Executor/Assignment 多实例、
40
+ orchestrator/worker/handoff 多角色、草稿/执行/部署视图、多语言、安装向导。
41
+
42
+ 那些是「**一个 agent 服务整个团队**」的形态。我们要的是「**一个人的会话变聪明**」——
43
+ 抄进来会把「1 个人 5 分钟装好」变成「一支队伍一下午配好」。
44
+
45
+ **唯一让我睡不着的是 Ticket 状态机**:我们的水位线表达不了「这条还在进行中」。
46
+ 已记进待办,不是这一轮。
47
+
48
+ ### 证据
49
+
50
+ ```
51
+ npm test → 392/392(新增:过滤链 5 组输入 + 面板字段不被清空)
52
+ preflight --fast → 面板文案快照已刷新
53
+ ```
54
+
5
55
  ## [0.9.251] - 2026-11-05 —— 14 条弹层用例断言的是「错误的树」
6
56
 
7
57
  T38 指出:这些用例传的是 `[list, true, {x, y}]`,而那个组件有 **4 个** `useState`
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.9.251-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.252-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
  [![awesome](https://img.shields.io/badge/awesome-dsh--plugin-%E2%9C%93-success.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
@@ -146,7 +146,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
146
146
  ## 开发
147
147
 
148
148
  ```sh
149
- npm test # 390 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
149
+ npm test # 392 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
150
150
  ```
151
151
 
152
152
  ### 工具输出:文本给人和 agent,JSON 给程序
@@ -206,7 +206,7 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
206
206
 
207
207
 
208
208
  ```bash
209
- npm test # 390 项单测(带离线开关,约 1.6 秒)
209
+ npm test # 392 项单测(带离线开关,约 1.6 秒)
210
210
  node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
211
211
  node scripts/preflight.mjs # 40 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
212
212
  node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
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.251'
17
+ const CLIENT_VERSION = '0.9.252'
18
18
  let BASE = '/session-superagent'
19
19
  /**
20
20
  * 挑「最新的那个服务端实例」。
@@ -1107,6 +1107,8 @@ window.__ModuleLoader__.load({
1107
1107
  filters: {
1108
1108
  labels: String(draft.labels || '').split(',').map((v) => v.trim()).filter(Boolean),
1109
1109
  onlyAssigned: !!draft.onlyAssigned,
1110
+ // 必须带上:filters 是**整块**发出去的,漏了它会把作者名单清空
1111
+ allowAuthors: String(draft.allowAuthors || '').split(',').map((v) => v.trim().replace(/^@/, '')).filter(Boolean),
1110
1112
  },
1111
1113
  activeHours: draft.activeHours || '',
1112
1114
  goal: draft.goal || '',
@@ -1132,6 +1134,7 @@ window.__ModuleLoader__.load({
1132
1134
  const CONTROL_TO_FIELD = {
1133
1135
  labels: "filters",
1134
1136
  onlyAssigned: "filters",
1137
+ allowAuthors: "filters",
1135
1138
  priorityReopened: "priority",
1136
1139
  priorityComments: "priority",
1137
1140
  priorityLabels: "priority",
@@ -1280,6 +1283,7 @@ window.__ModuleLoader__.load({
1280
1283
  // [object Object];保存时后端只收 string,于是静默无效而 Toast 说「已保存」。
1281
1284
  goal: watcher.note || (typeof watcher.goal === 'string' ? watcher.goal : (watcher.goal && watcher.goal.objective) || ''),
1282
1285
  onlyAssigned: !!(watcher.filters && watcher.filters.onlyAssigned),
1286
+ allowAuthors: (watcher.filters && watcher.filters.allowAuthors ? watcher.filters.allowAuthors : []).join(', '),
1283
1287
  // 下面这些以前没填 —— 打开一条隔离执行的守再直接保存,会把 isolated 写回 false
1284
1288
  observe: !!watcher.observe,
1285
1289
  isolated: !!watcher.isolated,
@@ -1384,6 +1388,8 @@ window.__ModuleLoader__.load({
1384
1388
  field('间隔(秒)', h(Input, { value: draft.intervalSec, onChange: (e) => setField({ ...draft, intervalSec: e.target.value }) }), '多长时间检查一次这个仓库,最小 30 秒'),
1385
1389
  field('只处理这些标签', h(Input, { value: draft.labels, placeholder: '逗号分隔,留空 = 全部', onChange: (e) => setField({ ...draft, labels: e.target.value }) })),
1386
1390
  field('活跃时段', h(HoursField, { value: draft.activeHours, onChange: (next) => setField({ ...draft, activeHours: next }) }), '只在这个时间段内唤醒;窗口外只攒条目,不打扰'),
1391
+ // 官方原型的 Policy 第一件事是「谁可以给你派活」。单人场景也要:别人随手提的 issue 不该叫醒你。
1392
+ field('只理这些人提的', h(Input, { value: draft.allowAuthors || '', placeholder: 'GitHub 登录名,逗号分隔,留空 = 谁都算', onChange: (e) => setField({ ...draft, allowAuthors: e.target.value }) }), '不在名单里的人提的 issue/PR 不会叫醒你(Gitee 也可以填)'),
1387
1393
  field('目标/规则', h(Input, { value: draft.goal || '', placeholder: '可选,会附在唤醒消息里', onChange: (e) => setField({ ...draft, goal: e.target.value }) })),
1388
1394
  h('label', { className: 'dt-switch-row' }, h(Toggle, { checked: !!draft.onlyAssigned, onChange: (v) => setField({ ...draft, onlyAssigned: v }), label: '只看已指派' }), '只处理已指派给人的条目'),
1389
1395
  field('单次最多唤醒条数', h(Input, { value: draft.batchLimit || '', placeholder: String(DEFAULTS.batchLimit || 5) + '(1-20)', onChange: (e) => setField({ ...draft, batchLimit: e.target.value }) })),
package/lib/index.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
 
45
45
  export const name = 'dsh-session-superagent'
46
46
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
47
- export const SERVER_VERSION = '0.9.251'
47
+ export const SERVER_VERSION = '0.9.252'
48
48
  export const inject = ['tools', 'agents', 'webServer']
49
49
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
50
50
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
@@ -2740,6 +2740,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2740
2740
  ignoreLabels: { type: 'array', items: { type: 'string' }, description: 'Skip items carrying any of these labels.' },
2741
2741
  onlyAssigned: { type: 'boolean', description: 'Only handle items assigned to someone (or to `assignee`).' },
2742
2742
  assignee: { type: 'string', description: 'With onlyAssigned: require this login.' },
2743
+ allowAuthors: { type: 'array', items: { type: 'string' }, description: '只要这些人提的(GitHub 登录名,可带 @)。空 = 谁都算。用来挡掉别人随手提的 issue。' },
2743
2744
  observe: { type: 'boolean', description: 'Observe only: record what WOULD be woken, never wake.' },
2744
2745
  isolated: { type: 'boolean', description: 'Run each wake in a throwaway git worktree.' },
2745
2746
  workdir: { type: 'string', description: 'Repository used for isolation worktrees (absolute path).' },
@@ -2801,6 +2802,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2801
2802
  if (args.ignoreLabels !== undefined) patch.ignoreLabels = args.ignoreLabels
2802
2803
  if (args.onlyAssigned !== undefined) patch.onlyAssigned = args.onlyAssigned
2803
2804
  if (args.assignee !== undefined) patch.assignee = args.assignee
2805
+ // 谁提的才算:参考官方原型的 Policy(谁来派活)。空数组 = 谁都算。
2806
+ if (args.allowAuthors !== undefined) patch.allowAuthors = args.allowAuthors
2804
2807
  if (Object.keys(patch).length > 0) entry.filters = mergeFilters(entry.filters, patch)
2805
2808
  if (typeof args.goal === 'string') entry.goal = args.goal.slice(0, 500)
2806
2809
  if (typeof args.observe === 'boolean') entry.observe = args.observe
@@ -2846,6 +2849,7 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
2846
2849
  if (entry.activeHours) flags.push('activeHours=' + entry.activeHours)
2847
2850
  if (entry.filters && entry.filters.labels && entry.filters.labels.length) flags.push('labels=' + entry.filters.labels.join(','))
2848
2851
  if (entry.filters && entry.filters.onlyAssigned) flags.push('onlyAssigned' + (entry.filters.assignee ? '(' + entry.filters.assignee + ')' : ''))
2852
+ if (entry.filters && entry.filters.allowAuthors && entry.filters.allowAuthors.length) flags.push('作者=' + entry.filters.allowAuthors.join(','))
2849
2853
  if (entry.batchLimit) flags.push('batch=' + entry.batchLimit)
2850
2854
  if (entry.maxWakesPerHour) flags.push('perHour=' + entry.maxWakesPerHour)
2851
2855
  if (entry.goal) flags.push('goal=' + JSON.stringify(entry.goal.slice(0, 40)))
package/lib/watch.js CHANGED
@@ -282,6 +282,8 @@ export const DEFAULT_FILTERS = {
282
282
  skipClosed: true,
283
283
  onlyAssigned: false,
284
284
  assignee: null,
285
+ // 谁提的才算:空 = 谁都算
286
+ allowAuthors: [],
285
287
  }
286
288
 
287
289
  /** 宽容地把用户传进来的 filters 规范化,缺字段走默认。 */
@@ -296,6 +298,8 @@ export function normalizeFilters(raw) {
296
298
  skipClosed: f.skipClosed !== false,
297
299
  onlyAssigned: f.onlyAssigned === true,
298
300
  assignee: typeof f.assignee === 'string' && f.assignee.trim() ? f.assignee.trim() : null,
301
+ // 谁提的才算(空 = 谁都算);顺手去掉 @ 前缀,客户复制粘贴的形如 @alice
302
+ allowAuthors: list(f.allowAuthors).map((n) => n.replace(/^@/, '')),
299
303
  }
300
304
  }
301
305
 
@@ -329,6 +333,15 @@ export function filterReason(item, filters = DEFAULT_FILTERS) {
329
333
  return '不在标签白名单: ' + f.labels.join(',')
330
334
  }
331
335
 
336
+ // 「谁提的」——官方原型把这一条放在 Policy 的第一位(谁可以给你派活)。
337
+ // 我们不做完整政策层,但白名单是单人场景也要的:别人随手提的 issue 不该叫醒你。
338
+ // 空数组 = 谁都算(默认,保持老行为)。
339
+ if (Array.isArray(f.allowAuthors) && f.allowAuthors.length > 0) {
340
+ const login = String((item.user && item.user.login) || '').toLowerCase()
341
+ const allowed = f.allowAuthors.map((n) => String(n).replace(/^@/, '').toLowerCase())
342
+ if (!allowed.includes(login)) return '作者不在名单: @' + (login || '?')
343
+ }
344
+
332
345
  if (f.onlyAssigned) {
333
346
  const assignees = (item.assignees ?? []).map((a) => String((a && a.login) || a).toLowerCase())
334
347
  if (f.assignee) return assignees.includes(f.assignee.toLowerCase()) ? null : '未指派给 @' + f.assignee
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.251",
3
+ "version": "0.9.252",
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",