geneseed 5.4.0 → 5.5.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 (162) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +30 -0
  3. package/SHIPPED.md +1 -1
  4. package/adapters/bob/README.md +12 -1
  5. package/adapters/opencode/README.md +2 -1
  6. package/adapters/opencode/plugins/geneseed-context.js +71 -10
  7. package/adapters/opencode/plugins/geneseed-guard.js +101 -19
  8. package/adapters/opencode/plugins/geneseed-learn.js +641 -6
  9. package/bin/geneseed-cli.mjs +3 -0
  10. package/bin/geneseed-hook.mjs +2 -1
  11. package/docs/concepts/agents.md +13 -1
  12. package/docs/concepts/enforcement-table.md +1 -1
  13. package/docs/concepts/foreman-mode.md +22 -3
  14. package/docs/concepts/hook-gates.md +1 -1
  15. package/docs/concepts/hooks.md +22 -5
  16. package/docs/concepts/host-matrix.md +2 -2
  17. package/docs/concepts/hosts.md +1 -1
  18. package/docs/concepts/shared-tier.md +1 -1
  19. package/docs/concepts/skills.md +21 -1
  20. package/docs/concepts/themes.md +1 -1
  21. package/docs/extending.md +10 -1
  22. package/docs/guides/install-clone.md +18 -0
  23. package/docs/guides/install-scripted.md +8 -2
  24. package/docs/guides/install.md +19 -1
  25. package/docs/guides/upgrade.md +1 -1
  26. package/docs/reference/env-context.md +1 -1
  27. package/docs/reference/environment.md +1 -1
  28. package/docs/reference/plugin-learn.md +4 -0
  29. package/docs/reference/profiles.md +142 -0
  30. package/docs/token-footprint.md +9 -4
  31. package/docs/understand/design-choices-engineering.md +1 -1
  32. package/docs/web-ui.md +3 -1
  33. package/harness.config.json +1 -1
  34. package/js/README.md +9 -2
  35. package/js/build/args.mjs +4 -3
  36. package/js/build/catalog.mjs +11 -1
  37. package/js/build/driver.mjs +42 -11
  38. package/js/build/emit-claude.mjs +24 -1
  39. package/js/build/emit-opencode.mjs +3 -0
  40. package/js/build/export.mjs +1 -1
  41. package/js/build/generate.mjs +2 -1
  42. package/js/build/notes-migrate.mjs +99 -0
  43. package/js/build/profile.mjs +14 -6
  44. package/js/build/render.mjs +34 -10
  45. package/js/build/source.mjs +85 -2
  46. package/js/cli-table.json +164 -4
  47. package/js/hosts/agent-runs.mjs +205 -0
  48. package/js/hosts/done-checks.mjs +3 -1
  49. package/js/hosts/hooks-done.mjs +91 -16
  50. package/js/hosts/hooks-learn.mjs +85 -0
  51. package/js/hosts/hooks-prims.mjs +39 -1
  52. package/js/hosts/hooks.mjs +6 -3
  53. package/js/hosts/hosts.mjs +10 -0
  54. package/js/hosts/installs.mjs +25 -1
  55. package/js/hosts/link.mjs +45 -10
  56. package/js/hosts/native.mjs +42 -5
  57. package/js/hosts/opencode.mjs +1 -1
  58. package/js/hosts/settings.mjs +72 -0
  59. package/js/hosts/spec-feedback.mjs +538 -0
  60. package/js/hosts/usage.mjs +67 -8
  61. package/js/inspect/agent-scores.mjs +118 -0
  62. package/js/inspect/checks-authoring.mjs +2 -1
  63. package/js/inspect/checks-build.mjs +20 -4
  64. package/js/inspect/checks-repo.mjs +27 -2
  65. package/js/inspect/cost.mjs +6 -5
  66. package/js/inspect/diff.mjs +25 -5
  67. package/js/inspect/doctor.mjs +4 -0
  68. package/js/inspect/status.mjs +3 -1
  69. package/js/inspect/validate.mjs +1 -0
  70. package/js/lib/machine-dir.mjs +8 -0
  71. package/js/lib/paths.mjs +4 -1
  72. package/js/maintain/profile-scope.mjs +145 -0
  73. package/js/maintain/profiles.mjs +486 -0
  74. package/js/maintain/setup.mjs +409 -15
  75. package/js/maintain/uninstall.mjs +4 -1
  76. package/js/maintain/update.mjs +1 -1
  77. package/js/web/actions.mjs +28 -38
  78. package/js/web/api.mjs +7 -2
  79. package/js/web/handler.mjs +8 -0
  80. package/js/web/jobs.mjs +5 -4
  81. package/js/web/profiles-api.mjs +201 -0
  82. package/js/web/routes.mjs +5 -0
  83. package/package.json +2 -1
  84. package/profiles/guillaume-claude-global.json +16 -0
  85. package/profiles/starter.json +14 -0
  86. package/src/AGENT.md.tmpl +1 -1
  87. package/src/agents/_self-improvement.md +15 -7
  88. package/src/agents/_template.md +4 -2
  89. package/src/agents/advocate.md +1 -1
  90. package/src/agents/architect.md +1 -1
  91. package/src/agents/developer.md +10 -3
  92. package/src/agents/devops-engineer.md +1 -1
  93. package/src/agents/docker-expert.md +1 -1
  94. package/src/agents/docs.md +1 -1
  95. package/src/agents/empiricist.md +1 -1
  96. package/src/agents/explorer.md +4 -2
  97. package/src/agents/framer.md +1 -1
  98. package/src/agents/historian.md +1 -1
  99. package/src/agents/kubernetes-specialist.md +1 -1
  100. package/src/agents/memory-curator.md +1 -1
  101. package/src/agents/operator.md +1 -1
  102. package/src/agents/performance.md +1 -1
  103. package/src/agents/pragmatist.md +1 -1
  104. package/src/agents/react-engineer.md +1 -1
  105. package/src/agents/react-reviewer.md +1 -1
  106. package/src/agents/researcher.md +1 -1
  107. package/src/agents/reviewer.md +10 -3
  108. package/src/agents/security.md +1 -1
  109. package/src/agents/skeptic.md +1 -1
  110. package/src/agents/spring-boot-engineer.md +1 -1
  111. package/src/agents/spring-reviewer.md +1 -1
  112. package/src/agents/spring-security.md +1 -1
  113. package/src/agents/steward.md +1 -1
  114. package/src/agents/tester.md +4 -2
  115. package/src/agents/user-advocate.md +1 -1
  116. package/src/agents/visionary.md +1 -1
  117. package/src/memory/README.md +12 -2
  118. package/src/modes/foreman.md +23 -10
  119. package/src/skill-descriptions.json +63 -0
  120. package/src/skills/_self-improvement.md +42 -26
  121. package/src/skills/_template.md +3 -1
  122. package/src/skills/brainstorm.md +35 -22
  123. package/src/skills/daydream/VENDOR.md +6 -0
  124. package/src/skills/diagram-design/VENDOR.md +4 -0
  125. package/src/skills/explain-changes/VENDOR.md +5 -1
  126. package/src/skills/parallel-agents.md +11 -0
  127. package/src/skills/pipeline.md +3 -3
  128. package/src/skills/plan.md +5 -4
  129. package/src/skills/react-view-transitions/VENDOR.md +7 -1
  130. package/src/skills/release.md +7 -2
  131. package/src/skills/rule/approve.md +2 -1
  132. package/src/skills/skill-forge.md +5 -3
  133. package/src/skills/token-report/VENDOR.md +5 -1
  134. package/src/upstreams.json +2 -2
  135. package/themes/README.md +3 -1
  136. package/web/dist/assets/{ActiveLoops-BJJN3P-V.js → ActiveLoops-DOJCPPPc.js} +1 -1
  137. package/web/dist/assets/{Activity-D2kOc3yi.js → Activity-LKsDzsnK.js} +1 -1
  138. package/web/dist/assets/{ActivityDetail-By3xOr21.js → ActivityDetail-DhwTfPm6.js} +1 -1
  139. package/web/dist/assets/{Bonsai-CBWDTBA4.js → Bonsai-CePMLrpr.js} +1 -1
  140. package/web/dist/assets/{CopyButton-BVbpriMB.js → CopyButton-CuoaJ6k7.js} +1 -1
  141. package/web/dist/assets/{Dashboard-CIJLPHM9.js → Dashboard-D1VKuvLe.js} +2 -2
  142. package/web/dist/assets/{Docs-CiRRIELs.js → Docs-CUrHJKaU.js} +1 -1
  143. package/web/dist/assets/{Factories-DhyK0O8d.js → Factories-Ci1XfmSy.js} +1 -1
  144. package/web/dist/assets/{GreenhouseView-DW3PgTPy.js → GreenhouseView-CNfH2lPK.js} +1 -1
  145. package/web/dist/assets/Installs-ZHQZM1iS.js +3 -0
  146. package/web/dist/assets/{JournalView-O65qEWfp.js → JournalView-CMsWahkS.js} +1 -1
  147. package/web/dist/assets/{Kits-C5U-yT6Z.js → Kits-CkliyK0n.js} +1 -1
  148. package/web/dist/assets/{Laws-CuTw_XNf.js → Laws-hh4O3HZ4.js} +1 -1
  149. package/web/dist/assets/{LibRows-D6-CVa3K.js → LibRows-Brv0Hmkr.js} +1 -1
  150. package/web/dist/assets/{Library-CzPlerd6.js → Library-BYmiLjJr.js} +1 -1
  151. package/web/dist/assets/{Loops-CqNF_-nS.js → Loops-ytm-xJ68.js} +1 -1
  152. package/web/dist/assets/{OperatorHudView-BNr8K5qj.js → OperatorHudView-KaqCx_HP.js} +1 -1
  153. package/web/dist/assets/{Personal-DeDb9e8O.js → Personal-CmcnRKYE.js} +1 -1
  154. package/web/dist/assets/{Settings-B8MPN_AD.js → Settings-tUrpdOfq.js} +1 -1
  155. package/web/dist/assets/{Tabs-DJzAez4h.js → Tabs-CD7etcGD.js} +1 -1
  156. package/web/dist/assets/api-CZ-x0iWG.js +1 -0
  157. package/web/dist/assets/{controls-D4wmg_pl.js → controls-CK7qHA8H.js} +1 -1
  158. package/web/dist/assets/{index-CRWqKxfY.css → index-Ba_Kg3Af.css} +1 -1
  159. package/web/dist/assets/{index-BL3P-9Rg.js → index-COKbhFNo.js} +3 -3
  160. package/web/dist/index.html +3 -3
  161. package/web/dist/assets/Installs-B6nlo-Ly.js +0 -3
  162. package/web/dist/assets/api-DLDVY3K-.js +0 -1
