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
@@ -11,7 +11,8 @@
11
11
  * must never block, slow or change a tool call. It rides `tool-gate`, the verb Bob already runs
12
12
  * on every tool and Claude/OpenClaude route their `Skill|Agent|Task` matcher to, so no host pays
13
13
  * an extra process for it. The OpenCode guard plugin carries the same rules inline (a plugin
14
- * cannot import from here); `tests/unit/usage.test.mjs` holds both to one table.
14
+ * cannot import from here): `NAME_RE` by `tests/twins.mjs`, `usageOf` by hand, since it reads
15
+ * no Bob shape. `tests/unit/usage.test.mjs` holds both to one table.
15
16
  *
16
17
  * Off when `GENESEED_NO_USAGE` is set or the install holds a `.usage-off` marker.
17
18
  */
@@ -27,8 +28,10 @@ const NAME_RE = /^[A-Za-z0-9][\w.:@/-]{0,99}$/;
27
28
  * `{kind, name}` for a skill or subagent call, else null. Reads the Claude shape (`tool_name` /
28
29
  * `tool_input`: `Skill` → `skill`, `Agent` or the older `Task` → `subagent_type`), OpenCode's
29
30
  * (`skill` → `name`, `task` → `subagent_type`; V2 hooks see the pre-alias `subagent` → `agent`)
30
- * and, best-effort, Bob's (`tool` / `input`, any tool whose name contains "skill"): Bob's skill
31
- * tool name is unverified, no Bob runs here.
31
+ * and Bob's (`tool` / `input`): `spawn_subagent` → `name`, `start_subtask` → `mode`, and,
32
+ * best-effort, any tool whose name contains "skill" (Bob's skill tool name is unverified, no Bob
33
+ * runs here). A subtask's `title` is never read: it is free text the agent wrote, and this
34
+ * ledger records no prompt. Its mode is the nearest thing Bob has to an agent's name.
32
35
  */
33
36
  export function usageOf(payload) {
34
37
  if (!payload || typeof payload !== 'object') return null;
@@ -42,6 +45,9 @@ export function usageOf(payload) {
42
45
  } else if (tool === 'agent' || tool === 'task' || tool === 'subagent') {
43
46
  kind = 'agent';
44
47
  name = ti.subagent_type ?? ti.agent;
48
+ } else if (tool === 'spawn_subagent' || tool === 'start_subtask') {
49
+ kind = 'agent';
50
+ name = tool === 'spawn_subagent' ? ti.name : ti.mode;
45
51
  }
46
52
  if (!kind || typeof name !== 'string') return null;
47
53
  name = name.trim().replace(/^\/+/, '');
@@ -98,6 +98,37 @@ const BARE_CITE_RE = /\{\{LAW\}\}\s+[IVXLCDM]+\b|\{\{DOCTRINE\}\}\s+[a-z]+\s+\d+
98
98
  // legal everywhere, including in an invariant that points at the tier as a whole.
99
99
  const DOCTRINE_TOKEN_RE = /\{\{DOCTRINE(?:\}\}|:)/;
100
100
 
101
+ // The sources the carrier inlines, where an excluded rule's citations are removed at render. A
102
+ // kit's rules file is inlined too (`kitsBody`); the rest of a kit folder ships beside it.
103
+ const CARRIER_SOURCE_RE = /^(?:AGENT\.md\.tmpl$|modes\/|postures\/|doctrines\/|kits\/[^/]+\/rules\.md$)/;
104
+ const PAREN_RE = /\(([^()]*)\)/g;
105
+ const CITE_TOKEN_RE = /\{\{(?:LAW|DOCTRINE):[^}]*\}\}/g;
106
+
107
+ /**
108
+ * A parenthetical in a carrier source that cites a doctrine rule holds citations only.
109
+ *
110
+ * ⚠ THIS IS WHAT MAKES D3 SAFE TO RENDER. An excluded rule is off, so `dropExcludedCitations`
111
+ * (`js/build/render.mjs`) removes its citations from the carrier — but only a group made of
112
+ * citations alone, because only then does the sentence still read with the group gone.
113
+ * `(*Consent Before Push* stays with you)` would survive the render and keep invoking a rule the
114
+ * install switched off. A prose mention outside parentheses is fine: it describes, it binds
115
+ * nothing. Doctrine citations only, because a law cannot be excluded.
116
+ * @param {string} rel path under src/, posix
117
+ * @param {string} text the raw source
118
+ */
119
+ export function citationGroupProblems(rel, text) {
120
+ if (!CARRIER_SOURCE_RE.test(rel)) return [];
121
+ const problems = [];
122
+ for (const [whole, inner] of text.matchAll(PAREN_RE)) {
123
+ if (!inner.includes('{{DOCTRINE:')) continue;
124
+ if (!inner.replace(CITE_TOKEN_RE, '').replace(/[,\s]/g, '')) continue;
125
+ problems.push(`[authoring] ${rel} mixes a doctrine citation with other words in '${whole.replace(/\s+/g, ' ')}'`
126
+ + ' — an excluded rule\'s citation is removed from the carrier only when its parentheses hold'
127
+ + ' citations alone; move the words outside: "…, so X ({{DOCTRINE:<id>}})"');
128
+ }
129
+ return problems;
130
+ }
131
+
101
132
  /**
102
133
  * The rules the hooks enforce at the tool boundary, and the address each is bound to there. The
103
134
  * hook path cannot afford to read the canon on every tool call, so its gate-ledger keys
@@ -284,6 +315,7 @@ export function constitutionProblems() {
284
315
  + 'reference a toggleable one, or a pack-off build ships a rule pointing at text '
285
316
  + 'that is not there. State the point directly instead');
286
317
  }
318
+ problems.push(...citationGroupProblems(rel, text));
287
319
  for (const [bare] of text.matchAll(BARE_CITE_RE)) {
288
320
  problems.push(`[authoring] ${rel} cites '${bare.replace(/\s+/g, ' ')}' by number — numbers are `
289
321
  + 'positional and move when the canon does; cite {{LAW:<id>}} / {{DOCTRINE:<id>}}');
@@ -9,6 +9,8 @@
9
9
  * (`git reflog expire --expire=now --all`, Law IV in Bob's `BLOCK_RULES`) and one that must pass (`git status`).
10
10
  * A gate wired `--no-deletion-gate` passes the Law IV call by design, so `badCommandFor` swaps in a
11
11
  * root-wide scan (ops 2) it must still refuse — a disarmed install is not a gate that stopped working.
12
+ * Bob is asked in Bob's own shapes as well (`probesFor`): the legacy payload, and a `write_file`
13
+ * carrying a credential.
12
14
  * Both directions are judged, because "allows everything" and "refuses everything" (the
13
15
  * PowerShell-fallback case `hookShellProblems` can only infer) are both broken gates.
14
16
  *
@@ -44,7 +46,7 @@ import { spawnSync } from 'node:child_process';
44
46
  * runs everything through `tool-gate --host bob`. OpenCode's guard is an in-process plugin with
45
47
  * no command: `guardProbe` below imports it instead.
46
48
  */
