geneseed 5.3.0 → 5.4.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 (198) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +23 -20
  3. package/SHIPPED.md +7 -7
  4. package/adapters/bob/README.md +31 -18
  5. package/adapters/claude-code/README.md +27 -22
  6. package/adapters/openclaude/README.md +18 -8
  7. package/adapters/opencode/HOW-OPENCODE-LOADS.md +8 -3
  8. package/adapters/opencode/README.md +3 -2
  9. package/adapters/opencode/plugins/geneseed-activity.js +20 -21
  10. package/adapters/opencode/plugins/geneseed-context.js +175 -62
  11. package/adapters/opencode/plugins/geneseed-guard.js +419 -205
  12. package/adapters/opencode/plugins/geneseed-workflow.js +3 -2
  13. package/adapters/opencode/workflows/_runtime.js +3 -2
  14. package/bin/geneseed-cli.mjs +7 -0
  15. package/bin/geneseed-hook.mjs +59 -11
  16. package/docs/PRD.md +1 -1
  17. package/docs/README.md +1 -0
  18. package/docs/concepts/agents.md +1 -1
  19. package/docs/concepts/collaboration.md +2 -2
  20. package/docs/concepts/enforcement-table.md +5 -2
  21. package/docs/concepts/exclusions.md +18 -4
  22. package/docs/concepts/footprint.md +11 -1
  23. package/docs/concepts/foreman-mode.md +1 -1
  24. package/docs/concepts/hook-gates.md +5 -5
  25. package/docs/concepts/hooks.md +4 -3
  26. package/docs/concepts/host-matrix.md +24 -6
  27. package/docs/concepts/kits.md +12 -2
  28. package/docs/concepts/loop-bricks.md +3 -3
  29. package/docs/concepts/loops.md +6 -4
  30. package/docs/concepts/ownership.md +1 -1
  31. package/docs/concepts/rules.md +2 -2
  32. package/docs/concepts/skills.md +1 -1
  33. package/docs/design-history.md +8 -0
  34. package/docs/extending.md +112 -35
  35. package/docs/guides/auto-merge.md +100 -0
  36. package/docs/guides/choose-your-setup.md +1 -1
  37. package/docs/guides/headless.md +1 -1
  38. package/docs/guides/install-bob.md +2 -2
  39. package/docs/guides/install-clone.md +1 -1
  40. package/docs/guides/install-openclaude.md +1 -1
  41. package/docs/guides/install.md +1 -1
  42. package/docs/guides/loop-finish.md +3 -3
  43. package/docs/guides/loop-running.md +4 -4
  44. package/docs/guides/project-context.md +1 -1
  45. package/docs/guides/run-a-factory.md +2 -2
  46. package/docs/guides/setup-doctrines.md +2 -2
  47. package/docs/guides/setup-footprint.md +1 -1
  48. package/docs/guides/uninstall.md +3 -3
  49. package/docs/guides/upgrade.md +1 -1
  50. package/docs/guides/verify.md +12 -0
  51. package/docs/guides/worktree.md +1 -1
  52. package/docs/reference/environment.md +5 -2
  53. package/docs/reference/plugin-activity.md +1 -1
  54. package/docs/reference/plugin-guard.md +1 -1
  55. package/docs/reference/plugin-learn.md +1 -1
  56. package/docs/reference/plugin-workflow.md +1 -1
  57. package/docs/reference/troubleshoot-doctor.md +2 -2
  58. package/docs/reference/troubleshoot-hooks.md +2 -2
  59. package/docs/reference/troubleshoot-install.md +3 -3
  60. package/docs/reference/troubleshoot-tools.md +1 -1
  61. package/docs/token-footprint.md +68 -4
  62. package/docs/understand/design-choices-hosts.md +1 -1
  63. package/docs/understand/design-choices-shape.md +1 -0
  64. package/docs/understand/enforced-vs-asked.md +2 -2
  65. package/docs/understand/machine-bob.md +1 -1
  66. package/docs/understand/machine-claude.md +2 -2
  67. package/docs/understand/on-your-machine.md +1 -1
  68. package/docs/web-ui.md +10 -5
  69. package/harness.config.json +1 -1
  70. package/js/README.md +5 -3
  71. package/js/build/args.mjs +13 -2
  72. package/js/build/driver.mjs +34 -7
  73. package/js/build/emit-claude.mjs +9 -5
  74. package/js/build/emit-opencode.mjs +13 -9
  75. package/js/build/generate.mjs +10 -165
  76. package/js/build/profile.mjs +318 -0
  77. package/js/build/render.mjs +81 -3
  78. package/js/build/retired-skills.mjs +60 -13
  79. package/js/build/source.mjs +15 -1
  80. package/js/build/stubs.mjs +4 -1
  81. package/js/cli-table.json +48 -3
  82. package/js/hosts/done-checks.mjs +6 -0
  83. package/js/hosts/geneseed-dir.mjs +3 -2
  84. package/js/hosts/gitref.mjs +5 -3
  85. package/js/hosts/hook-tap.mjs +104 -0
  86. package/js/hosts/hooks-context.mjs +4 -2
  87. package/js/hosts/hooks-done.mjs +345 -55
  88. package/js/hosts/hooks-learn.mjs +51 -19
  89. package/js/hosts/hooks-prims.mjs +5 -3
  90. package/js/hosts/hooks.mjs +172 -19
  91. package/js/hosts/hosts.mjs +80 -12
  92. package/js/hosts/installs.mjs +26 -1
  93. package/js/hosts/native.mjs +33 -7
  94. package/js/hosts/owned.mjs +7 -6
  95. package/js/hosts/ownership-gate.mjs +14 -1
  96. package/js/hosts/settings.mjs +273 -105
  97. package/js/hosts/shim.mjs +4 -4
  98. package/js/hosts/usage.mjs +9 -3
  99. package/js/inspect/checks-constitution.mjs +32 -0
  100. package/js/inspect/checks-probe.mjs +66 -5
  101. package/js/inspect/checks-repo.mjs +196 -2
  102. package/js/inspect/cost.mjs +34 -2
  103. package/js/inspect/diff.mjs +21 -3
  104. package/js/inspect/doctor.mjs +6 -1
  105. package/js/inspect/inventory.mjs +1 -1
  106. package/js/lib/machine-dir.mjs +1 -1
  107. package/js/lib/node-floor.mjs +46 -6
  108. package/js/maintain/setup.mjs +5 -1
  109. package/js/maintain/uninstall.mjs +42 -16
  110. package/js/maintain/update.mjs +4 -2
  111. package/js/web/actions.mjs +17 -12
  112. package/js/web/api.mjs +7 -2
  113. package/package.json +1 -1
  114. package/registry.json +14 -0
  115. package/src/AGENT.md.tmpl +15 -17
  116. package/src/bricks/pr-open.md +3 -2
  117. package/src/doctrines/ops.md +2 -2
  118. package/src/doctrines/process.md +40 -36
  119. package/src/factories/analysis-to-build.json +1 -1
  120. package/src/factories/bug-report-to-fix.json +1 -1
  121. package/src/factories/issue-to-pr.json +1 -1
  122. package/src/kits/terminal-tools/rules.md +10 -0
  123. package/src/kits/terminal-tools.json +13 -0
  124. package/src/licenses/herdr.txt +201 -0
  125. package/src/modes/foreman.md +6 -3
  126. package/src/skills/_self-improvement.md +9 -7
  127. package/src/skills/commit.md +17 -17
  128. package/src/skills/debug/ci.md +1 -1
  129. package/src/skills/dependencies.md +3 -3
  130. package/src/skills/document-project.md +3 -2
  131. package/src/skills/factory.md +13 -4
  132. package/src/skills/geneseed.md +4 -2
  133. package/src/skills/git-history.md +5 -7
  134. package/src/skills/herdr.md +135 -0
  135. package/src/skills/loop.md +3 -2
  136. package/src/skills/opencode-cli.md +84 -0
  137. package/src/skills/pipeline.md +1 -1
  138. package/src/skills/release.md +5 -8
  139. package/src/skills/review-response.md +4 -2
  140. package/src/skills/rule.md +27 -1
  141. package/src/skills/ship.md +54 -7
  142. package/src/skills/worktree.md +2 -2
  143. package/src/upstreams.json +7 -0
  144. package/themes/_TEMPLATE.json +2 -0
  145. package/themes/biker.json +2 -0
  146. package/themes/commentator.json +2 -0
  147. package/themes/cyberpunk.json +2 -0
  148. package/themes/gamer.json +2 -0
  149. package/themes/imperial.json +2 -0
  150. package/themes/joker.json +2 -0
  151. package/themes/marvin.json +2 -0
  152. package/themes/mean.json +2 -0
  153. package/themes/military.json +2 -0
  154. package/themes/neutral.json +2 -0
  155. package/themes/pirate.json +2 -0
  156. package/themes/sports.json +2 -0
  157. package/themes/verstappen.json +2 -0
  158. package/themes/wizard.json +2 -0
  159. package/web/dist/assets/Activity-D2kOc3yi.js +1 -0
  160. package/web/dist/assets/ActivityDetail-By3xOr21.js +1 -0
  161. package/web/dist/assets/{Bonsai-Bfpb6W-1.js → Bonsai-CBWDTBA4.js} +1 -1
  162. package/web/dist/assets/{CopyButton-ByIntFtB.js → CopyButton-BVbpriMB.js} +1 -1
  163. package/web/dist/assets/Dashboard-CIJLPHM9.js +2 -0
  164. package/web/dist/assets/{Docs-DvlMJhpu.js → Docs-CiRRIELs.js} +3 -3
  165. package/web/dist/assets/Factories-DhyK0O8d.js +1 -0
  166. package/web/dist/assets/GreenhouseView-DW3PgTPy.js +1 -0
  167. package/web/dist/assets/Installs-B6nlo-Ly.js +3 -0
  168. package/web/dist/assets/JournalView-O65qEWfp.js +1 -0
  169. package/web/dist/assets/Kits-C5U-yT6Z.js +1 -0
  170. package/web/dist/assets/Laws-CuTw_XNf.js +4 -0
  171. package/web/dist/assets/{LibRows-DEHjIoD-.js → LibRows-D6-CVa3K.js} +1 -1
  172. package/web/dist/assets/Library-CzPlerd6.js +3 -0
  173. package/web/dist/assets/Loops-CqNF_-nS.js +2 -0
  174. package/web/dist/assets/Markdown-CxkA7940.js +71 -0
  175. package/web/dist/assets/OperatorHudView-BNr8K5qj.js +1 -0
  176. package/web/dist/assets/Personal-DeDb9e8O.js +2 -0
  177. package/web/dist/assets/Settings-B8MPN_AD.js +1 -0
  178. package/web/dist/assets/{Tabs-CWeQTADL.js → Tabs-DJzAez4h.js} +1 -1
  179. package/web/dist/assets/index-BL3P-9Rg.js +6 -0
  180. package/web/dist/assets/{index-CsAZq0BQ.css → index-CRWqKxfY.css} +1 -1
  181. package/web/dist/index.html +2 -2
  182. package/adapters/claude-code/settings.json +0 -52
  183. package/web/dist/assets/Activity-CqJiquEq.js +0 -1
  184. package/web/dist/assets/ActivityDetail-BSzevynX.js +0 -1
  185. package/web/dist/assets/Dashboard-DBOEi9lQ.js +0 -2
  186. package/web/dist/assets/Factories-Bpvv7L2H.js +0 -1
  187. package/web/dist/assets/GreenhouseView-GpBsYn50.js +0 -1
  188. package/web/dist/assets/Installs-BlGmVrFK.js +0 -3
  189. package/web/dist/assets/JournalView-iLuLrOxE.js +0 -1
  190. package/web/dist/assets/Kits-DRwpxC-J.js +0 -1
  191. package/web/dist/assets/Laws-CZkiNOWQ.js +0 -4
  192. package/web/dist/assets/Library-B4K-1iNF.js +0 -3
  193. package/web/dist/assets/Loops-BWSzaW8E.js +0 -2
  194. package/web/dist/assets/Markdown-0ORz7tAc.js +0 -69
  195. package/web/dist/assets/OperatorHudView-BAXwCEvY.js +0 -1
  196. package/web/dist/assets/Personal-Bp9nV4GR.js +0 -2
  197. package/web/dist/assets/Settings-CWWuaIp-.js +0 -1
  198. package/web/dist/assets/index-How7SzDZ.js +0 -6
