geneseed 5.6.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +2 -2
  3. package/SHIPPED.md +2 -2
  4. package/adapters/opencode/README.md +7 -4
  5. package/docs/concepts/agents.md +10 -0
  6. package/docs/concepts/exclusions.md +1 -1
  7. package/docs/concepts/foreman-mode.md +4 -2
  8. package/docs/concepts/kits.md +20 -2
  9. package/docs/concepts/loops.md +5 -0
  10. package/docs/concepts/skills.md +1 -1
  11. package/docs/concepts/superpowers-kit.md +79 -0
  12. package/docs/extending.md +11 -4
  13. package/docs/guides/install-scripted.md +1 -1
  14. package/docs/reference/cli.md +2 -0
  15. package/docs/reference/profiles.md +10 -5
  16. package/harness.config.json +1 -1
  17. package/js/README.md +3 -0
  18. package/js/build/args.mjs +4 -2
  19. package/js/build/driver.mjs +8 -8
  20. package/js/build/emit-claude.mjs +5 -3
  21. package/js/build/emit-opencode.mjs +2 -2
  22. package/js/build/generate.mjs +1 -1
  23. package/js/build/profile.mjs +15 -7
  24. package/js/build/render.mjs +81 -10
  25. package/js/build/source.mjs +75 -1
  26. package/js/cli-table.json +17 -2
  27. package/js/hosts/installs.mjs +50 -4
  28. package/js/hosts/native.mjs +125 -9
  29. package/js/hosts/opencode.mjs +13 -15
  30. package/js/inspect/checks-authoring.mjs +24 -1
  31. package/js/inspect/checks-build.mjs +43 -2
  32. package/js/inspect/checks-counts.mjs +72 -1
  33. package/js/inspect/diff.mjs +17 -3
  34. package/js/inspect/doctor.mjs +23 -2
  35. package/js/inspect/status.mjs +5 -1
  36. package/js/inspect/validate.mjs +1 -1
  37. package/js/loop/catalog.mjs +10 -0
  38. package/js/maintain/kit-migration.mjs +109 -0
  39. package/js/maintain/plugin-detect.mjs +150 -0
  40. package/js/maintain/profiles.mjs +46 -5
  41. package/js/maintain/setup.mjs +45 -11
  42. package/js/maintain/update.mjs +1 -1
  43. package/js/web/actions.mjs +28 -7
  44. package/js/web/agent-models-api.mjs +172 -0
  45. package/js/web/api.mjs +3 -1
  46. package/js/web/profiles-api.mjs +11 -7
  47. package/js/web/routes.mjs +5 -1
  48. package/package.json +1 -1
  49. package/profiles/autonomous.json +1 -0
  50. package/profiles/corporate.json +1 -1
  51. package/profiles/mentor.json +1 -0
  52. package/profiles/minimal.json +2 -1
  53. package/profiles/starter.json +1 -1
  54. package/src/AGENT.md.tmpl +1 -6
  55. package/src/agents/_template.md +4 -0
  56. package/src/agents/advocate.md +1 -0
  57. package/src/agents/architect.md +1 -0
  58. package/src/agents/developer.md +12 -4
  59. package/src/agents/empiricist.md +1 -0
  60. package/src/agents/explorer.md +1 -0
  61. package/src/agents/framer.md +1 -0
  62. package/src/agents/historian.md +1 -0
  63. package/src/agents/operator.md +1 -0
  64. package/src/agents/performance.md +2 -1
  65. package/src/agents/pragmatist.md +1 -0
  66. package/src/agents/react-reviewer.md +1 -0
  67. package/src/agents/researcher.md +1 -0
  68. package/src/agents/reviewer.md +1 -0
  69. package/src/agents/security.md +1 -0
  70. package/src/agents/skeptic.md +1 -0
  71. package/src/agents/spring-reviewer.md +1 -0
  72. package/src/agents/spring-security.md +1 -0
  73. package/src/agents/steward.md +1 -0
  74. package/src/agents/user-advocate.md +1 -0
  75. package/src/agents/visionary.md +1 -0
  76. package/src/bricks/ci-fix.md +12 -2
  77. package/src/kits/superpowers/missing.md +3 -0
  78. package/src/kits/superpowers/provider.md +7 -0
  79. package/src/kits/superpowers/rules.md +6 -0
  80. package/src/kits/superpowers.json +45 -0
  81. package/src/modes/foreman.md +18 -12
  82. package/src/skills/parallel-agents.md +2 -2
  83. package/src/skills/spring-boot/cloud.md +8 -2
  84. package/src/skills/spring-boot.md +3 -1
  85. package/src/skills/spring-testing.md +3 -3
  86. package/src/upstreams.json +1 -1
  87. package/web/dist/assets/{ActiveLoops-DOJCPPPc.js → ActiveLoops-6p44eD86.js} +1 -1
  88. package/web/dist/assets/{Activity-bUSPM3Dl.js → Activity-CIgrq5R1.js} +1 -1
  89. package/web/dist/assets/{ActivityDetail-AHRoXeFN.js → ActivityDetail-Brqv1u4f.js} +1 -1
  90. package/web/dist/assets/{Bonsai-B5XY9pid.js → Bonsai-8NtlFrPO.js} +1 -1
  91. package/web/dist/assets/{CopyButton-C0wwRR9H.js → CopyButton-BHqKgdjJ.js} +1 -1
  92. package/web/dist/assets/{Dashboard-DPAA96EI.js → Dashboard-CoveJ_-U.js} +2 -2
  93. package/web/dist/assets/{Docs-CpGDq165.js → Docs-C1jzrFnD.js} +1 -1
  94. package/web/dist/assets/{Factories-cNhETa5Q.js → Factories-D5pLnt5S.js} +1 -1
  95. package/web/dist/assets/{GreenhouseView-DO3ADmT9.js → GreenhouseView-ofAQ-V5h.js} +1 -1
  96. package/web/dist/assets/Installs-DpWgyT5j.js +3 -0
  97. package/web/dist/assets/{JournalView--W-Lw_V9.js → JournalView-CsuN3_B-.js} +1 -1
  98. package/web/dist/assets/{Kits-ChfehxY6.js → Kits-P4xspDuN.js} +1 -1
  99. package/web/dist/assets/{Laws-CNxYmV36.js → Laws-DK3OwGDl.js} +1 -1
  100. package/web/dist/assets/{LibRows-CiPvsRYB.js → LibRows-CGO25X3D.js} +1 -1
  101. package/web/dist/assets/Library-e-94YED6.js +3 -0
  102. package/web/dist/assets/{Loops-DAblKkyq.js → Loops-C9DSBj-A.js} +1 -1
  103. package/web/dist/assets/{OperatorHudView-QtSaSyYm.js → OperatorHudView-Cc8mlViW.js} +1 -1
  104. package/web/dist/assets/{Personal-DxSGv638.js → Personal-DVh2jYPO.js} +1 -1
  105. package/web/dist/assets/{Settings-CgTbhvRv.js → Settings-CknBI-Fx.js} +1 -1
  106. package/web/dist/assets/{Tabs-Cf4X1hdz.js → Tabs-C30JrkJH.js} +1 -1
  107. package/web/dist/assets/api-DxwG8y94.js +1 -0
  108. package/web/dist/assets/index-CUJ8AaAF.css +1 -0
  109. package/web/dist/assets/{index-B_pTwZra.js → index-MB7E-va_.js} +3 -3
  110. package/web/dist/index.html +3 -3
  111. package/web/dist/assets/Installs-D3dDyq10.js +0 -3
  112. package/web/dist/assets/Library-BxQvbwVU.js +0 -3
  113. package/web/dist/assets/api-CZ-x0iWG.js +0 -1
  114. package/web/dist/assets/index-CzfImiYb.css +0 -1
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import path from 'node:path';
9
9
  import { VERSION_MARKER } from '../hosts/hosts.mjs';
