@darkbear9494/dsh-model-manager 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +220 -35
- package/client.js +5 -5
- package/cordis.patch.yml +12 -2
- package/lib/index.js +432 -8
- package/package.json +5 -3
- package/skills/autoplan/SKILL.md +34 -0
package/README.md
CHANGED
|
@@ -7,7 +7,12 @@ 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. Since 0.6.0 it ships one skill of its own: **`/autoplan`** turns the two
|
|
14
|
+
tiers into a workflow — the plan is designed by a `plan:`-labelled fork on the planning model, and
|
|
15
|
+
the main model implements the returned plan immediately, without stopping for approval.
|
|
11
16
|
|
|
12
17
|
## What it is
|
|
13
18
|
|
|
@@ -30,9 +35,17 @@ prefix decides the tier before any keyword is consulted, the policy never advert
|
|
|
30
35
|
with no models behind it, it teaches the delegating agent to leave `provider`/`model` unset
|
|
31
36
|
on tiered units (an explicitly named route overrides the tier under `hybrid`), and the
|
|
32
37
|
failover cursor is tracked per (session, role) so one tier's wear never pushes another tier
|
|
33
|
-
off its first model.
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
off its first model. 0.5.0 gives the top-level `planning` tier a second trigger besides plan
|
|
39
|
+
mode: a session that invoked one of the skills listed in `strategy.planningSkills` (default
|
|
40
|
+
`['grill-me', 'grilling']`) runs on the planning role's models for the rest of its life, whether
|
|
41
|
+
the intent arrived as a `/grilling` gesture in user text, as the harness's skill injection, or as
|
|
42
|
+
the model's own `skill` tool call — and it is read from a durable session projection, so it
|
|
43
|
+
survives a restart, a resume and a fork. 0.6.0 adds a second, complementary skill: `/autoplan`
|
|
44
|
+
plans on the planning tier and implements on `main` in the same turn, with no approval gate in
|
|
45
|
+
between — the label-driven tiers become a workflow instead of a setting. It is still deliberately
|
|
46
|
+
small: one ESM host file, one config schema, one bundled skill body, and one hand-written client
|
|
47
|
+
file that contributes a configuration card to the Plugins page. There is no build step for either
|
|
48
|
+
half.
|
|
36
49
|
|
|
37
50
|
## Install
|
|
38
51
|
|
|
@@ -94,11 +107,14 @@ version and updates the dependency in place.
|
|
|
94
107
|
|
|
95
108
|
### The registry copy
|
|
96
109
|
|
|
97
|
-
`@darkbear9494/dsh-model-manager@0.
|
|
98
|
-
files as 0.2.0 (the tarball grew, not the file list: the
|
|
99
|
-
README carry the new sections).
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
`@darkbear9494/dsh-model-manager@0.5.0` is the current release on the registry (published
|
|
111
|
+
2026-10-25), public access, the same 8 files as 0.2.0 (the tarball grew, not the file list: the
|
|
112
|
+
host half, the client half and this README carry the new sections). It packs 92.1 kB (292.2 kB
|
|
113
|
+
unpacked) with those 8 files; 0.2.0 packed 63.1 kB, and 0.1.0, the first publish, 62.3 kB. 0.6.0
|
|
114
|
+
is the first release with a bundled skill, so it adds a ninth file —
|
|
115
|
+
`skills/autoplan/SKILL.md` — and packs 97.1 kB (306.5 kB unpacked). The declared gate is
|
|
116
|
+
`>=0.1.7-rc.2 <0.3.0`, so every release on the 0.1.7–0.2.x runtime lines installs without an
|
|
117
|
+
exemption.
|
|
102
118
|
|
|
103
119
|
Two things learned while publishing it, in case a future version has to be released:
|
|
104
120
|
|
|
@@ -156,7 +172,8 @@ The 0.2.0 line is admitted because the host half is verified against it. Against
|
|
|
156
172
|
every API this plugin touches is unchanged from 0.1.7-rc.2: `dsh-session-projection`
|
|
157
173
|
(`stateOf`), `dsh-plan-mode`, `dsh-agent`, `dsh-subagent`, `dsh-tool-subagent` +
|
|
158
174
|
`model-selection-settings`, `dsh-tools`, `dsh-llm`, `dsh-session` and `dsh-client-modules` are
|
|
159
|
-
byte-identical, all
|
|
175
|
+
byte-identical, all six subscribed events (including `agent/pre-step`, whose dispatch and
|
|
176
|
+
decision shapes 0.5.0's skill trigger reads) and every probed service still exist, and all 22
|
|
160
177
|
failover `failure.code` values are still emitted. A real boot on that runtime applied the host
|
|
161
178
|
half, bound every event, resolved every injection and registered the `model_manager` tool. The
|
|
162
179
|
client half is unchanged too: `window.__ModuleLoader__.load({ id, factory })`, the `dsh.client`
|
|
@@ -187,7 +204,7 @@ Only a restart picks it up. Remove the old name, install the new one, then resta
|
|
|
187
204
|
|
|
188
205
|
| File | Purpose |
|
|
189
206
|
| --- | --- |
|
|
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. |
|
|
207
|
+
| `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
208
|
| `client.js` | Client half: the configuration card, contributed as a page in the Settings panel. |
|
|
192
209
|
| `locale/en.json`, `locale/zh.json` | Display metadata only — the bundle's `title` and `description` in the plugin list. |
|
|
193
210
|
| `cordis.patch.yml` | Bundle layer: inserts exactly one row, id `model-manager`. |
|
|
@@ -303,17 +320,27 @@ resolves to no route, and requests classified into it pass through unchanged —
|
|
|
303
320
|
|
|
304
321
|
| Role | What it is for | When it applies | Bundled default |
|
|
305
322
|
| --- | --- | --- | --- |
|
|
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` |
|
|
323
|
+
| `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) |
|
|
324
|
+
| `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
325
|
| `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
326
|
| `vision` | Image, screenshot, chart and OCR work. | Subagents whose label matches a vision keyword. | `models: []` (falls back to `execution`) |
|
|
310
327
|
|
|
328
|
+
A top-level session has two ways onto `planning`, and neither of them is its label:
|
|
329
|
+
the harness's plan mode, and `strategy.planningSkills` — the skills a user invokes to do thinking
|
|
330
|
+
work (`grilling`, plus the `grill-me` alias that loads it). Invoking one counts as entering the
|
|
331
|
+
tier: the session is on `planning` **for the rest of the session**, because the skill's
|
|
332
|
+
instructions stay in context and a grilling interview runs over many turns, not one. There is no
|
|
333
|
+
exit gesture — start a new session, or set `planningSkills: []`, which is the off switch — and a
|
|
334
|
+
model you hand-picked in the composer still wins under `hybrid`, the same way it does in plan mode.
|
|
335
|
+
See [Planning skills](#planning-skills).
|
|
336
|
+
|
|
311
337
|
A route is `{ provider, model, reasoningEffort? }`. The top-level `pick` is `first`
|
|
312
338
|
(default) or `round-robin` and applies to every role alike; with one model in a role's list
|
|
313
339
|
it has no effect for that role. Under `first` the list is a failover chain, and since 0.4.0
|
|
314
340
|
the wear position is tracked per **(session, role)**, not per session: a session that failed
|
|
315
341
|
over while it was serving `planning` (plan mode moves one session between `main` and
|
|
316
|
-
`planning` on every request
|
|
342
|
+
`planning` on every request; a planning skill moves it to `planning` and leaves it there) comes
|
|
343
|
+
back to `main` still on `main`'s first model. A role may
|
|
317
344
|
also carry a
|
|
318
345
|
`note` — free text for humans, printed under the role in the `routes` table and never
|
|
319
346
|
used for routing.
|
|
@@ -368,8 +395,8 @@ polling on the client, and the numbers survive a restart.
|
|
|
368
395
|
|
|
369
396
|
**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
397
|
|
|
371
|
-
Each role also carries a hint line (`Top-level agent outside plan mode
|
|
372
|
-
|
|
398
|
+
Each role also carries a hint line (`Top-level agent outside plan mode and planning skills. …`,
|
|
399
|
+
`Used for image, screenshot and OCR work. Pick a model
|
|
373
400
|
that accepts images.`, …) so the card explains itself without this README open.
|
|
374
401
|
|
|
375
402
|
The card cannot tell you whether a model accepts images: the session model catalog carries
|
|
@@ -561,7 +588,122 @@ matches, vision is tested before planning, so a label matching both lands on `vi
|
|
|
561
588
|
| `"summarize the changelog"` | nothing | `execution` | `pku-corpus/qwen3.8-flash` |
|
|
562
589
|
|
|
563
590
|
A non-subagent session is never classified by label: it gets `planning` while plan mode
|
|
564
|
-
is active
|
|
591
|
+
is active **or** while one of `strategy.planningSkills` has been invoked in it — a trigger that
|
|
592
|
+
then holds for the rest of the session — and `main` otherwise. See
|
|
593
|
+
[Planning skills](#planning-skills).
|
|
594
|
+
|
|
595
|
+
### Planning skills
|
|
596
|
+
|
|
597
|
+
`strategy.planningSkills` (default `['grill-me', 'grilling']`) is the user-facing half of the
|
|
598
|
+
planning tier: plan mode is the harness declaring that this session is doing thinking work, a
|
|
599
|
+
skill invocation is the user declaring the same thing. Both names ship in the list because
|
|
600
|
+
`grill-me` is the alias a person types and `grilling` is the skill it loads. A subagent is never
|
|
601
|
+
escalated by a skill — a child is classified by its label alone.
|
|
602
|
+
|
|
603
|
+
**Three signals count**, because DSH commits each of them before the request it can influence:
|
|
604
|
+
|
|
605
|
+
| Signal | Read from | Escalates |
|
|
606
|
+
| --- | --- | --- |
|
|
607
|
+
| 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 |
|
|
608
|
+
| A `/name` gesture in direct user text | the same two | the same step |
|
|
609
|
+
| A model-invoked `skill` tool call — `tool/call`, name `skill`, JSON `arguments.name` | the durable fold | the **next** request of that session |
|
|
610
|
+
|
|
611
|
+
Recognition uses the harness's own grammar, kept byte-identical to `dsh-tool-skill`'s: a skill
|
|
612
|
+
name is lowercase kebab-case (`[a-z0-9]+(-[a-z0-9]+)*`) and the gesture is a `/name` standing
|
|
613
|
+
alone between whitespace. So "grill me on this" written in prose matches nothing, while the
|
|
614
|
+
`skill` call the model then makes does — one request later, once that call is in the log.
|
|
615
|
+
|
|
616
|
+
**Why the first request needs a second hook.** DSH fires `agent/pre-step` *before*
|
|
617
|
+
`agent/request`, and commits the step's user batch — the skill injection included — only *after*
|
|
618
|
+
`agent/request` returns (`dsh-agent-loop`: `preStep()` → `prepareRequest()` →
|
|
619
|
+
`session.append('user/message')`). A fold-only design would therefore serve the first, and most
|
|
620
|
+
important, request of a `/grilling` turn on `main`. So the plugin registers a prepended,
|
|
621
|
+
observe-only `agent/pre-step` listener that records every skill name in the step's batches and
|
|
622
|
+
returns the harness's decision untouched. `{ prepend: true }` is what lets it see the injections
|
|
623
|
+
at all: `dsh-tool-skill` registers as an inner hook, so a normally ordered listener would run
|
|
624
|
+
inside it and never receive them. That map is per-process and is dropped with the agent on
|
|
625
|
+
`agent/disposed`.
|
|
626
|
+
|
|
627
|
+
**Why the trigger survives a restart.** The durable half is a third session projection,
|
|
628
|
+
`modelManagerPlanningSkill`, folded from the `user/message` and `tool/call` events. It stores
|
|
629
|
+
*every* skill name the session invoked, not just the configured planning ones, because membership
|
|
630
|
+
is decided against the **live** config on every request: adding a name to `planningSkills` reaches
|
|
631
|
+
a session that invoked it an hour ago, and `[]` switches the trigger off on the next request
|
|
632
|
+
without a restart. Both halves are append-only, which is what makes the trigger **sticky for the
|
|
633
|
+
rest of the session** — the way entering plan mode is, and for the same reason: the skill's
|
|
634
|
+
instructions stay in context and its interview runs over many turns. Plan mode is consulted first,
|
|
635
|
+
so a session that is in plan mode *and* has been grilled records trigger `plan-mode`; the role is
|
|
636
|
+
`planning` either way.
|
|
637
|
+
|
|
638
|
+
Normalization follows the keyword lists, with one addition: entries are trimmed, lowercased and
|
|
639
|
+
de-duplicated, and anything that is not a kebab-case skill name is dropped, so a typo in the list
|
|
640
|
+
can never match a session by accident. An absent or non-list value uses the defaults; an explicit
|
|
641
|
+
`[]` — or a list whose every entry was dropped — disables the trigger.
|
|
642
|
+
|
|
643
|
+
**What you can see of it.** The host logs one line per switch rather than per request
|
|
644
|
+
(`planning skill "grilling" is active in this session; top-level requests route as planning`),
|
|
645
|
+
`model_manager(action: "routes")` prints the live list on its `Planning skills:` line, and
|
|
646
|
+
`model_manager(action: "report")` adds a `Planning skill trigger: <session> → <skill>` line under
|
|
647
|
+
the `Top-level agents` table for any session that got there through a skill. The system-prompt
|
|
648
|
+
cheat sheet says the same, but only while the planning role actually has models behind it.
|
|
649
|
+
|
|
650
|
+
**It is a routing aid, not enforcement.** It decides which *role* a top-level request is
|
|
651
|
+
classified into, and nothing else. It cannot make a model think better, and under `hybrid` a model
|
|
652
|
+
you hand-picked in the composer still serves the session: the report row shows role `planning`
|
|
653
|
+
with reason `explicit session selection (respected)` and your route, exactly as it does in plan
|
|
654
|
+
mode. There is no exit gesture — start a new session, or set `planningSkills: []`.
|
|
655
|
+
|
|
656
|
+
### The `/autoplan` skill
|
|
657
|
+
|
|
658
|
+
`grilling` makes a session *think* on the planning tier; `/autoplan` makes it *think and then act*
|
|
659
|
+
without a review step. It is a **bundled skill**: the plugin registers it as a DSH runtime skill
|
|
660
|
+
through `ctx.skills.register` at startup, so installing the plugin is the whole install. Typing
|
|
661
|
+
`/autoplan <task>` in a session injects its body exactly like `dsh-tool-skill` injects any other
|
|
662
|
+
skill (the host recognises the `/name` gesture in direct user text, and the skill is
|
|
663
|
+
`userInvocable`); a model can also load it through the `skill` tool when the user asks to
|
|
664
|
+
plan-and-implement in one shot. The body ships as `skills/autoplan/SKILL.md`, read once at apply
|
|
665
|
+
time.
|
|
666
|
+
|
|
667
|
+
**The two phases use the two tiers, not a model swap mid-session:**
|
|
668
|
+
|
|
669
|
+
| Phase | Who runs it | Which model |
|
|
670
|
+
| --- | --- | --- |
|
|
671
|
+
| Plan | one `subagent_fork` the top-level agent dispatches, description `plan: design the implementation plan for <task>` | the `planning` role — the `plan:` label is the existing contract |
|
|
672
|
+
| Implement | the top-level session itself (or plain execution-tier units, per the delegation policy) | the `main` role |
|
|
673
|
+
|
|
674
|
+
The fork inherits the conversation, so the planner starts with every fact the main model already
|
|
675
|
+
gathered; it returns a decision-complete plan (goal, success criteria, changes by subsystem,
|
|
676
|
+
edge cases, tests, assumptions). The main model then implements it and reports what changed,
|
|
677
|
+
what it ran, and which assumptions it made on the user's behalf. The skill explicitly forbids
|
|
678
|
+
the things that would turn this into an approval flow: no `ask_user_question` to approve the
|
|
679
|
+
plan, no entering or exiting plan mode, no waiting. `autoplan` is deliberately **not** in
|
|
680
|
+
`strategy.planningSkills` — that list pins the whole session to the planning tier, while here the
|
|
681
|
+
top level must end up on `main` to implement.
|
|
682
|
+
|
|
683
|
+
**Why not switch the session's own model?** That was the other design: escalate the session to
|
|
684
|
+
`planning` on the gesture, then demote it when the plan is done. It needs a phase state machine,
|
|
685
|
+
a durable projection to survive restart, and a demotion trigger the manager cannot actually
|
|
686
|
+
observe — it would depend on the model remembering to call a marker tool, and a model that
|
|
687
|
+
forgets it leaves the whole session stuck on the expensive tier. Routing on the delegation label
|
|
688
|
+
already switches models per unit, and a fork carries the full conversation, so the two-phase
|
|
689
|
+
workflow needs no new state at all.
|
|
690
|
+
|
|
691
|
+
**Boundaries.** `/autoplan` skips *plan review*, not safety: approval prompts for risky
|
|
692
|
+
operations, sandbox limits and destructive-operation confirmations still apply, and the body says
|
|
693
|
+
so. Inside plan mode the plan-mode rules win — there the plan still goes through `exit_plan_mode`.
|
|
694
|
+
If the planning role has no models, the `plan:` unit simply keeps the inherited route and the flow
|
|
695
|
+
still runs. If `subagent_fork` is not in scope, the body falls back to plain `subagent` with a
|
|
696
|
+
self-contained prompt.
|
|
697
|
+
|
|
698
|
+
**Overrides and degradation.** The built-in copy is a runtime skill at DSH's runtime rank (250):
|
|
699
|
+
a project-level `.dsh/skills/autoplan/SKILL.md` (rank 100) or `.agents/skills/autoplan/` (200)
|
|
700
|
+
overrides it, but a `~/.dsh/skills/autoplan/` copy (rank 400) does **not** — that precedence is
|
|
701
|
+
DSH's, and it is the one surprising part of customising this skill. Registration is optional and
|
|
702
|
+
never load-bearing: no skills service in the composition, a throwing `register()`, or a missing or
|
|
703
|
+
malformed `SKILL.md` all degrade to a logged warning, and `model_manager(action: "routes")` prints
|
|
704
|
+
an `Autoplan skill: registered` / `not registered (…)` line so you can tell which case you are in.
|
|
705
|
+
Registering the skill is not routing: it happens even with `enabled: false`, where only the model
|
|
706
|
+
switch stops.
|
|
565
707
|
|
|
566
708
|
### The vision → execution fallback
|
|
567
709
|
|
|
@@ -794,6 +936,7 @@ Complete key set, with the schema defaults shown in comments:
|
|
|
794
936
|
mode: hybrid # default: hybrid; "hybrid" | "managed" | "advisory"
|
|
795
937
|
# visionKeywords: omitted = the 20 built-ins; any list you write replaces them
|
|
796
938
|
# planningKeywords: omitted = the 24 built-ins; [] DISABLES that classifier
|
|
939
|
+
# planningSkills: omitted = ['grill-me', 'grilling']; [] DISABLES the trigger
|
|
797
940
|
historyLimit: 300 # default: 300; any positive value floors to at least 1
|
|
798
941
|
autoDelegate: balanced # default: balanced; "off" | "balanced" | "eager" — the delegation policy
|
|
799
942
|
update: # 0.3.0 — automatic update check
|
|
@@ -802,9 +945,12 @@ Complete key set, with the schema defaults shown in comments:
|
|
|
802
945
|
intervalHours: 24 # default: 24; explicit 0 = check at boot only
|
|
803
946
|
```
|
|
804
947
|
|
|
805
|
-
The
|
|
806
|
-
|
|
807
|
-
|
|
948
|
+
The three lists are shown commented out because their default is a built-in list rather than a
|
|
949
|
+
literal value: omitting the key keeps the built-ins, while writing any list — including `[]` —
|
|
950
|
+
replaces them, and `[]` switches that classifier or trigger off entirely. `planningSkills` differs
|
|
951
|
+
in one way: its entries are normalized — trimmed, lowercased, de-duplicated, anything that is not
|
|
952
|
+
a kebab-case skill name dropped — so a list whose entries are all invalid is exactly the same as
|
|
953
|
+
`[]`. See [Planning skills](#planning-skills).
|
|
808
954
|
|
|
809
955
|
Behaviours of the `update` block worth knowing:
|
|
810
956
|
|
|
@@ -833,6 +979,12 @@ Behaviours of `readConfig` worth knowing:
|
|
|
833
979
|
individual route. A route written with the snake_case alias is called out by name —
|
|
834
980
|
`unknown key "roles.planning.models[].reasoning_effort" ignored — the key is
|
|
835
981
|
"reasoningEffort"`.
|
|
982
|
+
- `strategy.planningSkills` normalizes differently from the keyword lists: entries are trimmed,
|
|
983
|
+
lowercased, de-duplicated and dropped when they are not kebab-case skill names, so an absent or
|
|
984
|
+
non-list value means the `['grill-me', 'grilling']` defaults while *any* list replaces them —
|
|
985
|
+
including one that normalizes down to empty, which is the disabled state. Membership is checked
|
|
986
|
+
against the live config on every request, so adding a skill and setting `[]` both take effect on
|
|
987
|
+
the next request with no restart.
|
|
836
988
|
- `historyLimit` accepts any positive number, floored to an integer and raised to a
|
|
837
989
|
minimum of 1, so a fractional value cannot floor to 0 and silently disable usage
|
|
838
990
|
tracking. `0`, a negative number, a non-number or an absent key all mean 300.
|
|
@@ -922,8 +1074,8 @@ The plugin registers one read-only tool, `model_manager`, with five actions:
|
|
|
922
1074
|
|
|
923
1075
|
| Action | Returns |
|
|
924
1076
|
| --- | --- |
|
|
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. |
|
|
1077
|
+
| `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. |
|
|
1078
|
+
| `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
1079
|
| `usage` | Request and subagent counts per role/model across the whole process, including top-level turns. |
|
|
928
1080
|
| `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
1081
|
| `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 +1154,12 @@ The `reason` column is the outcome for that request:
|
|
|
1002
1154
|
| `advisory (not applied)` | `advisory` mode classified the request but changed nothing; the model shown is the one actually used. |
|
|
1003
1155
|
| `passthrough (role unconfigured)` | The role resolved to no route at all, so the request was returned unchanged. |
|
|
1004
1156
|
|
|
1157
|
+
A planning-skill escalation adds **no reason string**: the row reads exactly as it would in plan
|
|
1158
|
+
mode — `applied`, or `explicit session selection (respected)` when a hand-picked composer model is
|
|
1159
|
+
running — and the skill is named on its own line under the table,
|
|
1160
|
+
`Planning skill trigger: <session> → <skill>`, which appears only for sessions that reached
|
|
1161
|
+
`planning` through a skill.
|
|
1162
|
+
|
|
1005
1163
|
Verbatim example rows for the two reasons not shown above:
|
|
1006
1164
|
|
|
1007
1165
|
```text
|
|
@@ -1172,7 +1330,9 @@ mistaken for a normal "no routes listed" state.
|
|
|
1172
1330
|
## Tuning the classification
|
|
1173
1331
|
|
|
1174
1332
|
`strategy.visionKeywords` and `strategy.planningKeywords` are the whole classification
|
|
1175
|
-
policy
|
|
1333
|
+
policy **for delegated work**. A subagent is classified by its label and nothing else; the
|
|
1334
|
+
top-level tier comes from plan mode and `strategy.planningSkills`, documented under
|
|
1335
|
+
[Planning skills](#planning-skills).
|
|
1176
1336
|
|
|
1177
1337
|
- **An absent key uses the built-ins. An explicit `[]` disables that classifier.** That
|
|
1178
1338
|
is the only way to switch one off: `visionKeywords: []` sends every vision word to the
|
|
@@ -1248,7 +1408,11 @@ over keyword matches — to leave `provider` and `model` unset so the role route
|
|
|
1248
1408
|
(dropped under `advisory`), and it lists each role's
|
|
1249
1409
|
effective models (including a fallback). It is empty text when no role has any models, so
|
|
1250
1410
|
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.
|
|
1411
|
+
planning tier is missing it says so, so a `plan:` label is never a silent no-op. When
|
|
1412
|
+
`planningSkills` is non-empty **and** the planning role has models, the same section adds one
|
|
1413
|
+
line saying that a top-level session which invoked one of those skills runs on the planning tier,
|
|
1414
|
+
like plan mode; with no models behind the tier it stays quiet rather than advertising a trigger
|
|
1415
|
+
that routes nowhere.
|
|
1252
1416
|
|
|
1253
1417
|
## How it stays safe
|
|
1254
1418
|
|
|
@@ -1288,10 +1452,15 @@ degrades to a notice or a log line.
|
|
|
1288
1452
|
shape change degrades to "unset" rather than a render error.
|
|
1289
1453
|
- **Every optional integration is probed and wrapped.** Plan mode, the agent list and
|
|
1290
1454
|
lineage, the parent's request header, subagent listing, the allow-list service, the
|
|
1291
|
-
model-capability lookup,
|
|
1292
|
-
|
|
1293
|
-
|
|
1455
|
+
model-capability lookup, the `sessionProjections` registry the planning-skill fold is read
|
|
1456
|
+
from, `tools`, `systemPrompt` and the `skills` registry the `/autoplan` skill is registered
|
|
1457
|
+
on are each reached through a guarded accessor and a `try`/`catch`; a missing service means
|
|
1458
|
+
that feature is inert, not that the plugin fails. The `agent/request` handler catches its own errors, logs one warning
|
|
1294
1459
|
(`routing skipped for one request: …`) and returns the request it was given, unchanged.
|
|
1460
|
+
The `agent/pre-step` observer is observe-only: it wraps its own scan in a `try`, never
|
|
1461
|
+
touches the decision it returns, and ignores a rejected step. Without the projection registry
|
|
1462
|
+
the skill trigger falls back to the in-process pre-step signal alone, so it stops surviving a
|
|
1463
|
+
restart; without either signal the session simply stays on `main`.
|
|
1295
1464
|
- **The delegation policy cannot corrupt a prompt.** The section's text function is wrapped
|
|
1296
1465
|
end-to-end and returns `''` on any failure — including a throwing `tools.get` — so the
|
|
1297
1466
|
worst case is the pre-0.3.0 prompt with no policy, never a broken assembly. It renders
|
|
@@ -1323,8 +1492,9 @@ degrades to a notice or a log line.
|
|
|
1323
1492
|
and the route-level form with its `reasoningEffort` hint.
|
|
1324
1493
|
- **The pure helpers are exported for testing:** `name`, `Config`, `apply` plus
|
|
1325
1494
|
`readConfig`, `applyRoute`, `effectiveRouteOf`, `parseVersion`, `compareVersions`,
|
|
1326
|
-
`installedVersion`, `profileHint`, `delegationPolicyText`
|
|
1327
|
-
|
|
1495
|
+
`installedVersion`, `profileHint`, `delegationPolicyText`, `skillNamesOfEvent` — the skill
|
|
1496
|
+
fold's whole recognizer, so the gesture, injection and `tool/call` paths are testable without
|
|
1497
|
+
a session — and the three default lists (vision keywords, planning keywords, planning skills).
|
|
1328
1498
|
- **It does not touch the subagent allow-list row**, precisely to avoid the duplicate
|
|
1329
1499
|
loader entry id that would abort startup.
|
|
1330
1500
|
- **The `model_manager` tool is read-only.** Its description says so and the
|
|
@@ -1337,12 +1507,12 @@ degrades to a notice or a log line.
|
|
|
1337
1507
|
npm test
|
|
1338
1508
|
```
|
|
1339
1509
|
|
|
1340
|
-
Runs
|
|
1510
|
+
Runs twelve suites in child processes and aggregates the result — **993 assertions** at the time
|
|
1341
1511
|
of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
|
|
1342
1512
|
|
|
1343
1513
|
| Suite | Assertions | What it pins |
|
|
1344
1514
|
| --- | --- | --- |
|
|
1345
|
-
| `packaging.test.mjs` |
|
|
1515
|
+
| `packaging.test.mjs` | 37 | The package identity that nothing else cross-checks: the scoped name is the one string the bundle patch's loader row, the client half's module id and the host half's `PACKAGE_NAME` must all agree on, while the cordis row id, the client row namespace and the locale namespace must all *stay* unscoped. Plus publishability (not private, public access, a real `@deepseek-ai/dsh` version gate, schemastery still optional) and tarball completeness — every `exports` target and every `files` pattern resolved against disk, so a published package cannot mount-less. The gate is not string-matched: a self-validating semver comparator (prerelease-aware, and checked against the ordering trap first) proves the declared range admits 0.1.7-rc.2, 0.2.0-rc.2 **and** 0.2.0 while refusing 0.1.6 and 0.3.0 — because `<0.2.0` reads as "every 0.2.0 prerelease" while excluding 0.2.0 itself. 0.3.0 also pins the release plumbing both halves share: the client's `VERSION` constant equals `package.json` (a drift would ship a lying update banner), both halves fetch the same percent-encoded packument path, and the bundle patch carries the new `autoDelegate`/`update` defaults. |
|
|
1346
1516
|
| `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
1517
|
| `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
1518
|
| `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. |
|
|
@@ -1350,8 +1520,10 @@ of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
|
|
|
1350
1520
|
| `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
1521
|
| `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
1522
|
| `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` |
|
|
1523
|
+
| `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
1524
|
| `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. |
|
|
1525
|
+
| `autoplan-skill.test.mjs` | 42 | New in 0.6.0. The bundled `/autoplan` skill: the pure frontmatter parser (`parseSkillMarkdown`) accepting exactly a well-formed SKILL.md — CRLF, edge-trimming, a `---` line inside the body preserved, a `name:` line in the body not mistaken for frontmatter — and returning `undefined` for a missing/unclosed fence, an empty body, an empty description, an invalid name, and every hostile input without throwing; the shipped definition satisfying the runtime contract `dsh-skill` validates on `get()` (kebab name, non-empty description/content, both invocation flags, a string source) and its body carrying the load-bearing instructions (the `plan:`-labelled `subagent_fork`, the no-approval rule, the plan-mode boundary, the `subagent` fallback, the main-tier implementation phase) so it cannot be silently gutted; registration through a mock skills service — exactly once, the shipped definition, an info log naming the skill — and every degradation: a throwing `register()` and a composition with no skills service both leave `apply()` working with a warning, and `routes()` distinguishing registered from not; registration independent of `config.enabled`; and the routing invariant that `/autoplan` is not a planning skill — a top-level session that invoked it stays on the `main` tier, with `/grilling` as the escalating control. The packaging suite additionally pins that `skills/` is in `files` and the body ships. |
|
|
1526
|
+
| `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
1527
|
|
|
1356
1528
|
The suites are plain Node scripts — no test framework, and no dependency beyond Node itself.
|
|
1357
1529
|
|
|
@@ -1377,6 +1549,19 @@ outside the repository.
|
|
|
1377
1549
|
- **Leading-boundary matching still matches word prefixes** (`plan` in `"planet"`,
|
|
1378
1550
|
`render` in `"rendering"`), and the first match wins with vision tested before planning.
|
|
1379
1551
|
Two classifier lists cannot express precedence beyond that.
|
|
1552
|
+
- **The planning-skill trigger is sticky, and there is no exit gesture.** Once a session invokes
|
|
1553
|
+
a listed skill it stays on `planning` for the rest of that session: the durable
|
|
1554
|
+
`modelManagerPlanningSkill` fold records what the session *invoked*, not what is currently in
|
|
1555
|
+
force, and it is append-only. Start a new session, or set `strategy.planningSkills: []`, to opt
|
|
1556
|
+
out. A skill the **model** invoked (through its `skill` tool) escalates only from the next
|
|
1557
|
+
request of that session onward — the `tool/call` event exists only once the model has emitted
|
|
1558
|
+
it, so the step that asked for the skill still runs on the route already chosen.
|
|
1559
|
+
- **`/autoplan` is a workflow, not enforcement.** The body is injected as instructions, so the
|
|
1560
|
+
model decides how faithfully to follow it: nothing forces the fork, and nothing stops a model
|
|
1561
|
+
from asking a question anyway. What the plugin does guarantee is the tiers — the `plan:` label
|
|
1562
|
+
routes the planning fork, and the top-level session stays on `main` because `autoplan` is not in
|
|
1563
|
+
`planningSkills`. A project-level skill file of the same name overrides the bundled body
|
|
1564
|
+
entirely (see the override note above).
|
|
1380
1565
|
- **`hybrid` compares routes by value.** A child that deliberately names the same route as
|
|
1381
1566
|
the parent's effective route is indistinguishable from one that inherited it, and will
|
|
1382
1567
|
be rewritten to the role route.
|
|
@@ -1422,9 +1607,9 @@ outside the repository.
|
|
|
1422
1607
|
at 42 characters with `…`, and `"` becomes `'`.
|
|
1423
1608
|
- **`roles.<role>.note` affects only the `routes` table.** It is human annotation; no
|
|
1424
1609
|
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
|
|
1610
|
+
- **`main` empty is the simplest policy, and now not the only one.** With `main: []` a top-level
|
|
1611
|
+
turn outside plan mode and outside a planning skill is never rewritten. With `main` configured
|
|
1612
|
+
under `hybrid`, a session whose model was picked by hand keeps it (see "`main` and the composer's
|
|
1428
1613
|
model picker") and only untouched sessions are rewritten; under `managed` every top-level
|
|
1429
1614
|
request is rewritten, chosen by hand or not.
|
|
1430
1615
|
- **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.6.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,153 @@ 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
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Body of the bundled `/autoplan` skill, shipped beside this file.
|
|
247
|
+
*
|
|
248
|
+
* The skill is registered as a DSH runtime skill (`ctx.skills.register`) so
|
|
249
|
+
* that installing this plugin is the whole install: the user types
|
|
250
|
+
* `/autoplan <task>` and the harness injects the body like any other skill.
|
|
251
|
+
* The body is read at apply time with the same self-package read the version
|
|
252
|
+
* check already uses, so a bad install degrades to "skill not registered".
|
|
253
|
+
*/
|
|
254
|
+
const AUTOPLAN_SKILL_URL = new URL('../skills/autoplan/SKILL.md', import.meta.url);
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Parse a SKILL.md document's frontmatter and body. Pure.
|
|
258
|
+
*
|
|
259
|
+
* Deliberately minimal: the frontmatter must open the document with a `---`
|
|
260
|
+
* line, close on a `---` line, and declare single-line `name:` and
|
|
261
|
+
* `description:` values. Anything else — a missing fence, an invalid name, an
|
|
262
|
+
* empty description or an empty body — yields `undefined`, and the caller
|
|
263
|
+
* degrades to "not registered" instead of registering a malformed skill.
|
|
264
|
+
* CRLF is tolerated so a Windows checkout still loads.
|
|
265
|
+
*/
|
|
266
|
+
function parseSkillMarkdown(text) {
|
|
267
|
+
if (typeof text !== 'string') return undefined;
|
|
268
|
+
const source = text.replace(/\r\n?/g, '\n');
|
|
269
|
+
if (!source.startsWith('---\n')) return undefined;
|
|
270
|
+
let fence = source.indexOf('\n---', 4);
|
|
271
|
+
while (fence !== -1 && fence + 4 < source.length && source[fence + 4] !== '\n') {
|
|
272
|
+
fence = source.indexOf('\n---', fence + 1);
|
|
273
|
+
}
|
|
274
|
+
if (fence === -1) return undefined;
|
|
275
|
+
const frontmatter = source.slice(4, fence);
|
|
276
|
+
// Trim both edges: a body that opens with spaces would render as a Markdown
|
|
277
|
+
// code block in the harness's `<skill_instructions>` wrapper. Interior
|
|
278
|
+
// whitespace is preserved (it carries the document's structure).
|
|
279
|
+
const content = source.slice(fence + 4).trim();
|
|
280
|
+
const name = /^name:\s*(.*)$/m.exec(frontmatter)?.[1]?.trim() ?? '';
|
|
281
|
+
const description = /^description:\s*(.*)$/m.exec(frontmatter)?.[1]?.trim() ?? '';
|
|
282
|
+
if (!SKILL_NAME.test(name) || description === '' || content === '') return undefined;
|
|
283
|
+
return { name, description, content };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The runtime skill definition for `/autoplan`, or `undefined`.
|
|
288
|
+
*
|
|
289
|
+
* Shape is what `@deepseek-ai/dsh-skill`'s `register()` accepts: the body
|
|
290
|
+
* rides `content`, `source` is the display origin (this is a bundled provider,
|
|
291
|
+
* matching the harness's own `bundled` skills), and both invocation flags are
|
|
292
|
+
* on — a person can type `/autoplan`, and a model can load it through the
|
|
293
|
+
* `skill` tool when the user asks for "plan and implement in one shot".
|
|
294
|
+
*/
|
|
295
|
+
function autoplanSkillDefinition() {
|
|
296
|
+
let text;
|
|
297
|
+
try {
|
|
298
|
+
text = readFileSync(AUTOPLAN_SKILL_URL, 'utf8');
|
|
299
|
+
} catch {
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
const parsed = parseSkillMarkdown(text);
|
|
303
|
+
if (parsed === undefined) return undefined;
|
|
304
|
+
return {
|
|
305
|
+
name: parsed.name,
|
|
306
|
+
description: parsed.description,
|
|
307
|
+
content: parsed.content,
|
|
308
|
+
source: 'bundled',
|
|
309
|
+
invocation: { modelInvocable: true, userInvocable: true },
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
166
313
|
// ---------------------------------------------------------------------------
|
|
167
314
|
// Config
|
|
168
315
|
// ---------------------------------------------------------------------------
|
|
@@ -189,6 +336,7 @@ function buildConfigSchema(z) {
|
|
|
189
336
|
mode: z.union([z.const('hybrid'), z.const('managed'), z.const('advisory')]).default('hybrid'),
|
|
190
337
|
visionKeywords: z.array(z.string()).default(DEFAULT_VISION_KEYWORDS),
|
|
191
338
|
planningKeywords: z.array(z.string()).default(DEFAULT_PLANNING_KEYWORDS),
|
|
339
|
+
planningSkills: z.array(z.string()).default(DEFAULT_PLANNING_SKILLS),
|
|
192
340
|
historyLimit: z.number().default(300),
|
|
193
341
|
autoDelegate: z.union([z.const('off'), z.const('balanced'), z.const('eager')]).default('balanced'),
|
|
194
342
|
});
|
|
@@ -281,6 +429,28 @@ function asStringArray(value, fallback) {
|
|
|
281
429
|
.filter((item) => item !== '');
|
|
282
430
|
}
|
|
283
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Normalize the `planningSkills` list.
|
|
434
|
+
*
|
|
435
|
+
* Same shape as the keyword lists: an absent or malformed value takes the
|
|
436
|
+
* built-in default, while an explicit `[]` is honoured and disables the
|
|
437
|
+
* trigger. Names are lowercased (the DSH skill grammar is lowercase) and
|
|
438
|
+
* non-kebab entries are dropped, so a typo can never match a session by
|
|
439
|
+
* accident.
|
|
440
|
+
*/
|
|
441
|
+
function normalizeSkillNames(value) {
|
|
442
|
+
const raw = readVal(value);
|
|
443
|
+
if (!Array.isArray(raw)) return [...DEFAULT_PLANNING_SKILLS];
|
|
444
|
+
const names = [];
|
|
445
|
+
for (const item of raw) {
|
|
446
|
+
if (typeof item !== 'string') continue;
|
|
447
|
+
const name = item.trim().toLowerCase();
|
|
448
|
+
if (name === '' || !SKILL_NAME.test(name) || names.includes(name)) continue;
|
|
449
|
+
names.push(name);
|
|
450
|
+
}
|
|
451
|
+
return names;
|
|
452
|
+
}
|
|
453
|
+
|
|
284
454
|
function normalizeRoute(raw) {
|
|
285
455
|
const value = readVal(raw);
|
|
286
456
|
if (value === null || typeof value !== 'object') return undefined;
|
|
@@ -504,6 +674,9 @@ function readConfig(raw) {
|
|
|
504
674
|
mode: mode === 'managed' || mode === 'advisory' ? mode : 'hybrid',
|
|
505
675
|
visionKeywords: asStringArray(strategyRaw.visionKeywords, DEFAULT_VISION_KEYWORDS),
|
|
506
676
|
planningKeywords: asStringArray(strategyRaw.planningKeywords, DEFAULT_PLANNING_KEYWORDS),
|
|
677
|
+
// Absent/malformed -> the grill defaults; explicit [] switches the
|
|
678
|
+
// skill-to-planning escalation off.
|
|
679
|
+
planningSkills: normalizeSkillNames(strategyRaw.planningSkills),
|
|
507
680
|
// Guard against a positive fraction flooring to 0, which would evict every
|
|
508
681
|
// record immediately and silently disable usage tracking.
|
|
509
682
|
historyLimit: Number.isFinite(limit) && limit > 0 ? Math.max(1, Math.floor(limit)) : 300,
|
|
@@ -861,6 +1034,13 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
861
1034
|
*/
|
|
862
1035
|
let toolsService;
|
|
863
1036
|
|
|
1037
|
+
/**
|
|
1038
|
+
* Whether the bundled `/autoplan` runtime skill was registered. Surfaced by
|
|
1039
|
+
* the `routes` action so an operator can tell "the skill exists" from "this
|
|
1040
|
+
* composition has no skills service, or the shipped SKILL.md is broken".
|
|
1041
|
+
*/
|
|
1042
|
+
let autoplanRegistered = false;
|
|
1043
|
+
|
|
864
1044
|
/**
|
|
865
1045
|
* Latest update-check outcome. Statuses: `idle` (not yet checked), `checking`,
|
|
866
1046
|
* `ok` (up to date), `available` (a newer release exists), `error` (the check
|
|
@@ -879,6 +1059,113 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
879
1059
|
let visionMatch = keywordMatcher(config.strategy.visionKeywords);
|
|
880
1060
|
let planningMatch = keywordMatcher(config.strategy.planningKeywords);
|
|
881
1061
|
|
|
1062
|
+
/**
|
|
1063
|
+
* How many sessions' live skill names are remembered, and how many names one
|
|
1064
|
+
* session keeps. Both are backstops: `agent/disposed` is the normal cleanup,
|
|
1065
|
+
* and a session only ever invokes a handful of skills.
|
|
1066
|
+
*/
|
|
1067
|
+
const LIVE_SKILL_LIMIT = 1024;
|
|
1068
|
+
const SKILL_NAME_LIMIT = 64;
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* session id -> skill names seen in `agent/pre-step` batches this process.
|
|
1072
|
+
*
|
|
1073
|
+
* This is the signal that makes the FIRST request of a `/grilling` step route
|
|
1074
|
+
* as planning. The harness fires `agent/pre-step` before `agent/request` but
|
|
1075
|
+
* commits the step's user batch (including the skill injection) only after
|
|
1076
|
+
* `agent/request` returns (`dsh-agent-loop`: `preStep()` → `prepareRequest()`
|
|
1077
|
+
* → `session.append('user/message')`), so a log-only fold would serve the
|
|
1078
|
+
* first — and most important — request of the grilling turn on `main`.
|
|
1079
|
+
*/
|
|
1080
|
+
const liveSkills = new Map();
|
|
1081
|
+
|
|
1082
|
+
/** session id -> the last top-level trigger, so the info log fires once per switch. */
|
|
1083
|
+
const topTriggers = new Map();
|
|
1084
|
+
|
|
1085
|
+
/** Add one skill name to a session's live list, bounded and de-duplicated. */
|
|
1086
|
+
function addLiveSkill(id, name) {
|
|
1087
|
+
const normalized = typeof name === 'string' ? name.trim().toLowerCase() : '';
|
|
1088
|
+
if (normalized === '' || !SKILL_NAME.test(normalized)) return;
|
|
1089
|
+
let names = liveSkills.get(id);
|
|
1090
|
+
if (names === undefined) {
|
|
1091
|
+
names = [];
|
|
1092
|
+
liveSkills.set(id, names);
|
|
1093
|
+
while (liveSkills.size > LIVE_SKILL_LIMIT) {
|
|
1094
|
+
const oldest = liveSkills.keys().next().value;
|
|
1095
|
+
if (oldest === undefined) break;
|
|
1096
|
+
liveSkills.delete(oldest);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
if (names.length >= SKILL_NAME_LIMIT || names.includes(normalized)) return;
|
|
1100
|
+
names.push(normalized);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
/**
|
|
1104
|
+
* The planning skill currently in force for this agent, or `undefined`.
|
|
1105
|
+
*
|
|
1106
|
+
* Two sources are consulted. The live map covers the request that carries the
|
|
1107
|
+
* gesture itself; the `modelManagerPlanningSkill` projection is folded from
|
|
1108
|
+
* the durable log, so the trigger survives restart, resume and fork, and also
|
|
1109
|
+
* catches a model-invoked `skill` tool call on a later request. A skill stays
|
|
1110
|
+
* in force for the rest of the session: its instructions remain in context,
|
|
1111
|
+
* and the grilling interview spans many turns. Membership is read from the
|
|
1112
|
+
* live config on every request, so a Settings edit (or `[]`) applies to the
|
|
1113
|
+
* next request with no restart.
|
|
1114
|
+
*/
|
|
1115
|
+
function planningSkillFor(agent) {
|
|
1116
|
+
const wanted = config.strategy.planningSkills;
|
|
1117
|
+
if (wanted.length === 0) return undefined;
|
|
1118
|
+
const names = [];
|
|
1119
|
+
const live = typeof agent?.id === 'string' ? liveSkills.get(agent.id) : undefined;
|
|
1120
|
+
if (Array.isArray(live)) names.push(...live);
|
|
1121
|
+
const state = probe(() => projections?.stateOf?.(agent?.session, PLANNING_SKILL_PROJECTION_KEY));
|
|
1122
|
+
if (Array.isArray(state?.skills)) names.push(...state.skills);
|
|
1123
|
+
for (let index = names.length - 1; index >= 0; index -= 1) {
|
|
1124
|
+
const name = names[index];
|
|
1125
|
+
if (name !== undefined && wanted.includes(name)) return name;
|
|
1126
|
+
}
|
|
1127
|
+
return undefined;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Observe every pre-step batch and remember any skill it names.
|
|
1132
|
+
*
|
|
1133
|
+
* Registered with `{ prepend: true }` so its `await next()` returns the
|
|
1134
|
+
* decision *with* the harness's own skill injections (tool-skill registers as
|
|
1135
|
+
* an inner hook), and so the claimed direct user text — the `/grilling`
|
|
1136
|
+
* gesture — is visible even if that injection is unavailable. The decision is
|
|
1137
|
+
* returned untouched; anything this observer does must never fail a step.
|
|
1138
|
+
*/
|
|
1139
|
+
async function onPreStep(payload, next) {
|
|
1140
|
+
const decision = await next();
|
|
1141
|
+
try {
|
|
1142
|
+
const id = typeof payload?.agent?.id === 'string' ? payload.agent.id : undefined;
|
|
1143
|
+
if (id !== undefined && decision?.kind !== 'reject') {
|
|
1144
|
+
for (const batch of [payload?.messages, decision?.messages]) {
|
|
1145
|
+
if (!Array.isArray(batch)) continue;
|
|
1146
|
+
for (const message of batch) {
|
|
1147
|
+
for (const name of skillNamesOfMessage(message)) addLiveSkill(id, name);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
} catch {
|
|
1152
|
+
// Observe-only: a hostile message shape must never fail the step.
|
|
1153
|
+
}
|
|
1154
|
+
return decision;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
/** Log a top-level trigger once per switch, never once per request. */
|
|
1158
|
+
function noteTopTrigger(agent, trigger) {
|
|
1159
|
+
const id = typeof agent?.id === 'string' ? agent.id : undefined;
|
|
1160
|
+
if (id === undefined) return;
|
|
1161
|
+
if (topTriggers.get(id) === trigger) return;
|
|
1162
|
+
topTriggers.set(id, trigger);
|
|
1163
|
+
if (trigger.startsWith('skill:')) {
|
|
1164
|
+
log('info', `planning skill "${trigger.slice('skill:'.length)}" is active in this session; `
|
|
1165
|
+
+ 'top-level requests route as planning');
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
882
1169
|
/** The model list a role actually resolves to, including the vision fallback. */
|
|
883
1170
|
function effectiveModels(key) {
|
|
884
1171
|
const role = roleOf(key);
|
|
@@ -1075,12 +1362,22 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1075
1362
|
|
|
1076
1363
|
let role;
|
|
1077
1364
|
let label;
|
|
1365
|
+
let trigger;
|
|
1078
1366
|
if (isSubagent) {
|
|
1079
1367
|
const facts = await factsFor(agent.id);
|
|
1080
1368
|
label = facts?.label;
|
|
1081
1369
|
role = classifySubagent(label);
|
|
1082
1370
|
} else {
|
|
1083
|
-
|
|
1371
|
+
// Plan mode is the harness's own "thinking work" mode; a planning skill
|
|
1372
|
+
// (`grilling` / `grill-me`) is the user's own version of the same
|
|
1373
|
+
// intent, so both put the top-level session on the planning tier.
|
|
1374
|
+
const plan = planActive(ctx, agent);
|
|
1375
|
+
const skill = plan ? undefined : planningSkillFor(agent);
|
|
1376
|
+
trigger = skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
|
|
1377
|
+
// Only claim routing when routing is on; a disabled manager still records
|
|
1378
|
+
// the trigger in its observed rows, but must not log that requests route.
|
|
1379
|
+
if (config.enabled) noteTopTrigger(agent, trigger);
|
|
1380
|
+
role = plan || skill !== undefined ? 'planning' : 'main';
|
|
1084
1381
|
}
|
|
1085
1382
|
|
|
1086
1383
|
// Master switch off: observe and record, but never rewrite a route. The
|
|
@@ -1090,6 +1387,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1090
1387
|
if (!config.enabled) {
|
|
1091
1388
|
remember(agent.id, {
|
|
1092
1389
|
role,
|
|
1390
|
+
trigger,
|
|
1093
1391
|
label,
|
|
1094
1392
|
isSubagent,
|
|
1095
1393
|
provider: resolved.provider,
|
|
@@ -1115,6 +1413,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1115
1413
|
if (candidate === undefined) {
|
|
1116
1414
|
remember(agent.id, {
|
|
1117
1415
|
role,
|
|
1416
|
+
trigger,
|
|
1118
1417
|
provider: resolved.provider,
|
|
1119
1418
|
model: resolved.model,
|
|
1120
1419
|
reason: 'passthrough (role unconfigured)',
|
|
@@ -1192,6 +1491,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1192
1491
|
|
|
1193
1492
|
remember(agent.id, {
|
|
1194
1493
|
role,
|
|
1494
|
+
trigger,
|
|
1195
1495
|
label,
|
|
1196
1496
|
isSubagent,
|
|
1197
1497
|
provider: output.provider,
|
|
@@ -1706,6 +2006,17 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1706
2006
|
lines.push('A reason ending in (respected) is the verdict itself: a human choice won and the');
|
|
1707
2007
|
lines.push('manager stepped back. Under managed it never does, and a session that never had');
|
|
1708
2008
|
lines.push('a manual pick is rewritten by the main role.');
|
|
2009
|
+
const skillTriggers = topRows.filter((row) => typeof row.seen.trigger === 'string'
|
|
2010
|
+
&& row.seen.trigger.startsWith('skill:')
|
|
2011
|
+
&& row.seen.reason !== 'manager disabled (observed only)');
|
|
2012
|
+
if (skillTriggers.length > 0) {
|
|
2013
|
+
lines.push('');
|
|
2014
|
+
lines.push('Planning skill trigger: ' + skillTriggers
|
|
2015
|
+
.map((row) => `${shortId(row.sessionId)} → ${row.seen.trigger.slice('skill:'.length)}`)
|
|
2016
|
+
.join(', '));
|
|
2017
|
+
lines.push('These sessions invoked a planning skill, so they route to the planning tier for');
|
|
2018
|
+
lines.push('the rest of the session, like plan mode; a hand-picked composer model still wins.');
|
|
2019
|
+
}
|
|
1709
2020
|
lines.push('');
|
|
1710
2021
|
}
|
|
1711
2022
|
if (rows.length > 0) {
|
|
@@ -1791,6 +2102,17 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1791
2102
|
? 'orchestrate: nearly all substantive work goes to delegations'
|
|
1792
2103
|
: 'plan and dispatch subagents for multi-step and independent work'}`}`,
|
|
1793
2104
|
'',
|
|
2105
|
+
`Planning skills: ${config.strategy.planningSkills.length === 0
|
|
2106
|
+
? '(disabled) — skills never change the top-level role'
|
|
2107
|
+
: `${config.strategy.planningSkills.join(', ')} — a top-level session that invoked one routes as `
|
|
2108
|
+
+ 'planning for the rest of the session, like plan mode'}`,
|
|
2109
|
+
'',
|
|
2110
|
+
`Autoplan skill: ${autoplanRegistered
|
|
2111
|
+
? 'registered — `/autoplan` plans on the planning tier and implements on `main` '
|
|
2112
|
+
+ 'without an approval gate'
|
|
2113
|
+
: 'not registered (no skills service in this composition, or skills/autoplan/SKILL.md '
|
|
2114
|
+
+ 'is missing or invalid in this install)'}`,
|
|
2115
|
+
'',
|
|
1794
2116
|
allowListBlock(),
|
|
1795
2117
|
'',
|
|
1796
2118
|
visionBlock,
|
|
@@ -1824,12 +2146,16 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1824
2146
|
const planningGap = effectiveModels('planning').length === 0
|
|
1825
2147
|
? '\nThe planning tier has no models, so "plan:" labels keep the inherited route.'
|
|
1826
2148
|
: '';
|
|
2149
|
+
const skillNote = config.strategy.planningSkills.length > 0 && effectiveModels('planning').length > 0
|
|
2150
|
+
? '\nA top-level session that invoked '
|
|
2151
|
+
+ `${config.strategy.planningSkills.join(' / ')} runs on the planning tier, like plan mode.`
|
|
2152
|
+
: '';
|
|
1827
2153
|
return [
|
|
1828
2154
|
'## Model manager',
|
|
1829
2155
|
'Delegated work is routed by the label you give each delegation:',
|
|
1830
2156
|
...summary,
|
|
1831
2157
|
routing,
|
|
1832
|
-
`Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}`,
|
|
2158
|
+
`Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}${skillNote}`,
|
|
1833
2159
|
].join('\n');
|
|
1834
2160
|
}
|
|
1835
2161
|
|
|
@@ -2004,6 +2330,56 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2004
2330
|
wire: { viewSchema: selectionProjectionSchema, view: (state) => state },
|
|
2005
2331
|
};
|
|
2006
2332
|
|
|
2333
|
+
/**
|
|
2334
|
+
* Skills invoked anywhere in one session, folded from the durable log.
|
|
2335
|
+
*
|
|
2336
|
+
* The projection is the durable half of the planning-skill trigger: the live
|
|
2337
|
+
* pre-step map only covers this process, while this fold survives restart,
|
|
2338
|
+
* resume and fork. It records every skill name (not just the configured
|
|
2339
|
+
* planning ones), because membership is decided against the LIVE config at
|
|
2340
|
+
* request time — adding a skill to `strategy.planningSkills` must apply to a
|
|
2341
|
+
* session that invoked it earlier in the same process, and `[]` must switch
|
|
2342
|
+
* the trigger off immediately.
|
|
2343
|
+
*
|
|
2344
|
+
* Only the append-only log feeds it (compaction shadows surface nodes but
|
|
2345
|
+
* never deletes events), and a fold that adds nothing returns the same state
|
|
2346
|
+
* reference so the projection layer does not republish.
|
|
2347
|
+
*/
|
|
2348
|
+
const PLANNING_SKILL_PROJECTION_KEY = 'modelManagerPlanningSkill';
|
|
2349
|
+
const planningSkillProjectionSchema = {
|
|
2350
|
+
parse: (value) => {
|
|
2351
|
+
if (value === null || typeof value !== 'object') throw new Error('expected an object');
|
|
2352
|
+
if (!Array.isArray(value.skills)) throw new Error('skills: expected an array');
|
|
2353
|
+
const skills = [];
|
|
2354
|
+
for (const item of value.skills) {
|
|
2355
|
+
if (typeof item !== 'string') throw new Error('skills: expected strings');
|
|
2356
|
+
const name = item.trim().toLowerCase();
|
|
2357
|
+
if (!SKILL_NAME.test(name)) throw new Error(`skills: invalid skill name "${item}"`);
|
|
2358
|
+
if (!skills.includes(name) && skills.length < SKILL_NAME_LIMIT) skills.push(name);
|
|
2359
|
+
}
|
|
2360
|
+
return { skills };
|
|
2361
|
+
},
|
|
2362
|
+
};
|
|
2363
|
+
const planningSkillProjectionDefinition = {
|
|
2364
|
+
key: PLANNING_SKILL_PROJECTION_KEY,
|
|
2365
|
+
stateVersion: 1,
|
|
2366
|
+
stateSchema: planningSkillProjectionSchema,
|
|
2367
|
+
init: () => ({ skills: [] }),
|
|
2368
|
+
apply: (state, event) => {
|
|
2369
|
+
let added;
|
|
2370
|
+
for (const name of skillNamesOfEvent(event)) {
|
|
2371
|
+
const normalized = typeof name === 'string' ? name.trim().toLowerCase() : '';
|
|
2372
|
+
if (normalized === '' || !SKILL_NAME.test(normalized)) continue;
|
|
2373
|
+
if (state.skills.includes(normalized)) continue;
|
|
2374
|
+
if (added !== undefined && added.includes(normalized)) continue;
|
|
2375
|
+
if (state.skills.length + (added?.length ?? 0) >= SKILL_NAME_LIMIT) break;
|
|
2376
|
+
(added ??= []).push(normalized);
|
|
2377
|
+
}
|
|
2378
|
+
if (added === undefined) return state;
|
|
2379
|
+
return { skills: [...state.skills, ...added] };
|
|
2380
|
+
},
|
|
2381
|
+
};
|
|
2382
|
+
|
|
2007
2383
|
/** The projection registry, captured when this composition provides one. */
|
|
2008
2384
|
let projections;
|
|
2009
2385
|
|
|
@@ -2023,6 +2399,11 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2023
2399
|
function attach() {
|
|
2024
2400
|
ctx.on('agent/request', onAgentRequest);
|
|
2025
2401
|
ctx.on('agent/request-error', onRequestError);
|
|
2402
|
+
// Prepend so `next()` returns the decision WITH the harness's own skill
|
|
2403
|
+
// injections; a normally-registered listener would run inside tool-skill's
|
|
2404
|
+
// hook and never see them. The listener is observe-only and returns the
|
|
2405
|
+
// decision untouched.
|
|
2406
|
+
ctx.on('agent/pre-step', onPreStep, { prepend: true });
|
|
2026
2407
|
|
|
2027
2408
|
// Drop per-session failover state when its agent goes away, so a long-lived
|
|
2028
2409
|
// process does not accumulate entries for sessions that can no longer run.
|
|
@@ -2036,6 +2417,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2036
2417
|
if (key.startsWith(prefix)) failover.delete(key);
|
|
2037
2418
|
}
|
|
2038
2419
|
stepSwitches.delete(id);
|
|
2420
|
+
liveSkills.delete(id);
|
|
2421
|
+
topTriggers.delete(id);
|
|
2039
2422
|
});
|
|
2040
2423
|
|
|
2041
2424
|
// Resolve a newly published child's label immediately, and targeted rather
|
|
@@ -2069,7 +2452,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2069
2452
|
scheduleUpdateChecks();
|
|
2070
2453
|
const updateChanged = JSON.stringify(previousUpdate) !== JSON.stringify(config.update);
|
|
2071
2454
|
if (updateChanged) void checkForUpdate().catch(() => {});
|
|
2072
|
-
log('info', `settings reloaded — mode ${config.strategy.mode}, pick ${config.pick}, autoDelegate ${config.strategy.autoDelegate}
|
|
2455
|
+
log('info', `settings reloaded — mode ${config.strategy.mode}, pick ${config.pick}, autoDelegate ${config.strategy.autoDelegate}, `
|
|
2456
|
+
+ `planningSkills ${config.strategy.planningSkills.join('|') || '-'}; `
|
|
2073
2457
|
+ ROLE_NAMES
|
|
2074
2458
|
.map((key) => `${key}=${config.roles[key].models.length === 0 ? '-' : config.roles[key].models.map((r) => `${r.provider}/${r.model}`).join('|')}`)
|
|
2075
2459
|
.join(' '));
|
|
@@ -2088,11 +2472,13 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2088
2472
|
name: 'model_manager',
|
|
2089
2473
|
description: 'Inspect and explain the role-based model routing configured for this harness. '
|
|
2090
2474
|
+ 'action "report": a Top-level agents section naming which model served each '
|
|
2091
|
-
+ 'conversation
|
|
2092
|
-
+ 'composer,
|
|
2475
|
+
+ 'conversation, whether the manager yielded to a model a person picked in the '
|
|
2476
|
+
+ 'composer, and which planning skill (if any) put a session on the planning tier, '
|
|
2477
|
+
+ 'then one row per subagent with its label, role, reason, live status and '
|
|
2093
2478
|
+ 'totals. action "routes": the four role assignments '
|
|
2094
2479
|
+ '(including the vision->execution fallback), the shared selection strategy (first or round-robin), '
|
|
2095
|
-
+ 'the active distribution mode, the auto-delegation level, the
|
|
2480
|
+
+ 'the active distribution mode, the auto-delegation level, the planning-skill trigger, '
|
|
2481
|
+
+ 'the update-check status, '
|
|
2096
2482
|
+ 'and whether each '
|
|
2097
2483
|
+ 'route is dispatchable by the delegation tool, with the YAML to add any that are not. '
|
|
2098
2484
|
+ 'action "usage": request and subagent counts by role and model across the whole process. '
|
|
@@ -2163,8 +2549,10 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2163
2549
|
}
|
|
2164
2550
|
registry.register(usageProjectionDefinition);
|
|
2165
2551
|
registry.register(selectionProjectionDefinition);
|
|
2552
|
+
registry.register(planningSkillProjectionDefinition);
|
|
2166
2553
|
projections = registry;
|
|
2167
|
-
log('info', `registered the ${USAGE_PROJECTION_KEY}
|
|
2554
|
+
log('info', `registered the ${USAGE_PROJECTION_KEY}, ${SELECTION_PROJECTION_KEY} and `
|
|
2555
|
+
+ `${PLANNING_SKILL_PROJECTION_KEY} session projections`);
|
|
2168
2556
|
} catch (error) {
|
|
2169
2557
|
log('warn', `could not register the usage projection: ${error?.message ?? error}`);
|
|
2170
2558
|
}
|
|
@@ -2214,6 +2602,38 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2214
2602
|
log('warn', `system prompt section not registered: ${error?.message ?? error}`);
|
|
2215
2603
|
}
|
|
2216
2604
|
});
|
|
2605
|
+
|
|
2606
|
+
// The bundled `/autoplan` skill. Registration is a workflow concern, not
|
|
2607
|
+
// routing: it is deliberately independent of `config.enabled`, because a
|
|
2608
|
+
// manager that is observing only still ships the plan-then-implement
|
|
2609
|
+
// gesture, it simply stops moving the planning fork onto another model.
|
|
2610
|
+
// A composition without the skills service never runs this callback at
|
|
2611
|
+
// all, and every failure inside degrades to a warning.
|
|
2612
|
+
ctx.inject(['skills'], (scoped) => {
|
|
2613
|
+
try {
|
|
2614
|
+
const skills = scoped?.skills;
|
|
2615
|
+
if (skills === undefined || typeof skills.register !== 'function') {
|
|
2616
|
+
log('warn', 'the skills service is present but exposes no register(); /autoplan is unavailable');
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
const register = () => {
|
|
2620
|
+
const definition = autoplanSkillDefinition();
|
|
2621
|
+
if (definition === undefined) {
|
|
2622
|
+
log('warn', '/autoplan skill not registered: skills/autoplan/SKILL.md is missing or invalid');
|
|
2623
|
+
return () => {};
|
|
2624
|
+
}
|
|
2625
|
+
const dispose = skills.register(definition);
|
|
2626
|
+
autoplanRegistered = true;
|
|
2627
|
+
log('info', `registered the /autoplan skill — ${definition.description}`);
|
|
2628
|
+
return typeof dispose === 'function' ? dispose : () => {};
|
|
2629
|
+
};
|
|
2630
|
+
if (typeof scoped.effect === 'function') scoped.effect(register);
|
|
2631
|
+
else register();
|
|
2632
|
+
} catch (error) {
|
|
2633
|
+
autoplanRegistered = false;
|
|
2634
|
+
log('warn', `/autoplan skill not registered: ${error?.message ?? error}`);
|
|
2635
|
+
}
|
|
2636
|
+
});
|
|
2217
2637
|
}
|
|
2218
2638
|
|
|
2219
2639
|
// Boot diagnostic: tell the operator about role routes the delegation tool
|
|
@@ -2310,6 +2730,10 @@ export {
|
|
|
2310
2730
|
installedVersion,
|
|
2311
2731
|
profileHint,
|
|
2312
2732
|
delegationPolicyText,
|
|
2733
|
+
skillNamesOfEvent,
|
|
2734
|
+
parseSkillMarkdown,
|
|
2735
|
+
autoplanSkillDefinition,
|
|
2313
2736
|
DEFAULT_PLANNING_KEYWORDS,
|
|
2737
|
+
DEFAULT_PLANNING_SKILLS,
|
|
2314
2738
|
DEFAULT_VISION_KEYWORDS,
|
|
2315
2739
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkbear9494/dsh-model-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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, ship a /autoplan skill that plans on the planning tier then implements on main without stopping for approval, and check npm for updates.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"dsh",
|
|
9
9
|
"dsh-plugin",
|
|
10
|
+
"autoplan",
|
|
10
11
|
"deepseek-harness",
|
|
11
12
|
"cordis",
|
|
12
13
|
"model-routing",
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
},
|
|
35
36
|
"meta": {
|
|
36
37
|
"title": "Model manager",
|
|
37
|
-
"description": "Assign models to planning, execution, vision and main roles, see which model each subagent used, auto-delegate, and get update notices."
|
|
38
|
+
"description": "Assign models to planning, execution, vision and main roles, see which model each subagent used, auto-delegate, run /autoplan (plan on the planning tier, then implement on main without an approval gate), and get update notices."
|
|
38
39
|
},
|
|
39
40
|
"exports": {
|
|
40
41
|
".": "./lib/index.js",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"client.js",
|
|
48
49
|
"locale/*.json",
|
|
49
50
|
"cordis.patch.yml",
|
|
51
|
+
"skills",
|
|
50
52
|
"README.md"
|
|
51
53
|
],
|
|
52
54
|
"peerDependencies": {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: autoplan
|
|
3
|
+
description: Plan on the stronger planning tier, then implement immediately on the main tier without an approval gate. Use when the user invokes /autoplan, or asks to plan-and-implement in one shot instead of reviewing the plan first.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Work the request in two phases, back to back. Do not pause between them.
|
|
7
|
+
|
|
8
|
+
## Phase 1 — Plan (planning tier)
|
|
9
|
+
|
|
10
|
+
Gather the facts you need first — files, commands, docs. Never ask the user for anything you can look up yourself.
|
|
11
|
+
|
|
12
|
+
Dispatch the plan design as one delegation:
|
|
13
|
+
|
|
14
|
+
- Call `subagent_fork` with the description `plan: design the implementation plan for <short task name>`. The `plan:` prefix routes this unit to the planning tier's more capable model, and the fork inherits this conversation, so the planner already has the full context.
|
|
15
|
+
- Ask it for a decision-complete plan: the goal and success criteria, the changes grouped by file or subsystem, schema/API/data-flow impact, edge cases and failure modes, the tests to add or run, and explicit assumptions where the request was ambiguous.
|
|
16
|
+
- If `subagent_fork` is not available to you, use `subagent` with the same `plan:` description and a self-contained prompt carrying every fact the planner needs.
|
|
17
|
+
- If you are already running as a delegated subagent, do not delegate again: write the plan yourself in a few lines and move on.
|
|
18
|
+
|
|
19
|
+
Do not ask the user to approve, review, or adjust the plan. Do not enter plan mode for this, and never route it through `exit_plan_mode` — the whole point is that implementation does not wait on sign-off.
|
|
20
|
+
|
|
21
|
+
If the delegation fails or comes back empty, retry once. If it still fails, write a short plan yourself and continue. Never stall waiting for a plan.
|
|
22
|
+
|
|
23
|
+
## Phase 2 — Implement (main tier)
|
|
24
|
+
|
|
25
|
+
Start implementing the moment the plan comes back.
|
|
26
|
+
|
|
27
|
+
- Do not ask for confirmation or permission, and do not ask the user to choose between options you can decide yourself. Make the sensible choice, record the assumption, and carry on. The user can correct course on the result.
|
|
28
|
+
- Implement it yourself, or dispatch independent parts as plain (execution-tier) units per the active delegation policy. Label only image, screenshot, or OCR work with `vision:`.
|
|
29
|
+
- Follow the plan as written. Where reality forces a deviation, deviate minimally and note it.
|
|
30
|
+
- Keep the harness's normal safety surface: approval prompts for risky operations, sandbox limits, and destructive-operation confirmations are not part of what this skill skips. Only plan review is.
|
|
31
|
+
|
|
32
|
+
## Finish
|
|
33
|
+
|
|
34
|
+
Report what was implemented, the checks or tests you ran and their results, any deviation from the plan, and the assumptions the plan made on the user's behalf.
|