@darkbear9494/dsh-model-manager 0.6.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,12 @@ exactly as plan mode does. Since 0.6.0 it ships one skill of its own: **`/autopl
14
14
  tiers into a workflow — the plan is designed by a `plan:`-labelled fork on the planning model, and
15
15
  the main model implements the returned plan immediately, without stopping for approval. Since 0.6.1
16
16
  it also follows DSH 0.2's model-selection contract: a route is assigned with `agent.model.select()`
17
- before the step is prepared, instead of being rewritten at request time (which 0.2 aborts).
17
+ before the step is prepared, instead of being rewritten at request time (which 0.2 aborts). Since
18
+ 0.7.0 it registers its first real slash command: **`/readimage`** puts one message — and the images
19
+ attached to it — on the `vision` tier for that turn alone, then hands the session back to whatever
20
+ routing was in force. Since 0.7.1 the same one-turn contract has a cheap end: **`/quicktask`** puts
21
+ one text message on the `execution` tier for that turn alone — the simple task or quick question
22
+ that does not deserve the main model.
18
23
 
19
24
  ## What it is
20
25
 
@@ -44,7 +49,12 @@ the intent arrived as a `/grilling` gesture in user text, as the harness's skill
44
49
  the model's own `skill` tool call — and it is read from a durable session projection, so it
45
50
  survives a restart, a resume and a fork. 0.6.0 adds a second, complementary skill: `/autoplan`
46
51
  plans on the planning tier and implements on `main` in the same turn, with no approval gate in
47
- between — the label-driven tiers become a workflow instead of a setting. It is still deliberately
52
+ between — the label-driven tiers become a workflow instead of a setting. 0.7.0 adds the first
53
+ trigger that is a real slash command: `/readimage`, registered through the harness's `commands`
54
+ service, puts the one message that carries it — image attachments included — on the `vision` tier,
55
+ and only for that turn. 0.7.1 generalises that machinery into a family of one-turn commands and
56
+ adds its second member: `/quicktask` runs the one text message that carries it on the `execution`
57
+ tier, and only for that turn — the cheap end of the same contract. It is still deliberately
48
58
  small: one ESM host file, one config schema, one bundled skill body, and one hand-written client
49
59
  file that contributes a configuration card to the Plugins page. There is no build step for either
50
60
  half.
@@ -109,12 +119,14 @@ version and updates the dependency in place.
109
119
 
110
120
  ### The registry copy
111
121
 
112
- `@darkbear9494/dsh-model-manager@0.5.0` is the current release on the registry (published
113
- 2026-10-25), public access, the same 8 files as 0.2.0 (the tarball grew, not the file list: the
114
- host half, the client half and this README carry the new sections). It packs 92.1 kB (292.2 kB
115
- 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
116
- is the first release with a bundled skill, so it adds a ninth file —
117
- `skills/autoplan/SKILL.md` — and packs 97.1 kB (306.5 kB unpacked). The declared gate is
122
+ `@darkbear9494/dsh-model-manager@0.6.1` is the current release on the registry (published
123
+ 2026-11-06), public access, 9 files: the host half, the client half, this README, the two locale
124
+ dictionaries, the bundle patch, `package.json`, `LICENSE`, and `skills/autoplan/SKILL.md` — the
125
+ bundled skill 0.6.0 introduced. 0.6.0 (2026-11-05) was the first release with that ninth file and
126
+ packed 97.1 kB; 0.6.1 packs 102.4 kB (326.9 kB unpacked) with the DSH 0.2 model-selection fix.
127
+ Earlier: 0.5.0 packed 92.1 kB (292.2 kB unpacked) with the same 8 files as 0.2.0 (the tarball
128
+ grew, not the file list), 0.2.0 packed 63.1 kB, and 0.1.0, the first publish, 62.3 kB. The
129
+ declared gate is
118
130
  `>=0.1.7-rc.2 <0.3.0`, so every release on the 0.1.7–0.2.x runtime lines installs without an
119
131
  exemption.
120
132
 
@@ -707,6 +719,147 @@ an `Autoplan skill: registered` / `not registered (…)` line so you can tell wh
707
719
  Registering the skill is not routing: it happens even with `enabled: false`, where only the model
708
720
  switch stops.
709
721
 
722
+ ### The `/readimage` command
723
+
724
+ `/readimage` puts **one message** on the `vision` tier — the 图像识别 role — and only that message's
725
+ turn. It is the plugin's first **real slash command**: registered through the harness's `commands`
726
+ service, the same service `/plan` and `/compact` come from, declaring
727
+ `input: { hint: 'question about the attached image(s)', attachments: true }`, so it appears in the
728
+ composer's command autocomplete and can carry attachments. Registration needs only a composition
729
+ with a `commands` service and is independent of the model catalog; like the `/autoplan` skill, it is
730
+ not routing, so it happens even with `enabled: false`. The refusals live in the handler: with the
731
+ manager disabled, or with the vision role resolving to no models, the command returns a clear error
732
+ result instead of forwarding anything.
733
+
734
+ **Why a command and not a plain gesture.** On DSH 0.2.x the harness rejects image attachments at
735
+ prompt admission with `MODEL_DOES_NOT_SUPPORT_IMAGES` when the currently selected model declares
736
+ text-only input — *before* any plugin routing hook runs. A `/readimage` gesture typed as ordinary
737
+ text could therefore never carry an image past that gate while a text-only model is selected: the
738
+ message is refused before the manager could route it to a model that accepts images. The command
739
+ path admits attachments without the gate. The handler then forwards the original line — the
740
+ `/readimage` token included — plus the admitted image/file blocks as an ordinary user message
741
+ through `agent.followup()`, which queues a normal turn. That turn is routed by the same seams as any
742
+ other message; the token in the forwarded text is what names the intent. Bare `/readimage` with no
743
+ text and no attachments returns a usage error; bare `/readimage` with attachments forwards the token
744
+ plus the images.
745
+
746
+ **One turn, not one session.** This is the opposite of a [planning skill](#planning-skills): a skill
747
+ escalates the session for the rest of its life because its instructions stay in context, while
748
+ `/readimage` is per-message intent — the image is in *this* message, and the next message is ordinary
749
+ work again. The override is keyed to the **turn number** at the `agent/inbox/claimed` boundary — the
750
+ same seam where the 0.2.x selection reads the planning-skill gesture (see
751
+ [Switching models on DSH 0.2.x](#switching-models-on-dsh-02x)) — and maintained by `agent/pre-step`:
752
+
753
+ - Every step of the commanded turn runs on `vision`, tool-loop steps included, so the model that
754
+ sees the image keeps working with it.
755
+ - The next turn that claims a message without the gesture returns to normal routing: `main`, or
756
+ `planning` when plan mode or a planning skill is in force.
757
+ - A mid-turn steering message without the gesture does **not** cancel the override — it belongs to
758
+ the same turn.
759
+ - The override is process-live only. Nothing is folded into the durable log, so after a restart the
760
+ next message routes normally; only a fresh gesture commands a fresh turn.
761
+ - Subagent sessions are unaffected: a child's routing stays label-driven.
762
+
763
+ A short session:
764
+
765
+ ```text
766
+ you: /readimage what does this dashboard show? [screenshot attached]
767
+ → the whole turn runs on the vision role, tool-loop steps included
768
+ you: now fix the chart colours
769
+ → back on main (or planning, if plan mode or a planning skill is in force)
770
+ ```
771
+
772
+ **Precedence.** For its turn, `/readimage` outranks plan mode *and* planning skills
773
+ (`grilling` / `grill-me`): it is the most recent explicit instruction, and it names the tier for
774
+ exactly one message. Plan-mode tool restrictions still apply — they are composition-level, and only
775
+ the model changes. After the commanded turn the session returns to whatever state it was in: plan
776
+ mode, an active planning skill, or `main`.
777
+
778
+ **A hand-picked composer model yields for the turn, then comes back.** Under `hybrid` a model you
779
+ picked in the composer normally wins (see [`main` and the composer's model
780
+ picker](#main-and-the-composers-model-picker)). `/readimage` is an explicit, newer user instruction,
781
+ so it forces the vision route even over that pick — for the one turn. The pick is remembered, and
782
+ when the override ends the manager selects it back, so `hybrid` keeps respecting it on every later
783
+ turn. If you pick a *different* model in the composer after the commanded turn, that newer pick
784
+ wins over the remembered one — the restore hands back your latest choice, never a stale memory. On
785
+ the legacy DSH 0.1.x request-rewrite path nothing is durably selected in the first place, so
786
+ the pick survives automatically.
787
+
788
+ **Failover and diagnostics.** The commanded turn's role is recorded as `vision`, so in-step failover
789
+ walks the vision role's own chain — and the [image-capability warning](#vision-image-capability-check)
790
+ about text-only models in that chain still applies. The turn resolves the vision role the same way
791
+ any vision request does, including the [vision → execution fallback](#the-vision--execution-fallback)
792
+ when `vision` is empty. `model_manager(action: "report")` names the trigger `command:readimage` for
793
+ top-level turns routed this way, and `model_manager(action: "routes")` prints a line describing the
794
+ command — or saying it is disabled.
795
+
796
+ **The gesture works in plain text too.** The same word-boundary grammar that recognizes skill
797
+ gestures recognizes `/readimage` anywhere in a direct user message, so a text-only message carrying
798
+ the token routes to vision even when the command path was not used. Images still require the command
799
+ path: the admission gate above refuses them on the ordinary prompt path while a text-only model is
800
+ selected. The system-prompt cheat sheet gains one line telling the agent that you can type
801
+ `/readimage` to put one message on the vision tier.
802
+
803
+ The command name is configurable — `strategy.readImageCommand`, default `'readimage'`; an explicit
804
+ `''` disables both the command and the gesture. See [Configuration](#configuration).
805
+
806
+ ### The `/quicktask` command
807
+
808
+ `/quicktask` puts **one text message** on the `execution` tier — the 执行 role, the one that serves
809
+ delegated implementation work — and only that message's turn. It is 0.7.1's second one-turn
810
+ command: the same machinery `/readimage` introduced in 0.7.0, pointed at the cheap end of the
811
+ tier list instead of the vision end. The use case is the request that does not deserve your main
812
+ model — "rename this variable", "what does this error mean", "list the failing tests" — typed
813
+ from a session that is otherwise riding an expensive composer pick:
814
+
815
+ ```text
816
+ you: /quicktask what does this ESLint error mean?
817
+ → the whole turn runs on the execution role, tool-loop steps included
818
+ you: now refactor the module properly
819
+ → back on main (or planning, if plan mode or a planning skill is in force)
820
+ ```
821
+
822
+ Everything about the [one-turn contract](#the-readimage-command) carries over unchanged — the
823
+ turn-keyed override, the precedence over plan mode and planning skills for that turn only, the
824
+ force-then-restore of a hand-picked composer model, the process-live scope, the unaffected
825
+ subagent sessions, and the plain-text gesture recognition (the token `/quicktask` anywhere in a
826
+ direct user message routes the same way the command does). What differs:
827
+
828
+ - **Text only, on purpose.** The registration declares no attachment support, and the harness's
829
+ command executor refuses an invocation carrying attachments before dispatch. An image belongs
830
+ to `/readimage`; a quick turn must never land on an execution model that cannot read it. The
831
+ handler defends the same contract defensively: if attachments ever reach it anyway, it returns
832
+ an error instead of forwarding.
833
+ - **No admission gate to bypass.** `/readimage` needs the command path because the ordinary
834
+ prompt path refuses images while a text-only model is selected. `/quicktask` forwards plain
835
+ text, so the command registration is mostly convenience — palette discoverability, the hint,
836
+ the description — and a plain-text `/quicktask` gesture routes identically without it.
837
+ - **Failover walks the execution chain.** The commanded turn's role is recorded as `execution`,
838
+ so in-step failover walks the execution role's own list — with your quick-task model first.
839
+ The turn resolves the role the same way delegated implementation work does; there is no
840
+ fallback below `execution` (it *is* the fallback). And a command whose role resolves to no
841
+ models is inert everywhere: the handler refuses, the cheat sheet stays quiet, and the
842
+ plain-text gesture does not bind either — so the report never claims a turn "ran on" a role
843
+ nothing was selected for.
844
+ - **Two commands, one message.** A message carrying both `/readimage` and `/quicktask` tokens
845
+ binds `/readimage`: the image is physically in the message and only a vision-capable model can
846
+ serve it, while a quick turn is a cost preference you can re-issue on the next message. A
847
+ `/readimage` turn chaining straight into a `/quicktask` turn switches roles cleanly, and a
848
+ later plain turn restores the composer pick remembered before the first commanded turn.
849
+ - **Both commands must keep their own names.** The registry does not refuse a duplicate command
850
+ name (a second registration would shadow the first), so the manager resolves a config that
851
+ points both commands at one name itself: the earlier command in its scan order keeps the name
852
+ and the later one is skipped with a warning.
853
+
854
+ Diagnostics mirror the read-image ones: `model_manager(action: "report")` names the trigger
855
+ `command:quicktask` and prints a `Quick-task command:` block for sessions whose last turn was
856
+ commanded, and `model_manager(action: "routes")` prints a line describing the command — or
857
+ saying it is disabled or not registered. The system-prompt cheat sheet gains one line telling
858
+ the agent that you can type `/quicktask` to run one message on the execution tier.
859
+
860
+ The command name is configurable — `strategy.quickTaskCommand`, default `'quicktask'`; an
861
+ explicit `''` disables both the command and the gesture. See [Configuration](#configuration).
862
+
710
863
  ### Switching models on DSH 0.2.x
711
864
 
712
865
  DSH 0.2 moved model selection out of the request waterfall. The loop reads
@@ -977,6 +1130,8 @@ Complete key set, with the schema defaults shown in comments:
977
1130
  # visionKeywords: omitted = the 20 built-ins; any list you write replaces them
978
1131
  # planningKeywords: omitted = the 24 built-ins; [] DISABLES that classifier
979
1132
  # planningSkills: omitted = ['grill-me', 'grilling']; [] DISABLES the trigger
1133
+ readImageCommand: readimage # default: readimage; '' DISABLES the command and the text gesture
1134
+ quickTaskCommand: quicktask # default: quicktask; '' DISABLES the command and the text gesture
980
1135
  historyLimit: 300 # default: 300; any positive value floors to at least 1
981
1136
  autoDelegate: balanced # default: balanced; "off" | "balanced" | "eager" — the delegation policy
982
1137
  update: # 0.3.0 — automatic update check
@@ -1025,6 +1180,21 @@ Behaviours of `readConfig` worth knowing:
1025
1180
  including one that normalizes down to empty, which is the disabled state. Membership is checked
1026
1181
  against the live config on every request, so adding a skill and setting `[]` both take effect on
1027
1182
  the next request with no restart.
1183
+ - `strategy.readImageCommand` is one command name, not a list: omitting the key uses `'readimage'`,
1184
+ and an explicit `''` disables the feature entirely — no command is registered and no gesture is
1185
+ recognized. The name is trimmed and lowercased and must be kebab-case **starting with a letter**
1186
+ (`[a-z][a-z0-9]*(-[a-z0-9]+)*`) — kebab-case because the `/name` gesture scanner requires it, a
1187
+ leading letter because the command registry's own `COMMAND_NAME` does — so a name failing either
1188
+ could never be invoked as a command; an invalid name logs a warning and disables the feature
1189
+ instead of failing registration at boot. A Settings save re-registers
1190
+ the command under the new name immediately. See [The `/readimage`
1191
+ command](#the-readimage-command).
1192
+ - `strategy.quickTaskCommand` (0.7.1) follows exactly the same grammar and disable semantics for
1193
+ the quick-task command — omitted means `'quicktask'`, `''` disables it, an invalid name warns
1194
+ and disables — and one further rule: if both command names resolve to the same string, the
1195
+ earlier command (read-image) keeps the name and the quick-task command is skipped with a
1196
+ warning, because the registry would otherwise only shadow one of them. See [The `/quicktask`
1197
+ command](#the-quicktask-command).
1028
1198
  - `historyLimit` accepts any positive number, floored to an integer and raised to a
1029
1199
  minimum of 1, so a fractional value cannot floor to 0 and silently disable usage
1030
1200
  tracking. `0`, a negative number, a non-number or an absent key all mean 300.
@@ -1452,7 +1622,11 @@ planning tier is missing it says so, so a `plan:` label is never a silent no-op.
1452
1622
  `planningSkills` is non-empty **and** the planning role has models, the same section adds one
1453
1623
  line saying that a top-level session which invoked one of those skills runs on the planning tier,
1454
1624
  like plan mode; with no models behind the tier it stays quiet rather than advertising a trigger
1455
- that routes nowhere.
1625
+ that routes nowhere. One further line tells the agent that the user can type `/readimage` to put a
1626
+ single message on the vision tier (see [The `/readimage` command](#the-readimage-command)), and
1627
+ one more that the user can type `/quicktask` to run a single message on the execution tier
1628
+ (see [The `/quicktask` command](#the-quicktask-command)) — each line only while its command is
1629
+ enabled, the manager is neither disabled nor advisory, and the tier actually has models.
1456
1630
 
1457
1631
  ## How it stays safe
1458
1632
 
@@ -1534,7 +1708,10 @@ degrades to a notice or a log line.
1534
1708
  `readConfig`, `applyRoute`, `effectiveRouteOf`, `parseVersion`, `compareVersions`,
1535
1709
  `installedVersion`, `profileHint`, `delegationPolicyText`, `skillNamesOfEvent` — the skill
1536
1710
  fold's whole recognizer, so the gesture, injection and `tool/call` paths are testable without
1537
- a session — and the three default lists (vision keywords, planning keywords, planning skills).
1711
+ a session — the gesture scanner `commandGestureInMessages` with its 0.7.0 alias
1712
+ `readImageGestureInMessages`, both command-name normalizers, and the default lists and
1713
+ command names (vision keywords, planning keywords, planning skills, read-image and
1714
+ quick-task).
1538
1715
  - **It does not touch the subagent allow-list row**, precisely to avoid the duplicate
1539
1716
  loader entry id that would abort startup.
1540
1717
  - **The `model_manager` tool is read-only.** Its description says so and the
@@ -1547,8 +1724,9 @@ degrades to a notice or a log line.
1547
1724
  npm test
1548
1725
  ```
