llm-orchestrator 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +237 -45
  3. package/SKILL.md +30 -2
  4. package/adapters/agents.mjs +8 -5
  5. package/adapters/codex/index.mjs +0 -2
  6. package/adapters/commands.mjs +21 -1
  7. package/adapters/hooks.mjs +18 -6
  8. package/agents/advisor.md +53 -0
  9. package/agents/code-reviewer.md +1 -0
  10. package/agents/frontend-fixer.md +2 -1
  11. package/agents/frontend-specialist.md +2 -1
  12. package/agents/orchestrator.md +1 -1
  13. package/bin/budget.mjs +94 -0
  14. package/bin/cli-options.mjs +31 -10
  15. package/bin/discover-models.mjs +428 -13
  16. package/bin/doctor.mjs +54 -26
  17. package/bin/gate.mjs +1 -1
  18. package/bin/install.mjs +15 -8
  19. package/bin/llm-orchestrator.mjs +14 -3
  20. package/bin/model-thinking-report.mjs +1 -0
  21. package/bin/route.mjs +57 -18
  22. package/bin/strategy.mjs +234 -0
  23. package/bin/uninstall.mjs +3 -1
  24. package/commands/task.md +21 -1
  25. package/hooks/hooks.json +11 -0
  26. package/lib/adapter-renderer.mjs +131 -10
  27. package/lib/budget.mjs +269 -0
  28. package/lib/capability-resolver.mjs +59 -5
  29. package/lib/dispatch-contract.mjs +87 -24
  30. package/lib/file-lock.mjs +121 -0
  31. package/lib/first-run.mjs +53 -10
  32. package/lib/flow-gate.mjs +377 -71
  33. package/lib/installation.mjs +313 -75
  34. package/lib/learning.mjs +233 -0
  35. package/lib/project-discovery.mjs +4 -0
  36. package/lib/project-root.mjs +52 -0
  37. package/lib/router.mjs +473 -65
  38. package/lib/strategy-store.mjs +481 -0
  39. package/models/example-model-inventory.json +21 -10
  40. package/models/model-thinking-data.json +134 -2
  41. package/models/model-thinking-matrix.md +32 -0
  42. package/models/top-models.json +794 -44
  43. package/package.json +1 -1
  44. package/policies/capabilities.md +64 -10
  45. package/policies/dispatch.md +6 -1
  46. package/policies/learning.md +336 -0
  47. package/policies/routing.md +240 -63
  48. package/protocol.md +21 -0
  49. package/registries/agent-roles.json +43 -4
  50. package/registries/capabilities.json +2 -1
  51. package/registries/core-profile.json +29 -0
  52. package/registries/learning.json +219 -0
  53. package/registries/preferred-tools.json +85 -2
  54. package/registries/routing-matrix.json +61 -37
  55. package/registries/task-mappings.json +52 -6
  56. package/schemas/capability-contract.schema.json +1 -0
  57. package/schemas/flow-ledger.schema.json +8 -2
  58. package/schemas/installation-manifest.schema.json +56 -5
  59. package/schemas/learning.schema.json +139 -0
  60. package/schemas/routing-matrix.schema.json +23 -3
  61. package/schemas/top-models.schema.json +32 -6
  62. package/workflows/bug-fix.md +12 -0
  63. package/workflows/config.md +8 -0
  64. package/workflows/deploy.md +8 -0
  65. package/workflows/feature.md +17 -1
  66. package/workflows/incident.md +8 -0
  67. package/workflows/investigation.md +12 -0
  68. package/workflows/refactor.md +12 -0
  69. package/workflows/research.md +8 -0
  70. package/workflows/review.md +12 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "llm-orchestrator",
3
3
  "description": "Write /task once — it plans the work, shards it across parallel subagents, gates every phase and verifies before claiming done. Claude Code, Codex, OpenCode, Kilo.",
