geneseed 6.0.0 → 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 (46) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/SHIPPED.md +1 -1
  3. package/docs/concepts/agents.md +3 -1
  4. package/harness.config.json +1 -1
  5. package/js/README.md +2 -0
  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 +62 -26
  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 +207 -0
  14. package/js/web/api.mjs +3 -0
  15. package/js/web/model-catalog.mjs +324 -0
  16. package/js/web/routes.mjs +7 -1
  17. package/package.json +1 -1
  18. package/web/dist/assets/{ActiveLoops-DOJCPPPc.js → ActiveLoops-BWkImeYa.js} +1 -1
  19. package/web/dist/assets/{Activity-bUSPM3Dl.js → Activity-DJlPhk8q.js} +1 -1
  20. package/web/dist/assets/{ActivityDetail-AHRoXeFN.js → ActivityDetail-Dk7UPnE_.js} +1 -1
  21. package/web/dist/assets/{Bonsai-B5XY9pid.js → Bonsai-Bry-kOFb.js} +1 -1
  22. package/web/dist/assets/{CopyButton-C0wwRR9H.js → CopyButton-Cnnvjgkg.js} +1 -1
  23. package/web/dist/assets/{Dashboard-DPAA96EI.js → Dashboard-CWhh_GSc.js} +2 -2
  24. package/web/dist/assets/{Docs-CpGDq165.js → Docs-BJ23-fIx.js} +1 -1
  25. package/web/dist/assets/{Factories-cNhETa5Q.js → Factories-CjsIACyi.js} +1 -1
  26. package/web/dist/assets/{GreenhouseView-DO3ADmT9.js → GreenhouseView-VL_ZKJUR.js} +1 -1
  27. package/web/dist/assets/Installs-qcfOZNzF.js +3 -0
  28. package/web/dist/assets/{JournalView--W-Lw_V9.js → JournalView-KrmFUC-X.js} +1 -1
  29. package/web/dist/assets/{Kits-ChfehxY6.js → Kits-DDSerkJk.js} +1 -1
  30. package/web/dist/assets/{Laws-CNxYmV36.js → Laws-DDffPs6O.js} +1 -1
  31. package/web/dist/assets/{LibRows-CiPvsRYB.js → LibRows-QsUBjOF7.js} +1 -1
  32. package/web/dist/assets/Library-DzT3Mebh.js +3 -0
  33. package/web/dist/assets/{Loops-DAblKkyq.js → Loops-CjsX3brz.js} +1 -1
  34. package/web/dist/assets/Models-DPrAv3FG.js +1 -0
  35. package/web/dist/assets/{OperatorHudView-QtSaSyYm.js → OperatorHudView-Bdupodlc.js} +1 -1
  36. package/web/dist/assets/{Personal-DxSGv638.js → Personal-D-dpCUU5.js} +1 -1
  37. package/web/dist/assets/{Settings-CgTbhvRv.js → Settings-Dz33_Sys.js} +1 -1
  38. package/web/dist/assets/{Tabs-Cf4X1hdz.js → Tabs-qY40S34V.js} +1 -1
  39. package/web/dist/assets/api-C8nMUU1i.js +1 -0
  40. package/web/dist/assets/{index-B_pTwZra.js → index-BhT94v2q.js} +3 -3
  41. package/web/dist/assets/index-DcusoHzF.css +1 -0
  42. package/web/dist/index.html +3 -3
  43. package/web/dist/assets/Installs-D3dDyq10.js +0 -3
  44. package/web/dist/assets/Library-BxQvbwVU.js +0 -3
  45. package/web/dist/assets/api-CZ-x0iWG.js +0 -1
  46. package/web/dist/assets/index-CzfImiYb.css +0 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,26 @@ 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