1549
1726
 
1550
- Runs thirteen suites in child processes and aggregates the result — **1019 assertions** at the time
1551
- of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
1727
+ Runs the suites in child processes and aggregates the result — **1382 assertions** across
1728
+ **15 suites** at the time of writing. Each suite also runs on
1729
+ its own: `node test/<name>.test.mjs`.
1552
1730
 
1553
1731
  | Suite | Assertions | What it pins |
1554
1732
  | --- | --- | --- |
@@ -1564,8 +1742,10 @@ of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
1564
1742
  | `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. |
1565
1743
  | `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. |
1566
1744
  | `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. |
1567
-
1568
1745
  | `model-select.test.mjs` | 26 | New in 0.6.1. DSH 0.2's selection contract: the pure helpers (`sameSelection`, `planningSkillInMessages`, `selectionModelOf`); a claimed user message selects the role's route before the step is prepared — plain prompt → `main`, `/grilling` → `planning`, `/autoplan` → `main`, plan mode → `planning`, round-robin committing only on an applied selection, and a hand-picked composer model respected under `hybrid` while `managed` overrides it; the manager's own selection is not mistaken for a hand-picked one on the next turn; `agent/request` returns the step's fixed route untouched (the 0.2 crash path); `agent/pre-step` corrects the next step; failover selects the next model and does not retry the fixed step; and a 0.1.x agent without a selection surface keeps request-time rewriting. |
1746
+ | `readimage.test.mjs` | 180 | New in 0.7.0. The `/readimage` command: the pure gesture helper `readImageGestureInMessages` (word-boundary recognition in direct user text, pinned against the real `dsh-tool-skill` grammar when a DSH install resolves) and `normalizeReadImageCommand` (the default, an explicit `''`, trimming/lowercasing, an invalid name disabling the feature with a warning), command registration through the `commands` service — name/input/handler registration, volatile rename and disable re-arming, and the handler's forwarding (frozen user message with a fresh UUID, the `/readimage` token included, attachments preserved by identity) plus every refusal path (bare command, disabled manager, advisory mode, vision-unconfigured, no inbox, throwing followup, aborted signal), the turn-keyed override lifecycle through the real seam order claim → current → pre-step → request (whole-turn vision routing including tool-loop steps, mid-turn steering not cancelling it, the next plain turn returning to normal routing, consecutive gestures), composer-pick force-then-restore — including the corner cases that the restore must hand back the user's LATEST pick (a newer composer pick made after or between commanded turns is kept, never clobbered by the stale memory) and that `main` does not eat the restored pick — precedence over plan mode and planning skills for the commanded turn only, subagent sessions never binding the override while their label routing is untouched, the legacy 0.1.x rewrite path with the explicit-selection bypass for that one turn, both diagnostic surfaces, the cheat sheet never advertising the command while disabled or advisory, and `agent/disposed` clean rebind. Since 0.7.1 the suite also pins the exact 0.7.0 usage-error wording, so the shared handler cannot drift it. |
1747
+ | `quicktask.test.mjs` | 183 | New in 0.7.1. The `/quicktask` command, sharing the 0.7.0 turn-command machinery: `normalizeQuickTaskCommand` grammar (and the read-image normalizer staying intact through the shared core), the generic gesture scanner `commandGestureInMessages` with `readImageGestureInMessages` pinned as its alias export, command registration without attachment support and the handler's text-only contract (attachments refused defensively even though the executor refuses them first, exact usage wording pinned), every refusal path with execution-specific texts (disabled, advisory, execution-unconfigured, no inbox, throwing followup, aborted), volatile rename/disable/invalid re-arming with the read-image sibling untouched, the turn-keyed override lifecycle on the execution role (whole-turn routing, mid-turn steering, consecutive gestures, non-integer turns never binding), the quick-task-specific corners — a both-gesture message binding read-image, a `/readimage` turn chaining into a `/quicktask` turn with the original pick restored at the end, name collisions resolved first-wins in BOTH directions (with `routes` naming the collision rather than a missing service, the warning firing once per colliding name rather than per save, and the gesture scan staying consistent with the registry), and the gesture staying inert while the execution tier is empty so the report never claims a turn it could not route — composer-pick force-then-restore (including the newer-pick rules), precedence over plan mode and planning skills, subagent label routing untouched, the legacy 0.1.x rewrite path recording `applied (quick-task command, one turn)`, both diagnostic surfaces (`Quick-task command:` blocks and routes lines, gated in every disabled/advisory/unconfigured form), and `agent/disposed` clean rebind. |
1748
+
1569
1749
  The suites are plain Node scripts — no test framework, and no dependency beyond Node itself.
1570
1750
 
1571
1751
  Two of them optionally pin their expectations against the **real** harness internals rather
@@ -1610,6 +1790,18 @@ outside the repository.
1610
1790
  routes the planning fork, and the top-level session stays on `main` because `autoplan` is not in
1611
1791
  `planningSkills`. A project-level skill file of the same name overrides the bundled body
1612
1792
  entirely (see the override note above).
1793
+ - **The one-turn command overrides are process-live.** `/readimage` and `/quicktask` are
1794
+ per-message intent, not durable session
1795
+ state: nothing is folded into the log, so a restart loses an in-flight commanded turn's routing
1796
+ and the next message routes normally. Type the gesture again to command a new turn.
1797
+ - **Images need the command path on a text-only current model.** The plain-text gesture routes
1798
+ text-only messages, but it cannot carry attachments past the admission gate: on DSH 0.2.x with a
1799
+ text-only model selected, the harness refuses the images with `MODEL_DOES_NOT_SUPPORT_IMAGES`
1800
+ before any routing hook runs. Only the registered command admits them.
1801
+ - **The commands need a `commands` service in the composition.** Older harnesses without one
1802
+ register no command, and both features degrade to gesture-only routing for text messages — images
1803
+ then have no path at all while a text-only model is selected. `/quicktask` loses only the palette
1804
+ entry; its plain-text gesture routes identically.
1613
1805
  - **`hybrid` compares routes by value.** A child that deliberately names the same route as
1614
1806
  the parent's effective route is indistinguishable from one that inherited it, and will
1615
1807
  be rewritten to the role route.
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.6.1';
67
+ const VERSION = '0.7.1';
68
68
  /**
69
69
  * Registry path of this package. The scoped name is percent-encoded the
70
70
  * way npm serves scoped packuments.
package/cordis.patch.yml CHANGED
@@ -48,6 +48,21 @@
48
48
  # planningSkills:
49
49
  # - grill-me
50
50
  # - grilling
51
+ # Read-image command (0.7.0): the turn carrying `/readimage` runs on
52
+ # the vision role — one turn only, then the next message routes
53
+ # normally again. Registered as a real command with attachment
54
+ # support, so images pass admission even while a text-only model is
55
+ # selected. Omitting the key uses the built-in 'readimage'; an
56
+ # explicit '' disables the command and the gesture scan.
57
+ # readImageCommand: readimage
58
+ # Quick-task command (0.7.1): the turn carrying `/quicktask` runs on
59
+ # the execution role — the same one-turn contract, pointed at the
60
+ # cheap end: a simple task or quick question that does not deserve
61
+ # the main model. Text only (the executor refuses attachments for
62
+ # it; images belong to /readimage), and the next message routes
63
+ # normally again. Omitting the key uses the built-in 'quicktask';
64
+ # an explicit '' disables the command and the gesture scan.
65
+ # quickTaskCommand: quicktask
51
66
  # Auto-delegation policy (0.3.0): off | balanced | eager.
52
67
  # Adds a system-prompt section telling the top-level agent to plan
53
68
  # and dispatch subagents instead of doing everything itself.
package/lib/index.js CHANGED
@@ -25,6 +25,7 @@
25
25
  * @module @darkbear9494/dsh-model-manager
26
26
  */
27
27
 
28
+ import { randomUUID } from 'node:crypto';
28
29
  import { readFileSync } from 'node:fs';
29
30
 
30
31
  /**
@@ -52,7 +53,7 @@ const ROLE_NAMES = ['main', 'planning', 'execution', 'vision'];
52
53
  const KNOWN_TOP_KEYS = ['enabled', 'pick', 'roles', 'strategy', 'update'];
53
54
  const KNOWN_ROLE_KEYS = ['models', 'note'];
54
55
  const KNOWN_ROUTE_KEYS = ['provider', 'model', 'reasoningEffort'];
55
- const KNOWN_STRATEGY_KEYS = ['mode', 'visionKeywords', 'planningKeywords', 'planningSkills', 'historyLimit', 'autoDelegate'];
56
+ const KNOWN_STRATEGY_KEYS = ['mode', 'visionKeywords', 'planningKeywords', 'planningSkills', 'readImageCommand', 'quickTaskCommand', 'historyLimit', 'autoDelegate'];
56
57
  const KNOWN_UPDATE_KEYS = ['enabled', 'registry', 'intervalHours'];
57
58
 
58
59
  /**
@@ -174,6 +175,94 @@ const DEFAULT_PLANNING_KEYWORDS = [
174
175
  */
175
176
  const DEFAULT_PLANNING_SKILLS = ['grill-me', 'grilling'];
176
177
 
178
+ /**
179
+ * The command that puts ONE turn on the vision role (0.7.0).
180
+ *
181
+ * Unlike a planning skill — which escalates a session for its whole life —
182
+ * `/readimage` is per-message intent: the turn carrying it runs on the vision
183
+ * tier (the 图像识别 role), and the next message without it routes normally
184
+ * again. It is registered as a real harness command declaring attachment
185
+ * support, because the ordinary prompt path refuses images outright while a
186
+ * text-only model is selected (`MODEL_DOES_NOT_SUPPORT_IMAGES`), before any
187
+ * routing hook runs; the command path admits the images and the handler
188
+ * forwards them as an ordinary user message. An empty string disables it.
189
+ */
190
+ const DEFAULT_READ_IMAGE_COMMAND = 'readimage';
191
+
192
+ /**
193
+ * The command that puts ONE turn on the execution role (0.7.1).
194
+ *
195
+ * `/quicktask` is the cheap end of the same one-turn contract `/readimage`
196
+ * holds for vision: the turn carrying it runs on the execution tier (the
197
+ * 执行 role) — the tier that serves delegated implementation work — and the
198
+ * next message without it routes normally again. It exists for the quick
199
+ * request that does not deserve the main model: a rename, a one-line lookup,
200
+ * a "what does this error mean". It outranks plan mode, planning skills and a
201
+ * composer-picked model for its turn only, and the pick is restored
202
+ * afterwards, exactly like `/readimage`. Text only, on purpose: unlike
203
+ * `/readimage` the command does not declare attachment support, so the
204
+ * harness's executor refuses an invocation carrying attachments before
205
+ * dispatch — an image belongs to `/readimage`, and a quick turn must never
206
+ * land on an execution model that cannot read it. An empty string disables
207
+ * it.
208
+ */
209
+ const DEFAULT_QUICK_TASK_COMMAND = 'quicktask';
210
+
211
+ /**
212
+ * The manager's one-turn commands: per-message intent that owns its whole
213
+ * turn, then expires (0.7.1 generalises the 0.7.0 `/readimage` machinery).
214
+ *
215
+ * Each entry names the `strategy` key holding its command name, the role its
216
+ * turn runs on, and the surface texts (registration, refusal, routes,
217
+ * report); the engine machinery — turn binding, composer-pick restore,
218
+ * precedence over plan mode and planning skills, registration and re-arm —
219
+ * is shared and generic. `feature` is the label used in reasons and logs,
220
+ * `reportLabel` the heading the report block prints.
221
+ *
222
+ * The list order is also the precedence order for the gesture scan: a
223
+ * message carrying two command tokens binds the FIRST match, so `/readimage`
224
+ * wins over `/quicktask` — the image is physically in the message and only a
225
+ * vision-capable model can serve it, while `/quicktask` is a cost preference
226
+ * the user can re-issue on the next message.
227
+ */
228
+ const TURN_COMMANDS = [
229
+ {
230
+ key: 'readImage',
231
+ field: 'readImageCommand',
232
+ defaultName: DEFAULT_READ_IMAGE_COMMAND,
233
+ role: 'vision',
234
+ feature: 'read-image',
235
+ reportLabel: 'Read-image command:',
236
+ configureHint: 'set roles.vision.models to an image-capable model',
237
+ registeredNote: 'Registered with attachment support, so images pass admission even on a text-only current model.',
238
+ unregisteredNote: 'NOT registered (no commands service, or registration failed — see the startup log) — '
239
+ + 'only plain-text gestures route; images still need a current model that accepts them.',
240
+ description: 'Read attached images with the vision model: this message (and its turn) runs on the '
241
+ + "manager's vision role, then the next message returns to the normal route. Accepts image attachments.",
242
+ hint: 'question about the attached image(s)',
243
+ usageHint: 'question',
244
+ attachments: true,
245
+ },
246
+ {
247
+ key: 'quickTask',
248
+ field: 'quickTaskCommand',
249
+ defaultName: DEFAULT_QUICK_TASK_COMMAND,
250
+ role: 'execution',
251
+ feature: 'quick-task',
252
+ reportLabel: 'Quick-task command:',
253
+ configureHint: 'set roles.execution.models to the model simple tasks should run on',
254
+ registeredNote: 'Registered as a real command; a plain-text /name gesture routes the same turn.',
255
+ unregisteredNote: 'NOT registered (no commands service, or registration failed — see the startup log); '
256
+ + 'plain-text gestures still route the same turn, only the palette entry is missing.',
257
+ description: 'Run one simple task on the execution model: this message (and its turn) runs on the '
258
+ + "manager's execution role, then the next message returns to the normal route. Text only — images "
259
+ + 'belong to the read-image command.',
260
+ hint: 'simple task or question',
261
+ usageHint: 'simple task or question',
262
+ attachments: false,
263
+ },
264
+ ];
265
+
177
266
  /**
178
267
  * The public DSH skill-name grammar and the `/name` gesture the harness scans
179
268
  * for in direct user text.
@@ -337,6 +426,8 @@ function buildConfigSchema(z) {
337
426
  visionKeywords: z.array(z.string()).default(DEFAULT_VISION_KEYWORDS),
338
427
  planningKeywords: z.array(z.string()).default(DEFAULT_PLANNING_KEYWORDS),
339
428
  planningSkills: z.array(z.string()).default(DEFAULT_PLANNING_SKILLS),
429
+ readImageCommand: z.string().default(DEFAULT_READ_IMAGE_COMMAND),
430
+ quickTaskCommand: z.string().default(DEFAULT_QUICK_TASK_COMMAND),
340
431
  historyLimit: z.number().default(300),
341
432
  autoDelegate: z.union([z.const('off'), z.const('balanced'), z.const('eager')]).default('balanced'),
342
433
  });
@@ -451,6 +542,43 @@ function normalizeSkillNames(value) {
451
542
  return names;
452
543
  }
453
544
 
545
+ /**
546
+ * Normalize a one-turn command name (`strategy.readImageCommand` /
547
+ * `strategy.quickTaskCommand`).
548
+ *
549
+ * An absent or non-string value takes the command's built-in default (the
550
+ * same fail-on philosophy as the keyword lists: a malformed value must not
551
+ * silently switch a feature off). An explicit empty string is honoured and
552
+ * disables both the command registration and the gesture scan. A name
553
+ * outside the grammar logs a warning and disables the feature: it must be
554
+ * kebab-case for the gesture scanner AND start with a letter for the command
555
+ * registry's own `COMMAND_NAME`, so a name failing either could never be
556
+ * invoked as a command — better to refuse it at config time than fail
557
+ * registration at boot.
558
+ */
559
+ const COMMAND_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
560
+
561
+ function normalizeCommandName(value, warnings, field, fallback) {
562
+ const raw = readVal(value);
563
+ if (raw === undefined || raw === null || typeof raw !== 'string') return fallback;
564
+ const name = raw.trim().toLowerCase();
565
+ if (name === '') return '';
566
+ if (!COMMAND_NAME.test(name)) {
567
+ warnings?.push(`strategy.${field} "${raw}" is not a lowercase kebab-case name starting with a letter; the ${field === 'readImageCommand' ? 'read-image' : 'quick-task'} command is disabled`);
568
+ return '';
569
+ }
570
+ return name;
571
+ }
572
+
573
+ function normalizeReadImageCommand(value, warnings) {
574
+ return normalizeCommandName(value, warnings, 'readImageCommand', DEFAULT_READ_IMAGE_COMMAND);
575
+ }
576
+
577
+ /** Normalize `strategy.quickTaskCommand` (0.7.1); see {@link normalizeCommandName}. */
578
+ function normalizeQuickTaskCommand(value, warnings) {
579
+ return normalizeCommandName(value, warnings, 'quickTaskCommand', DEFAULT_QUICK_TASK_COMMAND);
580
+ }
581
+
454
582
  function normalizeRoute(raw) {
455
583
  const value = readVal(raw);
456
584
  if (value === null || typeof value !== 'object') return undefined;
@@ -677,6 +805,12 @@ function readConfig(raw) {
677
805
  // Absent/malformed -> the grill defaults; explicit [] switches the
678
806
  // skill-to-planning escalation off.
679
807
  planningSkills: normalizeSkillNames(strategyRaw.planningSkills),
808
+ // Absent/malformed -> 'readimage'; explicit '' switches the one-turn
809
+ // vision command off; an invalid name warns and disables it.
810
+ readImageCommand: normalizeReadImageCommand(strategyRaw.readImageCommand, warnings),
811
+ // Absent/malformed -> 'quicktask'; explicit '' switches the one-turn
812
+ // execution command off; an invalid name warns and disables it.
813
+ quickTaskCommand: normalizeQuickTaskCommand(strategyRaw.quickTaskCommand, warnings),
680
814
  // Guard against a positive fraction flooring to 0, which would evict every
681
815
  // record immediately and silently disable usage tracking.
682
816
  historyLimit: Number.isFinite(limit) && limit > 0 ? Math.max(1, Math.floor(limit)) : 300,
@@ -801,6 +935,36 @@ function planningSkillInMessages(messages, wanted) {
801
935
  return undefined;
802
936
  }
803
937
 
938
+ /**
939
+ * Whether a batch of user messages carries a given command's gesture. Pure.
940
+ *
941
+ * Recognition uses the harness's own `/name` grammar (the same word-boundary
942
+ * shape tool-skill scans), so `/readimage` or `/quicktask` reads as a gesture
943
+ * wherever it sits in the sentence while file paths and fractions never match.
944
+ * Only direct user text counts — no other source can forge the gesture. The
945
+ * command handlers forward the original line, token included, so the claimed
946
+ * message they queue carries the gesture into the routing seams below.
947
+ */
948
+ function commandGestureInMessages(messages, command) {
949
+ if (typeof command !== 'string' || command === '') return false;
950
+ for (const message of Array.isArray(messages) ? messages : []) {
951
+ if (message?.source?.kind !== 'user') continue;
952
+ for (const block of Array.isArray(message.content) ? message.content : []) {
953
+ if (block?.type !== 'text' || typeof block.text !== 'string') continue;
954
+ for (const match of block.text.matchAll(SKILL_GESTURE)) {
955
+ if (match[2] === command) return true;
956
+ }
957
+ }
958
+ }
959
+ return false;
960
+ }
961
+
962
+ /**
963
+ * The 0.7.0 export name for {@link commandGestureInMessages}, kept stable for
964
+ * the read-image test surface; the function itself is command-agnostic.
965
+ */
966
+ const readImageGestureInMessages = commandGestureInMessages;
967
+
804
968
  /** Find the delegating parent of a child session. */
805
969
  function findParent(ctx, childId) {
806
970
  return probe(() => {
@@ -1100,6 +1264,22 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1100
1264
  */
1101
1265
  let autoplanRegistered = false;
1102
1266
 
1267
+ /**
1268
+ * The `commands` service, captured when its injection resolves, plus the
1269
+ * live registrations of the one-turn commands. `commandRegistrations` maps
1270
+ * each TURN_COMMANDS key to `{ name, dispose }` — the name actually
1271
+ * registered ('' when none) — so a volatile Settings save that renames a
1272
+ * command can dispose the old registration and arm the new one, and
1273
+ * `routes` can tell "configured" from "registered in this composition".
1274
+ */
1275
+ let commandsService;
1276
+ const commandRegistrations = new Map();
1277
+ /**
1278
+ * TURN_COMMANDS key -> the colliding name already warned about, so an
1279
+ * unchanged volatile save does not repeat the collision warning.
1280
+ */
1281
+ const commandCollisionWarned = new Map();
1282
+
1103
1283
  /**
1104
1284
  * Latest update-check outcome. Statuses: `idle` (not yet checked), `checking`,
1105
1285
  * `ok` (up to date), `available` (a newer release exists), `error` (the check
@@ -1141,6 +1321,25 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1141
1321
  /** session id -> the last top-level trigger, so the info log fires once per switch. */
1142
1322
  const topTriggers = new Map();
1143
1323
 
1324
+ /**
1325
+ * session id -> `{ turn, restore, command }` for the ONE turn a one-turn
1326
+ * command owns (`/readimage` since 0.7.0, `/quicktask` since 0.7.1).
1327
+ *
1328
+ * The override is keyed to the turn number that claimed the gesture, which
1329
+ * is what makes it expire by itself: every later step of that turn compares
1330
+ * equal and stays on the command's role, while the first claim of any other
1331
+ * turn compares different and ends it. `restore` remembers a hand-picked
1332
+ * composer route the command overrode (hybrid normally respects it), so the
1333
+ * pick is selected back when the commanded turn ends instead of being
1334
+ * silently dropped.
1335
+ *
1336
+ * Deliberately process-live, with no durable projection: this is per-message
1337
+ * intent, not session state. After a restart the next message routes
1338
+ * normally, which is exactly the contract — only a fresh gesture commands a
1339
+ * fresh turn.
1340
+ */
1341
+ const commandTurns = new Map();
1342
+
1144
1343
  /** Add one skill name to a session's live list, bounded and de-duplicated. */
1145
1344
  function addLiveSkill(id, name) {
1146
1345
  const normalized = typeof name === 'string' ? name.trim().toLowerCase() : '';
@@ -1200,6 +1399,9 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1200
1399
  try {
1201
1400
  const agent = payload?.agent;
1202
1401
  const id = typeof agent?.id === 'string' ? agent.id : undefined;
1402
+ const isSubagent = agent === undefined
1403
+ ? false
1404
+ : probe(() => agent.session?.header?.origin === 'subagent') === true;
1203
1405
  if (id !== undefined && decision?.kind !== 'reject') {
1204
1406
  for (const batch of [payload?.messages, decision?.messages]) {
1205
1407
  if (!Array.isArray(batch)) continue;
@@ -1207,6 +1409,17 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1207
1409
  for (const name of skillNamesOfMessage(message)) addLiveSkill(id, name);
1208
1410
  }
1209
1411
  }
1412
+ // The one-turn command override binds here too, on every transport:
1413
+ // the claim boundary covers the first step, and this scan covers a
1414
+ // harness whose claim notification predates the listener (or a batch
1415
+ // the claim seam never saw). Top-level only — a child's routing stays
1416
+ // label-driven.
1417
+ if (!isSubagent) {
1418
+ for (const batch of [payload?.messages, decision?.messages]) {
1419
+ if (Array.isArray(batch)) noteCommandGesture(agent, batch, payload?.turn);
1420
+ }
1421
+ endCommandTurn(agent, payload?.turn);
1422
+ }
1210
1423
  }
1211
1424
  // On a harness that fixes the route at step preparation, keep the
1212
1425
  // selection correct from step to step: this call lands on the NEXT step,
@@ -1215,18 +1428,21 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1215
1428
  // that is about to run.
1216
1429
  if (agent !== undefined && decision?.kind !== 'reject'
1217
1430
  && selectionModelOf(agent) !== undefined && config.enabled) {
1218
- const isSubagent = probe(() => agent.session?.header?.origin === 'subagent') === true;
1219
1431
  if (isSubagent) {
1220
1432
  const facts = catalog.get(agent.id);
1221
1433
  if (facts !== undefined) {
1222
1434
  applySelection(agent, classifySubagent(facts.label), undefined, facts.label, true);
1223
1435
  }
1224
1436
  } else {
1437
+ const command = commandActive(agent, payload?.turn);
1225
1438
  const plan = planActive(ctx, agent);
1226
- const skill = plan ? undefined : planningSkillFor(agent);
1227
- const trigger = skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1228
- noteTopTrigger(agent, trigger);
1229
- applySelection(agent, plan || skill !== undefined ? 'planning' : 'main', trigger, undefined, false);
1439
+ const skill = plan || command ? undefined : planningSkillFor(agent);
1440
+ const trigger = command
1441
+ ? `command:${config.strategy[command.field]}`
1442
+ : skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1443
+ noteTopTrigger(agent, trigger, command);
1444
+ applySelection(agent, command ? command.role : plan || skill !== undefined ? 'planning' : 'main',
1445
+ trigger, undefined, false, command !== undefined);
1230
1446
  }
1231
1447
  }
1232
1448
  } catch {
@@ -1235,8 +1451,13 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1235
1451
  return decision;
1236
1452
  }
1237
1453
 
1238
- /** Log a top-level trigger once per switch, never once per request. */
1239
- function noteTopTrigger(agent, trigger) {
1454
+ /**
1455
+ * Log a top-level trigger once per switch, never once per request.
1456
+ *
1457
+ * `command` is the active one-turn command descriptor when `trigger` is a
1458
+ * `command:` trigger, so the log names the role its turn runs on.
1459
+ */
1460
+ function noteTopTrigger(agent, trigger, command) {
1240
1461
  const id = typeof agent?.id === 'string' ? agent.id : undefined;
1241
1462
  if (id === undefined) return;
1242
1463
  if (topTriggers.get(id) === trigger) return;
@@ -1245,6 +1466,143 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1245
1466
  log('info', `planning skill "${trigger.slice('skill:'.length)}" is active in this session; `
1246
1467
  + 'top-level requests route as planning');
1247
1468
  }
1469
+ if (trigger.startsWith('command:') && command !== undefined) {
1470
+ log('info', `/${trigger.slice('command:'.length)} commands this turn on the ${command.role} role; `
1471
+ + 'the next message without the gesture returns to the normal route');
1472
+ }
1473
+ }
1474
+
1475
+ /**
1476
+ * The one-turn command owning the turn a step belongs to, or `undefined`.
1477
+ * A bound turn only answers for its own turn number: a mid-turn steering
1478
+ * message (no gesture, same turn) keeps the command; a later turn does not.
1479
+ */
1480
+ function commandActive(agent, turn) {
1481
+ if (!Number.isSafeInteger(turn)) return undefined;
1482
+ const id = typeof agent?.id === 'string' ? agent.id : undefined;
1483
+ const active = id === undefined ? undefined : commandTurns.get(id);
1484
+ return active !== undefined && active.turn === turn ? active.command : undefined;
1485
+ }
1486
+
1487
+ /**
1488
+ * The first TURN_COMMANDS descriptor whose configured name appears as a
1489
+ * gesture in a batch of user messages, or `undefined`.
1490
+ *
1491
+ * `TURN_COMMANDS` order decides a message carrying two command tokens:
1492
+ * `/readimage` beats `/quicktask`, because the image in the message can
1493
+ * only be served by a vision-capable model while a quick turn is a cost
1494
+ * preference the user can re-issue.
1495
+ *
1496
+ * A command whose role resolves to no models never binds: there is no
1497
+ * route to command, and binding anyway would let the report claim a turn
1498
+ * "ran on" a role nothing was selected for. The handler and the cheat
1499
+ * sheet gate on the same emptiness, so every surface then agrees: the
1500
+ * gesture is inert, not half-alive.
1501
+ */
1502
+ function turnCommandInMessages(messages) {
1503
+ for (const command of TURN_COMMANDS) {
1504
+ const name = config.strategy[command.field];
1505
+ if (name !== '' && effectiveModels(command.role).length > 0
1506
+ && commandGestureInMessages(messages, name)) return command;
1507
+ }
1508
+ return undefined;
1509
+ }
1510
+
1511
+ /**
1512
+ * Bind the override to the turn whose claimed input carries the gesture.
1513
+ *
1514
+ * Called at both routing seams (the claim boundary and the pre-step batch)
1515
+ * with the turn number the harness reports, so the binding is to the turn
1516
+ * that OWNS the message — a mid-turn steering message without the gesture
1517
+ * cannot steal or cancel it. A consecutive commanded turn keeps the original
1518
+ * `restore` route: the pick to hand back is the one from before the first
1519
+ * override, never the role route the manager itself selected.
1520
+ */
1521
+ function noteCommandGesture(agent, messages, turn) {
1522
+ if (!Number.isSafeInteger(turn)) return;
1523
+ const id = typeof agent?.id === 'string' ? agent.id : undefined;
1524
+ if (id === undefined) return;
1525
+ const command = turnCommandInMessages(messages);
1526
+ if (command === undefined) return;
1527
+ const existing = commandTurns.get(id);
1528
+ if (existing?.turn === turn) return;
1529
+ const current = probe(() => selectionModelOf(agent)?.current());
1530
+ // A pick made after the previous commanded turn is newer than the one
1531
+ // remembered then, so it replaces the memory: what must come back is the
1532
+ // user's LATEST choice, never a stale one. When current is the manager's
1533
+ // own route for the previous commanded turn (the ordinary case) it is not
1534
+ // foreign and the original memory stands.
1535
+ const restore = (selectionIsForeign(agent, current) ? current : undefined) ?? existing?.restore;
1536
+ commandTurns.set(id, { turn, restore, command });
1537
+ }
1538
+
1539
+ /**
1540
+ * End the override when a DIFFERENT turn claims input, handing a remembered
1541
+ * composer pick back.
1542
+ *
1543
+ * The restore is selected before the normal role decision runs, so the
1544
+ * hybrid gate that follows reads the pick as foreign again and respects it —
1545
+ * ownership is dropped on purpose: a restored pick is the user's choice, not
1546
+ * a route the manager may replace with `main` on the next turn. On the 0.1.x
1547
+ * rewrite path nothing was ever durably selected, so there is nothing to
1548
+ * restore and the pick survives on its own.
1549
+ */
1550
+ function endCommandTurn(agent, turn) {
1551
+ const id = typeof agent?.id === 'string' ? agent.id : undefined;
1552
+ if (id === undefined || !Number.isSafeInteger(turn)) return;
1553
+ const active = commandTurns.get(id);
1554
+ if (active === undefined || active.turn === turn) return;
1555
+ commandTurns.delete(id);
1556
+ if (active.restore === undefined) return;
1557
+ if (!config.enabled || config.strategy.mode === 'advisory') return;
1558
+ const model = selectionModelOf(agent);
1559
+ if (model === undefined) return;
1560
+ try {
1561
+ // A hand pick made AFTER the commanded turn is newer than the one
1562
+ // remembered at command time. Keep it and drop ownership so hybrid
1563
+ // respects it — restoring the stale memory would eat the user's latest
1564
+ // choice, which is exactly what the restore exists to protect.
1565
+ const current = probe(() => model.current());
1566
+ if (selectionIsForeign(agent, current)) {
1567
+ managerSelected.delete(id);
1568
+ return;
1569
+ }
1570
+ model.select({
1571
+ provider: active.restore.provider,
1572
+ model: active.restore.model,
1573
+ ...(active.restore.reasoningEffort === undefined ? {} : { reasoningEffort: active.restore.reasoningEffort }),
1574
+ });
1575
+ managerSelected.delete(id);
1576
+ log('info', `restored the hand-picked ${active.restore.provider}/${active.restore.model} `
1577
+ + `for ${shortId(id)} after the ${active.command.feature} turn`);
1578
+ } catch (error) {
1579
+ log('warn', `could not restore the hand-picked route: ${error?.message ?? error}`);
1580
+ }
1581
+ }
1582
+
1583
+ /**
1584
+ * First-wins name ownership across the one-turn commands, in `TURN_COMMANDS`
1585
+ * order: the name each command's live config value resolves to, mapped to
1586
+ * the command that owns it. Used by the registration (the registry itself
1587
+ * only shadows a duplicate name) and by the `routes` note, so the two can
1588
+ * never disagree about who owns a token.
1589
+ */
1590
+ function turnCommandOwners() {
1591
+ const owner = new Map();
1592
+ for (const command of TURN_COMMANDS) {
1593
+ const name = config.strategy[command.field];
1594
+ if (name !== '' && !owner.has(name)) owner.set(name, command);
1595
+ }
1596
+ return owner;
1597
+ }
1598
+
1599
+ /**
1600
+ * Whether a one-turn command is registered under its live config name —
1601
+ * the fact `routes` reports next to each command, so an operator can tell
1602
+ * "configured" from "actually invocable in this composition".
1603
+ */
1604
+ function commandRegistered(command) {
1605
+ return commandRegistrations.get(command.key)?.name === config.strategy[command.field];
1248
1606
  }
1249
1607
 
1250
1608
  /** The model list a role actually resolves to, including the vision fallback. */
@@ -1345,8 +1703,15 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1345
1703
  * (before the first step) and at `agent/pre-step` (for the step after the one
1346
1704
  * in flight). Returns whether a selection was recorded; every failure is
1347
1705
  * contained.
1706
+ *
1707
+ * `force` is the one-turn commands' authority (`/readimage`, `/quicktask`):
1708
+ * an explicit user instruction for THIS message outranks even a hand-picked
1709
+ * composer route for the turn it commands (the pick is remembered and
1710
+ * restored afterwards by `endCommandTurn`). It never bypasses the master
1711
+ * switch or advisory mode — those mean the manager does not move routes at
1712
+ * all.
1348
1713
  */
1349
- function applySelection(agent, role, trigger, label, isSubagent) {
1714
+ function applySelection(agent, role, trigger, label, isSubagent, force = false) {
1350
1715
  const model = selectionModelOf(agent);
1351
1716
  if (model === undefined || !config.enabled) return false;
1352
1717
  try {
@@ -1355,7 +1720,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1355
1720
  if (candidate === undefined) return false;
1356
1721
  const route = candidate.route;
1357
1722
  const current = probe(() => model.current());
1358
- if (!selectionAllowed(agent, current, isSubagent)) {
1723
+ if (!force && !selectionAllowed(agent, current, isSubagent)) {
1359
1724
  if (!isSubagent && current !== undefined) {
1360
1725
  log('info', `session ${shortId(agent.id)} keeps ${current.provider}/${current.model}: `
1361
1726
  + 'a hand-picked model is respected under hybrid');
@@ -1452,14 +1817,27 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1452
1817
  }
1453
1818
  return;
1454
1819
  }
1820
+ // The claimed message names the intent, and the payload names the turn
1821
+ // that owns it: bind the one-turn command override to THAT turn, end any
1822
+ // older one (handing a remembered composer pick back), then decide the
1823
+ // role. A command outranks plan mode and planning skills for its own
1824
+ // turn — it is the most recent explicit instruction — and only for that
1825
+ // turn.
1826
+ const turn = payload?.turn;
1827
+ noteCommandGesture(agent, [message], turn);
1828
+ endCommandTurn(agent, turn);
1829
+ const command = commandActive(agent, turn);
1455
1830
  const plan = planActive(ctx, agent);
1456
- const skill = plan
1831
+ const skill = plan || command
1457
1832
  ? undefined
1458
1833
  : (planningSkillFor(agent)
1459
1834
  ?? planningSkillInMessages([message], config.strategy.planningSkills));
1460
- const trigger = skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1461
- noteTopTrigger(agent, trigger);
1462
- applySelection(agent, plan || skill !== undefined ? 'planning' : 'main', trigger, undefined, false);
1835
+ const trigger = command
1836
+ ? `command:${config.strategy[command.field]}`
1837
+ : skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1838
+ noteTopTrigger(agent, trigger, command);
1839
+ applySelection(agent, command ? command.role : plan || skill !== undefined ? 'planning' : 'main',
1840
+ trigger, undefined, false, command !== undefined);
1463
1841
  } catch {
1464
1842
  /* observe-only at the claim boundary */
1465
1843
  }
@@ -1622,21 +2000,26 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1622
2000
  let role;
1623
2001
  let label;
1624
2002
  let trigger;
2003
+ let command;
1625
2004
  if (isSubagent) {
1626
2005
  const facts = await factsFor(agent.id);
1627
2006
  label = facts?.label;
1628
2007
  role = classifySubagent(label);
1629
2008
  } else {
1630
- // Plan mode is the harness's own "thinking work" mode; a planning skill
2009
+ // The one-turn commands own their turn outright; below them, plan mode
2010
+ // is the harness's own "thinking work" mode and a planning skill
1631
2011
  // (`grilling` / `grill-me`) is the user's own version of the same
1632
2012
  // intent, so both put the top-level session on the planning tier.
2013
+ command = commandActive(agent, payload?.turn);
1633
2014
  const plan = planActive(ctx, agent);
1634
- const skill = plan ? undefined : planningSkillFor(agent);
1635
- trigger = skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
2015
+ const skill = plan || command ? undefined : planningSkillFor(agent);
2016
+ trigger = command
2017
+ ? `command:${config.strategy[command.field]}`
2018
+ : skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1636
2019
  // Only claim routing when routing is on; a disabled manager still records
1637
2020
  // the trigger in its observed rows, but must not log that requests route.
1638
- if (config.enabled) noteTopTrigger(agent, trigger);
1639
- role = plan || skill !== undefined ? 'planning' : 'main';
2021
+ if (config.enabled) noteTopTrigger(agent, trigger, command);
2022
+ role = command ? command.role : plan || skill !== undefined ? 'planning' : 'main';
1640
2023
  }
1641
2024
 
1642
2025
  // Master switch off: observe and record, but never rewrite a route. The
@@ -1722,13 +2105,17 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1722
2105
  output = resolved;
1723
2106
  } else {
1724
2107
  let inherited = true;
1725
- if (mode === 'hybrid' && !isSubagent && selectionWasExplicit(agent)) {
2108
+ if (mode === 'hybrid' && !isSubagent && !command && selectionWasExplicit(agent)) {
1726
2109
  // `main` replaces a route the user never chose; it does not overrule
1727
2110
  // one they did choose. The proof is a durable log event, so a real
1728
2111
  // composer pick survives restart, resume and fork, while a session
1729
2112
  // still riding the deployment default is rewritten as before.
1730
2113
  // `managed` is the mode for "the manager owns every route", including a
1731
2114
  // session the user already picked, and is left untouched here.
2115
+ // The one-turn commands are the one exception: each is an explicit
2116
+ // user instruction for THIS turn, newer than the pick, so it rewrites
2117
+ // for that turn only — the durable selection is untouched on this
2118
+ // path, and the next turn respects the pick again by itself.
1732
2119
  inherited = false;
1733
2120
  reason = 'explicit session selection (respected)';
1734
2121
  } else if (mode === 'hybrid' && isSubagent) {
@@ -1761,6 +2148,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1761
2148
  }
1762
2149
  output = inherited ? applyRoute(resolved, route) : resolved;
1763
2150
  didApply = inherited;
2151
+ if (didApply && command) reason = `applied (${command.feature} command, one turn)`;
1764
2152
  }
1765
2153
 
1766
2154
  // Commit the rotation only when a route was actually applied, and record
@@ -2326,6 +2714,23 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2326
2714
  lines.push('These sessions invoked a planning skill, so they route to the planning tier for');
2327
2715
  lines.push('the rest of the session, like plan mode; a hand-picked composer model still wins.');
2328
2716
  }
2717
+ const commandTriggers = topRows.filter((row) => typeof row.seen.trigger === 'string'
2718
+ && row.seen.trigger.startsWith('command:')
2719
+ && row.seen.reason !== 'manager disabled (observed only)');
2720
+ // One block per one-turn command, matched by the recorded ROLE rather
2721
+ // than the trigger's name text: a Settings rename after the fact must
2722
+ // not orphan a row, and a top-level turn only ever lands on `vision`
2723
+ // via /readimage or `execution` via /quicktask.
2724
+ for (const command of TURN_COMMANDS) {
2725
+ const rows = commandTriggers.filter((row) => row.seen.role === command.role);
2726
+ if (rows.length === 0) continue;
2727
+ lines.push('');
2728
+ lines.push(command.reportLabel + ' ' + rows
2729
+ .map((row) => `${shortId(row.sessionId)} → /${row.seen.trigger.slice('command:'.length)}`)
2730
+ .join(', '));
2731
+ lines.push(`The last turn of these sessions carried the ${command.feature} gesture, so it ran on the`);
2732
+ lines.push(`${command.role} role for that one turn; the next message without it routes normally again.`);
2733
+ }
2329
2734
  lines.push('');
2330
2735
  }
2331
2736
  if (rows.length > 0) {
@@ -2416,6 +2821,21 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2416
2821
  : `${config.strategy.planningSkills.join(', ')} — a top-level session that invoked one routes as `
2417
2822
  + 'planning for the rest of the session, like plan mode'}`,
