geneseed 4.27.1 → 4.29.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 (143) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +7 -4
  3. package/SHIPPED.md +2 -2
  4. package/adapters/bob/README.md +1 -1
  5. package/adapters/claude-code/README.md +4 -2
  6. package/adapters/opencode/HOW-OPENCODE-LOADS.md +2 -2
  7. package/adapters/opencode/README.md +18 -2
  8. package/adapters/opencode/plugins/geneseed-context.js +155 -18
  9. package/adapters/opencode/plugins/geneseed-guard.js +59 -8
  10. package/adapters/opencode/plugins/geneseed-workflow.js +27 -8
  11. package/adapters/opencode/workflows/_runtime.js +14 -3
  12. package/docs/concepts/enforcement-table.md +5 -4
  13. package/docs/concepts/exclusions.md +3 -3
  14. package/docs/concepts/hooks.md +11 -3
  15. package/docs/concepts/ownership.md +7 -6
  16. package/docs/concepts/skills.md +1 -0
  17. package/docs/guides/set-up-ownership.md +22 -6
  18. package/docs/reference/environment.md +1 -0
  19. package/docs/reference/plugin-context.md +3 -1
  20. package/docs/reference/plugin-guard.md +1 -1
  21. package/docs/understand/enforced-vs-asked.md +3 -3
  22. package/docs/understand/machine-bob.md +1 -1
  23. package/docs/understand/machine-claude.md +1 -1
  24. package/docs/understand/machine-opencode.md +1 -1
  25. package/harness.config.json +1 -1
  26. package/js/README.md +3 -1
  27. package/js/build/driver.mjs +29 -9
  28. package/js/build/emit-opencode.mjs +12 -10
  29. package/js/build/render.mjs +9 -0
  30. package/js/hosts/done-checks.mjs +134 -0
  31. package/js/hosts/geneseed-dir.mjs +116 -0
  32. package/js/hosts/hooks-context.mjs +19 -0
  33. package/js/hosts/hooks-done.mjs +82 -38
  34. package/js/hosts/hooks-learn.mjs +9 -2
  35. package/js/hosts/hooks-prims.mjs +4 -0
  36. package/js/hosts/hooks.mjs +139 -6
  37. package/js/hosts/hosts.mjs +6 -0
  38. package/js/hosts/native.mjs +1 -1
  39. package/js/hosts/owned.mjs +19 -0
  40. package/js/hosts/ownership-gate.mjs +64 -10
  41. package/js/hosts/settings.mjs +115 -74
  42. package/js/inspect/checks-constitution.mjs +5 -1
  43. package/js/inspect/cost.mjs +1 -1
  44. package/js/inspect/doctor.mjs +2 -1
  45. package/js/inspect/inventory.mjs +1 -1
  46. package/js/inspect/status.mjs +2 -1
  47. package/js/inspect/validate.mjs +2 -1
  48. package/js/lib/json.mjs +70 -0
  49. package/js/maintain/uninstall.mjs +18 -5
  50. package/js/web/gates-api.mjs +2 -2
  51. package/package.json +1 -1
  52. package/registry.json +14 -0
  53. package/src/AGENT.md.tmpl +2 -2
  54. package/src/doctrines/comms.md +9 -2
  55. package/src/licenses/i-have-adhd.txt +21 -0
  56. package/src/skills/_checkpoints.md +15 -2
  57. package/src/skills/adhd.md +40 -0
  58. package/src/skills/diagram-design/LICENSE +21 -0
  59. package/src/skills/diagram-design/SKILL.md +392 -0
  60. package/src/skills/diagram-design/THIRD_PARTY_LICENSES.md +134 -0
  61. package/src/skills/diagram-design/VENDOR.md +81 -0
  62. package/src/skills/diagram-design/assets/example-architecture.html +183 -0
  63. package/src/skills/diagram-design/assets/example-venn.html +110 -0
  64. package/src/skills/diagram-design/assets/template-dark.html +99 -0
  65. package/src/skills/diagram-design/assets/template-full.html +421 -0
  66. package/src/skills/diagram-design/assets/template-motion.html +448 -0
  67. package/src/skills/diagram-design/assets/template-terminal.html +188 -0
  68. package/src/skills/diagram-design/assets/template.html +100 -0
  69. package/src/skills/diagram-design/references/animation.md +135 -0
  70. package/src/skills/diagram-design/references/layout-budget.md +97 -0
  71. package/src/skills/diagram-design/references/onboarding.md +368 -0
  72. package/src/skills/diagram-design/references/output-spec.md +277 -0
  73. package/src/skills/diagram-design/references/primitive-annotation.md +36 -0
  74. package/src/skills/diagram-design/references/primitive-icons.md +782 -0
  75. package/src/skills/diagram-design/references/primitive-sketchy.md +43 -0
  76. package/src/skills/diagram-design/references/primitive-terminal.md +76 -0
  77. package/src/skills/diagram-design/references/primitives-core.md +144 -0
  78. package/src/skills/diagram-design/references/profiles.md +183 -0
  79. package/src/skills/diagram-design/references/semantic-patterns.md +154 -0
  80. package/src/skills/diagram-design/references/style-guide.md +232 -0
  81. package/src/skills/diagram-design/references/type-architecture-delta.md +143 -0
  82. package/src/skills/diagram-design/references/type-architecture.md +117 -0
  83. package/src/skills/diagram-design/references/type-axonometric-plan.md +83 -0
  84. package/src/skills/diagram-design/references/type-bar.md +108 -0
  85. package/src/skills/diagram-design/references/type-data-flow.md +371 -0
  86. package/src/skills/diagram-design/references/type-db-schema.md +48 -0
  87. package/src/skills/diagram-design/references/type-dependency.md +44 -0
  88. package/src/skills/diagram-design/references/type-deployment.md +45 -0
  89. package/src/skills/diagram-design/references/type-dp-integration.md +407 -0
  90. package/src/skills/diagram-design/references/type-dp-security-matrix.md +379 -0
  91. package/src/skills/diagram-design/references/type-er.md +25 -0
  92. package/src/skills/diagram-design/references/type-exploded.md +115 -0
  93. package/src/skills/diagram-design/references/type-fishbone.md +75 -0
  94. package/src/skills/diagram-design/references/type-flowchart.md +23 -0
  95. package/src/skills/diagram-design/references/type-gantt.md +45 -0
  96. package/src/skills/diagram-design/references/type-heatmap.md +80 -0
  97. package/src/skills/diagram-design/references/type-high-level.md +470 -0
  98. package/src/skills/diagram-design/references/type-it-state.md +468 -0
  99. package/src/skills/diagram-design/references/type-journey.md +55 -0
  100. package/src/skills/diagram-design/references/type-kanban.md +49 -0
  101. package/src/skills/diagram-design/references/type-layers.md +26 -0
  102. package/src/skills/diagram-design/references/type-line.md +337 -0
  103. package/src/skills/diagram-design/references/type-loop.md +223 -0
  104. package/src/skills/diagram-design/references/type-medallion.md +356 -0
  105. package/src/skills/diagram-design/references/type-nested.md +22 -0
  106. package/src/skills/diagram-design/references/type-org-chart.md +44 -0
  107. package/src/skills/diagram-design/references/type-polar.md +136 -0
  108. package/src/skills/diagram-design/references/type-process.md +490 -0
  109. package/src/skills/diagram-design/references/type-pyramid.md +33 -0
  110. package/src/skills/diagram-design/references/type-quadrant.md +81 -0
  111. package/src/skills/diagram-design/references/type-radar.md +82 -0
  112. package/src/skills/diagram-design/references/type-sankey.md +75 -0
  113. package/src/skills/diagram-design/references/type-scatter.md +276 -0
  114. package/src/skills/diagram-design/references/type-sequence.md +130 -0
  115. package/src/skills/diagram-design/references/type-service-blueprint.md +103 -0
  116. package/src/skills/diagram-design/references/type-state.md +30 -0
  117. package/src/skills/diagram-design/references/type-story-map.md +46 -0
  118. package/src/skills/diagram-design/references/type-swimlane.md +22 -0
  119. package/src/skills/diagram-design/references/type-timeline.md +20 -0
  120. package/src/skills/diagram-design/references/type-tree.md +24 -0
  121. package/src/skills/diagram-design/references/type-treemap.md +137 -0
  122. package/src/skills/diagram-design/references/type-uml-class.md +65 -0
  123. package/src/skills/diagram-design/references/type-venn.md +26 -0
  124. package/src/skills/diagram-design/references/type-wardley.md +39 -0
  125. package/src/skills/diagram-design/references/type-waterfall.md +75 -0
  126. package/src/skills/document-project.md +4 -1
  127. package/src/skills/ownership.md +26 -4
  128. package/src/upstreams.json +14 -0
  129. package/themes/_TEMPLATE.json +1 -0
  130. package/themes/biker.json +1 -0
  131. package/themes/commentator.json +1 -0
  132. package/themes/cyberpunk.json +1 -0
  133. package/themes/gamer.json +1 -0
  134. package/themes/imperial.json +1 -0
  135. package/themes/joker.json +1 -0
  136. package/themes/marvin.json +1 -0
  137. package/themes/mean.json +1 -0
  138. package/themes/military.json +1 -0
  139. package/themes/neutral.json +1 -0
  140. package/themes/pirate.json +1 -0
  141. package/themes/sports.json +1 -0
  142. package/themes/verstappen.json +1 -0
  143. package/themes/wizard.json +1 -0
