geneseed 4.31.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +107 -0
- package/DESIGN.md +2 -2
- package/README.md +6 -5
- package/SHIPPED.md +4 -3
- package/adapters/bob/README.md +6 -5
- package/adapters/claude-code/README.md +4 -3
- package/adapters/claude-code/skills/geneseed/SKILL.md +1 -1
- package/adapters/openclaude/README.md +4 -3
- package/adapters/opencode/GLOBAL-HARNESS-SPEC.md +3 -1
- package/adapters/opencode/HOW-OPENCODE-LOADS.md +2 -1
- package/adapters/opencode/README.md +18 -18
- package/adapters/opencode/plugins/geneseed-activity.js +57 -1
- package/adapters/opencode/plugins/geneseed-context.js +220 -18
- package/adapters/opencode/plugins/geneseed-guard.js +578 -74
- package/adapters/opencode/plugins/geneseed-learn.js +97 -23
- package/bin/geneseed-cli.mjs +17 -25
- package/bin/geneseed-hook.mjs +23 -8
- package/docs/DESIGN.md +175 -0
- package/docs/PRD.md +111 -0
- package/docs/README.md +3 -2
- package/docs/architecture.md +145 -0
- package/docs/concepts/agents.md +1 -1
- package/docs/concepts/collaboration.md +1 -1
- package/docs/concepts/enforcement-table.md +1 -1
- package/docs/concepts/exclusions.md +6 -6
- package/docs/concepts/footprint.md +1 -1
- package/docs/concepts/foreman-mode.md +2 -2
- package/docs/concepts/hook-gates.md +1 -1
- package/docs/concepts/hooks.md +27 -11
- package/docs/concepts/host-matrix.md +3 -3
- package/docs/concepts/hosts.md +1 -1
- package/docs/concepts/kits.md +3 -1
- package/docs/concepts/loop-bricks.md +1 -1
- package/docs/concepts/loop-notes.md +4 -2
- package/docs/concepts/loop-templates.md +7 -4
- package/docs/concepts/loops.md +3 -0
- package/docs/concepts/ownership.md +2 -2
- package/docs/concepts/rules.md +15 -2
- package/docs/concepts/shared-tier.md +73 -0
- package/docs/concepts/skills.md +2 -2
- package/docs/concepts/themes.md +1 -1
- package/docs/extending.md +13 -12
- package/docs/guides/install-claude-code.md +1 -1
- package/docs/guides/install-opencode.md +1 -1
- package/docs/guides/migrate.md +4 -2
- package/docs/guides/project-context.md +2 -2
- package/docs/guides/run-a-loop.md +1 -1
- package/docs/guides/set-up-ownership.md +1 -1
- package/docs/guides/setup-footprint.md +1 -1
- package/docs/guides/uninstall.md +2 -1
- package/docs/guides/upgrade-to-5.md +116 -0
- package/docs/guides/upgrade.md +21 -9
- package/docs/guides/wiki.md +3 -3
- package/docs/reference/env-context.md +5 -3
- package/docs/reference/environment.md +1 -1
- package/docs/reference/glossary.md +2 -0
- package/docs/reference/loop-actions.md +1 -1
- package/docs/reference/opencode-plugins.md +3 -3
- package/docs/reference/plugin-activity.md +1 -1
- package/docs/reference/plugin-context.md +5 -0
- package/docs/reference/plugin-guard.md +14 -6
- package/docs/reference/plugin-learn.md +13 -6
- package/docs/reference/troubleshoot-hooks.md +3 -3
- package/docs/reference/troubleshoot-update.md +14 -0
- package/docs/token-footprint.md +4 -3
- package/docs/understand/a-day.md +2 -2
- package/docs/understand/design-choices-install.md +2 -1
- package/docs/understand/enforced-vs-asked.md +4 -3
- package/docs/understand/machine-bob.md +3 -1
- package/docs/understand/machine-claude.md +7 -5
- package/docs/understand/machine-opencode.md +7 -5
- package/docs/understand/on-your-machine.md +4 -0
- package/docs/understand/take-it-out.md +1 -1
- package/docs/web-ui.md +141 -73
- package/harness.config.json +1 -1
- package/js/README.md +10 -6
- package/js/build/args.mjs +10 -8
- package/js/build/bundle.mjs +11 -13
- package/js/build/driver.mjs +66 -65
- package/js/build/emit-claude.mjs +22 -16
- package/js/build/emit-common.mjs +4 -5
- package/js/build/emit-opencode.mjs +22 -22
- package/js/build/fold.mjs +515 -0
- package/js/build/generate.mjs +41 -52
- package/js/build/render.mjs +115 -29
- package/js/build/source.mjs +4 -1
- package/js/build/stubs.mjs +70 -9
- package/js/build/version.mjs +10 -10
- package/js/cli-table.json +23 -83
- package/js/hosts/activity.mjs +2 -2
- package/js/hosts/geneseed-dir.mjs +1 -1
- package/js/hosts/hooks-context.mjs +410 -99
- package/js/hosts/hooks-done.mjs +97 -31
- package/js/hosts/hooks-learn.mjs +38 -7
- package/js/hosts/hooks-prims.mjs +69 -2
- package/js/hosts/hooks.mjs +300 -64
- package/js/hosts/hosts.mjs +150 -51
- package/js/hosts/installs.mjs +55 -167
- package/js/hosts/link.mjs +3 -5
- package/js/hosts/mcp.mjs +1 -1
- package/js/hosts/memory-files.mjs +219 -17
- package/js/hosts/ownership-gate.mjs +1 -1
- package/js/hosts/settings.mjs +18 -13
- package/js/hosts/shim.mjs +4 -33
- package/js/hosts/store-watch.mjs +189 -0
- package/js/inspect/checks-authoring.mjs +3 -3
- package/js/inspect/checks-build.mjs +45 -18
- package/js/inspect/checks-counts.mjs +4 -4
- package/js/inspect/checks-repo.mjs +13 -14
- package/js/inspect/cost.mjs +24 -2
- package/js/inspect/diff.mjs +123 -123
- package/js/inspect/doctor.mjs +22 -27
- package/js/inspect/excludes.mjs +181 -62
- package/js/inspect/inventory.mjs +22 -27
- package/js/inspect/registry.mjs +106 -30
- package/js/inspect/scan.mjs +5 -5
- package/js/inspect/status.mjs +141 -119
- package/js/inspect/validate.mjs +22 -24
- package/js/lib/fs.mjs +47 -50
- package/js/lib/json.mjs +10 -17
- package/js/lib/machine-dir.mjs +73 -0
- package/js/lib/paths.mjs +22 -33
- package/js/lib/proc.mjs +1 -1
- package/js/lib/prompt.mjs +19 -27
- package/js/lib/text.mjs +8 -12
- package/js/lib/udiff.mjs +11 -15
- package/js/loop/catalog.mjs +2 -3
- package/js/loop/state.mjs +15 -5
- package/js/maintain/memory.mjs +17 -17
- package/js/maintain/migrate.mjs +79 -89
- package/js/maintain/setup.mjs +43 -32
- package/js/maintain/uninstall.mjs +43 -61
- package/js/maintain/update.mjs +200 -93
- package/js/ui/anim.mjs +21 -35
- package/js/ui/cli.mjs +36 -58
- package/js/ui/menu.mjs +22 -45
- package/js/ui/tui.mjs +27 -67
- package/js/web/actions.mjs +38 -38
- package/js/web/api.mjs +132 -76
- package/js/web/catalog.mjs +175 -46
- package/js/web/docs.mjs +33 -12
- package/js/web/doctor-worker.mjs +14 -0
- package/js/web/handler.mjs +14 -5
- package/js/web/routes.mjs +17 -19
- package/js/web/state.mjs +78 -19
- package/js/web/update-check.mjs +25 -10
- package/js/web/user-files.mjs +50 -105
- package/package.json +7 -4
- package/registry.json +48 -55
- package/src/AGENT.md.tmpl +13 -14
- package/src/agents/_self-improvement.md +1 -1
- package/src/agents/_template.md +4 -1
- package/src/agents/advocate.md +1 -1
- package/src/agents/architect.md +1 -1
- package/src/agents/developer.md +6 -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 +1 -1
- package/src/agents/framer.md +1 -1
- package/src/agents/historian.md +1 -1
- package/src/agents/kubernetes-specialist.md +1 -1
- package/src/agents/memory-curator.md +2 -2
- package/src/agents/operator.md +1 -1
- package/src/agents/performance.md +1 -1
- package/src/agents/pragmatist.md +1 -1
- package/src/agents/react-engineer.md +1 -1
- package/src/agents/react-reviewer.md +1 -1
- package/src/agents/researcher.md +1 -1
- package/src/agents/reviewer.md +1 -1
- package/src/agents/security.md +1 -1
- package/src/agents/skeptic.md +1 -1
- package/src/agents/spring-boot-engineer.md +1 -1
- package/src/agents/spring-reviewer.md +1 -1
- package/src/agents/spring-security.md +1 -1
- package/src/agents/steward.md +1 -1
- package/src/agents/tester.md +5 -2
- package/src/agents/user-advocate.md +1 -1
- package/src/agents/visionary.md +1 -1
- package/src/bricks/apply.md +3 -0
- package/src/bricks/test.md +6 -4
- package/src/loops/bugfix.json +11 -5
- package/src/loops/feature.json +7 -4
- package/src/memory/README.md +1 -1
- package/src/skills/_self-improvement.md +2 -2
- package/src/skills/daydream/SKILL.md +2 -2
- package/src/skills/daydream/instructions.md +1 -1
- package/src/skills/geneseed.md +1 -1
- package/src/skills/learn-mode.md +1 -2
- package/src/skills/loop.md +1 -0
- package/src/skills/profile.md +2 -2
- package/src/skills/rule/approve.md +69 -0
- package/src/skills/rule/consolidate.md +3 -3
- package/src/skills/rule.md +13 -5
- package/src/skills/ship.md +9 -1
- package/src/skills/skill-forge.md +1 -1
- package/src/skills/teach.md +29 -12
- package/src/skills/wiki.md +1 -1
- package/themes/_TEMPLATE.json +1 -2
- package/themes/biker.json +1 -2
- package/themes/commentator.json +1 -2
- package/themes/cyberpunk.json +1 -2
- package/themes/gamer.json +1 -2
- package/themes/imperial.json +1 -2
- package/themes/joker.json +1 -2
- package/themes/marvin.json +1 -2
- package/themes/mean.json +1 -2
- package/themes/military.json +1 -2
- package/themes/neutral.json +1 -2
- package/themes/pirate.json +1 -2
- package/themes/sports.json +1 -2
- package/themes/verstappen.json +1 -2
- package/themes/wizard.json +1 -2
- package/web/dist/assets/Activity-D8G4eClY.js +1 -0
- package/web/dist/assets/ActivityDetail-BtOBYk3M.js +1 -0
- package/web/dist/assets/AgentGlyph-k6o3gCM1.js +1 -0
- package/web/dist/assets/Bonsai-B_y20b3i.js +1 -0
- package/web/dist/assets/{CopyButton-IXnXzH4Y.js → CopyButton-CHQte7Ap.js} +1 -1
- package/web/dist/assets/Dashboard-B8uXeJZ_.js +2 -0
- package/web/dist/assets/{DataTable-BWbUx4bY.js → DataTable-b9zTShqJ.js} +1 -1
- package/web/dist/assets/Docs-Dgv_MWfT.js +5 -0
- package/web/dist/assets/{EmptyState-1sPNleqv.js → EmptyState-CY5Pm2xy.js} +1 -1
- package/web/dist/assets/FilterInput-qGKNSlxv.js +1 -0
- package/web/dist/assets/GreenhouseView-CSzTMSl_.js +1 -0
- package/web/dist/assets/Installs-BDk9lqBI.js +3 -0
- package/web/dist/assets/JournalView-CvRk1-m5.js +1 -0
- package/web/dist/assets/Kits-CoITzxWM.js +1 -0
- package/web/dist/assets/Laws-Ctf5r9rE.js +3 -0
- package/web/dist/assets/Library-DNwHYVXt.js +3 -0
- package/web/dist/assets/{Loops-C5u7fQOR.js → Loops-S85PMQ8m.js} +2 -2
- package/web/dist/assets/Markdown-0ORz7tAc.js +69 -0
- package/web/dist/assets/OperatorHudView-DuGz_sTk.js +1 -0
- package/web/dist/assets/Personal-afJNwvRS.js +2 -0
- package/web/dist/assets/RailCats-AW92uhsX.js +1 -0
- package/web/dist/assets/Settings-CGDFz-6j.js +1 -0
- package/web/dist/assets/Tabs-1qLrnqmn.js +1 -0
- package/web/dist/assets/api-C46vAuqp.js +1 -0
- package/web/dist/assets/controls-D4wmg_pl.js +1 -0
- package/web/dist/assets/index-COTd4TRZ.js +3 -0
- package/web/dist/assets/index-CtorA7uK.css +1 -0
- package/web/dist/assets/motion-RlUl1osO.js +1 -0
- package/web/dist/assets/react-C1iE8mnY.js +9 -0
- package/web/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/web/dist/assets/{sections-ChwaobfW.js → sections-CtFz7HFH.js} +1 -1
- package/web/dist/assets/{usePoll-bDFN-Hr6.js → usePoll-o8ul-Sog.js} +1 -1
- package/web/dist/index.html +7 -7
- package/src/skills/quiz.md +0 -44
- package/web/dist/assets/Activity-B7cFtS00.js +0 -1
- package/web/dist/assets/ActivityDetail-C-GbMmuW.js +0 -1
- package/web/dist/assets/Bonsai-_YyexVC5.js +0 -1
- package/web/dist/assets/Dashboard-sCfEjowQ.js +0 -2
- package/web/dist/assets/Docs-w3Y7M5Ts.js +0 -5
- package/web/dist/assets/FilterInput-CZREvrjX.js +0 -1
- package/web/dist/assets/GreenhouseView-BWWbMKmg.js +0 -1
- package/web/dist/assets/Installs-CnkdJ-VA.js +0 -3
- package/web/dist/assets/JournalView-C7bPD3fZ.js +0 -1
- package/web/dist/assets/KitApply-CQQbnThf.js +0 -1
- package/web/dist/assets/Kits-aj07N7mT.js +0 -1
- package/web/dist/assets/Laws-DZ38nl_H.js +0 -3
- package/web/dist/assets/Library-QCGXPV5h.js +0 -2
- package/web/dist/assets/Markdown-DpmmtW2Y.js +0 -65
- package/web/dist/assets/OperatorHudView-Blu1lqiZ.js +0 -1
- package/web/dist/assets/Personal-ox_MktWO.js +0 -2
- package/web/dist/assets/RailCats-BuJD4Jou.js +0 -1
- package/web/dist/assets/Tabs-CIPyMAX-.js +0 -1
- package/web/dist/assets/api-BxjLd7Qd.js +0 -1
- package/web/dist/assets/index-0GCxkY7m.css +0 -1
- package/web/dist/assets/index-CzDi9JpF.js +0 -3
- package/web/dist/assets/motion-CXaUMNkg.js +0 -1
- package/web/dist/assets/react-DlYQp10C.js +0 -9
- package/web/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
package/js/inspect/excludes.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The sovereign-repo exclusion WRITER.
|
|
3
3
|
*
|
|
4
|
-
* THE READER
|
|
5
|
-
* and `EXCLUDE_DIRS
|
|
4
|
+
* THE READER LIVES IN `js/hosts/hosts.mjs`, which carries `sovereignBypass`, `EXCLUDES_FILE`
|
|
5
|
+
* and `EXCLUDE_DIRS`: every hook call reads `excludes.json` and stands down when
|
|
6
6
|
* cwd is under an excluded folder. This module is the other half — `harness exclude
|
|
7
7
|
* add|remove|list`, which maintains that file across every global install and wires the
|
|
8
8
|
* host-native per-repo suppression into the excluded repo.
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
* THE WEB ENDPOINT IS THIS MODULE — there is exactly ONE writer. `js/web/actions.mjs`
|
|
11
11
|
* dispatches straight to `excludeAdd`/`excludeRemove` here, and `apiExcludes` in
|
|
12
12
|
* `js/web/api.mjs` is `excludesSnapshot()` unmodified, so the CLI and the console are one
|
|
13
|
-
* writer over one user-owned file.
|
|
14
|
-
* same three names, and the surviving hazard is the one that outlived the split: two
|
|
13
|
+
* writer over one user-owned file. The surviving hazard is two
|
|
15
14
|
* PROCESSES writing at the same instant. `writeExcludes` is temp-plus-rename, so a
|
|
16
15
|
* concurrent pair loses one edit rather than tearing the file.
|
|
17
16
|
*
|
|
@@ -22,11 +21,13 @@ import { existsSync, mkdirSync, readdirSync, renameSync, rmdirSync, unlinkSync }
|
|
|
22
21
|
from 'node:fs';
|
|
23
22
|
import path from 'node:path';
|
|
24
23
|
import { EXCLUDES_FILE, EXCLUDES_STUB, BOB_RULES_STUB } from '../build/stubs.mjs';
|
|
25
|
-
import {
|
|
24
|
+
import { archiveStore } from '../hosts/memory-files.mjs';
|
|
25
|
+
import { loadJsonObject, wireClaudeExcludes, unwireClaudeExcludes } from '../hosts/settings.mjs';
|
|
26
26
|
import { GLOBAL_MANIFEST, HOSTS, resolvePath } from '../hosts/hosts.mjs';
|
|
27
27
|
import { readText, writeText, printOut, printErr, isDir, isFile, isOsError } from '../lib/fs.mjs';
|
|
28
28
|
import { parseJson, jsonDumpsIndent, get, isDict } from '../lib/json.mjs';
|
|
29
29
|
import { normcase, toPlatformPath } from '../lib/paths.mjs';
|
|
30
|
+
import { machineDir } from '../lib/machine-dir.mjs';
|
|
30
31
|
|
|
31
32
|
/** The per-repo settings file a claudeMdExcludes entry goes in (Claude and OpenClaude). */
|
|
32
33
|
const localSettings = (repo, host) =>
|
|
@@ -62,7 +63,7 @@ function globalInstalls() {
|
|
|
62
63
|
try {
|
|
63
64
|
cfg = configDir();
|
|
64
65
|
} catch {
|
|
65
|
-
continue; // a broken resolver must not kill the CLI
|
|
66
|
+
continue; // a broken resolver must not kill the CLI
|
|
66
67
|
}
|
|
67
68
|
if (isFile(path.join(cfg, GLOBAL_MANIFEST))) out.push({ host, cfg });
|
|
68
69
|
}
|
|
@@ -102,9 +103,9 @@ const canon = (p) => resolvePath(p);
|
|
|
102
103
|
*
|
|
103
104
|
* Resolved like `repo` itself (`canon`: `..` collapsed, symlinks followed), the one rule the
|
|
104
105
|
* hook's `sovereignBypass` and the OpenCode plugins apply too — so an entry that EXCLUDES a
|
|
105
|
-
* folder is exactly the entry `exclude remove` can take back.
|
|
106
|
-
*
|
|
107
|
-
*
|
|
106
|
+
* folder is exactly the entry `exclude remove` can take back. A lexical comparison would make
|
|
107
|
+
* a hand-edited `<repo>/../repo` an entry the plugins honoured, the hook ignored, and
|
|
108
|
+
* `remove` could not find.
|
|
108
109
|
*/
|
|
109
110
|
function same(stored, repo) {
|
|
110
111
|
if (typeof stored !== 'string' || !stored) return false;
|
|
@@ -115,6 +116,25 @@ function same(stored, repo) {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
/**
|
|
120
|
+
* The shared list (B8): the machine tier's `excludes.json`, read by every global install's hook
|
|
121
|
+
* and plugin next to its own. It holds paths only; the `wired` receipts stay in each host's file,
|
|
122
|
+
* because only that host can unwire what it wired. Written beside the host files, so one stale
|
|
123
|
+
* host no longer decides which folders are silent.
|
|
124
|
+
*/
|
|
125
|
+
function updateShared(change) {
|
|
126
|
+
const dir = machineDir();
|
|
127
|
+
const unsound = !listIsSound(dir);
|
|
128
|
+
const data = readExcludes(dir);
|
|
129
|
+
const before = JSON.stringify(data.excludes);
|
|
130
|
+
data.excludes = change(data.excludes);
|
|
131
|
+
if (JSON.stringify(data.excludes) === before) return; // a no-op remove creates nothing
|
|
132
|
+
// D10: a shared list that does not parse is moved aside before the write replaces it.
|
|
133
|
+
if (unsound) archiveStore(path.join(dir, EXCLUDES_FILE));
|
|
134
|
+
mkdirSync(dir, { recursive: true });
|
|
135
|
+
writeExcludes(dir, data);
|
|
136
|
+
}
|
|
137
|
+
|
|
118
138
|
/**
|
|
119
139
|
* `exclude_add` — add `path` to every global install's list and wire the per-repo
|
|
120
140
|
* suppression. Idempotent; returns `{ok, path, messages}`.
|
|
@@ -128,55 +148,147 @@ export function excludeAdd(target) {
|
|
|
128
148
|
return { ok: false, path: repo,
|
|
129
149
|
messages: ['no global Geneseed install found — nothing to exclude from'] };
|
|
130
150
|
}
|
|
131
|
-
for (const { host, cfg } of installs)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
for (const { host, cfg } of installs) addToHost(host, cfg, repo, messages);
|
|
152
|
+
updateShared((list) => [...list.filter((e) => !(isDict(e) && same(get(e, 'path'), repo))),
|
|
153
|
+
{ path: repo.split(path.sep).join('/') }]);
|
|
154
|
+
return { ok: true, path: repo, messages };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* One install's half of `excludeAdd`: wire the per-repo suppression and keep the receipt. Returns
|
|
159
|
+
* the files it wrote in the repo, which belongs to the user: the fold names each one.
|
|
160
|
+
*/
|
|
161
|
+
function addToHost(host, cfg, repo, messages, strict = false) {
|
|
162
|
+
const written = [];
|
|
163
|
+
const data = readExcludes(cfg);
|
|
164
|
+
const prior = data.excludes.find((e) => isDict(e) && same(get(e, 'path'), repo));
|
|
165
|
+
const priorWired = (isDict(prior) ? get(prior, 'wired') : null) || {};
|
|
166
|
+
const wired = {};
|
|
167
|
+
if ((host === 'claude' || host === 'openclaude') && isDir(repo)) {
|
|
168
|
+
const added = wireClaudeExcludes(localSettings(repo, host), [claudeMdEntry(cfg)]);
|
|
169
|
+
if (added.length) {
|
|
170
|
+
wired.claude_md_excludes = added;
|
|
171
|
+
written.push(localSettings(repo, host));
|
|
172
|
+
} else if (get(priorWired, 'claude_md_excludes')) {
|
|
173
|
+
// Idempotent re-add: OUR own prior excludeAdd call genuinely wired this entry
|
|
174
|
+
// (confirmed by the manifest record), so ownership carries forward even though
|
|
175
|
+
// wireClaudeExcludes reports nothing NEW this time.
|
|
176
|
+
wired.claude_md_excludes = get(priorWired, 'claude_md_excludes');
|
|
152
177
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
ours = readText(stub) === BOB_RULES_STUB;
|
|
162
|
-
} catch (e) {
|
|
163
|
-
if (!isOsError(e)) throw e;
|
|
164
|
-
ours = false;
|
|
165
|
-
}
|
|
166
|
-
wired.bob_rules_stub = ours;
|
|
167
|
-
if (!ours) messages.push(`${host}: rules/geneseed.md already exists (kept, not ours)`);
|
|
178
|
+
// else: the entry was already present for some OTHER reason (e.g. a project install's
|
|
179
|
+
// own project-bypasses-global wiring, or a bailed write) — do NOT fabricate ownership,
|
|
180
|
+
// or a later excludeRemove would strip wiring we never created.
|
|
181
|
+
if (!added.length) {
|
|
182
|
+
// `wireClaudeExcludes` answers [] for both 'already there' and 'could not write' (a commented,
|
|
183
|
+
// torn or unwritable settings file). Only the first is wired; the second must not be counted as it.
|
|
184
|
+
if (hasClaudeExclude(localSettings(repo, host), claudeMdEntry(cfg))) {
|
|
185
|
+
messages.push(`${host}: claudeMdExcludes already present (kept)`);
|
|
168
186
|
} else {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
187
|
+
const why = `${host}: claudeMdExcludes NOT wired in ${localSettings(repo, host)} (see the warning above)`;
|
|
188
|
+
if (strict) throw new Error(why);
|
|
189
|
+
messages.push(why);
|
|
172
190
|
}
|
|
173
191
|
}
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
data.excludes = entries;
|
|
177
|
-
writeExcludes(cfg, data);
|
|
192
|
+
const note = worktreeNote(host, cfg, repo);
|
|
193
|
+
if (note) messages.push(note);
|
|
178
194
|
}
|
|
179
|
-
|
|
195
|
+
if (host === 'bob' && isDir(repo)) {
|
|
196
|
+
const stub = path.join(repo, '.bob', 'rules', 'geneseed.md');
|
|
197
|
+
if (existsSync(stub)) {
|
|
198
|
+
// Ownership is decided by CONTENT, not mere existence — a re-add finds a stub that
|
|
199
|
+
// already exists because WE wrote it last time; an existence-only check would misread
|
|
200
|
+
// that as user content and orphan it on the next remove. Exact match means ours.
|
|
201
|
+
let ours;
|
|
202
|
+
try {
|
|
203
|
+
ours = readText(stub) === BOB_RULES_STUB;
|
|
204
|
+
} catch (e) {
|
|
205
|
+
if (!isOsError(e)) throw e;
|
|
206
|
+
ours = false;
|
|
207
|
+
}
|
|
208
|
+
wired.bob_rules_stub = ours;
|
|
209
|
+
if (!ours) messages.push(`${host}: rules/geneseed.md already exists (kept, not ours)`);
|
|
210
|
+
} else {
|
|
211
|
+
mkdirSync(path.dirname(stub), { recursive: true });
|
|
212
|
+
writeText(stub, BOB_RULES_STUB);
|
|
213
|
+
wired.bob_rules_stub = true;
|
|
214
|
+
written.push(stub);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const entries = data.excludes.filter((e) => !(isDict(e) && same(get(e, 'path'), repo)));
|
|
218
|
+
entries.push({ path: repo.split(path.sep).join('/'), wired });
|
|
219
|
+
data.excludes = entries;
|
|
220
|
+
writeExcludes(cfg, data);
|
|
221
|
+
return written;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Does the settings file already carry this `claudeMdExcludes` entry? A file that does not load carries none. */
|
|
225
|
+
function hasClaudeExclude(file, entry) {
|
|
226
|
+
const { state, data } = loadJsonObject(file);
|
|
227
|
+
return state === 'ok' && Array.isArray(get(data, 'claudeMdExcludes')) && get(data, 'claudeMdExcludes').includes(entry);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** What `addToHost` would write in `repo`, for a dry run. */
|
|
231
|
+
function wiringTargets(host, repo) {
|
|
232
|
+
if (!isDir(repo)) return [];
|
|
233
|
+
if (host === 'claude' || host === 'openclaude') return [localSettings(repo, host)];
|
|
234
|
+
const stub = path.join(repo, '.bob', 'rules', 'geneseed.md');
|
|
235
|
+
return host === 'bob' && !existsSync(stub) ? [stub] : [];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** The folders a list names, resolved; a `~user` form names no folder (`same`). */
|
|
239
|
+
function reposOf(list) {
|
|
240
|
+
const out = [];
|
|
241
|
+
for (const e of list) {
|
|
242
|
+
const p = isDict(e) ? get(e, 'path') : e;
|
|
243
|
+
if (typeof p !== 'string' || !p) continue;
|
|
244
|
+
try { out.push(canon(p)); } catch { /* skipped, as `same` does */ }
|
|
245
|
+
}
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const listedIn = (list, repo) => list.some((e) => same(isDict(e) ? get(e, 'path') : e, repo));
|
|
250
|
+
|
|
251
|
+
/** Does `cfg` hold a list a write would not destroy? `readExcludes` degrades a torn one to the stub. */
|
|
252
|
+
function listIsSound(cfg) {
|
|
253
|
+
const f = path.join(cfg, EXCLUDES_FILE);
|
|
254
|
+
if (!isFile(f)) return true;
|
|
255
|
+
try {
|
|
256
|
+
const data = parseJson(readText(f));
|
|
257
|
+
return isDict(data) && Array.isArray(get(data, 'excludes'));
|
|
258
|
+
} catch { return false; }
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Fold step 3, both ways: this host's folders join the shared list, and a shared folder this host
|
|
263
|
+
* never heard of gets the wiring `exclude add` gave the installs it found then. Writes only what
|
|
264
|
+
* is missing, so a second run writes nothing. The share goes first and each repo answers for
|
|
265
|
+
* itself: one a write cannot reach lands in `errors`, and its entry stays out of this host's list,
|
|
266
|
+
* so the next emit retries it. Throws, leaving both files as they are, when either list does not
|
|
267
|
+
* parse: the write would replace what the user can still repair by hand.
|
|
268
|
+
*/
|
|
269
|
+
export function foldExcludes(host, cfg, dryRun = false) {
|
|
270
|
+
const tier = machineDir();
|
|
271
|
+
for (const dir of [cfg, tier]) {
|
|
272
|
+
if (!listIsSound(dir)) throw new Error(`${path.join(dir, EXCLUDES_FILE)} does not parse`);
|
|
273
|
+
}
|
|
274
|
+
const own = readExcludes(cfg).excludes;
|
|
275
|
+
const shared = readExcludes(tier).excludes;
|
|
276
|
+
const toShare = [...new Set(reposOf(own))].filter((r) => !listedIn(shared, r));
|
|
277
|
+
const toWire = [...new Set(reposOf(shared))].filter((r) => !listedIn(own, r));
|
|
278
|
+
const paths = [];
|
|
279
|
+
const notices = [];
|
|
280
|
+
const errors = [];
|
|
281
|
+
if (dryRun) {
|
|
282
|
+
paths.push(...toWire.flatMap((repo) => wiringTargets(host, repo)));
|
|
283
|
+
} else {
|
|
284
|
+
if (toShare.length) {
|
|
285
|
+
updateShared((list) => [...list, ...toShare.map((r) => ({ path: r.split(path.sep).join('/') }))]);
|
|
286
|
+
}
|
|
287
|
+
for (const repo of toWire) {
|
|
288
|
+
try { paths.push(...addToHost(host, cfg, repo, notices, true)); } catch (e) { errors.push(`${repo}: ${e.message}`); }
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return { added: toShare.length, wired: toWire.length - errors.length, paths, notices, errors };
|
|
180
292
|
}
|
|
181
293
|
|
|
182
294
|
/**
|
|
@@ -212,19 +324,23 @@ export function excludeRemove(target) {
|
|
|
212
324
|
}
|
|
213
325
|
} catch (e) {
|
|
214
326
|
if (!isOsError(e)) throw e;
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
// Node's own wording. No cell can reach this branch (`unlink` on a file that
|
|
327
|
+
// `e.message` is Node's own wording, not `[Errno 13] Permission denied: '<path>'`.
|
|
328
|
+
// No cell can reach this branch (`unlink` on a file that
|
|
218
329
|
// `isFile` just confirmed, `rmdir` on a directory just measured empty), so a
|
|
219
|
-
// translation table here would be an unobservable guess.
|
|
220
|
-
//
|
|
221
|
-
// the same reason.
|
|
330
|
+
// translation table here would be an unobservable guess.
|
|
331
|
+
// `js/hosts/settings.mjs`'s `asOsError` is the same stub for the same reason.
|
|
222
332
|
messages.push(`${host}: could not remove ${stub} (${e.message})`);
|
|
223
333
|
}
|
|
224
334
|
}
|
|
225
335
|
data.excludes = keep;
|
|
226
336
|
writeExcludes(cfg, data);
|
|
227
337
|
}
|
|
338
|
+
// A folder only the shared list names (a fold put it there) is still excluded, so it comes out too.
|
|
339
|
+
updateShared((list) => {
|
|
340
|
+
const keep = list.filter((e) => !(isDict(e) && same(get(e, 'path'), repo)));
|
|
341
|
+
if (keep.length !== list.length) found = true;
|
|
342
|
+
return keep;
|
|
343
|
+
});
|
|
228
344
|
if (!found) messages.push(`${repo} was not excluded`);
|
|
229
345
|
return { ok: found, path: repo, messages };
|
|
230
346
|
}
|
|
@@ -237,7 +353,7 @@ export function excludeRemove(target) {
|
|
|
237
353
|
export function excludesSnapshot() {
|
|
238
354
|
const installs = globalInstalls();
|
|
239
355
|
const byPath = new Map();
|
|
240
|
-
|
|
356
|
+
const collect = (cfg, host) => {
|
|
241
357
|
for (const e of readExcludes(cfg).excludes) {
|
|
242
358
|
const p = isDict(e) ? get(e, 'path') : e;
|
|
243
359
|
if (typeof p !== 'string' || !p) continue;
|
|
@@ -246,9 +362,12 @@ export function excludesSnapshot() {
|
|
|
246
362
|
byPath.set(key, { path: p, hosts: [],
|
|
247
363
|
wired: (isDict(e) ? get(e, 'wired') : null) || {} });
|
|
248
364
|
}
|
|
249
|
-
byPath.get(key).hosts.push(host);
|
|
365
|
+
if (host) byPath.get(key).hosts.push(host);
|
|
250
366
|
}
|
|
251
|
-
}
|
|
367
|
+
};
|
|
368
|
+
for (const { host, cfg } of installs) collect(cfg, host);
|
|
369
|
+
// A folder only the shared list names is silent everywhere but wired nowhere: it lists with no host.
|
|
370
|
+
if (installs.length) collect(machineDir(), null);
|
|
252
371
|
const excludes = [...byPath.values()].sort(
|
|
253
372
|
(a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
254
373
|
return { excludes, installs: installs.map(({ host, cfg }) => ({ host, cfg })) };
|
package/js/inspect/inventory.mjs
CHANGED
|
@@ -4,22 +4,18 @@
|
|
|
4
4
|
* panel and the web console all read.
|
|
5
5
|
*
|
|
6
6
|
* WHY THIS FILE EXISTS RATHER THAN A THIRD COPY OF THE TABLES. `LAW_CLASS`, `SKILL_CLASS`,
|
|
7
|
-
* `LAW_CLASSES` and `ENTITY_STATUSES`
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `entity_status` and had stopped being true of the tables. P6c needs all of it, so the
|
|
11
|
-
* tables move HERE, to the module that mirrors where Python keeps them, and the doctor's
|
|
7
|
+
* `LAW_CLASSES` and `ENTITY_STATUSES` are validated by doctor's authoring gates, and the
|
|
8
|
+
* catalog needs all of them, so the
|
|
9
|
+
* tables live HERE, and the doctor's
|
|
12
10
|
* check modules import them — `checks-authoring.mjs` takes `LAW_CLASS`, `LAW_CLASSES` and
|
|
13
11
|
* `SKILL_CLASS`, `checks-repo.mjs` takes `ENTITY_STATUSES`. A copy of a value under test
|
|
14
12
|
* silently stops being the value under test.
|
|
15
13
|
*
|
|
16
|
-
* AND `inventoryCounts`
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* `length`s off it. The eleven `status` cells gate the counts; P6c's catalog cells gate
|
|
22
|
-
* the fields; both run over the same walk.
|
|
14
|
+
* AND `inventoryCounts` IS THREE `length`s OFF `tuiInventory`: the two must not become two
|
|
15
|
+
* classifiers, because the catalog consumes the very fields the count throws away. So there
|
|
16
|
+
* is one classifier — "a two-part relative path ending in `.md` and
|
|
17
|
+
* not starting with `_`, under `agents/` or `skills/`". The eleven `status` cells gate the
|
|
18
|
+
* counts; the catalog cells gate the fields; both run over the same walk.
|
|
23
19
|
*/
|
|
24
20
|
import path from 'node:path';
|
|
25
21
|
|
|
@@ -31,7 +27,7 @@ import { readText } from '../lib/fs.mjs';
|
|
|
31
27
|
import { parseJson } from '../lib/json.mjs';
|
|
32
28
|
|
|
33
29
|
/**
|
|
34
|
-
*
|
|
30
|
+
* A heading in the RENDERED laws file, e.g.
|
|
35
31
|
* `### Rule IV — Deletion Is Deliberate`.
|
|
36
32
|
*
|
|
37
33
|
* The rendered side only: the unrendered source declares a rule as `{{LAW:<id>}} <Name>`, and
|
|
@@ -67,17 +63,17 @@ const ONTOLOGY_HEADING_RE = /^####\s+(.+?)\s*$/;
|
|
|
67
63
|
/** The lead line of a pack file — `**Craft** — how code is written.` */
|
|
68
64
|
const PACK_LEAD_RE = /^\*\*(.+?)\*\*\s+[—-]\s+(.+?)\s*$/;
|
|
69
65
|
|
|
70
|
-
/**
|
|
66
|
+
/** Each rule's class, keyed by Roman numeral. */
|
|
71
67
|
export const LAW_CLASS = {
|
|
72
68
|
I: 'security', II: 'process', III: 'verify', IV: 'security', V: 'verify',
|
|
73
69
|
VI: 'security', VII: 'security', VIII: 'craft', IX: 'verify',
|
|
74
70
|
};
|
|
75
71
|
|
|
76
|
-
/**
|
|
72
|
+
/** The lifecycle statuses `registry.json` may carry. */
|
|
77
73
|
export const ENTITY_STATUSES = ['experimental', 'approved', 'deprecated'];
|
|
78
74
|
|
|
79
75
|
/**
|
|
80
|
-
*
|
|
76
|
+
* The six governance classes a law may carry.
|
|
81
77
|
*
|
|
82
78
|
* ⚠ SIX, THOUGH ONLY FOUR ARE IN USE. When the corpus became nine invariants, `context` and
|
|
83
79
|
* `comms` stopped having a member — that material moved to the ontology and the doctrine packs,
|
|
@@ -87,7 +83,7 @@ export const ENTITY_STATUSES = ['experimental', 'approved', 'deprecated'];
|
|
|
87
83
|
*/
|
|
88
84
|
export const LAW_CLASSES = ['security', 'process', 'verify', 'craft', 'context', 'comms'];
|
|
89
85
|
|
|
90
|
-
/**
|
|
86
|
+
/** Each skill's category, keyed by file stem. */
|
|
91
87
|
export const SKILL_CLASS = {
|
|
92
88
|
brainstorm: 'design', plan: 'design', council: 'design',
|
|
93
89
|
workflow: 'design', 'parallel-agents': 'design', pipeline: 'design',
|
|
@@ -109,7 +105,7 @@ export const SKILL_CLASS = {
|
|
|
109
105
|
// `understand` before, which made that class a grab-bag.
|
|
110
106
|
wiki: 'harness', geneseed: 'harness', rule: 'harness', profile: 'harness',
|
|
111
107
|
'skill-forge': 'harness', adhd: 'harness',
|
|
112
|
-
teach: 'learn',
|
|
108
|
+
teach: 'learn', 'learn-mode': 'learn',
|
|
113
109
|
};
|
|
114
110
|
|
|
115
111
|
/** `k in dict` — own keys only, where `k in obj` also finds `Object.prototype` members. */
|
|
@@ -122,10 +118,9 @@ const has = (obj, k) => Object.hasOwn(obj, k);
|
|
|
122
118
|
* (including a blank one) to the CURRENT record's body. Text before the first heading is
|
|
123
119
|
* dropped on the floor because `cur` is still null.
|
|
124
120
|
*
|
|
125
|
-
* `
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* it gates.
|
|
121
|
+
* `trim()`, applied at the end to every body. Its whitespace set differs from a
|
|
122
|
+
* strip-style one only at U+FEFF — a rendered body cannot end in a BOM, and a primitive to
|
|
123
|
+
* say so would cost more than it gates.
|
|
129
124
|
*/
|
|
130
125
|
function parseSections(text, re, makeRecord) {
|
|
131
126
|
const out = [];
|
|
@@ -145,7 +140,7 @@ function parseSections(text, re, makeRecord) {
|
|
|
145
140
|
}
|
|
146
141
|
|
|
147
142
|
/**
|
|
148
|
-
*
|
|
143
|
+
* The rendered laws file split into
|
|
149
144
|
* `{num, title, klass, body}`.
|
|
150
145
|
*/
|
|
151
146
|
function parseLaws(text) {
|
|
@@ -188,9 +183,9 @@ function parseOntology(text) {
|
|
|
188
183
|
}
|
|
189
184
|
|
|
190
185
|
/**
|
|
191
|
-
*
|
|
186
|
+
* The `entities` map from `registry.json`, or `{}`.
|
|
192
187
|
*
|
|
193
|
-
* Deliberately forgiving on BOTH failure modes
|
|
188
|
+
* Deliberately forgiving on BOTH failure modes: a missing file and a
|
|
194
189
|
* corrupt one both yield `{}`, which reads every badge as "unknown" rather than breaking
|
|
195
190
|
* the browser. `registryProblems` in `js/inspect/checks-repo.mjs` is the loud reader of the same file
|
|
196
191
|
* and stays separate — the two answer different questions.
|
|
@@ -207,7 +202,7 @@ export function loadRegistry() {
|
|
|
207
202
|
}
|
|
208
203
|
|
|
209
204
|
/**
|
|
210
|
-
*
|
|
205
|
+
* One entity's lifecycle status, plus the two derived
|
|
211
206
|
* states that are never stored.
|
|
212
207
|
*
|
|
213
208
|
* An entity the registry has never heard of is "personal": your own skill dropped into the
|
|
@@ -225,7 +220,7 @@ export function entityStatus(registry, key) {
|
|
|
225
220
|
}
|
|
226
221
|
|
|
227
222
|
/**
|
|
228
|
-
*
|
|
223
|
+
* Render-accurate inventory of all three constitutional tiers,
|
|
229
224
|
* plus every agent and skill with its one-line purpose, rendered spec, source and badge.
|
|
230
225
|
*
|
|
231
226
|
* THE WHOLE CATALOGUE, NOT THE BUILT SUBSET. All four pack files ship in every bundle
|