geneseed 4.32.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 (245) hide show
  1. package/CHANGELOG.md +85 -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 +85 -18
  14. package/adapters/opencode/plugins/geneseed-guard.js +437 -76
  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 +5 -5
  26. package/docs/concepts/footprint.md +1 -1
  27. package/docs/concepts/foreman-mode.md +2 -2
  28. package/docs/concepts/hooks.md +22 -8
  29. package/docs/concepts/host-matrix.md +2 -2
  30. package/docs/concepts/hosts.md +1 -1
  31. package/docs/concepts/kits.md +3 -1
  32. package/docs/concepts/ownership.md +1 -1
  33. package/docs/concepts/rules.md +15 -2
  34. package/docs/concepts/shared-tier.md +73 -0
  35. package/docs/concepts/skills.md +2 -2
  36. package/docs/concepts/themes.md +1 -1
  37. package/docs/extending.md +13 -12
  38. package/docs/guides/install-claude-code.md +1 -1
  39. package/docs/guides/install-opencode.md +1 -1
  40. package/docs/guides/migrate.md +4 -2
  41. package/docs/guides/project-context.md +2 -2
  42. package/docs/guides/setup-footprint.md +1 -1
  43. package/docs/guides/uninstall.md +2 -1
  44. package/docs/guides/upgrade-to-5.md +116 -0
  45. package/docs/guides/upgrade.md +21 -9
  46. package/docs/guides/wiki.md +3 -3
  47. package/docs/reference/env-context.md +5 -3
  48. package/docs/reference/environment.md +1 -1
  49. package/docs/reference/glossary.md +2 -0
  50. package/docs/reference/opencode-plugins.md +3 -3
  51. package/docs/reference/plugin-activity.md +1 -1
  52. package/docs/reference/plugin-context.md +1 -0
  53. package/docs/reference/plugin-guard.md +14 -6
  54. package/docs/reference/plugin-learn.md +13 -6
  55. package/docs/reference/troubleshoot-hooks.md +3 -3
  56. package/docs/reference/troubleshoot-update.md +14 -0
  57. package/docs/token-footprint.md +4 -3
  58. package/docs/understand/a-day.md +2 -2
  59. package/docs/understand/design-choices-install.md +2 -1
  60. package/docs/understand/enforced-vs-asked.md +1 -1
  61. package/docs/understand/machine-bob.md +2 -0
  62. package/docs/understand/machine-claude.md +7 -5
  63. package/docs/understand/machine-opencode.md +7 -5
  64. package/docs/understand/on-your-machine.md +4 -0
  65. package/docs/understand/take-it-out.md +1 -1
  66. package/docs/web-ui.md +126 -68
  67. package/harness.config.json +1 -1
  68. package/js/README.md +10 -6
  69. package/js/build/args.mjs +10 -8
  70. package/js/build/bundle.mjs +11 -13
  71. package/js/build/driver.mjs +66 -65
  72. package/js/build/emit-claude.mjs +22 -16
  73. package/js/build/emit-common.mjs +4 -5
  74. package/js/build/emit-opencode.mjs +22 -22
  75. package/js/build/fold.mjs +515 -0
  76. package/js/build/generate.mjs +41 -52
  77. package/js/build/render.mjs +115 -29
  78. package/js/build/source.mjs +4 -1
  79. package/js/build/stubs.mjs +70 -9
  80. package/js/build/version.mjs +10 -10
  81. package/js/cli-table.json +23 -83
  82. package/js/hosts/activity.mjs +2 -2
  83. package/js/hosts/geneseed-dir.mjs +1 -1
  84. package/js/hosts/hooks-context.mjs +389 -99
  85. package/js/hosts/hooks-learn.mjs +38 -7
  86. package/js/hosts/hooks-prims.mjs +4 -2
  87. package/js/hosts/hooks.mjs +114 -39
  88. package/js/hosts/hosts.mjs +150 -51
  89. package/js/hosts/installs.mjs +55 -167
  90. package/js/hosts/link.mjs +3 -5
  91. package/js/hosts/mcp.mjs +1 -1
  92. package/js/hosts/memory-files.mjs +219 -17
  93. package/js/hosts/ownership-gate.mjs +1 -1
  94. package/js/hosts/settings.mjs +18 -13
  95. package/js/hosts/shim.mjs +4 -33
  96. package/js/hosts/store-watch.mjs +189 -0
  97. package/js/inspect/checks-authoring.mjs +3 -3
  98. package/js/inspect/checks-build.mjs +45 -18
  99. package/js/inspect/checks-counts.mjs +4 -4
  100. package/js/inspect/checks-repo.mjs +13 -14
  101. package/js/inspect/cost.mjs +24 -2
  102. package/js/inspect/diff.mjs +123 -123
  103. package/js/inspect/doctor.mjs +22 -27
  104. package/js/inspect/excludes.mjs +181 -62
  105. package/js/inspect/inventory.mjs +22 -27
  106. package/js/inspect/registry.mjs +106 -30
  107. package/js/inspect/scan.mjs +5 -5
  108. package/js/inspect/status.mjs +141 -119
  109. package/js/inspect/validate.mjs +22 -24
  110. package/js/lib/fs.mjs +47 -50
  111. package/js/lib/json.mjs +10 -17
  112. package/js/lib/machine-dir.mjs +73 -0
  113. package/js/lib/paths.mjs +22 -33
  114. package/js/lib/proc.mjs +1 -1
  115. package/js/lib/prompt.mjs +19 -27
  116. package/js/lib/text.mjs +8 -12
  117. package/js/lib/udiff.mjs +11 -15
  118. package/js/loop/catalog.mjs +2 -3
  119. package/js/maintain/memory.mjs +17 -17
  120. package/js/maintain/migrate.mjs +79 -89
  121. package/js/maintain/setup.mjs +43 -32
  122. package/js/maintain/uninstall.mjs +43 -61
  123. package/js/maintain/update.mjs +200 -93
  124. package/js/ui/anim.mjs +21 -35
  125. package/js/ui/cli.mjs +36 -58
  126. package/js/ui/menu.mjs +22 -45
  127. package/js/ui/tui.mjs +27 -67
  128. package/js/web/actions.mjs +34 -34
  129. package/js/web/api.mjs +130 -74
  130. package/js/web/catalog.mjs +175 -46
  131. package/js/web/docs.mjs +33 -12
  132. package/js/web/doctor-worker.mjs +14 -0
  133. package/js/web/handler.mjs +14 -5
  134. package/js/web/routes.mjs +17 -19
  135. package/js/web/state.mjs +78 -19
  136. package/js/web/update-check.mjs +25 -10
  137. package/js/web/user-files.mjs +50 -105
  138. package/package.json +7 -4
  139. package/registry.json +48 -55
  140. package/src/AGENT.md.tmpl +13 -14
  141. package/src/agents/_self-improvement.md +1 -1
  142. package/src/agents/_template.md +1 -1
  143. package/src/agents/advocate.md +1 -1
  144. package/src/agents/architect.md +1 -1
  145. package/src/agents/developer.md +1 -1
  146. package/src/agents/devops-engineer.md +1 -1
  147. package/src/agents/docker-expert.md +1 -1
  148. package/src/agents/docs.md +1 -1
  149. package/src/agents/empiricist.md +1 -1
  150. package/src/agents/explorer.md +1 -1
  151. package/src/agents/framer.md +1 -1
  152. package/src/agents/historian.md +1 -1
  153. package/src/agents/kubernetes-specialist.md +1 -1
  154. package/src/agents/memory-curator.md +2 -2
  155. package/src/agents/operator.md +1 -1
  156. package/src/agents/performance.md +1 -1
  157. package/src/agents/pragmatist.md +1 -1
  158. package/src/agents/react-engineer.md +1 -1
  159. package/src/agents/react-reviewer.md +1 -1
  160. package/src/agents/researcher.md +1 -1
  161. package/src/agents/reviewer.md +1 -1
  162. package/src/agents/security.md +1 -1
  163. package/src/agents/skeptic.md +1 -1
  164. package/src/agents/spring-boot-engineer.md +1 -1
  165. package/src/agents/spring-reviewer.md +1 -1
  166. package/src/agents/spring-security.md +1 -1
  167. package/src/agents/steward.md +1 -1
  168. package/src/agents/tester.md +1 -1
  169. package/src/agents/user-advocate.md +1 -1
  170. package/src/agents/visionary.md +1 -1
  171. package/src/memory/README.md +1 -1
  172. package/src/skills/_self-improvement.md +2 -2
  173. package/src/skills/daydream/SKILL.md +2 -2
  174. package/src/skills/daydream/instructions.md +1 -1
  175. package/src/skills/geneseed.md +1 -1
  176. package/src/skills/learn-mode.md +1 -2
  177. package/src/skills/profile.md +2 -2
  178. package/src/skills/rule/approve.md +69 -0
  179. package/src/skills/rule/consolidate.md +3 -3
  180. package/src/skills/rule.md +13 -5
  181. package/src/skills/skill-forge.md +1 -1
  182. package/src/skills/teach.md +29 -12
  183. package/src/skills/wiki.md +1 -1
  184. package/themes/_TEMPLATE.json +1 -2
  185. package/themes/biker.json +1 -2
  186. package/themes/commentator.json +1 -2
  187. package/themes/cyberpunk.json +1 -2
  188. package/themes/gamer.json +1 -2
  189. package/themes/imperial.json +1 -2
  190. package/themes/joker.json +1 -2
  191. package/themes/marvin.json +1 -2
  192. package/themes/mean.json +1 -2
  193. package/themes/military.json +1 -2
  194. package/themes/neutral.json +1 -2
  195. package/themes/pirate.json +1 -2
  196. package/themes/sports.json +1 -2
  197. package/themes/verstappen.json +1 -2
  198. package/themes/wizard.json +1 -2
  199. package/web/dist/assets/Activity-D8G4eClY.js +1 -0
  200. package/web/dist/assets/ActivityDetail-BtOBYk3M.js +1 -0
  201. package/web/dist/assets/AgentGlyph-k6o3gCM1.js +1 -0
  202. package/web/dist/assets/Bonsai-B_y20b3i.js +1 -0
  203. package/web/dist/assets/{CopyButton-C5Li6awl.js → CopyButton-CHQte7Ap.js} +1 -1
  204. package/web/dist/assets/Dashboard-B8uXeJZ_.js +2 -0
  205. package/web/dist/assets/Docs-Dgv_MWfT.js +5 -0
  206. package/web/dist/assets/GreenhouseView-CSzTMSl_.js +1 -0
  207. package/web/dist/assets/Installs-BDk9lqBI.js +3 -0
  208. package/web/dist/assets/JournalView-CvRk1-m5.js +1 -0
  209. package/web/dist/assets/Kits-CoITzxWM.js +1 -0
  210. package/web/dist/assets/Laws-Ctf5r9rE.js +3 -0
  211. package/web/dist/assets/Library-DNwHYVXt.js +3 -0
  212. package/web/dist/assets/{Loops-CzitjxGV.js → Loops-S85PMQ8m.js} +2 -2
  213. package/web/dist/assets/{Markdown-C4S4tTA7.js → Markdown-0ORz7tAc.js} +21 -21
  214. package/web/dist/assets/OperatorHudView-DuGz_sTk.js +1 -0
  215. package/web/dist/assets/Personal-afJNwvRS.js +2 -0
  216. package/web/dist/assets/{RailCats-D5weYPCS.js → RailCats-AW92uhsX.js} +1 -1
  217. package/web/dist/assets/Settings-CGDFz-6j.js +1 -0
  218. package/web/dist/assets/Tabs-1qLrnqmn.js +1 -0
  219. package/web/dist/assets/api-C46vAuqp.js +1 -0
  220. package/web/dist/assets/controls-D4wmg_pl.js +1 -0
  221. package/web/dist/assets/index-COTd4TRZ.js +3 -0
  222. package/web/dist/assets/index-CtorA7uK.css +1 -0
  223. package/web/dist/assets/motion-RlUl1osO.js +1 -0
  224. package/web/dist/assets/{sections-ChwaobfW.js → sections-CtFz7HFH.js} +1 -1
  225. package/web/dist/index.html +5 -5
  226. package/src/skills/quiz.md +0 -44
  227. package/web/dist/assets/Activity-Bjy64wHC.js +0 -1
  228. package/web/dist/assets/ActivityDetail-B0AaipP8.js +0 -1
  229. package/web/dist/assets/Bonsai-CJniRqaH.js +0 -1
  230. package/web/dist/assets/Dashboard-B-6DTmae.js +0 -2
  231. package/web/dist/assets/Docs-LRc30XL9.js +0 -5
  232. package/web/dist/assets/GreenhouseView-CcoYlaWo.js +0 -1
  233. package/web/dist/assets/Installs-dp1epTcE.js +0 -3
  234. package/web/dist/assets/JournalView-nFP4poCf.js +0 -1
  235. package/web/dist/assets/KitApply-DwyZUj57.js +0 -1
  236. package/web/dist/assets/Kits-C0IEdZXe.js +0 -1
  237. package/web/dist/assets/Laws-CkykmQWu.js +0 -3
  238. package/web/dist/assets/Library-Guh9HBZU.js +0 -2
  239. package/web/dist/assets/OperatorHudView-DLGNulIY.js +0 -1
  240. package/web/dist/assets/Personal-BMtberL8.js +0 -2
  241. package/web/dist/assets/Tabs-uYJqfuQt.js +0 -1
  242. package/web/dist/assets/api-BxjLd7Qd.js +0 -1
  243. package/web/dist/assets/index-DA7BiaE5.js +0 -3
  244. package/web/dist/assets/index-dbbDGFDq.css +0 -1
  245. package/web/dist/assets/motion-Bccx3zE8.js +0 -1
