geneseed 5.5.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +27 -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 +8 -0
  6. package/docs/concepts/enforcement-table.md +1 -1
  7. package/docs/concepts/exclusions.md +1 -1
  8. package/docs/concepts/foreman-mode.md +5 -3
  9. package/docs/concepts/hooks.md +1 -1
  10. package/docs/concepts/kits.md +20 -2
  11. package/docs/concepts/loops.md +5 -0
  12. package/docs/concepts/skills.md +1 -1
  13. package/docs/concepts/superpowers-kit.md +79 -0
  14. package/docs/extending.md +11 -4
  15. package/docs/guides/install-scripted.md +1 -1
  16. package/docs/reference/cli.md +2 -0
  17. package/docs/reference/profiles.md +10 -5
  18. package/harness.config.json +1 -1
  19. package/js/README.md +2 -0
  20. package/js/build/args.mjs +4 -2
  21. package/js/build/driver.mjs +8 -8
  22. package/js/build/emit-claude.mjs +5 -3
  23. package/js/build/emit-opencode.mjs +2 -2
  24. package/js/build/generate.mjs +1 -1
  25. package/js/build/profile.mjs +15 -7
  26. package/js/build/render.mjs +81 -10
  27. package/js/build/source.mjs +75 -1
  28. package/js/cli-table.json +17 -2
  29. package/js/hosts/hooks.mjs +16 -5
  30. package/js/hosts/installs.mjs +50 -4
  31. package/js/hosts/native.mjs +104 -3
  32. package/js/hosts/opencode.mjs +13 -15
  33. package/js/inspect/checks-authoring.mjs +24 -1
  34. package/js/inspect/checks-build.mjs +43 -2
  35. package/js/inspect/checks-counts.mjs +72 -1
  36. package/js/inspect/diff.mjs +17 -3
  37. package/js/inspect/doctor.mjs +23 -2
  38. package/js/inspect/status.mjs +5 -1
  39. package/js/inspect/validate.mjs +1 -1
  40. package/js/loop/catalog.mjs +10 -0
  41. package/js/maintain/kit-migration.mjs +109 -0
  42. package/js/maintain/plugin-detect.mjs +150 -0
  43. package/js/maintain/profiles.mjs +46 -5
  44. package/js/maintain/setup.mjs +45 -11
  45. package/js/maintain/update.mjs +1 -1
  46. package/js/web/actions.mjs +28 -7
  47. package/js/web/api.mjs +3 -1
  48. package/js/web/profiles-api.mjs +11 -7
  49. package/package.json +1 -1
  50. package/profiles/autonomous.json +1 -0
  51. package/profiles/corporate.json +1 -1
  52. package/profiles/mentor.json +1 -0
  53. package/profiles/minimal.json +2 -1
  54. package/profiles/starter.json +1 -1
  55. package/src/AGENT.md.tmpl +1 -6
  56. package/src/agents/_template.md +4 -0
  57. package/src/agents/advocate.md +1 -0
  58. package/src/agents/architect.md +1 -0
  59. package/src/agents/developer.md +12 -4
  60. package/src/agents/empiricist.md +1 -0
  61. package/src/agents/explorer.md +1 -0
  62. package/src/agents/framer.md +1 -0
  63. package/src/agents/historian.md +1 -0
  64. package/src/agents/operator.md +1 -0
  65. package/src/agents/performance.md +2 -1
  66. package/src/agents/pragmatist.md +1 -0
  67. package/src/agents/react-reviewer.md +1 -0
  68. package/src/agents/researcher.md +1 -0
  69. package/src/agents/reviewer.md +1 -0
  70. package/src/agents/security.md +1 -0
  71. package/src/agents/skeptic.md +1 -0
  72. package/src/agents/spring-reviewer.md +1 -0
  73. package/src/agents/spring-security.md +1 -0
  74. package/src/agents/steward.md +1 -0
  75. package/src/agents/user-advocate.md +1 -0
  76. package/src/agents/visionary.md +1 -0
  77. package/src/bricks/ci-fix.md +12 -2
  78. package/src/kits/superpowers/missing.md +3 -0
  79. package/src/kits/superpowers/provider.md +7 -0
  80. package/src/kits/superpowers/rules.md +6 -0
  81. package/src/kits/superpowers.json +45 -0
  82. package/src/modes/foreman.md +18 -12
  83. package/src/skills/commit.md +4 -0
  84. package/src/skills/parallel-agents.md +2 -2
  85. package/src/skills/spring-boot/cloud.md +8 -2
  86. package/src/skills/spring-boot.md +3 -1
  87. package/src/skills/spring-testing.md +3 -3
  88. package/src/upstreams.json +1 -1
