geneseed 4.31.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/DESIGN.md +2 -2
  3. package/README.md +6 -5
  4. package/SHIPPED.md +4 -3
  5. package/adapters/bob/README.md +6 -5
  6. package/adapters/claude-code/README.md +4 -3
  7. package/adapters/claude-code/skills/geneseed/SKILL.md +1 -1
  8. package/adapters/openclaude/README.md +4 -3
  9. package/adapters/opencode/GLOBAL-HARNESS-SPEC.md +3 -1
  10. package/adapters/opencode/HOW-OPENCODE-LOADS.md +2 -1
  11. package/adapters/opencode/README.md +18 -18
  12. package/adapters/opencode/plugins/geneseed-activity.js +57 -1
  13. package/adapters/opencode/plugins/geneseed-context.js +220 -18
  14. package/adapters/opencode/plugins/geneseed-guard.js +578 -74
  15. package/adapters/opencode/plugins/geneseed-learn.js +97 -23
  16. package/bin/geneseed-cli.mjs +17 -25
  17. package/bin/geneseed-hook.mjs +23 -8
  18. package/docs/DESIGN.md +175 -0
  19. package/docs/PRD.md +111 -0
  20. package/docs/README.md +3 -2
  21. package/docs/architecture.md +145 -0
  22. package/docs/concepts/agents.md +1 -1
  23. package/docs/concepts/collaboration.md +1 -1
  24. package/docs/concepts/enforcement-table.md +1 -1
  25. package/docs/concepts/exclusions.md +6 -6
  26. package/docs/concepts/footprint.md +1 -1
  27. package/docs/concepts/foreman-mode.md +2 -2
  28. package/docs/concepts/hook-gates.md +1 -1
  29. package/docs/concepts/hooks.md +27 -11
  30. package/docs/concepts/host-matrix.md +3 -3
  31. package/docs/concepts/hosts.md +1 -1
  32. package/docs/concepts/kits.md +3 -1
  33. package/docs/concepts/loop-bricks.md +1 -1
  34. package/docs/concepts/loop-notes.md +4 -2
  35. package/docs/concepts/loop-templates.md +7 -4
  36. package/docs/concepts/loops.md +3 -0
  37. package/docs/concepts/ownership.md +2 -2
  38. package/docs/concepts/rules.md +15 -2
  39. package/docs/concepts/shared-tier.md +73 -0
  40. package/docs/concepts/skills.md +2 -2
  41. package/docs/concepts/themes.md +1 -1
  42. package/docs/extending.md +13 -12
  43. package/docs/guides/install-claude-code.md +1 -1
  44. package/docs/guides/install-opencode.md +1 -1
  45. package/docs/guides/migrate.md +4 -2
  46. package/docs/guides/project-context.md +2 -2
  47. package/docs/guides/run-a-loop.md +1 -1
  48. package/docs/guides/set-up-ownership.md +1 -1
  49. package/docs/guides/setup-footprint.md +1 -1
  50. package/docs/guides/uninstall.md +2 -1
  51. package/docs/guides/upgrade-to-5.md +116 -0
  52. package/docs/guides/upgrade.md +21 -9
  53. package/docs/guides/wiki.md +3 -3
  54. package/docs/reference/env-context.md +5 -3
  55. package/docs/reference/environment.md +1 -1
  56. package/docs/reference/glossary.md +2 -0
  57. package/docs/reference/loop-actions.md +1 -1
  58. package/docs/reference/opencode-plugins.md +3 -3
  59. package/docs/reference/plugin-activity.md +1 -1
  60. package/docs/reference/plugin-context.md +5 -0
  61. package/docs/reference/plugin-guard.md +14 -6
  62. package/docs/reference/plugin-learn.md +13 -6
  63. package/docs/reference/troubleshoot-hooks.md +3 -3
  64. package/docs/reference/troubleshoot-update.md +14 -0
  65. package/docs/token-footprint.md +4 -3
  66. package/docs/understand/a-day.md +2 -2
  67. package/docs/understand/design-choices-install.md +2 -1
  68. package/docs/understand/enforced-vs-asked.md +4 -3
  69. package/docs/understand/machine-bob.md +3 -1
  70. package/docs/understand/machine-claude.md +7 -5
  71. package/docs/understand/machine-opencode.md +7 -5
  72. package/docs/understand/on-your-machine.md +4 -0
  73. package/docs/understand/take-it-out.md +1 -1
  74. package/docs/web-ui.md +141 -73
  75. package/harness.config.json +1 -1
  76. package/js/README.md +10 -6
  77. package/js/build/args.mjs +10 -8
  78. package/js/build/bundle.mjs +11 -13
  79. package/js/build/driver.mjs +66 -65
  80. package/js/build/emit-claude.mjs +22 -16
  81. package/js/build/emit-common.mjs +4 -5
  82. package/js/build/emit-opencode.mjs +22 -22
  83. package/js/build/fold.mjs +515 -0
  84. package/js/build/generate.mjs +41 -52
  85. package/js/build/render.mjs +115 -29
  86. package/js/build/source.mjs +4 -1
  87. package/js/build/stubs.mjs +70 -9
  88. package/js/build/version.mjs +10 -10
  89. package/js/cli-table.json +23 -83
  90. package/js/hosts/activity.mjs +2 -2
  91. package/js/hosts/geneseed-dir.mjs +1 -1
  92. package/js/hosts/hooks-context.mjs +410 -99
  93. package/js/hosts/hooks-done.mjs +97 -31
  94. package/js/hosts/hooks-learn.mjs +38 -7
  95. package/js/hosts/hooks-prims.mjs +69 -2
  96. package/js/hosts/hooks.mjs +300 -64
  97. package/js/hosts/hosts.mjs +150 -51
  98. package/js/hosts/installs.mjs +55 -167
  99. package/js/hosts/link.mjs +3 -5
  100. package/js/hosts/mcp.mjs +1 -1
  101. package/js/hosts/memory-files.mjs +219 -17
  102. package/js/hosts/ownership-gate.mjs +1 -1
  103. package/js/hosts/settings.mjs +18 -13
  104. package/js/hosts/shim.mjs +4 -33
  105. package/js/hosts/store-watch.mjs +189 -0
  106. package/js/inspect/checks-authoring.mjs +3 -3
  107. package/js/inspect/checks-build.mjs +45 -18
  108. package/js/inspect/checks-counts.mjs +4 -4
  109. package/js/inspect/checks-repo.mjs +13 -14
  110. package/js/inspect/cost.mjs +24 -2
  111. package/js/inspect/diff.mjs +123 -123
  112. package/js/inspect/doctor.mjs +22 -27
  113. package/js/inspect/excludes.mjs +181 -62
  114. package/js/inspect/inventory.mjs +22 -27
  115. package/js/inspect/registry.mjs +106 -30
  116. package/js/inspect/scan.mjs +5 -5
  117. package/js/inspect/status.mjs +141 -119
  118. package/js/inspect/validate.mjs +22 -24
  119. package/js/lib/fs.mjs +47 -50
  120. package/js/lib/json.mjs +10 -17
  121. package/js/lib/machine-dir.mjs +73 -0
  122. package/js/lib/paths.mjs +22 -33
  123. package/js/lib/proc.mjs +1 -1
  124. package/js/lib/prompt.mjs +19 -27
  125. package/js/lib/text.mjs +8 -12
  126. package/js/lib/udiff.mjs +11 -15
  127. package/js/loop/catalog.mjs +2 -3
  128. package/js/loop/state.mjs +15 -5
  129. package/js/maintain/memory.mjs +17 -17
  130. package/js/maintain/migrate.mjs +79 -89
  131. package/js/maintain/setup.mjs +43 -32
  132. package/js/maintain/uninstall.mjs +43 -61
  133. package/js/maintain/update.mjs +200 -93
  134. package/js/ui/anim.mjs +21 -35
  135. package/js/ui/cli.mjs +36 -58
  136. package/js/ui/menu.mjs +22 -45
  137. package/js/ui/tui.mjs +27 -67
  138. package/js/web/actions.mjs +38 -38
  139. package/js/web/api.mjs +132 -76
  140. package/js/web/catalog.mjs +175 -46
  141. package/js/web/docs.mjs +33 -12
  142. package/js/web/doctor-worker.mjs +14 -0
  143. package/js/web/handler.mjs +14 -5
  144. package/js/web/routes.mjs +17 -19
  145. package/js/web/state.mjs +78 -19
  146. package/js/web/update-check.mjs +25 -10
  147. package/js/web/user-files.mjs +50 -105
  148. package/package.json +7 -4
  149. package/registry.json +48 -55
  150. package/src/AGENT.md.tmpl +13 -14
  151. package/src/agents/_self-improvement.md +1 -1
  152. package/src/agents/_template.md +4 -1
  153. package/src/agents/advocate.md +1 -1
  154. package/src/agents/architect.md +1 -1
  155. package/src/agents/developer.md +6 -3
  156. package/src/agents/devops-engineer.md +1 -1
  157. package/src/agents/docker-expert.md +1 -1
  158. package/src/agents/docs.md +1 -1
  159. package/src/agents/empiricist.md +1 -1
  160. package/src/agents/explorer.md +1 -1
  161. package/src/agents/framer.md +1 -1
  162. package/src/agents/historian.md +1 -1
  163. package/src/agents/kubernetes-specialist.md +1 -1
  164. package/src/agents/memory-curator.md +2 -2
  165. package/src/agents/operator.md +1 -1
  166. package/src/agents/performance.md +1 -1
  167. package/src/agents/pragmatist.md +1 -1
  168. package/src/agents/react-engineer.md +1 -1
  169. package/src/agents/react-reviewer.md +1 -1
  170. package/src/agents/researcher.md +1 -1
  171. package/src/agents/reviewer.md +1 -1
  172. package/src/agents/security.md +1 -1
  173. package/src/agents/skeptic.md +1 -1
  174. package/src/agents/spring-boot-engineer.md +1 -1
  175. package/src/agents/spring-reviewer.md +1 -1
  176. package/src/agents/spring-security.md +1 -1
  177. package/src/agents/steward.md +1 -1
  178. package/src/agents/tester.md +5 -2
  179. package/src/agents/user-advocate.md +1 -1
  180. package/src/agents/visionary.md +1 -1
  181. package/src/bricks/apply.md +3 -0
  182. package/src/bricks/test.md +6 -4
  183. package/src/loops/bugfix.json +11 -5
  184. package/src/loops/feature.json +7 -4
  185. package/src/memory/README.md +1 -1
  186. package/src/skills/_self-improvement.md +2 -2
  187. package/src/skills/daydream/SKILL.md +2 -2
  188. package/src/skills/daydream/instructions.md +1 -1
  189. package/src/skills/geneseed.md +1 -1
  190. package/src/skills/learn-mode.md +1 -2
  191. package/src/skills/loop.md +1 -0
  192. package/src/skills/profile.md +2 -2
  193. package/src/skills/rule/approve.md +69 -0
  194. package/src/skills/rule/consolidate.md +3 -3
  195. package/src/skills/rule.md +13 -5
  196. package/src/skills/ship.md +9 -1
  197. package/src/skills/skill-forge.md +1 -1
  198. package/src/skills/teach.md +29 -12
  199. package/src/skills/wiki.md +1 -1
  200. package/themes/_TEMPLATE.json +1 -2
  201. package/themes/biker.json +1 -2
  202. package/themes/commentator.json +1 -2
  203. package/themes/cyberpunk.json +1 -2
  204. package/themes/gamer.json +1 -2
  205. package/themes/imperial.json +1 -2
  206. package/themes/joker.json +1 -2
  207. package/themes/marvin.json +1 -2
  208. package/themes/mean.json +1 -2
  209. package/themes/military.json +1 -2
  210. package/themes/neutral.json +1 -2
  211. package/themes/pirate.json +1 -2
  212. package/themes/sports.json +1 -2
  213. package/themes/verstappen.json +1 -2
  214. package/themes/wizard.json +1 -2
  215. package/web/dist/assets/Activity-D8G4eClY.js +1 -0
  216. package/web/dist/assets/ActivityDetail-BtOBYk3M.js +1 -0
  217. package/web/dist/assets/AgentGlyph-k6o3gCM1.js +1 -0
  218. package/web/dist/assets/Bonsai-B_y20b3i.js +1 -0
  219. package/web/dist/assets/{CopyButton-IXnXzH4Y.js → CopyButton-CHQte7Ap.js} +1 -1
  220. package/web/dist/assets/Dashboard-B8uXeJZ_.js +2 -0
  221. package/web/dist/assets/{DataTable-BWbUx4bY.js → DataTable-b9zTShqJ.js} +1 -1
  222. package/web/dist/assets/Docs-Dgv_MWfT.js +5 -0
  223. package/web/dist/assets/{EmptyState-1sPNleqv.js → EmptyState-CY5Pm2xy.js} +1 -1
  224. package/web/dist/assets/FilterInput-qGKNSlxv.js +1 -0
  225. package/web/dist/assets/GreenhouseView-CSzTMSl_.js +1 -0
  226. package/web/dist/assets/Installs-BDk9lqBI.js +3 -0
  227. package/web/dist/assets/JournalView-CvRk1-m5.js +1 -0
  228. package/web/dist/assets/Kits-CoITzxWM.js +1 -0
  229. package/web/dist/assets/Laws-Ctf5r9rE.js +3 -0
  230. package/web/dist/assets/Library-DNwHYVXt.js +3 -0
  231. package/web/dist/assets/{Loops-C5u7fQOR.js → Loops-S85PMQ8m.js} +2 -2
  232. package/web/dist/assets/Markdown-0ORz7tAc.js +69 -0
  233. package/web/dist/assets/OperatorHudView-DuGz_sTk.js +1 -0
  234. package/web/dist/assets/Personal-afJNwvRS.js +2 -0
  235. package/web/dist/assets/RailCats-AW92uhsX.js +1 -0
  236. package/web/dist/assets/Settings-CGDFz-6j.js +1 -0
  237. package/web/dist/assets/Tabs-1qLrnqmn.js +1 -0
  238. package/web/dist/assets/api-C46vAuqp.js +1 -0
  239. package/web/dist/assets/controls-D4wmg_pl.js +1 -0
  240. package/web/dist/assets/index-COTd4TRZ.js +3 -0
  241. package/web/dist/assets/index-CtorA7uK.css +1 -0
  242. package/web/dist/assets/motion-RlUl1osO.js +1 -0
  243. package/web/dist/assets/react-C1iE8mnY.js +9 -0
  244. package/web/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  245. package/web/dist/assets/{sections-ChwaobfW.js → sections-CtFz7HFH.js} +1 -1
  246. package/web/dist/assets/{usePoll-bDFN-Hr6.js → usePoll-o8ul-Sog.js} +1 -1
  247. package/web/dist/index.html +7 -7
  248. package/src/skills/quiz.md +0 -44
  249. package/web/dist/assets/Activity-B7cFtS00.js +0 -1
  250. package/web/dist/assets/ActivityDetail-C-GbMmuW.js +0 -1
  251. package/web/dist/assets/Bonsai-_YyexVC5.js +0 -1
  252. package/web/dist/assets/Dashboard-sCfEjowQ.js +0 -2
  253. package/web/dist/assets/Docs-w3Y7M5Ts.js +0 -5
  254. package/web/dist/assets/FilterInput-CZREvrjX.js +0 -1
  255. package/web/dist/assets/GreenhouseView-BWWbMKmg.js +0 -1
  256. package/web/dist/assets/Installs-CnkdJ-VA.js +0 -3
  257. package/web/dist/assets/JournalView-C7bPD3fZ.js +0 -1
  258. package/web/dist/assets/KitApply-CQQbnThf.js +0 -1
  259. package/web/dist/assets/Kits-aj07N7mT.js +0 -1
  260. package/web/dist/assets/Laws-DZ38nl_H.js +0 -3
  261. package/web/dist/assets/Library-QCGXPV5h.js +0 -2
  262. package/web/dist/assets/Markdown-DpmmtW2Y.js +0 -65
  263. package/web/dist/assets/OperatorHudView-Blu1lqiZ.js +0 -1
  264. package/web/dist/assets/Personal-ox_MktWO.js +0 -2
  265. package/web/dist/assets/RailCats-BuJD4Jou.js +0 -1
  266. package/web/dist/assets/Tabs-CIPyMAX-.js +0 -1
  267. package/web/dist/assets/api-BxjLd7Qd.js +0 -1
  268. package/web/dist/assets/index-0GCxkY7m.css +0 -1
  269. package/web/dist/assets/index-CzDi9JpF.js +0 -3
  270. package/web/dist/assets/motion-CXaUMNkg.js +0 -1
  271. package/web/dist/assets/react-DlYQp10C.js +0 -9
  272. package/web/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * The sovereign-repo exclusion WRITER.