@@ -127,7 +127,7 @@ export function loopProblems() {
127
127
  }
128
128
 
129
129
  /**
130
- * `_harness_build._authoring_problems` — author-time gates on the source specs and plugins.
130
+ * Author-time gates on the source specs and plugins.
131
131
  *
132
132
  * Every agent/skill spec must carry a one-line `>` purpose blockquote as the FIRST content
133
133
  * block after its title, or its `description:` on every host either renders empty or silently
@@ -174,8 +174,8 @@ export function authoringProblems() {
174
174
  // THE ONE SPAWN. `node --check` and nothing else — see the module header, and
175
175
  // the `inspect/checks-authoring.mjs` row of the spawn allow-list in
176
176
  // `tests/unit/hook_cli.test.mjs`, which names this argv literally.
177
- // `NO_WINDOW` because the reference's `run()` folds `CREATE_NO_WINDOW` into every
178
- // CAPTURING spawn and this is one — and because this loop is the burst a user sees:
177
+ // `NO_WINDOW` because every CAPTURING spawn folds `CREATE_NO_WINDOW` in and this is
178
+ // one — and because this loop is the burst a user sees:
179
179
  // one console window per plugin, every time the web daemon runs the doctor.
180
180
  const r = spawnSync(node, ['--check', js], { encoding: 'utf-8', ...NO_WINDOW });
181
181
  if (r.status !== 0) {
@@ -10,14 +10,16 @@ import path from 'node:path';
10
10
  import { stripCapabilityLinks } from '../build/emit-common.mjs';
11
11
  import { STRUCTURE, renderAll } from '../build/render.mjs';
12
12
  import { CONFIG, CREDIT_RE, makeCfg } from '../build/source.mjs';
13
- import { CLAUDE_STYLE, hostCatalogsNatively, resolvePath } from '../hosts/hosts.mjs';
14
- import { EMIT_HOST_SCOPE, footprintOfDir, themeFiles } from '../hosts/installs.mjs';
13
+ import { CLAUDE_STYLE, HOSTS, hostCatalogsNatively, resolvePath } from '../hosts/hosts.mjs';
14
+ import { EMIT_HOST_SCOPE, footprintOfDir, readMaybe, renderedTier, themeFiles } from '../hosts/installs.mjs';
15
15
  import { isVendoredPath } from '../hosts/native.mjs';
16
16
  import { PALETTE_ROLES, colorThemeFiles } from '../hosts/opencode.mjs';
17
17
  import { readText, withDiscardableStderr } from '../lib/fs.mjs';
18
18
  import { parseJson, formatRepr } from '../lib/json.mjs';
19
+ import { renderedSharedRoot, sharedPaths } from '../lib/machine-dir.mjs';
20
+ import { normcase } from '../lib/paths.mjs';
19
21
  import {
20
- ABS_LINK_RE, LINK_RE, TOKEN_RE, has, isDir, isFile, rglob, sortedUnique, stemOf, stripCode, within,
22
+ ABS_LINK_RE, LINK_RE, NOTE, TOKEN_RE, has, isDir, isFile, rglob, sortedUnique, stemOf, stripCode, within,
21
23
  } from './scan.mjs';
22
24
  import { existsSync, readFileSync } from 'node:fs';
23
25
 
@@ -26,7 +28,7 @@ import { existsSync, readFileSync } from 'node:fs';
26
28
  // --------------------------------------------------------------------------------------
27
29
 
28
30
  /**
29
- * `_harness_build._link_problems` — dead links AND non-hermetic ones.
31
+ * Dead links AND non-hermetic ones.
30
32
  *
31
33
  * Hermeticity is what lets a bundle be copied or subtree-split into any repo; a link that
32
34
  * escapes `out` breaks it silently. The two are separate messages because they have separate
@@ -43,9 +45,8 @@ export function linkProblems(md, text, out, rel) {
43
45
  problems.push(`non-hermetic absolute link '${link}' in ${rel}`);
44
46
  continue;
45
47
  }
46
- // `(md.parent / raw).resolve()` — `resolvePath`, not `path.resolve`, because Python's
47
- // canonicalises the symlinks in the part that exists and this comparison is against an
48
- // `out` that went through the same call.
48
+ // `resolvePath`, not `path.resolve`, because it canonicalises the symlinks in the part
49
+ // that exists and this comparison is against an `out` that went through the same call.
49
50
  const target = resolvePath(path.join(path.dirname(md), raw));
50
51
  if (!existsSync(target)) problems.push(`dead link '${link}' in ${rel}`);
51
52
  else if (!within(target, out)) {
@@ -56,7 +57,7 @@ export function linkProblems(md, text, out, rel) {
56
57
  }
57
58
 
58
59
  /**
59
- * `_harness_build._check_build` — scan one rendered tree for unresolved tokens and bad links.
60
+ * Scan one rendered tree for unresolved tokens and bad links.
60
61
  *
61
62
  * `isVendored` decides which relative shape counts as a vendored folder, and the two callers
62
63
  * pass different ones ON PURPOSE: a `files`/opencode-global bundle nests skills at
@@ -64,7 +65,7 @@ export function linkProblems(md, text, out, rel) {
64
65
  * Vendored folders are verbatim upstream docs carrying their own license, and their internal
65
66
  * cross-links point at the upstream project's own files, so they are exempt.
66
67
  *
67
- * `rel` is `str(Path)`, i.e. the platform's separator, because that is what the Python prints
68
+ * `rel` keeps the platform's separator, because that is what the messages print
68
69
  * — every emit-scan cell in the acceptance matrix names a backslash on Windows.
69
70
  */