2418
2823
  '',
2824
+ ...TURN_COMMANDS.map((command) => {
2825
+ const name = config.strategy[command.field];
2826
+ const owner = turnCommandOwners().get(name);
2827
+ return `${command.reportLabel} ${name === ''
2828
+ ? `(disabled) — strategy.${command.field} is empty`
2829
+ : `/${name} — the turn carrying it runs on the ${command.role} role (one turn only; `
2830
+ + 'the next message without the gesture returns to the normal route, and a hand-picked composer model '
2831
+ + 'is restored afterwards). '
2832
+ + (commandRegistered(command) ? command.registeredNote
2833
+ : owner !== undefined && owner !== command
2834
+ ? `NOT registered under this name — strategy.${command.field} collides with the `
2835
+ + `${owner.feature} command's name, which keeps /${name}; the token routes ${owner.role}.`
2836
+ : command.unregisteredNote)}`;
2837
+ }),
2838
+ '',
2419
2839
  `Autoplan skill: ${autoplanRegistered
2420
2840
  ? 'registered — `/autoplan` plans on the planning tier and implements on `main` '
2421
2841
  + 'without an approval gate'
@@ -2461,12 +2881,24 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2461
2881
  ? '\nA top-level session that invoked '
2462
2882
  + `${config.strategy.planningSkills.join(' / ')} runs on the planning tier, like plan mode.`
2463
2883
  : '';
2884
+ const readImageNote = config.enabled && config.strategy.mode !== 'advisory'
2885
+ && config.strategy.readImageCommand !== '' && effectiveModels('vision').length > 0
2886
+ ? `\nThe user can type /${config.strategy.readImageCommand} to run one message (with images) on the vision `
2887
+ + 'tier for its whole turn; the next message without it returns to the normal route. Suggest it when '
2888
+ + 'the user wants an image read but the current model cannot see images.'
2889
+ : '';
2890
+ const quickTaskNote = config.enabled && config.strategy.mode !== 'advisory'
2891
+ && config.strategy.quickTaskCommand !== '' && effectiveModels('execution').length > 0
2892
+ ? `\nThe user can type /${config.strategy.quickTaskCommand} to run one message on the execution `
2893
+ + 'tier for its whole turn — a simple task or quick question that does not need the main model; '
2894
+ + 'the next message without it returns to the normal route.'
2895
+ : '';
2464
2896
  return [
2465
2897
  '## Model manager',
2466
2898
  'Delegated work is routed by the label you give each delegation:',
2467
2899
  ...summary,
2468
2900
  routing,
2469
- `Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}${skillNote}`,
2901
+ `Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}${skillNote}${readImageNote}${quickTaskNote}`,
2470
2902
  ].join('\n');
2471
2903
  }
2472
2904
 
@@ -2716,6 +3148,122 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2716
3148
  return state?.explicit === true;
2717
3149
  }