3
3
  *
4
- * THE READER WAS ALREADY HERE. `js/hosts/hosts.mjs` (since 2026-09; `hooks.mjs` before) has carried `sovereignBypass`, `EXCLUDES_FILE`
5
- * and `EXCLUDE_DIRS` since P5a: every hook call reads `excludes.json` and stands down when
4
+ * THE READER LIVES IN `js/hosts/hosts.mjs`, which carries `sovereignBypass`, `EXCLUDES_FILE`
5
+ * and `EXCLUDE_DIRS`: every hook call reads `excludes.json` and stands down when
6
6
  * cwd is under an excluded folder. This module is the other half — `harness exclude
7
7
  * add|remove|list`, which maintains that file across every global install and wires the
8
8
  * host-native per-repo suppression into the excluded repo.
@@ -10,8 +10,7 @@
10
10
  * THE WEB ENDPOINT IS THIS MODULE — there is exactly ONE writer. `js/web/actions.mjs`
11
11
  * dispatches straight to `excludeAdd`/`excludeRemove` here, and `apiExcludes` in
12
12
  * `js/web/api.mjs` is `excludesSnapshot()` unmodified, so the CLI and the console are one
13
- * writer over one user-owned file. It used to be two, with a Python endpoint calling the
14
- * same three names, and the surviving hazard is the one that outlived the split: two
13
+ * writer over one user-owned file. The surviving hazard is two
15
14
  * PROCESSES writing at the same instant. `writeExcludes` is temp-plus-rename, so a
