dsh-rolegroup 0.0.0-stage → 0.6.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zhou.XiaoNing
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,349 @@
1
+ # dsh-rolegroup
2
+
3
+ A role-based delegation plugin for dsh. Define a role once (name, bound model, persona), then delegate by role
4
+ name instead of writing `provider`/`model` every time. Each role gets its own host `dsh-tool-subagent`
5
+ instance, so the tool name is the role name.
6
+
7
+ The role/category binding is inspired by
8
+ [oh-my-openagent](https://github.com/code-yeongyu/oh-my-openagent) ("omo"); see §10.
9
+
10
+ > Version **0.6.0** | dsh **≥ 0.2.1-rc.1** | MIT
11
+
12
+ ---
13
+
14
+ ## 1. Why rolegroup
15
+
16
+ Every delegation asks the same question: is this job worth an expensive model, or is a cheap one enough? If
17
+ the answer lives in the call, it is easy to get wrong and hard to reuse.
18
+
19
+ | | Input | It handles | Limit |
20
+ |---|---|---|---|
21
+ | Bare `subagent` | provider/model every time | nothing | you have to remember the model |
22
+ | **Agent Teams** (official; 智能体团队) | task DAG / roster | who does what, dependencies, multi-round work | teammates inherit the root model; no per-member model binding |
23
+ | **dsh-rolegroup** | roles, defined once | which model this kind of work uses | one-off specialist delegation; no orchestration |
24
+
25
+ They solve different problems. Agent Teams coordinates the work; rolegroup picks the model for a single
26
+ delegation. The two can coexist in one deployment. A common pattern is to split expensive and cheap work:
27
+ `reviewer` on a cheap model, `coder` on a strong one, with Agent Teams still doing the coordination.
28
+
29
+ Two other things:
30
+
31
+ - The role is the tool. `analyst`, `coder`, and `scout` show up in the tool list, so you do not have to think
32
+ about the model when delegating.
33
+ - You can check the result. `/rolegroup doctor` lists the model each role is actually using, and whether it
34
+ is available (see §6).
35
+
36
+ ## 2. Quick start
37
+
38
+ ### Official plugin manager
39
+
40
+ ```sh
41
+ dsh plugin --profile web add dsh-rolegroup
42
+ ```
43
+
44
+ You can also open the Plugins page, click "Add plugin", choose "Install a third-party plugin", enter
45
+ `dsh-rolegroup`, and click "Install". Restart `dsh web` after installing.
46
+
47
+ If a third-party market rewrite drops the plugin, add it again.
48
+
49
+ ### Plugin market
50
+
51
+ Open the Plugin Market, search for `dsh-rolegroup`, and install it. The market uses the same plugin manager
52
+ underneath.
53
+
54
+ ### From source
55
+
56
+ For development or local changes:
57
+
58
+ ```sh
59
+ git clone https://github.com/zhouxnsz/dsh-rolegroup.git
60
+ cd dsh-rolegroup
61
+ npm run link:deps
62
+ npm install
63
+ dsh plugin --profile web add "link:$PWD"
64
+ ```
65
+
66
+ `link:deps` symlinks the deployment's schemastery into this repo; the Settings panel needs it for source
67
+ installs. Run `link:deps` before `npm install`: npm installs the `@deepseek-ai/schemastery` peer as a real
68
+ copy, which blocks the symlink.
69
+
70
+ You can also mount it on the home layer:
71
+
72
+ ```sh
73
+ ln -sfn "$PWD" ~/.dsh/profiles/web/node_modules/dsh-rolegroup
74
+ cat >> ~/.dsh/cordis.patch.yml <<'YAML'
75
+ - insert:
76
+ - id: dsh-rolegroup
77
+ name: 'dsh-rolegroup'
78
+ YAML
79
+ ```
80
+
81
+ The home layer survives profile rewrites, but it does not show up under "Installed" and has no toggle. Pick
82
+ one; do not use both.
83
+
84
+ ### Verify
85
+
86
+ ```sh
87
+ dsh --profile web --dump-config | grep -A1 dsh-rolegroup # should show - id: dsh-rolegroup
88
+ ```
89
+
90
+ Restart `dsh web` and open a new session. The seven role tools should be in the tool list; you can also run
91
+ `/rolegroup doctor` from the new session.
92
+
93
+ After changing code or `rolegroup.jsonc`, restart and open a new session. For panel saves, see §5.
94
+
95
+ ## 3. Built-in roles
96
+
97
+ With no configuration, the plugin registers seven roles. The models below are initial values;
98
+ `rolegroup.jsonc` or the panel can override them. What is actually in use is what `/rolegroup doctor` prints.
99
+
100
+ | Role | Built-in model | Responsibility |
101
+ |---|---|---|
102
+ | `analyst` | `qwen-token-plan-cn/qwen3.8-max` | Requirement clarification, path classification, plan review (do it / how), architecture decisions |
103
+ | `planner` | `kimi-coding/k3` | Plan design: file layout, task breakdown, interface contracts, writing `plans.md` |
104
+ | `coder` | `kimi-coding/k3` | Implementation: TDD red-green-refactor following `plans.md` steps |
105
+ | `reviewer` | `qwen-token-plan-cn/qwen3.8-max` | Closing review: check acceptance criteria against evidence (was it actually done) |
106
+ | `scout` | `deepseek-official/deepseek-flash` | Exploration and bulk search (returns `file:line` evidence) |
107
+ | `scribe` | `qwen-token-plan-cn/qwen3.8-flash` | Documentation backfill, reports, spec maintenance |
108
+ | `fallback` | `deepseek-official/deepseek-flash` | Catch-all for unclassified lightweight tasks |
109
+
110
+ Each role is a delegation-tool instance plus an auto-generated Agent Preset. The preset copies your default
111
+ session mode, replaces the persona, and removes the delegation group. That is why Settings → Agent presets
112
+ shows seven "角色:xxx · model" entries. They are generated: do not delete or rename them, and do not pick one for a
113
+ main session.
114
+
115
+ ## 4. Configuration
116
+
117
+ ### Lookup order
118
+
119
+ The plugin looks for config in this order and stops at the first hit:
120
+
121
+ 1. `<launch cwd>/.dsh/rolegroup.jsonc` (project-level)
122
+ 2. `$DSH_HOME/rolegroup.jsonc` (user-level; defaults to `~/.dsh`)
123
+ 3. none → built-in table (§3)
124
+
125
+ ### Format
126
+
127
+ ```jsonc
128
+ // .dsh/rolegroup.jsonc; list only the roles you want to change
129
+ {
130
+ "roles": {
131
+ "analyst": {
132
+ "provider": "qwen-token-plan-cn", // optional; inherits the built-in provider
133
+ "model": "qwen3.8-flash",
134
+ "reasoningEffort": "medium", // optional; omit to use the model default
135
+ "persona": "file://./personas/analyst.md", // optional; file:// link (relative to this file) or inline
136
+ "summary": "Requirement clarification and plan review" // optional; one line
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
142
+ The role name is the JSON key. Each role can set `provider`, `model`, `reasoningEffort` (optional), `persona`
143
+ (optional), and `summary` (optional). `reasoningEffort` must be a level the model supports; leave it out to
144
+ use the model default (see §5).
145
+
146
+ ### Precedence
147
+
148
+ **Panel (settings layer) > project `rolegroup.jsonc` > user `rolegroup.jsonc` > built-in table.**
149
+
150
+ One layer is chosen as a whole; layers are not merged role by role. If a layer exists, the layers below it are
151
+ not read at all. The final table comes from the chosen layer, with the built-in table filling in missing
152
+ roles.
153
+
154
+ What this means in practice: saving in the panel takes over the whole table, and `rolegroup.jsonc` stops
155
+ participating. A role that exists only in jsonc, and was not moved into the panel, falls back to the built-in
156
+ table; it does not keep using jsonc. So:
157
+
158
+ - Use jsonc or the panel, not both.
159
+ - Before takeover, the panel pre-fills the active table. Saving takes over the whole layer; you do not need to
160
+ copy jsonc rows into the panel by hand.
161
+ - To go back to jsonc, click "Reset to file config" in the panel (it clears `enabled` and `roles`).
162
+
163
+ To see which layer is active, read the "config source" line from `/rolegroup doctor`.
164
+
165
+ ### Runtime
166
+
167
+ - At startup, routes are checked. An unregistered provider means the role is not registered, and the log says
168
+ what to fix. A model that is not in the available list only produces a warning; the role is still
169
+ registered, and delegation checks it again.
170
+ - `maxDepth` is 1: the main session can delegate, role subagents cannot. Setting it to 0 also blocks
171
+ top-level delegation.
172
+ - Changes to `rolegroup.jsonc` are not hot-applied; restart and open a new session. Panel saves apply to new
173
+ sessions (see §5).
174
+ - Delegation returns a subagent id immediately. You get a completion notice when the task finishes; no
175
+ polling.
176
+
177
+ `readonly` is deprecated. If an old config still has it, you get a migration notice, but it does nothing. For
178
+ read-only, use a session-level permission preset (`read-only` / `workspace-write` / `danger-full-access`,
179
+ inherited by delegations); express a role's read-only lean in its persona.
180
+
181
+ ## 5. Settings panel
182
+
183
+ Settings → 角色配置 edits roles and model bindings: add or remove roles, change provider/model,
184
+ persona/summary, and reasoning effort. Save, Discard, and Reset to file config are at the bottom.
185
+
186
+ The panel does not take over by itself. Before takeover it reads the active table (jsonc or built-in) and
187
+ pre-fills the editor. Save becomes available after you change something; saving writes `enabled=true` and the
188
+ whole table, and the panel takes over. If the read fails, the panel falls back to an empty table with manual
189
+ add, an inline error, and a retry. Reset to file config clears both fields and exits takeover.
190
+
191
+ The header shows the plugin name and version, plus a GitHub link. The Config file button opens the active
192
+ `rolegroup.jsonc` in the right sidebar's document preview. It closes Settings first so the sidebar is visible.
193
+ If there is no config file, it shows a one-line notice in the page instead of a popup. The endpoint is local
194
+ only; host-side code changes need a `dsh web` restart.
195
+
196
+ Reasoning effort can be left empty, which means the model's default (Kimi K3, for example, defaults to
197
+ `high`). A higher level is usually slower and more expensive, but it reasons more thoroughly. The dropdown options come from
198
+ the model catalog and only include levels the model supports. An unsupported value is marked red and blocks
199
+ saving; switching models clears an old level the new model does not support.
200
+
201
+ Panel saves apply to new sessions; in-flight sessions are not affected. `rolegroup.jsonc` still needs a
202
+ restart and a new session.
203
+
204
+ You cannot disable the plugin by emptying the panel. `mergeRoles` always seeds the built-in table, so an empty
205
+ override table means "back to the seven built-in roles." To disable it, uninstall the plugin or remove its
206
+ install entry.
207
+
208
+ ## 6. Diagnostics
209
+
210
+ `/rolegroup doctor` reads the `$DSH_HOME/plugins/dsh-rolegroup/last-startup.json` snapshot and compares it
211
+ with the live llm service. It lists each role's name, bound model, provider, and whether the model is
212
+ available, with repair hints when something is wrong.
213
+
214
+ - `/rolegroup doctor`: diagnose.
215
+ - Bare `/rolegroup` or an unknown subcommand: print usage.
216
+
217
+ Note: pasting text starting with `/` into the GUI composer sends it as a normal message, not a command. Type
218
+ it by hand or pick it from the completion list.
219
+
220
+ Example:
221
+
222
+ > If a role's provider is not registered, an error block is appended below the table and the provider is
223
+ > marked ❌. The role is not registered. This matters most for a fallback role: a skipped fallback route does
224
+ > not exist. The built-in fallback is bound to `deepseek-official` because that provider is always
225
+ > registered:
226
+
227
+ ```
228
+ ❌ fallback:provider "example-provider" 当前未注册(在用:deepseek-official, kimi-coding, qwen-token-plan-cn)
229
+ 修复:① 检查该适配器的 key/额度;② 或在 rolegroup.jsonc 把 fallback 改用已注册 provider。
230
+ ```
231
+
232
+ ```
233
+ dsh-rolegroup doctor — 7 个在册角色
234
+ 快照时间 2026-10-25T12:00:00.000Z(0 天前)|配置来源 (内置默认表)
235
+
236
+ 角色 绑定模型 provider 模型
237
+ analyst qwen-token-plan-cn/qwen3.8-max ✅ ✅
238
+ planner kimi-coding/k3 ✅ ✅
239
+ coder kimi-coding/k3 ✅ ✅
240
+ reviewer qwen-token-plan-cn/qwen3.8-max ✅ ✅
241
+ scout deepseek-official/deepseek-flash ✅ ✅
242
+ scribe qwen-token-plan-cn/qwen3.8-flash ✅ ✅
243
+ fallback deepseek-official/deepseek-flash ✅ ✅
244
+
245
+ ✅ 无异常
246
+ ```
247
+
248
+ Also: a snapshot older than seven days, or one that looks hand-edited, gets a ⚠️, but the table is still
249
+ printed. A jsonc config untouched for 14 days gets a review notice; panel-written settings have no timestamp,
250
+ so no notice there. If the llm service is unavailable, the availability column reads ➖. A role whose preset
251
+ fails to activate goes into `invalid[]` and is not registered.
252
+
253
+ ## 7. Development
254
+
255
+ ```sh
256
+ npm run link:deps # first after cloning: create the schemastery symlink
257
+ npm install # then install the esbuild devDependency
258
+ npm test # offline smoke suite, 133 cases; pretest runs link:deps
259
+ npm run build:client # after editing src/client/** or lib/roles.js
260
+ ```
261
+
262
+ Run `link:deps` before `npm install`: npm installs the `@deepseek-ai/schemastery` peer as a real copy, which
263
+ blocks the symlink. If you already ran `npm install`, delete `node_modules/@deepseek-ai/schemastery` and rerun
264
+ `link:deps`. Without `npm install`, `npm test` fails with `ERR_MODULE_NOT_FOUND: esbuild`. Without
265
+ `link:deps`, dsh prints
266
+ `无法使用部署树的 @deepseek-ai/schemastery …` at startup and the plugin runs host-only: role tools still
267
+ work, but the Settings section is missing.
268
+
269
+ What `link:deps` does: the plugin is installed as a `link:`, so by Node's realpath rule it cannot import
270
+ `@deepseek-ai/*` directly. Settings also requires the entry to export a schemastery `Config` statically,
271
+ which cannot be resolved lazily. The script symlinks the deployment's schemastery into this repo; the symlink
272
+ is not committed.
273
+
274
+ Layout:
275
+
276
+ | Path | Contents |
277
+ |---|---|
278
+ | `lib/` | Host side: `index.js` (composition/recomposition), `roles.js` (role table and merge), `config.js` (settings `Config`), `config-info.js` (config snapshot + read-only route), `doctor.js`, `command.js` |
279
+ | `src/client/` | Client sources (`controller.js` / `card.jsx` / `locales.js` / `meta.js` / `config-file.js`); `lib/client.js` is the esbuild artifact and must be rebuilt after edits |
280
+ | `tests/` | Offline smoke suite (plain Node, no browser) |
281
+ | `scripts/` | `build-client.mjs` (esbuild bundle; injects the `package.json` version) and `link-deployment-deps.mjs` (environment symlink) |
282
+
283
+ ## 8. Compatibility
284
+
285
+ Verified on dsh 0.2.1-rc.3; dsh ≥ 0.2.1-rc.1 is required. On 0.2.0 the plugin still loads, and the panel and
286
+ doctor work, but roles are not registered and the startup log asks for an upgrade. The panel uses the
287
+ Config-schema settings interface from dsh 0.1.7: an entry with a static `Config` and `.volatile()`, plus
288
+ `configForms` and `settings.section` on the client.
289
+
290
+ The panel lives in Settings, so the plugin does not show up under the Plugins page's "Official" group. With
291
+ the official plugin manager or the Plugin Market it appears under "Installed", with an enable/disable toggle.
292
+
293
+ ## 9. FAQ
294
+
295
+ **Why do seven "角色:xxx · model" entries appear under Settings → Agent presets?**
296
+ They are generated by this plugin (one per role: copy of the default mode composition, persona replaced,
297
+ delegation group removed). Do not delete or rename them, and do not pick one for a main session. A deleted
298
+ preset makes the role fail the health audit on the next start or reload; selecting a role preset for a main
299
+ session gives you a session without the standard tools. Edit role config through the panel or
300
+ `rolegroup.jsonc`.
301
+
302
+ **Why doesn't a subagent/sub-session show its model?**
303
+ The subagent UI has no dedicated model chip. Rolegroup puts the model into two existing fields: the Agent
304
+ Preset name (the header role label reads e.g. `角色:scout · deepseek-flash`) and the delegation `description`
305
+ (the task title, e.g. `Login validation · kimi-coding/k3`). A dedicated model chip requires upstream subagent UI
306
+ support.
307
+
308
+ **I switched the session mode (PTC / minimal / creative). Why does the role tool surface stay the same?**
309
+ Role sub-sessions are based on your default mode, not on the per-session mode. If you only use the standard
310
+ mode, there is no difference.
311
+
312
+ **Installed, but no role tools appeared?**
313
+ ① Check that `--dump-config` shows `- id: dsh-rolegroup`; ② restart `dsh web` and open a new session
314
+ (neither code nor config is hot-applied); ③ run `/rolegroup doctor` to see whether a role was skipped because
315
+ its provider is not registered.
316
+
317
+ **The panel says "not taken over yet" or the read failed?**
318
+ While not taken over, the panel pre-fills the effective table; it degrades to an empty table only when the
319
+ read fails, with an inline error and a retry button. Save is only available after an edit.
320
+
321
+ **I edited `rolegroup.jsonc` and nothing changed?**
322
+ First check whether the panel has taken over (§4: with `enabled=true`, jsonc yields entirely, so a reload
323
+ changes nothing). If it has, click "Reset to file config" in the panel. If it has not, config is simply not
324
+ hot-applied: restart and open a new session.
325
+
326
+ **`/rolegroup` does nothing?**
327
+ Pasting text starting with `/` into the GUI composer sends it as an ordinary message. Type it by hand or pick
328
+ it from the completion list.
329
+
330
+ **The panel disappeared but the role tools still work?**
331
+ For a source install, it is usually the missing schemastery symlink; run `npm run link:deps` (see §7). For a
332
+ package or market install, the `@deepseek-ai/schemastery` peer dependency probably did not install; reinstall
333
+ the plugin or check the profile dependencies.
334
+
335
+ **How do I disable the plugin entirely?**
336
+ Disable or uninstall it in the Plugins page or Plugin Market, or remove it from the profile dependencies.
337
+ Mounted on the home layer from source: remove its insert row from `~/.dsh/cordis.patch.yml`.
338
+ ⚠️ An empty override table in the panel does not disable it; `mergeRoles` always seeds the built-in table.
339
+
340
+ ## 10. Credits
341
+
342
+ The role (category) to model binding, the JSONC config format, and the rule that role subagents cannot
343
+ delegate again are inspired by [oh-my-openagent](https://github.com/code-yeongyu/oh-my-openagent) ("omo"). The
344
+ model pairings are not copied from omo; this plugin's bindings are decided by its own configuration and
345
+ evaluation.
346
+
347
+ ## 11. License
348
+
349
+ MIT