@@ -51,8 +51,9 @@ import {
51
51
  openclaudeConfigDir, hostCatalogsNatively,
52
52
  } from '../hosts/hosts.mjs';
53
53
  import {
54
- hashesOf, ownedHashes, ownedState, ownedWithin, recordedDenies,
54
+ hashesOf, ownedHashes, ownedState, ownedWithin, recordedDenies, recordedEdit, editRecordKeys,
55
55
  } from '../hosts/owned.mjs';
56
+ import { seedProtectedChecks } from '../hosts/geneseed-dir.mjs';
56
57
 
57
58
  // P5d moved these out of this file for the reason P5c moved the host resolvers: `harness
58
59
  // status` renders to count, so `bin/geneseed-cli.mjs` needs the same checkout paths and the
@@ -244,6 +245,15 @@ function pruneOwned(oc, oldOwned, owned, oldHashes = {}, editRefused = []) {
244
245
  }
245
246
  }
246
247
 
248
+ /**
249
+ * Whether this PROJECT emit seeds `<git root>/.geneseed/protected-checks.txt`. A real emit does;
250
+ * a sandbox emit must not, because the seed walks UP to the git root and a sandbox under a temp
251
+ * dir that sits inside a repo would write into that repo. In-process sandbox callers
252
+ * (`validate`, `doctor`) pass `seed: false` through `emitProjectInto`; a spawned one (the golden
253
+ * matrix) sets `GENESEED_NO_SEED`, the same env channel `GENESEED_STACK_GLOBAL` uses.
254
+ */
255
+ const seeds = (args) => args.seed !== false && !process.env.GENESEED_NO_SEED;
256
+
247
257
  /**
248
258
  * The manifest PRE-read all three emit bodies performed inline: does a manifest already
249
259
  * exist at `manifestPath`, and if so, what does it parse to. `existed` is what
@@ -307,6 +317,7 @@ function emitOpencode(cfg, args, out) {
307
317
  const { existed: manifestExisted, doc } = readManifest(manifestPath);
308
318
  const oldOwned = (doc && doc.owned) || [];
309
319
  const oldDenies = recordedDenies(doc);
320
+ const oldEdit = recordedEdit(doc);
310
321
  const oldHashes = hashesOf(doc);
311
322
 
312
323
  const agentPathRel = relUnder(out, root);
@@ -319,9 +330,11 @@ function emitOpencode(cfg, args, out) {
319
330
  {
320
331
  theme: args.theme, out, root, footprint: args.footprint,
321
332
  nativeCatalog: hostCatalogsNatively('opencode'), oldOwned, manifestExisted, agentPath,
322
- oldDenies, oldHashes,
333
+ oldDenies, oldEdit, oldHashes,
323
334
  });
324
- const { owned, stats, cfgName, skillDenies, editRefused } = rendered;
335
+ const { owned, stats, cfgName, skillDenies, editRecord, editRefused } = rendered;
336
+ // Seed once: absent -> created, then the user's (never recorded, rewritten or removed).
337
+ if (seeds(args)) seedProtectedChecks(root);
325
338
 
326
339
  phaseLog('PRUNE');
327
340
  pruneOwned(oc, oldOwned, owned, oldHashes, editRefused);
@@ -335,6 +348,7 @@ function emitOpencode(cfg, args, out) {
335
348
  hashes: ownedHashes(oc, owned),
336
349
  scope: 'project',
337
350
  ...(skillDenies.length ? { skill_denies: skillDenies } : {}),
351
+ ...editRecordKeys(editRecord),
338
352
  });
339
353
 
340
354
  const extra = extrasTail(stats);
@@ -368,6 +382,7 @@ function emitOpencodeGlobal(cfg, args, out) {
368
382
  const { doc } = readManifest(manifestPath);
369
383
  const oldOwned = (doc && doc.owned) || [];
370
384
  const oldDenies = recordedDenies(doc);
385
+ const oldEdit = recordedEdit(doc);
371
386
  const oldHashes = hashesOf(doc);
372
387
 
373
388
  const agentPath = path.join(cfgDir, 'AGENT.md').split(path.sep).join('/');
@@ -377,9 +392,9 @@ function emitOpencodeGlobal(cfg, args, out) {
377
392
  {
378
393
  theme: args.theme, cfgDir, out,
379
394
  footprint: args.footprint, nativeCatalog: hostCatalogsNatively('opencode'),
380
- oldOwned, agentPath, oldDenies, oldHashes,
395
+ oldOwned, agentPath, oldDenies, oldEdit, oldHashes,
381
396
  });
382
- const { owned, stats, memStatus, nbStatus, cfgName, skillDenies, editRefused } = rendered;
397
+ const { owned, stats, memStatus, nbStatus, cfgName, skillDenies, editRecord, editRefused } = rendered;
383
398
 
384
399
  phaseLog('PRUNE');
385
400
  pruneOwned(cfgDir, oldOwned, owned, oldHashes, editRefused);
@@ -392,6 +407,7 @@ function emitOpencodeGlobal(cfg, args, out) {
392
407
  owned: [...owned].sort(),
393
408
  hashes: ownedHashes(cfgDir, owned),
394
409
  ...(skillDenies.length ? { skill_denies: skillDenies } : {}),
410
+ ...editRecordKeys(editRecord),
395
411
  });
396
412
 
397
413
  const extra = extrasTail(stats);
@@ -414,7 +430,7 @@ function emitOpencodeGlobal(cfg, args, out) {
414
430
  * built to throw — where `null` would raise an unrelated TypeError and `{}` would bake the
415
431
  * literal string `"undefined"` into the shim and silently kill every hook in the install.
416
432
  */
