dsh-session-superagent 0.9.261 → 0.9.262
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 +47 -0
- package/README.md +3 -3
- package/SETUP.md +109 -0
- package/client.js +1 -1
- package/docs/README.md +1 -0
- package/lib/index.js +6 -3
- package/lib/state-migration.js +25 -0
- package/lib/watch.js +46 -33
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,53 @@
|
|
|
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.262] - 2026-11-05 —— 状态可迁移、唤醒可分段、安装可复述
|
|
6
|
+
|
|
7
|
+
继续吸收官方工程纪律,不引入多角色或独立 Runtime。
|
|
8
|
+
|
|
9
|
+
### ① `watchers.json` 增加显式 `schemaVersion`
|
|
10
|
+
|
|
11
|
+
新增 `lib/state-migration.js`:
|
|
12
|
+
|
|
13
|
+
- v0(没有版本号的历史文件)→ v1,只补版本与必需容器,已有字段全部保留;
|
|
14
|
+
- `readState()` **先迁移、再 normalize**;
|
|
15
|
+
- 未来版本或非法版本拒绝按旧代码读取,自动退回 `.bak`,并把迁移后的备份写回主文件;
|
|
16
|
+
- `writeState()` 始终落当前版本。
|
|
17
|
+
|
|
18
|
+
同时补了两道清单:`sync-profile.mjs` 与 `package.json.files`。
|
|
19
|
+
并新增永久门禁:`lib/` 下任何 `.js` 没进 npm files,测试直接失败——本机硬链接能跑、发布包缺模块这类问题不能再漏。
|
|
20
|
+
|
|
21
|
+
### ② 唤醒消息变成稳定 sections
|
|
22
|
+
|
|
23
|
+
`buildWakeSections()` 返回有序 `{ id, lines }`:
|
|
24
|
+
`header / facts / selection? / overflow? / isolation? / goal? / identity? / access? / criteria? / next`。
|
|
25
|
+
|
|
26
|
+
`formatWatchText()` 只消费 sections。没有引入提示词编辑器或多角色。
|
|
27
|
+
goal 与标题中的换行、伪 `【完成标准】`、伪「接下来」都不能跳出所属段落。
|
|
28
|
+
|
|
29
|
+
旧新实现对拍 **7/7 IDENTICAL**,包括空 facts 的历史空行与合并场景。
|
|
30
|
+
|
|
31
|
+
### ③ 精简 `SETUP.md`
|
|
32
|
+
|
|
33
|
+
根目录新增 109 行安装剧本:
|
|
34
|
+
|
|
35
|
+
- 先只读探测,一次只问一个短问题;
|
|
36
|
+
- 收齐仓库、会话、过滤、隔离、goal 后给完整计划;
|
|
37
|
+
- 明确确认后才安装和写配置;
|
|
38
|
+
- 密钥只在操作者终端或面板凭证字段,不进入聊天;
|
|
39
|
+
- 验收覆盖 `watch_start / watch_status / watch_doctor`、面板、首轮唤醒与 `watch_ack`;
|
|
40
|
+
- 保留当前 profile 和一条安装命令,不复制官方 tmux/独立 profile。
|
|
41
|
+
|
|
42
|
+
并修正剧本中的 Gitee 默认标签为 `主理鱼-已处理`(半角冒号不被 Gitee 接受)。
|
|
43
|
+
|
|
44
|
+
### 证据
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
npm test → 442/442(新增:迁移 4 + 打包清单 2 + wake sections 7)
|
|
48
|
+
wake-samples → 7 个旧场景逐字兼容
|
|
49
|
+
npm pack --dry-run → 22 个文件,lib/state-migration.js 与 SETUP.md 均已包含
|
|
50
|
+
```
|
|
51
|
+
|
|
5
52
|
## [0.9.261] - 2026-11-05 —— 完整解构官方结构树,并落地 Delivery + Outbox
|
|
6
53
|
|
|
7
54
|
### 完整解构,不只列功能清单
|
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
|
[](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
|
|
@@ -146,7 +146,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
|
|
|
146
146
|
## 开发
|
|
147
147
|
|
|
148
148
|
```sh
|
|
149
|
-
npm test #
|
|
149
|
+
npm test # 442 项单测(带离线开关;裸 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 #
|
|
209
|
+
npm test # 442 项单测(带离线开关,约 1.6 秒)
|
|
210
210
|
node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
|
|
211
211
|
node scripts/preflight.mjs # 41 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
|
|
212
212
|
node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
|
package/SETUP.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# SETUP:主理鱼安装剧本
|
|
2
|
+
|
|
3
|
+
> 给 coding agent:陪操作者把 `dsh-session-superagent` 装进当前 DSH,并绑到一个现有会话。
|
|
4
|
+
> 操作者只需对自己的 agent 说:「读仓库根目录的 SETUP.md,按它带我安装主理鱼。」
|
|
5
|
+
|
|
6
|
+
## 0. 纪律
|
|
7
|
+
|
|
8
|
+
- 收齐全部答案前,只读 [README](README.md) 和 [为什么做这个产品](docs/为什么做这个产品.md),再跑一次下面的探测;除探测外不读别的文件、不改配置。
|
|
9
|
+
- 一条消息只问一个短问题,等回答再问下一题;每题给推荐答案和一句理由。上下文已经明确回答的题跳过。
|
|
10
|
+
- 提问期间不执行安装或配置。收齐全部答案后,一次给出完整计划;操作者明确确认后才执行。
|
|
11
|
+
- 密钥永远不在聊天里索要。登录只给操作者自己终端里的命令;token 只指向面板「主理鱼 → 设置 → 凭证」字段。
|
|
12
|
+
- 保留轻量形态:当前 profile、当前会话、一条插件安装命令。不另建 profile,不引入 tmux、独立 agent 账号或多角色执行体。
|
|
13
|
+
|
|
14
|
+
## 1. 只读探测
|
|
15
|
+
|
|
16
|
+
在仓库目录运行一次;逐项记录结果,缺失项进入计划,不变成追加问题:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
dsh --version
|
|
20
|
+
gh --version
|
|
21
|
+
printf 'DSH_PROFILE=%s\nDSH_HOME=%s\n' "${DSH_PROFILE-}" "${DSH_HOME-}"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
再按需调用现有工具:
|
|
25
|
+
|
|
26
|
+
- `repo_here`:只读当前 GitHub 仓库,作为第 1 题的推荐值;不可用就不猜仓库。
|
|
27
|
+
- `watch_doctor({format:"json"})`:插件已挂载时做安装前诊断;工具不存在就记为「尚未挂载或尚未加载」。它自己的隔离目录临时探针会自动删除。
|
|
28
|
+
|
|
29
|
+
除 `watch_doctor` 自身的检查外,不运行 `gh api`、`curl` 等网络探测,不运行 `gh auth token`,不读取凭证文件。
|
|
30
|
+
`DSH_PROFILE` 作为安装 profile;为空时在计划中列 `desktop`,由操作者随完整计划一起确认。
|
|
31
|
+
|
|
32
|
+
## 2. 一次一问
|
|
33
|
+
|
|
34
|
+
按顺序问以下五项。引号内是可改写的短模板,不要合并成问卷。
|
|
35
|
+
|
|
36
|
+
1. **仓库**
|
|
37
|
+
「要盯哪个仓库?推荐:当前仓库(GitHub 用 `owner/name`,Gitee 用 `gitee:owner/name`);直接用当前仓库最少抄录,也不容易绑错。」
|
|
38
|
+
2. **绑定会话**
|
|
39
|
+
「绑到当前这个会话吗?推荐:当前会话;`watch_start` 只唤醒调用它的会话,不必新开窗口或 agent。」
|
|
40
|
+
若答案是否,让操作者打开目标会话后从本剧本继续;不要编造 `sessionId` 参数。
|
|
41
|
+
3. **过滤与作者白名单**
|
|
42
|
+
「首轮过滤怎么设?推荐:`labels` 留空、`allowAuthors` 只含你的登录名(回复『默认:登录名』即可);先只让可信赖的人派活,噪音最小。」
|
|
43
|
+
操作者选择其他过滤时,在同一题收齐 `labels` / `ignoreLabels` / `allowAuthors` / `onlyAssigned` 等值。
|
|
44
|
+
4. **隔离**
|
|
45
|
+
「是否用一次性 worktree 隔离?推荐:首轮 `isolated:false`,先验证盯与唤醒,不创建副本;若选 `true`,请同答给出本地仓库的绝对 `workdir`。」
|
|
46
|
+
5. **goal**
|
|
47
|
+
「每次唤醒要附带什么目标?推荐:『按仓库 AGENTS.md 分诊并推进已确认事项,处理后 watch_ack』;这样唤醒本身就是可执行的任务书。」
|
|
48
|
+
|
|
49
|
+
轮询间隔、限流、凭证和 profile 不另起问题:采用默认值或写进完整计划。
|
|
50
|
+
|
|
51
|
+
## 3. 收齐后给完整计划
|
|
52
|
+
|
|
53
|
+
用一条消息列全以下内容,末尾只问「按此计划执行吗?」:
|
|
54
|
+
|
|
55
|
+
- **安装**:目标 profile;执行 `dsh plugin --profile <profile> add dsh-session-superagent`,已挂载则跳过重复安装。
|
|
56
|
+
- **绑定**:仓库、当前会话、过滤/作者白名单、`isolated`(开启时含 `workdir`)、goal。
|
|
57
|
+
- **默认值**:`intervalSec:60`、单次 5 条、单 watcher 每小时 6 次、整会话每小时 12 次、默认 ack 标签(GitHub `主理鱼:已处理` / Gitee `主理鱼-已处理`);未选的过滤参数省略。
|
|
58
|
+
- **操作者步骤**:需要登录时在自己终端跑 `gh auth login`;token 只填面板凭证字段。Gitee 需要 ack 时先建标签 `主理鱼-已处理`(Gitee 不允许半角冒号),GitHub 首次 ack 会自动建 `主理鱼:已处理`。
|
|
59
|
+
- **写入与回滚**:`watch_start` 会保存 watcher 并开始轮询;可用 `watch_stop({repo})` 暂停,确认不再需要时用 `watch_stop({repo,delete:true})` 删除配置。
|
|
60
|
+
- **验收**:下列第 5 节全部步骤;`watch_ack` 是否执行、是否回写评论,以及评论正文,都列清楚。
|
|
61
|
+
|
|
62
|
+
计划未获明确确认前,不调用安装命令、`watch_start`、`watch_ack`,也不替操作者创建测试 issue。
|
|
63
|
+
|
|
64
|
+
## 4. 确认后执行
|
|
65
|
+
|
|
66
|
+
1. **先做操作者步骤**。等待其完成登录或面板凭证填写;凭证失效时只重复给出 `gh auth login` 或凭证字段位置。
|
|
67
|
+
2. **装进当前 profile**(把占位符换成已确认值):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
dsh plugin --profile <profile> add dsh-session-superagent
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
不用 `npm i` 代替 profile 安装。`dsh` 不在 PATH 时保留原报错,把同一条命令交给操作者在自己的 DSH 终端执行。
|
|
74
|
+
3. **登记 watcher**。将计划中确认的参数传给 `watch_start`,例如:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"repo": "owner/name",
|
|
79
|
+
"intervalSec": 60,
|
|
80
|
+
"allowAuthors": ["operator-login"],
|
|
81
|
+
"isolated": false,
|
|
82
|
+
"goal": "按仓库 AGENTS.md 分诊并推进已确认事项,处理后 watch_ack"
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
示例不是固定答案:替换占位值;未选 `allowAuthors` 就省略,开启隔离则加入绝对路径 `workdir`。同一仓库重复调用会更新配置,不另造会话。
|
|
87
|
+
4. 任一步失败就报告原文;只修复已确认计划内的原因,新增外部写入先回到计划确认。
|
|
88
|
+
|
|
89
|
+
## 5. 安装后验收
|
|
90
|
+
|
|
91
|
+
| 顺序 | 动作 | 通过标准 |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| 1 | 已确认计划中的 `watch_start` 返回后,调用 `watch_status({format:"json"})` | 目标仓库出现,绑定当前会话,配置与计划一致,未处于意外暂停 |
|
|
94
|
+
| 2 | 调用 `watch_doctor({repo:"owner/name",format:"json"})` | gh 登录、仓库访问、挂载与隔离目录检查无 `FAIL`;GitHub 首次缺少 ack 标签的 `WARN` 可由首次 ack 消除 |
|
|
95
|
+
| 3 | 操作者看当前 DSH 面板 | 中间栏出现「主理鱼」,输入框下方总卫星环可展开,目标仓库可见;不另起面板服务 |
|
|
96
|
+
| 4 | 操作者用白名单账号新建一个测试 issue,或按计划更新既有 issue/PR | 在活跃时段和限额内,当前会话收到首轮「【主理鱼】」唤醒;面板「判定」能解释结果 |
|
|
97
|
+
| 5 | 首轮处理后执行已确认的 `watch_ack` | 返回成功,ack 标签与本地水位更新;同一条目不会无变化重复唤醒 |
|
|
98
|
+
| 6 | 再跑 `watch_status`,需要时复查面板「总览 / 判定」 | watcher 仍在运行,首轮结果与 ack 可追溯 |
|
|
99
|
+
|
|
100
|
+
第 5 步的最小形式(替换仓库与编号):
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
watch_ack({repo:"owner/name", number:123, note:"安装验收:首轮唤醒已处理", comment:false})
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`watch_ack` 即使 `comment:false` 也会写远端 ack 标签并推进本地水位,必须已包含在确认计划里。
|
|
107
|
+
`comment:true` 是另一项**显式写操作**:会把 `note` 作为评论发布到原 issue/PR,只有操作者明确同意评论正文后才使用;Gitee 回写 PR 时还要传 `kind:"pull"`。
|
|
108
|
+
|
|
109
|
+
最后交付:仓库与绑定会话、面板所见、首轮唤醒条目、ack 结果,以及 `watch_stop` 回滚方式。首轮先窄后宽,噪音偏大时优先收紧白名单或过滤,而不是增加唤醒频率。
|
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.262'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/docs/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
| 文档 | 什么时候读 |
|
|
6
6
|
|---|---|
|
|
7
7
|
| [README](../README.md) | 第一次接触这个插件:它做什么、怎么装、界面在哪、故障排查 |
|
|
8
|
+
| [SETUP](../SETUP.md) | 让 coding agent 陪操作者安装:只读探测、一次一问、计划确认、首轮唤醒验收 |
|
|
8
9
|
| [01-架构](01-架构.md) | 要改服务端逻辑:分层、11 步轮询管线、状态文件与落盘规则 |
|
|
9
10
|
| [design-system](design-system.md) | 要改界面:35 个设计 token、常用组件类、加页面的检查清单 |
|
|
10
11
|
| [official-gui-ia](official-gui-ia.md) | 想知道「官方原版长什么样、我们砍了什么、为什么」 |
|
package/lib/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import { redact } from './redact.js'
|
|
|
25
25
|
import { decodeBody, truncateUtf8 } from './body.js'
|
|
26
26
|
import { quotaDeferText, isOfflineMode } from './gh-format.js'
|
|
27
27
|
import { listGiteeItems, fetchGiteeLastComment, addGiteeLabel, addGiteeComment, ensureGiteeLabel, giteeWhoami, giteeRepo, mapGiteeRepoAccess, DEFAULT_ACK_LABEL_GITEE, giteeLabels, giteeHasLabel, isValidGiteeLabel, suggestGiteeLabel } from './gitee.js'
|
|
28
|
+
import { migrateState, CURRENT_STATE_SCHEMA } from './state-migration.js'
|
|
28
29
|
import {
|
|
29
30
|
effectiveIntervalMs, planWakeSettlement, advanceSeen, applyWatcherAction, batchFresh, decideWake, DEFAULT_ACK_LABEL, DEFAULT_PRIORITY, formatWatchText,
|
|
30
31
|
recordPendingWake, clearPending, pendingRetry,
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
|
|
47
48
|
export const name = 'dsh-session-superagent'
|
|
48
49
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
49
|
-
export const SERVER_VERSION = '0.9.
|
|
50
|
+
export const SERVER_VERSION = '0.9.262'
|
|
50
51
|
export const inject = ['tools', 'agents', 'webServer']
|
|
51
52
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
52
53
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
@@ -172,14 +173,15 @@ function readState() {
|
|
|
172
173
|
return { watchers: {} }
|
|
173
174
|
}
|
|
174
175
|
try {
|
|
175
|
-
|
|
176
|
+
// 先显式迁移,再做兼容归一;未来版本会抛错并落到 .bak,不盲目按旧代码读取。
|
|
177
|
+
const parsed = migrateState(JSON.parse(raw)).state
|
|
176
178
|
for (const entry of Object.values(parsed.watchers || {})) { normalizePaused(entry); normalizeAckLabel(entry) }
|
|
177
179
|
stateSource = 'ok'
|
|
178
180
|
return parsed
|
|
179
181
|
} catch {
|
|
180
182
|
// 主文件坏了:试试备份
|
|
181
183
|
try {
|
|
182
|
-
const backup = JSON.parse(readFileSync(stateFile() + '.bak', 'utf8'))
|
|
184
|
+
const backup = migrateState(JSON.parse(readFileSync(stateFile() + '.bak', 'utf8'))).state
|
|
183
185
|
for (const entry of Object.values(backup.watchers || {})) { normalizePaused(entry); normalizeAckLabel(entry) }
|
|
184
186
|
stateSource = 'backup'
|
|
185
187
|
// 把备份写回主文件,避免下次还走恢复路径
|
|
@@ -291,6 +293,7 @@ function writeState(state, options = {}) {
|
|
|
291
293
|
if (Object.keys(tombstones).length > 0) merged.deleted = tombstones
|
|
292
294
|
else delete merged.deleted
|
|
293
295
|
|
|
296
|
+
merged.schemaVersion = CURRENT_STATE_SCHEMA
|
|
294
297
|
const text = JSON.stringify(merged, null, 1)
|
|
295
298
|
// 原子写:写一半崩掉不该把全部 watcher 清空
|
|
296
299
|
const tmp = stateFile() + '.tmp'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* watchers.json 的显式 schema 迁移入口。
|
|
3
|
+
*
|
|
4
|
+
* 吸收官方 migration 的最小纪律:先迁移、再 normalize;未知未来版本拒绝;
|
|
5
|
+
* 失败交给 readState 的 .bak 恢复,不把半新半旧的状态当成正常状态。
|
|
6
|
+
* 这里只做我们实际需要的 v0 → v1,不搬 SQLite 迁移框架。
|
|
7
|
+
*/
|
|
8
|
+
export const CURRENT_STATE_SCHEMA = 1
|
|
9
|
+
|
|
10
|
+
export function migrateState(input) {
|
|
11
|
+
const raw = input && typeof input === 'object' && !Array.isArray(input) ? input : {}
|
|
12
|
+
const version = raw.schemaVersion === undefined ? 0 : Number(raw.schemaVersion)
|
|
13
|
+
if (!Number.isInteger(version) || version < 0) throw new Error('invalid state schemaVersion: ' + String(raw.schemaVersion))
|
|
14
|
+
if (version > CURRENT_STATE_SCHEMA) {
|
|
15
|
+
throw new Error('state schemaVersion ' + version + ' is newer than supported ' + CURRENT_STATE_SCHEMA)
|
|
16
|
+
}
|
|
17
|
+
if (version === CURRENT_STATE_SCHEMA) return { state: raw, changed: false, from: version }
|
|
18
|
+
// v0:没有 schemaVersion 的历史文件。保留所有已有字段,只补版本与必需容器。
|
|
19
|
+
const state = {
|
|
20
|
+
...raw,
|
|
21
|
+
schemaVersion: CURRENT_STATE_SCHEMA,
|
|
22
|
+
watchers: raw.watchers && typeof raw.watchers === 'object' && !Array.isArray(raw.watchers) ? raw.watchers : {},
|
|
23
|
+
}
|
|
24
|
+
return { state, changed: true, from: version }
|
|
25
|
+
}
|
package/lib/watch.js
CHANGED
|
@@ -108,11 +108,6 @@ export function advanceSeen(seen, fresh) {
|
|
|
108
108
|
return next
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
/** Build the wake text. Stable shape: one line per item, then the rule reminder. */
|
|
112
|
-
/**
|
|
113
|
-
* 唤醒消息 = 任务书。竞品的触发都带足上下文(类型、状态、作者、标签、是否草稿),
|
|
114
|
-
* 否则 agent 醒来还得自己查一遍。这里一次给全。
|
|
115
|
-
*/
|
|
116
111
|
/**
|
|
117
112
|
* 唤醒消息里的「完成标准」三条。
|
|
118
113
|
*
|
|
@@ -135,8 +130,15 @@ export function wakeCriteria({ isolation } = {}) {
|
|
|
135
130
|
// KB: actionable-suggestion.md —— 每个提示都要能回答「我现在该做什么」
|
|
136
131
|
// KB: actionable-does-not-mean-repeated.md —— 可执行 ≠ 把同一份指令印 N 遍(见 mergeWakeTexts)
|
|
137
132
|
// KB: error-must-have-next-step.md —— 每个错误都要带下一步
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
/**
|
|
134
|
+
* 唤醒消息 = 有序 section,而不是按角色拆分。竞品的触发都带足上下文
|
|
135
|
+
* (类型、状态、作者、标签、是否草稿),否则 agent 醒来还得自己查一遍。
|
|
136
|
+
*
|
|
137
|
+
* 每个 section 都是 `{ id, lines }`:id 稳定、lines 可直接断言或覆盖;
|
|
138
|
+
* 没有内容的可选 section 省略,header / facts / next 始终保留。
|
|
139
|
+
*/
|
|
140
|
+
export function buildWakeSections(repo, items, options = {}) {
|
|
141
|
+
const list = items ?? []
|
|
140
142
|
const more = Number(options.more) || 0
|
|
141
143
|
const lines = list.map((item) => {
|
|
142
144
|
const kind = item.pull_request ? 'PR' : 'issue'
|
|
@@ -202,12 +204,12 @@ export function formatWatchText(repo, fresh, options = {}) {
|
|
|
202
204
|
const rest = (options.restNumbers ?? []).map((n) => '#' + n).join(' ')
|
|
203
205
|
const iso = options.isolation
|
|
204
206
|
const isoLine = iso && iso.dir
|
|
205
|
-
?
|
|
207
|
+
? `【隔离工作区】${iso.dir}(分支 ${iso.branch})—— 只在这里改,推这个分支开 PR,别碰主工作区;用完 git worktree remove 掉。`
|
|
206
208
|
: iso && iso.error
|
|
207
|
-
?
|
|
209
|
+
? `【隔离失败】${iso.error};这次请谨慎,改完别留下未提交内容。`
|
|
208
210
|
: ''
|
|
209
211
|
const goalLine = options.goal
|
|
210
|
-
?
|
|
212
|
+
? `本条目主理目标:${String(options.goal).split(String.fromCharCode(13)).join(' ').split(String.fromCharCode(10)).join(' ').slice(0, 200)}`
|
|
211
213
|
: ''
|
|
212
214
|
// 身份说明:插件调 gh 用的是它绑定的账号,会话里跑的 git push 用的是会话自己的环境。
|
|
213
215
|
// 不说明的话,gh 评论挂智能体名下、git 提交挂操作者名下 —— 一次改动两个作者。
|
|
@@ -216,11 +218,11 @@ export function formatWatchText(repo, fresh, options = {}) {
|
|
|
216
218
|
// 进对话记录、可能被后续总结引用;带路径就等于把本机用户目录一并带出去。
|
|
217
219
|
// 会话只要知道「该问用户」就够了 —— 用户本来就知道自己的路径。
|
|
218
220
|
const identityLine = options.identityBound
|
|
219
|
-
?
|
|
221
|
+
? '【提交身份】本插件的 gh 已绑定单独的智能体账号。你在会话里执行 git / git push 时如需一致身份,'
|
|
220
222
|
+ '请向用户索取该账号的 gh 配置目录并设 GH_CONFIG_DIR;否则提交会落到操作者账号上。'
|
|
221
223
|
: ''
|
|
222
224
|
const moreLine = more > 0
|
|
223
|
-
?
|
|
225
|
+
? `(另有 ${more} 条:${rest},处理完这批再看)`
|
|
224
226
|
: ''
|
|
225
227
|
// 「为什么是这几条」:只给结果不给依据,会话/客户都没法判断要不要调过滤条件。
|
|
226
228
|
// 依据:GitHub 的通知带 reason(为什么通知你)、Slack 摘要会说明分组依据 —— 同一个道理。
|
|
@@ -250,34 +252,45 @@ export function formatWatchText(repo, fresh, options = {}) {
|
|
|
250
252
|
const more = Object.keys(options.skippedReasons).length > skipped.length ? ' 等' : ''
|
|
251
253
|
parts.push('本轮跳过 ' + total + ' 条(' + skipped.map(([reason, n]) => reason + ' × ' + n).join('、') + more + ')')
|
|
252
254
|
}
|
|
253
|
-
return parts.length > 0 ?
|
|
255
|
+
return parts.length > 0 ? '【为什么是这几条】' + parts.join(';') : ''
|
|
254
256
|
})()
|
|
255
257
|
// 完成标准要「可观测」:只说"做好它"等于没说。
|
|
256
258
|
// 依据:Given-When-Then 的核心是把验收写成可观察的结果(martinfowler.com/bliki/GivenWhenThen.html)。
|
|
257
|
-
const accessLine = options.access ?
|
|
259
|
+
const accessLine = options.access ? '【权限提示】' + options.access : ''
|
|
258
260
|
const criteria = Array.isArray(options.criteria) ? options.criteria.filter(Boolean).slice(0, 4) : []
|
|
259
|
-
const
|
|
260
|
-
?
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
lines.join('\n') +
|
|
268
|
-
whyLine +
|
|
269
|
-
moreLine +
|
|
270
|
-
isoLine +
|
|
271
|
-
goalLine +
|
|
272
|
-
identityLine +
|
|
273
|
-
accessLine +
|
|
274
|
-
criteriaLine +
|
|
275
|
-
'\n\n接下来:先读仓库 AGENTS.md 定「修 / 回 / 待定」;没有测试结果不算完成;' +
|
|
276
|
-
(options.provider === 'gitee'
|
|
261
|
+
const criteriaLines = criteria.length > 0
|
|
262
|
+
? ['【完成标准】', ...criteria.map((line, i) => (i + 1) + '. ' + line)]
|
|
263
|
+
: []
|
|
264
|
+
const headerLine = options.firstSync
|
|
265
|
+
? `【主理鱼】${repo} 首次同步:仓库里现有 ${lines.length} 条待处理(接上之前就在的,不是刚刚发生):`
|
|
266
|
+
: `【主理鱼】${repo} 有 ${lines.length} 条新动态:`
|
|
267
|
+
const nextLine = '接下来:先读仓库 AGENTS.md 定「修 / 回 / 待定」;没有测试结果不算完成;'
|
|
268
|
+
+ (options.provider === 'gitee'
|
|
277
269
|
// Gitee 没有 gh CLI:回写走网页/API,别让会话去跑 gh 命令
|
|
278
270
|
? '做完一条就写回 Gitee(网页或 API 都行)+ watch_ack 打标签,不要扩大范围。'
|
|
279
271
|
: '做完一条就写回 GitHub + watch_ack 打标签,不要扩大范围。')
|
|
280
|
-
|
|
272
|
+
|
|
273
|
+
const sections = [
|
|
274
|
+
{ id: 'header', lines: [headerLine] },
|
|
275
|
+
{ id: 'facts', lines },
|
|
276
|
+
]
|
|
277
|
+
if (whyLine) sections.push({ id: 'selection', lines: [whyLine] })
|
|
278
|
+
if (moreLine) sections.push({ id: 'overflow', lines: [moreLine] })
|
|
279
|
+
if (isoLine) sections.push({ id: 'isolation', lines: [isoLine] })
|
|
280
|
+
if (goalLine) sections.push({ id: 'goal', lines: [goalLine] })
|
|
281
|
+
if (identityLine) sections.push({ id: 'identity', lines: [identityLine] })
|
|
282
|
+
if (accessLine) sections.push({ id: 'access', lines: [accessLine] })
|
|
283
|
+
if (criteriaLines.length > 0) sections.push({ id: 'criteria', lines: criteriaLines })
|
|
284
|
+
// 空行属于 next section:无论 criteria 是否存在,收尾前都保持原有的一个空行。
|
|
285
|
+
sections.push({ id: 'next', lines: ['', nextLine] })
|
|
286
|
+
return sections
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** 把有序 sections 渲染成唤醒文本;两层 join 也保留空 facts 的旧空行行为。 */
|
|
290
|
+
export function formatWatchText(repo, fresh, options = {}) {
|
|
291
|
+
return buildWakeSections(repo, fresh, options)
|
|
292
|
+
.map((section) => section.lines.join('\n'))
|
|
293
|
+
.join('\n')
|
|
281
294
|
}
|
|
282
295
|
|
|
283
296
|
// ── 竞品蒸馏出来的四道闸(见 docs/competitive-analysis.md) ────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.262",
|
|
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",
|
|
@@ -18,8 +18,10 @@
|
|
|
18
18
|
"lib/redact.js",
|
|
19
19
|
"lib/body.js",
|
|
20
20
|
"lib/gitee.js",
|
|
21
|
+
"lib/state-migration.js",
|
|
21
22
|
"cordis.patch.yml",
|
|
22
23
|
"README.md",
|
|
24
|
+
"SETUP.md",
|
|
23
25
|
"CHANGELOG.md",
|
|
24
26
|
"LICENSE",
|
|
25
27
|
"client.js",
|