@darkbear9494/dsh-model-manager 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,59 +1,19 @@
1
1
  # @darkbear9494/dsh-model-manager
2
2
 
3
- A host-half plugin for DeepSeek Harness that assigns models to four roles — `main`,
4
- `planning`, `execution`, `vision` — applies them on the `agent/request` waterfall, and
5
- reports which model every subagent actually used, with its role, the reason, and its live
6
- status. Since 0.3.0 it also **prompts the top-level agent to delegate** (`strategy.autoDelegate`)
7
- and **checks npm for a newer release of itself** (`update`), surfacing an upgrade notice in the
8
- log, through the `model_manager` tool, on the settings card, and as a chip in the session header.
9
- Since 0.4.0 the delegation label is a contract, not a hint: a leading `plan:`/`vision:` prefix
10
- decides the tier outright, and each role's failover chain wears down on its own. Since 0.5.0 the
11
- *session* can also pick its own tier: invoking a thinking skill — `grilling`, or the `grill-me`
12
- alias people type — puts the top-level session on the `planning` role for the rest of the session,
13
- exactly as plan mode does. Since 0.6.0 it ships one skill of its own: **`/autoplan`** turns the two
14
- tiers into a workflow — the plan is designed by a `plan:`-labelled fork on the planning model, and
15
- the main model implements the returned plan immediately, without stopping for approval. Since 0.6.1
16
- it also follows DSH 0.2's model-selection contract: a route is assigned with `agent.model.select()`
17
- before the step is prepared, instead of being rewritten at request time (which 0.2 aborts). Since
18
- 0.7.0 it registers its first real slash command: **`/readimage`** puts one message — and the images
19
- attached to it — on the `vision` tier for that turn alone, then hands the session back to whatever
20
- routing was in force.
21
-
22
- ## What it is
23
-
24
- DSH already ships the primitives: the `subagent` tool accepts an explicit
25
- `provider`/`model` per delegation, and the `subagent-model-selection-settings` row
26
- constrains which routes an agent may name. What it does not ship is a layer above that:
27
- nothing assigns models to *kinds of work* (planning, implementation, image reading), and
28
- nothing tells you afterwards which model a given subagent ended up on.
29
-
30
- This plugin is that layer. It keeps one ordered route list per role, classifies each
31
- delegated child from the label the delegating agent gives it, rewrites the child's resolved
32
- route to the role's route when inheritance is provable, and exposes a read-only
33
- `model_manager` tool that reports what happened. 0.3.0 adds two layers on top of routing
34
- proper: an **auto-delegation policy** — a system-prompt section that teaches the top-level
35
- agent to plan and dispatch subagents instead of doing everything itself, which is the
36
- behaviour the harness's own instructions only nudge at — and an **update check** that
37
- compares the installed version with the registry's `dist-tags.latest` and tells you how to
38
- upgrade. 0.4.0 makes the label a contract instead of a hint: a leading `plan:`/`vision:`
39
- prefix decides the tier before any keyword is consulted, the policy never advertises a tier
40
- with no models behind it, it teaches the delegating agent to leave `provider`/`model` unset
41
- on tiered units (an explicitly named route overrides the tier under `hybrid`), and the
42
- failover cursor is tracked per (session, role) so one tier's wear never pushes another tier
43
- off its first model. 0.5.0 gives the top-level `planning` tier a second trigger besides plan
44
- mode: a session that invoked one of the skills listed in `strategy.planningSkills` (default
45
- `['grill-me', 'grilling']`) runs on the planning role's models for the rest of its life, whether
46
- the intent arrived as a `/grilling` gesture in user text, as the harness's skill injection, or as
47
- the model's own `skill` tool call — and it is read from a durable session projection, so it
48
- survives a restart, a resume and a fork. 0.6.0 adds a second, complementary skill: `/autoplan`
49
- plans on the planning tier and implements on `main` in the same turn, with no approval gate in
50
- between — the label-driven tiers become a workflow instead of a setting. 0.7.0 adds the first
51
- trigger that is a real slash command: `/readimage`, registered through the harness's `commands`
52
- service, puts the one message that carries it — image attachments included — on the `vision` tier,
53
- and only for that turn. It is still deliberately
54
- small: one ESM host file, one config schema, one bundled skill body, and one hand-written client
55
- file that contributes a configuration card to the Plugins page. There is no build step for either
56
- half.
3
+ A host-half plugin for DeepSeek Harness that assigns models to four roles — `main`, `planning`,
4
+ `execution`, `vision` — routes delegated work by role, and reports which model every subagent
5
+ actually used. Version **0.7.2**.
6
+
7
+ ## Highlights
8
+
9
+ - **Four-role routing.** The delegation label is the contract: a leading `plan:` / `vision:` prefix decides the tier outright; keyword matching is the fallback.
10
+ - **Message-authored `@model` pins.** A direct Chinese/English directive pins a role to a model for the whole session — durable projection, replayed on restart/resume/fork, inherited by children, suppresses failover, never guesses on ambiguity.
11
+ - **One-turn commands.** `/readimage` runs one message (with images) on `vision`; `/quicktask` runs one text message on `execution`. Each expires after its turn.
12
+ - **Planning-skill escalation.** Invoking `grilling` / `grill-me` puts the session on `planning` for its life. The bundled `/autoplan` skill plans on the planning tier, then implements on `main` with no approval gate.
13
+ - **Auto-delegation policy.** `off` / `balanced` / `eager` system-prompt section teaching the top-level agent to plan and dispatch subagents.
14
+ - **`model_manager` tool.** Read-only `report` / `routes` / `usage` / `client` / `update`, plus a per-session model-usage panel in the session header.
15
+ - **npm update checks.** Surfaced in the host log, the tool, the settings card, and a session-header chip.
16
+ - **Web settings card.** Volatile hot-reload edits. Works on DSH 0.1.x (request rewrite) and 0.2.x (`agent.model.select()`).
57
17
 
58
18
  ## Install
59
19
 
@@ -71,1032 +31,459 @@ git clone https://github.com/jyshangguan/dsh-model-manager.git
71
31
  dsh plugin --profile desktop add /absolute/path/to/dsh-model-manager
72
32
  ```
73
33
 
74
- Use the profile your app actually boots. `dsh web` and the Web GUI run the `web` profile; the
75
- desktop app (DeepSeek Harness.app) runs **`desktop`**, so a plugin installed into `web` is
76
- invisible there. When in doubt, check the running process's working directory: it is
77
- `$DSH_HOME/profiles/<name>`.
78
-
79
- `dsh plugin` forwards everything after `--profile <name>` to **pnpm, run inside the profile
80
- directory** under a file lock (`lib/bin.js` → `runPlugin` → `runPluginCommand` in
81
- `@deepseek-ai/dsh-plugin-manager`). It is the same code path the GUI's `install_bundle` action
82
- uses, so both leave an identical result.
83
-
84
- What makes it one command instead of three: after the install, `reconcile()` walks every *new*
85
- profile dependency, reads its manifest, and when it declares `dsh.bundle.patch` it validates that
86
- patch and appends the package name to `dsh.profile.bundles`, writing `package.json` atomically. A
87
- dependency that declares no `dsh.bundle` prints `installed as a plain dependency, not a profile
88
- layer` and is never mounted. The profile-layer registration you would otherwise hand-edit is the
89
- installer's job.
90
-
91
- Then **restart the harness once** and confirm the row mounted: `plugin_manager` `list_plugins`
92
- should show row id `model-manager`, `enabled: true`, `fiberPhase: active`.
93
-
94
- ### Add plugin, from the Plugins page
95
-
96
- The Plugins page's **Add plugin** field reads *"Enter the plugin's package name, GitHub repository
97
- address, or local directory path."* It is the GUI's `install_bundle`, and it parses the string
98
- through the same `parseInstallSpec` (`@deepseek-ai/dsh-plugin-manager/lib/types/install-spec.js`)
99
- before handing it to pnpm. All four forms work:
34
+ The latest npm release is **0.6.1**; GitHub `main` is already **0.7.2**, so the GitHub and
35
+ working-copy forms are how you get the current code. Use the profile your app actually boots:
36
+ `dsh web` / the Web GUI run `web`, the desktop app runs `desktop`. A plugin installed into the
37
+ wrong profile is invisible. The Plugins page **Add plugin** field accepts the same four forms
38
+ (package name, `github:…` or an `https://github.com/…` URL, absolute directory, local `.tgz`).
39
+ Re-running the add command with `@latest` is also the upgrade path.
100
40
 