2718
3150
 
3151
+ /**
3152
+ * The one-turn command handler (`/readimage`, `/quicktask`): forward,
3153
+ * don't answer.
3154
+ *
3155
+ * The harness's ordinary prompt path refuses images while the selected model
3156
+ * declares text-only input (`MODEL_DOES_NOT_SUPPORT_IMAGES` in
3157
+ * dsh-api-session-controller), and it does so BEFORE any routing hook runs —
3158
+ * so a gesture scan alone could never see an image message on a text-only
3159
+ * main tier. The command path admits attachments without that gate; this
3160
+ * handler rebuilds the original line (token included, so the claim-boundary
3161
+ * gesture scan binds the turn) plus the admitted image/file blocks as an
3162
+ * ordinary user message and queues it with `agent.followup()`. The message
3163
+ * shape mirrors dsh-llm's `createUserMessage` — role, fresh UUID identity,
3164
+ * `source.kind: 'user'` — without importing a harness package, which a
3165
+ * profile-installed plugin cannot resolve. Routing then happens at the claim
3166
+ * boundary exactly as it does for any typed message.
3167
+ *
3168
+ * `/quicktask` declares no attachment support, so the executor refuses an
3169
+ * invocation carrying attachments before this handler can ever see them;
3170
+ * the forwarding below stays generic (and defensive) regardless.
3171
+ */
3172
+ function turnCommandHandler(invocation, command) {
3173
+ try {
3174
+ const name = config.strategy[command.field];
3175
+ const agent = invocation?.agent;
3176
+ if (agent === undefined || typeof agent.followup !== 'function') {
3177
+ return { kind: 'error', text: `/${name}: this composition exposes no agent inbox to forward the message to` };
3178
+ }
3179
+ if (!config.enabled) {
3180
+ return { kind: 'error', text: `/${name}: the model manager is disabled, so the ${command.role} route cannot be selected` };
3181
+ }
3182
+ if (config.strategy.mode === 'advisory') {
3183
+ return { kind: 'error', text: `/${name}: the manager is advisory (observe-only), so it cannot switch this message to the ${command.role} model` };
3184
+ }
3185
+ if (effectiveModels(command.role).length === 0) {
3186
+ return { kind: 'error', text: `/${name}: no ${command.role} model is configured — ${command.configureHint}` };
3187
+ }
3188
+ const rawInput = typeof invocation?.rawInput === 'string' ? invocation.rawInput : '';
3189
+ const attachments = Array.isArray(invocation?.attachments) ? invocation.attachments : [];
3190
+ // Defensive, mirroring the registration: a non-declaring command never
3191
+ // legitimately receives attachments (the executor refuses the invocation
3192
+ // before dispatch), and a quick turn must not land an image on an
3193
+ // execution model that cannot read it.
3194
+ if (!command.attachments && attachments.length > 0) {
3195
+ return { kind: 'error', text: `/${name}: this command is text only — images belong to the read-image command` };
3196
+ }
3197
+ if (rawInput.trim() === '' && attachments.length === 0) {
3198
+ return { kind: 'error', text: `usage: /${name} <${command.usageHint}> — ${command.attachments ? 'attach the image(s) to read; ' : ''}the message runs on the ${command.role} model for one turn` };
3199
+ }
3200
+ if (invocation?.signal?.aborted === true) {
3201
+ return { kind: 'error', text: `/${name}: cancelled before the message was forwarded` };
3202
+ }
3203
+ const line = `/${name}${rawInput}`;
3204
+ agent.followup(Object.freeze({
3205
+ role: 'user',
3206
+ id: randomUUID(),
3207
+ source: Object.freeze({ kind: 'user' }),
3208
+ content: Object.freeze([Object.freeze({ type: 'text', text: line }), ...attachments]),
3209
+ }));
3210
+ return { kind: 'success' };
3211
+ } catch (error) {
3212
+ return { kind: 'error', text: `/${config.strategy[command.field]}: ${error?.message ?? error}` };
3213
+ }
3214
+ }
3215
+
3216
+ /**
3217
+ * Register (or re-register) every one-turn command under its live config
3218
+ * name. Idempotent while a name is unchanged; a rename disposes the old
3219
+ * registration first. Every failure degrades to a warning — a composition
3220
+ * without the commands service simply keeps the plain-text gesture routing.
3221
+ *
3222
+ * The registry itself does NOT refuse a duplicate name (a later
3223
+ * registration shadows the earlier one), so a config pointing two commands
3224
+ * at one name is resolved here instead, first-wins in `TURN_COMMANDS`
3225
+ * order: the losing command is skipped with a warning, and the gesture scan
3226
+ * (which walks the same order) stays consistent with what is registered.
3227
+ */
3228
+ function armTurnCommands() {
3229
+ if (commandsService === undefined || typeof commandsService.register !== 'function') return;
3230
+ const owner = turnCommandOwners();
3231
+ for (const command of TURN_COMMANDS) {
3232
+ const name = config.strategy[command.field];
3233
+ const registered = commandRegistrations.get(command.key);
3234
+ if (registered?.name === name && owner.get(name) === command) continue;
3235
+ if (registered !== undefined) {
3236
+ try { registered.dispose(); } catch { /* a failed dispose must not block the re-arm */ }
3237
+ commandRegistrations.delete(command.key);
3238
+ }
3239
+ if (name === '') continue;
3240
+ if (owner.get(name) !== command) {
3241
+ // Warn once per colliding name, not once per volatile save: an
3242
+ // unchanged config re-arms identically and must stay quiet.
3243
+ if (commandCollisionWarned.get(command.key) !== name) {
3244
+ commandCollisionWarned.set(command.key, name);
3245
+ log('warn', `/${name} already names the ${owner.get(name).feature} command, so the ${command.feature} `
3246
+ + `command is not registered — give strategy.${command.field} a name of its own`);
3247
+ }
3248
+ continue;
3249
+ }
3250
+ commandCollisionWarned.delete(command.key);
3251
+ try {
3252
+ const dispose = commandsService.register({
3253
+ name,
3254
+ description: command.description,
3255
+ input: { hint: command.hint, ...(command.attachments ? { attachments: true } : {}) },
3256
+ handler: (invocation) => turnCommandHandler(invocation, command),
3257
+ });
3258
+ commandRegistrations.set(command.key, { name, dispose: typeof dispose === 'function' ? dispose : () => {} });
3259
+ log('info', `registered the /${name} command — one turn on the ${command.role} role`
3260
+ + `${command.attachments ? ', with attachment support' : ''}`);
3261
+ } catch (error) {
3262
+ log('warn', `/${name} command not registered: ${error?.message ?? error}`);
3263
+ }
3264
+ }
3265
+ }
3266
+
2719
3267
  function attach() {
2720
3268
  ctx.on('agent/request', onAgentRequest);
2721
3269
  ctx.on('agent/request-error', onRequestError);
@@ -2740,6 +3288,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2740
3288
  liveSkills.delete(id);
2741
3289
  topTriggers.delete(id);
2742
3290
  managerSelected.delete(id);
3291
+ commandTurns.delete(id);
2743
3292
  });