16
15
  * concurrent pair loses one edit rather than tearing the file.
17
16
  *
@@ -22,11 +21,13 @@ import { existsSync, mkdirSync, readdirSync, renameSync, rmdirSync, unlinkSync }
22
21
  from 'node:fs';
23
22
  import path from 'node:path';
24
23
  import { EXCLUDES_FILE, EXCLUDES_STUB, BOB_RULES_STUB } from '../build/stubs.mjs';
25
- import { wireClaudeExcludes, unwireClaudeExcludes } from '../hosts/settings.mjs';
24
+ import { archiveStore } from '../hosts/memory-files.mjs';
25
+ import { loadJsonObject, wireClaudeExcludes, unwireClaudeExcludes } from '../hosts/settings.mjs';
26
26
  import { GLOBAL_MANIFEST, HOSTS, resolvePath } from '../hosts/hosts.mjs';
27
27
  import { readText, writeText, printOut, printErr, isDir, isFile, isOsError } from '../lib/fs.mjs';
28
28
  import { parseJson, jsonDumpsIndent, get, isDict } from '../lib/json.mjs';
29
29
  import { normcase, toPlatformPath } from '../lib/paths.mjs';
30
+ import { machineDir } from '../lib/machine-dir.mjs';
30
31
 
31
32
  /** The per-repo settings file a claudeMdExcludes entry goes in (Claude and OpenClaude). */