47
- const PROBED_VERB = { claude: 'git-gate', openclaude: 'git-gate', bob: 'tool-gate' };
49
+ export const PROBED_VERB = { claude: 'git-gate', openclaude: 'git-gate', bob: 'tool-gate' };
48
50
 
49
51
  // A Law IV act that loses data in EVERY state: since the gate asks only on real loss
50
52
  // (2026-10-17), a state-dependent act such as `reset --hard` would pass on a clean tree.
@@ -68,6 +70,61 @@ function probePayload(command, cwd) {
68
70
  });
69
71
  }
70
72
 
73
+ /** The older Bob shape, `{event, tool, input}`, which `tool-gate` normalises at its entry. */
74
+ function legacyBobPayload(command) {
75
+ return JSON.stringify({
76
+ event: 'PreToolUse', session_id: 'geneseed-probe', tool: 'execute_command', input: { command },
77
+ });
78
+ }
79
+
80
+ /**
81
+ * A credential-shaped string, put together at run time: the literal would trip this repo's own
82
+ * secret scans, and Law I's hook on whoever edits this file. It is the documented AWS example
83
+ * key id, which opens no account.
84
+ */
85
+ const probeCredential = () => ['AK', 'IA', 'IOSFODNN7', 'EXAMPLE'].join('');
86
+
87
+ /** Bob's `write_file`, in the keys Bob 2.2.3 sends, carrying `probeCredential()`. */
88
+ function bobSecretWritePayload(cwd) {
89
+ return JSON.stringify({
90
+ session_id: 'geneseed-probe', hook_event_name: 'PreToolUse', tool_name: 'write_file',
91
+ tool_input: { path: 'geneseed-probe.txt', content: `aws_access_key_id = ${probeCredential()}\n` },
92
+ cwd,
93
+ });
94
+ }
95
+
96
+ /** What the Bob credential probe is called in a problem line. Never the credential itself. */
97
+ export const SECRET_PROBE_NAME = 'write_file with a credential';
98
+
99
+ /**
100
+ * The probes for one gate command: `{ shape, name, bad, good }`, each a payload pair. `shape`
101
+ * is '' for the first, so a Claude or OpenClaude problem line reads as it always did; `good` is
102
+ * null where only the refusal is asked.
103
+ *
104
+ * Claude and OpenClaude get the one Claude-shaped pair. BOB GETS THREE, because a Claude-shaped
105
+ * Bash call is not what Bob sends: `tool-gate` reads a `command` field wherever it sits, so
106
+ * that pair alone could pass while the gate was blind to Bob's own payloads. The second pair is
107
+ * the legacy `{event, tool, input}` shape, which `normaliseBobPayload` must still lift; the
108
+ * third is a `write_file`, Bob's own edit tool, carrying a credential, which reaches Law I
109
+ * through the rule half of the gate. A gate wired `--no-secrets-gate` passes that write by
110
+ * design, so the third probe is left out, the way `badCommandFor` swaps the Law IV command.
111
+ */
112
+ export function probesFor(host, command, cwd) {
113
+ const badCommand = badCommandFor(command);
114
+ const probes = [{
115
+ shape: '', name: badCommand, bad: probePayload(badCommand, cwd), good: probePayload(GOOD_COMMAND, cwd),
116
+ }];
117
+ if (host !== 'bob') return probes;
118
+ probes.push({
119
+ shape: "Bob's legacy payload", name: badCommand,
120
+ bad: legacyBobPayload(badCommand), good: legacyBobPayload(GOOD_COMMAND),
121
+ });
122
+ if (!/ --no-secrets-gate(?:\s|$)/.test(command)) {
123
+ probes.push({ shape: "Bob's write_file", name: SECRET_PROBE_NAME, bad: bobSecretWritePayload(cwd), good: null });
124
+ }
125
+ return probes;
126
+ }
127
+
71
128
  /**
72
129
  * The shell a host runs this handler under, as `{ exe, argv, label, verbatim }` — or null when
73
130
  * that shell is not on this machine. Mirrors the emit's own rule: an explicit
@@ -170,10 +227,14 @@ export function gateProbe(targets = installTargets(), { platform = process.platf
170
227
  }
171
228
  const verdict = withTempDir((tmp) => {
172
229
  const runEnv = { ...env, GENESEED_GATE_PROBE: '1', CLAUDE_PROJECT_DIR: tmp };
173
- const badCommand = badCommandFor(handler.command);
174
- const bad = runOnce(shell, probePayload(badCommand, tmp), tmp, runEnv);
175
- const good = runOnce(shell, probePayload(GOOD_COMMAND, tmp), tmp, runEnv);
176
- return probeVerdict(host, bad, good, badCommand);
230
+ // The first probe that fails is the verdict: one line per gate, naming the shape.
231
+ for (const p of probesFor(host, handler.command, tmp)) {
232
+ const bad = runOnce(shell, p.bad, tmp, runEnv);
233
+ const good = p.good ? runOnce(shell, p.good, tmp, runEnv) : { status: 0, stdout: '', stderr: '' };
234
+ const v = probeVerdict(host, bad, good, p.name);
235
+ if (v) return p.shape ? `${v} (${p.shape})` : v;
236
+ }
237
+ return null;
177
238
  }, 'geneseed-probe-');
178
239
  if (verdict) problems.push(`${label} under ${shell.label} ${verdict}`);
179
240
  else probed.push(`${path.normalize(cfg)} (${verb}, ${shell.label})`);
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The checks over the REPO's own records — the registry, committed secrets, the hook shim,
3
3
  * the vendored skill folders (their pins and their SKILL.md frontmatter), skill aliases and
4
- * side files, the `js/README.md` module map, the host tables, and the scorecard ratchet.
4
+ * side files, the `js/README.md` module map, the host tables (their columns, Bob's block set,
5
+ * the one place a verified claim may sit, citations nobody can open), and the scorecard ratchet.
5
6
  *
6
7
  * Same contract as `checks-build.mjs`: an array of problem strings, empty when clean, one
7
8
  * planted fault per check in the gate. This is the group that reads what the repo SAYS about
@@ -20,6 +21,7 @@ import { hookShimPath, shimDeadPaths } from '../hosts/shim.mjs';
20
21
  import { readText } from '../lib/fs.mjs';
21
22
  import { formatRepr, formatValue } from '../lib/json.mjs';
22
23
  import { splitLines } from '../lib/udiff.mjs';
24
+ import { HOOK_PINNED } from './checks-constitution.mjs';
23
25
  import { ENTITY_STATUSES } from './inventory.mjs';
24
26
  import { assessRepo } from './scorecard.mjs';
25
27
  import { badgeUrl, renderSvg } from './scorecard-svg.mjs';
@@ -547,7 +549,7 @@ export function moduleMapProblems() {
547
549
  * machine-facing table (config dirs, project markers, catalog flags), and a doc-table LABEL is
548
550
  * a fact about two Markdown files, not about an install.
549
551
  */