2744
3293
 
2745
3294
  // Claim-boundary selection (DSH 0.2.x): the loop claims a step's input and
@@ -2784,6 +3333,10 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2784
3333
  };
2785
3334
  visionMatch = keywordMatcher(config.strategy.visionKeywords);
2786
3335
  planningMatch = keywordMatcher(config.strategy.planningKeywords);
3336
+ // A renamed (or disabled) one-turn command takes effect on the save:
3337
+ // the gesture scan already reads the live config, and this re-arms the
3338
+ // harness command registrations under the new names.
3339
+ armTurnCommands();
2787
3340
  for (const warning of config.warnings) log('warn', warning);
2788
3341
  // The delegation policy and the update schedule both read the live
2789
3342
  // config through this closure, so they follow a save with no restart.
@@ -2791,7 +3344,9 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2791
3344
  const updateChanged = JSON.stringify(previousUpdate) !== JSON.stringify(config.update);
2792
3345
  if (updateChanged) void checkForUpdate().catch(() => {});
2793
3346
  log('info', `settings reloaded — mode ${config.strategy.mode}, pick ${config.pick}, autoDelegate ${config.strategy.autoDelegate}, `
2794
- + `planningSkills ${config.strategy.planningSkills.join('|') || '-'}; `
3347
+ + `planningSkills ${config.strategy.planningSkills.join('|') || '-'}, `
3348
+ + `readImage ${config.strategy.readImageCommand || '-'}, `
3349
+ + `quickTask ${config.strategy.quickTaskCommand || '-'}; `
2795
3350
  + ROLE_NAMES
2796
3351
  .map((key) => `${key}=${config.roles[key].models.length === 0 ? '-' : config.roles[key].models.map((r) => `${r.provider}/${r.model}`).join('|')}`)
2797
3352
  .join(' '));