+
21
+ ## [6.0.1] — 2026-11-18
22
+
23
+ ### Added
24
+
25
+ - **The console sets the sub-agent model tiers.** On a Claude Code install, the Installs panel has a *Model tiers* switch (off or auto) beside the context window, kept by the same rebuild. With auto on, an editor shows the models of the standard and light tiers (an empty field means inherit; strong is always your session model) and saves them into `agent-overrides.json` key by key: your other keys are kept, and a file that does not parse is refused, never rewritten. It says a rebuild applies the change and offers it, and shows the Bedrock/Vertex alias warning when the console's own environment has it. In the Library, each agent shows its tier, the model it resolves to on that install and why, and a field to pin a model (an empty pin removes only `model`). New `GET` and `POST /api/agent-models`. The precedence (pin, then the map, then the tier default, then inherit) now lives in one function, `claudeAgentModel`, which the emit and the console both use.
26
+
27
+ ### Fixed
28
+
29
+ - **Console text fields follow the theme.** A text input with no page-specific style (the new tier and pin fields, the profile and onboarding fields) showed the browser's white box in the dark theme. It now has the select's look and keeps its focus outline.
30
+
11
31
  ## [6.0.0] — 2026-11-17
12
32
 
13
33
  ### 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.0**.
23
+ > string. Current label: **6.0.2**.
24
24
 
25
25
  ## Capabilities
26
26
 
@@ -42,10 +42,12 @@ 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 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
+
49
51
  ### Agents learn too
50
52
 
51
53
  When a subagent finishes, the hook copies each `spec-feedback:` line its report ends with into a notes file, with no model call. The line picks its scope with one question: is it true in any repo, or only here? A flaw of the spec is true in any repo: `[agent]` goes into the machine notes, `agent-notes/<name>.md` under `~/.config/geneseed/notes/` (a `[general]` line into `agent-notes/_general.md` there, which every agent reads). A fact true only in this repo is tagged `[agent:project]` and goes into `notebook/agent-notes/<name>.md` at the project root, one folder for every host (in a linked worktree, the main checkout's); a `[general:project]` line goes into `notebook/agent-notes/_general.md`, which every agent reads in that repo. The agent reads the machine notes and then the project notes first at its next dispatch; where they disagree, the project notes win. So a flaw it reported is in front of it until the user folds the fix into the source. See [Hooks](hooks.md). (Not on Bob, which has no subagent-finished event: there the caller copies the line into the machine or the project file.)
@@ -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.0"
5
+ "version": "6.0.2"
6
6
  }