417
- function emitClaudeCore(cfg, args, { cfgDir, claudeMd, scope, host, out, hookOpts }) {
433
+ function emitClaudeCore(cfg, args, { cfgDir, claudeMd, scope, host, out, hookOpts, root }) {
418
434
  const manifestPath = path.join(cfgDir, GLOBAL_MANIFEST);
419
435
  const { doc } = readManifest(manifestPath);
420
436
  const oldOwned = (doc && doc.owned) || [];
@@ -435,6 +451,8 @@ function emitClaudeCore(cfg, args, { cfgDir, claudeMd, scope, host, out, hookOpt
435
451
  hookOpts, oldHashes,
436
452
  });
437
453
  const { owned, stats, memStatus, nbStatus, managed, editRefused } = rendered;
454
+ // `root` is null on a global emit: it has no project to seed.
455
+ if (root && seeds(args)) seedProtectedChecks(root);
438
456
 
439
457
  phaseLog('PRUNE');
440
458
  pruneOwned(cfgDir, oldOwned, owned, oldHashes, editRefused);
@@ -560,7 +578,7 @@ const claudeShaped = (name) => (cfg, args, out) => {
560
578
  const hookOpts = hookRunnerEntry();
561
579
  before?.();
562
580
  const r = withWriteRecord(() => emitClaudeCore(cfg, args, {
563
- cfgDir, claudeMd, scope: configDir ? 'global' : 'project', host, out, hookOpts,
581
+ cfgDir, claudeMd, scope: configDir ? 'global' : 'project', host, out, hookOpts, root,
564
582
  }));
565
583
  process.stdout.write(summary(root ?? cfgDir, r));
566
584
  return configDir ? cfgDir : undefined;
@@ -666,17 +684,19 @@ function axesCfg({
666
684
 
667
685
  export function emitProjectInto(host, {
668
686
  theme, out, root, footprint = 'full', posture = null, mode = null, trust = null,
669
- doctrines = null, excludeRules = null, excludeSkills = null, kits = null, ...gates
687
+ doctrines = null, excludeRules = null, excludeSkills = null, kits = null, seed = true, ...gates
670
688
  }) {
671
689
  const emit = PROJECT_EMITS[host];
672
690
  // The axes ride the same rail into every `*Into`, and for the same reason: a drift reader
673
691
  // that renders `expected` at the DEFAULT pack set reports the whole doctrines section as
674
692
  // edited on every narrowed install, and `validate --doctrines craft` that ignored its flag
675
693
  // checked an all-packs render nobody asked for.
694
+ // `seed: false` — a SANDBOX emit (`validate`, `doctor`): the protected-checks seed walks UP to
695
+ // the git root, which for a temp dir inside a repo is that repo, outside the sandbox.
676
696
  return withPlatformNewlines(() => emit(
677
697
  axesCfg({
678
698
  posture, mode, trust, doctrines, excludeRules, excludeSkills, kits, ...gates }),
679
- { theme, footprint, root }, out,
699
+ { theme, footprint, root, seed }, out,
680
700
  ));
681
701
  }
682
702
 
@@ -13,7 +13,7 @@ import {
13
13
  copyPlugins, copyWorkflows, ensureAgentOverridesStub, writeColorThemes, writeCommandLayer,
14
14
  writeAliasCommands, writePonytailCommand, writePrimaryAgent, writeTheme,
15
15
  } from '../hosts/opencode.mjs';
16
- import { mergeOpencodeJson, opencodeSentinelWrite } from '../hosts/settings.mjs';
16
+ import { mergeOpencodeJson, opencodeEditAsks, opencodeSentinelWrite } from '../hosts/settings.mjs';
17
17
  import { isFile, readText, writeText } from '../lib/fs.mjs';
18
18
  import { relPosix } from '../lib/text.mjs';
19
19
  import { assertSourceComplete, build, phaseLog, ensureMemoryStore } from './bundle.mjs';
@@ -53,7 +53,7 @@ import { mkdirSync } from 'node:fs';
53
53
  */
54
54
  function opencodeLayer(cfg, items, themeName, theme, dir, owned, opts) {
55
55
  const {
56
- oldOwned, manifestExisted, agentPath, wireBase, overridesDir, oldDenies = [],
56
+ oldOwned, manifestExisted, agentPath, wireBase, overridesDir, oldDenies = [], oldEdit = { asks: [], shorthand: null },
57
57
  oldHashes = {},
58
58
  } = opts;
59
59
  ensureAgentOverridesStub(cfg, overridesDir);
@@ -98,7 +98,7 @@ function opencodeLayer(cfg, items, themeName, theme, dir, owned, opts) {
98
98
  const wired = {};
99
99
  const cfgName = path.basename(mergeOpencodeJson(path.join(wireBase, 'opencode.json'),
100
100
  agentPath, cfg.doctrines, cfg.excludeRules, userOnlySkills, staleSkillNames, wired,
101
- cfg.deletionGate));
101
+ cfg.deletionGate, opencodeEditAsks(dir, wireBase === dir, wireBase === dir ? null : agentPath), oldEdit));
102
102
  // The next record: Geneseed's earlier denies still wanted, plus the ones it added now. A merge
103
103
  // that wrote nothing (`skillsAdded` unset) keeps the old record whole.
104
104
  const skillDenies = wired.skillsAdded
@@ -107,7 +107,7 @@ function opencodeLayer(cfg, items, themeName, theme, dir, owned, opts) {
107
107
 
108
108
  return {
109
109
  nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands: commands.length, cfgName,
110
- skillDenies, editRefused: [...claim.editRefused],
110
+ skillDenies, editRecord: wired.editRecord ?? oldEdit, editRefused: [...claim.editRefused],
111
111
  };
112
112
  }
113
113
 
@@ -131,7 +131,7 @@ export function emitOpencodeRender(cfg, job) {
131
131
  phaseLog('RENDER');
132
132
  const {
133
133
  theme: _theme, out, root, footprint, nativeCatalog, oldOwned, manifestExisted, agentPath,
134
- oldDenies, oldHashes = {},
134
+ oldDenies, oldEdit, oldHashes = {},
135
135
  } = job;
136
136
  const oc = path.join(root, '.opencode');
137
137
 
@@ -146,9 +146,9 @@ export function emitOpencodeRender(cfg, job) {
146
146
  const { theme, items } = renderAll(cfg, _theme, { footprint, nativeCatalog });
147
147
 
148
148
  const {
149
- nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands, cfgName, skillDenies, editRefused,
149
+ nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands, cfgName, skillDenies, editRecord, editRefused,
150
150
  } = opencodeLayer(cfg, items, _theme, theme, oc, owned, {
151
- oldOwned, manifestExisted, agentPath, wireBase: root, overridesDir: out, oldDenies, oldHashes,
151
+ oldOwned, manifestExisted, agentPath, wireBase: root, overridesDir: out, oldDenies, oldEdit, oldHashes,
152
152
  });
153
153
 
154
154
  return {
@@ -158,6 +158,7 @@ export function emitOpencodeRender(cfg, job) {
158
158
  },
159
159
  cfgName,
160
160
  skillDenies,
161
+ editRecord,
161
162
  editRefused,
162
163
  };
163
164
  }
@@ -197,7 +198,7 @@ export function emitOpencodeRender(cfg, job) {
197
198
  export function emitOpencodeGlobalRender(cfg, job) {
198
199
  phaseLog('RENDER');
199
200
  const {
200
- theme: themeName, cfgDir, out, footprint, nativeCatalog, oldOwned, agentPath, oldDenies,
201
+ theme: themeName, cfgDir, out, footprint, nativeCatalog, oldOwned, agentPath, oldDenies, oldEdit,
201
202
  oldHashes = {},
202
203
  } = job;
203
204
 
@@ -223,9 +224,9 @@ export function emitOpencodeGlobalRender(cfg, job) {
223
224
  // `manifestExisted` is deliberately not passed — the Python does not pass it either, so
224
225
  // the pre-manifest header line is unreachable from this emit on both sides.
225
226
  const {
226
- nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands, cfgName, skillDenies, editRefused,
227
+ nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands, cfgName, skillDenies, editRecord, editRefused,
227
228
  } = opencodeLayer(cfg, items, themeName, theme, cfgDir, owned, {
228
- oldOwned, agentPath, wireBase: cfgDir, overridesDir: cfgDir, oldDenies, oldHashes,
229
+ oldOwned, agentPath, wireBase: cfgDir, overridesDir: cfgDir, oldDenies, oldEdit, oldHashes,
229
230
  });
230
231
 
231
232
  const memStatus = globalMemory(cfgDir, items, out, cfg.src);
@@ -250,6 +251,7 @@ export function emitOpencodeGlobalRender(cfg, job) {
250
251
  nbStatus,
251
252
  cfgName,
252
253
  skillDenies,
254
+ editRecord,
253
255
  editRefused,
254
256
  };
255
257
  }
@@ -510,6 +510,15 @@ export function effectiveTheme(cfg, themeName, { footprint = 'full', lawsPrefix
510
510
  // their wording is a parsed contract.
511
511
  theme.GATE_LINES = GATE_SWITCHES.filter((g) => cfg[g.key] === false)
512
512
  .map((g) => `\n${g.marker}: off`).join('');
513
+ // The carrier's ownership proposal (ruling D6): an install built `--no-ownership-gate` has
514
+ // chosen silence, so it renders no proposal at all — the hook alone standing down left the
515
+ // model still proposing the setup from this prose. Outside any LEAN block: both footprints.
516
+ // Paid on every session, so the three answers are named and the skill carries the how.
517
+ theme.OWNERSHIP_PROPOSAL = cfg.ownershipGate === false ? '' : ' With no section at all, propose it '
518
+ + 'once before the first\nwrite, shell writes included: set it up now, skip this session, or '
519
+ + 'skip in this repo until\nasked (ownership skill). A context line `Ownership: setup declined '
520
+ + '…` means propose nothing:\nrepeat it once, verbatim, in your first reply, after the '
521
+ + 'readiness line. In read-only work,\nsuggest `/document-project` once at most.';
513
522
  return theme;
514
523
  }
515
524
 
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Where the done gate's checks come from (`./hooks-done.mjs` judges them): the project's
3
+ * `.geneseed/done-checks.txt`, else what its root manifests imply.
4
+ *
5
+ * Its own module because two verbs read it — `learn` on Stop and `context` at SessionStart — and
6
+ * `context` is in the CLI's closure (`js/inspect/cost.mjs`), which may not reach a spawn:
7
+ * `./hooks-done.mjs` imports `./hooks.mjs`, which does. Nothing here may spawn either.
8
+ */
9
+ import { existsSync } from 'node:fs';
10
+ import path from 'node:path';
11
+ import { readText } from '../lib/fs.mjs';
12
+ import { DONE_LIST, splitLines } from './hooks-prims.mjs';
13
+
14
+ /** The declared checks, one per line, `#` comments; null when the project has no list. */
15
+ export function readDoneChecks(root) {
16
+ const file = path.join(root, DONE_LIST);
17
+ if (!existsSync(file)) return null;
18
+ try {
19
+ return splitLines(readText(file)).map((l) => l.trim().replace(/\s+/g, ' '))
20
+ .filter((l) => l && !l.startsWith('#'));
21
+ } catch {
22
+ return null;
23
+ }
24
+ }
25
+
26
+ // The package manager a lockfile names; first hit wins, npm without one.
27
+ const PM_LOCKS = [['bun.lockb', 'bun'], ['bun.lock', 'bun'], ['pnpm-lock.yaml', 'pnpm'], ['yarn.lock', 'yarn']];
28
+ const PM_SCRIPTS = ['test', 'lint', 'typecheck'];
29
+
30
+ /** One package.json script as a check: the lockfile's own spellings, plus npm's (npm runs any). */
31
+ function scriptCheck(pm, s) {
32
+ const npm = s === 'test' ? ['npm test', 'npm run test', 'npm t'] : [`npm run ${s}`];
33
+ // `bun test` is bun's own runner, not the `test` script: only `bun run` runs the script.
34
+ const own = pm === 'npm' ? [] : pm === 'bun' ? [`bun run ${s}`] : [`${pm} ${s}`, `${pm} run ${s}`];
35
+ return { label: own[0] ?? npm[0], forms: [...own, ...npm] };
36
+ }
37
+
38
+ // Each wrapper spelling (POSIX and Windows) times each task that runs the tests, with and without
39
+ // a leading `clean`. `refuse` names the flags that make the same command skip the tests: a
40
+ // segment carrying one is no pass (`hooks-done.mjs`'s `groupPasses`).
41
+ const wrapped = (label, bins, tasks, refuse) => ({
42
+ label, refuse, forms: bins.flatMap((b) => tasks.flatMap((t) => [`${b} ${t}`, `${b} clean ${t}`])),
43
+ });
44
+ const MAVEN = wrapped('mvn test', ['mvn', './mvnw', '.\\mvnw', 'mvnw', 'mvnw.cmd'], ['test', 'verify', 'install'],
45
+ /(?:^|\s)-D(?:skipTests|maven\.test\.skip)(?=[=\s]|$)/);
46
+ const GRADLE = wrapped('gradle test', ['gradle', './gradlew', '.\\gradlew', 'gradlew', 'gradlew.bat'], ['test', 'build', 'check'],
47
+ /(?:^|\s)(?:-x|--exclude-task)[ =](?:\S*:)?test(?=\s|$)/);
48
+ // shortcut: no `uv`-prefixed form — that spelling trips the no-Python gates in
49
+ // tests/unit/package_manifest.test.mjs (user decision 2026-10-29: no exemption), so a uv user's
50
+ // run reads as unproven, which is only an advisory.
51
+ const PYTEST = { label: 'pytest', forms: ['pytest', 'python -m pytest', 'python3 -m pytest', 'py -m pytest', 'poetry run pytest'] };
52
+ const MANIFEST_CHECKS = [
53
+ ['pom.xml', MAVEN],
54
+ ['build.gradle', GRADLE],
55
+ ['build.gradle.kts', GRADLE],
56
+ ['pyproject.toml', PYTEST],
57
+ ['Cargo.toml', { label: 'cargo test', forms: ['cargo test'], refuse: /(?:^|\s)--no-run(?=\s|$)/ }],
58
+ ['go.mod', { label: 'go test', forms: ['go test'] }],
59
+ ];
60
+ /**
61
+ * Every root manifest the checks are inferred from — what an emit seeds into the protected list.
62
+ * @type {string[]}
63
+ */
64
+ export const INFERRED_FROM = ['package.json', ...MANIFEST_CHECKS.map(([f]) => /** @type {string} */ (f))];
65
+
66
+ /**
67
+ * The checks the root's manifests imply, and which manifests implied them. npm's default `test`
68
+ * script (`echo "Error: no test specified" && exit 1`) is no check: it fails by design. A
69
+ * pyproject.toml implies `pytest` only where pytest shows: `[tool.pytest` in it, or a
70
+ * `pytest.ini`, `conftest.py` or `tests/` at the root — else a unittest-only or test-less repo
71
+ * would owe an advisory it can never clear.
72
+ *
73
+ * shortcut: KNOWN UNSEEN FORMS. Every one reads as "not run", so it costs a stray advisory, never
74
+ * a false pass; add a form here when a real transcript shows one:
75
+ * - the git root's manifests only — a monorepo's subprojects (`pnpm -r test`,
76
+ * `./gradlew :app:test`, `mvn -pl core test`) are neither inferred nor matched;
77
+ * - a sibling script (`npm run test:unit`) or a runner called directly (`npx vitest`);
78
+ * - a prefix before the command (`CI=1 npm test`, `mvn -q test`): forms match verbatim.
79
+ */
80
+ export function inferDoneChecks(root) {
81
+ const has = (f) => existsSync(path.join(root, f));
82
+ const sources = [];
83
+ const checks = [];
84
+ const add = (source, list) => {
85
+ if (!list.length) return;
86
+ sources.push(source);
87
+ for (const c of list) if (!checks.some((k) => k.label === c.label)) checks.push(c);
88
+ };
89
+ if (has('package.json')) {
90
+ let scripts = null;
91
+ try { scripts = JSON.parse(readText(path.join(root, 'package.json'))).scripts; } catch { /* unreadable: none */ }
92
+ if (!scripts || typeof scripts !== 'object') scripts = {};
93
+ const pm = (PM_LOCKS.find(([f]) => has(f)) ?? [null, 'npm'])[1];
94
+ add('package.json', PM_SCRIPTS.filter((s) => typeof scripts[s] === 'string'
95
+ && !(s === 'test' && /no test specified/.test(scripts[s]))).map((s) => scriptCheck(pm, s)));
96
+ }
97
+ const pytestShows = () => {
98
+ let toml = '';
99
+ try { toml = readText(path.join(root, 'pyproject.toml')); } catch { /* unreadable: no section */ }
100
+ return toml.includes('[tool.pytest') || ['pytest.ini', 'conftest.py', 'tests'].some(has);
101
+ };
102
+ for (const [file, check] of MANIFEST_CHECKS) {
103
+ if (has(file) && (check !== PYTEST || pytestShows())) add(file, [check]);
104
+ }
105
+ return { sources, checks };
106
+ }
107
+
108
+ /**
109
+ * The project's checks: `{ source, blocking, checks: [{ label, forms, refuse? }] }`. The file, when
110
+ * present, wins and blocks; else the inference, advisory. `source` names where they came from.
111
+ */
112
+ export function doneChecksOf(root) {
113
+ const listed = readDoneChecks(root);
114
+ if (listed) return { source: DONE_LIST, blocking: true, checks: listed.map((l) => ({ label: l, forms: [l] })) };
115
+ const { sources, checks } = inferDoneChecks(root);
116
+ return { source: sources.join(', '), blocking: false, checks };
117
+ }
118
+
119
+ /**
120
+ * The one SessionStart line naming the done gate's checks for the repo at `root`. `judged` false
121
+ * is a host that never judges a turn (Bob: its Stop carries no transcript): the line names the
122
+ * checks but claims no verdict.
123
+ */
124
+ export function doneLine(root, judged = true) {
125
+ const { source, blocking, checks } = doneChecksOf(root);
126
+ const names = checks.map((c) => c.label).join(', ');
127
+ const how = (verdict) => (judged ? verdict : 'not judged on this host');
128
+ if (blocking) {
129
+ return checks.length ? `Done gate: from ${source} — ${names} (${how('blocking')})`
130
+ : `Done gate: off — ${source} lists no checks`;
131
+ }
132
+ return checks.length ? `Done gate: inferred from ${source} — ${names} (${how('advisory')})`
133
+ : 'Done gate: no checks could be inferred';
134
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * The Node-side writers into a project's `<git root>/.geneseed/`: its personal-by-default
3
+ * `.gitignore`, and the protected-checks list a PROJECT emit seeds (A3, audit 2026-10-28).
4
+ *
5
+ * Why seed at all: the done gate infers its checks from the manifest (`done-checks.mjs`), so an
6
+ * agent that edits `package.json` lowers its own bar — and the protected-checks gate
7
+ * (`protectedIn`, `js/hosts/hooks.mjs`) asks only when the list exists. A fresh install armed
8
+ * nothing. The seed lists only paths that exist at that root, so no line is stale.
9
+ *
10
+ * SEED ONCE, then the file is the user's: created only when absent, never rewritten, never
11
+ * pruned, never deleted on uninstall, and recorded in no manifest. Owning it broke two ways
12
+ * (review 2026-10-29): two hosts in one repo, where one uninstall deleted the other's seed, and a
13
+ * committed seed plus a committed manifest, where every teammate's rebuild rewrote the team's
14
+ * list. To opt out, the user empties it; an existing file, even comment-only, is never re-seeded.
15
+ *
16
+ * Never throws: a `.geneseed` that is a file, a link or read-only must not cost the emit its
17
+ * manifest (the next emit would then read the whole install as the user's). Spawn-free.
18
+ */
19
+ import { lstatSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
20
+ import path from 'node:path';
21
+ import { INFERRED_FROM } from './done-checks.mjs';
22
+ import { gitRootOf } from './gitref.mjs';
23
+
24
+ /**
25
+ * The `.geneseed/.gitignore` every writer creates: personal by default, the team paths allowed
26
+ * back. Anchored `/*`: a bare `*` matches at every depth and would hide `bricks/x.md` even under
27
+ * `!bricks/`. The same string lives in `adapters/opencode/plugins/geneseed-workflow.js`,
28
+ * `adapters/opencode/workflows/_runtime.js` and `src/skills/_checkpoints.md`; tests pin them.
29
+ */
30
+ export const GENESEED_GITIGNORE = '/*\n!/.gitignore\n!/bricks/\n!/loops/\n!/protected-checks.txt\n!/done-checks.txt\n';
31
+
32
+ /**
33
+ * Create-if-absent; a file holding only `*` is Geneseed's former output (it hid team bricks),
34
+ * never a user edit, so it is upgraded. Any other content, or a link, is the user's. Never
35
+ * throws: hygiene must not fail an emit. Same content rules as `writeGitignore` in the two
36
+ * OpenCode copies, but NOT the same link handling: those still write through a symlinked
37
+ * `.gitignore` (a known follow-up); this one refuses to.
38
+ */
39
+ export function writeGeneseedGitignore(file) {
40
+ try { writeFileSync(file, GENESEED_GITIGNORE, { flag: 'wx' }); } catch {
41
+ try {
42
+ if (!lstatSync(file).isSymbolicLink() && /^\*(\r?\n)?$/.test(readFileSync(file, 'utf8'))) {
43
+ writeFileSync(file, GENESEED_GITIGNORE);
44
+ }
45
+ } catch { /* contained */ }
46
+ }
47
+ }
48
+
49
+ /** The seeded list, relative to the git root. */
50
+ export const SEED_REL = '.geneseed/protected-checks.txt';
51
+
52
+ /**
53
+ * What a project's checks live in. A string ending `/` is a folder, any other string a file; a
54
+ * regex matches file names at the root. Lockfiles are not listed: they move on every install.
55
+ */
56
+ const CANDIDATES = [
57
+ '.github/workflows/', '.gitlab-ci.yml', 'Jenkinsfile', 'azure-pipelines.yml', '.circleci/',
58
+ /^eslint\.config\./, /^\.eslintrc/, 'biome.json', 'biome.jsonc', 'tsconfig.json',
59
+ /^jest\.config\./, /^vitest\.config\./, 'pytest.ini', 'ruff.toml', '.golangci.yml', 'checkstyle.xml',
60
+ ...INFERRED_FROM,
61
+ ];
62
+
63
+ const SEED_HEADER = '# Seeded once by Geneseed with the checks found in this project; it is yours now.\n'
64
+ + '# A write tool aimed at a listed path asks you first (on Bob, it is blocked): External Gate.\n'
65
+ + '# One repo-relative file or folder per line; `#` starts a comment. A shell command is not\n'
66
+ + '# seen: CI holds that. To opt out, delete the listed paths (the comments may stay) but keep\n'
67
+ + '# the file: a missing file is seeded again.\n';
68
+
69
+ /** The seed for git root `root`, or null when none of the candidates exists there. */
70
+ export function protectedChecksSeed(root) {
71
+ const kind = (rel) => { try { return statSync(path.join(root, rel)); } catch { return null; } };
72
+ let names = [];
73
+ try { names = readdirSync(root).sort(); } catch { /* unreadable: no regex matches */ }
74
+ const found = [];
75
+ for (const c of CANDIDATES) {
76
+ if (typeof c !== 'string') {
77
+ for (const n of names) if (c.test(n) && kind(n)?.isFile() && !found.includes(n)) found.push(n);
78
+ } else if (c.endsWith('/') ? kind(c.slice(0, -1))?.isDirectory() : kind(c)?.isFile()) {
79
+ found.push(c);
80
+ }
81
+ }
82
+ return found.length ? `${SEED_HEADER}${found.join('\n')}\n` : null;
83
+ }
84
+
85
+ /**
86
+ * Seed `<git root of projectRoot>/.geneseed/protected-checks.txt` when it is absent and a
87
+ * candidate exists; then, whenever `.geneseed/` is a real directory, make sure its `.gitignore`
88
+ * exists (`writeGeneseedGitignore`). No git root: nothing. Nothing is written through a link: a
89
+ * `.geneseed` that is a symlink, or a leaf that is one (dangling included — `lstat`, not
90
+ * `exists`), is left alone. A failure is one stderr warning; the emit goes on.
91
+ */
92
+ export function seedProtectedChecks(projectRoot) {
93
+ const root = gitRootOf(projectRoot);
94
+ if (!root) return;
95
+ const dir = path.join(root, '.geneseed');
96
+ const at = (p) => lstatSync(p, { throwIfNoEntry: false });
97
+ try {
98
+ const d = at(dir);
99
+ if (d && !d.isDirectory()) {
100
+ process.stderr.write(`[geneseed] WARN: ${dir} is not a directory — `
101
+ + 'the protected-checks list was not seeded\n');
102
+ return;
103
+ }
104
+ if (!at(path.join(dir, 'protected-checks.txt'))) {
105
+ const text = protectedChecksSeed(root);
106
+ if (text !== null) {
107
+ mkdirSync(dir, { recursive: true });
108
+ writeFileSync(path.join(dir, 'protected-checks.txt'), text, { flag: 'wx' });
109
+ }
110
+ }
111
+ if (at(dir)?.isDirectory()) writeGeneseedGitignore(path.join(dir, '.gitignore'));
112
+ } catch (e) {
113
+ process.stderr.write(`[geneseed] WARN: could not seed ${SEED_REL} at ${root}: `
114
+ + `${e && e.message ? e.message : e}\n`);
115
+ }
116
+ }
@@ -11,6 +11,9 @@ import { normcase, toPlatformPath } from '../lib/paths.mjs';
11
11
  import { relPosix } from '../lib/text.mjs';
12
12
  import { globalHookStandingDown, hookProjectDir, resolvePath, sovereignBypass } from './hosts.mjs';
13
13
  import { isFile, isDir, sortPaths, listDir } from './hooks-prims.mjs';
14
+ import { gitRootOf } from './gitref.mjs';
15
+ import { doneLine } from './done-checks.mjs';
16
+ import { ownershipLine } from './ownership-gate.mjs';
14
17
 
15
18
  /**
16
19
  * `str(OSError)` — `[Errno N] strerror: 'filename'`, with the filename REPR'd.
@@ -443,9 +446,24 @@ export function cmdContext(args) {
443
446
  let [eager, lazy, source] = resolveContextSets(root, hookRoot);
444
447
  eager = eager.filter(fresh);
445
448
  lazy = lazy.filter(fresh);
449
+ // The done gate's checks for this repo, and where they come from (`./hooks-done.mjs`). No git
450
+ // root, no gate, no line. Printed even when there is nothing else to load. An install built
451
+ // `--no-done-gate` carries `Done gate: off` in its AGENT.md and gets no line — the OpenCode
452
+ // context plugin's `doneGateOff` reads the same marker with the same pattern.
453
+ const gitRoot = gitRootOf(root);
454
+ let carrier = '';
455
+ try { carrier = hookRoot ? readFileSync(path.join(hookRoot, 'AGENT.md'), 'utf8') : ''; } catch { /* no carrier: armed */ }
456
+ const gateOff = (marker) => new RegExp(`^${marker}:[ \\t]*off[ \\t]*\\r?$`, 'm').test(carrier);
457
+ // Bob's Stop carries no transcript, so the gate never judges a turn there (`hooks-done.mjs`).
458
+ const done = gitRoot && !gateOff('Done gate') ? doneLine(gitRoot, HOST !== 'bob') : null;
459
+ // The ownership decline reminder (`./ownership-gate.mjs`), under the same contract: an install
460
+ // built `--no-ownership-gate` carries `Ownership gate: off` and gets no line.
461
+ const owned = gitRoot && !gateOff('Ownership gate') ? ownershipLine(gitRoot) : null;
462
+ const heads = [done, owned].filter(Boolean);
446
463
  if (!session.length && !eager.length && !lazy.length) {
447
464
  err(`[context] nothing to load for ${root} `
448
465
  + '(no docs discovered, no manifest entries).\n');
466
+ if (heads.length) out(`${heads.join('\n')}\n`);
449
467
  return 0;
450
468
  }
451
469
 
@@ -454,6 +472,7 @@ export function cmdContext(args) {
454
472
  // the whole payload, not on the file bodies alone.
455
473
  let spent = 0;
456
474
  const push = (...ls) => { for (const l of ls) { lines.push(l); spent += cost(l); } };
475
+ if (heads.length) push(...heads, '');
457
476
  if (session.length) {
458
477
  push('=== SESSION FILES \u2014 your harness files, injected at session start '
459
478
  + '(untouched seeds skipped) ===', '');