@@ -2811,11 +3366,13 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2811
3366
  description: 'Inspect and explain the role-based model routing configured for this harness. '
2812
3367
  + 'action "report": a Top-level agents section naming which model served each '
2813
3368
  + 'conversation, whether the manager yielded to a model a person picked in the '
2814
- + 'composer, and which planning skill (if any) put a session on the planning tier, '
3369
+ + 'composer, which planning skill (if any) put a session on the planning tier, '
3370
+ + 'and whether the last turn carried a one-turn command (/readimage, /quicktask), '
2815
3371
  + 'then one row per subagent with its label, role, reason, live status and '
2816
3372
  + 'totals. action "routes": the four role assignments '
2817
3373
  + '(including the vision->execution fallback), the shared selection strategy (first or round-robin), '
2818
3374
  + 'the active distribution mode, the auto-delegation level, the planning-skill trigger, '
3375
+ + 'the one-turn commands (/readimage on the vision role, /quicktask on the execution role), '
2819
3376
  + 'the update-check status, '
2820
3377
  + 'and whether each '
2821
3378
  + 'route is dispatchable by the delegation tool, with the YAML to add any that are not. '
@@ -2972,6 +3529,38 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2972
3529
  log('warn', `/autoplan skill not registered: ${error?.message ?? error}`);
