geneseed 6.0.1 → 6.0.2

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 (45) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/SHIPPED.md +1 -1
  3. package/docs/concepts/agents.md +2 -2
  4. package/harness.config.json +1 -1
  5. package/js/README.md +2 -1
  6. package/js/build/emit-claude.mjs +2 -2
  7. package/js/build/emit-opencode.mjs +4 -2
  8. package/js/build/source.mjs +1 -1
  9. package/js/cli-table.json +1 -1
  10. package/js/hosts/native.mjs +48 -27
  11. package/js/hosts/opencode.mjs +3 -2
  12. package/js/inspect/checks-build.mjs +2 -2
  13. package/js/web/agent-models-api.mjs +52 -17
  14. package/js/web/api.mjs +3 -0
  15. package/js/web/model-catalog.mjs +324 -0
  16. package/js/web/routes.mjs +5 -3
  17. package/package.json +1 -1
  18. package/web/dist/assets/{ActiveLoops-6p44eD86.js → ActiveLoops-BWkImeYa.js} +1 -1
  19. package/web/dist/assets/{Activity-CIgrq5R1.js → Activity-DJlPhk8q.js} +1 -1
  20. package/web/dist/assets/{ActivityDetail-Brqv1u4f.js → ActivityDetail-Dk7UPnE_.js} +1 -1
  21. package/web/dist/assets/{Bonsai-8NtlFrPO.js → Bonsai-Bry-kOFb.js} +1 -1
  22. package/web/dist/assets/{CopyButton-BHqKgdjJ.js → CopyButton-Cnnvjgkg.js} +1 -1
  23. package/web/dist/assets/{Dashboard-CoveJ_-U.js → Dashboard-CWhh_GSc.js} +2 -2
  24. package/web/dist/assets/{Docs-C1jzrFnD.js → Docs-BJ23-fIx.js} +1 -1
  25. package/web/dist/assets/{Factories-D5pLnt5S.js → Factories-CjsIACyi.js} +1 -1
  26. package/web/dist/assets/{GreenhouseView-ofAQ-V5h.js → GreenhouseView-VL_ZKJUR.js} +1 -1
  27. package/web/dist/assets/Installs-qcfOZNzF.js +3 -0
  28. package/web/dist/assets/{JournalView-CsuN3_B-.js → JournalView-KrmFUC-X.js} +1 -1
  29. package/web/dist/assets/{Kits-P4xspDuN.js → Kits-DDSerkJk.js} +1 -1
  30. package/web/dist/assets/{Laws-DK3OwGDl.js → Laws-DDffPs6O.js} +1 -1
  31. package/web/dist/assets/{LibRows-CGO25X3D.js → LibRows-QsUBjOF7.js} +1 -1
  32. package/web/dist/assets/Library-DzT3Mebh.js +3 -0
  33. package/web/dist/assets/{Loops-C9DSBj-A.js → Loops-CjsX3brz.js} +1 -1
  34. package/web/dist/assets/Models-DPrAv3FG.js +1 -0
  35. package/web/dist/assets/{OperatorHudView-Cc8mlViW.js → OperatorHudView-Bdupodlc.js} +1 -1
  36. package/web/dist/assets/{Personal-DVh2jYPO.js → Personal-D-dpCUU5.js} +1 -1
  37. package/web/dist/assets/{Settings-CknBI-Fx.js → Settings-Dz33_Sys.js} +1 -1
  38. package/web/dist/assets/{Tabs-C30JrkJH.js → Tabs-qY40S34V.js} +1 -1
  39. package/web/dist/assets/api-C8nMUU1i.js +1 -0
  40. package/web/dist/assets/{index-MB7E-va_.js → index-BhT94v2q.js} +3 -3
  41. package/web/dist/assets/{index-CUJ8AaAF.css → index-DcusoHzF.css} +1 -1
  42. package/web/dist/index.html +3 -3
  43. package/web/dist/assets/Installs-DpWgyT5j.js +0 -3
  44. package/web/dist/assets/Library-e-94YED6.js +0 -3
  45. package/web/dist/assets/api-DxwG8y94.js +0 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,16 @@ label. For the capability ↔ spec map, see [SHIPPED.md](SHIPPED.md).
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [6.0.2] — 2026-11-18
12
+
13
+ ### Added
14
+
15
+ - **A Models page, and tier routing on OpenCode and OpenClaude.** *Build → Models* sets which model each sub-agent runs on, for every Claude Code, OpenCode and OpenClaude install: the routing switch, the standard and light tier models, and a pin per agent, picked from the models that install can use (your own providers first, then the models.dev ones you have a key for, then local Ollama or LM Studio). A company setup with a private URL and in-house model names works without any catalogue, and an OpenClaude install on the same endpoint offers the same names. The page never reads or sends an API key. `--tiers auto` now writes `model: provider/model` on OpenCode and `model:` on OpenClaude for the tiers your `tiers` map names; neither has a default model, so nothing changes until you pick one. With `--tiers off` every agent file is byte-identical.
16
+
17
+ ### Changed
18
+
19
+ - The Installs panel no longer has the *Model tiers* switch and editor, and the Library no longer has the pin field: each shows one line (routing, pins, the model an agent runs on) with a link to the Models page.
20
+
11
21
  ## [6.0.1] — 2026-11-18
12
22
 
13
23
  ### Added