package/js/README.md CHANGED
@@ -282,6 +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 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) |
285
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` |
286
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 |
287
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,
@@ -417,12 +417,10 @@ const WEBFETCH_MARKER = '<!-- webfetch: allow -->';
417
417
  * cannot name tools it has never seen, so a read-only agent in a session with such a server can
418
418
  * still write through it, until this becomes an allowlist (`tools:`).
419
419
  */
420
- function claudeAgentFrontmatter(stem, text, overrides, tierModel = null) {
420
+ function claudeAgentFrontmatter(stem, text, model = null) {
421
421
  const fm = [`name: ${stem}`, `description: ${jsonDumps(agentDescription(text))}`];
422
- const ov = agentOverride(overrides, stem);
423
- // Precedence, highest first (spec D5): the user's pin, then the tier's model, then inherit.
424
- if (isTruthy(ov.model)) fm.push(`model: ${formatValue(ov.model)}`);
425
- else if (tierModel) fm.push(`model: ${formatValue(tierModel)}`);
422
+ // `model` is `agentModel(...).model`: the one precedence, resolved by the caller.
423
+ if (model) fm.push(`model: ${model}`);
426
424
  if (isReadonly(text)) {
427
425
  const list = ['Write', 'Edit', 'NotebookEdit', 'Agent', 'Task'];
428
426
  if (!text.includes(WEBFETCH_MARKER)) list.push('WebFetch');
@@ -455,11 +453,18 @@ function bobAgentFrontmatter(stem, text) {
455
453
  return fm;
456
454
  }
457
455
 
458
- /** `_build_emit._opencode_agent_frontmatter`. */
459
- 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) {
460
463
  const fm = [`description: ${jsonDumps(agentDescription(text))}`, 'mode: subagent'];
461
464
  fm.push(`color: ${agentColor(stem, theme)}`);
462
- 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);
463
468
  if (isReadonly(text)) {
464
469
  fm.push('permission:', ' edit: deny',
465
470
  ` webfetch: ${text.includes(WEBFETCH_MARKER) ? 'allow' : 'deny'}`);
@@ -480,7 +485,7 @@ const OVERRIDE_KEYS = ['model', 'temperature', 'variant', 'steps'];
480
485
  * boolean, a list, an object — threw a bare TypeError that aborted the emit with a stack trace
481
486
  * naming nothing the user wrote.
482
487
  */
483
- function overrideProblem(v) {
488
+ export function overrideProblem(v) {
484
489
  if (typeof v === 'string') return /[\r\n\u2028\u2029]/.test(v) ? 'contains a line break' : '';
485
490
  // `parseJson` yields exactly one object `isDict` refuses: its number wrapper.
486
491
  const isNumber = typeof v === 'object' && v !== null && !Array.isArray(v) && !isDict(v);
@@ -492,7 +497,7 @@ function overrideProblem(v) {
492
497
  * `_build_emit._load_agent_overrides`, with every value that would break the frontmatter
493
498
  * dropped and named on stderr — the user's file, so a bad entry is a warning, never an abort.
494
499
  */
495
- export function loadAgentOverrides(base) {
500
+ export function loadAgentOverrides(base, report = warn) {
496
501
  const file = path.join(base, 'agent-overrides.json');
497
502
  let data;
498
503
  try {
@@ -514,7 +519,7 @@ export function loadAgentOverrides(base) {
514
519
  for (const [stem, entry] of Object.entries(agents)) {
515
520
  if (entry === null) continue;
516
521
  if (!isDict(entry)) {
517
- warn(`[geneseed] WARN: ${file}: agents.${stem} is not an object — skipped`);
522
+ report(`[geneseed] WARN: ${file}: agents.${stem} is not an object — skipped`);
518
523
  delete agents[stem];
519
524
  continue;
520
525
  }
@@ -522,7 +527,7 @@ export function loadAgentOverrides(base) {
522
527
  if (!given(entry[key])) continue;
523
528
  const why = overrideProblem(entry[key]);
524
529
  if (!why) continue;
525
- warn(`[geneseed] WARN: ${file}: agents.${stem}.${key} ${why} — skipped`);
530
+ report(`[geneseed] WARN: ${file}: agents.${stem}.${key} ${why} — skipped`);
526
531
  delete entry[key];
527
532
  }
528
533
  }
@@ -537,8 +542,18 @@ const CLAUDE_ALIAS_ENV = Object.freeze({
537
542
  opus: 'ANTHROPIC_DEFAULT_OPUS_MODEL', sonnet: 'ANTHROPIC_DEFAULT_SONNET_MODEL',
538
543
  haiku: 'ANTHROPIC_DEFAULT_HAIKU_MODEL',
539
544
  });
540
- /** The model each non-strong tier gets on Claude Code when `tiers.<tier>` names none (spec D2). */
541
- 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
+ });
542
557
  /** The tier-map keys that take a model; `strong` is the parent's model and takes none (D9). */
543
558
  const TIER_MAP_KEYS = ['standard', 'light'];
544
559
 
@@ -549,13 +564,13 @@ function envOn(env, name) {
549
564
  }
550
565
 
551
566
  /**
552
- * The model a tier gets on Claude Code, or null (inherit) — pure, so the table in
553
- * `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
554
569
  * (`loadTierMap`), `env` the environment.
555
570
  *
556
571
  * - `strong` never gets a line: it IS the parent's model.
557
- * - A tier the map does not name gets the alias default (`CLAUDE_TIER_DEFAULTS`); a tier the map
558
- * 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.
559
574
  * - D11 (revised 2026-11-17): the alias is ALWAYS written. On Bedrock or Vertex without
560
575
  * `ANTHROPIC_DEFAULT_<ALIAS>_MODEL`, Claude Code resolves it to its built-in model id (seen on
561
576
  * 2.1.326, Vertex: `haiku` -> claude-haiku-4-5@20251001, and the sub-agent runs), which may not