70
71
  export function checkBuild(themeName, out, isVendored = isVendoredPath) {
@@ -120,7 +121,7 @@ export function descriptionProblems(text, rel) {
120
121
  }
121
122
 
122
123
  /**
123
- * `_harness_build._theme_parity_problems` — every theme defines the same VOICE keys.
124
+ * Every theme defines the same VOICE keys.
124
125
  *
125
126
  * A token present in one theme map and missing from another renders as a raw `{{TOKEN}}`
126
127
  * only in the files that use it and only under that theme, so a plain build can miss it
@@ -148,11 +149,11 @@ export function themeParityProblems() {
148
149
  return problems;
149
150
  }
150
151
 
151
- /** `_harness_build._HEX_RE`. Anchored at BOTH ends, so `#12345` and `#1122334` both fail. */
152
+ /** Anchored at BOTH ends, so `#12345` and `#1122334` both fail. */
152
153
  const HEX_RE = /^#[0-9a-fA-F]{6}$/;
153
154
 
154
155
  /**
155
- * `_harness_build._color_theme_problems` — every curated colour theme carries the full
156
+ * Every curated colour theme carries the full
156
157
  * palette, in 6-digit hex. Voice-theme parity, for colours.
157
158
  *
158
159
  * TWO OF ITS THREE ARMS ARE UNREACHABLE FROM ANY CELL, and it is doctor's own ordering that
@@ -188,7 +189,32 @@ export function colorThemeProblems() {
188
189
  }
189
190
 
190
191
  /**
191
- * `_harness_build._rendered_problems` — a committed bundle must match a fresh render of
192
+ * Each global install whose carrier names another tier than the one this process resolves: the
193
+ * agent writes where the text says, the hooks read where the environment says. `$XDG_CONFIG_HOME`
194
+ * moved, or the install rendered relative and the tier has since appeared. A NOTE, because a
195
+ * rebuild clears it and `update` rolls a pull back on a doctor problem, and that rebuild comes
196
+ * after its gate. A relative carrier with no tier is a pre-tier install and is consistent.
197
+ */
198
+ export function renderedPathNotes() {
199
+ const root = renderedSharedRoot();
200
+ if (root === null) return [];
201
+ const notes = [];
202
+ for (const { host, configDir } of HOSTS) {
203
+ let dir;
204
+ try { dir = configDir(); } catch { continue; }
205
+ if (readMaybe(path.join(dir, '.geneseed-emit'))?.trim() !== `${host}-global`) continue;
206
+ const { text, root: rendered } = renderedTier(dir, host);
207
+ if (!text.includes('user-rules.md')) continue;
208
+ if (rendered === null ? isDir(sharedPaths().memory) : normcase(rendered) !== normcase(root)) {
209
+ notes.push(`${NOTE}[shared-tier] ${host}: the carrier renders ${rendered ?? 'relative paths'}, `
210
+ + `the run-time tier is ${root} — run geneseed rebuild-all`);
211
+ }
212
+ }
213
+ return notes;
214
+ }
215
+
216
+ /**
217
+ * A committed bundle must match a fresh render of
192
218
  * `src/` for its OWN recorded theme, emit and footprint.
193
219
  *
194
220
  * Doctor's temp builds never touch the committed bundle, so drift there is invisible to
@@ -226,15 +252,16 @@ export function renderedProblems(bundle) {
226
252
  if (scope === 'project' && CLAUDE_STYLE.includes(host)) return [];
227
253
  let items;
228
254
  try {
229
- // THE FIRST CALLER IN THE PORT THAT CATCHES A REFUSAL, and that is why the stderr is
230
- // buffered. `sys.exit(msg)` attaches the message to the EXCEPTION and the interpreter
231
- // prints it on the way out, so a Python caller that catches SystemExit sees no output at
232
- // all; this port's convention is to write at the raise site (`loadTheme`, and its
233
- // docblock says why), which is identical for every caller that lets the throw propagate
255
+ // THIS CALLER CATCHES A REFUSAL, and that is why the stderr is buffered. The
256
+ // convention is to write at the raise site (`loadTheme`, and its docblock says why),
257
+ // which is right for every caller that lets the throw propagate
234
258
  // and wrong for exactly this one. Buffered and replayed on success, so a WARN the render
235
259
  // legitimately emits still reaches the user, and discarded with the refusal it belongs to.
236
260
  ({ items } = withDiscardableStderr(() => renderAll(cfg, themeName, {
237
261
  footprint: footprintOfDir(bundle), nativeCatalog: hostCatalogsNatively(host),
262
+ // The bundle's own root, like its theme and footprint: `renderedPathNotes` judges that value,
263
+ // and a second verdict here would call every file stale for one moved directory.
264
+ sharedRoot: scope === 'global' ? renderedTier(bundle, host).root : null,
238
265
  })));
239
266
  } catch (e) {
240
267
  // `except SystemExit` — `effectiveTheme` refuses an unknown theme, and the driver's
@@ -19,7 +19,7 @@ import { globSorted, has, isDir, isFile, srcStems } from './scan.mjs';
19
19
  import { existsSync, readdirSync } from 'node:fs';
20
20
 
21
21
  /**
22
- * `_harness_build._prose_mirror_problems` — the human-readable count mirrors, the ones the
22
+ * The human-readable count mirrors, the ones the
23
23
  * badge regex never sees.
24
24
  *
25
25
  * The README "What you get" table and the web onboarding copy each restate the law / agent /
@@ -39,7 +39,7 @@ export function proseMirrorProblems(readme, web, counts, skillStems, shipped = '
39
39
  // The README plugin count. It had drifted — the overview sentence said six while seven
40
40
  // shipped — because the project's other plugin count ({N_PLUGINS} in the web docs) reads
41
41
  // a DEPLOYED plugins dir that a markdown file in this repository never has. `plugins` is
42
- // optional in `counts` (Python's `.get`, undefined here) because the corpus predates it.
42
+ // optional in `counts` (undefined when absent) because the corpus predates it.
43
43
  if (plugins !== undefined) {
44
44
  for (const m of readme.matchAll(/(\d+) \*{0,2}plugins/g)) {
45
45
  if (Number(m[1]) !== plugins) {
@@ -109,7 +109,7 @@ export function proseMirrorProblems(readme, web, counts, skillStems, shipped = '
109
109
  }
110
110
  }
111
111
  // N is a curated-subset size, not the total, so it is gated against the wikilinks it
112
- // introduces rather than against the skill count. `[\s\S]` is Python's `re.S` dot.
112
+ // introduces rather than against the skill count. `[\s\S]` is a dot that crosses newlines.
113
113
  const m = /(\d+) repeatable workflows the agent can invoke by name([\s\S]*?)playbook under/
114
114
  .exec(web);
115
115
  if (m) {
@@ -140,7 +140,7 @@ export function proseMirrorProblems(readme, web, counts, skillStems, shipped = '
140
140
  const TMPL_SPEC_RE = /\{\{DIR_(AGENTS|SKILLS)\}\}\/([A-Za-z0-9_-]+)\.md/g;
141
141
 
142
142
  /**
143
- * `_harness_build._count_table_problems` — the hand-authored AGENT.md tables and the README
143
+ * The hand-authored AGENT.md tables and the README
144
144
  * badges, against `src/`.
145
145
  *
146
146
  * The tables must list EXACTLY the spec files (no dead row, no orphaned spec) and each
@@ -27,7 +27,7 @@ import { isDir, isFile, rglob, srcStems, within } from './scan.mjs';
27
27
  import { existsSync, readFileSync, readdirSync } from 'node:fs';
28
28
 
29
29
  /**
30
- * `_harness_build._registry_keys` — every entity the registry must describe.
30
+ * Every entity the registry must describe.
31
31
  *
32
32
  * The flat agent and skill specs plus the vendored skill FOLDERS, which have no flat spec and
33
33
  * are still shipped capabilities. Keyed `<folder>/<stem>`, the shape doctor already prints.
@@ -47,7 +47,7 @@ const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
47
47
  // it too, and a copy would stop being the value under test the first time one side changed.
48
48
 
49
49
  /**
50
- * `_harness_build._registry_problems` — `registry.json` describes exactly what `src/`
50
+ * `registry.json` describes exactly what `src/`
51
51
  * provides, with well-formed fields.
52
52
  *
53
53
  * Two-way, like every anti-drift gate here: a new spec with no row and a row whose spec is
@@ -106,10 +106,10 @@ export function registryProblems() {
106
106
  }
107
107
 
108
108
  /**
109
- * `_harness_build._SECRET_PATTERNS` — credential shapes, by the prefix each issuer stamps,
109
+ * Credential shapes, by the prefix each issuer stamps,
110
110
  * plus the generic assignment. Deliberately narrow: a gate that cries wolf gets disabled.
111
111
  *
112
- * `(?i)` becomes the `i` flag on the last one only, which is where the Python puts it.
112
+ * `(?i)` becomes the `i` flag on the last one only.
113
113
  */
114
114
  /** @type {Array<[string, RegExp]>} */
115
115
  const SECRET_PATTERNS = [
@@ -124,7 +124,7 @@ const SECRET_PATTERNS = [
124
124
  ];
125
125
 
126
126
  /**
127
- * `_harness_build._secret_problems` — no credential may ship.
127
+ * No credential may ship.
128
128
  *
129
129
  * Sweeps the four trees `sourceFingerprint()` hashes, which is exactly the material that ends
130
130
  * up inside a user's bundle. Reports file:line and the KIND only — echoing the matched text
@@ -136,17 +136,16 @@ export function secretProblems() {
136
136
  if (!isDir(root)) continue;
137
137
  for (const p of rglob(root)) {
138
138
  if (!isFile(p) || p.split(path.sep).includes('__pycache__')) continue;
139
- // `except (OSError, UnicodeDecodeError): continue` — binary or unreadable, nothing to
140
- // scan. `readText` would substitute U+FFFD where Python RAISES, so the strict decode is
141
- // the check rather than a catch, and the newline folding `Path.read_text` does has to
142
- // be applied by hand afterwards for the LINE NUMBERS to agree.
139
+ // Binary or unreadable: nothing to scan. `readText` would substitute U+FFFD rather than
140
+ // raise, so the strict decode is the check rather than a catch, and the newline
141
+ // folding has to be applied by hand afterwards for the LINE NUMBERS to agree.
143
142
  let raw;
144
143
  try { raw = readFileSync(p); } catch { continue; }
145
144
  let s;
146
145
  try { s = new TextDecoder('utf-8', { fatal: true }).decode(raw); } catch { continue; }
147
146
  s = s.replaceAll('\r\n', '\n').replaceAll('\r', '\n');
148
- // `path.relative` returns a `..`-prefixed path where `relative_to` RAISES; the fallback
149
- // is the Python's, for a tree outside the repo (a test tmpdir).
147
+ // `path.relative` returns a `..`-prefixed path for a tree outside the repo (a test
148
+ // tmpdir); the fallback is the path as given.
150
149
  const r = path.relative(ROOT, p);
151
150
  const rel = (r.startsWith('..') || path.isAbsolute(r) ? p : r)
152
151
  .split(path.sep).join('/');
@@ -166,7 +165,7 @@ export function secretProblems() {
166
165
  }
167
166
 
168
167
  /**
169
- * `_harness_build._shim_problems` — the hook shim exists and points at something real.
168
+ * The hook shim exists and points at something real.
170
169
  *
171
170
  * This gate exists because the shim DISARMED an accidental safety net. When the emitted hook
172
171
  * command still carried the checkout path, moving the checkout made that command
@@ -225,7 +224,7 @@ const HEX40_RE = /^[0-9a-f]{40}$/;
225
224
  const MOVING_REFS = new Set(['main', 'master', 'develop', 'dev', 'head', 'latest', 'trunk']);
226
225
 
227
226
  /**
228
- * `_harness_build._vendor_pin_problems` — every vendored skill folder records where it came
227
+ * Every vendored skill folder records where it came
229
228
  * from: `**Upstream key:** <key>`, naming its `src/upstreams.json` entry, which holds the repo,
230
229
  * the pinned commit and the licence (`creditProblems` checks those facts).
231
230
  *
@@ -621,7 +620,7 @@ export function hostMatrixProblems(root = ROOT) {
621
620
  *
622
621
  * Taken from `geneseed scorecard` on main after #209-#213 (security policy, PR template, ARCHITECTURE
623
622
  * and ADRs, the audit and commitlint jobs, Dependabot, coverage, property tests, fuzzing): 26 of 31,
624
- * 81.2/100, matching upstream's Python tool check for check. Then the weekly Stryker run and the
623
+ * 81.2/100, matching upstream's scorecard tool check for check. Then the weekly Stryker run and the
625
624
  * offline link check added mutation_testing and stale_doc_detection: 28 of 31, 88.7 (A); the checkJs
626
625
  * pass added type_safety (partial: `strict` is off): 29 of 31, 90.4; calling the web job's prettier and vitest
627
626
  * directly (the scorecard reads only the root package.json's scripts) added formatter_enforcement
@@ -21,7 +21,7 @@
21
21
  */
22
22
  import path from 'node:path';
23
23
 
24
- import { sessionFiles } from '../hosts/hooks-context.mjs';
24
+ import { emittedHost, sessionFiles, tierSessionChars } from '../hosts/hooks-context.mjs';
25
25
  import { carriersFor } from '../hosts/installs.mjs';
26
26
  import { frontmatter } from '../hosts/memory-files.mjs';
27
27
  import { listDir } from '../hosts/hooks-prims.mjs';
@@ -37,6 +37,28 @@ import { isFile, readText } from '../lib/fs.mjs';
37
37
  */
38
38
  export const CARRIER_CEILING = { full: 66_432, lean: 41_612 };
39
39
 
40
+ /**
41
+ * THE TRADE OF `--shared-tier on`, stated once. `--help` (js/cli-table.json), the console's toggle
42
+ * and docs/concepts/rules.md quote these sentences; tests/unit/shared_tier_option.test.mjs
43
+ * holds the copies equal. The cost line carries the example figure (1 500 tokens, the estimate
44
+ * for a tier of 6 010 bytes before the memory map); the `setup` prompt swaps in this machine's.
45
+ */
46
+ export const SHARED_TIER_BENEFIT = 'This project sees your machine-wide rules, profile and memory map, so what you taught '
47
+ + 'one tool or repo applies here too.';
48
+ export const sharedTierCost = (figure = '1 500') => `About ${figure} tokens at every session start, growing with your rules. `
49
+ + 'The hook budget is fixed at 9 000 characters, and the tier loads before this project\'s docs, '
50
+ + 'so a large tier can push them down to a lazy listing.';
51
+
52
+ /**
53
+ * This machine's tier cost as the prompt shows it: characters over four (the estimate this module
54
+ * always makes), rounded to 100 so the figure does not pretend to a precision it lacks, with a thin
55
+ * grouping space as the spec writes it. An empty tier says so instead of "about 0".
56
+ */
57
+ export function sharedTierFigure() {
58
+ const tokens = Math.round(tierSessionChars() / 4 / 100) * 100;
59
+ return tokens > 0 ? String(tokens).replace(/\B(?=(\d{3})+$)/g, ' ') : null;
60
+ }
61
+
40
62
  /**
41
63
  * A frontmatter value as the host shows it. The emit writes descriptions JSON-escaped
42
64
  * (`—` for one em dash), and `frontmatter()` has already stripped the quotes, so the
@@ -108,7 +130,7 @@ export function alwaysOnCost({ host, root, dir, footprint }) {
108
130
  }
109
131
  }
110
132
  let context = 0;
111
- try { for (const s of sessionFiles(dir)) context += s.text.length; } catch { /* none */ }
133
+ try { for (const s of sessionFiles(dir, emittedHost(host))) context += s.text.length; } catch { /* none */ }
112
134
 
113
135
  return { carrier, skills, agents, context, ceiling: CARRIER_CEILING[footprint] ?? null };
114
136
  }