550
- const HOST_LABELS = { opencode: 'OpenCode', claude: 'Claude Code', bob: 'Bob', openclaude: 'OpenClaude' };
552
+ export const HOST_LABELS = { opencode: 'OpenCode', claude: 'Claude Code', bob: 'Bob', openclaude: 'OpenClaude' };
551
553
 
552
554
  /**
553
555
  * The two hand-written, one-column-per-host tables, and the non-host columns each one carries
@@ -615,6 +617,198 @@ export function hostMatrixProblems(root = ROOT) {
615
617
  return problems;
616
618
  }
617
619
 
620
+ /** `I`..`X` as the hook ledger numbers a law: the canon's label to the `law-N` key. */
621
+ const ROMAN = { I: 1, II: 2, III: 3, IV: 4, V: 5, VI: 6, VII: 7, VIII: 8, IX: 9, X: 10 };
622
+
623
+ /** `HOOK_PINNED`'s label (`IV`, `process 1`) as the hook's ledger key (`law-4`, `process-1`). */
624
+ const ledgerKey = (label) => (ROMAN[label] ? `law-${ROMAN[label]}` : label.replace(' ', '-'));
625
+
626
+ /** The ids inside `BLOCK_RULES = new Set([...])`, read off the source text; null when not found. */
627
+ function blockRulesOf(text) {
628
+ const m = /const BLOCK_RULES = new Set\(\[([^\]]*)\]\)/.exec(text);
629
+ return m ? new Set([...m[1].matchAll(/'([^']+)'/g)].map((x) => x[1])) : null;
630
+ }
631
+
632
+ /** Every `| … |` row of `text` as trimmed cells, the edge cells dropped. */
633
+ function tableRows(text) {
634
+ return text.split('\n').map((l) => l.trim()).filter((l) => l.startsWith('|'))
635
+ .map((l) => l.split('|').slice(1, -1).map((c) => c.trim()));
636
+ }
637
+
638
+ /**
639
+ * The Bob column of `docs/concepts/enforcement-table.md` says "block" exactly for the rules in
640
+ * `BLOCK_RULES` (`js/hosts/hooks.mjs`).
641
+ *
642
+ * WHY. Eight pages restated that set in prose, and when `process-1` joined it (2026-11) one
643
+ * was updated. The pages now point at the table, so the table is the one copy left to hold to
644
+ * the code. A rule's Bob cell that STARTS with `block` is a block; anything else (`log only`,
645
+ * `not judged`) is not. The rows are the `HOOK_PINNED` ids, whose labels give the ledger key.
646
+ *
647
+ * `BLOCK_RULES` is read by a regex over the source, never imported: `hooks.mjs` reaches
648
+ * `loss.mjs`, which starts a process, and the doctor runs inside the CLI, which may not
649
+ * (`tests/unit/hook_cli.test.mjs`). A source line the regex no longer finds is its own problem,
650
+ * so a refactor cannot turn this arm into one that checks nothing.
651
+ */
652
+ export function bobBlockProblems(root = ROOT) {
653
+ const rel = 'docs/concepts/enforcement-table.md';
654
+ let table; let hooks;
655
+ try {
656
+ table = readText(path.join(root, ...rel.split('/')));
657
+ hooks = readText(path.join(root, 'js', 'hosts', 'hooks.mjs'));
658
+ } catch (e) {
659
+ return [`[authoring] the Bob block check cannot read its inputs: ${e.message}`];
660
+ }
661
+ const blocked = blockRulesOf(hooks);
662
+ if (!blocked) {
663
+ return ['[authoring] js/hosts/hooks.mjs no longer declares `const BLOCK_RULES = new Set([…])` '
664
+ + 'on one line — the Bob block check (js/inspect/checks-repo.mjs) reads that line'];
665
+ }
666
+ const rows = tableRows(table);
667
+ const header = rows.find((r) => r[0] === 'id');
668
+ const bob = header ? header.indexOf('Bob') : -1;
669
+ if (bob < 0) return [`[authoring] ${rel} has no \`id\` table with a Bob column`];
670
+ const problems = [];
671
+ for (const [id, label] of Object.entries(HOOK_PINNED)) {
672
+ const row = rows.find((r) => r[0] === `\`${id}\``);
673
+ if (!row) { problems.push(`[authoring] ${rel} has no row for \`${id}\`, a rule the hooks gate`); continue; }
674
+ const says = /^block\b/.test(row[bob] || '');
675
+ const does = blocked.has(ledgerKey(label));
676
+ if (says !== does) {
677
+ problems.push(`[authoring] ${rel}: the Bob cell of \`${id}\` ${says ? 'says' : 'does not say'} `
678
+ + `"block", but BLOCK_RULES (js/hosts/hooks.mjs) ${does ? 'has' : 'does not have'} `
679
+ + `${ledgerKey(label)} — the table is the one statement of what Bob refuses`);
680
+ }
681
+ }
682
+ return problems;
683
+ }
684
+
685
+ /**
686
+ * Directories a walk of the checkout must not enter: the VCS directory, installed packages,
687
+ * build output, and the local working trees `.gitignore` names. The doctor cannot ask which
688
+ * files are tracked (no spawn in the CLI), so this list stands in for it; `docs/reviews` is
689
+ * here because a maintainer's machine has one.
690
+ */
691
+ const WALK_SKIP = new Set([
692
+ '.git', 'node_modules', 'web/node_modules', 'web/dist', 'Harness', 'archived-Harness',
693
+ 'improvements', 'coverage', 'reports', '.stryker-tmp', '.superpowers', '.geneseed',
694
+ '.claude/worktrees', 'docs/specs', 'docs/reviews', 'docs/superpowers',
695
+ 'agents', 'doctrines', 'laws', 'memory', 'modes', 'ontology', 'postures', 'skills', 'notebook',
696
+ ]);
697
+
698
+ /** The text files a claim or a citation can sit in. */
699
+ const TEXT_EXT = new Set(['.md', '.mjs', '.js', '.cjs', '.ts', '.tsx', '.json', '.yml', '.yaml', '.txt', '.tmpl']);
700
+
701
+ /** Every text file under `root` outside `WALK_SKIP`, as sorted `/`-separated relative paths. */
702
+ function checkoutTextFiles(root) {
703
+ const out = [];
704
+ const walk = (dir, rel) => {
705
+ let entries;
706
+ try { entries = readdirSync(dir, { withFileTypes: true }); } catch { return; }
707
+ for (const e of entries) {
708
+ const r = rel ? `${rel}/${e.name}` : e.name;
709
+ if (WALK_SKIP.has(r)) continue;
710
+ if (e.isDirectory()) walk(path.join(dir, e.name), r);
711
+ else if (e.isFile() && TEXT_EXT.has(path.extname(e.name))) out.push(r);
712
+ }
713
+ };
714
+ walk(root, '');
715
+ return out.sort();
716
+ }
717
+
718
+ /** The heading that opens the one block allowed to say what is verified, and its file. */
719
+ const VERIFIED_FILE = 'docs/concepts/host-matrix.md';
720
+ const VERIFIED_HEADING = '## What is verified';
721
+
722
+ /**
723
+ * A verified/unverified claim about a host, in the words this repo used for one. Two shapes:
724
+ * "verified live" / "unverified live", and "not (yet) (been) run|verified|tested against".
725
+ */
726
+ const STRAY_CLAIM_RE = /(un)?verified live|not (yet )?(been )?(run|verified|tested) against/i;
727
+
728
+ /** `text` with the What-is-verified block (heading to the next `## `) blanked, lines kept. */
729
+ function withoutVerifiedBlock(text) {
730
+ const lines = text.split('\n');
731
+ const start = lines.findIndex((l) => l.trim() === VERIFIED_HEADING);
732
+ if (start < 0) return text;
733
+ let end = lines.findIndex((l, i) => i > start && /^## /.test(l));
734
+ if (end < 0) end = lines.length;
735
+ return lines.map((l, i) => (i >= start && i < end ? '' : l)).join('\n');
736
+ }
737
+
738
+ /**
739
+ * What is verified about a host is said in ONE place, `## What is verified` in
740
+ * `docs/concepts/host-matrix.md`; a Markdown file that says it anywhere else fails.
741
+ *
742
+ * WHY. Nine pages each carried their own sentence, written at different times, and they
743
+ * disagreed: two said OpenClaude had never been run while the canary ran it weekly, and three
744
+ * said nothing about Bob had been seen live after two live sessions. A claim with a date can
745
+ * only stay true where someone will look for it. `CHANGELOG.md` and `docs/adr/` are dated
746
+ * records of what was true then, so they are exempt; the block itself is where the words belong.
747
+ */
748
+ export function strayClaimProblems(root = ROOT) {
749
+ const problems = [];
750
+ const block = path.join(root, ...VERIFIED_FILE.split('/'));
751
+ if (!(isFile(block) && readText(block).split('\n').some((l) => l.trim() === VERIFIED_HEADING))) {
752
+ problems.push(`[authoring] ${VERIFIED_FILE} has no \`${VERIFIED_HEADING}\` section — the one `
753
+ + 'place that says what was checked against each host');
754
+ }
755
+ for (const rel of checkoutTextFiles(root)) {
756
+ if (!rel.endsWith('.md') || rel === 'CHANGELOG.md' || rel.startsWith('docs/adr/')) continue;
757
+ let text;
758
+ try { text = readText(path.join(root, ...rel.split('/'))); } catch { continue; }
759
+ if (rel === VERIFIED_FILE) text = withoutVerifiedBlock(text);
760
+ text.split('\n').forEach((line, i) => {
761
+ const m = STRAY_CLAIM_RE.exec(line);
762
+ if (m) {
763
+ problems.push(`[authoring] ${rel}:${i + 1} says "${m[0]}" — what is verified about a host `
764
+ + `is said only under \`${VERIFIED_HEADING}\` in ${VERIFIED_FILE}; link there instead`);
765
+ }
766
+ });
767
+ }
768
+ return problems;
769
+ }
770
+
771
+ /** A citation of the local review notes: the directory, or one of the three files by name. */
772
+ const LOCAL_NOTE_RE = /docs\/reviews\/|bob-(verdict|docs|code)\.md/;
773
+
774
+ /**
775
+ * Files that may name `docs/reviews/`: this arm and its test (the pattern and its fixtures),
776
+ * the changelog (a dated record) and the packaging test (it records that the directory must
777
+ * never ship). `.gitignore`, which is what makes the directory local, has no text extension
778
+ * and is never read.
779
+ */
780
+ const LOCAL_NOTE_EXEMPT = new Set([
781
+ 'js/inspect/checks-repo.mjs', 'tests/unit/doctor_host_claims.test.mjs', 'CHANGELOG.md',
782
+ 'tests/unit/package_manifest.test.mjs',
783
+ ]);
784
+
785
+ /**
786
+ * No tracked file cites `docs/reviews/`, which `.gitignore` keeps off every machine but the
787
+ * author's.
788
+ *
789
+ * WHY. Docblocks and the Bob adapter page justified decisions with "see bob-verdict.md I1":
790
+ * a reference nobody else can open, so the reason was lost exactly where it was needed. A
791
+ * citation names something in the repo (the What-is-verified block), a dated observation
792
+ * ("Bob 2.2.3 bundle, read 2026-10"), or the host's public docs.
793
+ */
794
+ export function localNoteProblems(root = ROOT) {
795
+ const problems = [];
796
+ for (const rel of checkoutTextFiles(root)) {
797
+ if (LOCAL_NOTE_EXEMPT.has(rel)) continue;
798
+ let text;
799
+ try { text = readText(path.join(root, ...rel.split('/'))); } catch { continue; }
800
+ text.split('\n').forEach((line, i) => {
801
+ const m = LOCAL_NOTE_RE.exec(line);
802
+ if (m) {
803
+ problems.push(`[authoring] ${rel}:${i + 1} cites ${m[0]} — docs/reviews/ is gitignored, so `
804
+ + 'nobody else can open it; cite the What-is-verified block, a dated observation or '
805
+ + "the host's own docs");
806
+ }
807
+ });
808
+ }
809
+ return problems;
810
+ }
811
+
618
812
  /**
619
813
  * The AI Harness Scorecard checks this repo passes, written out — the ratchet's floor.
620
814
  *
@@ -15,7 +15,10 @@
15
15
  * `disable-model-invocation` on Claude Code and OpenClaude; on OpenCode, which
16
16
  * ignores that key, the `permission.skill` deny in `opencode.json`; on Bob no
17
17
  * SKILL.md exists for one, so there is nothing to skip.
18
- * - `agents` the same for native agents; Bob has none, its agents table is in the carrier.
18
+ * - `agents` the same for native agents. Bob counts 0: it has native `agents/<name>.md`
19
+ * files, but whether Bob lists them to the model is unverified, so its agents
20
+ * table stays in the carrier (`catalog.agents`, js/hosts/hosts.mjs) and is
21
+ * counted there.
19
22
  * - `context` the session files the context hook injects (untouched seeds already skipped).
20
23
  * The per-repo project context is NOT counted: it changes with the working dir.
21
24
  */
@@ -38,6 +41,31 @@ import { isFile, readText } from '../lib/fs.mjs';
38
41
  */
39
42
  export const CARRIER_CEILING = { full: 66_432, lean: 40_312 };
40
43
 
44
+ /**
45
+ * THE CEILING ON THE SKILL LISTING: the most the names and descriptions of the skills the model
46
+ * lists may weigh on a Claude Code install with every skill on. It is `alwaysOnCost(...).skills`
47
+ * for a `claude` emit: user-only skills and aliases are on disk but out of the listing, so they
48
+ * count 0. The footprint does not change it: a description is the same text in both.
49
+ *
50
+ * WHY A CEILING. The listing is always-on context, and unlike the carrier nothing bounded its
51
+ * total. Each description has its own cap (`DESCRIPTION_CAP`, js/hosts/native.mjs), which
52
+ * bounds one skill and says nothing about fifty: the catalogue once reached 22k characters
53
+ * before anyone measured it (that docblock has the history). And the host has a listing budget
54
+ * of its own, past which it trims descriptions without a word, so growth here ends as routing
55
+ * text the model never sees. A new skill, or a longer trigger sentence, now has to fit, or the
56
+ * number is raised in the open.
57
+ *
58
+ * MEASURED 2026-11-12: 8 706 characters over 48 listed skills, the same for
59
+ * `claude` and `claude-global`, full and lean. The ceiling is that figure plus 2 %, rounded up
60
+ * (the headroom the lean carrier ceiling was given). `tests/unit/emit_smoke.test.mjs` gates it.
61
+ * Raise it by the measured overrun and say why here, after trying a shorter description first.
62
+ *
63
+ * `alwaysOnCost` returns it as `skillCeiling` for a `claude` install only, the one host it was
64
+ * measured on and is gated for, and the console draws it under that install's cost breakdown.
65
+ * Every other host answers `null`: no bar, not a bar against a number nobody measured there.
66
+ */
67
+ export const SKILL_LISTING_CEILING = 8_881;
68
+
41
69
  /**
42
70
  * THE TRADE OF `--shared-tier on`, stated once. `--help` (js/cli-table.json), the console's toggle
43
71
  * and docs/concepts/rules.md quote these sentences; tests/unit/shared_tier_option.test.mjs
@@ -118,7 +146,11 @@ export function alwaysOnCost({ host, root, dir, footprint }) {
118
146
  const { skills, agents } = catalogueChars(host, root, dir);
119
147
  let context = 0;
120
148
  for (const s of sessionLayers(dir, host)) context += s.text.length;
121
- return { carrier, skills, agents, context, ceiling: CARRIER_CEILING[footprint] ?? null };
149
+ return {
150
+ carrier, skills, agents, context,
151
+ ceiling: CARRIER_CEILING[footprint] ?? null,
152
+ skillCeiling: host === 'claude' ? SKILL_LISTING_CEILING : null,
153
+ };
122
154
  }
123
155
 
124
156
  /** The install's root instruction file, or undefined: the first of the host's carriers on disk. */
@@ -45,7 +45,7 @@ import {
45
45
  trustOfDir,
46
46
  readJsonMaybe, readMaybe, renderedTier, themeOfDir,
47
47
  } from '../hosts/installs.mjs';
48
- import { hashesOf, ownedState, safeLeaf } from '../hosts/owned.mjs';
48
+ import { hashesOf, ownedState, safeLeaf, textHash } from '../hosts/owned.mjs';
49
49
  import { hostGlobalInstalls as globalInstalls } from './excludes.mjs';
50
50
  import { unifiedDiff, splitLines } from '../lib/udiff.mjs';
51
51
  import { printOut, printErr, readText, writeText, isFile } from '../lib/fs.mjs';
@@ -280,6 +280,8 @@ export function diffCollect({
280
280
  const manifest = readJsonMaybe(path.join(dir, GLOBAL_MANIFEST));
281
281
  const deployedOwned = ownedSet(dir, manifest);
282
282
  const hashes = hashesOf(manifest);
283
+ // The bases of the files an emit left to the user, read with `hashes`' own defensive reader.
284
+ const keptHashes = hashesOf({ hashes: manifest?.kept_hashes });
283
285
  // STALE IS NOT AN EDIT. A file whose bytes still match the hash its emit recorded was never
284
286
  // touched: it differs only because the source moved on, and the next rebuild overwrites it.
285
287
  // Reporting it as "edited" told every install behind its source that it was hand-edited.
@@ -303,7 +305,18 @@ export function diffCollect({
303
305
  // being behind, never an edit, with or without hashes.
304
306
  const stale = rel === VERSION_MARKER
305
307
  || (hashed && ownedState(dir, rel, hashes) === 'unmodified');
306
- rec = { rel, status: stale ? 'stale' : 'edited', diff };
308
+ // KEPT OR DIVERGED (spec 2026-11-13, D1/D6). The base is what the last emit wrote here:
309
+ // `hashes[rel]` while the rel is still owned, else the `kept_hashes[rel]` the emit that
310
+ // refused it carried forward. The edit loses nothing while the fresh render still hashes
311
+ // to that base. `tb` is the LOCATED render read through `readText` (CRLF folded), so
312
+ // `textHash` of it is the manifest's `fileHash` of the same bytes. No base: diverged.
313
+ let diverged;
314
+ if (!stale) {
315
+ const base = Object.hasOwn(hashes, rel) ? hashes[rel]
316
+ : Object.hasOwn(keptHashes, rel) ? keptHashes[rel] : null;
317
+ diverged = base === null || textHash(tb) !== base;
318
+ }
319
+ rec = { rel, status: stale ? 'stale' : 'edited', diff, ...(diverged !== undefined && { diverged }) };
307
320
  }
308
321
  } else if (isFile(a)) {
309
322
  const body = splitLines(readText(a));
@@ -570,7 +583,12 @@ export function cmdDiff(args) {
570
583
  if (stale.length) printOut(`[diff] ${stale.length} file(s) behind source — rebuild to update them\n`);
571
584
  const notes = collectNotes(target);
572
585
  if (notes.length) printOut(`[diff] ${notes.length} self-improvement note(s) to back-port\n`);
573
- for (const f of edited) printOut(` ~ ${f.rel} (edited in deployed — review to back-port)\n`);
586
+ // The two states of an edit (spec 2026-11-13 §4): kept loses nothing, diverged misses an update.
587
+ for (const f of edited) {
588
+ printOut(` ~ ${f.rel} (edited in deployed — ${'diverged' in f && f.diverged === false
589
+ ? 'source unchanged, nothing missed'
590
+ : 'the source has moved; review to back-port, or restore'})\n`);
591
+ }
574
592
  for (const f of added) printOut(` + ${f.rel} (only in deployed — your addition)\n`);
575
593
  for (const f of missing) printOut(` - ${f.rel} (in source, not deployed — re-emit to add)\n`);
576
594
  for (const f of linked) printOut(` = ${f.rel} (a link — yours, left alone)\n`);
@@ -44,7 +44,10 @@ import { gateProbe, guardProbe } from './checks-probe.mjs';
44
44
  import {
45
45
  checkBuild, colorThemeProblems, renderedPathNotes, renderedProblems, themeParityProblems,
46
46
  } from './checks-build.mjs';
47
- import { hostMatrixProblems, moduleMapProblems, scorecardProblems, shimProblems } from './checks-repo.mjs';
47
+ import {
48
+ bobBlockProblems, hostMatrixProblems, localNoteProblems, moduleMapProblems, scorecardProblems,
49
+ shimProblems, strayClaimProblems,
50
+ } from './checks-repo.mjs';
48
51
  import { NOTE, isDoctorNote, sortedProblems, sortedUnique, stemOf, withTempDir } from './scan.mjs';
49
52
 
50
53
  /**
@@ -264,6 +267,8 @@ export function doctorCollect({
264
267
  problems = problems.concat(ran('shared_paths', 'Rendered shared paths', renderedPathNotes()));
265
268
  problems = problems.concat(ran('map', 'Module map', moduleMapProblems()));
266
269
  problems = problems.concat(ran('host_matrix', 'Host tables', hostMatrixProblems()));
270
+ problems = problems.concat(ran('host_claims', 'Host claims',
271
+ [...bobBlockProblems(), ...strayClaimProblems(), ...localNoteProblems()]));
267
272
  problems = problems.concat(ran('scorecard', 'Scorecard floor', scorecardProblems()));
268
273
  // There is no `cli` check: the table is the OWNED document (`js/cli-table.json`), so
269
274
  // there is no generator to fall behind and no second file to hash. What gates it is
@@ -105,7 +105,7 @@ export const SKILL_CLASS = {
105
105
  // knowledge base, terminal) rather than about the user's code. They sat under
106
106
  // `understand` before, which made that class a grab-bag.
107
107
  wiki: 'harness', geneseed: 'harness', rule: 'harness', profile: 'harness',
108
- 'skill-forge': 'harness', adhd: 'harness',
108
+ 'skill-forge': 'harness', adhd: 'harness', herdr: 'harness', 'opencode-cli': 'harness',
109
109
  teach: 'learn', 'learn-mode': 'learn',
110
110
  };
111
111
 
@@ -17,7 +17,7 @@ import path from 'node:path';
17
17
  /**
18
18
  * The wiki manifest's names, newest first. The last two are earlier seeds', read with no end date:
19
19
  * nothing yet tells a user an install missed the rename, so dropping one would lose a wiki in
20
- * silence. The OpenCode plugins carry a copy (tests/unit/claude.test.mjs holds the context one equal).
20
+ * silence. The OpenCode plugins carry this line (`node tests/twins.mjs --write` after changing it).
21
21
  */
22
22
  export const WIKI_NAMES = ['geneseed-wiki.jsonc', 'wiki.jsonc', 'wiki.json'];
23
23
 
@@ -6,7 +6,15 @@
6
6
  * hook shim all run the binaries directly. ESM links the whole graph before any body runs, so
7
7
  * this only helps while every file still PARSES on the old Node; it runs before any of them
8
8
  * executes. The hook exits 0: a hook must never block a tool call, and the message on stderr
9
- * is what the host surfaces. Nothing here may print to stdout — the hook's decision channel.
9
+ * is what the host surfaces.
10
+ *
11
+ * Stdout is the hook's decision channel, and exactly one thing may go there: a gate verb's ask.
12
+ * A gate that exits 0 with stdout empty reads to Claude Code as "the gate deferred", so on an old
13
+ * Node every gated call used to run unjudged with nobody told. The gate now asks, with the
14
+ * gate-error wording a gate that failed to load uses (`verbFailed`, bin/geneseed-hook.mjs). Not on
15
+ * Bob: it ignores stdout and has no ask tier, and exit 2 there would refuse every tool, reads
16
+ * included, so Bob keeps the stderr sentence and exit 0. Every other verb and binary prints
17
+ * nothing on stdout.
10
18
  */
11
19
  import path from 'node:path';
12
20
 
@@ -22,10 +30,42 @@ export function belowFloor(version, floor = NODE_FLOOR) {
22
30
  return false;
23
31
  }
24
32
 
25
- if (belowFloor(process.versions.node)) {
26
- process.stderr.write(`geneseed needs Node ${NODE_FLOOR.replace(/\.0$/, '')} or newer; `
27
- + `this is Node ${process.versions.node}. `
33
+ const GATE_VERBS = ['git-gate', 'rule-gate', 'tool-gate'];
34
+
35
+ /**
36
+ * What a gate verb says on stdout below the floor: the document `askDecision(gateSafe('gate-error',
37
+ * 'ask', …))` builds (js/hosts/hooks-prims.mjs), written out. A literal because this file runs
38
+ * where that module may not parse; tests/unit/node_floor.test.mjs holds the two equal, and fails
39
+ * when NODE_FLOOR moves without it.
40
+ */
41
+ export const FLOOR_ASK = '{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "ask", '
42
+ + '"permissionDecisionReason": "Geneseed gate error: the check failed with \\"a Node older than 22.7\\", '
43
+ + 'so nothing judged this call.\\nSafe choice: Deny, then run geneseed doctor.\\n'
44
+ + 'It asks because a gate that crashed cannot say this call is safe.\\n'
45
+ + 'If you allow it, this call runs with no check at all."}}\n';
46
+
47
+ /**
48
+ * What a binary started as `argv` (`process.argv`) prints and exits with on Node `version`, or
49
+ * null at or above the floor. Pure, so the table in tests/unit/node_floor.test.mjs can state every
50
+ * case without an old Node to run. Only syntax every ESM-capable Node parses.
51
+ */
52
+ export function floorVerdict(version, argv) {
53
+ if (!belowFloor(version)) return null;
54
+ const stderr = 'geneseed needs Node ' + NODE_FLOOR.replace(/\.0$/, '') + ' or newer; '
55
+ + 'this is Node ' + version + '. '
28
56
  + 'Install a current Node from https://nodejs.org (or your package manager), then run the '
29
- + 'command again.\n');
30
- process.exit(path.basename(process.argv[1] || '').startsWith('geneseed-hook') ? 0 : 1);
57
+ + 'command again.\n';
58
+ if (!path.basename(argv[1] || '').startsWith('geneseed-hook')) return { stderr: stderr, stdout: '', code: 1 };
59
+ const rest = argv.slice(3);
60
+ const bob = rest.some(function (tok, i) { return tok === '--host=bob' || (tok === 'bob' && rest[i - 1] === '--host'); });
61
+ const asks = GATE_VERBS.indexOf(argv[2]) !== -1 && !bob;
62
+ return { stderr: stderr, stdout: asks ? FLOOR_ASK : '', code: 0 };
63
+ }
64
+
65
+ const verdict = floorVerdict(process.versions.node, process.argv);
66
+ if (verdict) {
67
+ process.stderr.write(verdict.stderr);
68
+ // The platform's line end, as `printOut` (./fs.mjs) writes every other verdict.
69
+ if (verdict.stdout) process.stdout.write(process.platform === 'win32' ? verdict.stdout.replace(/\n/g, '\r\n') : verdict.stdout);
70
+ process.exit(verdict.code);
31
71
  }
@@ -336,7 +336,7 @@ export function collectSetupLines(kitMap = null) {
336
336
  const gated = Object.values(gates).some((on) => on === false);
337
337
  printOut(`\nAbout to run: geneseed build ${
338
338
  setupBuildArgs(theme, emit, out, root, footprint, posture, mode, doctrines, allPacks,
339
- excludeRules, undefined, excludeSkills, gates, kits, sharedTier).join(' ')}\n`);
339
+ excludeRules, undefined, excludeSkills, gates, kits, sharedTier).join(' ')} --reset\n`);
340
340
  if (!confirm('Proceed?', true)) return null;
341
341
  // The key only when there is something to carry, so a selection that excludes no skill and
342
342
  // switches off no gate is the same object it was before either existed.
@@ -542,6 +542,10 @@ export function setupLines() {
542
542
  // one command and run another.
543
543
  const argv = setupBuildArgs(theme, emit, out, root, footprint, posture, mode, doctrines,
544
544
  doctrineOptions().map(([n]) => n), excludeRules, undefined, excludeSkills, gates, kits, sharedTier);
545
+ // `--reset`: the wizard's answers are a WHOLE selection, and `setupBuildArgs` elides an axis at
546
+ // its default, so answering one back to it (mode direct, posture peer) over an install would
547
+ // otherwise trip the preserve guard (js/build/profile.mjs). The plan line above says the same.
548
+ argv.push('--reset');
545
549
  printOut(`Running: geneseed build ${argv.join(' ')}\n`);
546
550
  const rc = driverMain(argv);
547
551
  if (rc !== 0) {