@darkbear9494/dsh-model-manager 0.4.0 → 0.5.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 +152 -30
- package/client.js +5 -5
- package/cordis.patch.yml +12 -2
- package/lib/index.js +317 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,10 @@ status. Since 0.3.0 it also **prompts the top-level agent to delegate** (`strate
|
|
|
7
7
|
and **checks npm for a newer release of itself** (`update`), surfacing an upgrade notice in the
|
|
8
8
|
log, through the `model_manager` tool, on the settings card, and as a chip in the session header.
|
|
9
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.
|
|
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.
|
|
11
14
|
|
|
12
15
|
## What it is
|
|
13
16
|
|
|
@@ -30,7 +33,12 @@ prefix decides the tier before any keyword is consulted, the policy never advert
|
|
|
30
33
|
with no models behind it, it teaches the delegating agent to leave `provider`/`model` unset
|
|
31
34
|
on tiered units (an explicitly named route overrides the tier under `hybrid`), and the
|
|
32
35
|
failover cursor is tracked per (session, role) so one tier's wear never pushes another tier
|
|
33
|
-
off its first model.
|
|
36
|
+
off its first model. 0.5.0 gives the top-level `planning` tier a second trigger besides plan
|
|
37
|
+
mode: a session that invoked one of the skills listed in `strategy.planningSkills` (default
|
|
38
|
+
`['grill-me', 'grilling']`) runs on the planning role's models for the rest of its life, whether
|
|
39
|
+
the intent arrived as a `/grilling` gesture in user text, as the harness's skill injection, or as
|
|
40
|
+
the model's own `skill` tool call — and it is read from a durable session projection, so it
|
|
41
|
+
survives a restart, a resume and a fork. It is still deliberately small: one ESM host
|
|
34
42
|
file, one config schema, and one hand-written client file that contributes a
|
|
35
43
|
configuration card to the Plugins page. There is no build step for either half.
|
|
36
44
|
|
|
@@ -94,11 +102,15 @@ version and updates the dependency in place.
|
|
|
94
102
|
|
|
95
103
|
### The registry copy
|
|
96
104
|
|
|
97
|
-
`@darkbear9494/dsh-model-manager@0.4.0` is the current release
|
|
98
|
-
files as 0.2.0 (the tarball grew, not the file list: the host half, the client
|
|
99
|
-
README carry the new sections). 0.
|
|
100
|
-
|
|
101
|
-
0.
|
|
105
|
+
`@darkbear9494/dsh-model-manager@0.4.0` is the current release **on the registry**, public
|
|
106
|
+
access, the same 8 files as 0.2.0 (the tarball grew, not the file list: the host half, the client
|
|
107
|
+
half and this README carry the new sections). The 0.5.0 planning-skill work described throughout
|
|
108
|
+
this README is this release **in the working copy** — nothing here claims it is published, because
|
|
109
|
+
it is not: `add @darkbear9494/dsh-model-manager@latest` still resolves 0.4.0 until someone runs
|
|
110
|
+
`npm publish`, so 0.5.0 installs from a local path (or from git, once it is pushed there). 0.2.0
|
|
111
|
+
packed 63.1 kB with the same 8 files, and 0.1.0, the first publish, 62.3 kB. The declared gate is
|
|
112
|
+
`>=0.1.7-rc.2 <0.3.0`, so every release on the 0.1.7–0.2.x runtime lines installs without an
|
|
113
|
+
exemption.
|
|
102
114
|
|
|
103
115
|
Two things learned while publishing it, in case a future version has to be released:
|
|
104
116
|
|
|
@@ -156,7 +168,8 @@ The 0.2.0 line is admitted because the host half is verified against it. Against
|
|
|
156
168
|
every API this plugin touches is unchanged from 0.1.7-rc.2: `dsh-session-projection`
|
|
157
169
|
(`stateOf`), `dsh-plan-mode`, `dsh-agent`, `dsh-subagent`, `dsh-tool-subagent` +
|
|
158
170
|
`model-selection-settings`, `dsh-tools`, `dsh-llm`, `dsh-session` and `dsh-client-modules` are
|
|
159
|
-
byte-identical, all
|
|
171
|
+
byte-identical, all six subscribed events (including `agent/pre-step`, whose dispatch and
|
|
172
|
+
decision shapes 0.5.0's skill trigger reads) and every probed service still exist, and all 22
|
|
160
173
|
failover `failure.code` values are still emitted. A real boot on that runtime applied the host
|
|
161
174
|
half, bound every event, resolved every injection and registered the `model_manager` tool. The
|
|
162
175
|
client half is unchanged too: `window.__ModuleLoader__.load({ id, factory })`, the `dsh.client`
|
|
@@ -187,7 +200,7 @@ Only a restart picks it up. Remove the old name, install the new one, then resta
|
|
|
187
200
|
|
|
188
201
|
| File | Purpose |
|
|
189
202
|
| --- | --- |
|
|
190
|
-
| `lib/index.js` | Host half: Cordis identity `model-manager`, exported `Config`, `apply`, the `agent/request` routing, the `agent/request-error` failover, and the `model_manager` tool. |
|
|
203
|
+
| `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. |
|
|
191
204
|
| `client.js` | Client half: the configuration card, contributed as a page in the Settings panel. |
|
|
192
205
|
| `locale/en.json`, `locale/zh.json` | Display metadata only — the bundle's `title` and `description` in the plugin list. |
|
|
193
206
|
| `cordis.patch.yml` | Bundle layer: inserts exactly one row, id `model-manager`. |
|
|
@@ -303,17 +316,27 @@ resolves to no route, and requests classified into it pass through unchanged —
|
|
|
303
316
|
|
|
304
317
|
| Role | What it is for | When it applies | Bundled default |
|
|
305
318
|
| --- | --- | --- | --- |
|
|
306
|
-
| `main` | The top-level agent outside plan mode. | Requests from a non-subagent session
|
|
307
|
-
| `planning` | Reasoning, design, analysis, research. | Top-level requests while plan mode is active; subagents whose label matches a planning keyword (and no vision keyword). | `pku-corpus/qwen3.8-max-0902` |
|
|
319
|
+
| `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) |
|
|
320
|
+
| `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` |
|
|
308
321
|
| `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` |
|
|
309
322
|
| `vision` | Image, screenshot, chart and OCR work. | Subagents whose label matches a vision keyword. | `models: []` (falls back to `execution`) |
|
|
310
323
|
|
|
324
|
+
A top-level session has two ways onto `planning`, and neither of them is its label:
|
|
325
|
+
the harness's plan mode, and `strategy.planningSkills` — the skills a user invokes to do thinking
|
|
326
|
+
work (`grilling`, plus the `grill-me` alias that loads it). Invoking one counts as entering the
|
|
327
|
+
tier: the session is on `planning` **for the rest of the session**, because the skill's
|
|
328
|
+
instructions stay in context and a grilling interview runs over many turns, not one. There is no
|
|
329
|
+
exit gesture — start a new session, or set `planningSkills: []`, which is the off switch — and a
|
|
330
|
+
model you hand-picked in the composer still wins under `hybrid`, the same way it does in plan mode.
|
|
331
|
+
See [Planning skills](#planning-skills).
|
|
332
|
+
|
|
311
333
|
A route is `{ provider, model, reasoningEffort? }`. The top-level `pick` is `first`
|
|
312
334
|
(default) or `round-robin` and applies to every role alike; with one model in a role's list
|
|
313
335
|
it has no effect for that role. Under `first` the list is a failover chain, and since 0.4.0
|
|
314
336
|
the wear position is tracked per **(session, role)**, not per session: a session that failed
|
|
315
337
|
over while it was serving `planning` (plan mode moves one session between `main` and
|
|
316
|
-
`planning` on every request
|
|
338
|
+
`planning` on every request; a planning skill moves it to `planning` and leaves it there) comes
|
|
339
|
+
back to `main` still on `main`'s first model. A role may
|
|
317
340
|
also carry a
|
|
318
341
|
`note` — free text for humans, printed under the role in the `routes` table and never
|
|
319
342
|
used for routing.
|
|
@@ -368,8 +391,8 @@ polling on the client, and the numbers survive a restart.
|
|
|
368
391
|
|
|
369
392
|
**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.
|
|
370
393
|
|
|
371
|
-
Each role also carries a hint line (`Top-level agent outside plan mode
|
|
372
|
-
|
|
394
|
+
Each role also carries a hint line (`Top-level agent outside plan mode and planning skills. …`,
|
|
395
|
+
`Used for image, screenshot and OCR work. Pick a model
|
|
373
396
|
that accepts images.`, …) so the card explains itself without this README open.
|
|
374
397
|
|
|
375
398
|
The card cannot tell you whether a model accepts images: the session model catalog carries
|
|
@@ -561,7 +584,70 @@ matches, vision is tested before planning, so a label matching both lands on `vi
|
|
|
561
584
|
| `"summarize the changelog"` | nothing | `execution` | `pku-corpus/qwen3.8-flash` |
|
|
562
585
|
|
|
563
586
|
A non-subagent session is never classified by label: it gets `planning` while plan mode
|
|
564
|
-
is active
|
|
587
|
+
is active **or** while one of `strategy.planningSkills` has been invoked in it — a trigger that
|
|
588
|
+
then holds for the rest of the session — and `main` otherwise. See
|
|
589
|
+
[Planning skills](#planning-skills).
|
|
590
|
+
|
|
591
|
+
### Planning skills
|
|
592
|
+
|
|
593
|
+
`strategy.planningSkills` (default `['grill-me', 'grilling']`) is the user-facing half of the
|
|
594
|
+
planning tier: plan mode is the harness declaring that this session is doing thinking work, a
|
|
595
|
+
skill invocation is the user declaring the same thing. Both names ship in the list because
|
|
596
|
+
`grill-me` is the alias a person types and `grilling` is the skill it loads. A subagent is never
|
|
597
|
+
escalated by a skill — a child is classified by its label alone.
|
|
598
|
+
|
|
599
|
+
**Three signals count**, because DSH commits each of them before the request it can influence:
|
|
600
|
+
|
|
601
|
+
| Signal | Read from | Escalates |
|
|
602
|
+
| --- | --- | --- |
|
|
603
|
+
| 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 |
|
|
604
|
+
| A `/name` gesture in direct user text | the same two | the same step |
|
|
605
|
+
| A model-invoked `skill` tool call — `tool/call`, name `skill`, JSON `arguments.name` | the durable fold | the **next** request of that session |
|
|
606
|
+
|
|
607
|
+
Recognition uses the harness's own grammar, kept byte-identical to `dsh-tool-skill`'s: a skill
|
|
608
|
+
name is lowercase kebab-case (`[a-z0-9]+(-[a-z0-9]+)*`) and the gesture is a `/name` standing
|
|
609
|
+
alone between whitespace. So "grill me on this" written in prose matches nothing, while the
|
|
610
|
+
`skill` call the model then makes does — one request later, once that call is in the log.
|
|
611
|
+
|
|
612
|
+
**Why the first request needs a second hook.** DSH fires `agent/pre-step` *before*
|
|
613
|
+
`agent/request`, and commits the step's user batch — the skill injection included — only *after*
|
|
614
|
+
`agent/request` returns (`dsh-agent-loop`: `preStep()` → `prepareRequest()` →
|
|
615
|
+
`session.append('user/message')`). A fold-only design would therefore serve the first, and most
|
|
616
|
+
important, request of a `/grilling` turn on `main`. So the plugin registers a prepended,
|
|
617
|
+
observe-only `agent/pre-step` listener that records every skill name in the step's batches and
|
|
618
|
+
returns the harness's decision untouched. `{ prepend: true }` is what lets it see the injections
|
|
619
|
+
at all: `dsh-tool-skill` registers as an inner hook, so a normally ordered listener would run
|
|
620
|
+
inside it and never receive them. That map is per-process and is dropped with the agent on
|
|
621
|
+
`agent/disposed`.
|
|
622
|
+
|
|
623
|
+
**Why the trigger survives a restart.** The durable half is a third session projection,
|
|
624
|
+
`modelManagerPlanningSkill`, folded from the `user/message` and `tool/call` events. It stores
|
|
625
|
+
*every* skill name the session invoked, not just the configured planning ones, because membership
|
|
626
|
+
is decided against the **live** config on every request: adding a name to `planningSkills` reaches
|
|
627
|
+
a session that invoked it an hour ago, and `[]` switches the trigger off on the next request
|
|
628
|
+
without a restart. Both halves are append-only, which is what makes the trigger **sticky for the
|
|
629
|
+
rest of the session** — the way entering plan mode is, and for the same reason: the skill's
|
|
630
|
+
instructions stay in context and its interview runs over many turns. Plan mode is consulted first,
|
|
631
|
+
so a session that is in plan mode *and* has been grilled records trigger `plan-mode`; the role is
|
|
632
|
+
`planning` either way.
|
|
633
|
+
|
|
634
|
+
Normalization follows the keyword lists, with one addition: entries are trimmed, lowercased and
|
|
635
|
+
de-duplicated, and anything that is not a kebab-case skill name is dropped, so a typo in the list
|
|
636
|
+
can never match a session by accident. An absent or non-list value uses the defaults; an explicit
|
|
637
|
+
`[]` — or a list whose every entry was dropped — disables the trigger.
|
|
638
|
+
|
|
639
|
+
**What you can see of it.** The host logs one line per switch rather than per request
|
|
640
|
+
(`planning skill "grilling" is active in this session; top-level requests route as planning`),
|
|
641
|
+
`model_manager(action: "routes")` prints the live list on its `Planning skills:` line, and
|
|
642
|
+
`model_manager(action: "report")` adds a `Planning skill trigger: <session> → <skill>` line under
|
|
643
|
+
the `Top-level agents` table for any session that got there through a skill. The system-prompt
|
|
644
|
+
cheat sheet says the same, but only while the planning role actually has models behind it.
|
|
645
|
+
|
|
646
|
+
**It is a routing aid, not enforcement.** It decides which *role* a top-level request is
|
|
647
|
+
classified into, and nothing else. It cannot make a model think better, and under `hybrid` a model
|
|
648
|
+
you hand-picked in the composer still serves the session: the report row shows role `planning`
|
|
649
|
+
with reason `explicit session selection (respected)` and your route, exactly as it does in plan
|
|
650
|
+
mode. There is no exit gesture — start a new session, or set `planningSkills: []`.
|
|
565
651
|
|
|
566
652
|
### The vision → execution fallback
|
|
567
653
|
|
|
@@ -794,6 +880,7 @@ Complete key set, with the schema defaults shown in comments:
|
|
|
794
880
|
mode: hybrid # default: hybrid; "hybrid" | "managed" | "advisory"
|
|
795
881
|
# visionKeywords: omitted = the 20 built-ins; any list you write replaces them
|
|
796
882
|
# planningKeywords: omitted = the 24 built-ins; [] DISABLES that classifier
|
|
883
|
+
# planningSkills: omitted = ['grill-me', 'grilling']; [] DISABLES the trigger
|
|
797
884
|
historyLimit: 300 # default: 300; any positive value floors to at least 1
|
|
798
885
|
autoDelegate: balanced # default: balanced; "off" | "balanced" | "eager" — the delegation policy
|
|
799
886
|
update: # 0.3.0 — automatic update check
|
|
@@ -802,9 +889,12 @@ Complete key set, with the schema defaults shown in comments:
|
|
|
802
889
|
intervalHours: 24 # default: 24; explicit 0 = check at boot only
|
|
803
890
|
```
|
|
804
891
|
|
|
805
|
-
The
|
|
806
|
-
|
|
807
|
-
|
|
892
|
+
The three lists are shown commented out because their default is a built-in list rather than a
|
|
893
|
+
literal value: omitting the key keeps the built-ins, while writing any list — including `[]` —
|
|
894
|
+
replaces them, and `[]` switches that classifier or trigger off entirely. `planningSkills` differs
|
|
895
|
+
in one way: its entries are normalized — trimmed, lowercased, de-duplicated, anything that is not
|
|
896
|
+
a kebab-case skill name dropped — so a list whose entries are all invalid is exactly the same as
|
|
897
|
+
`[]`. See [Planning skills](#planning-skills).
|
|
808
898
|
|
|
809
899
|
Behaviours of the `update` block worth knowing:
|
|
810
900
|
|
|
@@ -833,6 +923,12 @@ Behaviours of `readConfig` worth knowing:
|
|
|
833
923
|
individual route. A route written with the snake_case alias is called out by name —
|
|
834
924
|
`unknown key "roles.planning.models[].reasoning_effort" ignored — the key is
|
|
835
925
|
"reasoningEffort"`.
|
|
926
|
+
- `strategy.planningSkills` normalizes differently from the keyword lists: entries are trimmed,
|
|
927
|
+
lowercased, de-duplicated and dropped when they are not kebab-case skill names, so an absent or
|
|
928
|
+
non-list value means the `['grill-me', 'grilling']` defaults while *any* list replaces them —
|
|
929
|
+
including one that normalizes down to empty, which is the disabled state. Membership is checked
|
|
930
|
+
against the live config on every request, so adding a skill and setting `[]` both take effect on
|
|
931
|
+
the next request with no restart.
|
|
836
932
|
- `historyLimit` accepts any positive number, floored to an integer and raised to a
|
|
837
933
|
minimum of 1, so a fractional value cannot floor to 0 and silently disable usage
|
|
838
934
|
tracking. `0`, a negative number, a non-number or an absent key all mean 300.
|
|
@@ -922,8 +1018,8 @@ The plugin registers one read-only tool, `model_manager`, with five actions:
|
|
|
922
1018
|
|
|
923
1019
|
| Action | Returns |
|
|
924
1020
|
| --- | --- |
|
|
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. |
|
|
1021
|
+
| `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. |
|
|
1022
|
+
| `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. |
|
|
927
1023
|
| `usage` | Request and subagent counts per role/model across the whole process, including top-level turns. |
|
|
928
1024
|
| `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
1025
|
| `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. |
|
|
@@ -1002,6 +1098,12 @@ The `reason` column is the outcome for that request:
|
|
|
1002
1098
|
| `advisory (not applied)` | `advisory` mode classified the request but changed nothing; the model shown is the one actually used. |
|
|
1003
1099
|
| `passthrough (role unconfigured)` | The role resolved to no route at all, so the request was returned unchanged. |
|
|
1004
1100
|
|
|
1101
|
+
A planning-skill escalation adds **no reason string**: the row reads exactly as it would in plan
|
|
1102
|
+
mode — `applied`, or `explicit session selection (respected)` when a hand-picked composer model is
|
|
1103
|
+
running — and the skill is named on its own line under the table,
|
|
1104
|
+
`Planning skill trigger: <session> → <skill>`, which appears only for sessions that reached
|
|
1105
|
+
`planning` through a skill.
|
|
1106
|
+
|
|
1005
1107
|
Verbatim example rows for the two reasons not shown above:
|
|
1006
1108
|
|
|
1007
1109
|
```text
|
|
@@ -1172,7 +1274,9 @@ mistaken for a normal "no routes listed" state.
|
|
|
1172
1274
|
## Tuning the classification
|
|
1173
1275
|
|
|
1174
1276
|
`strategy.visionKeywords` and `strategy.planningKeywords` are the whole classification
|
|
1175
|
-
policy
|
|
1277
|
+
policy **for delegated work**. A subagent is classified by its label and nothing else; the
|
|
1278
|
+
top-level tier comes from plan mode and `strategy.planningSkills`, documented under
|
|
1279
|
+
[Planning skills](#planning-skills).
|
|
1176
1280
|
|
|
1177
1281
|
- **An absent key uses the built-ins. An explicit `[]` disables that classifier.** That
|
|
1178
1282
|
is the only way to switch one off: `visionKeywords: []` sends every vision word to the
|
|
@@ -1248,7 +1352,11 @@ over keyword matches — to leave `provider` and `model` unset so the role route
|
|
|
1248
1352
|
(dropped under `advisory`), and it lists each role's
|
|
1249
1353
|
effective models (including a fallback). It is empty text when no role has any models, so
|
|
1250
1354
|
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.
|
|
1355
|
+
planning tier is missing it says so, so a `plan:` label is never a silent no-op. When
|
|
1356
|
+
`planningSkills` is non-empty **and** the planning role has models, the same section adds one
|
|
1357
|
+
line saying that a top-level session which invoked one of those skills runs on the planning tier,
|
|
1358
|
+
like plan mode; with no models behind the tier it stays quiet rather than advertising a trigger
|
|
1359
|
+
that routes nowhere.
|
|
1252
1360
|
|
|
1253
1361
|
## How it stays safe
|
|
1254
1362
|
|
|
@@ -1288,10 +1396,15 @@ degrades to a notice or a log line.
|
|
|
1288
1396
|
shape change degrades to "unset" rather than a render error.
|
|
1289
1397
|
- **Every optional integration is probed and wrapped.** Plan mode, the agent list and
|
|
1290
1398
|
lineage, the parent's request header, subagent listing, the allow-list service, the
|
|
1291
|
-
model-capability lookup,
|
|
1399
|
+
model-capability lookup, the `sessionProjections` registry the planning-skill fold is read
|
|
1400
|
+
from, `tools` and `systemPrompt` are each reached through a guarded
|
|
1292
1401
|
accessor and a `try`/`catch`; a missing service means that feature is inert, not that the
|
|
1293
1402
|
plugin fails. The `agent/request` handler catches its own errors, logs one warning
|
|
1294
1403
|
(`routing skipped for one request: …`) and returns the request it was given, unchanged.
|
|
1404
|
+
The `agent/pre-step` observer is observe-only: it wraps its own scan in a `try`, never
|
|
1405
|
+
touches the decision it returns, and ignores a rejected step. Without the projection registry
|
|
1406
|
+
the skill trigger falls back to the in-process pre-step signal alone, so it stops surviving a
|
|
1407
|
+
restart; without either signal the session simply stays on `main`.
|
|
1295
1408
|
- **The delegation policy cannot corrupt a prompt.** The section's text function is wrapped
|
|
1296
1409
|
end-to-end and returns `''` on any failure — including a throwing `tools.get` — so the
|
|
1297
1410
|
worst case is the pre-0.3.0 prompt with no policy, never a broken assembly. It renders
|
|
@@ -1323,8 +1436,9 @@ degrades to a notice or a log line.
|
|
|
1323
1436
|
and the route-level form with its `reasoningEffort` hint.
|
|
1324
1437
|
- **The pure helpers are exported for testing:** `name`, `Config`, `apply` plus
|
|
1325
1438
|
`readConfig`, `applyRoute`, `effectiveRouteOf`, `parseVersion`, `compareVersions`,
|
|
1326
|
-
`installedVersion`, `profileHint`, `delegationPolicyText`
|
|
1327
|
-
|
|
1439
|
+
`installedVersion`, `profileHint`, `delegationPolicyText`, `skillNamesOfEvent` — the skill
|
|
1440
|
+
fold's whole recognizer, so the gesture, injection and `tool/call` paths are testable without
|
|
1441
|
+
a session — and the three default lists (vision keywords, planning keywords, planning skills).
|
|
1328
1442
|
- **It does not touch the subagent allow-list row**, precisely to avoid the duplicate
|
|
1329
1443
|
loader entry id that would abort startup.
|
|
1330
1444
|
- **The `model_manager` tool is read-only.** Its description says so and the
|
|
@@ -1337,7 +1451,7 @@ degrades to a notice or a log line.
|
|
|
1337
1451
|
npm test
|
|
1338
1452
|
```
|
|
1339
1453
|
|
|
1340
|
-
Runs
|
|
1454
|
+
Runs eleven suites in child processes and aggregates the result — **949 assertions** at the time
|
|
1341
1455
|
of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
|
|
1342
1456
|
|
|
1343
1457
|
| Suite | Assertions | What it pins |
|
|
@@ -1350,8 +1464,9 @@ of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
|
|
|
1350
1464
|
| `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
1465
|
| `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. |
|
|
1352
1466
|
| `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. |
|
|
1353
|
-
| `usage-projection.test.mjs` |
|
|
1467
|
+
| `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`). |
|
|
1354
1468
|
| `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. |
|
|
1469
|
+
| `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. |
|
|
1355
1470
|
|
|
1356
1471
|
The suites are plain Node scripts — no test framework, and no dependency beyond Node itself.
|
|
1357
1472
|
|
|
@@ -1377,6 +1492,13 @@ outside the repository.
|
|
|
1377
1492
|
- **Leading-boundary matching still matches word prefixes** (`plan` in `"planet"`,
|
|
1378
1493
|
`render` in `"rendering"`), and the first match wins with vision tested before planning.
|
|
1379
1494
|
Two classifier lists cannot express precedence beyond that.
|
|
1495
|
+
- **The planning-skill trigger is sticky, and there is no exit gesture.** Once a session invokes
|
|
1496
|
+
a listed skill it stays on `planning` for the rest of that session: the durable
|
|
1497
|
+
`modelManagerPlanningSkill` fold records what the session *invoked*, not what is currently in
|
|
1498
|
+
force, and it is append-only. Start a new session, or set `strategy.planningSkills: []`, to opt
|
|
1499
|
+
out. A skill the **model** invoked (through its `skill` tool) escalates only from the next
|
|
1500
|
+
request of that session onward — the `tool/call` event exists only once the model has emitted
|
|
1501
|
+
it, so the step that asked for the skill still runs on the route already chosen.
|
|
1380
1502
|
- **`hybrid` compares routes by value.** A child that deliberately names the same route as
|
|
1381
1503
|
the parent's effective route is indistinguishable from one that inherited it, and will
|
|
1382
1504
|
be rewritten to the role route.
|
|
@@ -1422,9 +1544,9 @@ outside the repository.
|
|
|
1422
1544
|
at 42 characters with `…`, and `"` becomes `'`.
|
|
1423
1545
|
- **`roles.<role>.note` affects only the `routes` table.** It is human annotation; no
|
|
1424
1546
|
routing decision, report or count reads it, and the boot log does not print it.
|
|
1425
|
-
- **`main` empty is the simplest policy, and now not the only one.** With `main: []` a
|
|
1426
|
-
|
|
1427
|
-
`hybrid`, a session whose model was picked by hand keeps it (see "`main` and the composer's
|
|
1547
|
+
- **`main` empty is the simplest policy, and now not the only one.** With `main: []` a top-level
|
|
1548
|
+
turn outside plan mode and outside a planning skill is never rewritten. With `main` configured
|
|
1549
|
+
under `hybrid`, a session whose model was picked by hand keeps it (see "`main` and the composer's
|
|
1428
1550
|
model picker") and only untouched sessions are rewritten; under `managed` every top-level
|
|
1429
1551
|
request is rewritten, chosen by hand or not.
|
|
1430
1552
|
- **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.
|
package/client.js
CHANGED
|
@@ -64,7 +64,7 @@ window.__ModuleLoader__.load({
|
|
|
64
64
|
* test/packaging.test.mjs pins it equal to package.json, so a release that
|
|
65
65
|
* forgets to bump both fails the suite instead of shipping a wrong banner.
|
|
66
66
|
*/
|
|
67
|
-
const VERSION = '0.
|
|
67
|
+
const VERSION = '0.5.0';
|
|
68
68
|
/**
|
|
69
69
|
* Registry path of this package. The scoped name is percent-encoded the
|
|
70
70
|
* way npm serves scoped packuments.
|
|
@@ -85,9 +85,9 @@ window.__ModuleLoader__.load({
|
|
|
85
85
|
summary: 'Model roles',
|
|
86
86
|
help: 'Each role names the model used for that kind of work. Changes apply immediately.',
|
|
87
87
|
roleMain: 'Main model',
|
|
88
|
-
roleMainHint: 'Top-level agent outside plan mode. Unset keeps the composer in charge. When set, it takes over only sessions that never had a manual pick — a model you chose in the composer keeps running, unless the mode is managed.',
|
|
88
|
+
roleMainHint: 'Top-level agent outside plan mode and planning skills. Unset keeps the composer in charge. When set, it takes over only sessions that never had a manual pick — a model you chose in the composer keeps running, unless the mode is managed.',
|
|
89
89
|
rolePlanning: 'Planning and reasoning',
|
|
90
|
-
rolePlanningHint: 'Used in plan mode and for delegations labelled as planning work.',
|
|
90
|
+
rolePlanningHint: 'Used in plan mode, while a planning skill such as grilling is active, and for delegations labelled as planning work.',
|
|
91
91
|
roleExecution: 'Execution',
|
|
92
92
|
roleExecutionHint: 'The default tier for delegated implementation work.',
|
|
93
93
|
roleVision: 'Image recognition',
|
|
@@ -149,9 +149,9 @@ window.__ModuleLoader__.load({
|
|
|
149
149
|
summary: '模型角色',
|
|
150
150
|
help: '每个角色指定该类工作使用的模型。更改会立即生效。',
|
|
151
151
|
roleMain: '主模型',
|
|
152
|
-
roleMainHint: '
|
|
152
|
+
roleMainHint: '非计划模式且没有规划类技能生效时顶层 Agent 使用的模型。留空则完全跟随输入框选择。设置后只接管从未手动选过模型的会话;你在输入框点选过的模型会继续使用,除非分发模式为 managed。',
|
|
153
153
|
rolePlanning: '规划与推理',
|
|
154
|
-
rolePlanningHint: '
|
|
154
|
+
rolePlanningHint: '计划模式下使用,规划类技能(如 grilling)生效时也使用,也用于标记为规划类工作的委派。',
|
|
155
155
|
roleExecution: '执行',
|
|
156
156
|
roleExecutionHint: '委派实现的默认档位。',
|
|
157
157
|
roleVision: '图像识别',
|
package/cordis.patch.yml
CHANGED
|
@@ -20,10 +20,12 @@
|
|
|
20
20
|
# `round-robin` rotates across each role's list.
|
|
21
21
|
pick: first
|
|
22
22
|
roles:
|
|
23
|
-
# Main agent outside plan mode
|
|
23
|
+
# Main agent outside plan mode and outside an active planning skill.
|
|
24
|
+
# Empty = leave the composer choice alone.
|
|
24
25
|
main:
|
|
25
26
|
models: []
|
|
26
|
-
# Plan mode
|
|
27
|
+
# Plan mode, a session that invoked a listed planning skill (0.5.0),
|
|
28
|
+
# and delegations labelled as planning/reasoning work.
|
|
27
29
|
planning:
|
|
28
30
|
models:
|
|
29
31
|
- provider: pku-corpus
|
|
@@ -38,6 +40,14 @@
|
|
|
38
40
|
models: []
|
|
39
41
|
strategy:
|
|
40
42
|
mode: hybrid
|
|
43
|
+
# Planning skills (0.5.0): skills that move the TOP-LEVEL session onto
|
|
44
|
+
# the planning role for the rest of the session, the way plan mode does.
|
|
45
|
+
# Omitting the key uses the built-in ['grill-me', 'grilling']; an
|
|
46
|
+
# explicit [] disables the trigger. Names must be lowercase kebab-case;
|
|
47
|
+
# anything else is dropped, so a typo cannot match a session by accident.
|
|
48
|
+
# planningSkills:
|
|
49
|
+
# - grill-me
|
|
50
|
+
# - grilling
|
|
41
51
|
# Auto-delegation policy (0.3.0): off | balanced | eager.
|
|
42
52
|
# Adds a system-prompt section telling the top-level agent to plan
|
|
43
53
|
# and dispatch subagents instead of doing everything itself.
|
package/lib/index.js
CHANGED
|
@@ -52,7 +52,7 @@ const ROLE_NAMES = ['main', 'planning', 'execution', 'vision'];
|
|
|
52
52
|
const KNOWN_TOP_KEYS = ['enabled', 'pick', 'roles', 'strategy', 'update'];
|
|
53
53
|
const KNOWN_ROLE_KEYS = ['models', 'note'];
|
|
54
54
|
const KNOWN_ROUTE_KEYS = ['provider', 'model', 'reasoningEffort'];
|
|
55
|
-
const KNOWN_STRATEGY_KEYS = ['mode', 'visionKeywords', 'planningKeywords', 'historyLimit', 'autoDelegate'];
|
|
55
|
+
const KNOWN_STRATEGY_KEYS = ['mode', 'visionKeywords', 'planningKeywords', 'planningSkills', 'historyLimit', 'autoDelegate'];
|
|
56
56
|
const KNOWN_UPDATE_KEYS = ['enabled', 'registry', 'intervalHours'];
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -163,6 +163,85 @@ const DEFAULT_PLANNING_KEYWORDS = [
|
|
|
163
163
|
'spec', 'specification', 'decompose', 'breakdown', 'proposal', 'root cause',
|
|
164
164
|
];
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Skills that put a top-level session on the planning tier.
|
|
168
|
+
*
|
|
169
|
+
* These are interactive thinking skills: a session that invokes one is doing
|
|
170
|
+
* design/review work for its whole life, exactly like a session in plan mode,
|
|
171
|
+
* so it should run on the planning role's more capable models rather than
|
|
172
|
+
* `main`. `grill-me` is the user-facing alias that loads `grilling`, so both
|
|
173
|
+
* names are listed. An empty list disables the trigger.
|
|
174
|
+
*/
|
|
175
|
+
const DEFAULT_PLANNING_SKILLS = ['grill-me', 'grilling'];
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The public DSH skill-name grammar and the `/name` gesture the harness scans
|
|
179
|
+
* for in direct user text.
|
|
180
|
+
*
|
|
181
|
+
* Kept byte-identical to `@deepseek-ai/dsh-tool-skill`'s `SKILL_NAME` and
|
|
182
|
+
* `SKILL_GESTURE` (dsh-tool-skill/lib/index.js): the manager must recognise
|
|
183
|
+
* exactly the gestures the harness itself turns into a skill invocation.
|
|
184
|
+
*/
|
|
185
|
+
const SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
186
|
+
const SKILL_GESTURE = /(^|\s)\/([a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/g;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Names of the skills one user message records, in order. Pure.
|
|
190
|
+
*
|
|
191
|
+
* `source.kind === 'skill-invocation'` is the canonical record of a user's
|
|
192
|
+
* `/name` invocation (DSH's own validated injection). The `/name` gesture in
|
|
193
|
+
* direct user text is scanned too, with the harness's exact grammar, so the
|
|
194
|
+
* intent is visible to `agent/pre-step` in the same step that carries it —
|
|
195
|
+
* before the injection exists and before any event is committed.
|
|
196
|
+
*/
|
|
197
|
+
function skillNamesOfMessage(message) {
|
|
198
|
+
if (message === null || typeof message !== 'object') return [];
|
|
199
|
+
const source = message.source;
|
|
200
|
+
if (source?.kind === 'skill-invocation') {
|
|
201
|
+
return typeof source.name === 'string' ? [source.name] : [];
|
|
202
|
+
}
|
|
203
|
+
if (source?.kind !== 'user') return [];
|
|
204
|
+
const names = [];
|
|
205
|
+
for (const block of Array.isArray(message.content) ? message.content : []) {
|
|
206
|
+
if (block === null || typeof block !== 'object') continue;
|
|
207
|
+
if (block.type !== 'text' || typeof block.text !== 'string') continue;
|
|
208
|
+
for (const match of block.text.matchAll(SKILL_GESTURE)) {
|
|
209
|
+
if (match[2] !== undefined) names.push(match[2]);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return names;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Names of the skills one durable event records, in event order. Pure, so both
|
|
217
|
+
* the projection fold and the pre-step scan are unit-testable without a session.
|
|
218
|
+
*
|
|
219
|
+
* Three records count, because DSH writes each of them before the request it
|
|
220
|
+
* influences:
|
|
221
|
+
* - a user-invoked skill's injected `user/message` (`source.kind ===
|
|
222
|
+
* 'skill-invocation'`, `source.name`) — the canonical record;
|
|
223
|
+
* - the `/name` gesture in direct user text (the same message helper);
|
|
224
|
+
* - a model-invoked `skill` tool call (`tool/call`, name `skill`, JSON
|
|
225
|
+
* arguments), so "grill me on this" without a slash escalates on the next
|
|
226
|
+
* request of the same session.
|
|
227
|
+
*/
|
|
228
|
+
function skillNamesOfEvent(event) {
|
|
229
|
+
if (event === null || typeof event !== 'object') return [];
|
|
230
|
+
if (event.type === 'user/message') return skillNamesOfMessage(event.data);
|
|
231
|
+
if (event.type === 'tool/call') {
|
|
232
|
+
const data = event.data;
|
|
233
|
+
if (data?.name !== 'skill' || typeof data.arguments !== 'string') return [];
|
|
234
|
+
let args;
|
|
235
|
+
try {
|
|
236
|
+
args = JSON.parse(data.arguments);
|
|
237
|
+
} catch {
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
return typeof args?.name === 'string' ? [args.name] : [];
|
|
241
|
+
}
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
|
|
166
245
|
// ---------------------------------------------------------------------------
|
|
167
246
|
// Config
|
|
168
247
|
// ---------------------------------------------------------------------------
|
|
@@ -189,6 +268,7 @@ function buildConfigSchema(z) {
|
|
|
189
268
|
mode: z.union([z.const('hybrid'), z.const('managed'), z.const('advisory')]).default('hybrid'),
|
|
190
269
|
visionKeywords: z.array(z.string()).default(DEFAULT_VISION_KEYWORDS),
|
|
191
270
|
planningKeywords: z.array(z.string()).default(DEFAULT_PLANNING_KEYWORDS),
|
|
271
|
+
planningSkills: z.array(z.string()).default(DEFAULT_PLANNING_SKILLS),
|
|
192
272
|
historyLimit: z.number().default(300),
|
|
193
273
|
autoDelegate: z.union([z.const('off'), z.const('balanced'), z.const('eager')]).default('balanced'),
|
|
194
274
|
});
|
|
@@ -281,6 +361,28 @@ function asStringArray(value, fallback) {
|
|
|
281
361
|
.filter((item) => item !== '');
|
|
282
362
|
}
|
|
283
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Normalize the `planningSkills` list.
|
|
366
|
+
*
|
|
367
|
+
* Same shape as the keyword lists: an absent or malformed value takes the
|
|
368
|
+
* built-in default, while an explicit `[]` is honoured and disables the
|
|
369
|
+
* trigger. Names are lowercased (the DSH skill grammar is lowercase) and
|
|
370
|
+
* non-kebab entries are dropped, so a typo can never match a session by
|
|
371
|
+
* accident.
|
|
372
|
+
*/
|
|
373
|
+
function normalizeSkillNames(value) {
|
|
374
|
+
const raw = readVal(value);
|
|
375
|
+
if (!Array.isArray(raw)) return [...DEFAULT_PLANNING_SKILLS];
|
|
376
|
+
const names = [];
|
|
377
|
+
for (const item of raw) {
|
|
378
|
+
if (typeof item !== 'string') continue;
|
|
379
|
+
const name = item.trim().toLowerCase();
|
|
380
|
+
if (name === '' || !SKILL_NAME.test(name) || names.includes(name)) continue;
|
|
381
|
+
names.push(name);
|
|
382
|
+
}
|
|
383
|
+
return names;
|
|
384
|
+
}
|
|
385
|
+
|
|
284
386
|
function normalizeRoute(raw) {
|
|
285
387
|
const value = readVal(raw);
|
|
286
388
|
if (value === null || typeof value !== 'object') return undefined;
|
|
@@ -504,6 +606,9 @@ function readConfig(raw) {
|
|
|
504
606
|
mode: mode === 'managed' || mode === 'advisory' ? mode : 'hybrid',
|
|
505
607
|
visionKeywords: asStringArray(strategyRaw.visionKeywords, DEFAULT_VISION_KEYWORDS),
|
|
506
608
|
planningKeywords: asStringArray(strategyRaw.planningKeywords, DEFAULT_PLANNING_KEYWORDS),
|
|
609
|
+
// Absent/malformed -> the grill defaults; explicit [] switches the
|
|
610
|
+
// skill-to-planning escalation off.
|
|
611
|
+
planningSkills: normalizeSkillNames(strategyRaw.planningSkills),
|
|
507
612
|
// Guard against a positive fraction flooring to 0, which would evict every
|
|
508
613
|
// record immediately and silently disable usage tracking.
|
|
509
614
|
historyLimit: Number.isFinite(limit) && limit > 0 ? Math.max(1, Math.floor(limit)) : 300,
|
|
@@ -879,6 +984,113 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
879
984
|
let visionMatch = keywordMatcher(config.strategy.visionKeywords);
|
|
880
985
|
let planningMatch = keywordMatcher(config.strategy.planningKeywords);
|
|
881
986
|
|
|
987
|
+
/**
|
|
988
|
+
* How many sessions' live skill names are remembered, and how many names one
|
|
989
|
+
* session keeps. Both are backstops: `agent/disposed` is the normal cleanup,
|
|
990
|
+
* and a session only ever invokes a handful of skills.
|
|
991
|
+
*/
|
|
992
|
+
const LIVE_SKILL_LIMIT = 1024;
|
|
993
|
+
const SKILL_NAME_LIMIT = 64;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* session id -> skill names seen in `agent/pre-step` batches this process.
|
|
997
|
+
*
|
|
998
|
+
* This is the signal that makes the FIRST request of a `/grilling` step route
|
|
999
|
+
* as planning. The harness fires `agent/pre-step` before `agent/request` but
|
|
1000
|
+
* commits the step's user batch (including the skill injection) only after
|
|
1001
|
+
* `agent/request` returns (`dsh-agent-loop`: `preStep()` → `prepareRequest()`
|
|
1002
|
+
* → `session.append('user/message')`), so a log-only fold would serve the
|
|
1003
|
+
* first — and most important — request of the grilling turn on `main`.
|
|
1004
|
+
*/
|
|
1005
|
+
const liveSkills = new Map();
|
|
1006
|
+
|
|
1007
|
+
/** session id -> the last top-level trigger, so the info log fires once per switch. */
|
|
1008
|
+
const topTriggers = new Map();
|
|
1009
|
+
|
|
1010
|
+
/** Add one skill name to a session's live list, bounded and de-duplicated. */
|
|
1011
|
+
function addLiveSkill(id, name) {
|
|
1012
|
+
const normalized = typeof name === 'string' ? name.trim().toLowerCase() : '';
|
|
1013
|
+
if (normalized === '' || !SKILL_NAME.test(normalized)) return;
|
|
1014
|
+
let names = liveSkills.get(id);
|
|
1015
|
+
if (names === undefined) {
|
|
1016
|
+
names = [];
|
|
1017
|
+
liveSkills.set(id, names);
|
|
1018
|
+
while (liveSkills.size > LIVE_SKILL_LIMIT) {
|
|
1019
|
+
const oldest = liveSkills.keys().next().value;
|
|
1020
|
+
if (oldest === undefined) break;
|
|
1021
|
+
liveSkills.delete(oldest);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
if (names.length >= SKILL_NAME_LIMIT || names.includes(normalized)) return;
|
|
1025
|
+
names.push(normalized);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* The planning skill currently in force for this agent, or `undefined`.
|
|
1030
|
+
*
|
|
1031
|
+
* Two sources are consulted. The live map covers the request that carries the
|
|
1032
|
+
* gesture itself; the `modelManagerPlanningSkill` projection is folded from
|
|
1033
|
+
* the durable log, so the trigger survives restart, resume and fork, and also
|
|
1034
|
+
* catches a model-invoked `skill` tool call on a later request. A skill stays
|
|
1035
|
+
* in force for the rest of the session: its instructions remain in context,
|
|
1036
|
+
* and the grilling interview spans many turns. Membership is read from the
|
|
1037
|
+
* live config on every request, so a Settings edit (or `[]`) applies to the
|
|
1038
|
+
* next request with no restart.
|
|
1039
|
+
*/
|
|
1040
|
+
function planningSkillFor(agent) {
|
|
1041
|
+
const wanted = config.strategy.planningSkills;
|
|
1042
|
+
if (wanted.length === 0) return undefined;
|
|
1043
|
+
const names = [];
|
|
1044
|
+
const live = typeof agent?.id === 'string' ? liveSkills.get(agent.id) : undefined;
|
|
1045
|
+
if (Array.isArray(live)) names.push(...live);
|
|
1046
|
+
const state = probe(() => projections?.stateOf?.(agent?.session, PLANNING_SKILL_PROJECTION_KEY));
|
|
1047
|
+
if (Array.isArray(state?.skills)) names.push(...state.skills);
|
|
1048
|
+
for (let index = names.length - 1; index >= 0; index -= 1) {
|
|
1049
|
+
const name = names[index];
|
|
1050
|
+
if (name !== undefined && wanted.includes(name)) return name;
|
|
1051
|
+
}
|
|
1052
|
+
return undefined;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Observe every pre-step batch and remember any skill it names.
|
|
1057
|
+
*
|
|
1058
|
+
* Registered with `{ prepend: true }` so its `await next()` returns the
|
|
1059
|
+
* decision *with* the harness's own skill injections (tool-skill registers as
|
|
1060
|
+
* an inner hook), and so the claimed direct user text — the `/grilling`
|
|
1061
|
+
* gesture — is visible even if that injection is unavailable. The decision is
|
|
1062
|
+
* returned untouched; anything this observer does must never fail a step.
|
|
1063
|
+
*/
|
|
1064
|
+
async function onPreStep(payload, next) {
|
|
1065
|
+
const decision = await next();
|
|
1066
|
+
try {
|
|
1067
|
+
const id = typeof payload?.agent?.id === 'string' ? payload.agent.id : undefined;
|
|
1068
|
+
if (id !== undefined && decision?.kind !== 'reject') {
|
|
1069
|
+
for (const batch of [payload?.messages, decision?.messages]) {
|
|
1070
|
+
if (!Array.isArray(batch)) continue;
|
|
1071
|
+
for (const message of batch) {
|
|
1072
|
+
for (const name of skillNamesOfMessage(message)) addLiveSkill(id, name);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
} catch {
|
|
1077
|
+
// Observe-only: a hostile message shape must never fail the step.
|
|
1078
|
+
}
|
|
1079
|
+
return decision;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/** Log a top-level trigger once per switch, never once per request. */
|
|
1083
|
+
function noteTopTrigger(agent, trigger) {
|
|
1084
|
+
const id = typeof agent?.id === 'string' ? agent.id : undefined;
|
|
1085
|
+
if (id === undefined) return;
|
|
1086
|
+
if (topTriggers.get(id) === trigger) return;
|
|
1087
|
+
topTriggers.set(id, trigger);
|
|
1088
|
+
if (trigger.startsWith('skill:')) {
|
|
1089
|
+
log('info', `planning skill "${trigger.slice('skill:'.length)}" is active in this session; `
|
|
1090
|
+
+ 'top-level requests route as planning');
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
882
1094
|
/** The model list a role actually resolves to, including the vision fallback. */
|
|
883
1095
|
function effectiveModels(key) {
|
|
884
1096
|
const role = roleOf(key);
|
|
@@ -1075,12 +1287,22 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1075
1287
|
|
|
1076
1288
|
let role;
|
|
1077
1289
|
let label;
|
|
1290
|
+
let trigger;
|
|
1078
1291
|
if (isSubagent) {
|
|
1079
1292
|
const facts = await factsFor(agent.id);
|
|
1080
1293
|
label = facts?.label;
|
|
1081
1294
|
role = classifySubagent(label);
|
|
1082
1295
|
} else {
|
|
1083
|
-
|
|
1296
|
+
// Plan mode is the harness's own "thinking work" mode; a planning skill
|
|
1297
|
+
// (`grilling` / `grill-me`) is the user's own version of the same
|
|
1298
|
+
// intent, so both put the top-level session on the planning tier.
|
|
1299
|
+
const plan = planActive(ctx, agent);
|
|
1300
|
+
const skill = plan ? undefined : planningSkillFor(agent);
|
|
1301
|
+
trigger = skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
|
|
1302
|
+
// Only claim routing when routing is on; a disabled manager still records
|
|
1303
|
+
// the trigger in its observed rows, but must not log that requests route.
|
|
1304
|
+
if (config.enabled) noteTopTrigger(agent, trigger);
|
|
1305
|
+
role = plan || skill !== undefined ? 'planning' : 'main';
|
|
1084
1306
|
}
|
|
1085
1307
|
|
|
1086
1308
|
// Master switch off: observe and record, but never rewrite a route. The
|
|
@@ -1090,6 +1312,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1090
1312
|
if (!config.enabled) {
|
|
1091
1313
|
remember(agent.id, {
|
|
1092
1314
|
role,
|
|
1315
|
+
trigger,
|
|
1093
1316
|
label,
|
|
1094
1317
|
isSubagent,
|
|
1095
1318
|
provider: resolved.provider,
|
|
@@ -1115,6 +1338,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1115
1338
|
if (candidate === undefined) {
|
|
1116
1339
|
remember(agent.id, {
|
|
1117
1340
|
role,
|
|
1341
|
+
trigger,
|
|
1118
1342
|
provider: resolved.provider,
|
|
1119
1343
|
model: resolved.model,
|
|
1120
1344
|
reason: 'passthrough (role unconfigured)',
|
|
@@ -1192,6 +1416,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1192
1416
|
|
|
1193
1417
|
remember(agent.id, {
|
|
1194
1418
|
role,
|
|
1419
|
+
trigger,
|
|
1195
1420
|
label,
|
|
1196
1421
|
isSubagent,
|
|
1197
1422
|
provider: output.provider,
|
|
@@ -1706,6 +1931,17 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1706
1931
|
lines.push('A reason ending in (respected) is the verdict itself: a human choice won and the');
|
|
1707
1932
|
lines.push('manager stepped back. Under managed it never does, and a session that never had');
|
|
1708
1933
|
lines.push('a manual pick is rewritten by the main role.');
|
|
1934
|
+
const skillTriggers = topRows.filter((row) => typeof row.seen.trigger === 'string'
|
|
1935
|
+
&& row.seen.trigger.startsWith('skill:')
|
|
1936
|
+
&& row.seen.reason !== 'manager disabled (observed only)');
|
|
1937
|
+
if (skillTriggers.length > 0) {
|
|
1938
|
+
lines.push('');
|
|
1939
|
+
lines.push('Planning skill trigger: ' + skillTriggers
|
|
1940
|
+
.map((row) => `${shortId(row.sessionId)} → ${row.seen.trigger.slice('skill:'.length)}`)
|
|
1941
|
+
.join(', '));
|
|
1942
|
+
lines.push('These sessions invoked a planning skill, so they route to the planning tier for');
|
|
1943
|
+
lines.push('the rest of the session, like plan mode; a hand-picked composer model still wins.');
|
|
1944
|
+
}
|
|
1709
1945
|
lines.push('');
|
|
1710
1946
|
}
|
|
1711
1947
|
if (rows.length > 0) {
|
|
@@ -1791,6 +2027,11 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1791
2027
|
? 'orchestrate: nearly all substantive work goes to delegations'
|
|
1792
2028
|
: 'plan and dispatch subagents for multi-step and independent work'}`}`,
|
|
1793
2029
|
'',
|
|
2030
|
+
`Planning skills: ${config.strategy.planningSkills.length === 0
|
|
2031
|
+
? '(disabled) — skills never change the top-level role'
|
|
2032
|
+
: `${config.strategy.planningSkills.join(', ')} — a top-level session that invoked one routes as `
|
|
2033
|
+
+ 'planning for the rest of the session, like plan mode'}`,
|
|
2034
|
+
'',
|
|
1794
2035
|
allowListBlock(),
|
|
1795
2036
|
'',
|
|
1796
2037
|
visionBlock,
|
|
@@ -1824,12 +2065,16 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1824
2065
|
const planningGap = effectiveModels('planning').length === 0
|
|
1825
2066
|
? '\nThe planning tier has no models, so "plan:" labels keep the inherited route.'
|
|
1826
2067
|
: '';
|
|
2068
|
+
const skillNote = config.strategy.planningSkills.length > 0 && effectiveModels('planning').length > 0
|
|
2069
|
+
? '\nA top-level session that invoked '
|
|
2070
|
+
+ `${config.strategy.planningSkills.join(' / ')} runs on the planning tier, like plan mode.`
|
|
2071
|
+
: '';
|
|
1827
2072
|
return [
|
|
1828
2073
|
'## Model manager',
|
|
1829
2074
|
'Delegated work is routed by the label you give each delegation:',
|
|
1830
2075
|
...summary,
|
|
1831
2076
|
routing,
|
|
1832
|
-
`Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}`,
|
|
2077
|
+
`Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}${skillNote}`,
|
|
1833
2078
|
].join('\n');
|
|
1834
2079
|
}
|
|
1835
2080
|
|
|
@@ -2004,6 +2249,56 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2004
2249
|
wire: { viewSchema: selectionProjectionSchema, view: (state) => state },
|
|
2005
2250
|
};
|
|
2006
2251
|
|
|
2252
|
+
/**
|
|
2253
|
+
* Skills invoked anywhere in one session, folded from the durable log.
|
|
2254
|
+
*
|
|
2255
|
+
* The projection is the durable half of the planning-skill trigger: the live
|
|
2256
|
+
* pre-step map only covers this process, while this fold survives restart,
|
|
2257
|
+
* resume and fork. It records every skill name (not just the configured
|
|
2258
|
+
* planning ones), because membership is decided against the LIVE config at
|
|
2259
|
+
* request time — adding a skill to `strategy.planningSkills` must apply to a
|
|
2260
|
+
* session that invoked it earlier in the same process, and `[]` must switch
|
|
2261
|
+
* the trigger off immediately.
|
|
2262
|
+
*
|
|
2263
|
+
* Only the append-only log feeds it (compaction shadows surface nodes but
|
|
2264
|
+
* never deletes events), and a fold that adds nothing returns the same state
|
|
2265
|
+
* reference so the projection layer does not republish.
|
|
2266
|
+
*/
|
|
2267
|
+
const PLANNING_SKILL_PROJECTION_KEY = 'modelManagerPlanningSkill';
|
|
2268
|
+
const planningSkillProjectionSchema = {
|
|
2269
|
+
parse: (value) => {
|
|
2270
|
+
if (value === null || typeof value !== 'object') throw new Error('expected an object');
|
|
2271
|
+
if (!Array.isArray(value.skills)) throw new Error('skills: expected an array');
|
|
2272
|
+
const skills = [];
|
|
2273
|
+
for (const item of value.skills) {
|
|
2274
|
+
if (typeof item !== 'string') throw new Error('skills: expected strings');
|
|
2275
|
+
const name = item.trim().toLowerCase();
|
|
2276
|
+
if (!SKILL_NAME.test(name)) throw new Error(`skills: invalid skill name "${item}"`);
|
|
2277
|
+
if (!skills.includes(name) && skills.length < SKILL_NAME_LIMIT) skills.push(name);
|
|
2278
|
+
}
|
|
2279
|
+
return { skills };
|
|
2280
|
+
},
|
|
2281
|
+
};
|
|
2282
|
+
const planningSkillProjectionDefinition = {
|
|
2283
|
+
key: PLANNING_SKILL_PROJECTION_KEY,
|
|
2284
|
+
stateVersion: 1,
|
|
2285
|
+
stateSchema: planningSkillProjectionSchema,
|
|
2286
|
+
init: () => ({ skills: [] }),
|
|
2287
|
+
apply: (state, event) => {
|
|
2288
|
+
let added;
|
|
2289
|
+
for (const name of skillNamesOfEvent(event)) {
|
|
2290
|
+
const normalized = typeof name === 'string' ? name.trim().toLowerCase() : '';
|
|
2291
|
+
if (normalized === '' || !SKILL_NAME.test(normalized)) continue;
|
|
2292
|
+
if (state.skills.includes(normalized)) continue;
|
|
2293
|
+
if (added !== undefined && added.includes(normalized)) continue;
|
|
2294
|
+
if (state.skills.length + (added?.length ?? 0) >= SKILL_NAME_LIMIT) break;
|
|
2295
|
+
(added ??= []).push(normalized);
|
|
2296
|
+
}
|
|
2297
|
+
if (added === undefined) return state;
|
|
2298
|
+
return { skills: [...state.skills, ...added] };
|
|
2299
|
+
},
|
|
2300
|
+
};
|
|
2301
|
+
|
|
2007
2302
|
/** The projection registry, captured when this composition provides one. */
|
|
2008
2303
|
let projections;
|
|
2009
2304
|
|
|
@@ -2023,6 +2318,11 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2023
2318
|
function attach() {
|
|
2024
2319
|
ctx.on('agent/request', onAgentRequest);
|
|
2025
2320
|
ctx.on('agent/request-error', onRequestError);
|
|
2321
|
+
// Prepend so `next()` returns the decision WITH the harness's own skill
|
|
2322
|
+
// injections; a normally-registered listener would run inside tool-skill's
|
|
2323
|
+
// hook and never see them. The listener is observe-only and returns the
|
|
2324
|
+
// decision untouched.
|
|
2325
|
+
ctx.on('agent/pre-step', onPreStep, { prepend: true });
|
|
2026
2326
|
|
|
2027
2327
|
// Drop per-session failover state when its agent goes away, so a long-lived
|
|
2028
2328
|
// process does not accumulate entries for sessions that can no longer run.
|
|
@@ -2036,6 +2336,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2036
2336
|
if (key.startsWith(prefix)) failover.delete(key);
|
|
2037
2337
|
}
|
|
2038
2338
|
stepSwitches.delete(id);
|
|
2339
|
+
liveSkills.delete(id);
|
|
2340
|
+
topTriggers.delete(id);
|
|
2039
2341
|
});
|
|
2040
2342
|
|
|
2041
2343
|
// Resolve a newly published child's label immediately, and targeted rather
|
|
@@ -2069,7 +2371,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2069
2371
|
scheduleUpdateChecks();
|
|
2070
2372
|
const updateChanged = JSON.stringify(previousUpdate) !== JSON.stringify(config.update);
|
|
2071
2373
|
if (updateChanged) void checkForUpdate().catch(() => {});
|
|
2072
|
-
log('info', `settings reloaded — mode ${config.strategy.mode}, pick ${config.pick}, autoDelegate ${config.strategy.autoDelegate}
|
|
2374
|
+
log('info', `settings reloaded — mode ${config.strategy.mode}, pick ${config.pick}, autoDelegate ${config.strategy.autoDelegate}, `
|
|
2375
|
+
+ `planningSkills ${config.strategy.planningSkills.join('|') || '-'}; `
|
|
2073
2376
|
+ ROLE_NAMES
|
|
2074
2377
|
.map((key) => `${key}=${config.roles[key].models.length === 0 ? '-' : config.roles[key].models.map((r) => `${r.provider}/${r.model}`).join('|')}`)
|
|
2075
2378
|
.join(' '));
|
|
@@ -2088,11 +2391,13 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2088
2391
|
name: 'model_manager',
|
|
2089
2392
|
description: 'Inspect and explain the role-based model routing configured for this harness. '
|
|
2090
2393
|
+ 'action "report": a Top-level agents section naming which model served each '
|
|
2091
|
-
+ 'conversation
|
|
2092
|
-
+ 'composer,
|
|
2394
|
+
+ 'conversation, whether the manager yielded to a model a person picked in the '
|
|
2395
|
+
+ 'composer, and which planning skill (if any) put a session on the planning tier, '
|
|
2396
|
+
+ 'then one row per subagent with its label, role, reason, live status and '
|
|
2093
2397
|
+ 'totals. action "routes": the four role assignments '
|
|
2094
2398
|
+ '(including the vision->execution fallback), the shared selection strategy (first or round-robin), '
|
|
2095
|
-
+ 'the active distribution mode, the auto-delegation level, the
|
|
2399
|
+
+ 'the active distribution mode, the auto-delegation level, the planning-skill trigger, '
|
|
2400
|
+
+ 'the update-check status, '
|
|
2096
2401
|
+ 'and whether each '
|
|
2097
2402
|
+ 'route is dispatchable by the delegation tool, with the YAML to add any that are not. '
|
|
2098
2403
|
+ 'action "usage": request and subagent counts by role and model across the whole process. '
|
|
@@ -2163,8 +2468,10 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2163
2468
|
}
|
|
2164
2469
|
registry.register(usageProjectionDefinition);
|
|
2165
2470
|
registry.register(selectionProjectionDefinition);
|
|
2471
|
+
registry.register(planningSkillProjectionDefinition);
|
|
2166
2472
|
projections = registry;
|
|
2167
|
-
log('info', `registered the ${USAGE_PROJECTION_KEY}
|
|
2473
|
+
log('info', `registered the ${USAGE_PROJECTION_KEY}, ${SELECTION_PROJECTION_KEY} and `
|
|
2474
|
+
+ `${PLANNING_SKILL_PROJECTION_KEY} session projections`);
|
|
2168
2475
|
} catch (error) {
|
|
2169
2476
|
log('warn', `could not register the usage projection: ${error?.message ?? error}`);
|
|
2170
2477
|
}
|
|
@@ -2310,6 +2617,8 @@ export {
|
|
|
2310
2617
|
installedVersion,
|
|
2311
2618
|
profileHint,
|
|
2312
2619
|
delegationPolicyText,
|
|
2620
|
+
skillNamesOfEvent,
|
|
2313
2621
|
DEFAULT_PLANNING_KEYWORDS,
|
|
2622
|
+
DEFAULT_PLANNING_SKILLS,
|
|
2314
2623
|
DEFAULT_VISION_KEYWORDS,
|
|
2315
2624
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkbear9494/dsh-model-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Role-based model manager for DeepSeek Harness: assign models to planning, execution, vision and main roles, route subagent work by role, report which model every subagent used, prompt the top-level agent to delegate, and check npm for updates.",
|
|
5
|
+
"description": "Role-based model manager for DeepSeek Harness: assign models to planning, execution, vision and main roles, route subagent work by role, escalate sessions that invoke a planning skill (grilling / grill-me) to the planning role, report which model every subagent used, prompt the top-level agent to delegate, and check npm for updates.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"dsh",
|