@darkbear9494/dsh-model-manager 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,11 @@
3
3
  A host-half plugin for DeepSeek Harness that assigns models to four roles — `main`,
4
4
  `planning`, `execution`, `vision` — applies them on the `agent/request` waterfall, and
5
5
  reports which model every subagent actually used, with its role, the reason, and its live
6
- status.
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.
7
11
 
8
12
  ## What it is
9
13
 
@@ -16,7 +20,17 @@ nothing tells you afterwards which model a given subagent ended up on.
16
20
  This plugin is that layer. It keeps one ordered route list per role, classifies each
17
21
  delegated child from the label the delegating agent gives it, rewrites the child's resolved
18
22
  route to the role's route when inheritance is provable, and exposes a read-only
19
- `model_manager` tool that reports what happened. It is deliberately small: one ESM host
23
+ `model_manager` tool that reports what happened. 0.3.0 adds two layers on top of routing
24
+ proper: an **auto-delegation policy** — a system-prompt section that teaches the top-level
25
+ agent to plan and dispatch subagents instead of doing everything itself, which is the
26
+ behaviour the harness's own instructions only nudge at — and an **update check** that
27
+ compares the installed version with the registry's `dist-tags.latest` and tells you how to
28
+ upgrade. 0.4.0 makes the label a contract instead of a hint: a leading `plan:`/`vision:`
29
+ prefix decides the tier before any keyword is consulted, the policy never advertises a tier
30
+ with no models behind it, it teaches the delegating agent to leave `provider`/`model` unset
31
+ on tiered units (an explicitly named route overrides the tier under `hybrid`), and the
32
+ failover cursor is tracked per (session, role) so one tier's wear never pushes another tier
33
+ off its first model. It is still deliberately small: one ESM host
20
34
  file, one config schema, and one hand-written client file that contributes a
21
35
  configuration card to the Plugins page. There is no build step for either half.
22
36
 
@@ -68,19 +82,23 @@ before handing it to pnpm. All four forms work:
68
82
  | `@darkbear9494/dsh-model-manager` | registry — the shortest one to type |
69
83
  | `github:jyshangguan/dsh-model-manager` | git — the `https://github.com/…` URL works too |
70
84
  | `/Users/you/src/dsh-model-manager` | absolute local directory (relative paths are refused) |
71
- | `/Users/you/darkbear9494-dsh-model-manager-0.2.0.tgz` | local tarball — `npm pack` makes one |
85
+ | `/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) |
72
86
 
73
87
  Registering the plugin by name was verified end-to-end on this runtime: `dsh plugin --profile
