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
@@ -28,7 +28,8 @@
28
28
  //
29
29
  // MACHINE WIKI (AGENT.md §8): the same block also carries the user's own knowledge
30
30
  // base(s) — typically an Obsidian vault — declared once per machine in `geneseed-wiki.jsonc`
31
- // ($GENESEED_WIKI -> $GENESEED_HARNESS/geneseed-wiki.jsonc -> beside this plugin's install).
31
+ // ($GENESEED_WIKI -> $GENESEED_HARNESS/geneseed-wiki.jsonc -> beside this plugin's install ->
32
+ // the machine tier).
32
33
  // Each wiki's eager entries inject in full and lazy entries list, drawing on the
33
34
  // SAME budgets as the project context; its conventions/inbox/protected metadata is
34
35
  // surfaced so the agent knows the house rules before writing. No wiki manifest, or an
@@ -116,8 +117,13 @@ async function mainWorktreeOf(dir) {
116
117
  async function sovereignBypass(cwd) {
117
118
  try {
118
119
  const cfg = path.dirname(PLUGIN_DIR) // plugins/ sits directly in <cfg>
119
- const raw = await fs.readFile(path.join(cfg, "excludes.json"), "utf8")
120
- const entries = (JSON.parse(raw).excludes) || []
120
+ const listOf = async (file) => {
121
+ try { const l = JSON.parse(await fs.readFile(file, "utf8")).excludes; return Array.isArray(l) ? l : [] } catch { return [] }
122
+ }
123
+ const entries = await listOf(path.join(cfg, "excludes.json"))
124
+ // Shared list (<machineDir>/excludes.json): a GLOBAL install adds it, a project install never does.
125
+ const shared = await listOf(path.join(machineDir(), "excludes.json"))
126
+ if (shared.length && await readsTier(cfg)) entries.push(...shared)
121
127
  const here = norm(cwd || process.cwd())
122
128
  const main = await mainWorktreeOf(cwd || process.cwd())
123
129
  const heres = main ? [here, norm(main)] : [here]
@@ -214,8 +220,9 @@ async function isDir(p) {
214
220
  // tests/unit/claude.test.mjs gates both copies against SESSION_SEEDS in js/build/stubs.mjs.
215
221
  // context.json is not here: it is a manifest, honoured by resolveSource. geneseed-wiki.jsonc
216
222
  // is not here either: the MACHINE WIKI block below already renders it in full.
217
- const SESSION_FILES = ["user-rules.md", "PROFILE.md", "memory/MEMORY.md", "anamnesis/MEMORY.md",
218
- "notebook/NOTEBOOK.md"]
223
+ const SESSION_FILES = ["user-rules.md", "PROFILE.md", "memory/MEMORY.md", "notebook/NOTEBOOK.md"]
224
+ // The wiki manifest's names, newest first: WIKI_NAMES in js/lib/machine-dir.mjs.
225
+ const WIKI_NAMES = ["geneseed-wiki.jsonc", "wiki.jsonc", "wiki.json"]
219
226
  const SEED_SHA256 = new Set([
220
227
  "5c2e92fb1acde041e02d9ebf158460d8ff7a07cbc2b447859631604610130721", // user-rules.md
221
228
  "29e012c3c4349ea62a9082cbd04bb25599a0ec280d62c33f6e10742809471816", // PROFILE.md
@@ -238,18 +245,72 @@ async function harnessDir() {
238
245
  return null
239
246
  }
240
247
 
241
- // Session files present under the harness dir and changed from their seed: [{ rel, abs, text }].
248
+ // The machine tier: machineDir() in js/lib/machine-dir.mjs, which a plugin cannot import.
249
+ function machineDir() {
250
+ return path.join(process.env.XDG_CONFIG_HOME || path.join(homedir(), ".config"), "geneseed")
251
+ }
252
+
253
+ // Only a global install reads the tier: its .geneseed-emit names a -global emit, or it is the host's config dir.
254
+ // The host's own config dir counts as global too, whatever its marker says (the hook's
255
+ // isHostGlobalDir accepts both): OPENCODE_CONFIG_DIR, else <XDG config>/opencode.
256
+ const hostConfigDir = () => process.env.OPENCODE_CONFIG_DIR || path.join(process.env.XDG_CONFIG_HOME || path.join(homedir(), ".config"), "opencode")
257
+ async function isHostConfigDir(dir) {
258
+ const real = async (d) => { const r = await fs.realpath(path.resolve(d)).catch(() => path.resolve(d)); return process.platform === "win32" ? r.toLowerCase() : r }
259
+ return (await real(dir)) === (await real(hostConfigDir()))
260
+ }
261
+
262
+ async function readsTier(dir) {
263
+ try { if ((await fs.readFile(path.join(dir, ".geneseed-emit"), "utf8")).trim().endsWith("-global")) return true } catch { /* no marker */ }
264
+ return isHostConfigDir(dir)
265
+ }
266
+
267
+ // A PROJECT install with `Shared tier: on` in its AGENT.md reads the tier too (the hook's projectReadsTier),
268
+ // unless a global OpenCode install exists: its plugin loads beside this one and already injects it, so a
269
+ // second tier here would be a double. The global install's marker is <config dir>/.geneseed-emit.
270
+ async function projectReadsTier(dir) {
271
+ try {
272
+ if (!/^Shared tier:[ \t]*on[ \t]*\r?$/m.test(await fs.readFile(path.join(dir, "AGENT.md"), "utf8"))) return false
273
+ return !(await isFile(path.join(hostConfigDir(), ".geneseed-emit")))
274
+ } catch { return false }
275
+ }
276
+ async function tierFor(dir) { return (await readsTier(dir)) || (await projectReadsTier(dir)) }
277
+
278
+ // The fold's pending items, the twin of js/hosts/hooks-context.mjs `draftLine`: same line, same count.
279
+ async function draftLine() {
280
+ try {
281
+ const { items } = JSON.parse(await fs.readFile(path.join(machineDir(), ".fold-state.json"), "utf8"))
282
+ const n = Object.values(items ?? {}).filter((i) => i?.state === "pending").length
283
+ return n ? `[drafts] ${n} drafted item${n === 1 ? "" : "s"} in user-rules.draft.md wait${n === 1 ? "s" : ""} for the user's decision (the rule skill).` : null
284
+ } catch { return null }
285
+ }
286
+
287
+ // A session file's text, CRLF-folded and trimmed; null when missing, unreadable or still its seed.
288
+ async function sessionText(abs) {
289
+ let text
290
+ try { text = (await fs.readFile(abs, "utf8")).replace(/\r\n/g, "\n") } catch { return null }
291
+ if (SEED_SHA256.has(createHash("sha256").update(text).digest("hex"))) return null
292
+ return text.replace(/\n+$/, "")
293
+ }
294
+
295
+ // Session files in force for the harness dir, changed from their seed: [{ rel, abs, text, label }],
296
+ // one per layer. A global install reads the tier first, then its own host layer; the notebook stays
297
+ // per host. PROFILE.md is whole, so a non-seed host copy replaces the shared one. The others
298
+ // concatenate. The (shared) and (host: …) labels appear only when the tier has a say in that file.
242
299
  async function sessionFiles(dir) {
243
300
  const found = []
244
301
  if (!dir) return found
302
+ const tier = await tierFor(dir)
303
+ const entry = (rel, abs, text, label) => {
304
+ const nudge = rel === "memory/MEMORY.md" ? memoryNudge(text) : ""
305
+ found.push({ rel, abs, label, text: nudge ? `${text}\n${nudge}` : text })
306
+ }
245
307
  for (const rel of SESSION_FILES) {
246
308
  const abs = path.join(dir, rel)
247
- let text
248
- try { text = (await fs.readFile(abs, "utf8")).replace(/\r\n/g, "\n") } catch { continue }
249
- if (SEED_SHA256.has(createHash("sha256").update(text).digest("hex"))) continue
250
- text = text.replace(/\n+$/, "")
251
- const nudge = rel.endsWith("MEMORY.md") ? memoryNudge(text) : ""
252
- found.push({ rel, abs, text: nudge ? `${text}\n${nudge}` : text })
309
+ const host = await sessionText(abs)
310
+ const sharedAbs = tier && rel !== "notebook/NOTEBOOK.md" ? path.join(machineDir(), rel) : null
311
+ const shared = sharedAbs ? await sessionText(sharedAbs) : null
312
+ if (shared !== null && !(host !== null && rel === "PROFILE.md")) entry(rel, sharedAbs, shared, "shared")
313
+ if (host !== null) entry(rel, abs, host, shared === null ? "" : "host: opencode")
253
314
  }
254
315
  return found
255
316
  }
@@ -610,6 +671,7 @@ async function resolveSource(root, harness = null) {
610
671
  // 1. $GENESEED_WIKI explicit manifest path
611
672
  // 2. $GENESEED_HARNESS/geneseed-wiki.jsonc pinned install dir
612
673
  // 3. <plugin dir>/../geneseed-wiki.jsonc auto-locate: beside the installed AGENT.md
674
+ // 4. <machine dir>/geneseed-wiki.jsonc global install only, when 2 and 3 are absent or a seed
613
675
  async function resolveWikiFile() {
614
676
  const explicit = process.env.GENESEED_WIKI
615
677
  if (explicit && (await isFile(explicit))) return explicit
@@ -620,14 +682,18 @@ async function resolveWikiFile() {
620
682
  const harness = await harnessDir()
621
683
  if (harness) bases.push(harness)
622
684
  bases.push(path.resolve(PLUGIN_DIR, ".."))
685
+ let host = null
623
686
  for (const base of bases) {
624
- // wiki.jsonc and wiki.json are the legacy names from earlier seeds — still honoured.
625
- for (const name of ["geneseed-wiki.jsonc", "wiki.jsonc", "wiki.json"]) {
687
+ for (const name of WIKI_NAMES) {
626
688
  const p = path.join(base, name)
627
- if (await isFile(p)) return p
689
+ if (!host && (await isFile(p))) host = p
628
690
  }
629
691
  }
630
- return null
692
+ if (harness && (await tierFor(harness)) && (!host || (await sessionText(host)) === null)) {
693
+ const shared = path.join(machineDir(), WIKI_NAMES[0])
694
+ if ((await sessionText(shared)) !== null) return shared
695
+ }
696
+ return host
631
697
  }
632
698
 
633
699
  // Walk a vault folder for .md notes — like the project walk, but dot-folders are
@@ -806,7 +872,7 @@ async function buildBlock(sets, wikis = [], commands = [], session = [], done =
806
872
  const ses = []
807
873
  for (const s of session) {
808
874
  const size = Buffer.byteLength(s.text, "utf8")
809
- ses.push(`----- ${s.rel} -----`)
875
+ ses.push(`----- ${s.rel}${s.label ? ` (${s.label})` : ""} -----`)
810
876
  if (size > EAGER_FILE_KB * 1024) {
811
877
  ses.push(`[demoted: ${s.rel} exceeded ${EAGER_FILE_KB} KB — read ${s.abs} on demand]`, "")
812
878
  continue
@@ -859,7 +925,9 @@ async function resolveBlock(root, judged = true) {
859
925
  const commands = await discoverCommands(root)
860
926
  const done = (await doneGateOff()) ? null : await doneLine(root, judged).catch(() => null)
861
927
  const owned = (await ownershipGateOff()) ? null : await ownershipLine(root).catch(() => null)
862
- const heads = [done, owned].filter(Boolean).join("\n") || null
928
+ const floor = await runtimeFloorLine(root).catch(() => null)
929
+ const drafts = harness && (await tierFor(harness)) ? await draftLine() : null
930
+ const heads = [done, owned, floor, drafts].filter(Boolean).join("\n") || null
863
931
  return { block: await buildBlock(sets, wikis, commands, await sessionFiles(harness), heads), src }
864
932
  }
865
933
 
@@ -894,6 +962,95 @@ async function alreadyInjected(client, sid) {
894
962
  return false
895
963
  }
896
964
 
965
+ // ---- test-weakening twin: BEGIN — adapters/opencode/plugins/geneseed-context.js carries everything
966
+ // down to the END marker verbatim, with `export ` dropped (tests/plugins/context_done.test.mjs diffs the two).
967
+
968
+ /**
969
+ * A test file: a path segment `test`, `tests`, `__tests__` or `spec`, or a name `*.test.*`,
970
+ * `*.spec.*`, `*_test.*` or `test_*`. Give it a path relative to the repo, or an ancestor
971
+ * folder named `test` makes every file a test.
972
+ */
973
+ const TEST_PATH_RE = /(?:^|[\\/])(?:tests?|__tests__|spec)[\\/]|(?:^|[\\/])test_[^\\/]*$|\.(?:test|spec)\.[^\\/]*$|_test\.[^\\/]*$/;
974
+ const isTestPath = (p) => TEST_PATH_RE.test(p);
975
+ // `\bxit`, or `process.exit(` reads as one; `(?<!mark)`, or `pytest.mark.skip(` counts twice.
976
+ const SKIP_MARKERS = [['.skip', /(?<!mark)\.skip\(/g], ['xit', /\bxit\(/g], ['xfail', /\bxfail\b/g],
977
+ ['@Disabled', /@Disabled\b/g], ['@Ignore', /@Ignore\b/g], ['pytest.mark.skip', /\bpytest\.mark\.skip/g],
978
+ ['t.Skip', /\bt\.Skip\(/g]];
979
+ const ASSERT_LINE_RE = /\bassert\w*!?\s*[.(]|\bexpect\s*\(|^assert\s/;
980
+ const COMMENT_LINE_RE = /^(?:\/\/|\/\*|\*|#)/;
981
+ // shortcut: only whole comment lines are dropped, so a marker in a string or a trailing comment, and
982
+ // any other `.skip(` (`stream().skip(1)`), still count. Upgrade by parsing the language; it is an advisory.
983
+ const code = (text) => text.split(/\r?\n/).filter((l) => !COMMENT_LINE_RE.test(l.trim())).join('\n');
984
+ // shortcut: a Set hides the loss of one of two identical lines, and `require.Equal`, `t.Errorf` and
985
+ // `.should` are not read as assertions. Upgrade by counting lines and widening `ASSERT_LINE_RE`.
986
+ const assertLines = (text) => new Set(text.split(/\r?\n/).map((l) => l.trim())
987
+ .filter((l) => ASSERT_LINE_RE.test(l) && !COMMENT_LINE_RE.test(l)));
988
+
989
+ /**
990
+ * What `pairs` of `[old, new]` text do to a test, as labels: a skip marker the new text has more
991
+ * of (`.skip added`), or an assertion line gone with none new in its place (`assertion removed`).
992
+ * A comment is no assertion, so commenting one out removes it. Cure the Cause's advisory half.
993
+ */
994
+ function weakenedBy(pairs) {
995
+ const found = new Set();
996
+ for (const [before, after] of pairs) {
997
+ for (const [label, re] of SKIP_MARKERS) {
998
+ if ((code(after).match(re) || []).length > (code(before).match(re) || []).length) found.add(`${label} added`);
999
+ }
1000
+ const was = assertLines(before);
1001
+ const now = assertLines(after);
1002
+ if ([...was].some((l) => !now.has(l)) && [...now].every((l) => was.has(l))) found.add('assertion removed');
1003
+ }
1004
+ return [...found];
1005
+ }
1006
+ // ---- test-weakening twin: END
1007
+
1008
+ // A weakened test (Cure the Cause), ADVISORY. OpenCode has no turn end to report at, so a write is
1009
+ // read before it runs and the next request carries one reminder, on OpenCode 1 and 2 alike: both
1010
+ // expose the tool's input before it runs, unlike the tool parts the done gate reads on V1 alone.
1011
+ // shortcut: a call the guard then refuses still counts; move to an after-hook if that ever misleads.
1012
+ const WEAKENED = new Map() // sessionID -> Map(path -> labels)
1013
+ function testEditPairs(tool, args, before) {
1014
+ const t = String(tool).toLowerCase()
1015
+ if (t === "write" && typeof args.content === "string") return [[null, before, args.content]]
1016
+ if (t === "edit" && typeof args.newString === "string") return [[null, String(args.oldString ?? ""), args.newString]]
1017
+ if ((t !== "patch" && t !== "apply_patch") || typeof args.patchText !== "string") return []
1018
+ // `*** Add|Update File: <path>` sections: `-` lines leave the file, `+` lines land in it.
1019
+ const out = []
1020
+ for (const line of args.patchText.split(/\r?\n/)) {
1021
+ const m = /^\*\*\* (?:Add|Update) File:\s*(.+)$/.exec(line)
1022
+ if (m) out.push([m[1].trim(), "", ""])
1023
+ else if (out.length && /^[-+]/.test(line)) out[out.length - 1][line[0] === "-" ? 1 : 2] += `${line.slice(1)}\n`
1024
+ }
1025
+ return out
1026
+ }
1027
+ async function noteWeakened(root, sid, tool, args) {
1028
+ try {
1029
+ if (!sid || !args) return
1030
+ const file = typeof args.filePath === "string" ? path.resolve(root, args.filePath) : null
1031
+ let before = ""
1032
+ if (file && String(tool).toLowerCase() === "write" && isTestPath(path.relative(root, file))) {
1033
+ before = await fs.readFile(file, "utf8").catch(() => "")
1034
+ }
1035
+ for (const [p, was, now] of testEditPairs(tool, args, before)) {
1036
+ const rel = path.relative(root, p === null ? file ?? "" : path.resolve(root, p)).replace(/\\/g, "/")
1037
+ const hits = isTestPath(rel) ? weakenedBy([[was, now]]) : []
1038
+ if (!hits.length) continue
1039
+ if (!WEAKENED.has(sid)) WEAKENED.set(sid, new Map())
1040
+ WEAKENED.get(sid).set(rel, [...new Set([...(WEAKENED.get(sid).get(rel) ?? []), ...hits])])
1041
+ }
1042
+ } catch (err) { log(`test-weakening error: ${err?.message ?? err}`) }
1043
+ }
1044
+ // The reminder owed to this session, once; null when there is none.
1045
+ function takeWeakened(sid) {
1046
+ const files = WEAKENED.get(sid)
1047
+ if (!files) return null
1048
+ WEAKENED.delete(sid)
1049
+ const list = [...files].map(([rel, hits]) => `${rel} (${hits.join(", ")})`).join("; ")
1050
+ return `Geneseed (Cure the Cause) — advisory: test weakened this turn: ${list}. Fix the code, not the `
1051
+ + "test. State this in your closing summary, with the reason."
1052
+ }
1053
+
897
1054
  // ---- The done gate (#289): the OpenCode twin of js/hosts/hooks-done.mjs ----------------
898
1055
  // OpenCode has no turn-end event a plugin can block on, so its ceiling is a reminder: on the
899
1056
  // request AFTER a turn that edited files without the project's declared checks passing
@@ -1049,6 +1206,18 @@ async function ownershipLine(dir) {
1049
1206
  return since ? `Ownership: setup declined since ${since} — not set up; say "set up ownership" to run it` : null
1050
1207
  }
1051
1208
 
1209
+ // ---- The runtime floor: the twin of js/hosts/hooks-context.mjs `runtimeFloorLine` ----
1210
+ // One line when the git root's package.json is a JSON object with no `engines` field; the hook's
1211
+ // shortcut comment names the manifests not read. No done-gate or ownership switch silences it.
1212
+ const FLOOR_LINE = "Runtime floor: package.json declares no engines — name the supported runtime before you "
1213
+ + "add a dependency or a language feature."
1214
+ async function runtimeFloorLine(dir) {
1215
+ const root = await gitRootOf(dir)
1216
+ if (!root) return null
1217
+ const pkg = await readJson(path.join(root, "package.json"))
1218
+ return pkg && typeof pkg === "object" && !Array.isArray(pkg) && pkg.engines === undefined ? FLOOR_LINE : null
1219
+ }
1220
+
1052
1221
  function runsUnpiped(command, line) {
1053
1222
  const cmd = String(command).replace(/[ \t]+/g, " ")
1054
1223
  for (let i = cmd.indexOf(line); i !== -1; i = cmd.indexOf(line, i + 1)) {
@@ -1237,6 +1406,10 @@ export const GeneseedContext = async (ctx) => {
1237
1406
  })
1238
1407
 
1239
1408
  return {
1409
+ "tool.execute.before": async (input, output) => {
1410
+ await noteWeakened(root, input?.sessionID, input?.tool, output?.args)
1411
+ },
1412
+
1240
1413
  event: async ({ event }) => {
1241
1414
  if (!event || INJECT_OFF) return
1242
1415
  if (await sovereignBypass(root)) return
@@ -1311,6 +1484,16 @@ export const GeneseedContext = async (ctx) => {
1311
1484
  })
1312
1485
  log("transform: done-gate reminder injected")
1313
1486
  })().catch((err) => log(`done-gate error: ${err?.message ?? err}`))
1487
+ // The weakened-test reminder, on the same switch: it needs no checks, so not inside the above.
1488
+ const weakened = !(await doneGateOff()) && takeWeakened(sid)
1489
+ if (weakened) {
1490
+ const stamp = Date.now()
1491
+ output.messages.unshift({
1492
+ info: { id: `geneseed-weakened-${stamp}`, role: "user", sessionID: sid, time: { created: stamp } },
1493
+ parts: [{ id: `geneseed-weakened-part-${stamp}`, type: "text", text: weakened }],
1494
+ })
1495
+ log("transform: test-weakening reminder injected")
1496
+ }
1314
1497
  if (INJECT_OFF || !TRANSFORM || fallbackVisible) return
1315
1498
  try {
1316
1499
  // Already present this request? (idempotent across plugin copies / retries.)
@@ -1374,8 +1557,27 @@ async function setupV2(ctx) {
1374
1557
  console.error(`[geneseed-context] done gate: ${DONE_LIST} found, but OpenCode 2 turns are not judged.`)
1375
1558
  }
1376
1559
 
1560
+ // The weakened-test reminder, which INJECT_OFF and visible delivery leave on, as on V1. A V2
1561
+ // callback that throws fails the agent step, so both swallow their errors.
1562
+ await ctx.tool?.hook?.("execute.before", async (event) => {
1563
+ await noteWeakened(root, event?.sessionID, event?.tool, event?.input)
1564
+ })
1565
+ const remindWeakened = async (event) => {
1566
+ try {
1567
+ if (!Array.isArray(event?.messages) || await sovereignBypass(root) || await doneGateOff()) return
1568
+ if (await skipSession(event.sessionID)) return
1569
+ const weakened = takeWeakened(event.sessionID)
1570
+ if (weakened) event.messages.unshift(v2UserMessage(event.messages, weakened))
1571
+ } catch (err) {
1572
+ log(`test-weakening error: ${err?.message ?? err}`)
1573
+ }
1574
+ }
1575
+
1576
+ // One `context` hook either way: only `remindWeakened` in visible delivery.
1577
+ if (VISIBLE) await ctx.session.hook("context", remindWeakened)
1377
1578
  if (!VISIBLE) {
1378
1579
  await ctx.session.hook("context", async (event) => {
1580
+ await remindWeakened(event)
1379
1581
  if (INJECT_OFF) return
1380
1582
  try {
1381
1583
  if (await sovereignBypass(root)) return