geneseed 5.3.1 → 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.
- package/CHANGELOG.md +102 -0
- package/README.md +51 -18
- package/SHIPPED.md +7 -7
- package/adapters/bob/README.md +12 -1
- package/adapters/opencode/README.md +5 -3
- package/adapters/opencode/plugins/geneseed-context.js +77 -10
- package/adapters/opencode/plugins/geneseed-guard.js +106 -22
- package/adapters/opencode/plugins/geneseed-learn.js +641 -6
- package/bin/geneseed-cli.mjs +10 -0
- package/bin/geneseed-hook.mjs +5 -4
- package/docs/PRD.md +1 -1
- package/docs/README.md +1 -0
- package/docs/concepts/agents.md +14 -2
- package/docs/concepts/collaboration.md +2 -2
- package/docs/concepts/enforcement-table.md +5 -2
- package/docs/concepts/exclusions.md +16 -2
- package/docs/concepts/footprint.md +1 -1
- package/docs/concepts/foreman-mode.md +23 -4
- package/docs/concepts/hook-gates.md +4 -4
- package/docs/concepts/hooks.md +25 -7
- package/docs/concepts/host-matrix.md +4 -4
- package/docs/concepts/hosts.md +1 -1
- package/docs/concepts/kits.md +12 -2
- package/docs/concepts/loop-bricks.md +3 -3
- package/docs/concepts/loops.md +6 -4
- package/docs/concepts/ownership.md +1 -1
- package/docs/concepts/rules.md +2 -2
- package/docs/concepts/shared-tier.md +1 -1
- package/docs/concepts/skills.md +21 -1
- package/docs/concepts/themes.md +1 -1
- package/docs/extending.md +73 -29
- package/docs/guides/auto-merge.md +100 -0
- package/docs/guides/choose-your-setup.md +1 -1
- package/docs/guides/headless.md +1 -1
- package/docs/guides/install-clone.md +19 -1
- package/docs/guides/install-scripted.md +8 -2
- package/docs/guides/install.md +20 -2
- package/docs/guides/loop-finish.md +3 -3
- package/docs/guides/loop-running.md +4 -4
- package/docs/guides/project-context.md +1 -1
- package/docs/guides/run-a-factory.md +2 -2
- package/docs/guides/setup-doctrines.md +2 -2
- package/docs/guides/setup-footprint.md +1 -1
- package/docs/guides/uninstall.md +3 -3
- package/docs/guides/upgrade.md +2 -2
- package/docs/guides/worktree.md +1 -1
- package/docs/reference/env-context.md +1 -1
- package/docs/reference/environment.md +4 -2
- package/docs/reference/plugin-activity.md +1 -1
- package/docs/reference/plugin-guard.md +1 -1
- package/docs/reference/plugin-learn.md +5 -1
- package/docs/reference/plugin-workflow.md +1 -1
- package/docs/reference/profiles.md +142 -0
- package/docs/reference/troubleshoot-doctor.md +1 -1
- package/docs/reference/troubleshoot-hooks.md +2 -2
- package/docs/reference/troubleshoot-install.md +3 -3
- package/docs/reference/troubleshoot-tools.md +1 -1
- package/docs/token-footprint.md +11 -6
- package/docs/understand/design-choices-engineering.md +1 -1
- package/docs/understand/enforced-vs-asked.md +1 -1
- package/docs/understand/machine-claude.md +2 -2
- package/docs/understand/on-your-machine.md +1 -1
- package/docs/web-ui.md +8 -6
- package/harness.config.json +1 -1
- package/js/README.md +11 -3
- package/js/build/args.mjs +16 -4
- package/js/build/catalog.mjs +11 -1
- package/js/build/driver.mjs +74 -16
- package/js/build/emit-claude.mjs +32 -5
- package/js/build/emit-opencode.mjs +16 -9
- package/js/build/export.mjs +1 -1
- package/js/build/generate.mjs +12 -157
- package/js/build/notes-migrate.mjs +99 -0
- package/js/build/profile.mjs +326 -0
- package/js/build/render.mjs +110 -8
- package/js/build/retired-skills.mjs +60 -13
- package/js/build/source.mjs +100 -3
- package/js/build/stubs.mjs +4 -1
- package/js/cli-table.json +212 -7
- package/js/hosts/agent-runs.mjs +205 -0
- package/js/hosts/done-checks.mjs +3 -1
- package/js/hosts/hooks-done.mjs +428 -63
- package/js/hosts/hooks-learn.mjs +89 -3
- package/js/hosts/hooks-prims.mjs +44 -4
- package/js/hosts/hooks.mjs +159 -9
- package/js/hosts/hosts.mjs +10 -0
- package/js/hosts/installs.mjs +44 -2
- package/js/hosts/link.mjs +45 -10
- package/js/hosts/native.mjs +61 -7
- package/js/hosts/opencode.mjs +1 -1
- package/js/hosts/settings.mjs +101 -3
- package/js/hosts/spec-feedback.mjs +538 -0
- package/js/hosts/usage.mjs +67 -8
- package/js/inspect/agent-scores.mjs +118 -0
- package/js/inspect/checks-authoring.mjs +2 -1
- package/js/inspect/checks-build.mjs +20 -4
- package/js/inspect/checks-constitution.mjs +32 -0
- package/js/inspect/checks-repo.mjs +27 -2
- package/js/inspect/cost.mjs +6 -5
- package/js/inspect/diff.mjs +46 -8
- package/js/inspect/doctor.mjs +4 -0
- package/js/inspect/inventory.mjs +1 -1
- package/js/inspect/status.mjs +3 -1
- package/js/inspect/validate.mjs +1 -0
- package/js/lib/machine-dir.mjs +8 -0
- package/js/lib/paths.mjs +4 -1
- package/js/maintain/profile-scope.mjs +145 -0
- package/js/maintain/profiles.mjs +486 -0
- package/js/maintain/setup.mjs +413 -15
- package/js/maintain/uninstall.mjs +4 -1
- package/js/maintain/update.mjs +4 -2
- package/js/web/actions.mjs +44 -41
- package/js/web/api.mjs +13 -3
- package/js/web/handler.mjs +8 -0
- package/js/web/jobs.mjs +5 -4
- package/js/web/profiles-api.mjs +201 -0
- package/js/web/routes.mjs +5 -0
- package/package.json +2 -1
- package/profiles/guillaume-claude-global.json +16 -0
- package/profiles/starter.json +14 -0
- package/registry.json +14 -0
- package/src/AGENT.md.tmpl +16 -18
- package/src/agents/_self-improvement.md +15 -7
- package/src/agents/_template.md +4 -2
- package/src/agents/advocate.md +1 -1
- package/src/agents/architect.md +1 -1
- package/src/agents/developer.md +10 -3
- 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 +4 -2
- 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 +1 -1
- 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 +10 -3
- 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 +4 -2
- package/src/agents/user-advocate.md +1 -1
- package/src/agents/visionary.md +1 -1
- package/src/bricks/pr-open.md +3 -2
- package/src/doctrines/ops.md +2 -2
- package/src/doctrines/process.md +40 -36
- package/src/factories/analysis-to-build.json +1 -1
- package/src/factories/bug-report-to-fix.json +1 -1
- package/src/factories/issue-to-pr.json +1 -1
- package/src/kits/terminal-tools/rules.md +10 -0
- package/src/kits/terminal-tools.json +13 -0
- package/src/licenses/herdr.txt +201 -0
- package/src/memory/README.md +12 -2
- package/src/modes/foreman.md +25 -9
- package/src/skill-descriptions.json +63 -0
- package/src/skills/_self-improvement.md +42 -24
- package/src/skills/_template.md +3 -1
- package/src/skills/brainstorm.md +35 -22
- package/src/skills/commit.md +17 -17
- package/src/skills/daydream/VENDOR.md +6 -0
- package/src/skills/debug/ci.md +1 -1
- package/src/skills/dependencies.md +3 -3
- package/src/skills/diagram-design/VENDOR.md +4 -0
- package/src/skills/document-project.md +3 -2
- package/src/skills/explain-changes/VENDOR.md +5 -1
- package/src/skills/factory.md +13 -4
- package/src/skills/geneseed.md +4 -2
- package/src/skills/git-history.md +5 -7
- package/src/skills/herdr.md +135 -0
- package/src/skills/loop.md +3 -2
- package/src/skills/opencode-cli.md +84 -0
- package/src/skills/parallel-agents.md +11 -0
- package/src/skills/pipeline.md +3 -3
- package/src/skills/plan.md +5 -4
- package/src/skills/react-view-transitions/VENDOR.md +7 -1
- package/src/skills/release.md +11 -9
- package/src/skills/review-response.md +4 -2
- package/src/skills/rule/approve.md +2 -1
- package/src/skills/rule.md +27 -1
- package/src/skills/ship.md +54 -7
- package/src/skills/skill-forge.md +5 -3
- package/src/skills/token-report/VENDOR.md +5 -1
- package/src/skills/worktree.md +2 -2
- package/src/upstreams.json +9 -2
- package/themes/README.md +3 -1
- package/themes/_TEMPLATE.json +2 -0
- package/themes/biker.json +2 -0
- package/themes/commentator.json +2 -0
- package/themes/cyberpunk.json +2 -0
- package/themes/gamer.json +2 -0
- package/themes/imperial.json +2 -0
- package/themes/joker.json +2 -0
- package/themes/marvin.json +2 -0
- package/themes/mean.json +2 -0
- package/themes/military.json +2 -0
- package/themes/neutral.json +2 -0
- package/themes/pirate.json +2 -0
- package/themes/sports.json +2 -0
- package/themes/verstappen.json +2 -0
- package/themes/wizard.json +2 -0
- package/web/dist/assets/{ActiveLoops-BJJN3P-V.js → ActiveLoops-DOJCPPPc.js} +1 -1
- package/web/dist/assets/Activity-LKsDzsnK.js +1 -0
- package/web/dist/assets/ActivityDetail-DhwTfPm6.js +1 -0
- package/web/dist/assets/{Bonsai-BBl4XXqs.js → Bonsai-CePMLrpr.js} +1 -1
- package/web/dist/assets/{CopyButton-Beven8yn.js → CopyButton-CuoaJ6k7.js} +1 -1
- package/web/dist/assets/Dashboard-D1VKuvLe.js +2 -0
- package/web/dist/assets/Docs-CUrHJKaU.js +5 -0
- package/web/dist/assets/Factories-Ci1XfmSy.js +1 -0
- package/web/dist/assets/{GreenhouseView-Bce212qd.js → GreenhouseView-CNfH2lPK.js} +1 -1
- package/web/dist/assets/Installs-ZHQZM1iS.js +3 -0
- package/web/dist/assets/{JournalView-CV4omyww.js → JournalView-CMsWahkS.js} +1 -1
- package/web/dist/assets/Kits-CkliyK0n.js +1 -0
- package/web/dist/assets/Laws-hh4O3HZ4.js +4 -0
- package/web/dist/assets/{LibRows-Dag1s0ZX.js → LibRows-Brv0Hmkr.js} +1 -1
- package/web/dist/assets/Library-BYmiLjJr.js +3 -0
- package/web/dist/assets/Loops-ytm-xJ68.js +2 -0
- package/web/dist/assets/{OperatorHudView-JmYY1pBR.js → OperatorHudView-KaqCx_HP.js} +1 -1
- package/web/dist/assets/Personal-CmcnRKYE.js +2 -0
- package/web/dist/assets/Settings-tUrpdOfq.js +1 -0
- package/web/dist/assets/{Tabs-8zsyEPSK.js → Tabs-CD7etcGD.js} +1 -1
- package/web/dist/assets/api-CZ-x0iWG.js +1 -0
- package/web/dist/assets/{controls-D4wmg_pl.js → controls-CK7qHA8H.js} +1 -1
- package/web/dist/assets/{index-CRWqKxfY.css → index-Ba_Kg3Af.css} +1 -1
- package/web/dist/assets/index-COKbhFNo.js +6 -0
- package/web/dist/index.html +3 -3
- package/web/dist/assets/Activity-WQ3ykgxU.js +0 -1
- package/web/dist/assets/ActivityDetail-7rt04SkS.js +0 -1
- package/web/dist/assets/Dashboard-BgLArtgu.js +0 -2
- package/web/dist/assets/Docs-B5aHp86J.js +0 -5
- package/web/dist/assets/Factories-BjqzXAw8.js +0 -1
- package/web/dist/assets/Installs-B1OsrHXF.js +0 -3
- package/web/dist/assets/Kits-CW1e7xNa.js +0 -1
- package/web/dist/assets/Laws-1Ckf1lbs.js +0 -4
- package/web/dist/assets/Library-B3FuFLel.js +0 -3
- package/web/dist/assets/Loops-CwqgnLNw.js +0 -2
- package/web/dist/assets/Personal-DKLgLa7Z.js +0 -2
- package/web/dist/assets/Settings-BwErnh-R.js +0 -1
- package/web/dist/assets/api-DLDVY3K-.js +0 -1
- package/web/dist/assets/index-Ce6qF2nG.js +0 -6
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An install's profile — every setting read back off a deployed install, and the argv that
|
|
3
|
+
* re-emits it unchanged — plus the preserve guard that holds a build to it.
|
|
4
|
+
*
|
|
5
|
+
* Moved out of `generate.mjs` so the driver can import it: `generate.mjs` lazily imports
|
|
6
|
+
* `update.mjs`, which spawns git, and the driver is under a transitive `child_process` ban
|
|
7
|
+
* (`tests/unit/hook_cli.test.mjs` walks dynamic imports too). This module reads the install
|
|
8
|
+
* through `js/hosts/installs.mjs` and prints nothing. `generate.mjs` re-exports the three
|
|
9
|
+
* profile functions, so their callers did not move.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync } from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
|
|
14
|
+
import { DEFAULT_CONTEXT_WINDOW, GATE_SWITCHES, PACK_ORDER } from './source.mjs';
|
|
15
|
+
import { DEFAULT_PRESET } from '../loop/score.mjs';
|
|
16
|
+
import { CLAUDE_STYLE, GLOBAL_MANIFEST, HOSTS } from '../hosts/hosts.mjs';
|
|
17
|
+
import {
|
|
18
|
+
EMIT_FOR, EMIT_HOST_SCOPE, contextWindowOfDir, defaultMode, defaultPosture, defaultTheme, doctrinesForBuild,
|
|
19
|
+
emitHostScopeOf, excludedRulesOfDir, excludedSkillsOfDir, footprintOfDir, kitsOfDir, sharedTierOfDir,
|
|
20
|
+
gatesOfDir, installState, modeOfDir, postureOfDir, readMaybe, themeOfDir, trustOfDir,
|
|
21
|
+
} from '../hosts/installs.mjs';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `_harness_setup._setup_build_args` — the generator argv for one selection. Pure but for one
|
|
25
|
+
* read: `harness.config.json`, for the posture and mode the driver would default to.
|
|
26
|
+
*
|
|
27
|
+
* The elision rules are not symmetric: `footprint` is ALWAYS passed,
|
|
28
|
+
* because omitting it when it matched the generator's default silently coupled the answer to
|
|
29
|
+
* whatever that default happened to be — the moment the default moved, picking the old one
|
|
30
|
+
* produced the new one. `posture` and `mode` elide only at the default the driver would
|
|
31
|
+
* actually take, which is `configDefaults()` (`harness.config.json`), read here through
|
|
32
|
+
* `defaultPosture()`/`defaultMode()`. Eliding at the literals `peer`/`direct` turned a replay
|
|
33
|
+
* of a `peer` install into an `artisan` build under `{"posture":"artisan"}` — and the
|
|
34
|
+
* preserve guard then refused `rebuild-all`. `trust` elides at `DEFAULT_PRESET`, which no
|
|
35
|
+
* config key feeds.
|
|
36
|
+
*
|
|
37
|
+
* ⚠ `doctrines` DOES NOT ELIDE, AND THAT IS THE SAFETY DECISION, NOT A STYLE ONE. It used to
|
|
38
|
+
* elide on the full set, by analogy with posture and mode — but those two compare against a
|
|
39
|
+
* FROZEN LITERAL (`'peer'`, `'direct'`), while the default a missing `--doctrines` actually
|
|
40
|
+
* lands on is `configDefaults()`, which reads `harness.config.json`. With `{"doctrines":
|
|
41
|
+
* ["craft"]}` in that file, an install carrying all four packs re-emitted by `upgrade` was
|
|
42
|
+
* silently narrowed to one — and the narrowing takes the commit/push consent gate off an
|
|
43
|
+
* install whose owner never asked for that. Same trap as `footprint`, one axis over, with a
|
|
44
|
+
* boundary behind it. A caller that knows the selection now always says so.
|
|
45
|
+
*
|
|
46
|
+
* `allPacks` survives the elision's removal because it is still what CANONICALISES the value:
|
|
47
|
+
* the flag is emitted in the checkout's pack order, not the order handed in, and this function
|
|
48
|
+
* is pure and has no discovery of its own.
|
|
49
|
+
*
|
|
50
|
+
* Two states: `null` means "the caller expressed no opinion" and emits no flag at all, so the
|
|
51
|
+
* generator falls back to `harness.config.json` — the only route left to that fallback, and it
|
|
52
|
+
* is reached only where nothing was read back off an install; `[]` is a deliberate empty
|
|
53
|
+
* selection and emits `--doctrines none`, which is the spelling the driver's `parseDoctrines`
|
|
54
|
+
* accepts (an empty `--doctrines ` is a usage error there, so it can never be produced here).
|
|
55
|
+
*/
|
|
56
|
+
export function setupBuildArgs(theme, emit, out = null, root = null, footprint = 'lean',
|
|
57
|
+
posture = 'peer', mode = 'direct', doctrines = null, allPacks = PACK_ORDER,
|
|
58
|
+
excludeRules = null, trust = DEFAULT_PRESET, excludeSkills = null, gates = {}, kits = null, sharedTier = false,
|
|
59
|
+
contextWindow = DEFAULT_CONTEXT_WINDOW) {
|
|
60
|
+
const argv = ['--theme', theme, '--emit', emit];
|
|
61
|
+
if (!emit.endsWith('-global')) {
|
|
62
|
+
if (out) argv.push('--out', out);
|
|
63
|
+
if (root) argv.push('--root', root);
|
|
64
|
+
}
|
|
65
|
+
if (footprint) argv.push('--footprint', footprint);
|
|
66
|
+
if (posture && posture !== defaultPosture()) argv.push('--posture', posture);
|
|
67
|
+
if (mode && mode !== defaultMode()) argv.push('--mode', mode);
|
|
68
|
+
if (trust && trust !== DEFAULT_PRESET) argv.push('--trust', trust);
|
|
69
|
+
if (Array.isArray(doctrines)) {
|
|
70
|
+
// Emitted in `allPacks` order, not the order handed in: a caller may legitimately pass an
|
|
71
|
+
// unsorted list, and the flag has to be canonical for the same reason the driver
|
|
72
|
+
// re-normalises on parse — the `Active packs:` marker is compared against itself.
|
|
73
|
+
const picked = allPacks.filter((p) => doctrines.includes(p));
|
|
74
|
+
argv.push('--doctrines', picked.length ? picked.join(',') : 'none');
|
|
75
|
+
}
|
|
76
|
+
// The second axis, emitted the same way and for the same reason — but ALWAYS when the
|
|
77
|
+
// caller passed a list, empty included. An omitted flag reads as "no opinion" and the
|
|
78
|
+
// driver's config fallback fills it in; `none` is the caller saying "exclude nothing",
|
|
79
|
+
// which is exactly what a rebuild that just re-enabled the last rule has to say.
|
|
80
|
+
if (Array.isArray(excludeRules)) {
|
|
81
|
+
argv.push('--exclude-rules', excludeRules.length ? excludeRules.join(',') : 'none');
|
|
82
|
+
}
|
|
83
|
+
// Skills elide when nothing is excluded: the driver's default IS nothing (no config key
|
|
84
|
+
// feeds it), so the flag's absence and `none` are the same answer, and every argv that
|
|
85
|
+
// excludes nothing stays the bytes it was before the flag existed.
|
|
86
|
+
if (excludeSkills?.length) argv.push('--exclude-skills', excludeSkills.join(','));
|
|
87
|
+
// The gate switches elide when armed: the driver's default IS armed (no config key feeds
|
|
88
|
+
// them), so only an explicit `false` speaks, and every armed argv stays the bytes it was.
|
|
89
|
+
// `gates` is one object keyed as `GATE_SWITCHES` keys it (`gatesOfDir`, a profile, a body).
|
|
90
|
+
// Law order, so a Law IV-only install still ends on `--no-deletion-gate` as it did.
|
|
91
|
+
for (const g of GATE_SWITCHES) if (gates?.[g.key] === false) argv.push(g.flag);
|
|
92
|
+
// Kits elide when none is on, as skills do: no config key feeds them, so absence and `none`
|
|
93
|
+
// are the same answer. Last, so an argv naming no kit is the bytes it always was.
|
|
94
|
+
if (kits?.length) argv.push('--kits', [...kits].sort().join(','));
|
|
95
|
+
// The shared tier elides when off, like the kits: the default is off, so only `on` speaks.
|
|
96
|
+
if (sharedTier) argv.push('--shared-tier', 'on');
|
|
97
|
+
// The context window elides at its default, like the shared tier: no config key feeds it, so
|
|
98
|
+
// only `1m` speaks and every default argv stays the bytes it was before the flag existed.
|
|
99
|
+
if (contextWindow && contextWindow !== DEFAULT_CONTEXT_WINDOW) argv.push('--context-window', contextWindow);
|
|
100
|
+
return argv;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// The emit for an install carrying NO marker is `EMIT_FOR` (`js/hosts/installs.mjs`): a
|
|
104
|
+
// pre-marker install still has a (host, scope), which is what the walk found it by, so it is
|
|
105
|
+
// rebuilt in its own mode rather than defaulted to OpenCode.
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Everything `rebuild-all` reads back off one install, and the argv that re-emits it unchanged.
|
|
109
|
+
*
|
|
110
|
+
* EXTRACTED SO `status` SHOWS WHAT A REBUILD WOULD USE, not a second reading of the same
|
|
111
|
+
* markers that could drift from this one. An agent changing one setting takes `argv`, edits one
|
|
112
|
+
* flag and runs it; every flag it did not touch has to be the install's own, or the "one
|
|
113
|
+
* change" silently resets the rest — which is exactly the failure the seven read-backs below
|
|
114
|
+
* exist to prevent.
|
|
115
|
+
*
|
|
116
|
+
* THE MARKER IS TRUSTED ONLY FOR ITS OWN HOST. There is one `.geneseed-emit` per root and the
|
|
117
|
+
* last deploy wins, so in a dual-host repo (`.opencode/` and `.claude/` in one cwd) the other
|
|
118
|
+
* host's row would otherwise rebuild with the WRONG emit — turning a Claude install into an
|
|
119
|
+
* OpenCode one. `rebuild-all/a-dual-host-repo-rebuilds-each-row-in-its-own-emit` is the cell.
|
|
120
|
+
*/
|
|
121
|
+
export function installProfile(host, scope, root, notify = null) {
|
|
122
|
+
const raw = readMaybe(path.join(root, '.geneseed-emit'));
|
|
123
|
+
let marker = raw === null ? '' : raw.trim();
|
|
124
|
+
if (marker && (EMIT_HOST_SCOPE.get(marker) ?? ['', ''])[0] !== host) marker = '';
|
|
125
|
+
const emit = marker || EMIT_FOR.get(`${host} ${scope}`) || 'opencode-global';
|
|
126
|
+
// Every read-back below is narrowed to `host`'s OWN carrier (host-compat B1): in a repo
|
|
127
|
+
// shared with another Claude-style host, an un-narrowed scan answers with WHICHEVER host's
|
|
128
|
+
// carrier the shared `CARRIERS` order favours — the wrong carrier for every host but one.
|
|
129
|
+
const theme = themeOfDir(root, host) || defaultTheme();
|
|
130
|
+
const footprint = footprintOfDir(root);
|
|
131
|
+
const posture = postureOfDir(root, host) || defaultPosture();
|
|
132
|
+
const mode = modeOfDir(root, host) || defaultMode();
|
|
133
|
+
// Read off the deployed loop skill; no config fallback — `DEFAULT_PRESET` is the engine's.
|
|
134
|
+
const trust = trustOfDir(root, host) || DEFAULT_PRESET;
|
|
135
|
+
// A rebuild that defaulted the pack selection would re-emit an install into a constitution
|
|
136
|
+
// its owner did not choose — and in one direction that is not merely surprising: dropping
|
|
137
|
+
// the process pack takes the commit/push consent RULES out of AGENT.md while
|
|
138
|
+
// `claudeHookGroups` keeps the gate wired, or the reverse. ⚠ AND THE FALLBACK IS NOT
|
|
139
|
+
// `harness.config.json`: a pre-migration carrier has no marker, and resolving that silence
|
|
140
|
+
// out of a machine-wide config narrows every such install on its first upgrade.
|
|
141
|
+
// `doctrinesForBuild` resolves unknown to ALL packs — see its docblock.
|
|
142
|
+
const doctrines = doctrinesForBuild(root, host);
|
|
143
|
+
// The per-rule axis is preserved for the same reason and with sharper teeth: an upgrade that
|
|
144
|
+
// dropped it would quietly hand back every rule its owner switched off, and `process 5` is
|
|
145
|
+
// one of them. No marker reads as `[]` (`excludedRulesOfDir`), never `null`, so the argv always
|
|
146
|
+
// spells the flag (`none` included) and `harness.config.json`'s `excludeRules` never fills it in.
|
|
147
|
+
const excludeRules = excludedRulesOfDir(root, host);
|
|
148
|
+
// Skills left out stay left out: an upgrade that forgot them would put them all back.
|
|
149
|
+
const excludeSkills = excludedSkillsOfDir(root, host, notify);
|
|
150
|
+
// The gate switches: a rebuild that forgot one would silently re-arm (or, read wrong, disarm)
|
|
151
|
+
// the install. A missing marker reads as armed.
|
|
152
|
+
const gates = gatesOfDir(root, host);
|
|
153
|
+
// Kits on stay on (spec A3); one this checkout no longer ships drops with a notice (R2).
|
|
154
|
+
const kits = kitsOfDir(root, host, notify);
|
|
155
|
+
// A project install's `Shared tier: on` stays on across a rebuild; a global install never has it.
|
|
156
|
+
const sharedTier = sharedTierOfDir(root, host);
|
|
157
|
+
// `Context window: 1m` stays 1m: a rebuild that forgot it would shrink the listing cap.
|
|
158
|
+
const contextWindow = contextWindowOfDir(root, host);
|
|
159
|
+
const out = scope === 'global' ? null : root;
|
|
160
|
+
const argv = setupBuildArgs(theme, emit, out, out, footprint, posture, mode, doctrines,
|
|
161
|
+
PACK_ORDER, excludeRules, trust, excludeSkills, gates, kits, sharedTier, contextWindow);
|
|
162
|
+
// A GLOBAL ROW NAMES ITS OWN DIR. `root` came from the host's config-dir resolver, which
|
|
163
|
+
// honours env overrides (`OPENCODE_CONFIG_DIR`, `CLAUDE_CONFIG_DIR`…); without the flag the
|
|
164
|
+
// same argv run from a shell lacking that variable re-emits into the DEFAULT dir — a second
|
|
165
|
+
// install beside the one it was meant to rebuild. Appended, so the argv's head is unchanged.
|
|
166
|
+
if (scope === 'global') argv.push('--config-dir', root);
|
|
167
|
+
return {
|
|
168
|
+
host, scope, root, state: installState(root, host, scope),
|
|
169
|
+
emit, theme, footprint, posture, mode, trust, doctrines, excludeRules, excludeSkills,
|
|
170
|
+
kits, sharedTier, contextWindow, ...gates, argv,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* `argv` as one pasteable command, using the `geneseed build` launcher rather than the raw
|
|
176
|
+
* generator: `geneseed-build` is only on PATH for an npm global install, while a git-clone
|
|
177
|
+
* install has only the `geneseed` launcher, and `geneseed build` now forwards every flag
|
|
178
|
+
* `setupBuildArgs` produces. Only whitespace is quoted — a path holding shell metacharacters
|
|
179
|
+
* (`$`, `&`) would need quoting by hand.
|
|
180
|
+
*/
|
|
181
|
+
export function rebuildCommand(argv) {
|
|
182
|
+
return ['geneseed', 'build', ...argv.map((a) => (/\s/.test(a) ? `"${a}"` : a))].join(' ');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// --------------------------------------------------------------------------------------
|
|
186
|
+
// the preserve guard
|
|
187
|
+
// --------------------------------------------------------------------------------------
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The settings the guard compares, in the order a refusal lists them. `name` is what the
|
|
191
|
+
* refusal prints, `given` the `parseArgs` key a caller sets by passing the flag, `flag` the
|
|
192
|
+
* generator flag, and `now`/`was` the value on each side, spelled so equal means unchanged.
|
|
193
|
+
* The gate switches are rows too: each has a flag for its non-default side only, so a caller
|
|
194
|
+
* returns one to its default with `--reset`, never by omission.
|
|
195
|
+
*/
|
|
196
|
+
const show = (v) => (Array.isArray(v) ? (v.length ? v.join(',') : 'none') : String(v));
|
|
197
|
+
const sorted = (v) => [...(v ?? [])].sort();
|
|
198
|
+
/** @type {{ name: string, given: string, flag: string, gate?: boolean, now: (a: any) => string, was: (p: any) => string }[]} */
|
|
199
|
+
const GUARDED = [
|
|
200
|
+
{ name: 'theme', given: 'theme', flag: '--theme', now: (a) => a.theme, was: (p) => p.theme },
|
|
201
|
+
{ name: 'footprint', given: 'footprint', flag: '--footprint', now: (a) => a.footprint, was: (p) => p.footprint },
|
|
202
|
+
{ name: 'posture', given: 'posture', flag: '--posture', now: (a) => a.posture, was: (p) => p.posture },
|
|
203
|
+
{ name: 'mode', given: 'mode', flag: '--mode', now: (a) => a.mode, was: (p) => p.mode },
|
|
204
|
+
{ name: 'trust', given: 'trust', flag: '--trust', now: (a) => a.trust, was: (p) => p.trust },
|
|
205
|
+
{ name: 'doctrines', given: 'doctrines', flag: '--doctrines', now: (a) => show(a.doctrines), was: (p) => show(p.doctrines) },
|
|
206
|
+
{ name: 'exclude-rules', given: 'excludeRules', flag: '--exclude-rules',
|
|
207
|
+
now: (a) => show(sorted(a.excludeRules)), was: (p) => show(sorted(p.excludeRules)) },
|
|
208
|
+
{ name: 'exclude-skills', given: 'excludeSkills', flag: '--exclude-skills',
|
|
209
|
+
now: (a) => show(sorted(a.excludeSkills)), was: (p) => show(sorted(p.excludeSkills)) },
|
|
210
|
+
{ name: 'kits', given: 'kits', flag: '--kits', now: (a) => show(sorted(a.kits)), was: (p) => show(sorted(p.kits)) },
|
|
211
|
+
{ name: 'shared-tier', given: 'sharedTier', flag: '--shared-tier',
|
|
212
|
+
now: (a) => (a.sharedTier === 'on' ? 'on' : 'off'), was: (p) => (p.sharedTier ? 'on' : 'off') },
|
|
213
|
+
{ name: 'context-window', given: 'contextWindow', flag: '--context-window',
|
|
214
|
+
now: (a) => a.contextWindow ?? DEFAULT_CONTEXT_WINDOW, was: (p) => p.contextWindow },
|
|
215
|
+
// A switch reads as its flag says. `--no-deletion-gate` given is `deletion-gate: off`;
|
|
216
|
+
// `--strict-consent` (the one switch whose flag adds asks, so it is not `--no-*`) given is
|
|
217
|
+
// `strict-consent: on`. Either way the flag given means the switch's key is `false`.
|
|
218
|
+
...GATE_SWITCHES.map((g) => {
|
|
219
|
+
const negative = g.flag.startsWith('--no-');
|
|
220
|
+
const [given, idle] = negative ? ['off', 'on'] : ['on', 'off'];
|
|
221
|
+
return {
|
|
222
|
+
name: g.flag.replace(/^--(no-)?/, ''), given: g.arg, flag: g.flag, gate: true,
|
|
223
|
+
now: (a) => (a[g.arg] ? given : idle), was: (p) => (p[g.key] === false ? given : idle),
|
|
224
|
+
};
|
|
225
|
+
}),
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
/** A guarded row's flag and value as the caller gave them, for the preserving command. */
|
|
229
|
+
function givenTokens(row, args) {
|
|
230
|
+
if (row.gate) return args[row.given] ? [row.flag] : [];
|
|
231
|
+
return [row.flag, row.now(args)];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The install a host emit would render into, or null: none there, a plain bundle, or a config
|
|
236
|
+
* dir that cannot be resolved (the emit itself then fails on its own terms).
|
|
237
|
+
*
|
|
238
|
+
* PRESENT MEANS GENESEED WROTE IT. A `.geneseed-emit` marker naming this emit's (host, scope)
|
|
239
|
+
* counts. So does a Geneseed manifest: a global install's, a Claude-style project layer's, or
|
|
240
|
+
* an OpenCode project's `.opencode/.geneseed-manifest.json` — files only Geneseed writes. The
|
|
241
|
+
* manifest matters in a dual-host repo, where the one root marker names whichever host deployed
|
|
242
|
+
* last. An OpenCode project is NOT detected by its `.opencode/` directory alone (which is what
|
|
243
|
+
* `installState(root, 'opencode', 'project')` tests): that directory is the user's tool config
|
|
244
|
+
* before it is ours, and the guard must never refuse a first install into a repo that already
|
|
245
|
+
* uses OpenCode.
|
|
246
|
+
*/
|
|
247
|
+
export function guardTarget(args, out) {
|
|
248
|
+
if (args.emit === 'files') return null;
|
|
249
|
+
const [host, scope] = EMIT_HOST_SCOPE.get(args.emit) ?? [];
|
|
250
|
+
if (!host) return null;
|
|
251
|
+
let root = out;
|
|
252
|
+
if (scope === 'global') {
|
|
253
|
+
try {
|
|
254
|
+
root = args.cfgDir ?? HOSTS.find((h) => h.host === host).configDir();
|
|
255
|
+
} catch { return null; }
|
|
256
|
+
}
|
|
257
|
+
const marker = emitHostScopeOf(root);
|
|
258
|
+
const marked = marker !== null && marker[0] === host && marker[1] === scope;
|
|
259
|
+
const managed = scope === 'project' && host === 'opencode'
|
|
260
|
+
? existsSync(path.join(root, '.opencode', GLOBAL_MANIFEST))
|
|
261
|
+
: (scope === 'global' || CLAUDE_STYLE.includes(host)) && installState(root, host, scope) === 'active';
|
|
262
|
+
return marked || managed ? { host, scope, root } : null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The preserve guard: what a build would change on the install it targets that its caller did
|
|
267
|
+
* not ask to change. Null when the build may run.
|
|
268
|
+
*
|
|
269
|
+
* WHY A REFUSAL AND NOT AN INHERIT. A flag the caller omits takes the generator's default (or
|
|
270
|
+
* `harness.config.json`'s), never the install's: that is what a build has always meant, and
|
|
271
|
+
* the fresh install, the plan line and the docs all say so. Inheriting would change the meaning
|
|
272
|
+
* of every bare build in silence. Refusing changes nothing that was right before — a build
|
|
273
|
+
* that keeps every setting still runs — and stops only the one that resets settings nobody
|
|
274
|
+
* named. That is the failure reported in 2026-11: an agent "reinstalled" with a bare build and
|
|
275
|
+
* the theme, mode, posture and packs of the user's harness fell back to the defaults.
|
|
276
|
+
*
|
|
277
|
+
* `given` is the set of `parseArgs` keys the caller passed; a setting passed is intent and is
|
|
278
|
+
* never compared. `--reset` (`args.reset`) is the caller's consent to the defaults and skips
|
|
279
|
+
* the guard. Replays (`rebuild-all`, `upgrade`, `migrate`, the console's rebuild) pass the
|
|
280
|
+
* install's whole profile, so they compare equal and run unchanged.
|
|
281
|
+
*
|
|
282
|
+
* Returns `{ host, scope, root, changes: [{ name, from, to }], command }`. `command` is the
|
|
283
|
+
* install's own rebuild (`installProfile(...).argv`) with every flag the caller passed applied
|
|
284
|
+
* on top, so running it keeps everything the caller did not name.
|
|
285
|
+
*/
|
|
286
|
+
export function preserveRefusal(args, given, out, root = null) {
|
|
287
|
+
if (args.reset) return null;
|
|
288
|
+
const target = guardTarget(args, out);
|
|
289
|
+
if (!target) return null;
|
|
290
|
+
const p = installProfile(target.host, target.scope, target.root);
|
|
291
|
+
const changes = GUARDED.filter((r) => !given.has(r.given) && r.now(args) !== r.was(p))
|
|
292
|
+
.map((r) => ({ name: r.name, from: r.was(p), to: r.now(args) }));
|
|
293
|
+
if (!changes.length) return null;
|
|
294
|
+
// The install's own argv, each passed flag's value swapped in where the argv has the flag,
|
|
295
|
+
// the rest appended. A project emit's `--root`, when the caller gave one, replaces the
|
|
296
|
+
// profile's; `--emit` is the caller's (the profile's names the same host and scope).
|
|
297
|
+
const argv = [...p.argv];
|
|
298
|
+
const swap = (flag, tokens) => {
|
|
299
|
+
const i = argv.indexOf(flag);
|
|
300
|
+
if (i >= 0) argv.splice(i, 2, ...tokens);
|
|
301
|
+
else argv.push(...tokens);
|
|
302
|
+
};
|
|
303
|
+
swap('--emit', ['--emit', args.emit]);
|
|
304
|
+
if (root && target.scope === 'project') swap('--root', ['--root', root]);
|
|
305
|
+
for (const row of GUARDED) {
|
|
306
|
+
if (!given.has(row.given)) continue;
|
|
307
|
+
const tokens = givenTokens(row, args);
|
|
308
|
+
if (row.gate) { if (!argv.includes(row.flag)) argv.push(...tokens); } else swap(row.flag, tokens);
|
|
309
|
+
}
|
|
310
|
+
if (args.force) argv.push('--force');
|
|
311
|
+
if (args.pruneGates) argv.push('--prune-gates');
|
|
312
|
+
return { ...target, changes, command: rebuildCommand(argv) };
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** The refusal as the driver prints it: each change, then the command that keeps the rest. */
|
|
316
|
+
export function preserveRefusalText(r) {
|
|
317
|
+
return [
|
|
318
|
+
`geneseed: error: refused: this build would change settings of the ${r.host} ${r.scope} install `
|
|
319
|
+
+ `at ${r.root} that it was not given:`,
|
|
320
|
+
...r.changes.map((c) => ` ${c.name}: ${c.from} -> ${c.to}`),
|
|
321
|
+
'Nothing was written. To rebuild that install and keep its settings, run:',
|
|
322
|
+
` ${r.command}`,
|
|
323
|
+
'Add --reset only to return the settings listed above to their defaults.',
|
|
324
|
+
'',
|
|
325
|
+
].join('\n');
|
|
326
|
+
}
|
package/js/build/render.mjs
CHANGED
|
@@ -37,8 +37,11 @@ import { normcase, comparePaths } from '../lib/paths.mjs';
|
|
|
37
37
|
import {
|
|
38
38
|
CREDIT_RE, GATE_SWITCHES, PACK_ORDER, kitMembers, loadKits, readPackText, resolveCredits, resolveRuleIds, ruleCanon, titleKey, upstreamOf,
|
|
39
39
|
} from './source.mjs';
|
|
40
|
+
import { CONTEXT_WINDOW_MARKER, DEFAULT_CONTEXT_WINDOW } from './source.mjs';
|
|
40
41
|
import { SHARED_TIER_LINE } from '../hosts/hosts.mjs';
|
|
41
|
-
import {
|
|
42
|
+
import { PROJECT_NOTES_DIR } from '../hosts/spec-feedback.mjs';
|
|
43
|
+
import { PORTABLE_MACHINE_DIR } from '../lib/machine-dir.mjs';
|
|
44
|
+
import { VENDORED_SKILL_DIRS, vendoredWithCatalogueLine } from '../hosts/native.mjs';
|
|
42
45
|
import { DEFAULT_PRESET } from '../loop/score.mjs';
|
|
43
46
|
|
|
44
47
|
/** Document STRUCTURE is theme-INDEPENDENT — mirrors `_build_render.STRUCTURE`. */
|
|
@@ -72,7 +75,11 @@ export function pathTokens(theme, sharedRoot = null) {
|
|
|
72
75
|
const at = sharedRoot ? `${sharedRoot}/` : theme.AT_HARNESS ?? '';
|
|
73
76
|
return {
|
|
74
77
|
PATH_MEMORY: sharedRoot ? `${at}memory` : memory,
|
|
75
|
-
|
|
78
|
+
// The two notes scopes (js/hosts/spec-feedback.mjs `PROJECT_NOTES_DIR`). Machine: the tier,
|
|
79
|
+
// absolute on a global emit, the portable `~` form on any other (a project's files travel).
|
|
80
|
+
// Project: relative to the project root, the same on every host and never prefixed.
|
|
81
|
+
PATH_NOTES: `${sharedRoot ?? PORTABLE_MACHINE_DIR}/notes`,
|
|
82
|
+
PATH_PROJECT_NOTES: PROJECT_NOTES_DIR,
|
|
76
83
|
PATH_RULES: `${at}user-rules.md`,
|
|
77
84
|
PATH_PROFILE: `${at}PROFILE.md`,
|
|
78
85
|
PATH_WIKI: `${at}geneseed-wiki.jsonc`,
|
|
@@ -95,9 +102,10 @@ export const SRC_DIR_TOKENS = {
|
|
|
95
102
|
};
|
|
96
103
|
|
|
97
104
|
const TEXT_SUFFIXES = new Set(['.md', '.tmpl', '.json', '.txt', '.yml', '.yaml']);
|
|
98
|
-
/** Top-level `src/` entries the build reads but never ships: upstream-credit provenance,
|
|
99
|
-
* kit manifests (a kit's members ship flat from `skills/` and `agents/`)
|
|
100
|
-
|
|
105
|
+
/** Top-level `src/` entries the build reads but never ships: upstream-credit provenance, the
|
|
106
|
+
* kit manifests (a kit's members ship flat from `skills/` and `agents/`), and the skill
|
|
107
|
+
* catalogue lines (they ship inside each skill's frontmatter, `skillDescription`). */
|
|
108
|
+
const NOT_BUNDLED = new Set(['upstreams.json', 'licenses', 'kits', 'skill-descriptions.json']);
|
|
101
109
|
|
|
102
110
|
// Digits are legal after the first character: `DOC_<PACK>_<n>` (the doctrine rule titles) are
|
|
103
111
|
// the first token names in the project to carry one, and without `0-9` here `{{DOC_CRAFT_1}}`
|
|
@@ -397,6 +405,12 @@ function readSource(cfg, p) {
|
|
|
397
405
|
return text;
|
|
398
406
|
}
|
|
399
407
|
|
|
408
|
+
/** A skill spec's id, `skills/<id>.md` (a `_` file is a partial, not a skill), else null. */
|
|
409
|
+
function skillIdOf(file) {
|
|
410
|
+
const stem = path.basename(file, '.md');
|
|
411
|
+
return path.basename(path.dirname(file)) === 'skills' && file.endsWith('.md') && !stem.startsWith('_') ? stem : null;
|
|
412
|
+
}
|
|
413
|
+
|
|
400
414
|
/**
|
|
401
415
|
* `_build_render.render_file`.
|
|
402
416
|
*
|
|
@@ -424,10 +438,23 @@ export function renderFile(cfg, filePath, theme, footprint = 'full', lawsPrefix
|
|
|
424
438
|
.replace(/\n+$/, ''); // `.rstrip("\n")`
|
|
425
439
|
});
|
|
426
440
|
|
|
441
|
+
// A skill's own id, for the notes path and the feedback tag its self-improvement include names
|
|
442
|
+
// (src/skills/_self-improvement.md): literal, so the model never guesses it from an alias it
|
|
443
|
+
// was run under. On the top-level file only, once the includes are flattened into it; any
|
|
444
|
+
// other file (the include itself, the template) keeps the `<name>` placeholder.
|
|
445
|
+
if (!visiting.size) text = text.replaceAll('{{SKILL_NAME}}', skillIdOf(here) ?? '<name>');
|
|
427
446
|
text = resolveCatalogs(text, nativeCatalog, cfg.excludeSkills ?? [], cfg);
|
|
428
447
|
text = resolveLean(text, footprint);
|
|
429
448
|
if (footprint === 'lean') text = leanVoice(text, cfg.src);
|
|
430
|
-
|
|
449
|
+
text = substitute(text, theme);
|
|
450
|
+
// D3 lives HERE, not in `renderAll`: every root file is rendered by this function, and the
|
|
451
|
+
// Claude/Bob emitters re-render the template with prefixed DIR_* tokens (`prefixedAgentText`)
|
|
452
|
+
// without going through `renderAll`'s items. Top-level template only; an include is flattened
|
|
453
|
+
// into it first.
|
|
454
|
+
if (!visiting.size && normcase(here) === normcase(path.resolve(cfg.src, 'AGENT.md.tmpl'))) {
|
|
455
|
+
text = dropCarrierCitations(cfg, text);
|
|
456
|
+
}
|
|
457
|
+
return text;
|
|
431
458
|
}
|
|
432
459
|
|
|
433
460
|
/** `_build_render._posture_body` / `_mode_body` — one helper, both registers. */
|
|
@@ -441,6 +468,15 @@ function registerBody(cfg, theme, dir, selected, fallback) {
|
|
|
441
468
|
return '';
|
|
442
469
|
}
|
|
443
470
|
|
|
471
|
+
/**
|
|
472
|
+
* The selected mode's body. Exported because it names `{{DIR_NOTEBOOK}}` paths: the root file's
|
|
473
|
+
* re-render with prefixed DIR_* tokens (`prefixedAgentText`, js/build/emit-claude.mjs) rebuilds
|
|
474
|
+
* it as it rebuilds KITS_BODY, or the Foreman ledger points at `notebook/` beside `.claude/`.
|
|
475
|
+
*/
|
|
476
|
+
export function modeBody(cfg, theme) {
|
|
477
|
+
return registerBody(cfg, theme, 'modes', cfg.mode ?? 'direct', 'direct');
|
|
478
|
+
}
|
|
479
|
+
|
|
444
480
|
/**
|
|
445
481
|
* The doctrine packs this build actually renders, in `PACK_ORDER` — and the two gates
|
|
446
482
|
* that stand between `cfg.doctrines` and a silently wrong AGENT.md.
|
|
@@ -526,6 +562,58 @@ function dropExcludedRules(text, pack, excluded) {
|
|
|
526
562
|
.join('');
|
|
527
563
|
}
|
|
528
564
|
|
|
565
|
+
/**
|
|
566
|
+
* A parenthetical made of rule citations only — `(*A*)`, `(*A*, *B*)` — with the blanks before
|
|
567
|
+
* it: spaces, and at most one line break, so a citation wrapped onto its own line leaves no
|
|
568
|
+
* orphaned punctuation at the start of the next.
|
|
569
|
+
*/
|
|
570
|
+
const CITE_GROUP_RE = /([ \t]*(?:\r?\n[ \t]*)?)\((\*[^*()\n]+\*(?:,[ \t]*\*[^*()\n]+\*)*)\)/g;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Remove the citations of excluded rules from rendered carrier text (owner decision D3,
|
|
574
|
+
* 2026-11-11: an excluded rule is OFF, so the text read every turn stops invoking it).
|
|
575
|
+
*
|
|
576
|
+
* ⚠ AFTER SUBSTITUTION, ON THE RENDERED TEXT, the opposite of `dropExcludedRules` and for the
|
|
577
|
+
* opposite reason: a citation renders as the rule's English principle in italics, identical in
|
|
578
|
+
* every voice (`resolveRuleIds`), so here the rendered form is the one literal, and a cited
|
|
579
|
+
* rule's include chain (template, mode, posture, packs) is already flat.
|
|
580
|
+
*
|
|
581
|
+
* Only a group whose every item is a rule name is touched. The doctor holds every carrier
|
|
582
|
+
* source to that shape (`citationGroupProblems`), so each removal leaves a sentence that still
|
|
583
|
+
* reads. A prose mention ("Where *X* refuses …") and a group with any other italic stay: the
|
|
584
|
+
* first binds nothing, the second may be plain emphasis. `offNames` empty is the identity, which
|
|
585
|
+
* keeps a build with no exclusion byte-identical.
|
|
586
|
+
* @param {string} text
|
|
587
|
+
* @param {Set<string>} offNames principle names of the excluded rules
|
|
588
|
+
* @param {Set<string>} allNames principle names of every rule in the canon
|
|
589
|
+
*/
|
|
590
|
+
export function dropExcludedCitations(text, offNames, allNames) {
|
|
591
|
+
if (!offNames.size) return text;
|
|
592
|
+
return text.replace(CITE_GROUP_RE, (whole, lead, inner) => {
|
|
593
|
+
const names = inner.match(/\*[^*]+\*/g).map((s) => s.slice(1, -1));
|
|
594
|
+
if (!names.every((n) => allNames.has(n))) return whole;
|
|
595
|
+
const kept = names.filter((n) => !offNames.has(n));
|
|
596
|
+
if (kept.length === names.length) return whole;
|
|
597
|
+
return kept.length ? `${lead}(${kept.map((n) => `*${n}*`).join(', ')})` : '';
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* `dropExcludedCitations` with this build's names: the excluded doctrine rules of
|
|
603
|
+
* `cfg.excludeRules`. The bundle's other files — the complete packs on disk included — never
|
|
604
|
+
* pass through here, so they keep every citation.
|
|
605
|
+
* @param {any} cfg
|
|
606
|
+
* @param {string} text
|
|
607
|
+
*/
|
|
608
|
+
function dropCarrierCitations(cfg, text) {
|
|
609
|
+
const offRules = new Set(cfg.excludeRules ?? []);
|
|
610
|
+
if (!offRules.size) return text;
|
|
611
|
+
const canonRules = ruleCanon(cfg.src).rules;
|
|
612
|
+
const offNames = new Set(canonRules.filter((r) => r.kind === 'DOCTRINE' && offRules.has(`${r.pack}.${r.n}`))
|
|
613
|
+
.map((r) => r.name));
|
|
614
|
+
return dropExcludedCitations(text, offNames, new Set(canonRules.map((r) => r.name)));
|
|
615
|
+
}
|
|
616
|
+
|
|
529
617
|
function doctrinesBody(cfg, theme, active, footprint, lawsPrefix) {
|
|
530
618
|
// At lean the section still carries the one pointer with no pack active: it names the laws too.
|
|
531
619
|
if (!active.length) return footprint === 'lean' ? briefPointer(theme, lawsPrefix, false) : '';
|
|
@@ -558,6 +646,9 @@ export function effectiveTheme(cfg, themeName, {
|
|
|
558
646
|
footprint = 'full', lawsPrefix = '', sharedRoot = null,
|
|
559
647
|
} = {}) {
|
|
560
648
|
const theme = { ...loadTheme(cfg, themeName), ...(cfg.structure ?? STRUCTURE) };
|
|
649
|
+
// Neither notes path takes `lawsPrefix`: the machine one is the tier's, and the project one is
|
|
650
|
+
// the project root's `notebook/` on every host. Prefixing it once sent OpenClaude's skills to
|
|
651
|
+
// `notebook/` while its hook wrote `.openclaude/notebook/` (T10).
|
|
561
652
|
Object.assign(theme, pathTokens(theme, sharedRoot));
|
|
562
653
|
// Empty without a tier, so a project emit and a default build stay byte-identical (the
|
|
563
654
|
// `EXCLUDED_SKILLS_LINE` contract). Each rides the end of a template line, so its value carries
|
|
@@ -570,7 +661,7 @@ export function effectiveTheme(cfg, themeName, {
|
|
|
570
661
|
+ 'holds this convention, and any fact\n> that landed here waits for the next emit to move it.'
|
|
571
662
|
: '';
|
|
572
663
|
theme.POSTURE_BODY = registerBody(cfg, theme, 'postures', cfg.posture ?? 'peer', 'peer');
|
|
573
|
-
theme.MODE_BODY =
|
|
664
|
+
theme.MODE_BODY = modeBody(cfg, theme);
|
|
574
665
|
// The loop skill's default trust preset (`--trust`), raw for `--preset` and capitalised for
|
|
575
666
|
// the `Default trust preset: **<Label>**` line `trustOfDir` reads back off an install.
|
|
576
667
|
theme.TRUST = cfg.trust ?? DEFAULT_PRESET;
|
|
@@ -581,6 +672,10 @@ export function effectiveTheme(cfg, themeName, {
|
|
|
581
672
|
// than two positional params keeps the existing two-arg call sites — every test, and
|
|
582
673
|
// `renderAll` — compiling unchanged, and defaults to the full text if a caller forgets.
|
|
583
674
|
const active = activeDoctrines(cfg);
|
|
675
|
+
// Consent Before Push under strict consent (`--strict-consent`): one sentence after the rule, at
|
|
676
|
+
// both footprints. Set before the doctrine body, which substitutes it.
|
|
677
|
+
theme.STRICT_CONSENT = cfg.ownBranchPass === false ? ' This install runs strict consent: every\n'
|
|
678
|
+
+ 'commit and push, your own branch included, needs the user\'s explicit acceptance.' : '';
|
|
584
679
|
theme.DOCTRINES_BODY = doctrinesBody(cfg, theme, active, footprint, lawsPrefix);
|
|
585
680
|
theme.DOCTRINES_LIST = active.length ? active.join(', ') : 'none';
|
|
586
681
|
// ⚠ EMITTED ONLY WHEN SOMETHING IS EXCLUDED, and that is not cosmetic. An unconditional
|
|
@@ -611,6 +706,9 @@ export function effectiveTheme(cfg, themeName, {
|
|
|
611
706
|
// The shared-tier marker, under the same contract (`sharedTierOfDir` reads it): written only when
|
|
612
707
|
// `on`, so a default build stays byte-identical. Not `GATE_SWITCHES`, which holds `--no-*` disarms.
|
|
613
708
|
theme.SHARED_TIER_LINE = cfg.sharedTier ? `\n${SHARED_TIER_LINE}\n` : '';
|
|
709
|
+
// `--context-window`, under the same contract (`contextWindowOfDir` reads it): a line only off the default.
|
|
710
|
+
theme.CONTEXT_WINDOW_LINE = cfg.contextWindow && cfg.contextWindow !== DEFAULT_CONTEXT_WINDOW
|
|
711
|
+
? `\n${CONTEXT_WINDOW_MARKER}: ${cfg.contextWindow}\n` : '';
|
|
614
712
|
// The gate switches (`GATE_SWITCHES`: Laws I, III, IV), under the same contract: a line is
|
|
615
713
|
// written only when its gate is OFF, so a default build stays byte-identical and a missing
|
|
616
714
|
// line reads back as armed (`gatesOfDir`). The OpenCode plugins read these lines at load, so
|
|
@@ -694,8 +792,12 @@ export function renderAll(cfg, themeName, {
|
|
|
694
792
|
// accident, which is a different thing from shipping whole by contract.
|
|
695
793
|
// Keyed on the SOURCE rel, not the themed one, so a DIR_* rename cannot un-exempt them.
|
|
696
794
|
const fp = /^(?:laws|ontology|doctrines)[\\/]/.test(rel) ? 'full' : footprint;
|
|
697
|
-
|
|
795
|
+
let text = TEXT_SUFFIXES.has(suffixOf(path.basename(file)))
|
|
698
796
|
? renderFile(cfg, file, theme, fp, lawsPrefix, new Set(), nativeCatalog) : null;
|
|
797
|
+
// A vendored skill's listed description is our catalogue line, on every host and in the
|
|
798
|
+
// bundle; here, once, so no writer applies it twice.
|
|
799
|
+
if (text !== null && sp[0] === 'skills' && sp.length === 3 && sp[2] === 'SKILL.md'
|
|
800
|
+
&& VENDORED_SKILL_DIRS.has(sp[1])) text = vendoredWithCatalogueLine(text, sp[1], cfg.src);
|
|
699
801
|
items.push({ rel: outRel, text, src: file });
|
|
700
802
|
// A credited skill ships its upstream's licence beside it, one copy per (skill, key). The
|
|
701
803
|
// token is gone from `text`, so the raw source is scanned; an unknown key or a null
|