74
88
  <name> add @darkbear9494/dsh-model-manager` resolves the current release (`^0.1.0` at first
75
89
  publish, `^0.2.0` since) from the registry, `reconcile()`
76
90
  appends the bundle, the composed tree mounts row `model-manager`, and a boot reaches the LLM stage
77
91
  with no peer refusal and no loader error. The git and local-path forms were checked the same way.
92
+ The same add command is the **upgrade** path: re-running it with `@latest` resolves the newer
93
+ version and updates the dependency in place.
78
94
 
79
95
  ### The registry copy
80
96
 
81
- `@darkbear9494/dsh-model-manager@0.2.0` is the current release, public access, 8 files, 63.1 kB
82
- packed (0.1.0, the first publish, was 62.3 kB with the same 8 files). Its
83
- declared gate is `>=0.1.7-rc.2 <0.3.0`, so it installs on the 0.2.0 line without an exemption.
97
+ `@darkbear9494/dsh-model-manager@0.4.0` is the current release, public access, the same 8
98
+ files as 0.2.0 (the tarball grew, not the file list: the host half, the client half and this
99
+ README carry the new sections). 0.2.0 packed 63.1 kB with the same 8 files, and 0.1.0, the
100
+ first publish, 62.3 kB. The declared gate is `>=0.1.7-rc.2 <0.3.0`, so every release on the
101
+ 0.1.7–0.2.x runtime lines installs without an exemption.
84
102
 
85
103
  Two things learned while publishing it, in case a future version has to be released:
86
104
 
@@ -292,7 +310,11 @@ resolves to no route, and requests classified into it pass through unchanged —
292
310
 
293
311
  A route is `{ provider, model, reasoningEffort? }`. The top-level `pick` is `first`
294
312
  (default) or `round-robin` and applies to every role alike; with one model in a role's list
295
- it has no effect for that role. A role may also carry a
313
+ it has no effect for that role. Under `first` the list is a failover chain, and since 0.4.0
314
+ the wear position is tracked per **(session, role)**, not per session: a session that failed
315
+ over while it was serving `planning` (plan mode moves one session between `main` and
316
+ `planning` on every request) comes back to `main` still on `main`'s first model. A role may
317
+ also carry a
296
318
  `note` — free text for humans, printed under the role in the `routes` table and never
297
319
  used for routing.
298
320
 
@@ -300,25 +322,27 @@ used for routing.
300
322
 
301
323
  The client half contributes a configuration card to the Plugins page. It writes exactly the
302
324
  values documented under [Configuration](#configuration) — `roles.<role>.models`, the
303
- top-level `pick` and `strategy.mode` — so the two paths are interchangeable: use the card to try a routing
325
+ top-level `pick`, `strategy.mode` and `strategy.autoDelegate` — so the two paths are
326
+ interchangeable: use the card to try a routing
304
327
  choice, the YAML to pin it. This package's own `cordis.patch.yml` is the declarative source
305
328
  that ships with the bundle and is re-read on every boot, and a profile patch overrides it by
306
329
  row id; the card never edits patch files, so if a patch layer pins a value, edit the patch.
307
330
 
308
331
  ### Where the card appears
309
332
 
310
- `client.js` registers **two** surfaces and deliberately nothing on the Plugins page:
333
+ `client.js` registers **three** surfaces and deliberately nothing on the Plugins page:
311
334
 
312
335
  | Slot | Registration id | What it renders |
313
336
  | --- | --- | --- |
314
- | `settings.section` | `model-manager` | The configuration card: the four roles and their model lists, the shared selection strategy, the distribution mode. |
337
+ | `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. |
315
338
  | `conversation.session.header.utilities` | `model-manager-usage` | The per-session model-usage summary the host half folds from the durable log. |
339
+ | `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. |
316
340
 
317
341
  So the path is **设置 → 模型管理器** — not Plugins → the row → configure. `plugins.item` and
318
342
  `plugins.row.config` are *not* registered: one card in one place was the requirement, and a
319
343
  second copy on the Plugins page would only be a second place for the same values to disagree.
320
344
 
321
- Both entries are registered **unconditionally** rather than behind the shipped
345
+ All entries are registered **unconditionally** rather than behind the shipped
322
346
  `configForms.whileServed([ns], …)` gate. The Host serves a settings namespace only for a row
323
347
  whose Config schema has volatile fields, so that gate would hide the card entirely whenever the
324
348
  optional schemastery dependency failed to resolve — making a packaging problem look exactly like
@@ -338,7 +362,9 @@ polling on the client, and the numbers survive a restart.
338
362
  | `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. |
339
363
  | 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. |
340
364
  | `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. |
365
+ | `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. |
341
366
  | 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. |
367
+ | 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). |
342
368
 
343
369
  **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.
344
370
 
@@ -422,9 +448,11 @@ the patch layer.
422
448
  **Verification status, stated honestly:** the client half was verified by JavaScript syntax,
423
449
  manifest validation, a structural load of the `window.__ModuleLoader__.load` factory — which
424
450
  confirms that only `react` is required, that `apply` registers the `dsh-model-manager` locale