32
33
  const localSettings = (repo, host) =>
@@ -62,7 +63,7 @@ function globalInstalls() {
62
63
  try {
63
64
  cfg = configDir();
64
65
  } catch {
65
- continue; // a broken resolver must not kill the CLI, as the Python's bare `except`
66
+ continue; // a broken resolver must not kill the CLI
66
67
  }
67
68
  if (isFile(path.join(cfg, GLOBAL_MANIFEST))) out.push({ host, cfg });
68
69
  }
@@ -102,9 +103,9 @@ const canon = (p) => resolvePath(p);
102
103
  *
103
104
  * Resolved like `repo` itself (`canon`: `..` collapsed, symlinks followed), the one rule the
104
105
  * hook's `sovereignBypass` and the OpenCode plugins apply too — so an entry that EXCLUDES a
105
- * folder is exactly the entry `exclude remove` can take back. It used to compare lexically,
106
- * mirroring the former Python `Path()`, which made a hand-edited `<repo>/../repo` an entry the
107
- * plugins honoured, the hook ignored, and `remove` could not find.
106
+ * folder is exactly the entry `exclude remove` can take back. A lexical comparison would make
107
+ * a hand-edited `<repo>/../repo` an entry the plugins honoured, the hook ignored, and
108
+ * `remove` could not find.
108
109
  */
109
110
  function same(stored, repo) {
110
111
  if (typeof stored !== 'string' || !stored) return false;
@@ -115,6 +116,25 @@ function same(stored, repo) {
115
116
  }
116
117
  }
117
118
 
