geneseed 5.1.1 → 5.3.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 +52 -0
- package/README.md +2 -2
- package/SHIPPED.md +1 -1
- package/adapters/opencode/README.md +4 -3
- package/adapters/opencode/plugins/geneseed-context.js +82 -29
- package/adapters/opencode/plugins/geneseed-guard.js +118 -8
- package/bin/geneseed-cli.mjs +64 -16
- package/bin/geneseed-hook.mjs +37 -3
- package/docs/concepts/exclusions.md +1 -1
- package/docs/concepts/factories.md +40 -6
- package/docs/concepts/footprint.md +1 -1
- package/docs/concepts/foreman-mode.md +2 -2
- package/docs/concepts/host-matrix.md +1 -1
- package/docs/concepts/loop-gates.md +1 -1
- package/docs/concepts/loops.md +2 -2
- package/docs/concepts/shared-tier.md +1 -1
- package/docs/design-history.md +140 -0
- package/docs/extending.md +54 -162
- package/docs/guides/run-a-factory.md +15 -2
- package/docs/guides/setup-doctrines.md +1 -1
- package/docs/guides/upgrade.md +2 -2
- package/docs/reference/factory-actions.md +6 -5
- package/docs/reference/troubleshoot-update.md +1 -1
- package/docs/understand/enforced-vs-asked.md +1 -1
- package/docs/web-ui.md +16 -3
- package/harness.config.json +1 -1
- package/js/README.md +10 -7
- package/js/build/args.mjs +10 -4
- package/js/build/bundle.mjs +122 -23
- package/js/build/driver.mjs +32 -12
- package/js/build/emit-claude.mjs +2 -1
- package/js/build/emit-common.mjs +2 -2
- package/js/build/emit-opencode.mjs +22 -10
- package/js/build/export.mjs +431 -0
- package/js/build/generate.mjs +3 -0
- package/js/build/render.mjs +44 -24
- package/js/build/source.mjs +6 -1
- package/js/cli-table.json +232 -57
- package/js/factory/cli.mjs +24 -5
- package/js/factory/graph.mjs +13 -9
- package/js/factory/metrics.mjs +93 -0
- package/js/factory/registry.mjs +37 -12
- package/js/factory/state.mjs +25 -6
- package/js/hosts/hooks-context.mjs +26 -1
- package/js/hosts/hooks-done.mjs +8 -2
- package/js/hosts/hooks-prims.mjs +52 -3
- package/js/hosts/hooks.mjs +155 -33
- package/js/hosts/hosts.mjs +2 -4
- package/js/hosts/installs.mjs +28 -0
- package/js/hosts/loss.mjs +25 -3
- package/js/hosts/native.mjs +30 -2
- package/js/hosts/owned.mjs +55 -1
- package/js/hosts/ownership-gate.mjs +5 -5
- package/js/hosts/settings.mjs +83 -33
- package/js/inspect/diff.mjs +16 -1
- package/js/inspect/doctor.mjs +7 -3
- package/js/inspect/excludes.mjs +18 -6
- package/js/inspect/status.mjs +35 -7
- package/js/inspect/validate.mjs +44 -21
- package/js/lib/managed-block.mjs +74 -0
- package/js/maintain/uninstall.mjs +85 -15
- package/js/maintain/update.mjs +31 -7
- package/js/ui/cli.mjs +34 -4
- package/js/ui/menu.mjs +1 -1
- package/js/ui/tui.mjs +11 -14
- package/js/web/actions.mjs +5 -0
- package/js/web/api.mjs +32 -11
- package/js/web/daemon.mjs +0 -1
- package/js/web/server.mjs +1 -0
- package/js/web/state.mjs +37 -16
- package/package.json +1 -1
- package/src/AGENT.md.tmpl +23 -17
- package/src/agents/_template.md +1 -1
- package/src/agents/advocate.md +1 -1
- package/src/agents/developer.md +12 -3
- package/src/agents/empiricist.md +1 -1
- package/src/agents/framer.md +1 -1
- package/src/agents/historian.md +1 -1
- package/src/agents/operator.md +1 -1
- package/src/agents/pragmatist.md +1 -1
- package/src/agents/researcher.md +1 -1
- package/src/agents/skeptic.md +1 -1
- package/src/agents/steward.md +1 -1
- package/src/agents/user-advocate.md +1 -1
- package/src/agents/visionary.md +1 -1
- package/src/bricks/intake.md +10 -3
- package/src/bricks/retro.md +13 -3
- package/src/doctrines/comms.md +1 -1
- package/src/doctrines/ops.md +1 -1
- package/src/doctrines/process.md +7 -5
- package/src/factories/analysis-to-build.json +1 -0
- package/src/factories/bug-report-to-fix.json +1 -0
- package/src/factories/issue-to-pr.json +1 -0
- package/src/laws/universal.md +2 -2
- package/src/modes/foreman.md +8 -14
- package/src/skills/commit.md +7 -2
- package/src/skills/debug.md +1 -1
- package/src/skills/diagram-design/SKILL.md +1 -1
- package/src/skills/diagram-design/VENDOR.md +3 -1
- package/src/skills/factory-forge.md +5 -3
- package/src/skills/factory.md +22 -1
- package/src/skills/geneseed.md +1 -1
- package/src/skills/handoff.md +1 -1
- package/src/skills/parallel-agents.md +1 -1
- package/src/skills/pipeline.md +6 -6
- package/src/skills/plan.md +7 -3
- package/src/skills/spring-testing.md +1 -1
- package/themes/biker.json +78 -78
- package/themes/commentator.json +81 -81
- package/themes/cyberpunk.json +79 -79
- package/themes/gamer.json +77 -77
- package/themes/imperial.json +82 -82
- package/themes/joker.json +79 -79
- package/themes/marvin.json +82 -82
- package/themes/mean.json +82 -82
- package/themes/military.json +78 -78
- package/themes/neutral.json +78 -78
- package/themes/pirate.json +79 -79
- package/themes/sports.json +79 -79
- package/themes/verstappen.json +78 -78
- package/themes/wizard.json +79 -79
- package/web/dist/assets/ActiveLoops-BJJN3P-V.js +1 -0
- package/web/dist/assets/Activity-CqJiquEq.js +1 -0
- package/web/dist/assets/ActivityDetail-BSzevynX.js +1 -0
- package/web/dist/assets/{Bonsai-hiG_gGNU.js → Bonsai-Bfpb6W-1.js} +1 -1
- package/web/dist/assets/{CopyButton-DUIUfNp6.js → CopyButton-ByIntFtB.js} +1 -1
- package/web/dist/assets/Dashboard-DBOEi9lQ.js +2 -0
- package/web/dist/assets/Docs-DvlMJhpu.js +5 -0
- package/web/dist/assets/Factories-Bpvv7L2H.js +1 -0
- package/web/dist/assets/{GreenhouseView-BKxy5apE.js → GreenhouseView-GpBsYn50.js} +1 -1
- package/web/dist/assets/Installs-BlGmVrFK.js +3 -0
- package/web/dist/assets/{JournalView-ChFitHjo.js → JournalView-iLuLrOxE.js} +1 -1
- package/web/dist/assets/Kits-DRwpxC-J.js +1 -0
- package/web/dist/assets/Laws-CZkiNOWQ.js +4 -0
- package/web/dist/assets/LibRows-DEHjIoD-.js +1 -0
- package/web/dist/assets/Library-B4K-1iNF.js +3 -0
- package/web/dist/assets/Loops-BWSzaW8E.js +2 -0
- package/web/dist/assets/{OperatorHudView-BO0aIKPL.js → OperatorHudView-BAXwCEvY.js} +1 -1
- package/web/dist/assets/Personal-Bp9nV4GR.js +2 -0
- package/web/dist/assets/Settings-CWWuaIp-.js +1 -0
- package/web/dist/assets/Tabs-CWeQTADL.js +1 -0
- package/web/dist/assets/index-CsAZq0BQ.css +1 -0
- package/web/dist/assets/index-How7SzDZ.js +6 -0
- package/web/dist/assets/usePoll-D5c_qIFZ.js +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/ActiveLoops-BTHIaRhn.js +0 -1
- package/web/dist/assets/Activity-CpkBwpu7.js +0 -1
- package/web/dist/assets/ActivityDetail-DTPziZWM.js +0 -1
- package/web/dist/assets/Dashboard-Dnw6EyX7.js +0 -2
- package/web/dist/assets/Docs-BEET_l16.js +0 -5
- package/web/dist/assets/Factories-D6KXkfWw.js +0 -1
- package/web/dist/assets/Installs-CnFVlVD0.js +0 -3
- package/web/dist/assets/Kits-CcR-OlwQ.js +0 -1
- package/web/dist/assets/Laws-B1s5idOg.js +0 -4
- package/web/dist/assets/LibRows-BZgdbI1l.js +0 -1
- package/web/dist/assets/Library-x6TkkEVF.js +0 -3
- package/web/dist/assets/Loops-BH93KKxn.js +0 -2
- package/web/dist/assets/Personal-CE_0Vhh0.js +0 -2
- package/web/dist/assets/Settings-CbpZvVN_.js +0 -1
- package/web/dist/assets/Tabs-C2oW7oEj.js +0 -1
- package/web/dist/assets/index-BQwOmbor.js +0 -6
- package/web/dist/assets/index-CuIop_pO.css +0 -1
- package/web/dist/assets/usePoll-o8ul-Sog.js +0 -1
package/js/README.md
CHANGED
|
@@ -39,7 +39,7 @@ layers. These pairs import each other (relative imports between folders, measure
|
|
|
39
39
|
| build ↔ hosts | 24 / 5 | hosts reads `build/source.mjs` (`installs`, `link`, `native`, `opencode`) and `build/version.mjs` (`opencode`) |
|
|
40
40
|
| build ↔ inspect | 2 / 23 | `build/driver.mjs` records deploy roots in `inspect/registry.mjs`; `build/catalog.mjs` reads `inspect/inventory.mjs` |
|
|
41
41
|
| build ↔ loop | 4 / 1 | `loop/catalog.mjs` reads `build/source.mjs` |
|
|
42
|
-
| build ↔ ui | 2 /
|
|
42
|
+
| build ↔ ui | 2 / 2 | `ui/cli.mjs` reads `ROOT` from `build/source.mjs` and the generator's choice lists from `build/args.mjs` |
|
|
43
43
|
| build ↔ web | 1 / 9 | `build/generate.mjs` lazily imports `web/daemon.mjs` to restart a stale console after `rebuild-all` |
|
|
44
44
|
| hosts ↔ inspect | 1 / 36 | `hosts/installs.mjs` reads `inspect/registry.mjs`'s deploy roots |
|
|
45
45
|
| ui ↔ web | 1 / 1 | `ui/menu.mjs` starts the daemon; `web/docs.mjs` renders `ui/cli.mjs`'s CLI reference |
|
|
@@ -61,7 +61,7 @@ as a per-host install at project or global scope.
|
|
|
61
61
|
|---|---|
|
|
62
62
|
| `source.mjs` | Where the SOURCE is: `ROOT`/`SRC`/`THEMES`/`CONFIG`, `PACK_ORDER`, the rule canon (stable ids → positional numbers, citations → names), the cfg object |
|
|
63
63
|
| `render.mjs` | The pure text pipeline: theme load, `INCLUDE` inlining, CATALOG blocks, `{{TOKENS}}`, dest paths |
|
|
64
|
-
| `bundle.mjs` | `build` — render a theme into a bundle dir, plus the source-completeness refusal. Sits UNDER both emits |
|
|
64
|
+
| `bundle.mjs` | `build` — render a theme into a bundle dir, claim-on-create per file (an existing file it did not write is the user's), plus the source-completeness refusal. Sits UNDER both emits |
|
|
65
65
|
| `emit-claude.mjs` | The Claude/Bob/OpenClaude emit — the render half plus the settings + CLAUDE.md managed-block wire |
|
|
66
66
|
| `emit-opencode.mjs` | The OpenCode emits — a project's `.opencode/` and the global config dir. Deliberate twin of the above |
|
|
67
67
|
| `emit-common.mjs` | Constants, tree walkers, and the three writers BOTH global emits share. Decides no host |
|
|
@@ -74,6 +74,7 @@ as a per-host install at project or global scope.
|
|
|
74
74
|
| `args.mjs` | The generator's flag surface: `harness.config.json` defaults, the `--emit`/`--theme`/`--footprint` parse tables and choices, `-h`, and `die` (a throw, so `rebuild-all` survives one bad install) |
|
|
75
75
|
| `generate.mjs` | CLI verbs `build`, `prompt`, `theme`, `rebuild-all` — the thin face over `driver.mjs` |
|
|
76
76
|
| `catalog.mjs` | `geneseed catalog` — prints the shipped roster. Classifies nothing itself |
|
|
77
|
+
| `export.mjs` | `geneseed export` — skills, agents and the constitution as catalogue entities for a shared library (`SKILL.md`/`AGENT.md` + `metadata.yaml`), shaped by a profile kept outside the repo. One way, claim-on-create, not an install |
|
|
77
78
|
| `themes.mjs` | Maintainer-only `--sync-themes`: inserts `_TEMPLATE.json`'s missing keys into the committed themes |
|
|
78
79
|
|
|
79
80
|
**Before editing:** `render.mjs` writes nothing, and its output is what every emit target
|
|
@@ -109,12 +110,12 @@ user co-owns, and the hook verbs those emitted configs then run.
|
|
|
109
110
|
| `loss.mjs` | Law IV calibrated to real loss: `lossReason` decides whether a command would really lose data (protected branch, unpushed branch, dirty tree, stash, reflog, files git cannot restore) and fails closed. The gate path's one `git` spawn, reached only after `LOSS_CANDIDATE_RE` matched. Twin: the OpenCode guard plugin |
|
|
110
111
|
| `settings.mjs` | Merges into user-owned `settings.json`/`opencode.json` (one `loadJsonObject` reader for all of them) and the managed blocks |
|
|
111
112
|
| `shim.mjs` | The machine-wide hook shim: its path, body, liveness (`shimDead`, read on every CLI run), `hookPrefix`/`hookRunnerEntry`; and the web console's login launcher (`autostartState`/`autostartInstall`/`autostartRemove`). Kept cheap to import |
|
|
112
|
-
| `native.mjs` | Capability specs → host-native subagents and skills. The impure half of the emit |
|
|
113
|
+
| `native.mjs` | Capability specs → host-native subagents and skills. The impure half of the emit. `claimer`: claim-on-create, what an emit kept (`claim.kept`), and `--force` |
|
|
113
114
|
| `opencode.mjs` | OpenCode-only extras: colour themes, primary agent, `/commands`, plugins, overrides stub |
|
|
114
|
-
| `installs.mjs` | Detects deployed installs and reads back their theme, footprint, posture, mode and loop trust preset |
|
|
115
|
+
| `installs.mjs` | Detects deployed installs and reads back their theme, footprint, posture, mode and loop trust preset; `leftoversOf`, the files an install keeps that are not Geneseed's copy, read off the emit's record for the console |
|
|
115
116
|
| `mcp.mjs` | Reads each host's MCP config (`mcpServers`, or OpenCode's `mcp`) and where it lives — read-only since 2026-10: the user edits the file, Geneseed only shows it |
|
|
116
117
|
| `link.mjs` | `geneseed link`/`unlink` — the PATH shim, and the only Windows USER-Path registry edit |
|
|
117
|
-
| `owned.mjs` | Manifest rel -> path on disk decisions: `ownedWithin`, the containment boundary `uninstall.mjs` and the driver's prune both go through before acting on an `owned` list entry |
|
|
118
|
+
| `owned.mjs` | Manifest rel -> path on disk decisions: `ownedWithin`, the containment boundary `uninstall.mjs` and the driver's prune both go through before acting on an `owned` list entry; and `bundleFiles`, the list a bundle keeps of the files it wrote (in `.geneseed-srcdirs.json`), which the build's prune and the OpenCode project uninstall remove by |
|
|
118
119
|
|
|
119
120
|
**Before editing:** `hooks*.mjs` **are the hook path** — the verdict travels as JSON on stdout and
|
|
120
121
|
every arm exits 0, so one stray printed byte turns a blocking gate silently permissive, and anything
|
|
@@ -169,6 +170,7 @@ into files users have committed, so change the test that states it in the same c
|
|
|
169
170
|
| `udiff.mjs` | `geneseed diff`'s own difflib clone — the alignment IS the printed hunks — plus `splitLines` |
|
|
170
171
|
| `proc.mjs` | One constant: the `windowsHide` flag every spawn in `js/` must reuse |
|
|
171
172
|
| `prompt.mjs` | The line-mode stdin readers — `ask`, `promptLine`, `confirm`, `askChoice` — read a byte at a time so they stop where Enter stops. Shared by `setup`, `uninstall` and `web` without dragging in the wizard |
|
|
173
|
+
| `managed-block.mjs` | Where the `<!-- BEGIN/END GENESEED -->` block is in a co-owned file: whole-line markers, the first END with the last BEGIN above it. One definition for the writer (`settings.mjs`) and the hook-side readers; no imports, so the hook path may load it. The OpenCode plugins carry `BLOCK_RE_SOURCE` by value |
|
|
172
174
|
| `machine-dir.mjs` | `machineDir()`, `sharedPaths()`, `readDefaultInstall()` and `WIKI_NAMES`: the one home of `$XDG_CONFIG_HOME/geneseed`, the names beneath it, the reader of the chosen default install, and the wiki manifest's names. Spawn-free, so the hook and driver may import it |
|
|
173
175
|
| `node-floor.mjs` | The first import of all three binaries: below Node 22.7, one sentence on stderr and exit 1 (0 in the hook) instead of a stack trace |
|
|
174
176
|
|
|
@@ -215,8 +217,9 @@ brick or a whole loop; a fork's named outcomes pick its lane), persisted as a JS
|
|
|
215
217
|
|---|---|
|
|
216
218
|
| `graph.mjs` | `checkFactory` — the rules a factory must satisfy before a stage runs: stages exist, edges cover every outcome, `$close` is reachable, every cycle is declared (the loop engine's `undeclaredCycles`), `$lane` only behind a fork, `protected` a list of paths, and every `review.seats` entry a shipped agent. Also the fork helpers the engine shares: `isFork`, `lanesOf`, `laneTargets`, `spentCycle` |
|
|
217
219
|
| `state.mjs` | The engine itself: `initFactory`, `nextStage`, `recordStage`, `decideFactory`, `renderFactoryFile`/`parseFactoryFile`, `validateFactoryState`, `countSpecTasks` |
|
|
218
|
-
| `
|
|
219
|
-
| `
|
|
220
|
+
| `metrics.mjs` | `runMetrics(state, { now })` — pure: per stage its runs, reworks, work time and tokens, and per run its work time, waiting time, the wait still open at a held gate (to `now`, which the caller reads), tokens and transitions, from the history's `at` stamps. Unknown is `null`, never 0. The one writer of those numbers: `factory report` prints it, and the console reads it through `registry.mjs` |
|
|
221
|
+
| `cli.mjs` | `geneseed factory check\|list\|init\|next\|record\|decide\|report` — the only face of this engine. It reads the clock; the engine stays pure |
|
|
222
|
+
| `registry.mjs` | `factories.json` beside `loops.json`: `recordFactory` (called by `factory init`, and the one place the registry is swept and pruned), `listFactories` (the console's read-only rows, each live row with its `metrics`), on the loop registry's own `loadRows`/`saveRows`/`sweepRows`. A run and its child loop share a root, which is how a reader groups them |
|
|
220
223
|
|
|
221
224
|
**Before editing:** `FACTORY.md` is in `js/loop/state.mjs`'s `ENGINE_FILES`, so a child loop never
|
|
222
225
|
scores it; the clean-tree check after a stage outside a loop filters with that same list. `cli.mjs`
|
package/js/build/args.mjs
CHANGED
|
@@ -99,19 +99,25 @@ export function configDefaults(config = CONFIG, rules = ruleCanon(SRC).rules) {
|
|
|
99
99
|
* own private copy of the flags is a second source that drifts silently the first time a
|
|
100
100
|
* flag is added to one and not the other, and nothing downstream would say so.
|
|
101
101
|
*/
|
|
102
|
-
const VALUED = {
|
|
102
|
+
export const VALUED = {
|
|
103
103
|
'--theme': 'theme', '--posture': 'posture', '--mode': 'mode', '--trust': 'trust',
|
|
104
104
|
'--doctrines': 'doctrines', '--exclude-rules': 'excludeRules', '--exclude-skills': 'excludeSkills',
|
|
105
105
|
'--kits': 'kits', '--shared-tier': 'sharedTier',
|
|
106
106
|
'--out': 'out', '--target': 'out', '--emit': 'emit',
|
|
107
107
|
'--footprint': 'footprint', '--root': 'root', '--config-dir': 'cfgDir',
|
|
108
108
|
};
|
|
109
|
-
const FLAGS = {
|
|
109
|
+
export const FLAGS = {
|
|
110
110
|
'--sync-themes': 'syncThemes', '--validate-only': 'validateOnly',
|
|
111
111
|
// The gate switches (`GATE_SWITCHES`, law order). No `harness.config.json` key feeds them,
|
|
112
112
|
// deliberately: a rebuild elides a flag when armed, so a config default could disarm an armed
|
|
113
113
|
// install on its next upgrade.
|
|
114
114
|
...Object.fromEntries(GATE_SWITCHES.map((g) => [g.flag, g.arg])),
|
|
115
|
+
// One-shot, so no marker and no rebuild replays it: take back the OpenCode `permission.bash`
|
|
116
|
+
// gates whose rule is off, on an install older than the `bash_gates` record.
|
|
117
|
+
'--prune-gates': 'pruneGates',
|
|
118
|
+
// One build's instruction, never recorded: Geneseed's copy replaces a file the user edited
|
|
119
|
+
// or put at a name Geneseed ships. `claimer` (js/hosts/native.mjs) holds the rule.
|
|
120
|
+
'--force': 'force',
|
|
115
121
|
'-v': 'verbose', '--verbose': 'verbose',
|
|
116
122
|
};
|
|
117
123
|
|
|
@@ -149,7 +155,7 @@ const FLAG_BY_NAME = Object.fromEntries(
|
|
|
149
155
|
* advertised a metavar that lies. It is validated by `parseDoctrines` instead and prints the
|
|
150
156
|
* plain `DOCTRINES` metavar, exactly as `--theme` (also open-ended) already does.
|
|
151
157
|
*/
|
|
152
|
-
function choicesFor() {
|
|
158
|
+
export function choicesFor() {
|
|
153
159
|
return {
|
|
154
160
|
'--emit': EMITS,
|
|
155
161
|
'--footprint': ['lean', 'full'],
|
|
@@ -368,7 +374,7 @@ export function parseArgs(argv, defaults) {
|
|
|
368
374
|
kits: defaults.kits ?? [],
|
|
369
375
|
sharedTier: 'off',
|
|
370
376
|
out: 'Harness', emit: 'files', footprint: 'lean', root: null,
|
|
371
|
-
syncThemes: false, validateOnly: false, verbose: false,
|
|
377
|
+
syncThemes: false, validateOnly: false, verbose: false, pruneGates: false, force: false,
|
|
372
378
|
...Object.fromEntries(GATE_SWITCHES.map((g) => [g.arg, false])),
|
|
373
379
|
};
|
|
374
380
|
const { tokens } = nodeParseArgs({
|
package/js/build/bundle.mjs
CHANGED
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import path from 'node:path';
|
|
14
14
|
import { VERSION_MARKER } from '../hosts/hosts.mjs';
|
|
15
|
+
import { BUNDLE_FILES_KEY, bundleFiles, ownedWithin } from '../hosts/owned.mjs';
|
|
15
16
|
import { migrateMemoryIndex } from '../hosts/memory-files.mjs';
|
|
16
|
-
import { copyFile,
|
|
17
|
+
import { copyFile, isFile, readText, writeText } from '../lib/fs.mjs';
|
|
17
18
|
import { jsonDumpsIndent, parseJson, formatReprAscii, isTruthy } from '../lib/json.mjs';
|
|
18
19
|
import { OWNED_SRC_DIRS, SRC_DIRS_MARKER, TMPL_SPEC_RE } from './emit-common.mjs';
|
|
19
20
|
import { SRC_DIR_TOKENS, renderAll } from './render.mjs';
|
|
@@ -21,8 +22,12 @@ import {
|
|
|
21
22
|
ensureBundleGitignore, ensureContextStub, ensureMemoryIndex, ensureNotebookIndex,
|
|
22
23
|
ensureProfileStub, ensureRulesStub, ensureWikiStub,
|
|
23
24
|
} from './stubs.mjs';
|
|
25
|
+
import { retiredSkillNames, skillLabels } from './retired-skills.mjs';
|
|
26
|
+
import { skillAliases } from './source.mjs';
|
|
24
27
|
import { writeVersion } from './version.mjs';
|
|
25
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
existsSync, mkdirSync, readdirSync, renameSync, rmdirSync, unlinkSync,
|
|
30
|
+
} from 'node:fs';
|
|
26
31
|
|
|
27
32
|
/**
|
|
28
33
|
* Seed the memory index, then move a flat one to topics — the pair every emit runs on its
|
|
@@ -94,13 +99,53 @@ function readPriorSrcDirs(out) {
|
|
|
94
99
|
return data && typeof data === 'object' && !Array.isArray(data) ? data : {};
|
|
95
100
|
}
|
|
96
101
|
|
|
97
|
-
/**
|
|
98
|
-
|
|
102
|
+
/**
|
|
103
|
+
* `_build_render._write_src_dirs_marker` — temp + replace. `files` rides in the same marker:
|
|
104
|
+
* every rel this build wrote, the stores apart (see `build`).
|
|
105
|
+
*/
|
|
106
|
+
function writeSrcDirsMarker(out, resolved, files, extra = {}) {
|
|
99
107
|
const tmp = path.join(out, `${SRC_DIRS_MARKER}.tmp`);
|
|
100
|
-
writeText(tmp, `${jsonDumpsIndent(resolved)}\n`);
|
|
108
|
+
writeText(tmp, `${jsonDumpsIndent({ ...resolved, [BUNDLE_FILES_KEY]: files, ...extra })}\n`);
|
|
101
109
|
renameSync(tmp, path.join(out, SRC_DIRS_MARKER));
|
|
102
110
|
}
|
|
103
111
|
|
|
112
|
+
/**
|
|
113
|
+
* The retired skills still lying in a bundle's skills dir that no record owns: `<name>.md`
|
|
114
|
+
* where the name is one Geneseed shipped and no longer does, and the file carries the render's
|
|
115
|
+
* `# <Skill label>: <id>` heading outside a code fence, the flat twin of `isRendered`
|
|
116
|
+
* (`./retired-skills.mjs`). A retired name is a plain word, so a file under one may be the
|
|
117
|
+
* user's own; the heading is what tells them apart.
|
|
118
|
+
*
|
|
119
|
+
* This is the leftover of a bundle an older build rendered, which kept no file list: the build
|
|
120
|
+
* that starts the list cannot know what its predecessor wrote, so it leaves such a file, names
|
|
121
|
+
* it, and records it as `stale`. `--force` removes it.
|
|
122
|
+
*/
|
|
123
|
+
function staleRetired(out, skillsDirname, shipped, mine, aliases) {
|
|
124
|
+
const labels = skillLabels();
|
|
125
|
+
const found = [];
|
|
126
|
+
for (const name of retiredSkillNames({ aliases })) {
|
|
127
|
+
const rel = `${skillsDirname}/${name}.md`;
|
|
128
|
+
if (shipped.has(rel) || mine?.has(rel)) continue;
|
|
129
|
+
let text;
|
|
130
|
+
try { text = readText(path.join(out, rel)); } catch { continue; }
|
|
131
|
+
const ids = new Set([name, aliases.get(name)].filter(Boolean));
|
|
132
|
+
let fenced = false;
|
|
133
|
+
for (const line of text.split('\n')) {
|
|
134
|
+
if (/^\s*(```|~~~)/.test(line)) { fenced = !fenced; continue; }
|
|
135
|
+
const h = fenced ? null : /^# (.+?): (\S+)\s*$/.exec(line);
|
|
136
|
+
if (h && labels.has(h[1]) && ids.has(h[2])) { found.push(rel); break; }
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return found;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Remove now-empty directories from `dir` up to, never including, `out`. */
|
|
143
|
+
function pruneEmptyDirs(dir, out) {
|
|
144
|
+
for (let d = dir; d !== out && d.startsWith(out + path.sep); d = path.dirname(d)) {
|
|
145
|
+
try { if (readdirSync(d).length) return; rmdirSync(d); } catch { return; }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
104
149
|
/**
|
|
105
150
|
* The guard on the prune of a RENAMED owned dir — `build`'s one destructive path driven
|
|
106
151
|
* by file content rather than by code.
|
|
@@ -171,16 +216,19 @@ export function build(cfg, themeName, out, { footprint = 'full', nativeCatalog =
|
|
|
171
216
|
assertSourceComplete(cfg, `theme '${themeName}'`);
|
|
172
217
|
mkdirSync(out, { recursive: true });
|
|
173
218
|
|
|
174
|
-
//
|
|
175
|
-
//
|
|
219
|
+
// Ownership is per file — `bundleFiles` says why. `mine` is what the previous build wrote
|
|
220
|
+
// here, or null when there is no record (a first render, or an older build's bundle).
|
|
176
221
|
const isBundle = isFile(path.join(out, '.geneseed-theme')) || isFile(path.join(out, VERSION_MARKER));
|
|
177
222
|
const priorSrcDirs = isBundle ? readPriorSrcDirs(out) : {};
|
|
223
|
+
const prior = isBundle ? bundleFiles(out) : null;
|
|
224
|
+
const mine = prior && new Set(prior);
|
|
178
225
|
const resolvedSrcDirs = {};
|
|
226
|
+
const ownedNames = new Set();
|
|
179
227
|
for (const srcDir of OWNED_SRC_DIRS) {
|
|
180
228
|
// `??` falls back on an explicit JSON null too. No theme has one.
|
|
181
229
|
const dirname = theme[SRC_DIR_TOKENS[srcDir]] ?? srcDir;
|
|
182
230
|
resolvedSrcDirs[srcDir] = dirname;
|
|
183
|
-
|
|
231
|
+
ownedNames.add(dirname);
|
|
184
232
|
|
|
185
233
|
// `isTruthy`, not `priorName &&`: the marker is user-editable JSON, and an
|
|
186
234
|
// empty `[]`, `{}` or `0` must count as absent although JS's `&&` treats the first two
|
|
@@ -188,44 +236,95 @@ export function build(cfg, themeName, out, { footprint = 'full', nativeCatalog =
|
|
|
188
236
|
// only from a hand-edited file, which is the one place nobody would look for it.
|
|
189
237
|
const priorName = priorSrcDirs[srcDir];
|
|
190
238
|
if (isBundle && isTruthy(priorName) && priorName !== dirname) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
} else {
|
|
239
|
+
// A theme renamed the dir: the old name's recorded files go in the prune below.
|
|
240
|
+
if (safePriorDirName(out, priorName)) ownedNames.add(priorName);
|
|
241
|
+
else {
|
|
195
242
|
process.stderr.write('[geneseed] WARN: ignoring suspicious prior dir name '
|
|
196
243
|
+ `${formatReprAscii(priorName)} recorded in ${SRC_DIRS_MARKER} - not pruned.\n`);
|
|
197
244
|
}
|
|
198
245
|
}
|
|
246
|
+
}
|
|
199
247
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
248
|
+
// The prune: a recorded file under an owned dir that this render no longer ships. Before the
|
|
249
|
+
// writes, as the whole-dir wipe it replaces was, so a rel that changed only in case is not
|
|
250
|
+
// deleted after being written on a case-insensitive disk. `ownedWithin` contains the rels:
|
|
251
|
+
// the marker is a file a user can edit.
|
|
252
|
+
const shipped = new Set(items.map(({ rel }) => rel));
|
|
253
|
+
for (const rel of ownedWithin(out, (prior ?? []).filter((r) => !shipped.has(r)))) {
|
|
254
|
+
if (!ownedNames.has(rel.split('/')[0])) continue;
|
|
255
|
+
const victim = path.join(out, rel);
|
|
256
|
+
try {
|
|
257
|
+
if (isFile(victim)) { unlinkSync(victim); pruneEmptyDirs(path.dirname(victim), out); }
|
|
258
|
+
} catch (e) {
|
|
259
|
+
process.stderr.write(`[geneseed] WARN: could not remove stale ${rel} (${e.message})\n`);
|
|
208
260
|
}
|
|
209
261
|
}
|
|
210
262
|
|
|
211
263
|
const nbDirname = theme[SRC_DIR_TOKENS.notebook] ?? 'notebook';
|
|
264
|
+
const memDirname = theme[SRC_DIR_TOKENS.memory] ?? 'memory';
|
|
265
|
+
const written = [];
|
|
266
|
+
const yours = [];
|
|
267
|
+
const replaced = [];
|
|
268
|
+
const force = cfg.force === true;
|
|
212
269
|
for (const { rel, text, src } of items) {
|
|
213
270
|
const dest = path.join(out, rel);
|
|
214
|
-
mkdirSync(path.dirname(dest), { recursive: true });
|
|
215
271
|
// The notebook is the agent's sovereign space: seeded files are written once and
|
|
216
272
|
// never re-emitted, so the agent may rewrite its own rules. Only `.gitignore` is
|
|
217
273
|
// re-asserted — the one law it cannot lift.
|
|
218
274
|
const parts = rel.split('/');
|
|
219
|
-
|
|
275
|
+
const there = existsSync(dest);
|
|
276
|
+
if (parts[0] === nbDirname && path.basename(rel) !== '.gitignore' && there) {
|
|
220
277
|
continue;
|
|
221
278
|
}
|
|
279
|
+
// The two stores stand outside the claim and the record: their seeds are rewritten as
|
|
280
|
+
// before, and nothing in them is ever removed, by a build or by an uninstall.
|
|
281
|
+
const store = parts[0] === nbDirname || parts[0] === memDirname;
|
|
282
|
+
// Claim-on-create. With a record, only a recorded file is overwritten. Without one, an
|
|
283
|
+
// older build's bundle is overwritten as that build did, and in a folder that is no
|
|
284
|
+
// bundle at all an existing file is the user's.
|
|
285
|
+
// `--force` takes Geneseed's copy instead, and says which files it replaced.
|
|
286
|
+
if (there && !store && !(mine ? mine.has(rel) : isBundle)) {
|
|
287
|
+
if (!force) { yours.push(rel); continue; }
|
|
288
|
+
replaced.push(rel);
|
|
289
|
+
}
|
|
290
|
+
mkdirSync(path.dirname(dest), { recursive: true });
|
|
222
291
|
if (text !== null) writeText(dest, text);
|
|
223
292
|
else copyFile(src, dest);
|
|
293
|
+
if (!store) written.push(rel);
|
|
294
|
+
}
|
|
295
|
+
const shown = (rels) => rels.slice(0, 5).join(', ') + (rels.length > 5 ? `, and ${rels.length - 5} more` : '');
|
|
296
|
+
if (replaced.length) {
|
|
297
|
+
process.stdout.write(`[geneseed] --force: replaced ${replaced.length} existing file(s) in ${out}: `
|
|
298
|
+
+ `${shown(replaced)}.\n`);
|
|
299
|
+
}
|
|
300
|
+
let stale = staleRetired(out, resolvedSrcDirs.skills, shipped, mine, skillAliases(cfg.src));
|
|
301
|
+
if (stale.length && force) {
|
|
302
|
+
for (const rel of ownedWithin(out, stale)) {
|
|
303
|
+
try { unlinkSync(path.join(out, rel)); } catch { /* still there: named again next build */ }
|
|
304
|
+
}
|
|
305
|
+
process.stdout.write(`[geneseed] --force: removed ${stale.length} retired file(s) an older build `
|
|
306
|
+
+ `left in ${out}: ${shown(stale)}.\n`);
|
|
307
|
+
stale = stale.filter((rel) => existsSync(path.join(out, rel)));
|
|
308
|
+
} else if (stale.length) {
|
|
309
|
+
process.stdout.write(`[geneseed] WARN: ${stale.length} file(s) in ${out} are skills an older build `
|
|
310
|
+
+ `shipped and this one retired: ${shown(stale)}. They were left in place; rebuild with `
|
|
311
|
+
+ '--force to remove them.\n');
|
|
312
|
+
}
|
|
313
|
+
if (yours.length) {
|
|
314
|
+
// STDOUT, and ASCII-only: this print crashed with UnicodeEncodeError on a cp1252
|
|
315
|
+
// Windows console when it carried a warning-sign emoji.
|
|
316
|
+
process.stdout.write(`[geneseed] WARN: kept ${yours.length} existing file(s) Geneseed did not `
|
|
317
|
+
+ `write in ${out}, and skipped its own copy of each: ${shown(yours)}. Move one aside and `
|
|
318
|
+
+ 'rebuild to get Geneseed\'s copy, or rebuild with --force to replace them all.\n');
|
|
224
319
|
}
|
|
225
320
|
|
|
226
321
|
writeText(path.join(out, '.geneseed-theme'), `${themeName}\n`);
|
|
227
322
|
writeVersion(cfg, out);
|
|
228
|
-
|
|
323
|
+
// `kept` and `stale` only when there is one: a clean bundle's marker carries neither.
|
|
324
|
+
writeSrcDirsMarker(out, resolvedSrcDirs, written.sort(), {
|
|
325
|
+
...(yours.length ? { kept: yours.sort() } : {}),
|
|
326
|
+
...(stale.length ? { stale: stale.sort() } : {}),
|
|
327
|
+
});
|
|
229
328
|
ensureContextStub(out);
|
|
230
329
|
ensureWikiStub(out);
|
|
231
330
|
ensureRulesStub(out);
|
package/js/build/driver.mjs
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
openclaudeConfigDir, hostCatalogsNatively,
|
|
52
52
|
} from '../hosts/hosts.mjs';
|
|
53
53
|
import {
|
|
54
|
-
hashesOf, ownedHashes, ownedState, ownedWithin, recordedDenies, recordedEdit, editRecordKeys,
|
|
54
|
+
hashesOf, ownedHashes, ownedState, ownedWithin, recordedDenies, recordedEdit, recordedGates, editRecordKeys,
|
|
55
55
|
} from '../hosts/owned.mjs';
|
|
56
56
|
import { seedProtectedChecks } from '../hosts/geneseed-dir.mjs';
|
|
57
57
|
|
|
@@ -214,8 +214,11 @@ function writeManifestAtomic(file, data) {
|
|
|
214
214
|
* your edited... delete it to get Geneseed's copy back": two warnings about one rel that is in
|
|
215
215
|
* fact still shipped. Excluded from `stale` before anything is checked or printed — silently,
|
|
216
216
|
* because `claimer` already said everything there is to say about it.
|
|
217
|
+
*
|
|
218
|
+
* `force` (`--force`): an edited stale rel is removed too, and named. It was Geneseed's file and
|
|
219
|
+
* Geneseed no longer ships it, which is the leftover the flag exists to clear.
|
|
217
220
|
*/
|
|
218
|
-
function pruneOwned(oc, oldOwned, owned, oldHashes = {}, editRefused = []) {
|
|
221
|
+
function pruneOwned(oc, oldOwned, owned, oldHashes = {}, editRefused = [], force = false) {
|
|
219
222
|
const now = new Set(owned);
|
|
220
223
|
const alreadyWarned = new Set(editRefused);
|
|
221
224
|
const stale = [...new Set(oldOwned)]
|
|
@@ -223,8 +226,11 @@ function pruneOwned(oc, oldOwned, owned, oldHashes = {}, editRefused = []) {
|
|
|
223
226
|
const failed = [];
|
|
224
227
|
for (const rel of ownedWithin(oc, stale)) {
|
|
225
228
|
if (ownedState(oc, rel, oldHashes) === 'modified') {
|
|
226
|
-
|
|
227
|
-
|
|
229
|
+
if (!force) {
|
|
230
|
+
process.stderr.write(`[geneseed] kept your edited ${rel} (no longer shipped)\n`);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
process.stderr.write(`[geneseed] --force: removed your edited ${rel} (no longer shipped)\n`);
|
|
228
234
|
}
|
|
229
235
|
const victim = path.join(oc, rel);
|
|
230
236
|
try {
|
|
@@ -246,6 +252,13 @@ function pruneOwned(oc, oldOwned, owned, oldHashes = {}, editRefused = []) {
|
|
|
246
252
|
}
|
|
247
253
|
}
|
|
248
254
|
|
|
255
|
+
/**
|
|
256
|
+
* The manifest's `kept` key: the rels this emit left to the user where it ships a file of its
|
|
257
|
+
* own (`claim.kept`). Written only when there is one, so a clean install's manifest is unchanged.
|
|
258
|
+
* `keptFilesOf` (js/hosts/installs.mjs) is the reader, for the console.
|
|
259
|
+
*/
|
|
260
|
+
const keptKey = (kept) => (kept && kept.length ? { kept: [...kept].sort() } : {});
|
|
261
|
+
|
|
249
262
|
/**
|
|
250
263
|
* Whether this PROJECT emit seeds `<git root>/.geneseed/protected-checks.txt`. A real emit does;
|
|
251
264
|
* a sandbox emit must not, because the seed walks UP to the git root and a sandbox under a temp
|
|
@@ -319,6 +332,7 @@ function emitOpencode(cfg, args, out) {
|
|
|
319
332
|
const oldOwned = (doc && doc.owned) || [];
|
|
320
333
|
const oldDenies = recordedDenies(doc);
|
|
321
334
|
const oldEdit = recordedEdit(doc);
|
|
335
|
+
const oldGates = recordedGates(doc);
|
|
322
336
|
const oldHashes = hashesOf(doc);
|
|
323
337
|
|
|
324
338
|
const agentPathRel = relUnder(out, root);
|
|
@@ -331,14 +345,14 @@ function emitOpencode(cfg, args, out) {
|
|
|
331
345
|
{
|
|
332
346
|
theme: args.theme, out, root, footprint: args.footprint,
|
|
333
347
|
nativeCatalog: hostCatalogsNatively('opencode'), oldOwned, manifestExisted, agentPath,
|
|
334
|
-
oldDenies, oldEdit, oldHashes,
|
|
348
|
+
oldDenies, oldEdit, oldHashes, oldGates,
|
|
335
349
|
});
|
|
336
|
-
const { owned, stats, cfgName, skillDenies, editRecord, editRefused } = rendered;
|
|
350
|
+
const { owned, stats, cfgName, skillDenies, editRecord, editRefused, bashGates, kept } = rendered;
|
|
337
351
|
// Seed once: absent -> created, then the user's (never recorded, rewritten or removed).
|
|
338
352
|
if (seeds(args)) seedProtectedChecks(root);
|
|
339
353
|
|
|
340
354
|
phaseLog('PRUNE');
|
|
341
|
-
pruneOwned(oc, oldOwned, owned, oldHashes, editRefused);
|
|
355
|
+
pruneOwned(oc, oldOwned, owned, oldHashes, editRefused, cfg.force);
|
|
342
356
|
|
|
343
357
|
phaseLog('MANIFEST');
|
|
344
358
|
writeManifestAtomic(manifestPath, {
|
|
@@ -347,9 +361,11 @@ function emitOpencode(cfg, args, out) {
|
|
|
347
361
|
+ 'list is yours and is never touched.',
|
|
348
362
|
owned: [...owned].sort(),
|
|
349
363
|
hashes: ownedHashes(oc, owned),
|
|
364
|
+
...keptKey(kept),
|
|
350
365
|
scope: 'project',
|
|
351
366
|
...(skillDenies.length ? { skill_denies: skillDenies } : {}),
|
|
352
367
|
...editRecordKeys(editRecord),
|
|
368
|
+
...(bashGates.length ? { bash_gates: bashGates } : {}),
|
|
353
369
|
});
|
|
354
370
|
|
|
355
371
|
const extra = extrasTail(stats);
|
|
@@ -384,6 +400,7 @@ function emitOpencodeGlobal(cfg, args, out) {
|
|
|
384
400
|
const oldOwned = (doc && doc.owned) || [];
|
|
385
401
|
const oldDenies = recordedDenies(doc);
|
|
386
402
|
const oldEdit = recordedEdit(doc);
|
|
403
|
+
const oldGates = recordedGates(doc);
|
|
387
404
|
const oldHashes = hashesOf(doc);
|
|
388
405
|
|
|
389
406
|
const agentPath = path.join(cfgDir, 'AGENT.md').split(path.sep).join('/');
|
|
@@ -393,12 +410,12 @@ function emitOpencodeGlobal(cfg, args, out) {
|
|
|
393
410
|
{
|
|
394
411
|
theme: args.theme, cfgDir, out, sharedRoot: args.sharedRoot,
|
|
395
412
|
footprint: args.footprint, nativeCatalog: hostCatalogsNatively('opencode'),
|
|
396
|
-
oldOwned, agentPath, oldDenies, oldEdit, oldHashes,
|
|
413
|
+
oldOwned, agentPath, oldDenies, oldEdit, oldHashes, oldGates,
|
|
397
414
|
});
|
|
398
|
-
const { owned, stats, memStatus, nbStatus, cfgName, skillDenies, editRecord, editRefused } = rendered;
|
|
415
|
+
const { owned, stats, memStatus, nbStatus, cfgName, skillDenies, editRecord, editRefused, bashGates, kept } = rendered;
|
|
399
416
|
|
|
400
417
|
phaseLog('PRUNE');
|
|
401
|
-
pruneOwned(cfgDir, oldOwned, owned, oldHashes, editRefused);
|
|
418
|
+
pruneOwned(cfgDir, oldOwned, owned, oldHashes, editRefused, cfg.force);
|
|
402
419
|
|
|
403
420
|
phaseLog('MANIFEST');
|
|
404
421
|
writeManifestAtomic(manifestPath, {
|
|
@@ -407,8 +424,10 @@ function emitOpencodeGlobal(cfg, args, out) {
|
|
|
407
424
|
+ 'stores are NOT listed — they are never deleted.',
|
|
408
425
|
owned: [...owned].sort(),
|
|
409
426
|
hashes: ownedHashes(cfgDir, owned),
|
|
427
|
+
...keptKey(kept),
|
|
410
428
|
...(skillDenies.length ? { skill_denies: skillDenies } : {}),
|
|
411
429
|
...editRecordKeys(editRecord),
|
|
430
|
+
...(bashGates.length ? { bash_gates: bashGates } : {}),
|
|
412
431
|
});
|
|
413
432
|
|
|
414
433
|
const extra = extrasTail(stats);
|
|
@@ -450,12 +469,12 @@ function emitClaudeCore(cfg, args, { cfgDir, claudeMd, scope, host, out, hookOpt
|
|
|
450
469
|
oldOwned, oldManaged, preambleExclude: preambleExclude(claudeMd, host),
|
|
451
470
|
hookOpts, oldHashes,
|
|
452
471
|
});
|
|
453
|
-
const { owned, stats, memStatus, nbStatus, managed, editRefused } = rendered;
|
|
472
|
+
const { owned, stats, memStatus, nbStatus, managed, editRefused, kept } = rendered;
|
|
454
473
|
// `root` is null on a global emit: it has no project to seed.
|
|
455
474
|
if (root && seeds(args)) seedProtectedChecks(root);
|
|
456
475
|
|
|
457
476
|
phaseLog('PRUNE');
|
|
458
|
-
pruneOwned(cfgDir, oldOwned, owned, oldHashes, editRefused);
|
|
477
|
+
pruneOwned(cfgDir, oldOwned, owned, oldHashes, editRefused, cfg.force);
|
|
459
478
|
|
|
460
479
|
phaseLog('MANIFEST');
|
|
461
480
|
writeManifestAtomic(manifestPath, {
|
|
@@ -466,6 +485,7 @@ function emitClaudeCore(cfg, args, { cfgDir, claudeMd, scope, host, out, hookOpt
|
|
|
466
485
|
+ 'hooks so uninstall removes exactly those.',
|
|
467
486
|
owned: [...owned].sort(),
|
|
468
487
|
hashes: ownedHashes(cfgDir, owned),
|
|
488
|
+
...keptKey(kept),
|
|
469
489
|
managed,
|
|
470
490
|
scope,
|
|
471
491
|
});
|
package/js/build/emit-claude.mjs
CHANGED
|
@@ -127,7 +127,7 @@ export function emitClaudeRender(cfg, job) {
|
|
|
127
127
|
// prints once across the whole emit rather than once per writer.
|
|
128
128
|
// Before the claim: a retired folder freed here lets this emit write the alias that replaces it.
|
|
129
129
|
if (sharedRoot !== null) pruneRetiredSkills(host, cfgDir, oldOwned);
|
|
130
|
-
const claim = claimer(oldOwned, cfgDir, true, oldHashes);
|
|
130
|
+
const claim = claimer(oldOwned, cfgDir, true, oldHashes, cfg.force);
|
|
131
131
|
const { nAgents, nSkills, written } = writeNativeLayer(
|
|
132
132
|
items, path.join(cfgDir, 'agents'), path.join(cfgDir, 'skills'),
|
|
133
133
|
loadAgentOverrides(cfgDir),
|
|
@@ -206,6 +206,7 @@ export function emitClaudeRender(cfg, job) {
|
|
|
206
206
|
nbStatus,
|
|
207
207
|
managed,
|
|
208
208
|
editRefused: [...claim.editRefused],
|
|
209
|
+
kept: [...claim.kept],
|
|
209
210
|
};
|
|
210
211
|
}
|
|
211
212
|
|
package/js/build/emit-common.mjs
CHANGED
|
@@ -16,8 +16,8 @@ import { relPosix } from '../lib/text.mjs';
|
|
|
16
16
|
import { SRC_DIR_TOKENS, destRel } from './render.mjs';
|
|
17
17
|
import { mkdirSync, readdirSync, cpSync } from 'node:fs';
|
|
18
18
|
|
|
19
|
-
/** `_build_render.SRC_DIRS_MARKER`. */
|
|
20
|
-
export
|
|
19
|
+
/** `_build_render.SRC_DIRS_MARKER` — defined beside its file-list reader, `bundleFiles`. */
|
|
20
|
+
export { SRC_DIRS_MARKER } from '../hosts/owned.mjs';
|
|
21
21
|
/**
|
|
22
22
|
* `_build_render.OWNED_SRC_DIRS` — wiped and regenerated each run.
|
|
23
23
|
*
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* plainly as two files with the same shape than as two sections of one.
|
|
8
8
|
*/
|
|
9
9
|
import path from 'node:path';
|
|
10
|
+
import { bundleFiles } from '../hosts/owned.mjs';
|
|
10
11
|
import { VERSION_MARKER } from '../hosts/hosts.mjs';
|
|
11
12
|
import { claimer, loadAgentOverrides, writeNativeLayer } from '../hosts/native.mjs';
|
|
12
13
|
import {
|
|
@@ -55,12 +56,12 @@ import { mkdirSync } from 'node:fs';
|
|
|
55
56
|
function opencodeLayer(cfg, items, themeName, theme, dir, owned, opts) {
|
|
56
57
|
const {
|
|
57
58
|
oldOwned, manifestExisted, agentPath, wireBase, overridesDir, oldDenies = [], oldEdit = { asks: [], shorthand: null },
|
|
58
|
-
oldHashes = {},
|
|
59
|
+
oldHashes = {}, oldGates = [],
|
|
59
60
|
} = opts;
|
|
60
61
|
ensureAgentOverridesStub(cfg, overridesDir);
|
|
61
62
|
const overrides = loadAgentOverrides(overridesDir);
|
|
62
63
|
// One claim for every writer below whose path lands in `owned` — see `claimer`.
|
|
63
|
-
const claim = claimer(oldOwned, dir, manifestExisted, oldHashes);
|
|
64
|
+
const claim = claimer(oldOwned, dir, manifestExisted, oldHashes, cfg.force);
|
|
64
65
|
|
|
65
66
|
const { nAgents, nSkills, written, userOnlySkills } = writeNativeLayer(
|
|
66
67
|
items, path.join(dir, 'agents'), path.join(dir, 'skills'), overrides,
|
|
@@ -100,7 +101,7 @@ function opencodeLayer(cfg, items, themeName, theme, dir, owned, opts) {
|
|
|
100
101
|
const cfgName = path.basename(mergeOpencodeJson(path.join(wireBase, 'opencode.json'),
|
|
101
102
|
agentPath, cfg.doctrines, cfg.excludeRules, userOnlySkills, staleSkillNames, wired,
|
|
102
103
|
cfg.deletionGate, opencodeEditAsks(dir, wireBase === dir, wireBase === dir ? null : agentPath,
|
|
103
|
-
cfg.doctrines, cfg.excludeRules), oldEdit));
|
|
104
|
+
cfg.doctrines, cfg.excludeRules), oldEdit, oldGates, cfg.pruneGates));
|
|
104
105
|
// The next record: Geneseed's earlier denies still wanted, plus the ones it added now. A merge
|
|
105
106
|
// that wrote nothing (`skillsAdded` unset) keeps the old record whole.
|
|
106
107
|
const skillDenies = wired.skillsAdded
|
|
@@ -110,6 +111,9 @@ function opencodeLayer(cfg, items, themeName, theme, dir, owned, opts) {
|
|
|
110
111
|
return {
|
|
111
112
|
nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands: commands.length, cfgName,
|
|
112
113
|
skillDenies, editRecord: wired.editRecord ?? oldEdit, editRefused: [...claim.editRefused],
|
|
114
|
+
// As `skillDenies`: a merge that wrote nothing keeps the old record whole.
|
|
115
|
+
bashGates: wired.bashGates ? [...wired.bashGates].sort() : oldGates,
|
|
116
|
+
kept: [...claim.kept],
|
|
113
117
|
};
|
|
114
118
|
}
|
|
115
119
|
|
|
@@ -133,7 +137,7 @@ export function emitOpencodeRender(cfg, job) {
|
|
|
133
137
|
phaseLog('RENDER');
|
|
134
138
|
const {
|
|
135
139
|
theme: _theme, out, root, footprint, nativeCatalog, oldOwned, manifestExisted, agentPath,
|
|
136
|
-
oldDenies, oldEdit, oldHashes = {},
|
|
140
|
+
oldDenies, oldEdit, oldHashes = {}, oldGates = [],
|
|
137
141
|
} = job;
|
|
138
142
|
const oc = path.join(root, '.opencode');
|
|
139
143
|
|
|
@@ -141,16 +145,20 @@ export function emitOpencodeRender(cfg, job) {
|
|
|
141
145
|
|
|
142
146
|
// OpenCode loads agents/skills natively, so strip AGENT.md's per-row spec links to
|
|
143
147
|
// plain names (the portable build keeps them). A deliberate de-link, not a fix.
|
|
148
|
+
// Only the AGENT.md this build wrote: one it found there and kept is the user's, and this
|
|
149
|
+
// rewrite changed its links, and its line endings on Windows.
|
|
144
150
|
const agentMd = path.join(out, 'AGENT.md');
|
|
145
|
-
if (isFile(agentMd)
|
|
151
|
+
if (isFile(agentMd) && bundleFiles(out)?.includes('AGENT.md')) {
|
|
152
|
+
writeText(agentMd, stripCapabilityLinks(readText(agentMd)));
|
|
153
|
+
}
|
|
146
154
|
|
|
147
155
|
const owned = [];
|
|
148
156
|
const { theme, items } = renderAll(cfg, _theme, { footprint, nativeCatalog });
|
|
149
157
|
|
|
150
158
|
const {
|
|
151
|
-
nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands, cfgName, skillDenies, editRecord, editRefused,
|
|
159
|
+
nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands, cfgName, skillDenies, editRecord, editRefused, bashGates, kept,
|
|
152
160
|
} = opencodeLayer(cfg, items, _theme, theme, oc, owned, {
|
|
153
|
-
oldOwned, manifestExisted, agentPath, wireBase: root, overridesDir: out, oldDenies, oldEdit, oldHashes,
|
|
161
|
+
oldOwned, manifestExisted, agentPath, wireBase: root, overridesDir: out, oldDenies, oldEdit, oldHashes, oldGates,
|
|
154
162
|
});
|
|
155
163
|
|
|
156
164
|
return {
|
|
@@ -162,6 +170,8 @@ export function emitOpencodeRender(cfg, job) {
|
|
|
162
170
|
skillDenies,
|
|
163
171
|
editRecord,
|
|
164
172
|
editRefused,
|
|
173
|
+
bashGates,
|
|
174
|
+
kept,
|
|
165
175
|
};
|
|
166
176
|
}
|
|
167
177
|
|
|
@@ -196,7 +206,7 @@ export function emitOpencodeGlobalRender(cfg, job) {
|
|
|
196
206
|
phaseLog('RENDER');
|
|
197
207
|
const {
|
|
198
208
|
theme: themeName, cfgDir, out, footprint, nativeCatalog, oldOwned, agentPath, oldDenies, oldEdit,
|
|
199
|
-
oldHashes = {},
|
|
209
|
+
oldHashes = {}, oldGates = [],
|
|
200
210
|
} = job;
|
|
201
211
|
|
|
202
212
|
// No `lawsPrefix`: the standalone laws dir sits beside AGENT.md in <cfg>, so the lean
|
|
@@ -227,9 +237,9 @@ export function emitOpencodeGlobalRender(cfg, job) {
|
|
|
227
237
|
// `manifestExisted` is deliberately not passed, so
|
|
228
238
|
// the pre-manifest header line is unreachable from this emit.
|
|
229
239
|
const {
|
|
230
|
-
nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands, cfgName, skillDenies, editRecord, editRefused,
|
|
240
|
+
nAgents, nSkills, nPlugins, nWorkflows, primary, nCommands, cfgName, skillDenies, editRecord, editRefused, bashGates, kept,
|
|
231
241
|
} = opencodeLayer(cfg, items, themeName, theme, cfgDir, owned, {
|
|
232
|
-
oldOwned, agentPath, wireBase: cfgDir, overridesDir: cfgDir, oldDenies, oldEdit, oldHashes,
|
|
242
|
+
oldOwned, agentPath, wireBase: cfgDir, overridesDir: cfgDir, oldDenies, oldEdit, oldHashes, oldGates,
|
|
233
243
|
});
|
|
234
244
|
|
|
235
245
|
const memStatus = globalMemory(cfgDir, items, out, cfg.src);
|
|
@@ -258,5 +268,7 @@ export function emitOpencodeGlobalRender(cfg, job) {
|
|
|
258
268
|
skillDenies,
|
|
259
269
|
editRecord,
|
|
260
270
|
editRefused,
|
|
271
|
+
bashGates,
|
|
272
|
+
kept,
|
|
261
273
|
};
|
|
262
274
|
}
|