@@ -35,7 +35,8 @@ import { existsSync, readdirSync } from 'node:fs';
35
35
  import path from 'node:path';
36
36
 
37
37
  import {
38
- CONFIG, GATE_SWITCHES, PACK_ORDER, RETIRED_KIT_IDS, THEMES, discoverNames, loadKits, resolveSkillNames,
38
+ CONFIG, CONTEXT_WINDOWS, CONTEXT_WINDOW_MARKER, DEFAULT_CONTEXT_WINDOW, GATE_SWITCHES, PACK_ORDER,
39
+ RETIRED_KIT_IDS, THEMES, discoverNames, loadKits, resolveSkillNames,
39
40
  } from '../build/source.mjs';
40
41
  import {
41
42
  CARRIERS, CLAUDE_STYLE, DISABLED_STASH, GLOBAL_MANIFEST, HOSTS, SHARED_TIER_RE, carriersFor, gateCarrierText, isHostGlobalDir,
@@ -492,6 +493,25 @@ export function sharedTierOfDir(d, host = null) {
492
493
  }, false, host);
493
494
  }
494
495
 
496
+ const CONTEXT_WINDOW_RE = new RegExp(`^${CONTEXT_WINDOW_MARKER}:[ \\t]*(\\S+?)[ \\t]*\\r?$`, 'm');
497
+
498
+ /**
499
+ * The context window a DEPLOYED install was built for (`--context-window`), read back so
500
+ * `rebuild-all`, `upgrade`, `diff`, the wizard, profiles and the console re-render it. A missing
501
+ * line is the default: the marker is only ever written off it (the kits line's contract), and an
502
+ * install older than the option is a default install. A value this checkout does not know reads
503
+ * as the default too, so a hand-edited line can never reach `--context-window` and refuse a rebuild.
504
+ */
505
+ export function contextWindowOfDir(d, host = null) {
506
+ return firstCarrier(d, (carrierPath) => {
507
+ const text = readMaybe(carrierPath);
508
+ if (text === null) return undefined;
509
+ const m = CONTEXT_WINDOW_RE.exec(text);
510
+ if (!m) return undefined;
511
+ return Object.hasOwn(CONTEXT_WINDOWS, m[1]) ? m[1] : DEFAULT_CONTEXT_WINDOW;
512
+ }, DEFAULT_CONTEXT_WINDOW, host);
513
+ }
514
+
495
515
  /**
496
516
  * Whether a DEPLOYED install keeps one law's hook gate armed — `true` (armed) or `false` (its
497
517
  * `<marker>: off` line, written by a build with that gate's `--no-*-gate` flag; `GATE_SWITCHES`).
@@ -833,6 +853,7 @@ export function installedDefaults() {
833
853
  const found = {
834
854
  theme: null, posture: null, mode: null, emit: null, footprint: null, doctrines: null,
835
855
  excludeRules: null, excludeSkills: null, kits: null, sharedTier: false,
856
+ contextWindow: DEFAULT_CONTEXT_WINDOW,
836
857
  };
837
858
  const candidates = [];
838
859
  for (const { host, configDir } of HOSTS) {
@@ -882,6 +903,9 @@ export function installedDefaults() {
882
903
  try { found.kits = kitsOfDir(base); } catch { found.kits = []; }
883
904
  }
884
905
  if (!found.sharedTier) found.sharedTier = sharedTierOfDir(base);
906
+ // Two states too: the default and no line read the same, so the first install that says
907
+ // otherwise speaks.
908
+ if (found.contextWindow === DEFAULT_CONTEXT_WINDOW) found.contextWindow = contextWindowOfDir(base);
885
909
  }
886
910
  return found;
887
911
  }
package/js/hosts/link.mjs CHANGED
@@ -72,7 +72,7 @@
72
72
  * source-level: that file asserts the spawn's shape without running it.
73
73
  */