2973
3530
  }
2974
3531
  });
3532
+
3533
+ // The one-turn commands (`/readimage` since 0.7.0, `/quicktask` since
3534
+ // 0.7.1). Like /autoplan these are workflow gestures the plugin ships,
3535
+ // but unlike a skill /readimage must accept image attachments: the
3536
+ // command path is the only admission seam that lets images through while
3537
+ // a text-only model is selected (/quicktask declares none, so the
3538
+ // executor refuses attachments for it before dispatch). Registration
3539
+ // follows the live config names; a volatile save re-arms them below.
3540
+ ctx.inject(['commands'], (scoped) => {
3541
+ try {
3542
+ commandsService = scoped?.commands;
3543
+ if (commandsService === undefined || typeof commandsService.register !== 'function') {
3544
+ log('warn', 'the commands service is present but exposes no register(); the one-turn commands are unavailable');
3545
+ return;
3546
+ }
3547
+ if (typeof scoped.effect === 'function') {
3548
+ scoped.effect(() => {
3549
+ armTurnCommands();
3550
+ return () => {
3551
+ for (const [, entry] of commandRegistrations) {
3552
+ try { entry.dispose(); } catch { /* disposal is best-effort */ }
3553
+ }
3554
+ commandRegistrations.clear();
3555
+ };
3556
+ });
3557
+ } else {
3558
+ armTurnCommands();
3559
+ }
3560
+ } catch (error) {
3561
+ log('warn', `one-turn command not registered: ${error?.message ?? error}`);
3562
+ }
3563
+ });
2975
3564
  }