425
- namespace with the same 46 keys in English and Chinese (the test compares the sorted key *sets*,
426
- not just their counts), that exactly two surfaces are injected — `settings.section` under
427
- `model-manager` and `conversation.session.header.utilities` under `model-manager-usage` — and
451
+ namespace with the same 61 keys in English and Chinese (the test compares the sorted key *sets*,
452
+ not just their counts), that exactly three registrations land across the two surfaces —
453
+ `settings.section` under `model-manager` and `conversation.session.header.utilities` under
454
+ `model-manager-usage` (the per-session usage) plus `model-manager-update` (the update chip,
455
+ which renders `null` while the update store is idle) — and
428
456
  that `apply` still returns normally when every injected collaborator throws. It was also checked
429
457
  against the live slot contract in `@deepseek-ai/dsh-client-ui-settings`. **Visual verification of
430
458
  the rendered card is not available in this environment:** the harness's own verification guidance
@@ -509,15 +537,20 @@ unresolved-lineage route all leave the rotation where it was.
509
537
 
510
538
  Only a session whose `session.header.origin` is `'subagent'` is classified by label. The
511
539
  label is the `description` the delegating agent passed to the `subagent` tool, which the
512
- harness stores as the child's label. Matching is case-insensitive and anchored at a
513
- leading word boundary, in this order:
540
+ harness stores as the child's label. Matching is case-insensitive, anchored at a leading
541
+ word boundary, and prefix-first, in this order:
514
542
 
515
543
  1. Empty label → `execution`.
516
- 2. Any `visionKeywords` match → `vision`.
517
- 3. Else any `planningKeywords` match → `planning`.
518
- 4. Else `execution`.
544
+ 2. A label starting with `plan:` (case-insensitive, leading whitespace ignored) →
545
+ `planning`.
546
+ 3. A label starting with `vision:` → `vision`.
547
+ 4. Else any `visionKeywords` match → `vision`.
548
+ 5. Else any `planningKeywords` match → `planning`.
549
+ 6. Else `execution`.
519
550
 
520
- Vision is tested before planning, so a label that matches both lands on `vision`.
551
+ The leading prefix is authoritative — it is the one part of the label the delegating model
552
+ writes *on purpose*, so `"plan: analyse the screenshots"` is planning work. Among keyword
553
+ matches, vision is tested before planning, so a label matching both lands on `vision`.
521
554
 
522
555
  | Delegation `description` | Matched by | Role | Applied route (bundled defaults) |
523
556
  | --- | --- | --- | --- |
@@ -599,6 +632,128 @@ warn [model-manager] vision role route(s) declare no image input and image work
599
632
  undeclared modalities may well accept images, and an unresolvable route is already reported
600
633
  by the allow-list audit.
601
634
 
