geneseed 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +30 -0
- package/SHIPPED.md +1 -1
- package/adapters/bob/README.md +12 -1
- package/adapters/opencode/README.md +2 -1
- package/adapters/opencode/plugins/geneseed-context.js +71 -10
- package/adapters/opencode/plugins/geneseed-guard.js +101 -19
- package/adapters/opencode/plugins/geneseed-learn.js +641 -6
- package/bin/geneseed-cli.mjs +3 -0
- package/bin/geneseed-hook.mjs +2 -1
- package/docs/concepts/agents.md +13 -1
- package/docs/concepts/enforcement-table.md +1 -1
- package/docs/concepts/foreman-mode.md +22 -3
- package/docs/concepts/hook-gates.md +1 -1
- package/docs/concepts/hooks.md +22 -5
- package/docs/concepts/host-matrix.md +2 -2
- package/docs/concepts/hosts.md +1 -1
- package/docs/concepts/shared-tier.md +1 -1
- package/docs/concepts/skills.md +21 -1
- package/docs/concepts/themes.md +1 -1
- package/docs/extending.md +10 -1
- package/docs/guides/install-clone.md +18 -0
- package/docs/guides/install-scripted.md +8 -2
- package/docs/guides/install.md +19 -1
- package/docs/guides/upgrade.md +1 -1
- package/docs/reference/env-context.md +1 -1
- package/docs/reference/environment.md +1 -1
- package/docs/reference/plugin-learn.md +4 -0
- package/docs/reference/profiles.md +142 -0
- package/docs/token-footprint.md +9 -4
- package/docs/understand/design-choices-engineering.md +1 -1
- package/docs/web-ui.md +3 -1
- package/harness.config.json +1 -1
- package/js/README.md +9 -2
- package/js/build/args.mjs +4 -3
- package/js/build/catalog.mjs +11 -1
- package/js/build/driver.mjs +42 -11
- package/js/build/emit-claude.mjs +24 -1
- package/js/build/emit-opencode.mjs +3 -0
- package/js/build/export.mjs +1 -1
- package/js/build/generate.mjs +2 -1
- package/js/build/notes-migrate.mjs +99 -0
- package/js/build/profile.mjs +14 -6
- package/js/build/render.mjs +34 -10
- package/js/build/source.mjs +85 -2
- package/js/cli-table.json +164 -4
- package/js/hosts/agent-runs.mjs +205 -0
- package/js/hosts/done-checks.mjs +3 -1
- package/js/hosts/hooks-done.mjs +91 -16
- package/js/hosts/hooks-learn.mjs +85 -0
- package/js/hosts/hooks-prims.mjs +39 -1
- package/js/hosts/hooks.mjs +6 -3
- package/js/hosts/hosts.mjs +10 -0
- package/js/hosts/installs.mjs +25 -1
- package/js/hosts/link.mjs +45 -10
- package/js/hosts/native.mjs +42 -5
- package/js/hosts/opencode.mjs +1 -1
- package/js/hosts/settings.mjs +72 -0
- package/js/hosts/spec-feedback.mjs +538 -0
- package/js/hosts/usage.mjs +67 -8
- package/js/inspect/agent-scores.mjs +118 -0
- package/js/inspect/checks-authoring.mjs +2 -1
- package/js/inspect/checks-build.mjs +20 -4
- package/js/inspect/checks-repo.mjs +27 -2
- package/js/inspect/cost.mjs +6 -5
- package/js/inspect/diff.mjs +25 -5
- package/js/inspect/doctor.mjs +4 -0
- package/js/inspect/status.mjs +3 -1
- package/js/inspect/validate.mjs +1 -0
- package/js/lib/machine-dir.mjs +8 -0
- package/js/lib/paths.mjs +4 -1
- package/js/maintain/profile-scope.mjs +145 -0
- package/js/maintain/profiles.mjs +486 -0
- package/js/maintain/setup.mjs +409 -15
- package/js/maintain/uninstall.mjs +4 -1
- package/js/maintain/update.mjs +1 -1
- package/js/web/actions.mjs +28 -38
- package/js/web/api.mjs +7 -2
- package/js/web/handler.mjs +8 -0
- package/js/web/jobs.mjs +5 -4
- package/js/web/profiles-api.mjs +201 -0
- package/js/web/routes.mjs +5 -0
- package/package.json +2 -1
- package/profiles/guillaume-claude-global.json +16 -0
- package/profiles/starter.json +14 -0
- package/src/AGENT.md.tmpl +1 -1
- package/src/agents/_self-improvement.md +15 -7
- package/src/agents/_template.md +4 -2
- package/src/agents/advocate.md +1 -1
- package/src/agents/architect.md +1 -1
- package/src/agents/developer.md +10 -3
- package/src/agents/devops-engineer.md +1 -1
- package/src/agents/docker-expert.md +1 -1
- package/src/agents/docs.md +1 -1
- package/src/agents/empiricist.md +1 -1
- package/src/agents/explorer.md +4 -2
- package/src/agents/framer.md +1 -1
- package/src/agents/historian.md +1 -1
- package/src/agents/kubernetes-specialist.md +1 -1
- package/src/agents/memory-curator.md +1 -1
- package/src/agents/operator.md +1 -1
- package/src/agents/performance.md +1 -1
- package/src/agents/pragmatist.md +1 -1
- package/src/agents/react-engineer.md +1 -1
- package/src/agents/react-reviewer.md +1 -1
- package/src/agents/researcher.md +1 -1
- package/src/agents/reviewer.md +10 -3
- package/src/agents/security.md +1 -1
- package/src/agents/skeptic.md +1 -1
- package/src/agents/spring-boot-engineer.md +1 -1
- package/src/agents/spring-reviewer.md +1 -1
- package/src/agents/spring-security.md +1 -1
- package/src/agents/steward.md +1 -1
- package/src/agents/tester.md +4 -2
- package/src/agents/user-advocate.md +1 -1
- package/src/agents/visionary.md +1 -1
- package/src/memory/README.md +12 -2
- package/src/modes/foreman.md +23 -10
- package/src/skill-descriptions.json +63 -0
- package/src/skills/_self-improvement.md +42 -26
- package/src/skills/_template.md +3 -1
- package/src/skills/brainstorm.md +35 -22
- package/src/skills/daydream/VENDOR.md +6 -0
- package/src/skills/diagram-design/VENDOR.md +4 -0
- package/src/skills/explain-changes/VENDOR.md +5 -1
- package/src/skills/parallel-agents.md +11 -0
- package/src/skills/pipeline.md +3 -3
- package/src/skills/plan.md +5 -4
- package/src/skills/react-view-transitions/VENDOR.md +7 -1
- package/src/skills/release.md +7 -2
- package/src/skills/rule/approve.md +2 -1
- package/src/skills/skill-forge.md +5 -3
- package/src/skills/token-report/VENDOR.md +5 -1
- package/src/upstreams.json +2 -2
- package/themes/README.md +3 -1
- package/web/dist/assets/{ActiveLoops-BJJN3P-V.js → ActiveLoops-DOJCPPPc.js} +1 -1
- package/web/dist/assets/{Activity-D2kOc3yi.js → Activity-LKsDzsnK.js} +1 -1
- package/web/dist/assets/{ActivityDetail-By3xOr21.js → ActivityDetail-DhwTfPm6.js} +1 -1
- package/web/dist/assets/{Bonsai-CBWDTBA4.js → Bonsai-CePMLrpr.js} +1 -1
- package/web/dist/assets/{CopyButton-BVbpriMB.js → CopyButton-CuoaJ6k7.js} +1 -1
- package/web/dist/assets/{Dashboard-CIJLPHM9.js → Dashboard-D1VKuvLe.js} +2 -2
- package/web/dist/assets/{Docs-CiRRIELs.js → Docs-CUrHJKaU.js} +1 -1
- package/web/dist/assets/{Factories-DhyK0O8d.js → Factories-Ci1XfmSy.js} +1 -1
- package/web/dist/assets/{GreenhouseView-DW3PgTPy.js → GreenhouseView-CNfH2lPK.js} +1 -1
- package/web/dist/assets/Installs-ZHQZM1iS.js +3 -0
- package/web/dist/assets/{JournalView-O65qEWfp.js → JournalView-CMsWahkS.js} +1 -1
- package/web/dist/assets/{Kits-C5U-yT6Z.js → Kits-CkliyK0n.js} +1 -1
- package/web/dist/assets/{Laws-CuTw_XNf.js → Laws-hh4O3HZ4.js} +1 -1
- package/web/dist/assets/{LibRows-D6-CVa3K.js → LibRows-Brv0Hmkr.js} +1 -1
- package/web/dist/assets/{Library-CzPlerd6.js → Library-BYmiLjJr.js} +1 -1
- package/web/dist/assets/{Loops-CqNF_-nS.js → Loops-ytm-xJ68.js} +1 -1
- package/web/dist/assets/{OperatorHudView-BNr8K5qj.js → OperatorHudView-KaqCx_HP.js} +1 -1
- package/web/dist/assets/{Personal-DeDb9e8O.js → Personal-CmcnRKYE.js} +1 -1
- package/web/dist/assets/{Settings-B8MPN_AD.js → Settings-tUrpdOfq.js} +1 -1
- package/web/dist/assets/{Tabs-DJzAez4h.js → Tabs-CD7etcGD.js} +1 -1
- package/web/dist/assets/api-CZ-x0iWG.js +1 -0
- package/web/dist/assets/{controls-D4wmg_pl.js → controls-CK7qHA8H.js} +1 -1
- package/web/dist/assets/{index-CRWqKxfY.css → index-Ba_Kg3Af.css} +1 -1
- package/web/dist/assets/{index-BL3P-9Rg.js → index-COKbhFNo.js} +3 -3
- package/web/dist/index.html +3 -3
- package/web/dist/assets/Installs-B6nlo-Ly.js +0 -3
- package/web/dist/assets/api-DLDVY3K-.js +0 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `geneseed catalog agents --scores` — the read side of the agent outcome ledger
|
|
3
|
+
* (js/hosts/agent-runs.mjs writes it). One table per active install that holds a ledger: a row per
|
|
4
|
+
* agent and spec hash, so the runs before a spec edit and the runs after it are two rows to compare.
|
|
5
|
+
*
|
|
6
|
+
* READ-ONLY. A hook may append at any moment, so the file is never rewritten here; a garbage line
|
|
7
|
+
* is skipped, never fatal.
|
|
8
|
+
*
|
|
9
|
+
* WHAT A COLUMN MEANS, and what it cannot mean. UNBLOCKED is `never blocked / judged`, over the
|
|
10
|
+
* runs the done gate judged (`done: "ended"`): the gate's return cannot tell a pass from an
|
|
11
|
+
* advisory or a spent cap (agent-runs.mjs header), so this is not a pass rate. REFUSED and TOOLS
|
|
12
|
+
* are means per run over the runs that carry a count, with that count in brackets, and `-` below
|
|
13
|
+
* MEAN_FLOOR such runs; FEEDBACK is the spec-feedback lines the reports carried, summed; REPORTS is
|
|
14
|
+
* the runs that ended with a report. SINCE and LAST are the first and last day a row was seen.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
|
|
19
|
+
import { CLAUDE_STYLE, HOSTS } from '../hosts/hosts.mjs';
|
|
20
|
+
import { installState, installTargets } from '../hosts/installs.mjs';
|
|
21
|
+
import { RUNS_LEDGER, USAGE_OFF } from '../hosts/usage.mjs';
|
|
22
|
+
import { printErr, printOut } from '../lib/fs.mjs';
|
|
23
|
+
import { padEndToWidth } from '../lib/text.mjs';
|
|
24
|
+
|
|
25
|
+
const isCount = (n) => Number.isInteger(n) && n >= 0;
|
|
26
|
+
|
|
27
|
+
/** The ledger's well-formed lines, in file order. A missing file is no runs. */
|
|
28
|
+
export function readRuns(file) {
|
|
29
|
+
let raw;
|
|
30
|
+
try { raw = readFileSync(file, 'utf8'); } catch { return []; }
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const line of raw.split('\n')) {
|
|
33
|
+
let e;
|
|
34
|
+
try { e = JSON.parse(line); } catch { continue; }
|
|
35
|
+
if (!e || typeof e !== 'object' || typeof e.ts !== 'string' || typeof e.agent !== 'string') continue;
|
|
36
|
+
out.push(e);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* One row per agent and spec, agents in name order and each agent's specs in the order first seen
|
|
43
|
+
* (so an agent's rows read oldest spec first). Sums, not means: `scoreLines` divides.
|
|
44
|
+
*/
|
|
45
|
+
export function scoreRows(entries) {
|
|
46
|
+
const rows = new Map();
|
|
47
|
+
for (const e of entries) {
|
|
48
|
+
const spec = typeof e.spec === 'string' ? e.spec : null;
|
|
49
|
+
const key = `${e.agent}\u0000${spec}`;
|
|
50
|
+
let r = rows.get(key);
|
|
51
|
+
if (!r) {
|
|
52
|
+
rows.set(key, r = { agent: e.agent, spec, runs: 0, judged: 0, unblocked: 0, refused: 0, refusedRuns: 0,
|
|
53
|
+
tools: 0, toolRuns: 0, feedback: 0, reports: 0, since: e.ts, last: e.ts, order: rows.size });
|
|
54
|
+
}
|
|
55
|
+
r.runs += 1;
|
|
56
|
+
if (e.done === 'ended') {
|
|
57
|
+
r.judged += 1;
|
|
58
|
+
if (e.blocks === 0) r.unblocked += 1;
|
|
59
|
+
}
|
|
60
|
+
if (isCount(e.refused)) { r.refused += e.refused; r.refusedRuns += 1; }
|
|
61
|
+
if (isCount(e.tools)) { r.tools += e.tools; r.toolRuns += 1; }
|
|
62
|
+
if (isCount(e.feedback)) r.feedback += e.feedback;
|
|
63
|
+
if (e.report === true) r.reports += 1;
|
|
64
|
+
if (e.ts < r.since) r.since = e.ts;
|
|
65
|
+
if (e.ts > r.last) r.last = e.ts;
|
|
66
|
+
}
|
|
67
|
+
return [...rows.values()].sort((a, b) => (a.agent < b.agent ? -1 : a.agent > b.agent ? 1 : a.order - b.order));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Below this many counted runs a mean says nothing, so it prints `-`. */
|
|
71
|
+
export const MEAN_FLOOR = 3;
|
|
72
|
+
const mean = (sum, n) => (n >= MEAN_FLOOR ? `${(Math.round((sum / n) * 10) / 10).toFixed(1)} (${n})` : '-');
|
|
73
|
+
|
|
74
|
+
/** The table as lines: a header, then one line per row, columns padded to their widest cell. */
|
|
75
|
+
export function scoreLines(rows) {
|
|
76
|
+
const head = ['AGENT', 'SPEC', 'RUNS', 'UNBLOCKED', 'REFUSED', 'TOOLS', 'FEEDBACK', 'REPORTS', 'SINCE', 'LAST'];
|
|
77
|
+
const cells = rows.map((r) => [r.agent, r.spec ?? '-', String(r.runs),
|
|
78
|
+
r.judged ? `${r.unblocked}/${r.judged}` : '-',
|
|
79
|
+
mean(r.refused, r.refusedRuns), mean(r.tools, r.toolRuns), String(r.feedback),
|
|
80
|
+
`${r.reports}/${r.runs}`, r.since, r.last]);
|
|
81
|
+
const widths = head.map((h, i) => Math.max(h.length, ...cells.map((c) => c[i].length)));
|
|
82
|
+
const line = (c) => c.map((v, i) => (i === c.length - 1 ? v : padEndToWidth(v, widths[i]))).join(' ').trimEnd();
|
|
83
|
+
return [line(head), ...cells.map(line)];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The folders an install's ledger may sit in: the Claude-style project's marker folder, else the
|
|
88
|
+
* root. For OpenCode also `<root>/.opencode`, a LEGACY read: a project install's learn plugin
|
|
89
|
+
* wrote there (its `<plugins>/..`) until it learned `notebookHome`, and now writes `<root>/notebook`
|
|
90
|
+
* like every other ledger. Kept so the runs recorded before that still show.
|
|
91
|
+
*/
|
|
92
|
+
function ledgerDirs(host, scope, root) {
|
|
93
|
+
if (scope === 'project' && CLAUDE_STYLE.includes(host)) return [path.join(root, HOSTS.find((h) => h.host === host).projectMarker)];
|
|
94
|
+
return host === 'opencode' ? [root, path.join(root, '.opencode')] : [root];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The verb. `targets` is `installTargets()`'s shape, `[host, scope, root]`; a test passes its own. */
|
|
98
|
+
export function cmdAgentScores(targets = installTargets()) {
|
|
99
|
+
const active = targets.filter(([host, scope, root]) => installState(root, host, scope) === 'active');
|
|
100
|
+
if (!active.length) {
|
|
101
|
+
printErr('[scores] no active Geneseed install found. Run `geneseed setup` first.\n');
|
|
102
|
+
return 1;
|
|
103
|
+
}
|
|
104
|
+
let shown = 0;
|
|
105
|
+
for (const [host, scope, root] of active) {
|
|
106
|
+
for (const dir of ledgerDirs(host, scope, root)) {
|
|
107
|
+
const file = path.join(dir, RUNS_LEDGER);
|
|
108
|
+
const rows = scoreRows(readRuns(file));
|
|
109
|
+
if (!rows.length) continue;
|
|
110
|
+
shown += 1;
|
|
111
|
+
const off = process.env.GENESEED_NO_USAGE || existsSync(path.join(dir, USAGE_OFF)) ? ' (recording is off)' : '';
|
|
112
|
+
printOut(`[scores] ${host} ${scope}: ${file}${off}\n`);
|
|
113
|
+
for (const l of scoreLines(rows)) printOut(` ${l}\n`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!shown) printOut(`[scores] no agent runs recorded yet (${RUNS_LEDGER.split(path.sep).join('/')} in each install).\n`);
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
@@ -21,7 +21,7 @@ import { blankCodeSpans } from '../lib/text.mjs';
|
|
|
21
21
|
import { which } from '../lib/paths.mjs';
|
|
22
22
|
import { NO_WINDOW } from '../lib/proc.mjs';
|
|
23
23
|
import {
|
|
24
|
-
aliasProblems, creditProblems, folderSkillProblems, registryProblems, secretProblems, sideFileProblems,
|
|
24
|
+
aliasProblems, catalogueLineProblems, creditProblems, folderSkillProblems, registryProblems, secretProblems, sideFileProblems,
|
|
25
25
|
vendorPinProblems,
|
|
26
26
|
} from './checks-repo.mjs';
|
|
27
27
|
import { constitutionProblems, leanBlockProblems } from './checks-constitution.mjs';
|
|
@@ -203,6 +203,7 @@ export function authoringProblems() {
|
|
|
203
203
|
problems.push(...vendorPinProblems());
|
|
204
204
|
problems.push(...folderSkillProblems());
|
|
205
205
|
problems.push(...aliasProblems());
|
|
206
|
+
problems.push(...catalogueLineProblems());
|
|
206
207
|
problems.push(...creditProblems());
|
|
207
208
|
problems.push(...sideFileProblems());
|
|
208
209
|
problems.push(...constitutionProblems());
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import { stripCapabilityLinks } from '../build/emit-common.mjs';
|
|
11
11
|
import { STRUCTURE, renderAll } from '../build/render.mjs';
|
|
12
|
-
import { CONFIG, CREDIT_RE, makeCfg } from '../build/source.mjs';
|
|
12
|
+
import { CONFIG, CREDIT_RE, DESCRIPTION_LIMIT, makeCfg } from '../build/source.mjs';
|
|
13
13
|
import { CLAUDE_STYLE, HOSTS, hostCatalogsNatively, resolvePath } from '../hosts/hosts.mjs';
|
|
14
14
|
import { EMIT_HOST_SCOPE, footprintOfDir, readMaybe, renderedTier, themeFiles } from '../hosts/installs.mjs';
|
|
15
15
|
import { isVendoredPath } from '../hosts/native.mjs';
|
|
@@ -74,7 +74,14 @@ export function checkBuild(themeName, out, isVendored = isVendoredPath) {
|
|
|
74
74
|
for (const md of rglob(outAbs)) {
|
|
75
75
|
if (!md.endsWith('.md') || !isFile(md)) continue;
|
|
76
76
|
const rel = path.relative(outAbs, md);
|
|
77
|
-
if (isVendored(rel))
|
|
77
|
+
if (isVendored(rel)) {
|
|
78
|
+
// Upstream docs are exempt, but a vendored SKILL.md's description is ours (the catalogue
|
|
79
|
+
// line `vendoredWithCatalogueLine` writes) and is listed like any other skill's.
|
|
80
|
+
if (path.basename(rel) === 'SKILL.md') {
|
|
81
|
+
for (const p of descriptionProblems(readText(md), rel)) problems.push(`[${themeName}] ${p}`);
|
|
82
|
+
}
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
78
85
|
const text = readText(md);
|
|
79
86
|
// Sorted per file: `doctorCollect` re-sorts everything anyway, but `validate` prints these
|
|
80
87
|
// in the order they come back.
|
|
@@ -102,10 +109,16 @@ export function checkBuild(themeName, out, isVendored = isVendoredPath) {
|
|
|
102
109
|
* the spec warns degrades discovery, since the text is injected into the system prompt.
|
|
103
110
|
* The pronoun arm reads only the `Use when:` half, and skips quoted user phrases ("teach me
|
|
104
111
|
* X" is what the user types, not the description's voice): the purpose half is the theme's
|
|
105
|
-
* persona copy ("Make your own OpenCode theme"), authored per theme on purpose.
|
|
112
|
+
* persona copy ("Make your own OpenCode theme"), authored per theme on purpose. A skill's
|
|
113
|
+
* catalogue line (`src/skill-descriptions.json`) has no `Use when:` and no persona half: the
|
|
114
|
+
* pronoun arm reads all of it.
|
|
115
|
+
* A fourth arm, for a skill's `SKILL.md` only: the description is at most `DESCRIPTION_LIMIT`
|
|
116
|
+
* characters. The model's skill listing has a budget, and the host drops the descriptions of
|
|
117
|
+
* the least-used skills when it overruns; agents are listed apart and keep their own length.
|
|
106
118
|
* Files without frontmatter (every bundle `.md`, AGENT.md) carry no description and pass.
|
|
107
119
|
*/
|
|
108
120
|
const DESC_LINE_RE = /^---\n(?:.*\n)*?description: (".*")\n(?:.*\n)*?---\n/;
|
|
121
|
+
const SKILL_FILE_RE = /(?:^|[\\/])skills[\\/][^\\/]+[\\/]SKILL\.md$/;
|
|
109
122
|
export function descriptionProblems(text, rel) {
|
|
110
123
|
const m = text.match(DESC_LINE_RE);
|
|
111
124
|
if (!m) return [];
|
|
@@ -113,7 +126,10 @@ export function descriptionProblems(text, rel) {
|
|
|
113
126
|
const problems = [];
|
|
114
127
|
if (desc.endsWith('…')) problems.push(`description cut mid-sentence in ${rel} — shorten the first trigger sentence`);
|
|
115
128
|
if (/<\/?[A-Za-z][^>]*>/.test(desc)) problems.push(`description carries an XML-like tag in ${rel}`);
|
|
116
|
-
|
|
129
|
+
if (SKILL_FILE_RE.test(rel) && desc.length > DESCRIPTION_LIMIT) {
|
|
130
|
+
problems.push(`description is ${desc.length} characters in ${rel}, over ${DESCRIPTION_LIMIT} — shorten its line in src/skill-descriptions.json`);
|
|
131
|
+
}
|
|
132
|
+
const when = desc.includes(' Use when: ') ? desc.split(' Use when: ')[1] : desc;
|
|
117
133
|
if (/\b(I|I'm|me|my|you|you're|your)\b/i.test(when.replace(/"[^"]*"|\bI\/O\b/g, ''))) {
|
|
118
134
|
problems.push(`description's "Use when" is not in the third person in ${rel}`);
|
|
119
135
|
}
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import {
|
|
13
|
-
ALIASES_RE, CREDIT_RE, PLUGIN_SRC, RETIRED_SKILL_IDS, ROOT, SRC, THEMES,
|
|
14
|
-
knownSkillIds, upstreams,
|
|
13
|
+
ALIASES_RE, CREDIT_RE, DESCRIPTION_LIMIT, PLUGIN_SRC, RETIRED_SKILL_IDS, ROOT, SRC, THEMES,
|
|
14
|
+
WORKFLOW_SRC, aliasesOf, knownSkillIds, skillDescriptions, upstreams,
|
|
15
15
|
} from '../build/source.mjs';
|
|
16
16
|
import { HOSTS } from '../hosts/hosts.mjs';
|
|
17
17
|
import { installTargets, installsReferencingShim } from '../hosts/installs.mjs';
|
|
@@ -345,6 +345,31 @@ export function creditProblems(src = SRC) {
|
|
|
345
345
|
return problems;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
/**
|
|
349
|
+
* The doctor's arm of `src/skill-descriptions.json`, the one home of every skill's
|
|
350
|
+
* model-visible `description:` (`skillDescriptions`, `skillDescription`). Every skill id —
|
|
351
|
+
* flat, folder or vendored, kits included — has exactly one line, each line names a skill, and
|
|
352
|
+
* none is over `DESCRIPTION_LIMIT`: a skill with no line falls back to purpose + trigger, which
|
|
353
|
+
* ran to 320 characters, and a stale key is a line nobody reads. `checkBuild`'s
|
|
354
|
+
* `descriptionProblems` holds the emitted file to the same limit.
|
|
355
|
+
*/
|
|
356
|
+
export function catalogueLineProblems(src = SRC, lines = skillDescriptions(src)) {
|
|
357
|
+
const problems = [];
|
|
358
|
+
const known = knownSkillIds(src);
|
|
359
|
+
const where = 'src/skill-descriptions.json';
|
|
360
|
+
for (const id of known) {
|
|
361
|
+
if (!Object.hasOwn(lines, id)) problems.push(`[authoring] skill '${id}' has no line in ${where}`);
|
|
362
|
+
}
|
|
363
|
+
for (const [id, line] of Object.entries(lines)) {
|
|
364
|
+
if (!known.includes(id)) problems.push(`[authoring] ${where} has a line for '${id}', which is no skill`);
|
|
365
|
+
else if (typeof line !== 'string' || !line.trim()) problems.push(`[authoring] ${where}: '${id}' is empty`);
|
|
366
|
+
else if (line.length > DESCRIPTION_LIMIT) {
|
|
367
|
+
problems.push(`[authoring] ${where}: '${id}' is ${line.length} characters, over ${DESCRIPTION_LIMIT}`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return problems;
|
|
371
|
+
}
|
|
372
|
+
|
|
348
373
|
/**
|
|
349
374
|
* Every `<!-- aliases: … -->` name is a clean, unclaimed, single-owner path segment.
|
|
350
375
|
*
|
package/js/inspect/cost.mjs
CHANGED
|
@@ -48,23 +48,24 @@ export const CARRIER_CEILING = { full: 66_432, lean: 40_312 };
|
|
|
48
48
|
* count 0. The footprint does not change it: a description is the same text in both.
|
|
49
49
|
*
|
|
50
50
|
* WHY A CEILING. The listing is always-on context, and unlike the carrier nothing bounded its
|
|
51
|
-
* total. Each description has its own
|
|
51
|
+
* total. Each description has its own limit (`DESCRIPTION_LIMIT`, 80, js/build/source.mjs), which
|
|
52
52
|
* bounds one skill and says nothing about fifty: the catalogue once reached 22k characters
|
|
53
53
|
* before anyone measured it (that docblock has the history). And the host has a listing budget
|
|
54
54
|
* of its own, past which it trims descriptions without a word, so growth here ends as routing
|
|
55
55
|
* text the model never sees. A new skill, or a longer trigger sentence, now has to fit, or the
|
|
56
56
|
* number is raised in the open.
|
|
57
57
|
*
|
|
58
|
-
* MEASURED 2026-11-
|
|
59
|
-
*
|
|
60
|
-
* (
|
|
58
|
+
* MEASURED 2026-11-15: 3 971 characters over the default install's listed skills (neutral, no
|
|
59
|
+
* kits), down from 8 836 when each skill's description became its 80-character catalogue line
|
|
60
|
+
* (`src/skill-descriptions.json`). The ceiling is that figure plus 2 %, rounded up (the
|
|
61
|
+
* headroom the lean carrier ceiling was given). `tests/unit/emit_smoke.test.mjs` gates it.
|
|
61
62
|
* Raise it by the measured overrun and say why here, after trying a shorter description first.
|
|
62
63
|
*
|
|
63
64
|
* `alwaysOnCost` returns it as `skillCeiling` for a `claude` install only, the one host it was
|
|
64
65
|
* measured on and is gated for, and the console draws it under that install's cost breakdown.
|
|
65
66
|
* Every other host answers `null`: no bar, not a bar against a number nobody measured there.
|
|
66
67
|
*/
|
|
67
|
-
export const SKILL_LISTING_CEILING =
|
|
68
|
+
export const SKILL_LISTING_CEILING = 4_051;
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* THE TRADE OF `--shared-tier on`, stated once. `--help` (js/cli-table.json), the console's toggle
|
package/js/inspect/diff.mjs
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
} from '../hosts/hosts.mjs';
|
|
41
41
|
import {
|
|
42
42
|
EMIT_HOST_SCOPE, defaultTheme, doctrinesForBuild, excludedRulesOfDir,
|
|
43
|
-
excludedSkillsOfDir, gatesOfDir, kitsOfDir, sharedTierOfDir,
|
|
43
|
+
contextWindowOfDir, excludedSkillsOfDir, gatesOfDir, kitsOfDir, sharedTierOfDir,
|
|
44
44
|
footprintOfDir, modeOfDir, postureOfDir,
|
|
45
45
|
trustOfDir,
|
|
46
46
|
readJsonMaybe, readMaybe, renderedTier, themeOfDir,
|
|
@@ -50,7 +50,8 @@ import { hostGlobalInstalls as globalInstalls } from './excludes.mjs';
|
|
|
50
50
|
import { unifiedDiff, splitLines } from '../lib/udiff.mjs';
|
|
51
51
|
import { printOut, printErr, readText, writeText, isFile } from '../lib/fs.mjs';
|
|
52
52
|
import { NOTES_DIRS, sharedPaths } from '../lib/machine-dir.mjs';
|
|
53
|
-
import { toPlatformPath } from '../lib/paths.mjs';
|
|
53
|
+
import { normcase, toPlatformPath } from '../lib/paths.mjs';
|
|
54
|
+
import { projectNotesDir } from '../hosts/spec-feedback.mjs';
|
|
54
55
|
import { relPosix } from '../lib/text.mjs';
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -266,6 +267,8 @@ export function diffCollect({
|
|
|
266
267
|
kits: kitsOfDir(dir, host),
|
|
267
268
|
// The shared-tier marker, or an install built `--shared-tier on` reads its `Shared tier: on` line as drift.
|
|
268
269
|
sharedTier: sharedTierOfDir(dir, host),
|
|
270
|
+
// The context window, or a `1m` install reads its `Context window: 1m` line as drift.
|
|
271
|
+
contextWindow: contextWindowOfDir(dir, host),
|
|
269
272
|
// The gate switches, or a disarmed install reads its `<gate>: off` line as drift.
|
|
270
273
|
...gatesOfDir(dir, host),
|
|
271
274
|
// The tier root it rendered, or an install left relative reads every file as behind source.
|
|
@@ -362,11 +365,28 @@ export const drifted = (files) => files.filter((f) => f.status !== 'linked');
|
|
|
362
365
|
*/
|
|
363
366
|
const localChanges = (files) => drifted(files).filter((f) => f.status !== 'stale');
|
|
364
367
|
|
|
365
|
-
/**
|
|
368
|
+
/**
|
|
369
|
+
* Where an install's notes are: its own notebook (where every note went before the two scopes,
|
|
370
|
+
* and a global install's until the fold), the machine notes in the tier's `notes/`, which every
|
|
371
|
+
* install's loops now write (D6), and, for a project install, the project notes in
|
|
372
|
+
* `<project>/notebook` (js/hosts/spec-feedback.mjs `projectNotesDir`, a linked worktree mapped to its main checkout). The project is the
|
|
373
|
+
* install's parent when the install is a host layer (`.claude`, `.opencode`, …), else the install
|
|
374
|
+
* itself. One folder is listed once, under its first label.
|
|
375
|
+
*/
|
|
366
376
|
function notesRoots(dir) {
|
|
367
377
|
const roots = [[path.join(dir, 'notebook'), 'notebook']];
|
|
368
|
-
try {
|
|
369
|
-
|
|
378
|
+
try { roots.push([sharedPaths().notes, 'notes']); } catch { /* no home: no tier */ }
|
|
379
|
+
if (!isGlobalInstall(null, dir)) {
|
|
380
|
+
const project = path.basename(dir).startsWith('.') ? path.dirname(dir) : dir;
|
|
381
|
+
roots.push([projectNotesDir(project), 'project-notebook']);
|
|
382
|
+
}
|
|
383
|
+
const seen = new Set();
|
|
384
|
+
return roots.filter(([root]) => {
|
|
385
|
+
const k = normcase(path.resolve(root));
|
|
386
|
+
if (seen.has(k)) return false;
|
|
387
|
+
seen.add(k);
|
|
388
|
+
return true;
|
|
389
|
+
});
|
|
370
390
|
}
|
|
371
391
|
|
|
372
392
|
/**
|
package/js/inspect/doctor.mjs
CHANGED
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
shimProblems, strayClaimProblems,
|
|
50
50
|
} from './checks-repo.mjs';
|
|
51
51
|
import { NOTE, isDoctorNote, sortedProblems, sortedUnique, stemOf, withTempDir } from './scan.mjs';
|
|
52
|
+
import { profileSetProblems } from '../maintain/profiles.mjs';
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
* Which themes doctor validates.
|
|
@@ -245,6 +246,9 @@ export function doctorCollect({
|
|
|
245
246
|
problems = problems.concat(ran('authoring', 'Authoring gates', authoringProblems()));
|
|
246
247
|
problems = problems.concat(ran('loops', 'Loop catalogue', loopProblems()));
|
|
247
248
|
problems = problems.concat(ran('factories', 'Factory catalogue', factoryProblems()));
|
|
249
|
+
// Every profile, Shipped and Personal, through the loader `setup --profile` uses, and every
|
|
250
|
+
// Personal file a Shipped name shadows (install profiles, D10, D36).
|
|
251
|
+
problems = problems.concat(ran('profiles', 'Install profiles', profileSetProblems()));
|
|
248
252
|
problems = problems.concat(ran('shim', 'Hook shim', shimProbs));
|
|
249
253
|
// Windows: a Claude install's hooks emitted for Git Bash on a machine that no longer has it
|
|
250
254
|
// misbehave under PowerShell — context/learn fail open, and the two gates fail CLOSED
|
package/js/inspect/status.mjs
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
37
37
|
import path from 'node:path';
|
|
38
38
|
|
|
39
|
-
import { GATE_SWITCHES, THEMES, ROOT, loadKits, makeCfg } from '../build/source.mjs';
|
|
39
|
+
import { DEFAULT_CONTEXT_WINDOW, GATE_SWITCHES, THEMES, ROOT, loadKits, makeCfg } from '../build/source.mjs';
|
|
40
40
|
import { tuiInventory } from './inventory.mjs';
|
|
41
41
|
import { sourceGeneration } from '../build/render.mjs';
|
|
42
42
|
import { readVersion, sourceFingerprint } from '../build/version.mjs';
|
|
@@ -508,6 +508,8 @@ export function statusLines(d, color = false, boxed = true) {
|
|
|
508
508
|
packs, excl, ...(p.excludeSkills?.length ? [`skills off: ${p.excludeSkills.join(',')}`] : []),
|
|
509
509
|
...(p.kits?.length ? [`kits: ${p.kits.join(',')}`] : []),
|
|
510
510
|
...(p.sharedTier ? ['shared tier: on'] : []),
|
|
511
|
+
// Elided at the default, like the shared tier, so a default row prints what it did.
|
|
512
|
+
...(p.contextWindow && p.contextWindow !== DEFAULT_CONTEXT_WINDOW ? [`context window: ${p.contextWindow}`] : []),
|
|
511
513
|
// Each elided when armed. The law's text still binds; only its tool-boundary gate is off.
|
|
512
514
|
...GATE_SWITCHES.filter((g) => p[g.key] === false)
|
|
513
515
|
.map((g) => `${g.marker.toLowerCase()}: off${g.law ? ` (Law ${g.law} text still binds)` : ''}`)]
|
package/js/inspect/validate.mjs
CHANGED
|
@@ -155,6 +155,7 @@ export function cmdValidate(args) {
|
|
|
155
155
|
theme: args.theme, footprint: args.footprint, posture: args.posture, mode: args.mode,
|
|
156
156
|
trust: args.trust, doctrines: args.doctrines, excludeRules: args.excludeRules,
|
|
157
157
|
excludeSkills: args.excludeSkills, kits: args.kits, sharedTier: args.sharedTier === 'on',
|
|
158
|
+
contextWindow: args.contextWindow,
|
|
158
159
|
...Object.fromEntries(GATE_SWITCHES.map((g) => [g.key, args[g.arg] ? false : null])),
|
|
159
160
|
};
|
|
160
161
|
let scanDirs;
|
package/js/lib/machine-dir.mjs
CHANGED
|
@@ -30,6 +30,14 @@ export const LEGACY_WIKI_SEED = 'cccc917c34e6b990e821620bdb4739090151885ab71b6e8
|
|
|
30
30
|
/** Where the self-improvement loops write, relative to a notes root. */
|
|
31
31
|
export const NOTES_DIRS = ['skill-notes', 'agent-notes'];
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The tier's root as a PROJECT emit names it. A project install's files may be committed and read
|
|
35
|
+
* on a teammate's machine, so they never carry this machine's absolute path: the default location
|
|
36
|
+
* in `~` form, the same bytes on every machine. A relocated `$XDG_CONFIG_HOME` is the one case it
|
|
37
|
+
* misses: there the hook still writes to the real tier, and a project's step 0 reads the default.
|
|
38
|
+
*/
|
|
39
|
+
export const PORTABLE_MACHINE_DIR = '~/.config/geneseed';
|
|
40
|
+
|
|
33
41
|
export function machineDir() {
|
|
34
42
|
const base = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config');
|
|
35
43
|
return path.join(base, 'geneseed');
|
package/js/lib/paths.mjs
CHANGED
|
@@ -12,6 +12,9 @@ import path from 'node:path';
|
|
|
12
12
|
/** Does `root` sit directly in a `node_modules`? Any name: an npm alias installs under its own. */
|
|
13
13
|
export const inNodeModules = (root) => path.basename(path.dirname(root)).toLowerCase() === 'node_modules';
|
|
14
14
|
|
|
15
|
+
/** Does `root` sit in npm's npx cache (`…/_npx/<hash>/…`)? npm prunes that cache. */
|
|
16
|
+
export const inNpxCache = (root) => root.split(/[\\/]/).includes('_npx');
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
19
|
* Is `root` a lasting install of the npm package, `…/node_modules/geneseed`? A path rule, so
|
|
17
20
|
* `migrate` can answer under the CLI's spawn ban. An npx cache is not one: npm prunes it, and the
|
|
@@ -20,7 +23,7 @@ export const inNodeModules = (root) => path.basename(path.dirname(root)).toLower
|
|
|
20
23
|
* upgrade if a project-local `migrate` ever proves real.
|
|
21
24
|
*/
|
|
22
25
|
export const isNpmPackageDir = (root) => inNodeModules(root) && path.basename(root).toLowerCase() === 'geneseed'
|
|
23
|
-
&& !root
|
|
26
|
+
&& !inNpxCache(root);
|
|
24
27
|
|
|
25
28
|
const { X_OK } = constants;
|
|
26
29
|
/**
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scope half of `geneseed profile apply` (spec D32, D39): the project folder a profile may be
|
|
3
|
+
* built into, and what a global install of the same host still does inside that folder.
|
|
4
|
+
*
|
|
5
|
+
* SPAWN-FREE, like the rest of `js/maintain/`: the CLI imports it under the `child_process` ban,
|
|
6
|
+
* and the web console's deploy and apply routes import it too, so the folder check has one home.
|
|
7
|
+
*/
|
|
8
|
+
import { accessSync, constants } from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
|
|
11
|
+
import { GATE_SWITCHES } from '../build/source.mjs';
|
|
12
|
+
import {
|
|
13
|
+
HOSTS, bobConfigDir, claudeConfigDir, expanduser, openclaudeConfigDir, opencodeConfigDir, resolvePath,
|
|
14
|
+
} from '../hosts/hosts.mjs';
|
|
15
|
+
import { gatesOfDir, installState } from '../hosts/installs.mjs';
|
|
16
|
+
import { isDir } from '../lib/fs.mjs';
|
|
17
|
+
import { normcase } from '../lib/paths.mjs';
|
|
18
|
+
import { stripWhitespace } from '../lib/text.mjs';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A folder a PROJECT emit may be built into: `{ root }`, resolved, or `{ error }`.
|
|
22
|
+
*
|
|
23
|
+
* THIS TAKES A RAW PATH, so it is a trust boundary: an existing, writable directory that is not a
|
|
24
|
+
* host's own global config dir (a project emit there would mislabel as the global row and collide
|
|
25
|
+
* on dedup). Moved out of `apiDeployCmd` (js/web/actions.mjs, which spawns) so the CLI's
|
|
26
|
+
* `profile apply --project` and the console share one check; the texts are the console's own.
|
|
27
|
+
*
|
|
28
|
+
* `hosts` are the hosts about to be built there: for each, the folder is also refused when its
|
|
29
|
+
* project marker (`<folder>/.claude`, …) IS that host's global config dir (`markerCollision`) —
|
|
30
|
+
* `--project ~` for Claude Code would otherwise write a project install over the global one.
|
|
31
|
+
*/
|
|
32
|
+
export function checkProjectFolder(rawPath, hosts = []) {
|
|
33
|
+
const raw = stripWhitespace(typeof rawPath === 'string' ? rawPath : '');
|
|
34
|
+
if (!raw) return { error: 'no folder given' };
|
|
35
|
+
let root;
|
|
36
|
+
try {
|
|
37
|
+
root = resolvePath(expanduser(raw));
|
|
38
|
+
} catch {
|
|
39
|
+
return { error: `bad path: ${raw}` };
|
|
40
|
+
}
|
|
41
|
+
if (!isDir(root)) return { error: `not a folder: ${root}` };
|
|
42
|
+
try {
|
|
43
|
+
accessSync(root, constants.W_OK);
|
|
44
|
+
} catch {
|
|
45
|
+
return { error: `folder not writable: ${root}` };
|
|
46
|
+
}
|
|
47
|
+
const cfgdirs = new Set();
|
|
48
|
+
for (const fn of [opencodeConfigDir, claudeConfigDir, bobConfigDir, openclaudeConfigDir]) {
|
|
49
|
+
try {
|
|
50
|
+
cfgdirs.add(resolvePath(fn()));
|
|
51
|
+
} catch { /* not every host has a resolvable config dir; skip it */ }
|
|
52
|
+
}
|
|
53
|
+
if (cfgdirs.has(root)) {
|
|
54
|
+
return { error: "that's a host global config dir — use its existing row to build a global install" };
|
|
55
|
+
}
|
|
56
|
+
for (const host of hosts) {
|
|
57
|
+
const hit = markerCollision(root, host);
|
|
58
|
+
if (hit) return { error: hit };
|
|
59
|
+
}
|
|
60
|
+
return { root };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The refusal when a project install of `host` in `root` would land IN that host's global config
|
|
65
|
+
* dir — `<root>/<projectMarker>` resolves to it (`~` and `~/.claude` for Claude Code) — else
|
|
66
|
+
* null. Case-folded on Windows (`normcase`). A config dir that cannot be resolved is no collision.
|
|
67
|
+
*/
|
|
68
|
+
export function markerCollision(root, host) {
|
|
69
|
+
const row = HOSTS.find((h) => h.host === host);
|
|
70
|
+
if (!row) return null;
|
|
71
|
+
let cfg;
|
|
72
|
+
try { cfg = resolvePath(row.configDir()); } catch { return null; }
|
|
73
|
+
const at = resolvePath(path.join(root, row.projectMarker));
|
|
74
|
+
if (normcase(at) !== normcase(cfg)) return null;
|
|
75
|
+
return `${root} holds the ${host} global install (${cfg}): a ${host} project install there would `
|
|
76
|
+
+ 'overwrite it — pick a project folder';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The global hook verbs that STAND DOWN for a live, wired project install of the same host in the
|
|
81
|
+
* session's start folder (`globalHookStandingDown`, js/hosts/hosts.mjs; docs/concepts/hook-gates.md).
|
|
82
|
+
* `tests/unit/profile_scope.test.mjs` holds this list against the verbs the hooks pass to that
|
|
83
|
+
* function, so a verb that starts (or stops) standing down fails the suite.
|
|
84
|
+
*/
|
|
85
|
+
export const STAND_DOWN_VERBS = ['context', 'git-gate', 'learn'];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Which global hook verb carries each gate switch, per host: the `--no-*` flag of a switch rides
|
|
89
|
+
* these commands (`claudeHookGroups`, js/hosts/settings.mjs). `null`: the host has no hook verbs —
|
|
90
|
+
* OpenCode's gates live in its plugins, which do not stand down for a project install
|
|
91
|
+
* (docs/concepts/exclusions.md: "Bob's `tool-gate` and the OpenCode guard do not stand down").
|
|
92
|
+
* `ownBranchPass` is no gate of its own: it tunes the consent ask of `git-gate`/`tool-gate`.
|
|
93
|
+
* `tests/unit/profile_scope.test.mjs` derives the same table from real emitted settings files.
|
|
94
|
+
*/
|
|
95
|
+
export const GATE_VERBS = {
|
|
96
|
+
claude: {
|
|
97
|
+
secretsGate: ['rule-gate'], doneGate: ['learn'], deletionGate: ['git-gate'], ownershipGate: ['rule-gate'],
|
|
98
|
+
externalGate: ['git-gate', 'rule-gate'], testNote: ['rule-gate', 'learn'],
|
|
99
|
+
},
|
|
100
|
+
openclaude: {
|
|
101
|
+
secretsGate: ['rule-gate'], doneGate: ['learn'], deletionGate: ['git-gate'], ownershipGate: ['rule-gate'],
|
|
102
|
+
externalGate: ['git-gate', 'rule-gate'], testNote: ['rule-gate', 'learn'],
|
|
103
|
+
},
|
|
104
|
+
bob: {
|
|
105
|
+
secretsGate: ['tool-gate'], doneGate: ['learn'], deletionGate: ['tool-gate'], ownershipGate: ['tool-gate'],
|
|
106
|
+
externalGate: ['tool-gate'], testNote: ['tool-gate', 'learn'],
|
|
107
|
+
},
|
|
108
|
+
opencode: null,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** The gate switches D39 names: every `GATE_SWITCHES` row but the consent tuning. */
|
|
112
|
+
const LAYER_GATES = GATE_SWITCHES.filter((g) => g.key !== 'ownBranchPass');
|
|
113
|
+
|
|
114
|
+
/** Whether gate `key` of a global `host` install still runs inside a project with its own install. */
|
|
115
|
+
export function gateRunsInProject(host, key) {
|
|
116
|
+
const table = GATE_VERBS[host];
|
|
117
|
+
if (table === null) return true;
|
|
118
|
+
return (table?.[key] ?? []).some((verb) => !STAND_DOWN_VERBS.includes(verb));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* What a global install of `host` still does inside a project folder that gets its own install
|
|
123
|
+
* (spec D39), or null when there is no active global install of that host.
|
|
124
|
+
*
|
|
125
|
+
* `{ root, gates }`: the global install's dir, and the marker names (`Secrets gate`, …) of its
|
|
126
|
+
* ARMED gates that still run in the project — a gate the global install switched off runs
|
|
127
|
+
* nowhere, so it is not named. Both root files load either way: the host reads its global
|
|
128
|
+
* instructions file and the project's. `configDir` is the test's seam.
|
|
129
|
+
*/
|
|
130
|
+
export function globalLayering(host, { configDir = (h) => HOSTS.find((x) => x.host === h).configDir() } = {}) {
|
|
131
|
+
let root;
|
|
132
|
+
try { root = configDir(host); } catch { return null; }
|
|
133
|
+
if (!root || installState(root, host, 'global') !== 'active') return null;
|
|
134
|
+
const armed = gatesOfDir(root, host);
|
|
135
|
+
const gates = LAYER_GATES.filter((g) => armed[g.key] !== false && gateRunsInProject(host, g.key)).map((g) => g.marker);
|
|
136
|
+
return { root, gates };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The D39 summary line for one host, or null; `docs/concepts/exclusions.md` holds the detail. */
|
|
140
|
+
export function layeringText(label, layer, project) {
|
|
141
|
+
if (!layer) return null;
|
|
142
|
+
const still = layer.gates.length ? layer.gates.join(', ') : 'none';
|
|
143
|
+
return `${label}: the global install at ${layer.root} is active too, so both root files load in ${project}. `
|
|
144
|
+
+ `Global gates that still run there: ${still} (see docs/concepts/exclusions.md)`;
|
|
145
|
+
}
|