geneseed 4.32.0 → 5.0.1
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 +101 -0
- package/DESIGN.md +2 -2
- package/README.md +6 -5
- package/SHIPPED.md +4 -3
- package/adapters/bob/README.md +6 -5
- package/adapters/claude-code/README.md +4 -3
- package/adapters/claude-code/skills/geneseed/SKILL.md +1 -1
- package/adapters/openclaude/README.md +4 -3
- package/adapters/opencode/GLOBAL-HARNESS-SPEC.md +3 -1
- package/adapters/opencode/HOW-OPENCODE-LOADS.md +2 -1
- package/adapters/opencode/README.md +18 -18
- package/adapters/opencode/plugins/geneseed-activity.js +57 -1
- package/adapters/opencode/plugins/geneseed-context.js +85 -18
- package/adapters/opencode/plugins/geneseed-guard.js +437 -76
- package/adapters/opencode/plugins/geneseed-learn.js +97 -23
- package/bin/geneseed-cli.mjs +17 -25
- package/bin/geneseed-hook.mjs +23 -8
- package/docs/DESIGN.md +175 -0
- package/docs/PRD.md +111 -0
- package/docs/README.md +3 -2
- package/docs/architecture.md +145 -0
- package/docs/concepts/agents.md +1 -1
- package/docs/concepts/collaboration.md +1 -1
- package/docs/concepts/enforcement-table.md +1 -1
- package/docs/concepts/exclusions.md +5 -5
- package/docs/concepts/footprint.md +1 -1
- package/docs/concepts/foreman-mode.md +2 -2
- package/docs/concepts/hooks.md +22 -8
- package/docs/concepts/host-matrix.md +2 -2
- package/docs/concepts/hosts.md +1 -1
- package/docs/concepts/kits.md +3 -1
- package/docs/concepts/ownership.md +1 -1
- package/docs/concepts/rules.md +15 -2
- package/docs/concepts/shared-tier.md +73 -0
- package/docs/concepts/skills.md +2 -2
- package/docs/concepts/themes.md +1 -1
- package/docs/extending.md +13 -12
- package/docs/guides/install-claude-code.md +1 -1
- package/docs/guides/install-opencode.md +1 -1
- package/docs/guides/migrate.md +8 -4
- package/docs/guides/project-context.md +2 -2
- package/docs/guides/setup-footprint.md +1 -1
- package/docs/guides/uninstall.md +2 -1
- package/docs/guides/upgrade-to-5.md +118 -0
- package/docs/guides/upgrade.md +21 -9
- package/docs/guides/wiki.md +3 -3
- package/docs/reference/env-context.md +5 -3
- package/docs/reference/environment.md +1 -1
- package/docs/reference/glossary.md +2 -0
- package/docs/reference/opencode-plugins.md +3 -3
- package/docs/reference/plugin-activity.md +1 -1
- package/docs/reference/plugin-context.md +1 -0
- package/docs/reference/plugin-guard.md +14 -6
- package/docs/reference/plugin-learn.md +13 -6
- package/docs/reference/troubleshoot-hooks.md +3 -3
- package/docs/reference/troubleshoot-update.md +14 -0
- package/docs/token-footprint.md +4 -3
- package/docs/understand/a-day.md +2 -2
- package/docs/understand/design-choices-install.md +2 -1
- package/docs/understand/enforced-vs-asked.md +1 -1
- package/docs/understand/machine-bob.md +2 -0
- package/docs/understand/machine-claude.md +7 -5
- package/docs/understand/machine-opencode.md +7 -5
- package/docs/understand/on-your-machine.md +4 -0
- package/docs/understand/take-it-out.md +1 -1
- package/docs/web-ui.md +135 -70
- package/harness.config.json +1 -1
- package/js/README.md +12 -7
- 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/rule-decide.mjs +273 -0
- package/js/build/source.mjs +4 -1
- package/js/build/stubs.mjs +70 -9
- package/js/build/version.mjs +10 -10
- package/js/cli-table.json +23 -83
- package/js/hosts/activity.mjs +2 -2
- package/js/hosts/geneseed-dir.mjs +1 -1
- package/js/hosts/hooks-context.mjs +389 -99
- package/js/hosts/hooks-learn.mjs +38 -7
- package/js/hosts/hooks-prims.mjs +4 -2
- package/js/hosts/hooks.mjs +114 -39
- package/js/hosts/hosts.mjs +150 -51
- package/js/hosts/installs.mjs +59 -171
- 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 +191 -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 +110 -32
- 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 +35 -33
- package/js/lib/proc.mjs +1 -1
- package/js/lib/prompt.mjs +19 -27
- package/js/lib/text.mjs +8 -12
- package/js/lib/udiff.mjs +11 -15
- package/js/loop/catalog.mjs +2 -3
- package/js/maintain/memory.mjs +17 -17
- package/js/maintain/migrate.mjs +120 -92
- package/js/maintain/setup.mjs +43 -32
- package/js/maintain/uninstall.mjs +43 -61
- package/js/maintain/update.mjs +200 -93
- package/js/ui/anim.mjs +21 -35
- package/js/ui/cli.mjs +36 -58
- package/js/ui/menu.mjs +22 -45
- package/js/ui/tui.mjs +27 -67
- package/js/web/actions.mjs +34 -34
- package/js/web/api.mjs +142 -79
- 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 +16 -5
- package/js/web/routes.mjs +24 -22
- package/js/web/state.mjs +78 -19
- package/js/web/update-check.mjs +27 -12
- package/js/web/user-files.mjs +76 -104
- package/package.json +7 -4
- package/registry.json +48 -55
- package/src/AGENT.md.tmpl +13 -14
- package/src/agents/_self-improvement.md +1 -1
- package/src/agents/_template.md +1 -1
- package/src/agents/advocate.md +1 -1
- package/src/agents/architect.md +1 -1
- package/src/agents/developer.md +1 -1
- package/src/agents/devops-engineer.md +1 -1
- package/src/agents/docker-expert.md +1 -1
- package/src/agents/docs.md +1 -1
- package/src/agents/empiricist.md +1 -1
- package/src/agents/explorer.md +1 -1
- package/src/agents/framer.md +1 -1
- package/src/agents/historian.md +1 -1
- package/src/agents/kubernetes-specialist.md +1 -1
- package/src/agents/memory-curator.md +2 -2
- package/src/agents/operator.md +1 -1
- package/src/agents/performance.md +1 -1
- package/src/agents/pragmatist.md +1 -1
- package/src/agents/react-engineer.md +1 -1
- package/src/agents/react-reviewer.md +1 -1
- package/src/agents/researcher.md +1 -1
- package/src/agents/reviewer.md +1 -1
- package/src/agents/security.md +1 -1
- package/src/agents/skeptic.md +1 -1
- package/src/agents/spring-boot-engineer.md +1 -1
- package/src/agents/spring-reviewer.md +1 -1
- package/src/agents/spring-security.md +1 -1
- package/src/agents/steward.md +1 -1
- package/src/agents/tester.md +1 -1
- package/src/agents/user-advocate.md +1 -1
- package/src/agents/visionary.md +1 -1
- package/src/memory/README.md +1 -1
- package/src/skills/_self-improvement.md +2 -2
- package/src/skills/daydream/SKILL.md +2 -2
- package/src/skills/daydream/instructions.md +1 -1
- package/src/skills/geneseed.md +1 -1
- package/src/skills/learn-mode.md +1 -2
- package/src/skills/profile.md +2 -2
- package/src/skills/rule/approve.md +75 -0
- package/src/skills/rule/consolidate.md +3 -3
- package/src/skills/rule.md +14 -5
- package/src/skills/skill-forge.md +1 -1
- package/src/skills/teach.md +29 -12
- package/src/skills/wiki.md +1 -1
- package/themes/_TEMPLATE.json +1 -2
- package/themes/biker.json +1 -2
- package/themes/commentator.json +1 -2
- package/themes/cyberpunk.json +1 -2
- package/themes/gamer.json +1 -2
- package/themes/imperial.json +1 -2
- package/themes/joker.json +1 -2
- package/themes/marvin.json +1 -2
- package/themes/mean.json +1 -2
- package/themes/military.json +1 -2
- package/themes/neutral.json +1 -2
- package/themes/pirate.json +1 -2
- package/themes/sports.json +1 -2
- package/themes/verstappen.json +1 -2
- package/themes/wizard.json +1 -2
- package/web/dist/assets/Activity-Ci4PZco3.js +1 -0
- package/web/dist/assets/ActivityDetail-C8hroCND.js +1 -0
- package/web/dist/assets/AgentGlyph-k6o3gCM1.js +1 -0
- package/web/dist/assets/Bonsai-C1iBAt4v.js +1 -0
- package/web/dist/assets/{CopyButton-C5Li6awl.js → CopyButton-DJ3a4N88.js} +1 -1
- package/web/dist/assets/Dashboard-C_On4KXw.js +2 -0
- package/web/dist/assets/Docs-Kffdg5uV.js +5 -0
- package/web/dist/assets/GreenhouseView-k56_cBSF.js +1 -0
- package/web/dist/assets/Installs-DtEKLC9h.js +3 -0
- package/web/dist/assets/JournalView-RQnk5l7I.js +1 -0
- package/web/dist/assets/Kits-CXkEBpnf.js +1 -0
- package/web/dist/assets/Laws-DhhIVqmh.js +3 -0
- package/web/dist/assets/Library-CAUiEoJo.js +3 -0
- package/web/dist/assets/{Loops-CzitjxGV.js → Loops-LKD8mF4E.js} +2 -2
- package/web/dist/assets/{Markdown-C4S4tTA7.js → Markdown-0ORz7tAc.js} +21 -21
- package/web/dist/assets/OperatorHudView-CM5jNPwL.js +1 -0
- package/web/dist/assets/Personal-B6Uoly3C.js +2 -0
- package/web/dist/assets/{RailCats-D5weYPCS.js → RailCats-DQxxYBEP.js} +1 -1
- package/web/dist/assets/Settings-BTe6-wda.js +1 -0
- package/web/dist/assets/Tabs-CbdDWTp_.js +1 -0
- package/web/dist/assets/api-D_r0Jtla.js +1 -0
- package/web/dist/assets/controls-D4wmg_pl.js +1 -0
- package/web/dist/assets/index-HfGmYXab.js +3 -0
- package/web/dist/assets/index-ao3M-Fhm.css +1 -0
- package/web/dist/assets/motion-RlUl1osO.js +1 -0
- package/web/dist/assets/{sections-ChwaobfW.js → sections-CtFz7HFH.js} +1 -1
- package/web/dist/index.html +5 -5
- package/src/skills/quiz.md +0 -44
- package/web/dist/assets/Activity-Bjy64wHC.js +0 -1
- package/web/dist/assets/ActivityDetail-B0AaipP8.js +0 -1
- package/web/dist/assets/Bonsai-CJniRqaH.js +0 -1
- package/web/dist/assets/Dashboard-B-6DTmae.js +0 -2
- package/web/dist/assets/Docs-LRc30XL9.js +0 -5
- package/web/dist/assets/GreenhouseView-CcoYlaWo.js +0 -1
- package/web/dist/assets/Installs-dp1epTcE.js +0 -3
- package/web/dist/assets/JournalView-nFP4poCf.js +0 -1
- package/web/dist/assets/KitApply-DwyZUj57.js +0 -1
- package/web/dist/assets/Kits-C0IEdZXe.js +0 -1
- package/web/dist/assets/Laws-CkykmQWu.js +0 -3
- package/web/dist/assets/Library-Guh9HBZU.js +0 -2
- package/web/dist/assets/OperatorHudView-DLGNulIY.js +0 -1
- package/web/dist/assets/Personal-BMtberL8.js +0 -2
- package/web/dist/assets/Tabs-uYJqfuQt.js +0 -1
- package/web/dist/assets/api-BxjLd7Qd.js +0 -1
- package/web/dist/assets/index-DA7BiaE5.js +0 -3
- package/web/dist/assets/index-dbbDGFDq.css +0 -1
- package/web/dist/assets/motion-Bccx3zE8.js +0 -1
package/js/hosts/hosts.mjs
CHANGED
|
@@ -19,8 +19,13 @@ import path from 'node:path';
|
|
|
19
19
|
import os from 'node:os';
|
|
20
20
|
import { printErr, withDiscardableStderr, isDir, isFile, readText } from '../lib/fs.mjs';
|
|
21
21
|
import { toPlatformPath, normcase } from '../lib/paths.mjs';
|
|
22
|
+
import { sharedPaths, machineDir } from '../lib/machine-dir.mjs';
|
|
22
23
|
import { mainWorktreeOf } from './gitref.mjs';
|
|
23
24
|
|
|
25
|
+
/** The marker a project built `--shared-tier on` carries, and its one reader. The OpenCode context plugin holds a copy. */
|
|
26
|
+
export const SHARED_TIER_LINE = 'Shared tier: on';
|
|
27
|
+
export const SHARED_TIER_RE = /^Shared tier:[ \t]*on[ \t]*\r?$/m;
|
|
28
|
+
|
|
24
29
|
/** `_build_global.GLOBAL_MANIFEST` — the file whose presence means "a global install". */
|
|
25
30
|
export const GLOBAL_MANIFEST = '.geneseed-manifest.json';
|
|
26
31
|
|
|
@@ -47,6 +52,9 @@ export const ADVISORY_VERB = 'done-gate-advisory';
|
|
|
47
52
|
* second copy in `js/inspect/` was the alternative, and a copy is what let the `~user`
|
|
48
53
|
* refusal diverge between the two CLIs once already (see `hooks.mjs`'s header).
|
|
49
54
|
*
|
|
55
|
+
* SHARED LIST: a global install also honours `excludes.json` in the machine tier (B8: the lists
|
|
56
|
+
* drifted across hosts). The OpenCode plugins carry the same union in their twins.
|
|
57
|
+
*
|
|
50
58
|
* A LINKED GIT WORKTREE OF AN EXCLUDED REPO IS EXCLUDED TOO, wherever it sits on disk: the
|
|
51
59
|
* cwd matches, or the main worktree `mainWorktreeOf` reads off the `.git` file does. An
|
|
52
60
|
* exclusion names a repository the user keeps sovereign, not a folder; a worktree elsewhere
|
|
@@ -54,13 +62,22 @@ export const ADVISORY_VERB = 'done-gate-advisory';
|
|
|
54
62
|
*/
|
|
55
63
|
export function sovereignBypass(root) {
|
|
56
64
|
if (!root) return false;
|
|
57
|
-
|
|
65
|
+
const listOf = (file) => {
|
|
66
|
+
try {
|
|
67
|
+
const data = JSON.parse(readText(file));
|
|
68
|
+
return Array.isArray(data && data.excludes) ? data.excludes : [];
|
|
69
|
+
} catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const entries = listOf(path.join(root, EXCLUDES_FILE));
|
|
74
|
+
// The shared list (`<machineDir>/excludes.json`) adds to a GLOBAL install's own, never to a
|
|
75
|
+
// project install's: a folder excluded for the global harness must not silence a project
|
|
76
|
+
// install that lives inside it. The tier test runs only when the shared list has entries.
|
|
58
77
|
try {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
} catch {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
78
|
+
const shared = listOf(path.join(machineDir(), EXCLUDES_FILE));
|
|
79
|
+
if (shared.length && isGlobalInstall(null, root)) entries.push(...shared);
|
|
80
|
+
} catch { /* no home dir, or an unresolvable config dir: the host list alone */ }
|
|
64
81
|
// Nothing to match, so no reason to pay for the cwd and `.git` reads below on every hook call.
|
|
65
82
|
if (!entries.length) return false;
|
|
66
83
|
let heres;
|
|
@@ -78,11 +95,11 @@ export function sovereignBypass(root) {
|
|
|
78
95
|
if (typeof raw !== 'string' || !raw.trim()) continue;
|
|
79
96
|
let base;
|
|
80
97
|
try {
|
|
81
|
-
// `.rstrip("\\/")` AFTER normcase,
|
|
98
|
+
// `.rstrip("\\/")` AFTER normcase, so the separator
|
|
82
99
|
// test below cannot be fooled by a trailing slash in the user's file.
|
|
83
100
|
//
|
|
84
101
|
// `withDiscardableStderr` because `expanduser` writes its refusal at the RAISE SITE
|
|
85
|
-
// and this caller catches:
|
|
102
|
+
// and this caller catches: nothing should print here, so replaying the
|
|
86
103
|
// message would be a stderr divergence on every hook call for one bad entry.
|
|
87
104
|
//
|
|
88
105
|
// `resolvePath`, the same resolution as `heres` above: symlinks and junctions are followed on
|
|
@@ -211,7 +228,7 @@ function projectWiresVerb(cand, verb) {
|
|
|
211
228
|
}
|
|
212
229
|
|
|
213
230
|
/**
|
|
214
|
-
*
|
|
231
|
+
* The file this install's hooks were actually wired into.
|
|
215
232
|
*
|
|
216
233
|
* `settings.local.json` for a Claude or OpenClaude PROJECT install (personal, untracked),
|
|
217
234
|
* `settings.json` everywhere else (including Bob's, which documents no local variant), and
|
|
@@ -236,7 +253,7 @@ function emitMarkerOf(dir) {
|
|
|
236
253
|
try { return readText(path.join(dir, '.geneseed-emit')).trim(); } catch { return ''; }
|
|
237
254
|
}
|
|
238
255
|
|
|
239
|
-
/**
|
|
256
|
+
/** A sibling dir whose presence means "disabled". */
|
|
240
257
|
export const DISABLED_STASH = '.geneseed-disabled';
|
|
241
258
|
|
|
242
259
|
/**
|
|
@@ -250,7 +267,7 @@ export const DISABLED_STASH = '.geneseed-disabled';
|
|
|
250
267
|
* only against `configDir()` made `rebuild-all` re-emit it as a PROJECT rooted at `$HOME`;
|
|
251
268
|
* * its own `.geneseed-emit` names a `-global` emit (`<host>-global` when `host` is given).
|
|
252
269
|
* Case-folded on Windows. A `configDir()` that throws propagates: each caller already has the
|
|
253
|
-
* catch that says what "cannot tell" means for it (the
|
|
270
|
+
* catch that says what "cannot tell" means for it (`isGlobalInstall` is the one most share).
|
|
254
271
|
*/
|
|
255
272
|
export function isHostGlobalDir(host, dir) {
|
|
256
273
|
const emit = emitMarkerOf(dir);
|
|
@@ -261,6 +278,28 @@ export function isHostGlobalDir(host, dir) {
|
|
|
261
278
|
&& normcase(resolvePath(path.join(os.homedir(), h.projectMarker))) === c)));
|
|
262
279
|
}
|
|
263
280
|
|
|
281
|
+
/**
|
|
282
|
+
* `isHostGlobalDir` for the callers that read "cannot tell" as "not global": whatever reads the
|
|
283
|
+
* machine tier stays on its own layer then, and no refusal printed on the way reaches stderr. A
|
|
284
|
+
* caller whose "cannot tell" must fail the other way (`holdsInstall`'s) keeps its own catch.
|
|
285
|
+
*/
|
|
286
|
+
export function isGlobalInstall(host, dir) {
|
|
287
|
+
try { return withDiscardableStderr(() => isHostGlobalDir(host, dir)); } catch { return false; }
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Is `cfgDir` the one directory `host`'s `configDir()` resolves to? Only such an install creates
|
|
292
|
+
* and folds the shared tier. Stricter than `isHostGlobalDir` on purpose: `diff` renders a global
|
|
293
|
+
* emit into a temp dir and `rebuild-all` passes `--config-dir` for every row, so neither a
|
|
294
|
+
* `-global` marker, the flag nor a default `~/.claude` proves this is the live install.
|
|
295
|
+
*/
|
|
296
|
+
export function isCanonical(cfgDir, host) {
|
|
297
|
+
const row = HOSTS.find((h) => h.host === host);
|
|
298
|
+
try {
|
|
299
|
+
return !!row && normcase(resolvePath(cfgDir)) === normcase(resolvePath(row.configDir()));
|
|
300
|
+
} catch { return false; }
|
|
301
|
+
}
|
|
302
|
+
|
|
264
303
|
/**
|
|
265
304
|
* The project root a hook judges against: `$CLAUDE_PROJECT_DIR` (Claude Code and OpenClaude set
|
|
266
305
|
* it for every hook — the session's root, where its project hooks were loaded from), else the
|
|
@@ -281,23 +320,11 @@ export const VERSION_MARKER = '.geneseed-version';
|
|
|
281
320
|
/**
|
|
282
321
|
* `Path.expanduser()` — a LEADING `~` only, and `~` alone counts.
|
|
283
322
|
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
* AND THE POSIX HALF OF THAT SENTENCE WAS WRONG IN ITS TURN, corrected here while the
|
|
291
|
-
* reference is still on the machine to ask. `posixpath.expanduser` does the analogous thing
|
|
292
|
-
* through the password database and returns the path unchanged when the account is unknown
|
|
293
|
-
* — but the reference does not call it. It calls `Path.expanduser`, which re-checks the
|
|
294
|
-
* result and RAISES `RuntimeError: Could not determine home directory.` So the divergence
|
|
295
|
-
* below is WINDOWS-ONLY: on POSIX the reference and this port already agree in kind — both
|
|
296
|
-
* refuse — and differ only in which exception says so.
|
|
297
|
-
*
|
|
298
|
-
* This port deliberately does NEITHER. Reproducing `ntpath`'s swap faithfully needs its own
|
|
299
|
-
* corpus, and the Python reference is being deleted, so byte-parity on this one input stops
|
|
300
|
-
* mattering the moment it is. What matters instead is that a `~user` form never resolves
|
|
323
|
+
* `ntpath.expanduser('~someuser/x')` swaps the last component of `%USERPROFILE%`, expanding a
|
|
324
|
+
* name that may not be a real account. `Path.expanduser` on POSIX raises when the account is
|
|
325
|
+
* unknown. The two disagree, so the divergence is WINDOWS-ONLY.
|
|
326
|
+
*
|
|
327
|
+
* This port deliberately does NEITHER. What matters is that a `~user` form never resolves
|
|
301
328
|
* SILENTLY to the wrong place: the old code below returned it untouched, so
|
|
302
329
|
* `--target ~someone/x` created a literal `~someone` directory in whatever cwd the user ran
|
|
303
330
|
* from. It now REFUSES the form outright. This is the single primitive every config-dir env
|
|
@@ -430,8 +457,8 @@ export function openclaudeConfigDir() {
|
|
|
430
457
|
*
|
|
431
458
|
* `projectMarker` joined in P5f. `_install_targets` asks "does this cwd carry a project
|
|
432
459
|
* install of host H", and `_claude_cfg` asks "which subdir holds a project install's
|
|
433
|
-
* manifest" — both are the same `.opencode`/`.claude`/`.bob`/`.openclaude` value
|
|
434
|
-
*
|
|
460
|
+
* manifest" — both are the same `.opencode`/`.claude`/`.bob`/`.openclaude` value as
|
|
461
|
+
* `build.HOSTS[host]["project_marker"]`, so it belongs beside the config dir rather
|
|
435
462
|
* than in a second table in `js/hosts/installs.mjs`.
|
|
436
463
|
*
|
|
437
464
|
* `agentFile` joined in P5h, and for one caller: `cmd_uninstall` names the managed block's
|
|
@@ -463,6 +490,55 @@ export const HOSTS = [
|
|
|
463
490
|
{ host: 'openclaude', family: 'claude', configDir: openclaudeConfigDir, projectMarker: '.openclaude', agentFile: 'CLAUDE.md', catalog: { skills: true, agents: true }, carrierInLayer: true },
|
|
464
491
|
];
|
|
465
492
|
|
|
493
|
+
/**
|
|
494
|
+
* The four root-level carriers, plus one more.
|
|
495
|
+
*
|
|
496
|
+
* A shared table rather than three copies of the same list: `_theme_of_dir`,
|
|
497
|
+
* `_posture_of_dir` and `_mode_of_dir` each walk it, and the order is observable (the first
|
|
498
|
+
* carrier that answers wins). `rules/geneseed.md` is spelled with `path.join` at each use.
|
|
499
|
+
*
|
|
500
|
+
* `.openclaude/CLAUDE.md` is half
|
|
501
|
+
* of the fix for host-compat verdict B1 (the other half is `carriersFor`, below).
|
|
502
|
+
* OpenClaude's own per-repo carrier is `carrierInLayer` (see `CLAUDE_SHAPED.openclaude` in
|
|
503
|
+
* `js/build/driver.mjs`, and the `HOSTS` column of the same name): it sits at
|
|
504
|
+
* `<repo>/.openclaude/CLAUDE.md`, and the root `CLAUDE.md` is deliberately left untouched so a
|
|
505
|
+
* Claude Code install can share the repo.
|
|
506
|
+
*
|
|
507
|
+
* ⚠ THIS LIST STAYS HOST-AGNOSTIC ON PURPOSE — it is only `firstCarrier`'s FALLBACK for a
|
|
508
|
+
* caller with no host to narrow by (none of this module's exported `*OfDir` readers is one;
|
|
509
|
+
* see `carriersFor`). A caller that DOES have a host must pass it, or in a repo sharing two
|
|
510
|
+
* carriers that answer the same probe — only root `CLAUDE.md` today, between `claude` and
|
|
511
|
+
* `openclaude`'s global scope — this host-agnostic order decides for both of them, which was
|
|
512
|
+
* exactly B1's failure mode reversed: reading `.openclaude/CLAUDE.md` unconditionally made
|
|
513
|
+
* `claude`'s OWN read-back answer OpenClaude's settings in a shared repo.
|
|
514
|
+
*/
|
|
515
|
+
export const CARRIERS = [
|
|
516
|
+
'AGENT.md', path.join('.openclaude', 'CLAUDE.md'), 'CLAUDE.md',
|
|
517
|
+
path.join('rules', 'geneseed.md'), 'AGENTS.md',
|
|
518
|
+
];
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* `host`'s own carrier path(s), narrowed off the single `HOSTS` table — `carrierInLayer` and
|
|
522
|
+
* `projectMarker`/`agentFile` — rather than a second hand-rolled host→carrier map.
|
|
523
|
+
*
|
|
524
|
+
* ONE HOST, ONE ANSWER, EXCEPT BOB. `carrierInLayer` true (OpenClaude only) tries the nested
|
|
525
|
+
* per-repo path FIRST and the bare `agentFile` SECOND, because the same column name means two
|
|
526
|
+
* different locations depending on scope: `<repo>/.openclaude/CLAUDE.md` for a project
|
|
527
|
+
* install, `<cfgDir>/CLAUDE.md` for a global one (see `CLAUDE_SHAPED.openclaude-global`,
|
|
528
|
+
* which has no `carrierInLayer`). Bob is the one host with a second, differently-NAMED
|
|
529
|
+
* carrier — `rules/geneseed.md` at global scope, because Bob never auto-loads a global
|
|
530
|
+
* `AGENTS.md` (`CLAUDE_SHAPED['bob-global']`'s summary says so) — which `HOSTS` has no column
|
|
531
|
+
* for and this hard-codes, same as the un-narrowed `CARRIERS` above always did.
|
|
532
|
+
*/
|
|
533
|
+
export function carriersFor(host) {
|
|
534
|
+
const row = HOSTS.find((h) => h.host === host);
|
|
535
|
+
if (!row) return CARRIERS;
|
|
536
|
+
if (host === 'bob') return [path.join('rules', 'geneseed.md'), row.agentFile];
|
|
537
|
+
return row.carrierInLayer
|
|
538
|
+
? [path.join(row.projectMarker, row.agentFile), row.agentFile]
|
|
539
|
+
: [row.agentFile];
|
|
540
|
+
}
|
|
541
|
+
|
|
466
542
|
/** Each Claude-family host's project marker, keyed by host — `globalHookStandingDown`'s table. */
|
|
467
543
|
const STAND_DOWN_MARKERS = Object.fromEntries(HOSTS.filter((h) => h.family === 'claude')
|
|
468
544
|
.map((h) => [h.host, h.projectMarker]));
|
|
@@ -478,7 +554,7 @@ export const CLAUDE_STYLE = HOSTS.filter((h) => h.family === 'claude').map((h) =
|
|
|
478
554
|
* that catalogues natively gets AGENT.md's tables collapsed to a pointer and comparing the
|
|
479
555
|
* portable shape against its bundle reports AGENT.md stale on every run forever. It is a
|
|
480
556
|
* column and not a set literal so that the capability is declared in exactly one place
|
|
481
|
-
*
|
|
557
|
+
* The driver reads it through this function too.
|
|
482
558
|
*
|
|
483
559
|
* Unknown host -> false, which is the shape that KEEPS the tables. The value arrives from a
|
|
484
560
|
* user-editable `.geneseed-emit` marker, so an unrecognised one must degrade to the portable
|
|
@@ -497,17 +573,44 @@ export function hostCatalogsNatively(host) {
|
|
|
497
573
|
return HOSTS.find((h) => h.host === host)?.catalog || false;
|
|
498
574
|
}
|
|
499
575
|
|
|
500
|
-
/** `
|
|
501
|
-
|
|
576
|
+
/** Did an emit make `base`? Every one leaves the version marker there and the index in `memory/`. */
|
|
577
|
+
function holdsInstall(base) {
|
|
578
|
+
if (!isFile(path.join(base, VERSION_MARKER)) || !isFile(path.join(base, 'memory', 'MEMORY.md'))) return false;
|
|
579
|
+
try { return !withDiscardableStderr(() => isHostGlobalDir(null, base)); } catch { return false; /* no home: cannot tell, so a destructive path fails closed */ }
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* The stores of the project install or bundle rooted at `root`, the marker's own first, so a repo
|
|
584
|
+
* that two hosts share answers with the host that emitted last. A Claude-family project keeps its
|
|
585
|
+
* data under its layer; OpenCode and the bundle at the root. A marker is only a claim: a stale or
|
|
586
|
+
* hand-written one over a repo's own folder must not make that folder deletable (I4).
|
|
587
|
+
*/
|
|
588
|
+
function projectStores(root) {
|
|
589
|
+
const emit = emitMarkerOf(root);
|
|
590
|
+
if (emit !== 'files' && !HOSTS.some((h) => h.host === emit)) return [];
|
|
591
|
+
const layers = HOSTS.filter((h) => h.family === 'claude').map((h) => h.projectMarker);
|
|
592
|
+
const own = HOSTS.find((h) => h.host === emit && h.family === 'claude')?.projectMarker ?? '';
|
|
593
|
+
return [...new Set([own, ...layers, ''])].map((l) => path.join(root, l)).filter(holdsInstall)
|
|
594
|
+
.map((base) => path.join(base, 'memory'));
|
|
595
|
+
}
|
|
502
596
|
|
|
503
597
|
/**
|
|
504
|
-
*
|
|
598
|
+
* Where `learn` dedups and indexes, and what
|
|
505
599
|
* `status` reports on its memory row.
|
|
506
600
|
*
|
|
507
|
-
* Precedence: `--memory` > `$GENESEED_MEMORY` >
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
601
|
+
* Precedence: `--memory` > `$GENESEED_MEMORY` > `$GENESEED_HARNESS/memory` > the store of a project
|
|
602
|
+
* install in the cwd or `./Harness` > the shared store (`<machine dir>/memory`) > the OpenCode
|
|
603
|
+
* GLOBAL config dir's store. Each counts only when it exists, so a machine without the shared
|
|
604
|
+
* tier falls through. null => stdout-only. The learn plugin knows its own install and ends in a
|
|
605
|
+
* bare `./memory`: it only ever writes. This resolver also serves `memory rm --purge`.
|
|
606
|
+
*
|
|
607
|
+
* A FOLDER NAMED `memory` IS NOT A STORE (I4). `memory rm --purge` deleted a repo's own
|
|
608
|
+
* `memory/design-notes.md` when the mere name was enough, so only an install makes the folder
|
|
609
|
+
* count (`projectStores`). Without one it is reached through `--memory`.
|
|
610
|
+
*
|
|
611
|
+
* ONLY `memory` NAMES A STORE. The imperial theme's `anamnesis` alias matched Terra's
|
|
612
|
+
* `Anamnesis/` vault by Windows case folding (B3) and `learn` wrote facts into it. The alias is
|
|
613
|
+
* read only where it is copied forward (`globalMemory`, `migrateStrayBundle`).
|
|
511
614
|
*
|
|
512
615
|
* HERE rather than in `js/hosts/hooks.mjs`, where it was written, because P5d gave it a second
|
|
513
616
|
* caller that cannot import that file: `bin/geneseed-cli.mjs` is under a transitive
|
|
@@ -522,8 +625,7 @@ export function resolveMemoryDir(explicit) {
|
|
|
522
625
|
}
|
|
523
626
|
const env = process.env.GENESEED_MEMORY;
|
|
524
627
|
if (env && isDir(env)) return toPlatformPath(env);
|
|
525
|
-
const
|
|
526
|
-
const bases = [cwd, path.join(cwd, 'Harness')];
|
|
628
|
+
const stores = [];
|
|
527
629
|
const gh = process.env.GENESEED_HARNESS;
|
|
528
630
|
if (gh) {
|
|
529
631
|
// PER BASE, and the walk continues. `$GENESEED_HARNESS` is the FOURTH user-controlled
|
|
@@ -534,16 +636,13 @@ export function resolveMemoryDir(explicit) {
|
|
|
534
636
|
// trace on a hook path and a non-zero exit, the exact failure the other three guards
|
|
535
637
|
// exist to prevent. Skipping the base degrades to "no memory store from $GENESEED_HARNESS",
|
|
536
638
|
// which is what an unset variable already does. `withDiscardableStderr` because the
|
|
537
|
-
// refusal prints at the RAISE SITE and both callers byte-compare stderr
|
|
538
|
-
//
|
|
539
|
-
try {
|
|
540
|
-
}
|
|
541
|
-
try { bases.push(opencodeConfigDir()); } catch { /* best-effort, as the Python */ }
|
|
542
|
-
for (const base of bases) {
|
|
543
|
-
for (const name of MEMORY_DIR_NAMES) {
|
|
544
|
-
const cand = path.join(base, name);
|
|
545
|
-
if (isDir(cand)) return cand;
|
|
546
|
-
}
|
|
639
|
+
// refusal prints at the RAISE SITE and both callers byte-compare stderr, and nothing
|
|
640
|
+
// may print here.
|
|
641
|
+
try { stores.push(path.join(withDiscardableStderr(() => expanduser(gh)), 'memory')); } catch { /* skip it */ }
|
|
547
642
|
}
|
|
548
|
-
|
|
643
|
+
const cwd = process.cwd();
|
|
644
|
+
stores.push(...[cwd, path.join(cwd, 'Harness')].flatMap(projectStores));
|
|
645
|
+
try { stores.push(sharedPaths().memory); } catch { /* no home dir: no shared store */ }
|
|
646
|
+
try { stores.push(path.join(opencodeConfigDir(), 'memory')); } catch { /* best-effort */ }
|
|
647
|
+
return stores.find(isDir) ?? null;
|
|
549
648
|
}
|