@darkbear9494/dsh-model-manager 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,10 @@ 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.
18
21
 
19
22
  ## What it is
20
23
 
@@ -44,7 +47,10 @@ the intent arrived as a `/grilling` gesture in user text, as the harness's skill
44
47
  the model's own `skill` tool call — and it is read from a durable session projection, so it
45
48
  survives a restart, a resume and a fork. 0.6.0 adds a second, complementary skill: `/autoplan`
46
49
  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
50
+ between — the label-driven tiers become a workflow instead of a setting. 0.7.0 adds the first
51
+ trigger that is a real slash command: `/readimage`, registered through the harness's `commands`
52
+ service, puts the one message that carries it — image attachments included — on the `vision` tier,
53
+ and only for that turn. It is still deliberately
48
54
  small: one ESM host file, one config schema, one bundled skill body, and one hand-written client
49
55
  file that contributes a configuration card to the Plugins page. There is no build step for either
50
56
  half.
@@ -109,12 +115,14 @@ version and updates the dependency in place.
109
115
 
110
116
  ### The registry copy
111
117
 
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
118
+ `@darkbear9494/dsh-model-manager@0.6.1` is the current release on the registry (published
119
+ 2026-11-06), public access, 9 files: the host half, the client half, this README, the two locale
120
+ dictionaries, the bundle patch, `package.json`, `LICENSE`, and `skills/autoplan/SKILL.md` — the
121
+ bundled skill 0.6.0 introduced. 0.6.0 (2026-11-05) was the first release with that ninth file and
122
+ packed 97.1 kB; 0.6.1 packs 102.4 kB (326.9 kB unpacked) with the DSH 0.2 model-selection fix.
123
+ Earlier: 0.5.0 packed 92.1 kB (292.2 kB unpacked) with the same 8 files as 0.2.0 (the tarball
124
+ grew, not the file list), 0.2.0 packed 63.1 kB, and 0.1.0, the first publish, 62.3 kB. The
125
+ declared gate is
118
126
  `>=0.1.7-rc.2 <0.3.0`, so every release on the 0.1.7–0.2.x runtime lines installs without an
119
127
  exemption.
120
128
 
@@ -707,6 +715,90 @@ an `Autoplan skill: registered` / `not registered (…)` line so you can tell wh
707
715
  Registering the skill is not routing: it happens even with `enabled: false`, where only the model
708
716
  switch stops.
709
717
 