635
+ ## Auto-delegation policy (`strategy.autoDelegate`)
636
+
637
+ **The problem it solves.** The harness gives the top-level agent a `subagent` tool and a
638
+ one-line nudge ("Start independent delegations together in one message"), but nothing tells
639
+ it *when* to delegate. In practice the model does the work itself and only reaches for a
640
+ delegation when it cannot proceed — image reading being the canonical case. This plugin is
641
+ already in the business of routing delegations by role; 0.3.0 makes it also *ask* for them.
642
+
643
+ `strategy.autoDelegate` controls a second system-prompt section, `model-manager:delegation`
644
+ (order 550 — next to the harness's own `PLAN_POLICY`/`TEAM_POLICY` rows, not next to the
645
+ routing cheat sheet, because this is a behavioural policy rather than a routing fact):
646
+
647
+ | Level | Rendered for | What it tells the top-level agent |
648
+ | --- | --- | --- |
649
+ | `off` | nobody | Nothing — no section text at all. |
650
+ | `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. |
651
+ | `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. |
652
+
653
+ Both levels end with the same labelling block, so the policy and the role tiers are used
654
+ together — which is the point of having both in one plugin. The block labels each delegation
655
+ by the *kind of work it carries* (`plan:` = must be thought through, `vision:` = reads images,
656
+ plain = mechanical execution), states that a leading prefix decides the tier with keyword
657
+ matching as the fallback, and — under any mode that actually routes — tells the agent to
658
+ **omit `provider` and `model` on `plan:`/`vision:` units**, because a route named explicitly
659
+ on the delegation overrides the tier. That last line is the one that makes the label matter
660
+ under `hybrid`, where a respected explicit choice is exactly what defeats role routing.
661
+
662
+ **Rendering is per assembly, and deliberately narrow.** The section's text function receives
663
+ the assembly context (`{ agent, scope }`, the same object `dsh-agent`'s
664
+ `assembleContextFor` builds) and returns `''` — no policy at all — unless every gate passes:
665
+
666
+ - the manager is enabled and the level is not `off`;
667
+ - the assembly is **not** a delegated child: `session.header.origin === 'subagent'` or
668
+ `header.delegationDepth > 0` both disqualify. Children already carry the harness's fixed
669
+ `subagent:delegation` runtime context, and encouraging a child to re-delegate would push
670
+ every unit one depth level down for no benefit;
671
+ - the assembly's scope **actually exposes a delegation tool**, checked with
672
+ `tools.get('subagent', scope)` / `tools.get('subagent_fork', scope)` — the same probe
673
+ `dsh-tool-subagent`'s own prompt section uses. An agent whose composition restricted the
674
+ delegation tools never sees a policy naming a tool it cannot call, and a harness that
675
+ renames the tool loses the policy rather than rendering a broken instruction.
676
+
677
+ Beyond the gates, the labelling block adapts to what is actually behind it: a tier with no
678
+ configured models is never advertised (no `plan:` line when the planning role is empty — and
679
+ the balanced "plan first" bullet loses its label too), and under `advisory`, where nothing is
680
+ routed at all, the omit-`provider`/`model` line is dropped because it would warn about
681
+ nothing.
682
+
683
+ Only the tools that resolve are named: with both present the policy mentions `subagent` and
684
+ the `subagent_fork` preference for work that needs this conversation's context; with only
685
+ `subagent` the fork line is dropped. `model_manager(action: "routes")` reports the level
686
+ (`Auto-delegation: balanced — …`), and the settings card offers the three-way select, so
687
+ switching levels needs no restart — the section reads the live config, so a saved edit
688
+ applies to the next request.
689
+
690
+ ## Automatic update checks
691
+
692
+ The host half checks whether a newer `@darkbear9494/dsh-model-manager` is published, and
693
+ tells you — passively in the log, on demand through the tool, and persistently in the Web UI.
694
+
695
+ **How it works.** The plugin reads its own version from its `package.json` (so a git
696
+ checkout, an npm install and a tarball install all report what actually shipped), fetches
697
+ the abbreviated packument `<registry>/@darkbear9494%2fdsh-model-manager` with
698
+ `Accept: application/vnd.npm.install-v1+json`, reads `dist-tags.latest`, and compares the
699
+ two with a semver comparator that handles prereleases (`0.3.1-rc.1 < 0.3.1`, numeric
700
+ prerelease identifiers compare numerically). The first check runs ~10 s after boot — never
701
+ on the boot path — and then once per `intervalHours`; every failure path (no network,
702
+ CORS, a malformed packument) lands in a logged diagnostic and a `CHECK FAILED` verdict,
703
+ never a throw, and never touches routing.
704
+
705
+ **Where a newer release is surfaced:**
706
+
707
+ | Surface | What you see |
708
+ | --- | --- |
709
+ | 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.` |
710
+ | `model_manager` action `update` | The full report below — including the paste-ready upgrade command with the live profile name. |
711
+ | `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. |
712
+ | Settings card | A warn-toned banner at the top of the card with the versions, the upgrade command, and a **Re-check** button. |
713
+ | 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. |
714
+
715
+ Asking for the check directly:
716
+
717
+ ```text
718
+ model_manager(action: "update")
719
+ ```
720
+
721
+ ```text
722
+ Model manager update check
723
+
724
+ installed : 0.2.0
725
+ latest : 0.3.0
726
+ registry : https://registry.npmjs.org
727
+ checked : 2026-10-07T03:12:44.612Z
728
+ verdict : UPDATE AVAILABLE (0.2.0 -> 0.3.0)
729
+
730
+ To upgrade, run in a terminal:
731
+
732
+ dsh plugin --profile desktop add @darkbear9494/dsh-model-manager@latest
733
+
734
+ then restart the harness so the new version mounts. The Plugins page can reinstall
735
+ the same package instead; both paths run the same installer. Tell the user this
736
+ upgrade is available and what command to run.
737
+ ```
738
+
739
+ The `<profile>` in the command is read from the host's working directory
740
+ (`$DSH_HOME/profiles/<name>`); when the layout does not match, the command prints
741
+ `<profile>` as a placeholder. Upgrading is re-running the add command — the installer
742
+ (`dsh plugin add` / the GUI's `install_bundle`) resolves the new version, updates the
743
+ dependency and keeps the bundle registration; restart the harness afterwards so the new
744
+ host half mounts.
745
+
746
+ **The browser half runs the same comparison itself.** The Web client cannot read the host's
747
+ in-memory state, so `client.js` pins the version it shipped with (a packaging test pins
748
+ that constant equal to `package.json`) and fetches the same packument once per page load —
749
+ plus on every `settings/document-updated` (the registry URL is row config, so a change
750
+ re-checks) and on the banner's Re-check button. That is why the chip and banner can appear
751
+ the moment the GUI opens. An offline or registry-blocked deployment simply sees no banner;
752
+ the host log and the tool action still report the update. This also means the browser makes
753
+ one cross-origin `fetch` to the configured registry — `registry.npmjs.org` (and npmmirror)
754
+ answer it with `Access-Control-Allow-Origin: *`; a registry that does not is silently
755
+ unusable for the client half and only the host surfaces remain.
756
+
602
757
  ## Configuration
603
758
 
604
759
  Config is the `config` of the row id `model-manager`. This bundle ships a layer that
@@ -640,12 +795,28 @@ Complete key set, with the schema defaults shown in comments:
640
795
  # visionKeywords: omitted = the 20 built-ins; any list you write replaces them
641
796
  # planningKeywords: omitted = the 24 built-ins; [] DISABLES that classifier
642
797
  historyLimit: 300 # default: 300; any positive value floors to at least 1
798
+ autoDelegate: balanced # default: balanced; "off" | "balanced" | "eager" — the delegation policy
799
+ update: # 0.3.0 — automatic update check
800
+ enabled: true # default: true; only an explicit false stops the checks
801
+ registry: https://registry.npmjs.org # any npm-compatible registry (npmmirror works)
802
+ intervalHours: 24 # default: 24; explicit 0 = check at boot only
643
803
  ```
644
804
 
645
805
  The two keyword lists are shown commented out because their default is the built-in list
646
806
  rather than a literal value: omitting the key keeps the built-ins, while writing any list —
647
807
  including `[]` — replaces them, and `[]` switches that classifier off entirely.
648
808
 
809
+ Behaviours of the `update` block worth knowing:
810
+
811
+ - `registry` must be an `http(s)` origin; anything else (or a non-string) falls back to
812
+ `https://registry.npmjs.org`. Trailing slashes are trimmed.
813
+ - `intervalHours` accepts a fraction (0.5 = 30 min, useful when watching a release land)
814
+ and is floored at one minute so a mis-typed hour cannot hammer a registry. An absent,
815
+ malformed or negative value means the 24 h default; an explicit `0` means "check at boot
816
+ only". `enabled: false` is the actual off switch.
817
+ - A settings save that changes the update block re-arms the schedule **and** runs one
818
+ immediate check, so switching to a mirror registry takes effect without a restart.
819
+
649
820
  Each entry of `models` is:
650
821
 
651
822
  | Key | Required | Default | Meaning |
@@ -697,6 +868,11 @@ The bundled layer this package ships is:
697
868
  models: []
698
869
  strategy:
699
870
  mode: hybrid
871
+ autoDelegate: balanced
872
+ update:
873
+ enabled: true
874
+ registry: https://registry.npmjs.org
875
+ intervalHours: 24
700
876
  ```
701
877
 
702
878
  ## Seeing which model each subagent used
@@ -742,14 +918,15 @@ finished value: no folding in the browser, no polling, no fetch route. That is t
742
918
 
743
919
  ### The tool
744
920
 
745
- The plugin registers one read-only tool, `model_manager`, with four actions:
921
+ The plugin registers one read-only tool, `model_manager`, with five actions:
746
922
 
747
923
  | Action | Returns |
748
924
  | --- | --- |
749
- | `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. |
750
- | `routes` | Role table (role, effective models, role `note`), the shared selection strategy, active mode, allow-list audit with a YAML snippet for unlisted routes, the vision image-capability check, and the first 8 keywords of each list. |
925
+ | `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. Carries one update-available line when a newer release was found. |
926
+ | `routes` | Role table (role, effective models, role `note`), the shared selection strategy, active mode, the auto-delegation level, 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. |
751
927
  | `usage` | Request and subagent counts per role/model across the whole process, including top-level turns. |
752
928
  | `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. |
929
+ | `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. |
753
930
 
754
931
  Both `report` and `usage` read **process-local in-memory state**: they answer for the current
755
932
  `dsh` process only, and a restart clears them. A subagent that finished before a restart
@@ -929,7 +1106,7 @@ Vision role (image capability):
929
1106
 
930
1107
  Delegation labels select the tier. The `description` you pass to a delegation
931
1108
  becomes the child label, which the manager matches against (word-anchored):
932
- vision : vision, visual, image, images, screenshot, screen shot, ocr, figure, …
1109
+ vision : vision, visual, image, images, screenshot, screen shot, ocr, diagram, …
933
1110
  planning : plan, planning, design, architect, architecture, analyse, analyze, analysis, …
934
1111
  else : execution
935
1112
  ```
@@ -1007,15 +1184,20 @@ policy.
1007
1184
  longer matches `"redesign"`, while `screenshot` still matches `"screenshots"` and the
1008
1185
  multi-word `ui mock` still matches. It is not a full-word match, so `plan` still matches
1009
1186
  `"planet"` and `render` still matches `"rendering"`. Prefer distinctive words.
1010
- - Vision is tested before planning, so a label matching both goes to vision.
1187
+ - A leading `plan:` / `vision:` prefix is authoritative: it decides the tier before any
1188
+ keyword is consulted. Among keyword matches, vision is tested before planning, so a
1189
+ label matching both goes to `vision`.
1190
+ - The built-in vision list has no `figure` — "figure out the bug" is ordinary reasoning
1191
+ work, and a genuine figure-reading unit can say `vision: read figure 3`. Re-add it with
1192
+ `strategy.visionKeywords` if your labels read that way.
1011
1193
  - Regex metacharacters in a keyword are escaped, so `pkg.io` or `a+b` match literally.
1012
1194
  - The matchers are rebuilt on a saved Settings edit, so a keyword change applies live.
1013
1195
 
1014
1196
  The built-in lists, used when a keyword list is absent:
1015
1197
 
1016
1198
  ```text
1017
- vision (20): vision, visual, image, images, screenshot, screen shot, ocr, figure,
1018
- diagram, chart, plot, photo, picture, png, jpg, jpeg, webp, gif,
1199
+ vision (19): vision, visual, image, images, screenshot, screen shot, ocr, diagram,
1200
+ chart, plot, photo, picture, png, jpg, jpeg, webp, gif,
1019
1201
  ui mock, render
1020
1202
  planning (24): plan, planning, design, architect, architecture, analyse, analyze,
1021
1203
  analysis, research, investigate, review, critique, strategy, reasoning,
@@ -1029,7 +1211,7 @@ and prints `(disabled)` for an explicitly emptied list:
1029
1211
  ```text
1030
1212
  Delegation labels select the tier. The `description` you pass to a delegation
1031
1213
  becomes the child label, which the manager matches against (word-anchored):
1032
- vision : vision, visual, image, images, screenshot, screen shot, ocr, figure, …
1214
+ vision : vision, visual, image, images, screenshot, screen shot, ocr, diagram, …
1033
1215
  planning : (disabled)
1034
1216
  else : execution
1035
1217
  ```
@@ -1060,10 +1242,13 @@ Replace a list with the keywords you want, remembering that a patch override rep
1060
1242
  ```
1061
1243
 
1062
1244
  The plugin also contributes a system-prompt section (name `model-manager`, order 60) that
1063
- tells the delegating agent to start a delegation description with `plan:` for reasoning
1064
- work, `vision:` for image work, or leave it plain for execution, and lists each role's
1245
+ tells the delegating agent to label a delegation description with `plan:` for thinking
1246
+ work, `vision:` for image work, or leave it plain for execution — a leading prefix winning
1247
+ over keyword matches — to leave `provider` and `model` unset so the role route applies
1248
+ (dropped under `advisory`), and it lists each role's
1065
1249
  effective models (including a fallback). It is empty text when no role has any models, so
1066
- the prompt is not padded with a description of routing that does nothing.
1250
+ the prompt is not padded with a description of routing that does nothing; when only the
1251
+ planning tier is missing it says so, so a `plan:` label is never a silent no-op.
1067
1252
 
1068
1253
  ## How it stays safe
1069
1254
 
@@ -1107,6 +1292,18 @@ degrades to a notice or a log line.
1107
1292
  accessor and a `try`/`catch`; a missing service means that feature is inert, not that the
1108
1293
  plugin fails. The `agent/request` handler catches its own errors, logs one warning
1109
1294
  (`routing skipped for one request: …`) and returns the request it was given, unchanged.
1295
+ - **The delegation policy cannot corrupt a prompt.** The section's text function is wrapped
1296
+ end-to-end and returns `''` on any failure — including a throwing `tools.get` — so the
1297
+ worst case is the pre-0.3.0 prompt with no policy, never a broken assembly. It renders
1298
+ only for depth-0 top-level agents that actually have the delegation tools, and reads the
1299
+ live config, so a volatile save changes it on the next request.
1300
+ - **The update check cannot disturb anything.** It starts ~10 s after boot (never on the
1301
+ boot path), runs behind a timeout and a coalescing guard, and every failure path lands
1302
+ in `updateState.status === 'error'` with a reason at info level — offline deployments log
1303
+ one line per interval, not a warning storm. It writes nothing, changes no routing, and a
1304
+ missing `fetch` is just another failed check. The client half's check is gated on
1305
+ `window.location`, browser-only, wrapped in the same `safely` discipline, and its timers
1306
+ (host side) are unref'd or cordis-effect-owned so a test process still exits.
1110
1307
  - **`apply` never throws.** The whole body sits behind a backstop that logs
1111
1308
  `failed to initialise; model routing is disabled: …` and returns, so a misconfiguration
1112
1309
  degrades routing instead of preventing the harness from booting. Malformed configs
@@ -1122,13 +1319,17 @@ degrades to a notice or a log line.
1122
1319
  so `readConfig` returns a `warnings` array and `apply` logs each entry at warn level:
1123
1320
  `unknown config key "bogus" ignored`, `unknown role "nope" ignored`,
1124
1321
  `unknown key "roles.planning.mispelled" ignored`, `unknown key "strategy.nope" ignored`,
1322
+ `unknown key "update.nope" ignored`,
1125
1323
  and the route-level form with its `reasoningEffort` hint.
1126
1324
  - **The pure helpers are exported for testing:** `name`, `Config`, `apply` plus
1127
- `readConfig`, `applyRoute`, `effectiveRouteOf` and the two default keyword lists.
1325
+ `readConfig`, `applyRoute`, `effectiveRouteOf`, `parseVersion`, `compareVersions`,
1326
+ `installedVersion`, `profileHint`, `delegationPolicyText` and the two default keyword
1327
+ lists.
1128
1328
  - **It does not touch the subagent allow-list row**, precisely to avoid the duplicate
1129
1329
  loader entry id that would abort startup.
1130
1330
  - **The `model_manager` tool is read-only.** Its description says so and the
1131
- implementation only reads state.
1331
+ implementation only reads state — the `update` action forces a network check but writes
1332
+ nothing.
1132
1333
 
1133
1334
  ## Testing
1134
1335
 
@@ -1136,16 +1337,18 @@ degrades to a notice or a log line.
1136
1337
  npm test
1137
1338
  ```
1138
1339
 
1139
- Runs eight suites in child processes and aggregates the result — **683 assertions** at the time
1340
+ Runs ten suites in child processes and aggregates the result — **848 assertions** at the time
1140
1341
  of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
1141
1342
 
1142
1343
  | Suite | Assertions | What it pins |
1143
1344
  | --- | --- | --- |
1144
- | `packaging.test.mjs` | 31 | 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. Each identity assertion was mutation-checked: breaking any one of the four name sites, or "tidying" the row id or locale namespace to match, fails exactly one assertion; reverting the upper bound to `<0.2.0` fails exactly two. |
1145
- | `routing.test.mjs` | 9 | The four roles route as documented; label classification; an explicit child route is respected; the tool and system-prompt section register; `apply` survives malformed configs. |
1146
- | `edge.test.mjs` | 553 | Hostile configs, keyword anchoring and trimming, 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. |
1147
- | `failover.test.mjs` | 24 | 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. |
1148
- | `client-structure.test.mjs` | 35 | The client half loads through `window.__ModuleLoader__`, requires **only** `react`, exports `{ inject, apply }`, registers its locale dictionaries and exactly two surfaces, 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. |
1345
+ | `packaging.test.mjs` | 35 | 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. |
1346
+ | `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. |
1347
+ | `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. |
1348
+ | `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. |
1349
+ | `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. |
1350
+ | `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. |
1351
+ | `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. |
1149
1352
  | `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. |
1150
1353
  | `usage-projection.test.mjs` | 42 | 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`). |
1151
1354
  | `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. |
@@ -1241,3 +1444,22 @@ outside the repository.
1241
1444
  - **The card needs one restart after installing**, because the client-module boot manifest
1242
1445
  caches package metadata per loader specifier until restart. Before that the Settings entry is
1243
1446
  simply absent.
1447
+ - **The delegation policy is a prompt, not an enforcement.** `strategy.autoDelegate` changes
1448
+ what the top-level agent is *told*; it cannot make a model delegate, and a strong-willed
1449
+ model can still do the work itself. `eager` is the stronger instruction, not a guarantee.
1450
+ A label is likewise overridable: under `hybrid`, a delegation that names `provider`/`model`
1451
+ keeps that route — which is why the policy now tells the agent to leave those unset on
1452
+ `plan:`/`vision:` units, but it cannot stop a model that insists on naming one. The policy
1453
+ also disappears silently if the harness's subagent tool is renamed
1454
+ (`toolName` in `dsh-tool-subagent` config), because the text function only names tools it
1455
+ can resolve in scope.
1456
+ - **The update check sees `dist-tags.latest`, nothing else.** It compares against the
1457
+ `latest` tag on the configured registry, so a newer prerelease (or a `next` tag) is
1458
+ invisible, and an intranet mirror that lags npm will keep reporting "up to date" after a
1459
+ release. The browser banner additionally needs the registry to answer CORS — npmjs and
1460
+ npmmirror do; one that does not simply leaves the client-side surfaces empty while the
1461
+ host log and the tool action still report.
1462
+ - **The client banner's "installed" version is the pinned constant.** The browser cannot
1463
+ read `package.json`, so `client.js` pins `VERSION` and a packaging test keeps it equal;
1464
+ a hand-edited checkout that bumps only one side will show a self-inconsistent banner
1465
+ (which the same test refuses to let the repo ship).