74
74
  import {
75
- chmodSync, existsSync, lstatSync, mkdirSync, readlinkSync, rmSync,
75
+ appendFileSync, chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, rmSync,
76
76
  } from 'node:fs';
77
77
  import { isatty } from 'node:tty';
78
78
  import { spawnSync } from 'node:child_process';
@@ -140,23 +140,44 @@ export function withoutPathBlock(text) {
140
140
  * `~/.local/bin`, so a linked `geneseed` was not found (reported 2026-10). Only in a terminal:
141
141
  * the web console's button and every test run without one, and get the printed line instead,
142
142
  * so no gate can edit the developer's own startup file. Returns whether it wrote.
143
+ *
144
+ * `unattended` is `setup --profile`'s: running the profile IS the consent (install profiles,
145
+ * D26), so it writes the block without asking and without a terminal, and records the file it
146
+ * changed in `report.rcFile` for the run's summary. Only that caller passes it. `rc` is the
147
+ * test's seam; every caller takes `shellRcFile()`.
148
+ *
149
+ * THE BLOCK IS APPENDED, NEVER THE FILE REWRITTEN: a rewrite of someone's startup file risks the
150
+ * whole file for the sake of three lines. The block takes the file's own line ending. Only a
151
+ * missing file reads as empty; any other read error (permissions, a directory) refuses the write,
152
+ * because writing over a file that could not be read is how a startup file gets lost.
143
153
  */