4
- "version": "1.4.0",
4
+ "version": "1.6.0",
5
5
  "author": {
6
6
  "name": "Bogdan-Gabriel Torcescu",
7
7
  "url": "https://www.linkedin.com/in/bogdantorcescu/"
package/README.md CHANGED
@@ -11,10 +11,14 @@ It:
11
11
 
12
12
  → shards it across parallel subagents
13
13
 
14
+ → gives each part to the cheapest model that can do it
15
+
14
16
  → gates each phase
15
17
 
16
18
  → verifies the result before claiming it’s done
17
19
 
20
+ → keeps what the expensive model worked out, so the cheap one handles it next time
21
+
18
22
  Built for the kind of tasks where one agent and one context window simply aren’t enough.
19
23
 
20
24
  ## License
@@ -42,6 +46,8 @@ That is the whole interface. What happens after you press enter:
42
46
  | **Builds a flow** | Phases, parallel groups, dependencies — each shard with its own scope, owner, acceptance conditions and iteration budget. |
43
47
  | **Writes the prompts** | Each subagent gets a dispatch contract: the facts that shard needs, the tools it may use, what it must produce. Not a copy of the whole conversation. |
44
48
  | **Picks a model per shard** | Cheap model for the mechanical shard, a strong one with high thinking for the hard shard — decided per shard at dispatch time against live pricing, not once for the whole task. |
49
+ | **Asks a bigger model only at a decision** | A hard plan, a design choice, a diagnosis that will not converge: the top-tier model is consulted once, as an advisor, and the everyday model does the work. Top-tier use is capped at 10% of dispatches. |
50
+ | **Keeps what it learned** | The advisor's answer is saved as a short strategy card. The next task of that kind gets the card, on the everyday model. |
45
51
  | **Runs them in parallel** | Clean sessions, disjoint file ownership, so two agents cannot fight over the same file. |
46
52
  | **Gates every phase** | `G0` plan approved → `G1` evidence complete → `G2` hypothesis valid → `G3` a test that actually fails → `G4` suite green → `G5` independent review passed → `G6` verified on the real surfaces. A phase does not start until the gate before it resolves. |
47
53
  | **Proves it, then stops** | Completion claims need evidence: fresh local test output, not a subagent's summary. Then it checkpoints what it learned and cleans up its branches and worktrees. |
@@ -72,6 +78,50 @@ The installer renders all eleven into your harness's native command directory.
72
78
  Works on Claude Code, Codex, OpenCode and Kilo — the same flow, rendered into each one's native
73
79
  commands and agents.
74
80
 
81
+ ## In plain words
82
+
83
+ Think of a building site. Nobody hands the whole house to one worker. A site manager reads the
84
+ plans, splits the job, sends the electrician to the wiring and the apprentice to carry bricks, checks
85
+ each stage before the next one starts, and signs off after the inspection.
86
+
87
+ llm-orchestrator is that site manager for AI coding agents. You describe the job in one sentence.
88
+ It works out what kind of job it is, breaks it into parts, gives each part to a specialist agent on
89
+ a model priced for that part, checks the work at seven points, and reports "done" when the tests
90
+ say so.
91
+
92
+ Two habits make it cheaper the longer you use it. The expensive model is called in the way you
93
+ would call a senior consultant: for the hard decision, for an hour, while the regular team does the
94
+ building. And what the consultant decided is written down as a one-page checklist. The next time
95
+ the same kind of job comes up, the regular team follows the checklist and the consultant is not
96
+ called.
97
+
98
+ ## What you get
99
+
100
+ | You want | What it does |
101
+ |---|---|
102
+ | **To stop babysitting** | One line in, a reviewed and verified result out. It plans, writes the subagent prompts, runs them in parallel and proves the work. When it needs you, it asks once, with all its questions together. If the agent ends its turn on "next, I'll…" while the task is still open, a hook sends it back to work (Claude Code and Codex). |
103
+ | **The right specialist on each part** | 16 roles, from a read-only code explorer to a database-migration author, a payment-webhook specialist and an independent reviewer. 9 kinds of task (bug, feature, incident, refactor, investigation, review, deploy, config, research), each with its own flow. Harder work fans out wider: 2 agents for a moderate task, 3 for a complex one, 4 for a critical one. |
104
+ | **A bill that matches the work** | Four model tiers and six thinking levels. Each part goes to the cheapest model that does it reliably, at the lowest thinking level that is enough. Risk raises the level of the reviewer and leaves the builder's alone: a one-line change to a refund rule is built cheaply and reviewed by a senior model. The registry carries 33 models from 11 providers with dated list prices, and routing follows the models your IDE actually exposes. |
105
+ | **Top-tier models used like consultants** | The frontier model advises at a plan, a design, a diagnosis or a synthesis, and the everyday model executes. The package counts every dispatch and holds frontier use to 10% of the last 100, with at most 3% spent on trying a small task on a big model to see whether it finds a different direction. |
106
+ | **A team that learns** | Each consult leaves a strategy card: when this situation appears, do this, then check that. One expensive run teaches the cheap model that kind of task. Cards earn trust on real work: three passes promote one, two failures retire it. Nothing is re-run for comparison, so learning costs no extra calls. |
107
+ | **Work that survives a closed laptop** | State is written to memory as the task moves: the plan, the evidence, each gate, what was decided and why. A new session resumes from that record. After a context compaction the open task is restated to the model. |
108
+ | **Text that does not read like a machine wrote it** | When a task writes or edits text for people — a landing page, an email, a store listing, release notes — it uses a copywriting skill by design: it works out whether you want new text, a rewrite or a one-line fix, keeps your voice and your language, and refuses to invent numbers or customers. Interface strings stay with the UI design skill. |
109
+ | **"Done" that means done** | Seven gates, in order. A failing test exists before the fix. Money, auth, migrations and 18 other risk areas get an independent reviewer that never shares the builder's history. Completion needs fresh test output, not an agent's summary. |
110
+ | **It switched on by default** | Install it once and it engages in every project you open. A project that does not want it says so with one empty file, `.orchestrator-off`. |
111
+ | **One way of working across tools** | Claude Code, Codex, OpenCode and Kilo run the same flow, rendered into each one's own commands and agents. |
112
+ | **A safe first try** | Every install is a dry run until you add `--apply`. Uninstall removes only the files the package wrote. No tool call is ever blocked. |
113
+
114
+ ### What it does not do
115
+
116
+ - It cannot see which model your IDE really ran. The 10% cap counts the dispatches the orchestrator
117
+ reports, so it holds for an orchestrator that follows the flow and not for one that skips it.
118
+ - A strategy card is checked by the next real task, so a bad card is found at its second use. Cards
119
+ are short, one per dispatch, and retired after two failures for that reason.
120
+ - Models released after the benchmark snapshot have prices and no measured score. They are placed by
121
+ list price and are kept out of critical review seats until they are measured.
122
+ - On OpenCode and Kilo the turn-end continuation is not available, and the headless advisor command
123
+ is unverified.
124
+
75
125
  ## Quick start
76
126
 
77
127
  Pick the line that matches your harness. Everything is a dry run until you pass `--apply`.
@@ -226,6 +276,8 @@ These apply to every task, everywhere, regardless of harness (see `registries/co
226
276
 
227
277
  Four more gates are equally mandatory, at their own trigger rather than on every turn: `verification.checks` (verification-before-completion, before any completion claim), `skill.check` (before any action, check whether a skill already covers it), `tool.discovery` (search before declaring a tool absent), and `user.native_question` (every question to the user goes through the harness's native mechanism, batched into one question — `AskUserQuestion` on Claude Code, `request_user_input` / `update_plan` on Codex, `question` on OpenCode, `ask_followup_question` on Kilo; see `policies/questions.md`).
228
278
 
279
+ One more is mandatory by domain — `D1`, `ui.design_system` → [Impeccable](https://impeccable.style) (`impeccable`, Apache-2.0; `registries/core-profile.json` order 13, `domain_conditional: true`). It applies to every task whose pre-evaluation domain is `FRONTEND`, or that creates, changes, reviews or audits UI or visual design: `/impeccable shape` (or `critique`) before building — `/impeccable init` first when the project has no `PRODUCT.md` — and `/impeccable audit` + `/impeccable polish` before G5; each `workflows/<type>.md` names the command for each phase. `ui-ux-pro-max`, `frontend-design`, `design-system`, `ui-styling` and `web-design-guidelines` stay available as complements — they never substitute for it silently, and the resolver will not bind them in its place. A missing Impeccable follows the same portability rule as the core tools: gap declared first, install recommended once, degraded only after an explicit refusal.
280
+
229
281
  #### Installing the core tools
230
282
 
231
283
  `llm-orchestrator init` reports which of these are missing and prints the matching command. The
@@ -244,6 +296,8 @@ can `npx`.
244
296
  | `docs.current` | context7 | `claude mcp add context7 -- npx -y @upstash/context7-mcp` |
245
297
  | `research.retrieve` | exa | `claude mcp add exa -- npx -y exa-mcp-server` |
246
298
  | `tool.discovery` | harness-native tool search | built in, nothing to install |
299
+ | `content.copywriting` (text written for people; recommended, never blocking) | copywriting + copy-editing | `npx skills add coreyhaines31/marketingskills` (MIT; the whole pack, for the harnesses it detects — also offered as a Claude Code and Codex plugin marketplace). Complement for README and release-note prose: `npx skills add blader/humanizer` (MIT) |
300
+ | `ui.design_system` (frontend/UI tasks) | impeccable | `npx impeccable install` from the project root (detects Claude Code, Codex, Cursor, Gemini CLI, OpenCode, Copilot, … and installs into each; refresh with `npx impeccable update`), or on Claude Code `/plugin marketplace add pbakaus/impeccable` then `/plugin install impeccable@impeccable` (skill id `impeccable:impeccable`). A harness the installer does not detect (Kilo is not in its published list) is a declared gap. Start a new project with `/impeccable init` |
247
301
 
248
302
  The `/plugin ...` lines are Claude Code commands, typed in a session. The `claude mcp add ...` lines
249
303
  are shell commands; on Codex, OpenCode or Kilo, register the same MCP server through that harness's
@@ -253,7 +307,9 @@ Every one of these is optional in the sense that the core still runs without it
253
307
  in **declared degraded mode**, and every plan and report says so. That is the design, not a
254
308
  workaround.
255
309
 
256
- The eight rows above are `registries/core-profile.json` orders 1–8, in that order. The same eight, in the same order, appear in `SKILL.md`, `policies/capabilities.md` and the `task` command checklist, and `lib/first-run.mjs` checks exactly these for presence — `tests/coherence.test.mjs` fails if any of those six lists drifts.
310
+ `init` reports a missing `impeccable` on a project whose discovery finds a UI framework (the `frontend` domain: Vue, Nuxt, React, Next, Svelte, Angular, Solid, Preact, Astro, Lit). `doctor` reports it, with the install hint, when the task it is asked about triggers it — `doctor --task feature --domain FRONTEND`, or a UI signal such as `--signals web-ui`.
311
+
312
+ The first eight rows of the core table above are `registries/core-profile.json` orders 1–8, in that order. The same eight, in the same order, appear in `SKILL.md`, `policies/capabilities.md` and the `task` command checklist, and `lib/first-run.mjs` checks exactly these for presence — `tests/coherence.test.mjs` fails if any of those six lists drifts.
257
313
 
258
314
  ### Registries
259
315
 
@@ -262,6 +318,7 @@ The eight rows above are `registries/core-profile.json` orders 1–8, in that or
262
318
  - `registries/task-mappings.json` — per-task-type (feature, bug, incident, refactor, investigation, review, deployment, config, research...) mandatory/optional/available obligations.
263
319
  - `registries/preferred-tools.json` — concrete tool bindings (MCP, skill, CLI, workflow, native fallback, agent role) per capability, with install hints.
264
320
  - `registries/agent-roles.json` — the specialist agent roster, their capabilities/skills/MCPs, and the RO/RW/ORCHESTRATOR permission profiles.
321
+ - `registries/learning.json` — the frontier cap and exploration share, when the advisor is consulted, and the shape and lifecycle of strategy cards.
265
322
 
266
323
  Project-specific bindings live in the consuming project's `AGENTS.md`, under `## Orchestration bindings (project)`; they can only **add or tighten** obligations, never loosen a core mandatory one.
267
324
 
@@ -289,6 +346,48 @@ Multiple harnesses may share one explicitly enabled skill root using a comma-sep
289
346
 
290
347
  Each rendered agent carries native frontmatter for its harness: Claude Code gets `disallowedTools: Write, Edit, NotebookEdit` on an edit-denied role (read-only roles and the orchestrator); OpenCode and Kilo get `mode: subagent` (`primary` for the orchestrator) and `permission: edit: deny` on the same roles. Edit denial does not sandbox shell writes: it removes the edit tools only, and read-only roles keep Bash for inspection; the rendered Permissions section tells them never to write through the shell, and a hard boundary needs the harness's own shell permissions. On OpenCode and Kilo, the rendered `general.md` and `explore.md` share their names with the built-in `general` and `explore` subagents and replace their prompts project-wide. That is intended: the role ids are what the flow gate classifies dispatches by, and the replacements stay bounded (`general`, RW within its owned files) or read-only (`explore`).
291
348
 
349
+ **Install once, for every project — `--global`.** A project install steers one project. `--global`
350
+ takes no `--project`: it writes to the harness's own user-scope configuration, so orchestrate-core
351
+ engages in every project you open with that harness, with nothing to add per project.
352
+
353
+ ```sh
354
+ npx llm-orchestrator install --global --harness codex # dry run: prints the plan
355
+ npx llm-orchestrator install --global --harness codex --apply
356
+ npx llm-orchestrator uninstall --global --harness codex --apply # that harness only
357
+ npx llm-orchestrator uninstall --global --apply # everything a global install wrote
358
+ ```
359
+
360
+ | Harness | What `--global` writes (relative to your home directory) |
361
+ | --- | --- |
362
+ | Codex | a managed span in `.codex/AGENTS.md`; marked flow-hook groups merged into `.codex/hooks.json` (trust them once in `/hooks`). `CODEX_HOME` replaces `.codex` when set |
363
+ | Claude Code | a managed span in `.claude/CLAUDE.md`; marked flow-hook groups merged into `.claude/settings.json` — skipped, and listed under `skipped`, when the llm-orchestrator plugin is enabled, because the plugin already ships those hooks and both would fire |
364
+ | OpenCode | a managed span in `.config/opencode/AGENTS.md`; the flow plugin at `.config/opencode/plugins/orchestrate-flow.js`. `XDG_CONFIG_HOME` replaces `.config` when set, for Kilo too |
365
+ | Kilo | a managed span in `.config/kilo/AGENTS.md` (created when absent); no hooks — no user-scope plugin directory is verified for Kilo, so the plan lists it under `skipped` and a project install adds them per project |
366
+
367
+ The runtime is copied to the skills root as usual, since the hooks call it. Everything written is
368
+ delimited and recorded in one manifest per home directory, which also records the skills root: a
369
+ second run changes nothing, a later run with more harnesses extends the same install (and keeps
370
+ that skills root unless you pass `--skills-root`), and `uninstall --global` removes exactly those
371
+ spans, hook groups and files — for the harnesses named, or all of them when `--harness` is omitted
372
+ — leaving the rest of each file byte for byte. The runtime copy under the skills root stays, as on a project uninstall
373
+ (`retained_shared_runtime` lists it), because other installs may share it. A file this package did not write is never replaced — an existing
374
+ `orchestrate-flow.js` of your own, or a hooks file that is not plain JSON, is reported under
375
+ `conflicts`, and `conflict_reasons` says why for each path. A harness in conflict is skipped whole
376
+ and listed under `skipped`; the harnesses without one are applied (`applied_harnesses`), and the
377
+ exit status is non-zero only when nothing could be applied. Move the file away and run the command
378
+ again to add the skipped harness. `--no-flow-hooks` installs the instruction spans alone, but it
379
+ applies to the whole install, not to one harness. A symbolic link of your own (a dotfile manager's
380
+ `~/.claude`, a linked `CLAUDE.md`) is written through, never replaced, as long as it resolves to a
381
+ regular file or directory inside the install root; one that leaves it is a conflict. A global
382
+ install only writes inside the home directory, so a `CODEX_HOME` or `XDG_CONFIG_HOME` outside it
383
+ skips that harness. `--home <dir>` says where user scope is (default: your home directory) and rebases the
384
+ default skills, state and Codex prompts roots under it — for tests and non-standard layouts; with
385
+ it, `CODEX_HOME` and `XDG_CONFIG_HOME` are ignored.
386
+
387
+ A project opts out of a global install — and of the Claude Code plugin — with any one of: a
388
+ `.orchestrator-off` file in its root, a line `orchestrate-core: off` in its `AGENTS.md` or
389
+ `CLAUDE.md`, or `LLM_ORCHESTRATOR_OFF=1` in the environment (see "Flow adherence").
390
+
292
391
  ### Step by step
293
392
 
294
393
  Same five steps for every harness; only the skills root and the reload differ.
@@ -366,8 +465,25 @@ more instructions:
366
465
  classify, then `llm-orchestrator run start --type <TYPE>`, or declare the task trivial with
367
466
  `llm-orchestrator run start --trivial "<reason>"`. Once per prompt, never for subagents, never for
368
467
  reading the orchestration instructions.
369
- - **Nothing is ever blocked.** The handler (`llm-orchestrator gate`) has no deny path, fails open on
370
- any error, and is wrapped so a missing runtime is a silent no-op.
468
+ - The first prompt of a session gets one more sentence, once per session: orchestrate-core is
469
+ mandatory here, load the skill (Claude Code: the Skill tool, `orchestrate-core` or the plugin's
470
+ `llm-orchestrator:orchestrate-core`; elsewhere the installed skill or the bridge), classify, open a
471
+ run — and how a project opts out. It arrives on `SessionStart` or `UserPromptSubmit`, whichever
472
+ fires first, and never again once the skill was loaded in the session. Until then the work
473
+ reminder above also says to load the skill first.
474
+ - **No tool call is ever blocked.** The handler (`llm-orchestrator gate`) has no deny path, fails
475
+ open on any error, and is wrapped so a missing runtime is a silent no-op.
476
+ - **One thing is decided, at the end of a turn.** When a typed run is still open and the model's
477
+ last message announces more work instead of doing it ("Next, I'll…", "I will now…"), the `Stop`
478
+ hook answers `decision: "block"` with one sentence: continue, or ask the user explicitly, or
479
+ verify and close the run. It never fires when the message ends with a question to you, when the
480
+ model says it is waiting on background work or the harness reports background tasks, for a
481
+ subagent, for a trivial run or with no run open. At most two continuations per prompt. Only the
482
+ end of the message is classified and nothing of it is stored; the audit counts
483
+ `forced_continues`. The allowance is restored by a tool call, so only a model that keeps talking
484
+ without working is bounded; work that waits for your approval ("once you approve…") and quoted or
485
+ code text never count. `LLM_ORCHESTRATOR_NO_CONTINUE=1` switches it off. Claude Code and Codex honour
486
+ it; OpenCode and Kilo have no documented way to continue a turn, so there it is not sent.
371
487
  - Each project keeps a ledger in `.orchestrator-run/` (self-gitignored): ids, task types, counts
372
488
  and timestamps only — never prompts, tool inputs or file contents. `doctor` reports it under
373
489
  `flow.adherence`: runs, trivial declarations, tasks that skipped the flow, runs started outside
@@ -396,16 +512,32 @@ more instructions:
396
512
  - Once the entrypoint is loaded, read-only discovery (reading files, `grep`, `git status`, tool
397
513
  version checks) before `run start` is SKILL.md steps 2–3, not a deviation. An edit, a write, a
398
514
  dispatch or any other shell command before the run is.
399
- - Only projects that use orchestrate-core are steered — an `AGENTS.md`/`CLAUDE.md` naming the
400
- entrypoint (every CLI install writes one) or an existing ledger. The Claude Code plugin's hooks
401
- therefore stay silent in unrelated projects.
515
+ - Every project is steered unless it opts out. The hooks of a global install or of the Claude Code
516
+ plugin fire everywhere, so no per-project install or instruction line is needed. A project says no
517
+ with a `.orchestrator-off` file in its root, a line `orchestrate-core: off` in its `AGENTS.md` or
518
+ `CLAUDE.md`, or `LLM_ORCHESTRATOR_OFF=1` in the environment; it then gets no reminders and no
519
+ `.orchestrator-run/` directory, even if a run is started. Outside a project — no `.git`,
520
+ `AGENTS.md`, `CLAUDE.md` or ledger, or your home directory itself — the hooks stay silent until a
521
+ run is started there. `doctor` reports which applies under `flow.engagement`: `global`,
522
+ `per_project`, `opted_out` or `none`. It also lists under `flow.hooks.double_firing` the case
523
+ where the Claude Code plugin is enabled and a settings copy of the hooks exists as well.
524
+ - After a compaction or a resumed session (`SessionStart` with source `compact` or `resume`) an
525
+ open run is restated to the model — its type and how many planned shards were dispatched — so
526
+ the flow continues instead of being re-planned or forgotten.
527
+ - A run command counts only where the shell would run it. Text that merely contains one — a
528
+ `grep` pattern, a commit message, a comment, a heredoc body — never opens or closes a run.
529
+ - The project is the repository: a session started in a subdirectory shares the ledger and the
530
+ opt-out of the repository root.
531
+ - A shell command that carries several run commands (`… run close; … run start --type <T>`) applies
532
+ them in order: the last one is the state the session is left in.
402
533
 
403
534
  | Harness | Where the hooks live |
404
535
  | --- | --- |
405
536
  | Claude Code (plugin) | the plugin's own `hooks/hooks.json` — active on `/plugin install` |
406
- | Claude Code (CLI install) | marked entries merged into `.claude/settings.json`; the rest of the file is untouched |
537
+ | Claude Code (CLI install) | marked entries merged into `.claude/settings.json`; the rest of the file is untouched. Skipped, and listed under `skipped`, when the plugin is enabled for you (`enabledPlugins` in `~/.claude/settings.json`, unless the project's own settings switch it off): both would answer every event. `--flow-hooks` on that run writes them anyway, for a repository shared with people who do not use the plugin |
407
538
  | Codex | marked entries in `.codex/hooks.json` — trust them once in `/hooks` |
408
- | OpenCode / Kilo | `.opencode/plugins/orchestrate-flow.js` / `.kilo/plugin/orchestrate-flow.js` (auto-loaded by each); the reminder is appended to the tool's output, since these harnesses have no pre-tool context channel |
539
+ | OpenCode / Kilo | `.opencode/plugins/orchestrate-flow.js` / `.kilo/plugin/orchestrate-flow.js` (auto-loaded by each); the reminder is appended to the tool's output, since these harnesses have no pre-tool context channel — the once-per-session sentence rides on the session's first tool output for the same reason |
540
+ | Any of them, `install --global` | the same entries at user scope: `~/.claude/settings.json`, `~/.codex/hooks.json`, `~/.config/opencode/plugins/orchestrate-flow.js` (none for Kilo) |
409
541
 
410
542
  `install --no-flow-hooks` skips them (and withdraws hooks an earlier install wrote); the choice is
411
543
  remembered until `--flow-hooks` turns them back on. `uninstall` removes exactly the marked entries
@@ -438,58 +570,117 @@ This resolves (task type, phase, role, risk, complexity, context size, harness)
438
570
 
439
571
  ## Cost-aware routing (built in)
440
572
 
441
- Routing is data, not prose: `registries/routing-matrix.json` encodes the W/S/X/F tiers, the T0–T5 thinking levels with their per-provider controls (`effort` on Claude, `reasoning_effort` on Codex, budget-only on Haiku), the tier × thinking resolution table, default routing, the per-task-type flows (phase → pair → roles → gate), 21 risk-floor areas with implementation and independent-review floors, agent defaults, both escalation ladders, fan-out minimums (2 MODERATE / 3 COMPLEX / 4 CRITICAL), the target tier distribution and the quota degradation ladder. `models/top-models.json` carries the curated shortlist — thirteen ladder incumbents (three of them fallbacks for their successors) and ten measured candidates — with their supported thinking levels, prices, measured $/task per effort and thinking-cost indices (Artificial Analysis snapshot, copied verbatim, never invented). `lib/router.mjs` resolves a dispatch; `bin/route.mjs` exposes it:
573
+ Routing is data, not prose: `registries/routing-matrix.json` encodes the W/S/X/F tiers, the T0–T5 thinking levels with their per-provider controls (`effort` on Claude, `reasoning_effort` on Codex, budget-only on Haiku), the tier × thinking resolution table, default routing, the per-task-type flows (phase → pair → roles → gate), 21 risk-floor areas with implementation and independent-review floors, agent defaults, both escalation ladders, fan-out minimums (2 MODERATE / 3 COMPLEX / 4 CRITICAL), the target tier distribution and the quota degradation ladder. `models/top-models.json` carries the model registry — 33 models: 19 seated on a provider ladder (the seat-holders and the models they succeeded, which stay routable as fallbacks), ten measured candidates and four priced-but-unrated models — with their supported thinking levels, list prices with the date and page each was read from (`price_as_of`, `price_source`), measured $/task per effort and thinking-cost indices (Artificial Analysis v4.3.2 snapshot, copied verbatim, never invented). `lib/router.mjs` resolves a dispatch; `bin/route.mjs` exposes it:
442
574
 
443
575
  ```sh
444
576
  node bin/llm-orchestrator.mjs route --list # vocab: task types, phases, roles, areas
445
577
  node bin/llm-orchestrator.mjs route --task BUG_FIX --phase fix --area refund --risk critical --harness codex
446
578
  node bin/llm-orchestrator.mjs route --task FEATURE --complexity COMPLEX --flow --provider anthropic # whole flow, $ estimate, tier histogram
447
579
  node bin/llm-orchestrator.mjs route --task FEATURE --phase implementation --include-candidates --cheapest-thinking
580
+ node bin/llm-orchestrator.mjs route --task FEATURE --phase implementation --harness kilo --inventory inventory.json # seats from what the runtime exposes
448
581
  ```
449
582
 
450
- - `--include-candidates` ranks the ten measured candidates alongside the incumbents. They are held out by default, and an exposed candidate in a runtime inventory is admitted for noncritical lanes only — never for an independent-review seat, a T4/T5 pair or a risk-floor review row, and not for the implementation seat of a dispatch that requires an independent reviewer.
583
+ - `--include-candidates` ranks the ten measured candidates alongside the incumbents. They are held out by default, and an exposed candidate in a runtime inventory is admitted for noncritical lanes only — never for an independent-review seat, a T4/T5 pair or a risk-floor review row, and not for the implementation seat of a dispatch that requires an independent reviewer. The same seats are closed to a free variant (`…:free`) and to a gateway variant (an id whose vendor segments do not name the model's provider, such as `ollama/kimi-k3`), and an unmeasured successor is never promoted into one: the measured predecessor keeps the seat and the successor is listed as the alternative, `unmeasured: not seated for critical review`.
584
+ - `--trust-configured` seats models that an inventory only marks `configured` — read from the harness configuration by `models discover --config`, dispatch not proven. Without it such an inventory seats nothing and the output says why; with it every seat carries the label "configured, not verified in this session".
451
585
  - `--cheapest-thinking` (with `--max-score-loss <n>`, default 2) returns the lowest-cost (model, effort) whose measured score is within that many displayed points of the incumbent config for the resolved pair — the thinking-cost optimisation, in one line.
452
- - `--kind <default-routing kind>` overrides the starting row of the resolution order; `--context-tokens <n>` feeds the context axis (worker window cap, >272K repricing cliff); `--json` prints the machine-readable form of any of the above.
586
+ - `--provider <name>` ranks one provider's models. Any provider in the registry is accepted (`route --list` prints them: openai, anthropic, google, xai, meta, moonshot and the rest) — the list is read from the registry, not hard-coded.
587
+ - `--kind <default-routing kind>` overrides the starting row of the resolution order; `--context-tokens <n>` feeds the context axis (the W working-set cap, and the seated model's own repricing threshold — Haiku 5.5 above a 100K prompt, the Codex models above 272K); `--json` prints the machine-readable form of any of the above.
588
+
589
+ Resolution order: default routing → agent default → task-flow phase → complexity → risk floor (upward only) → context rules (the 150K W working-set cap, each seated model's own window and repricing threshold from the registry) → caps (Terra/Sol never above `high`, Fable 5.1 only with `--explicit-fable-5-1`). A runtime inventory (`--inventory`) filters the ranking to models actually exposed in the session.
590
+
591
+ **Routing adapts to what the harness exposes.** Only Claude Code and Codex have a hard-coded ladder. Any other harness or provider — OpenCode, Kilo, `--provider google` — takes each tier's seat from the inventory: the exposed registry models of that tier, cheapest measured `$/task` first, then token price index, under every admission rule. Inventory ids are matched to registry models by rule, never by resemblance: gateway and vendor prefixes (`openrouter/anthropic/claude-opus-5-5`), Bedrock and Vertex forms (`us.anthropic.claude-sonnet-5-v1:0`, `claude-sonnet-5@20260101`), free-tier suffixes (`opencode/muse-spark-1.3-contributor-free`) and dot-versus-dash spellings all resolve, and the row carries the inventory's own id as the one to dispatch. An id that does not reduce to exactly one registry model is listed as **unrated** and never seated. With nothing eligible — or with no ladder and no inventory at all — the result is `blocked: "no eligible model"`, never a quieter tier and never a default to Claude. `--flow` reports that per phase: on a harness with no ladder and no `--inventory`, every phase is `blocked: "no ladder for this harness: pass --inventory (see models discover)"` and the command exits 2; `--provider openai` or `--provider anthropic` selects a ladder explicitly. A flow total is the sum over the dispatches that have a measured `$/task`, and the mean divides by those alone; when any dispatch is unmeasured the total is marked partial (`est_total_partial`) and the cost band is not judged — `cost band not evaluated: N of M dispatches have no measured $/task`.
453
592
 
454
- Resolution order: default routing → agent default → task-flow phase → complexity → risk floor (upward only) → context rules (Haiku 200K cap, Codex >272K repricing) → caps (Terra/Sol never above `high`, Fable 5.1 only with `--explicit-fable-5-1`). A runtime inventory (`--inventory`) filters the ranking to models actually exposed in the session.
593
+ `models discover --harness <h>` builds that inventory from an active-session snapshot (`--input`), from the harness CLI (`--native`, OpenCode only), or from the harness configuration (`--config`: Claude Code `settings.json`, Codex `config.toml` and its models cache, OpenCode and Kilo config files; `--home <dir>` reads under another directory and overrides `CLAUDE_CONFIG_DIR`, `CODEX_HOME` and `XDG_CONFIG_HOME`, which are honoured otherwise). `--config` reads model and provider ids only — never credentials. A value in a model field is accepted only when it matches a conservative id grammar; a URL, a `user:secret@host` form, a key-shaped segment or a long opaque token is counted (`rejected: <n> value(s) that did not look like a model id`) and never echoed. A settings file or config directory whose real path leaves its root is not followed. It reports every id as `configured`, not `exposed`: a configuration entry does not prove dispatch works, so confirm it against the session before routing on it.
455
594
 
456
595
  ### Per-shard selection, not per task
457
596
 
458
- The CLI resolves one dispatch. Inside a flow, the same resolution runs **for every PlanShard, at dispatch time, against the live inventory** — `lib/dispatch-contract.mjs` exposes `buildShardRouting(shard, options)` for one shard, `buildShardContracts(flow, { inventory, harness, includeCandidates })` for all of them (returning the flow ledger: tier histogram against the target distribution, mean `$/task`, blocked shards, warnings), and `rerouteRemaining(flow, inventory)` when a model-not-found, a rejected effort or a quota change invalidates the inventory mid-flow — remaining shards only, so the ledger stays true. Each shard carries a `routing` block with exactly these thirteen fields: `pair`, `tier`, `thinking_level`, `model_requested`, `effort_requested`, `model_effective`, `effort_effective`, `review_floor`, `independent_review`, `selection_reason`, `inventory_revision`, `price_source`, `est_usd_per_task`. An inventory that exposes nothing eligible for the resolved tier yields `blocked: "no eligible model"` — the floor is never lowered to fit what happens to be available.
459
-
460
- ### Shortlisted models and thinking levels (snapshot 2026-09-23)
461
-
462
- Incumbents hold a seat on a provider ladder. Candidates are measured but unseated: their tier is a `tier_bands` placement from the best measured Artificial Analysis score (W ≤ 37, S 38–44, X 45–50, F ≥ 51), and they rank only with `--include-candidates` or an inventory that exposes them.
463
-
464
- | Model | Provider | Ladder | Admission | Tier | Thinking levels | $ in / out per MTok |
465
- |---|---|---|---|---|---|---|
466
- | GPT-6 Luna | openai | codex | incumbent | W | low, medium, high, xhigh, max (reasoning_effort) | $0.1 / $0.5 |
467
- | GPT-5.6 Luna | openai | codex | incumbent (fallback for GPT-6 Luna) | W | low, medium, high, xhigh, max (reasoning_effort) | $0.2 / $1.2 |
468
- | GPT-5.6 Terra | openai | codex | incumbent (S fallback; GPT-6 Sol holds the S seat one notch down) | S | low, medium, high, xhigh, max (reasoning_effort) | $2 / $12 |
469
- | GPT-6 Sol | openai | codex | incumbent | X | low, medium, high, xhigh, max (reasoning_effort) | $2 / $10 |
470
- | GPT-5.6 Sol | openai | codex | incumbent (fallback for GPT-6 Sol) | X | low, medium, high, xhigh, max (reasoning_effort) | $4 / $20 |
471
- | GPT-6 Astra | openai | codex | incumbent | F | low, medium, high, xhigh, max (reasoning_effort) | $10 / $50 |
472
- | Claude Haiku 4.5 | anthropic | claude | incumbent | W | disabled, enabled (budget_tokens) | $1 / $5 |
473
- | Claude Sonnet 5 | anthropic | claude | incumbent | S | low, medium, high, xhigh, max (effort) | $2 / $10 |
474
- | Claude Opus 5 | anthropic | claude | incumbent (fallback for Opus 5.5) | X | low, medium, high, xhigh, max (effort) | $5 / $25 |
475
- | Claude Opus 5.5 | anthropic | claude | incumbent | X | low, medium, high, xhigh, max (effort) | $4 / $20 |
476
- | Claude Fable 5 | anthropic | claude | incumbent | F | low, medium, high, xhigh, max (effort) | $10 / $50 |
477
- | Claude Fable 5.1 | anthropic | claude | incumbent | F | low, medium, high, xhigh, max (effort) | $10 / $50 |
478
- | Grok 4.7 | xai | — | incumbent | — (unrated) | low, medium, high, xhigh (reasoning_effort) | $2 / $6 |
479
- | Muse Spark 1.3 | muse | third-party | candidate | X (48) | xhigh, max (provider-default) | $1.25 / $4.25 |
480
- | Grok 4.6 | xai | third-party | candidate | S (44) | low, medium, high, xhigh (reasoning_effort) | $2 / $6 |
481
- | MiMo V2.6 Pro | xiaomi | third-party | candidate | X (46) | default (provider-default) | $0.435 / $0.87 |
482
- | Gemini 3.8 Flash | google | third-party | candidate | S (41) | low, medium, high (provider-default) | $0.75 / $3.75 |
483
- | Qwen3.8 Max | alibaba | third-party | candidate | X (45) | default (provider-default) | $2 / $6 |
484
- | GLM 5.3 | z.ai | open | candidate | X (45) | max (provider-default) | $1.4 / $4.4 |
485
- | GLM 5.3 Flash | z.ai | open | candidate | S (42) | default (provider-default) | $0.15 / $0.5 |
486
- | Kimi K3 | moonshot | open | candidate | S (44) | low, max (provider-default) | $3 / $15 |
487
- | DeepSeek V4.1 Flash | deepseek | open | candidate | S (39) | max (provider-default) | $0.3 / $1.2 |
488
- | MiniMax M3 | minimax | open | candidate | W (29) | default (provider-default) | $0.3 / $1.2 |
597
+ The CLI resolves one dispatch. Inside a flow, the same resolution runs **for every PlanShard, at dispatch time, against the live inventory** — `lib/dispatch-contract.mjs` exposes `buildShardRouting(shard, options)` for one shard, `buildShardContracts(flow, { inventory, harness, includeCandidates })` for all of them (returning the flow ledger: tier histogram against the target distribution, mean `$/task` over the measured shards, a partial-total marker, blocked shards, warnings), and `rerouteRemaining(flow, inventory)` when a model-not-found, a rejected effort or a quota change invalidates the inventory mid-flow — remaining shards only, so the ledger stays true. Each shard carries a `routing` block with exactly these thirteen fields: `pair`, `tier`, `thinking_level`, `model_requested`, `effort_requested`, `model_effective`, `effort_effective`, `review_floor`, `independent_review`, `selection_reason`, `inventory_revision`, `price_source`, `est_usd_per_task`. An inventory that exposes nothing eligible for the resolved tier yields `blocked: "no eligible model"` — the floor is never lowered to fit what happens to be available.
598
+
599
+ ### Shortlisted models and thinking levels (benchmark snapshot 2026-09-23)
600
+
601
+ Incumbents hold a seat on a provider ladder; a model that succeeded another on list price holds the seat and the older one stays as its fallback. Models added after the benchmark snapshot are **unmeasured**: Artificial Analysis now publishes v5.0.2, this dataset is pinned to v4.3.2, and the two are not mixed — so those models are placed by list price and provider succession, never by score, and carry no `$/task`. Candidates are measured but unseated: their tier is a `tier_bands` placement from the best measured Artificial Analysis score (W ≤ 37, S 38–44, X 45–50, F ≥ 51), and they rank only with `--include-candidates` or an inventory that exposes them.
602
+
603
+ | Model | Provider | Ladder | Admission | Tier | Thinking levels | $ in / out per MTok | Price read |
604
+ |---|---|---|---|---|---|---|---|
605
+ | GPT-5.6 Luna | openai | codex | incumbent (fallback for GPT-6 Luna) | W | low, medium, high, xhigh, max (reasoning_effort) | $0.2 / $1.2 | 2026-09-22 |
606
+ | GPT-6 Luna | openai | codex | incumbent (succeeds GPT-5.6 Luna) | W | none, low, medium, high, xhigh, max (reasoning_effort) | $0.1 / $0.5 | 2026-09-23 |
607
+ | GPT-5.6 Terra | openai | codex | incumbent (fallback for GPT-6.1 Terra) | S | low, medium, high, xhigh, max (reasoning_effort) | $2 / $12 | 2026-09-22 |
608
+ | GPT-6.1 Terra | openai | codex | incumbent (succeeds GPT-5.6 Terra) | S | none, low, medium, high, xhigh, max (reasoning_effort) — unmeasured | $1 / $5 | 2026-12-01 |
609
+ | GPT-5.6 Sol | openai | codex | incumbent (fallback for GPT-6 Sol) | X | low, medium, high, xhigh, max (reasoning_effort) | $4 / $20 | 2026-09-22 |
610
+ | GPT-6 Sol | openai | codex | incumbent (succeeds GPT-5.6 Sol; fallback for GPT-6.2 Sol; keeps X T4 and every review X seat; holds the S seat one notch down) | S, X | low, medium, high, xhigh, max (reasoning_effort) | $2 / $10 | 2026-09-23 |
611
+ | GPT-6.1 Sol | openai | codex | incumbent (no seat of its own) | X | low, medium, high, xhigh, max (reasoning_effort) — unmeasured | $2 / $10 | 2026-12-01 |
612
+ | GPT-6.2 Sol | openai | codex | incumbent (succeeds GPT-6 Sol on non-critical X T2/T3 only) | X | low, medium, high, xhigh, max (reasoning_effort) — unmeasured | $2 / $10 | 2026-12-01 |
613
+ | GPT-6 Astra | openai | codex | incumbent (fallback for GPT-6.2 Astra; keeps F T4, F T5 and every review F seat) | F | low, medium, high, xhigh, max (reasoning_effort) | $10 / $50 | 2026-09-22 |
614
+ | GPT-6.2 Astra | openai | codex | incumbent (succeeds GPT-6 Astra on non-critical F T3 only) | F | low, medium, high, xhigh, max (reasoning_effort) — unmeasured | $8 / $40 | 2026-12-01 |
615
+ | Claude Haiku 4.5 | anthropic | claude | incumbent (fallback for Claude Haiku 5.5; keeps every review W seat) | W | disabled, enabled (budget_tokens) | $1 / $5 | 2026-09-22 |
616
+ | Claude Haiku 5.5 | anthropic | claude | incumbent (succeeds Claude Haiku 4.5) | W | low, medium, high, xhigh, max (effort) — unmeasured | $0.1 / $0.5 (≤100K prompt), $0.5 / $2.5 above | 2026-12-01 |
617
+ | Claude Sonnet 5 | anthropic | claude | incumbent (fallback for Claude Sonnet 5.5; keeps every review S seat) | S | low, medium, high, xhigh, max (effort) | $2 / $10 | 2026-09-22 |
618
+ | Claude Sonnet 5.5 | anthropic | claude | incumbent (succeeds Claude Sonnet 5) | S | low, medium, high, xhigh, max (effort) — unmeasured | $2 / $10 | 2026-12-01 |
619
+ | Claude Opus 5 | anthropic | claude | incumbent (fallback for Claude Opus 5.5) | X | low, medium, high, xhigh, max (effort) | $5 / $25 | 2026-09-22 |
620
+ | Claude Opus 5.5 | anthropic | claude | incumbent (succeeds Claude Opus 5) | X | low, medium, high, xhigh, max (effort) | $4 / $20 | 2026-09-22 |
621
+ | Claude Fable 5 | anthropic | claude | incumbent (fallback for Claude Fable 5.2; keeps F T4, F T5 and every review F seat) | F | low, medium, high, xhigh, max (effort) | $10 / $50 | 2026-09-22 |
622
+ | Claude Fable 5.2 | anthropic | claude | incumbent (succeeds Claude Fable 5 on non-critical F T3 only) | F | low, medium, high, xhigh, max (effort) — unmeasured | $8 / $40 | 2026-12-01 |
623
+ | Claude Fable 5.1 | anthropic | claude | incumbent (≤2% cap, explicit only) | F | low, medium, high, xhigh, max (effort) | $10 / $50 | 2026-09-22 |
624
+ | Grok 4.7 | xai | — | unrated | — (unrated) | low, medium, high, xhigh (reasoning_effort) | $2 / $6 | 2026-12-01 |
625
+ | Muse Spark 1.3 | meta | third-party | candidate (deprecated; successor Muse Wonder) | X (48) | xhigh, max (provider-default) | $1.25 / $4.25 | 2026-09-22 |
626
+ | Grok 4.6 | xai | third-party | candidate | S (44) | low, medium, high, xhigh (reasoning_effort) | $2 / $6 | 2026-12-01 |
627
+ | MiMo V2.6 Pro | xiaomi | third-party | candidate | X (46) | default (provider-default) | $0.435 / $0.87 | 2026-09-22 |
628
+ | Gemini 3.8 Flash | google | third-party | candidate | S (41) | low, medium, high (provider-default) | $0.75 / $3.75 | 2026-12-01 |
629
+ | Gemini 4 Carbon | google | — | unrated | — (unrated) | default (provider-default) — unmeasured | $4 / $20 | 2026-12-01 |
630
+ | Gemini 4 Neon | google | — | unrated | — (unrated) | default (provider-default) — unmeasured | $3 / $15 | 2026-12-01 |
631
+ | Gemini 4 Hydrogen | google | — | unrated | — (unrated) | default (provider-default) — unmeasured | $1.5 / $7.5 | 2026-12-01 |
632
+ | Qwen3.8 Max | alibaba | third-party | candidate | X (45) | default (provider-default) | $2 / $6 | 2026-09-22 |
633
+ | GLM 5.3 | z.ai | open | candidate | X (45) | max (provider-default) | $1.4 / $4.4 | 2026-09-22 |
634
+ | GLM 5.3 Flash | z.ai | open | candidate | S (42) | default (provider-default) | $0.15 / $0.5 | 2026-09-22 |
635
+ | Kimi K3 | moonshot | open | candidate | S (44) | low, max (provider-default) | $3 / $15 | 2026-09-22 |
636
+ | DeepSeek V4.1 Flash | deepseek | open | candidate | S (39) | max (provider-default) | $0.3 / $1.2 | 2026-09-22 |
637
+ | MiniMax M3 | minimax | open | candidate | W (29) | default (provider-default) | $0.3 / $1.2 | 2026-09-22 |
489
638
 
490
639
  `control: provider-default` means the real thinking parameter is unverified for that model — dispatch the provider default and never send an invented effort enum. Data retention and endpoint eligibility are unknown for every candidate: no secrets, PII, production tokens or credential-bearing code.
491
640
 
492
- Prices and measured costs are dated evidence, not live tariffs; refresh `models/` before relying on the numbers.
641
+ Prices and measured costs are dated evidence, not live tariffs; refresh `models/` before relying on the numbers. Gemini 3.8 Flash reprices to $1.50 / $7.50 on 2027-01-01.
642
+
643
+ ## Advisor, strategy cards and the frontier budget
644
+
645
+ A frontier model (tier F: Fable, Astra and their equivalents) is consulted at a decision point, and what it decides is kept, so the normal model handles that kind of task next time. Three things make that work without raising consumption:
646
+
647
+ - **The frontier tier advises; the routed tier works.** The `advisor` role (read-only, F T3) receives a decision packet of at most 50 lines at a plan, design, hypothesis, synthesis or analysis decision, at most twice per task, and only when no usable stored strategy matched and the task is COMPLEX, CRITICAL or novel — or after a failed verifier that one step up the escalation ladder did not fix.
648
+ - **Distillation is passive.** The advisor's answer *is* the strategy card: cues, single steps written as "when cue, do action, check result", traps and a verification, in at most 60 lines and with no finished output. There is no replay and no with-and-without comparison run. A card starts `provisional` and is validated by the next real task of its class, on the normal model, through the gates that task runs anyway.
649
+ - **The cap is counted.** At most 10% of the last 100 dispatches may run on tier F, and at most 3% may be exploratory upgrades of small tasks, inside that 10% and only while frontier use is under 7%. A frontier dispatch that a risk floor requires always runs and is counted.
650
+
651
+ ```sh
652
+ # For a decision shard, or any shard about to use tier F: inject a card, consult the advisor, explore, or run as routed
653
+ node bin/llm-orchestrator.mjs strategy decide --task-type FEATURE --phase plan --area api-crud --tags rest,pagination --complexity COMPLEX --task T-42
654
+
655
+ # Before every dispatch: check the cap and write the ledger line in one step (exit 2 = refused, nothing written)
656
+ node bin/llm-orchestrator.mjs budget spend --tier F --kind advisor --signature "FEATURE/plan/api-crud" --task T-42
657
+ node bin/llm-orchestrator.mjs budget spend --tier S --signature "FEATURE/plan/api-crud" --task T-42
658
+ node bin/llm-orchestrator.mjs budget status
659
+
660
+ # After the task passed its gates: keep the advisor's card, and score a card that was used
661
+ node bin/llm-orchestrator.mjs strategy add --task-type FEATURE --phase plan --area api-crud --tags rest,pagination --title "Endpoint beside an existing resource" --file card.md
662
+ node bin/llm-orchestrator.mjs strategy outcome --id s-0123456789 --result pass
663
+ node bin/llm-orchestrator.mjs strategy list
664
+ ```
665
+
666
+ | Command | What it does |
667
+ |---|---|
668
+ | `strategy decide` | Matches the task to stored cards and reads the budget, then answers `inject`, `advisor`, `explore` or `normal` with the reason, and prints the `signature` and the normalised tags to reuse. `--task-type` is one of the nine task types, `--phase` a phase of the flow by its name or its workflow label ("Plan / design"), `--area` a risk-floor area or left out; an unknown value is refused with the accepted list. `--novel` sends a decision to the advisor; `--verifier-failed` does so only for a COMPLEX or CRITICAL task or together with `--escalated` (the ladder below the frontier was tried); `--consults <n>` says how many consults the task already used; `--task <id>` keeps sibling shards of the same task from counting as repeats of its class; `--json` prints the machine-readable form |
669
+ | `strategy advisor` | Prints the advisor's full brief for a decision `--packet <file>` and how `--harness <claude\|codex\|opencode\|kilo>` can reach a larger model: a native advisor tool, a subagent on the frontier `--model <id>`, that harness's own headless CLI, or, with no larger model exposed, a declared degraded same-model consult. `--run` executes the headless CLI and prints the answer; it first spends from the budget (`--tier <F\|X>`, default F) and exits 2 without calling the model when the cap is spent. `--existing <id>` and `--exploration` ask for same-or-different direction against a stored card |
670
+ | `strategy match` | One card or none: exact task type, phase and area (or a wildcard on the card), then enough shared tags. A task without tags matches nothing |
671
+ | `strategy add` | Validates and stores a card (`--file card.md`, or `--file -` for standard input). It needs `--title` and at least two `--tags`, taken from the tag vocabulary first. It refuses a card that is too long, lacks the `When` / `Steps` / `Verify` sections, carries more than 40 lines of code, or matches a secret, home-path or email pattern. The same title on the same task class becomes a new revision: provisional again, counters restarted, earlier totals kept. `--kind <advisor\|exploration\|escalation>`, `--source-model <id>`, `--scope <project\|global>` |
672
+ | `strategy outcome` | `--result pass` or `--result fail` after the task's gates. Three passes and no failure in the current revision promote a card; two failures not outnumbered by passes retire it |
673
+ | `strategy explored` | `--result same` or `--result different` after an exploratory upgrade. A class found to go the same direction is not explored again for 90 days |
674
+ | `strategy list` / `show` / `retire` | Inspect the store, or retire a card by hand (`--id`) |
675
+ | `budget spend` | Checks the cap and writes one ledger line, as one locked step, so parallel dispatches cannot share the last frontier slot: `--tier <W\|S\|X\|F>`, `--kind <task\|advisor\|exploration\|review-floor>`, the `--signature` that `strategy decide` printed, and `--task <id>`. Exit 2 means refused and nothing written. `--kind review-floor` is never refused and needs `--area`: a risk-floor area whose floor is tier F (`major-architecture`, `cross-system-redesign`) |
676
+ | `budget record` | The same line for a dispatch that already happened: always written, with `over_cap: true` and a warning when it was past the cap |
677
+ | `budget check` / `status` | Read-only: whether one more dispatch would fit, and the window's shares |
678
+
679
+ Where things live: the dispatch ledger is `.orchestrator-run/dispatches.jsonl` at the repository root — the nearest directory with a `.git` entry above `--project` or the working directory (a tier, a kind, a timestamp and hashes of the signature and the task id per line, never a prompt). Cards live outside every repository, under the package state root (`--state-root`, default `~/.local/state/portable-orchestrator/strategies/`), in one scope per project plus a shared `global` scope. Only the CLI writes the card index and its counters, one writer at a time, and it keeps the previous index as `index.json.bak`.
680
+
681
+ The advisor does not depend on a harness feature. Claude Code dispatches the `advisor` agent with a model override; Codex gets the brief as a `spawn_agent` prompt; OpenCode and Kilo take a subagent's model from its agent file, so `install --with-agents --advisor-model <provider/model>` pins the `advisor` agent to your frontier model. Where none of that is possible, `strategy advisor --run` calls the harness's own CLI headless. The OpenCode and Kilo headless commands are unverified and are labelled so.
682
+
683
+ What it cannot do: no hook sees which model a harness actually ran, so the ledger is what the orchestrator declares, not a measurement — an orchestrator that never calls `budget spend` is not capped, and one that dispatches on tier F after an exit 2 is not stopped. The secret scan on cards is pattern-based and incomplete. And because nothing is replayed, a bad card is found at its second use; cards are short, one per dispatch, and retired quickly for that reason. Tasks with no deterministic verifier keep their decisions on the advisor path. The full rules are in [policies/learning.md](policies/learning.md), and every threshold is in `registries/learning.json`.
493
684
 
494
685
  ## Updating
495
686
 
@@ -527,7 +718,8 @@ node bin/llm-orchestrator.mjs models discover --harness codex --native
527
718
 
528
719
  `models discover` writes a model-availability inventory for one harness (`--harness`) — from an
529
720
  active-session snapshot (`--input`), by asking that harness's CLI (`--native`, which only OpenCode
530
- exposes today), or, given neither, an
721
+ exposes today), from the harness configuration (`--config`, optionally under `--home <dir>`; ids
722
+ only, each reported as `configured`), or, given none of them, an
531
723
  explicitly `unknown` inventory rather than a guess; `--output` writes it to a file instead of stdout.
532
724
  `models report` renders the matrix the router reads: `--check` fails when
533
725
  `models/model-thinking-matrix.md` no longer matches `models/model-thinking-data.json`, and
package/SKILL.md CHANGED
@@ -40,10 +40,22 @@ merely worse — it makes it invalid.
40
40
  `model_effective`, `effort_effective`, `review_floor`, `independent_review`, `selection_reason`,
41
41
  `inventory_revision`, `price_source`, `est_usd_per_task`) before it may be dispatched. Then
42
42
  dispatch: clean-session, disjoint ownership, fan-out minimums, permission profiles. See
43
- [dispatch](policies/dispatch.md) and [routing](policies/routing.md).
43
+ [dispatch](policies/dispatch.md) and [routing](policies/routing.md). For every shard whose phase
44
+ is a decision phase (plan, design, hypothesis, synthesis, analysis), and for any shard about to
45
+ use tier F, run `... strategy decide` and follow its action: inject the stored strategy card,
46
+ consult the `advisor` once, spend an exploratory upgrade, or dispatch as routed. It may be run
47
+ for any other shard as well; that is how a card stored for an implementation phase is found and
48
+ how an exploratory upgrade is offered. Before every
49
+ dispatch run `... budget spend` with the signature `strategy decide` printed and the task id: it
50
+ checks the cap and writes the ledger line in one step, and exit 2 means the dispatch must not
51
+ run on tier F. The frontier tier is capped at 10% of the dispatches the orchestrator declares
52
+ this way. See [learning](policies/learning.md).
44
53
  7. **Enforce the gates** — G0…G6. A gate is passed, failed, unverified or `not_applicable` with a
45
54
  recorded reason. No phase starts before its predecessor gate resolves.
46
- 8. **Verify** — [verification](policies/verification.md). Evidence before assertions, always.
55
+ 8. **Verify** — [verification](policies/verification.md). Evidence before assertions, always. Once
56
+ G4 and G5 resolve, record `... strategy outcome` for a card that was used, store the advisor's
57
+ card with `... strategy add` when a frontier model was consulted and the task passed, and record
58
+ `... strategy explored` for an exploratory upgrade.
47
59
  9. **Persist state** — [state](policies/state.md). Drawers, not transcripts.
48
60
  10. **Clean up** — [cleanup](policies/cleanup.md). A flow is not complete while cleanup is pending
49
61
  or blocked. Close the run last: `... run close` (same CLI as step 4).
@@ -77,6 +89,21 @@ Four more gates are equally mandatory, at their own trigger rather than on every
77
89
  | `tool.discovery` | harness-native tool search | Before saying a tool or MCP is unavailable | [capabilities](policies/capabilities.md) |
78
90
  | `user.native_question` | the harness's native question mechanism | Whenever the user must be asked — one batched question, never free text at the end of a message | [questions](policies/questions.md) |
79
91
 
92
+ One more is mandatory by domain — on every task whose domain is `FRONTEND`, or that creates,
93
+ changes, reviews or audits UI or visual design (`registries/core-profile.json` order 13,
94
+ `domain_conditional: true`):
95
+
96
+ | # | Capability | Item | When | Contract |
97
+ |---|---|---|---|---|
98
+ | D1 | `ui.design_system` | `impeccable` (`/impeccable <command> <target>`) | Any `FRONTEND`-domain task, or any task that creates, changes, reviews or audits UI or visual design | `/impeccable shape` (or `critique`) before building — `init` first when `PRODUCT.md` is missing; `audit` + `polish` before G5; per-phase commands in `workflows/<type>.md`. `ui-ux-pro-max`, `frontend-design`, `design-system`, `ui-styling` and `web-design-guidelines` are complements — they never substitute for it silently |
99
+
100
+ One capability is recommended by design rather than mandatory — its trigger is not a judgment call,
101
+ and its absence never blocks a task:
102
+
103
+ | Capability | Item | When | Contract |
104
+ |---|---|---|---|
105
+ | `content.copywriting` | `copywriting` (new or rewritten text), `copy-editing` (existing text) | Any task that writes, rewrites, edits, reviews or localises text people will read outside a UI surface: marketing and product copy, emails, store listings, social posts, release notes, docs prose | [capabilities](policies/capabilities.md): diagnose before writing, no invented proof, keep the language and voice of the text, a point edit stays a point edit. UI strings stay with `D1` |
106
+
80
107
  Plus every row of the project's `## Orchestration bindings (project)` section marked mandatory.
81
108
 
82
109
  ### When a mandatory item is not installed (portability rule)
@@ -100,6 +127,7 @@ is pending, and do not start the phase the missing item gates.
100
127
  | [policies/capabilities.md](policies/capabilities.md) | every task, without exception |
101
128
  | [policies/routing.md](policies/routing.md) | any model choice, tier decision or delegation |
102
129
  | [policies/dispatch.md](policies/dispatch.md) | any child dispatch, worktree or parallel group |
130
+ | [policies/learning.md](policies/learning.md) | any plan, design, hypothesis, synthesis or analysis decision; any frontier-tier dispatch; closing a task that used a frontier model or a strategy card |
103
131
  | [policies/execution.md](policies/execution.md) | producing the response that carries out the work |
104
132
  | [policies/questions.md](policies/questions.md) | asking the user anything at all |
105
133
  | [policies/state.md](policies/state.md) | writing any task state or handoff |
@@ -70,13 +70,15 @@ const ORCHESTRATOR_RULES = [
70
70
  const HARNESS_FORMATS = new Set(['claude', 'opencode', 'kilo']);
71
71
  const EDIT_TOOLS = 'Write, Edit, NotebookEdit';
72
72
 
73
- function frontmatter(role, profile, harness) {
73
+ function frontmatter(role, profile, harness, model = null) {
74
74
  const editDenied = !(profile?.required_access ?? []).includes('edit');
75
75
  const lines = [`name: ${role.id}`, `description: ${JSON.stringify(role.description)}`];
76
76
  if (harness === 'claude') {
77
77
  if (editDenied) lines.push(`disallowedTools: ${EDIT_TOOLS}`);
78
78
  } else {
79
79
  lines.push(`mode: ${role.permission_profile === 'ORCHESTRATOR' ? 'primary' : 'subagent'}`);
80
+ // OpenCode and Kilo take a subagent's model from its agent file, not from the dispatch.
81
+ if (model) lines.push(`model: ${model}`);
80
82
  if (editDenied) lines.push('permission:', ' edit: deny');
81
83
  }
82
84
  return lines.join('\n');
@@ -95,7 +97,7 @@ function toolLines(role) {
95
97
  return lines;
96
98
  }
97
99
 
98
- function renderRole(role, profile, harness) {
100
+ function renderRole(role, profile, harness, model = null) {
99
101
  const orchestrator = role.permission_profile === 'ORCHESTRATOR';
100
102
  const {charter} = role;
101
103
  if (!charter) throw new Error(`registries/agent-roles.json: role ${role.id} has no charter; every role needs mission, principles, done_when, never and handoff`);
@@ -123,7 +125,7 @@ function renderRole(role, profile, harness) {
123
125
  `## Handoff\n${charter.handoff}\n${handoffFields}`,
124
126
  ];
125
127
  return `---
126
- ${frontmatter(role, profile, harness)}
128
+ ${frontmatter(role, profile, harness, model)}
127
129
  ---
128
130
  ${MD_MARKER}
129
131
 
@@ -136,10 +138,11 @@ ${sections.join('\n\n')}
136
138
  * frontmatter format of `harness` (`claude` — also the plugin's agents/ — `opencode`
137
139
  * or `kilo`). Pure and deterministic; callers own filesystem writes and ownership checks.
138
140
  */
139
- export function agentFiles(directory, harness = 'claude', registry = loadRegistry()) {
141
+ export function agentFiles(directory, harness = 'claude', registry = loadRegistry(), {advisorModel = null} = {}) {
140
142
  if (!HARNESS_FORMATS.has(harness)) throw new Error(`agentFiles: unsupported agent harness ${harness}`);
141
143
  return registry.roles.map((role) => ({
142
144
  path: `${directory}/${role.id}.md`,
143
- content: renderRole(role, registry.permission_profiles?.[role.permission_profile], harness),
145
+ // Only the advisor is pinned: it is the one role whose point is a larger model.
146
+ content: renderRole(role, registry.permission_profiles?.[role.permission_profile], harness, role.id === 'advisor' ? advisorModel : null),
144
147
  }));
145
148
  }
@@ -7,8 +7,6 @@ import {nativeCommands} from '../commands.mjs';
7
7
  // user-scope prompts (~/.codex/prompts/<name>.md). The paths returned here
8
8
  // are bare filenames — installation.mjs resolves them against the operator's
9
9
  // chosen codexPromptsRoot, never against the project root.
10
- export const nativeCommand = null;
11
-
12
10
  export const prompts = nativeCommands('.').map(({path, content}) => ({
13
11
  path: path.replace('./', ''),
14
12
  content,
@@ -60,6 +60,21 @@ core tool in this order (present / gap declared / explicit user refusal):
60
60
  8. \`exa\` for any external or current fact (research.retrieve)
61
61
  9. \`verification-before-completion\` (verification.checks)
62
62
 
63
+ Domain-conditional — when the task's domain is FRONTEND, or it creates, changes, reviews or audits
64
+ UI or visual design, also declare:
65
+
66
+ D1. \`impeccable\` (ui.design_system) — \`/impeccable shape\` (or \`critique\`) before building,
67
+ \`audit\` + \`polish\` before G5; \`/impeccable init\` first when PRODUCT.md is missing.
68
+ ui-ux-pro-max, frontend-design, design-system, ui-styling and web-design-guidelines complement
69
+ it — never substitute for it silently.
70
+
71
+ Text for people — when the task writes, rewrites, edits, reviews or localises text people will read
72
+ outside a UI surface (marketing and product copy, emails, store listings, social posts, release
73
+ notes, docs prose), use \`copywriting\` for new or rewritten text and \`copy-editing\` for existing
74
+ text (content.copywriting): diagnose before writing, no invented proof, keep the language and voice
75
+ of the text, a point edit stays a point edit. UI strings stay with D1. Recommended by design: a
76
+ missing skill is named once with its install and never blocks the task.
77
+
63
78
  Questions: native, batched, once — every question to the user (mandatory-tool gap, batched
64
79
  "skip or fix?" minor findings, destructive confirmation, surviving scope ambiguity) goes through the
65
80
  harness's native question mechanism (user.native_question), batched into ONE question at the decision
@@ -86,7 +101,12 @@ time against the live inventory, filling its \`routing\` block (\`pair\`, \`tier
86
101
  thinking level in the routing policy, with risk floors and an independent reviewer seat that is
87
102
  never cut — never one pair for the whole task, never a silent downgrade below a tier floor
88
103
  (\`blocked: no eligible model\` instead), and on an inventory change re-route the remaining shards
89
- only; enforce G0–G6; checkpoint to memory every 6–8 tool calls or before
104
+ only; before a decision shard (plan, design, hypothesis, synthesis) and before any
105
+ frontier-tier dispatch run \`strategy decide\` and follow it — inject the stored strategy card,
106
+ consult the \`advisor\` once, or dispatch as routed — and pass every dispatch through
107
+ \`budget spend\` first (frontier tier at most 10% of dispatches; exit 2 means stay on the routed
108
+ tier; see the learning policy); enforce G0–G6;
109
+ checkpoint to memory every 6–8 tool calls or before
90
110
  compaction. If a child returns \`Streaming response failed\` with a resumable id, record
91
111
  \`subagent_stream_recovery_pending\`, resume that exact child with its original phase contract
92
112
  (max three attempts), else one fresh child only from a complete handoff, else