dsh-batch-review 0.0.0-stage → 1.1.2
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.en.md +49 -0
- package/CHANGELOG.md +236 -0
- package/LICENSE +21 -0
- package/README.en.md +207 -0
- package/README.md +206 -2
- package/cordis.patch.yml +33 -0
- package/examples/items.json +41 -0
- package/icon.svg +8 -0
- package/index.js +142 -0
- package/lib/client.js +1337 -0
- package/lib/config.js +188 -0
- package/lib/i18n.js +223 -0
- package/lib/panel.js +873 -0
- package/lib/prompt.js +58 -0
- package/lib/skill.js +65 -0
- package/lib/tool.js +1141 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +71 -3
- package/skills/batch-review-table/SKILL.en.md +214 -0
- package/skills/batch-review-table/SKILL.md +133 -0
- package/skills/batch-review-table/assets/review.html +1109 -0
- package/skills/batch-review-table/references/html-fallback.md +88 -0
- package/skills/batch-review-table/scripts/build_review.py +447 -0
- package/skills/batch-review-table/scripts/collect_server.py +570 -0
package/README.md
CHANGED
|
@@ -1,3 +1,207 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-batch-review
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/palx666/dsh-batch-review/actions/workflows/ci.yml) [](https://github.com/deepseek-ai/deepseek-harness)
|
|
4
|
+
|
|
5
|
+
[English](README.en.md) | [中文](README.md)
|
|
6
|
+
|
|
7
|
+
## 简介
|
|
8
|
+
|
|
9
|
+
给 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 用的多条批阅工具:原提问卡片的“升级版”,旨在优化 Agent 在向用户询问、确认或申请批复多个问题时的交互。批阅面板可同时包含多组/多个问题,用户通过简单的点击选项或者输入文本批量或逐条作答,结论会以结构化数据回到 Agent,不打断工作流。
|
|
10
|
+
|
|
11
|
+
## 硬规则:凡需用户表态,一律调用 `batch_review`
|
|
12
|
+
|
|
13
|
+
**这条规则随插件自动注入,不需要额外配置**:插件在 system prompt 注册 `dsh-batch-review:routing` 段(每次请求生效),并内置 `batch-review-table` 技能覆盖同一套判据。
|
|
14
|
+
|
|
15
|
+
- **凡需要用户给出反馈**——确认、选择、批准、驳回、评分、评论——就给可点界面,不要用文字问[要不要 / 行不行]。
|
|
16
|
+
- **凡需要用户表态 → `batch_review`**——单条也走面板(默认阈值 1);**只有计划批准 / 宿主审批类** → `ask_user_question`(只有原生接口能发出这两种 intent,`batch_review` 渲染不了)。
|
|
17
|
+
- **未表态 ≠ 通过**:`filled: false` 必须追问,不能当成已通过。
|
|
18
|
+
|
|
19
|
+
**不想自动注入?** 设置 → 左侧导航[批阅面板]→ 高级设置,取消[注入路由规则到 system prompt](等价于配置 `injectRoutingRule: false`),**重启 DSH 后生效**。关闭后插件不再往 system prompt 写任何东西;此时**推荐自己维护规则**:在你的 `AGENTS.md` 里写清楚**什么时候该调用 `batch_review`**(普通表态场景都用它;只有计划批准 / 审批类才用 `ask_user_question`),否则 Agent 不会主动想到它(工具还在,但只能靠你点名)。
|
|
20
|
+
|
|
21
|
+
## 实现形式
|
|
22
|
+
|
|
23
|
+
Agent 调一次 `batch_review`,把清单交给 Web UI——默认面板阈值 1,单条与多条都走输入框上方的一屏面板(面板不在线时才退回原生卡片);用户逐条表态后,工具返回一份结构化结果:每条一个结论 + 备注,外加一段可直接贴进回复的 `report_text`。面板由 DSH 自带的 web server 经 `/api/batch-review/*` 提供,**无需另开应用、不占额外端口**,而且[没表态]永远不会被当成[通过]。面板高度可拖动顶边的手柄调整——条目多时不必只靠滚动条。
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
Agent → batch_review({ title, items: [6 条] })
|
|
27
|
+
→ 一屏面板(默认阈值 1,面板在线)或原生卡片(降级)
|
|
28
|
+
→ { items:[{verdict,note,filled}], summary, report_text }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 它做什么
|
|
32
|
+
|
|
33
|
+
- **`batch_review` 工具**:Agent 一次传入全部条目;每条映射为一道题(默认走面板条目);返回 `items[].{id,title,type,verdict,note,filled}` + `summary` + `report_text`。
|
|
34
|
+
- **未填 = 未通过(fail-closed)**:跳过或留空的条目返回 `filled: false`,报告里单列[未填:…(没填不代表通过,需要单独追问)]。会话中断则返回 `cancelled: true`、`items: []`——不会静默通过。
|
|
35
|
+
- **五种条目类型**:`confirm`(通过 / 不通过 / 待定)、`bool`、`choice`、`text`、`scale`。
|
|
36
|
+
- **按需多选**:条目设 `multiSelect: true` 即可多选;结果里 `verdict` 用顿号拼接所有选项,同时新增 `selected[]` 数组保留完整选择。
|
|
37
|
+
- **内置技能**:包内同时注册 `batch-review-table` 技能(决策通道路由:`ask_user_question` / `batch_review` / HTML 表格怎么选),装插件即装技能。
|
|
38
|
+
- **HTML 回退**:条目多或需要落盘时,技能自带 `review.html` + `build_review.py` + `collect_server.py`。
|
|
39
|
+
|
|
40
|
+
## 和原生卡片的关系
|
|
41
|
+
|
|
42
|
+
`batch_review` 建立在 DSH 原生提问卡片之上,可以理解为是它的“升级版”:正常情况下完全替代原生卡片,只在特定情况(面板调用失败、手动设定等)会回退到原生卡片。若希望在较少条目时使用原生卡片,可在设置中调高面板触发阈值。
|
|
43
|
+
|
|
44
|
+
面板只在挂载期间轮询 `GET /api/batch-review/state`;不在线(用户不在会话页、客户端未加载、DSH 没有 webServer)时,`batch_review` 自动降级为原生卡片,不会卡住。返回里的 `surface` 字段写明这次是 `panel` 还是 `cards`。
|
|
45
|
+
|
|
46
|
+
两种界面返回**同一份契约**——`items[].{verdict,note,filled}`、`summary`、`report_text`——所以技能和 Agent 都不需要关心走的是哪一种。
|
|
47
|
+
|
|
48
|
+
批阅只属于**发起它的会话**:切换到别的会话或工作区时,不会看到别人的待办批阅。
|
|
49
|
+
|
|
50
|
+
## 设置说明
|
|
51
|
+
|
|
52
|
+
设置 → 左侧导航[批阅面板]里有 3 项基本设置:
|
|
53
|
+
|
|
54
|
+
| 设置 | 默认 | 范围 | 作用 |
|
|
55
|
+
|---|---|---|---|
|
|
56
|
+
| Panel threshold(面板阈值) | 1 | 1–100 | 多少条起走面板;默认 1 = 全部走面板,设回 2+ 才让低于阈值的批次走原生卡片 |
|
|
57
|
+
| Item cap(条目上限) | 100 | 1–500 | 一次批阅最多几条;超过直接驳回并提示拆批,不渲染 |
|
|
58
|
+
| Timeout (ms)(超时) | 15 分钟 | 1 秒–24 小时 | 一次批阅在面板上的**总等待基准**;实际上限 = 基准 + 6 秒/条,默认最高 45 分钟(配置的基准更大时以配置为准)。超时按取消返回(不会变成通过)。单次工具调用只等约 90 秒,然后返回 `pending: true` + `review_id`,需要再调一次续等 |
|
|
59
|
+
|
|
60
|
+
[高级设置]里另有:`virtualThreshold`(虚拟滚动阈值)、`maxBodyBytes`(请求体上限)、`allowExternalPersist`(允许持久化到工作目录外)、`injectRoutingRule`(是否把路由规则注入 system prompt)。面板**只服务回环对端**:原 `allowNonLoopback`(接受非回环对端)已移除,配置文件里残留该键会被忽略并在启动时告警;经反代或隧道访问 GUI 时面板不会出现。这些**一般不需要改**,调整前请确认影响。
|
|
61
|
+
|
|
62
|
+
## 安装
|
|
63
|
+
|
|
64
|
+
**要求**:DeepSeek Harness `>=0.2.1-rc.3 <0.2.2 || >=0.2.2-rc.1 <=0.2.2`(0.2.2-rc.1 起包含 rc.1;宿主 API 与客户端 slot 已在 0.2.2-rc.1 上核对,未做全量真机复测)、Node.js `>=20`。零运行时依赖、无构建步骤(纯 ESM)。
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
# 装当前发布版(推荐,可复现;tag 指向与本地一致的提交)
|
|
68
|
+
dsh plugin --profile <profile> add github:palx666/dsh-batch-review#v1.1.2
|
|
69
|
+
|
|
70
|
+
# 或钉住 tarball
|
|
71
|
+
dsh plugin --profile <profile> add https://github.com/palx666/dsh-batch-review/archive/refs/tags/v1.1.2.tar.gz
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
> `main` 分支可能落后于 tag(发布流程是先提交、再打 tag);直接写 `github:palx666/dsh-batch-review` 装到的是 `main` 的现状,不保证是最新发布。市场条目若用 tarball,以 Release 附件为准。
|
|
75
|
+
|
|
76
|
+
重启 DSH(`dsh web` 或桌面端)让插件加载。验证:Agent 的工具列表里应出现 `batch_review`。
|
|
77
|
+
|
|
78
|
+
## 用法
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"title": "验收:文件复制 / 下载按钮",
|
|
83
|
+
"persist": "review/acceptance.json",
|
|
84
|
+
"items": [
|
|
85
|
+
{ "id": 1, "type": "confirm", "op": "重启 DSH、刷新页面", "expect": "界面正常,不白屏" },
|
|
86
|
+
{ "id": 2, "type": "choice", "label": "接入方式", "options": [{ "v": "A", "t": "直连 18080" }, { "v": "B", "t": "走 DSH subagent" }] },
|
|
87
|
+
{ "id": 3, "type": "bool", "label": "网关计划任务常驻", "boolDesc": "接受" },
|
|
88
|
+
{ "id": 4, "type": "scale", "label": "整体评分", "min": 1, "max": 5 },
|
|
89
|
+
{ "id": 5, "type": "text", "label": "有没有看着不对的地方" }
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`persist` 用相对路径时,按**agent 的工作区**解析(宿主没有暴露工作区时退回宿主进程 cwd);默认只允许写工作区 / 进程 cwd 子树,要写到别处需在设置里打开 `allowExternalPersist`。
|
|
95
|
+
|
|
96
|
+
返回(截断):
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"cancelled": false,
|
|
101
|
+
"items": [
|
|
102
|
+
{ "id": "1", "type": "confirm", "verdict": "通过", "note": "", "filled": true },
|
|
103
|
+
{ "id": "3", "type": "bool", "verdict": "", "note": "", "filled": false }
|
|
104
|
+
],
|
|
105
|
+
"summary": { "total": 5, "filled": 4 },
|
|
106
|
+
"persisted": "/abs/path/review/acceptance.json",
|
|
107
|
+
"report_text": "【批阅】验收:文件复制 / 下载按钮\n共 5 条 · 已填 4 条 · 未填 1 条\n…\n未填:3(没填不代表通过,需要单独追问)"
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
工具对模型的硬约束:
|
|
112
|
+
|
|
113
|
+
- `items` 必须非空,`id` 必须唯一——答案按 id 回填,重复 id 会被直接拒绝,不会互相覆盖;
|
|
114
|
+
- `persist`(可选)把结果另存为 UTF-8 JSON,会话结束后仍可查;返回的 `persisted` 是实际绝对路径,写失败时 `persist_error` 有原因(不影响批阅结果);
|
|
115
|
+
- 工具会挂起等用户作答,同一批**不要调两次**;
|
|
116
|
+
- `filled: false` 必须追问,不能当通过;
|
|
117
|
+
- `cancelled: true` 表示没有任何结论,必须重新发起。
|
|
118
|
+
|
|
119
|
+
## 大数量批阅
|
|
120
|
+
|
|
121
|
+
三个通道各管一段:**面板 → HTML 批阅页 → Excel 表**,条数越多越往后。
|
|
122
|
+
|
|
123
|
+
- 面板按 `group`(缺省用 `header`)把**连续**条目分组,每个组头带[清空];组内是 confirm 条目时还会带[通过 / 不通过 / 待定]的批量按钮(只出现该组实际提供的结论类型,bool/choice/scale 组不显示这类按钮)。100 条只要 Agent 先分类,是可操作的;平铺的 100 条不是。
|
|
124
|
+
- **50 条及以上**时面板顶部提示改用 Excel 表。`build_review.py --format xlsx` 生成的表自带[状态]列下拉(通过 / 不通过 / 待定 / 跳过),适合几十到上千条——逐条点选在 HTML 页里要点上千次,Excel 里可以下拉 + 拖动批量填。
|
|
125
|
+
- xlsx 需要 `openpyxl`;没装时脚本会提示并**自动降级为 csv**(同样能填,只是没有下拉)。
|
|
126
|
+
- `group` 是可选自由文本,分几类由 Agent 决定。
|
|
127
|
+
|
|
128
|
+
## 包内有什么
|
|
129
|
+
|
|
130
|
+
| 路径 | 作用 |
|
|
131
|
+
|---|---|
|
|
132
|
+
| `index.js` | 宿主插件:注册工具、技能 provider、面板路由 |
|
|
133
|
+
| `lib/tool.js` | 条目校验、`AskUserQuestionItem` 映射、答案折叠、报告、面板/卡片路由 |
|
|
134
|
+
| `lib/panel.js` | 面板通道:单条等待中的批阅、`/api/batch-review` 路由、在线判定 |
|
|
135
|
+
| `lib/client.js` | 浏览器半区:`conversation.input.dock` 里的一屏批阅面板 |
|
|
136
|
+
| `lib/prompt.js` | systemPrompt 路由段(batch_review vs ask_user_question) |
|
|
137
|
+
| `lib/skill.js` | 内置 `batch-review-table` 技能的 provider |
|
|
138
|
+
| `lib/config.js` | 三层配置解析与校验(默认值 / cordis / 设置文件) |
|
|
139
|
+
| `lib/i18n.js` | 中英词典、占位符替换、错误本地化 |
|
|
140
|
+
| `skills/batch-review-table/SKILL.md` | 决策通道路由规则 + HTML 回退流程 |
|
|
141
|
+
| `skills/batch-review-table/SKILL.en.md` | 英文版技能(与 `SKILL.md` 同一套判据) |
|
|
142
|
+
| `skills/batch-review-table/references/html-fallback.md` | HTML 回退细节(协议、结果契约、xlsx/csv 导出)——按需读 |
|
|
143
|
+
| `skills/batch-review-table/assets/review.html` | 单文件批阅页(进度条、翻页、只看未完成、复制/下载 JSON) |
|
|
144
|
+
| `skills/batch-review-table/scripts/build_review.py` | 从 items JSON 渲染批阅页(或 xlsx/csv 表) |
|
|
145
|
+
| `skills/batch-review-table/scripts/collect_server.py` | 本机 127.0.0.1 回传服务:页面 → `POST /submit` → 结果文件 + stdout |
|
|
146
|
+
| `locale/zh.json`、`locale/en.json` | 给宿主 locale 服务的词典(客户端切语言用) |
|
|
147
|
+
| `cordis.patch.yml` | 插件声明(bundle patch,安装时读取) |
|
|
148
|
+
|
|
149
|
+
## 语言
|
|
150
|
+
|
|
151
|
+
支持中文和英文,默认跟随 GUI 语言,切换立即生效、无需刷新。技能同时提供 `SKILL.md`(中文)与 `SKILL.en.md`(英文)。
|
|
152
|
+
|
|
153
|
+
## 已知限制
|
|
154
|
+
|
|
155
|
+
- **面板依赖客户端半区**:面板挂在 `conversation.input.dock`,只在挂载时轮询。宿主没有 `webServer`、客户端没加载 bundle、或用户不在会话页,都等于[面板不在线],工具会降级到原生卡片而不是一直等。
|
|
156
|
+
- **原生卡片没有续等**:等待是一次性的,例如在 PTC 模式下宿主执行预算(如 `run_code` 默认 2 分钟)会在用户作答前掐断它,这也是现在默认都走面板的原因之一。
|
|
157
|
+
- **面板只接受回环对端与回环 Host**:接口先拒绝非回环的 TCP 对端,再拒绝归一化后仍不是回环的 `Host`(`localhost`、整个 `127/8`、`::1`、IPv4-mapped `::ffff:127.x.x.x`、或 socket 自身绑定地址);经反代、隧道访问 GUI 时面板不会出现,工具退回原生卡片、结论不丢;浏览器控制台会提示一次。
|
|
158
|
+
- **原生卡片上说明文字并入标题**:`expect` / `boolDesc` / `detail` 会用破折号接在标题后(如[重启 — 不白屏]),不再作为宿主卡片的 `detail` 行下发——那一行的左边距只有 2px(标题所在的 header 是 24px)且继承主色,看起来像顶到标题左侧外的一条线。面板仍把说明作为独立的、缩进且灰色的说明行显示。
|
|
159
|
+
- **原生卡片只认 root Agent**:`userQuestions.ask()` 只接受 live runtime root,子代理走到卡片路径会拿到 `DELEGATED_CALLER`。面板路径不经过这个宿主调用,所以面板在线时子代理仍能通过面板提问。
|
|
160
|
+
- **持久化需显式开启**:批阅结果默认不落盘;传 `persist: "<路径>"` 才会把结论写成 UTF-8 JSON(返回的 `persisted` 是实际写入的绝对路径)。`persist` 默认只能写 agent 工作区 / 宿主进程 cwd 子树,写到别处需在配置里设 `allowExternalPersist: true`。不传的话,会话中途结束就是 `cancelled: true`,需要重新问一遍。设置页会单独写自己的配置文件(见下一条)。
|
|
161
|
+
- **条数上限(默认 100)**:超过即**驳回**并提示调用方拆成多批,不渲染。要调上限见[设置说明](#设置说明)。
|
|
162
|
+
- **大批次跳过屏外绘制**:超过 `virtualThreshold` 条时面板给行加 `content-visibility: auto`,浏览器跳过视口外的布局与绘制,但每行保留真实高度——没有固定行高,不会裁切内容。默认值(`maxItems: 100`、`virtualThreshold: 500`)下这条路径不触发;要验证就在[设置 → 高级设置]里调低 `virtualThreshold`。
|
|
163
|
+
- **中文只是兜底**:既无面板上报、也无显式 `lang` 时,选项标签(`confirm`:[通过 / 不通过 / 待定],`bool`:[是 / 否])与 `report_text` 回退中文;其余情况跟随界面语言或 `lang` 参数。
|
|
164
|
+
- **样式只用 DSH 主题变量**:原生卡片的外观完全由 DSH 提供;面板的 CSS 全部使用 `--dsw-*` 主题变量(无硬编码颜色),跟随 DSH 亮色/暗色切换。已在 DSH `0.2.1-rc.5` 下实测 orca-maid 0.1.1、maid-atelier 0.1.9、orca-link 0.1.9、deep-whale-manager 0.1.8、maid-whale-webui 0.1.1(DeepSeek Cloud Paper)可读。
|
|
165
|
+
|
|
166
|
+
## 安全边界
|
|
167
|
+
|
|
168
|
+
- **session id 是界面隔离,不是用户认证**:批阅只显示给发起它的会话;它不构成跨用户权限控制,同一 DSH 用户的其他会话/页面仍可能读到本机路由的返回。
|
|
169
|
+
- **本机同用户进程可访问本机路由**:`/api/batch-review/*` 挂在宿主 webServer 上,默认只接受回环对端(`127.0.0.1` / `::1` / IPv4-mapped)。同一台机器、同一用户运行的其他程序可以请求这些路由;把 GUI 放在反代 / 隧道后面不会让面板可用(面板只服务回环)。确实需要远程批阅时,请另配带网络认证的方案,不要依赖 Host 头。
|
|
170
|
+
- **HTML 回传只信任本机生成的页面**:`collect_server.py` 用页面内嵌的一次性 token 认证提交;不要把回传端口暴露到局域网,也不要把生成的页面交给不受信任的人。
|
|
171
|
+
- **设置文件**:`$DSH_HOME/dsh-batch-review.config.json`(默认 `~/.dsh/dsh-batch-review.config.json`)。卸载插件不会删除该文件,也不会删除你用 `persist` 主动写出的结果。
|
|
172
|
+
- **路由规则注入默认开启**:`injectRoutingRule` 默认把「需要用户表态时用 batch_review」写进 system prompt;纯文字用户可以关掉它,或在本机修改 `lib/prompt.js` 的注入文本以收窄触发条件。
|
|
173
|
+
|
|
174
|
+
## 开发
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
node --test # 映射、折叠、报告、插件注册(Node 20/22/24)
|
|
178
|
+
python -m unittest discover -s skills/batch-review-table/scripts -p 'test_review_collect.py' -v # 回传服务
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
HTML 回退有自己的冒烟路径:
|
|
182
|
+
|
|
183
|
+
```sh
|
|
184
|
+
python skills/batch-review-table/scripts/build_review.py --data examples/items.json --out review/demo.html
|
|
185
|
+
python skills/batch-review-table/scripts/build_review.py --data examples/items.json --format xlsx --out review/demo.xlsx
|
|
186
|
+
python skills/batch-review-table/scripts/collect_server.py # 然后用浏览器打开 review/demo.html
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## 升级与卸载
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
# 升级:装新 tag(先看 CHANGELOG)
|
|
193
|
+
dsh plugin --profile <profile> add github:palx666/dsh-batch-review#v1.1.2
|
|
194
|
+
|
|
195
|
+
# 卸载
|
|
196
|
+
dsh plugin --profile <profile> remove dsh-batch-review
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
卸载不会删除 `$DSH_HOME/dsh-batch-review.config.json`,也不会删除你用 `persist` 写出的结果;重置设置可在设置页点「重置」,或删除该配置文件后重启。
|
|
200
|
+
|
|
201
|
+
## 许可
|
|
202
|
+
|
|
203
|
+
MIT,见 [LICENSE](LICENSE)。
|
|
204
|
+
|
|
205
|
+
## 制作
|
|
206
|
+
|
|
207
|
+
使用 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(dsh)制作:工具、面板与技能均基于其 API 编写。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
- insert:
|
|
2
|
+
- id: dsh-batch-review
|
|
3
|
+
name: dsh-batch-review
|
|
4
|
+
# Tunables. Edit these in your profile's patch layer; this file only ships
|
|
5
|
+
# the defaults.
|
|
6
|
+
config:
|
|
7
|
+
# Reviews with at least this many items use the dock panel instead of
|
|
8
|
+
# the native card. Default 1 = every review uses the panel, even a
|
|
9
|
+
# single item. Raise it to 2+ only if the native card is wanted for
|
|
10
|
+
# small batches: the card path has no wait slicing, so a long review
|
|
11
|
+
# there can be cut off by the host execution budget and must restart.
|
|
12
|
+
panelThreshold: 1
|
|
13
|
+
# Hard rejection above this many items: the tool refuses and tells the
|
|
14
|
+
# caller to split the batch. The hard ceiling is 500 (human review time),
|
|
15
|
+
# so a larger value is rejected at load time rather than silently capped.
|
|
16
|
+
maxItems: 100
|
|
17
|
+
# Above this many rows the panel lets the browser skip off-screen
|
|
18
|
+
# layout/paint (content-visibility: auto); every row keeps its real
|
|
19
|
+
# height. Hard floor 50: below that the virtual path is a test rig, not
|
|
20
|
+
# a setting, and small batches fit one screen anyway. Hard ceiling 2000.
|
|
21
|
+
virtualThreshold: 500
|
|
22
|
+
# Base budget for one review to stay on the panel (never an implicit
|
|
23
|
+
# pass). The effective ceiling is this base plus 6 s per item, capped at
|
|
24
|
+
# 45 minutes; a larger base here is respected as-is. One tool call only
|
|
25
|
+
# waits a ~90 s slice and returns {pending:true, review_id}; the caller
|
|
26
|
+
# resumes with the same id, so a short host execution budget cannot end
|
|
27
|
+
# the review. 15 minutes is the owner's chosen base.
|
|
28
|
+
panelTimeoutMs: 900000
|
|
29
|
+
# Largest panel request body accepted, in bytes. Hard ceiling 128 MB.
|
|
30
|
+
maxBodyBytes: 67108864
|
|
31
|
+
# `persist` is model-supplied: by default it may only write inside the
|
|
32
|
+
# host process cwd subtree. Set true to allow any path on disk.
|
|
33
|
+
allowExternalPersist: false
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "acceptance-demo",
|
|
3
|
+
"title": "验收:文件复制 / 下载按钮",
|
|
4
|
+
"subtitle": "demo data for build_review.py",
|
|
5
|
+
"mode": "sequential",
|
|
6
|
+
"items": [
|
|
7
|
+
{
|
|
8
|
+
"id": 1,
|
|
9
|
+
"type": "confirm",
|
|
10
|
+
"op": "重启 DSH、刷新页面",
|
|
11
|
+
"expect": "界面正常,不白屏"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"id": 2,
|
|
15
|
+
"type": "choice",
|
|
16
|
+
"label": "接入方式",
|
|
17
|
+
"options": [
|
|
18
|
+
{ "v": "A", "t": "直连 18080" },
|
|
19
|
+
{ "v": "B", "t": "走 DSH subagent" }
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": 3,
|
|
24
|
+
"type": "bool",
|
|
25
|
+
"label": "网关计划任务常驻",
|
|
26
|
+
"boolLabel": "接受"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": 4,
|
|
30
|
+
"type": "scale",
|
|
31
|
+
"label": "整体评分",
|
|
32
|
+
"min": 1,
|
|
33
|
+
"max": 5
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": 5,
|
|
37
|
+
"type": "text",
|
|
38
|
+
"label": "有没有看着不对的地方"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
package/icon.svg
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="批阅表格">
|
|
2
|
+
<rect x="4" y="8" width="40" height="32" rx="5" fill="#0969da" opacity="0.12"/>
|
|
3
|
+
<rect x="4" y="8" width="40" height="32" rx="5" fill="none" stroke="#0969da" stroke-width="2.4"/>
|
|
4
|
+
<path d="M4 18h40" stroke="#0969da" stroke-width="2.2" stroke-linecap="round"/>
|
|
5
|
+
<path d="M18 18v22M32 18v22" stroke="#0969da" stroke-width="1.8" opacity="0.45"/>
|
|
6
|
+
<path d="M9 25.5l3 3 6-6" fill="none" stroke="#1a7f37" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7
|
+
<path d="M23 26.5h6M37 26.5h6M23 33h6" stroke="#59636e" stroke-width="2" stroke-linecap="round" opacity="0.6"/>
|
|
8
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-batch-review — host half.
|
|
3
|
+
*
|
|
4
|
+
* Registers three things with the host:
|
|
5
|
+
*
|
|
6
|
+
* 1. the `batch_review` tool — the agent hands over N items; they are answered
|
|
7
|
+
* either through the paged native card (`ctx.userQuestions.ask()`) or, when
|
|
8
|
+
* the review is large enough and the client panel is mounted, through the
|
|
9
|
+
* one-screen panel (`lib/panel.js` + `lib/client.js`);
|
|
10
|
+
* 2. the panel's HTTP surface under `/api/batch-review` (only when the host
|
|
11
|
+
* exposes `webServer` — leaner compositions fall back to the native card);
|
|
12
|
+
* 3. the `batch-review-table` skill — the routing rules and the HTML fallback
|
|
13
|
+
* that ships in `skills/`.
|
|
14
|
+
*
|
|
15
|
+
* See `lib/tool.js` for the mapping/report helpers and `lib/skill.js` for the
|
|
16
|
+
* skill provider.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { makeBatchReviewTool } from './lib/tool.js';
|
|
20
|
+
import { registerSkill } from './lib/skill.js';
|
|
21
|
+
import { BatchReviewPanel } from './lib/panel.js';
|
|
22
|
+
import { registerPrompt } from './lib/prompt.js';
|
|
23
|
+
import {
|
|
24
|
+
DEFAULTS,
|
|
25
|
+
LIMITS,
|
|
26
|
+
configPath,
|
|
27
|
+
normalize,
|
|
28
|
+
readFileConfigRaw,
|
|
29
|
+
removedConfigKeys,
|
|
30
|
+
resolveConfig,
|
|
31
|
+
writeFileConfig,
|
|
32
|
+
} from './lib/config.js';
|
|
33
|
+
|
|
34
|
+
/** Services this plugin needs from the host. `webServer` is optional. */
|
|
35
|
+
export const inject = ['tools', 'userQuestions', 'skills'];
|
|
36
|
+
|
|
37
|
+
export function apply(ctx, rawConfig) {
|
|
38
|
+
/** Defaults < cordis config < settings file; the section mutates this in place. */
|
|
39
|
+
const settingsFile = configPath();
|
|
40
|
+
const { errors: cordisErrors, deprecated } = normalize(rawConfig);
|
|
41
|
+
if (cordisErrors.length > 0) {
|
|
42
|
+
// A typo in the profile patch used to be dropped without a trace: the value
|
|
43
|
+
// silently fell back to the default while the operator believed it applied.
|
|
44
|
+
ctx.logger?.warn?.('dsh-batch-review: cordis config 值非法已忽略:' + cordisErrors.join(';'));
|
|
45
|
+
}
|
|
46
|
+
// A removed key must not look active. The panel now serves loopback clients
|
|
47
|
+
// only, so a leftover `allowNonLoopback` (in the profile or the settings file)
|
|
48
|
+
// is dropped and called out once at startup.
|
|
49
|
+
const removedKeys = new Set([
|
|
50
|
+
...deprecated,
|
|
51
|
+
...removedConfigKeys(readFileConfigRaw(settingsFile)),
|
|
52
|
+
]);
|
|
53
|
+
for (const key of removedKeys) {
|
|
54
|
+
ctx.logger?.warn?.(
|
|
55
|
+
`dsh-batch-review: 配置项 ${key} 已移除,面板只服务回环客户端;该项被忽略。`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const config = resolveConfig(rawConfig, settingsFile);
|
|
59
|
+
const panel = new BatchReviewPanel({
|
|
60
|
+
logger: ctx.logger,
|
|
61
|
+
timeoutMs: config.panelTimeoutMs,
|
|
62
|
+
maxBodyBytes: config.maxBodyBytes,
|
|
63
|
+
virtualThreshold: config.virtualThreshold,
|
|
64
|
+
// The Settings → left-nav [批阅面板] section reads and writes these through
|
|
65
|
+
// GET/POST /config.
|
|
66
|
+
settings: {
|
|
67
|
+
path: settingsFile,
|
|
68
|
+
defaults: DEFAULTS,
|
|
69
|
+
limits: LIMITS,
|
|
70
|
+
config,
|
|
71
|
+
save(patch) {
|
|
72
|
+
// The settings page reports its UI language on every request, so a bad
|
|
73
|
+
// value is reported in the language the owner is reading.
|
|
74
|
+
const { values, errors, removals } = normalize(patch, panel.locale);
|
|
75
|
+
if (errors.length > 0) {
|
|
76
|
+
const error = new Error(errors.join(';'));
|
|
77
|
+
error.status = 400;
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
// Only the keys the page actually changed arrive here (null = drop the
|
|
81
|
+
// stored override), so saving one field no longer freezes every other
|
|
82
|
+
// tunable at its resolved value and silently shadows the cordis layer.
|
|
83
|
+
const next = { ...values };
|
|
84
|
+
for (const key of removals) next[key] = null;
|
|
85
|
+
writeFileConfig(next, settingsFile);
|
|
86
|
+
Object.assign(config, resolveConfig(rawConfig, settingsFile));
|
|
87
|
+
// Panel-side tunables live on the instance, so apply them now instead of
|
|
88
|
+
// asking for a restart.
|
|
89
|
+
panel.timeoutMs = config.panelTimeoutMs;
|
|
90
|
+
panel.maxBodyBytes = config.maxBodyBytes;
|
|
91
|
+
panel.virtualThreshold = config.virtualThreshold;
|
|
92
|
+
return { ...config };
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// An unloaded plugin must leave no waiting review and no timeout timer behind:
|
|
98
|
+
// the disposer settles a live review as CANCELLED and forgets the cache.
|
|
99
|
+
ctx.effect(() => () => panel.dispose());
|
|
100
|
+
|
|
101
|
+
ctx.effect(() => {
|
|
102
|
+
const dispose = ctx.tools.register(makeBatchReviewTool(ctx, { panel, config }));
|
|
103
|
+
return () => dispose();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
ctx.effect(() => {
|
|
107
|
+
const dispose = registerSkill(ctx);
|
|
108
|
+
return () => dispose();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Routing rule as a prompt section: present on every request, so other users do
|
|
112
|
+
// not have to copy an AGENTS.md rule by hand. Optional — a composition without
|
|
113
|
+
// the systemPrompt service still gets the tool and the skill. Users who prefer
|
|
114
|
+
// to own the rule can switch it off with `injectRoutingRule: false`; the section
|
|
115
|
+
// is registered at apply time, so the change takes a restart.
|
|
116
|
+
ctx.effect(() => {
|
|
117
|
+
if (config.injectRoutingRule === false) return () => {};
|
|
118
|
+
const dispose = registerPrompt(ctx);
|
|
119
|
+
return () => {
|
|
120
|
+
if (typeof dispose === 'function') dispose();
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// The panel is an optional surface: without a web server the native card still
|
|
125
|
+
// works, and `panel.available()` stays false so the tool never waits for it.
|
|
126
|
+
try {
|
|
127
|
+
ctx.inject(['webServer'], (webCtx) => {
|
|
128
|
+
const disposers = panel.routes().map((definition) => webCtx.webServer.register(definition));
|
|
129
|
+
return () => {
|
|
130
|
+
for (const dispose of disposers) {
|
|
131
|
+
try {
|
|
132
|
+
dispose?.();
|
|
133
|
+
} catch {
|
|
134
|
+
/* unloading must not throw */
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
} catch (error) {
|
|
140
|
+
ctx.logger?.warn?.(`dsh-batch-review: panel routes not registered: ${String(error?.message ?? error)}`);
|
|
141
|
+
}
|
|
142
|
+
}
|