@@ -0,0 +1,318 @@
1
+ /**
2
+ * An install's profile — every setting read back off a deployed install, and the argv that
3
+ * re-emits it unchanged — plus the preserve guard that holds a build to it.
4
+ *
5
+ * Moved out of `generate.mjs` so the driver can import it: `generate.mjs` lazily imports
6
+ * `update.mjs`, which spawns git, and the driver is under a transitive `child_process` ban
7
+ * (`tests/unit/hook_cli.test.mjs` walks dynamic imports too). This module reads the install
8
+ * through `js/hosts/installs.mjs` and prints nothing. `generate.mjs` re-exports the three
9
+ * profile functions, so their callers did not move.
10
+ */
11
+ import { existsSync } from 'node:fs';
12
+ import path from 'node:path';
13
+
14
+ import { GATE_SWITCHES, PACK_ORDER } from './source.mjs';
15
+ import { DEFAULT_PRESET } from '../loop/score.mjs';
16
+ import { CLAUDE_STYLE, GLOBAL_MANIFEST, HOSTS } from '../hosts/hosts.mjs';
17
+ import {
18
+ EMIT_FOR, EMIT_HOST_SCOPE, defaultMode, defaultPosture, defaultTheme, doctrinesForBuild,
19
+ emitHostScopeOf, excludedRulesOfDir, excludedSkillsOfDir, footprintOfDir, kitsOfDir, sharedTierOfDir,
20
+ gatesOfDir, installState, modeOfDir, postureOfDir, readMaybe, themeOfDir, trustOfDir,
21
+ } from '../hosts/installs.mjs';
22
+
23
+ /**
24
+ * `_harness_setup._setup_build_args` — the generator argv for one selection. Pure but for one
25
+ * read: `harness.config.json`, for the posture and mode the driver would default to.
26
+ *
27
+ * The elision rules are not symmetric: `footprint` is ALWAYS passed,
28
+ * because omitting it when it matched the generator's default silently coupled the answer to
29
+ * whatever that default happened to be — the moment the default moved, picking the old one
30
+ * produced the new one. `posture` and `mode` elide only at the default the driver would
31
+ * actually take, which is `configDefaults()` (`harness.config.json`), read here through
32
+ * `defaultPosture()`/`defaultMode()`. Eliding at the literals `peer`/`direct` turned a replay
33
+ * of a `peer` install into an `artisan` build under `{"posture":"artisan"}` — and the
34
+ * preserve guard then refused `rebuild-all`. `trust` elides at `DEFAULT_PRESET`, which no
35
+ * config key feeds.
36
+ *
37
+ * ⚠ `doctrines` DOES NOT ELIDE, AND THAT IS THE SAFETY DECISION, NOT A STYLE ONE. It used to
38
+ * elide on the full set, by analogy with posture and mode — but those two compare against a
39
+ * FROZEN LITERAL (`'peer'`, `'direct'`), while the default a missing `--doctrines` actually
40
+ * lands on is `configDefaults()`, which reads `harness.config.json`. With `{"doctrines":
41
+ * ["craft"]}` in that file, an install carrying all four packs re-emitted by `upgrade` was
42
+ * silently narrowed to one — and the narrowing takes the commit/push consent gate off an
43
+ * install whose owner never asked for that. Same trap as `footprint`, one axis over, with a
44
+ * boundary behind it. A caller that knows the selection now always says so.
45
+ *
46
+ * `allPacks` survives the elision's removal because it is still what CANONICALISES the value:
47
+ * the flag is emitted in the checkout's pack order, not the order handed in, and this function
48
+ * is pure and has no discovery of its own.
49
+ *
50
+ * Two states: `null` means "the caller expressed no opinion" and emits no flag at all, so the
51
+ * generator falls back to `harness.config.json` — the only route left to that fallback, and it
52
+ * is reached only where nothing was read back off an install; `[]` is a deliberate empty
53
+ * selection and emits `--doctrines none`, which is the spelling the driver's `parseDoctrines`
54
+ * accepts (an empty `--doctrines ` is a usage error there, so it can never be produced here).
55
+ */
56
+ export function setupBuildArgs(theme, emit, out = null, root = null, footprint = 'lean',
57
+ posture = 'peer', mode = 'direct', doctrines = null, allPacks = PACK_ORDER,
58
+ excludeRules = null, trust = DEFAULT_PRESET, excludeSkills = null, gates = {}, kits = null, sharedTier = false) {
59
+ const argv = ['--theme', theme, '--emit', emit];
60
+ if (!emit.endsWith('-global')) {
61
+ if (out) argv.push('--out', out);
62
+ if (root) argv.push('--root', root);
63
+ }
64
+ if (footprint) argv.push('--footprint', footprint);
65
+ if (posture && posture !== defaultPosture()) argv.push('--posture', posture);
66
+ if (mode && mode !== defaultMode()) argv.push('--mode', mode);
67
+ if (trust && trust !== DEFAULT_PRESET) argv.push('--trust', trust);
68
+ if (Array.isArray(doctrines)) {
69
+ // Emitted in `allPacks` order, not the order handed in: a caller may legitimately pass an
70
+ // unsorted list, and the flag has to be canonical for the same reason the driver
71
+ // re-normalises on parse — the `Active packs:` marker is compared against itself.
72
+ const picked = allPacks.filter((p) => doctrines.includes(p));
73
+ argv.push('--doctrines', picked.length ? picked.join(',') : 'none');
74
+ }
75
+ // The second axis, emitted the same way and for the same reason — but ALWAYS when the
76
+ // caller passed a list, empty included. An omitted flag reads as "no opinion" and the
77
+ // driver's config fallback fills it in; `none` is the caller saying "exclude nothing",
78
+ // which is exactly what a rebuild that just re-enabled the last rule has to say.
79
+ if (Array.isArray(excludeRules)) {
80
+ argv.push('--exclude-rules', excludeRules.length ? excludeRules.join(',') : 'none');
81
+ }
82
+ // Skills elide when nothing is excluded: the driver's default IS nothing (no config key
83
+ // feeds it), so the flag's absence and `none` are the same answer, and every argv that
84
+ // excludes nothing stays the bytes it was before the flag existed.
85
+ if (excludeSkills?.length) argv.push('--exclude-skills', excludeSkills.join(','));
86
+ // The gate switches elide when armed: the driver's default IS armed (no config key feeds
87
+ // them), so only an explicit `false` speaks, and every armed argv stays the bytes it was.
88
+ // `gates` is one object keyed as `GATE_SWITCHES` keys it (`gatesOfDir`, a profile, a body).
89
+ // Law order, so a Law IV-only install still ends on `--no-deletion-gate` as it did.
90
+ for (const g of GATE_SWITCHES) if (gates?.[g.key] === false) argv.push(g.flag);
91
+ // Kits elide when none is on, as skills do: no config key feeds them, so absence and `none`
92
+ // are the same answer. Last, so an argv naming no kit is the bytes it always was.
93
+ if (kits?.length) argv.push('--kits', [...kits].sort().join(','));
94
+ // The shared tier elides when off, like the kits: the default is off, so only `on` speaks.
95
+ if (sharedTier) argv.push('--shared-tier', 'on');
96
+ return argv;
97
+ }
98
+
99
+ // The emit for an install carrying NO marker is `EMIT_FOR` (`js/hosts/installs.mjs`): a
100
+ // pre-marker install still has a (host, scope), which is what the walk found it by, so it is
101
+ // rebuilt in its own mode rather than defaulted to OpenCode.
102
+
103
+ /**
104
+ * Everything `rebuild-all` reads back off one install, and the argv that re-emits it unchanged.
105
+ *
106
+ * EXTRACTED SO `status` SHOWS WHAT A REBUILD WOULD USE, not a second reading of the same
107
+ * markers that could drift from this one. An agent changing one setting takes `argv`, edits one
108
+ * flag and runs it; every flag it did not touch has to be the install's own, or the "one
109
+ * change" silently resets the rest — which is exactly the failure the seven read-backs below
110
+ * exist to prevent.
111
+ *
112
+ * THE MARKER IS TRUSTED ONLY FOR ITS OWN HOST. There is one `.geneseed-emit` per root and the
113
+ * last deploy wins, so in a dual-host repo (`.opencode/` and `.claude/` in one cwd) the other
114
+ * host's row would otherwise rebuild with the WRONG emit — turning a Claude install into an
115
+ * OpenCode one. `rebuild-all/a-dual-host-repo-rebuilds-each-row-in-its-own-emit` is the cell.
116
+ */
117
+ export function installProfile(host, scope, root, notify = null) {
118
+ const raw = readMaybe(path.join(root, '.geneseed-emit'));
119
+ let marker = raw === null ? '' : raw.trim();
120
+ if (marker && (EMIT_HOST_SCOPE.get(marker) ?? ['', ''])[0] !== host) marker = '';
121
+ const emit = marker || EMIT_FOR.get(`${host} ${scope}`) || 'opencode-global';
122
+ // Every read-back below is narrowed to `host`'s OWN carrier (host-compat B1): in a repo
123
+ // shared with another Claude-style host, an un-narrowed scan answers with WHICHEVER host's
124
+ // carrier the shared `CARRIERS` order favours — the wrong carrier for every host but one.
125
+ const theme = themeOfDir(root, host) || defaultTheme();
126
+ const footprint = footprintOfDir(root);
127
+ const posture = postureOfDir(root, host) || defaultPosture();
128
+ const mode = modeOfDir(root, host) || defaultMode();
129
+ // Read off the deployed loop skill; no config fallback — `DEFAULT_PRESET` is the engine's.
130
+ const trust = trustOfDir(root, host) || DEFAULT_PRESET;
131
+ // A rebuild that defaulted the pack selection would re-emit an install into a constitution
132
+ // its owner did not choose — and in one direction that is not merely surprising: dropping
133
+ // the process pack takes the commit/push consent RULES out of AGENT.md while
134
+ // `claudeHookGroups` keeps the gate wired, or the reverse. ⚠ AND THE FALLBACK IS NOT
135
+ // `harness.config.json`: a pre-migration carrier has no marker, and resolving that silence
136
+ // out of a machine-wide config narrows every such install on its first upgrade.
137
+ // `doctrinesForBuild` resolves unknown to ALL packs — see its docblock.
138
+ const doctrines = doctrinesForBuild(root, host);
139
+ // The per-rule axis is preserved for the same reason and with sharper teeth: an upgrade that
140
+ // dropped it would quietly hand back every rule its owner switched off, and `process 5` is
141
+ // one of them. No marker reads as `[]` (`excludedRulesOfDir`), never `null`, so the argv always
142
+ // spells the flag (`none` included) and `harness.config.json`'s `excludeRules` never fills it in.
143
+ const excludeRules = excludedRulesOfDir(root, host);
144
+ // Skills left out stay left out: an upgrade that forgot them would put them all back.
145
+ const excludeSkills = excludedSkillsOfDir(root, host, notify);
146
+ // The gate switches: a rebuild that forgot one would silently re-arm (or, read wrong, disarm)
147
+ // the install. A missing marker reads as armed.
148
+ const gates = gatesOfDir(root, host);
149
+ // Kits on stay on (spec A3); one this checkout no longer ships drops with a notice (R2).
150
+ const kits = kitsOfDir(root, host, notify);
151
+ // A project install's `Shared tier: on` stays on across a rebuild; a global install never has it.
152
+ const sharedTier = sharedTierOfDir(root, host);
153
+ const out = scope === 'global' ? null : root;
154
+ const argv = setupBuildArgs(theme, emit, out, out, footprint, posture, mode, doctrines,
155
+ PACK_ORDER, excludeRules, trust, excludeSkills, gates, kits, sharedTier);
156
+ // A GLOBAL ROW NAMES ITS OWN DIR. `root` came from the host's config-dir resolver, which
157
+ // honours env overrides (`OPENCODE_CONFIG_DIR`, `CLAUDE_CONFIG_DIR`…); without the flag the
158
+ // same argv run from a shell lacking that variable re-emits into the DEFAULT dir — a second
159
+ // install beside the one it was meant to rebuild. Appended, so the argv's head is unchanged.
160
+ if (scope === 'global') argv.push('--config-dir', root);
161
+ return {
162
+ host, scope, root, state: installState(root, host, scope),
163
+ emit, theme, footprint, posture, mode, trust, doctrines, excludeRules, excludeSkills,
164
+ kits, sharedTier, ...gates, argv,
165
+ };
166
+ }
167
+
168
+ /**
169
+ * `argv` as one pasteable command, using the `geneseed build` launcher rather than the raw
170
+ * generator: `geneseed-build` is only on PATH for an npm global install, while a git-clone
171
+ * install has only the `geneseed` launcher, and `geneseed build` now forwards every flag
172
+ * `setupBuildArgs` produces. Only whitespace is quoted — a path holding shell metacharacters
173
+ * (`$`, `&`) would need quoting by hand.
174
+ */
175
+ export function rebuildCommand(argv) {
176
+ return ['geneseed', 'build', ...argv.map((a) => (/\s/.test(a) ? `"${a}"` : a))].join(' ');
177
+ }
178
+
179
+ // --------------------------------------------------------------------------------------
180
+ // the preserve guard
181
+ // --------------------------------------------------------------------------------------
182
+
183
+ /**
184
+ * The settings the guard compares, in the order a refusal lists them. `name` is what the
185
+ * refusal prints, `given` the `parseArgs` key a caller sets by passing the flag, `flag` the
186
+ * generator flag, and `now`/`was` the value on each side, spelled so equal means unchanged.
187
+ * The gate switches are rows too: each has a flag for its non-default side only, so a caller
188
+ * returns one to its default with `--reset`, never by omission.
189
+ */
190
+ const show = (v) => (Array.isArray(v) ? (v.length ? v.join(',') : 'none') : String(v));
191
+ const sorted = (v) => [...(v ?? [])].sort();
192
+ /** @type {{ name: string, given: string, flag: string, gate?: boolean, now: (a: any) => string, was: (p: any) => string }[]} */
193
+ const GUARDED = [
194
+ { name: 'theme', given: 'theme', flag: '--theme', now: (a) => a.theme, was: (p) => p.theme },
195
+ { name: 'footprint', given: 'footprint', flag: '--footprint', now: (a) => a.footprint, was: (p) => p.footprint },
196
+ { name: 'posture', given: 'posture', flag: '--posture', now: (a) => a.posture, was: (p) => p.posture },
197
+ { name: 'mode', given: 'mode', flag: '--mode', now: (a) => a.mode, was: (p) => p.mode },
198
+ { name: 'trust', given: 'trust', flag: '--trust', now: (a) => a.trust, was: (p) => p.trust },
199
+ { name: 'doctrines', given: 'doctrines', flag: '--doctrines', now: (a) => show(a.doctrines), was: (p) => show(p.doctrines) },
200
+ { name: 'exclude-rules', given: 'excludeRules', flag: '--exclude-rules',
201
+ now: (a) => show(sorted(a.excludeRules)), was: (p) => show(sorted(p.excludeRules)) },
202
+ { name: 'exclude-skills', given: 'excludeSkills', flag: '--exclude-skills',
203
+ now: (a) => show(sorted(a.excludeSkills)), was: (p) => show(sorted(p.excludeSkills)) },
204
+ { name: 'kits', given: 'kits', flag: '--kits', now: (a) => show(sorted(a.kits)), was: (p) => show(sorted(p.kits)) },
205
+ { name: 'shared-tier', given: 'sharedTier', flag: '--shared-tier',
206
+ now: (a) => (a.sharedTier === 'on' ? 'on' : 'off'), was: (p) => (p.sharedTier ? 'on' : 'off') },
207
+ // A switch reads as its flag says. `--no-deletion-gate` given is `deletion-gate: off`;
208
+ // `--strict-consent` (the one switch whose flag adds asks, so it is not `--no-*`) given is
209
+ // `strict-consent: on`. Either way the flag given means the switch's key is `false`.
210
+ ...GATE_SWITCHES.map((g) => {
211
+ const negative = g.flag.startsWith('--no-');
212
+ const [given, idle] = negative ? ['off', 'on'] : ['on', 'off'];
213
+ return {
214
+ name: g.flag.replace(/^--(no-)?/, ''), given: g.arg, flag: g.flag, gate: true,
215
+ now: (a) => (a[g.arg] ? given : idle), was: (p) => (p[g.key] === false ? given : idle),
216
+ };
217
+ }),
218
+ ];
219
+
220
+ /** A guarded row's flag and value as the caller gave them, for the preserving command. */
221
+ function givenTokens(row, args) {
222
+ if (row.gate) return args[row.given] ? [row.flag] : [];
223
+ return [row.flag, row.now(args)];
224
+ }
225
+
226
+ /**
227
+ * The install a host emit would render into, or null: none there, a plain bundle, or a config
228
+ * dir that cannot be resolved (the emit itself then fails on its own terms).
229
+ *
230
+ * PRESENT MEANS GENESEED WROTE IT. A `.geneseed-emit` marker naming this emit's (host, scope)
231
+ * counts. So does a Geneseed manifest: a global install's, a Claude-style project layer's, or
232
+ * an OpenCode project's `.opencode/.geneseed-manifest.json` — files only Geneseed writes. The
233
+ * manifest matters in a dual-host repo, where the one root marker names whichever host deployed
234
+ * last. An OpenCode project is NOT detected by its `.opencode/` directory alone (which is what
235
+ * `installState(root, 'opencode', 'project')` tests): that directory is the user's tool config
236
+ * before it is ours, and the guard must never refuse a first install into a repo that already
237
+ * uses OpenCode.
238
+ */
239
+ function guardTarget(args, out) {
240
+ if (args.emit === 'files') return null;
241
+ const [host, scope] = EMIT_HOST_SCOPE.get(args.emit) ?? [];
242
+ if (!host) return null;
243
+ let root = out;
244
+ if (scope === 'global') {
245
+ try {
246
+ root = args.cfgDir ?? HOSTS.find((h) => h.host === host).configDir();
247
+ } catch { return null; }
248
+ }
249
+ const marker = emitHostScopeOf(root);
250
+ const marked = marker !== null && marker[0] === host && marker[1] === scope;
251
+ const managed = scope === 'project' && host === 'opencode'
252
+ ? existsSync(path.join(root, '.opencode', GLOBAL_MANIFEST))
253
+ : (scope === 'global' || CLAUDE_STYLE.includes(host)) && installState(root, host, scope) === 'active';
254
+ return marked || managed ? { host, scope, root } : null;
255
+ }
256
+
257
+ /**
258
+ * The preserve guard: what a build would change on the install it targets that its caller did
259
+ * not ask to change. Null when the build may run.
260
+ *
261
+ * WHY A REFUSAL AND NOT AN INHERIT. A flag the caller omits takes the generator's default (or
262
+ * `harness.config.json`'s), never the install's: that is what a build has always meant, and
263
+ * the fresh install, the plan line and the docs all say so. Inheriting would change the meaning
264
+ * of every bare build in silence. Refusing changes nothing that was right before — a build
265
+ * that keeps every setting still runs — and stops only the one that resets settings nobody
266
+ * named. That is the failure reported in 2026-11: an agent "reinstalled" with a bare build and
267
+ * the theme, mode, posture and packs of the user's harness fell back to the defaults.
268
+ *
269
+ * `given` is the set of `parseArgs` keys the caller passed; a setting passed is intent and is
270
+ * never compared. `--reset` (`args.reset`) is the caller's consent to the defaults and skips
271
+ * the guard. Replays (`rebuild-all`, `upgrade`, `migrate`, the console's rebuild) pass the
272
+ * install's whole profile, so they compare equal and run unchanged.
273
+ *
274
+ * Returns `{ host, scope, root, changes: [{ name, from, to }], command }`. `command` is the
275
+ * install's own rebuild (`installProfile(...).argv`) with every flag the caller passed applied
276
+ * on top, so running it keeps everything the caller did not name.
277
+ */
278
+ export function preserveRefusal(args, given, out, root = null) {
279
+ if (args.reset) return null;
280
+ const target = guardTarget(args, out);
281
+ if (!target) return null;
282
+ const p = installProfile(target.host, target.scope, target.root);
283
+ const changes = GUARDED.filter((r) => !given.has(r.given) && r.now(args) !== r.was(p))
284
+ .map((r) => ({ name: r.name, from: r.was(p), to: r.now(args) }));
285
+ if (!changes.length) return null;
286
+ // The install's own argv, each passed flag's value swapped in where the argv has the flag,
287
+ // the rest appended. A project emit's `--root`, when the caller gave one, replaces the
288
+ // profile's; `--emit` is the caller's (the profile's names the same host and scope).
289
+ const argv = [...p.argv];
290
+ const swap = (flag, tokens) => {
291
+ const i = argv.indexOf(flag);
292
+ if (i >= 0) argv.splice(i, 2, ...tokens);
293
+ else argv.push(...tokens);
294
+ };
295
+ swap('--emit', ['--emit', args.emit]);
296
+ if (root && target.scope === 'project') swap('--root', ['--root', root]);
297
+ for (const row of GUARDED) {
298
+ if (!given.has(row.given)) continue;
299
+ const tokens = givenTokens(row, args);
300
+ if (row.gate) { if (!argv.includes(row.flag)) argv.push(...tokens); } else swap(row.flag, tokens);
301
+ }
302
+ if (args.force) argv.push('--force');
303
+ if (args.pruneGates) argv.push('--prune-gates');
304
+ return { ...target, changes, command: rebuildCommand(argv) };
305
+ }
306
+
307
+ /** The refusal as the driver prints it: each change, then the command that keeps the rest. */
308
+ export function preserveRefusalText(r) {
309
+ return [
310
+ `geneseed: error: refused: this build would change settings of the ${r.host} ${r.scope} install `
311
+ + `at ${r.root} that it was not given:`,
312
+ ...r.changes.map((c) => ` ${c.name}: ${c.from} -> ${c.to}`),
313
+ 'Nothing was written. To rebuild that install and keep its settings, run:',
314
+ ` ${r.command}`,
315
+ 'Add --reset only to return the settings listed above to their defaults.',
316
+ '',
317
+ ].join('\n');
318
+ }
@@ -427,7 +427,15 @@ export function renderFile(cfg, filePath, theme, footprint = 'full', lawsPrefix
427
427
  text = resolveCatalogs(text, nativeCatalog, cfg.excludeSkills ?? [], cfg);
428
428
  text = resolveLean(text, footprint);
429
429
  if (footprint === 'lean') text = leanVoice(text, cfg.src);
430
- return substitute(text, theme);
430
+ text = substitute(text, theme);
431
+ // D3 lives HERE, not in `renderAll`: every root file is rendered by this function, and the
432
+ // Claude/Bob emitters re-render the template with prefixed DIR_* tokens (`prefixedAgentText`)
433
+ // without going through `renderAll`'s items. Top-level template only; an include is flattened
434
+ // into it first.
435
+ if (!visiting.size && normcase(here) === normcase(path.resolve(cfg.src, 'AGENT.md.tmpl'))) {
436
+ text = dropCarrierCitations(cfg, text);
437
+ }
438
+ return text;
431
439
  }