@@ -724,13 +724,13 @@ const PROJECT_EMITS = {
724
724
  * carry straight past the parameter default.
725
725
  */
726
726
  function axesCfg({
727
- posture, mode, trust, doctrines, excludeRules, excludeSkills, kits, sharedTier, contextWindow, ...gates
727
+ posture, mode, trust, doctrines, excludeRules, excludeSkills, kits, sharedTier, contextWindow, tiers, ...gates
728
728
  }) {
729
729
  return makeCfg({
730
730
  ...(posture ? { posture } : {}), ...(mode ? { mode } : {}), ...(trust ? { trust } : {}),
731
731
  ...(doctrines ? { doctrines } : {}), ...(excludeRules ? { excludeRules } : {}),
732
732
  ...(excludeSkills ? { excludeSkills } : {}), ...(kits ? { kits } : {}), ...(sharedTier ? { sharedTier } : {}),
733
- ...(contextWindow ? { contextWindow } : {}),
733
+ ...(contextWindow ? { contextWindow } : {}), ...(tiers ? { tiers } : {}),
734
734
  // The gate switches (`GATE_SWITCHES` keys): only an explicit `false` disarms; `null` (no
735
735
  // opinion) keeps the gate.
736
736
  ...Object.fromEntries(GATE_SWITCHES.filter((g) => gates[g.key] === false).map((g) => [g.arg, true])),
@@ -739,7 +739,7 @@ function axesCfg({
739
739
 
740
740
  export function emitProjectInto(host, {
741
741
  theme, out, root, footprint = 'full', posture = null, mode = null, trust = null,
742
- doctrines = null, excludeRules = null, excludeSkills = null, kits = null, sharedTier = false, contextWindow = null, seed = true, ...gates
742
+ doctrines = null, excludeRules = null, excludeSkills = null, kits = null, sharedTier = false, contextWindow = null, tiers = null, seed = true, ...gates
743
743
  }) {
744
744
  const emit = PROJECT_EMITS[host];
745
745
  // The axes ride the same rail into every `*Into`, and for the same reason: a drift reader
@@ -750,7 +750,7 @@ export function emitProjectInto(host, {
750
750
  // the git root, which for a temp dir inside a repo is that repo, outside the sandbox.
751
751
  return withPlatformNewlines(() => emit(
752
752
  axesCfg({
753
- posture, mode, trust, doctrines, excludeRules, excludeSkills, kits, sharedTier, contextWindow, ...gates }),
753
+ posture, mode, trust, doctrines, excludeRules, excludeSkills, kits, sharedTier, contextWindow, tiers, ...gates }),
754
754
  { theme, footprint, root, seed }, out,
755
755
  ));
756
756
  }
@@ -765,16 +765,16 @@ export function emitProjectInto(host, {
765
765
  */
766
766
  export function buildInto({
767
767
  theme, out, footprint = 'lean', posture = null, mode = null, trust = null, doctrines = null,
768
- excludeRules = null, excludeSkills = null, kits = null, sharedTier = false, contextWindow = null, ...gates
768
+ excludeRules = null, excludeSkills = null, kits = null, sharedTier = false, contextWindow = null, tiers = null, ...gates
769
769
  }) {
770
770
  return withPlatformNewlines(() => build(axesCfg({
771
- posture, mode, trust, doctrines, excludeRules, excludeSkills, kits, sharedTier, contextWindow, ...gates }),
771
+ posture, mode, trust, doctrines, excludeRules, excludeSkills, kits, sharedTier, contextWindow, tiers, ...gates }),
772
772
  theme, out, { footprint, nativeCatalog: false }));
773
773
  }
774
774
 
775
775
  export function emitGlobalInto(host, {
776
776
  theme, out, cfgDir, footprint, posture = null, mode = null, doctrines = null, trust = null,
777
- excludeRules = null, excludeSkills = null, kits = null, sharedTier = false, contextWindow = null,
777
+ excludeRules = null, excludeSkills = null, kits = null, sharedTier = false, contextWindow = null, tiers = null,
778
778
  sharedRoot = undefined, ...gates
779
779
  }) {
780
780
  // `build.HOSTS.get(host, build.HOSTS["opencode"])` — an unknown host falls back rather than
@@ -792,7 +792,7 @@ export function emitGlobalInto(host, {
792
792
  // the same scar the footprint left in `diffCollect`, one axis over each time.
793
793
  return withPlatformNewlines(() => emit(
794
794
  axesCfg({
795
- posture, mode, trust, doctrines, excludeRules, excludeSkills, kits, sharedTier, contextWindow, ...gates }),
795
+ posture, mode, trust, doctrines, excludeRules, excludeSkills, kits, sharedTier, contextWindow, tiers, ...gates }),
796
796
  { theme, footprint, root: null, cfgDir, sharedRoot }, out,
797
797
  ));
798
798
  }
@@ -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
  {
@@ -136,6 +136,14 @@ const ARG_RE = '[\\w./:@^~=+,-]+';
136
136
  const SEG_ADD_RE = new RegExp(`^git\\s+add(\\s+${ARG_RE})*$`);
137
137
  const SEG_COMMIT_RE = new RegExp(`^git\\s+commit(\\s+-q)?\\s+(-F\\s+|--file[=\\s])${ARG_RE}(\\s+-q)?$`);
138
138
  const SEG_READONLY_RE = new RegExp(`^git\\s+(status|diff|log|rev-parse|show)(\\s+${ARG_RE})*$`);
139
+ // A fetch writes only remote-tracking refs, FETCH_HEAD and tags git will not clobber, never a
140
+ // local branch, as long as no refspec names a destination (`a:b`, `+a:b`) and no option names a
141
+ // program (`--upload-pack=<cmd>` runs one). So: a few flags that take no value, then at most one
142
+ // remote and its branches, each a plain name whose first character is alphanumeric (no `:`, no
143
+ // `+`, no flag, no `.` or path for the remote). Added for the own-branch and worker passes
144
+ // (2026-11-17): `git fetch origin && git merge origin/main && git commit …` is how a branch
145
+ // catches up with its base, and the fetch alone made the whole chain ask.
146
+ const SEG_FETCH_RE = /^git\s+fetch(?:\s+(?:--prune|-p|--tags|-t|--no-tags|--all|--quiet|-q))*(?:\s+[A-Za-z0-9][A-Za-z0-9._-]*(?:\s+[A-Za-z0-9][\w./-]*)*)?$/;
139
147
 
140
148
  /**
141
149
  * `git push`, exactly: `[-u|--set-upstream] <remote> HEAD:<branch>` or
@@ -209,8 +217,9 @@ const SHARED_BRANCH_RE = /^(?:main|master|develop|development|(?:release|hotfix)
209
217
  * sets on tool events inside a subagent or in-process teammate). A session that merely runs in
210
218
  * a worktree, as the desktop app's do, has none and asks. A host that sends none asks always.
211
219
  * - The command: none of `UNSAFE_CHARS_RE` or `SUBSHELL_CHARS_RE`, no `push` word anywhere (a mixed
212
- * command asks), every segment an add, a read-only look, or `SEG_LOCAL_RE`, after at most one
213
- * leading `cd <path>` (an agent's shell starts in the parent's checkout). The `cd` target and
220
+ * command asks), every segment an add, a read-only look, a fetch (`SEG_FETCH_RE`) or
221
+ * `SEG_LOCAL_RE`, after at most one leading `cd <path>` (an agent's shell starts in the
222
+ * parent's checkout). The `cd` target and
214
223
  * `cwd` are resolved with `realpathSync`, git's physical path; `cd -`, `~` or a path that does
215
224
  * not resolve asks.
216
225
  * - The tree: `cwd` a linked worktree (`mainWorktreeOf`, read off disk, no spawn), its branch
@@ -232,7 +241,7 @@ export function worktreeExempt(command, cwd, agentId) {
232
241
  segments.shift();
233
242
  }
234
243
  if (!segments.length || !segments.every((seg) => SEG_ADD_RE.test(seg) || SEG_READONLY_RE.test(seg)
235
- || SEG_LOCAL_RE.test(seg))) return false;
244
+ || SEG_FETCH_RE.test(seg) || SEG_LOCAL_RE.test(seg))) return false;
236
245
  const main = mainWorktreeOf(dir);
237
246
  const branch = main && currentBranch(dir);
238
247
  if (!branch || branch.includes('..') || SHARED_BRANCH_RE.test(branch)) return false;
@@ -339,7 +348,8 @@ function maskMessages(command, shell) {
339
348
  * - No `agentId`: a sub-agent never pushes, and its local commits are `worktreeExempt`'s to judge.
340
349
  * - The command, with its messages masked (`maskMessages`): none of `UNSAFE_CHARS_RE` or
341
350
  * `SUBSHELL_CHARS_RE`; every segment an add, a
342
- * read-only look, a plain commit or merge (`SEG_LOCAL_RE`, or the loop's `-F` commit), or a
351
+ * read-only look, a fetch (`SEG_FETCH_RE`), a plain commit or merge (`SEG_LOCAL_RE`, or the
352
+ * loop's `-F` commit), or a
343
353
  * plain push (`SEG_PUSH_RE`) of THIS branch, spelled `<branch>`, `HEAD:<branch>` or
344
354
  * `HEAD:refs/heads/<branch>`; after at most one leading `cd <path>`. Bare `git push` asks:
345
355
  * `push.default` and the global config decide where it goes, and this read cannot see them.
@@ -384,7 +394,8 @@ export function ownBranchExempt(command, cwd, agentId, shell = null) {
384
394
  const taken = [...protectedBranches(root), main && currentBranch(main)].filter(Boolean);
385
395
  if (taken.some((b) => b.toLowerCase() === branch.toLowerCase())) return false;
386
396
  return segments.every((seg) => {
387
- if (SEG_ADD_RE.test(seg) || SEG_READONLY_RE.test(seg) || SEG_LOCAL_RE.test(seg) || SEG_COMMIT_RE.test(seg)) return true;
397
+ if (SEG_ADD_RE.test(seg) || SEG_READONLY_RE.test(seg) || SEG_FETCH_RE.test(seg) || SEG_LOCAL_RE.test(seg)
398
+ || SEG_COMMIT_RE.test(seg)) return true;
388
399
  const push = SEG_PUSH_RE.exec(seg);
389
400
  if (!push) return false;
390
401
  const ref = push[2];