144
- function offerShellPath(dir) {
145
- const rc = shellRcFile();
146
- if (!rc || !isatty(0)) return false;
147
- const text = readMaybe(rc) ?? '';
154
+ export function offerShellPath(dir, { unattended = false, report = null, rc = shellRcFile() } = {}) {
155
+ if (!rc || (!unattended && !isatty(0))) return false;
156
+ let text;
157
+ try {
158
+ text = readFileSync(rc, 'utf8');
159
+ } catch (e) {
160
+ if (e && e.code !== 'ENOENT') {
161
+ printErr(`geneseed: could not read ${rc} (${asOsError(e)}) — leaving it unchanged\n`);
162
+ return false;
163
+ }
164
+ text = '';
165
+ }
148
166
  if (text.includes(RC_BEGIN)) {
149
167
  printOut(`geneseed: ${rc} already adds it — open a NEW terminal, then run 'geneseed'.\n`);
150
168
  return true;
151
169
  }
152
- if (!confirm(`geneseed: add '${dir}' to your PATH in ${rc}?`, true)) return false;
170
+ if (!unattended && !confirm(`geneseed: add '${dir}' to your PATH in ${rc}?`, true)) return false;
171
+ const eol = text.includes('\r\n') ? '\r\n' : '\n';
172
+ const sep = text === '' || text.endsWith('\n') ? '' : eol;
153
173
  try {
154
- writeText(rc, withPathBlock(text, dir));
174
+ appendFileSync(rc, sep + withPathBlock('', dir).replaceAll('\n', eol), 'utf8');
155
175
  } catch (e) {
156
176
  printErr(`geneseed: could not write ${rc} (${asOsError(e)})\n`);
157
177
  return false;
158
178
  }
159
179
  printOut(`geneseed: added it to ${rc} — open a NEW terminal, then run 'geneseed'.\n`);
180
+ if (report) report.rcFile = rc;
160
181
  return true;
161
182
  }
162
183
 
@@ -264,8 +285,15 @@ function isOurLauncher(f) {
264
285
  return existsSync(f) && (readMaybe(f) ?? '').includes(SHIM_MARKER);
265
286
  }
266
287
 
267
- /** Put `geneseed` on PATH so it runs from any directory. */
268
- export function cmdLink(args) {
288
+ /**
289
+ * Put `geneseed` on PATH so it runs from any directory. `opts` is `setup --profile`'s (see
290
+ * `offerShellPath`): `unattended` writes the shell rc block without asking; `report` receives
291
+ * `rcFile` (the startup file it changed), `foreign` (a launcher it left alone), and `onPath`:
292
+ * false, with `pathDir`, when the launcher was written but its dir is not on PATH (PowerShell
293
+ * blocked, a shell whose startup file this cannot edit, an rc write that failed) — exit 0 all the
294
+ * same, so only `report` can tell the caller.
295
+ */
296
+ export function cmdLink(args, opts = {}) {
269
297
  const here = ROOT;
270
298
  if (IS_WIN) {
271
299
  const bindir = winBinDir();
@@ -284,8 +312,10 @@ export function cmdLink(args) {
284
312
  printOut(`geneseed: wrote shim ${shim}\n`);
285
313
  if (winPathHas(process.env.PATH || '', bindir) || winUserPath('add', bindir)) {
286
314
  printOut(`geneseed: '${bindir}' is on your user PATH — open a NEW terminal, then run \`geneseed\`.\n`);
315
+ if (opts.report) opts.report.onPath = true;
287
316
  } else {
288
317
  printOut(`geneseed: add '${bindir}' to your PATH manually, then run \`geneseed\` from anywhere.\n`);
318
+ if (opts.report) Object.assign(opts.report, { onPath: false, pathDir: bindir });
289
319
  }
290
320
  return 0;
291
321
  }
@@ -318,6 +348,7 @@ export function cmdLink(args) {
318
348
  // judgement `cmdUnlink` makes about the same file.
319
349
  if (isSymlink(dest) || existsSync(dest)) {
320
350
  if (!isOurLauncher(dest)) {
351
+ if (opts.report) opts.report.foreign = dest;
321
352
  printErr(`geneseed: ${dest} exists and is not a launcher geneseed wrote — leaving it `
322
353
  + 'alone. Remove it yourself, or pick another dir: geneseed link <dir>\n');
323
354
  return 1;
@@ -339,9 +370,13 @@ export function cmdLink(args) {
339
370
  printOut(`geneseed: linked ${dest} -> ${entry}\n`);
340
371
  if ((process.env.PATH || '').split(path.delimiter).includes(targetDir)) {
341
372
  printOut(`geneseed: '${targetDir}' is on PATH — run 'geneseed' from anywhere.\n`);
342
- } else if (!offerShellPath(targetDir)) {
373
+ if (opts.report) opts.report.onPath = true;
374
+ } else if (!offerShellPath(targetDir, { unattended: opts.unattended, report: opts.report })) {
343
375
  printOut(`geneseed: NOTE '${targetDir}' is not on your PATH. Add it, e.g.:\n`);
344
376
  printOut(` echo 'export PATH="${targetDir}:$PATH"' >> ~/.zshrc # or ~/.bashrc\n`);
377
+ if (opts.report) Object.assign(opts.report, { onPath: false, pathDir: targetDir });
378
+ } else if (opts.report) {
379
+ opts.report.onPath = true;
345
380
  }
346
381
  return 0;
347
382
  }
@@ -32,7 +32,7 @@ import path from 'node:path';
32
32
  import { writeText, copyFile, readText } from '../lib/fs.mjs';
33
33
  import { jsonDumps, parseJson, formatValue, formatRepr, isTruthy, isDict } from '../lib/json.mjs';
34
34
  import { relPosix } from '../lib/text.mjs';
35
- import { aliasesOf } from '../build/source.mjs';
35
+ import { aliasesOf, skillDescriptions } from '../build/source.mjs';
36
36
  import { resolvePath } from './hosts.mjs';
37
37
  import { claimLeaf, ownedState } from './owned.mjs';
38
38
  // `lstripNewlines` on spec bodies is a no-op on every input the generator produces today
@@ -147,7 +147,8 @@ function triggerOf(text) {
147
147
  }
148
148
 
149
149
  /**
150
- * Purpose + the trigger's FIRST sentence, the emitted `description:` of a skill. Every
150
+ * Purpose + the trigger's FIRST sentence: the emitted `description:` of a skill that has no
151
+ * catalogue line (see below), and the form every skill had until 2026-11-15. Every
151
152
  * description is always-on context on a host that catalogues natively: at the earlier
152
153
  * 900-char cap the catalogue weighed 22k chars (~5.6k tokens) across 51 skills, three times
153
154
  * the figure the footprint page quoted. The first sentence says WHEN; the later sentences
@@ -157,8 +158,44 @@ function triggerOf(text) {
157
158
  * failure, so the cure is a shorter first trigger sentence in the source, never a wider cap.
158
159
  */
159
160
  const DESCRIPTION_CAP = 320;
160
- export function skillDescription(text) {
161
- return withWhen(firstBlockquote(text), triggerOf(text));
161
+ /**
162
+ * A skill with a line in `src/skill-descriptions.json` (`skillDescriptions`) gets that line,
163
+ * and every shipped skill has one (`catalogueLineProblems` refuses a gap); the purpose +
164
+ * trigger composition above is the fallback for a fixture tree or a skill not catalogued yet.
165
+ */
166
+ export function skillDescription(text, stem = null, src = undefined) {
167
+ const line = stem === null ? undefined : skillDescriptions(src)[stem];
168
+ return typeof line === 'string' ? line : withWhen(firstBlockquote(text), triggerOf(text));
169
+ }
170
+
171
+ /**
172
+ * A vendored skill's own SKILL.md with its frontmatter `description:` swapped for the
173
+ * catalogue line, the upstream description kept as the first body line, as a blockquote. The
174
+ * upstream lines ran to 600 characters and were the longest in the listing. Text with no
175
+ * catalogue line, no frontmatter or no `description:` key passes unchanged, and so does a
176
+ * value this cannot read whole: a block scalar (`>`, `|`), a plain scalar continued on an
177
+ * indented next line, or a quoted value that does not close on its line.
178
+ */
179
+ export function vendoredWithCatalogueLine(text, stem, src = undefined) {
180
+ const line = skillDescriptions(src)[stem];
181
+ const m = /^---\r?\n([\s\S]*?\r?\n)?---\r?\n/.exec(text);
182
+ if (typeof line !== 'string' || !m) return text;
183
+ const eol = text.includes('\r\n') ? '\r\n' : '\n';
184
+ const lines = m[0].split(/\r?\n/);
185
+ const at = lines.findIndex((ln) => /^description:/.test(ln));
186
+ const raw = at < 0 ? '' : lines[at].replace(/^description:\s*/, '');
187
+ if (!raw || /^[>|]/.test(raw) || /^[ \t]/.test(lines[at + 1] ?? '')) return text;
188
+ let upstream = raw;
189
+ if (raw.startsWith('"')) {
190
+ try { upstream = parseJson(raw); } catch { return text; }
191
+ } else if (raw.startsWith("'")) {
192
+ // YAML single quotes: `''` is an escaped quote, and the value must close on its line.
193
+ if (!/^'(?:[^']|'')*'$/.test(raw)) return text;
194
+ upstream = raw.slice(1, -1).replaceAll("''", "'");
195
+ }
196
+ lines[at] = `description: ${jsonDumps(line)}`;
197
+ const body = text.slice(m[0].length).replace(/^(\r?\n)+/, '');
198
+ return `${lines.join(eol)}${eol}> ${upstream}${eol}${eol}${body}`;
162
199
  }
163
200
 
164
201
  /**
@@ -752,7 +789,7 @@ export function writeNativeLayer(items, agentsDir, skillsDir, overrides = null,
752
789
  // ALIASES are the one case every non-Claude dialect shares: no alias skill via
753
790
  // frontmatter exists for them either, so an alias skill there would land in the
754
791
  // model's catalogue as a duplicate; it gets a command instead (`writeAliasCommands`).
755
- fm = [`name: ${stem}`, `description: ${jsonDumps(skillDescription(text))}`];
792
+ fm = [`name: ${stem}`, `description: ${jsonDumps(skillDescription(text, stem, src))}`];
756
793
  userOnly = isUserInvokedOnly(text);
757
794
  if (userOnly && !bobDialect) fm.push('disable-model-invocation: true');
758
795
  body = stripSkillBodyLinks(pointSideFiles(body, stem, skillDirOf ? skillDirOf(stem)
@@ -388,7 +388,7 @@ export function writeAliasCommands(cfg, items, commandDir, claim = (_dest) => tr
388
388
  for (const name of names) {
389
389
  const dest = path.join(commandDir, `${name}.md`);
390
390
  if (!claim(dest)) continue;
391
- writeCommandFile(dest, name === stem ? skillDescription(text) : `Alias of ${stem}.`, body);
391
+ writeCommandFile(dest, name === stem ? skillDescription(text, stem, cfg.src) : `Alias of ${stem}.`, body);
392
392
  written.push(dest);
393
393
  }
394
394
  }
@@ -1443,6 +1443,78 @@ export function unwireClaudeEnv(p, recorded) {
1443
1443
  }
1444
1444
  }
1445
1445
 
1446
+ /**
1447
+ * The skill-listing keys of `--context-window` (`CONTEXT_WINDOWS`, js/build/source.mjs), merged
1448
+ * into top-level settings keys one by one. Returns the `{key: value}` pairs Geneseed owns after
1449
+ * the merge, which the manifest records (`managed.settings_listing`).
1450
+ *
1451
+ * UNLIKE `wireClaudeEnv`, A VALUE GENESEED OWNS CAN CHANGE: `200k` -> `1m` turns 80 into 120 and
1452
+ * takes the fraction away. So ownership is the record, checked against the file:
1453
+ * - a key absent from the file is written and recorded;
1454
+ * - a key on file with exactly the recorded value is Geneseed's: updated to `want`, or removed
1455
+ * when `want` no longer names it;
1456
+ * - any other key on file is the user's, even one equal to `want` with no record, and it stays
1457
+ * untouched and unrecorded, so uninstall never takes it.
1458
+ * A commented file is never rewritten: the wanted changes are printed for a hand merge and the
1459
+ * keys already owned stay recorded as they are on file.
1460
+ */
1461
+ export function wireClaudeListing(p, wanted = {}, recorded = {}) {
1462
+ // Parsed, so every number is the `JsonNumber` the renderers require (`jsonDumpsCompact` below).
1463
+ const want = parseJson(JSON.stringify(wanted));
1464
+ const prior = isDict(recorded) ? recorded : {};
1465
+ const loaded = readSettingsForMerge(p, 'Its skill-listing keys were not wired.');
1466
+ // A file that cannot be read changes nothing, so what this install owns stays on record.
1467
+ if (!loaded) return { ...prior };
1468
+ const [config, hadComments] = loaded;
1469
+ // `deepEquals`, never `===`: a parsed number is a `JsonNumber` wrapper (js/lib/json.mjs).
1470
+ const owned = (k) => has(prior, k) && has(config, k) && deepEquals(config[k], prior[k]);
1471
+ const next = { ...config };
1472
+ const record = {};
1473
+ for (const k of new Set([...Object.keys(prior), ...Object.keys(want)])) {
1474
+ if (has(want, k) && (!has(config, k) || owned(k))) {
1475
+ if (!has(config, k) || !deepEquals(config[k], want[k])) next[k] = want[k];
1476
+ record[k] = want[k];
1477
+ } else if (!has(want, k) && owned(k)) {
1478
+ delete next[k];
1479
+ }
1480
+ }
1481
+ const changed = Object.keys({ ...config, ...next })
1482
+ .some((k) => has(config, k) !== has(next, k) || !deepEquals(config[k], next[k]));
1483
+ if (!changed) return record;
1484
+ if (hadComments) {
1485
+ const add = Object.fromEntries(Object.entries(record).filter(([k, v]) => !deepEquals(config[k], v)));
1486
+ const drop = Object.keys(config).filter((k) => !has(next, k));
1487
+ process.stderr.write(`[geneseed] ${path.basename(p)} has comments — not rewriting it `
1488
+ + '(your edits are kept). Merge its skill-listing keys by hand: set '
1489
+ + `${jsonDumpsCompact(add)}${drop.length ? `, remove ${drop.join(', ')}` : ''}\n`);
1490
+ return Object.fromEntries(Object.keys(prior).filter(owned).map((k) => [k, config[k]]));
1491
+ }
1492
+ try {
1493
+ atomicWriteJson(p, next);
1494
+ } catch (e) {
1495
+ if (!isOsError(e)) throw e;
1496
+ process.stderr.write(`[geneseed] WARN: could not write ${p} (${e.message}) — its `
1497
+ + `skill-listing keys were not wired. Set them by hand: ${jsonDumpsCompact(want)}\n`);
1498
+ return Object.fromEntries(Object.keys(prior).filter(owned).map((k) => [k, config[k]]));
1499
+ }
1500
+ return record;
1501
+ }
1502
+
1503
+ /** Remove each recorded skill-listing key while it still holds the recorded value. */
1504
+ export function unwireClaudeListing(p, recorded) {
1505
+ if (!isDict(recorded) || !Object.keys(recorded).length) return;
1506
+ const { state, data: loaded, hadComments } = loadJsonObject(p);
1507
+ if (state !== 'ok' || hadComments) return;
1508
+ const gone = Object.keys(recorded).filter((k) => has(loaded, k) && deepEquals(loaded[k], recorded[k]));
1509
+ if (!gone.length) return;
1510
+ for (const k of gone) delete loaded[k];
1511
+ try {
1512
+ atomicWriteJson(p, loaded);
1513
+ } catch (e) {
1514
+ if (!isOsError(e)) throw e;
1515
+ }
1516
+ }
1517
+
1446
1518
  /** `_build_settings._unwire_claude_excludes`. */
1447
1519
  export function unwireClaudeExcludes(p, excludes) {
1448
1520
  if (!excludes || !excludes.length) return;