@@ -563,14 +578,15 @@ function envOn(env, name) {
563
578
  * pin it; the doctor prints it (`tierEnvNotes`), the build says nothing. Only the three aliases
564
579
  * are checked: any other value is a model id the user wrote and owns.
565
580
  */
566
- export function claudeTierModel(tier, map = {}, env = {}) {
581
+ export function tierModel(tier, map = {}, env = {}, host = 'claude') {
567
582
  if (!TIER_MAP_KEYS.includes(tier)) return { model: null, warning: null };
568
583
  const named = Object.hasOwn(map, tier);
569
- 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);
570
585
  if (!isTruthy(value)) return { model: null, warning: null };
571
586
  const alias = String(value).trim().toLowerCase();
572
587
  const cloud = ['CLAUDE_CODE_USE_BEDROCK', 'CLAUDE_CODE_USE_VERTEX'].find((n) => envOn(env, n));
573
- 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;
574
590
  const warning = cloud && need && !String(env[need] ?? '').trim()
575
591
  ? `--tiers auto: ${cloud} is set but ${need} is not, so the ${tier} tier's '${alias}' alias `
576
592
  + `resolves to Claude Code's built-in model id, which may not exist in your cloud project — `
@@ -579,6 +595,26 @@ export function claudeTierModel(tier, map = {}, env = {}) {
579
595
  return { model: String(value), warning };
580
596
  }
581
597
 
598
+ /**
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.
609
+ */
610
+ export function agentModel(tier, pin, tiers = null) {
611
+ if (isTruthy(pin)) return { model: formatValue(pin), from: 'pin', warning: null };
612
+ if (!tiers) return { model: null, from: 'inherit', warning: null };
613
+ const { model, warning } = tierModel(tier, tiers.map, tiers.env, tiers.host);
614
+ if (!model) return { model: null, from: 'inherit', warning: null };
615
+ return { model: formatValue(model), from: Object.hasOwn(tiers.map, tier) ? 'map' : 'default', warning };
616
+ }
617
+
582
618
  /**
583
619
  * The user's `tiers` map from `agent-overrides.json` (spec D9): `{ "standard": "<model>",
584
620
  * "light": "<model>" }`. `strong` takes no value and is dropped with a notice, as is any other
@@ -785,15 +821,15 @@ export function writeNativeLayer(items, agentsDir, skillsDir, overrides = null,
785
821
  // choice. The caller (`emit-claude.mjs`) routes the suppressed names through
786
822
  // `writeAliasCommands(..., alsoUserOnly: true)` into `.bob/commands/*.md` instead (O2).
787
823
  bobDialect = false,
788
- // `--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.
789
826
  tiers = null,
790
827
  } = {}) {
791
828
  const ov = overrides || {};
792
829
  if (bobDialect) warnBobIgnored(ov);
793
830
  else if (host === 'claude') warnClaudeIgnored(ov);
794
831
  // D11: the build never withholds the alias; the doctor warns about a cloud provider (`tierEnvNotes`).
795
- const tierModelOf = (tier) => (!tiers || host !== 'claude' || bobDialect ? null
796
- : claudeTierModel(tier, tiers.map, tiers.env).model);
832
+ const tiersHere = tiers && !bobDialect ? tiers : null;
797
833
  let nAgents = 0;
798
834
  let nSkills = 0;
799
835
  const written = [];
@@ -872,8 +908,8 @@ export function writeNativeLayer(items, agentsDir, skillsDir, overrides = null,
872
908
  let userOnly = false;
873
909
  if (folder === 'agents') {
874
910
  if (bobDialect) fm = bobAgentFrontmatter(stem, text);
875
- else if (host === 'claude') fm = claudeAgentFrontmatter(stem, text, ov, tierModelOf(tier));
876
- 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);
877
913
  dest = path.join(agentsDir, `${stem}.md`);
878
914
  body = stripAgentSkillLinks(body);
879
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
  }
@@ -0,0 +1,207 @@
1
+ /**
2
+ * The console's view of the sub-agent models — `GET`/`POST /api/agent-models`.
3
+ *
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
8
+ * the emit writes agent frontmatter with, so this page can never promise a model the build will
9
+ * not write. The value validation is `overrideProblem` and the map reader `loadTierMap`, there too.
10
+ *
11
+ * THE FILE IS THE USER'S. A write changes only the keys it names, key by key, in the order the
12
+ * file already has; it refuses a file that does not parse, or a `tiers`/`agents` that is not an
13
+ * object, rather than replace what it cannot read. Nothing here rebuilds: the model is written
14
+ * into the agent files at emit, so a save answers `rebuild: true` and the page offers the rebuild
15
+ * through the install action.
16
+ *
17
+ * A tier's value: a string sets it (`''` is the user choosing inherit, as `loadTierMap` reads it),
18
+ * `null` removes the key (back to the tier's default). A pin: a string sets it, `''` or `null`
19
+ * removes `model` and leaves the rest of the agent's entry alone.
20
+ *
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.
26
+ */
27
+ import path from 'node:path';
28
+
29
+ import { renderAll } from '../build/render.mjs';
30
+ import { loadKits, makeCfg } from '../build/source.mjs';
31
+ import { EMIT_HOST_SCOPE, tiersOfDir } from '../hosts/installs.mjs';
32
+ import {
33
+ TIER_DEFAULTS, agentModel, loadAgentOverrides, loadTierMap, overrideProblem,
34
+ } from '../hosts/native.mjs';
35
+ import { readModelCatalog } from './model-catalog.mjs';
36
+ import { isFile, readText, writeTextAtomic } from '../lib/fs.mjs';
37
+ import { formatValue, isDict, isTruthy, jsonDumpsIndent, parseJson } from '../lib/json.mjs';
38
+ import { bget } from './actions.mjs';
39
+
40
+ const FILE = 'agent-overrides.json';
41
+ /** The tiers that take a model; `strong` is the session's own and has no key. */
42
+ const MAP_TIERS = ['standard', 'light'];
43
+ const MAX_MODEL = 200;
44
+
45
+ let tierTable = null;
46
+ /**
47
+ * `Map<agent name, 'strong'|'standard'|'light'>` off the SOURCE: the render strips an agent's
48
+ * `<!-- tier: -->` line from every output, so an installed file cannot say it. Every kit's agents
49
+ * are included, so a kit's seat is not read as `standard` by default. Built once per process.
50
+ */
51
+ export function agentTiers() {
52
+ if (tierTable) return tierTable;
53
+ const out = new Map();
54
+ const { items } = renderAll(makeCfg({ kits: [...loadKits().keys()] }), 'neutral');
55
+ for (const { rel, tier = 'standard' } of items) {
56
+ const m = /^agents\/([^_/][^/]*)\.md$/.exec(rel);
57
+ if (m) out.set(m[1], tier);
58
+ }
59
+ tierTable = out;
60
+ return out;
61
+ }
62
+
63
+ /** `{ exists, data, problem }`: the file parsed as an object, else why it cannot be edited. */
64
+ function readOverrides(dir) {
65
+ const file = path.join(dir, FILE);
66
+ if (!isFile(file)) return { file, exists: false, data: {}, problem: null };
67
+ let data;
68
+ try { data = parseJson(readText(file)); } catch {
69
+ return { file, exists: true, data: null, problem: `${FILE} is not valid JSON (comments are not allowed) — fix it by hand` };
70
+ }
71
+ if (!isDict(data)) return { file, exists: true, data: null, problem: `${FILE} is not a JSON object — fix it by hand` };
72
+ return { file, exists: true, data, problem: null };
73
+ }
74
+
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. */
79
+ function viewOf(state) {
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 };
105
+ }
106
+
107
+ export function apiAgentModels(state, env = process.env) {
108
+ const { host, claude, dir } = viewOf(state);
109
+ const tiers = tiersOfDir(state.root ?? dir, host);
110
+ const known = agentTiers();
111
+ const names = state.inventory.agents.map((a) => a.name);
112
+ if (!claude) {
113
+ return { host, claude, tiers, agents: names.map((name) => ({ name, tier: known.get(name) ?? null })) };
114
+ }
115
+ const { file, problem } = readOverrides(dir);
116
+ // The loaders take a no-op reporter: a console read prints nothing on stderr.
117
+ const quiet = () => {};
118
+ const map = problem ? {} : loadTierMap(dir, quiet);
119
+ const pins = problem ? {} : loadAgentOverrides(dir, quiet);
120
+ const on = tiers === 'auto' ? { map, env, host } : null;
121
+ const warnings = new Set();
122
+ const agents = names.map((name) => {
123
+ const tier = known.get(name) ?? null;
124
+ const pin = Object.hasOwn(pins, name) && isTruthy(pins[name]?.model) ? formatValue(pins[name].model) : null;
125
+ // A personal agent (no shipped source) is not Geneseed's to tier: only its pin counts.
126
+ const r = agentModel(tier ?? 'none', pin, tier ? on : null);
127
+ // The alias warning is the tier map's, whether or not the routing is installed yet: the
128
+ // console's editor shows with a picked `auto`, before the rebuild that turns it on.
129
+ const w = tier ? agentModel(tier, pin, { map, env, host }).warning : null;
130
+ if (w) warnings.add(w);
131
+ return { name, tier, pin, model: r.model, from: r.from };
132
+ });
133
+ return {
134
+ host, claude, tiers, file: { path: file, problem },
135
+ map: Object.fromEntries(Object.entries(map).map(([k, v]) => [k, formatValue(v)])),
136
+ defaults: { ...TIER_DEFAULTS[host] },
137
+ warnings: [...warnings], agents,
138
+ };
139
+ }
140
+
141
+ /**
142
+ * Apply one edit to the parsed file in place; the problems found, none applied when there are some.
143
+ * `edit` is `{ tiers?: {standard?, light?}, agents?: {<name>: model} }`, `names` the installed agents.
144
+ */
145
+ export function editOverrides(data, edit, names, host = 'claude') {
146
+ const problems = [];
147
+ const asModel = (where, v) => {
148
+ if (v === null) return null;
149
+ if (typeof v !== 'string') { problems.push(`${where}: a model name, or null`); return undefined; }
150
+ const s = v.trim();
151
+ const why = overrideProblem(s);
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
+ }
157
+ if (s.length > MAX_MODEL) { problems.push(`${where} is longer than ${MAX_MODEL} characters`); return undefined; }
158
+ return s;
159
+ };
160
+ const tiers = isDict(edit.tiers) ? edit.tiers : {};
161
+ const agents = isDict(edit.agents) ? edit.agents : {};
162
+ const tierOps = [];
163
+ for (const [k, v] of Object.entries(tiers)) {
164
+ if (!MAP_TIERS.includes(k)) { problems.push(`tiers.${k} is not a tier that takes a model (${MAP_TIERS.join(', ')})`); continue; }
165
+ const m = asModel(`tiers.${k}`, v);
166
+ if (m !== undefined) tierOps.push([k, m]);
167
+ }
168
+ const pinOps = [];
169
+ for (const [name, v] of Object.entries(agents)) {
170
+ if (name === '__proto__' || !names.includes(name)) { problems.push(`agents.${name} is not an installed agent`); continue; }
171
+ const m = asModel(`agents.${name}.model`, v);
172
+ if (m !== undefined) pinOps.push([name, m === '' ? null : m]);
173
+ }
174
+ if (!tierOps.length && !pinOps.length && !problems.length) problems.push('nothing to save');
175
+ if (tierOps.length && Object.hasOwn(data, 'tiers') && !isDict(data.tiers)) problems.push(`${FILE}: "tiers" is not an object — fix it by hand`);
176
+ if (pinOps.length && Object.hasOwn(data, 'agents') && !isDict(data.agents)) problems.push(`${FILE}: "agents" is not an object — fix it by hand`);
177
+ if (problems.length) return problems;
178
+
179
+ for (const [k, m] of tierOps) {
180
+ if (m === null) { if (isDict(data.tiers)) delete data.tiers[k]; continue; }
181
+ if (!isDict(data.tiers)) data.tiers = {};
182
+ data.tiers[k] = m;
183
+ }
184
+ for (const [name, m] of pinOps) {
185
+ if (m === null) {
186
+ if (isDict(data.agents) && Object.hasOwn(data.agents, name) && isDict(data.agents[name])) delete data.agents[name].model;
187
+ continue;
188
+ }
189
+ if (!isDict(data.agents)) data.agents = {};
190
+ if (!Object.hasOwn(data.agents, name) || !isDict(data.agents[name])) data.agents[name] = {};
191
+ data.agents[name].model = m;
192
+ }
193
+ return [];
194
+ }
195
+
196
+ /** `POST /api/agent-models`: `ok: false` (a 409) when nothing was written, with the reason. */
197
+ export function apiAgentModelsSave(state, body) {
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' };
200
+ const { file, data, problem } = readOverrides(dir);
201
+ if (problem) return { ok: false, error: problem };
202
+ const names = state.inventory.agents.map((a) => a.name);
203
+ const problems = editOverrides(data, { tiers: bget(body, 'tiers'), agents: bget(body, 'agents') }, names, host);
204
+ if (problems.length) return { ok: false, error: problems.join('; ') };
205
+ writeTextAtomic(file, `${jsonDumpsIndent(data, { ensureAscii: false })}\n`);
206
+ return { ok: true, rebuild: true, ...apiAgentModels(state) };
207
+ }
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.