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/hosts/hooks-done.mjs
CHANGED
|
@@ -11,8 +11,17 @@
|
|
|
11
11
|
* one command per line, and it BLOCKS (a present file that lists nothing switches the gate off for
|
|
12
12
|
* that project). Absent, the checks are INFERRED from the root manifests (`inferDoneChecks`), and
|
|
13
13
|
* an inferred check is ADVISORY: an unproven turn still ends, with a `systemMessage` to the user,
|
|
14
|
-
* a ledger line and a stderr line — never `decision: block`.
|
|
15
|
-
*
|
|
14
|
+
* a ledger line and a stderr line — never `decision: block`. It stays advisory, with no date: an
|
|
15
|
+
* inferred check is a guess at a project's proof, and only a list the project wrote may block
|
|
16
|
+
* (user decision 2026-11). An inferred check is a GROUP of accepted command forms (`npm test` |
|
|
17
|
+
* `npm run test` | `npm t`), satisfied by any one.
|
|
18
|
+
*
|
|
19
|
+
* THE OTHER ADVISORY: A WEAKENED TEST (Cure the Cause). A turn whose write tools added a skip marker
|
|
20
|
+
* to a test file, or dropped an assertion (`weakenedBy`), gets a `[done-gate] advisory` line in the
|
|
21
|
+
* same `systemMessage`. It needs no checks and never blocks, and `--no-done-gate` silences it as
|
|
22
|
+
* it silences the inferred advisory: `cmdLearn` does not call this module at all then. On a Write
|
|
23
|
+
* the old text comes from the transcript line's `toolUseResult.originalFile` (a string on an
|
|
24
|
+
* update, null on a create, seen in real transcripts 2026-11); without it the text reads as new.
|
|
16
25
|
*
|
|
17
26
|
* WHY IT RIDES `learn` AND NOT A VERB OR A FLAG OF ITS OWN (ADR 0010). The machine-wide shim is
|
|
18
27
|
* last-writer-wins: an older `geneseed-hook` would refuse a new verb or flag, and the Stop
|
|
@@ -33,7 +42,8 @@
|
|
|
33
42
|
* inferred checks from `doneLine`, in the SessionStart context, instead.
|
|
34
43
|
*
|
|
35
44
|
* WHAT COUNTS (shortcut: write tools only; a shell `sed -i` or redirect is not an edit here —
|
|
36
|
-
* seeing
|
|
45
|
+
* seeing every one would need `git status`, a spawn; the rule gate reads the common forms for
|
|
46
|
+
* `protected-checks.txt`, but a turn is judged on what it wrote, which a command line cannot prove):
|
|
37
47
|
* - an edit is a Write/Edit/NotebookEdit/MultiEdit whose target is under the project root and
|
|
38
48
|
* whose result is not an error (a denied write changed nothing);
|
|
39
49
|
* - a pass is a Bash/PowerShell call whose command contains one of the check's forms UNPIPED (a pipe
|
|
@@ -56,7 +66,7 @@ import { within } from '../lib/paths.mjs';
|
|
|
56
66
|
import { gitRootOf } from './gitref.mjs';
|
|
57
67
|
import { recordGate } from './hooks.mjs';
|
|
58
68
|
import { ADVISORY_VERB } from './hosts.mjs';
|
|
59
|
-
import { DONE_LIST, splitLines, tailReader } from './hooks-prims.mjs';
|
|
69
|
+
import { DONE_LIST, editPairs, isTestPath, splitLines, tailReader, weakenedBy } from './hooks-prims.mjs';
|
|
60
70
|
import { doneChecksOf } from './done-checks.mjs';
|
|
61
71
|
|
|
62
72
|
const EDIT_TOOLS = new Set(['Write', 'Edit', 'NotebookEdit', 'MultiEdit']);
|
|
@@ -133,15 +143,12 @@ function isPrompt(obj) {
|
|
|
133
143
|
}
|
|
134
144
|
|
|
135
145
|
/**
|
|
136
|
-
* The
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* null ("read more") — a turn judged from its middle could miss its edit and wrongly pass.
|
|
141
|
-
* A check is a line (one form) or a `{ label, forms }` group; the answer lists labels.
|
|
146
|
+
* The current turn in transcript TEXT: its tool calls in order, each result's `is_error`, and the
|
|
147
|
+
* old text the host recorded for a write. `whole` false means the text is only the file's tail:
|
|
148
|
+
* with no prompt in it the turn may start earlier, so the answer is null ("read more") — a turn
|
|
149
|
+
* judged from its middle could miss its edit and wrongly pass.
|
|
142
150
|
*/
|
|
143
|
-
|
|
144
|
-
const groups = checks.map((c) => (typeof c === 'string' ? { label: c, forms: [c] } : c));
|
|
151
|
+
function turnOf(transcript, whole) {
|
|
145
152
|
const entries = [];
|
|
146
153
|
for (const line of splitLines(transcript)) {
|
|
147
154
|
if (!line.trim()) continue;
|
|
@@ -157,6 +164,7 @@ export function doneDecide(transcript, checks, root, cwd = root, whole = true) {
|
|
|
157
164
|
}
|
|
158
165
|
const calls = []; // tool_use blocks, in order
|
|
159
166
|
const results = new Map(); // tool_use_id -> is_error
|
|
167
|
+
const originals = new Map(); // tool_use_id -> the file before a Write
|
|
160
168
|
for (const obj of entries.slice(start)) {
|
|
161
169
|
if (obj.isSidechain) continue;
|
|
162
170
|
const content = obj.message && obj.message.content;
|
|
@@ -164,15 +172,58 @@ export function doneDecide(transcript, checks, root, cwd = root, whole = true) {
|
|
|
164
172
|
for (const b of content) {
|
|
165
173
|
if (!b || typeof b !== 'object') continue;
|
|
166
174
|
if (b.type === 'tool_use') calls.push(b);
|
|
167
|
-
else if (b.type === 'tool_result')
|
|
175
|
+
else if (b.type === 'tool_result') {
|
|
176
|
+
results.set(b.tool_use_id, b.is_error === true);
|
|
177
|
+
const before = obj.toolUseResult && obj.toolUseResult.originalFile;
|
|
178
|
+
if (typeof before === 'string') originals.set(b.tool_use_id, before);
|
|
179
|
+
}
|
|
168
180
|
}
|
|
169
181
|
}
|
|
182
|
+
return { calls, results, originals };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** The target of a landed write under `root`, absolute, or null. A denied write changed nothing. */
|
|
186
|
+
function editTarget(c, results, root, cwd) {
|
|
187
|
+
if (!EDIT_TOOLS.has(c.name) || results.get(c.id) === true) return null;
|
|
188
|
+
const p = c.input && (c.input.file_path || c.input.notebook_path || c.input.path);
|
|
189
|
+
if (typeof p !== 'string' || !p) return null;
|
|
190
|
+
const abs = path.resolve(cwd, p);
|
|
191
|
+
return within(abs, root) ? abs : null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** The turn's weakened tests, one `path (labels)` entry per file, the path relative to `root`. */
|
|
195
|
+
function weakenedTests({ calls, results, originals }, root, cwd) {
|
|
196
|
+
const byFile = new Map();
|
|
197
|
+
for (const c of calls) {
|
|
198
|
+
const abs = editTarget(c, results, root, cwd);
|
|
199
|
+
if (!abs) continue;
|
|
200
|
+
const rel = path.relative(root, abs).split(path.sep).join('/');
|
|
201
|
+
if (!isTestPath(rel)) continue;
|
|
202
|
+
const hits = weakenedBy(editPairs(c.input, originals.get(c.id)));
|
|
203
|
+
if (hits.length) byFile.set(rel, new Set([...(byFile.get(rel) || []), ...hits]));
|
|
204
|
+
}
|
|
205
|
+
return [...byFile].map(([rel, hits]) => `${rel} (${[...hits].join(', ')})`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The decision, over transcript TEXT: the checks that have not passed since the turn's last
|
|
210
|
+
* edit, or [] when the turn may end (no edit, or every check passed after it); null when `whole`
|
|
211
|
+
* is false and the tail holds no prompt (`turnOf`). Exported for the unit tier — a transcript is
|
|
212
|
+
* text no CLI cell can vary cheaply. A check is a line (one form) or a `{ label, forms }` group;
|
|
213
|
+
* the answer lists labels.
|
|
214
|
+
*/
|
|
215
|
+
export function doneDecide(transcript, checks, root, cwd = root, whole = true) {
|
|
216
|
+
const turn = turnOf(transcript, whole);
|
|
217
|
+
return turn && missingChecks(turn, checks, root, cwd);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** `weakenedTests` over transcript TEXT, for the unit tier: `doneDecide`'s other question. */
|
|
221
|
+
export const weakenedIn = (transcript, root, cwd = root) => weakenedTests(turnOf(transcript, true), root, cwd);
|
|
222
|
+
|
|
223
|
+
function missingChecks({ calls, results }, checks, root, cwd) {
|
|
224
|
+
const groups = checks.map((c) => (typeof c === 'string' ? { label: c, forms: [c] } : c));
|
|
170
225
|
let lastEdit = -1;
|
|
171
|
-
calls.forEach((c, i) => {
|
|
172
|
-
if (!EDIT_TOOLS.has(c.name) || results.get(c.id) === true) return;
|
|
173
|
-
const p = c.input && (c.input.file_path || c.input.notebook_path || c.input.path);
|
|
174
|
-
if (typeof p === 'string' && p && within(path.resolve(cwd, p), root)) lastEdit = i;
|
|
175
|
-
});
|
|
226
|
+
calls.forEach((c, i) => { if (editTarget(c, results, root, cwd)) lastEdit = i; });
|
|
176
227
|
if (lastEdit === -1) return [];
|
|
177
228
|
const passed = new Set();
|
|
178
229
|
calls.slice(lastEdit + 1).forEach((c) => {
|
|
@@ -199,38 +250,53 @@ export function doneGate(meta, args, install, read = tailReader()) {
|
|
|
199
250
|
const root = gitRootOf(cwd);
|
|
200
251
|
if (!root) return null;
|
|
201
252
|
const { source, blocking, checks } = doneChecksOf(root);
|
|
202
|
-
if (!checks.length) return null;
|
|
203
253
|
// Bob's Stop payload carries no transcript (learn's I2): nothing to judge, and a listed gate
|
|
204
254
|
// says so. Inferred checks stay quiet there: every repo with a manifest would log it.
|
|
205
255
|
if (args.host === 'bob' || typeof meta.transcript_path !== 'string') {
|
|
206
|
-
if (blocking) err(`[done-gate] no transcript${args.host === 'bob' ? ' (bob)' : ''} — turn not judged.\n`);
|
|
256
|
+
if (blocking && checks.length) err(`[done-gate] no transcript${args.host === 'bob' ? ' (bob)' : ''} — turn not judged.\n`);
|
|
207
257
|
return null;
|
|
208
258
|
}
|
|
209
|
-
let
|
|
259
|
+
let verdict;
|
|
210
260
|
try {
|
|
211
|
-
|
|
212
|
-
|
|
261
|
+
verdict = read(meta.transcript_path, (text, whole) => {
|
|
262
|
+
const turn = turnOf(text, whole);
|
|
263
|
+
return turn && {
|
|
264
|
+
missing: missingChecks(turn, checks, root, cwd), weakened: weakenedTests(turn, root, cwd),
|
|
265
|
+
};
|
|
266
|
+
});
|
|
213
267
|
} catch {
|
|
214
268
|
// No ask tier on Stop: blocking on an unreadable transcript would trap the user.
|
|
215
|
-
err('[done-gate] transcript unreadable — turn not judged.\n');
|
|
269
|
+
if (checks.length) err('[done-gate] transcript unreadable — turn not judged.\n');
|
|
216
270
|
return null;
|
|
217
271
|
}
|
|
272
|
+
const { missing, weakened } = verdict;
|
|
273
|
+
// One JSON document on stdout, whatever the advisories: Stop reads no second one.
|
|
274
|
+
const advise = (...said) => {
|
|
275
|
+
if (weakened.length) {
|
|
276
|
+
// A stable id, not a law number: an advisory is no hook-pinned rule (`HOOK_PINNED`).
|
|
277
|
+
recordGate(install, ADVISORY_VERB, 'cure-the-cause');
|
|
278
|
+
const line = `[done-gate] advisory — test weakened this turn: ${weakened.join('; ')}`;
|
|
279
|
+
err(`${line}\n`);
|
|
280
|
+
said.push(`${line}. Cure the Cause: fix the code, not the test.`);
|
|
281
|
+
}
|
|
282
|
+
out(`${JSON.stringify({ systemMessage: said.join(' ') })}\n`);
|
|
283
|
+
return 'advisory';
|
|
284
|
+
};
|
|
285
|
+
if (!missing.length && weakened.length) return advise();
|
|
218
286
|
if (!missing.length) return null;
|
|
219
287
|
if (!blocking) {
|
|
220
288
|
recordGate(install, ADVISORY_VERB, 'law-3');
|
|
221
289
|
err(`[done-gate] advisory — unproven since the last edit: ${missing.join('; ')}\n`);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
+ `List your own in ${DONE_LIST} to make the gate block.`,
|
|
226
|
-
})}\n`);
|
|
227
|
-
return 'advisory';
|
|
290
|
+
return advise('Geneseed done gate (advisory) — this turn edited files, and these checks '
|
|
291
|
+
+ `inferred from ${source} have not passed since the last edit: ${missing.join('; ')}. `
|
|
292
|
+
+ `List your own in ${DONE_LIST} to make the gate block.`);
|
|
228
293
|
}
|
|
229
294
|
if (meta.stop_hook_active === true) {
|
|
230
295
|
recordGate(install, 'done-gate-cap', 'law-3');
|
|
231
296
|
err(`[done-gate] cap reached — turn ends with unproven checks: ${missing.join('; ')}\n`);
|
|
232
|
-
return null;
|
|
297
|
+
return weakened.length ? advise() : null;
|
|
233
298
|
}
|
|
299
|
+
// The turn goes on, so a weakened test is said at the Stop that really ends it.
|
|
234
300
|
recordGate(install, 'done-gate', 'law-3');
|
|
235
301
|
out(`${JSON.stringify({
|
|
236
302
|
decision: 'block',
|
package/js/hosts/hooks-learn.mjs
CHANGED
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { spawnSync } from 'node:child_process';
|
|
9
|
-
import { readText, printOut as out, printErr as err } from '../lib/fs.mjs';
|
|
9
|
+
import { readText, isDir, printOut as out, printErr as err } from '../lib/fs.mjs';
|
|
10
10
|
import { toPlatformPath } from '../lib/paths.mjs';
|
|
11
11
|
import { NO_WINDOW } from '../lib/proc.mjs';
|
|
12
12
|
import {
|
|
13
|
-
globalHookStandingDown, hookProjectDir, resolveMemoryDir, sovereignBypass,
|
|
13
|
+
globalHookStandingDown, hookProjectDir, isGlobalInstall, resolveMemoryDir, sovereignBypass,
|
|
14
14
|
} from './hosts.mjs';
|
|
15
|
+
import { sharedPaths } from '../lib/machine-dir.mjs';
|
|
15
16
|
import { readStdin, splitLines, splitWords, tailReader } from './hooks-prims.mjs';
|
|
16
17
|
import { doneGate } from './hooks-done.mjs';
|
|
18
|
+
import { recordOwnWrites, storeReport } from './store-watch.mjs';
|
|
17
19
|
import {
|
|
18
20
|
existingSlugs, readFacts, writeMemories, consolidateMemory, appendAgentLesson,
|
|
19
21
|
} from './memory-files.mjs';
|
|
@@ -217,8 +219,7 @@ export function buildLearnPrompt(notes, facts) {
|
|
|
217
219
|
*/
|
|
218
220
|
function runLlm(llm, prompt) {
|
|
219
221
|
const argv = splitWords(llm);
|
|
220
|
-
// `
|
|
221
|
-
// which folds in `CREATE_NO_WINDOW`; a model CLI invoked from the windowless daemon
|
|
222
|
+
// `NO_WINDOW` folds in `CREATE_NO_WINDOW`; a model CLI invoked from the windowless daemon
|
|
222
223
|
// otherwise pops a console for as long as it takes to answer.
|
|
223
224
|
//
|
|
224
225
|
// `GENESEED_LEARN_CHILD=1` (Claude B2): `$GENESEED_LLM="claude -p"` with hooks not disabled
|
|
@@ -276,13 +277,24 @@ function learnAgentLesson(meta, notes, args) {
|
|
|
276
277
|
const lesson = splitLines(text)[0].replace(/^[-*]+/, '').trim();
|
|
277
278
|
const n = Array.from(lesson).length; // code points, as `len()` counts them
|
|
278
279
|
if (n >= 10 && n <= 300) {
|
|
279
|
-
|
|
280
|
+
const written = recordOwnWrites(path.dirname(memDir), () => appendAgentLesson(memDir, agent, lesson));
|
|
281
|
+
err(written ? `[learn] agent lesson -> ${written}\n`
|
|
282
|
+
: `[learn] ${agent}'s lesson file is not UTF-8 - left as it is, lesson dropped\n`);
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
285
|
if (proc.returncode !== 0 && proc.stderr) err(proc.stderr);
|
|
283
286
|
return proc.returncode;
|
|
284
287
|
}
|
|
285
288
|
|
|
289
|
+
/** `--memory` of a global install's hook, swapped for the shared store when that exists. */
|
|
290
|
+
function sharedStoreFor(install, args) {
|
|
291
|
+
if (!install) return args.memory;
|
|
292
|
+
try {
|
|
293
|
+
const shared = sharedPaths().memory;
|
|
294
|
+
return isDir(shared) && isGlobalInstall(args.host ?? null, install) ? shared : args.memory;
|
|
295
|
+
} catch { return args.memory; }
|
|
296
|
+
}
|
|
297
|
+
|
|
286
298
|
export function cmdLearn(args) {
|
|
287
299
|
// B2: stand straight down inside a model-CLI child `runLlm` just spawned (see its comment).
|
|
288
300
|
// Checked before anything else — a child never gets as far as reading its own stdin, let
|
|
@@ -295,7 +307,7 @@ export function cmdLearn(args) {
|
|
|
295
307
|
err('[learn] no memory store found \u2014 nothing to consolidate.\n');
|
|
296
308
|
return 0;
|
|
297
309
|
}
|
|
298
|
-
const report = consolidateMemory(memDir);
|
|
310
|
+
const report = recordOwnWrites(path.dirname(memDir), () => consolidateMemory(memDir));
|
|
299
311
|
err(`[learn] consolidated ${memDir}: +${report.added.length} indexed, `
|
|
300
312
|
+ `-${report.pruned.length} pruned, `
|
|
301
313
|
+ `${report.duplicates.length} duplicate description(s)\n`);
|
|
@@ -321,6 +333,14 @@ export function cmdLearn(args) {
|
|
|
321
333
|
const hookEvent = typeof meta.hook_event_name === 'string' ? meta.hook_event_name
|
|
322
334
|
: (typeof meta.event === 'string' ? meta.event : null);
|
|
323
335
|
|
|
336
|
+
// A global install's hook passes its own host store; the shared store is where its facts live
|
|
337
|
+
// once it exists, or they land in the seeded host store and wait for the next fold. Only a hook
|
|
338
|
+
// call is redirected: it names its event or carries a transcript, and a person who typed
|
|
339
|
+
// `--memory` meant that store. Empty stdin is neither, and has no notes to write anywhere.
|
|
340
|
+
if (hookEvent || typeof meta.transcript_path === 'string') {
|
|
341
|
+
args = { ...args, memory: sharedStoreFor(install, args) };
|
|
342
|
+
}
|
|
343
|
+
|
|
324
344
|
// The done gate (#289) judges the turn BEFORE anything here spawns, and only on Stop. A block
|
|
325
345
|
// means the turn goes on, so there is nothing to distil yet: the next Stop will.
|
|
326
346
|
// `--no-done-gate` (the install switched Law III's gate off) skips the check, never the
|
|
@@ -332,6 +352,17 @@ export function cmdLearn(args) {
|
|
|
332
352
|
? doneGate(meta, args, install, read) : null;
|
|
333
353
|
if (verdict === 'block') return 0;
|
|
334
354
|
|
|
355
|
+
// The change report, at the turn's real end (./store-watch.mjs). One JSON document on stdout, so an
|
|
356
|
+
// advisory already there keeps it, and Bob reads no stdout here at all: those go to stderr.
|
|
357
|
+
if (hookEvent === 'Stop' && !args.file && install) {
|
|
358
|
+
const said = storeReport(install, meta.session_id, {
|
|
359
|
+
transcript: typeof meta.transcript_path === 'string' ? meta.transcript_path : null,
|
|
360
|
+
cwd: meta.cwd, host: args.host || 'claude',
|
|
361
|
+
});
|
|
362
|
+
if (said && (verdict === 'advisory' || args.host === 'bob')) err(`[geneseed] ${said}\n`);
|
|
363
|
+
else if (said) out(`${JSON.stringify({ systemMessage: said })}\n`);
|
|
364
|
+
}
|
|
365
|
+
|
|
335
366
|
// I2 (Bob): its Stop payload never carries `transcript_path`, so there is never a transcript
|
|
336
367
|
// to distil — and the bare envelope itself is not notes text (that would waste a model call
|
|
337
368
|
// on `{"event":"Stop","session_id":"s"}`). Scoped to `--host bob`: every other host's Stop/
|
|
@@ -384,7 +415,7 @@ export function cmdLearn(args) {
|
|
|
384
415
|
const proc = runLlm(llm, prompt);
|
|
385
416
|
const output = proc.stdout;
|
|
386
417
|
if (memDir && output.trim() && output.trim().toUpperCase() !== 'NOTHING') {
|
|
387
|
-
const { created, updated, archived } = writeMemories(output, memDir, existing);
|
|
418
|
+
const { created, updated, archived } = recordOwnWrites(path.dirname(memDir), () => writeMemories(output, memDir, existing));
|
|
388
419
|
if (created.length) {
|
|
389
420
|
err(`[learn] wrote ${created.length} memory file(s) to `
|
|
390
421
|
+ `${memDir}: ${created.join(', ')}\n`);
|
package/js/hosts/hooks-prims.mjs
CHANGED
|
@@ -70,15 +70,17 @@ export function selfAndParents(p) {
|
|
|
70
70
|
* the other. The trailing empty is dropped the way Python drops it (`"a\n"` is one line,
|
|
71
71
|
* `""` is none).
|
|
72
72
|
*/
|
|
73
|
+
export const LINE_BREAK = /\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029]/;
|
|
74
|
+
|
|
73
75
|
export function splitLines(text) {
|
|
74
76
|
if (!text) return [];
|
|
75
|
-
const parts = text.split(
|
|
77
|
+
const parts = text.split(LINE_BREAK);
|
|
76
78
|
if (parts.length && parts[parts.length - 1] === '') parts.pop();
|
|
77
79
|
return parts;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
/** The first window a Stop reads from a transcript's end; real transcripts reach 50 MB. */
|
|
81
|
-
|
|
83
|
+
const TAIL_BYTES = 2 * 1024 * 1024;
|
|
82
84
|
|
|
83
85
|
/**
|
|
84
86
|
* A transcript reader for ONE hook invocation: `read(file, judge)` hands `judge(text, whole)`
|
|
@@ -137,6 +139,71 @@ export const DONE_LIST = '.geneseed/done-checks.txt';
|
|
|
137
139
|
export const SECRET_RE =
|
|
138
140
|
/\b(?:AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,}|sk-ant-[A-Za-z0-9_-]{20,}|xox[abprs]-[0-9A-Za-z-]{10,})\b|-----BEGIN [A-Z ]*PRIVATE KEY-----/;
|
|
139
141
|
|
|
142
|
+
// ---- test-weakening twin: BEGIN — adapters/opencode/plugins/geneseed-context.js carries everything
|
|
143
|
+
// down to the END marker verbatim, with `export ` dropped (tests/plugins/context_done.test.mjs diffs the two).
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A test file: a path segment `test`, `tests`, `__tests__` or `spec`, or a name `*.test.*`,
|
|
147
|
+
* `*.spec.*`, `*_test.*` or `test_*`. Give it a path relative to the repo, or an ancestor
|
|
148
|
+
* folder named `test` makes every file a test.
|
|
149
|
+
*/
|
|
150
|
+
const TEST_PATH_RE = /(?:^|[\\/])(?:tests?|__tests__|spec)[\\/]|(?:^|[\\/])test_[^\\/]*$|\.(?:test|spec)\.[^\\/]*$|_test\.[^\\/]*$/;
|
|
151
|
+
export const isTestPath = (p) => TEST_PATH_RE.test(p);
|
|
152
|
+
// `\bxit`, or `process.exit(` reads as one; `(?<!mark)`, or `pytest.mark.skip(` counts twice.
|
|
153
|
+
const SKIP_MARKERS = [['.skip', /(?<!mark)\.skip\(/g], ['xit', /\bxit\(/g], ['xfail', /\bxfail\b/g],
|
|
154
|
+
['@Disabled', /@Disabled\b/g], ['@Ignore', /@Ignore\b/g], ['pytest.mark.skip', /\bpytest\.mark\.skip/g],
|
|
155
|
+
['t.Skip', /\bt\.Skip\(/g]];
|
|
156
|
+
const ASSERT_LINE_RE = /\bassert\w*!?\s*[.(]|\bexpect\s*\(|^assert\s/;
|
|
157
|
+
const COMMENT_LINE_RE = /^(?:\/\/|\/\*|\*|#)/;
|
|
158
|
+
// shortcut: only whole comment lines are dropped, so a marker in a string or a trailing comment, and
|
|
159
|
+
// any other `.skip(` (`stream().skip(1)`), still count. Upgrade by parsing the language; it is an advisory.
|
|
160
|
+
const code = (text) => text.split(/\r?\n/).filter((l) => !COMMENT_LINE_RE.test(l.trim())).join('\n');
|
|
161
|
+
// shortcut: a Set hides the loss of one of two identical lines, and `require.Equal`, `t.Errorf` and
|
|
162
|
+
// `.should` are not read as assertions. Upgrade by counting lines and widening `ASSERT_LINE_RE`.
|
|
163
|
+
const assertLines = (text) => new Set(text.split(/\r?\n/).map((l) => l.trim())
|
|
164
|
+
.filter((l) => ASSERT_LINE_RE.test(l) && !COMMENT_LINE_RE.test(l)));
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* What `pairs` of `[old, new]` text do to a test, as labels: a skip marker the new text has more
|
|
168
|
+
* of (`.skip added`), or an assertion line gone with none new in its place (`assertion removed`).
|
|
169
|
+
* A comment is no assertion, so commenting one out removes it. Cure the Cause's advisory half.
|
|
170
|
+
*/
|
|
171
|
+
export function weakenedBy(pairs) {
|
|
172
|
+
const found = new Set();
|
|
173
|
+
for (const [before, after] of pairs) {
|
|
174
|
+
for (const [label, re] of SKIP_MARKERS) {
|
|
175
|
+
if ((code(after).match(re) || []).length > (code(before).match(re) || []).length) found.add(`${label} added`);
|
|
176
|
+
}
|
|
177
|
+
const was = assertLines(before);
|
|
178
|
+
const now = assertLines(after);
|
|
179
|
+
if ([...was].some((l) => !now.has(l)) && [...now].every((l) => was.has(l))) found.add('assertion removed');
|
|
180
|
+
}
|
|
181
|
+
return [...found];
|
|
182
|
+
}
|
|
183
|
+
// ---- test-weakening twin: END
|
|
184
|
+
|
|
185
|
+
// One Roo-style `apply_diff` block: its SEARCH half, then its REPLACE half.
|
|
186
|
+
export const DIFF_BLOCK_RE = /<<<<<<< SEARCH\r?\n(?::start_line:\s*\d+\r?\n)?(?:-------\r?\n)?([\s\S]*?)\r?\n?=======\r?\n([\s\S]*?)\r?\n?>>>>>>> REPLACE/g;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A write tool's input as `[old, new]` pairs for `weakenedBy`. `whole` is the file before a
|
|
190
|
+
* whole-file write, which the input does not carry. NotebookEdit's input names no old text either,
|
|
191
|
+
* so a cell that already held a marker reads as adding it.
|
|
192
|
+
*/
|
|
193
|
+
export function editPairs(ti, whole = '') {
|
|
194
|
+
const text = (v) => (typeof v === 'string' ? v : '');
|
|
195
|
+
const pairs = [];
|
|
196
|
+
if (typeof ti.content === 'string') pairs.push([whole, ti.content]);
|
|
197
|
+
if (typeof ti.new_string === 'string') pairs.push([text(ti.old_string), ti.new_string]);
|
|
198
|
+
if (typeof ti.new_source === 'string') pairs.push(['', ti.new_source]);
|
|
199
|
+
if (typeof ti.replace === 'string') pairs.push([text(ti.search), ti.replace]);
|
|
200
|
+
for (const e of Array.isArray(ti.edits) ? ti.edits : []) {
|
|
201
|
+
if (e && typeof e.new_string === 'string') pairs.push([text(e.old_string), e.new_string]);
|
|
202
|
+
}
|
|
203
|
+
if (typeof ti.diff === 'string') for (const m of ti.diff.matchAll(DIFF_BLOCK_RE)) pairs.push([m[1], m[2]]);
|
|
204
|
+
return pairs;
|
|
205
|
+
}
|
|
206
|
+
|
|
140
207
|
const OFF = ['off', '0', 'false', 'no'];
|
|
141
208
|
|
|
142
209
|
/**
|