718
+ ### The `/readimage` command
719
+
720
+ `/readimage` puts **one message** on the `vision` tier — the 图像识别 role — and only that message's
721
+ turn. It is the plugin's first **real slash command**: registered through the harness's `commands`
722
+ service, the same service `/plan` and `/compact` come from, declaring
723
+ `input: { hint: 'question about the attached image(s)', attachments: true }`, so it appears in the
724
+ composer's command autocomplete and can carry attachments. Registration needs only a composition
725
+ with a `commands` service and is independent of the model catalog; like the `/autoplan` skill, it is
726
+ not routing, so it happens even with `enabled: false`. The refusals live in the handler: with the
727
+ manager disabled, or with the vision role resolving to no models, the command returns a clear error
728
+ result instead of forwarding anything.
729
+
730
+ **Why a command and not a plain gesture.** On DSH 0.2.x the harness rejects image attachments at
731
+ prompt admission with `MODEL_DOES_NOT_SUPPORT_IMAGES` when the currently selected model declares
732
+ text-only input — *before* any plugin routing hook runs. A `/readimage` gesture typed as ordinary
733
+ text could therefore never carry an image past that gate while a text-only model is selected: the
734
+ message is refused before the manager could route it to a model that accepts images. The command
735
+ path admits attachments without the gate. The handler then forwards the original line — the
736
+ `/readimage` token included — plus the admitted image/file blocks as an ordinary user message
737
+ through `agent.followup()`, which queues a normal turn. That turn is routed by the same seams as any
738
+ other message; the token in the forwarded text is what names the intent. Bare `/readimage` with no
739
+ text and no attachments returns a usage error; bare `/readimage` with attachments forwards the token
740
+ plus the images.
741
+
742
+ **One turn, not one session.** This is the opposite of a [planning skill](#planning-skills): a skill
743
+ escalates the session for the rest of its life because its instructions stay in context, while
744
+ `/readimage` is per-message intent — the image is in *this* message, and the next message is ordinary
745
+ work again. The override is keyed to the **turn number** at the `agent/inbox/claimed` boundary — the
746
+ same seam where the 0.2.x selection reads the planning-skill gesture (see
747
+ [Switching models on DSH 0.2.x](#switching-models-on-dsh-02x)) — and maintained by `agent/pre-step`:
748
+
749
+ - Every step of the commanded turn runs on `vision`, tool-loop steps included, so the model that
750
+ sees the image keeps working with it.
751
+ - The next turn that claims a message without the gesture returns to normal routing: `main`, or
752
+ `planning` when plan mode or a planning skill is in force.
753
+ - A mid-turn steering message without the gesture does **not** cancel the override — it belongs to
754
+ the same turn.
755
+ - The override is process-live only. Nothing is folded into the durable log, so after a restart the
756
+ next message routes normally; only a fresh gesture commands a fresh turn.
757
+ - Subagent sessions are unaffected: a child's routing stays label-driven.
758
+
759
+ A short session:
760
+
761
+ ```text
762
+ you: /readimage what does this dashboard show? [screenshot attached]
763
+ → the whole turn runs on the vision role, tool-loop steps included
764
+ you: now fix the chart colours
765
+ → back on main (or planning, if plan mode or a planning skill is in force)
766
+ ```
767
+
768
+ **Precedence.** For its turn, `/readimage` outranks plan mode *and* planning skills
769
+ (`grilling` / `grill-me`): it is the most recent explicit instruction, and it names the tier for
770
+ exactly one message. Plan-mode tool restrictions still apply — they are composition-level, and only
771
+ the model changes. After the commanded turn the session returns to whatever state it was in: plan
772
+ mode, an active planning skill, or `main`.
773
+
774
+ **A hand-picked composer model yields for the turn, then comes back.** Under `hybrid` a model you
775
+ picked in the composer normally wins (see [`main` and the composer's model
776
+ picker](#main-and-the-composers-model-picker)). `/readimage` is an explicit, newer user instruction,
777
+ so it forces the vision route even over that pick — for the one turn. The pick is remembered, and
778
+ when the override ends the manager selects it back, so `hybrid` keeps respecting it on every later
779
+ turn. If you pick a *different* model in the composer after the commanded turn, that newer pick
780
+ wins over the remembered one — the restore hands back your latest choice, never a stale memory. On
781
+ the legacy DSH 0.1.x request-rewrite path nothing is durably selected in the first place, so
782
+ the pick survives automatically.
783
+
784
+ **Failover and diagnostics.** The commanded turn's role is recorded as `vision`, so in-step failover
785
+ walks the vision role's own chain — and the [image-capability warning](#vision-image-capability-check)
786
+ about text-only models in that chain still applies. The turn resolves the vision role the same way
787
+ any vision request does, including the [vision → execution fallback](#the-vision--execution-fallback)
788
+ when `vision` is empty. `model_manager(action: "report")` names the trigger `command:readimage` for
789
+ top-level turns routed this way, and `model_manager(action: "routes")` prints a line describing the
790
+ command — or saying it is disabled.
791
+
792
+ **The gesture works in plain text too.** The same word-boundary grammar that recognizes skill
793
+ gestures recognizes `/readimage` anywhere in a direct user message, so a text-only message carrying
794
+ the token routes to vision even when the command path was not used. Images still require the command
795
+ path: the admission gate above refuses them on the ordinary prompt path while a text-only model is
796
+ selected. The system-prompt cheat sheet gains one line telling the agent that you can type
797
+ `/readimage` to put one message on the vision tier.
798
+
799
+ The command name is configurable — `strategy.readImageCommand`, default `'readimage'`; an explicit
800
+ `''` disables both the command and the gesture. See [Configuration](#configuration).
801
+
710
802
  ### Switching models on DSH 0.2.x
711
803
 
712
804
  DSH 0.2 moved model selection out of the request waterfall. The loop reads
@@ -977,6 +1069,7 @@ Complete key set, with the schema defaults shown in comments:
977
1069
  # visionKeywords: omitted = the 20 built-ins; any list you write replaces them
978
1070
  # planningKeywords: omitted = the 24 built-ins; [] DISABLES that classifier
979
1071
  # planningSkills: omitted = ['grill-me', 'grilling']; [] DISABLES the trigger
1072
+ readImageCommand: readimage # default: readimage; '' DISABLES the command and the text gesture
980
1073
  historyLimit: 300 # default: 300; any positive value floors to at least 1
981
1074
  autoDelegate: balanced # default: balanced; "off" | "balanced" | "eager" — the delegation policy
982
1075
  update: # 0.3.0 — automatic update check
@@ -1025,6 +1118,15 @@ Behaviours of `readConfig` worth knowing:
1025
1118
  including one that normalizes down to empty, which is the disabled state. Membership is checked
1026
1119
  against the live config on every request, so adding a skill and setting `[]` both take effect on
1027
1120
  the next request with no restart.
1121
+ - `strategy.readImageCommand` is one command name, not a list: omitting the key uses `'readimage'`,
1122
+ and an explicit `''` disables the feature entirely — no command is registered and no gesture is
1123
+ recognized. The name is trimmed and lowercased and must be kebab-case **starting with a letter**
1124
+ (`[a-z][a-z0-9]*(-[a-z0-9]+)*`) — kebab-case because the `/name` gesture scanner requires it, a
1125
+ leading letter because the command registry's own `COMMAND_NAME` does — so a name failing either
1126
+ could never be invoked as a command; an invalid name logs a warning and disables the feature
1127
+ instead of failing registration at boot. A Settings save re-registers
1128
+ the command under the new name immediately. See [The `/readimage`
1129
+ command](#the-readimage-command).
1028
1130
  - `historyLimit` accepts any positive number, floored to an integer and raised to a
1029
1131
  minimum of 1, so a fractional value cannot floor to 0 and silently disable usage
1030
1132
  tracking. `0`, a negative number, a non-number or an absent key all mean 300.
@@ -1452,7 +1554,8 @@ planning tier is missing it says so, so a `plan:` label is never a silent no-op.
1452
1554
  `planningSkills` is non-empty **and** the planning role has models, the same section adds one
1453
1555
  line saying that a top-level session which invoked one of those skills runs on the planning tier,
1454
1556
  like plan mode; with no models behind the tier it stays quiet rather than advertising a trigger
1455
- that routes nowhere.
1557
+ that routes nowhere. One further line tells the agent that the user can type `/readimage` to put a
1558
+ single message on the vision tier (see [The `/readimage` command](#the-readimage-command)).
1456
1559
 
1457
1560
  ## How it stays safe
1458
1561
 
@@ -1547,8 +1650,9 @@ degrades to a notice or a log line.
1547
1650
  npm test
1548
1651
  ```
1549
1652
 
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`.
1653
+ Runs the suites in child processes and aggregates the result — **1198 assertions** across
1654
+ **14 suites** at the time of writing. Each suite also runs on
1655
+ its own: `node test/<name>.test.mjs`.
1552
1656
 
1553
1657
  | Suite | Assertions | What it pins |
1554
1658
  | --- | --- | --- |
@@ -1564,8 +1668,9 @@ of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
1564
1668
  | `explicit-selection.test.mjs` | 25 | The rule that `main` yields to a hand-picked session model, and nothing else does: respected under `hybrid`, still applied under `managed`, untouched by a respected call in the round-robin rotation, and falling back to the old rewriting behaviour when the projection service is absent, when `stateOf` throws, or when the key was never registered. A disabled manager is checked too. Plus the `Top-level agents` report table: the hand-picked versus default-driven verdict, no orphaned subagent header when no subagent exists, a row that outlives its agent degrading to `unknown, agent no longer live`, and — read back out of the renderer's own source — proof that the reason column is still padded past the longest reason string it can print. |
1565
1669
  | `autoplan-skill.test.mjs` | 42 | New in 0.6.0. The bundled `/autoplan` skill: the pure frontmatter parser (`parseSkillMarkdown`) accepting exactly a well-formed SKILL.md — CRLF, edge-trimming, a `---` line inside the body preserved, a `name:` line in the body not mistaken for frontmatter — and returning `undefined` for a missing/unclosed fence, an empty body, an empty description, an invalid name, and every hostile input without throwing; the shipped definition satisfying the runtime contract `dsh-skill` validates on `get()` (kebab name, non-empty description/content, both invocation flags, a string source) and its body carrying the load-bearing instructions (the `plan:`-labelled `subagent_fork`, the no-approval rule, the plan-mode boundary, the `subagent` fallback, the main-tier implementation phase) so it cannot be silently gutted; registration through a mock skills service — exactly once, the shipped definition, an info log naming the skill — and every degradation: a throwing `register()` and a composition with no skills service both leave `apply()` working with a warning, and `routes()` distinguishing registered from not; registration independent of `config.enabled`; and the routing invariant that `/autoplan` is not a planning skill — a top-level session that invoked it stays on the `main` tier, with `/grilling` as the escalating control. The packaging suite additionally pins that `skills/` is in `files` and the body ships. |
1566
1670
  | `planning-skills.test.mjs` | 100 | New in 0.5.0. The skill → top-level `planning` escalation, in eight blocks: the pure event fold `skillNamesOfEvent` over all three records — the `skill-invocation` injection, the `/name` gesture in direct user text, and a model's `skill` `tool/call` with JSON arguments — including the gesture-boundary rules, hostile payloads that record nothing and never throw, and the grammar pinned **byte-identical against the real `dsh-tool-skill`** when a DSH install resolves; `planningSkills` configuration (absent → `grill-me`/`grilling`, explicit `[]` honoured, lowercasing/trimming/de-duplication, invalid names dropped, volatile refs unwrapped, no unknown-key warning either way, and the schema union accepting an array / rejecting anything else); the `modelManagerPlanningSkill` projection (key, `stateVersion`, `init`, folding all three event shapes, mixed-case canonicalization, same-reference returns that suppress republishing, `.parse` rejecting junk); the **live** `agent/pre-step` signal — registered prepended, routing the FIRST request of a gesture step, stickiness across later turns, non-listed skills left on `main`, `[]` disabling it, the enter/reject decision returned by identity, a dozen hostile payloads, a subagent never escalated, `agent/disposed` dropping the live signal, a volatile reload of `[]` applying to the next request, and the info notice firing once per switch; the **durable** signal (a resumed session routing planning from a logged invocation, gesture, or model tool call, a durable name inert under `[]`, and no throw when the projection service is absent); plan mode keeping its own behaviour and owning the trigger when both apply; an explicit composer pick still winning the route while the row records role `planning`; and both diagnostic surfaces — the `Planning skills:` line in `routes` and the `Planning skill trigger:` line in `report`, each in its enabled and disabled form. |
1567
-
1568
1671
  | `model-select.test.mjs` | 26 | New in 0.6.1. DSH 0.2's selection contract: the pure helpers (`sameSelection`, `planningSkillInMessages`, `selectionModelOf`); a claimed user message selects the role's route before the step is prepared — plain prompt → `main`, `/grilling` → `planning`, `/autoplan` → `main`, plan mode → `planning`, round-robin committing only on an applied selection, and a hand-picked composer model respected under `hybrid` while `managed` overrides it; the manager's own selection is not mistaken for a hand-picked one on the next turn; `agent/request` returns the step's fixed route untouched (the 0.2 crash path); `agent/pre-step` corrects the next step; failover selects the next model and does not retry the fixed step; and a 0.1.x agent without a selection surface keeps request-time rewriting. |
1672
+ | `readimage.test.mjs` | 179 | New in 0.7.0. The `/readimage` command: the pure gesture helper `readImageGestureInMessages` (word-boundary recognition in direct user text, pinned against the real `dsh-tool-skill` grammar when a DSH install resolves) and `normalizeReadImageCommand` (the default, an explicit `''`, trimming/lowercasing, an invalid name disabling the feature with a warning), command registration through the `commands` service — name/input/handler registration, volatile rename and disable re-arming, and the handler's forwarding (frozen user message with a fresh UUID, the `/readimage` token included, attachments preserved by identity) plus every refusal path (bare command, disabled manager, advisory mode, vision-unconfigured, no inbox, throwing followup, aborted signal), the turn-keyed override lifecycle through the real seam order claim → current → pre-step → request (whole-turn vision routing including tool-loop steps, mid-turn steering not cancelling it, the next plain turn returning to normal routing, consecutive gestures), composer-pick force-then-restore — including the corner cases that the restore must hand back the user's LATEST pick (a newer composer pick made after or between commanded turns is kept, never clobbered by the stale memory) and that `main` does not eat the restored pick — precedence over plan mode and planning skills for the commanded turn only, subagent sessions never binding the override while their label routing is untouched, the legacy 0.1.x rewrite path with the explicit-selection bypass for that one turn, both diagnostic surfaces, the cheat sheet never advertising the command while disabled or advisory, and `agent/disposed` clean rebind. |
1673
+
1569
1674
  The suites are plain Node scripts — no test framework, and no dependency beyond Node itself.
1570
1675
 
1571
1676
  Two of them optionally pin their expectations against the **real** harness internals rather
@@ -1610,6 +1715,16 @@ outside the repository.
1610
1715
  routes the planning fork, and the top-level session stays on `main` because `autoplan` is not in
1611
1716
  `planningSkills`. A project-level skill file of the same name overrides the bundled body
1612
1717
  entirely (see the override note above).
1718
+ - **The `/readimage` override is process-live.** It is per-message intent, not durable session
1719
+ state: nothing is folded into the log, so a restart loses an in-flight commanded turn's routing
1720
+ and the next message routes normally. Type the gesture again to command a new turn.
1721
+ - **Images need the command path on a text-only current model.** The plain-text gesture routes
1722
+ text-only messages, but it cannot carry attachments past the admission gate: on DSH 0.2.x with a
1723
+ text-only model selected, the harness refuses the images with `MODEL_DOES_NOT_SUPPORT_IMAGES`
1724
+ before any routing hook runs. Only the registered command admits them.
1725
+ - **The command needs a `commands` service in the composition.** Older harnesses without one
1726
+ register no command, and the feature degrades to gesture-only routing for text messages — images
1727
+ then have no path at all while a text-only model is selected.
1613
1728
  - **`hybrid` compares routes by value.** A child that deliberately names the same route as
1614
1729
  the parent's effective route is indistinguishable from one that inherited it, and will
1615
1730
  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.0';
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,13 @@
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
51
58
  # Auto-delegation policy (0.3.0): off | balanced | eager.
52
59
  # Adds a system-prompt section telling the top-level agent to plan
53
60
  # 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', 'historyLimit', 'autoDelegate'];
56
57
  const KNOWN_UPDATE_KEYS = ['enabled', 'registry', 'intervalHours'];
57
58
 
58
59
  /**
@@ -174,6 +175,20 @@ 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
+
177
192
  /**
178
193
  * The public DSH skill-name grammar and the `/name` gesture the harness scans
179
194
  * for in direct user text.
@@ -337,6 +352,7 @@ function buildConfigSchema(z) {
337
352
  visionKeywords: z.array(z.string()).default(DEFAULT_VISION_KEYWORDS),
338
353
  planningKeywords: z.array(z.string()).default(DEFAULT_PLANNING_KEYWORDS),
339
354
  planningSkills: z.array(z.string()).default(DEFAULT_PLANNING_SKILLS),
355
+ readImageCommand: z.string().default(DEFAULT_READ_IMAGE_COMMAND),
340
356
  historyLimit: z.number().default(300),
341
357
  autoDelegate: z.union([z.const('off'), z.const('balanced'), z.const('eager')]).default('balanced'),
342
358
  });
@@ -451,6 +467,32 @@ function normalizeSkillNames(value) {
451
467
  return names;
452
468
  }
453
469
 
470
+ /**
471
+ * Normalize `strategy.readImageCommand`.
472
+ *
473
+ * An absent or non-string value takes the built-in default (the same fail-on
474
+ * philosophy as the keyword lists: a malformed value must not silently switch
475
+ * a feature off). An explicit empty string is honoured and disables both the
476
+ * command registration and the gesture scan. A name outside the grammar logs
477
+ * a warning and disables the feature: it must be kebab-case for the gesture
478
+ * scanner AND start with a letter for the command registry's own
479
+ * `COMMAND_NAME`, so a name failing either could never be invoked as a
480
+ * command — better to refuse it at config time than fail registration at boot.
481
+ */
482
+ const READ_IMAGE_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
483
+
484
+ function normalizeReadImageCommand(value, warnings) {
485
+ const raw = readVal(value);
486
+ if (raw === undefined || raw === null || typeof raw !== 'string') return DEFAULT_READ_IMAGE_COMMAND;
487
+ const name = raw.trim().toLowerCase();
488
+ if (name === '') return '';
489
+ if (!READ_IMAGE_NAME.test(name)) {
490
+ warnings?.push(`strategy.readImageCommand "${raw}" is not a lowercase kebab-case name starting with a letter; the read-image command is disabled`);
491
+ return '';
492
+ }
493
+ return name;
494
+ }
495
+
454
496
  function normalizeRoute(raw) {
455
497
  const value = readVal(raw);
456
498
  if (value === null || typeof value !== 'object') return undefined;
@@ -677,6 +719,9 @@ function readConfig(raw) {
677
719
  // Absent/malformed -> the grill defaults; explicit [] switches the
678
720
  // skill-to-planning escalation off.
679
721
  planningSkills: normalizeSkillNames(strategyRaw.planningSkills),
722
+ // Absent/malformed -> 'readimage'; explicit '' switches the one-turn
723
+ // vision command off; an invalid name warns and disables it.
724
+ readImageCommand: normalizeReadImageCommand(strategyRaw.readImageCommand, warnings),
680
725
  // Guard against a positive fraction flooring to 0, which would evict every
681
726
  // record immediately and silently disable usage tracking.
682
727
  historyLimit: Number.isFinite(limit) && limit > 0 ? Math.max(1, Math.floor(limit)) : 300,
@@ -801,6 +846,30 @@ function planningSkillInMessages(messages, wanted) {
801
846
  return undefined;
802
847
  }
803
848
 
849
+ /**
850
+ * Whether a batch of user messages carries the read-image gesture. Pure.
851
+ *
852
+ * Recognition uses the harness's own `/name` grammar (the same word-boundary
853
+ * shape tool-skill scans), so `/readimage` reads as a gesture wherever it sits
854
+ * in the sentence while file paths and fractions never match. Only direct user
855
+ * text counts — no other source can forge the gesture. The command handler
856
+ * forwards the original line, token included, so the claimed message it queues
857
+ * carries the gesture into the routing seams below.
858
+ */
859
+ function readImageGestureInMessages(messages, command) {
860
+ if (typeof command !== 'string' || command === '') return false;
861
+ for (const message of Array.isArray(messages) ? messages : []) {
862
+ if (message?.source?.kind !== 'user') continue;
863
+ for (const block of Array.isArray(message.content) ? message.content : []) {
864
+ if (block?.type !== 'text' || typeof block.text !== 'string') continue;
865
+ for (const match of block.text.matchAll(SKILL_GESTURE)) {
866
+ if (match[2] === command) return true;
867
+ }
868
+ }
869
+ }
870
+ return false;
871
+ }
872
+
804
873
  /** Find the delegating parent of a child session. */
805
874
  function findParent(ctx, childId) {
806
875
  return probe(() => {
@@ -1100,6 +1169,17 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1100
1169
  */
1101
1170
  let autoplanRegistered = false;
1102
1171
 
1172
+ /**
1173
+ * The `commands` service, captured when its injection resolves, plus the
1174
+ * live registration of the read-image command. `readImageName` is the name
1175
+ * actually registered ('' when none), so a volatile Settings save that
1176
+ * renames the command can dispose the old registration and arm the new one,
1177
+ * and `routes` can tell "configured" from "registered in this composition".
1178
+ */
1179
+ let commandsService;
1180
+ let readImageDispose;
1181
+ let readImageName = '';
1182
+
1103
1183
  /**
1104
1184
  * Latest update-check outcome. Statuses: `idle` (not yet checked), `checking`,
1105
1185
  * `ok` (up to date), `available` (a newer release exists), `error` (the check
@@ -1141,6 +1221,23 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1141
1221
  /** session id -> the last top-level trigger, so the info log fires once per switch. */
1142
1222
  const topTriggers = new Map();
1143
1223
 
1224
+ /**
1225
+ * session id -> `{ turn, restore }` for the ONE turn carrying `/readimage`.
1226
+ *
1227
+ * The override is keyed to the turn number that claimed the gesture, which
1228
+ * is what makes it expire by itself: every later step of that turn compares
1229
+ * equal and stays on vision, while the first claim of any other turn compares
1230
+ * different and ends it. `restore` remembers a hand-picked composer route the
1231
+ * command overrode (hybrid normally respects it), so the pick is selected
1232
+ * back when the commanded turn ends instead of being silently dropped.
1233
+ *
1234
+ * Deliberately process-live, with no durable projection: this is per-message
1235
+ * intent, not session state. After a restart the next message routes
1236
+ * normally, which is exactly the contract — only a fresh gesture commands a
1237
+ * fresh turn.
1238
+ */
1239
+ const readImageTurns = new Map();
1240
+
1144
1241
  /** Add one skill name to a session's live list, bounded and de-duplicated. */
1145
1242
  function addLiveSkill(id, name) {
1146
1243
  const normalized = typeof name === 'string' ? name.trim().toLowerCase() : '';
@@ -1200,6 +1297,9 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1200
1297
  try {
1201
1298
  const agent = payload?.agent;
1202
1299
  const id = typeof agent?.id === 'string' ? agent.id : undefined;
1300
+ const isSubagent = agent === undefined
1301
+ ? false
1302
+ : probe(() => agent.session?.header?.origin === 'subagent') === true;
1203
1303
  if (id !== undefined && decision?.kind !== 'reject') {
1204
1304
  for (const batch of [payload?.messages, decision?.messages]) {
1205
1305
  if (!Array.isArray(batch)) continue;
@@ -1207,6 +1307,16 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1207
1307
  for (const name of skillNamesOfMessage(message)) addLiveSkill(id, name);
1208
1308
  }
1209
1309
  }
1310
+ // The read-image override binds here too, on every transport: the
1311
+ // claim boundary covers the first step, and this scan covers a harness
1312
+ // whose claim notification predates the listener (or a batch the claim
1313
+ // seam never saw). Top-level only — a child's routing stays label-driven.
1314
+ if (!isSubagent) {
1315
+ for (const batch of [payload?.messages, decision?.messages]) {
1316
+ if (Array.isArray(batch)) noteReadImageGesture(agent, batch, payload?.turn);
1317
+ }
1318
+ endReadImageTurn(agent, payload?.turn);
1319
+ }
1210
1320
  }
1211
1321
  // On a harness that fixes the route at step preparation, keep the
1212
1322
  // selection correct from step to step: this call lands on the NEXT step,
@@ -1215,18 +1325,21 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1215
1325
  // that is about to run.
1216
1326
  if (agent !== undefined && decision?.kind !== 'reject'
1217
1327
  && selectionModelOf(agent) !== undefined && config.enabled) {
1218
- const isSubagent = probe(() => agent.session?.header?.origin === 'subagent') === true;
1219
1328
  if (isSubagent) {
1220
1329
  const facts = catalog.get(agent.id);
1221
1330
  if (facts !== undefined) {
1222
1331
  applySelection(agent, classifySubagent(facts.label), undefined, facts.label, true);
1223
1332
  }
1224
1333
  } else {
1334
+ const readImage = readImageActive(agent, payload?.turn);
1225
1335
  const plan = planActive(ctx, agent);
1226
- const skill = plan ? undefined : planningSkillFor(agent);
1227
- const trigger = skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1336
+ const skill = plan || readImage ? undefined : planningSkillFor(agent);
1337
+ const trigger = readImage
1338
+ ? `command:${config.strategy.readImageCommand}`
1339
+ : skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1228
1340
  noteTopTrigger(agent, trigger);
1229
- applySelection(agent, plan || skill !== undefined ? 'planning' : 'main', trigger, undefined, false);
1341
+ applySelection(agent, readImage ? 'vision' : plan || skill !== undefined ? 'planning' : 'main',
1342
+ trigger, undefined, false, readImage);
1230
1343
  }
1231
1344
  }
1232
1345
  } catch {
@@ -1245,6 +1358,88 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1245
1358
  log('info', `planning skill "${trigger.slice('skill:'.length)}" is active in this session; `
1246
1359
  + 'top-level requests route as planning');
1247
1360
  }
1361
+ if (trigger.startsWith('command:')) {
1362
+ log('info', `/${trigger.slice('command:'.length)} commands this turn on the vision role; `
1363
+ + 'the next message without the gesture returns to the normal route');
1364
+ }
1365
+ }
1366
+
1367
+ /** Whether the read-image override owns the turn a step belongs to. */
1368
+ function readImageActive(agent, turn) {
1369
+ if (!Number.isSafeInteger(turn)) return false;
1370
+ const id = typeof agent?.id === 'string' ? agent.id : undefined;
1371
+ return id !== undefined && readImageTurns.get(id)?.turn === turn;
1372
+ }
1373
+
1374
+ /**
1375
+ * Bind the override to the turn whose claimed input carries the gesture.
1376
+ *
1377
+ * Called at both routing seams (the claim boundary and the pre-step batch)
1378
+ * with the turn number the harness reports, so the binding is to the turn
1379
+ * that OWNS the message — a mid-turn steering message without the gesture
1380
+ * cannot steal or cancel it. A consecutive commanded turn keeps the original
1381
+ * `restore` route: the pick to hand back is the one from before the first
1382
+ * override, never the vision route the manager itself selected.
1383
+ */
1384
+ function noteReadImageGesture(agent, messages, turn) {
1385
+ const command = config.strategy.readImageCommand;
1386
+ if (command === '' || !Number.isSafeInteger(turn)) return;
1387
+ const id = typeof agent?.id === 'string' ? agent.id : undefined;
1388
+ if (id === undefined || !readImageGestureInMessages(messages, command)) return;
1389
+ const existing = readImageTurns.get(id);
1390
+ if (existing?.turn === turn) return;
1391
+ const current = probe(() => selectionModelOf(agent)?.current());
1392
+ // A pick made after the previous commanded turn is newer than the one
1393
+ // remembered then, so it replaces the memory: what must come back is the
1394
+ // user's LATEST choice, never a stale one. When current is the manager's
1395
+ // own vision route (the ordinary case) it is not foreign and the original
1396
+ // memory stands.
1397
+ const restore = (selectionIsForeign(agent, current) ? current : undefined) ?? existing?.restore;
1398
+ readImageTurns.set(id, { turn, restore });
1399
+ }
1400
+
1401
+ /**
1402
+ * End the override when a DIFFERENT turn claims input, handing a remembered
1403
+ * composer pick back.
1404
+ *
1405
+ * The restore is selected before the normal role decision runs, so the
1406
+ * hybrid gate that follows reads the pick as foreign again and respects it —
1407
+ * ownership is dropped on purpose: a restored pick is the user's choice, not
1408
+ * a route the manager may replace with `main` on the next turn. On the 0.1.x
1409
+ * rewrite path nothing was ever durably selected, so there is nothing to
1410
+ * restore and the pick survives on its own.
1411
+ */
1412
+ function endReadImageTurn(agent, turn) {
1413
+ const id = typeof agent?.id === 'string' ? agent.id : undefined;
1414
+ if (id === undefined || !Number.isSafeInteger(turn)) return;
1415
+ const active = readImageTurns.get(id);
1416
+ if (active === undefined || active.turn === turn) return;
1417
+ readImageTurns.delete(id);
1418
+ if (active.restore === undefined) return;
1419
+ if (!config.enabled || config.strategy.mode === 'advisory') return;
1420
+ const model = selectionModelOf(agent);
1421
+ if (model === undefined) return;
1422
+ try {
1423
+ // A hand pick made AFTER the commanded turn is newer than the one
1424
+ // remembered at command time. Keep it and drop ownership so hybrid
1425
+ // respects it — restoring the stale memory would eat the user's latest
1426
+ // choice, which is exactly what the restore exists to protect.
1427
+ const current = probe(() => model.current());
1428
+ if (selectionIsForeign(agent, current)) {
1429
+ managerSelected.delete(id);
1430
+ return;
1431
+ }
1432
+ model.select({
1433
+ provider: active.restore.provider,
1434
+ model: active.restore.model,
1435
+ ...(active.restore.reasoningEffort === undefined ? {} : { reasoningEffort: active.restore.reasoningEffort }),
1436
+ });
1437
+ managerSelected.delete(id);
1438
+ log('info', `restored the hand-picked ${active.restore.provider}/${active.restore.model} `
1439
+ + `for ${shortId(id)} after the read-image turn`);
1440
+ } catch (error) {
1441
+ log('warn', `could not restore the hand-picked route: ${error?.message ?? error}`);
1442
+ }
1248
1443
  }
1249
1444
 
1250
1445
  /** The model list a role actually resolves to, including the vision fallback. */
@@ -1345,8 +1540,14 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1345
1540
  * (before the first step) and at `agent/pre-step` (for the step after the one
1346
1541
  * in flight). Returns whether a selection was recorded; every failure is
1347
1542
  * contained.
1543
+ *
1544
+ * `force` is the read-image command's one-turn authority: an explicit user
1545
+ * instruction for THIS message outranks even a hand-picked composer route
1546
+ * for the turn it commands (the pick is remembered and restored afterwards
1547
+ * by `endReadImageTurn`). It never bypasses the master switch or advisory
1548
+ * mode — those mean the manager does not move routes at all.
1348
1549
  */
1349
- function applySelection(agent, role, trigger, label, isSubagent) {
1550
+ function applySelection(agent, role, trigger, label, isSubagent, force = false) {
1350
1551
  const model = selectionModelOf(agent);
1351
1552
  if (model === undefined || !config.enabled) return false;
1352
1553
  try {
@@ -1355,7 +1556,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1355
1556
  if (candidate === undefined) return false;
1356
1557
  const route = candidate.route;
1357
1558
  const current = probe(() => model.current());
1358
- if (!selectionAllowed(agent, current, isSubagent)) {
1559
+ if (!force && !selectionAllowed(agent, current, isSubagent)) {
1359
1560
  if (!isSubagent && current !== undefined) {
1360
1561
  log('info', `session ${shortId(agent.id)} keeps ${current.provider}/${current.model}: `
1361
1562
  + 'a hand-picked model is respected under hybrid');
@@ -1452,14 +1653,26 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1452
1653
  }
1453
1654
  return;
1454
1655
  }
1656
+ // The claimed message names the intent, and the payload names the turn
1657
+ // that owns it: bind the read-image override to THAT turn, end any older
1658
+ // one (handing a remembered composer pick back), then decide the role.
1659
+ // The command outranks plan mode and planning skills for its own turn —
1660
+ // it is the most recent explicit instruction — and only for that turn.
1661
+ const turn = payload?.turn;
1662
+ noteReadImageGesture(agent, [message], turn);
1663
+ endReadImageTurn(agent, turn);
1664
+ const readImage = readImageActive(agent, turn);
1455
1665
  const plan = planActive(ctx, agent);
1456
- const skill = plan
1666
+ const skill = plan || readImage
1457
1667
  ? undefined
1458
1668
  : (planningSkillFor(agent)
1459
1669
  ?? planningSkillInMessages([message], config.strategy.planningSkills));
1460
- const trigger = skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1670
+ const trigger = readImage
1671
+ ? `command:${config.strategy.readImageCommand}`
1672
+ : skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1461
1673
  noteTopTrigger(agent, trigger);
1462
- applySelection(agent, plan || skill !== undefined ? 'planning' : 'main', trigger, undefined, false);
1674
+ applySelection(agent, readImage ? 'vision' : plan || skill !== undefined ? 'planning' : 'main',
1675
+ trigger, undefined, false, readImage);
1463
1676
  } catch {
1464
1677
  /* observe-only at the claim boundary */
1465
1678
  }
@@ -1622,21 +1835,26 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1622
1835
  let role;
1623
1836
  let label;
1624
1837
  let trigger;
1838
+ let readImage = false;
1625
1839
  if (isSubagent) {
1626
1840
  const facts = await factsFor(agent.id);
1627
1841
  label = facts?.label;
1628
1842
  role = classifySubagent(label);
1629
1843
  } else {
1630
- // Plan mode is the harness's own "thinking work" mode; a planning skill
1844
+ // The read-image command owns its turn outright; below it, plan mode
1845
+ // is the harness's own "thinking work" mode and a planning skill
1631
1846
  // (`grilling` / `grill-me`) is the user's own version of the same
1632
1847
  // intent, so both put the top-level session on the planning tier.
1848
+ readImage = readImageActive(agent, payload?.turn);
1633
1849
  const plan = planActive(ctx, agent);
1634
- const skill = plan ? undefined : planningSkillFor(agent);
1635
- trigger = skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1850
+ const skill = plan || readImage ? undefined : planningSkillFor(agent);
1851
+ trigger = readImage
1852
+ ? `command:${config.strategy.readImageCommand}`
1853
+ : skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
1636
1854
  // Only claim routing when routing is on; a disabled manager still records
1637
1855
  // the trigger in its observed rows, but must not log that requests route.
1638
1856
  if (config.enabled) noteTopTrigger(agent, trigger);
1639
- role = plan || skill !== undefined ? 'planning' : 'main';
1857
+ role = readImage ? 'vision' : plan || skill !== undefined ? 'planning' : 'main';
1640
1858
  }
1641
1859
 
1642
1860
  // Master switch off: observe and record, but never rewrite a route. The
@@ -1722,13 +1940,17 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1722
1940
  output = resolved;
1723
1941
  } else {
1724
1942
  let inherited = true;
1725
- if (mode === 'hybrid' && !isSubagent && selectionWasExplicit(agent)) {
1943
+ if (mode === 'hybrid' && !isSubagent && !readImage && selectionWasExplicit(agent)) {
1726
1944
  // `main` replaces a route the user never chose; it does not overrule
1727
1945
  // one they did choose. The proof is a durable log event, so a real
1728
1946
  // composer pick survives restart, resume and fork, while a session
1729
1947
  // still riding the deployment default is rewritten as before.
1730
1948
  // `managed` is the mode for "the manager owns every route", including a
1731
1949
  // session the user already picked, and is left untouched here.
1950
+ // The read-image command is the one exception: it is an explicit user
1951
+ // instruction for THIS turn, newer than the pick, so it rewrites for
1952
+ // that turn only — the durable selection is untouched on this path,
1953
+ // and the next turn respects the pick again by itself.
1732
1954
  inherited = false;
1733
1955
  reason = 'explicit session selection (respected)';
1734
1956
  } else if (mode === 'hybrid' && isSubagent) {
@@ -1761,6 +1983,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
1761
1983
  }
1762
1984
  output = inherited ? applyRoute(resolved, route) : resolved;
1763
1985
  didApply = inherited;
1986
+ if (didApply && readImage) reason = 'applied (read-image command, one turn)';
1764
1987
  }
1765
1988
 
1766
1989
  // Commit the rotation only when a route was actually applied, and record
@@ -2326,6 +2549,17 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2326
2549
  lines.push('These sessions invoked a planning skill, so they route to the planning tier for');
2327
2550
  lines.push('the rest of the session, like plan mode; a hand-picked composer model still wins.');
2328
2551
  }
2552
+ const commandTriggers = topRows.filter((row) => typeof row.seen.trigger === 'string'
2553
+ && row.seen.trigger.startsWith('command:')
2554
+ && row.seen.reason !== 'manager disabled (observed only)');
2555
+ if (commandTriggers.length > 0) {
2556
+ lines.push('');
2557
+ lines.push('Read-image command: ' + commandTriggers
2558
+ .map((row) => `${shortId(row.sessionId)} → /${row.seen.trigger.slice('command:'.length)}`)
2559
+ .join(', '));
2560
+ lines.push('The last turn of these sessions carried the read-image gesture, so it ran on the');
2561
+ lines.push('vision role for that one turn; the next message without it routes normally again.');
2562
+ }
2329
2563
  lines.push('');
2330
2564
  }
2331
2565
  if (rows.length > 0) {
@@ -2416,6 +2650,16 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2416
2650
  : `${config.strategy.planningSkills.join(', ')} — a top-level session that invoked one routes as `
2417
2651
  + 'planning for the rest of the session, like plan mode'}`,
2418
2652
  '',
2653
+ `Read-image command: ${config.strategy.readImageCommand === ''
2654
+ ? '(disabled) — strategy.readImageCommand is empty'
2655
+ : `/${config.strategy.readImageCommand} — the turn carrying it runs on the vision role (one turn only; `
2656
+ + 'the next message without the gesture returns to the normal route, and a hand-picked composer model '
2657
+ + 'is restored afterwards). '
2658
+ + (readImageName === config.strategy.readImageCommand
2659
+ ? 'Registered with attachment support, so images pass admission even on a text-only current model.'
2660
+ : 'NOT registered (no commands service, or registration failed — see the startup log) — '
2661
+ + 'only plain-text gestures route; images still need a current model that accepts them.')}`,
2662
+ '',
2419
2663
  `Autoplan skill: ${autoplanRegistered
2420
2664
  ? 'registered — `/autoplan` plans on the planning tier and implements on `main` '
2421
2665
  + 'without an approval gate'
@@ -2461,12 +2705,18 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2461
2705
  ? '\nA top-level session that invoked '
2462
2706
  + `${config.strategy.planningSkills.join(' / ')} runs on the planning tier, like plan mode.`
2463
2707
  : '';
2708
+ const readImageNote = config.enabled && config.strategy.mode !== 'advisory'
2709
+ && config.strategy.readImageCommand !== '' && effectiveModels('vision').length > 0
2710
+ ? `\nThe user can type /${config.strategy.readImageCommand} to run one message (with images) on the vision `
2711
+ + 'tier for its whole turn; the next message without it returns to the normal route. Suggest it when '
2712
+ + 'the user wants an image read but the current model cannot see images.'
2713
+ : '';
2464
2714
  return [
2465
2715
  '## Model manager',
2466
2716
  'Delegated work is routed by the label you give each delegation:',
2467
2717
  ...summary,
2468
2718
  routing,
2469
- `Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}${skillNote}`,
2719
+ `Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}${skillNote}${readImageNote}`,
2470
2720
  ].join('\n');
2471
2721
  }
2472
2722
 
@@ -2716,6 +2966,90 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2716
2966
  return state?.explicit === true;
2717
2967
  }
2718
2968
 
2969
+ /**
2970
+ * The `/readimage` command handler: forward, don't answer.
2971
+ *
2972
+ * The harness's ordinary prompt path refuses images while the selected model
2973
+ * declares text-only input (`MODEL_DOES_NOT_SUPPORT_IMAGES` in
2974
+ * dsh-api-session-controller), and it does so BEFORE any routing hook runs —
2975
+ * so a gesture scan alone could never see an image message on a text-only
2976
+ * main tier. The command path admits attachments without that gate; this
2977
+ * handler rebuilds the original line (token included, so the claim-boundary
2978
+ * gesture scan binds the turn) plus the admitted image/file blocks as an
2979
+ * ordinary user message and queues it with `agent.followup()`. The message
2980
+ * shape mirrors dsh-llm's `createUserMessage` — role, fresh UUID identity,
2981
+ * `source.kind: 'user'` — without importing a harness package, which a
2982
+ * profile-installed plugin cannot resolve. Routing then happens at the claim
2983
+ * boundary exactly as it does for any typed message.
2984
+ */
2985
+ function readImageHandler(invocation, name) {
2986
+ try {
2987
+ const agent = invocation?.agent;
2988
+ if (agent === undefined || typeof agent.followup !== 'function') {
2989
+ return { kind: 'error', text: `/${name}: this composition exposes no agent inbox to forward the message to` };
2990
+ }
2991
+ if (!config.enabled) {
2992
+ return { kind: 'error', text: `/${name}: the model manager is disabled, so the vision route cannot be selected` };
2993
+ }
2994
+ if (config.strategy.mode === 'advisory') {
2995
+ return { kind: 'error', text: `/${name}: the manager is advisory (observe-only), so it cannot switch this message to the vision model` };
2996
+ }
2997
+ if (effectiveModels('vision').length === 0) {
2998
+ return { kind: 'error', text: `/${name}: no vision model is configured — set roles.vision.models to an image-capable model` };
2999
+ }
3000
+ const rawInput = typeof invocation?.rawInput === 'string' ? invocation.rawInput : '';
3001
+ const attachments = Array.isArray(invocation?.attachments) ? invocation.attachments : [];
3002
+ if (rawInput.trim() === '' && attachments.length === 0) {
3003
+ return { kind: 'error', text: `usage: /${name} <question> — attach the image(s) to read; the message runs on the vision model for one turn` };
3004
+ }
3005
+ if (invocation?.signal?.aborted === true) {
3006
+ return { kind: 'error', text: `/${name}: cancelled before the message was forwarded` };
3007
+ }
3008
+ const line = `/${name}${rawInput}`;
3009
+ agent.followup(Object.freeze({
3010
+ role: 'user',
3011
+ id: randomUUID(),
3012
+ source: Object.freeze({ kind: 'user' }),
3013
+ content: Object.freeze([Object.freeze({ type: 'text', text: line }), ...attachments]),
3014
+ }));
3015
+ return { kind: 'success' };
3016
+ } catch (error) {
3017
+ return { kind: 'error', text: `/${name}: ${error?.message ?? error}` };
3018
+ }
3019
+ }
3020
+
3021
+ /**
3022
+ * Register (or re-register) the read-image command under the live config
3023
+ * name. Idempotent while the name is unchanged; a rename disposes the old
3024
+ * registration first. Every failure degrades to a warning — a composition
3025
+ * without the commands service simply keeps the plain-text gesture routing.
3026
+ */
3027
+ function armReadImageCommand() {
3028
+ if (commandsService === undefined || typeof commandsService.register !== 'function') return;
3029
+ const name = config.strategy.readImageCommand;
3030
+ if (readImageName === name) return;
3031
+ if (readImageDispose !== undefined) {
3032
+ try { readImageDispose(); } catch { /* a failed dispose must not block the re-arm */ }
3033
+ readImageDispose = undefined;
3034
+ }
3035
+ readImageName = '';
3036
+ if (name === '') return;
3037
+ try {
3038
+ const dispose = commandsService.register({
3039
+ name,
3040
+ description: 'Read attached images with the vision model: this message (and its turn) runs on the '
3041
+ + "manager's vision role, then the next message returns to the normal route. Accepts image attachments.",
3042
+ input: { hint: 'question about the attached image(s)', attachments: true },
3043
+ handler: (invocation) => readImageHandler(invocation, name),
3044
+ });
3045
+ readImageDispose = typeof dispose === 'function' ? dispose : () => {};
3046
+ readImageName = name;
3047
+ log('info', `registered the /${name} command — one turn on the vision role, with attachment support`);
3048
+ } catch (error) {
3049
+ log('warn', `/${name} command not registered: ${error?.message ?? error}`);
3050
+ }
3051
+ }
3052
+
2719
3053
  function attach() {
2720
3054
  ctx.on('agent/request', onAgentRequest);
2721
3055
  ctx.on('agent/request-error', onRequestError);
@@ -2740,6 +3074,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2740
3074
  liveSkills.delete(id);
2741
3075
  topTriggers.delete(id);
2742
3076
  managerSelected.delete(id);
3077
+ readImageTurns.delete(id);
2743
3078
  });
2744
3079
 
2745
3080
  // Claim-boundary selection (DSH 0.2.x): the loop claims a step's input and
@@ -2784,6 +3119,10 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2784
3119
  };
2785
3120
  visionMatch = keywordMatcher(config.strategy.visionKeywords);
2786
3121
  planningMatch = keywordMatcher(config.strategy.planningKeywords);
3122
+ // A renamed (or disabled) read-image command takes effect on the save:
3123
+ // the gesture scan already reads the live config, and this re-arms the
3124
+ // harness command registration under the new name.
3125
+ armReadImageCommand();
2787
3126
  for (const warning of config.warnings) log('warn', warning);
2788
3127
  // The delegation policy and the update schedule both read the live
2789
3128
  // config through this closure, so they follow a save with no restart.
@@ -2791,7 +3130,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2791
3130
  const updateChanged = JSON.stringify(previousUpdate) !== JSON.stringify(config.update);
2792
3131
  if (updateChanged) void checkForUpdate().catch(() => {});
2793
3132
  log('info', `settings reloaded — mode ${config.strategy.mode}, pick ${config.pick}, autoDelegate ${config.strategy.autoDelegate}, `
2794
- + `planningSkills ${config.strategy.planningSkills.join('|') || '-'}; `
3133
+ + `planningSkills ${config.strategy.planningSkills.join('|') || '-'}, `
3134
+ + `readImage ${config.strategy.readImageCommand || '-'}; `
2795
3135
  + ROLE_NAMES
2796
3136
  .map((key) => `${key}=${config.roles[key].models.length === 0 ? '-' : config.roles[key].models.map((r) => `${r.provider}/${r.model}`).join('|')}`)
2797
3137
  .join(' '));
@@ -2811,11 +3151,13 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2811
3151
  description: 'Inspect and explain the role-based model routing configured for this harness. '
2812
3152
  + 'action "report": a Top-level agents section naming which model served each '
2813
3153
  + '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, '
3154
+ + 'composer, which planning skill (if any) put a session on the planning tier, '
3155
+ + 'and whether the last turn carried the read-image command, '
2815
3156
  + 'then one row per subagent with its label, role, reason, live status and '
2816
3157
  + 'totals. action "routes": the four role assignments '
2817
3158
  + '(including the vision->execution fallback), the shared selection strategy (first or round-robin), '
2818
3159
  + 'the active distribution mode, the auto-delegation level, the planning-skill trigger, '
3160
+ + 'the read-image command (one turn on the vision role), '
2819
3161
  + 'the update-check status, '
2820
3162
  + 'and whether each '
2821
3163
  + 'route is dispatchable by the delegation tool, with the YAML to add any that are not. '
@@ -2972,6 +3314,37 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
2972
3314
  log('warn', `/autoplan skill not registered: ${error?.message ?? error}`);
2973
3315
  }
2974
3316
  });
3317
+
3318
+ // The read-image command (0.7.0). Like /autoplan this is a workflow
3319
+ // gesture the plugin ships, but unlike a skill it must accept image
3320
+ // attachments: the command path is the only admission seam that lets
3321
+ // images through while a text-only model is selected. Registration
3322
+ // follows the live config name; a volatile save re-arms it below.
3323
+ ctx.inject(['commands'], (scoped) => {
3324
+ try {
3325
+ commandsService = scoped?.commands;
3326
+ if (commandsService === undefined || typeof commandsService.register !== 'function') {
3327
+ log('warn', 'the commands service is present but exposes no register(); the read-image command is unavailable');
3328
+ return;
3329
+ }
3330
+ if (typeof scoped.effect === 'function') {
3331
+ scoped.effect(() => {
3332
+ armReadImageCommand();
3333
+ return () => {
3334
+ if (readImageDispose !== undefined) {
3335
+ try { readImageDispose(); } catch { /* disposal is best-effort */ }
3336
+ readImageDispose = undefined;
3337
+ }
3338
+ readImageName = '';
3339
+ };
3340
+ });
3341
+ } else {
3342
+ armReadImageCommand();
3343
+ }
3344
+ } catch (error) {
3345
+ log('warn', `read-image command not registered: ${error?.message ?? error}`);
3346
+ }
3347
+ });
2975
3348
  }
2976
3349
 
2977
3350
  // Boot diagnostic: tell the operator about role routes the delegation tool
@@ -3074,7 +3447,10 @@ export {
3074
3447
  selectionModelOf,
3075
3448
  sameSelection,
3076
3449
  planningSkillInMessages,
3450
+ readImageGestureInMessages,
3451
+ normalizeReadImageCommand,
3077
3452
  DEFAULT_PLANNING_KEYWORDS,
3078
3453
  DEFAULT_PLANNING_SKILLS,
3454
+ DEFAULT_READ_IMAGE_COMMAND,
3079
3455
  DEFAULT_VISION_KEYWORDS,
3080
3456
  };
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@darkbear9494/dsh-model-manager",
3
- "version": "0.6.1",
3
+ "version": "0.7.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, 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, 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",
11
12
  "deepseek-harness",
12
13
  "cordis",
13
14
  "model-routing",
@@ -35,7 +36,7 @@
35
36
  },
36
37
  "meta": {
37
38
  "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."
39
+ "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), and get update notices."
39
40
  },
40
41
  "exports": {
41
42
  ".": "./lib/index.js",