101
- | Field input | Spec kind |
102
- | --- | --- |
103
- | `@darkbear9494/dsh-model-manager` | registry — the shortest one to type |
104
- | `github:jyshangguan/dsh-model-manager` | git — the `https://github.com/…` URL works too |
105
- | `/Users/you/src/dsh-model-manager` | absolute local directory (relative paths are refused) |
106
- | `/Users/you/darkbear9494-dsh-model-manager-0.2.0.tgz` | local tarball — `npm pack` makes one (0.3.0's would be named the same way) |
107
-
108
- Registering the plugin by name was verified end-to-end on this runtime: `dsh plugin --profile
109
- <name> add @darkbear9494/dsh-model-manager` resolves the current release (`^0.1.0` at first
110
- publish, `^0.2.0` since) from the registry, `reconcile()`
111
- appends the bundle, the composed tree mounts row `model-manager`, and a boot reaches the LLM stage
112
- with no peer refusal and no loader error. The git and local-path forms were checked the same way.
113
- The same add command is the **upgrade** path: re-running it with `@latest` resolves the newer
114
- version and updates the dependency in place.
115
-
116
- ### The registry copy
117
-
118
- `@darkbear9494/dsh-model-manager@0.6.1` is the current release on the registry (published
119
- 2026-11-06), public access, 9 files: the host half, the client half, this README, the two locale
120
- dictionaries, the bundle patch, `package.json`, `LICENSE`, and `skills/autoplan/SKILL.md` — the
121
- bundled skill 0.6.0 introduced. 0.6.0 (2026-11-05) was the first release with that ninth file and
122
- packed 97.1 kB; 0.6.1 packs 102.4 kB (326.9 kB unpacked) with the DSH 0.2 model-selection fix.
123
- Earlier: 0.5.0 packed 92.1 kB (292.2 kB unpacked) with the same 8 files as 0.2.0 (the tarball
124
- grew, not the file list), 0.2.0 packed 63.1 kB, and 0.1.0, the first publish, 62.3 kB. The
125
- declared gate is
126
- `>=0.1.7-rc.2 <0.3.0`, so every release on the 0.1.7–0.2.x runtime lines installs without an
127
- exemption.
128
-
129
- Two things learned while publishing it, in case a future version has to be released:
130
-
131
- - The scope has to equal the npm account, or name an organization the account belongs to. See
132
- [Why the package is scoped](#why-the-package-is-scoped-and-why-the-scope-is-darkbear9494).
133
- - The registry's read path lags the write. Immediately after a successful `npm publish`
134
- (`PUT 200`, `exit 0`) the packument can still answer `404 Not found` — and so can `npm view`,
135
- `npm install` and a GUI install — while the tarball URL already returns `200`. It cleared on its
136
- own in about five minutes here. Wait it out rather than republishing; the second `npm publish`
137
- would fail on the version already existing.
138
-
139
- ### Why the package is scoped, and why the scope is `@darkbear9494`
140
-
141
- The unscoped name `dsh-model-manager` is **already taken on npm by a different plugin**: another
142
- DeepSeek Harness package whose Chinese display name is also 模型管理器, and which also declares
143
- `dsh.bundle.patch`. Installing by that bare name fetches theirs and auto-registers it into your
144
- boot graph; were both ever mounted together their loader rows could collide on one id, which
145
- aborts startup with `duplicate loader entry id`. `test/packaging.test.mjs` pins the scoped name
146
- so this cannot silently regress.
147
-
148
- The scope is not decoration. npm accepts a **user-scoped** package only when the scope equals the
149
- authenticated npm username; anything else is refused at publish time with
150
- `404 Not Found - PUT https://registry.npmjs.org/@<scope>%2f<name> - Scope not found`, unless the
151
- scope is an organization you belong to. This package was briefly `@jyshangguan/dsh-model-manager`,
152
- which failed to publish for exactly that reason — `@jyshangguan` is a GitHub handle, not the npm
153
- account. `@darkbear9494` is the npm account, so scope and account agree and no organization is
154
- needed. If the publishing account ever changes, the package name has to change with it.
155
-
156
- ### The runtime version gate
157
-
158
- `peerDependencies["@deepseek-ai/dsh"]` is `>=0.1.7-rc.2 <0.3.0`. The harness checks exactly that
159
- peer — only names equal to `@deepseek-ai/dsh` or beginning `@deepseek-ai/dsh-` — with semver,
160
- **prereleases included** (`semver.satisfies(runtime, range, { includePrerelease: true })` in
161
- `@deepseek-ai/dsh-app-boot`), and refuses an incompatible install while printing the exemption
162
- command:
41
+ After installing, **restart the harness once** (the client-module boot manifest caches package
42
+ metadata until restart) and confirm the row mounted: `plugin_manager` `list_plugins` should show
43
+ `model-manager`, `enabled: true`, `fiberPhase: active`.
163
44
 
164
- ```bash
165
- dsh plugin --profile desktop allow-version @darkbear9494/dsh-model-manager@0.2.0 \
166
- --dsh-version <exact runtime version> --accept-risk
167
- ```
45
+ Install notes worth knowing:
168
46
 
169
- Without that peer this plugin would install silently onto a harness too old to have
170
- `sessionProjections.stateOf` or the `model/selection` event, and then degrade with no
171
- explanation. Profiles ship `autoInstallPeers: false`, so declaring the peer does not pull a
172
- second copy of dsh into the profile.
173
-
174
- The range was `>=0.1.7-rc.2 <0.2.0` through 0.1.0, and that upper bound did not mean what it
175
- looked like. In semver a prerelease sorts *below* its release, so `0.2.0-rc.2 < 0.2.0` is true:
176
- the old range admitted **every 0.2.0 prerelease** while excluding `0.2.0` itself. It therefore
177
- permitted exactly the builds nobody had tested and blocked the release it appeared to target.
178
- `<0.3.0` is what it was meant to say, and it now covers the whole 0.2.0 line deliberately.
179
-
180
- The 0.2.0 line is admitted because the host half is verified against it. Against **dsh
181
- 0.2.0-rc.2** — the core bundled in DeepSeek Harness.app 0.2.0-rc.2 and the `latest` tag on npm —
182
- every API this plugin touches is unchanged from 0.1.7-rc.2: `dsh-session-projection`
183
- (`stateOf`), `dsh-plan-mode`, `dsh-agent`, `dsh-subagent`, `dsh-tool-subagent` +
184
- `model-selection-settings`, `dsh-tools`, `dsh-llm`, `dsh-session` and `dsh-client-modules` are
185
- byte-identical, all six subscribed events (including `agent/pre-step`, whose dispatch and
186
- decision shapes 0.5.0's skill trigger reads) and every probed service still exist, and all 22
187
- failover `failure.code` values are still emitted. A real boot on that runtime applied the host
188
- half, bound every event, resolved every injection and registered the `model_manager` tool. The
189
- client half is unchanged too: `window.__ModuleLoader__.load({ id, factory })`, the `dsh.client`
190
- manifest keys and every injected namespace still match what 0.2.0 provides.
191
-
192
- What did change between the two runtimes touches nothing here: `dsh-agent-loop` adds
193
- `ToolCallRecovery` on step failure, `dsh-session` refactors tail repair, `dsh-config-editor`
194
- changes how inherited config composes, and `dsh-api-remotes` gains transport code plus two
195
- namespaces (`productAnalytics`, `userQuestions`) with **no removals**.
196
-
197
- ### Renaming or moving a linked install
198
-
199
- Both of these were hit for real while scoping this package, on DSH 0.1.7-rc.2:
200
-
201
- `remove_bundle` drops the dependency from the profile's `package.json` and removes it from
202
- `dsh.profile.bundles`, but **leaves the symlink behind** in the profile's `node_modules`. Delete
203
- that orphan yourself: a directory whose name no longer matches the `name` in its own manifest is
204
- precisely what a resolution scanner should not have to reason about. (Clearing it did *not* fix
205
- the symptom below, so it is hygiene rather than a remedy.)
206
-
207
- And a **running host cannot import a package name that did not exist when it booted**. The runtime
208
- resolution is computed from the installation and the bundles selected at startup, then handed to
209
- Node's ESM and CommonJS resolvers, so after a rename the entry reports `failed to import` —
210
- `inactiveEntries` finding `entry.fiber === undefined` — however many times you toggle the bundle.
211
- The package itself is fine: `node -e "import('<new name>')"` from the profile directory succeeds,
212
- and `dsh --profile <name> --dump-config` composes the row correctly, override config included.
213
- Only a restart picks it up. Remove the old name, install the new one, then restart once.
214
-
215
- | File | Purpose |
216
- | --- | --- |
217
- | `lib/index.js` | Host half: Cordis identity `model-manager`, exported `Config`, `apply`, the `agent/request` routing, the `agent/request-error` failover, the `agent/pre-step` planning-skill observer, the three session projections, and the `model_manager` tool. |
218
- | `client.js` | Client half: the configuration card, contributed as a page in the Settings panel. |
219
- | `locale/en.json`, `locale/zh.json` | Display metadata only — the bundle's `title` and `description` in the plugin list. |
220
- | `cordis.patch.yml` | Bundle layer: inserts exactly one row, id `model-manager`. |
221
- | `package.json` | Package `@darkbear9494/dsh-model-manager`, declaring `dsh.bundle.patch`, `dsh.client`, and the `@deepseek-ai/dsh` version gate. |
222
- | `test/` | The test suite; `npm test` runs all of it. See [Testing](#testing). |
47
+ - **The scoped name is load-bearing.** The bare name `dsh-model-manager` is a *different* npm plugin; installing it auto-registers that one, and two rows sharing an id abort startup with `duplicate loader entry id`. The scope `@darkbear9494` must equal the publishing npm account.
48
+ - **Runtime gate.** `peerDependencies["@deepseek-ai/dsh"]` is `>=0.1.7-rc.2 <0.3.0`, checked with prereleases included, so the whole 0.1.7–0.2.x line installs without an exemption; an incompatible runtime is refused with an `allow-version … --accept-risk` command.
49
+ - **Working-copy installs are linked, not copied.** Point the optional schema dependency at the harness's copy once per machine, or the Settings card (and two test assertions) degrade:
50
+ ```bash
51
+ mkdir -p node_modules/@deepseek-ai
52
+ ln -s "$(npm root -g)/@deepseek-ai/dsh/node_modules/@deepseek-ai/schemastery" \
53
+ node_modules/@deepseek-ai/schemastery
54
+ ```
55
+ Without it the plugin still routes (`Config` degrades to `undefined`, `readConfig` normalizes the raw config); only schema validation and the Settings form are skipped.
56
+ - **Renaming a linked install needs a restart.** `remove_bundle` leaves the old symlink in the profile's `node_modules` (delete it yourself), and a running host cannot import a package name that did not exist at boot — remove the old name, install the new one, restart once.
223
57
 
224
- ### Making the schema dependency resolvable
58
+ ## Quick start
225
59
 
226
- `@deepseek-ai/schemastery` is declared as an **optional peer**: the harness ships it, and this
227
- package deliberately does not install its own copy, so the `Config` schema is built by the same
228
- schemastery instance the loader validates with.
229
-
230
- But a path-based install is *linked*, not copied, so Node resolves this package's imports from
231
- its own directory upward — which never reaches the profile's `node_modules`. Point it at the
232
- harness's copy once per machine:
233
-
234
- ```bash
235
- mkdir -p node_modules/@deepseek-ai
236
- ln -s "$(npm root -g)/@deepseek-ai/dsh/node_modules/@deepseek-ai/schemastery" \
237
- node_modules/@deepseek-ai/schemastery
238
- ```
239
-
240
- `npm root -g` is the global install root; adjust if your `dsh` lives somewhere else.
241
- `node_modules/` is git-ignored, so this step is not carried by the repository.
242
-
243
- Skipping it does not break the plugin: `Config` degrades to `undefined`, cordis's
244
- `resolveConfig` passes the raw config straight through, and routing keeps working. What you
245
- lose is the Settings card — the harness only serves a settings namespace for a row that has a
246
- Config schema, so the card would report the namespace as unavailable.
247
-
248
- **The test suite needs it too**, and fails less gracefully than the plugin does: without a
249
- resolvable schemastery, `edge` dies on `TypeError: plugin.Config is not a constructor` and
250
- `client-diagnostic` loses one assertion. This is a known rough edge — the suites should skip
251
- those cases with a warning instead of crashing. Create the symlink before running `npm test` on
252
- a fresh clone.
253
-
254
- **Restart the harness once after installing.** The client half reaches the browser through
255
- a boot manifest: the node half of `client-modules` scans the loader's entries for packages
256
- declaring `dsh.client`, and package metadata — including the negative "not a client
257
- package" verdict — is cached per loader specifier *until restart*. It is the same restart
258
- the host half needs, so do both at once. Before it, the Plugins page simply shows no
259
- configure control for this bundle.
260
-
261
- ```json
262
- {
263
- "exports": {
264
- ".": "./lib/index.js",
265
- "./client": "./client.js",
266
- "./locale/*.json": "./locale/*.json",
267
- "./package.json": "./package.json"
268
- },
269
- "dsh": {
270
- "bundle": {
271
- "patch": "./cordis.patch.yml"
272
- },
273
- "client": {
274
- "platform": "web",
275
- "immediately": true,
276
- "inject": [
277
- "@deepseek-ai/dsh-client-locale",
278
- "@deepseek-ai/dsh-client-ui-settings",
279
- "@deepseek-ai/dsh-api-remotes"
280
- ]
281
- }
282
- }
283
- }
284
- ```
285
-
286
- `platform: "web"` is what makes this a browser module for the web shell, and `immediately:
287
- true` marks it for stage-one prefetch, so its factory is registered during module-face boot
288
- instead of on demand. `inject` is a *dependency edge*, not a mount whitelist: each named package
289
- has to arrive first because it declares something this half uses —
290
- `@deepseek-ai/dsh-client-locale` for `ctx.locale.register`, `@deepseek-ai/dsh-client-ui-settings`
291
- for the `settings.section` slot, and `@deepseek-ai/dsh-api-remotes` for the `remote.llm` and
292
- `remote.session` faces the card reads the model catalog and the usage projection through. If one
293
- is missing from the composition that registration has nothing to attach to; the host half still
294
- routes, and the boot log names the surface that never appeared.
295
-
296
- To smoke-test it before installing anything, mount the entry by path in a throwaway
297
- patch layer and boot the whole plugin tree headless — a plugin that breaks startup fails
298
- here instead of in your running server:
60
+ The bundle ships a layer that inserts row `model-manager` with sensible defaults (see
61
+ [Configuration](#configuration)). Override it from the profile's own `cordis.patch.yml` by id —
62
+ or edit the same values live on the Settings card (设置 → 模型管理器):
299
63
 
300
64
  ```yaml
301
- # smoke.patch.yml
302
- - insert:
303
- - id: model-manager-smoke
304
- name: '/absolute/path/to/dsh-model-manager/lib/index.js'
305
- config:
306
- roles:
307
- planning:
308
- models:
309
- - provider: pku-corpus
310
- model: qwen3.8-max-0902
311
- execution:
312
- models:
313
- - provider: pku-corpus
314
- model: qwen3.8-flash
315
- strategy:
316
- mode: hybrid
65
+ - id: model-manager
66
+ config:
67
+ pick: first
68
+ roles:
69
+ main:
70
+ models: [] # leave the composer choice alone
71
+ planning:
72
+ models:
73
+ - provider: pku-corpus
74
+ model: qwen3.8-max-0902
75
+ execution:
76
+ models:
77
+ - provider: pku-corpus
78
+ model: qwen3.8-flash
79
+ vision:
80
+ models: [] # falls back to execution
81
+ strategy:
82
+ mode: hybrid
83
+ autoDelegate: balanced
317
84
  ```
318
85
 
319
- ```bash
320
- dsh --profile web --patch ./smoke.patch.yml headless "say ok"
321
- ```
86
+ > An id override **replaces `config` wholesale, never deep-merged**. Restate every key you want
87
+ > to keep; an override that sets only `strategy.mode` also drops every role route.
322
88
 
323
- ## The four roles
89
+ ## How routing works
324
90
 
325
- Each role holds an ordered list of routes. Since 0.2.0 the **selection strategy is one
326
- top-level `pick` for every role** — the per-role `pick` field of 0.1.x is gone, and a config
327
- that still carries it gets a warning naming the move. A role with no models
328
- resolves to no route, and requests classified into it pass through unchanged — except
329
- `vision`, which falls back to `execution`. A subagent never uses `main`.
91
+ Each role holds an ordered list of routes `{ provider, model, reasoningEffort? }`. A role with no
92
+ models resolves to no route and its requests pass through unchanged — except `vision`, which
93
+ falls back to `execution`. A subagent never uses `main`.
330
94
 
331
95
  | Role | What it is for | When it applies | Bundled default |
332
96
  | --- | --- | --- | --- |
333
- | `main` | The top-level agent, outside plan mode and outside any active planning skill. | Requests from a non-subagent session **outside** plan mode and outside any active planning skill. | `models: []` (no route — the composer choice is left alone) |
334
- | `planning` | Reasoning, design, analysis, research. | Top-level requests while plan mode is active **or** while a listed planning skill (default `grilling` / `grill-me`) has been invoked in the session; subagents whose label matches a planning keyword (and no vision keyword). | `pku-corpus/qwen3.8-max-0902` |
335
- | `execution` | Default tier for delegated implementation. | Every subagent that matches neither keyword list, including a child with an empty label; also the fallback for vision when `vision` has no models. | `pku-corpus/qwen3.8-flash` |
336
- | `vision` | Image, screenshot, chart and OCR work. | Subagents whose label matches a vision keyword. | `models: []` (falls back to `execution`) |
337
-
338
- A top-level session has two ways onto `planning`, and neither of them is its label:
339
- the harness's plan mode, and `strategy.planningSkills` — the skills a user invokes to do thinking
340
- work (`grilling`, plus the `grill-me` alias that loads it). Invoking one counts as entering the
341
- tier: the session is on `planning` **for the rest of the session**, because the skill's
342
- instructions stay in context and a grilling interview runs over many turns, not one. There is no
343
- exit gesture — start a new session, or set `planningSkills: []`, which is the off switch — and a
344
- model you hand-picked in the composer still wins under `hybrid`, the same way it does in plan mode.
345
- See [Planning skills](#planning-skills).
346
-
347
- A route is `{ provider, model, reasoningEffort? }`. The top-level `pick` is `first`
348
- (default) or `round-robin` and applies to every role alike; with one model in a role's list
349
- it has no effect for that role. Under `first` the list is a failover chain, and since 0.4.0
350
- the wear position is tracked per **(session, role)**, not per session: a session that failed
351
- over while it was serving `planning` (plan mode moves one session between `main` and
352
- `planning` on every request; a planning skill moves it to `planning` and leaves it there) comes
353
- back to `main` still on `main`'s first model. A role may
354
- also carry a
355
- `note` — free text for humans, printed under the role in the `routes` table and never
356
- used for routing.
357
-
358
- ## Configure in the UI
359
-
360
- The client half contributes a configuration card to the Plugins page. It writes exactly the
361
- values documented under [Configuration](#configuration) — `roles.<role>.models`, the
362
- top-level `pick`, `strategy.mode` and `strategy.autoDelegate` — so the two paths are
363
- interchangeable: use the card to try a routing
364
- choice, the YAML to pin it. This package's own `cordis.patch.yml` is the declarative source
365
- that ships with the bundle and is re-read on every boot, and a profile patch overrides it by
366
- row id; the card never edits patch files, so if a patch layer pins a value, edit the patch.
367
-
368
- ### Where the card appears
369
-
370
- `client.js` registers **three** surfaces and deliberately nothing on the Plugins page:
371
-
372
- | Slot | Registration id | What it renders |
373
- | --- | --- | --- |
374
- | `settings.section` | `model-manager` | The configuration card: the four roles and their model lists, the shared selection strategy, the auto-delegation level, the distribution mode, and the update banner. |
375
- | `conversation.session.header.utilities` | `model-manager-usage` | The per-session model-usage summary the host half folds from the durable log. |
376
- | `conversation.session.header.utilities` | `model-manager-update` | The update-available chip (0.3.0): renders nothing unless a newer release was found, then shows `更新:<latest>` and discloses the upgrade command on click. |
377
-
378
- So the path is **设置 → 模型管理器** — not Plugins → the row → configure. `plugins.item` and
379
- `plugins.row.config` are *not* registered: one card in one place was the requirement, and a
380
- second copy on the Plugins page would only be a second place for the same values to disagree.
381
-
382
- All entries are registered **unconditionally** rather than behind the shipped
383
- `configForms.whileServed([ns], …)` gate. The Host serves a settings namespace only for a row
384
- whose Config schema has volatile fields, so that gate would hide the card entirely whenever the
385
- optional schemastery dependency failed to resolve — making a packaging problem look exactly like
386
- a missing feature. The entry is therefore always reachable, and the card itself reports why it
387
- cannot show values.
388
-
389
- The usage surface only subscribes to a finished value: the host half folds `modelManagerUsage`
390
- out of the durable session log and ships it as a wired projection, so there is no folding and no
391
- polling on the client, and the numbers survive a restart.
97
+ | `main` | The top-level agent. | Non-subagent requests outside plan mode and outside any active planning skill. | `[]` (composer choice left alone) |
98
+ | `planning` | Reasoning, design, analysis, research. | Top-level requests in plan mode **or** after a listed planning skill was invoked; subagents whose label matches a planning keyword (and no vision keyword). | `pku-corpus/qwen3.8-max-0902` |
99
+ | `execution` | Default tier for delegated implementation. | Every subagent matching neither keyword list (including an empty label); the vision fallback. | `pku-corpus/qwen3.8-flash` |
100
+ | `vision` | Image, screenshot, chart, OCR work. | Subagents whose label matches a vision keyword. | `[]` (falls back to `execution`) |
392
101
 
393
- ### What the card offers
394
-
395
- | Control | Writes | Notes |
396
- | --- | --- | --- |
397
- | Model rows, one per role (`Main model`, `Planning and reasoning`, `Execution`, `Image recognition`) | `set roles.<role>.models` | Each configured route is its own row with a `<select>` grouped by provider in `<optgroup>`s, fed by `ctx.remote.session.modelCatalog()` and labelled `name — id`. A route the catalog stopped advertising stays selectable and is marked `(not in catalog)` rather than being silently swapped. An empty list is the YAML default: no route for that role, and `vision` falls back to `execution`. |
398
- | Add a model | `set roles.<role>.models` | One dashed control under the rows, listing every catalog model the role has not already used, so a model cannot be added twice. |
399
- | `up` / `remove` | `set roles.<role>.models` | Reorder and delete. The whole list is rewritten in one atomic operation, so a reorder cannot interleave into a partial state. The up control is **disabled on the first row** rather than absent, so the column never changes width. |
400
- | Reasoning-effort picker | `set roles.<role>.models` (single route with `reasoningEffort`) | Appears **only when the selected model advertises `reasoning.efforts`** in the catalog. `(model default)` writes a route with no `reasoningEffort`, letting the adapter choose; naming a tier explicitly is how you satisfy a model that rejects a request without one. |
401
- | `Pick` (`first` / `round-robin`) | `set pick` | **One control for every role** (since 0.2.0), rendered next to the distribution mode with a hint line. `first` always uses index 0 of each role's list and only advances when a route fails; `round-robin` spreads consecutive requests across each role's list. |
402
- | `Auto delegation` (`off` / `balanced` / `eager`) | `set strategy.autoDelegate` | New in 0.3.0. The [delegation policy](#auto-delegation-policy-strategyautodelegate) level, labelled with one-line explanations. A stored level the card does not know displays as `balanced`, mirroring the host half's fallback. |
403
- | Distribution mode | `set strategy.mode` | `hybrid` / `managed` / `advisory`, labelled with the same one-line explanations this README uses. A stored mode the card does not know displays as `hybrid`, mirroring the host half's fallback. |
404
- | Update banner (read-only) | — | New in 0.3.0. When the client-side update store says a newer release exists, a warn-toned banner opens the card: versions, the upgrade command, and a **Re-check** button. See [Automatic update checks](#automatic-update-checks). |
405
-
406
- **Layout.** One CSS grid per role, with fixed column tracks `auto minmax(0, 1fr) auto auto` — index, model, effort, actions. That choice is the whole reason the rows line up: in a flex row a control with `flex: 1 1 16rem` takes width from its siblings, so any row that omits one control (a model with no reasoning tiers, a first row with no reorder button) pulls every other row's right edge out of alignment. Under the grid a row with no effort control still emits an empty cell, so the action column sits at the same x everywhere. The two actions are glyphs rather than words, so the column is also the same width in either locale; each keeps an `aria-label` and a native `title`. The add affordance is deliberately unlike a model row — dashed border, no fill, muted text, spanning the value columns.
407
-
408
- Each role also carries a hint line (`Top-level agent outside plan mode and planning skills. …`,
409
- `Used for image, screenshot and OCR work. Pick a model
410
- that accepts images.`, …) so the card explains itself without this README open.
411
-
412
- The card cannot tell you whether a model accepts images: the session model catalog carries
413
- ids, names and reasoning efforts, and no modality field. Use
414
- `model_manager(action: "routes")` for the vision capability audit, which asks the host half's
415
- `llm` service instead.
416
-
417
- ### How a change reaches the router
418
-
419
- **Immediately, with no Save button.** Every control writes on `change`, and the host half
420
- re-reads its config on `loader/volatile-update`, so the next request uses the new value
421
- without a restart. A short status line confirms the outcome (`Saved`, or the host's refusal
422
- or error message) in the theme's success/error colour.
423
-
424
- **The UI never writes settings storage itself.** The page owner hands the card a `form`
425
- built from the row's settings namespace (`model-manager`): `form.state` with the accepted
426
- `value`, the current `revision`, `writable` and `status`, and `form.mutate(ops, revision)`
427
- for ordered path operations. The card always submits with the revision it just read, and a
428
- mutate that returns falsy or throws is reported rather than assumed to have worked. That is
429
- why this card cannot race the host's own settings writes: a stale write is fenced off by the
430
- revision rather than silently overwriting a newer one.
431
-
432
- ### When the card cannot show anything
433
-
434
- A component that throws blanks its whole slot entry, so each unavailable state renders a
435
- notice instead — and every optional collaborator is probed, with any failure logged as
436
- `[model-manager] <step>: <message>` through a wrapper that keeps applying:
437
-
438
- | State | Cause | Rendered copy |
439
- | --- | --- | --- |
440
- | No `form` on a page render | the host rendered this slot without values — a defensive path, not the row page | `This page did not supply configuration values, so the model roles cannot be edited here. Open this plugin's own row on the Plugins page to configure it.` (warning colour) |
441
- | No `form` on the summary render | the row-list render always omits it | renders nothing: the card returns `null` and the row's description stands |
442
- | Catalog loading | `modelCatalog()` in flight | every control renders **disabled**, the add control offers only its own `Add a model…` placeholder, a configured route the catalog has not returned yet still shows as `provider/model (not advertised)` so its value is never silently swapped, and `Loading models…` appears below |
443
- | Not available to this client | `form.state.status === 'unavailable'` — the namespace is not exposed here | `These settings are not available to this client right now.` (warning colour) |
444
- | Read-only deployment | `status === 'ready'` but `writable === false` | role rows render disabled, plus `This deployment stores settings read-only.` |
445
- | Nothing advertised | catalog ready with zero provider groups | `No models are advertised yet. Configure a provider route, then reopen this page.` |
446
- | Partial failure | catalog `failures` non-empty | `Some providers could not be listed: <name, name>` (warning colour) |
447
- | Fetch failed | `modelCatalog()` returned an error or threw | the error message, in the error colour |
448
-
449
- The notices are ordered so a read-only deployment says so before anything about the catalog,
450
- and the write-result line (`Saved` / refusal) is last, because it is the most transient.
451
-
452
- The catalog is fetched once per page load and refreshed on the `llm/adapters-updated` and
453
- `settings/document-updated` remote events, so adding a provider route makes its models
454
- appear without a reload. A `generation` counter discards a response that is older than the
455
- most recent request, and a throwing subscriber cannot break the other subscribers.
456
-
457
- **A configured route the catalog no longer advertises stays selectable**, appended as an
458
- extra option labelled `pku-corpus/some-retired-model (not advertised)` and kept as the
459
- selected value. Without that, a `<select>` whose value matches no `<option>` renders as its
460
- first option instead — so the card would appear to name a model the config does not select,
461
- and saving anything else on that row would overwrite the real route.
462
-
463
- Note also that picking a *different* model for a role preserves a `reasoningEffort` already
464
- stored on that route. If the new model advertises no efforts, the effort picker disappears
465
- while the stored effort remains in the config; clear it by writing the role's models from
466
- the patch layer.
467
-
468
- ### How the card is built
469
-
470
- - **It requires exactly one module: `react`.** The harness's plugin practices forbid
471
- `require`-ing Harness Client packages from a hand-written client half — including
472
- `@deepseek-ai/dsh-client-ui-primitives` — because a second copy of a UI package in the
473
- browser graph is a breakage waiting to happen. So the `<select>` controls here are written
474
- locally in `client.js` rather than imported.
475
- - **Styling uses only `--dsw-alias-*` theme tokens**: `bg-layer-1`, `border-l1`,
476
- `label-primary`, `label-secondary`, `state-success-primary`, `state-error-primary`,
477
- `state-warn-primary`. Light and dark follow the host, and a future token rename degrades
478
- to an inherited colour instead of breaking the entry.
479
- - **Its copy is localized.** `apply` registers a `dsh-model-manager` locale namespace with
480
- inline English and Chinese dictionaries through `ctx.locale`, and binds it for rendering;
481
- if the binding fails, labels degrade to their key names. The `locale/en.json` and
482
- `locale/zh.json` files in the package are separate: they are the bundle's `title` and
483
- `description` as shown in the plugin list.
484
-
485
- **Verification status, stated honestly:** the client half was verified by JavaScript syntax,
486
- manifest validation, a structural load of the `window.__ModuleLoader__.load` factory — which
487
- confirms that only `react` is required, that `apply` registers the `dsh-model-manager` locale
488
- namespace with the same 61 keys in English and Chinese (the test compares the sorted key *sets*,
489
- not just their counts), that exactly three registrations land across the two surfaces —
490
- `settings.section` under `model-manager` and `conversation.session.header.utilities` under
491
- `model-manager-usage` (the per-session usage) plus `model-manager-update` (the update chip,
492
- which renders `null` while the update store is idle) — and
493
- that `apply` still returns normally when every injected collaborator throws. It was also checked
494
- against the live slot contract in `@deepseek-ai/dsh-client-ui-settings`. **Visual verification of
495
- the rendered card is not available in this environment:** the harness's own verification guidance
496
- forbids emulating React/DOM or building mock previews as a substitute for a browser, so the
497
- rendered appearance is unverified. Remember the restart after installing, since the live slot only
498
- populates once the client-module boot manifest has been rebuilt.
499
-
500
- ## Distribution strategy
501
-
502
- ### Modes
503
-
504
- `strategy.mode` decides whether the selected role route is written into the request.
505
-
506
- | Mode | Behaviour |
507
- | --- | --- |
508
- | `hybrid` (default) | Top-level requests are rewritten whenever the role has a route. A subagent is rewritten **only when inheritance is provable** — its resolved route equals the parent's effective route, or equals a route this manager already applied to that child (see below). Anything else is respected as the child's own choice. |
509
- | `managed` | The role route is always applied, overriding an explicit per-delegation `provider`/`model`. Use this if you want routing regardless of lineage. |
510
- | `advisory` | Never rewrites anything. It classifies the request and records the model actually used. |
511
-
512
- `hybrid` is what makes per-delegation choices work: pass nothing and the role decides;
513
- pass an explicit `provider`/`model` to the delegation tool and your choice survives.
514
-
515
- ### `main` and the composer's model picker
516
-
517
- These are two different mechanisms, and they used to collide: the composer writes the
518
- session's own route (`session.selectModel`), while the manager rewrote it at request time
519
- whenever `main` was configured — so the picker kept displaying a model that was never used.
520
-
521
- In `hybrid` the manager now backs off when you have actually chosen. The test is
522
- **durable, not a guess**: selecting a model in the composer appends a
523
- `model/selection` event to the session log — that event has exactly one append site in the
524
- whole install (`selectForNextRequest`) — and this plugin folds it into a
525
- `modelManagerSelection` session projection. A session with such an event keeps your pick and
526
- records `explicit session selection (respected)`; a session that never had one is running on
527
- the deployment default, which is the route `main` exists to replace.
528
-
529
- Three things follow from that. `managed` is unchanged — it means "the manager owns every
530
- route", including a session you picked by hand. A respected selection **does not consume the
531
- round-robin rotation**, because rotation commits only when a route is applied; the first
532
- request the manager does take over still gets the first model. And the choice survives a
533
- restart, a resume and a fork, because it is read from the log rather than remembered in
534
- process state.
535
-
536
- One caveat worth knowing: **the composer's picker also overwrites the deployment default**
537
- (implementation note: `selectModel` calls `selectForNextRequest` *and*
538
- `agentDefaultModel.saveSelection` in the same action). Picking a model for one session
539
- therefore changes what brand-new sessions start on too, which is the harness's behaviour, not
540
- this plugin's.
541
-
542
- ### What "inherited" means
543
-
544
- Three rules decide whether a subagent request is treated as inherited.
545
-
546
- **The parent's effective route.** Read the same way DSH itself computes the route it
547
- passes to a child: the parent's latest request header
548
- (`agent.session.requestHeader()?.config`) owns `provider`/`model`, and the parent's
549
- creation options (`agent.options`) are only the pre-first-request fallback. That matters
550
- because after request-time selection the header reflects what the parent actually ran on
551
- — including a route this plugin applied. Comparing against `agent.options` instead would
552
- misread a manager-rewritten parent as an explicit child choice and silently stop routing.
553
-
554
- **Manager-owned children.** Once the manager routes a child, that child's own request
555
- header changes, so on its next request it no longer equals the parent's route. Without a
556
- second rule, a long-running child would be reclassified as an explicit choice and quietly
557
- stop being managed. So a child is also treated as inherited when its route equals the
558
- route the manager itself last applied to it. This is tracked by an internal `applied` flag
559
- recorded per request, and it is `true` only when a route was really applied — `advisory`,
560
- respected-explicit and `passthrough` all record `false`, so **an explicit choice is never
561
- re-adopted**. Manager-ownership is checked before lineage, so a child the manager already
562
- routed stays managed even if its parent goes away.
563
-
564
- **Unresolvable lineage fails closed.** If no delegating parent can be found and the child
565
- is not manager-owned, the plugin cannot prove inheritance: it **respects the child's own
566
- route** and records `lineage unresolved (child route respected)`. If you want the role
567
- route applied no matter what, use `managed`.
568
-
569
- All comparisons are by value. A `round-robin` advance is committed **only when a route is
570
- actually applied**: `advisory` passes, a respected explicit route, and a respected
571
- unresolved-lineage route all leave the rotation where it was.
572
-
573
- ### Label-driven classification
574
-
575
- Only a session whose `session.header.origin` is `'subagent'` is classified by label. The
576
- label is the `description` the delegating agent passed to the `subagent` tool, which the
577
- harness stores as the child's label. Matching is case-insensitive, anchored at a leading
578
- word boundary, and prefix-first, in this order:
102
+ **Label classification** (subagents only; `session.header.origin === 'subagent'`). The label is
103
+ the `description` passed to the `subagent` tool. Matching is case-insensitive, anchored at a
104
+ leading word boundary, prefix-first:
579
105
 
580
106
  1. Empty label → `execution`.
581
- 2. A label starting with `plan:` (case-insensitive, leading whitespace ignored) →
582
- `planning`.
583
- 3. A label starting with `vision:` → `vision`.
584
- 4. Else any `visionKeywords` match → `vision`.
585
- 5. Else any `planningKeywords` match → `planning`.
107
+ 2. Leading `plan:` (whitespace ignored) → `planning`.
108
+ 3. Leading `vision:` → `vision`.
109
+ 4. Any `visionKeywords` match → `vision`.
110
+ 5. Any `planningKeywords` match → `planning`.
586
111
  6. Else `execution`.
587
112
 
588
- The leading prefix is authoritative — it is the one part of the label the delegating model
589
- writes *on purpose*, so `"plan: analyse the screenshots"` is planning work. Among keyword
590
- matches, vision is tested before planning, so a label matching both lands on `vision`.
113
+ The leading prefix is authoritative — `"plan: analyse the screenshots"` is planning work; among
114
+ keyword matches vision is tested before planning, so a label matching both lands on `vision`.
115
+ Keywords match word *prefixes* (`plan` matches `"planet"`, `screenshot` matches `"screenshots"`),
116
+ but a leading boundary stops `spec` matching `"inspect"`; regex metacharacters are escaped
117
+ (`pkg.io` matches literally). Built-in lists and tuning: [Configuration](#configuration).
591
118
 
592
- | Delegation `description` | Matched by | Role | Applied route (bundled defaults) |
593
- | --- | --- | --- | --- |
594
- | `"plan: design the migration"` | `plan`, `design` | `planning` | `pku-corpus/qwen3.8-max-0902` |
595
- | `"vision: read this screenshot"` | `vision`, `screenshot` | `vision` | falls back to `execution` → `pku-corpus/qwen3.8-flash` |
596
- | `"fix the typo"` | nothing | `execution` | `pku-corpus/qwen3.8-flash` |
597
- | `"analyze the parser design"` | `analyze`, `design` | `planning` | `pku-corpus/qwen3.8-max-0902` |
598
- | `"summarize the changelog"` | nothing | `execution` | `pku-corpus/qwen3.8-flash` |
119
+ **Distribution mode** (`strategy.mode`) decides whether the selected role route is written:
599
120
 
600
- A non-subagent session is never classified by label: it gets `planning` while plan mode
601
- is active **or** while one of `strategy.planningSkills` has been invoked in it — a trigger that
602
- then holds for the rest of the session — and `main` otherwise. See
603
- [Planning skills](#planning-skills).
604
-
605
- ### Planning skills
606
-
607
- `strategy.planningSkills` (default `['grill-me', 'grilling']`) is the user-facing half of the
608
- planning tier: plan mode is the harness declaring that this session is doing thinking work, a
609
- skill invocation is the user declaring the same thing. Both names ship in the list because
610
- `grill-me` is the alias a person types and `grilling` is the skill it loads. A subagent is never
611
- escalated by a skill — a child is classified by its label alone.
612
-
613
- **Three signals count**, because DSH commits each of them before the request it can influence:
121
+ | Mode | Behaviour |
122
+ | --- | --- |
123
+ | `hybrid` (default) | Top-level requests are rewritten whenever the role has a route. A subagent is rewritten only when inheritance is provable (below); anything else is respected as the child's own choice. |
124
+ | `managed` | The role route is always applied, overriding an explicit per-delegation `provider`/`model`. |
125
+ | `advisory` | Never rewrites; classifies and records the model actually used. |
614
126
 
615
- | Signal | Read from | Escalates |
616
- | --- | --- | --- |
617
- | The injected skill message — `user/message` with `source.kind: 'skill-invocation'` and `source.name` | the durable fold **and** `agent/pre-step` | the step that carries the gesture |
618
- | A `/name` gesture in direct user text | the same two | the same step |
619
- | A model-invoked `skill` tool call — `tool/call`, name `skill`, JSON `arguments.name` | the durable fold | the **next** request of that session |
620
-
621
- Recognition uses the harness's own grammar, kept byte-identical to `dsh-tool-skill`'s: a skill
622
- name is lowercase kebab-case (`[a-z0-9]+(-[a-z0-9]+)*`) and the gesture is a `/name` standing
623
- alone between whitespace. So "grill me on this" written in prose matches nothing, while the
624
- `skill` call the model then makes does — one request later, once that call is in the log.
625
-
626
- **Why the first request needs a second hook.** DSH fires `agent/pre-step` *before*
627
- `agent/request`, and commits the step's user batch — the skill injection included — only *after*
628
- `agent/request` returns (`dsh-agent-loop`: `preStep()` → `prepareRequest()` →
629
- `session.append('user/message')`). A fold-only design would therefore serve the first, and most
630
- important, request of a `/grilling` turn on `main`. So the plugin registers a prepended,
631
- observe-only `agent/pre-step` listener that records every skill name in the step's batches and
632
- returns the harness's decision untouched. `{ prepend: true }` is what lets it see the injections
633
- at all: `dsh-tool-skill` registers as an inner hook, so a normally ordered listener would run
634
- inside it and never receive them. That map is per-process and is dropped with the agent on
635
- `agent/disposed`.
636
-
637
- **Why the trigger survives a restart.** The durable half is a third session projection,
638
- `modelManagerPlanningSkill`, folded from the `user/message` and `tool/call` events. It stores
639
- *every* skill name the session invoked, not just the configured planning ones, because membership
640
- is decided against the **live** config on every request: adding a name to `planningSkills` reaches
641
- a session that invoked it an hour ago, and `[]` switches the trigger off on the next request
642
- without a restart. Both halves are append-only, which is what makes the trigger **sticky for the
643
- rest of the session** — the way entering plan mode is, and for the same reason: the skill's
644
- instructions stay in context and its interview runs over many turns. Plan mode is consulted first,
645
- so a session that is in plan mode *and* has been grilled records trigger `plan-mode`; the role is
646
- `planning` either way.
647
-
648
- Normalization follows the keyword lists, with one addition: entries are trimmed, lowercased and
649
- de-duplicated, and anything that is not a kebab-case skill name is dropped, so a typo in the list
650
- can never match a session by accident. An absent or non-list value uses the defaults; an explicit
651
- `[]` — or a list whose every entry was dropped — disables the trigger.
652
-
653
- **What you can see of it.** The host logs one line per switch rather than per request
654
- (`planning skill "grilling" is active in this session; top-level requests route as planning`),
655
- `model_manager(action: "routes")` prints the live list on its `Planning skills:` line, and
656
- `model_manager(action: "report")` adds a `Planning skill trigger: <session> → <skill>` line under
657
- the `Top-level agents` table for any session that got there through a skill. The system-prompt
658
- cheat sheet says the same, but only while the planning role actually has models behind it.
659
-
660
- **It is a routing aid, not enforcement.** It decides which *role* a top-level request is
661
- classified into, and nothing else. It cannot make a model think better, and under `hybrid` a model
662
- you hand-picked in the composer still serves the session: the report row shows role `planning`
663
- with reason `explicit session selection (respected)` and your route, exactly as it does in plan
664
- mode. There is no exit gesture — start a new session, or set `planningSkills: []`.
665
-
666
- ### The `/autoplan` skill
667
-
668
- `grilling` makes a session *think* on the planning tier; `/autoplan` makes it *think and then act*
669
- without a review step. It is a **bundled skill**: the plugin registers it as a DSH runtime skill
670
- through `ctx.skills.register` at startup, so installing the plugin is the whole install. Typing
671
- `/autoplan <task>` in a session injects its body exactly like `dsh-tool-skill` injects any other
672
- skill (the host recognises the `/name` gesture in direct user text, and the skill is
673
- `userInvocable`); a model can also load it through the `skill` tool when the user asks to
674
- plan-and-implement in one shot. The body ships as `skills/autoplan/SKILL.md`, read once at apply
675
- time.
676
-
677
- **The two phases use the two tiers, not a model swap mid-session:**
678
-
679
- | Phase | Who runs it | Which model |
680
- | --- | --- | --- |
681
- | Plan | one `subagent_fork` the top-level agent dispatches, description `plan: design the implementation plan for <task>` | the `planning` role — the `plan:` label is the existing contract |
682
- | Implement | the top-level session itself (or plain execution-tier units, per the delegation policy) | the `main` role |
683
-
684
- The fork inherits the conversation, so the planner starts with every fact the main model already
685
- gathered; it returns a decision-complete plan (goal, success criteria, changes by subsystem,
686
- edge cases, tests, assumptions). The main model then implements it and reports what changed,
687
- what it ran, and which assumptions it made on the user's behalf. The skill explicitly forbids
688
- the things that would turn this into an approval flow: no `ask_user_question` to approve the
689
- plan, no entering or exiting plan mode, no waiting. `autoplan` is deliberately **not** in
690
- `strategy.planningSkills` — that list pins the whole session to the planning tier, while here the
691
- top level must end up on `main` to implement.
692
-
693
- **Why not switch the session's own model?** That was the other design: escalate the session to
694
- `planning` on the gesture, then demote it when the plan is done. It needs a phase state machine,
695
- a durable projection to survive restart, and a demotion trigger the manager cannot actually
696
- observe — it would depend on the model remembering to call a marker tool, and a model that
697
- forgets it leaves the whole session stuck on the expensive tier. Routing on the delegation label
698
- already switches models per unit, and a fork carries the full conversation, so the two-phase
699
- workflow needs no new state at all.
700
-
701
- **Boundaries.** `/autoplan` skips *plan review*, not safety: approval prompts for risky
702
- operations, sandbox limits and destructive-operation confirmations still apply, and the body says
703
- so. Inside plan mode the plan-mode rules win — there the plan still goes through `exit_plan_mode`.
704
- If the planning role has no models, the `plan:` unit simply keeps the inherited route and the flow
705
- still runs. If `subagent_fork` is not in scope, the body falls back to plain `subagent` with a
706
- self-contained prompt.
707
-
708
- **Overrides and degradation.** The built-in copy is a runtime skill at DSH's runtime rank (250):
709
- a project-level `.dsh/skills/autoplan/SKILL.md` (rank 100) or `.agents/skills/autoplan/` (200)
710
- overrides it, but a `~/.dsh/skills/autoplan/` copy (rank 400) does **not** — that precedence is
711
- DSH's, and it is the one surprising part of customising this skill. Registration is optional and
712
- never load-bearing: no skills service in the composition, a throwing `register()`, or a missing or
713
- malformed `SKILL.md` all degrade to a logged warning, and `model_manager(action: "routes")` prints
714
- an `Autoplan skill: registered` / `not registered (…)` line so you can tell which case you are in.
715
- Registering the skill is not routing: it happens even with `enabled: false`, where only the model
716
- switch stops.
717
-
718
- ### The `/readimage` command
719
-
720
- `/readimage` puts **one message** on the `vision` tier — the 图像识别 role — and only that message's
721
- turn. It is the plugin's first **real slash command**: registered through the harness's `commands`
722
- service, the same service `/plan` and `/compact` come from, declaring
723
- `input: { hint: 'question about the attached image(s)', attachments: true }`, so it appears in the
724
- composer's command autocomplete and can carry attachments. Registration needs only a composition
725
- with a `commands` service and is independent of the model catalog; like the `/autoplan` skill, it is
726
- not routing, so it happens even with `enabled: false`. The refusals live in the handler: with the
727
- manager disabled, or with the vision role resolving to no models, the command returns a clear error
728
- result instead of forwarding anything.
729
-
730
- **Why a command and not a plain gesture.** On DSH 0.2.x the harness rejects image attachments at
731
- prompt admission with `MODEL_DOES_NOT_SUPPORT_IMAGES` when the currently selected model declares
732
- text-only input — *before* any plugin routing hook runs. A `/readimage` gesture typed as ordinary
733
- text could therefore never carry an image past that gate while a text-only model is selected: the
734
- message is refused before the manager could route it to a model that accepts images. The command
735
- path admits attachments without the gate. The handler then forwards the original line — the
736
- `/readimage` token included — plus the admitted image/file blocks as an ordinary user message
737
- through `agent.followup()`, which queues a normal turn. That turn is routed by the same seams as any
738
- other message; the token in the forwarded text is what names the intent. Bare `/readimage` with no
739
- text and no attachments returns a usage error; bare `/readimage` with attachments forwards the token
740
- plus the images.
741
-
742
- **One turn, not one session.** This is the opposite of a [planning skill](#planning-skills): a skill
743
- escalates the session for the rest of its life because its instructions stay in context, while
744
- `/readimage` is per-message intent — the image is in *this* message, and the next message is ordinary
745
- work again. The override is keyed to the **turn number** at the `agent/inbox/claimed` boundary — the
746
- same seam where the 0.2.x selection reads the planning-skill gesture (see
747
- [Switching models on DSH 0.2.x](#switching-models-on-dsh-02x)) — and maintained by `agent/pre-step`:
748
-
749
- - Every step of the commanded turn runs on `vision`, tool-loop steps included, so the model that
750
- sees the image keeps working with it.
751
- - The next turn that claims a message without the gesture returns to normal routing: `main`, or
752
- `planning` when plan mode or a planning skill is in force.
753
- - A mid-turn steering message without the gesture does **not** cancel the override — it belongs to
754
- the same turn.
755
- - The override is process-live only. Nothing is folded into the durable log, so after a restart the
756
- next message routes normally; only a fresh gesture commands a fresh turn.
757
- - Subagent sessions are unaffected: a child's routing stays label-driven.
758
-
759
- A short session:
127
+ `enabled: false` makes the whole manager observe-only regardless of mode. Under `hybrid`, pass nothing and the role decides; pass an explicit `provider`/`model` to the delegation tool and your choice survives.
760
128
 
761
- ```text
762
- you: /readimage what does this dashboard show? [screenshot attached]
763
- → the whole turn runs on the vision role, tool-loop steps included
764
- you: now fix the chart colours
765
- → back on main (or planning, if plan mode or a planning skill is in force)
766
- ```
129
+ **A composer pick is not a routing lock.** Whenever the active role has an automatic route, that
130
+ route applies whether the session is on the deployment default or on a model picked in the main
131
+ UI; if the role has no route, the current/composer route remains the fallback. The only lasting
132
+ user-level override is a [message-authored pin](#message-authored-model-pins).
767
133
 
768
- **Precedence.** For its turn, `/readimage` outranks plan mode *and* planning skills
769
- (`grilling` / `grill-me`): it is the most recent explicit instruction, and it names the tier for
770
- exactly one message. Plan-mode tool restrictions still apply — they are composition-level, and only
771
- the model changes. After the commanded turn the session returns to whatever state it was in: plan
772
- mode, an active planning skill, or `main`.
773
-
774
- **A hand-picked composer model yields for the turn, then comes back.** Under `hybrid` a model you
775
- picked in the composer normally wins (see [`main` and the composer's model
776
- picker](#main-and-the-composers-model-picker)). `/readimage` is an explicit, newer user instruction,
777
- so it forces the vision route even over that pick — for the one turn. The pick is remembered, and
778
- when the override ends the manager selects it back, so `hybrid` keeps respecting it on every later
779
- turn. If you pick a *different* model in the composer after the commanded turn, that newer pick
780
- wins over the remembered one — the restore hands back your latest choice, never a stale memory. On
781
- the legacy DSH 0.1.x request-rewrite path nothing is durably selected in the first place, so
782
- the pick survives automatically.
783
-
784
- **Failover and diagnostics.** The commanded turn's role is recorded as `vision`, so in-step failover
785
- walks the vision role's own chain — and the [image-capability warning](#vision-image-capability-check)
786
- about text-only models in that chain still applies. The turn resolves the vision role the same way
787
- any vision request does, including the [vision → execution fallback](#the-vision--execution-fallback)
788
- when `vision` is empty. `model_manager(action: "report")` names the trigger `command:readimage` for
789
- top-level turns routed this way, and `model_manager(action: "routes")` prints a line describing the
790
- command — or saying it is disabled.
791
-
792
- **The gesture works in plain text too.** The same word-boundary grammar that recognizes skill
793
- gestures recognizes `/readimage` anywhere in a direct user message, so a text-only message carrying
794
- the token routes to vision even when the command path was not used. Images still require the command
795
- path: the admission gate above refuses them on the ordinary prompt path while a text-only model is
796
- selected. The system-prompt cheat sheet gains one line telling the agent that you can type
797
- `/readimage` to put one message on the vision tier.
798
-
799
- The command name is configurable — `strategy.readImageCommand`, default `'readimage'`; an explicit
800
- `''` disables both the command and the gesture. See [Configuration](#configuration).
801
-
802
- ### Switching models on DSH 0.2.x
803
-
804
- DSH 0.2 moved model selection out of the request waterfall. The loop reads
805
- `agent.model.current()` at the start of step preparation and fixes
806
- provider/model/reasoningEffort for that step; an `agent/request` listener that proposes another
807
- route now **aborts the turn** with
808
- `agent/request proposed "…" after step preparation fixed "…"; use agent.model.select() before step
809
- preparation`. 0.6.1 follows the new contract while keeping the 0.1.x path:
810
-
811
- | Harness | How a route is applied | `agent/request` |
812
- | --- | --- | --- |
813
- | 0.1.x (no `agent.model.select`) | the manager rewrites the proposed route | routing |
814
- | 0.2.x (`agent.model.select` present) | `agent.model.select()` **before** the step is prepared | observe-only |
815
-
816
- On 0.2.x the selection is made at `agent/inbox/claimed`, which is the one moment that beats the
817
- fix without fighting it: the loop claims a step's input and only then reads the model, and the
818
- claim notifications are emitted outside the session append being published — a selection made
819
- there is accepted and lands on the request that is about to run. (A `session/event` listener
820
- cannot do this: it runs inside the append, where a nested append is refused as reentrant.) A
821
- second selection at `agent/pre-step` keeps later steps correct — plan mode toggled mid-turn, a
822
- skill invoked on a later step, a child whose label was not yet known — at the price of landing on
823
- the *next* step, which is the best any pre-step hook can do.
824
-
825
- Consequences worth knowing:
826
-
827
- - **A hand-picked model still wins under `hybrid`.** A route is the manager's own when it
828
- selected it (`managerSelected`), and the deployment default when it equals the agent's creation
829
- options; anything else is a recorded choice and is respected. Ownership is in-process, so after
830
- a restart a session whose route the manager had selected reads as hand-picked and is left alone
831
- until a turn actually routes it again — `managed` overrides it as always.
832
- - **Failover cannot retry the same step on another model.** The step's route is fixed, so a
833
- failure advances the role's cursor, selects the next model for the next request, and the failing
834
- step ends instead of retrying a model already known to be down. The log says so; on 0.1.x the
835
- old same-step retry is unchanged.
836
- - **`routes` reports the transport** on its `Routing transport:` line — `agent.model.select()
837
- before step preparation (DSH ≥ 0.2)` or `agent/request route rewrite (DSH 0.1.x)` — read from
838
- the live agents, so it states what the running composition is actually doing.
839
-
840
- ### The vision → execution fallback
841
-
842
- If `vision.models` is empty when a vision request is routed, the plugin serves it from the
843
- execution role's models instead. The role recorded for that request is still `vision`;
844
- the model is the execution role's, and the shared `pick` strategy with the execution
845
- role's `round-robin` counter are the ones used. The `routes` table marks such a role `(via execution)`. If
846
- `execution` is empty as well, there is no route and the request passes through. This is
847
- why the bundled default (`vision: []`) is safe: vision work is served by the execution
848
- tier until you configure a dedicated vision model.
849
-
850
- ### Vision image capability check
851
-
852
- A text-only model cannot serve image work: the harness rejects image blocks on requests to
853
- a model that does not declare image input. Because the vision role has a fallback and can
854
- name any provider, `routes` verifies the models it will actually use, through
855
- `ctx.get('llm')` → `resolveModelInfo(provider, model)` → `inputModalities`. The check
856
- follows the **effective** vision route, so with the bundled default it audits the execution
857
- model the fallback would use.
858
-
859
- | Verdict | Condition | Detail text |
860
- | --- | --- | --- |
861
- | `ok` | `inputModalities` includes `image` | `accepts images` |
862
- | `NO IMAGES` | `inputModalities` present without `image` | `declares <modalities> — image work routed here will fail` |
863
- | `unknown` | no `inputModalities` on the resolved info (absent means unknown) | `image support not declared` |
864
- | `unresolved` | `resolveModelInfo` threw | `could not resolve (<error message>)` |
134
+ **Subagent inheritance** (the `hybrid` gate) — three rules, all comparisons by value:
865
135
 
866
- ```text
867
- Vision role (image capability):
868
- ok pku-corpus/kimi-k3 — accepts images
869
- NO IMAGES pku-corpus/qwen3.8-flash — declares text — image work routed here will fail
870
- unknown pku-corpus/mystery — image support not declared
871
- unresolved pku-corpus/broken — could not resolve (no adapter registered for provider "pku-corpus")
872
- ```
136
+ - **Manager-owned.** The child's route equals the route the manager last applied to it, so a
137
+ long-running child stays managed even after its parent goes away. An explicit choice is never
138
+ re-adopted (`advisory`, respected-explicit and passthrough record no ownership).
139
+ - **Parent's effective route.** The parent's latest request header owns `provider`/`model`
140
+ (creation options are only the pre-first-request fallback), mirroring DSH's own
141
+ `parentAgentOptionsForDelegation`. A child whose resolved route differs is an explicit choice
142
+ and is respected.
143
+ - **Unresolvable lineage fails closed.** No provable parent and not manager-owned → the child
144
+ keeps its own route (`lineage unresolved (child route respected)`). Use `managed` to route
145
+ regardless of lineage.
873
146
 
874
- The check reports three distinct states on purpose, and they are never conflated.
147
+ A `round-robin` advance is committed **only when a route is actually applied**; advisory passes
148
+ and both kinds of respected route leave the rotation where it was.
875
149
 
876
- **Checked** — the block above. With the bundled default (no dedicated vision model) it
877
- audits the execution model the fallback would use:
150
+ **Selection strategy** (`pick`) is one top-level value for every role: `first` (default) treats each list as a failover chain; `round-robin` rotates across it. The failover cursor is tracked per **(session, role)**, so one tier's wear never pushes another tier off its first model. Rotation counters are per-role and per-process (reset on restart); routing is per LLM request, so a `round-robin` role can rotate between the steps of one turn.
878
151
 
879
- ```text
880
- Vision role (image capability):
881
- NO IMAGES pku-corpus/qwen3.8-flash — declares text — image work routed here will fail
882
- ```
152
+ **Failover** (`agent/request-error`): downstream recovery (same-model retry, compaction, image offload) is asked first and stays authoritative; only when all decline does the manager advance the role's cursor — on provider failures (`SERVER`, `RATE_LIMIT`, `TIMEOUT`, `AUTH`, `QUOTA`, `HTTP_5xx`, …), never on `ABORTED`, `INVALID_REQUEST` or `IMAGE_OFFLOAD_REQUIRED`. At most 3 switches per step; under `first` the chain walks to its end and stops (no wrap), `round-robin` wraps; a pinned attempt suppresses failover entirely.
883
153
 
884
- **Nothing to check** — no effective vision route, i.e. `vision` *and* `execution` are both
885
- empty. Image-labelled children then keep their parent's route:
154
+ **DSH 0.2 selection contract.** 0.2 fixes provider/model/reasoningEffort at step preparation and aborts a turn whose `agent/request` proposes another route, so the manager selects with `agent.model.select()` at `agent/inbox/claimed` (before the first step) and corrects later steps at `agent/pre-step`; `agent/request` is observe-only. On 0.1.x (no selection surface) it rewrites the request as before. On 0.2.x a failure advances the cursor and selects the next model for the *next* request — the failing step ends rather than retrying a known-down model; 0.1.x keeps the same-step retry. `routes` reports the live transport on its `Routing transport:` line.
886
155
 
887
- ```text
888
- Vision role: no route configured, so image-labelled delegations have no dedicated model
889
- and will simply inherit the delegating parent's route.
890
- ```
156
+ **Vision → execution fallback.** With `vision.models` empty, vision requests are served from the execution role's models (role still recorded `vision`, using execution's rotation counter); `routes` marks the role `(via execution)`, and passes through if execution is empty too. `routes` also audits the effective vision route's image capability through the `llm` service (`ok` / `NO IMAGES` / `unknown` / `unresolved`); boot warns only for `NO IMAGES`.
891
157
 
892
- **Not checked** — no `llm` service in this composition:
158
+ **Safety.** Neither half may break the harness: the schema dependency is guarded (missing → routing still works), every optional service is probed and wrapped, `apply` has a backstop that degrades routing instead of failing startup, a bad live edit keeps the previous config, unknown keys are logged not ignored, and `model_manager` is read-only.
893
159
 
894
- ```text
895
- Vision role: not checked (no llm service in this composition).
896
- ```
160
+ ## Message-authored model pins
897
161
 
898
- At boot the plugin runs the same check once and warns only for the `NO IMAGES` case, since
899
- that is the one that fails at run time:
162
+ A direct user message can pin a role to a model for the **whole session**, in Chinese or English:
900
163
 
901
164
  ```text
902
- warn [model-manager] vision role route(s) declare no image input and image work routed to them will fail: pku-corpus/qwen3.8-flash. Point roles.vision.models at an image-capable model.
165
+ 这个任务的主模型请使用@kimi-k3.1-pro来执行,理解模型用@glm-5.3-prime来执行
166
+ Use @kimi-k3.1-pro as the main model and @glm-5.3-prime as the understanding model.
167
+ Set the main model to @kimi-k3.1-pro and the planning model to @glm-5.3-prime.
903
168
  ```
904
169
 
905
- `unknown` and `unresolved` are reported by `routes` but not warned about: a model with
906
- undeclared modalities may well accept images, and an unresolvable route is already reported
907
- by the allow-list audit.
908
-
909
- ## Auto-delegation policy (`strategy.autoDelegate`)
170
+ | Role | Accepted aliases (case-insensitive for English) |
171
+ | --- | --- |
172
+ | `main` | `主模型`, `主要模型`, `main model` |
173
+ | `planning` | `理解模型`, `规划模型`, `规划与推理`, `推理模型`, `planning [model]`, `reasoning [model]`, `understanding model` |
174
+ | `execution` | `执行模型`, `execution [model]` |
175
+ | `vision` | `视觉模型`, `图像模型`, `图像识别模型`, `vision [model]`, `image model` |
176
+
177
+ The grammar requires **role + an assignment verb + `@model`** (a colon also works). Both
178
+ role-first (`主模型请使用@x`, `set the main model to @x`, `main model: @x`) and English
179
+ mention-first (`use @x as the main model`) forms work. Fenced/inline code, non-user sources,
180
+ negated assignments (`不`/`别`/`not`/`don't`) and ordinary `@file` references create no pins. Only
181
+ the top-level human's messages are authoritative — a model-authored delegation brief cannot pin
182
+ its own session. Children inherit the parent's active pins, including a pin that overrides an
183
+ explicitly delegated route.
184
+
185
+ **Scope is the whole session.** A later `请保持之前模型指定规则` / `Keep the previous model
186
+ assignments.` changes nothing. A new directive replaces only that role; unspecified roles stay
187
+ automatic. `主模型恢复自动分配`, `Main model: clear the pin`, or `Return to automatic routing for
188
+ all models.` clears the corresponding pin(s). Raw directives (not a temporarily resolved provider)
189
+ are folded into the `modelManagerDirectives` projection, so restart, resume and fork replay
190
+ reconstruct the same intent.
191
+
192
+ A valid pin bypasses the composer and subagent-route vetoes and **never consumes round-robin or
193
+ advances a failover cursor**. A provider failure on a pinned attempt produces no manager retry;
194
+ downstream same-model retry and compaction stay authoritative. Other roles keep normal
195
+ rotation/failover. Clearing a pin restores the role's next unused automatic route.
196
+
197
+ **Resolution.** Bare `@model` ids are exact and case-sensitive and must resolve to one provider;
198
+ duplicate ids are ambiguous and the manager never picks the first. Use `@provider/model` to
199
+ disambiguate or to name an exact route while discovery is cold (everything after the first slash
200
+ belongs to the model id). Unknown, incomplete and ambiguous resolutions preserve the current
201
+ route, suppress manager failover for that role, and emit an actionable warning rather than
202
+ guessing. Role-configured routes are deterministic hints while the async catalog warms; catalog
203
+ refreshes follow `llm/adapters-updated` and `llm/models-updated`. On DSH 0.2 the directive is
204
+ parsed at `agent/inbox/claimed`, before `model.current()` fixes the first request; the pre-step
205
+ observer is the 0.1.x fallback and covers a missed claim. `report` and `routes` list active pins
206
+ and their resolved routes.
207
+
208
+ **Pins compose with the one-turn commands.** The commands choose the *role* for their turn; a pin
209
+ chooses the *model* within it. A pinned vision role supplies the pinned model to a `/readimage`
210
+ turn; a `/quicktask` turn leaves a `main` pin untouched (the next plain turn returns to it). An
211
+ unpinned commanded turn walks its role's failover chain; a pinned one keeps the suppression.
212
+
213
+ **Harness caveat.** The composer's picker also overwrites the *deployment default*
214
+ (`selectModel` calls `selectForNextRequest` and `agentDefaultModel.saveSelection`), so picking a
215
+ model for one session changes what brand-new sessions start on. That is DSH's behavior, not a
216
+ model-manager pin.
217
+
218
+ ## One-turn commands
219
+
220
+ `/readimage` and `/quicktask` put **one message's turn** on a role, then expire. They are real
221
+ slash commands registered through the harness's `commands` service (the same service `/plan`
222
+ comes from), so they appear in the composer's command autocomplete.
223
+
224
+ ### Shared contract
225
+
226
+ - The override is keyed to the **turn number** at `agent/inbox/claimed` and maintained by
227
+ `agent/pre-step`: every step of the commanded turn runs on the role, tool-loop steps included.
228
+ - A mid-turn steering message without the gesture does **not** cancel it (same turn). The next
229
+ turn that claims a message without the gesture returns to normal routing.
230
+ - **Process-live only.** Nothing is folded into the durable log; after a restart the next message
231
+ routes normally. Type the gesture again to command a fresh turn.
232
+ - For its turn the command **outranks plan mode and planning skills** (the most recent explicit
233
+ instruction). Plan-mode tool restrictions still apply — only the model changes.
234
+ - Subagent sessions are unaffected; a child's routing stays label-driven.
235
+ - At the end of the turn the manager **hands back the composer pick** remembered before the
236
+ override — a UI courtesy, not a routing veto: the next plain turn routes by role again. A pick
237
+ made *after* (or between) commanded turns is newer and is handed back instead, never clobbered
238
+ by a stale memory; consecutive commanded turns keep the original restore. On the 0.1.x rewrite
239
+ path nothing was durably selected, so the hand-back is a no-op.
240
+ - A command whose role resolves to **no models is inert everywhere**: the handler refuses, the
241
+ cheat sheet stays quiet, and the plain-text gesture does not bind.
242
+
243
+ ### /readimage
244
+
245
+ Puts the turn on `vision` (the 图像识别 role). Registered with `input: { hint: 'question about the
246
+ attached image(s)', attachments: true }`. **Why a command and not a plain gesture:** on DSH 0.2.x
247
+ the harness rejects image attachments at prompt admission with `MODEL_DOES_NOT_SUPPORT_IMAGES`
248
+ when the selected model is text-only — *before* any routing hook runs. The command path admits
249
+ attachments without that gate; the handler forwards the original line (the `/readimage` token
250
+ included) plus the admitted image/file blocks as an ordinary user message via `agent.followup()`,
251
+ and the token in the forwarded text names the intent at the claim boundary. Bare `/readimage`
252
+ with no text and no attachments returns a usage error; with attachments it forwards the token
253
+ plus the images. The plain-text gesture also routes a text-only message carrying the token, but
254
+ images still require the command path. Failover walks the vision chain (with the vision →
255
+ execution fallback when vision is empty); `report` names the trigger `command:readimage`.
256
+
257
+ ### /quicktask
258
+
259
+ Puts the turn on `execution` (the 执行 role) — the cheap end, for the request that does not
260
+ deserve the main model ("rename this variable", "what does this error mean"). What differs:
261
+
262
+ - **Text only, on purpose.** No attachment support is declared; the executor refuses an
263
+ invocation carrying attachments before dispatch, and the handler defends the same contract
264
+ defensively. An image belongs to `/readimage`.
265
+ - **No admission gate to bypass.** It forwards plain text, so the registration is mostly
266
+ convenience (palette, hint); a plain-text `/quicktask` gesture routes identically.
267
+ - **Failover walks the execution chain**; there is no fallback below execution (it *is* the
268
+ fallback).
269
+ - **Two tokens, one message:** a message carrying both `/readimage` and `/quicktask` binds
270
+ `/readimage` — the image is physically present and only a vision-capable model can serve it.
271
+ - **Name collisions are first-wins.** The registry only shadows a duplicate name, so the manager
272
+ resolves a config pointing both commands at one name itself: the earlier command (read-image)
273
+ keeps the name, the later is skipped with a warning.
274
+
275
+ `report` names the trigger `command:quicktask` and prints a `Quick-task command:` block; `routes`
276
+ prints a line per command (or says it is disabled / not registered).
277
+
278
+ **Configuration.** `strategy.readImageCommand` (default `'readimage'`) and
279
+ `strategy.quickTaskCommand` (default `'quicktask'`); an explicit `''` disables both the command
280
+ and the gesture. Names are trimmed, lowercased, and must be kebab-case starting with a letter
281
+ (`[a-z][a-z0-9]*(-[a-z0-9]+)*`); an invalid name warns and disables the feature. A Settings save
282
+ re-registers the command under the new name immediately. Both register even with `enabled: false`
283
+ (only the model switch stops); the refusals live in the handler.
284
+
285
+ ## Planning skills and /autoplan
910
286
 
911
- **The problem it solves.** The harness gives the top-level agent a `subagent` tool and a
912
- one-line nudge ("Start independent delegations together in one message"), but nothing tells
913
- it *when* to delegate. In practice the model does the work itself and only reaches for a
914
- delegation when it cannot proceed — image reading being the canonical case. This plugin is
915
- already in the business of routing delegations by role; 0.3.0 makes it also *ask* for them.
287
+ `strategy.planningSkills` (default `['grill-me', 'grilling']`) is the user-facing half of the
288
+ planning tier: plan mode is the harness declaring thinking work, a skill invocation is the user
289
+ declaring the same. Both names ship because `grill-me` is the alias a person types and `grilling`
290
+ is the skill it loads. A subagent is never escalated by a skill.
291
+
292
+ **Three signals count**, each committed before the request it influences: the injected
293
+ `skill-invocation` message, a `/name` gesture in direct user text (both read by the durable fold
294
+ *and* a prepended `agent/pre-step` observer, so the first request of the turn is covered), and a
295
+ model-invoked `skill` `tool/call` (durable fold only — escalates the *next* request). Recognition
296
+ uses the harness's own grammar, byte-identical to `dsh-tool-skill`: a kebab-case name and a
297
+ `/name` standing alone between whitespace, so prose "grill me on this" matches nothing while the
298
+ `skill` call the model then makes does, one request later.
299
+
300
+ The durable projection `modelManagerPlanningSkill` stores *every* skill the session invoked;
301
+ membership is checked against the **live** config on every request, so adding a name reaches a
302
+ session that invoked it an hour ago and `[]` switches the trigger off without a restart. The
303
+ trigger is **sticky for the rest of the session** (the skill's instructions stay in context);
304
+ there is no exit gesture — start a new session or set `planningSkills: []`. Plan mode is consulted
305
+ first (trigger `plan-mode`). Entries are trimmed, lowercased, de-duplicated, and non-kebab names
306
+ dropped; an absent/non-list value uses the defaults, an explicit `[]` (or all-invalid list)
307
+ disables. It is a routing aid, not enforcement: a composer pick does not veto the planning route,
308
+ and a `planning` message pin takes precedence. Diagnostics: one log line per switch, a
309
+ `Planning skills:` line in `routes`, and `Planning skill trigger: <session> → <skill>` in `report`.
310
+
311
+ **`/autoplan`** is a bundled skill (registered via `ctx.skills.register` at startup; body
312
+ `skills/autoplan/SKILL.md`, read at apply time). Typing `/autoplan <task>` injects its body like
313
+ any skill; a model can also load it through the `skill` tool. It turns the two tiers into a
314
+ workflow: one `subagent_fork` labelled `plan: design the implementation plan for <task>` designs a
315
+ decision-complete, dispatch-ready unit list on the **planning** role (the fork inherits the whole
316
+ conversation), then the top level dispatches the independent units together as **execution**-tier
317
+ delegations and integrates/verifies on **main** — no approval gate, no `ask_user_question` to
318
+ approve, no plan mode, no waiting. `autoplan` is deliberately **not** in `planningSkills` (the top
319
+ level must end on `main`). Boundaries: safety prompts/sandbox limits still apply; inside plan mode
320
+ the plan-mode rules win; with no planning models the `plan:` unit keeps the inherited route; with
321
+ no `subagent_fork` in scope it falls back to plain `subagent`. Override precedence is DSH's: a
322
+ project `.dsh/skills/autoplan/` (rank 100) or `.agents/skills/autoplan/` (200) overrides the
323
+ bundled runtime copy (250), but `~/.dsh/skills/autoplan/` (400) does **not**. Registration is
324
+ optional and degrades to a logged warning; `routes` prints `Autoplan skill: registered` / `not
325
+ registered (…)`. It registers even with `enabled: false`.
326
+
327
+ ## Auto-delegation policy
916
328
 
917
329
  `strategy.autoDelegate` controls a second system-prompt section, `model-manager:delegation`
918
- (order 550 — next to the harness's own `PLAN_POLICY`/`TEAM_POLICY` rows, not next to the
919
- routing cheat sheet, because this is a behavioural policy rather than a routing fact):
330
+ (order 550, beside the harness's behavioural policy rows):
920
331
 
921
- | Level | Rendered for | What it tells the top-level agent |
922
- | --- | --- | --- |
923
- | `off` | nobody | Nothing — no section text at all. |
924
- | `balanced` (default) | the orchestrating top-level agent | Default to solving substantive work through subagents: delegate the decomposition itself as a `plan:` unit, dispatch the units it returned together in one message, keep coordination / trivial edits / user-facing decisions / final synthesis for yourself, verify what comes back. |
925
- | `eager` | the orchestrating top-level agent | You are the orchestrator: nearly all substantive work — research, analysis, implementation, review, verification — belongs in delegations, the decomposition itself going out as a `plan:` unit first; do work yourself only when no delegation can carry it. |
926
-
927
- Both levels end with the same labelling block, so the policy and the role tiers are used
928
- together — which is the point of having both in one plugin. The block labels each delegation
929
- by the *kind of work it carries* (`plan:` = must be thought through, `vision:` = reads images,
930
- plain = mechanical execution), states that a leading prefix decides the tier with keyword
931
- matching as the fallback, and — under any mode that actually routes — tells the agent to
932
- **omit `provider` and `model` on `plan:`/`vision:` units**, because a route named explicitly
933
- on the delegation overrides the tier. That last line is the one that makes the label matter
934
- under `hybrid`, where a respected explicit choice is exactly what defeats role routing.
935
-
936
- **Rendering is per assembly, and deliberately narrow.** The section's text function receives
937
- the assembly context (`{ agent, scope }`, the same object `dsh-agent`'s
938
- `assembleContextFor` builds) and returns `''` — no policy at all — unless every gate passes:
939
-
940
- - the manager is enabled and the level is not `off`;
941
- - the assembly is **not** a delegated child: `session.header.origin === 'subagent'` or
942
- `header.delegationDepth > 0` both disqualify. Children already carry the harness's fixed
943
- `subagent:delegation` runtime context, and encouraging a child to re-delegate would push
944
- every unit one depth level down for no benefit;
945
- - the assembly's scope **actually exposes a delegation tool**, checked with
946
- `tools.get('subagent', scope)` / `tools.get('subagent_fork', scope)` — the same probe
947
- `dsh-tool-subagent`'s own prompt section uses. An agent whose composition restricted the
948
- delegation tools never sees a policy naming a tool it cannot call, and a harness that
949
- renames the tool loses the policy rather than rendering a broken instruction.
950
-
951
- Beyond the gates, the labelling block adapts to what is actually behind it: a tier with no
952
- configured models is never advertised (no `plan:` line when the planning role is empty — and
953
- the balanced "plan first" bullet loses its label too), and under `advisory`, where nothing is
954
- routed at all, the omit-`provider`/`model` line is dropped because it would warn about
955
- nothing.
956
-
957
- Only the tools that resolve are named: with both present the policy mentions `subagent` and
958
- the `subagent_fork` preference for work that needs this conversation's context; with only
959
- `subagent` the fork line is dropped. `model_manager(action: "routes")` reports the level
960
- (`Auto-delegation: balanced — …`), and the settings card offers the three-way select, so
961
- switching levels needs no restart — the section reads the live config, so a saved edit
962
- applies to the next request.
963
-
964
- ## Automatic update checks
965
-
966
- The host half checks whether a newer `@darkbear9494/dsh-model-manager` is published, and
967
- tells you — passively in the log, on demand through the tool, and persistently in the Web UI.
968
-
969
- **How it works.** The plugin reads its own version from its `package.json` (so a git
970
- checkout, an npm install and a tarball install all report what actually shipped), fetches
971
- the abbreviated packument `<registry>/@darkbear9494%2fdsh-model-manager` with
972
- `Accept: application/vnd.npm.install-v1+json`, reads `dist-tags.latest`, and compares the
973
- two with a semver comparator that handles prereleases (`0.3.1-rc.1 < 0.3.1`, numeric
974
- prerelease identifiers compare numerically). The first check runs ~10 s after boot — never
975
- on the boot path — and then once per `intervalHours`; every failure path (no network,
976
- CORS, a malformed packument) lands in a logged diagnostic and a `CHECK FAILED` verdict,
977
- never a throw, and never touches routing.
978
-
979
- **Where a newer release is surfaced:**
980
-
981
- | Surface | What you see |
332
+ | Level | What it tells the top-level agent |
982
333
  | --- | --- |
983
- | Host log | `warn [model-manager] update available: @darkbear9494/dsh-model-manager 0.2.0 -> 0.3.0 (checked https://registry.npmjs.org). Run the model_manager tool with action "update" for the upgrade command, then restart.` |
984
- | `model_manager` action `update` | The full report below — including the paste-ready upgrade command with the live profile name. |
985
- | `report` / `routes` | One status line each (`Update check: 0.3.0 AVAILABLE (installed 0.2.0, …)`); `routes` always carries the line, `report` only when an update exists. |
986
- | Settings card | A warn-toned banner at the top of the card with the versions, the upgrade command, and a **Re-check** button. |
987
- | Session header | A small `更新:0.3.0` chip next to the usage button; clicking it discloses the upgrade command. It disappears when the store says up to date. |
334
+ | `off` | Nothing — no section text. |
335
+ | `balanced` (default) | Default to subagents for substantive work: 3+ files, 2+ independent areas, or 4+ tool calls → delegate the decomposition as a `plan:` unit and dispatch the returned units together; delegate a second independent area rather than editing it yourself; keep coordination, single-file edits, user-facing decisions and final synthesis; verify what comes back. |
336
+ | `eager` | You are the orchestrator: nearly all substantive work belongs in delegations, the decomposition going out as a `plan:` unit first; do work yourself only when no delegation can carry it. |
337
+
338
+ Both levels end with the same labelling block (`plan:` = thinking, `vision:` = images, plain =
339
+ execution; prefix decides, keywords fall back) and — under any mode that routes — tell the agent
340
+ to **omit `provider`/`model`** on tiered units, because an explicitly named route overrides the
341
+ tier under `hybrid`. Rendering is narrow: only an enabled, non-`off` manager, only a depth-0
342
+ top-level assembly (not a subagent), and only a scope that actually exposes `subagent` /
343
+ `subagent_fork` (probed with `tools.get`). A tier with no models is never advertised; under
344
+ `advisory` the omit line is dropped; only resolved tools are named (a fork-only scope keeps the
345
+ `subagent_fork` preference). `routes` reports the level; the card offers the three-way select;
346
+ the section reads live config, so a saved edit applies to the next request.
347
+
348
+ ## Seeing what ran
349
+
350
+ The Web UI already attributes each completed Turn to its provider/model (the **用量** button →
351
+ **本轮用量** dialog), shown only when Settings → General → Performance & usage is `detailed` (the
352
+ default) and every attempt reported exact usage — so a Turn where failover switched models hides
353
+ its usage row. There is no harness aggregate *by model for a whole session*; this plugin supplies
354
+ one as a **Model usage** button in the session header, folded from the durable log
355
+ (`modelManagerUsage`), so it survives restart and is identical after fork/resume/replay. Only
356
+ attempts with an exact usage sample and a provider/model on the committed message are counted.
357
+
358
+ The read-only `model_manager` tool has five actions:
988
359
 
989
- Asking for the check directly:
360
+ | Action | Returns |
361
+ | --- | --- |
362
+ | `report` (default) | A `Top-level agents` table (session, role, model, reason, live status, composer/default origin), active message pins, planning-skill and one-turn-command triggers, then the per-subagent table (child, role, model, reason, status, label) and subagent-only totals by role/model. Carries an update line only when a newer release exists. |
363
+ | `routes` | Role table (effective models, `note`), shared `pick`, mode, live directives with Chinese/English examples, auto-delegation level, planning-skill list, the one-turn commands, autoplan registration, routing transport, update status, the allow-list audit with YAML for unlisted routes, the vision image-capability check, and the first 8 keywords of each list. |
364
+ | `usage` | Request and subagent counts per role/model across the whole process, including top-level turns. |
365
+ | `client` | Whether the Host composed the Web client half into the browser boot graph, the bundle route, and the graph revision. Use it when the settings card does not appear. |
366
+ | `update` | Forces a fresh update check; installed vs latest, registry, timestamp, and the paste-ready upgrade command with the live profile name. |
990
367
 
991
- ```text
992
- model_manager(action: "update")
993
- ```
368
+ `report` and `usage` read **process-local** state; a restart clears them (a subagent that finished
369
+ before a restart reappears as `(not yet routed)`, role `?`). For restart-surviving history use the
370
+ per-session usage panel. Shortened `report` example (0.1.x request-rewrite path):
994
371
 
995
372
  ```text
996
- Model manager update check
373
+ Top-level agents — 1
997
374
 
998
- installed : 0.2.0
999
- latest : 0.3.0
1000
- registry : https://registry.npmjs.org
1001
- checked : 2026-10-07T03:12:44.612Z
1002
- verdict : UPDATE AVAILABLE (0.2.0 -> 0.3.0)
375
+ session role model reason status the session model was
376
+ ----------- --------- ------------------------------- ------------------------------------------- -------- --------------------------------
377
+ a1b2c3d4-e main pku-corpus/main-tier applied running composer pick; automatic routing still applies
1003
378
 
1004
- To upgrade, run in a terminal:
379
+ Subagent model report — 2 subagent(s)
1005
380
 
1006
- dsh plugin --profile desktop add @darkbear9494/dsh-model-manager@latest
381
+ child role model reason status label
382
+ ---------- --------- ------------------------------- ------------------------------------------- -------- --------------------
383
+ 7c1f0a92-a planning pku-corpus/qwen3.8-max-0902 applied running "plan: design the migration"
384
+ 925d4c6e-a execution pku-corpus/qwen3.8-flash applied running "fix the typo"
1007
385
 
1008
- then restart the harness so the new version mounts. The Plugins page can reinstall
1009
- the same package instead; both paths run the same installer. Tell the user this
1010
- upgrade is available and what command to run.
386
+ mode: hybrid
1011
387
  ```
1012
388
 
1013
- The `<profile>` in the command is read from the host's working directory
1014
- (`$DSH_HOME/profiles/<name>`); when the layout does not match, the command prints
1015
- `<profile>` as a placeholder. Upgrading is re-running the add command — the installer
1016
- (`dsh plugin add` / the GUI's `install_bundle`) resolves the new version, updates the
1017
- dependency and keeps the bundle registration; restart the harness afterwards so the new
1018
- host half mounts.
1019
-
1020
- **The browser half runs the same comparison itself.** The Web client cannot read the host's
1021
- in-memory state, so `client.js` pins the version it shipped with (a packaging test pins
1022
- that constant equal to `package.json`) and fetches the same packument once per page load —
1023
- plus on every `settings/document-updated` (the registry URL is row config, so a change
1024
- re-checks) and on the banner's Re-check button. That is why the chip and banner can appear
1025
- the moment the GUI opens. An offline or registry-blocked deployment simply sees no banner;
1026
- the host log and the tool action still report the update. This also means the browser makes
1027
- one cross-origin `fetch` to the configured registry — `registry.npmjs.org` (and npmmirror)
1028
- answer it with `Access-Control-Allow-Origin: *`; a registry that does not is silently
1029
- unusable for the client half and only the host surfaces remain.
389
+ The `reason` column is the outcome for that request:
390
+
391
+ | Reason | Meaning |
392
+ | --- | --- |
393
+ | `applied` | The role route was written into the request. |
394
+ | `applied (manager-owned)` | The child's route matched the manager's last applied route, so it stayed managed. |
395
+ | `message directive (pinned)` | A direct `@model` directive fixed this role for the session; rotation/failover suppressed. |
396
+ | `message directive unresolved` | The named model was unknown/ambiguous/unresolvable; current route preserved, nothing guessed. |
397
+ | `explicit child route (respected)` | `hybrid` found the child's route differed from the parent's effective route. |
398
+ | `lineage unresolved (child route respected)` | No provable parent and not manager-owned; the child kept its route. |
399
+ | `advisory (not applied)` | `advisory` classified but changed nothing. |
400
+ | `passthrough (role unconfigured)` | The role resolved to no route. |
401
+
402
+ On DSH 0.2.x the applied rows instead read `step route selected before preparation` / `step route
403
+ fixed by the session` (the request waterfall is observe-only there). A planning-skill escalation
404
+ adds no reason string; the skill is named on its own line under the table. The `status` column is
405
+ the harness's live status (`running`, `idle`, …), `live` when no status is exposed, `inactive`
406
+ when `agents.get` cannot resolve the child. Labels are flattened to one line, truncated at 42
407
+ characters, `"` shown as `'`; the `child`/`session` columns are 10-character id prefixes.
408
+
409
+ ## Update checks
410
+
411
+ The host reads its own version from `package.json`, fetches the abbreviated packument
412
+ `<registry>/@darkbear9494%2fdsh-model-manager`, reads `dist-tags.latest`, and compares with a
413
+ prerelease-aware semver comparator. The first check runs ~10 s after boot (never on the boot
414
+ path), then once per `intervalHours`; every failure lands in a logged diagnostic and a
415
+ `CHECK FAILED` verdict, never a throw, never touching routing. A newer release is surfaced in
416
+ four places: the host log (warn), the `model_manager` `update` action (full report + upgrade
417
+ command), a status line in `routes` (always) and `report` (only when available), the settings-card
418
+ banner, and a session-header `更新:<latest>` chip. The browser half runs the same comparison
419
+ itself (a pinned `VERSION` constant, fetched once per page load plus on `settings/document-updated`
420
+ and the banner's Re-check), so the chip can appear the moment the GUI opens; it needs the registry
421
+ to answer CORS (npmjs and npmmirror do). Upgrading is re-running the add command, then restarting.
422
+
423
+ Configuration: `update.enabled` (default `true`; only explicit `false` stops checks),
424
+ `update.registry` (default `https://registry.npmjs.org`; http(s) origin only, trailing slashes
425
+ trimmed, else fallback), `update.intervalHours` (default `24`; explicit `0` = boot only; fractions
426
+ allowed, floored at one minute; absent/malformed/negative → 24). A settings save that changes the
427
+ update block re-arms the schedule **and** runs one immediate check.
428
+
429
+ ## Settings card
430
+
431
+ The client half contributes one configuration card at **设置 → 模型管理器** (`settings.section`,
432
+ id `model-manager`) — nothing on the Plugins page — plus two read-only session-header surfaces:
433
+ the per-session usage panel (`model-manager-usage`) and the update chip (`model-manager-update`).
434
+ The card edits exactly `roles.<role>.models`, the top-level `pick`, `strategy.mode` and
435
+ `strategy.autoDelegate`, so the card and the YAML are two views of one config; it never edits
436
+ patch files, so a value pinned by a patch layer must be edited in the patch.
437
+
438
+ Every control writes on `change` (no Save button); the host re-reads config on
439
+ `loader/volatile-update`, so the next request uses the new value without a restart. Writes are
440
+ revision-fenced through the row's settings namespace, so a stale write cannot race the host.
441
+ Model rows are catalog-fed `<select>`s; a route the catalog stopped advertising stays selectable,
442
+ marked `(not in catalog)`, rather than being silently swapped. The effort picker appears only when
443
+ the selected model advertises reasoning efforts. When the card cannot show values (no form,
444
+ unavailable namespace, read-only deployment, catalog loading/empty/failed) it renders a notice
445
+ instead of blanking the slot. The card cannot tell you whether a model accepts images (the catalog
446
+ carries no modality field) — use `model_manager(action: "routes")` for that audit.
1030
447
 
1031
448
  ## Configuration
1032
449
 
1033
- Config is the `config` of the row id `model-manager`. This bundle ships a layer that
1034
- inserts it; a profile can override it by id, and the harness also presents it on the
1035
- Settings page — `roles` and `strategy` are declared `volatile`, so the form is
1036
- auto-generated from the schema and a saved edit is committed in place without a remount. The
1037
- [card on the Plugins page](#configure-in-the-ui) writes the same paths into the same
1038
- namespace, so the YAML below and the card are two views of one config; the patch remains the
1039
- declarative copy that ships with the package.
1040
-
1041
- **Saved Settings edits apply live.** The loader commits a volatile-only save and returns
1042
- *before* re-running `apply`, so the plugin listens on `loader/volatile-update` and
1043
- re-reads the config itself — including rebuilding the keyword matchers. A keyword or role
1044
- change saved on the Settings page — or from the [card on the Plugins
1045
- page](#configure-in-the-ui), which writes the same volatile namespace — takes effect on the
1046
- next request, with no restart. The
1047
- event logs `settings reloaded — mode …, pick …` on success; a value that cannot be re-read logs
1048
- `could not reload settings; routing keeps the previous config: …` and the previously
1049
- active config stays in force.
1050
-
1051
- Complete key set, with the schema defaults shown in comments:
450
+ Config is the `config` of row id `model-manager`. `roles`, `strategy`, `update`, `enabled` and
451
+ `pick` are declared `volatile`, so a saved Settings edit is committed in place and re-read on
452
+ `loader/volatile-update` (keyword matchers rebuilt) — effective on the next request, no restart.
453
+ A value that cannot be re-read logs `could not reload settings; routing keeps the previous
454
+ config: …` and the previous config stays in force. Complete key set (schema defaults in comments):
1052
455
 
1053
456
  ```yaml
1054
457
  - id: model-manager
1055
458
  config:
459
+ enabled: true # default: true; only an explicit false makes the manager observe-only
1056
460
  pick: first # default: first; "first" | "round-robin" — ONE strategy for every role
1057
461
  roles:
1058
462
  main:
1059
- models: [] # default: [] — empty means "leave the composer/model selection alone"
1060
- note: '' # default: none — optional free text, printed by `routes` under the role
463
+ models: [] # default: [] — empty leaves the composer/model selection alone
464
+ note: '' # default: none — free text, printed by `routes` under the role only
1061
465
  planning:
1062
- models: [] # schema default: [] (this package's own layer sets pku-corpus/qwen3.8-max-0902)
466
+ models: [] # schema default: [] (this package's layer sets pku-corpus/qwen3.8-max-0902)
1063
467
  execution:
1064
- models: [] # schema default: [] (this package's own layer sets pku-corpus/qwen3.8-flash)
468
+ models: [] # schema default: [] (this package's layer sets pku-corpus/qwen3.8-flash)
1065
469
  vision:
1066
470
  models: [] # schema default: [] — empty falls back to the execution role
1067
471
  strategy:
1068
- mode: hybrid # default: hybrid; "hybrid" | "managed" | "advisory"
1069
- # visionKeywords: omitted = the 20 built-ins; any list you write replaces them
1070
- # planningKeywords: omitted = the 24 built-ins; [] DISABLES that classifier
472
+ mode: hybrid # default: hybrid; "hybrid" | "managed" | "advisory" (unknown → hybrid)
473
+ # visionKeywords: omitted = the 19 built-ins; any list replaces them; [] DISABLES the classifier
474
+ # planningKeywords: omitted = the 24 built-ins; [] DISABLES the classifier
1071
475
  # planningSkills: omitted = ['grill-me', 'grilling']; [] DISABLES the trigger
1072
476
  readImageCommand: readimage # default: readimage; '' DISABLES the command and the text gesture
1073
- historyLimit: 300 # default: 300; any positive value floors to at least 1
1074
- autoDelegate: balanced # default: balanced; "off" | "balanced" | "eager" — the delegation policy
1075
- update: # 0.3.0 — automatic update check
477
+ quickTaskCommand: quicktask # default: quicktask; '' DISABLES the command and the text gesture
478
+ historyLimit: 300 # default: 300; any positive value floors to an integer, minimum 1
479
+ autoDelegate: balanced # default: balanced; "off" | "balanced" | "eager" (unknown → balanced)
480
+ update:
1076
481
  enabled: true # default: true; only an explicit false stops the checks
1077
482
  registry: https://registry.npmjs.org # any npm-compatible registry (npmmirror works)
1078
483
  intervalHours: 24 # default: 24; explicit 0 = check at boot only
1079
484
  ```
1080
485
 
1081
- The three lists are shown commented out because their default is a built-in list rather than a
1082
- literal value: omitting the key keeps the built-ins, while writing any list — including `[]` —
1083
- replaces them, and `[]` switches that classifier or trigger off entirely. `planningSkills` differs
1084
- in one way: its entries are normalized — trimmed, lowercased, de-duplicated, anything that is not
1085
- a kebab-case skill name dropped — so a list whose entries are all invalid is exactly the same as
1086
- `[]`. See [Planning skills](#planning-skills).
1087
-
1088
- Behaviours of the `update` block worth knowing:
1089
-
1090
- - `registry` must be an `http(s)` origin; anything else (or a non-string) falls back to
1091
- `https://registry.npmjs.org`. Trailing slashes are trimmed.
1092
- - `intervalHours` accepts a fraction (0.5 = 30 min, useful when watching a release land)
1093
- and is floored at one minute so a mis-typed hour cannot hammer a registry. An absent,
1094
- malformed or negative value means the 24 h default; an explicit `0` means "check at boot
1095
- only". `enabled: false` is the actual off switch.
1096
- - A settings save that changes the update block re-arms the schedule **and** runs one
1097
- immediate check, so switching to a mirror registry takes effect without a restart.
1098
-
1099
- Each entry of `models` is:
486
+ Each `models` entry:
1100
487
 
1101
488
  | Key | Required | Default | Meaning |
1102
489
  | --- | --- | --- | --- |
@@ -1104,326 +491,80 @@ Each entry of `models` is:
1104
491
  | `model` | yes | — | Model id, e.g. `qwen3.8-flash`. |
1105
492
  | `reasoningEffort` | no | none | Applied as the route's reasoning effort when the manager writes the route. |
1106
493
 
1107
- Behaviours of `readConfig` worth knowing:
1108
-
1109
- - A route missing `provider` or `model` is dropped rather than failing the plugin. A role
1110
- whose every route is invalid behaves exactly like an empty role.
1111
- - Unknown keys are reported rather than ignored, at three levels: the row, a role, and an
1112
- individual route. A route written with the snake_case alias is called out by name —
1113
- `unknown key "roles.planning.models[].reasoning_effort" ignored — the key is
1114
- "reasoningEffort"`.
1115
- - `strategy.planningSkills` normalizes differently from the keyword lists: entries are trimmed,
1116
- lowercased, de-duplicated and dropped when they are not kebab-case skill names, so an absent or
1117
- non-list value means the `['grill-me', 'grilling']` defaults while *any* list replaces them —
1118
- including one that normalizes down to empty, which is the disabled state. Membership is checked
1119
- against the live config on every request, so adding a skill and setting `[]` both take effect on
1120
- the next request with no restart.
1121
- - `strategy.readImageCommand` is one command name, not a list: omitting the key uses `'readimage'`,
1122
- and an explicit `''` disables the feature entirely — no command is registered and no gesture is
1123
- recognized. The name is trimmed and lowercased and must be kebab-case **starting with a letter**
1124
- (`[a-z][a-z0-9]*(-[a-z0-9]+)*`) — kebab-case because the `/name` gesture scanner requires it, a
1125
- leading letter because the command registry's own `COMMAND_NAME` does — so a name failing either
1126
- could never be invoked as a command; an invalid name logs a warning and disables the feature
1127
- instead of failing registration at boot. A Settings save re-registers
1128
- the command under the new name immediately. See [The `/readimage`
1129
- command](#the-readimage-command).
1130
- - `historyLimit` accepts any positive number, floored to an integer and raised to a
1131
- minimum of 1, so a fractional value cannot floor to 0 and silently disable usage
1132
- tracking. `0`, a negative number, a non-number or an absent key all mean 300.
1133
- - When the manager switches a request to a different route it **drops an inherited
1134
- reasoning effort** unless the role names one, because the destination model may not
1135
- accept the previous effort and `prepareCall` rejects unsupported explicit efforts
1136
- instead of clamping them.
1137
-
1138
- > A profile patch entry with an `id` and no `insert` replaces the target row's fields,
1139
- > and `config` is **replaced wholesale, never deep-merged**. An override that sets only
1140
- > `strategy.mode` therefore also drops every role route. Restate every key you want to
1141
- > keep.
1142
-
1143
- The bundled layer this package ships is:
1144
-
1145
- ```yaml
1146
- - insert:
1147
- - id: model-manager
1148
- name: '@darkbear9494/dsh-model-manager'
1149
- config:
1150
- roles:
1151
- main:
1152
- models: []
1153
- planning:
1154
- models:
1155
- - provider: pku-corpus
1156
- model: qwen3.8-max-0902
1157
- execution:
1158
- models:
1159
- - provider: pku-corpus
1160
- model: qwen3.8-flash
1161
- vision:
1162
- models: []
1163
- strategy:
1164
- mode: hybrid
1165
- autoDelegate: balanced
1166
- update:
1167
- enabled: true
1168
- registry: https://registry.npmjs.org
1169
- intervalHours: 24
1170
- ```
1171
-
1172
- ## Seeing which model each subagent used
1173
-
1174
- ### First: the harness already shows this per Turn
1175
-
1176
- Before reaching for the tool, note that the Web UI already attributes each completed Turn to
1177
- the exact provider/model that served it. On every completed Turn's footer there is a button
1178
- labelled **用量 {total}** ("Usage {total}", with a database icon); clicking it opens the
1179
- **本轮用量** ("Turn usage") dialog, whose rows are Uncached input, Output (with its reasoning
1180
- subset), Cached input, Cache write, Cache hit, and **Provider / model**.
1181
-
1182
- Two conditions decide whether it appears:
1183
-
1184
- - **Settings → General → Performance & usage** must be `detailed`, not `compact`. `detailed`
1185
- is the default. `compact` hides per-Turn usage entirely.
1186
- - Accounting is deliberately all-or-nothing. A Turn discloses usage only when the loaded
1187
- window includes `turn/start` and **every** started model attempt reported safe, exact
1188
- usage. The harness hides a partial total rather than showing a misleading one.
1189
-
1190
- That second rule interacts with this plugin's failover, and it is worth understanding before
1191
- filing it as a bug: a failed attempt settles as an `assistant/attempt` event, which carries no
1192
- token usage unless its stream reported some. `deriveTurnTokenUsage` then marks the whole Turn
1193
- invalid and discloses nothing. So **on a Turn where a model failed and the manager switched to
1194
- another, the usage row will be absent** — the accounting genuinely cannot prove an exact total
1195
- for that Turn. This is the harness's own rule and it applies equally to the harness's built-in
1196
- retries; failover simply produces such Turns more often.
1197
-
1198
- There is no per-model **aggregate for one whole session** in the harness itself: its session-level
1199
- projections (`tokenUsage`, `contextPressure`, `contextBreakdown`) accumulate four token buckets with
1200
- no route split. This plugin supplies exactly that, as a **Model usage** button in the session header.
1201
-
1202
- It is a session projection folded from the durable log (`modelManagerUsage`), not a live counter, so
1203
- the numbers survive a restart and are identical after fork, resume, and replay. Each row shows
1204
- provider/model, uncached input, output, cached input and cache write when reported, request count,
1205
- and a total. Only attempts carrying an exact usage sample **and** a provider/model on the committed
1206
- message are counted — the same refusal the per-Turn dialog makes, so the two never disagree about
1207
- which numbers are provable.
1208
-
1209
- Because the host half declares the projection and wires a view, the client half only subscribes to a
1210
- finished value: no folding in the browser, no polling, no fetch route. That is the sanctioned path —
1211
- *"a domain ships projection support with zero client code."*
1212
-
1213
- ### The tool
1214
-
1215
- The plugin registers one read-only tool, `model_manager`, with five actions:
1216
-
1217
- | Action | Returns |
1218
- | --- | --- |
1219
- | `report` (default) | A `Top-level agents` table — session id, role, model, reason, live status, and whether the session's model was picked by hand or left at the deployment default — then the per-subagent table: child id, role, model, reason, live status, delegation label, and finally the active mode with subagent-only totals by role/model. Under the top-level table it names any session that is on `planning` because of a planning skill (`Planning skill trigger: <session> → <skill>`). Carries one update-available line when a newer release was found. |
1220
- | `routes` | Role table (role, effective models, role `note`), the shared selection strategy, active mode, the auto-delegation level, the planning-skill list (`Planning skills: grill-me, grilling — …`, or `(disabled)`), the update-check status line, allow-list audit with a YAML snippet for unlisted routes, the vision image-capability check, and the first 8 keywords of each list. |
1221
- | `usage` | Request and subagent counts per role/model across the whole process, including top-level turns. |
1222
- | `client` | Whether the Host composed this package's Web client half into the browser boot graph, the route serving its bundle, and the current graph revision. Use it when the settings card does not appear. |
1223
- | `update` | Forces a fresh [update check](#automatic-update-checks) and returns installed vs latest, the registry, the timestamp, and — when a newer release exists — the paste-ready upgrade command with the live profile name. Use it whenever `report`/`routes` says an update is available, and relay the command to the user. |
1224
-
1225
- Both `report` and `usage` read **process-local in-memory state**: they answer for the current
1226
- `dsh` process only, and a restart clears them. A subagent that finished before a restart
1227
- therefore reappears as `(not yet routed)` with role `?`, because it was re-registered on resume
1228
- but issued no request in this process. For history that survives a restart, use the per-Turn
1229
- usage dialog described above — it is derived from the durable session log.
1230
-
1231
- Asking for the report:
1232
-
1233
- ```text
1234
- model_manager(action: "report")
1235
- ```
1236
-
1237
- Sample output, generated by running the real renderer against a mock harness instead of typed by
1238
- hand — a hand-typed example is exactly how this file shipped a misaligned table. The `session` and
1239
- `child` columns hold 10-character id prefixes:
494
+ `readConfig` behaviours worth knowing:
495
+
496
+ - A route missing `provider` or `model` is dropped, not fatal; a role whose every route is invalid
497
+ behaves like an empty role. Provider/model/effort strings are trimmed.
498
+ - Unknown keys are reported at three levels (row, role, route). A legacy per-role `pick` warns
499
+ that it moved to the top level in 0.2.0 and is ignored; the snake_case `reasoning_effort` alias
500
+ is called out by name with the correct key.
501
+ - The keyword lists: an absent key uses the built-ins, **any** list (including `[]`) replaces
502
+ them, and `[]` switches that classifier off. Entries are trimmed and empties dropped.
503
+ - `planningSkills` normalizes further (lowercased, de-duplicated, non-kebab dropped), so an
504
+ all-invalid list equals `[]`. Membership is checked against live config every request.
505
+ - `readImageCommand` / `quickTaskCommand`: absent/non-string → the default; `''` disables; an
506
+ invalid name warns and disables. If both resolve to one name, read-image keeps it (first-wins).
507
+ - `historyLimit`: any positive finite number floors to an integer ≥ 1; `0`, negative, non-number
508
+ or absent all mean 300.
509
+ - Switching a request to a different route **drops an inherited reasoning effort** unless the role
510
+ names one (the destination model may reject the previous effort; `prepareCall` does not clamp).
511
+ - A profile id override **replaces `config` wholesale** — restate every key you want to keep.
512
+
513
+ The built-in keyword lists (used when a list is absent):
1240
514
 
1241
515
  ```text
1242
- Top-level agents — 1
1243
-
1244
- session role model reason status the session model was
1245
- ----------- --------- ------------------------------- ------------------------------------------- -------- --------------------------------
1246
- a1b2c3d4-e main user-picked/glm-5.2 explicit session selection (respected) running picked by hand, so main yields
1247
-
1248
- A reason ending in (respected) is the verdict itself: a human choice won and the
1249
- manager stepped back. Under managed it never does, and a session that never had
1250
- a manual pick is rewritten by the main role.
1251
-
1252
- Subagent model report — 3 subagent(s)
1253
-
1254
- child role model reason status label
1255
- ---------- --------- ------------------------------- ------------------------------------------- -------- --------------------
1256
- 7c1f0a92-a planning pku-corpus/qwen3.8-max-0902 applied running "plan: design the migration"
1257
- 925d4c6e-a execution pku-corpus/deepseek-v4-flash-0731 applied running "fix the typo"
1258
- e0c7b551-a vision pku-corpus/kimi-k3 applied running "vision: read this screenshot"
1259
-
1260
- mode: hybrid
1261
-
1262
- Subagent requests by role/model:
1263
- 1 req / 1 subagent(s) execution pku-corpus/deepseek-v4-flash-0731
1264
- 1 req / 1 subagent(s) planning pku-corpus/qwen3.8-max-0902
1265
- 1 req / 1 subagent(s) vision pku-corpus/kimi-k3
1266
- ```
1267
-
1268
- Reading it:
1269
-
1270
- - `e0c7b551-e` is a `vision` row served by the first vision model; with `vision: []` it
1271
- would show the execution model instead. Role and model are reported independently.
1272
- - `925d4c6e-d` was dispatched with an explicit route, so `hybrid` left it alone.
1273
- - `b84e2d10-b` issued two requests. The first was routed by the manager; on the second the
1274
- child's own header already carried the applied route, so it reads
1275
- `applied (manager-owned)` rather than being mistaken for an explicit choice. Hence the
1276
- planning total of `3 req / 2 subagent(s)`.
1277
- - `0a1b2c3d-f` has no resolvable delegating parent and no manager-applied route, so
1278
- `hybrid` failed closed: the child kept the route it was given, and with it no label the
1279
- catalog could resolve.
1280
- - The totals are **subagent-only**, so the top-level turn this parent made is not counted
1281
- here. `usage` is the action that covers the whole process.
1282
-
1283
- The `status` column is the child's live status as the harness reports it (`running`,
1284
- `idle`, …), `live` when the harness exposes the agent without a status, and `inactive`
1285
- when `agents.get` cannot resolve the child — for example after it has gone away.
1286
-
1287
- The `reason` column is the outcome for that request:
1288
-
1289
- | Reason | Meaning |
1290
- | --- | --- |
1291
- | `applied` | The role route was written into the request. |
1292
- | `applied (manager-owned)` | The child's route matched what the manager last applied to it, so it stayed under management and the role route was written again. |
1293
- | `explicit session selection (respected)` | `hybrid`, top-level: the session log carries a `model/selection` event, so the model running is one a person chose in the composer. `main` is skipped and the rotation is not advanced. |
1294
- | `explicit child route (respected)` | `hybrid` found the child's resolved route differed from the parent's effective route, so it was treated as the delegating agent's own choice and left alone. |
1295
- | `lineage unresolved (child route respected)` | No delegating parent could be resolved and the child was not manager-owned, so inheritance was not provable and the child kept its route. |
1296
- | `advisory (not applied)` | `advisory` mode classified the request but changed nothing; the model shown is the one actually used. |
1297
- | `passthrough (role unconfigured)` | The role resolved to no route at all, so the request was returned unchanged. |
1298
-
1299
- A planning-skill escalation adds **no reason string**: the row reads exactly as it would in plan
1300
- mode — `applied`, or `explicit session selection (respected)` when a hand-picked composer model is
1301
- running — and the skill is named on its own line under the table,
1302
- `Planning skill trigger: <session> → <skill>`, which appears only for sessions that reached
1303
- `planning` through a skill.
1304
-
1305
- Verbatim example rows for the two reasons not shown above:
1306
-
1307
- ```text
1308
- 99aa11bb-0 execution pku-corpus/qwen3.8-max advisory (not applied) running "fix the typo"
1309
- 4d5e6f70-0 execution pku-corpus/qwen3.8-max passthrough (role unconfigured) running "fix the typo in README"
516
+ vision (19): vision, visual, image, images, screenshot, screen shot, ocr, diagram,
517
+ chart, plot, photo, picture, png, jpg, jpeg, webp, gif, ui mock, render
518
+ planning (24): plan, planning, design, architect, architecture, analyse, analyze,
519
+ analysis, research, investigate, review, critique, strategy, reasoning,
520
+ reason, compare, evaluate, assess, spec, specification, decompose,
521
+ breakdown, proposal, root cause
1310
522
  ```
1311
523
 
1312
- A subagent the catalog knows about but which has not issued a request yet shows
1313
- `(not yet routed)` in the model column and `-` as its reason. Labels are collapsed to a
1314
- single line, truncated at 42 characters, and any `"` in them is displayed as `'` so the
1315
- column can never be misread.
1316
-
1317
- `usage` counts every request the process recorded, including top-level turns — its header
1318
- says so, and a top-level bucket shows `0 subagent(s)`:
1319
-
1320
- ```text
1321
- Requests by role/model (whole process, including top-level turns)
1322
-
1323
- 1 req 1 subagent(s) execution pku-corpus/deepseek-v4-flash-0731
1324
- 1 req 1 subagent(s) execution pku-corpus/qwen3.8-flash
1325
- 1 req 1 subagent(s) execution pku-corpus/qwen3.8-max
1326
- 1 req 0 subagent(s) main pku-corpus/qwen3.8-max
1327
- 3 req 2 subagent(s) planning pku-corpus/qwen3.8-max-0902
1328
- 1 req 1 subagent(s) vision pku-corpus/kimi-k3
1329
- ```
524
+ There is no `figure` in the vision list on purpose ("figure out the bug" is reasoning work); a
525
+ genuine figure-reading unit can say `vision: read figure 3`, or re-add `figure` via
526
+ `strategy.visionKeywords`. `routes` prints the first 8 entries of each list (`…` when more,
527
+ `(disabled)` for an emptied list). The routing cheat sheet (system-prompt section `model-manager`,
528
+ order 60) lists each role's effective models, teaches the label contract, and is empty when no
529
+ role has models; it adds the planning-skill and command notes only while their tier has models.
1330
530
 
1331
531
  ## The allow-list gotcha
1332
532
 
1333
- The profile's `subagent-model-selection-settings` row (`.allowedModels`) constrains what
1334
- an agent may **name**. `assertAllowedModelSelection` in the subagent tool returns early
1335
- when the delegation call names no `provider`, `model` or `reasoning_effort`, so:
1336
-
1337
- - **Role routing is not blocked by the allow-list.** The manager rewrites *inherited*
1338
- delegations at request time, and an inherited delegation names nothing, so a route
1339
- outside the list still serves it.
1340
- - What the list does affect: an agent that **explicitly** names a route outside it is
1341
- refused at delegation time with an error of the form
1342
- `child LLM route "pku-corpus/qwen3.8-max-0902" is not allowed for this Session`, and that
1343
- route is absent from what `list_subagent_models` advertises — so the model is invisible
1344
- to agents even while the manager uses it.
533
+ The profile's `subagent-model-selection-settings` row (`.allowedModels`) constrains what an agent
534
+ may **name**. The delegation tool's gate returns early when a call names no
535
+ `provider`/`model`/`reasoning_effort`, so:
1345
536
 
1346
- Two further properties matter in practice:
537
+ - **Role routing is not blocked by the allow-list.** The manager rewrites *inherited* delegations,
538
+ which name nothing, so a route outside the list still serves them.
539
+ - An agent that **explicitly** names an unlisted route is refused at delegation time
540
+ (`child LLM route "…" is not allowed for this Session`), and that route is absent from
541
+ `list_subagent_models` — invisible to agents even while the manager uses it.
542
+ - The list is sampled per session when it receives its delegation tools, so a session started
543
+ before an edit keeps the old list until recreated. With `enabled: false`, no subagent can
544
+ select a model at all.
1347
545
 
1348
- - The list is sampled per Session when the session receives its delegation tools, so a
1349
- session started before you edited it keeps the old list until the session is recreated.
1350
- - With `enabled: false`, no subagent can select a model at all. `routes` says so
1351
- explicitly when it detects that state.
1352
-
1353
- The plugin cannot fix the list for you. Inserting a second `subagent-model-selection-settings`
1354
- row would abort startup with `duplicate loader entry id`, so the plugin only reads it. If
1355
- any role's **effective** route is unlisted — including a `vision` → `execution` fallback —
1356
- it logs a warning at boot naming the routes, and `routes` renders the audit plus the exact
1357
- YAML to add. Unlisted routes are de-duplicated, one snippet entry each:
546
+ The plugin only **reads** the list — inserting a second row would abort startup with
547
+ `duplicate loader entry id`. If any role's effective route is unlisted (including a vision →
548
+ execution fallback) it warns at boot and `routes` renders the audit plus the exact YAML to add:
1358
549
 
1359
550
  ```text
1360
- model_manager(action: "routes")
1361
- ```
1362
-
1363
- ```text
1364
- Model manager roles
1365
-
1366
- Enabled: yes
1367
-
1368
- Selection: first — every role starts at its top model and fails over down its list (one strategy for all roles)
1369
-
1370
- Role effective model(s)
1371
- ---------- ------------------------------------------
1372
- main (unconfigured — passes through)
1373
- planning pku-corpus/qwen3.8-max-0902
1374
- note: use for architecture and migration design
1375
- execution pku-corpus/qwen3.8-flash
1376
- vision pku-corpus/kimi-k3, pku-corpus/qwen3.8-flash, pku-corpus/mystery, pku-corpus/broken
1377
-
1378
- Strategy mode: hybrid (apply when the child inherited the parent route)
1379
-
1380
551
  Allow-list: enabled, 4 route(s) currently dispatchable
1381
552
  allowed planning pku-corpus/qwen3.8-max-0902
1382
553
  allowed execution pku-corpus/qwen3.8-flash
1383
- allowed vision pku-corpus/kimi-k3
1384
- allowed vision pku-corpus/qwen3.8-flash
1385
554
  BLOCKED vision pku-corpus/mystery
1386
555
  BLOCKED vision pku-corpus/broken
1387
556
 
1388
- 2 role route(s) are not in the subagent allow-list.
1389
- This does NOT block role routing: the harness gates only *explicit* model-facing
1390
- choices, and the manager routes pure-inheritance delegations at request time. What
1391
- it does affect: an agent that names one of these routes explicitly will be refused,
1392
- and the route will not appear in `list_subagent_models`. Add them to
1393
- `subagent-model-selection-settings` (`.allowedModels`) — in the profile patch, or on
1394
- the Subagent settings page — to make them selectable:
557
+ 2 role route(s) are not in the subagent allow-list. This does NOT block role routing;
558
+ add them to `.allowedModels` to make them selectable:
1395
559
 
1396
560
  - provider: pku-corpus
1397
561
  model: mystery
1398
562
  - provider: pku-corpus
1399
563
  model: broken
1400
-
1401
- Vision role (image capability):
1402
- ok pku-corpus/kimi-k3 — accepts images
1403
- NO IMAGES pku-corpus/qwen3.8-flash — declares text — image work routed here will fail
1404
- unknown pku-corpus/mystery — image support not declared
1405
- unresolved pku-corpus/broken — could not resolve (no adapter registered for provider "pku-corpus")
1406
-
1407
- Delegation labels select the tier. The `description` you pass to a delegation
1408
- becomes the child label, which the manager matches against (word-anchored):
1409
- vision : vision, visual, image, images, screenshot, screen shot, ocr, diagram, …
1410
- planning : plan, planning, design, architect, architecture, analyse, analyze, analysis, …
1411
- else : execution
1412
- ```
1413
-
1414
- When nothing is missing the audit says so, and the role table marks a fallback
1415
- `(via execution)` while the audit row is labelled with the role that uses it:
1416
-
1417
- ```text
1418
- Allow-list: enabled, 2 route(s) currently dispatchable
1419
- allowed planning pku-corpus/qwen3.8-max-0902
1420
- allowed execution pku-corpus/qwen3.8-flash
1421
- allowed vision pku-corpus/qwen3.8-flash
1422
- All role routes are allow-listed.
1423
564
  ```
1424
565
 
1425
- To add a route, paste the snippet under `allowedModels:` in the profile patch, restating
1426
- the whole config because an id override replaces `config` wholesale:
566
+ Paste the snippet under `allowedModels:` in the profile patch, restating the whole config (an id
567
+ override replaces `config` wholesale):
1427
568
 
1428
569
  ```yaml
1429
570
  - id: subagent-model-selection-settings
@@ -1433,216 +574,13 @@ the whole config because an id override replaces `config` wholesale:
1433
574
  - provider: pku-corpus
1434
575
  model: qwen3.8-flash
1435
576
  - provider: pku-corpus
1436
- model: qwen3.8-max-0902 # a route the audit reported
1437
- - provider: pku-corpus
1438
- model: deepseek-v4-flash-0731
1439
- ```
1440
-
1441
- ### When the audit cannot read the list
1442
-
1443
- `routes` distinguishes three outcomes, because they call for different fixes.
1444
-
1445
- **No such service** in this composition — a missing feature, not a mistake:
1446
-
1447
- ```text
1448
- Allow-list: unavailable (no subagent model-selection settings service in this composition).
1449
- ```
1450
-
1451
- **Model selection is disabled** — subagents cannot choose a model at all:
1452
-
1453
- ```text
1454
- Allow-list: model selection is DISABLED — subagents cannot select a model at all.
1455
- ```
1456
-
1457
- **The settings owner refused to report** — a configuration error, not a missing feature.
1458
- Its `current()` throws when selection is enabled with an empty `allowedModels`, which is a
1459
- broken deployment that every delegation would hit:
1460
-
1461
- ```text
1462
- Allow-list: the subagent model-selection settings refused to report its routes:
1463
- enabled subagent model selection requires at least one allowed model
1464
- Fix `subagent-model-selection-settings` in the profile patch (an enabled policy needs a
1465
- non-empty `allowedModels`), then reload.
1466
- ```
1467
-
1468
- The same refusal is logged at boot as
1469
- `subagent model-selection settings refused to report its routes: <error>`, so it is not
1470
- mistaken for a normal "no routes listed" state.
1471
-
1472
- ## Tuning the classification
1473
-
1474
- `strategy.visionKeywords` and `strategy.planningKeywords` are the whole classification
1475
- policy **for delegated work**. A subagent is classified by its label and nothing else; the
1476
- top-level tier comes from plan mode and `strategy.planningSkills`, documented under
1477
- [Planning skills](#planning-skills).
1478
-
1479
- - **An absent key uses the built-ins. An explicit `[]` disables that classifier.** That
1480
- is the only way to switch one off: `visionKeywords: []` sends every vision word to the
1481
- planning and execution tests instead. Treat a disabled classifier as intentional —
1482
- with `planning: []` the planning role becomes unreachable for subagents, and with
1483
- `vision: []` no subagent is ever classified `vision`.
1484
- - **Matching is case-insensitive and anchored at a leading word boundary.** A keyword must
1485
- begin at the start of a word, so `spec` no longer matches `"inspect"` and `design` no
1486
- longer matches `"redesign"`, while `screenshot` still matches `"screenshots"` and the
1487
- multi-word `ui mock` still matches. It is not a full-word match, so `plan` still matches
1488
- `"planet"` and `render` still matches `"rendering"`. Prefer distinctive words.
1489
- - A leading `plan:` / `vision:` prefix is authoritative: it decides the tier before any
1490
- keyword is consulted. Among keyword matches, vision is tested before planning, so a
1491
- label matching both goes to `vision`.
1492
- - The built-in vision list has no `figure` — "figure out the bug" is ordinary reasoning
1493
- work, and a genuine figure-reading unit can say `vision: read figure 3`. Re-add it with
1494
- `strategy.visionKeywords` if your labels read that way.
1495
- - Regex metacharacters in a keyword are escaped, so `pkg.io` or `a+b` match literally.
1496
- - The matchers are rebuilt on a saved Settings edit, so a keyword change applies live.
1497
-
1498
- The built-in lists, used when a keyword list is absent:
1499
-
1500
- ```text
1501
- vision (19): vision, visual, image, images, screenshot, screen shot, ocr, diagram,
1502
- chart, plot, photo, picture, png, jpg, jpeg, webp, gif,
1503
- ui mock, render
1504
- planning (24): plan, planning, design, architect, architecture, analyse, analyze,
1505
- analysis, research, investigate, review, critique, strategy, reasoning,
1506
- reason, compare, evaluate, assess, spec, specification, decompose,
1507
- breakdown, proposal, root cause
1508
- ```
1509
-
1510
- `routes` prints the first 8 entries of each list, appending `…` only when there are more,
1511
- and prints `(disabled)` for an explicitly emptied list:
1512
-
1513
- ```text
1514
- Delegation labels select the tier. The `description` you pass to a delegation
1515
- becomes the child label, which the manager matches against (word-anchored):
1516
- vision : vision, visual, image, images, screenshot, screen shot, ocr, diagram, …
1517
- planning : (disabled)
1518
- else : execution
1519
- ```
1520
-
1521
- Replace a list with the keywords you want, remembering that a patch override replaces
1522
- `config` wholesale:
1523
-
1524
- ```yaml
1525
- - id: model-manager
1526
- config:
1527
- roles:
1528
- planning:
1529
- models:
1530
- - provider: pku-corpus
1531
- model: qwen3.8-max-0902
1532
- execution:
1533
- models:
1534
- - provider: pku-corpus
1535
- model: qwen3.8-flash
1536
- strategy:
1537
- mode: hybrid
1538
- planningKeywords: # replaces the 24 built-ins entirely
1539
- - plan
1540
- - design
1541
- - audit
1542
- - benchmark
1543
- visionKeywords: [] # disables the vision classifier
577
+ model: qwen3.8-max-0902
1544
578
  ```
1545
579
 
1546
- The plugin also contributes a system-prompt section (name `model-manager`, order 60) that
1547
- tells the delegating agent to label a delegation description with `plan:` for thinking
1548
- work, `vision:` for image work, or leave it plain for execution — a leading prefix winning
1549
- over keyword matches — to leave `provider` and `model` unset so the role route applies
1550
- (dropped under `advisory`), and it lists each role's
1551
- effective models (including a fallback). It is empty text when no role has any models, so
1552
- the prompt is not padded with a description of routing that does nothing; when only the
1553
- planning tier is missing it says so, so a `plan:` label is never a silent no-op. When
1554
- `planningSkills` is non-empty **and** the planning role has models, the same section adds one
1555
- line saying that a top-level session which invoked one of those skills runs on the planning tier,
1556
- like plan mode; with no models behind the tier it stays quiet rather than advertising a trigger
1557
- that routes nowhere. One further line tells the agent that the user can type `/readimage` to put a
1558
- single message on the vision tier (see [The `/readimage` command](#the-readimage-command)).
1559
-
1560
- ## How it stays safe
1561
-
1562
- Both halves obey the same rule: neither may be able to break the harness it is loaded into.
1563
- A host `apply` that throws fails the loader entry and therefore startup, and a client
1564
- component that throws blanks its whole slot entry, so every risky path is probed and
1565
- degrades to a notice or a log line.
1566
-
1567
- - **Its own schema dependency cannot fail startup.** `@deepseek-ai/schemastery` is loaded
1568
- through a guarded dynamic import and the schema is built inside a guard. If the
1569
- dependency is missing *or incompatible* (a version whose `.default()` / `.volatile()`
1570
- chain differs), the plugin still loads and still routes: `Config` is left undefined, so
1571
- cordis's `resolveConfig` passes the raw config straight through and `readConfig`
1572
- normalizes it defensively. Only schema validation and the auto-generated Settings page
1573
- are skipped.
1574
- - **No settings API.** `settings.installSection` / `installSettingsSection` /
1575
- `settingsNamespace` were removed in DSH 0.1.7, and calling them fails `apply`, which
1576
- fails the loader entry and therefore startup. The host half never touches that API: it
1577
- exports a volatile `Config` and lets the harness auto-generate the Settings form
1578
- (`autoGenerate` defaults to true). It claims no settings namespace either — and neither
1579
- does the client half, which writes the row's *existing* namespace through the `form` the
1580
- plugins page hands it, so the card cannot register a second store or race the host.
1581
- - **The host half imports nothing but its own schema dependency.** It does not import
1582
- `@deepseek-ai/dsh-tools`, `dsh-llm` or `cordis`, which are not resolvable from a
1583
- profile-installed plugin; the tool is registered in the normalized shape the registry
1584
- expects, using plain JSON Schema, and the `llm` service is reached through
1585
- `ctx.get('llm')` rather than an import.
1586
- - **The client half requires one module: `react`.** Harness Client packages — including
1587
- `@deepseek-ai/dsh-client-ui-primitives` — are not `require`d from a hand-written client
1588
- half, so the controls are local and styled with `--dsw-alias-*` tokens only. Its
1589
- collaborators (`slots`, `locale`, `remote`) arrive as injected services, and each use of
1590
- them sits inside a `safely(label, fn)` wrapper that logs
1591
- `[model-manager] <step>: <message>` and continues: a missing locale seat, a failed
1592
- catalog fetch, a rejected subscription or an absent slot registry leaves the card
1593
- unreadable, never fatal. Every value read from the host is re-narrowed before use
1594
- (`isObject` guards on `form.state.value`, `roles`, each catalog group and route), so a
1595
- shape change degrades to "unset" rather than a render error.
1596
- - **Every optional integration is probed and wrapped.** Plan mode, the agent list and
1597
- lineage, the parent's request header, subagent listing, the allow-list service, the
1598
- model-capability lookup, the `sessionProjections` registry the planning-skill fold is read
1599
- from, `tools`, `systemPrompt` and the `skills` registry the `/autoplan` skill is registered
1600
- on are each reached through a guarded accessor and a `try`/`catch`; a missing service means
1601
- that feature is inert, not that the plugin fails. The `agent/request` handler catches its own errors, logs one warning
1602
- (`routing skipped for one request: …`) and returns the request it was given, unchanged.
1603
- The `agent/pre-step` observer is observe-only: it wraps its own scan in a `try`, never
1604
- touches the decision it returns, and ignores a rejected step. Without the projection registry
1605
- the skill trigger falls back to the in-process pre-step signal alone, so it stops surviving a
1606
- restart; without either signal the session simply stays on `main`.
1607
- - **The delegation policy cannot corrupt a prompt.** The section's text function is wrapped
1608
- end-to-end and returns `''` on any failure — including a throwing `tools.get` — so the
1609
- worst case is the pre-0.3.0 prompt with no policy, never a broken assembly. It renders
1610
- only for depth-0 top-level agents that actually have the delegation tools, and reads the
1611
- live config, so a volatile save changes it on the next request.
1612
- - **The update check cannot disturb anything.** It starts ~10 s after boot (never on the
1613
- boot path), runs behind a timeout and a coalescing guard, and every failure path lands
1614
- in `updateState.status === 'error'` with a reason at info level — offline deployments log
1615
- one line per interval, not a warning storm. It writes nothing, changes no routing, and a
1616
- missing `fetch` is just another failed check. The client half's check is gated on
1617
- `window.location`, browser-only, wrapped in the same `safely` discipline, and its timers
1618
- (host side) are unref'd or cordis-effect-owned so a test process still exits.
1619
- - **`apply` never throws.** The whole body sits behind a backstop that logs
1620
- `failed to initialise; model routing is disabled: …` and returns, so a misconfiguration
1621
- degrades routing instead of preventing the harness from booting. Malformed configs
1622
- (`roles: "not-an-object"`, `strategy: null`, an unknown mode, a negative `historyLimit`,
1623
- routes with empty ids) all apply cleanly; bad routes are filtered out and the mode falls
1624
- back to `hybrid`.
1625
- - **A bad live edit cannot break a running router.** The `loader/volatile-update` handler
1626
- is wrapped: a config it cannot re-read logs
1627
- `could not reload settings; routing keeps the previous config: …` and the previous
1628
- config stays in force. The boot capability check is an async probe with its own catch, so
1629
- a slow or failing `llm` service cannot disturb startup.
1630
- - **Typos are reported, not silently ignored.** Schemastery does not reject unknown keys,
1631
- so `readConfig` returns a `warnings` array and `apply` logs each entry at warn level:
1632
- `unknown config key "bogus" ignored`, `unknown role "nope" ignored`,
1633
- `unknown key "roles.planning.mispelled" ignored`, `unknown key "strategy.nope" ignored`,
1634
- `unknown key "update.nope" ignored`,
1635
- and the route-level form with its `reasoningEffort` hint.
1636
- - **The pure helpers are exported for testing:** `name`, `Config`, `apply` plus
1637
- `readConfig`, `applyRoute`, `effectiveRouteOf`, `parseVersion`, `compareVersions`,
1638
- `installedVersion`, `profileHint`, `delegationPolicyText`, `skillNamesOfEvent` — the skill
1639
- fold's whole recognizer, so the gesture, injection and `tool/call` paths are testable without
1640
- a session — and the three default lists (vision keywords, planning keywords, planning skills).
1641
- - **It does not touch the subagent allow-list row**, precisely to avoid the duplicate
1642
- loader entry id that would abort startup.
1643
- - **The `model_manager` tool is read-only.** Its description says so and the
1644
- implementation only reads state — the `update` action forces a network check but writes
1645
- nothing.
580
+ `routes` distinguishes three unreadable states: no such service in the composition (a missing
581
+ feature), model selection disabled (subagents cannot choose at all), and the settings owner
582
+ refusing to report (an enabled policy with an empty `allowedModels` — a broken deployment, also
583
+ logged at boot).
1646
584
 
1647
585
  ## Testing
1648
586
 
@@ -1650,164 +588,78 @@ degrades to a notice or a log line.
1650
588
  npm test
1651
589
  ```
1652
590
 
1653
- Runs the suites in child processes and aggregates the result — **1198 assertions** across
1654
- **14 suites** at the time of writing. Each suite also runs on
1655
- its own: `node test/<name>.test.mjs`.
591
+ Runs the suites in child processes and aggregates the result — **1576 assertions** across
592
+ **18 suites**. Each suite also runs alone: `node test/<name>.test.mjs`. They are plain Node
593
+ scripts — no framework, no dependency beyond Node, no network, nothing written outside the repo.
594
+ Two optionally pin expectations against the **real** harness internals (`dsh-subagent`'s
595
+ `resolveChildAgentOptions` and the allow-list gate); `test/paths.mjs` finds DSH from the `dsh`
596
+ executable on `PATH` or `DSH_INSTALL_DIR`, falling back to a local re-implementation with a `WARN`
597
+ when neither resolves.
1656
598
 
1657
599
  | Suite | Assertions | What it pins |
1658
600
  | --- | --- | --- |
1659
- | `packaging.test.mjs` | 37 | The package identity that nothing else cross-checks: the scoped name is the one string the bundle patch's loader row, the client half's module id and the host half's `PACKAGE_NAME` must all agree on, while the cordis row id, the client row namespace and the locale namespace must all *stay* unscoped. Plus publishability (not private, public access, a real `@deepseek-ai/dsh` version gate, schemastery still optional) and tarball completeness — every `exports` target and every `files` pattern resolved against disk, so a published package cannot mount-less. The gate is not string-matched: a self-validating semver comparator (prerelease-aware, and checked against the ordering trap first) proves the declared range admits 0.1.7-rc.2, 0.2.0-rc.2 **and** 0.2.0 while refusing 0.1.6 and 0.3.0 — because `<0.2.0` reads as "every 0.2.0 prerelease" while excluding 0.2.0 itself. 0.3.0 also pins the release plumbing both halves share: the client's `VERSION` constant equals `package.json` (a drift would ship a lying update banner), both halves fetch the same percent-encoded packument path, and the bundle patch carries the new `autoDelegate`/`update` defaults. |
1660
- | `routing.test.mjs` | 10 | The four roles route as documented; label classification (including a leading `plan:` beating vision keywords under `hybrid`); an explicit child route is respected; the tool and **both** system-prompt sections register; `apply` survives malformed configs. |
1661
- | `delegation.test.mjs` | 39 | The auto-delegation policy: config normalization (absent → `balanced`, unrecognised → `balanced`, volatile refs unwrapped), the schema union, section registration and its 550 order, and every rendering gate — children (by `origin` and by `delegationDepth`) get `''`, tool-less scopes get `''`, fork-only scopes still get a policy naming `subagent_fork`, the master switch suppresses it, a volatile save switches levels live, and a throwing `tools.get` degrades to `''` instead of throwing out of a prompt section. Plus tier awareness: the policy delegates the decomposition, states the prefix rule, teaches the omit-`provider` rule (dropped under `advisory`), and never advertises a `plan:` tier with no models behind it. |
1662
- | `update.test.mjs` | 58 | Version parsing and semver comparison (prerelease ordering, numeric identifiers, build-metadata equality, unparseable → `undefined`), `installedVersion` against the real manifest, `profileHint` from a real chdir, update-config normalization (registry sanitization, interval semantics including explicit 0 and the one-minute floor), and the check itself end-to-end with `fetch` mocked: available / up-to-date / older-latest / HTTP failure / malformed packument / rejected fetch / disabled-never-fetches / custom registry, plus the `report`/`routes` status lines, the log levels (available → warn, failure → info), scheduling through the cordis timer API (10 s boot delay, 24 h interval, boot-only, floor, disarm), and a volatile re-arm that immediately re-checks a changed registry. |
1663
- | `edge.test.mjs` | 557 | Hostile configs, keyword anchoring and trimming, the leading-prefix rule (`plan:`/`vision:` beat keyword matches, case-insensitive, whitespace-tolerant; `"figure out"` is no longer an image label), explicit-`[]`-disables versus absent-uses-defaults, the 0.2.0 pick migration (legacy per-role values warn and are ignored; the top-level value normalizes), round-robin committing only on apply, LRU eviction, the manager-owned rule, volatile settings reload, every `reason` string, the report/usage/routes output, and the generated allow-list YAML round-tripped through the **real** harness validator. |
1664
- | `failover.test.mjs` | 28 | The failover chain and every guard: it walks to the end of the list and then stops rather than wrapping; `ABORTED`, `INVALID_REQUEST` and `IMAGE_OFFLOAD_REQUIRED` never fail over; a downstream recovery decision is passed through untouched; the per-step cap holds and resets on a new step; `round-robin` does wrap; single-model and disabled roles do nothing; a route outside the role's list is left alone; hostile payloads never throw; subagent chains fail over too. And the cursor isolation of 0.4.0: a planning failure advances only the planning cursor, so the same session back on `main` starts at `main`'s first model, and re-entering plan mode resumes the worn planning chain. |
1665
- | `client-structure.test.mjs` | 37 | The client half loads through `window.__ModuleLoader__`, requires **only** `react`, exports `{ inject, apply }`, registers its locale dictionaries and exactly three surfaces (settings card, usage surface, update chip — the last of which renders `null` while the update store is idle), and — because the check mirrors the real `SlotCore.register` validation — fails if a registration ever loses its `name`. It also declares each `remote.<namespace>` used must appear in `inject`, drives the settings-form bindings, renders the usage surface against a stubbed projection face in both its collapsed and expanded states (an empty-projection case proving those render assertions are not vacuous), and pins the 0.2.0 card shape: exactly one shared selection control writing the top-level `pick`, with no per-role pick control left anywhere in the tree. The update check itself is gated on `window.location`, so the suite provably never fetches. |
1666
- | `client-diagnostic.test.mjs` | 17 | Every branch of `model_manager` with `action: "client"`, including the two that matter most: a bundle the Host will not serve, and a bundle that serves but registers the wrong id. |
1667
- | `usage-projection.test.mjs` | 43 | The projections this plugin registers — all three of them, `modelManagerUsage`, `modelManagerSelection` and since 0.5.0 `modelManagerPlanningSkill`, each asserted to be registered under its own key — and the per-session model-usage fold: bucket sums against the harness's own field names, refusal of unsafe or fractional counts without aborting the fold, usage recovered from an embedded stream, separate attribution per provider/model, immutable state transitions, reference stability that suppresses republishing, and both schemas rejecting junk through the only method cordis calls (`.parse`). |
1668
- | `explicit-selection.test.mjs` | 25 | The rule that `main` yields to a hand-picked session model, and nothing else does: respected under `hybrid`, still applied under `managed`, untouched by a respected call in the round-robin rotation, and falling back to the old rewriting behaviour when the projection service is absent, when `stateOf` throws, or when the key was never registered. A disabled manager is checked too. Plus the `Top-level agents` report table: the hand-picked versus default-driven verdict, no orphaned subagent header when no subagent exists, a row that outlives its agent degrading to `unknown, agent no longer live`, and — read back out of the renderer's own source — proof that the reason column is still padded past the longest reason string it can print. |
1669
- | `autoplan-skill.test.mjs` | 42 | New in 0.6.0. The bundled `/autoplan` skill: the pure frontmatter parser (`parseSkillMarkdown`) accepting exactly a well-formed SKILL.md — CRLF, edge-trimming, a `---` line inside the body preserved, a `name:` line in the body not mistaken for frontmatter — and returning `undefined` for a missing/unclosed fence, an empty body, an empty description, an invalid name, and every hostile input without throwing; the shipped definition satisfying the runtime contract `dsh-skill` validates on `get()` (kebab name, non-empty description/content, both invocation flags, a string source) and its body carrying the load-bearing instructions (the `plan:`-labelled `subagent_fork`, the no-approval rule, the plan-mode boundary, the `subagent` fallback, the main-tier implementation phase) so it cannot be silently gutted; registration through a mock skills service — exactly once, the shipped definition, an info log naming the skill — and every degradation: a throwing `register()` and a composition with no skills service both leave `apply()` working with a warning, and `routes()` distinguishing registered from not; registration independent of `config.enabled`; and the routing invariant that `/autoplan` is not a planning skill — a top-level session that invoked it stays on the `main` tier, with `/grilling` as the escalating control. The packaging suite additionally pins that `skills/` is in `files` and the body ships. |
1670
- | `planning-skills.test.mjs` | 100 | New in 0.5.0. The skill → top-level `planning` escalation, in eight blocks: the pure event fold `skillNamesOfEvent` over all three records — the `skill-invocation` injection, the `/name` gesture in direct user text, and a model's `skill` `tool/call` with JSON arguments — including the gesture-boundary rules, hostile payloads that record nothing and never throw, and the grammar pinned **byte-identical against the real `dsh-tool-skill`** when a DSH install resolves; `planningSkills` configuration (absent → `grill-me`/`grilling`, explicit `[]` honoured, lowercasing/trimming/de-duplication, invalid names dropped, volatile refs unwrapped, no unknown-key warning either way, and the schema union accepting an array / rejecting anything else); the `modelManagerPlanningSkill` projection (key, `stateVersion`, `init`, folding all three event shapes, mixed-case canonicalization, same-reference returns that suppress republishing, `.parse` rejecting junk); the **live** `agent/pre-step` signal — registered prepended, routing the FIRST request of a gesture step, stickiness across later turns, non-listed skills left on `main`, `[]` disabling it, the enter/reject decision returned by identity, a dozen hostile payloads, a subagent never escalated, `agent/disposed` dropping the live signal, a volatile reload of `[]` applying to the next request, and the info notice firing once per switch; the **durable** signal (a resumed session routing planning from a logged invocation, gesture, or model tool call, a durable name inert under `[]`, and no throw when the projection service is absent); plan mode keeping its own behaviour and owning the trigger when both apply; an explicit composer pick still winning the route while the row records role `planning`; and both diagnostic surfaces — the `Planning skills:` line in `routes` and the `Planning skill trigger:` line in `report`, each in its enabled and disabled form. |
1671
- | `model-select.test.mjs` | 26 | New in 0.6.1. DSH 0.2's selection contract: the pure helpers (`sameSelection`, `planningSkillInMessages`, `selectionModelOf`); a claimed user message selects the role's route before the step is prepared — plain prompt → `main`, `/grilling` → `planning`, `/autoplan` → `main`, plan mode → `planning`, round-robin committing only on an applied selection, and a hand-picked composer model respected under `hybrid` while `managed` overrides it; the manager's own selection is not mistaken for a hand-picked one on the next turn; `agent/request` returns the step's fixed route untouched (the 0.2 crash path); `agent/pre-step` corrects the next step; failover selects the next model and does not retry the fixed step; and a 0.1.x agent without a selection surface keeps request-time rewriting. |
1672
- | `readimage.test.mjs` | 179 | New in 0.7.0. The `/readimage` command: the pure gesture helper `readImageGestureInMessages` (word-boundary recognition in direct user text, pinned against the real `dsh-tool-skill` grammar when a DSH install resolves) and `normalizeReadImageCommand` (the default, an explicit `''`, trimming/lowercasing, an invalid name disabling the feature with a warning), command registration through the `commands` service — name/input/handler registration, volatile rename and disable re-arming, and the handler's forwarding (frozen user message with a fresh UUID, the `/readimage` token included, attachments preserved by identity) plus every refusal path (bare command, disabled manager, advisory mode, vision-unconfigured, no inbox, throwing followup, aborted signal), the turn-keyed override lifecycle through the real seam order claim → current → pre-step → request (whole-turn vision routing including tool-loop steps, mid-turn steering not cancelling it, the next plain turn returning to normal routing, consecutive gestures), composer-pick force-then-restore — including the corner cases that the restore must hand back the user's LATEST pick (a newer composer pick made after or between commanded turns is kept, never clobbered by the stale memory) and that `main` does not eat the restored pick — precedence over plan mode and planning skills for the commanded turn only, subagent sessions never binding the override while their label routing is untouched, the legacy 0.1.x rewrite path with the explicit-selection bypass for that one turn, both diagnostic surfaces, the cheat sheet never advertising the command while disabled or advisory, and `agent/disposed` clean rebind. |
1673
-
1674
- The suites are plain Node scripts — no test framework, and no dependency beyond Node itself.
1675
-
1676
- Two of them optionally pin their expectations against the **real** harness internals rather
1677
- than a transcription of them: `dsh-subagent`'s `resolveChildAgentOptions` (what a delegated
1678
- child actually inherits) and `SubagentModelSelectionConfig.current` (the allow-list gate that
1679
- rejects a repeated route). `test/paths.mjs` discovers the DSH installation from the `dsh`
1680
- executable on `PATH`, or from `DSH_INSTALL_DIR` if you set it. When neither resolves, those
1681
- assertions fall back to a local re-implementation and print a `WARN` — the suite still passes,
1682
- but it is then testing my model of the harness rather than the harness, so prefer running it
1683
- where `dsh` is installed.
1684
-
1685
- Nothing in the suite touches the network, a profile, or a running harness, and nothing writes
1686
- outside the repository.
601
+ | `packaging` | 37 | Scoped-name agreement across all halves, publishability, the semver runtime gate, tarball completeness, and the shared release plumbing (client `VERSION`, packument path, patch defaults). |
602
+ | `routing` | 10 | The four roles route as documented; prefix beats keywords; explicit child route respected; tool and both prompt sections register; malformed configs survive. |
603
+ | `delegation` | 43 | Policy normalization, section registration/order, every rendering gate, tier awareness, and the omit-`provider` rule. |
604
+ | `update` | 58 | Version parsing/comparison, config normalization, the check end-to-end with mocked fetch, status lines, log levels, scheduling, and volatile re-arm. |
605
+ | `edge` | 557 | Hostile configs, keyword anchoring, the prefix rule, `[]`-disables vs absent-defaults, the pick migration, rotation/ownership rules, volatile reload, every reason string, report/usage/routes output, allow-list YAML round-trip. |
606
+ | `failover` | 28 | The chain and every guard (terminal codes, downstream passthrough, per-step cap, round-robin wrap, single-model/disabled roles) and per-(session, role) cursor isolation. |
607
+ | `client-structure` | 37 | The client loads via `window.__ModuleLoader__`, requires only `react`, registers locale + exactly three surfaces, drives the settings form, renders usage, and pins the shared-`pick` card shape. |
608
+ | `client-diagnostic` | 17 | Every branch of `model_manager` action `client`, including a bundle the Host will not serve and one serving the wrong id. |
609
+ | `usage-projection` | 44 | The four projections under their own keys, the per-session usage fold (bucket sums, unsafe-count refusal, stream recovery, per-route attribution, immutability, schema rejection). |
610
+ | `directive-parser` | 52 | Chinese/English role-first/mention-first parsing, all aliases, keep/clear gestures, exclusions, patch folding, provider-qualified splitting, and catalog resolution cases. |
611
+ | `message-directives` | 44 | Real-engine pins: selection before the first 0.2 request, composer precedence, durable replay/override/clear, parent/child inheritance, no rotation consumption, pinned/unpinned failover, 0.1 fallback, diagnostics. |
612
+ | `explicit-selection` | 25 | Composer selections no longer veto `main` under hybrid/managed; rotation not secretly consumed; the top-level report table and reason-column padding. |
613
+ | `planning-skills` | 99 | The skill → planning escalation: the event fold over all three records, config normalization, the projection, the live pre-step signal, the durable signal, plan-mode precedence, and both diagnostic surfaces. |
614
+ | `autoplan-skill` | 46 | The frontmatter parser, the shipped definition satisfying the runtime contract and carrying its load-bearing instructions, registration and every degradation, and the invariant that `/autoplan` is not a planning skill. |
615
+ | `model-select` | 26 | DSH 0.2's selection contract: claim-boundary selection per trigger, observe-only request identity, pre-step correction, failover selecting the next model, and the 0.1.x rewrite fallback. |
616
+ | `readimage` | 178 | The gesture helper and name normalizer, command registration/re-arm, handler forwarding and every refusal, the turn-keyed override lifecycle, composer hand-back and newer-pick rules, precedence, and the 0.1.x path. |
617
+ | `quicktask` | 183 | The shared machinery on execution: text-only contract, every refusal, the override lifecycle, both-gesture precedence, chaining, first-wins name collisions, inert-when-empty, hand-back, and diagnostics. |
618
+ | `pin-command` | 92 | Pin × one-turn-command composition on the real engine: pinned vision/execution serving commanded turns, pins surviving turns and restart, failover suppression, clear gestures, the 0.1.x path, and the composer policy end-to-end. |
619
+
620
+ The `readimage` count (178) is without a DSH install; with one, two extra grammar pins bring it to
621
+ 180.
1687
622
 
1688
623
  ## Limitations
1689
624
 
1690
- - **Classification is label-driven, not content-driven.** At `agent/request` time the
1691
- plugin has no supported way to read a child's message blocks, so it matches the child's
1692
- delegation label and nothing else. Image detection is therefore label-based: a
1693
- delegation about an image whose `description` contains no vision keyword is classified
1694
- `execution`.
1695
- - **Leading-boundary matching still matches word prefixes** (`plan` in `"planet"`,
1696
- `render` in `"rendering"`), and the first match wins with vision tested before planning.
1697
- Two classifier lists cannot express precedence beyond that.
1698
- - **The planning-skill trigger is sticky, and there is no exit gesture.** Once a session invokes
1699
- a listed skill it stays on `planning` for the rest of that session: the durable
1700
- `modelManagerPlanningSkill` fold records what the session *invoked*, not what is currently in
1701
- force, and it is append-only. Start a new session, or set `strategy.planningSkills: []`, to opt
1702
- out. A skill the **model** invoked (through its `skill` tool) escalates only from the next
1703
- request of that session onward — the `tool/call` event exists only once the model has emitted
1704
- it, so the step that asked for the skill still runs on the route already chosen.
1705
- - **Failover is per request, not per step, on DSH 0.2.x.** The route is fixed when a step is
1706
- prepared, so a provider failure advances the role's cursor and selects the next model for the
1707
- next request; the failing step ends rather than being retried on another model. On 0.1.x the
1708
- same-step retry is unchanged. See [Switching models on DSH 0.2.x](#switching-models-on-dsh-02x).
1709
- - **Selection ownership is in-process.** A route the manager selected reads as hand-picked after a
1710
- restart, because 0.2 records every selection in the same durable event; `managed` overrides it,
1711
- and the next turn that routes the session re-establishes ownership.
1712
- - **`/autoplan` is a workflow, not enforcement.** The body is injected as instructions, so the
1713
- model decides how faithfully to follow it: nothing forces the fork, and nothing stops a model
1714
- from asking a question anyway. What the plugin does guarantee is the tiers — the `plan:` label
1715
- routes the planning fork, and the top-level session stays on `main` because `autoplan` is not in
1716
- `planningSkills`. A project-level skill file of the same name overrides the bundled body
1717
- entirely (see the override note above).
1718
- - **The `/readimage` override is process-live.** It is per-message intent, not durable session
1719
- state: nothing is folded into the log, so a restart loses an in-flight commanded turn's routing
1720
- and the next message routes normally. Type the gesture again to command a new turn.
1721
- - **Images need the command path on a text-only current model.** The plain-text gesture routes
1722
- text-only messages, but it cannot carry attachments past the admission gate: on DSH 0.2.x with a
1723
- text-only model selected, the harness refuses the images with `MODEL_DOES_NOT_SUPPORT_IMAGES`
1724
- before any routing hook runs. Only the registered command admits them.
1725
- - **The command needs a `commands` service in the composition.** Older harnesses without one
1726
- register no command, and the feature degrades to gesture-only routing for text messages — images
1727
- then have no path at all while a text-only model is selected.
1728
- - **`hybrid` compares routes by value.** A child that deliberately names the same route as
1729
- the parent's effective route is indistinguishable from one that inherited it, and will
1730
- be rewritten to the role route.
1731
- - **Under `hybrid`, an unresolved lineage means the child keeps its own route.** The
1732
- manager will not touch a delegation whose inheritance it cannot prove; if you want
1733
- routing regardless of lineage, use `managed`. The report shows
1734
- `lineage unresolved (child route respected)` for those requests, so a broken lineage
1735
- integration is visible rather than silent — but it does also mean a child that should
1736
- have been managed was not.
1737
- - **Manager-ownership is sticky.** Once a route has been applied to a child, that child
1738
- keeps being managed as long as its route matches the applied one, even after its parent
1739
- is gone. If a child legitimately changes its own model to one the parent also uses, the
1740
- manager takes it back.
1741
- - **`round-robin` is per-process; the strategy itself is global.** The pick strategy is one
1742
- top-level value shared by every role, but the rotation counters are per-role, live in an
1743
- in-memory `Map` and
1744
- reset to index 0 on restart. A role with a single model never advances, and an advance is
1745
- committed only when a route is applied, so `advisory` passes and both kinds of respected
1746
- route do not rotate. Routing happens per LLM request, not per turn, so a `round-robin`
1747
- role can still rotate models between the steps of one turn.
1748
- - **Usage history is in-process.** A `Map` capped at `strategy.historyLimit` (300),
1749
- evicted least-recently-used: an active subagent stays, an idle one goes first. Nothing is
1750
- persisted, so after a restart `report` and `usage` start empty.
1751
- - **`report` lists top-level rows but its totals stay subagent-only.** The `Top-level agents`
1752
- table covers every session this process saw a request for, top-level or not; the
1753
- `Subagent requests by role/model:` block beneath it counts subagents only. `usage` counts the
1754
- whole process, including top-level `main`/`planning` turns (shown as `0 subagent(s)`). So the
1755
- two tables inside `report` answer for different populations, and neither one matches `usage`.
1756
- - **The `status` column needs the live agent list.** It is the status the harness reports,
1757
- `live` when a live agent exposes no status, and `inactive` when `agents.get` cannot
1758
- resolve the child. If the `agents` service is unavailable or has no `get`, every row
1759
- reads `inactive` whether or not the subagent is alive.
1760
- - **The image-capability check covers only the vision role's effective models.** A planning
1761
- or execution child handed an image is not checked, `unknown` and `unresolved` verdicts are
1762
- reported but never warned about at boot, and with the bundled default (`vision: []`) the
1763
- check audits the execution fallback rather than a dedicated vision model.
1764
- - **The allow-list audit is informational for routing.** Since the harness gates only
1765
- explicit choices, a `BLOCKED` row does not mean role routing failed — it means agents
1766
- cannot name that route and `list_subagent_models` will not show it.
1767
- - **The `child` column is a 10-character id prefix**, so two session ids sharing their
1768
- first 10 characters are indistinguishable in the table.
1769
- - **Labels are flattened for display.** Newlines collapse to spaces, the text is truncated
1770
- at 42 characters with `…`, and `"` becomes `'`.
1771
- - **`roles.<role>.note` affects only the `routes` table.** It is human annotation; no
1772
- routing decision, report or count reads it, and the boot log does not print it.
1773
- - **`main` empty is the simplest policy, and now not the only one.** With `main: []` a top-level
1774
- turn outside plan mode and outside a planning skill is never rewritten. With `main` configured
1775
- under `hybrid`, a session whose model was picked by hand keeps it (see "`main` and the composer's
1776
- model picker") and only untouched sessions are rewritten; under `managed` every top-level
1777
- request is rewritten, chosen by hand or not.
1778
- - **The card can only pick what the catalog advertises.** A route the catalog stopped returning keeps its row and stays editable, labelled `(not advertised)`, but you cannot add such a route — or any model absent from the catalog — from the UI. Provider and model are never free text here, so a typo cannot be written into the config; use the patch layer for a route the host does not advertise.
1779
- - **The card has no image-capability information.** `session/modelCatalog` exposes ids,
1780
- names and reasoning efforts, not modalities, so nothing in the UI stops you picking a
1781
- text-only model for `vision`; the host half's `routes` audit is the check.
1782
- - **A stored effort can be invisible.** Picking a different model keeps the route's previous
1783
- `reasoningEffort`, and the effort picker only renders when the newly selected model
1784
- advertises efforts — so a stale effort can remain in the config with no control to clear
1785
- it. Remove it in the patch layer.
1786
- - **The card lives in exactly one place: 设置.** It registers `settings.section` under
1787
- `model-manager`, and nothing on the Plugins page — `plugins.item` and `plugins.row.config` are
1788
- deliberately not registered, so there is one copy of these values and one place to edit them.
1789
- The second surface, `conversation.session.header.utilities` under `model-manager-usage`, is
1790
- read-only: it shows the per-session model usage the host half folds from the durable log, and
1791
- writes nothing.
1792
- - **The card needs one restart after installing**, because the client-module boot manifest
1793
- caches package metadata per loader specifier until restart. Before that the Settings entry is
1794
- simply absent.
1795
- - **The delegation policy is a prompt, not an enforcement.** `strategy.autoDelegate` changes
1796
- what the top-level agent is *told*; it cannot make a model delegate, and a strong-willed
1797
- model can still do the work itself. `eager` is the stronger instruction, not a guarantee.
1798
- A label is likewise overridable: under `hybrid`, a delegation that names `provider`/`model`
1799
- keeps that route — which is why the policy now tells the agent to leave those unset on
1800
- `plan:`/`vision:` units, but it cannot stop a model that insists on naming one. The policy
1801
- also disappears silently if the harness's subagent tool is renamed
1802
- (`toolName` in `dsh-tool-subagent` config), because the text function only names tools it
1803
- can resolve in scope.
1804
- - **The update check sees `dist-tags.latest`, nothing else.** It compares against the
1805
- `latest` tag on the configured registry, so a newer prerelease (or a `next` tag) is
1806
- invisible, and an intranet mirror that lags npm will keep reporting "up to date" after a
1807
- release. The browser banner additionally needs the registry to answer CORS — npmjs and
1808
- npmmirror do; one that does not simply leaves the client-side surfaces empty while the
1809
- host log and the tool action still report.
1810
- - **The client banner's "installed" version is the pinned constant.** The browser cannot
1811
- read `package.json`, so `client.js` pins `VERSION` and a packaging test keeps it equal;
1812
- a hand-edited checkout that bumps only one side will show a self-inconsistent banner
1813
- (which the same test refuses to let the repo ship).
625
+ - **Label-driven, not content-driven.** The plugin cannot read a child's message blocks at request time, so an image delegation whose label has no vision keyword is `execution`.
626
+ - **Leading-boundary matching matches word prefixes** (`plan` in `"planet"`); first match wins, vision before planning. Two lists cannot express finer precedence.
627
+ - **The planning-skill trigger is sticky, no exit gesture.** Start a new session or set `planningSkills: []`; a model-invoked skill escalates only from the next request.
628
+ - **Failover is per request, not per step, on DSH 0.2.x** (route fixed at preparation); 0.1.x keeps the same-step retry.
629
+ - **Directive resolution depends on the live catalog.** A bare id can become unknown/ambiguous if providers change; qualified pins are stable; unresolved pins preserve the route and suppress failover. Image admission precedes any directive switch, so a directive cannot rescue an already-rejected attachment.
630
+ - **`/autoplan` is a workflow, not enforcement.** The model decides how faithfully to follow the body; the plugin guarantees only the tiers. A project-level skill file overrides it.
631
+ - **One-turn overrides are process-live**; a restart loses an in-flight commanded turn's routing.
632
+ - **Images need the command path on a text-only current model** (the admission gate refuses them before any routing hook); the plain-text gesture routes text only.
633
+ - **The commands need a `commands` service**; without one they degrade to gesture-only text routing, and images have no path while a text-only model is selected.
634
+ - **`hybrid` compares routes by value**, so a child deliberately naming the parent's route is indistinguishable from inheritance and is rewritten.
635
+ - **Unresolved lineage under `hybrid` keeps the child's route** (visible as `lineage unresolved`, but a child that should have been managed was not); use `managed` to force.
636
+ - **Manager-ownership is sticky** — a child stays managed while its route matches the applied one, even after its parent is gone.
637
+ - **`round-robin` is per-process; the strategy is global.** Counters are per-role, reset on restart; a single-model role never advances; an advance commits only on apply; routing is per request, so a role can rotate within one turn.
638
+ - **Usage history is in-process** (a `Map` capped at `historyLimit`, LRU-evicted); `report`/`usage` start empty after a restart.
639
+ - **`report` totals stay subagent-only** though it lists top-level rows; `usage` counts the whole process — different populations.
640
+ - **The `status` column needs the live agent list**; without it every row reads `inactive`.
641
+ - **The image-capability check covers only the vision role's effective models**; `unknown`/`unresolved` are reported but never warned at boot.
642
+ - **The allow-list audit is informational for routing** — `BLOCKED` means agents cannot name the route, not that role routing failed.
643
+ - **The `child`/`session` columns are 10-character id prefixes.**
644
+ - **Labels are flattened for display** — one line, truncated at 42 characters, `"` → `'`.
645
+ - **`roles.<role>.note` affects only the `routes` table** — no routing decision reads it.
646
+ - **`main: []` is the simplest passthrough.** With an automatic `main` route, composer selections are overridden under `hybrid` and `managed`; only a message directive creates a session pin.
647
+ - **The card picks only what the catalog advertises.** A retired route stays editable (`(not advertised)`) but cannot be added from the UI; provider/model are never free text.
648
+ - **The card has no image-capability information** (no modalities in the catalog); `routes` is the check.
649
+ - **A stored effort can be invisible** — picking a different model keeps the previous `reasoningEffort`, and the picker only renders when the new model advertises efforts; clear it in the patch.
650
+ - **The card lives in exactly one place (设置)**; the usage surface is read-only.
651
+ - **The card needs one restart after installing** (the boot manifest caches package metadata until then).
652
+ - **The delegation policy is a prompt, not enforcement.** A model can still do the work itself or name a route under `hybrid`; the policy disappears if the subagent tool is renamed.
653
+ - **The update check sees `dist-tags.latest` only** — a newer prerelease/`next` tag is invisible, a lagging mirror reports "up to date"; the browser banner also needs registry CORS.
654
+ - **The client banner's "installed" version is a pinned constant** kept equal to `package.json` by a packaging test; bumping one side alone shows a self-inconsistent banner.
655
+
656
+ ## Release notes
657
+
658
+ - **0.3.0** — auto-delegation policy (`strategy.autoDelegate`) and npm update checks.
659
+ - **0.4.0** — the delegation label became a contract (`plan:`/`vision:` prefixes) and failover cursors became per-(session, role).
660
+ - **0.5.0** — planning-skill escalation (`grilling` / `grill-me` → the planning tier for the session).
661
+ - **0.6.0** — the bundled `/autoplan` skill (plan on the planning tier, implement on main, no approval gate).
662
+ - **0.6.1** — DSH 0.2 model-selection contract (`agent.model.select()` before step preparation).
663
+ - **0.7.0** — `/readimage`, the first one-turn command (vision, with image admission).
664
+ - **0.7.1** — `/quicktask`, the one-turn command's cheap end (execution, text only).
665
+ - **0.7.2** — message-authored `@model` session pins; a composer pick is no longer a routing lock.