dsh-rolegroup 0.11.7 → 0.12.0

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
@@ -3,8 +3,65 @@
3
3
  本项目遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
4
4
  版本纪律见 `AGENTS.md`「提交与发布」。
5
5
 
6
- > **`npm` 上一个已发布版本是 `0.6.1`。** 这期间开发中用过 0.6.2 / 0.6.3 / 0.8.0 等内部里程碑号,
7
- > 但都没有发布;下面 `0.7.0` 是**自 `0.6.1` 以来的累积变更**(按 semver 只升一个 minor,不跳号)。
6
+ > **历史注记**:`0.7.0` 发布前,npm 上的上一版本是 `0.6.1`;这期间开发中用过 0.6.2 / 0.6.3 / 0.8.0 等
7
+ > 内部里程碑号但都没发布,所以 `0.7.0` 是**自 `0.6.1` 以来的累积变更**(按 semver 只升一个 minor,不跳号)。
8
+ > 当前 npm 上的 latest 见 registry(2026-11-16 查 `dist-tags.latest` = `0.11.7`)。
9
+
10
+ ---
11
+
12
+ ## [0.12.0] — 2026-11-16
13
+
14
+ ### Added
15
+
16
+ - 新增 `/rg <任务>` 命令(`/rolegroup work <任务>` 长别名):向主会话注入一条
17
+ `source.kind='rolegroup'` 的委派指令;只主会话可用,子会话拒绝;不点名具体角色,按在册公告选择。
18
+
19
+ ### Changed
20
+
21
+ - 角色委派方法论:`analyst` / `reviewer` / `scout` 的 persona 增加核验纪律(逐字引用、`UNVERIFIED`、
22
+ `PARTIAL` 与 `FALSE` 的区分);`roleAnnouncement` 增加简报模板、父 agent 规范(子任务结论是输入不是裁决)
23
+ 和角色分流(代码定位/事实取证 → scout,带验收标准的收口核对 → reviewer,设计判断 → analyst;
24
+ 实现任务已有结构化计划或规格才派 coder,未形成计划的可先派 planner)。
25
+ - 依据:2026-11-16 的四臂对照。同一 `analyst` 下,中性简报逐字准确;加了“如果全真就说 5/5 TRUE”的简报
26
+ 把 5 条部分成立的命题全判 `TRUE` 并编造引用。完整记录在内部评测档案,不随仓库公开。
27
+ - 角色公告明确备用链只在配置提供 `fallbackModels` 时生效,示例路由改为 `kimi-coding/k3.1-pro`,并明确角色工具仅主会话可用。
28
+ - coder/planner 去方法论化:内置 persona 不再写死 TDD 与 plans.md;计划/规格路径由调用方简报给出(兼容 openspec
29
+ 的 tasks.md、superpowers 的 docs/plans/*.md、changeflow 的 plans/<change>.md),验证节奏以计划描述为准。
30
+ 注意传播断点:已在面板保存过角色的用户,其内联 persona 不受内置表变更影响,需「恢复官方推荐」或手动编辑才能切换到新默认。
31
+
32
+ ### Fixed
33
+
34
+ - 启动期改用备用档后,末次角色公告会按实际路由重发,并列出「已改用备用档」的角色;重挂失败或被 preset
35
+ 健康审计剔除的角色不会再同时出现在这条备用档提示里。
36
+ - 零在册角色且有降级时,公告只说明当前无角色、列出降级并给出 `/rolegroup doctor`,不再输出空角色列表、
37
+ `fallback` 分流或简报模板;降级段也删去了并不总成立的「其余角色不受影响」。零角色且无降级时公告返回空串。
38
+ - provider 已注册但模型未在广告列表的角色,除了启动日志,现在也会在公告中列出「模型未在广告列表」及
39
+ 「委派预检可能失败」;降级与该预警可并存,风险条目使用 resolved 实际备用路由,不再错写主路由。
40
+ - 修复路由解析返回角色副本后按对象 key 回收导致的 fiber/preset 残留;重挂失败立即按 toolName 从有效角色
41
+ 剔除并回收资源,后续审计 reject/timeout 不再把它留在 registered,也不影响其他健康角色。
42
+ - 修正公告的备用链与证据要求:不再声称所有角色都有备用链;代码、运行、图片与外部事实分别要求文件:行号、
43
+ 命令与输出、区域/坐标和原始来源,无法复现的按 UNVERIFIED 处理。
44
+ - 文档修正与精简:源码首装改为 `npm install --omit=peer` → `link:deps`,analyst 示例回到
45
+ `qwen3.8-max`,vision 备用链说明补齐账号档;删除过期的测试数量,合并重复安装说明并压缩 doctor 正常示例。
46
+
47
+ ### 验证
48
+
49
+ - `npm test` 154 passed;
50
+ - `npm run build:client` 连跑两次,产物 hash 一致(构建确定性);
51
+ - 真实 DSH 中 `/rolegroup doctor`:重载前后均 8 个角色在册,`failed` / `invalid` / `problems` 为空;
52
+ - 一次 `/rg` 实际委派:命中 `fallback`,返回了包名与版本;
53
+ - 插件停用再启用后,启动报告的时间字段有更新。
54
+
55
+ 截至定版时尚未执行 `npm publish`。
56
+
57
+ ### English summary
58
+
59
+ Adds `/rg` for role-based delegation from the main session. Changes delegation verification discipline
60
+ (verbatim citations, evidence requirements per fact type) and makes coder/planner methodology-neutral so
61
+ callers pass their own plan or spec paths. Fixes lifecycle cleanup (no leftover fiber/preset when
62
+ re-registration fails), warnings that now report the actual fallback route, and role announcement text that
63
+ no longer overclaims fallback chains or hides degradation states. Also corrects and trims the bilingual
64
+ installation, model, and diagnostics documentation.
8
65
 
9
66
  ---
10
67
 
package/README.en.md CHANGED
@@ -7,7 +7,7 @@ instance, so the tool name is the role name.
7
7
  The role/category binding is inspired by
8
8
  [oh-my-openagent](https://github.com/code-yeongyu/oh-my-openagent) ("omo"); see §9.
9
9
 
10
- > Version **0.11.7** | dsh **≥ 0.2.1-rc.1** (verified on 0.2.2-rc.3) | MIT
10
+ > Version **0.12.0** | dsh **≥ 0.2.1-rc.1** (verified on 0.2.2-rc.3) | MIT
11
11
 
12
12
  ---
13
13
 
@@ -30,11 +30,9 @@ delegation. The two can coexist in one deployment. A common pattern is to split
30
30
 
31
31
  | We do not | Why |
32
32
  |---|---|
33
- | **Orchestrate** (DAGs, multi-round collaboration, team pipelines) | That is the official Agent Teams' job; two orchestrators fight each other |
34
33
  | **Register an MCP server** | Dozens of tools inflate the tool list, the permission surface, and the prompt budget |
35
34
  | **Write a project-level state directory** (`.rolegroup/`) | We route work; we are not a runtime state machine — state belongs to the orchestration layer |
36
35
  | **Take over the main session's Agent Preset** | An explicit preset **replaces** the parent composition (§4); taking over means choosing for the user |
37
- | **Keep dual-shape branches for old dsh lines** | Since v0.6 we support ≥0.2.1 only; older lines get a clear error instead of half-working |
38
36
 
39
37
  When you need orchestration, state, or an MCP tool chain, compose other plugins — they do not replace this one.
40
38
 
@@ -49,12 +47,8 @@ dsh plugin --profile web add dsh-rolegroup
49
47
  You can also open the Plugins page, click "Add plugin", choose "Install a third-party plugin", enter
50
48
  `dsh-rolegroup`, and click "Install". Restart `dsh web` after installing.
51
49
 
52
- If a third-party market rewrite drops the plugin, add it again.
53
-
54
- ### Plugin market
55
-
56
- Open the Plugin Market, search for `dsh-rolegroup`, and install it. The market uses the same plugin manager
57
- underneath.
50
+ If a third-party market rewrite drops the plugin, add it again. You can also search for
51
+ `dsh-rolegroup` in the Plugin Market and install it — same flow underneath.
58
52
 
59
53
  ### From source
60
54
 
@@ -63,16 +57,19 @@ For development or local changes:
63
57
  ```sh
64
58
  git clone https://github.com/zhouxnsz/dsh-rolegroup.git
65
59
  cd dsh-rolegroup
60
+ npm install --omit=peer
66
61
  npm run link:deps
67
- npm install
68
62
  dsh plugin --profile web add "link:$PWD"
69
63
  ```
70
64
 
71
- `link:deps` symlinks the deployment's schemastery into this repo; the Settings panel needs it for source
72
- installs. Run `link:deps` before `npm install`: npm installs the `@deepseek-ai/schemastery` peer as a real
73
- copy, which blocks the symlink.
65
+ `--omit=peer` installs the esbuild devDependency without pulling the peer
66
+ `@deepseek-ai/schemastery` in as a real copy; `link:deps` then symlinks the deployment's schemastery into
67
+ this repo, which the Settings panel needs for source installs. The reverse order breaks: a plain
68
+ `npm install` puts a real copy there first, and `link:deps` **does not overwrite** an existing real
69
+ directory. If you already have one, delete `node_modules/@deepseek-ai/schemastery` and rerun `link:deps`.
74
70
 
75
- You can also mount it on the home layer:
71
+ You can also mount it on the home layer (use this only to survive profile rewrites; for regular
72
+ development use the `link:` install above):
76
73
 
77
74
  ```sh
78
75
  ln -sfn "$PWD" ~/.dsh/profiles/web/node_modules/dsh-rolegroup
@@ -95,6 +92,19 @@ dsh --profile web --dump-config | grep -A1 dsh-rolegroup # should show - id: d
95
92
  Restart `dsh web` and open a new session. The eight role tools should be in the tool list; you can also run
96
93
  `/rolegroup doctor` from the new session.
97
94
 
95
+ ### Delegate by role
96
+
97
+ Type:
98
+
99
+ ```
100
+ /rg <task>
101
+ ```
102
+
103
+ The plugin injects the task plus a "delegate by role" directive into the main session; the main model then
104
+ picks from the roles registered on this machine, writes briefs, and dispatches. `/rolegroup work <task>` is
105
+ the long alias. `/rg` is main-session only — child sessions get an error. It only triggers; whether to
106
+ dispatch is still the main model's call.
107
+
98
108
  After changing code, restart and open a new session. For panel saves, see §5.
99
109
 
100
110
  ## 3. Built-in roles
@@ -110,8 +120,8 @@ them in the panel. Model ids and the effective routes are whatever `/rolegroup d
110
120
  | Role | Built-in model | Responsibility |
111
121
  |---|---|---|
112
122
  | `analyst` | Qwen3.8 Max | Requirement clarification, path classification, plan review (do it / how), architecture decisions |
113
- | `planner` | Kimi K3.1 Pro | Plan design: file layout, task breakdown, interface contracts, writing `plans.md` |
114
- | `coder` | Kimi K3.1 Pro | Implementation: TDD red-green-refactor following `plans.md` steps |
123
+ | `planner` | Kimi K3.1 Pro | Plan design: file layout, task breakdown, interface contracts, writing the plan document |
124
+ | `coder` | Kimi K3.1 Pro | Implementation: follow the steps of the plan/spec document supplied in the brief and report evidence per step |
115
125
  | `reviewer` | Qwen3.8 Flash | Closing review: check acceptance criteria against evidence (was it actually done) |
116
126
  | `scout` | DeepSeek V4.1 Flash | Exploration and bulk search (returns `file:line` evidence) |
117
127
  | `scribe` | Qwen3.8 Flash | Documentation backfill, reports, spec maintenance |
@@ -120,8 +130,28 @@ them in the panel. Model ids and the effective routes are whatever `/rolegroup d
120
130
 
121
131
  ### Recommended bindings (official suggestion)
122
132
 
123
- See **[MODELS.en.md](./MODELS.en.md)** for the recommended model per role. "Recommended" and "built-in default"
124
- can differ — `reviewer` is one.
133
+ See **[MODELS.en.md](./MODELS.en.md)** for the built-in default model per role.
134
+
135
+ ### Delegation quality
136
+
137
+ Roles do not inherit the parent's context; the more specific the brief, the more usable the result. The
138
+ plugin gives the main model a fixed template in the system prompt:
139
+
140
+ - A brief should state: background, goal, constraints, acceptance, known facts (`file:line`), claims to verify;
141
+ - Factual conclusions need verifiable evidence: `file:line` for code, command and output for runtime results,
142
+ region/coordinates for images, and original sources for external facts;
143
+ quote verbatim, and unreproducible facts are marked UNVERIFIED;
144
+ - Do not prescribe the expected verdict distribution ("should be all true / should find problems"). The
145
+ 2026-11-16 comparison showed this wording makes `analyst` compress partially-true claims into `TRUE` and
146
+ fabricate quotes; the neutral briefs quoted verbatim.
147
+ - A subagent's conclusion is input, not a verdict. Spot-check quotes; do not adopt a confident report that
148
+ cannot show evidence.
149
+
150
+ Fallback chains apply only when a role configuration provides fallbackModels; an explicitly configured role
151
+ without that field does not inherit the built-in chain.
152
+ The degraded and model-unadvertised warnings can coexist, and preflight risk names the actual fallback route.
153
+
154
+ Use `scout` for code location and fact-finding, `reviewer` for acceptance-criteria closing review, and `analyst` for design judgement. For implementation, use `coder` when a structured plan or spec already exists (with its path supplied in the brief); if no plan has been formed, you may delegate to `planner` first.
125
155
 
126
156
  ## 4. Configuration
127
157
 
@@ -159,14 +189,11 @@ available, with repair hints when something is wrong. When a built-in fallback i
159
189
  > On a fresh machine, run `/rolegroup doctor` first to see which roles' primary routes are unavailable; change
160
190
  > bindings in the panel.
161
191
 
162
- Note: pasting text starting with `/` into the GUI composer sends it as a normal message, not a command. Type
163
- it by hand or pick it from the completion list.
164
-
165
192
  Example:
166
193
 
167
194
  > If a role's provider is not registered, an error block is appended below the table and the provider is
168
195
  > marked ❌. The role is not registered. This matters most for a fallback role: a skipped fallback route does
169
- > not exist. Built-in fallbacks point at dsh's own DeepSeek providers, which ship with every install:
196
+ > not exist. The built-in `fallback` role uses `deepseek-official` because that provider is always registered:
170
197
 
171
198
  ```
172
199
  ❌ fallback:provider "example-provider" 当前未注册(在用:deepseek-official, kimi-coding, qwen-token-plan-cn)
@@ -175,18 +202,9 @@ Example:
175
202
 
176
203
  ```
177
204
  dsh-rolegroup doctor — 8 个在册角色
178
- 快照时间 2026-10-25T12:00:00.000Z(0 天前)|配置来源 (内置默认表)
179
-
180
- 角色 绑定模型 provider 模型
181
- analyst qwen-token-plan-cn/qwen3.8-max ✅ ✅
182
- planner kimi-coding/k3.1-pro ✅ ✅
183
- coder kimi-coding/k3.1-pro ✅ ✅
184
- reviewer qwen-token-plan-cn/qwen3.8-flash ✅ ✅
185
- scout deepseek-official/deepseek-flash ✅ ✅
186
- scribe qwen-token-plan-cn/qwen3.8-flash ✅ ✅
187
- vision qwen-token-plan-cn/qwen3.8-flash ✅ ✅
188
- fallback deepseek-official/deepseek-flash ✅ ✅
189
-
205
+ analyst qwen-token-plan-cn/qwen3.8-max ✅ ✅
206
+ planner kimi-coding/k3.1-pro ✅ ✅
207
+ …
190
208
  ✅ 无异常
191
209
  ```
192
210
 
@@ -196,23 +214,17 @@ when the llm service is down the availability column shows ➖.
196
214
  ## 7. Development
197
215
 
198
216
  ```sh
199
- npm run link:deps # first after cloning: create the schemastery symlink
200
- npm install # then install the esbuild devDependency
201
- npm test # offline smoke suite, 158 cases; pretest runs link:deps
202
- npm run build:client # after editing src/client/** or lib/roles.js
217
+ npm install --omit=peer # esbuild devDependency, without schemastery as a real copy
218
+ npm run link:deps # symlink the deployment's schemastery into this repo
219
+ npm test # offline smoke suite (plain Node); pretest runs link:deps
220
+ npm run build:client # after editing src/client/** or lib/roles.js
203
221
  ```
204
222
 
205
- Run `link:deps` before `npm install`: npm installs the `@deepseek-ai/schemastery` peer as a real copy, which
206
- blocks the symlink. If you already ran `npm install`, delete `node_modules/@deepseek-ai/schemastery` and rerun
207
- `link:deps`. Without `npm install`, `npm test` fails with `ERR_MODULE_NOT_FOUND: esbuild`. Without
208
- `link:deps`, dsh prints
223
+ For the install order and why, see §2 "From source". Without `npm install`, `npm test` fails with
224
+ `ERR_MODULE_NOT_FOUND: esbuild`. Without `link:deps`, dsh prints
209
225
  `无法使用部署树的 @deepseek-ai/schemastery …` at startup and the plugin runs host-only: role tools still
210
- work, but the Settings section is missing.
211
-
212
- What `link:deps` does: the plugin is installed as a `link:`, so by Node's realpath rule it cannot import
213
- `@deepseek-ai/*` directly. Settings also requires the entry to export a schemastery `Config` statically,
214
- which cannot be resolved lazily. The script symlinks the deployment's schemastery into this repo; the symlink
215
- is not committed.
226
+ work, but the Settings section is missing. `pretest` runs `link:deps` automatically, but it likewise does
227
+ not overwrite an existing real copy.
216
228
 
217
229
  Layout:
218
230
 
package/README.md CHANGED
@@ -6,7 +6,7 @@ dsh 的角色化委派插件。先定义角色(名字、绑定模型、persona
6
6
  角色/类别绑定的思路参考了 [oh-my-openagent](https://github.com/code-yeongyu/oh-my-openagent)(omo),
7
7
  详见 §9。
8
8
 
9
- > 版本 **0.11.7** | 要求 dsh **≥ 0.2.1-rc.1**(本机实测 0.2.2-rc.3)| MIT
9
+ > 版本 **0.12.0** | 要求 dsh **≥ 0.2.1-rc.1**(本机实测 0.2.2-rc.3)| MIT
10
10
 
11
11
  ---
12
12
 
@@ -27,7 +27,6 @@ dsh 的角色化委派插件。先定义角色(名字、绑定模型、persona
27
27
 
28
28
  | 不做 | 为什么 |
29
29
  |---|---|
30
- | **不做编排**(DAG / 多轮协作 / 团队流水线) | 那是官方智能体团队的职责;两套编排会互相踩 |
31
30
  | **不注册 MCP server** | 几十个工具会把工具列表、权限面、prompt 预算一起撑大 |
32
31
  | **不写项目级状态目录**(`.rolegroup/`) | 我们做的是「路由」,不是「运行时状态机」;状态属于编排层 |
33
32
  | **不接管主会话的会话模式(Agent Preset)** | 显式 preset 是**替换**父组合(§4),接管等于替用户做选择 |
@@ -45,11 +44,8 @@ dsh plugin --profile web add dsh-rolegroup
45
44
  也可以在「插件」页 →「添加插件」→「安装第三方插件」,填 `dsh-rolegroup`,点「安装」。装好后重启
46
45
  `dsh web`。
47
46
 
48
- 如果第三方市场重写 profile 把插件清掉,重新 `add` 一次即可。
49
-
50
- ### 插件市场
51
-
52
- 打开「插件市场」,搜索 `dsh-rolegroup`,点安装。市场和上面的插件管理器走同一套安装流程。
47
+ 如果第三方市场重写 profile 把插件清掉,重新 `add` 一次即可。也可以在「插件市场」搜索
48
+ `dsh-rolegroup` 安装,走同一套流程。
53
49
 
54
50
  ### 从源码安装
55
51
 
@@ -58,15 +54,17 @@ dsh plugin --profile web add dsh-rolegroup
58
54
  ```sh
59
55
  git clone https://github.com/zhouxnsz/dsh-rolegroup.git
60
56
  cd dsh-rolegroup
57
+ npm install --omit=peer
61
58
  npm run link:deps
62
- npm install
63
59
  dsh plugin --profile web add "link:$PWD"
64
60
  ```
65
61
 
66
- `link:deps` 会把部署树的 schemastery 软链进来;源码安装时设置面板需要它。先跑 `link:deps` 再跑
67
- `npm install`:npm 会把 peer dependency `@deepseek-ai/schemastery` 装成真实副本,顺序反了会挡住软链。
62
+ `--omit=peer` 装 devDependency esbuild 而不把 peer `@deepseek-ai/schemastery` 装成真实副本;随后
63
+ `link:deps` 把部署树的 schemastery 软链进来,设置面板需要它。顺序反过来会踩坑:普通 `npm install`
64
+ 先装出真实副本,之后 `link:deps` 遇到真实目录**不覆盖**。已有真实副本时删掉
65
+ `node_modules/@deepseek-ai/schemastery` 再跑一次 `link:deps`。
68
66
 
69
- 也可以挂到 home 层:
67
+ 也可以挂到 home 层(仅当需要绕过 profile 重写时使用;常规开发用上面的 `link:` 安装):
70
68
 
71
69
  ```sh
72
70
  ln -sfn "$PWD" ~/.dsh/profiles/web/node_modules/dsh-rolegroup
@@ -77,8 +75,7 @@ cat >> ~/.dsh/cordis.patch.yml <<'YAML'
77
75
  YAML
78
76
  ```
79
77
 
80
- home 层不会被 profile 重写覆盖,但不会出现在「已安装」组,也没有启停开关。两种源码安装方式选一个,
81
- 不要同时用。
78
+ home 层不会被 profile 重写覆盖,但不会出现在「已安装」组,也没有启停开关。两种方式选一个,不要同时用。
82
79
 
83
80
  ### 验证
84
81
 
@@ -89,6 +86,18 @@ dsh --profile web --dump-config | grep -A1 dsh-rolegroup # 应出现 - id: dsh
89
86
  重启 `dsh web`,开一个新会话。工具列表里应该出现 8 个角色工具;也可以在新会话里跑
90
87
  `/rolegroup doctor`。
91
88
 
89
+ ### 按角色委派
90
+
91
+ 在会话里输入:
92
+
93
+ ```
94
+ /rg <任务>
95
+ ```
96
+
97
+ 插件会把任务和一段“按角色委派”的指令注入主会话;主模型据此从本机在册角色中选择、写简报并派发。
98
+ `/rolegroup work <任务>` 是长别名。`/rg` 只主会话可用,子会话调用会被拒绝;它只负责触发,
99
+ 是否派发仍由主模型判断。
100
+
92
101
  改代码后需要重启并开新会话。面板保存怎么生效,见 §5。
93
102
 
94
103
  ## 3. 内置角色
@@ -102,8 +111,8 @@ dsh --profile web --dump-config | grep -A1 dsh-rolegroup # 应出现 - id: dsh
102
111
  | 角色 | 内置绑定模型 | 职责 |
103
112
  |---|---|---|
104
113
  | `analyst` | Qwen3.8 Max | 需求澄清、路径分类、方案评审(做不做/怎么做)、架构决策 |
105
- | `planner` | Kimi K3.1 Pro | 计划设计:文件结构、任务拆分、接口契约、`plans.md` 落笔 |
106
- | `coder` | Kimi K3.1 Pro | 编码执行:按 `plans.md` 步骤 TDD 红-绿-重构 |
114
+ | `planner` | Kimi K3.1 Pro | 计划设计:文件结构、任务拆分、接口契约、计划文档落笔 |
115
+ | `coder` | Kimi K3.1 Pro | 编码执行:按计划/规格文档步骤实现并回填证据 |
107
116
  | `reviewer` | Qwen3.8 Flash | 收口审查:逐项核对验收标准与证据(做没做到) |
108
117
  | `scout` | DeepSeek V4.1 Flash | 探索定位、批量搜索(返回 `文件:行号` 证据) |
109
118
  | `scribe` | Qwen3.8 Flash | 文档回填、报告、spec 维护 |
@@ -112,7 +121,22 @@ dsh --profile web --dump-config | grep -A1 dsh-rolegroup # 应出现 - id: dsh
112
121
 
113
122
  ### 推荐绑定(官方建议)
114
123
 
115
- 各角色的官方推荐模型见 **[MODELS.md](./MODELS.md)**。表里「推荐」与「内置默认」可能不同,比如 `reviewer`。
124
+ 各角色的内置默认模型见 **[MODELS.md](./MODELS.md)**。
125
+
126
+ ### 委派质量
127
+
128
+ 角色不继承父会话上下文,简报越具体,返回越可用。插件在系统提示里给主模型一段固定模板:
129
+
130
+ - 简报至少写:背景、目标、约束、验收、已知事实(文件:行号)、待核验命题;
131
+ - 事实性结论必须有可核验依据:代码事实给文件:行号,运行结果给命令与输出,图片给区域/坐标,外部事实给原始来源;引用逐字,无法复现的按 UNVERIFIED 处理;
132
+ - 不要预设结论分布(不要写「应该全真/应该有问题」)。2026-11-16 的对照显示,这种写法会让 `analyst`
133
+ 把部分成立的命题压成 `TRUE` 并编造引用;中性简报逐字准确。
134
+ - 子任务结论是输入,不是裁决;主模型要抽查引用,重结论轻证据的回报不要直接采纳。
135
+
136
+ 备用链仅在角色配置提供 fallbackModels 时生效;显式配置的角色没写这个字段时,不继承内置链。
137
+ 降级与模型未广告预警可并存,预检风险使用实际备用路由。
138
+
139
+ 代码定位与事实取证用 `scout`;带验收标准的收口核对用 `reviewer`;设计判断用 `analyst`。实现任务已有结构化计划或规格时用 `coder`(路径随简报给出),未形成计划的可先派 `planner`。
116
140
 
117
141
  ## 4. 配置
118
142
 
@@ -160,18 +184,9 @@ doctor 会写明「主路由 X 不可用,已用内置备用档 Y」。
160
184
 
161
185
  ```
162
186
  dsh-rolegroup doctor — 8 个在册角色
163
- 快照时间 2026-10-25T12:00:00.000Z(0 天前)|配置来源 (内置默认表)
164
-
165
- 角色 绑定模型 provider 模型
166
- analyst qwen-token-plan-cn/qwen3.8-max ✅ ✅
167
- planner kimi-coding/k3.1-pro ✅ ✅
168
- coder kimi-coding/k3.1-pro ✅ ✅
169
- reviewer qwen-token-plan-cn/qwen3.8-flash ✅ ✅
170
- scout deepseek-official/deepseek-flash ✅ ✅
171
- scribe qwen-token-plan-cn/qwen3.8-flash ✅ ✅
172
- vision qwen-token-plan-cn/qwen3.8-flash ✅ ✅
173
- fallback deepseek-official/deepseek-flash ✅ ✅
174
-
187
+ analyst qwen-token-plan-cn/qwen3.8-max ✅ ✅
188
+ planner kimi-coding/k3.1-pro ✅ ✅
189
+ …
175
190
  ✅ 无异常
176
191
  ```
177
192
 
@@ -180,21 +195,16 @@ fallback deepseek-official/deepseek-flash ✅ ✅
180
195
  ## 7. 开发
181
196
 
182
197
  ```sh
183
- npm run link:deps # 首次 clone 后先跑:建 schemastery 软链
184
- npm install # 再装 devDependency esbuild
185
- npm test # 离线 smoke test,158 项;pretest 会自动跑 link:deps
186
- npm run build:client # 改了 src/client/** 或 lib/roles.js 后重建 lib/client.js
198
+ npm install --omit=peer # 装 devDependency esbuild,不把 schemastery 装成真实副本
199
+ npm run link:deps # 把部署树的 schemastery 软链进来
200
+ npm test # 离线 smoke suite(Node 直跑);pretest 会自动跑 link:deps
201
+ npm run build:client # 改了 src/client/** 或 lib/roles.js 后重建 lib/client.js
187
202
  ```
188
203
 
189
- 先跑 `link:deps` 再跑 `npm install`:npm 会把 `@deepseek-ai/schemastery` 这个 peer 装成真实副本,
190
- 顺序反了会挡住软链。如果已经装过,删掉 `node_modules/@deepseek-ai/schemastery` 再跑一次 `link:deps`。
191
- 不跑 `npm install`,`npm test` 会报 `ERR_MODULE_NOT_FOUND: esbuild`。不跑 `link:deps`,dsh 启动时会
192
- 打印 `无法使用部署树的 @deepseek-ai/schemastery …`,插件降级成 host-only:角色工具还能用,设置页
193
- 那一节会缺席。
194
-
195
- `link:deps` 是做什么的:插件以 `link:` 形式安装,按 Node 的 realpath 规则,没法直接 import
196
- `@deepseek-ai/*`;而 settings 要求条目静态导出 schemastery 的 `Config`,不能延迟解析。所以脚本把部署
197
- 树里的 schemastery 软链到本仓库,软链不会提交。
204
+ 安装顺序和原因见 §2「从源码安装」。不跑 `npm install`,`npm test` 会报
205
+ `ERR_MODULE_NOT_FOUND: esbuild`。不跑 `link:deps`,dsh 启动时会打印
206
+ `无法使用部署树的 @deepseek-ai/schemastery …`,插件降级成 host-only:角色工具还能用,设置页
207
+ 那一节会缺席。`pretest` 虽然自动跑 `link:deps`,但同样不会覆盖已存在的真实副本。
198
208
 
199
209
  目录:
200
210
 
package/lib/client.js CHANGED
@@ -33,7 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
33
33
  var PLUGIN_VERSION, PLUGIN_REPO_URL;
34
34
  var init_meta = __esm({
35
35
  "src/client/meta.js"() {
36
- PLUGIN_VERSION = true ? "0.11.7" : "dev";
36
+ PLUGIN_VERSION = true ? "0.12.0" : "dev";
37
37
  PLUGIN_REPO_URL = "https://github.com/zhouxnsz/dsh-rolegroup";
38
38
  }
39
39
  });
@@ -310,6 +310,8 @@ var DEFAULT_ROLES = {
310
310
  "\u4F60\u662F analyst\u2014\u2014\u9700\u6C42\u6F84\u6E05\u4E0E\u65B9\u6848\u8BC4\u5BA1\u89D2\u8272\u3002",
311
311
  "\u804C\u8D23\uFF1A\u628A\u6A21\u7CCA\u9700\u6C42\u5148\u5206\u7C7B\u8DEF\u5F84\uFF08\u63A2\u7D22/\u53D8\u66F4/\u4FEE\u590D\uFF09\uFF0C\u63D0\u51FA\u5173\u952E\u95EE\u9898\uFF0C\u8BC4\u5BA1\u300C\u505A\u4E0D\u505A\u3001\u600E\u4E48\u505A\u300D\uFF0C\u7ED9\u51FA\u67B6\u6784\u51B3\u7B56\u5EFA\u8BAE\u3002",
312
312
  "\u94C1\u5F8B\uFF1A\u4F60\u53EA\u8BFB\u4E0D\u5199\uFF0C\u4E0D\u52A8\u624B\u5B9E\u73B0\uFF1B\u8F93\u51FA\u5FC5\u987B\u662F\u7ED3\u8BBA + \u4F9D\u636E\uFF08\u6587\u4EF6:\u884C\u53F7 \u6216\u5B98\u65B9\u6765\u6E90\uFF09\uFF1B",
313
+ "\u6838\u9A8C\u7EAA\u5F8B\uFF1A\u6D89\u53CA API/\u5B57\u6BB5/\u547D\u4EE4\u884C\u4E3A\u7684\u65AD\u8A00\uFF0C\u5148\u8BFB\u6E90\u7801\u5E76\u9010\u5B57\u5F15\u7528\uFF1B\u65E0\u6CD5\u786E\u8BA4\u7684\u6807 UNVERIFIED\uFF0C\u4E0D\u7528\u8BB0\u5FC6\u8865\u5168\uFF1B",
314
+ "\u63AA\u8F9E\u6216\u8BED\u5883\u4E0D\u7CBE\u786E\u5224 PARTIAL\uFF0C\u88AB\u6E90\u7801\u76F4\u63A5\u5426\u5B9A\u624D\u5224 FALSE\uFF1B\u4E0D\u8981\u5236\u9020 FALSE\uFF0C\u4E5F\u4E0D\u8981\u628A PARTIAL \u538B\u6210 TRUE\u3002",
313
315
  "\u53D1\u73B0\u9700\u6C42\u6B67\u4E49\u65F6\u5148\u5217\u5206\u652F\u518D\u63D0\u95EE\uFF0C\u4E0D\u66FF\u7528\u6237\u62CD\u677F\u3002"
314
316
  ].join("\n")
315
317
  },
@@ -317,11 +319,11 @@ var DEFAULT_ROLES = {
317
319
  provider: "kimi-coding",
318
320
  model: "k3.1-pro",
319
321
  fallbackModels: ["deepseek-account/deepseek-flash", "deepseek-official/deepseek-flash", "deepseek-official/deepseek-v4-pro"],
320
- summary: "\u8BA1\u5212\u8BBE\u8BA1\uFF1A\u6587\u4EF6\u7ED3\u6784\u3001\u4EFB\u52A1\u62C6\u5206\u3001\u63A5\u53E3\u5951\u7EA6\u3001plans.md \u843D\u7B14",
322
+ summary: "\u8BA1\u5212\u8BBE\u8BA1\uFF1A\u6587\u4EF6\u7ED3\u6784\u3001\u4EFB\u52A1\u62C6\u5206\u3001\u63A5\u53E3\u5951\u7EA6\u3001\u8BA1\u5212\u6587\u6863\u843D\u7B14",
321
323
  persona: [
322
324
  "\u4F60\u662F planner\u2014\u2014\u8BA1\u5212\u8BBE\u8BA1\u89D2\u8272\u3002",
323
- "\u804C\u8D23\uFF1A\u628A\u6279\u51C6\u540E\u7684\u65B9\u6848\u843D\u6210\u53EF\u6267\u884C\u8BA1\u5212\uFF1A\u6587\u4EF6\u7ED3\u6784\u3001\u4EFB\u52A1\u62C6\u5206\uFF08\u6BCF\u4EFB\u52A1\u5E26\u9A8C\u6536\u6807\u51C6\u3001\u6D89\u53CA\u6587\u4EF6\u3001\u6D4B\u8BD5\u5148\u884C\u3001\u8BC1\u636E\uFF09\u3001\u63A5\u53E3\u5951\u7EA6\u3002",
324
- "\u7EA6\u5B9A\uFF1A\u4F60\u7684\u5199\u5165\u8303\u56F4\u4EC5\u9650 plans/ \u76EE\u5F55\u4E0E\u8BA1\u5212\u6587\u6863\uFF08\u8F6F\u7EA6\u5B9A\uFF09\uFF1B\u4E0D\u5199\u751F\u4EA7\u4EE3\u7801\uFF1B",
325
+ "\u804C\u8D23\uFF1A\u628A\u6279\u51C6\u540E\u7684\u65B9\u6848\u843D\u6210\u53EF\u6267\u884C\u8BA1\u5212\uFF1A\u6587\u4EF6\u7ED3\u6784\u3001\u4EFB\u52A1\u62C6\u5206\uFF08\u6BCF\u4EFB\u52A1\u5E26\u9A8C\u6536\u6807\u51C6\u3001\u6D89\u53CA\u6587\u4EF6\u3001\u9A8C\u8BC1\u7B56\u7565\u3001\u8BC1\u636E\uFF09\u3001\u63A5\u53E3\u5951\u7EA6\u3002",
326
+ "\u7EA6\u5B9A\uFF1A\u4F60\u7684\u5199\u5165\u8303\u56F4\u4EC5\u9650\u8C03\u7528\u65B9\u6307\u5B9A\u7684\u8BA1\u5212\u76EE\u5F55\u4E0E\u8BA1\u5212\u6587\u6863\uFF08\u672A\u6307\u5B9A\u65F6\u9ED8\u8BA4 plans/\uFF0C\u8F6F\u7EA6\u5B9A\uFF09\uFF1B\u4E0D\u5199\u751F\u4EA7\u4EE3\u7801\uFF1B",
325
327
  "\u4EFB\u52A1\u7C92\u5EA6\u4EE5\u300C\u4E00\u4E2A coder \u4E00\u8F6E\u80FD\u95ED\u73AF\u300D\u4E3A\u51C6\u3002"
326
328
  ].join("\n")
327
329
  },
@@ -329,10 +331,10 @@ var DEFAULT_ROLES = {
329
331
  provider: "kimi-coding",
330
332
  model: "k3.1-pro",
331
333
  fallbackModels: ["deepseek-account/deepseek-flash", "deepseek-official/deepseek-flash", "deepseek-official/deepseek-v4-pro"],
332
- summary: "\u7F16\u7801\u6267\u884C\uFF1A\u6309 plans.md \u6B65\u9AA4 TDD \u7EA2-\u7EFF-\u91CD\u6784",
334
+ summary: "\u7F16\u7801\u6267\u884C\uFF1A\u6309\u8BA1\u5212/\u89C4\u683C\u6587\u6863\u6B65\u9AA4\u5B9E\u73B0\u5E76\u56DE\u586B\u8BC1\u636E",
333
335
  persona: [
334
336
  "\u4F60\u662F coder\u2014\u2014\u7F16\u7801\u6267\u884C\u89D2\u8272\u3002",
335
- "\u804C\u8D23\uFF1A\u4E25\u683C\u6309 plans.md \u7684\u4EFB\u52A1\u6B65\u9AA4\u6267\u884C TDD\uFF1A\u5148\u5199\u5931\u8D25\u6D4B\u8BD5\uFF08\u7EA2\uFF09\u2192 \u6700\u5C0F\u5B9E\u73B0\u901A\u8FC7\uFF08\u7EFF\uFF09\u2192 \u91CD\u6784\uFF1B",
337
+ "\u804C\u8D23\uFF1A\u4E25\u683C\u6309\u8C03\u7528\u65B9\u7B80\u62A5\u6307\u5B9A\u7684\u8BA1\u5212\u6216\u89C4\u683C\u6587\u6863\uFF08\u8DEF\u5F84\u7531\u7B80\u62A5\u7ED9\u51FA\uFF09\u6267\u884C\u4EFB\u52A1\u6B65\u9AA4\uFF1B\u9A8C\u8BC1\u8282\u594F\u4EE5\u8BA1\u5212\u63CF\u8FF0\u4E3A\u51C6\uFF0C\u4E0D\u81EA\u5E26\u56FA\u5B9A\u65B9\u6CD5\u8BBA\uFF1B",
336
338
  "\u6BCF\u6B65\u56DE\u586B\u8BC1\u636E\uFF08\u8DD1\u4E86\u4EC0\u4E48\u547D\u4EE4\u3001\u770B\u5230\u4EC0\u4E48\u8F93\u51FA\uFF09\u3002",
337
339
  "\u94C1\u5F8B\uFF1A\u4E0D\u504F\u79BB\u8BA1\u5212\u64C5\u81EA\u6269\u5927\u8303\u56F4\uFF1B\u9047\u5230\u8BA1\u5212\u7F3A\u9677\uFF0C\u505C\u4E0B\u6765\u62A5\u544A\uFF0C\u4E0D\u7ED5\u9053\u3002"
338
340
  ].join("\n")
@@ -346,6 +348,8 @@ var DEFAULT_ROLES = {
346
348
  "\u4F60\u662F reviewer\u2014\u2014\u6536\u53E3\u5BA1\u67E5\u89D2\u8272\u3002",
347
349
  "\u804C\u8D23\uFF1A\u9010\u9879\u6838\u5BF9\u9A8C\u6536\u6807\u51C6\u4E0E\u5B9E\u9645\u4EA7\u7269\uFF0C\u53EA\u8BA4\u8BC1\u636E\uFF08\u547D\u4EE4\u8F93\u51FA\u3001\u6D4B\u8BD5\u8BB0\u5F55\u3001\u6587\u4EF6:\u884C\u53F7\uFF09\uFF0C\u4E0D\u63A5\u53D7\u300C\u6211\u89C9\u5F97\u597D\u4E86\u300D\uFF1B",
348
350
  "\u6309\u4E25\u91CD\u5EA6\u5217\u51FA\u95EE\u9898\uFF08\u963B\u585E/\u5EFA\u8BAE\uFF09\u3002",
351
+ "\u6838\u9A8C\u7EAA\u5F8B\uFF1A\u4E8B\u5B9E\u6027\u7ED3\u8BBA\u9010\u5B57\u5F15\u7528\u6587\u4EF6:\u884C\u53F7\uFF1B\u65E0\u6CD5\u5F15\u7528\u5C31\u6807 UNVERIFIED\uFF1B",
352
+ "\u533A\u5206 PARTIAL\uFF08\u63AA\u8F9E/\u8BED\u5883\u4E0D\u7CBE\u786E\uFF09\u4E0E FALSE\uFF08\u88AB\u6E90\u7801\u76F4\u63A5\u5426\u5B9A\uFF09\uFF0C\u4E0D\u8981\u4E3A\u4E86\u627E\u9519\u628A PARTIAL \u5224\u6210 FALSE\uFF0C\u4E5F\u4E0D\u8981\u628A PARTIAL \u538B\u6210 TRUE\uFF1B\u5168\u771F\u5C31\u5199\u5168\u771F\u3002",
349
353
  "\u94C1\u5F8B\uFF1A\u4F60\u53EA\u8BFB\u4E0D\u5199\uFF1B\u5BA1\u67E5\u8303\u56F4\u9650\u4E8E\u9A8C\u6536\u6807\u51C6\u3001\u8BC1\u636E\u771F\u5B9E\u6027\u3001\u8BA1\u5212\u7B26\u5408\u5EA6\uFF0C\u4E0D\u505A\u98CE\u683C\u8B66\u5BDF\uFF1B",
350
354
  "\u7ED3\u8BBA\u5FC5\u987B\u660E\u786E\uFF1A\u901A\u8FC7 / \u6709\u6761\u4EF6\u901A\u8FC7 / \u6253\u56DE\u3002"
351
355
  ].join("\n")
@@ -358,6 +362,7 @@ var DEFAULT_ROLES = {
358
362
  persona: [
359
363
  "\u4F60\u662F scout\u2014\u2014\u63A2\u7D22\u5B9A\u4F4D\u89D2\u8272\u3002",
360
364
  "\u804C\u8D23\uFF1A\u5728\u4EE3\u7801\u5E93\u4E2D\u5FEB\u901F\u5B9A\u4F4D\uFF08\u6279\u91CF\u641C\u7D22\u3001\u4EA4\u53C9\u5F15\u7528\uFF09\uFF0C\u8FD4\u56DE \u6587\u4EF6:\u884C\u53F7 \u7EA7\u522B\u7684\u8BC1\u636E\u6E05\u5355\u4E0E\u4E00\u53E5\u8BDD\u7ED3\u8BBA\u3002",
365
+ "\u6838\u9A8C\u7EAA\u5F8B\uFF1A\u5148\u8BFB cited line \u524D\u540E 10 \u884C\uFF1B\u8FD4\u56DE\u9010\u5B57\u5F15\u7528\uFF0C\u4E0D\u8F6C\u8FF0\u3001\u4E0D\u7528\u8BB0\u5FC6\u8865\u5168\u4EE3\u7801\uFF1B\u65E0\u6CD5\u786E\u8BA4\u7684\u6807 UNVERIFIED\uFF1B\u547D\u9898\u5E26\u8BED\u5883\u9650\u5B9A\u65F6\u5224 PARTIAL \u5E76\u5199\u51FA\u9650\u5B9A\u3002",
361
366
  "\u94C1\u5F8B\uFF1A\u4F60\u53EA\u8BFB\u4E0D\u5199\uFF1B\u4E0D\u505A\u957F\u7BC7\u5206\u6790\uFF0C\u5B9A\u4F4D\u5373\u4EA4\u4ED8\uFF1B",
362
367
  "\u627E\u4E0D\u5230\u5C31\u660E\u8BF4\u627E\u4E0D\u5230\uFF0C\u5E76\u7ED9\u51FA\u5DF2\u6392\u9664\u7684\u8DEF\u5F84\u3002"
363
368
  ].join("\n")
package/lib/command.js CHANGED
@@ -12,15 +12,25 @@
12
12
  // 2. handler 不得抛——一切 IO 失败归一化为 kind:'error' 结果文本。
13
13
  // 3. 尊重 invocation.signal:aborted 时立刻返回,不再发起 listModels 调用。
14
14
  // 4. 单角色 hint ≤3 条、异常 >10 条折叠(渲染层 enforce,见 doctor.js)。
15
+ import { randomUUID } from 'node:crypto'
15
16
  import { auditRoles, readStartupReport, renderDoctorText } from './doctor.js'
16
17
  import { renderBindingsExport } from './init.js'
17
18
 
18
19
  const COMMAND_NAME = 'rolegroup'
19
- const COMMAND_DESCRIPTION = '角色表体检与导出:doctor 报告绑定模型/provider 可用性,init 导出当前生效绑定'
20
+ const COMMAND_DESCRIPTION = '角色表体检、绑定导出与按角色委派:doctor / init / work'
21
+ const RG_COMMAND_NAME = 'rg'
22
+ const RG_COMMAND_DESCRIPTION = '按角色委派任务(/rg <任务>)'
23
+ const RG_SOURCE_KIND = 'rolegroup'
24
+ const RG_USAGE = [
25
+ '用法:/rg <任务>',
26
+ ' 把任务按本机在册角色委派;/rolegroup work <任务> 是长别名。',
27
+ ' 仅主会话可用;角色不可再嵌套委派。',
28
+ ].join('\n')
20
29
  const USAGE = [
21
30
  '用法:/rolegroup <子命令>',
22
31
  ' doctor 角色表体检(读上次启动快照,比对当前 provider/模型可用性并给修复建议)',
23
32
  ' init 导出当前生效的角色绑定(JSONC 文本;仅供留档/比对)',
33
+ ' work <任务> 按角色委派(同 /rg)',
24
34
  ' --help 显示本帮助',
25
35
  ].join('\n')
26
36
 
@@ -28,7 +38,7 @@ const USAGE = [
28
38
  * 自解析子命令(宿主只认注册名,子命令是插件自己的语法责任,H5)。
29
39
  * 不做前缀模糊匹配('docto' → unknown,避免误触发,AC-16)。
30
40
  * @param {string} rawInput 命令名之后逐字保留的文本
31
- * @returns {{ kind: 'doctor' } | { kind: 'usage' } | { kind: 'unknown', sub: string }}
41
+ * @returns {{ kind: 'doctor' } | { kind: 'init' } | { kind: 'work', task: string } | { kind: 'usage' } | { kind: 'unknown', sub: string }}
32
42
  */
33
43
  export function parseRolegroupCommand(rawInput) {
34
44
  const trimmed = (rawInput ?? '').trim()
@@ -36,6 +46,11 @@ export function parseRolegroupCommand(rawInput) {
36
46
  const sub = trimmed.split(/\s+/u)[0]
37
47
  if (sub === '--help' || sub === '-h' || sub === 'help') return { kind: 'usage' }
38
48
  if (sub === 'doctor') return { kind: 'doctor' }
49
+ if (sub === 'work') {
50
+ const task = trimmed.replace(/^work(?:\s+|$)/u, '').trim()
51
+ if (task === '') return { kind: 'usage' }
52
+ return { kind: 'work', task }
53
+ }
39
54
  if (sub === 'init') {
40
55
  const extra = trimmed.split(/\s+/u).slice(1)
41
56
  if (extra.length > 0) return { kind: 'unknown', sub: `init ${extra.join(' ')}` }
@@ -44,6 +59,81 @@ export function parseRolegroupCommand(rawInput) {
44
59
  return { kind: 'unknown', sub }
45
60
  }
46
61
 
62
+ /**
63
+ * `/rg` 注入的开关指令。刻意**不点名具体角色**:角色会因 provider 不可用被剪枝,
64
+ * systemPrompt 公告才是实际在册表的同源视图。
65
+ * @param {string} task
66
+ * @returns {string}
67
+ */
68
+ export function buildRgDirective(task) {
69
+ const body = typeof task === 'string' ? task.trim() : ''
70
+ return [
71
+ '[/rg] 用户通过 /rg 提交了下面的任务。请按本机角色公告里在册的角色处理:',
72
+ '先判断哪些子任务可独立、需要不同模型或专长;为每个子任务写全简报(背景、目标、约束、验收标准、相关文件:行号),再委派给对应角色。',
73
+ '不要自己从头实现;汇总时说明每个角色返回了什么、哪些未验证。',
74
+ '这是 /rg 命令生成的委派指令,不是新的用户请求;不要据此创建或修改 goal,也不要改写会话标题。',
75
+ '任务:',
76
+ body,
77
+ ].join('\n')
78
+ }
79
+
80
+ /**
81
+ * 本地构造 `UserMessage`,不 import `@deepseek-ai/dsh-llm`(link: 形态下裸导入会失败)。
82
+ * session 校验只要求:id 非空 string、role='user'、source.kind 非空 string、content 数组。
83
+ * 用自定义 source kind `rolegroup`,避免被 goal 的 `hasDirectHumanInput`(只认 'user')
84
+ * 当成“直接人类请求”。
85
+ * @param {string} task
86
+ * @param {() => string} [idFactory] 测试注入固定 id
87
+ * @returns {object}
88
+ */
89
+ export function createRgUserMessage(task, idFactory = randomUUID) {
90
+ const id = idFactory()
91
+ const content = Object.freeze([Object.freeze({ type: 'text', text: buildRgDirective(task) })])
92
+ return Object.freeze({
93
+ id,
94
+ role: 'user',
95
+ content,
96
+ source: Object.freeze({ kind: RG_SOURCE_KIND, command: RG_COMMAND_NAME }),
97
+ })
98
+ }
99
+
100
+ /**
101
+ * 子会话判定:subagent 用 origin / delegationDepth;`parentSession` 对普通 fork 不可靠,
102
+ * 不能单凭它判断(dsh-session types.d.ts:72-76)。
103
+ * @param {object|undefined} header
104
+ * @returns {boolean}
105
+ */
106
+ export function isSubagentSession(header) {
107
+ if (header === undefined || header === null || typeof header !== 'object') return false
108
+ return header.origin === 'subagent'
109
+ || (typeof header.delegationDepth === 'number' && header.delegationDepth > 0)
110
+ }
111
+
112
+ /**
113
+ * `/rg` 与 `/rolegroup work` 共用的 handler。同步执行,永不抛(红线 2)。
114
+ * @param {object} invocation
115
+ * @param {string} [taskOverride] `/rolegroup work` 已解析出的任务
116
+ * @returns {{ kind: 'success', text: string } | { kind: 'error', text: string }}
117
+ */
118
+ function handleRg(invocation, taskOverride) {
119
+ try {
120
+ if (invocation?.signal?.aborted) return { kind: 'error', text: '/rg:已取消(signal 已中止)' }
121
+ const task = typeof taskOverride === 'string' ? taskOverride.trim() : (invocation?.rawInput ?? '').trim()
122
+ if (task === '') return { kind: 'error', text: RG_USAGE }
123
+ const agent = invocation?.agent
124
+ if (agent === undefined || agent === null || typeof agent.followup !== 'function') {
125
+ return { kind: 'error', text: '/rg:当前会话不可用(缺少可注入的 agent)。' }
126
+ }
127
+ if (isSubagentSession(agent.session?.header)) {
128
+ return { kind: 'error', text: '/rg 仅主会话可用;角色工具不可再嵌套委派。' }
129
+ }
130
+ agent.followup(createRgUserMessage(task))
131
+ return { kind: 'success', text: '已提交角色委派指令;接下来由主模型按在册角色选择并派发。' }
132
+ } catch (error) {
133
+ return { kind: 'error', text: `/rg 执行失败:${error?.message ?? error}` }
134
+ }
135
+ }
136
+
47
137
  function warn(ctx, message) {
48
138
  try { ctx.logger?.warn?.(message) } catch { /* 日志都不可用时静默 */ }
49
139
  }
@@ -62,6 +152,8 @@ export function installRolegroupCommands(ctx, options = {}) {
62
152
  if (done) return // 立即通道与 inject 通道理论上只其一触发,防御双触发
63
153
  done = true
64
154
  registerCommand(cctx, commands, options)
155
+ // /rg 与 /rolegroup 各自独立:/rolegroup 被占用时短命令仍可注册,反之亦然。
156
+ registerRgCommand(cctx, commands)
65
157
  }
66
158
 
67
159
  let immediate
@@ -93,21 +185,49 @@ function registerCommand(cctx, commands, options = {}) {
93
185
  const existing = commands.list?.(undefined) ?? []
94
186
  if (existing.some((c) => c?.name === COMMAND_NAME)) {
95
187
  warn(cctx, `dsh-rolegroup: 全局命令 "/${COMMAND_NAME}" 已被占用,放弃注册(doctor 不可用,其余功能不受影响)`)
96
- return
188
+ return false
97
189
  }
98
190
  } catch { /* list 不可用时照常注册,冲突由宿主裁决 */ }
99
191
 
100
192
  const definition = {
101
193
  name: COMMAND_NAME,
102
194
  description: COMMAND_DESCRIPTION,
103
- input: { hint: '[doctor|init]' }, // 不设 attachments:默认拒绝附件(AC-18)
195
+ input: { hint: '[doctor|init|work]' }, // 不设 attachments:默认拒绝附件(AC-18)
104
196
  handler: (invocation) => handleInvocation(cctx, invocation, options),
105
197
  }
106
198
  try {
107
199
  if (typeof cctx.effect === 'function') cctx.effect(() => commands.register(definition), 'dsh-rolegroup: command')
108
200
  else commands.register(definition)
201
+ return true
109
202
  } catch (error) {
110
203
  warn(cctx, `dsh-rolegroup: /rolegroup 命令注册失败:${error?.message ?? error};其余功能不受影响`)
204
+ return false
205
+ }
206
+ }
207
+
208
+ /** 注册短命令 /rg。被占用或注册失败只 warn,不抛;/rolegroup work 长别名仍可用。 */
209
+ function registerRgCommand(cctx, commands) {
210
+ try {
211
+ const existing = commands.list?.(undefined) ?? []
212
+ if (existing.some((c) => c?.name === RG_COMMAND_NAME)) {
213
+ warn(cctx, `dsh-rolegroup: 全局命令 "/${RG_COMMAND_NAME}" 已被占用,跳过短命令;/rolegroup work 仍可用`)
214
+ return false
215
+ }
216
+ } catch { /* list 不可用时照常注册,冲突由宿主裁决 */ }
217
+
218
+ const definition = {
219
+ name: RG_COMMAND_NAME,
220
+ description: RG_COMMAND_DESCRIPTION,
221
+ input: { hint: '<任务描述>' },
222
+ handler: (invocation) => handleRg(invocation),
223
+ }
224
+ try {
225
+ if (typeof cctx.effect === 'function') cctx.effect(() => commands.register(definition), 'dsh-rolegroup: rg command')
226
+ else commands.register(definition)
227
+ return true
228
+ } catch (error) {
229
+ warn(cctx, `dsh-rolegroup: /${RG_COMMAND_NAME} 命令注册失败:${error?.message ?? error};/rolegroup work 仍可用`)
230
+ return false
111
231
  }
112
232
  }
113
233
 
@@ -117,6 +237,7 @@ async function handleInvocation(ctx, invocation, options = {}) {
117
237
  const parsed = parseRolegroupCommand(invocation?.rawInput ?? '')
118
238
  if (parsed.kind === 'usage') return { kind: 'success', text: USAGE }
119
239
  if (parsed.kind === 'unknown') return { kind: 'error', text: `未知子命令 "${parsed.sub}"。\n\n${USAGE}` }
240
+ if (parsed.kind === 'work') return handleRg(invocation, parsed.task)
120
241
  if (parsed.kind === 'init') return await executeInit(ctx, parsed, invocation?.signal, options?.describeLayer)
121
242
  return await executeDoctor(ctx, invocation?.signal)
122
243
  } catch (error) {
package/lib/index.js CHANGED
@@ -182,13 +182,13 @@ async function resolvePersonaFiles(ctx, roles, configSource) {
182
182
  /**
183
183
  * 启动路由校验(proposal §4 修订:白名单对固定 agentOptions 实例不生效,
184
184
  * 真正的防线是 provider 注册 + 委派时 preflight;这里把失败尽量提前到启动时)。
185
- * @returns {Promise<{valid: object[], invalid: Array<{role, reason}>}>}
185
+ * @returns {Promise<{valid: object[], invalid: Array<{role, reason}>, degraded: Array<object>, unadvertised: Array<{toolName, route}>}>}
186
186
  */
187
187
  async function validateRoutes(ctx, roles) {
188
188
  const llm = ctx.get?.('llm')
189
189
  if (llm === undefined) {
190
190
  ctx.logger.warn('dsh-rolegroup: llm 服务不可用,跳过路由启动校验(委派时仍会预检)')
191
- return { valid: roles, invalid: [], degraded: [] }
191
+ return { valid: roles, invalid: [], degraded: [], unadvertised: [] }
192
192
  }
193
193
  const providerIds = llm.listProviders().map((p) => p.id)
194
194
  const providerSet = new Set(providerIds)
@@ -207,6 +207,7 @@ async function validateRoutes(ctx, roles) {
207
207
  const valid = []
208
208
  const invalid = []
209
209
  const degraded = []
210
+ const unadvertised = []
210
211
  for (const role of roles) {
211
212
  const resolved = resolveRoleRoute(role, { providers: providerSet, modelsOf })
212
213
  if (!resolved.ok) {
@@ -222,13 +223,15 @@ async function validateRoutes(ctx, roles) {
222
223
  degraded.push({ toolName: role.toolName, primary: resolved.primary, role, resolved: resolved.role })
223
224
  ctx.logger.warn(`dsh-rolegroup: 角色 "${role.toolName}" 的主路由 ${resolved.primary} 不可用,改用备用档 `
224
225
  + `${resolved.role.provider}/${resolved.role.model}(内置链自动降级)`)
225
- } else if (resolved.warning === 'model-unadvertised') {
226
- ctx.logger.warn(`dsh-rolegroup: 角色 "${role.toolName}" 的模型 "${role.model}" 不在 ${role.provider} 的广告列表;`
227
- + '仍注册,委派时预检会最终裁决')
226
+ }
227
+ if (resolved.warning === 'model-unadvertised') {
228
+ unadvertised.push({ toolName: role.toolName, route: `${resolved.role.provider}/${resolved.role.model}` })
229
+ ctx.logger.warn(`dsh-rolegroup: 角色 "${role.toolName}" 的模型 "${resolved.role.model}" 不在 ${resolved.role.provider} 的广告列表`
230
+ + `(${resolved.role.provider}/${resolved.role.model});仍注册,委派时预检会最终裁决`)
228
231
  }
229
232
  valid.push(resolved.role)
230
233
  }
231
- return { valid, invalid, degraded }
234
+ return { valid, invalid, degraded, unadvertised }
232
235
  }
233
236
 
234
237
  async function apply(ctx, optionsOrConfig) {
@@ -267,7 +270,7 @@ async function apply(ctx, optionsOrConfig) {
267
270
  // 立即注册全部角色,不做启动时路由硬校验——实证(2026-09-22 双实例,L1):
268
271
  // llm-pi-ai 的 provider 注册晚于本插件 apply(彼时只有内置 deepseek-official),
269
272
  // 启动即校验会误杀全部非 deepseek 角色。校验延后到 llm/adapters-updated 防抖后进行。
270
- const fibers = new Map() // role -> cordis Fiber(dispose 即注销该角色的工具)
273
+ const fibers = new Map() // role.toolName -> cordis Fiber(dispose 即注销该角色的工具)
271
274
  const registered = []
272
275
  const failed = []
273
276
  /** toolName → 主路由不可用时的降级记录(写进启动报告,doctor 读)。 */
@@ -307,23 +310,23 @@ async function apply(ctx, optionsOrConfig) {
307
310
 
308
311
  // ---- v0.6 注册链:角色 = Agent Preset(persona + 克隆的完整组合)+ 委派工具实例 ----
309
312
  // 顺序不可交换:tool-subagent 的 validate() 会 readDocument(presetId)(上游 lib/index.js:533/:583)。
310
- const presetDisposers = new Map() // role -> disposePreset
313
+ const presetDisposers = new Map() // role.toolName -> disposePreset
311
314
 
312
315
  /** 注销一个角色:**先 fiber 后 preset**,每步独立 try/warn(顺序理由:工具先消失)。 */
313
- const disposeRole = async (role) => {
314
- const fiber = fibers.get(role)
315
- fibers.delete(role)
316
+ const disposeRole = async (toolName) => {
317
+ const fiber = fibers.get(toolName)
318
+ fibers.delete(toolName)
316
319
  try {
317
320
  await fiber?.dispose()
318
321
  } catch (err) {
319
- log.warn(`dsh-rolegroup: 角色 "${role.toolName}" 注销失败:${err?.message ?? err}`)
322
+ log.warn(`dsh-rolegroup: 角色 "${toolName}" 注销失败:${err?.message ?? err}`)
320
323
  }
321
- const disposePreset = presetDisposers.get(role)
322
- presetDisposers.delete(role)
324
+ const disposePreset = presetDisposers.get(toolName)
325
+ presetDisposers.delete(toolName)
323
326
  try {
324
327
  await disposePreset?.()
325
328
  } catch (err) {
326
- log.warn(`dsh-rolegroup: 角色 "${role.toolName}" 的 agent preset 注销失败:${err?.message ?? err}`)
329
+ log.warn(`dsh-rolegroup: 角色 "${toolName}" 的 agent preset 注销失败:${err?.message ?? err}`)
327
330
  }
328
331
  }
329
332
 
@@ -331,7 +334,7 @@ async function apply(ctx, optionsOrConfig) {
331
334
  // 否则会留孤儿 preset → 下次加载撞 `Duplicate agent preset` 让全部角色失败。
332
335
  try {
333
336
  ctx.effect?.(() => async () => {
334
- for (const role of [...fibers.keys()]) await disposeRole(role)
337
+ for (const toolName of [...fibers.keys()]) await disposeRole(toolName)
335
338
  }, 'dsh-rolegroup: dispose roles')
336
339
  } catch { /* effect 不可用时忽略(宿主 teardown 时 cordis 仍会 dispose 子 fiber) */ }
337
340
 
@@ -344,8 +347,8 @@ async function apply(ctx, optionsOrConfig) {
344
347
  const definition = buildPresetDefinition(basePresetRows, role, index)
345
348
  disposePreset = await presetsService.register(definition)
346
349
  const fiber = await ctx.plugin(subagentModule, buildInstanceConfig(role, definition.id))
347
- presetDisposers.set(role, disposePreset)
348
- fibers.set(role, fiber)
350
+ presetDisposers.set(role.toolName, disposePreset)
351
+ fibers.set(role.toolName, fiber)
349
352
  registered.push(role)
350
353
  log.info(`dsh-rolegroup: 角色 "${role.toolName}" 就绪(preset ${definition.id})`)
351
354
  } catch (err) {
@@ -435,11 +438,13 @@ async function apply(ctx, optionsOrConfig) {
435
438
  let valid
436
439
  let invalid
437
440
  let degraded = []
441
+ let unadvertised = []
438
442
  try {
439
443
  const result = await validateRoutes(ctx, registered)
440
444
  valid = result.valid
441
445
  invalid = result.invalid
442
446
  degraded = result.degraded ?? []
447
+ unadvertised = result.unadvertised ?? []
443
448
  } catch (validationError) {
444
449
  log.warn(`dsh-rolegroup: 启动终验路由校验失败(${validationError?.message ?? validationError}),按全量在册写报告`)
445
450
  valid = registered
@@ -452,15 +457,15 @@ async function apply(ctx, optionsOrConfig) {
452
457
  if (subagentModule === undefined || !canRegisterRoles) break
453
458
  const original = item.role
454
459
  const index = registered.findIndex((r) => r.toolName === original.toolName)
455
- const fiber = fibers.get(original)
456
- fibers.delete(original)
460
+ const fiber = fibers.get(original.toolName)
461
+ fibers.delete(original.toolName)
457
462
  try { await fiber?.dispose() } catch (err) {
458
463
  log.warn(`dsh-rolegroup: 角色 "${original.toolName}" 重挂前注销失败:${err?.message ?? err}`)
459
464
  }
460
- try { await presetDisposers.get(original)?.() } catch (err) {
465
+ try { await presetDisposers.get(original.toolName)?.() } catch (err) {
461
466
  log.warn(`dsh-rolegroup: 角色 "${original.toolName}" 的旧 preset 注销失败:${err?.message ?? err}`)
462
467
  }
463
- presetDisposers.delete(original)
468
+ presetDisposers.delete(original.toolName)
464
469
  let disposePreset
465
470
  try {
466
471
  // preset 的 name/description 带模型:降级后 header 必须显示**实际在跑**的路由,
@@ -468,12 +473,17 @@ async function apply(ctx, optionsOrConfig) {
468
473
  const definition = buildPresetDefinition(basePresetRows, item.resolved, index < 0 ? 0 : index)
469
474
  disposePreset = await presetsService.register(definition)
470
475
  const fiberNew = await ctx.plugin(subagentModule, buildInstanceConfig(item.resolved, definition.id))
471
- presetDisposers.set(original, disposePreset)
472
- fibers.set(original, fiberNew)
476
+ presetDisposers.set(original.toolName, disposePreset)
477
+ fibers.set(original.toolName, fiberNew)
473
478
  degradedRoutes.set(original.toolName, { primary: item.primary, provider: item.resolved.provider, model: item.resolved.model })
474
479
  } catch (err) {
480
+ // resolved.role 是副本;valid 必须按 toolName 立即剔除,不能依赖后续健康审计成功。
481
+ for (let validIndex = valid.length - 1; validIndex >= 0; validIndex -= 1) {
482
+ if (valid[validIndex].toolName === original.toolName) valid.splice(validIndex, 1)
483
+ }
475
484
  try { await disposePreset?.() } catch { /* 主错误已记录 */ }
476
485
  invalid.push({ role: original, reason: `备用档 ${item.resolved.provider}/${item.resolved.model} 注册失败:${err?.message ?? err}` })
486
+ await disposeRole(original.toolName)
477
487
  }
478
488
  }
479
489
  // v0.6 preset 健康审计(D8/D12):只在 finalize 做——此时 apply 已返回,不会在宿主 row
@@ -508,8 +518,13 @@ async function apply(ctx, optionsOrConfig) {
508
518
  }
509
519
  for (const { role, reason } of invalid) {
510
520
  log.error(`dsh-rolegroup: 角色 "${role.toolName}" 已注销——${reason}`)
511
- await disposeRole(role) // v0.6:fiber + preset 一并回收(剪枝路径也不得留孤儿)
521
+ await disposeRole(role.toolName) // v0.6:fiber + preset 一并回收(剪枝路径也不得留孤儿)
512
522
  }
523
+ // degraded 可能含重挂失败或审计剔除的角色;只给最终仍在册的角色写备用档公告。
524
+ const activeNames = new Set(valid.map((role) => role.toolName))
525
+ for (const { role } of invalid) activeNames.delete(role.toolName)
526
+ const degradedNames = degraded.map((item) => item.toolName).filter((toolName) => activeNames.has(toolName))
527
+ const unadvertisedNames = unadvertised.filter((item) => activeNames.has(item.toolName))
513
528
  // 运行时降级(v0.7):让模型也能看见——启动报告/doctor 只有人看得到。
514
529
  const degradations = []
515
530
  if (!canRegisterRoles) {
@@ -517,7 +532,14 @@ async function apply(ctx, optionsOrConfig) {
517
532
  }
518
533
  if (failed.length > 0) degradations.push(`注册失败:${failed.map((r) => r.toolName).join(', ')}`)
519
534
  if (invalid.length > 0) degradations.push(`已剪枝:${invalid.map((item) => item.role.toolName).join(', ')}`)
520
- if (invalid.length > 0 || failed.length > 0 || !canRegisterRoles || alwaysAnnounce) announce(valid, degradations)
535
+ if (degradedNames.length > 0) degradations.push(`${degradedNames.join(', ')} 已改用备用档`)
536
+ if (unadvertisedNames.length > 0) {
537
+ degradations.push(`模型未在广告列表:${unadvertisedNames.map((item) => `${item.toolName}(${item.route})`).join(', ')}(委派预检可能失败)`)
538
+ }
539
+ if (invalid.length > 0 || failed.length > 0 || !canRegisterRoles || alwaysAnnounce
540
+ || degradedNames.length > 0 || unadvertisedNames.length > 0) {
541
+ announce(valid, degradations)
542
+ }
521
543
  const summary = valid.map((r) => `${r.toolName}→${r.provider}/${r.model}`).join(' ')
522
544
  if (invalid.length === 0 && failed.length === 0 && problems.length === 0) {
523
545
  log.info(`dsh-rolegroup: ${valid.length} 个角色已注册:${summary}`)
@@ -529,7 +551,7 @@ async function apply(ctx, optionsOrConfig) {
529
551
 
530
552
  // D2 可重入装配:dispose 现有全部 fiber → 按新表注册 → finalize 收尾(三集合先清账再重记)
531
553
  const compose = async (nextRoles, configSource) => {
532
- for (const role of [...fibers.keys()]) await disposeRole(role)
554
+ for (const toolName of [...fibers.keys()]) await disposeRole(toolName)
533
555
  registered.length = 0
534
556
  failed.length = 0
535
557
  degradedRoutes.clear()
package/lib/roles.js CHANGED
@@ -44,6 +44,8 @@ export const DEFAULT_ROLES = {
44
44
  '你是 analyst——需求澄清与方案评审角色。',
45
45
  '职责:把模糊需求先分类路径(探索/变更/修复),提出关键问题,评审「做不做、怎么做」,给出架构决策建议。',
46
46
  '铁律:你只读不写,不动手实现;输出必须是结论 + 依据(文件:行号 或官方来源);',
47
+ '核验纪律:涉及 API/字段/命令行为的断言,先读源码并逐字引用;无法确认的标 UNVERIFIED,不用记忆补全;',
48
+ '措辞或语境不精确判 PARTIAL,被源码直接否定才判 FALSE;不要制造 FALSE,也不要把 PARTIAL 压成 TRUE。',
47
49
  '发现需求歧义时先列分支再提问,不替用户拍板。',
48
50
  ].join('\n'),
49
51
  },
@@ -51,11 +53,11 @@ export const DEFAULT_ROLES = {
51
53
  provider: 'kimi-coding',
52
54
  model: 'k3.1-pro',
53
55
  fallbackModels: ['deepseek-account/deepseek-flash', 'deepseek-official/deepseek-flash', 'deepseek-official/deepseek-v4-pro'],
54
- summary: '计划设计:文件结构、任务拆分、接口契约、plans.md 落笔',
56
+ summary: '计划设计:文件结构、任务拆分、接口契约、计划文档落笔',
55
57
  persona: [
56
58
  '你是 planner——计划设计角色。',
57
- '职责:把批准后的方案落成可执行计划:文件结构、任务拆分(每任务带验收标准、涉及文件、测试先行、证据)、接口契约。',
58
- '约定:你的写入范围仅限 plans/ 目录与计划文档(软约定);不写生产代码;',
59
+ '职责:把批准后的方案落成可执行计划:文件结构、任务拆分(每任务带验收标准、涉及文件、验证策略、证据)、接口契约。',
60
+ '约定:你的写入范围仅限调用方指定的计划目录与计划文档(未指定时默认 plans/,软约定);不写生产代码;',
59
61
  '任务粒度以「一个 coder 一轮能闭环」为准。',
60
62
  ].join('\n'),
61
63
  },
@@ -63,10 +65,10 @@ export const DEFAULT_ROLES = {
63
65
  provider: 'kimi-coding',
64
66
  model: 'k3.1-pro',
65
67
  fallbackModels: ['deepseek-account/deepseek-flash', 'deepseek-official/deepseek-flash', 'deepseek-official/deepseek-v4-pro'],
66
- summary: '编码执行:按 plans.md 步骤 TDD 红-绿-重构',
68
+ summary: '编码执行:按计划/规格文档步骤实现并回填证据',
67
69
  persona: [
68
70
  '你是 coder——编码执行角色。',
69
- '职责:严格按 plans.md 的任务步骤执行 TDD:先写失败测试(红)→ 最小实现通过(绿)→ 重构;',
71
+ '职责:严格按调用方简报指定的计划或规格文档(路径由简报给出)执行任务步骤;验证节奏以计划描述为准,不自带固定方法论;',
70
72
  '每步回填证据(跑了什么命令、看到什么输出)。',
71
73
  '铁律:不偏离计划擅自扩大范围;遇到计划缺陷,停下来报告,不绕道。',
72
74
  ].join('\n'),
@@ -80,6 +82,8 @@ export const DEFAULT_ROLES = {
80
82
  '你是 reviewer——收口审查角色。',
81
83
  '职责:逐项核对验收标准与实际产物,只认证据(命令输出、测试记录、文件:行号),不接受「我觉得好了」;',
82
84
  '按严重度列出问题(阻塞/建议)。',
85
+ '核验纪律:事实性结论逐字引用文件:行号;无法引用就标 UNVERIFIED;',
86
+ '区分 PARTIAL(措辞/语境不精确)与 FALSE(被源码直接否定),不要为了找错把 PARTIAL 判成 FALSE,也不要把 PARTIAL 压成 TRUE;全真就写全真。',
83
87
  '铁律:你只读不写;审查范围限于验收标准、证据真实性、计划符合度,不做风格警察;',
84
88
  '结论必须明确:通过 / 有条件通过 / 打回。',
85
89
  ].join('\n'),
@@ -92,6 +96,7 @@ export const DEFAULT_ROLES = {
92
96
  persona: [
93
97
  '你是 scout——探索定位角色。',
94
98
  '职责:在代码库中快速定位(批量搜索、交叉引用),返回 文件:行号 级别的证据清单与一句话结论。',
99
+ '核验纪律:先读 cited line 前后 10 行;返回逐字引用,不转述、不用记忆补全代码;无法确认的标 UNVERIFIED;命题带语境限定时判 PARTIAL 并写出限定。',
95
100
  '铁律:你只读不写;不做长篇分析,定位即交付;',
96
101
  '找不到就明说找不到,并给出已排除的路径。',
97
102
  ].join('\n'),
@@ -149,7 +154,7 @@ export const DEFAULT_ROLES = {
149
154
 
150
155
  /** 自定义角色(内置表以外的名字)缺省 persona。 */
151
156
  function genericPersona(toolName) {
152
- return `你是 ${toolName}——自定义委派角色。按调用方给定的任务简报执行,输出结论与依据。`
157
+ return `你是 ${toolName}——自定义委派角色。按调用方给定的任务简报执行,输出结论与依据;事实性断言必须能落到文件:行号,无法确认的标 UNVERIFIED。`
153
158
  }
154
159
 
155
160
  /**
@@ -359,22 +364,34 @@ export function buildInstanceConfig(role, presetId) {
359
364
  * 角色被剪枝/注册失败/整体契约不可用时,父模型会照常尝试委派一个不存在的工具,然后撞错。
360
365
  * 把降级写进公告,模型就能主动换角色或直接告知用户怎么修。
361
366
  * 健康时**完全不出现**该段(避免每次会话都挂着噪音)。
367
+ * 零角色且有降级时只输出「当前没有在册角色」+ 降级段;两者都空时返回空串(调用方据此不注册 section)。
362
368
  *
363
369
  * @param {Array<object>} roles 在册角色
364
370
  * @param {{ degradations?: string[] }} [options] 降级描述(每条一句人话,不含反引号——列表断言靠它区分在册角色)
365
371
  */
366
372
  export function roleAnnouncement(roles, options = {}) {
367
373
  const degradations = (options?.degradations ?? []).filter((line) => typeof line === 'string' && line !== '')
374
+ const degradationLines = degradations.length > 0
375
+ ? [`运行时降级:${degradations.join(';')}——排查入口 /rolegroup doctor`]
376
+ : []
377
+ if (roles.length === 0) {
378
+ if (degradationLines.length === 0) return ''
379
+ return [
380
+ '本机已安装 dsh-rolegroup 插件(角色化委派层):当前没有在册角色,不要尝试调用角色工具。',
381
+ ...degradationLines,
382
+ ].join('\n')
383
+ }
368
384
  const lines = roles.map((r) => `- \`${r.toolName}\`(${r.provider}/${r.model}):${r.summary}`)
369
385
  return [
370
- '本机已安装 dsh-rolegroup 插件(角色化委派层):以下角色是绑定了固定模型的委派工具,按任务性质选用——',
386
+ '本机已安装 dsh-rolegroup 插件(角色化委派层):以下角色是绑定了模型路由的委派工具;备用链仅在角色配置提供 fallbackModels 时生效。按任务性质选用——',
371
387
  ...lines,
372
- '使用约定:角色工具均为一次性委派(不可再嵌套委派);委派会立即返回 subagent id,任务完成时你会收到完成通知(不要轮询等待)。',
373
- '委派时 `description` 会作为子任务标题显示在页面上;请写成「任务摘要 · provider/model」,例如「登录校验实现 · kimi-coding/k3」,方便一眼看出用了哪个模型。',
374
- '把任务简报写完整(背景、目标、验收标准),角色不继承你的上下文;未分类的轻量任务用 `fallback`。',
388
+ '使用约定:角色工具仅主会话可用,均为一次性委派(不可再嵌套委派);委派会立即返回 subagent 名称,任务完成时你会收到完成通知(不要轮询等待)。',
389
+ '委派时 `description` 会作为子任务标题显示在页面上;请写成「任务摘要 · provider/model」,例如「登录校验实现 · kimi-coding/k3.1-pro」,方便一眼看出用了哪个模型。',
390
+ '把任务简报写完整:背景、目标、约束、验收、已知事实(文件:行号)、待核验命题;角色不继承你的上下文,未分类的轻量任务用 `fallback`。',
391
+ '不要预设结论分布(不要写「应该全真/应该有问题」),引用逐字。事实性结论必须有可核验依据:代码事实给文件:行号,运行结果给命令与输出,图片给区域/坐标,外部事实给原始来源;无法复现的按 UNVERIFIED 处理。',
392
+ '子任务结论是输入,不是裁决:抽查引用。代码定位/事实取证用 scout;带验收标准的收口核对用 reviewer;设计判断用 analyst。',
393
+ '实现任务:已有结构化计划或规格的用 coder(路径随简报给出);未形成计划的可先派 planner。',
375
394
  '角色↔模型搭配由 dsh-rolegroup 配置管理,改配置无需改工作流。',
376
- ...(degradations.length > 0
377
- ? [`运行时降级:${degradations.join(';')}(其余角色不受影响)——排查入口 /rolegroup doctor`]
378
- : []),
395
+ ...degradationLines,
379
396
  ].join('\n')
380
397
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-rolegroup",
3
- "version": "0.11.7",
3
+ "version": "0.12.0",
4
4
  "description": "角色化委派插件:把「这类活该用哪个模型」固化为角色(名字 + 绑定模型 + persona),按角色名委派 · Role-based delegation: bind each kind of work to a model once and delegate by role name",
5
5
  "icon": "assets/icon.svg",
6
6
  "license": "MIT",