dsh-submodel 0.1.0 → 0.3.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/README.en.md ADDED
@@ -0,0 +1,304 @@
1
+ # dsh-submodel
2
+
3
+ **The default policy pack for the official subagent.** Install once and "who does what, when to delegate, and to whom" is configured for you.
4
+
5
+ ![dsh-submodel: the main model routes work to an executor route or expert routes](https://raw.githubusercontent.com/angel291592/dsh-submodel/main/assets/hero.svg)
6
+
7
+ [![npm version](https://img.shields.io/npm/v/dsh-submodel.svg)](https://www.npmjs.com/package/dsh-submodel)
8
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-submodel.svg)](https://www.npmjs.com/package/dsh-submodel)
9
+ [![license](https://img.shields.io/npm/l/dsh-submodel.svg)](https://github.com/angel291592/dsh-submodel/blob/main/LICENSE)
10
+ [![DSH](https://img.shields.io/badge/DeepSeek%20Harness-%E2%89%A50.2.2-4d6bfe.svg)](https://github.com/angel291592/dsh-submodel)
11
+ [![dshbase](https://img.shields.io/badge/dshbase-install--tested-2ea44f.svg)](https://github.com/ylwl1997/dshbase/issues/221)
12
+
13
+ [中文](README.md) | **English**
14
+
15
+ It does **not** ship its own provider system — it reads the channels and models already configured in your
16
+ profile, writes a delegation policy into the system prompt, and adds one unified entry point
17
+ (`delegate_task`) on top of the official `subagent`. Since 0.2.0 the mode is decided by **route** (no model
18
+ naming convention required), and there is a first-run setup wizard plus `economyRoutes`. Since 0.3.0 you can
19
+ optionally enable the **team formation self-check**: with Agent Teams enabled, the top-level main model declares
20
+ whether to parallelise, how many teammates to start, and which model each one uses before the first real task
21
+ (off by default). Requires DSH `0.2.2-rc.1` (`0.2.1` and older are not compatible).
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ dsh plugin --profile <your-profile> add dsh-submodel # 1. install
27
+ dsh --profile <your-profile> # 2. start (restart the profile after adding)
28
+ # 3. on the first session, follow "Configuration (two steps)" below; or call configure_submodel
29
+ ```
30
+
31
+ ## Configuration (two steps)
32
+
33
+ Configuration has **two layers**, and delegation only works when both are done:
34
+
35
+ | Layer | What it controls | If missing |
36
+ |---|---|---|
37
+ | ① Host authorization | DSH's own "subagent model selection" setting: which routes a subagent may switch to | Delegating to a non-inherited route fails with `child LLM route "…/…" is not allowed for this Session` |
38
+ | ② Plugin config | This package's `executor` (execution route) and `experts` (expert routes) | In boss mode there is no default delegation target: an `error` is logged and nothing is delegated |
39
+
40
+ ### ① Host authorization (required)
41
+
42
+ By default the native `subagent` only lets a child inherit the parent session's route. To let a child switch
43
+ to an execution/expert route, authorize it in the host first:
44
+
45
+ - **GUI**: open **subagent model selection** in Settings (config id `subagent-model-selection-settings`),
46
+ turn it on, and add the execution route and expert routes to the allow-list one by one.
47
+ - **Or write the profile patch YAML** (`~/.dsh/profiles/<your-profile>/cordis.patch.yml`; the file is an empty
48
+ array `[]` by default — append the entry to that array):
49
+
50
+ ```yaml
51
+ - id: subagent-model-selection-settings
52
+ config:
53
+ enabled: true
54
+ allowedModels:
55
+ - provider: your-provider
56
+ model: your-model
57
+ - provider: your-provider
58
+ model: your-strong-model
59
+ ```
60
+
61
+ Note: `allowedModels` must not be empty when `enabled: true`; host authorization only applies to **new
62
+ sessions**, so open a new session (or restart the profile) after writing it.
63
+
64
+ ### ② Plugin configuration (pick one)
65
+
66
+ **Option A (recommended): call `configure_submodel` on the first session — it writes both places**
67
+
68
+ No YAML by hand. As long as you are the top-level agent, `autoConfigure` keeps its default `true`, and
69
+ `executor` is not configured yet, the `configure_submodel` tool appears on the first session:
70
+
71
+ 1. Call it. It asks three questions — **execution route** (where verifiable execution blocks go; single
72
+ choice), **expert routes** (models you may name when escalating; multi-choice), and **whether to write the
73
+ host authorization row too** (recommended: yes);
74
+ 2. On confirmation it uses the official `configEditor` to write **host authorization first, then plugin
75
+ config** (the plugin config's `executor`, `experts` and `economyRoutes` all reflect your choices), so both
76
+ take effect together;
77
+ 3. It takes effect on the next session. Writing the plugin config reloads this plugin and the tool
78
+ disappears afterwards — that is expected, not an error.
79
+
80
+ On clients without a GUI (headless / plain CLI) or when a required service is missing, no question card is
81
+ shown: the tool returns copyable manual YAML instead and **writes nothing**.
82
+
83
+ **Option B: five-line YAML by hand**
84
+
85
+ In your profile patch layer (`~/.dsh/profiles/<your-profile>/cordis.patch.yml`), override this package by id.
86
+ The file is an empty array `[]` by default: **replace `[]` with the entry below**; if it already has entries,
87
+ append this one to the array.
88
+
89
+ ```yaml
90
+ - id: submodel
91
+ config:
92
+ executor:
93
+ provider: your-provider
94
+ model: your-model
95
+ ```
96
+
97
+ Note: a profile patch **replaces the whole `config` block** of an entry — fields you leave out fall back to
98
+ their defaults (see the table below); they are not merged field by field with the built-in defaults.
99
+
100
+ Full field reference:
101
+
102
+ | Field | Default | Description |
103
+ |---|---|---|
104
+ | `enabled` | `true` | Master switch; when `false`, only an empty prompt section is registered and no tools/guards are installed |
105
+ | `autoConfigure` | `true` | Whether to register the `configure_submodel` wizard for first-run setup (visible only for a top-level agent whose `executor` is not configured); turn it off to configure everything manually |
106
+ | `preset` | `standard` | Only applies to that composition |
107
+ | `teamFit.enabled` | `false` | Team formation self-check section (0.3.0+): needs the master `enabled` switch to be `true` as well, plus the official Agent Teams plugin; visible only to the top-level main model of the target preset — see below. Off by default, which is the rollback state |
108
+ | `executor.provider` / `executor.model` | empty | Execution route: the default delegation target in boss mode; **leaving it empty logs an `error`** (see Troubleshooting). Switching the main model to this route also means Flash mode |
109
+ | `executor.reasoningEffort` | `max` | Default effort only when the caller did not specify one |
110
+ | `economyRoutes` | `[]` | Extra "cheap routes", each `{provider?, model}`: the current request matching any of them counts as Flash (`economize`) mode. Omit `provider` to match on `model` alone; **when non-empty, the legacy flash-suffix rule no longer applies** |
111
+ | `experts` | `[]` | Expert routes you may name explicitly when escalating, each `{label, provider, model, reasoningEffort?}`; `reasoningEffort` is reserved for now and does not affect delegation |
112
+ | `texts.economize` / `texts.boss` / `texts.child` | empty | When non-empty, replaces the built-in prompt section verbatim (no interpolation afterwards) |
113
+ | `toolName` | `list_subagent_models` | Tool name used as the capability gate for the policy section |
114
+ | `order` | `2850` | Order of the policy section in the system prompt |
115
+ | `guardNativeSubagent` | `true` | Whether to reject a non-economy-route (non-Flash mode) top-level agent that calls the native `subagent` without a complete provider/model pair |
116
+
117
+ ## How it decides who does what (route-based since 0.2.0)
118
+
119
+ There are two modes, and the decision looks only at the **route of the current request** (`provider` +
120
+ `model`) — no model-name suffix is required:
121
+
122
+ 1. Current request route **== the configured `executor` route** → **Flash (`economize`) mode**;
123
+ 2. The request matches any route in **`economyRoutes`** → **Flash (`economize`) mode** (for multiple cheap routes);
124
+ 3. When `economyRoutes` is empty, the legacy rule still applies: a model name ending in `flash` → **Flash
125
+ (`economize`) mode**;
126
+ 4. Everything else → **boss mode**.
127
+
128
+ Built-in behaviour:
129
+
130
+ - **Flash mode**: do the work yourself by default; ordinary subtasks go through `delegate_task` (no
131
+ provider/model — the child inherits the current route); escalate only when "the problem itself is complex"
132
+ or "it exceeds your execution limits", naming a route from `experts`.
133
+ - **Boss mode**: understanding, judgement and writing stay with the main model; verifiable execution blocks
134
+ default to the configured `executor` route.
135
+ - **Children**: hard boundary — `delegate_task` / `subagent` / `subagent_fork` / `workflow` / `spawn_teammate`
136
+ are unavailable to a child, preventing recursive delegation.
137
+ - **`delegate_task`**: same parameters as the native `subagent` (`description`, `prompt`, and optional
138
+ `provider` / `model` / `reasoning_effort`; `provider` and `model` must be supplied **together** — one alone
139
+ fails immediately). It goes through `ctx.tools.execute` and raises a real native call, so the host's
140
+ allowlist / preflight / permissions still apply. Since 0.2.0 the semantics are "starts an independently
141
+ managed subagent and **immediately returns its id**; the runtime notifies you when it finishes": do not poll
142
+ repeatedly — use `list_agents` to look at live subagents, `send_message` to append, and `interrupt_agent` to
143
+ stop. Call `list_subagent_models` first if you are unsure which routes are authorized.
144
+
145
+ Two typical calls:
146
+
147
+ ```json
148
+ // 1) Boss → execution route: omit provider/model and the configured executor is filled in
149
+ { "description": "run the tests", "prompt": "<complete task: goal, constraints, what has been tried>" }
150
+ ```
151
+
152
+ ```json
153
+ // 2) Escalate → expert route: provider/model together, and the route must be in the host allow-list
154
+ { "description": "review the state machine", "prompt": "<complete task>", "provider": "your-provider", "model": "your-model" }
155
+ ```
156
+
157
+ ## Team formation self-check (optional, 0.3.0+)
158
+
159
+ This is an extra prompt section for users who have **Agent Teams enabled**; it is off by default. When
160
+ enabled, the top-level main model first decides "can this be parallelised, how many teammates, which model
161
+ for each" before every real task and reports the conclusion in three fixed leading lines:
162
+
163
+ ```
164
+ 可并行性:
165
+ 串行点:
166
+ 决定:
167
+ ```
168
+
169
+ - Greetings do not trigger it; follow-up questions, progress queries and retries reuse the earlier decision,
170
+ and it re-evaluates only when the task scope or the set of editable files changes.
171
+ - **Serial**: the third line is exactly "决定:本次串行,不用任务板" — zero task-board entries and zero
172
+ teammates, and the main model does the work itself.
173
+ - **Parallel**: the third line is "决定:并行 N 个队友", followed on the same line by each block's work,
174
+ owner, write scope (read-only also stated), concrete model, acceptance method and dependencies; only 2–4
175
+ mutually non-conflicting, independently verifiable blocks qualify.
176
+ - In parallel mode the task board records each block's `write_scopes` and `blocked_by`; shared files,
177
+ integration, commits and final verification stay with the main model.
178
+ - Model assignment reuses this package's routing (see the previous section): execution blocks go through
179
+ `delegate_task`; independent reviews use a fresh context; escalation still follows "problem complexity /
180
+ execution bottleneck" and never a review or risk label alone.
181
+
182
+ Requirements: (1) the official Agent Teams plugin is enabled; (2) this package's `enabled: true` (default);
183
+ (3) `teamFit.enabled: true` (default `false`). It only applies to the **top-level main model** of the target
184
+ `preset` (default `standard`); subagents and other compositions do not show it, while a normal user fork
185
+ (which merely carries `parentSession`) still counts as the main model.
186
+
187
+ ```yaml
188
+ # Append this one field; a profile patch replaces the whole config block,
189
+ # so keep any existing fields in the same block.
190
+ - id: submodel
191
+ config:
192
+ teamFit:
193
+ enabled: true
194
+ ```
195
+
196
+ > The snippet only shows the new field. If your config already has `executor` / `experts`, keep them in the
197
+ > same `config` block — a profile patch **replaces the whole block** and does not merge field by field.
198
+
199
+ **Rollback**: set `teamFit.enabled` to `false` and restart the profile — no plugin removal needed; the master
200
+ `enabled: false` also works. When Agent Teams is off or a service query fails, the section hides itself and
201
+ does not affect other prompt sections.
202
+
203
+ ## Relationship to the official plugins
204
+
205
+ | Capability | Provided by |
206
+ |---|---|
207
+ | Status view `list_agents`, append `send_message`, stop `interrupt_agent` | Official `@deepseek-ai/dsh-tool-subagent-control` (this package does **not** register them) |
208
+ | Policy text, `delegate_task`, child guard, `configure_submodel` wizard | This package |
209
+ | Model selection itself (`provider` / `model` parameters of `subagent`) | Official subagent (this package only consumes it) |
210
+
211
+ ## Compatibility
212
+
213
+ | DSH version | Status |
214
+ |---|---|
215
+ | `0.2.2-rc.1` | ✅ Target version: fixture + isolated-profile **real-host load verified**; GUI end-to-end is for the user to accept (**not verified**) |
216
+ | `0.2.1-rc.5` and older | ❌ Incompatible: no batch `ctx.tools.execute`, and no 0.2.2 child-route semantics |
217
+ | Other `0.2.x` versions | Not tested per version; `engines.dsh` declares `>=0.2.2-rc.1 <0.3.0`, so out-of-range versions are rejected by the installer |
218
+
219
+ ## Troubleshooting
220
+
221
+ Fail-fast: startup warnings are logged only and never thrown; errors only surface when you call a tool.
222
+
223
+ | Symptom | Level | Meaning and fix |
224
+ |---|---|---|
225
+ | `config.executor.provider/model 未配置,自动委派不可用…` | `error` | No default delegation target: call `configure_submodel` or add `executor` manually as in "Configuration (two steps)" |
226
+ | `child LLM route "…/…" is not allowed for this Session` | error on delegation | **Host authorization missing** (or this route is not in the allow-list): open "subagent model selection", add the route (takes effect on new sessions), or re-run `configure_submodel` and accept the host-authorization write |
227
+ | `configure_submodel` is not visible | — | ① `executor` is already configured (the wizard intentionally appears only once); ② `autoConfigure` is `false`; ③ the native `subagent` in this session exposes no model-selection parameters (check that model selection is enabled in the profile/preset); ④ you are not the top-level agent |
228
+ | `configure_submodel` returns no question card | — | The client has no GUI (headless / plain CLI), so there is nobody to ask; the tool returns manual YAML and writes nothing — use Option B above |
229
+ | `当前 profile 无 agentPresets 服务,策略不生效` | `warn` | This profile has no agentPresets service; use a profile that supports compositions |
230
+ | `原生 subagent 未暴露 provider/model,delegate_task 不安装` | `warn` | The native `subagent` in this session exposes no model-selection parameters: the whole install (policy section / guard / tools) is skipped and retried automatically once the capability appears |
231
+ | `本会话未启用官方 subagent 模型选择,策略段不渲染` | `info` | Enable `subagent-model-selection-settings` in Settings (host authorization applies to new sessions only); tools are still installed subject to their own gate |
232
+
233
+ ## Known limitations
234
+
235
+ - The policy text is Chinese by default; override it with `texts.*` (tool descriptions and some guard
236
+ rejections stay in English).
237
+ - Applies only to the composition named by `preset` (default `standard`).
238
+ - No budget guard / nudging / failure re-routing (watchdog).
239
+ - `configure_submodel` writes exactly two places — this package's config row and the host authorization row
240
+ (`subagent-model-selection-settings`); it does not create channels or credentials and does not touch other
241
+ plugins.
242
+ - Model metadata has no price field, so which routes count as "cheap" is up to your configuration (the wizard
243
+ only pre-fills candidates; it does not decide for you).
244
+ - Non-GUI clients have no question card, so use Option B (manual YAML).
245
+ - The team formation self-check is a **prompt-level constraint**: whether to parallelise and how many teammates to start is still the main model's decision, not enforced; it does not enable Agent Teams for you.
246
+
247
+ ## Rollback
248
+
249
+ ```bash
250
+ dsh plugin --profile <your-profile> remove dsh-submodel
251
+ ```
252
+
253
+ Removing the plugin leaves the host authorization row in the profile patch; to revert that too, delete the
254
+ `subagent-model-selection-settings` entry manually.
255
+
256
+ To turn off only the team formation self-check while keeping everything else, set `teamFit.enabled` to `false`
257
+ and restart the profile (no plugin removal needed).
258
+
259
+ ## Development and verification
260
+
261
+ ```bash
262
+ npm install # development dependency (schemastery)
263
+ node tests/unit/flash-routing-fixture.mjs ./lib # pure functions + lifecycle regression
264
+ python -m unittest discover -s tests/unit # Python driver (run from the package root)
265
+ node tests/unit/public-profile-smoke.mjs # deterministic smoke test with a clean user config
266
+ ```
267
+
268
+ Current verification counts (CI runs the same commands on every push / PR, see `.github/workflows/ci.yml`):
269
+
270
+ <!-- verification counts: fixture / Python / smoke numbers live only in this table; update here if measurements differ. -->
271
+
272
+ | Check | Result |
273
+ |---|---|
274
+ | fixture | **126** assertions, `failed: 0` |
275
+ | Python driver | **7** test cases, `OK` |
276
+ | Public-profile smoke | **8** assertions, `failed: 0` |
277
+
278
+ GUI end-to-end (the `configure_submodel` card and both writes, `delegate_task` delegation, and switching the
279
+ main model to the execution route to enter economize mode) must be accepted by the user in a restarted real
280
+ GUI session and is **not verified yet**. For the team formation self-check, the deterministic parts (the three
281
+ leading lines, identity/preset/team-state gating, off-by-default rollback) are covered by the fixture; the
282
+ actual first-turn reply and teammate count in a real GUI conversation still need acceptance in a new session.
283
+
284
+ ## Contributing
285
+
286
+ - Read [CONTRIBUTING.en.md](CONTRIBUTING.en.md) ([简体中文](CONTRIBUTING.md)) before opening an issue or a
287
+ pull request: it lists the three test suites, the commit format, and what must not end up in the repo.
288
+ - Security problems go through the private channel in [SECURITY.en.md](SECURITY.en.md), not a public issue.
289
+ - By participating you agree to the [Code of Conduct](CODE_OF_CONDUCT.en.md).
290
+
291
+ ## Releasing (maintainers)
292
+
293
+ Releases go through GitHub Actions + npm **Trusted Publishing (OIDC)**; no npm token is stored on this
294
+ machine or in the repository:
295
+
296
+ 1. Add a `## <version> (YYYY-MM-DD)` section at the top of `CHANGELOG.md`;
297
+ 2. On `main`, run `pwsh scripts/release.ps1 <version>`: it runs the gates, bumps the `package.json`
298
+ version, commits, tags and pushes, then polls npm until the new version appears;
299
+ 3. The repository's `release` workflow (`.github/workflows/release.yml`) re-runs the tests after the tag
300
+ push and publishes with `npm publish`; the script tries to create the GitHub Release once npm confirms.
301
+
302
+ One-time setup: configure a Trusted Publisher in the npm package settings (repository
303
+ `angel291592/dsh-submodel`, workflow `release.yml`, allow Direct publish). After that, releasing needs no
304
+ npm password, one-time code, or token.
package/README.md CHANGED
@@ -1,27 +1,89 @@
1
1
  # dsh-submodel
2
2
 
3
- > **官方 subagent 的默认策略包**:装上一次配好「什么时候自己干、什么时候派出去、派给谁」。
3
+ **官方 subagent 的默认策略包**:装上一次配好「什么时候自己干、什么时候派出去、派给谁」。
4
+
5
+ ![dsh-submodel:主脑按意图把任务路由到执行路由或专家路由](https://raw.githubusercontent.com/angel291592/dsh-submodel/main/assets/hero.svg)
6
+
7
+ [![npm version](https://img.shields.io/npm/v/dsh-submodel.svg)](https://www.npmjs.com/package/dsh-submodel)
8
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-submodel.svg)](https://www.npmjs.com/package/dsh-submodel)
9
+ [![license](https://img.shields.io/npm/l/dsh-submodel.svg)](https://github.com/angel291592/dsh-submodel/blob/main/LICENSE)
10
+ [![DSH](https://img.shields.io/badge/DeepSeek%20Harness-%E2%89%A50.2.2-4d6bfe.svg)](https://github.com/angel291592/dsh-submodel)
11
+ [![dshbase](https://img.shields.io/badge/dshbase-install--tested-2ea44f.svg)](https://github.com/ylwl1997/dshbase/issues/221)
12
+
13
+ **中文** | [English](README.en.md)
4
14
 
5
15
  它**不新建 provider 体系**——只读你 profile 里已有的渠道与模型配置,把委派策略写进系统提示词,
6
- 并给官方 `subagent` 补一个统一的委派入口 `delegate_task`。本机实测于 DeepSeek Harness `0.2.1-rc.5`。
16
+ 并给官方 `subagent` 补一个统一的委派入口 `delegate_task`。0.2.0 起模式按**路由**判定(不再依赖
17
+ 模型命名约定),并提供首次配置向导与 `economyRoutes`;0.3.0 起可**可选**开启「团队队形自检」:
18
+ 同时启用官方 Agent Teams 后,顶层主代理在首轮实际任务前先声明是否并行、开几个队友、每个用什么模型
19
+ (默认关闭)。要求 DSH `0.2.2-rc.1`(`0.2.1` 及更早不兼容)。
7
20
 
8
21
  ## 安装
9
22
 
10
23
  ```bash
11
- dsh plugin --profile <你的 profile> add dsh-submodel
24
+ dsh plugin --profile <你的 profile> add dsh-submodel # 1. 安装
25
+ dsh --profile <你的 profile> # 2. 启动(装完插件需重启 profile)
26
+ # 3. 首次会话按下面「两步配置」完成授权与路由;或直接调用 configure_submodel
27
+ ```
28
+
29
+ ## 配置(两步)
30
+
31
+ 配置分**两层**,缺一层都派不出去:
32
+
33
+ | 层 | 管什么 | 缺失的后果 |
34
+ |---|---|---|
35
+ | ① 宿主授权 | DSH 自己的「子代理模型选择」设置:允许子代理切到哪些路由 | 子代理要切到非继承路由时,派工报 `child LLM route "…/…" is not allowed for this Session` |
36
+ | ② 插件配置 | 本包的 `executor`(执行路由)与 `experts`(专家路由) | 强主脑模式下没有默认派工目标,只记 error 日志、不派工 |
37
+
38
+ ### ① 宿主授权(必须)
39
+
40
+ DSH 原生 `subagent` 默认只允许子代理沿用父会话的路由;要让子代理切到执行/专家路由,先做宿主授权:
41
+
42
+ - **GUI**:打开「设置」里的 **子代理模型选择**(配置项 id 为 `subagent-model-selection-settings`),
43
+ 打开开关,并把执行路由、专家路由**逐条**加入允许列表。
44
+ - **或手写 profile 补丁 YAML**(`~/.dsh/profiles/<你的 profile>/cordis.patch.yml`;该文件默认是空数组
45
+ `[]`,把下面的条目追加进数组即可):
46
+
47
+ ```yaml
48
+ - id: subagent-model-selection-settings
49
+ config:
50
+ enabled: true
51
+ allowedModels:
52
+ - provider: your-provider
53
+ model: your-model
54
+ - provider: your-provider
55
+ model: your-strong-model
12
56
  ```
13
57
 
14
- ## 配置(5 行)
58
+ 注意:`enabled: true` 时 `allowedModels` 不能为空;宿主授权**只对新会话生效**,写完要新开会话(或重启 profile)。
15
59
 
16
- 在你的 profile 补丁层(`~/.dsh/profiles/<你的 profile>/cordis.patch.yml`)里按 id 覆盖配置。
60
+ ### ② 插件配置(二选一)
61
+
62
+ **方式 A(推荐):首次会话调用 `configure_submodel` 自动写两处**
63
+
64
+ 不用手写 YAML。只要满足:顶层主代理 + `autoConfigure` 保持默认 `true` + `executor` 还没配置,
65
+ 首次会话里就会出现 `configure_submodel` 工具:
66
+
67
+ 1. 调用它,会依次问 3 个问题——**执行路由**(日常可验证的执行块派给谁,单选)、
68
+ **专家路由**(需要升级时允许点名的模型,可多选)、**是否同时写宿主授权表**(推荐「是」);
69
+ 2. 确认后它用官方 `configEditor` **先写宿主授权、再写插件配置**(插件配置里的 `executor`、`experts`
70
+ 与 `economyRoutes` 都按你的选择落盘),两处一起生效;
71
+ 3. 新会话生效。写入成功后本插件会重载、该工具随之消失——这是预期的,不是出错。
72
+
73
+ 没有 GUI 客户端(headless / 纯 CLI)或相关服务不可用时,它不会弹卡,而是直接返回可复制的手动
74
+ YAML,并且**不会写任何配置**。
75
+
76
+ **方式 B:手动写 5 行 YAML**
77
+
78
+ 在 profile 补丁层(`~/.dsh/profiles/<你的 profile>/cordis.patch.yml`)里按 id 覆盖配置。
17
79
  该文件默认是空数组 `[]`:**把 `[]` 替换成下面的条目**;已有其他条目时,把它追加到数组里。
18
80
 
19
81
  ```yaml
20
82
  - id: submodel
21
83
  config:
22
84
  executor:
23
- provider: <执行渠道>
24
- model: <执行模型>
85
+ provider: your-provider
86
+ model: your-model
25
87
  ```
26
88
 
27
89
  注意:profile 补丁对某一条目的 `config` 是**整段替换**——没写的字段回落到默认值(见下表),
@@ -32,55 +94,130 @@ dsh plugin --profile <你的 profile> add dsh-submodel
32
94
  | 字段 | 默认值 | 说明 |
33
95
  |---|---|---|
34
96
  | `enabled` | `true` | 总开关;`false` 时只注册一个空段,不装任何工具/guard |
97
+ | `autoConfigure` | `true` | 是否在首次配置时注册 `configure_submodel` 向导(顶层主代理且 `executor` 未配置才可见);关掉后完全手动配置 |
35
98
  | `preset` | `standard` | 只对这个 composition 生效 |
36
- | `executor.provider` / `executor.model` | 空 | 非 Flash 主脑的默认派工目标;**留空会记 error 日志**(见故障排查) |
99
+ | `teamFit.enabled` | `false` | 团队队形自检段开关(0.3.0+):需总开关 `enabled` 同时为 `true`、并启用官方 Agent Teams;只对目标 preset 的顶层主代理显示,详见下文。默认关闭 = 回滚态 |
100
+ | `executor.provider` / `executor.model` | 空 | 执行路由:强主脑的默认派工目标;**留空会记 error 日志**(见故障排查)。主模型切到这条路由本身也等于进入 Flash 模式 |
37
101
  | `executor.reasoningEffort` | `max` | 只在调用方没显式指定档位时作缺省 |
102
+ | `economyRoutes` | `[]` | 额外声明「便宜路由」,每项 `{provider?, model}`:本次请求命中任一项即算 Flash(economize)模式。`provider` 省略时只按 `model` 匹配;**非空时旧的 flash 后缀规则不再生效** |
38
103
  | `experts` | `[]` | 允许升级时显式点名的专家路由列表,每项 `{label, provider, model, reasoningEffort?}`;`reasoningEffort` 目前为预留字段,不影响派工 |
39
104
  | `texts.economize` / `texts.boss` / `texts.child` | 空 | 非空时整段替换内置正文(替换后不再插值) |
40
105
  | `toolName` | `list_subagent_models` | 策略段的能力门控工具名 |
41
106
  | `order` | `2850` | 策略段在系统提示词里的顺序 |
42
- | `guardNativeSubagent` | `true` | 是否拦截"非 Flash 顶层用原生 `subagent` 却不给完整 provider/model" |
107
+ | `guardNativeSubagent` | `true` | 是否拦截"非经济路由(非 Flash 模式)顶层用原生 `subagent` 却不给完整 provider/model" |
108
+
109
+ ## 它怎么判断该谁干(0.2.0 起按路由)
43
110
 
44
- ## 它做什么
111
+ 两种模式,判定只看**本次请求的路由**(`provider` + `model`),不再要求模型名带特定后缀:
45
112
 
46
- - **Flash 主脑**:默认自己干;普通子任务用 `delegate_task`(不传 provider/model,子代继承当前路由);
113
+ 1. 本次请求路由 **== 配置的 `executor` 路由** → **Flash(`economize`)模式**;
114
+ 2. 命中配置的 **`economyRoutes`** 任一条 → **Flash(`economize`)模式**(有多条便宜路由时用);
115
+ 3. `economyRoutes` 为空时保留旧版兼容:模型名以 `flash` 结尾 → **Flash(`economize`)模式**;
116
+ 4. 其余 → **强主脑(`boss`)模式**。
117
+
118
+ 内置正文与行为:
119
+
120
+ - **Flash 模式**:默认自己干;普通子任务用 `delegate_task`(不传 provider/model,子代继承当前路由);
47
121
  只有"问题本身够复杂"或"超出执行上限"时才升级,升级时从 `experts` 里点名。
48
- - **非 Flash 主脑**:理解/判断/写作自己来;可验证的执行块默认派给 `executor` 配置的执行路由。
122
+ - **强主脑模式**:理解/判断/写作自己来;可验证的执行块默认派给 `executor` 配置的执行路由。
49
123
  - **子代**:硬边界——`delegate_task` / `subagent` / `subagent_fork` / `workflow` / `spawn_teammate`
50
124
  一律不可用,防止递归派活。
51
- - **`delegate_task`**:参数与原生 `subagent` 相同;`provider` 与 `model` 必须成对传;经
52
- `ctx.tools.execute` 发起真正的原生调用,宿主的 allowlist / 预检 / 权限照旧生效。
125
+ - **`delegate_task`**:参数与原生 `subagent` 相同(`description`、`prompt`,以及可选的
126
+ `provider` / `model` / `reasoning_effort`;`provider` 与 `model` 必须**成对**传,只给一个会立即失败)。
127
+ 经 `ctx.tools.execute` 发起真正的原生调用,宿主的 allowlist / 预检 / 权限照旧生效。
128
+ 0.2.0 起语义为「启动后**立即返回子会话 id**,完成时由运行时通知」:不要反复轮询,需要查看在线
129
+ 子代理用 `list_agents`、追加消息用 `send_message`、停止用 `interrupt_agent`。
130
+ 不确定有哪些已授权路由时先调 `list_subagent_models`。
131
+
132
+ 两个典型用法:
133
+
134
+ ```json
135
+ // 1) 强主脑 → 执行路由:不传 provider/model,自动补 executor
136
+ { "description": "跑通测试", "prompt": "<完整任务说明:目标、约束、已试过的方案>" }
137
+ ```
138
+
139
+ ```json
140
+ // 2) 升级 → 专家路由:provider/model 成对,且必须已在宿主授权列表里
141
+ { "description": "复核状态机", "prompt": "<完整任务说明>", "provider": "your-provider", "model": "your-model" }
142
+ ```
143
+
144
+ ## 团队队形自检(可选,0.3.0+)
145
+
146
+ 这是给**启用了 Agent Teams 的用户**的附加提示词段,默认关闭。打开后,顶层主代理在每轮实际任务
147
+ 开始前先判断「能不能并行、开几个队友、每个用什么模型」,并把结论用下面三个行首连续报给你:
148
+
149
+ ```
150
+ 可并行性:
151
+ 串行点:
152
+ 决定:
153
+ ```
154
+
155
+ - **问候不触发**;普通追问、进度查询和重试沿用已经给出的决定,只有任务范围或可改动文件范围变化才重判。
156
+ - **串行**时第三行固定为「决定:本次串行,不用任务板」:任务板新增 0 项、启动队友 0 个,主代理自己做完。
157
+ - **并行**时写「决定:并行 N 个队友」,并在同一行写清每块工作、负责人、写域(只读也注明)、具体模型、
158
+ 验收方法和依赖;只有能拆成 2–4 个互不争写、可独立验收的块时才并行。
159
+ - 并行时任务板记录每块的 `write_scopes` 与 `blocked_by`;共享文件、集成、提交和最终验证由主代理独占。
160
+ - 模型分配沿用本包已有的模型路由(见上一节):普通执行块走 `delegate_task`;独立审查使用全新上下文;
161
+ 升级专家仍按「问题复杂度 / 执行瓶颈」判据,不因审查或风险标签直接跳档。
162
+
163
+ **前提与开关**:需要同时满足 ① 官方 Agent Teams 已启用;② 本包 `enabled: true`(默认);
164
+ ③ `teamFit.enabled: true`(默认 `false`)。只对目标 `preset`(默认 `standard`)的**顶层主代理**生效;
165
+ 子代理与其他 composition 不显示;普通用户 fork 出来的会话(只带 `parentSession`)仍按主脑处理。
166
+
167
+ ```yaml
168
+ # 只追加这一项;profile 补丁会整段替换 config,已有字段必须一起保留。
169
+ - id: submodel
170
+ config:
171
+ teamFit:
172
+ enabled: true
173
+ ```
174
+
175
+ > 上面只示范新增字段。若你已有 `executor` / `experts` 等配置,请在同一 `config` 块里一并保留——
176
+ > profile 补丁是**整段替换**,不会逐字段合并。
177
+
178
+ **回滚**:把 `teamFit.enabled` 设为 `false` 并重启 profile 即可完全关闭(不必卸载插件);
179
+ 总开关 `enabled: false` 同样有效。团队关闭或服务查询失败时,这段正文自动隐藏,不影响其他提示词。
53
180
 
54
181
  ## 与官方插件的边界
55
182
 
56
183
  | 能力 | 提供方 |
57
184
  |---|---|
58
185
  | 状态查看 `list_agents`、追加消息 `send_message`、停止 `interrupt_agent` | 官方 `@deepseek-ai/dsh-tool-subagent-control`(本包**不重复注册**) |
59
- | 策略正文、`delegate_task`、子代 guard | 本包 |
186
+ | 策略正文、`delegate_task`、子代 guard、`configure_submodel` 向导 | 本包 |
60
187
  | 模型选择能力本身(`subagent` 的 `provider`/`model` 参数) | 官方 subagent(本包只消费) |
61
188
 
62
189
  ## 兼容性
63
190
 
64
191
  | DSH 版本 | 状态 |
65
192
  |---|---|
66
- | `0.2.1-rc.5` | ✅ 实测通过(安装、`--dump-config`、启动均实测) |
67
- | 其他 rc / 正式版 | 未逐一实测(`engines.dsh` 声明 `>=0.2.1-rc.3 <0.3.0`,不作宽承诺) |
193
+ | `0.2.2-rc.1` | ✅ 目标版本:fixture + 隔离 profile **真机装载已验**;GUI 端到端由用户验收(**未验证**) |
194
+ | `0.2.1-rc.5` 及更早 | ❌ 不兼容:没有批量 `ctx.tools.execute`,也没有 0.2.2 的子代理路由语义 |
195
+ | 其他 `0.2.x` 版本 | 未逐版实测;`engines.dsh` 声明 `>=0.2.2-rc.1 <0.3.0`,范围外的版本会被安装器拦住 |
68
196
 
69
- ## 故障排查(fail-fast:只记日志,绝不抛)
197
+ ## 故障排查
70
198
 
71
- | 现象(日志) | 级别 | 含义与处理 |
199
+ fail-fast:启动期的告警只记日志、绝不抛;只有你主动调用工具时才可能收到错误。
200
+
201
+ | 现象 | 级别 | 含义与处理 |
72
202
  |---|---|---|
73
- | `config.executor.provider/model 未配置,自动委派不可用` | `error` | 非 Flash 主脑没有默认派工目标;按上面的 5 行配置补上 |
203
+ | `config.executor.provider/model 未配置,自动委派不可用…` | `error` | 没有默认派工目标:调用 `configure_submodel` 自动配置,或按上面「两步配置」手动补 `executor` |
204
+ | `child LLM route "…/…" is not allowed for this Session` | 派工时报错 | **宿主授权缺失**(或没包含这条路由):打开「子代理模型选择」并把该路由加入允许列表(新会话生效);或重新运行 `configure_submodel` 并勾选写宿主授权 |
205
+ | 看不到 `configure_submodel` | — | ① `executor` 已配置(向导按设计只出现一次);② `autoConfigure` 被设为 `false`;③ 当前会话的原生 `subagent` 没有选模参数(先确认 profile/preset 开启了模型选择);④ 当前不是顶层主代理 |
206
+ | 调用 `configure_submodel` 后没有弹提问卡 | — | 当前客户端没有 GUI(headless / 纯 CLI),没人可问;工具会返回手动 YAML 且不写配置,按「方式 B」手写即可 |
74
207
  | `当前 profile 无 agentPresets 服务,策略不生效` | `warn` | 该 profile 没有 agentPresets 服务;换一个支持 composition 的 profile |
75
- | `原生 subagent 未暴露 provider/model,delegate_task 不安装` | `warn` | 本会话的原生 `subagent` 没有选模参数:该 agent 上**整套安装**(策略段 / guard / `delegate_task`)都会跳过,等能力出现后由 `tools/change` 或 `agent/pre-step` 自动补装 |
76
- | `本会话未启用官方 subagent 模型选择,策略段不渲染` | `info` | 去设置里启用 `subagent-model-selection`;工具本身仍按注册门控安装 |
208
+ | `原生 subagent 未暴露 provider/model,delegate_task 不安装` | `warn` | 本会话的原生 `subagent` 没有选模参数:该 agent 上**整套安装**(策略段 / guard / 工具)都会跳过,等能力出现后由 `tools/change` 或 `agent/pre-step` 自动补装 |
209
+ | `本会话未启用官方 subagent 模型选择,策略段不渲染` | `info` | 去设置里启用 `subagent-model-selection-settings`(宿主授权只对新会话生效);工具本身仍按注册门控安装 |
77
210
 
78
211
  ## 已知限制
79
212
 
213
+ - 策略正文默认中文;可用 `texts.*` 整段覆盖(工具描述与部分 guard 拒绝理由仍为英文)。
80
214
  - 只对 `preset` 指定的 composition 生效(默认 `standard`)。
81
- - 不提供预算护栏 / 催收 / 故障改派(watchdog)——v0.2 候选。
82
- - 不提供英文文案与 locale:默认中文,可用 `texts.*` 整段覆盖(工具描述与 guard 拒绝理由仍为英文)。
83
- - 正文里的执行路由与专家路由全部来自你的配置,本包内置模板**不含任何具体渠道/模型名**。
215
+ - 不提供预算护栏 / 催收 / 故障改派(watchdog)。
216
+ - `configure_submodel` 只写两处:本插件配置行 + 宿主授权行(`subagent-model-selection-settings`);
217
+ 不创建渠道/密钥,也不改其他插件。
218
+ - 模型元数据里没有价格字段,哪些路由算"便宜"由你的配置决定(向导只做候选预填,不替你拍板)。
219
+ - 非 GUI 客户端没有提问卡可用,只能用「方式 B」手动 YAML。
220
+ - 团队队形自检只做**提示词约束**:是否并行、开几个队友仍由主代理判断,不强制;它也不会替你开启 Agent Teams。
84
221
 
85
222
  ## 回滚
86
223
 
@@ -88,10 +225,50 @@ dsh plugin --profile <你的 profile> add dsh-submodel
88
225
  dsh plugin --profile <你的 profile> remove dsh-submodel
89
226
  ```
90
227
 
228
+ 插件移除后,宿主授权行仍在 profile 补丁里;如需一并撤销,手动删除 `subagent-model-selection-settings` 条目即可。
229
+
230
+ 只关团队队形自检、保留其他功能:把 `teamFit.enabled` 设为 `false` 并重启 profile(不必卸载插件)。
231
+
91
232
  ## 开发与验证
92
233
 
93
234
  ```bash
94
- node tests/unit/flash-routing-fixture.mjs ./lib # 纯函数 + 生命周期回归(71 条断言)
95
- python -m unittest discover -s tests/unit # 包根执行(7 个用例)
96
- node tests/unit/public-profile-smoke.mjs # 干净用户配置的确定性冒烟(5 条断言)
235
+ npm install # 安装开发依赖(schemastery)
236
+ node tests/unit/flash-routing-fixture.mjs ./lib # 纯函数 + 生命周期回归
237
+ python -m unittest discover -s tests/unit # Python 驱动(包根执行)
238
+ node tests/unit/public-profile-smoke.mjs # 干净用户配置的确定性冒烟
97
239
  ```
240
+
241
+ 当前验证计数(CI 在每次 push / PR 跑同一组命令,见 `.github/workflows/ci.yml`):
242
+
243
+ <!-- 验证计数:fixture / Python / smoke 三处数字集中在这里;实测有出入时只改本表。 -->
244
+
245
+ | 检查 | 结果 |
246
+ |---|---|
247
+ | fixture | **126** 条断言,`failed: 0` |
248
+ | Python 驱动 | **7** 个用例 `OK` |
249
+ | 公共 profile 冒烟 | **8** 条断言,`failed: 0` |
250
+
251
+ GUI 端到端(`configure_submodel` 弹卡与两处写入、`delegate_task` 派工、主模型切到执行路由后进入
252
+ economize 模式)需要在重启后的真实 GUI 会话里由用户验收,**尚未验证**。团队队形自检的确定性部分
253
+ (三行正文、身份/预设/团队状态门控、默认关闭与回滚)已由 fixture 覆盖;真实 GUI 首轮对话里的
254
+ 实际回复与队友数同样需要在新会话里验收。
255
+
256
+ ## 参与贡献
257
+
258
+ - 提 issue / PR 前先看[贡献指南](CONTRIBUTING.md)(English: [CONTRIBUTING.en.md](CONTRIBUTING.en.md)):
259
+ 要跑的三条测试、提交格式、以及不该带进仓库的东西都写在那里。
260
+ - 安全问题请走私密渠道([安全政策](SECURITY.md)),不要开公开 issue。
261
+ - 参与本项目即视为同意[行为准则](CODE_OF_CONDUCT.md)。
262
+
263
+ ## 发版(维护者)
264
+
265
+ 发布走 GitHub Actions + npm **Trusted Publishing(OIDC)**,本机与仓库都不保存 npm 令牌:
266
+
267
+ 1. 在 `CHANGELOG.md` 顶部补 `## <版本>(YYYY-MM-DD)` 段;
268
+ 2. 在 `main` 分支运行 `pwsh scripts/release.ps1 <版本>`:跑门禁 → 改 `package.json` 版本 →
269
+ 提交 → 打 tag → push,并轮询 npm 直到看到新版本;
270
+ 3. 仓库的 `release` 工作流(`.github/workflows/release.yml`)在 tag push 后再次跑测试并自动
271
+ `npm publish`;`scripts/release.ps1` 验证成功后会尽量创建 GitHub Release。
272
+
273
+ 首次接入需在 npm 包设置里一次性配置 Trusted Publisher(仓库 `angel291592/dsh-submodel`、
274
+ 工作流 `release.yml`,并允许 Direct publish),之后发版不再需要 npm 密码 / 动态码 / 令牌。