10
- import { claimer, loadAgentOverrides, writeNativeLayer } from '../hosts/native.mjs';
10
+ import { claimer, loadAgentOverrides, loadTierMap, writeNativeLayer } from '../hosts/native.mjs';
11
11
  import { ensureAgentOverridesStub, writeAliasCommands } from '../hosts/opencode.mjs';
12
12
  import {
13
13
  managedBlockRemove, managedBlockWrite, mergeClaudeSettings,
@@ -64,7 +64,7 @@ export function emitClaudeRender(cfg, job) {
64
64
  const lawsPrefix = relCfg === '.' ? '' : `${relCfg}/`;
65
65
  // A re-render of a deployed install sends that install's root, null included.
66
66
  const { sharedRoot = scope === 'global' ? sharedRootFor(cfgDir, host) : null } = job;
67
- const { theme, items } = renderAll(cfg, themeName, { footprint, lawsPrefix, nativeCatalog, sharedRoot });
67
+ const { theme, items } = renderAll(cfg, themeName, { footprint, lawsPrefix, nativeCatalog, sharedRoot, pluginHost: host === 'claude' ? 'claude' : '' });
68
68
  assertSourceComplete(cfg, `claude-${scope}`);
69
69
  mkdirSync(cfgDir, { recursive: true });
70
70
 
@@ -137,7 +137,9 @@ export function emitClaudeRender(cfg, job) {
137
137
  const { nAgents, nSkills, written } = writeNativeLayer(
138
138
  items, path.join(cfgDir, 'agents'), path.join(cfgDir, 'skills'),
139
139
  loadAgentOverrides(cfgDir),
140
- { host: 'claude', bobDialect: isBob, oldOwned, cfg: cfgDir, src: cfg.src, skillDirOf, claim });
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
143
  for (const p of written) owned.push(relPosix(cfgDir, p));
142
144
 
143
145
  // Bob host-compat O2/R1: an alias, or a genuinely user-only skill (unverified
@@ -155,7 +155,7 @@ export function emitOpencodeRender(cfg, job) {
155
155
  }
156
156
 
157
157
  const owned = [];
158
- const { theme, items } = renderAll(cfg, _theme, { footprint, nativeCatalog });
158
+ const { theme, items } = renderAll(cfg, _theme, { footprint, nativeCatalog, pluginHost: 'opencode' });
159
159
 
160
160
  const {
161
161
  nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands, cfgName, skillDenies, editRecord, editRefused, bashGates, kept, keptHashes,
@@ -218,7 +218,7 @@ export function emitOpencodeGlobalRender(cfg, job) {
218
218
  // pointer's relative `laws/universal.md` resolves with no prefix.
219
219
  // A re-render of a deployed install sends that install's root, null included.
220
220
  const { sharedRoot = sharedRootFor(cfgDir, 'opencode') } = job;
221
- const { theme, items } = renderAll(cfg, themeName, { footprint, nativeCatalog, sharedRoot });
221
+ const { theme, items } = renderAll(cfg, themeName, { footprint, nativeCatalog, sharedRoot, pluginHost: 'opencode' });
222
222
  assertSourceComplete(cfg, 'opencode-global');
223
223
  mkdirSync(cfgDir, { recursive: true });
224
224
 
@@ -92,7 +92,7 @@ const BUILD_FORWARD = [
92
92
  ['theme', '--theme'], ['emit', '--emit'], ['footprint', '--footprint'],
93
93
  ['posture', '--posture'], ['mode', '--mode'], ['trust', '--trust'], ['doctrines', '--doctrines'],
94
94
  ['excludeRules', '--exclude-rules'], ['excludeSkills', '--exclude-skills'], ['kits', '--kits'], ['sharedTier', '--shared-tier'],
95
- ['contextWindow', '--context-window'], ['out', '--out'], ['root', '--root'],
95
+ ['contextWindow', '--context-window'], ['tiers', '--tiers'], ['out', '--out'], ['root', '--root'],
96
96
  ['configDir', '--config-dir'],
97
97
  ];
98
98
 
@@ -11,13 +11,14 @@
11
11
  import { existsSync } from 'node:fs';
12
12
  import path from 'node:path';
13
13
 
14
- import { DEFAULT_CONTEXT_WINDOW, GATE_SWITCHES, PACK_ORDER } from './source.mjs';
14
+ import { DEFAULT_CONTEXT_WINDOW, DEFAULT_TIERS, GATE_SWITCHES, PACK_ORDER, loadKits } from './source.mjs';
15
+ import { migrateSuperpowersKit } from '../maintain/kit-migration.mjs';
15
16
  import { DEFAULT_PRESET } from '../loop/score.mjs';
16
17
  import { CLAUDE_STYLE, GLOBAL_MANIFEST, HOSTS } from '../hosts/hosts.mjs';
17
18
  import {
18
19
  EMIT_FOR, EMIT_HOST_SCOPE, contextWindowOfDir, defaultMode, defaultPosture, defaultTheme, doctrinesForBuild,
19
- emitHostScopeOf, excludedRulesOfDir, excludedSkillsOfDir, footprintOfDir, kitsOfDir, sharedTierOfDir,
20
- gatesOfDir, installState, modeOfDir, postureOfDir, readMaybe, themeOfDir, trustOfDir,
20
+ emitHostScopeOf, excludedRulesOfDir, excludedSkillsOfDir, footprintOfDir, kitAwareOfDir, kitsOfDir, sharedTierOfDir,
21
+ gatesOfDir, installState, modeOfDir, postureOfDir, readMaybe, themeOfDir, tiersOfDir, trustOfDir,
21
22
  } from '../hosts/installs.mjs';
22
23
 
23
24
  /**
@@ -56,7 +57,7 @@ import {
56
57
  export function setupBuildArgs(theme, emit, out = null, root = null, footprint = 'lean',
57
58
  posture = 'peer', mode = 'direct', doctrines = null, allPacks = PACK_ORDER,
58
59
  excludeRules = null, trust = DEFAULT_PRESET, excludeSkills = null, gates = {}, kits = null, sharedTier = false,
59
- contextWindow = DEFAULT_CONTEXT_WINDOW) {
60
+ contextWindow = DEFAULT_CONTEXT_WINDOW, tiers = DEFAULT_TIERS) {
60
61
  const argv = ['--theme', theme, '--emit', emit];
61
62
  if (!emit.endsWith('-global')) {
62
63
  if (out) argv.push('--out', out);
@@ -97,6 +98,9 @@ export function setupBuildArgs(theme, emit, out = null, root = null, footprint =
97
98
  // The context window elides at its default, like the shared tier: no config key feeds it, so
98
99
  // only `1m` speaks and every default argv stays the bytes it was before the flag existed.
99
100
  if (contextWindow && contextWindow !== DEFAULT_CONTEXT_WINDOW) argv.push('--context-window', contextWindow);
101
+ // The tier routing elides at its default, like the context window: only `auto` speaks, last, so
102
+ // every argv with the routing off stays the bytes it was before the flag existed.
103
+ if (tiers && tiers !== DEFAULT_TIERS) argv.push('--tiers', tiers);
100
104
  return argv;
101
105
  }
102
106
 
@@ -151,14 +155,17 @@ export function installProfile(host, scope, root, notify = null) {
151
155
  // the install. A missing marker reads as armed.
152
156
  const gates = gatesOfDir(root, host);
153
157
  // Kits on stay on (spec A3); one this checkout no longer ships drops with a notice (R2).
154
- const kits = kitsOfDir(root, host, notify);
158
+ // An install built before the superpowers kit existed keeps its five Rites unless the plugin is seen.
159
+ const kits = migrateSuperpowersKit({ host, scope, root, kits: kitsOfDir(root, host, notify), notify, knownKits: [...loadKits().keys()], aware: kitAwareOfDir(root, host) });
155
160
  // A project install's `Shared tier: on` stays on across a rebuild; a global install never has it.
156
161
  const sharedTier = sharedTierOfDir(root, host);
157
162
  // `Context window: 1m` stays 1m: a rebuild that forgot it would shrink the listing cap.
158
163
  const contextWindow = contextWindowOfDir(root, host);
164
+ // `Model tiers: auto` stays auto: a rebuild that forgot it would put every agent back on the parent's model.
165
+ const tiers = tiersOfDir(root, host);
159
166
  const out = scope === 'global' ? null : root;
160
167
  const argv = setupBuildArgs(theme, emit, out, out, footprint, posture, mode, doctrines,
161
- PACK_ORDER, excludeRules, trust, excludeSkills, gates, kits, sharedTier, contextWindow);
168
+ PACK_ORDER, excludeRules, trust, excludeSkills, gates, kits, sharedTier, contextWindow, tiers);
162
169
  // A GLOBAL ROW NAMES ITS OWN DIR. `root` came from the host's config-dir resolver, which
163
170
  // honours env overrides (`OPENCODE_CONFIG_DIR`, `CLAUDE_CONFIG_DIR`…); without the flag the
164
171
  // same argv run from a shell lacking that variable re-emits into the DEFAULT dir — a second
@@ -167,7 +174,7 @@ export function installProfile(host, scope, root, notify = null) {
167
174
  return {
168
175
  host, scope, root, state: installState(root, host, scope),
169
176
  emit, theme, footprint, posture, mode, trust, doctrines, excludeRules, excludeSkills,
170
- kits, sharedTier, contextWindow, ...gates, argv,
177
+ kits, sharedTier, contextWindow, tiers, ...gates, argv,
171
178
  };
172
179
  }
173
180
 
@@ -212,6 +219,7 @@ const GUARDED = [
212
219
  now: (a) => (a.sharedTier === 'on' ? 'on' : 'off'), was: (p) => (p.sharedTier ? 'on' : 'off') },
213
220
  { name: 'context-window', given: 'contextWindow', flag: '--context-window',
214
221
  now: (a) => a.contextWindow ?? DEFAULT_CONTEXT_WINDOW, was: (p) => p.contextWindow },
222
+ { name: 'tiers', given: 'tiers', flag: '--tiers', now: (a) => a.tiers ?? DEFAULT_TIERS, was: (p) => p.tiers },
215
223
  // A switch reads as its flag says. `--no-deletion-gate` given is `deletion-gate: off`;
216
224
  // `--strict-consent` (the one switch whose flag adds asks, so it is not `--no-*`) given is
217
225
  // `strict-consent: on`. Either way the flag given means the switch's key is `false`.
@@ -35,9 +35,9 @@ import { parseJson } from '../lib/json.mjs';
35
35
  import { normcase, comparePaths } from '../lib/paths.mjs';
36
36
  // `js/build/source.mjs` imports nothing but node builtins, so this direction cannot cycle.
37
37
  import {
38
- CREDIT_RE, GATE_SWITCHES, PACK_ORDER, kitMembers, loadKits, readPackText, resolveCredits, resolveRuleIds, ruleCanon, titleKey, upstreamOf,
38
+ CREDIT_RE, GATE_SWITCHES, PACK_ORDER, WORKFLOW_PROVIDER_HEADING, kitMembers, linkTargetOf, loadKits, readPackText, resolveCredits, resolveRuleIds, ruleCanon, titleKey, upstreamOf,
39
39
  } from './source.mjs';
40
- import { CONTEXT_WINDOW_MARKER, DEFAULT_CONTEXT_WINDOW } from './source.mjs';
40
+ import { CONTEXT_WINDOW_MARKER, DEFAULT_CONTEXT_WINDOW, DEFAULT_TIERS, TIERS_MARKER, splitTier } from './source.mjs';
41
41
  import { SHARED_TIER_LINE } from '../hosts/hosts.mjs';
42
42
  import { PROJECT_NOTES_DIR } from '../hosts/spec-feedback.mjs';
43
43
  import { PORTABLE_MACHINE_DIR } from '../lib/machine-dir.mjs';
@@ -251,8 +251,60 @@ function activeKits(cfg) {
251
251
  * carrier re-rendered with prefixed DIR_* tokens (`prefixedAgentText`) must rebuild it too.
252
252
  */
253
253
  export function kitsBody(cfg, theme, lawsPrefix = '') {
254
- return activeKits(cfg).map(([, m]) => `\n${renderFile(cfg, path.join(cfg.src, m.rules), theme,
254
+ const on = activeKits(cfg).map(([, m]) => `\n${renderFile(cfg, path.join(cfg.src, m.rules), theme,
255
255
  'full', lawsPrefix).trim()}\n`).join('');
256
+ // A kit that is OFF but has a plugin to stand in for it leaves a Workflow provider block: the
257
+ // plugin's rank and routing on a host that has it, the missing-provider line on one that has not.
258
+ const off = [...replacements(cfg).keys()].map((k) => {
259
+ const r = kitsOf(cfg).get(k).replacedBy;
260
+ const file = theme.PLUGIN_HOST ? r.provider : r.missing;
261
+ return typeof file === 'string' ? `\n${renderFile(cfg, path.join(cfg.src, file), theme, 'full', lawsPrefix).trim()}\n` : '';
262
+ }).join('');
263
+ return on + off;
264
+ }
265
+
266
+ /**
267
+ * The kits that are off and have `replacedBy`, and what each leaves behind:
268
+ * `Map<kit, Map<skill, plugin skill>>`. Read once per cfg, like the kits themselves.
269
+ */
270
+ const REPLACEMENTS = new WeakMap();
271
+ function replacements(cfg) {
272
+ let out = REPLACEMENTS.get(cfg);
273
+ if (!out) {
274
+ out = new Map();
275
+ for (const [k, m] of kitsOf(cfg)) {
276
+ if ((cfg.kits ?? []).includes(k) || !m.replacedBy) continue;
277
+ out.set(k, new Map(Object.entries(m.replacedBy.skills)));
278
+ }
279
+ REPLACEMENTS.set(cfg, out);
280
+ }
281
+ return out;
282
+ }
283
+
284
+ /** Markdown links, label and target. */
285
+ const MD_LINK_RE = /\[([^\]]+)\]\(([^)\s]+)\)/g;
286
+
287
+ /**
288
+ * The one place a link to a skill of a kit that is OFF is rewritten (spec 3): the label stays, the
289
+ * target becomes the plugin's skill in the host's spelling (`replacedBy.hosts`), or nothing on a
290
+ * host with no plugin. Run on source text before tokens, so `[debug {{SKILL}}](debug.md)` and
291
+ * `({{DIR_SKILLS}}/debug.md)` meet one resolver (`linkTargetOf`). No emitter filters again.
292
+ */
293
+ function rewriteOffKitLinks(cfg, theme, rel, text) {
294
+ const off = replacements(cfg);
295
+ if (!off.size) return text;
296
+ return text.replace(MD_LINK_RE, (whole, label, target) => {
297
+ const hit = linkTargetOf(rel, target);
298
+ if (hit?.kind !== 'skills') return whole;
299
+ for (const [kit, map] of off) {
300
+ if (!map.has(hit.name)) continue;
301
+ const tpl = kitsOf(cfg).get(kit).replacedBy.hosts?.[theme.PLUGIN_HOST];
302
+ if (tpl) return `${label} (\`${tpl.replace('{name}', map.get(hit.name))}\`)`;
303
+ // A host with no plugin names no skill that cannot exist: the step in plain words (`replacedBy.plain`).
304
+ return kitsOf(cfg).get(kit).replacedBy.plain?.[hit.name] ?? label;
305
+ }
306
+ return whole;
307
+ });
256
308
  }
257
309
 
258
310
  /**
@@ -426,6 +478,9 @@ export function renderFile(cfg, filePath, theme, footprint = 'full', lawsPrefix
426
478
  visiting = new Set(), nativeCatalog = false) {
427
479
  const here = path.resolve(filePath);
428
480
  let text = readSource(cfg, here);
481
+ if (replacements(cfg).size && normcase(here).startsWith(normcase(path.resolve(cfg.src)) + path.sep)) {
482
+ text = rewriteOffKitLinks(cfg, theme, path.relative(cfg.src, here).split(path.sep).join('/'), text);
483
+ }
429
484
 
430
485
  text = text.replace(INCLUDE_RE, (_whole, rel) => {
431
486
  const target = path.resolve(cfg.src, rel);
@@ -565,9 +620,12 @@ function dropExcludedRules(text, pack, excluded) {
565
620
  /**
566
621
  * A parenthetical made of rule citations only — `(*A*)`, `(*A*, *B*)` — with the blanks before
567
622
  * it: spaces, and at most one line break, so a citation wrapped onto its own line leaves no
568
- * orphaned punctuation at the start of the next.
623
+ * orphaned punctuation at the start of the next. Between items, any blanks, line breaks
624
+ * included: a source wraps a long list after a comma (Bound the Loop's lean half), and a
625
+ * separator narrower than the doctor's `citationGroupProblems` (`[,\s]`) left that group whole,
626
+ * still citing the excluded rule. A name itself never wraps: it renders from a spaceless token.
569
627
  */
570
- const CITE_GROUP_RE = /([ \t]*(?:\r?\n[ \t]*)?)\((\*[^*()\n]+\*(?:,[ \t]*\*[^*()\n]+\*)*)\)/g;
628
+ const CITE_GROUP_RE = /([ \t]*(?:\r?\n[ \t]*)?)\((\*[^*()\n]+\*(?:,\s*\*[^*()\n]+\*)*)\)/g;
571
629
 
572
630
  /**
573
631
  * Remove the citations of excluded rules from rendered carrier text (owner decision D3,
@@ -643,9 +701,14 @@ function doctrinesBody(cfg, theme, active, footprint, lawsPrefix) {
643
701
  * parity harnesses, which drive this module directly.
644
702
  */
645
703
  export function effectiveTheme(cfg, themeName, {
646
- footprint = 'full', lawsPrefix = '', sharedRoot = null,
704
+ footprint = 'full', lawsPrefix = '', sharedRoot = null, pluginHost = '',
647
705
  } = {}) {
648
706
  const theme = { ...loadTheme(cfg, themeName), ...(cfg.structure ?? STRUCTURE) };
707
+ // The host whose plugin stands in for a kit that is off (`replacedBy.hosts`): '' on a host with
708
+ // none (Bob, OpenClaude, the plain bundle). PLUGIN_PREFIX is how that host spells a plugin skill.
709
+ theme.PLUGIN_HOST = pluginHost;
710
+ theme.PROVIDER_HEADING = WORKFLOW_PROVIDER_HEADING;
711
+ theme.PLUGIN_PREFIX = pluginHost === 'claude' ? 'superpowers:' : '';
649
712
  // Neither notes path takes `lawsPrefix`: the machine one is the tier's, and the project one is
650
713
  // the project root's `notebook/` on every host. Prefixing it once sent OpenClaude's skills to
651
714
  // `notebook/` while its hook wrote `.openclaude/notebook/` (T10).
@@ -709,6 +772,8 @@ export function effectiveTheme(cfg, themeName, {
709
772
  // `--context-window`, under the same contract (`contextWindowOfDir` reads it): a line only off the default.
710
773
  theme.CONTEXT_WINDOW_LINE = cfg.contextWindow && cfg.contextWindow !== DEFAULT_CONTEXT_WINDOW
711
774
  ? `\n${CONTEXT_WINDOW_MARKER}: ${cfg.contextWindow}\n` : '';
775
+ // `--tiers`, under the same contract (`tiersOfDir` reads it): a line only off the default.
776
+ theme.TIERS_LINE = cfg.tiers && cfg.tiers !== DEFAULT_TIERS ? `\n${TIERS_MARKER}: ${cfg.tiers}\n` : '';
712
777
  // The gate switches (`GATE_SWITCHES`: Laws I, III, IV), under the same contract: a line is
713
778
  // written only when its gate is OFF, so a default build stays byte-identical and a missing
714
779
  // line reads back as armed (`gatesOfDir`). The OpenCode plugins read these lines at load, so
@@ -766,12 +831,12 @@ export function destRel(rel) {
766
831
  * @param {any} cfg
767
832
  * @param {string} themeName
768
833
  * `sharedRoot` is the tier's root on a global emit (`sharedRootFor`): see `pathTokens`.
769
- * @param {{ footprint?: string, lawsPrefix?: string, sharedRoot?: string | null, nativeCatalog?: boolean | { skills?: boolean, agents?: boolean } }} [opts]
834
+ * @param {{ footprint?: string, lawsPrefix?: string, sharedRoot?: string | null, pluginHost?: string, nativeCatalog?: boolean | { skills?: boolean, agents?: boolean } }} [opts]
770
835
  */
771
836
  export function renderAll(cfg, themeName, {
772
- footprint = 'full', lawsPrefix = '', nativeCatalog = false, sharedRoot = null,
837
+ footprint = 'full', lawsPrefix = '', nativeCatalog = false, sharedRoot = null, pluginHost = '',
773
838
  } = {}) {
774
- const theme = effectiveTheme(cfg, themeName, { footprint, lawsPrefix, sharedRoot });
839
+ const theme = effectiveTheme(cfg, themeName, { footprint, lawsPrefix, sharedRoot, pluginHost });
775
840
  const items = [];
776
841
  const skipped = new Set(cfg.excludeSkills ?? []);
777
842
  // Members of every kit `--kits` did not name: kit logic, not `excludeSkills`, so no marker.
@@ -798,7 +863,13 @@ export function renderAll(cfg, themeName, {
798
863
  // bundle; here, once, so no writer applies it twice.
799
864
  if (text !== null && sp[0] === 'skills' && sp.length === 3 && sp[2] === 'SKILL.md'
800
865
  && VENDORED_SKILL_DIRS.has(sp[1])) text = vendoredWithCatalogueLine(text, sp[1], cfg.src);
801
- items.push({ rel: outRel, text, src: file });
866
+ // An agent's tier line is read here and stripped, so no host's output carries it
867
+ // (`splitTier`); the emit reads the tier off the item.
868
+ let tier;
869
+ if (text !== null && sp[0] === 'agents' && sp.length === 2 && sp[1].endsWith('.md')) {
870
+ ({ text, tier } = splitTier(text));
871
+ }
872
+ items.push(tier === undefined ? { rel: outRel, text, src: file } : { rel: outRel, text, src: file, tier });
802
873
  // A credited skill ships its upstream's licence beside it, one copy per (skill, key). The
803
874
  // token is gone from `text`, so the raw source is scanned; an unknown key or a null
804
875
  // licenseFile yields no copy. A vendored folder's VENDOR.md carries a credit too, but the
@@ -301,6 +301,13 @@ export function resolveCredits(text, src = SRC) {
301
301
  });
302
302
  }
303
303
 
304
+ /**
305
+ * The heading of the Workflow provider block a kit that is off leaves in the carrier (`kits/superpowers/provider.md`
306
+ * and `missing.md` write it through `{{PROVIDER_HEADING}}`). `kitAwareOfDir` matches it: one writer, so a rename
307
+ * cannot turn every post-kit install into a pre-kit one.
308
+ */
309
+ export const WORKFLOW_PROVIDER_HEADING = '### Workflow provider';
310
+
304
311
  /**
305
312
  * `src/kits/<kit>.json`, parsed, as `Map<kit, manifest>` in sorted kit order. A manifest is
306
313
  * `{ description, skills, agents, rules, rulesWordBudget, catalogue, banned? }`, the sole writer of its
@@ -323,10 +330,39 @@ export function loadKits(src = SRC) {
323
330
  if (m.banned !== undefined && !(Array.isArray(m.banned) && m.banned.every((b) => typeof b === 'string' && b))) {
324
331
  throw new Error(`src/kits/${n}: 'banned' must be an array of non-empty strings`);
325
332
  }
333
+ // `replacedBy` names the plugin that stands in for the kit when it is off (the superpowers
334
+ // kit): only its shape is read here; `kitProblems` holds its content (mapping, upstream key).
335
+ const r = m.replacedBy;
336
+ if (r !== undefined && !(r !== null && typeof r === 'object' && !Array.isArray(r)
337
+ && typeof r.upstream === 'string' && r.hosts !== null && typeof r.hosts === 'object'
338
+ && r.skills !== null && typeof r.skills === 'object')) {
339
+ throw new Error(`src/kits/${n}: 'replacedBy' must be { upstream, hosts, skills } objects`);
340
+ }
326
341
  return [n.slice(0, -'.json'.length), m];
327
342
  }));
328
343
  }
329
344
 
345
+ /**
346
+ * Where a markdown link target points inside `src`, as `{ kind: 'skills' | 'agents', name }`, or
347
+ * null (an URL, an anchor, a path outside the two folders, a link to the file's own skill). `rel`
348
+ * is the linking file's path under `src`, posix. The `{{DIR_SKILLS}}` / `{{DIR_AGENTS}}` tokens
349
+ * read as the folders they name, so one resolver serves the scan (`specLinks`) and the kit-off
350
+ * rewrite in `js/build/render.mjs`: the two cannot disagree about what a link points at.
351
+ */
352
+ export function linkTargetOf(rel, target) {
353
+ const t = target.split('#')[0].replace(/\{\{DIR_SKILLS\}\}/g, 'skills').replace(/\{\{DIR_AGENTS\}\}/g, 'agents');
354
+ if (!t || /^[a-z][a-z0-9+.-]*:/i.test(t) || t.startsWith('/')) return null;
355
+ // A target that LEADS with the folder token names the folder from the source root, whichever folder the
356
+ // linking file sits in (`laws/`, `doctrines/`, the template); a relative one, `../{{DIR_AGENTS}}/x.md`, is
357
+ // resolved from the file.
358
+ const anchored = /^\{\{DIR_(SKILLS|AGENTS)\}\}\//.test(target);
359
+ const hit = /^(skills|agents)\/([a-z0-9-]+)(?:\.md|\/.*)?$/.exec(path.posix.normalize(anchored ? t : path.posix.join(path.posix.dirname(rel), t)));
360
+ if (!hit) return null;
361
+ const own = rel.split('/');
362
+ if (own[0] === hit[1] && own[1] && own[1].replace(/\.md$/, '') === hit[2]) return null;
363
+ return { kind: hit[1], name: hit[2] };
364
+ }
365
+
330
366
  /** Every skill and agent the kits handed in claim (a `loadKits` Map, or a subset of one). */
331
367
  export function kitMembers(kits) {
332
368
  const skills = new Set();
@@ -511,6 +547,17 @@ export function specLinks(src = SRC) {
511
547
  const kind = m[1].toLowerCase();
512
548
  links.push({ rel: sp.join('/'), kind, name: m[2], kit: ofKit(sp), owner: owners[kind].get(m[2]) ?? null });
513
549
  }
550
+ // F1: a relative link (`(debug.md)`, `(../{{DIR_AGENTS}}/x.md)`) ships as dead as a token one
551
+ // when its target is left out. The token forms above are counted already, so a target
552
+ // spelled with one is skipped here. A brick's `skill:` is NOT a link: bricks never ship, and
553
+ // `availability` (js/loop/catalog.mjs) already turns a missing skill into an unavailable
554
+ // brick, which is why the minimal profile may exclude `bruno` and `factory`.
555
+ const add = (hit) => {
556
+ if (hit) links.push({ rel: sp.join('/'), ...hit, kit: ofKit(sp), owner: owners[hit.kind].get(hit.name) ?? null });
557
+ };
558
+ for (const m of text.matchAll(/\]\(([^)\s]+)\)/g)) {
559
+ if (!m[1].includes('{{DIR_')) add(linkTargetOf(sp.join('/'), m[1]));
560
+ }
514
561
  }
515
562
  }
516
563
  };
@@ -528,6 +575,31 @@ export function specLinks(src = SRC) {
528
575
  * its target (`resolveSkillNames`); the doctor keeps the namespace clean (`aliasProblems`).
529
576
  */
530
577
  export const ALIASES_RE = /^<!--[ \t]*aliases:[ \t]*(.+?)[ \t]*-->[ \t]*\r?$/m;
578
+
579
+ /**
580
+ * `--tiers auto|off`: the sub-agent model tiers (spec `2026-11-17-subagent-model-tiers.md`).
581
+ * An agent source names its tier on a line of its own, `<!-- tier: strong|light -->`; no marker
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`).
584
+ *
585
+ * THE LINE IS STRIPPED FROM EVERY OUTPUT, WHOLE (`splitTier`): it sits directly above
586
+ * `## When to dispatch`, so removing the line leaves the text a build rendered before the marker
587
+ * existed, byte for byte. Anchored to a whole line, so a spec that merely QUOTES the syntax in
588
+ * prose or a code span declares nothing.
589
+ */
590
+ export const TIER_MARKER_RE = /^[ \t]*<!--[ \t]*tier:[ \t]*(strong|light)[ \t]*-->[ \t]*\r?\n/m;
591
+ /** The tiers a marker may name; an unmarked agent is `standard`. */
592
+ export const MARKED_TIERS = Object.freeze(['strong', 'light']);
593
+ export const TIERS_CHOICES = Object.freeze(['auto', 'off']);
594
+ export const DEFAULT_TIERS = 'off';
595
+ /** The carrier marker, written only when the value is not the default (the kits line's contract). */
596
+ export const TIERS_MARKER = 'Model tiers';
597
+ /** `{ text, tier }`: the spec without its tier line, and the tier it named (`standard` when none). */
598
+ export function splitTier(text) {
599
+ const m = TIER_MARKER_RE.exec(text);
600
+ return m ? { text: text.slice(0, m.index) + text.slice(m.index + m[0].length), tier: m[1] }
601
+ : { text, tier: 'standard' };
602
+ }
531
603
  export function aliasesOf(text) {
532
604
  const m = ALIASES_RE.exec(text);
533
605
  return m ? m[1].split(',').map((s) => s.trim()).filter(Boolean) : [];
@@ -696,7 +768,7 @@ export const CONTEXT_WINDOW_MARKER = 'Context window';
696
768
  export function makeCfg({
697
769
  posture = 'peer', mode = 'direct', trust = DEFAULT_PRESET, doctrines = PACK_ORDER,
698
770
  excludeRules = [], excludeSkills = [], kits = [], sharedTier = /** @type {boolean | string} */ (false),
699
- contextWindow = DEFAULT_CONTEXT_WINDOW, pruneGates = false, force = false, ...switches
771
+ contextWindow = DEFAULT_CONTEXT_WINDOW, tiers = DEFAULT_TIERS, pruneGates = false, force = false, ...switches
700
772
  } = {}) {
701
773
  return {
702
774
  root: ROOT,
@@ -730,6 +802,8 @@ export function makeCfg({
730
802
  sharedTier: sharedTier === true || sharedTier === 'on',
731
803
  // The context window the install is built for (`CONTEXT_WINDOWS`); anything unknown is the default.
732
804
  contextWindow: Object.hasOwn(CONTEXT_WINDOWS, contextWindow) ? contextWindow : DEFAULT_CONTEXT_WINDOW,
805
+ // `--tiers auto|off`: only a literal `auto` turns the tier routing on; anything else is off.
806
+ tiers: tiers === 'auto' ? 'auto' : DEFAULT_TIERS,
733
807
  // `--force`, for this one build: only a literal `true` forces. Never an axis of the install.
734
808
  force: force === true,
735
809
  // The gate switches (`GATE_SWITCHES`: `secretsGate`, `doneGate`, `deletionGate`), each armed
package/js/cli-table.json CHANGED
@@ -250,6 +250,21 @@
250
250
  "type": null,
251
251
  "hidden": false
252
252
  },
253
+ {
254
+ "names": [
255
+ "--tiers"
256
+ ],
257
+ "dest": "tiers",
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",
260
+ "choices": null,
261
+ "default": null,
262
+ "required": false,
263
+ "nargs": null,
264
+ "is_flag": false,
265
+ "type": null,
266
+ "hidden": false
267
+ },
253
268
  {
254
269
  "names": [
255
270
  "--out"
@@ -633,7 +648,7 @@
633
648
  {
634
649
  "name": "doctor",
635
650
  "help": "validate the build (the installed theme; --all sweeps every theme, slowly)",
636
- "description": "validate the build: unresolved tokens, dead links, non-hermetic escapes, theme-key parity, and that a committed bundle matches src. Defaults to the INSTALLED theme (--theme NAME for one, --all to sweep every theme). --all renders every theme through every emit, so it takes minutes rather than seconds; it prints one progress line per theme on stderr.",
651
+ "description": "validate the build: unresolved tokens, dead links, non-hermetic escapes, theme-key parity, and that a committed bundle matches src. Defaults to the INSTALLED theme (--theme NAME for one, --all to sweep every theme). --all renders every theme through every emit, so it takes minutes rather than seconds; it prints one progress line per theme on stderr. It also prints a [note] WARN per install when the superpowers kit and the official superpowers plugin are both on, or both off (read from settings files, never from a process).",
637
652
  "positionals": [],
638
653
  "options": [
639
654
  {
@@ -1949,7 +1964,7 @@
1949
1964
  {
1950
1965
  "name": "status",
1951
1966
  "help": "print the install dashboard (theme, installs, memory, version, gates)",
1952
- "description": "print the install dashboard: theme, every install with its settings, components, memory, version, and the state of the tool-boundary gates. --json prints the same payload for a script. Off a terminal the rows are plain, with no box.",
1967
+ "description": "print the install dashboard: theme, every install with its settings, components, memory, version, and the state of the tool-boundary gates. --json prints the same payload for a script. Off a terminal the rows are plain, with no box. An install with the superpowers kit and the plugin both on, or both off, gets a WARN row.",
1953
1968
  "positionals": [],
1954
1969
  "options": [
1955
1970
  {
@@ -35,8 +35,8 @@ import { existsSync, readdirSync } from 'node:fs';
35
35
  import path from 'node:path';
36
36
 
37
37
  import {
38
- CONFIG, CONTEXT_WINDOWS, CONTEXT_WINDOW_MARKER, DEFAULT_CONTEXT_WINDOW, GATE_SWITCHES, PACK_ORDER,
39
- RETIRED_KIT_IDS, THEMES, discoverNames, loadKits, resolveSkillNames,
38
+ CONFIG, CONTEXT_WINDOWS, CONTEXT_WINDOW_MARKER, DEFAULT_CONTEXT_WINDOW, DEFAULT_TIERS, GATE_SWITCHES, PACK_ORDER,
39
+ RETIRED_KIT_IDS, TIERS_CHOICES, TIERS_MARKER, THEMES, WORKFLOW_PROVIDER_HEADING, discoverNames, linkedSkillIds, loadKits, resolveSkillNames,
40
40
  } from '../build/source.mjs';
41
41
  import {
42
42
  CARRIERS, CLAUDE_STYLE, DISABLED_STASH, GLOBAL_MANIFEST, HOSTS, SHARED_TIER_RE, carriersFor, gateCarrierText, isHostGlobalDir,
@@ -448,7 +448,13 @@ export function excludedSkillsOfDir(d, host = null, notify = null) {
448
448
  const { ids, notices, unknown } = resolveSkillNames(m[1].split(',').map((s) => s.trim()).filter(Boolean));
449
449
  if (unknown.length) return [];
450
450
  if (notify) for (const n of notices) notify(n);
451
- return ids;
451
+ // A skill some spec LINKS to became protected after the install was made (F1: relative links
452
+ // count): the flag would refuse the name and break every replay, and re-admitting a skill is
453
+ // the safe direction, so the exclusion is dropped with a notice, as an alias to a linked skill is.
454
+ const linked = ids.length ? linkedSkillIds() : [];
455
+ const kept = ids.filter((n) => !linked.includes(n));
456
+ if (notify) for (const n of ids.filter((x) => linked.includes(x))) notify(`'${n}' is linked to by another skill and cannot be excluded — exclusion dropped`);
457
+ return kept;
452
458
  }, [], host);
453
459
  }
454
460
 
@@ -480,6 +486,26 @@ export function kitsOfDir(d, host = null, notify = null) {
480
486
  }
481
487
 
482
488
 
489
+ /**
490
+ * Was this install built by a Geneseed that knows the `superpowers` kit? Read off the carrier: such
491
+ * a build writes either `Active kits: ... superpowers` or, with the kit off, the Workflow provider
492
+ * block (`WORKFLOW_PROVIDER_HEADING`). An older build writes neither. The migration of an install made
493
+ * before the kit (`js/maintain/kit-migration.mjs`) reads this beside the release the marker records,
494
+ * because a build made after the kit but before its release carries the old release number.
495
+ * `null` when there is no Geneseed carrier to read: nothing is installed there to migrate.
496
+ */
497
+ export function kitAwareOfDir(d, host = null) {
498
+ return firstCarrier(d, (carrierPath) => {
499
+ const text = readMaybe(carrierPath);
500
+ if (text === null) return undefined;
501
+ // A carrier with no `Active packs:` line is not one Geneseed rendered (a file the user wrote
502
+ // and the emit kept): there is nothing in it to migrate, so it reads like no carrier at all.
503
+ if (!/^Active packs:/m.test(text)) return undefined;
504
+ const line = KITS_RE.exec(text);
505
+ return new RegExp(`^${WORKFLOW_PROVIDER_HEADING}\\r?$`, 'm').test(text) || (line !== null && /(^|[ ,])superpowers\b/.test(line[1]));
506
+ }, null, host);
507
+ }
508
+
483
509
  /**
484
510
  * Whether a DEPLOYED install reads the shared tier (`--shared-tier on`), read back so `rebuild-all`,
485
511
  * `upgrade`, `diff`, the wizard and the console re-render it. A missing line is `false`: the default
@@ -512,6 +538,25 @@ export function contextWindowOfDir(d, host = null) {
512
538
  }, DEFAULT_CONTEXT_WINDOW, host);
513
539
  }
514
540
 
541
+ const TIERS_RE = new RegExp(`^${TIERS_MARKER}:[ \\t]*(\\S+?)[ \\t]*\\r?$`, 'm');
542
+
543
+ /**
544
+ * The sub-agent tier routing a DEPLOYED install was built with (`--tiers`), read back so
545
+ * `rebuild-all`, `upgrade`, `diff` and the guard re-render it. A missing line is the default
546
+ * (`off`): the marker is only ever written off it, so an install older than the option is a
547
+ * default install. A value this checkout does not know reads as the default too, so a
548
+ * hand-edited line can never reach `--tiers` and refuse a rebuild.
549
+ */
550
+ export function tiersOfDir(d, host = null) {
551
+ return firstCarrier(d, (carrierPath) => {
552
+ const text = readMaybe(carrierPath);
553
+ if (text === null) return undefined;
554
+ const m = TIERS_RE.exec(text);
555
+ if (!m) return undefined;
556
+ return TIERS_CHOICES.includes(m[1]) ? m[1] : DEFAULT_TIERS;
557
+ }, DEFAULT_TIERS, host);
558
+ }
559
+
515
560
  /**
516
561
  * Whether a DEPLOYED install keeps one law's hook gate armed — `true` (armed) or `false` (its
517
562
  * `<marker>: off` line, written by a build with that gate's `--no-*-gate` flag; `GATE_SWITCHES`).
@@ -853,7 +898,7 @@ export function installedDefaults() {
853
898
  const found = {
854
899
  theme: null, posture: null, mode: null, emit: null, footprint: null, doctrines: null,
855
900
  excludeRules: null, excludeSkills: null, kits: null, sharedTier: false,
856
- contextWindow: DEFAULT_CONTEXT_WINDOW,
901
+ contextWindow: DEFAULT_CONTEXT_WINDOW, tiers: DEFAULT_TIERS,
857
902
  };
858
903
  const candidates = [];
859
904
  for (const { host, configDir } of HOSTS) {
@@ -906,6 +951,7 @@ export function installedDefaults() {
906
951
  // Two states too: the default and no line read the same, so the first install that says
907
952
  // otherwise speaks.
908
953
  if (found.contextWindow === DEFAULT_CONTEXT_WINDOW) found.contextWindow = contextWindowOfDir(base);
954
+ if (found.tiers === DEFAULT_TIERS) found.tiers = tiersOfDir(base);
909
955
  }
910
956
  return found;
911
957
  }