2976
3565
 
2977
3566
  // Boot diagnostic: tell the operator about role routes the delegation tool
@@ -3074,7 +3663,13 @@ export {
3074
3663
  selectionModelOf,
3075
3664
  sameSelection,
3076
3665
  planningSkillInMessages,
3666
+ commandGestureInMessages,
3667
+ readImageGestureInMessages,
3668
+ normalizeReadImageCommand,
3669
+ normalizeQuickTaskCommand,
3077
3670
  DEFAULT_PLANNING_KEYWORDS,
3078
3671
  DEFAULT_PLANNING_SKILLS,
3672
+ DEFAULT_READ_IMAGE_COMMAND,
3673
+ DEFAULT_QUICK_TASK_COMMAND,
3079
3674
  DEFAULT_VISION_KEYWORDS,
3080
3675
  };
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@darkbear9494/dsh-model-manager",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
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, 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 switch models through agent.model.select() on DSH 0.2.x, 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, run /readimage messages with images on the vision role for one turn, run /quicktask messages on the execution role for one turn, 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 switch models through agent.model.select() on DSH 0.2.x, and check npm for updates.",
6
6
  "license": "MIT",
7
7
  "keywords": [
8
8
  "dsh",
9
9
  "dsh-plugin",
10
10
  "autoplan",
11
+ "readimage",
12
+ "quicktask",
11
13
  "deepseek-harness",
12
14
  "cordis",
13
15
  "model-routing",
@@ -35,7 +37,7 @@
35
37
  },
36
38
  "meta": {
37
39
  "title": "Model manager",
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."
40
+ "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), read images with /readimage (one turn on the vision tier), run simple tasks with /quicktask (one turn on the execution tier), and get update notices."
39
41
  },
40
42
  "exports": {
41
43
  ".": "./lib/index.js",