geneseed 4.32.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/DESIGN.md +2 -2
- package/README.md +6 -5
- package/SHIPPED.md +4 -3
- package/adapters/bob/README.md +6 -5
- package/adapters/claude-code/README.md +4 -3
- package/adapters/claude-code/skills/geneseed/SKILL.md +1 -1
- package/adapters/openclaude/README.md +4 -3
- package/adapters/opencode/GLOBAL-HARNESS-SPEC.md +3 -1
- package/adapters/opencode/HOW-OPENCODE-LOADS.md +2 -1
- package/adapters/opencode/README.md +18 -18
- package/adapters/opencode/plugins/geneseed-activity.js +57 -1
- package/adapters/opencode/plugins/geneseed-context.js +85 -18
- package/adapters/opencode/plugins/geneseed-guard.js +437 -76
- package/adapters/opencode/plugins/geneseed-learn.js +97 -23
- package/bin/geneseed-cli.mjs +17 -25
- package/bin/geneseed-hook.mjs +23 -8
- package/docs/DESIGN.md +175 -0
- package/docs/PRD.md +111 -0
- package/docs/README.md +3 -2
- package/docs/architecture.md +145 -0
- package/docs/concepts/agents.md +1 -1
- package/docs/concepts/collaboration.md +1 -1
- package/docs/concepts/enforcement-table.md +1 -1
- package/docs/concepts/exclusions.md +5 -5
- package/docs/concepts/footprint.md +1 -1
- package/docs/concepts/foreman-mode.md +2 -2
- package/docs/concepts/hooks.md +22 -8
- package/docs/concepts/host-matrix.md +2 -2
- package/docs/concepts/hosts.md +1 -1
- package/docs/concepts/kits.md +3 -1
- package/docs/concepts/ownership.md +1 -1
- package/docs/concepts/rules.md +15 -2
- package/docs/concepts/shared-tier.md +73 -0
- package/docs/concepts/skills.md +2 -2
- package/docs/concepts/themes.md +1 -1
- package/docs/extending.md +13 -12
- package/docs/guides/install-claude-code.md +1 -1
- package/docs/guides/install-opencode.md +1 -1
- package/docs/guides/migrate.md +4 -2
- package/docs/guides/project-context.md +2 -2
- package/docs/guides/setup-footprint.md +1 -1
- package/docs/guides/uninstall.md +2 -1
- package/docs/guides/upgrade-to-5.md +116 -0
- package/docs/guides/upgrade.md +21 -9
- package/docs/guides/wiki.md +3 -3
- package/docs/reference/env-context.md +5 -3
- package/docs/reference/environment.md +1 -1
- package/docs/reference/glossary.md +2 -0
- package/docs/reference/opencode-plugins.md +3 -3
- package/docs/reference/plugin-activity.md +1 -1
- package/docs/reference/plugin-context.md +1 -0
- package/docs/reference/plugin-guard.md +14 -6
- package/docs/reference/plugin-learn.md +13 -6
- package/docs/reference/troubleshoot-hooks.md +3 -3
- package/docs/reference/troubleshoot-update.md +14 -0
- package/docs/token-footprint.md +4 -3
- package/docs/understand/a-day.md +2 -2
- package/docs/understand/design-choices-install.md +2 -1
- package/docs/understand/enforced-vs-asked.md +1 -1
- package/docs/understand/machine-bob.md +2 -0
- package/docs/understand/machine-claude.md +7 -5
- package/docs/understand/machine-opencode.md +7 -5
- package/docs/understand/on-your-machine.md +4 -0
- package/docs/understand/take-it-out.md +1 -1
- package/docs/web-ui.md +126 -68
- package/harness.config.json +1 -1
- package/js/README.md +10 -6
- package/js/build/args.mjs +10 -8
- package/js/build/bundle.mjs +11 -13
- package/js/build/driver.mjs +66 -65
- package/js/build/emit-claude.mjs +22 -16
- package/js/build/emit-common.mjs +4 -5
- package/js/build/emit-opencode.mjs +22 -22
- package/js/build/fold.mjs +515 -0
- package/js/build/generate.mjs +41 -52
- package/js/build/render.mjs +115 -29
- package/js/build/source.mjs +4 -1
- package/js/build/stubs.mjs +70 -9
- package/js/build/version.mjs +10 -10
- package/js/cli-table.json +23 -83
- package/js/hosts/activity.mjs +2 -2
- package/js/hosts/geneseed-dir.mjs +1 -1
- package/js/hosts/hooks-context.mjs +389 -99
- package/js/hosts/hooks-learn.mjs +38 -7
- package/js/hosts/hooks-prims.mjs +4 -2
- package/js/hosts/hooks.mjs +114 -39
- package/js/hosts/hosts.mjs +150 -51
- package/js/hosts/installs.mjs +55 -167
- package/js/hosts/link.mjs +3 -5
- package/js/hosts/mcp.mjs +1 -1
- package/js/hosts/memory-files.mjs +219 -17
- package/js/hosts/ownership-gate.mjs +1 -1
- package/js/hosts/settings.mjs +18 -13
- package/js/hosts/shim.mjs +4 -33
- package/js/hosts/store-watch.mjs +189 -0
- package/js/inspect/checks-authoring.mjs +3 -3
- package/js/inspect/checks-build.mjs +45 -18
- package/js/inspect/checks-counts.mjs +4 -4
- package/js/inspect/checks-repo.mjs +13 -14
- package/js/inspect/cost.mjs +24 -2
- package/js/inspect/diff.mjs +123 -123
- package/js/inspect/doctor.mjs +22 -27
- package/js/inspect/excludes.mjs +181 -62
- package/js/inspect/inventory.mjs +22 -27
- package/js/inspect/registry.mjs +106 -30
- package/js/inspect/scan.mjs +5 -5
- package/js/inspect/status.mjs +141 -119
- package/js/inspect/validate.mjs +22 -24
- package/js/lib/fs.mjs +47 -50
- package/js/lib/json.mjs +10 -17
- package/js/lib/machine-dir.mjs +73 -0
- package/js/lib/paths.mjs +22 -33
- package/js/lib/proc.mjs +1 -1
- package/js/lib/prompt.mjs +19 -27
- package/js/lib/text.mjs +8 -12
- package/js/lib/udiff.mjs +11 -15
- package/js/loop/catalog.mjs +2 -3
- package/js/maintain/memory.mjs +17 -17
- package/js/maintain/migrate.mjs +79 -89
- package/js/maintain/setup.mjs +43 -32
- package/js/maintain/uninstall.mjs +43 -61
- package/js/maintain/update.mjs +200 -93
- package/js/ui/anim.mjs +21 -35
- package/js/ui/cli.mjs +36 -58
- package/js/ui/menu.mjs +22 -45
- package/js/ui/tui.mjs +27 -67
- package/js/web/actions.mjs +34 -34
- package/js/web/api.mjs +130 -74
- package/js/web/catalog.mjs +175 -46
- package/js/web/docs.mjs +33 -12
- package/js/web/doctor-worker.mjs +14 -0
- package/js/web/handler.mjs +14 -5
- package/js/web/routes.mjs +17 -19
- package/js/web/state.mjs +78 -19
- package/js/web/update-check.mjs +25 -10
- package/js/web/user-files.mjs +50 -105
- package/package.json +7 -4
- package/registry.json +48 -55
- package/src/AGENT.md.tmpl +13 -14
- package/src/agents/_self-improvement.md +1 -1
- package/src/agents/_template.md +1 -1
- package/src/agents/advocate.md +1 -1
- package/src/agents/architect.md +1 -1
- package/src/agents/developer.md +1 -1
- package/src/agents/devops-engineer.md +1 -1
- package/src/agents/docker-expert.md +1 -1
- package/src/agents/docs.md +1 -1
- package/src/agents/empiricist.md +1 -1
- package/src/agents/explorer.md +1 -1
- package/src/agents/framer.md +1 -1
- package/src/agents/historian.md +1 -1
- package/src/agents/kubernetes-specialist.md +1 -1
- package/src/agents/memory-curator.md +2 -2
- package/src/agents/operator.md +1 -1
- package/src/agents/performance.md +1 -1
- package/src/agents/pragmatist.md +1 -1
- package/src/agents/react-engineer.md +1 -1
- package/src/agents/react-reviewer.md +1 -1
- package/src/agents/researcher.md +1 -1
- package/src/agents/reviewer.md +1 -1
- package/src/agents/security.md +1 -1
- package/src/agents/skeptic.md +1 -1
- package/src/agents/spring-boot-engineer.md +1 -1
- package/src/agents/spring-reviewer.md +1 -1
- package/src/agents/spring-security.md +1 -1
- package/src/agents/steward.md +1 -1
- package/src/agents/tester.md +1 -1
- package/src/agents/user-advocate.md +1 -1
- package/src/agents/visionary.md +1 -1
- package/src/memory/README.md +1 -1
- package/src/skills/_self-improvement.md +2 -2
- package/src/skills/daydream/SKILL.md +2 -2
- package/src/skills/daydream/instructions.md +1 -1
- package/src/skills/geneseed.md +1 -1
- package/src/skills/learn-mode.md +1 -2
- package/src/skills/profile.md +2 -2
- package/src/skills/rule/approve.md +69 -0
- package/src/skills/rule/consolidate.md +3 -3
- package/src/skills/rule.md +13 -5
- package/src/skills/skill-forge.md +1 -1
- package/src/skills/teach.md +29 -12
- package/src/skills/wiki.md +1 -1
- package/themes/_TEMPLATE.json +1 -2
- package/themes/biker.json +1 -2
- package/themes/commentator.json +1 -2
- package/themes/cyberpunk.json +1 -2
- package/themes/gamer.json +1 -2
- package/themes/imperial.json +1 -2
- package/themes/joker.json +1 -2
- package/themes/marvin.json +1 -2
- package/themes/mean.json +1 -2
- package/themes/military.json +1 -2
- package/themes/neutral.json +1 -2
- package/themes/pirate.json +1 -2
- package/themes/sports.json +1 -2
- package/themes/verstappen.json +1 -2
- package/themes/wizard.json +1 -2
- package/web/dist/assets/Activity-D8G4eClY.js +1 -0
- package/web/dist/assets/ActivityDetail-BtOBYk3M.js +1 -0
- package/web/dist/assets/AgentGlyph-k6o3gCM1.js +1 -0
- package/web/dist/assets/Bonsai-B_y20b3i.js +1 -0
- package/web/dist/assets/{CopyButton-C5Li6awl.js → CopyButton-CHQte7Ap.js} +1 -1
- package/web/dist/assets/Dashboard-B8uXeJZ_.js +2 -0
- package/web/dist/assets/Docs-Dgv_MWfT.js +5 -0
- package/web/dist/assets/GreenhouseView-CSzTMSl_.js +1 -0
- package/web/dist/assets/Installs-BDk9lqBI.js +3 -0
- package/web/dist/assets/JournalView-CvRk1-m5.js +1 -0
- package/web/dist/assets/Kits-CoITzxWM.js +1 -0
- package/web/dist/assets/Laws-Ctf5r9rE.js +3 -0
- package/web/dist/assets/Library-DNwHYVXt.js +3 -0
- package/web/dist/assets/{Loops-CzitjxGV.js → Loops-S85PMQ8m.js} +2 -2
- package/web/dist/assets/{Markdown-C4S4tTA7.js → Markdown-0ORz7tAc.js} +21 -21
- package/web/dist/assets/OperatorHudView-DuGz_sTk.js +1 -0
- package/web/dist/assets/Personal-afJNwvRS.js +2 -0
- package/web/dist/assets/{RailCats-D5weYPCS.js → RailCats-AW92uhsX.js} +1 -1
- package/web/dist/assets/Settings-CGDFz-6j.js +1 -0
- package/web/dist/assets/Tabs-1qLrnqmn.js +1 -0
- package/web/dist/assets/api-C46vAuqp.js +1 -0
- package/web/dist/assets/controls-D4wmg_pl.js +1 -0
- package/web/dist/assets/index-COTd4TRZ.js +3 -0
- package/web/dist/assets/index-CtorA7uK.css +1 -0
- package/web/dist/assets/motion-RlUl1osO.js +1 -0
- package/web/dist/assets/{sections-ChwaobfW.js → sections-CtFz7HFH.js} +1 -1
- package/web/dist/index.html +5 -5
- package/src/skills/quiz.md +0 -44
- package/web/dist/assets/Activity-Bjy64wHC.js +0 -1
- package/web/dist/assets/ActivityDetail-B0AaipP8.js +0 -1
- package/web/dist/assets/Bonsai-CJniRqaH.js +0 -1
- package/web/dist/assets/Dashboard-B-6DTmae.js +0 -2
- package/web/dist/assets/Docs-LRc30XL9.js +0 -5
- package/web/dist/assets/GreenhouseView-CcoYlaWo.js +0 -1
- package/web/dist/assets/Installs-dp1epTcE.js +0 -3
- package/web/dist/assets/JournalView-nFP4poCf.js +0 -1
- package/web/dist/assets/KitApply-DwyZUj57.js +0 -1
- package/web/dist/assets/Kits-C0IEdZXe.js +0 -1
- package/web/dist/assets/Laws-CkykmQWu.js +0 -3
- package/web/dist/assets/Library-Guh9HBZU.js +0 -2
- package/web/dist/assets/OperatorHudView-DLGNulIY.js +0 -1
- package/web/dist/assets/Personal-BMtberL8.js +0 -2
- package/web/dist/assets/Tabs-uYJqfuQt.js +0 -1
- package/web/dist/assets/api-BxjLd7Qd.js +0 -1
- package/web/dist/assets/index-DA7BiaE5.js +0 -3
- package/web/dist/assets/index-dbbDGFDq.css +0 -1
- package/web/dist/assets/motion-Bccx3zE8.js +0 -1
package/js/build/generate.mjs
CHANGED
|
@@ -6,16 +6,14 @@
|
|
|
6
6
|
* they are the last one that can be measured by a closure walk alone — `cmd_build`'s body is
|
|
7
7
|
* three lines because the work is a `subprocess`, and a name walk cannot see through one.
|
|
8
8
|
*
|
|
9
|
-
* WHY `build` IMPORTS THE DRIVER RATHER THAN SPAWNING IT.
|
|
10
|
-
*
|
|
11
|
-
* Reproducing that shape here would mean spawning `node bin/build-driver.mjs`, and
|
|
9
|
+
* WHY `build` IMPORTS THE DRIVER RATHER THAN SPAWNING IT. Spawning would be
|
|
10
|
+
* a passthrough to a second process, and would mean spawning `node bin/build-driver.mjs`, and
|
|
12
11
|
* `tests/unit/hook_cli.test.mjs`'s 'the CLI entry reaches child_process only where it is
|
|
13
12
|
* declared' forbids it: the check is transitive over this entry's imports and allow-lists only
|
|
14
13
|
* the modules that genuinely start processes — `web`, `upgrade`, `setup` — and P5c's argument
|
|
15
14
|
* for it is that the ban should outlive them rather than be dismantled by a verb that does not.
|
|
16
|
-
* It is also the wrong shape on its own terms.
|
|
17
|
-
* process
|
|
18
|
-
* one, and a Node CLI spawning a Node driver to do work it could do in-process is exactly
|
|
15
|
+
* It is also the wrong shape on its own terms. `bin/build-driver.mjs` is a module in this
|
|
16
|
+
* process, and a Node CLI spawning a Node driver to do work it could do in-process is exactly
|
|
19
17
|
* the passthrough the whole port has been removing. So the driver's `main` is exported and
|
|
20
18
|
* called directly, and the observable contract — the tree, the streams, the exit code — is
|
|
21
19
|
* what the `build/*` cells of `tests/golden.mjs --cli` assert.
|
|
@@ -40,11 +38,13 @@ import { DEFAULT_PRESET } from '../loop/score.mjs';
|
|
|
40
38
|
import { opencodeConfigDir, resolvePath } from '../hosts/hosts.mjs';
|
|
41
39
|
import {
|
|
42
40
|
EMIT_HOST_SCOPE, defaultMode, defaultPosture, defaultTheme, doctrinesForBuild,
|
|
43
|
-
excludedRulesOfDir, excludedSkillsOfDir, footprintOfDir, kitsOfDir, gatesOfDir, installState, installTargets,
|
|
44
|
-
|
|
41
|
+
excludedRulesOfDir, excludedSkillsOfDir, footprintOfDir, kitsOfDir, sharedTierOfDir, gatesOfDir, installState, installTargets,
|
|
42
|
+
modeOfDir, postureOfDir, readMaybe, themeOfDir, trustOfDir,
|
|
45
43
|
} from '../hosts/installs.mjs';
|
|
46
44
|
import { colorThemeFiles, colorThemeJson, PALETTE_ROLES } from '../hosts/opencode.mjs';
|
|
47
45
|
import { renderAll } from './render.mjs';
|
|
46
|
+
import { renamedFilesIn } from './stubs.mjs';
|
|
47
|
+
import { sharedPaths } from '../lib/machine-dir.mjs';
|
|
48
48
|
import { printOut, printErr, readText, writeText, isDir } from '../lib/fs.mjs';
|
|
49
49
|
import { jsonDumpsIndent, parseJson, formatRepr } from '../lib/json.mjs';
|
|
50
50
|
|
|
@@ -56,8 +56,8 @@ const HEX_RE = /^#[0-9a-fA-F]{6}$/;
|
|
|
56
56
|
*
|
|
57
57
|
* The convention `js/build/bundle.mjs`'s `assertSourceComplete` set and `bin/geneseed-cli.mjs`
|
|
58
58
|
* honours: write at the raise site, mark the throw as a DELIBERATE refusal with `exitCode`,
|
|
59
|
-
* and let anything unmarked keep its stack
|
|
60
|
-
*
|
|
59
|
+
* and let anything unmarked keep its stack, because dressing a crash as a one-liner
|
|
60
|
+
* would hide a bug.
|
|
61
61
|
*/
|
|
62
62
|
function sysExit(msg) {
|
|
63
63
|
// `printErr`, NOT a local newline translation. The first draft inlined the `\n` ->
|
|
@@ -76,8 +76,8 @@ function sysExit(msg) {
|
|
|
76
76
|
/**
|
|
77
77
|
* `_harness_build.cmd_build` — render `src/` into `./Harness`.
|
|
78
78
|
*
|
|
79
|
-
* `--out` defaults to the RELATIVE `"Harness"` in the generator and
|
|
80
|
-
*
|
|
79
|
+
* `--out` defaults to the RELATIVE `"Harness"` in the generator and no `cwd` is passed,
|
|
80
|
+
* so the bundle lands under the invocation's directory rather than the checkout's.
|
|
81
81
|
* Calling the driver in-process keeps that: `resolveOut` resolves against `process.cwd()`
|
|
82
82
|
* the same way. `build/the-bundle-follows-cwd-not-the-checkout` is the cell.
|
|
83
83
|
*
|
|
@@ -95,7 +95,7 @@ function sysExit(msg) {
|
|
|
95
95
|
const BUILD_FORWARD = [
|
|
96
96
|
['theme', '--theme'], ['emit', '--emit'], ['footprint', '--footprint'],
|
|
97
97
|
['posture', '--posture'], ['mode', '--mode'], ['trust', '--trust'], ['doctrines', '--doctrines'],
|
|
98
|
-
['excludeRules', '--exclude-rules'], ['excludeSkills', '--exclude-skills'], ['kits', '--kits'], ['out', '--out'], ['root', '--root'],
|
|
98
|
+
['excludeRules', '--exclude-rules'], ['excludeSkills', '--exclude-skills'], ['kits', '--kits'], ['sharedTier', '--shared-tier'], ['out', '--out'], ['root', '--root'],
|
|
99
99
|
['configDir', '--config-dir'],
|
|
100
100
|
];
|
|
101
101
|
|
|
@@ -115,7 +115,7 @@ export function cmdBuild(args) {
|
|
|
115
115
|
/**
|
|
116
116
|
* `_harness_setup._setup_build_args` — the generator argv for one selection. Pure.
|
|
117
117
|
*
|
|
118
|
-
* The elision rules are not symmetric
|
|
118
|
+
* The elision rules are not symmetric: `footprint` is ALWAYS passed,
|
|
119
119
|
* because omitting it when it matched the generator's default silently coupled the answer to
|
|
120
120
|
* whatever that default happened to be — the moment the default moved, picking the old one
|
|
121
121
|
* produced the new one. `posture`, `mode` and `trust` still elide at theirs, and none has moved.
|
|
@@ -141,7 +141,7 @@ export function cmdBuild(args) {
|
|
|
141
141
|
*/
|
|
142
142
|
export function setupBuildArgs(theme, emit, out = null, root = null, footprint = 'lean',
|
|
143
143
|
posture = 'peer', mode = 'direct', doctrines = null, allPacks = PACK_ORDER,
|
|
144
|
-
excludeRules = null, trust = DEFAULT_PRESET, excludeSkills = null, gates = {}, kits = null) {
|
|
144
|
+
excludeRules = null, trust = DEFAULT_PRESET, excludeSkills = null, gates = {}, kits = null, sharedTier = false) {
|
|
145
145
|
const argv = ['--theme', theme, '--emit', emit];
|
|
146
146
|
if (!emit.endsWith('-global')) {
|
|
147
147
|
if (out) argv.push('--out', out);
|
|
@@ -177,6 +177,8 @@ export function setupBuildArgs(theme, emit, out = null, root = null, footprint =
|
|
|
177
177
|
// Kits elide when none is on, as skills do: no config key feeds them, so absence and `none`
|
|
178
178
|
// are the same answer. Last, so an argv naming no kit is the bytes it always was.
|
|
179
179
|
if (kits?.length) argv.push('--kits', [...kits].sort().join(','));
|
|
180
|
+
// The shared tier elides when off, like the kits: the default is off, so only `on` speaks.
|
|
181
|
+
if (sharedTier) argv.push('--shared-tier', 'on');
|
|
180
182
|
return argv;
|
|
181
183
|
}
|
|
182
184
|
|
|
@@ -240,9 +242,11 @@ export function installProfile(host, scope, root, notify = null) {
|
|
|
240
242
|
const gates = gatesOfDir(root, host);
|
|
241
243
|
// Kits on stay on (spec A3); one this checkout no longer ships drops with a notice (R2).
|
|
242
244
|
const kits = kitsOfDir(root, host, notify);
|
|
245
|
+
// A project install's `Shared tier: on` stays on across a rebuild; a global install never has it.
|
|
246
|
+
const sharedTier = sharedTierOfDir(root, host);
|
|
243
247
|
const out = scope === 'global' ? null : root;
|
|
244
248
|
const argv = setupBuildArgs(theme, emit, out, out, footprint, posture, mode, doctrines,
|
|
245
|
-
PACK_ORDER, excludeRules, trust, excludeSkills, gates, kits);
|
|
249
|
+
PACK_ORDER, excludeRules, trust, excludeSkills, gates, kits, sharedTier);
|
|
246
250
|
// A GLOBAL ROW NAMES ITS OWN DIR. `root` came from the host's config-dir resolver, which
|
|
247
251
|
// honours env overrides (`OPENCODE_CONFIG_DIR`, `CLAUDE_CONFIG_DIR`…); without the flag the
|
|
248
252
|
// same argv run from a shell lacking that variable re-emits into the DEFAULT dir — a second
|
|
@@ -251,7 +255,7 @@ export function installProfile(host, scope, root, notify = null) {
|
|
|
251
255
|
return {
|
|
252
256
|
host, scope, root, state: installState(root, host, scope),
|
|
253
257
|
emit, theme, footprint, posture, mode, trust, doctrines, excludeRules, excludeSkills,
|
|
254
|
-
kits, ...gates, argv,
|
|
258
|
+
kits, sharedTier, ...gates, argv,
|
|
255
259
|
};
|
|
256
260
|
}
|
|
257
261
|
|
|
@@ -269,9 +273,8 @@ export function rebuildCommand(argv) {
|
|
|
269
273
|
/**
|
|
270
274
|
* `_harness_build.cmd_rebuild_all` — re-emit every ACTIVE install in place, best-effort.
|
|
271
275
|
*
|
|
272
|
-
* WHY THIS IS THE VERB THAT MADE THE DRIVER'S `die` A THROW.
|
|
273
|
-
*
|
|
274
|
-
* subprocess gives you for nothing. Calling `main` in-process — the route P5e established for
|
|
276
|
+
* WHY THIS IS THE VERB THAT MADE THE DRIVER'S `die` A THROW. A subprocess per install
|
|
277
|
+
* would hand back a return code, so "continue past a failure" would come for nothing. Calling `main` in-process — the route P5e established for
|
|
275
278
|
* `build`, and the only one the `child_process` ban leaves — makes a `process.exit` inside
|
|
276
279
|
* the generator's flag parser end the whole loop instead of one install. So `die` throws and
|
|
277
280
|
* `main` converts, and `rebuild-all/one-broken-install-does-not-stop-the-rest` is the cell
|
|
@@ -283,17 +286,14 @@ export function rebuildCommand(argv) {
|
|
|
283
286
|
* defaulted any of them would silently re-emit an install into something its owner did not
|
|
284
287
|
* choose — which is the same failure mode `_footprint_of_dir`'s WARN exists to prevent, at a
|
|
285
288
|
* larger scale.
|
|
286
|
-
*
|
|
287
|
-
* A LEGACY CARRIER IS SKIPPED, NEVER RE-EMITTED. `installProfile` (through `doctrinesOfDir`/
|
|
288
|
-
* `excludedRulesOfDir`) no longer migrates a pre-comms carrier — it reads it as written. Calling
|
|
289
|
-
* `driverMain` on that read-back would WRITE a fresh carrier missing `comms` and still naming
|
|
290
|
-
* `process 7`/`process 8` nowhere, which deletes the one signal (`legacyProcessCarrierOfDir`)
|
|
291
|
-
* that could ever have caught it again: a permanent, silent loss, and `upgrade` reaches this
|
|
292
|
-
* same loop by shelling into `rebuild-all` (`js/maintain/update.mjs`'s `rebuildInstalls`), so
|
|
293
|
-
* fixing it once here covers both verbs. Checked BEFORE `installProfile`, so no argv is even
|
|
294
|
-
* built for it.
|
|
295
289
|
*/
|
|
296
290
|
export async function cmdRebuildAll() {
|
|
291
|
+
// Lazy: `update.mjs` spawns git, and this module is on the static graph of the no-spawn CLI.
|
|
292
|
+
const refusal = (await import('../maintain/update.mjs')).gateRefusal();
|
|
293
|
+
if (refusal) {
|
|
294
|
+
printErr(`[rebuild-all] not started: ${refusal}\n`);
|
|
295
|
+
return 1;
|
|
296
|
+
}
|
|
297
297
|
const rc = rebuildAll();
|
|
298
298
|
// A console started before an upgrade keeps serving the old `index.html`; restart it — only
|
|
299
299
|
// when stale, see `bounceDaemonIfRunning`. Lazy: no other verb in this module needs js/web/.
|
|
@@ -311,16 +311,8 @@ export function rebuildAll() {
|
|
|
311
311
|
return 0;
|
|
312
312
|
}
|
|
313
313
|
const failures = [];
|
|
314
|
-
const skipped = [];
|
|
315
314
|
for (const [host, scope, root] of targets) {
|
|
316
315
|
const label = `${host}:${scope} (${root})`;
|
|
317
|
-
// Ask BEFORE `installProfile`: a legacy carrier must never reach `driverMain`, see above.
|
|
318
|
-
if (legacyProcessCarrierOfDir(root, host)) {
|
|
319
|
-
skipped.push(label);
|
|
320
|
-
printOut(`[rebuild-all] SKIPPED ${label}: pre-comms carrier (names 'process 8') — `
|
|
321
|
-
+ 'run `geneseed setup` for it.\n');
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
316
|
// The one replay that speaks when an excluded skill's name got older: status and the console
|
|
325
317
|
// read the same profile on every refresh and stay silent.
|
|
326
318
|
const p = installProfile(host, scope, root, (n) => printErr(`[rebuild-all] ${label}: ${n}\n`));
|
|
@@ -332,21 +324,19 @@ export function rebuildAll() {
|
|
|
332
324
|
printErr(`[rebuild-all] FAILED ${label} (exit ${rc})\n`);
|
|
333
325
|
}
|
|
334
326
|
}
|
|
327
|
+
// M3: an old-name wiki manifest that survived the rebuilds (a rename failed, or the file sits
|
|
328
|
+
// where no emit looks) is named once, here, whatever else the summary says.
|
|
329
|
+
const scanned = targets.map(([, , r]) => r);
|
|
330
|
+
try { scanned.push(sharedPaths().root); } catch { /* no home dir: no tier to scan */ }
|
|
331
|
+
for (const { file, now } of renamedFilesIn(scanned)) {
|
|
332
|
+
printOut(`[rebuild-all] WARN ${file} is still read under its old name; rename it to ${now}.\n`);
|
|
333
|
+
}
|
|
335
334
|
if (failures.length) {
|
|
336
335
|
printErr(`[rebuild-all] ${failures.length}/${targets.length} install(s) failed: `
|
|
337
336
|
+ `${failures.join(', ')}\n`);
|
|
338
337
|
return 1;
|
|
339
338
|
}
|
|
340
|
-
|
|
341
|
-
// Skipping is protective, not a failure — same convention as the install count itself
|
|
342
|
-
// already filtering to `active` targets without flagging the inactive ones. Exit 0 as long
|
|
343
|
-
// as nothing that WAS attempted failed; the per-install SKIPPED line above is the record.
|
|
344
|
-
if (skipped.length) {
|
|
345
|
-
printOut(`[rebuild-all] rebuilt ${rebuilt} install(s), skipped ${skipped.length}: `
|
|
346
|
-
+ `${skipped.join(', ')}.\n`);
|
|
347
|
-
} else {
|
|
348
|
-
printOut(`[rebuild-all] rebuilt ${rebuilt} install(s).\n`);
|
|
349
|
-
}
|
|
339
|
+
printOut(`[rebuild-all] rebuilt ${targets.length} install(s).\n`);
|
|
350
340
|
return 0;
|
|
351
341
|
}
|
|
352
342
|
|
|
@@ -362,7 +352,7 @@ export function rebuildAll() {
|
|
|
362
352
|
* would only cost a surrogate decode per astral character in a 400 KB document, and the
|
|
363
353
|
* count is identical either way.
|
|
364
354
|
*/
|
|
365
|
-
|
|
355
|
+
function fenceFor(text) {
|
|
366
356
|
let longest = 0;
|
|
367
357
|
let run = 0;
|
|
368
358
|
for (let i = 0; i < text.length; i += 1) {
|
|
@@ -409,8 +399,7 @@ export function buildPrompt(cfg, themeName) {
|
|
|
409
399
|
/**
|
|
410
400
|
* `_harness_build.cmd_prompt`.
|
|
411
401
|
*
|
|
412
|
-
* Both output paths translate newlines
|
|
413
|
-
* `sys.stdout.write` and `Path.write_text`, and BOTH are `newline=None` translators on
|
|
402
|
+
* Both output paths translate newlines, as text-mode writes do on
|
|
414
403
|
* Windows. At ~10,000 newlines in a 400 KB document that is the largest byte difference this
|
|
415
404
|
* port could ship, and `harness_golden` can only see half of it — the FILE half is compared
|
|
416
405
|
* directly, the stdout half is folded by `subprocess`'s universal-newline decode, which is
|
|
@@ -419,7 +408,7 @@ export function buildPrompt(cfg, themeName) {
|
|
|
419
408
|
* platform's'.
|
|
420
409
|
*/
|
|
421
410
|
export function cmdPrompt(args) {
|
|
422
|
-
//
|
|
411
|
+
// A literal 'neutral', NOT the config's theme, so this
|
|
423
412
|
// deliberately does not go through `configDefaults()`.
|
|
424
413
|
const themeName = args.theme || 'neutral';
|
|
425
414
|
const text = buildPrompt(makeCfg(), themeName);
|
|
@@ -509,7 +498,7 @@ function loadUserPalette(args, cfg) {
|
|
|
509
498
|
* `_harness_build.cmd_theme` — a user colour theme in both flavours, into the live dir.
|
|
510
499
|
*
|
|
511
500
|
* The palette is validated BEFORE the destination is resolved and before `mkdir`, so a
|
|
512
|
-
* refusal leaves no directory behind
|
|
501
|
+
* refusal leaves no directory behind.
|
|
513
502
|
*
|
|
514
503
|
* **THAT ORDER IS NOT OBSERVABLE, and the first draft of this comment claimed it was.**
|
|
515
504
|
* Swapping the two halves so a refusal creates the directory first is GREEN across all 166
|
package/js/build/render.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The generator's render core, in Node — the first half of the port.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The pure text pipeline: load a
|
|
5
5
|
* theme, lay the fixed neutral STRUCTURE over it, inline INCLUDE directives, resolve
|
|
6
6
|
* AGENT.md's CATALOG blocks, substitute {{TOKENS}}, and hand back every source file with
|
|
7
7
|
* its themed output path. It writes nothing and reads nothing but `src/` and `themes/`.
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* THIS module is only RENDER
|
|
15
15
|
* because it is the only stage whose output is a pure function of the source tree.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* BYTE IDENTITY IS THE CONTRACT, NOT THE INTENT. The output must stay byte-identical for
|
|
18
|
+
* the same inputs, so
|
|
19
19
|
* what holds the line is `tests/golden.mjs --against`, replaying recorded emit cells;
|
|
20
20
|
* drives both over every theme x footprint x posture x mode and byte-compares the
|
|
21
|
-
* written trees. Where Python and JS
|
|
21
|
+
* written trees. Where the earlier Python semantics and JS differ silently — path sort order,
|
|
22
22
|
* `.suffix`, `splitlines`, universal newlines — the difference is spelled out at the
|
|
23
23
|
* call site rather than left to the reader.
|
|
24
24
|
*
|
|
@@ -30,13 +30,14 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { readdirSync, statSync, existsSync } from 'node:fs';
|
|
32
32
|
import path from 'node:path';
|
|
33
|
-
import { readText } from '../lib/fs.mjs';
|
|
33
|
+
import { isDir, readText } from '../lib/fs.mjs';
|
|
34
34
|
import { parseJson } from '../lib/json.mjs';
|
|
35
35
|
import { normcase, comparePaths } from '../lib/paths.mjs';
|
|
36
36
|
// `js/build/source.mjs` imports nothing but node builtins, so this direction cannot cycle.
|
|
37
37
|
import {
|
|
38
38
|
CREDIT_RE, GATE_SWITCHES, PACK_ORDER, kitMembers, loadKits, readPackText, resolveCredits, resolveRuleIds, ruleCanon, upstreamOf,
|
|
39
39
|
} from './source.mjs';
|
|
40
|
+
import { SHARED_TIER_LINE } from '../hosts/hosts.mjs';
|
|
40
41
|
import { VENDORED_SKILL_DIRS } from '../hosts/native.mjs';
|
|
41
42
|
import { DEFAULT_PRESET } from '../loop/score.mjs';
|
|
42
43
|
|
|
@@ -57,6 +58,31 @@ export const STRUCTURE = {
|
|
|
57
58
|
ONT_OWNERSHIP: 'Ownership', ONT_CONDUCT: 'Conduct',
|
|
58
59
|
};
|
|
59
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Where a fact, rule, profile or note LIVES, as prose names it (C10). `DIR_MEMORY` cannot say
|
|
63
|
+
* so: it also names the output dir and takes `prefixedAgentText`'s prefix. On a global emit these
|
|
64
|
+
* are absolute under `sharedRoot`, which no prefix may touch. Otherwise each follows the `DIR_*`
|
|
65
|
+
* token it replaced, prefix included, so a project emit keeps its bytes: `prefixedAgentText`
|
|
66
|
+
* calls this again after prefixing. `LINK_MEMORY` drops the link on a global emit, because an
|
|
67
|
+
* absolute target is what `linkProblems` refuses as non-hermetic. `WIKI_TIER` is the hop a Rite
|
|
68
|
+
* takes past the host's wiki file, which the fold re-seeds to an empty list: nothing off a tier.
|
|
69
|
+
*/
|
|
70
|
+
export function pathTokens(theme, sharedRoot = null) {
|
|
71
|
+
const memory = theme.DIR_MEMORY ?? 'memory';
|
|
72
|
+
const at = sharedRoot ? `${sharedRoot}/` : theme.AT_HARNESS ?? '';
|
|
73
|
+
return {
|
|
74
|
+
PATH_MEMORY: sharedRoot ? `${at}memory` : memory,
|
|
75
|
+
PATH_NOTES: sharedRoot ? `${at}notes` : theme.DIR_NOTEBOOK ?? 'notebook',
|
|
76
|
+
PATH_RULES: `${at}user-rules.md`,
|
|
77
|
+
PATH_PROFILE: `${at}PROFILE.md`,
|
|
78
|
+
PATH_WIKI: `${at}geneseed-wiki.jsonc`,
|
|
79
|
+
WIKI_TIER: sharedRoot ? `, then, when that one declares no wiki, the shared \`${at}geneseed-wiki.jsonc\`` : '',
|
|
80
|
+
LINK_MEMORY: sharedRoot ? `\`${at}memory/\`` : `[\`${memory}/\`](${memory}/)`,
|
|
81
|
+
PROFILE_LOCATION: sharedRoot ? `\`${at}PROFILE.md\``
|
|
82
|
+
: '`PROFILE.md` beside the deployed AGENT.md',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
60
86
|
/**
|
|
61
87
|
* Source top-level dirs whose OUTPUT name is themed. Mirrors `SRC_DIR_TOKENS`.
|
|
62
88
|
* Exported because `js/build/bundle.mjs`'s `build` resolves the same tokens to decide which
|
|
@@ -96,7 +122,7 @@ export const LEAN_BLOCK_RE =
|
|
|
96
122
|
/[ \t]*<!-- LEAN:begin -->\n(?<full>[\s\S]*?)[ \t]*<!-- LEAN:else -->\n(?<lean>[\s\S]*?)[ \t]*<!-- LEAN:end -->\n/g;
|
|
97
123
|
|
|
98
124
|
/**
|
|
99
|
-
* `PurePath.suffix
|
|
125
|
+
* A file suffix, `PurePath.suffix` style. Not `path.extname`: it is '' for a name whose only dot is
|
|
100
126
|
* leading (`.gitignore`) or trailing (`foo.`), where `extname` returns '' and '.'
|
|
101
127
|
* respectively. Neither spelling is in TEXT_SUFFIXES, so the divergence is invisible
|
|
102
128
|
* today — which is exactly why it is written out rather than relied upon.
|
|
@@ -120,7 +146,7 @@ function sortedSourceFiles(src) {
|
|
|
120
146
|
return out.sort(comparePaths); // `sorted()` — case-folded on Windows only
|
|
121
147
|
}
|
|
122
148
|
|
|
123
|
-
/**
|
|
149
|
+
/** Load a theme. Throws a marked refusal, which the driver turns into an exit code. */
|
|
124
150
|
export function loadTheme(cfg, name) {
|
|
125
151
|
const p = path.join(cfg.themes, `${name}.json`);
|
|
126
152
|
if (!existsSync(p)) {
|
|
@@ -135,12 +161,12 @@ export function loadTheme(cfg, name) {
|
|
|
135
161
|
// is the refusal, on every path. It is also reachable from `geneseed status`, which takes
|
|
136
162
|
// its theme from a `.geneseed-theme`
|
|
137
163
|
// marker — an unvalidated file in a user's install. A bare `throw` there printed a Node
|
|
138
|
-
// stack trace where
|
|
164
|
+
// stack trace where one line was wanted, and the acceptance matrix is what said so.
|
|
139
165
|
process.stderr.write(`[geneseed] unknown theme '${name}'. available: ${available}\n`);
|
|
140
166
|
throw Object.assign(new Error(`unknown theme '${name}'`), { exitCode: 1 });
|
|
141
167
|
}
|
|
142
168
|
// parseJson, not JSON.parse: one rule for every JSON the generator reads, so a numeric
|
|
143
|
-
// theme value keeps the int/float distinction
|
|
169
|
+
// theme value keeps the int/float distinction that `str()` and `repr()` render
|
|
144
170
|
// differently. No shipped theme has one today; `_theme_json`'s ACCENT and the
|
|
145
171
|
// AGENT_COLORS validation warning are both one authoring typo away from needing it.
|
|
146
172
|
return parseJson(readText(p));
|
|
@@ -151,8 +177,8 @@ export function substitute(text, theme) {
|
|
|
151
177
|
return text.replace(TOKEN_RE, (whole, key) => {
|
|
152
178
|
if (!Object.hasOwn(theme, key)) return whole; // visible for debugging
|
|
153
179
|
const v = theme[key];
|
|
154
|
-
//
|
|
155
|
-
// `
|
|
180
|
+
// A token renders as `String(theme[key])`, which is only well-defined for strings —
|
|
181
|
+
// `String(true)` and `String({...})` are not what a Python-minded author expects. Every one of
|
|
156
182
|
// the 148 tokens the source tree actually uses resolves to a string today
|
|
157
183
|
// (AGENT_COLORS is a dict but is never a token), so a non-string here means the
|
|
158
184
|
// source or a theme grew a case nobody has decided the semantics for. Fail loudly
|
|
@@ -254,7 +280,7 @@ function resolveLean(text, footprint) {
|
|
|
254
280
|
* `re.split(r"(?m)^(?=### )", text)`.
|
|
255
281
|
*
|
|
256
282
|
* Hand-rolled rather than `String.split` with a lookahead: splitting on a zero-width
|
|
257
|
-
* match is a corner both engines implement, and the leading ''
|
|
283
|
+
* match is a corner both engines implement, and the leading '' produced when the
|
|
258
284
|
* text starts with a heading is load-bearing (it becomes `blocks[0]`, the preamble).
|
|
259
285
|
*/
|
|
260
286
|
export function splitAtLawHeadings(text) {
|
|
@@ -281,18 +307,63 @@ export function lawsPointer(theme, lawsPrefix = '') {
|
|
|
281
307
|
}
|
|
282
308
|
|
|
283
309
|
/**
|
|
284
|
-
* SOURCE
|
|
285
|
-
* self-improvement footer is included by ~50 specs — and `doctor --all` repeats
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
310
|
+
* WHAT THE SOURCE TREE YIELDS, SHARED UNTIL IT CHANGES. One emit renders the same partials over
|
|
311
|
+
* and over — the self-improvement footer is included by ~50 specs — and `doctor --all` repeats
|
|
312
|
+
* that across 84 emits, each with its own `makeCfg()`, so a cache per `cfg` object still read,
|
|
313
|
+
* stripped and resolved everything 84 times. A cache per process is no answer either: the web
|
|
314
|
+
* daemon renders in-process for days, and each request must see today's source.
|
|
315
|
+
*
|
|
316
|
+
* So a generation lives as long as the tree's stamp. The stamp covers the WHOLE tree, never the
|
|
317
|
+
* one file being read, because a resolved text depends on other files: rename a law and every
|
|
318
|
+
* file citing it renders differently with its own mtime untouched. Paths are in it, so an added
|
|
319
|
+
* or deleted file moves it, and so is `cfg.root`, which `sourceFingerprint` hashes against.
|
|
320
|
+
*
|
|
321
|
+
* Stamped once per `cfg`: the source cannot change under one operation, and a stat walk is what
|
|
322
|
+
* each operation now pays instead of the reads. The stamp is taken BEFORE anything is read, so
|
|
323
|
+
* an edit landing mid-operation costs a repeat read next time, never an old text kept.
|
|
324
|
+
*
|
|
325
|
+
* A tree written in the last `SETTLE_MS` is never shared, the way git distrusts a racy index
|
|
326
|
+
* entry: a second edit of the same size inside one timestamp tick would leave the stamp as it was,
|
|
327
|
+
* and a tick is 2 s on FAT. A shared stamp is therefore always older than any later edit's.
|
|
289
328
|
*/
|
|
290
|
-
const
|
|
329
|
+
const SETTLE_MS = 3_000;
|
|
330
|
+
const GENERATIONS = new Map(); // cfg.src -> the latest generation: one per tree, never a history
|
|
331
|
+
const GENERATION_OF = new WeakMap();
|
|
332
|
+
export function sourceGeneration(cfg) {
|
|
333
|
+
let generation = GENERATION_OF.get(cfg);
|
|
334
|
+
if (generation) return generation;
|
|
335
|
+
const { stamp, newest } = sourceStamp(cfg);
|
|
336
|
+
generation = GENERATIONS.get(cfg.src);
|
|
337
|
+
if (generation?.stamp !== stamp) {
|
|
338
|
+
generation = { stamp, texts: new Map() };
|
|
339
|
+
if (Date.now() - newest > SETTLE_MS) GENERATIONS.set(cfg.src, generation);
|
|
340
|
+
}
|
|
341
|
+
GENERATION_OF.set(cfg, generation);
|
|
342
|
+
return generation;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function sourceStamp(cfg) {
|
|
346
|
+
const lines = [cfg.root];
|
|
347
|
+
let newest = 0;
|
|
348
|
+
for (const root of [cfg.src, cfg.themes, cfg.pluginSrc, cfg.workflowSrc]) {
|
|
349
|
+
if (!isDir(root)) continue;
|
|
350
|
+
for (const p of sortedSourceFiles(root)) {
|
|
351
|
+
// A file deleted since the walk listed it is simply not in the tree any more.
|
|
352
|
+
const st = statSync(p, { throwIfNoEntry: false });
|
|
353
|
+
if (!st) continue;
|
|
354
|
+
const { size, mtimeMs, ctimeMs } = st;
|
|
355
|
+
newest = Math.max(newest, mtimeMs);
|
|
356
|
+
lines.push(`${p}\0${size}\0${mtimeMs}\0${ctimeMs}`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return { stamp: lines.join('\n'), newest };
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** Only files under `cfg.src` — the one tree nothing in a render writes to. */
|
|
291
363
|
function readSource(cfg, p) {
|
|
292
364
|
const src = cfg && cfg.src ? normcase(path.resolve(cfg.src)) + path.sep : null;
|
|
293
365
|
if (!src || !normcase(p).startsWith(src)) return readText(p);
|
|
294
|
-
|
|
295
|
-
if (!seen) SRC_TEXT.set(cfg, (seen = new Map()));
|
|
366
|
+
const seen = sourceGeneration(cfg).texts;
|
|
296
367
|
let text = seen.get(p);
|
|
297
368
|
// Rule ids and credits resolve here, once per file, so every stage after sees the addressed form.
|
|
298
369
|
if (text === undefined) seen.set(p, (text = resolveCredits(resolveRuleIds(readText(p), cfg.src), cfg.src)));
|
|
@@ -457,14 +528,27 @@ function doctrinesBody(cfg, theme, active, footprint, lawsPrefix) {
|
|
|
457
528
|
* `_build_render.effective_theme`.
|
|
458
529
|
*
|
|
459
530
|
* `cfg.structure` overrides the constant below when the driver supplies one, and it
|
|
460
|
-
* always does. STRUCTURE is a module-level
|
|
531
|
+
* always does. STRUCTURE is a module-level constant that tests once MUTATED to
|
|
461
532
|
* simulate a themed DIR_* rename (`SrcDirRenameOrphanTests`); in-process that reaches
|
|
462
533
|
* every reader because the splice shares one dict object, and across a process boundary
|
|
463
534
|
* it reaches nothing at all unless it travels. The constant stays as the default for the
|
|
464
535
|
* parity harnesses, which drive this module directly.
|
|
465
536
|
*/
|
|
466
|
-
export function effectiveTheme(cfg, themeName, {
|
|
537
|
+
export function effectiveTheme(cfg, themeName, {
|
|
538
|
+
footprint = 'full', lawsPrefix = '', sharedRoot = null,
|
|
539
|
+
} = {}) {
|
|
467
540
|
const theme = { ...loadTheme(cfg, themeName), ...(cfg.structure ?? STRUCTURE) };
|
|
541
|
+
Object.assign(theme, pathTokens(theme, sharedRoot));
|
|
542
|
+
// Empty without a tier, so a project emit and a default build stay byte-identical (the
|
|
543
|
+
// `EXCLUDED_SKILLS_LINE` contract). Each rides the end of a template line, so its value carries
|
|
544
|
+
// the blank line. C1 lives in this text: the readers only concatenate, shared first.
|
|
545
|
+
theme.RULE_LAYERS_LINE = sharedRoot ? '\n\n`user-rules.md` has layers: the shared file above, '
|
|
546
|
+
+ `this host's file, then a project's. Where they disagree the later layer wins, so project `
|
|
547
|
+
+ `over host over shared, and all three stay under the ${theme.LAWS}.` : '';
|
|
548
|
+
theme.SHARED_STORE_NOTE = sharedRoot ? `\n\n> **On this install the store is shared.** New facts `
|
|
549
|
+
+ `go to \`${sharedRoot}/memory/\`, which every host on this machine reads. This directory `
|
|
550
|
+
+ 'holds this convention, and any fact\n> that landed here waits for the next emit to move it.'
|
|
551
|
+
: '';
|
|
468
552
|
theme.POSTURE_BODY = registerBody(cfg, theme, 'postures', cfg.posture ?? 'peer', 'peer');
|
|
469
553
|
theme.MODE_BODY = registerBody(cfg, theme, 'modes', cfg.mode ?? 'direct', 'direct');
|
|
470
554
|
// The loop skill's default trust preset (`--trust`), raw for `--preset` and capitalised for
|
|
@@ -504,6 +588,9 @@ export function effectiveTheme(cfg, themeName, { footprint = 'full', lawsPrefix
|
|
|
504
588
|
const kits = activeKits(cfg);
|
|
505
589
|
theme.KITS_LINE = kits.length ? `\nActive kits: ${kits.map(([k]) => k).join(', ')}\n` : '';
|
|
506
590
|
theme.KITS_BODY = kitsBody(cfg, theme, lawsPrefix);
|
|
591
|
+
// The shared-tier marker, under the same contract (`sharedTierOfDir` reads it): written only when
|
|
592
|
+
// `on`, so a default build stays byte-identical. Not `GATE_SWITCHES`, which holds `--no-*` disarms.
|
|
593
|
+
theme.SHARED_TIER_LINE = cfg.sharedTier ? `\n${SHARED_TIER_LINE}\n` : '';
|
|
507
594
|
// The gate switches (`GATE_SWITCHES`: Laws I, III, IV), under the same contract: a line is
|
|
508
595
|
// written only when its gate is OFF, so a default build stays byte-identical and a missing
|
|
509
596
|
// line reads back as armed (`gatesOfDir`). The OpenCode plugins read these lines at load, so
|
|
@@ -535,8 +622,7 @@ export function themedRel(rel, theme) {
|
|
|
535
622
|
* `_build_render.dest_rel` — AGENT.md.tmpl -> AGENT.md; gitignore -> .gitignore;
|
|
536
623
|
* everything else keeps its name.
|
|
537
624
|
*
|
|
538
|
-
* WHY THE IGNORE FILES ARE STORED WITHOUT THE DOT —
|
|
539
|
-
* full argument. In short: `src/memory/.gitignore` and `src/notebook/.gitignore` are
|
|
625
|
+
* WHY THE IGNORE FILES ARE STORED WITHOUT THE DOT — in short: `src/memory/.gitignore` and `src/notebook/.gitignore` are
|
|
540
626
|
* product content, and under their real names `npm install` renamed them to `.npmignore`
|
|
541
627
|
* on extraction (so an npm-installed Geneseed emitted bundles with NO `.gitignore` and
|
|
542
628
|
* leaked the user's agent memory into their repo) while `npm pack` read the notebook's
|
|
@@ -558,16 +644,16 @@ export function destRel(rel) {
|
|
|
558
644
|
* Returns `{ theme, items }` where each item is `{ rel, text, src }` — `rel` is the
|
|
559
645
|
* themed POSIX output path, `text` is the rendered text or `null` for a binary that the
|
|
560
646
|
* caller copies from `src`. A credited skill's licence copy also carries `licenceOf` (the
|
|
561
|
-
* skill's stem), since its `src` is not under that skill.
|
|
562
|
-
* same data with the field names the Python docstring already uses.
|
|
647
|
+
* skill's stem), since its `src` is not under that skill. Each entry is an object with named fields.
|
|
563
648
|
* @param {any} cfg
|
|
564
649
|
* @param {string} themeName
|
|
565
|
-
*
|
|
650
|
+
* `sharedRoot` is the tier's root on a global emit (`sharedRootFor`): see `pathTokens`.
|
|
651
|
+
* @param {{ footprint?: string, lawsPrefix?: string, sharedRoot?: string | null, nativeCatalog?: boolean | { skills?: boolean, agents?: boolean } }} [opts]
|
|
566
652
|
*/
|
|
567
653
|
export function renderAll(cfg, themeName, {
|
|
568
|
-
footprint = 'full', lawsPrefix = '', nativeCatalog = false,
|
|
654
|
+
footprint = 'full', lawsPrefix = '', nativeCatalog = false, sharedRoot = null,
|
|
569
655
|
} = {}) {
|
|
570
|
-
const theme = effectiveTheme(cfg, themeName, { footprint, lawsPrefix });
|
|
656
|
+
const theme = effectiveTheme(cfg, themeName, { footprint, lawsPrefix, sharedRoot });
|
|
571
657
|
const items = [];
|
|
572
658
|
const skipped = new Set(cfg.excludeSkills ?? []);
|
|
573
659
|
// Members of every kit `--kits` did not name: kit logic, not `excludeSkills`, so no marker.
|
package/js/build/source.mjs
CHANGED
|
@@ -199,6 +199,7 @@ export function ruleSummaries(src = SRC) {
|
|
|
199
199
|
*/
|
|
200
200
|
const AUTHOR_NOTE_RE = /[ \t]*<!--[ \t]*note:[\s\S]*?-->[ \t]*\r?\n?/g;
|
|
201
201
|
export function stripAuthorNotes(text) {
|
|
202
|
+
if (!text.includes('note:')) return text; // most files: skips the blanking and the regex scan
|
|
202
203
|
const masked = blankCodeSpans(text);
|
|
203
204
|
const ranges = [...masked.matchAll(AUTHOR_NOTE_RE)]
|
|
204
205
|
.map((m) => [m.index, m.index + m[0].length]);
|
|
@@ -554,7 +555,7 @@ export const GATE_SWITCHES = [
|
|
|
554
555
|
*/
|
|
555
556
|
export function makeCfg({
|
|
556
557
|
posture = 'peer', mode = 'direct', trust = DEFAULT_PRESET, doctrines = PACK_ORDER,
|
|
557
|
-
excludeRules = [], excludeSkills = [], kits = [], ...switches
|
|
558
|
+
excludeRules = [], excludeSkills = [], kits = [], sharedTier = /** @type {boolean | string} */ (false), ...switches
|
|
558
559
|
} = {}) {
|
|
559
560
|
return {
|
|
560
561
|
root: ROOT,
|
|
@@ -584,6 +585,8 @@ export function makeCfg({
|
|
|
584
585
|
excludeSkills: Array.isArray(excludeSkills) ? [...excludeSkills] : [],
|
|
585
586
|
// Kits switched on for this install — off unless named, so a default build is unchanged.
|
|
586
587
|
kits: Array.isArray(kits) ? [...kits] : [],
|
|
588
|
+
// The shared tier read by a PROJECT install (`--shared-tier on`); `on` from the flag, a boolean from a read-back.
|
|
589
|
+
sharedTier: sharedTier === true || sharedTier === 'on',
|
|
587
590
|
// The gate switches (`GATE_SWITCHES`: `secretsGate`, `doneGate`, `deletionGate`), each armed
|
|
588
591
|
// unless its `no*` arg says so in so many words: only a literal `true` disarms, so every
|
|
589
592
|
// caller that never heard of a switch keeps the gate.
|
package/js/build/stubs.mjs
CHANGED
|
@@ -14,9 +14,10 @@ import path from 'node:path';
|
|
|
14
14
|
import { writeText } from '../lib/fs.mjs';
|
|
15
15
|
import { isDir } from '../lib/fs.mjs';
|
|
16
16
|
import { jsonDumpsIndent } from '../lib/json.mjs';
|
|
17
|
-
import {
|
|
17
|
+
import { NOTES_DIRS, WIKI_NAMES, renderedSharedRoot, sharedPaths } from '../lib/machine-dir.mjs';
|
|
18
|
+
import { EXCLUDES_FILE, isCanonical } from '../hosts/hosts.mjs';
|
|
18
19
|
import { MEMORY_SEED } from '../hosts/memory-files.mjs';
|
|
19
|
-
import { existsSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
20
21
|
|
|
21
22
|
// ---------------------------------------------------------------------------
|
|
22
23
|
// Seeded stubs. Written once into the bundle and NEVER overwritten — each holds
|
|
@@ -239,24 +240,50 @@ export function ensureContextStub(out) {
|
|
|
239
240
|
}
|
|
240
241
|
|
|
241
242
|
/** The wiki manifest's name. `geneseed-` says who owns it in a shared `.claude/`/`.opencode/`. */
|
|
242
|
-
export const WIKI_FILE =
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
export const WIKI_FILE = WIKI_NAMES[0];
|
|
244
|
+
const LEGACY_WIKI_FILES = WIKI_NAMES.slice(1);
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* `{new: [old…]}` — every file a build renamed, with the names it used to have. The fallback that
|
|
248
|
+
* still reads an old name has no end date, so `status` and `rebuild-all` warn while one is on disk
|
|
249
|
+
* (M3): removal waits for a release after users have been told. One table, so the next rename is
|
|
250
|
+
* one row and not a second warning.
|
|
251
|
+
*/
|
|
252
|
+
export const RENAMED_FILES = { [WIKI_FILE]: LEGACY_WIKI_FILES };
|
|
253
|
+
|
|
254
|
+
/** The old-name files present in `dirs`, as `{file, now}`: the path found and the name it takes. */
|
|
255
|
+
export function renamedFilesIn(dirs) {
|
|
256
|
+
const found = [];
|
|
257
|
+
for (const dir of dirs) {
|
|
258
|
+
for (const [now, olds] of Object.entries(RENAMED_FILES)) {
|
|
259
|
+
for (const old of olds) {
|
|
260
|
+
const file = path.join(dir, old);
|
|
261
|
+
if (existsSync(file)) found.push({ file, now });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return found;
|
|
266
|
+
}
|
|
246
267
|
|
|
247
268
|
/**
|
|
248
269
|
* `_build_render.ensure_wiki_stub`, plus the rename. A legacy manifest is the user's file: it is
|
|
249
270
|
* RENAMED to `WIKI_FILE` (bytes preserved by construction), never copied and never seeded beside.
|
|
250
271
|
* A rename that fails (the file held open on Windows) leaves it where it is and seeds nothing —
|
|
251
|
-
* a seed beside it would fork the user's declarations; the readers' fallback still finds it.
|
|
272
|
+
* a seed beside it would fork the user's declarations; the readers' fallback still finds it. The
|
|
273
|
+
* failure is WARNED (B6): it used to be swallowed, and the old name then stayed in use unseen.
|
|
252
274
|
* The sibling `.gitignore` follows the rename, or the private paths become committable.
|
|
253
275
|
*/
|
|
254
|
-
export function ensureWikiStub(out
|
|
276
|
+
export function ensureWikiStub(out, { rename = renameSync,
|
|
277
|
+
warn = (m) => process.stderr.write(m) } = {}) {
|
|
255
278
|
const dest = path.join(out, WIKI_FILE);
|
|
256
279
|
if (existsSync(dest)) return;
|
|
257
280
|
const legacy = LEGACY_WIKI_FILES.find((n) => existsSync(path.join(out, n)));
|
|
258
281
|
if (!legacy) return seed(dest, WIKI_STUB);
|
|
259
|
-
try {
|
|
282
|
+
try { rename(path.join(out, legacy), dest); } catch (e) {
|
|
283
|
+
warn(`[geneseed] WARN could not rename ${path.join(out, legacy)} to ${WIKI_FILE}: ${e.message}; `
|
|
284
|
+
+ 'it is still read under its old name, and the next build tries again\n');
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
260
287
|
ignoreRenamedWiki(path.join(out, '.gitignore'), legacy);
|
|
261
288
|
}
|
|
262
289
|
|
|
@@ -285,6 +312,40 @@ export const ensureProfileStub = stubWriter(PROFILE_FILE, PROFILE_STUB);
|
|
|
285
312
|
*/
|
|
286
313
|
export const ensureExcludesStub = stubWriter(EXCLUDES_FILE, EXCLUDES_STUB);
|
|
287
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Create the machine tier and seed what is absent; every file is the user's once it exists, as a
|
|
317
|
+
* host's are. Nothing here enters a manifest: uninstall never touches the tier (D8). False when it
|
|
318
|
+
* cannot be created, and that is never fatal: the emit renders relative and the host layer serves.
|
|
319
|
+
*/
|
|
320
|
+
export function ensureSharedTier() {
|
|
321
|
+
try {
|
|
322
|
+
const tier = sharedPaths();
|
|
323
|
+
mkdirSync(tier.memory, { recursive: true });
|
|
324
|
+
for (const sub of NOTES_DIRS) mkdirSync(path.join(tier.notes, sub), { recursive: true });
|
|
325
|
+
ensureMemoryIndex(tier.memory);
|
|
326
|
+
ensureRulesStub(tier.root);
|
|
327
|
+
ensureProfileStub(tier.root);
|
|
328
|
+
ensureWikiStub(tier.root);
|
|
329
|
+
ensureExcludesStub(tier.root);
|
|
330
|
+
return true;
|
|
331
|
+
} catch (e) {
|
|
332
|
+
process.stderr.write(`[geneseed] WARN could not create the shared tier: ${e.message}; `
|
|
333
|
+
+ 'this emit renders relative paths\n');
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* The root a global emit renders. Rendering and creating are two decisions: every global emit
|
|
340
|
+
* renders the same path, and only a canonical one creates the tier. null, so relative paths, only
|
|
341
|
+
* when that creation failed or there is no home. `diff` and Restore do not ask: they re-render a
|
|
342
|
+
* deployed install, so they send its own root (`renderedTier`).
|
|
343
|
+
*/
|
|
344
|
+
export function sharedRootFor(cfgDir, host) {
|
|
345
|
+
const root = renderedSharedRoot();
|
|
346
|
+
return root !== null && (!isCanonical(cfgDir, host) || ensureSharedTier()) ? root : null;
|
|
347
|
+
}
|
|
348
|
+
|
|
288
349
|
/** `_build_render.ensure_bundle_gitignore`. */
|
|
289
350
|
export const ensureBundleGitignore = stubWriter('.gitignore', BUNDLE_GITIGNORE);
|
|
290
351
|
|