package/SHIPPED.md CHANGED
@@ -20,7 +20,7 @@ historical references, not files distributed with the repo.
20
20
  > **On version numbers.** [`harness.config.json`](harness.config.json)'s `version` is a
21
21
  > human-readable label only. The canonical identity of an installed harness is the
22
22
  > **source fingerprint** stamped in `.geneseed-version` (see `geneseed version`), not the
23
- > string. Current label: **6.0.1**.
23
+ > string. Current label: **6.0.2**.
24
24
 
25
25
  ## Capabilities
26
26
 
@@ -42,11 +42,11 @@ In [foreman mode](foreman-mode.md) the session hands each task that would block
42
42
 
43
43
  Each agent source names a tier on a line of its own, `<!-- tier: strong|light -->`; an unmarked agent is `standard`. `strong` is the judgement seats (`reviewer`, `security`, `architect`, `performance`, and the kit seats `react-reviewer`, `spring-reviewer`, `spring-security`), `light` is the read-only seats (`explorer`, `researcher` and the ten council debaters), and the rest are `standard`. The line never reaches an install.
44
44
 
45
- By default nothing changes: every agent runs on your session model. A build with `--tiers auto` (recorded in the install, kept by `rebuild-all`) makes a **Claude Code** install write `model: sonnet` for `standard` agents and `model: haiku` for `light` ones; `strong` agents write no line and inherit. OpenClaude and Bob inherit, and OpenCode records the choice and still inherits (its resolver is not built yet).
45
+ By default nothing changes: every agent runs on your session model. A build with `--tiers auto` (recorded in the install, kept by `rebuild-all`) makes a **Claude Code** install write `model: sonnet` for `standard` agents and `model: haiku` for `light` ones; `strong` agents write no line and inherit. **OpenCode** (`model: provider/model`, a `#variant` suffix kept as written) and **OpenClaude** route too, but have no default model: a tier routes only once your `tiers` map names a model for it, because OpenCode has no alias and OpenClaude's `sonnet` and `haiku` mean the parent model on a provider that is not Anthropic. Bob takes no per-agent model and inherits.
46
46
 
47
47
  Two settings of yours steer it, both in `agent-overrides.json`. A `tiers` map renames the models (`{ "tiers": { "standard": "opus", "light": "claude-haiku-4-5" } }`; an empty value means inherit), and an `agents.<name>.model` pin beats its tier, a stronger model included. The build always writes the alias. On Bedrock or Vertex, Claude Code maps an alias through `ANTHROPIC_DEFAULT_SONNET_MODEL` or `ANTHROPIC_DEFAULT_HAIKU_MODEL`; without it, it uses its built-in model id, which may not exist in your cloud project. With `CLAUDE_CODE_USE_BEDROCK` or `CLAUDE_CODE_USE_VERTEX` set and the variable missing, `geneseed doctor` tells you to pin it.
48
48
 
49
- The web console sets all of this. On a Claude Code install, the Installs panel has a **Model tiers** switch and, while it is on, an editor for the two models; the Library shows each agent's tier, the model it resolves to and a pin field. Both write `agent-overrides.json` and change only the keys they name; a file that does not parse is refused. The model is written into the agent files at emit, so a save takes effect at the next rebuild, which the panel offers.
49
+ The web console sets all of this on its **Build → Models** page, for any Claude Code, OpenCode or OpenClaude install. It has the routing switch (`off` or `auto`), the two tier models, and one row per agent with the model it runs on, why, and a pin. A picker lists the models the install can use: Claude Code's aliases (filtered by `availableModels`); on OpenCode your own providers from `opencode.json` or `opencode.jsonc` first (a company gateway with in-house model names works with no models.dev cache), then the models.dev providers you have a key or login for, then Ollama or LM Studio if one runs on this machine; on OpenClaude the active provider's model, the models of an OpenCode provider on the same endpoint, local runtimes and your `agentModels` routes. It never reads or sends an API key and calls no endpoint that needs one. A model you type is saved as written and marked *not detected* when nothing lists it. The page edits `agent-overrides.json` key by key (a file that does not parse is refused); the model is written into the agent files at emit, so a save takes effect at the next rebuild, which the page offers and which also applies the routing. The Installs panel and the Library show one line each and link to the page.
50
50
 
51
51
  ### Agents learn too
52
52
 
@@ -2,5 +2,5 @@
2
2
  "_comment": "version is a human-readable release label only; the canonical identity of an installed harness is the source fingerprint stamped in .geneseed-version (see `harness version`), not this string.",
3
3
  "theme": "neutral",
4
4
  "product": "Geneseed",
5
- "version": "6.0.1"
5
+ "version": "6.0.2"
6
6
  }
package/js/README.md CHANGED
@@ -282,7 +282,8 @@ the deployed harness as JSON.
282
282
  | `api.mjs` | The dashboard and settings reads: overview, recent, themes, setup, doctor, diff, installs, excludes, loops |
283
283
  | `update-check.mjs` | Is a newer release on npm? Answers from memory, refreshes in the background (a day when it got an answer, an hour when it did not), `null` on any failure, never asked under `node --test` |
284
284
  | `gates-api.mjs` | `GET /api/gates`: gate asks per rule per day over 30 days, read off every installed harness's `notebook/gates.jsonl` (the Overview's sparklines) |