119
+ /**
120
+ * The shared list (B8): the machine tier's `excludes.json`, read by every global install's hook
121
+ * and plugin next to its own. It holds paths only; the `wired` receipts stay in each host's file,
122
+ * because only that host can unwire what it wired. Written beside the host files, so one stale
123
+ * host no longer decides which folders are silent.
124
+ */
125
+ function updateShared(change) {
126
+ const dir = machineDir();
127
+ const unsound = !listIsSound(dir);
128
+ const data = readExcludes(dir);
129
+ const before = JSON.stringify(data.excludes);
130
+ data.excludes = change(data.excludes);
131
+ if (JSON.stringify(data.excludes) === before) return; // a no-op remove creates nothing
132
+ // D10: a shared list that does not parse is moved aside before the write replaces it.
133
+ if (unsound) archiveStore(path.join(dir, EXCLUDES_FILE));
134
+ mkdirSync(dir, { recursive: true });
135
+ writeExcludes(dir, data);
136
+ }
137
+
118
138
  /**
119
139
  * `exclude_add` — add `path` to every global install's list and wire the per-repo
120
140
  * suppression. Idempotent; returns `{ok, path, messages}`.
@@ -128,55 +148,147 @@ export function excludeAdd(target) {
128
148
  return { ok: false, path: repo,
129
149
  messages: ['no global Geneseed install found — nothing to exclude from'] };
130
150
  }
131
- for (const { host, cfg } of installs) {
132
- const data = readExcludes(cfg);
133
- const prior = data.excludes.find((e) => isDict(e) && same(get(e, 'path'), repo));
134
- const priorWired = (isDict(prior) ? get(prior, 'wired') : null) || {};
135
- const wired = {};
136
- if ((host === 'claude' || host === 'openclaude') && isDir(repo)) {
137
- const added = wireClaudeExcludes(localSettings(repo, host), [claudeMdEntry(cfg)]);
138
- if (added.length) {
139
- wired.claude_md_excludes = added;
140
- } else if (get(priorWired, 'claude_md_excludes')) {
141
- // Idempotent re-add: OUR own prior excludeAdd call genuinely wired this entry
142
- // (confirmed by the manifest record), so ownership carries forward even though
143
- // wireClaudeExcludes reports nothing NEW this time.
144
- wired.claude_md_excludes = get(priorWired, 'claude_md_excludes');
145
- }
146
- // else: the entry was already present for some OTHER reason (e.g. a project install's
147
- // own project-bypasses-global wiring, or a bailed write) — do NOT fabricate ownership,
148
- // or a later excludeRemove would strip wiring we never created.
149
- if (!added.length) messages.push(`${host}: claudeMdExcludes already present (kept)`);
150
- const note = worktreeNote(host, cfg, repo);
151
- if (note) messages.push(note);
151
+ for (const { host, cfg } of installs) addToHost(host, cfg, repo, messages);
152
+ updateShared((list) => [...list.filter((e) => !(isDict(e) && same(get(e, 'path'), repo))),
153
+ { path: repo.split(path.sep).join('/') }]);
154
+ return { ok: true, path: repo, messages };
155
+ }
156
+
157
+ /**
158
+ * One install's half of `excludeAdd`: wire the per-repo suppression and keep the receipt. Returns
159
+ * the files it wrote in the repo, which belongs to the user: the fold names each one.
160
+ */
161
+ function addToHost(host, cfg, repo, messages, strict = false) {
162
+ const written = [];
163
+ const data = readExcludes(cfg);
164
+ const prior = data.excludes.find((e) => isDict(e) && same(get(e, 'path'), repo));
165
+ const priorWired = (isDict(prior) ? get(prior, 'wired') : null) || {};
166
+ const wired = {};
167
+ if ((host === 'claude' || host === 'openclaude') && isDir(repo)) {
168
+ const added = wireClaudeExcludes(localSettings(repo, host), [claudeMdEntry(cfg)]);
169
+ if (added.length) {
170
+ wired.claude_md_excludes = added;
171
+ written.push(localSettings(repo, host));
172
+ } else if (get(priorWired, 'claude_md_excludes')) {
173
+ // Idempotent re-add: OUR own prior excludeAdd call genuinely wired this entry
174
+ // (confirmed by the manifest record), so ownership carries forward even though
175
+ // wireClaudeExcludes reports nothing NEW this time.
176
+ wired.claude_md_excludes = get(priorWired, 'claude_md_excludes');
152
177
  }
153
- if (host === 'bob' && isDir(repo)) {
154
- const stub = path.join(repo, '.bob', 'rules', 'geneseed.md');
155
- if (existsSync(stub)) {
156
- // Ownership is decided by CONTENT, not mere existence — a re-add finds a stub that
157
- // already exists because WE wrote it last time; an existence-only check would misread
158
- // that as user content and orphan it on the next remove. Exact match means ours.
159
- let ours;
160
- try {
161
- ours = readText(stub) === BOB_RULES_STUB;
162
- } catch (e) {
163
- if (!isOsError(e)) throw e;
164
- ours = false;
165
- }
166
- wired.bob_rules_stub = ours;
167
- if (!ours) messages.push(`${host}: rules/geneseed.md already exists (kept, not ours)`);
178
+ // else: the entry was already present for some OTHER reason (e.g. a project install's
179
+ // own project-bypasses-global wiring, or a bailed write) — do NOT fabricate ownership,
180
+ // or a later excludeRemove would strip wiring we never created.
181
+ if (!added.length) {
182
+ // `wireClaudeExcludes` answers [] for both 'already there' and 'could not write' (a commented,
183
+ // torn or unwritable settings file). Only the first is wired; the second must not be counted as it.
184
+ if (hasClaudeExclude(localSettings(repo, host), claudeMdEntry(cfg))) {
185
+ messages.push(`${host}: claudeMdExcludes already present (kept)`);
168
186
  } else {
169
- mkdirSync(path.dirname(stub), { recursive: true });
170
- writeText(stub, BOB_RULES_STUB);
171
- wired.bob_rules_stub = true;
187
+ const why = `${host}: claudeMdExcludes NOT wired in ${localSettings(repo, host)} (see the warning above)`;
188
+ if (strict) throw new Error(why);
189
+ messages.push(why);
172
190
  }
173
191
  }
174
- const entries = data.excludes.filter((e) => !(isDict(e) && same(get(e, 'path'), repo)));
175
- entries.push({ path: repo.split(path.sep).join('/'), wired });
176
- data.excludes = entries;
177
- writeExcludes(cfg, data);
192
+ const note = worktreeNote(host, cfg, repo);
193
+ if (note) messages.push(note);
178
194
  }
179
- return { ok: true, path: repo, messages };
195
+ if (host === 'bob' && isDir(repo)) {
196
+ const stub = path.join(repo, '.bob', 'rules', 'geneseed.md');
197
+ if (existsSync(stub)) {
198
+ // Ownership is decided by CONTENT, not mere existence — a re-add finds a stub that
199
+ // already exists because WE wrote it last time; an existence-only check would misread
200
+ // that as user content and orphan it on the next remove. Exact match means ours.
201
+ let ours;
202
+ try {
203
+ ours = readText(stub) === BOB_RULES_STUB;
204
+ } catch (e) {
205
+ if (!isOsError(e)) throw e;
206
+ ours = false;
207
+ }
208
+ wired.bob_rules_stub = ours;
209
+ if (!ours) messages.push(`${host}: rules/geneseed.md already exists (kept, not ours)`);
210
+ } else {
211
+ mkdirSync(path.dirname(stub), { recursive: true });
212
+ writeText(stub, BOB_RULES_STUB);
213
+ wired.bob_rules_stub = true;
214
+ written.push(stub);
215
+ }
216
+ }
217
+ const entries = data.excludes.filter((e) => !(isDict(e) && same(get(e, 'path'), repo)));
218
+ entries.push({ path: repo.split(path.sep).join('/'), wired });
219
+ data.excludes = entries;
220
+ writeExcludes(cfg, data);
221
+ return written;
222
+ }
223
+
224
+ /** Does the settings file already carry this `claudeMdExcludes` entry? A file that does not load carries none. */
225
+ function hasClaudeExclude(file, entry) {
226
+ const { state, data } = loadJsonObject(file);
227
+ return state === 'ok' && Array.isArray(get(data, 'claudeMdExcludes')) && get(data, 'claudeMdExcludes').includes(entry);
228
+ }
229
+
230
+ /** What `addToHost` would write in `repo`, for a dry run. */
231
+ function wiringTargets(host, repo) {
232
+ if (!isDir(repo)) return [];
233
+ if (host === 'claude' || host === 'openclaude') return [localSettings(repo, host)];
234
+ const stub = path.join(repo, '.bob', 'rules', 'geneseed.md');
235
+ return host === 'bob' && !existsSync(stub) ? [stub] : [];
236
+ }
237
+
238
+ /** The folders a list names, resolved; a `~user` form names no folder (`same`). */
239
+ function reposOf(list) {
240
+ const out = [];
241
+ for (const e of list) {
242
+ const p = isDict(e) ? get(e, 'path') : e;
243
+ if (typeof p !== 'string' || !p) continue;
244
+ try { out.push(canon(p)); } catch { /* skipped, as `same` does */ }
245
+ }
246
+ return out;
247
+ }
248
+
249
+ const listedIn = (list, repo) => list.some((e) => same(isDict(e) ? get(e, 'path') : e, repo));
250
+
251
+ /** Does `cfg` hold a list a write would not destroy? `readExcludes` degrades a torn one to the stub. */
252
+ function listIsSound(cfg) {
253
+ const f = path.join(cfg, EXCLUDES_FILE);
254
+ if (!isFile(f)) return true;
255
+ try {
256
+ const data = parseJson(readText(f));
257
+ return isDict(data) && Array.isArray(get(data, 'excludes'));
258
+ } catch { return false; }
259
+ }
260
+
261
+ /**
262
+ * Fold step 3, both ways: this host's folders join the shared list, and a shared folder this host
263
+ * never heard of gets the wiring `exclude add` gave the installs it found then. Writes only what
264
+ * is missing, so a second run writes nothing. The share goes first and each repo answers for
265
+ * itself: one a write cannot reach lands in `errors`, and its entry stays out of this host's list,
266
+ * so the next emit retries it. Throws, leaving both files as they are, when either list does not
267
+ * parse: the write would replace what the user can still repair by hand.
268
+ */
269
+ export function foldExcludes(host, cfg, dryRun = false) {
270
+ const tier = machineDir();
271
+ for (const dir of [cfg, tier]) {
272
+ if (!listIsSound(dir)) throw new Error(`${path.join(dir, EXCLUDES_FILE)} does not parse`);
273
+ }
274
+ const own = readExcludes(cfg).excludes;
275
+ const shared = readExcludes(tier).excludes;
276
+ const toShare = [...new Set(reposOf(own))].filter((r) => !listedIn(shared, r));
277
+ const toWire = [...new Set(reposOf(shared))].filter((r) => !listedIn(own, r));
278
+ const paths = [];
279
+ const notices = [];
280
+ const errors = [];
281
+ if (dryRun) {
282
+ paths.push(...toWire.flatMap((repo) => wiringTargets(host, repo)));
283
+ } else {
284
+ if (toShare.length) {
285
+ updateShared((list) => [...list, ...toShare.map((r) => ({ path: r.split(path.sep).join('/') }))]);
286
+ }
287
+ for (const repo of toWire) {
288
+ try { paths.push(...addToHost(host, cfg, repo, notices, true)); } catch (e) { errors.push(`${repo}: ${e.message}`); }
289
+ }
290
+ }
291
+ return { added: toShare.length, wired: toWire.length - errors.length, paths, notices, errors };
180
292
  }
181
293
 
182
294
  /**
@@ -212,19 +324,23 @@ export function excludeRemove(target) {
212
324
  }
213
325
  } catch (e) {
214
326
  if (!isOsError(e)) throw e;
215
- // KNOWN DIVERGENCE, deliberately not papered over: Python interpolates
216
- // `str(OSError)` — `[Errno 13] Permission denied: '<path>'` — and `e.message` is
217
- // Node's own wording. No cell can reach this branch (`unlink` on a file that
327
+ // `e.message` is Node's own wording, not `[Errno 13] Permission denied: '<path>'`.
328
+ // No cell can reach this branch (`unlink` on a file that
218
329
  // `isFile` just confirmed, `rmdir` on a directory just measured empty), so a
219
- // translation table here would be an unobservable guess. Same class as P5b's
220
- // untested `die()` newline; `js/hosts/settings.mjs`'s `asOsError` is the same stub for
221
- // the same reason.
330
+ // translation table here would be an unobservable guess.
331
+ // `js/hosts/settings.mjs`'s `asOsError` is the same stub for the same reason.
222
332
  messages.push(`${host}: could not remove ${stub} (${e.message})`);
223
333
  }
224
334
  }
225
335
  data.excludes = keep;
226
336
  writeExcludes(cfg, data);
227
337
  }
338
+ // A folder only the shared list names (a fold put it there) is still excluded, so it comes out too.
339
+ updateShared((list) => {
340
+ const keep = list.filter((e) => !(isDict(e) && same(get(e, 'path'), repo)));
341
+ if (keep.length !== list.length) found = true;
342
+ return keep;
343
+ });
228
344
  if (!found) messages.push(`${repo} was not excluded`);
229
345
  return { ok: found, path: repo, messages };
230
346
  }
@@ -237,7 +353,7 @@ export function excludeRemove(target) {
237
353
  export function excludesSnapshot() {
238
354
  const installs = globalInstalls();
239
355
  const byPath = new Map();
240
- for (const { host, cfg } of installs) {
356
+ const collect = (cfg, host) => {
241
357
  for (const e of readExcludes(cfg).excludes) {
242
358
  const p = isDict(e) ? get(e, 'path') : e;
243
359
  if (typeof p !== 'string' || !p) continue;
@@ -246,9 +362,12 @@ export function excludesSnapshot() {
246
362
  byPath.set(key, { path: p, hosts: [],
247
363
  wired: (isDict(e) ? get(e, 'wired') : null) || {} });
248
364
  }
249
- byPath.get(key).hosts.push(host);
365
+ if (host) byPath.get(key).hosts.push(host);
250
366
  }
251
- }
367
+ };
368
+ for (const { host, cfg } of installs) collect(cfg, host);
369
+ // A folder only the shared list names is silent everywhere but wired nowhere: it lists with no host.
370
+ if (installs.length) collect(machineDir(), null);
252
371
  const excludes = [...byPath.values()].sort(
253
372
  (a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
254
373
  return { excludes, installs: installs.map(({ host, cfg }) => ({ host, cfg })) };
@@ -4,22 +4,18 @@
4
4
  * panel and the web console all read.
5
5
  *
6
6
  * WHY THIS FILE EXISTS RATHER THAN A THIRD COPY OF THE TABLES. `LAW_CLASS`, `SKILL_CLASS`,
7
- * `LAW_CLASSES` and `ENTITY_STATUSES` crossed in P5g, inside `js/inspect/doctor.mjs`, because
8
- * doctor's authoring gates are what validate them — and `js/inspect/status.mjs`'s docblock said
9
- * flatly that "the taxonomy P7 owns" was not ported, which was true of `_parse_laws` and
10
- * `entity_status` and had stopped being true of the tables. P6c needs all of it, so the
11
- * tables move HERE, to the module that mirrors where Python keeps them, and the doctor's
7
+ * `LAW_CLASSES` and `ENTITY_STATUSES` are validated by doctor's authoring gates, and the
8
+ * catalog needs all of them, so the
9
+ * tables live HERE, and the doctor's
12
10
  * check modules import them — `checks-authoring.mjs` takes `LAW_CLASS`, `LAW_CLASSES` and
13
11
  * `SKILL_CLASS`, `checks-repo.mjs` takes `ENTITY_STATUSES`. A copy of a value under test
14
12
  * silently stops being the value under test.
15
13
  *
16
- * AND `inventoryCounts` FOLDS BACK INTO `tuiInventory`. P5d shipped a counting-only twin
17
- * with a docblock warning that the two must not become two classifiers; this is the phase
18
- * that would have made them two, because `api_catalog` consumes the very fields the count
19
- * threw away. So there is one classifier — "a two-part relative path ending in `.md` and
20
- * not starting with `_`, under `agents/` or `skills/`" — and `inventoryCounts` is three
21
- * `length`s off it. The eleven `status` cells gate the counts; P6c's catalog cells gate
22
- * the fields; both run over the same walk.
14
+ * AND `inventoryCounts` IS THREE `length`s OFF `tuiInventory`: the two must not become two
15
+ * classifiers, because the catalog consumes the very fields the count throws away. So there
16
+ * is one classifier — "a two-part relative path ending in `.md` and
17
+ * not starting with `_`, under `agents/` or `skills/`". The eleven `status` cells gate the
18
+ * counts; the catalog cells gate the fields; both run over the same walk.
23
19
  */
24
20
  import path from 'node:path';
25
21
 
@@ -31,7 +27,7 @@ import { readText } from '../lib/fs.mjs';
31
27
  import { parseJson } from '../lib/json.mjs';
32
28
 
33
29
  /**
34
- * `_harness_tui.LAW_HEADING_RE` — a heading in the RENDERED laws file, e.g.
30
+ * A heading in the RENDERED laws file, e.g.
35
31
  * `### Rule IV — Deletion Is Deliberate`.
36
32
  *
37
33
  * The rendered side only: the unrendered source declares a rule as `{{LAW:<id>}} <Name>`, and
@@ -67,17 +63,17 @@ const ONTOLOGY_HEADING_RE = /^####\s+(.+?)\s*$/;
67
63
  /** The lead line of a pack file — `**Craft** — how code is written.` */
68
64
  const PACK_LEAD_RE = /^\*\*(.+?)\*\*\s+[—-]\s+(.+?)\s*$/;
69
65
 
70
- /** `_harness_tui.LAW_CLASS` — each rule's class, keyed by Roman numeral. */
66
+ /** Each rule's class, keyed by Roman numeral. */
71
67
  export const LAW_CLASS = {
72
68
  I: 'security', II: 'process', III: 'verify', IV: 'security', V: 'verify',
73
69
  VI: 'security', VII: 'security', VIII: 'craft', IX: 'verify',
74
70
  };
75
71
 
76
- /** `_harness_tui.ENTITY_STATUSES` — the lifecycle statuses `registry.json` may carry. */
72
+ /** The lifecycle statuses `registry.json` may carry. */
77
73
  export const ENTITY_STATUSES = ['experimental', 'approved', 'deprecated'];
78
74
 
79
75
  /**
80
- * `_harness_tui.LAW_CLASSES` — the six governance classes a law may carry.
76
+ * The six governance classes a law may carry.
81
77
  *
82
78
  * ⚠ SIX, THOUGH ONLY FOUR ARE IN USE. When the corpus became nine invariants, `context` and
83
79
  * `comms` stopped having a member — that material moved to the ontology and the doctrine packs,
@@ -87,7 +83,7 @@ export const ENTITY_STATUSES = ['experimental', 'approved', 'deprecated'];
87
83
  */
88
84
  export const LAW_CLASSES = ['security', 'process', 'verify', 'craft', 'context', 'comms'];
89
85
 
90
- /** `_harness_tui.SKILL_CLASS` — each skill's category, keyed by file stem. */
86
+ /** Each skill's category, keyed by file stem. */
91
87
  export const SKILL_CLASS = {
92
88
  brainstorm: 'design', plan: 'design', council: 'design',
93
89
  workflow: 'design', 'parallel-agents': 'design', pipeline: 'design',
@@ -109,7 +105,7 @@ export const SKILL_CLASS = {
109
105
  // `understand` before, which made that class a grab-bag.
110
106
  wiki: 'harness', geneseed: 'harness', rule: 'harness', profile: 'harness',
111
107
  'skill-forge': 'harness', adhd: 'harness',
112
- teach: 'learn', quiz: 'learn', 'learn-mode': 'learn',
108
+ teach: 'learn', 'learn-mode': 'learn',
113
109
  };
114
110
 
115
111
  /** `k in dict` — own keys only, where `k in obj` also finds `Object.prototype` members. */
@@ -122,10 +118,9 @@ const has = (obj, k) => Object.hasOwn(obj, k);
122
118
  * (including a blank one) to the CURRENT record's body. Text before the first heading is
123
119
  * dropped on the floor because `cur` is still null.
124
120
  *
125
- * `str.strip()`, applied at the end to every body. `trim()`'s whitespace set differs from
126
- * Python's only at U+FEFF, which is the standing item this port has carried since P4 — a
127
- * rendered body cannot end in a BOM, and a fourth primitive to say so would cost more than
128
- * it gates.
121
+ * `trim()`, applied at the end to every body. Its whitespace set differs from a
122
+ * strip-style one only at U+FEFF — a rendered body cannot end in a BOM, and a primitive to
123
+ * say so would cost more than it gates.
129
124
  */
130
125
  function parseSections(text, re, makeRecord) {
131
126
  const out = [];
@@ -145,7 +140,7 @@ function parseSections(text, re, makeRecord) {
145
140
  }
146
141
 
147
142
  /**
148
- * `_harness_tui._parse_laws` — the rendered laws file split into
143
+ * The rendered laws file split into
149
144
  * `{num, title, klass, body}`.
150
145
  */
151
146
  function parseLaws(text) {
@@ -188,9 +183,9 @@ function parseOntology(text) {
188
183
  }
189
184
 
190
185
  /**
191
- * `_harness_tui.load_registry` — the `entities` map from `registry.json`, or `{}`.
186
+ * The `entities` map from `registry.json`, or `{}`.
192
187
  *
193
- * Deliberately forgiving on BOTH failure modes, as the reference is: a missing file and a
188
+ * Deliberately forgiving on BOTH failure modes: a missing file and a
194
189
  * corrupt one both yield `{}`, which reads every badge as "unknown" rather than breaking
195
190
  * the browser. `registryProblems` in `js/inspect/checks-repo.mjs` is the loud reader of the same file
196
191
  * and stays separate — the two answer different questions.
@@ -207,7 +202,7 @@ export function loadRegistry() {
207
202
  }
208
203
 
209
204
  /**
210
- * `_harness_tui.entity_status` — one entity's lifecycle status, plus the two derived
205
+ * One entity's lifecycle status, plus the two derived
211
206
  * states that are never stored.
212
207
  *
213
208
  * An entity the registry has never heard of is "personal": your own skill dropped into the
@@ -225,7 +220,7 @@ export function entityStatus(registry, key) {
225
220
  }
226
221
 
227
222
  /**
228
- * `_harness_tui._tui_inventory` — render-accurate inventory of all three constitutional tiers,
223
+ * Render-accurate inventory of all three constitutional tiers,
229
224
  * plus every agent and skill with its one-line purpose, rendered spec, source and badge.
230
225
  *
231
226
  * THE WHOLE CATALOGUE, NOT THE BUILT SUBSET. All four pack files ship in every bundle