432
440
 
433
441
  /** `_build_render._posture_body` / `_mode_body` — one helper, both registers. */
@@ -441,6 +449,15 @@ function registerBody(cfg, theme, dir, selected, fallback) {
441
449
  return '';
442
450
  }
443
451
 
452
+ /**
453
+ * The selected mode's body. Exported because it names `{{DIR_NOTEBOOK}}` paths: the root file's
454
+ * re-render with prefixed DIR_* tokens (`prefixedAgentText`, js/build/emit-claude.mjs) rebuilds
455
+ * it as it rebuilds KITS_BODY, or the Foreman ledger points at `notebook/` beside `.claude/`.
456
+ */
457
+ export function modeBody(cfg, theme) {
458
+ return registerBody(cfg, theme, 'modes', cfg.mode ?? 'direct', 'direct');
459
+ }
460
+
444
461
  /**
445
462
  * The doctrine packs this build actually renders, in `PACK_ORDER` — and the two gates
446
463
  * that stand between `cfg.doctrines` and a silently wrong AGENT.md.
@@ -526,6 +543,58 @@ function dropExcludedRules(text, pack, excluded) {
526
543
  .join('');
527
544
  }
528
545
 
546
+ /**
547
+ * A parenthetical made of rule citations only — `(*A*)`, `(*A*, *B*)` — with the blanks before
548
+ * it: spaces, and at most one line break, so a citation wrapped onto its own line leaves no
549
+ * orphaned punctuation at the start of the next.
550
+ */
551
+ const CITE_GROUP_RE = /([ \t]*(?:\r?\n[ \t]*)?)\((\*[^*()\n]+\*(?:,[ \t]*\*[^*()\n]+\*)*)\)/g;
552
+
553
+ /**
554
+ * Remove the citations of excluded rules from rendered carrier text (owner decision D3,
555
+ * 2026-11-11: an excluded rule is OFF, so the text read every turn stops invoking it).
556
+ *
557
+ * ⚠ AFTER SUBSTITUTION, ON THE RENDERED TEXT, the opposite of `dropExcludedRules` and for the
558
+ * opposite reason: a citation renders as the rule's English principle in italics, identical in
559
+ * every voice (`resolveRuleIds`), so here the rendered form is the one literal, and a cited
560
+ * rule's include chain (template, mode, posture, packs) is already flat.
561
+ *
562
+ * Only a group whose every item is a rule name is touched. The doctor holds every carrier
563
+ * source to that shape (`citationGroupProblems`), so each removal leaves a sentence that still
564
+ * reads. A prose mention ("Where *X* refuses …") and a group with any other italic stay: the
565
+ * first binds nothing, the second may be plain emphasis. `offNames` empty is the identity, which
566
+ * keeps a build with no exclusion byte-identical.
567
+ * @param {string} text
568
+ * @param {Set<string>} offNames principle names of the excluded rules
569
+ * @param {Set<string>} allNames principle names of every rule in the canon
570
+ */
571
+ export function dropExcludedCitations(text, offNames, allNames) {
572
+ if (!offNames.size) return text;
573
+ return text.replace(CITE_GROUP_RE, (whole, lead, inner) => {
574
+ const names = inner.match(/\*[^*]+\*/g).map((s) => s.slice(1, -1));
575
+ if (!names.every((n) => allNames.has(n))) return whole;
576
+ const kept = names.filter((n) => !offNames.has(n));
577
+ if (kept.length === names.length) return whole;
578
+ return kept.length ? `${lead}(${kept.map((n) => `*${n}*`).join(', ')})` : '';
579
+ });
580
+ }
581
+
582
+ /**
583
+ * `dropExcludedCitations` with this build's names: the excluded doctrine rules of
584
+ * `cfg.excludeRules`. The bundle's other files — the complete packs on disk included — never
585
+ * pass through here, so they keep every citation.
586
+ * @param {any} cfg
587
+ * @param {string} text
588
+ */
589
+ function dropCarrierCitations(cfg, text) {
590
+ const offRules = new Set(cfg.excludeRules ?? []);
591
+ if (!offRules.size) return text;
592
+ const canonRules = ruleCanon(cfg.src).rules;
593
+ const offNames = new Set(canonRules.filter((r) => r.kind === 'DOCTRINE' && offRules.has(`${r.pack}.${r.n}`))
594
+ .map((r) => r.name));
595
+ return dropExcludedCitations(text, offNames, new Set(canonRules.map((r) => r.name)));
596
+ }
597
+
529
598
  function doctrinesBody(cfg, theme, active, footprint, lawsPrefix) {
530
599
  // At lean the section still carries the one pointer with no pack active: it names the laws too.
531
600
  if (!active.length) return footprint === 'lean' ? briefPointer(theme, lawsPrefix, false) : '';
@@ -559,6 +628,11 @@ export function effectiveTheme(cfg, themeName, {
559
628
  } = {}) {
560
629
  const theme = { ...loadTheme(cfg, themeName), ...(cfg.structure ?? STRUCTURE) };
561
630
  Object.assign(theme, pathTokens(theme, sharedRoot));
631
+ // A skill or agent names its notes file as a path the agent opens from the project root, and
632
+ // on an install whose harness sits a level down (`.claude/`) the notebook is there too. Only
633
+ // the relative form takes the prefix; the root file's re-render (`prefixedAgentText`) derives
634
+ // its own from its prefixed DIR_NOTEBOOK.
635
+ if (!sharedRoot) theme.PATH_NOTES = `${lawsPrefix}${theme.PATH_NOTES}`;
562
636
  // Empty without a tier, so a project emit and a default build stay byte-identical (the
563
637
  // `EXCLUDED_SKILLS_LINE` contract). Each rides the end of a template line, so its value carries
564
638
  // the blank line. C1 lives in this text: the readers only concatenate, shared first.
@@ -570,7 +644,7 @@ export function effectiveTheme(cfg, themeName, {
570
644
  + 'holds this convention, and any fact\n> that landed here waits for the next emit to move it.'
571
645
  : '';
572
646
  theme.POSTURE_BODY = registerBody(cfg, theme, 'postures', cfg.posture ?? 'peer', 'peer');
573
- theme.MODE_BODY = registerBody(cfg, theme, 'modes', cfg.mode ?? 'direct', 'direct');
647
+ theme.MODE_BODY = modeBody(cfg, theme);
574
648
  // The loop skill's default trust preset (`--trust`), raw for `--preset` and capitalised for
575
649
  // the `Default trust preset: **<Label>**` line `trustOfDir` reads back off an install.
576
650
  theme.TRUST = cfg.trust ?? DEFAULT_PRESET;
@@ -581,6 +655,10 @@ export function effectiveTheme(cfg, themeName, {
581
655
  // than two positional params keeps the existing two-arg call sites — every test, and
582
656
  // `renderAll` — compiling unchanged, and defaults to the full text if a caller forgets.
583
657
  const active = activeDoctrines(cfg);
658
+ // Consent Before Push under strict consent (`--strict-consent`): one sentence after the rule, at
659
+ // both footprints. Set before the doctrine body, which substitutes it.
660
+ theme.STRICT_CONSENT = cfg.ownBranchPass === false ? ' This install runs strict consent: every\n'
661
+ + 'commit and push, your own branch included, needs the user\'s explicit acceptance.' : '';
584
662
  theme.DOCTRINES_BODY = doctrinesBody(cfg, theme, active, footprint, lawsPrefix);
585
663
  theme.DOCTRINES_LIST = active.length ? active.join(', ') : 'none';
586
664
  // ⚠ EMITTED ONLY WHEN SOMETHING IS EXCLUDED, and that is not cosmetic. An unconditional
@@ -694,7 +772,7 @@ export function renderAll(cfg, themeName, {
694
772
  // accident, which is a different thing from shipping whole by contract.
695
773
  // Keyed on the SOURCE rel, not the themed one, so a DIR_* rename cannot un-exempt them.
696
774
  const fp = /^(?:laws|ontology|doctrines)[\\/]/.test(rel) ? 'full' : footprint;
697
- const text = TEXT_SUFFIXES.has(suffixOf(path.basename(file)))
775
+ let text = TEXT_SUFFIXES.has(suffixOf(path.basename(file)))
698
776
  ? renderFile(cfg, file, theme, fp, lawsPrefix, new Set(), nativeCatalog) : null;
699
777
  items.push({ rel: outRel, text, src: file });
700
778
  // A credited skill ships its upstream's licence beside it, one copy per (skill, key). The
@@ -6,25 +6,43 @@
6
6
  *
7
7
  * An alias is a plain word, so a folder under one may be the user's own (`grill-me` on this very
8
8
  * machine is a user skill, and a link). A folder moves only when ALL of these hold:
9
- * (a) its name is retired and not a live skill;
9
+ * (a) its name is retired and not a live skill, or it is a REVIVED name (below);
10
10
  * (b) no manifest owns a path under it — an owned one is the ordinary prune's;
11
11
  * (c) it, the `skills/` root, and everything inside it are real entries, never a link;
12
12
  * (d) its SKILL.md carries the render's fingerprint (`isRendered`).
13
13
  * Anything else stays where it is and `migrate --dry-run` keeps calling it an orphan.
14
14
  *
15
+ * A revived name (`REVIVED_SKILL_IDS`) is live again. An unowned render under it is one of two
16
+ * things: the copy an older build wrote before it retired the name, or a file the user edited and
17
+ * a later emit declined to overwrite (`claimer` records that refusal in the manifest's `kept` and
18
+ * drops the file from `owned`). The `kept` record tells them apart:
19
+ * - nothing under the folder is in `kept`: the older build's copy. It moves aside whether or
20
+ * not this emit ships the skill. Kit off, that is the cleanup it got while the name was
21
+ * retired. Kit on, the emit then claims a free folder and writes the current copy, where
22
+ * `claimer` would otherwise keep the stale file as the user's;
23
+ * - a path under it is in `kept`: the user's edit. It stays, and `held` hands those `kept`
24
+ * entries back to the emit, which records them again. A kit-off emit claims nothing under
25
+ * the folder, so without that carry the record would lapse and the next emit would take the
26
+ * edit for an old copy.
27
+ * Only revived names get this: an unowned render of any other live skill is never a candidate.
28
+ *
15
29
  * Moved, not deleted: to `<cfg>/archived-skills/<name>/<stamp>/`, outside the `skills/` root a
16
30
  * host scans (`archiveStore`'s sibling would sit inside it and load again).
17
31
  */
18
32
  import { lstatSync, readdirSync, readFileSync, renameSync } from 'node:fs';
19
33
  import path from 'node:path';
20
34
 
21
- import { RETIRED_SKILL_IDS, THEMES, knownSkillIds, skillAliases } from './source.mjs';
22
- import { isCanonical } from '../hosts/hosts.mjs';
35
+ import { RETIRED_SKILL_IDS, REVIVED_SKILL_IDS, THEMES, knownSkillIds, skillAliases } from './source.mjs';
36
+ import { GLOBAL_MANIFEST, isCanonical } from '../hosts/hosts.mjs';
23
37
  import { archiveStore } from '../hosts/memory-files.mjs';
24
38
 
25
- /** Every name an earlier build shipped a skill folder under and this one does not. */
26
- export function retiredSkillNames({ live = knownSkillIds(), aliases = skillAliases() } = {}) {
27
- return [...new Set([...aliases.keys(), ...Object.keys(RETIRED_SKILL_IDS)])].filter((n) => !live.includes(n));
39
+ /**
40
+ * Every name an earlier build shipped a skill folder under and this one does not, plus every
41
+ * revived name, whose unowned render is an older build's copy whether or not it ships today.
42
+ */
43
+ export function retiredSkillNames({ live = knownSkillIds(), aliases = skillAliases(), revived = REVIVED_SKILL_IDS } = {}) {
44
+ const gone = [...aliases.keys(), ...Object.keys(RETIRED_SKILL_IDS)].filter((n) => !live.includes(n));
45
+ return [...new Set([...gone, ...Object.keys(revived)])];
28
46
  }
29
47
 
30
48
  /** Whether a manifest `owned` list holds `rel` or a path under it. */
@@ -103,26 +121,50 @@ export function isRendered(dir, name, { aliases = skillAliases(), labels = skill
103
121
  * The retired folders of `cfg` split by what the next canonical emit does with them:
104
122
  * `prune` (a-d all hold) and `keep` (unowned, present, but failing c or d). Paths are absolute.
105
123
  * `unreadable` names each folder kept because it could not be listed, with the reason.
124
+ * `held` lists the manifest `kept` entries under a revived folder that stays as the user's edit
125
+ * (see the module docblock); the emit records them again. Neither pruned nor an orphan.
106
126
  * `opts.readdir` is the listing call, injectable so a test can make a folder unreadable.
127
+ * `opts.kept` is the manifest's `kept` from BEFORE this emit; by default it is read from `cfg`.
107
128
  */
108
129
  export function retiredSkillFolders(cfg, owned, opts = {}) {
109
- const { readdir = readdirSync } = opts;
130
+ const { readdir = readdirSync, kept = recordedKept(cfg), revived = REVIVED_SKILL_IDS } = opts;
110
131
  const prune = [];
111
132
  const keep = [];
112
133
  const unreadable = [];
134
+ const held = [];
113
135
  const root = path.join(cfg, 'skills');
114
136
  const rootStat = lstat(root);
115
- if (!rootStat) return { prune, keep, unreadable };
137
+ if (!rootStat) return { prune, keep, unreadable, held };
116
138
  // A linked `skills/` root (a dotfiles setup) is the user's whole tree: nothing in it moves.
117
139
  const linkedRoot = rootStat.isSymbolicLink();
118
140
  const aliases = opts.aliases ?? skillAliases();
119
- for (const name of retiredSkillNames({ ...opts, aliases })) {
120
- if (ownsRel(owned, `skills/${name}`)) continue;
141
+ for (const name of retiredSkillNames({ ...opts, aliases, revived })) {
142
+ const rel = `skills/${name}`;
121
143
  const dir = path.join(root, name);
144
+ // Before the `owned` skip: an owned side file (a LICENSE) must not hide the kept SKILL.md
145
+ // beside it, or the record lapses in that emit and the next one archives the edit.
146
+ // Only an entry whose own file is still there and not owned is held: once the user deletes
147
+ // the edit, the record must lapse, or the manifest would call Geneseed's new copy theirs.
148
+ const live = Object.hasOwn(revived, name)
149
+ ? kept.filter((k) => (k === rel || k.startsWith(`${rel}/`)) && !owned.includes(k) && lstat(path.join(cfg, k)))
150
+ : [];
151
+ if (live.length) {
152
+ held.push(...live);
153
+ continue;
154
+ }
155
+ if (ownsRel(owned, rel)) continue;
122
156
  if (!lstat(dir)) continue;
123
157
  (!linkedRoot && plainTree(dir, readdir, unreadable) && isRendered(dir, name, { aliases }) ? prune : keep).push(dir);
124
158
  }
125
- return { prune, keep, unreadable };
159
+ return { prune, keep, unreadable, held };
160
+ }
161
+
162
+ /** The manifest's `kept` list in `cfg`, or `[]` when there is no readable manifest. */
163
+ function recordedKept(cfg) {
164
+ try {
165
+ const man = JSON.parse(readFileSync(path.join(cfg, GLOBAL_MANIFEST), 'utf8'));
166
+ return Array.isArray(man?.kept) ? man.kept.filter((k) => typeof k === 'string') : [];
167
+ } catch { return []; }
126
168
  }
127
169
 
128
170
  /** Where `pruneRetiredSkills` moves `skills/<name>`: the stamp folder goes under it. */
@@ -135,13 +177,17 @@ export const retiredArchiveOf = (cfg, name) => path.join(cfg, 'archived-skills',
135
177
  * A folder it cannot read, or a failed move, warns and leaves the folder; it never fails the emit.
136
178
  * Raw stream writes, as `pruneOwned`'s: the driver's `withPlatformNewlines` already translates,
137
179
  * and `printOut` on top of it would print `\r\r\n` on Windows.
180
+ * Returns `held`: the `kept` entries of user edits under revived names, for the emit to record
181
+ * again in its manifest (`[]` off the canonical path, where nothing is ever pruned). A survey that
182
+ * throws moves nothing and holds every recorded `kept` entry under a revived name, so a failed
183
+ * run never lapses one.
138
184
  */
139
185
  export function pruneRetiredSkills(host, cfg, oldOwned) {
140
- if (!isCanonical(cfg, host)) return;
186
+ if (!isCanonical(cfg, host)) return [];
141
187
  let found;
142
188
  try { found = retiredSkillFolders(cfg, oldOwned); } catch (e) {
143
189
  process.stderr.write(`[geneseed] WARN: ${host}: could not survey retired skills (${e.message}); nothing moved\n`);
144
- return;
190
+ return recordedKept(cfg).filter((k) => Object.keys(REVIVED_SKILL_IDS).some((n) => k.startsWith(`skills/${n}/`)));
145
191
  }
146
192
  for (const u of found.unreadable) {
147
193
  process.stderr.write(`[geneseed] WARN: ${host}: could not read retired skill folder ${u}; it stays\n`);
@@ -155,4 +201,5 @@ export function pruneRetiredSkills(host, cfg, oldOwned) {
155
201
  process.stderr.write(`[geneseed] WARN: ${host}: could not move retired skill skills/${name} aside (${e.message}); it stays\n`);
156
202
  }
157
203
  }
204
+ return found.held;
158
205
  }
@@ -523,10 +523,20 @@ export function skillAliases(src = SRC) {
523
523
  * the whole rebuild. A retired name is dropped with a notice instead (excluding a skill that
524
524
  * no longer ships is already true), and the doctor refuses it as a new skill or alias name, so
525
525
  * it never comes back meaning something else — `RETIRED_RULE_IDS`' contract, for skills.
526
+ * A name taken back out moves to `REVIVED_SKILL_IDS` below.
526
527
  */
527
528
  export const RETIRED_SKILL_IDS = {
528
529
  tickets: 'removed in the 2026-10 sharpen; plan slices the work now',
529
- herdr: 'removed 2026-10; Orca covers multi-pane and multi-agent work',
530
+ };
531
+
532
+ /**
533
+ * Retired names that ship again, for the same tool, so an old `--exclude-skills <name>` still
534
+ * means what it meant. Kept because an older build's render may still sit unowned under the
535
+ * name: `retiredSkillNames` (`./retired-skills.mjs`) keeps each one a prune candidate, so that
536
+ * copy is moved aside instead of being kept as the user's file.
537
+ */
538
+ export const REVIVED_SKILL_IDS = {
539
+ herdr: 'retired 2026-10; back 2026-11 as a terminal-tools kit skill for the same tool',
530
540
  };
531
541
 
532
542
  /**
@@ -584,6 +594,10 @@ export const GATE_SWITCHES = [
584
594
  // Cure the Cause's weakened-test note, edit time and turn end. Advisory, so no gate the doctor
585
595
  // pins (`HOOK_PINNED`; ledger key `cure-the-cause`): `law: null`, though the console shows it on Rule VIII.
586
596
  { key: 'testNote', flag: '--no-test-note', arg: 'noTestNote', marker: 'Test note', law: null },
597
+ // Consent Before Push's own-branch pass (user decision 2026-11-13): off is STRICT consent, every
598
+ // commit and push asks again. A switch that adds asks, so its flag does not read `--no-*`; the
599
+ // contract is the others' all the same: armed by default, a marker line only when off.
600
+ { key: 'ownBranchPass', flag: '--strict-consent', arg: 'strictConsent', marker: 'Own-branch pass', law: null },
587
601
  ];
588
602
 
589
603
  /**
@@ -146,11 +146,14 @@ the project's own. Follow the root \`AGENTS.md\`.
146
146
  * template's sigil paragraph — below the banner — the first reply to a real request carried
147
147
  * no sigil; with this paragraph on top it did. Bob's own greeting persona outranks a rule
148
148
  * that does not say it overrides it. A bare "hi" still gets Bob's fixed welcome either way.
149
+ * Seen live (2026-11): told only "begin with this line", Bob also echoed the theme's fenced
150
+ * banner right under it — two banners per first reply — so the override forbids the echo.
149
151
  */
150
152
  export function bobFirstReply(sigil) {
151
153
  return '**First-reply override — highest priority.** Your very first reply in every '
152
154
  + 'conversation MUST begin with this exact line, before anything else and instead of any '
153
- + `default greeting or self-introduction:\n\n> ${sigil}\n\n`;
155
+ + 'default greeting or self-introduction. Print that line once and never reproduce the '
156
+ + `fenced banner block below it: the line is the whole greeting:\n\n> ${sigil}\n\n`;
154
157
  }
155
158
 
156
159
  /** `_build_render.PROFILE_FILE`. */