285
- | `agent-models-api.mjs` | `GET`/`POST /api/agent-models`: one Claude Code install's `tiers` map and per-agent model pins in `agent-overrides.json` (merged key by key, a file that does not parse is refused), with each agent's tier and the model it resolves to (`claudeAgentModel`, the emit's own precedence) |
285
+ | `agent-models-api.mjs` | `GET`/`POST /api/agent-models`: one install's (Claude Code, OpenCode or OpenClaude) `tiers` map and per-agent model pins in `agent-overrides.json` (merged key by key, a file that does not parse is refused), with each agent's tier and the model it resolves to (`agentModel`, the emit's own precedence) and the install's model list |
286
+ | `model-catalog.mjs` | The models one install can run, per host: Claude aliases, OpenCode custom providers then the models.dev cache then loopback Ollama/LM Studio probes, OpenClaude's profile, same-endpoint OpenCode providers and routes. Files and loopback only; never a key value (a test pins it) |
286
287
  | `usage-api.mjs` | `GET /api/usage`: the 30-day skill and agent call counts across every installed harness, the never-fired list, a fleet-wide `names` list (per-name 30-day counts, installs, daily series, last day seen), and skips lines older than 90 days in each `notebook/usage.jsonl` |
287
288
  | `profiles-api.mjs` | The Profiles tab: `GET /api/profiles` (both sources, the installs that follow each, an apply preview) and the `profile-apply` / `profile-save` jobs, which run the CLI's own verb |
288
289
  | `user-files.mjs` | The fingerprint-guarded editors for `user-rules.md` (incl. memory promotion) and `PROFILE.md`, read and write |
@@ -138,8 +138,8 @@ export function emitClaudeRender(cfg, job) {
138
138
  items, path.join(cfgDir, 'agents'), path.join(cfgDir, 'skills'),
139
139
  loadAgentOverrides(cfgDir),
140
140
  { host: 'claude', bobDialect: isBob, oldOwned, cfg: cfgDir, src: cfg.src, skillDirOf, claim,
141
- // Claude Code only: OpenClaude and Bob inherit (spec B6, D8).
142
- tiers: cfg.tiers === 'auto' && host === 'claude' ? { map: loadTierMap(cfgDir), env: process.env } : null });
141
+ // Claude Code and OpenClaude route by tier (2026-11-18 D1); Bob's agents take no model.
142
+ tiers: cfg.tiers === 'auto' && !isBob ? { map: loadTierMap(cfgDir), env: process.env, host } : null });
143
143
  for (const p of written) owned.push(relPosix(cfgDir, p));
144
144
 
145
145
  // Bob host-compat O2/R1: an alias, or a genuinely user-only skill (unverified
@@ -9,7 +9,7 @@
9
9
  import path from 'node:path';
10
10
  import { bundleFiles } from '../hosts/owned.mjs';
11
11
  import { VERSION_MARKER } from '../hosts/hosts.mjs';
12
- import { claimer, loadAgentOverrides, writeNativeLayer } from '../hosts/native.mjs';
12
+ import { claimer, loadAgentOverrides, loadTierMap, writeNativeLayer } from '../hosts/native.mjs';
13
13
  import {
14
14
  copyPlugins, copyWorkflows, ensureAgentOverridesStub, writeColorThemes, writeCommandLayer,
15
15
  writeAliasCommands, writePonytailCommand, writePrimaryAgent, writeTheme,
@@ -66,7 +66,9 @@ function opencodeLayer(cfg, items, themeName, theme, dir, owned, opts) {
66
66
 
67
67
  const { nAgents, nSkills, written, userOnlySkills } = writeNativeLayer(
68
68
  items, path.join(dir, 'agents'), path.join(dir, 'skills'), overrides,
69
- { host: 'opencode', theme, src: cfg.src, claim });
69
+ { host: 'opencode', theme, src: cfg.src, claim,
70
+ // `--tiers auto`: a tier routes once the user's `tiers` map names a model for it (no default).
71
+ tiers: cfg.tiers === 'auto' ? { map: loadTierMap(overridesDir), env: process.env, host: 'opencode' } : null });
70
72
  for (const p of written) owned.push(relPosix(dir, p));
71
73
 
72
74
  const primary = writePrimaryAgent(cfg, path.join(dir, 'agents'), overrides, claim);
@@ -580,7 +580,7 @@ export const ALIASES_RE = /^<!--[ \t]*aliases:[ \t]*(.+?)[ \t]*-->[ \t]*\r?$/m;
580
580
  * `--tiers auto|off`: the sub-agent model tiers (spec `2026-11-17-subagent-model-tiers.md`).
581
581
  * An agent source names its tier on a line of its own, `<!-- tier: strong|light -->`; no marker
582
582
  * is `standard`, the default. `strong` runs on the parent's model, `light` on a cheaper one,
583
- * and what each tier means on a host is that host's emit (Claude: `claudeTierModel`).
583
+ * and what each tier means on a host is that host's emit (`tierModel`, with the per-host defaults in `TIER_DEFAULTS`).
584
584
  *
585
585
  * THE LINE IS STRIPPED FROM EVERY OUTPUT, WHOLE (`splitTier`): it sits directly above
586
586
  * `## When to dispatch`, so removing the line leaves the text a build rendered before the marker
package/js/cli-table.json CHANGED
@@ -256,7 +256,7 @@
256
256
  ],
257
257
  "dest": "tiers",
258
258
  "metavar": null,
259
- "help": "route sub-agents to a cheaper model by tier: auto|off (default: off). With auto, a Claude Code install writes model: sonnet for standard agents and model: haiku for light ones (read-only seats); strong agents inherit your session model. A per-agent pin in agent-overrides.json wins, and its tiers map renames the two models. Other hosts record it and write nothing yet",
259
+ "help": "route sub-agents to a cheaper model by tier: auto|off (default: off). With auto, a Claude Code install writes model: sonnet for standard agents and model: haiku for light ones (read-only seats); strong agents inherit your session model. A per-agent pin in agent-overrides.json wins, and its tiers map renames the two models. OpenCode and OpenClaude route too, but only the tiers the map names a model for (no default); Bob records it and writes nothing",
260
260
  "choices": null,
261
261
  "default": null,
262
262
  "required": false,
@@ -419,7 +419,7 @@ const WEBFETCH_MARKER = '<!-- webfetch: allow -->';
419
419
  */
420
420
  function claudeAgentFrontmatter(stem, text, model = null) {
421
421
  const fm = [`name: ${stem}`, `description: ${jsonDumps(agentDescription(text))}`];
422
- // `model` is `claudeAgentModel(...).model`: the one precedence, resolved by the caller.
422
+ // `model` is `agentModel(...).model`: the one precedence, resolved by the caller.
423
423
  if (model) fm.push(`model: ${model}`);
424
424
  if (isReadonly(text)) {
425
425
  const list = ['Write', 'Edit', 'NotebookEdit', 'Agent', 'Task'];
@@ -453,11 +453,18 @@ function bobAgentFrontmatter(stem, text) {
453
453
  return fm;
454
454
  }
455
455
 
456
- /** `_build_emit._opencode_agent_frontmatter`. */
457
- function opencodeAgentFrontmatter(stem, text, overrides, theme = null) {
456
+ /**
457
+ * `_build_emit._opencode_agent_frontmatter`. With `tiers` (`--tiers auto`) an agent the user did
458
+ * not pin gets its tier's model, `provider/model` (V2 may carry a `#variant` suffix, written
459
+ * verbatim; V1's `variant` stays its own key, which `pushOverrideLines` already writes). Without
460
+ * `tiers`, or with a pin, the lines are exactly the override's own: byte-identical to before.
461
+ */
462
+ function opencodeAgentFrontmatter(stem, text, overrides, theme = null, tier = 'standard', tiers = null) {
458
463
  const fm = [`description: ${jsonDumps(agentDescription(text))}`, 'mode: subagent'];
459
464
  fm.push(`color: ${agentColor(stem, theme)}`);
460
- pushOverrideLines(fm, agentOverride(overrides, stem));
465
+ const ov = agentOverride(overrides, stem);
466
+ const tm = tiers && !isTruthy(ov.model) ? agentModel(tier, null, tiers).model : null;
467
+ pushOverrideLines(fm, tm ? { ...ov, model: tm } : ov);
461
468
  if (isReadonly(text)) {
462
469
  fm.push('permission:', ' edit: deny',
463
470
  ` webfetch: ${text.includes(WEBFETCH_MARKER) ? 'allow' : 'deny'}`);
@@ -535,8 +542,18 @@ const CLAUDE_ALIAS_ENV = Object.freeze({
535
542
  opus: 'ANTHROPIC_DEFAULT_OPUS_MODEL', sonnet: 'ANTHROPIC_DEFAULT_SONNET_MODEL',
536
543
  haiku: 'ANTHROPIC_DEFAULT_HAIKU_MODEL',
537
544
  });
538
- /** The model each non-strong tier gets on Claude Code when `tiers.<tier>` names none (spec D2). */
539
- export const CLAUDE_TIER_DEFAULTS = Object.freeze({ standard: 'sonnet', light: 'haiku' });
545
+ /**
546
+ * The model each non-strong tier gets when `tiers.<tier>` names none, per host: THE ONE TABLE of
547
+ * the defaults (spec D2, 2026-11-18 D1). Claude Code has its two aliases. OpenCode and OpenClaude
548
+ * have NONE (O12): a tier routes only once the user picks a model for it, because OpenCode has no
549
+ * alias at all and, on an OpenClaude provider that is not Anthropic, `sonnet`/`haiku` resolve to the
550
+ * parent's model, so a default there would promise a saving it does not give.
551
+ */
552
+ export const TIER_DEFAULTS = Object.freeze({
553
+ claude: Object.freeze({ standard: 'sonnet', light: 'haiku' }),
554
+ opencode: Object.freeze({}),
555
+ openclaude: Object.freeze({}),
556
+ });
540
557
  /** The tier-map keys that take a model; `strong` is the parent's model and takes none (D9). */
541
558
  const TIER_MAP_KEYS = ['standard', 'light'];
542
559
 
@@ -547,13 +564,13 @@ function envOn(env, name) {
547
564
  }
548
565
 
549
566
  /**
550
- * The model a tier gets on Claude Code, or null (inherit) — pure, so the table in
551
- * `tests/unit/tiers.test.mjs` states every row. `map` is the user's `tiers` map
567
+ * The model a tier gets on `host` (`claude`, `opencode` or `openclaude`), or null (inherit) — pure,
568
+ * so the table in `tests/unit/tiers.test.mjs` states every row. `map` is the user's `tiers` map
552
569
  * (`loadTierMap`), `env` the environment.
553
570
  *
554
571
  * - `strong` never gets a line: it IS the parent's model.
555
- * - A tier the map does not name gets the alias default (`CLAUDE_TIER_DEFAULTS`); a tier the map
556
- * names with an empty value is the user choosing inherit.
572
+ * - A tier the map does not name gets the host's default (`TIER_DEFAULTS`: Claude's two aliases,
573
+ * none elsewhere); a tier the map names with an empty value is the user choosing inherit.
557
574
  * - D11 (revised 2026-11-17): the alias is ALWAYS written. On Bedrock or Vertex without
558
575
  * `ANTHROPIC_DEFAULT_<ALIAS>_MODEL`, Claude Code resolves it to its built-in model id (seen on
559
576
  * 2.1.326, Vertex: `haiku` -> claude-haiku-4-5@20251001, and the sub-agent runs), which may not
@@ -561,14 +578,15 @@ function envOn(env, name) {
561
578
  * pin it; the doctor prints it (`tierEnvNotes`), the build says nothing. Only the three aliases
562
579
  * are checked: any other value is a model id the user wrote and owns.
563
580
  */
564
- export function claudeTierModel(tier, map = {}, env = {}) {
581
+ export function tierModel(tier, map = {}, env = {}, host = 'claude') {
565
582
  if (!TIER_MAP_KEYS.includes(tier)) return { model: null, warning: null };
566
583
  const named = Object.hasOwn(map, tier);
567
- const value = named ? map[tier] : CLAUDE_TIER_DEFAULTS[tier];
584
+ const value = named ? map[tier] : (Object.hasOwn(TIER_DEFAULTS, host) ? TIER_DEFAULTS[host][tier] : undefined);
568
585
  if (!isTruthy(value)) return { model: null, warning: null };
569
586
  const alias = String(value).trim().toLowerCase();
570
587
  const cloud = ['CLAUDE_CODE_USE_BEDROCK', 'CLAUDE_CODE_USE_VERTEX'].find((n) => envOn(env, n));
571
- const need = Object.hasOwn(CLAUDE_ALIAS_ENV, alias) ? CLAUDE_ALIAS_ENV[alias] : null;
588
+ // The cloud-alias advice is Claude Code's: no other host reads `ANTHROPIC_DEFAULT_*_MODEL` for a tier.
589
+ const need = host === 'claude' && Object.hasOwn(CLAUDE_ALIAS_ENV, alias) ? CLAUDE_ALIAS_ENV[alias] : null;
572
590
  const warning = cloud && need && !String(env[need] ?? '').trim()
573
591
  ? `--tiers auto: ${cloud} is set but ${need} is not, so the ${tier} tier's '${alias}' alias `
574
592
  + `resolves to Claude Code's built-in model id, which may not exist in your cloud project — `
@@ -578,19 +596,21 @@ export function claudeTierModel(tier, map = {}, env = {}) {
578
596
  }
579
597
 
580
598
  /**
581
- * The model one agent gets on Claude Code, and why — THE ONE HOME of the precedence (spec D5),
582
- * highest first: the user's pin (`agents.<name>.model`), then the `tiers` map, then the tier's
583
- * default alias, then inherit. The emit writes `model` into the agent's frontmatter
584
- * (`writeNativeLayer`) and the console shows the same answer (`js/web/agent-models-api.mjs`).
585
- *
586
- * `tiers` is `{ map, env }` while `--tiers auto` is on, else null (a pin still applies).
587
- * `from`: `pin`, `map` (the map names the tier, an empty value included), `default`, `inherit`.
588
- * `warning` is `claudeTierModel`'s, and only for a model the tier gave: a pinned agent has none.
599
+ * The model one agent gets, and why — THE ONE HOME of the precedence (spec D5), on every host,
600
+ * highest first: the user's pin (`agents.<name>.model`), then the `tiers` map, then the host's
601
+ * default for the tier (`TIER_DEFAULTS`), then inherit. The emit writes `model` into the agent's
602
+ * frontmatter (`writeNativeLayer`) and the console shows the same answer
603
+ * (`js/web/agent-models-api.mjs`).
604
+ *
605
+ * `tiers` is `{ map, env, host }` while `--tiers auto` is on, else null (a pin still applies);
606
+ * `host` defaults to `claude`. `from`: `pin`, `map` (the map names the tier, an empty value
607
+ * included), `default`, `inherit`.
608
+ * `warning` is `tierModel`'s, and only for a model the tier gave: a pinned agent has none.
589
609
  */
590
- export function claudeAgentModel(tier, pin, tiers = null) {
610
+ export function agentModel(tier, pin, tiers = null) {
591
611
  if (isTruthy(pin)) return { model: formatValue(pin), from: 'pin', warning: null };
592
612
  if (!tiers) return { model: null, from: 'inherit', warning: null };
593
- const { model, warning } = claudeTierModel(tier, tiers.map, tiers.env);
613
+ const { model, warning } = tierModel(tier, tiers.map, tiers.env, tiers.host);
594
614
  if (!model) return { model: null, from: 'inherit', warning: null };
595
615
  return { model: formatValue(model), from: Object.hasOwn(tiers.map, tier) ? 'map' : 'default', warning };
596
616
  }
@@ -801,14 +821,15 @@ export function writeNativeLayer(items, agentsDir, skillsDir, overrides = null,
801
821
  // choice. The caller (`emit-claude.mjs`) routes the suppressed names through
802
822
  // `writeAliasCommands(..., alsoUserOnly: true)` into `.bob/commands/*.md` instead (O2).
803
823
  bobDialect = false,
804
- // `--tiers auto` on Claude Code: `{ map, env }` (`loadTierMap`, the build env), else null — no tier line.
824
+ // `--tiers auto`: `{ map, env, host }` (`loadTierMap`, the build env, the real host: Claude Code,
825
+ // OpenClaude or OpenCode), else null — no tier line. Bob's agents take no model at all.
805
826
  tiers = null,
806
827
  } = {}) {
807
828
  const ov = overrides || {};
808
829
  if (bobDialect) warnBobIgnored(ov);
809
830
  else if (host === 'claude') warnClaudeIgnored(ov);
810
831
  // D11: the build never withholds the alias; the doctor warns about a cloud provider (`tierEnvNotes`).
811
- const tiersHere = tiers && host === 'claude' && !bobDialect ? tiers : null;
832
+ const tiersHere = tiers && !bobDialect ? tiers : null;
812
833
  let nAgents = 0;
813
834
  let nSkills = 0;
814
835
  const written = [];
@@ -887,8 +908,8 @@ export function writeNativeLayer(items, agentsDir, skillsDir, overrides = null,
887
908
  let userOnly = false;
888
909
  if (folder === 'agents') {
889
910
  if (bobDialect) fm = bobAgentFrontmatter(stem, text);
890
- else if (host === 'claude') fm = claudeAgentFrontmatter(stem, text, claudeAgentModel(tier, agentOverride(ov, stem).model, tiersHere).model);
891
- else fm = opencodeAgentFrontmatter(stem, text, ov, theme);
911
+ else if (host === 'claude') fm = claudeAgentFrontmatter(stem, text, agentModel(tier, agentOverride(ov, stem).model, tiersHere).model);
912
+ else fm = opencodeAgentFrontmatter(stem, text, ov, theme, tier, tiersHere);
892
913
  dest = path.join(agentsDir, `${stem}.md`);
893
914
  body = stripAgentSkillLinks(body);
894
915
  kind = 'agent';
@@ -84,8 +84,9 @@ const AGENT_OVERRIDES_STUB = {
84
84
  + '"reviewer": {"model": "anthropic/claude-haiku-4-5", "temperature": 0.1, '
85
85
  + '"variant": "high", "steps": 20}. '
86
86
  + 'Tiers (build with --tiers auto): "tiers": {"standard": "<model>", "light": "<model>"} '
87
- + 'names the model each tier runs on; a tier you leave out gets its host default (Claude Code: '
88
- + 'sonnet and haiku; other hosts inherit), an empty value means inherit, strong is always the session model. A '
87
+ + 'names the model each tier runs on (OpenCode: provider/model); a tier you leave out gets its host default '
88
+ + '(Claude Code: sonnet and haiku; OpenCode and OpenClaude inherit), an empty value means inherit, strong is '
89
+ + 'always the session model. The console\'s Models page sets these. A '
89
90
  + 'per-agent entry in "agents" wins over its tier. '
90
91
  + 'Host-specific; git-ignored. A future TUI screen edits this — rebuild to apply.'
91
92
  ),
@@ -14,7 +14,7 @@ import { CLAUDE_STYLE, HOSTS, hostCatalogsNatively, resolvePath } from '../hosts
14
14
  import {
15
15
  EMIT_HOST_SCOPE, footprintOfDir, installState, installTargets, readMaybe, renderedTier, themeFiles, tiersOfDir,
16
16
  } from '../hosts/installs.mjs';
17
- import { claudeTierModel, isVendoredPath, loadAgentOverrides, loadTierMap } from '../hosts/native.mjs';
17
+ import { isVendoredPath, tierModel, loadAgentOverrides, loadTierMap } from '../hosts/native.mjs';
18
18
  import { PALETTE_ROLES, colorThemeFiles } from '../hosts/opencode.mjs';
19
19
  import { readText, withDiscardableStderr } from '../lib/fs.mjs';
20
20
  import { parseJson, formatRepr } from '../lib/json.mjs';
@@ -262,7 +262,7 @@ export function tierEnvNotes(env = process.env) {
262
262
  }
263
263
  for (const tier of ['standard', 'light']) {
264
264
  if (agents[tier].every((stem) => Object.hasOwn(pins, stem) && pins[stem]?.model)) continue;
265
- const { warning } = claudeTierModel(tier, map, env);
265
+ const { warning } = tierModel(tier, map, env, 'claude');
266
266
  const where = scope === 'global' ? host : `${host} (project ${root})`;
267
267
  if (warning) notes.push(`${NOTE}[tiers] ${where}: ${warning}`);
268
268
  }
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * The console's view of the sub-agent models — `GET`/`POST /api/agent-models`.
3
3
  *
4
- * What it reads and writes is `agent-overrides.json` of ONE Claude Code install: the `tiers` map
5
- * (`standard`, `light`) and each agent's `agents.<name>.model` pin. The precedence (pin > map >
6
- * the tier's default > inherit) is `claudeAgentModel` in `js/hosts/native.mjs`, the same function
4
+ * What it reads and writes is `agent-overrides.json` of ONE install (Claude Code, OpenCode or
5
+ * OpenClaude; Bob takes no model): the `tiers` map (`standard`, `light`) and each agent's
6
+ * `agents.<name>.model` pin. The precedence (pin > map > the host's tier default > inherit) is
7
+ * `agentModel` in `js/hosts/native.mjs`, the same function
7
8
  * the emit writes agent frontmatter with, so this page can never promise a model the build will
8
9
  * not write. The value validation is `overrideProblem` and the map reader `loadTierMap`, there too.
9
10
  *
@@ -17,8 +18,11 @@
17
18
  * `null` removes the key (back to the tier's default). A pin: a string sets it, `''` or `null`
18
19
  * removes `model` and leaves the rest of the agent's entry alone.
19
20
  *
20
- * Pins and the map are Claude Code's: OpenCode records pins but this page does not edit them, and
21
- * a host that is not Claude Code answers each agent's tier and no model.
21
+ * The GET also lists the models the install can run (`model-catalog.mjs`), and a save is validated
22
+ * per host: OpenCode takes `provider/model[#variant]`, the others any single-line string. The
23
+ * routing (`--tiers`) is not written here: the page sends it with the rebuild, through the existing
24
+ * `install` action (its `tiers` field), so one path rebuilds. A host with no per-agent model (Bob)
25
+ * answers each agent's tier and no model.
22
26
  */
23
27
  import path from 'node:path';
24
28
 
@@ -26,8 +30,9 @@ import { renderAll } from '../build/render.mjs';
26
30
  import { loadKits, makeCfg } from '../build/source.mjs';
27
31
  import { EMIT_HOST_SCOPE, tiersOfDir } from '../hosts/installs.mjs';
28
32
  import {
29
- CLAUDE_TIER_DEFAULTS, claudeAgentModel, loadAgentOverrides, loadTierMap, overrideProblem,
33
+ TIER_DEFAULTS, agentModel, loadAgentOverrides, loadTierMap, overrideProblem,
30
34
  } from '../hosts/native.mjs';
35
+ import { readModelCatalog } from './model-catalog.mjs';
31
36
  import { isFile, readText, writeTextAtomic } from '../lib/fs.mjs';
32
37
  import { formatValue, isDict, isTruthy, jsonDumpsIndent, parseJson } from '../lib/json.mjs';
33
38
  import { bget } from './actions.mjs';
@@ -67,10 +72,36 @@ function readOverrides(dir) {
67
72
  return { file, exists: true, data, problem: null };
68
73
  }
69
74
 
70
- /** The view's host and the install's directory; `claude` false for every host but Claude Code. */
75
+ /** The hosts whose agents take a `model:` line: every host but Bob. */
76
+ const ROUTES = ['claude', 'opencode', 'openclaude'];
77
+
78
+ /** The view's host, scope and the install's directory; `claude` (routing supported) false only for Bob. */
71
79
  function viewOf(state) {
72
- const [host] = EMIT_HOST_SCOPE.get(state.emit || '') ?? ['opencode'];
73
- return { host, claude: host === 'claude', dir: state.target };
80
+ const [host, scope] = EMIT_HOST_SCOPE.get(state.emit || '') ?? ['opencode', 'global'];
81
+ return { host, scope, claude: ROUTES.includes(host), dir: state.target };
82
+ }
83
+
84
+ /** The model ids this install's `agent-overrides.json` holds: the tier map's values and the pins. */
85
+ function modelsInUse(dir) {
86
+ const { data, problem } = readOverrides(dir);
87
+ if (problem || !data) return [];
88
+ const out = [];
89
+ if (isDict(data.tiers)) for (const v of Object.values(data.tiers)) if (typeof v === 'string' && v.trim()) out.push(v.trim());
90
+ if (isDict(data.agents)) for (const e of Object.values(data.agents)) if (isDict(e) && typeof e.model === 'string' && e.model.trim()) out.push(e.model.trim());
91
+ return out;
92
+ }
93
+
94
+ /**
95
+ * `GET /api/agent-models`: the per-agent view (`apiAgentModels`) plus the install's `models` and
96
+ * `groups` (`readModelCatalog`: files and loopback probes, never a key). Async because of the probes.
97
+ * `opts` (`env`, `home`, `fetchFn`) lets a test plant the machine.
98
+ */
99
+ export async function apiAgentModelsFull(state, opts = {}) {
100
+ const view = apiAgentModels(state, opts.env);
101
+ const { host, scope, dir } = viewOf(state);
102
+ if (!view.claude) return { ...view, models: [], groups: [] };
103
+ const cat = await readModelCatalog({ host, scope, dir, root: state.root ?? dir, inUse: modelsInUse(dir), ...opts });
104
+ return { ...view, ...cat };
74
105
  }
75
106
 
76
107
  export function apiAgentModels(state, env = process.env) {
@@ -86,23 +117,23 @@ export function apiAgentModels(state, env = process.env) {
86
117
  const quiet = () => {};
87
118
  const map = problem ? {} : loadTierMap(dir, quiet);
88
119
  const pins = problem ? {} : loadAgentOverrides(dir, quiet);
89
- const on = tiers === 'auto' ? { map, env } : null;
120
+ const on = tiers === 'auto' ? { map, env, host } : null;
90
121
  const warnings = new Set();
91
122
  const agents = names.map((name) => {
92
123
  const tier = known.get(name) ?? null;
93
124
  const pin = Object.hasOwn(pins, name) && isTruthy(pins[name]?.model) ? formatValue(pins[name].model) : null;
94
125
  // A personal agent (no shipped source) is not Geneseed's to tier: only its pin counts.
95
- const r = claudeAgentModel(tier ?? 'none', pin, tier ? on : null);
126
+ const r = agentModel(tier ?? 'none', pin, tier ? on : null);
96
127
  // The alias warning is the tier map's, whether or not the routing is installed yet: the
97
128
  // console's editor shows with a picked `auto`, before the rebuild that turns it on.
98
- const w = tier ? claudeAgentModel(tier, pin, { map, env }).warning : null;
129
+ const w = tier ? agentModel(tier, pin, { map, env, host }).warning : null;
99
130
  if (w) warnings.add(w);
100
131
  return { name, tier, pin, model: r.model, from: r.from };
101
132
  });
102
133
  return {
103
134
  host, claude, tiers, file: { path: file, problem },
104
135
  map: Object.fromEntries(Object.entries(map).map(([k, v]) => [k, formatValue(v)])),
105
- defaults: { ...CLAUDE_TIER_DEFAULTS },
136
+ defaults: { ...TIER_DEFAULTS[host] },
106
137
  warnings: [...warnings], agents,
107
138
  };
108
139
  }
@@ -111,7 +142,7 @@ export function apiAgentModels(state, env = process.env) {
111
142
  * Apply one edit to the parsed file in place; the problems found, none applied when there are some.
112
143
  * `edit` is `{ tiers?: {standard?, light?}, agents?: {<name>: model} }`, `names` the installed agents.
113
144
  */
114
- export function editOverrides(data, edit, names) {
145
+ export function editOverrides(data, edit, names, host = 'claude') {
115
146
  const problems = [];
116
147
  const asModel = (where, v) => {
117
148
  if (v === null) return null;
@@ -119,6 +150,10 @@ export function editOverrides(data, edit, names) {
119
150
  const s = v.trim();
120
151
  const why = overrideProblem(s);
121
152
  if (why) { problems.push(`${where} ${why}`); return undefined; }
153
+ // OpenCode names a model `provider/model[#variant]`: the provider ends at the first `/`.
154
+ if (host === 'opencode' && s && !/^[^\s/]+\/[^\s]+$/.test(s)) {
155
+ problems.push(`${where} must look like provider/model, with no whitespace`); return undefined;
156
+ }
122
157
  if (s.length > MAX_MODEL) { problems.push(`${where} is longer than ${MAX_MODEL} characters`); return undefined; }
123
158
  return s;
124
159
  };
@@ -160,12 +195,12 @@ export function editOverrides(data, edit, names) {
160
195
 
161
196
  /** `POST /api/agent-models`: `ok: false` (a 409) when nothing was written, with the reason. */
162
197
  export function apiAgentModelsSave(state, body) {
163
- const { claude, dir } = viewOf(state);
164
- if (!claude) return { ok: false, error: 'Models are set on Claude Code installs only' };
198
+ const { host, claude, dir } = viewOf(state);
199
+ if (!claude) return { ok: false, error: 'This host takes no per-agent model (Bob), so there is nothing to save' };
165
200
  const { file, data, problem } = readOverrides(dir);
166
201
  if (problem) return { ok: false, error: problem };
167
202
  const names = state.inventory.agents.map((a) => a.name);
168
- const problems = editOverrides(data, { tiers: bget(body, 'tiers'), agents: bget(body, 'agents') }, names);
203
+ const problems = editOverrides(data, { tiers: bget(body, 'tiers'), agents: bget(body, 'agents') }, names, host);
169
204
  if (problems.length) return { ok: false, error: problems.join('; ') };
170
205
  writeTextAtomic(file, `${jsonDumpsIndent(data, { ensureAscii: false })}\n`);
171
206
  return { ok: true, rebuild: true, ...apiAgentModels(state) };
package/js/web/api.mjs CHANGED
@@ -37,6 +37,7 @@ import { accentFor, keptKitFiles, statusData } from '../inspect/status.mjs';
37
37
  import { writeTextAtomic } from '../lib/fs.mjs';
38
38
  import { sharedPaths } from '../lib/machine-dir.mjs';
39
39
  import { comparePaths } from '../lib/paths.mjs';
40
+ import { pinCountOf } from './model-catalog.mjs';
40
41
  import {
41
42
  configItems, deployed, dget, fleetCounts, memoryDir, memoryItems, notebookItems, orSkip, tierOf, wikiItems,
42
43
  } from './catalog.mjs';
@@ -252,6 +253,8 @@ export function apiInstalls(state) {
252
253
  // Files here that are the user's where Geneseed ships one, and retired leftovers: what a
253
254
  // forced rebuild would replace or remove (`leftoversOf`). Read off the emit's own record.
254
255
  leftovers: leftoversOf(root, host, scope),
256
+ // The agents of this install that carry their own model pin: the Installs panel's line to the Models page.
257
+ pins: installState(root, host, scope) === 'absent' ? 0 : pinCountOf(viewCfg(host, scope, root)),
255
258
  // OpenCode only: the bash gates a `--prune-gates` rebuild would take out (`strandedGatesOf`).
256
259
  strandedGates: strandedGatesOf(root, host, scope),
257
260
  // The install a request naming none reads (`defaultView`): the console's pickers start on it.