geneseed 5.3.0 → 5.4.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 +95 -0
- package/README.md +23 -20
- package/SHIPPED.md +7 -7
- package/adapters/bob/README.md +31 -18
- package/adapters/claude-code/README.md +27 -22
- package/adapters/openclaude/README.md +18 -8
- package/adapters/opencode/HOW-OPENCODE-LOADS.md +8 -3
- package/adapters/opencode/README.md +3 -2
- package/adapters/opencode/plugins/geneseed-activity.js +20 -21
- package/adapters/opencode/plugins/geneseed-context.js +175 -62
- package/adapters/opencode/plugins/geneseed-guard.js +419 -205
- package/adapters/opencode/plugins/geneseed-workflow.js +3 -2
- package/adapters/opencode/workflows/_runtime.js +3 -2
- package/bin/geneseed-cli.mjs +7 -0
- package/bin/geneseed-hook.mjs +59 -11
- package/docs/PRD.md +1 -1
- package/docs/README.md +1 -0
- package/docs/concepts/agents.md +1 -1
- package/docs/concepts/collaboration.md +2 -2
- package/docs/concepts/enforcement-table.md +5 -2
- package/docs/concepts/exclusions.md +18 -4
- package/docs/concepts/footprint.md +11 -1
- package/docs/concepts/foreman-mode.md +1 -1
- package/docs/concepts/hook-gates.md +5 -5
- package/docs/concepts/hooks.md +4 -3
- package/docs/concepts/host-matrix.md +24 -6
- package/docs/concepts/kits.md +12 -2
- package/docs/concepts/loop-bricks.md +3 -3
- package/docs/concepts/loops.md +6 -4
- package/docs/concepts/ownership.md +1 -1
- package/docs/concepts/rules.md +2 -2
- package/docs/concepts/skills.md +1 -1
- package/docs/design-history.md +8 -0
- package/docs/extending.md +112 -35
- package/docs/guides/auto-merge.md +100 -0
- package/docs/guides/choose-your-setup.md +1 -1
- package/docs/guides/headless.md +1 -1
- package/docs/guides/install-bob.md +2 -2
- package/docs/guides/install-clone.md +1 -1
- package/docs/guides/install-openclaude.md +1 -1
- package/docs/guides/install.md +1 -1
- package/docs/guides/loop-finish.md +3 -3
- package/docs/guides/loop-running.md +4 -4
- package/docs/guides/project-context.md +1 -1
- package/docs/guides/run-a-factory.md +2 -2
- package/docs/guides/setup-doctrines.md +2 -2
- package/docs/guides/setup-footprint.md +1 -1
- package/docs/guides/uninstall.md +3 -3
- package/docs/guides/upgrade.md +1 -1
- package/docs/guides/verify.md +12 -0
- package/docs/guides/worktree.md +1 -1
- package/docs/reference/environment.md +5 -2
- package/docs/reference/plugin-activity.md +1 -1
- package/docs/reference/plugin-guard.md +1 -1
- package/docs/reference/plugin-learn.md +1 -1
- package/docs/reference/plugin-workflow.md +1 -1
- package/docs/reference/troubleshoot-doctor.md +2 -2
- package/docs/reference/troubleshoot-hooks.md +2 -2
- package/docs/reference/troubleshoot-install.md +3 -3
- package/docs/reference/troubleshoot-tools.md +1 -1
- package/docs/token-footprint.md +68 -4
- package/docs/understand/design-choices-hosts.md +1 -1
- package/docs/understand/design-choices-shape.md +1 -0
- package/docs/understand/enforced-vs-asked.md +2 -2
- package/docs/understand/machine-bob.md +1 -1
- package/docs/understand/machine-claude.md +2 -2
- package/docs/understand/on-your-machine.md +1 -1
- package/docs/web-ui.md +10 -5
- package/harness.config.json +1 -1
- package/js/README.md +5 -3
- package/js/build/args.mjs +13 -2
- package/js/build/driver.mjs +34 -7
- package/js/build/emit-claude.mjs +9 -5
- package/js/build/emit-opencode.mjs +13 -9
- package/js/build/generate.mjs +10 -165
- package/js/build/profile.mjs +318 -0
- package/js/build/render.mjs +81 -3
- package/js/build/retired-skills.mjs +60 -13
- package/js/build/source.mjs +15 -1
- package/js/build/stubs.mjs +4 -1
- package/js/cli-table.json +48 -3
- package/js/hosts/done-checks.mjs +6 -0
- package/js/hosts/geneseed-dir.mjs +3 -2
- package/js/hosts/gitref.mjs +5 -3
- package/js/hosts/hook-tap.mjs +104 -0
- package/js/hosts/hooks-context.mjs +4 -2
- package/js/hosts/hooks-done.mjs +345 -55
- package/js/hosts/hooks-learn.mjs +51 -19
- package/js/hosts/hooks-prims.mjs +5 -3
- package/js/hosts/hooks.mjs +172 -19
- package/js/hosts/hosts.mjs +80 -12
- package/js/hosts/installs.mjs +26 -1
- package/js/hosts/native.mjs +33 -7
- package/js/hosts/owned.mjs +7 -6
- package/js/hosts/ownership-gate.mjs +14 -1
- package/js/hosts/settings.mjs +273 -105
- package/js/hosts/shim.mjs +4 -4
- package/js/hosts/usage.mjs +9 -3
- package/js/inspect/checks-constitution.mjs +32 -0
- package/js/inspect/checks-probe.mjs +66 -5
- package/js/inspect/checks-repo.mjs +196 -2
- package/js/inspect/cost.mjs +34 -2
- package/js/inspect/diff.mjs +21 -3
- package/js/inspect/doctor.mjs +6 -1
- package/js/inspect/inventory.mjs +1 -1
- package/js/lib/machine-dir.mjs +1 -1
- package/js/lib/node-floor.mjs +46 -6
- package/js/maintain/setup.mjs +5 -1
- package/js/maintain/uninstall.mjs +42 -16
- package/js/maintain/update.mjs +4 -2
- package/js/web/actions.mjs +17 -12
- package/js/web/api.mjs +7 -2
- package/package.json +1 -1
- package/registry.json +14 -0
- package/src/AGENT.md.tmpl +15 -17
- package/src/bricks/pr-open.md +3 -2
- package/src/doctrines/ops.md +2 -2
- package/src/doctrines/process.md +40 -36
- package/src/factories/analysis-to-build.json +1 -1
- package/src/factories/bug-report-to-fix.json +1 -1
- package/src/factories/issue-to-pr.json +1 -1
- package/src/kits/terminal-tools/rules.md +10 -0
- package/src/kits/terminal-tools.json +13 -0
- package/src/licenses/herdr.txt +201 -0
- package/src/modes/foreman.md +6 -3
- package/src/skills/_self-improvement.md +9 -7
- package/src/skills/commit.md +17 -17
- package/src/skills/debug/ci.md +1 -1
- package/src/skills/dependencies.md +3 -3
- package/src/skills/document-project.md +3 -2
- package/src/skills/factory.md +13 -4
- package/src/skills/geneseed.md +4 -2
- package/src/skills/git-history.md +5 -7
- package/src/skills/herdr.md +135 -0
- package/src/skills/loop.md +3 -2
- package/src/skills/opencode-cli.md +84 -0
- package/src/skills/pipeline.md +1 -1
- package/src/skills/release.md +5 -8
- package/src/skills/review-response.md +4 -2
- package/src/skills/rule.md +27 -1
- package/src/skills/ship.md +54 -7
- package/src/skills/worktree.md +2 -2
- package/src/upstreams.json +7 -0
- package/themes/_TEMPLATE.json +2 -0
- package/themes/biker.json +2 -0
- package/themes/commentator.json +2 -0
- package/themes/cyberpunk.json +2 -0
- package/themes/gamer.json +2 -0
- package/themes/imperial.json +2 -0
- package/themes/joker.json +2 -0
- package/themes/marvin.json +2 -0
- package/themes/mean.json +2 -0
- package/themes/military.json +2 -0
- package/themes/neutral.json +2 -0
- package/themes/pirate.json +2 -0
- package/themes/sports.json +2 -0
- package/themes/verstappen.json +2 -0
- package/themes/wizard.json +2 -0
- package/web/dist/assets/Activity-D2kOc3yi.js +1 -0
- package/web/dist/assets/ActivityDetail-By3xOr21.js +1 -0
- package/web/dist/assets/{Bonsai-Bfpb6W-1.js → Bonsai-CBWDTBA4.js} +1 -1
- package/web/dist/assets/{CopyButton-ByIntFtB.js → CopyButton-BVbpriMB.js} +1 -1
- package/web/dist/assets/Dashboard-CIJLPHM9.js +2 -0
- package/web/dist/assets/{Docs-DvlMJhpu.js → Docs-CiRRIELs.js} +3 -3
- package/web/dist/assets/Factories-DhyK0O8d.js +1 -0
- package/web/dist/assets/GreenhouseView-DW3PgTPy.js +1 -0
- package/web/dist/assets/Installs-B6nlo-Ly.js +3 -0
- package/web/dist/assets/JournalView-O65qEWfp.js +1 -0
- package/web/dist/assets/Kits-C5U-yT6Z.js +1 -0
- package/web/dist/assets/Laws-CuTw_XNf.js +4 -0
- package/web/dist/assets/{LibRows-DEHjIoD-.js → LibRows-D6-CVa3K.js} +1 -1
- package/web/dist/assets/Library-CzPlerd6.js +3 -0
- package/web/dist/assets/Loops-CqNF_-nS.js +2 -0
- package/web/dist/assets/Markdown-CxkA7940.js +71 -0
- package/web/dist/assets/OperatorHudView-BNr8K5qj.js +1 -0
- package/web/dist/assets/Personal-DeDb9e8O.js +2 -0
- package/web/dist/assets/Settings-B8MPN_AD.js +1 -0
- package/web/dist/assets/{Tabs-CWeQTADL.js → Tabs-DJzAez4h.js} +1 -1
- package/web/dist/assets/index-BL3P-9Rg.js +6 -0
- package/web/dist/assets/{index-CsAZq0BQ.css → index-CRWqKxfY.css} +1 -1
- package/web/dist/index.html +2 -2
- package/adapters/claude-code/settings.json +0 -52
- package/web/dist/assets/Activity-CqJiquEq.js +0 -1
- package/web/dist/assets/ActivityDetail-BSzevynX.js +0 -1
- package/web/dist/assets/Dashboard-DBOEi9lQ.js +0 -2
- package/web/dist/assets/Factories-Bpvv7L2H.js +0 -1
- package/web/dist/assets/GreenhouseView-GpBsYn50.js +0 -1
- package/web/dist/assets/Installs-BlGmVrFK.js +0 -3
- package/web/dist/assets/JournalView-iLuLrOxE.js +0 -1
- package/web/dist/assets/Kits-DRwpxC-J.js +0 -1
- package/web/dist/assets/Laws-CZkiNOWQ.js +0 -4
- package/web/dist/assets/Library-B4K-1iNF.js +0 -3
- package/web/dist/assets/Loops-BWSzaW8E.js +0 -2
- package/web/dist/assets/Markdown-0ORz7tAc.js +0 -69
- package/web/dist/assets/OperatorHudView-BAXwCEvY.js +0 -1
- package/web/dist/assets/Personal-Bp9nV4GR.js +0 -2
- package/web/dist/assets/Settings-CWWuaIp-.js +0 -1
- package/web/dist/assets/index-How7SzDZ.js +0 -6
package/js/cli-table.json
CHANGED
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
{
|
|
68
68
|
"name": "build",
|
|
69
69
|
"help": "render the harness with the generator's flags (dry run: geneseed validate)",
|
|
70
|
-
"description": "render the harness (same flags as geneseed-build; an omitted flag takes the generator default, not the install's
|
|
70
|
+
"description": "render the harness (same flags as geneseed-build; an omitted flag takes the generator default, not the install's, so a build over an existing install that would change a setting it was not given refuses and prints the install's own rebuild command, as geneseed status --json shows it — --reset accepts the defaults; dry run: geneseed validate)",
|
|
71
71
|
"positionals": [],
|
|
72
72
|
"options": [
|
|
73
73
|
{
|
|
@@ -370,6 +370,21 @@
|
|
|
370
370
|
"type": null,
|
|
371
371
|
"hidden": false
|
|
372
372
|
},
|
|
373
|
+
{
|
|
374
|
+
"names": [
|
|
375
|
+
"--strict-consent"
|
|
376
|
+
],
|
|
377
|
+
"dest": "strict_consent",
|
|
378
|
+
"metavar": null,
|
|
379
|
+
"help": "Consent Before Push asks for every git commit and push, own branch included (records `Own-branch pass: off`); default: only the main branch asks",
|
|
380
|
+
"choices": null,
|
|
381
|
+
"default": false,
|
|
382
|
+
"required": false,
|
|
383
|
+
"nargs": "0",
|
|
384
|
+
"is_flag": true,
|
|
385
|
+
"type": null,
|
|
386
|
+
"hidden": false
|
|
387
|
+
},
|
|
373
388
|
{
|
|
374
389
|
"names": [
|
|
375
390
|
"--prune-gates"
|
|
@@ -399,6 +414,21 @@
|
|
|
399
414
|
"is_flag": true,
|
|
400
415
|
"type": null,
|
|
401
416
|
"hidden": false
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"names": [
|
|
420
|
+
"--reset"
|
|
421
|
+
],
|
|
422
|
+
"dest": "reset",
|
|
423
|
+
"metavar": null,
|
|
424
|
+
"help": "for this one build, return every setting this build does not pass to its default on the install it targets. Without it, a build over an existing install that would change a setting it was not given refuses, lists each change and prints the command that keeps them (the install's own rebuild, as geneseed status --json shows it). Not recorded",
|
|
425
|
+
"choices": null,
|
|
426
|
+
"default": false,
|
|
427
|
+
"required": false,
|
|
428
|
+
"nargs": "0",
|
|
429
|
+
"is_flag": true,
|
|
430
|
+
"type": null,
|
|
431
|
+
"hidden": false
|
|
402
432
|
}
|
|
403
433
|
],
|
|
404
434
|
"mutex": []
|
|
@@ -955,7 +985,7 @@
|
|
|
955
985
|
},
|
|
956
986
|
{
|
|
957
987
|
"name": "git-gate",
|
|
958
|
-
"help": "PreToolUse hook: ASK before a history-discarding git act (Deletion Is Deliberate), a recursive scan of a whole filesystem (Commands Must Return) and
|
|
988
|
+
"help": "PreToolUse hook: ASK before a history-discarding git act (Deletion Is Deliberate), a recursive scan of a whole filesystem (Commands Must Return) and a git commit or push onto the main branch (Consent Before Push backstop)",
|
|
959
989
|
"description": "",
|
|
960
990
|
"positionals": [],
|
|
961
991
|
"options": [
|
|
@@ -995,7 +1025,22 @@
|
|
|
995
1025
|
],
|
|
996
1026
|
"dest": "no_consent",
|
|
997
1027
|
"metavar": null,
|
|
998
|
-
"help": "skip the Consent Before Push commit/push ask (set by the emit when the process pack or that rule is off); Deletion Is Deliberate still asks",
|
|
1028
|
+
"help": "skip the Consent Before Push main-branch commit/push ask (set by the emit when the process pack or that rule is off); Deletion Is Deliberate still asks",
|
|
1029
|
+
"choices": null,
|
|
1030
|
+
"default": false,
|
|
1031
|
+
"required": false,
|
|
1032
|
+
"nargs": "0",
|
|
1033
|
+
"is_flag": true,
|
|
1034
|
+
"type": null,
|
|
1035
|
+
"hidden": false
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
"names": [
|
|
1039
|
+
"--strict-consent"
|
|
1040
|
+
],
|
|
1041
|
+
"dest": "strict_consent",
|
|
1042
|
+
"metavar": null,
|
|
1043
|
+
"help": "ask on every git commit and push, own branch included (set by the emit for a strict-consent install); the main-branch ask is the same either way",
|
|
999
1044
|
"choices": null,
|
|
1000
1045
|
"default": false,
|
|
1001
1046
|
"required": false,
|
package/js/hosts/done-checks.mjs
CHANGED
|
@@ -23,6 +23,10 @@ export function readDoneChecks(root) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// ---- done-check tables twin: BEGIN — adapters/opencode/plugins/geneseed-context.js carries
|
|
27
|
+
// everything down to the END marker verbatim, with `export ` dropped (node tests/twins.mjs --write
|
|
28
|
+
// keeps it). Its `inferDoneChecks` is the async reading of the one below, kept by hand.
|
|
29
|
+
|
|
26
30
|
// The package manager a lockfile names; first hit wins, npm without one. Exported for the gate that
|
|
27
31
|
// holds the factory `checks` brick's restatement of these rules to this list (factory_graph test).
|
|
28
32
|
export const PM_LOCKS = [['bun.lockb', 'bun'], ['bun.lock', 'bun'], ['pnpm-lock.yaml', 'pnpm'], ['yarn.lock', 'yarn']];
|
|
@@ -58,6 +62,8 @@ const MANIFEST_CHECKS = [
|
|
|
58
62
|
['Cargo.toml', { label: 'cargo test', forms: ['cargo test'], refuse: /(?:^|\s)--no-run(?=\s|$)/ }],
|
|
59
63
|
['go.mod', { label: 'go test', forms: ['go test'] }],
|
|
60
64
|
];
|
|
65
|
+
|
|
66
|
+
// ---- done-check tables twin: END
|
|
61
67
|
/**
|
|
62
68
|
* Every root manifest the checks are inferred from — what an emit seeds into the protected list.
|
|
63
69
|
* @type {string[]}
|
|
@@ -24,8 +24,9 @@ import { gitRootOf } from './gitref.mjs';
|
|
|
24
24
|
/**
|
|
25
25
|
* The `.geneseed/.gitignore` every writer creates: personal by default, the team paths allowed
|
|
26
26
|
* back. Anchored `/*`: a bare `*` matches at every depth and would hide `bricks/x.md` even under
|
|
27
|
-
* `!bricks/`.
|
|
28
|
-
* `adapters/opencode/workflows/_runtime.js`
|
|
27
|
+
* `!bricks/`. `adapters/opencode/plugins/geneseed-workflow.js` and
|
|
28
|
+
* `adapters/opencode/workflows/_runtime.js` carry this line (`node tests/twins.mjs --write`
|
|
29
|
+
* after changing it); `src/skills/_checkpoints.md` restates it by hand, and a test pins that.
|
|
29
30
|
*/
|
|
30
31
|
export const GENESEED_GITIGNORE = '/*\n!/.gitignore\n!/bricks/\n!/loops/\n!/factories/\n!/protected-checks.txt\n!/done-checks.txt\n';
|
|
31
32
|
|
package/js/hosts/gitref.mjs
CHANGED
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
* import. A module that is fs/path only is importable from anywhere.
|
|
14
14
|
*
|
|
15
15
|
* The OpenCode guard plugin (`adapters/opencode/plugins/geneseed-guard.js`) is copied whole
|
|
16
|
-
* into an install and cannot import this, so it carries
|
|
16
|
+
* into an install and cannot import this, so it carries copies of `gitRootOf`, `gitDirOf`,
|
|
17
17
|
* `gitCommonDirOf`, `currentBranch`, `protectedBranches` and `stashExists` for its Law IV and
|
|
18
|
-
* protected-checks gates
|
|
19
|
-
*
|
|
18
|
+
* protected-checks gates, and the activity plugin of `gitRootOf`, `gitDirOf` and
|
|
19
|
+
* `mainWorktreeOf`. After changing one here, `node tests/twins.mjs --write` — so those
|
|
20
|
+
* functions may use nothing the plugins do not import (`existsSync`, `statSync`,
|
|
21
|
+
* `readFileSync`, `readdirSync`, `path`).
|
|
20
22
|
*/
|
|
21
23
|
import { existsSync, statSync, lstatSync, readFileSync, readdirSync, openSync, readSync, closeSync } from 'node:fs';
|
|
22
24
|
import path from 'node:path';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE HOOK TAP: an opt-in record of what a host really sends a hook, as a fixture.
|
|
3
|
+
*
|
|
4
|
+
* `GENESEED_HOOK_TAP=<dir>` in the environment the HOST runs under, and every hook call writes
|
|
5
|
+
* one file, `<dir>/<host>-<event>-<n>.json`, after the verb has decided and printed.
|
|
6
|
+
*
|
|
7
|
+
* WHY IT EXISTS. What a host puts on a hook's stdin is the one input this repo cannot derive:
|
|
8
|
+
* Bob's payload was first read off its docs (`{event, tool, input}`), then off its shipped
|
|
9
|
+
* bundle (Claude's keys plus `cwd`), and neither is a recording. Bob is not on npm, so the
|
|
10
|
+
* canary cannot ask it (docs/concepts/host-matrix.md, "What is verified"). A person with the
|
|
11
|
+
* host can: set the variable, do one thing per event, send the files. Each is then a row in a
|
|
12
|
+
* test instead of a sentence in a docblock.
|
|
13
|
+
*
|
|
14
|
+
* WHAT IT WRITES IS THE SHAPE, NOT THE VALUES. A payload carries the user's prompt, file
|
|
15
|
+
* contents, commands and paths, and a tap file is made to be sent to someone else. So every
|
|
16
|
+
* string becomes `{ type: 'string', length: n }`, at any depth. The exceptions are the few
|
|
17
|
+
* top-level strings that say which event and which tool this is (`KEPT`); they come from the
|
|
18
|
+
* host's own vocabulary, and still pass through Law I's pattern (`SECRET_RE`, the activity
|
|
19
|
+
* writer's redaction). Numbers, booleans and null are kept: they are flags and counts. Keys
|
|
20
|
+
* are kept: they are the whole point.
|
|
21
|
+
*
|
|
22
|
+
* WHAT IT REFUSES, silently, like everything on the hook path:
|
|
23
|
+
* - a tap directory inside a git worktree (`gitRootOf`): a capture must not be one `git add`
|
|
24
|
+
* away from a commit;
|
|
25
|
+
* - a relative directory: a hook's cwd is the session's project;
|
|
26
|
+
* - a model-CLI child `learn` spawned (`GENESEED_LEARN_CHILD`), whose hooks are not the host's.
|
|
27
|
+
*
|
|
28
|
+
* IT NEVER PRINTS AND NEVER THROWS. A hook's stdout is its verdict and its exit code is the
|
|
29
|
+
* block; the caller wraps this too. The variable is read from the environment only and no emit
|
|
30
|
+
* ever writes it into a settings file (`tests/unit/hook_tap.test.mjs` holds both).
|
|
31
|
+
*
|
|
32
|
+
* Loaded by `bin/geneseed-hook.mjs` through a dynamic import, and only when the variable is
|
|
33
|
+
* set, so a hook that is not tapped pays one `process.env` read.
|
|
34
|
+
*/
|
|
35
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
36
|
+
import path from 'node:path';
|
|
37
|
+
|
|
38
|
+
import { gitRootOf } from './gitref.mjs';
|
|
39
|
+
import { SECRET_RE } from './hooks-prims.mjs';
|
|
40
|
+
|
|
41
|
+
/** The top-level strings kept as written: which event, which tool, and how it was triggered. */
|
|
42
|
+
const KEPT = new Set(['hook_event_name', 'event', 'tool_name', 'tool', 'source', 'trigger',
|
|
43
|
+
'permission_mode', 'agent_type', 'matcher']);
|
|
44
|
+
|
|
45
|
+
const SECRET_ALL = new RegExp(SECRET_RE.source, 'g');
|
|
46
|
+
/** A kept string, cut and with anything credential-shaped replaced. */
|
|
47
|
+
const kept = (s) => s.slice(0, 80).replace(SECRET_ALL, '[redacted]');
|
|
48
|
+
|
|
49
|
+
/** How deep a payload is followed. Deeper values become `{ type: 'depth' }`. */
|
|
50
|
+
const MAX_DEPTH = 12;
|
|
51
|
+
/** The most files one event name may fill; the tap then stops rather than fill a disk. */
|
|
52
|
+
const MAX_FILES = 1000;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* `value` with every string replaced by its type and length, keys and structure kept.
|
|
56
|
+
* `top` is true for the payload's own keys, the only place `KEPT` applies.
|
|
57
|
+
*/
|
|
58
|
+
export function shapeOf(value, top = true, depth = 0) {
|
|
59
|
+
if (typeof value === 'string') return { type: 'string', length: value.length };
|
|
60
|
+
if (value === null || typeof value !== 'object') return value;
|
|
61
|
+
if (depth >= MAX_DEPTH) return { type: 'depth' };
|
|
62
|
+
if (Array.isArray(value)) return value.map((v) => shapeOf(v, false, depth + 1));
|
|
63
|
+
const out = {};
|
|
64
|
+
for (const [k, v] of Object.entries(value)) {
|
|
65
|
+
out[k] = top && KEPT.has(k) && typeof v === 'string' ? kept(v) : shapeOf(v, false, depth + 1);
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** A file-name part: letters, digits, `_` and `-` only, never empty. */
|
|
71
|
+
const part = (s, fallback) => (typeof s === 'string' && s.replace(/[^A-Za-z0-9_-]/g, '').slice(0, 40)) || fallback;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Write one tap file for `raw`, the hook's stdin. Returns the file's path, or null when
|
|
75
|
+
* nothing was written (refused, or the directory is full). Never throws.
|
|
76
|
+
*/
|
|
77
|
+
export function tapPayload(dir, raw, { verb, host }) {
|
|
78
|
+
try {
|
|
79
|
+
if (process.env.GENESEED_LEARN_CHILD) return null;
|
|
80
|
+
if (typeof dir !== 'string' || !path.isAbsolute(dir) || gitRootOf(dir)) return null;
|
|
81
|
+
let payload = null;
|
|
82
|
+
try { payload = JSON.parse(raw); } catch { /* not JSON: recorded as such, by length */ }
|
|
83
|
+
const isObject = payload !== null && typeof payload === 'object' && !Array.isArray(payload);
|
|
84
|
+
const event = part(isObject ? (payload.hook_event_name ?? payload.event) : null, verb);
|
|
85
|
+
const body = `${JSON.stringify({
|
|
86
|
+
tap: { host, verb, json: payload !== null || raw.trim() === 'null', bytes: raw.length },
|
|
87
|
+
payload: shapeOf(payload),
|
|
88
|
+
}, null, 2)}\n`;
|
|
89
|
+
mkdirSync(dir, { recursive: true });
|
|
90
|
+
for (let n = 1; n <= MAX_FILES; n += 1) {
|
|
91
|
+
const file = path.join(dir, `${part(host, 'host')}-${event}-${n}.json`);
|
|
92
|
+
try {
|
|
93
|
+
// `wx`: two hooks of one turn run at once, and neither may take the other's number.
|
|
94
|
+
writeFileSync(file, body, { flag: 'wx' });
|
|
95
|
+
return file;
|
|
96
|
+
} catch (e) {
|
|
97
|
+
if (e.code !== 'EEXIST') return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
} catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -97,7 +97,7 @@ const EXCLUDE_DIRS = new Set(['node_modules', '.git', 'dist', 'build', 'vendor',
|
|
|
97
97
|
// The OpenCode context plugin carries the same rule for AGENT.md/AGENTS.md/CLAUDE.md.
|
|
98
98
|
// OpenClaude's root file is AGENTS.md, or CLAUDE.md when AGENTS.md is absent — resolved
|
|
99
99
|
// per repo in `discoverContext`, since which one it loads depends on what is on disk.
|
|
100
|
-
const NATIVE_ROOT = {
|
|
100
|
+
export const NATIVE_ROOT = {
|
|
101
101
|
claude: ['CLAUDE.md'], bob: ['AGENTS.md'],
|
|
102
102
|
openclaude: ['AGENTS.md', 'CLAUDE.md'],
|
|
103
103
|
};
|
|
@@ -848,6 +848,8 @@ export function cmdContext(args) {
|
|
|
848
848
|
// Discovery (and the stand-down) runs against the SESSION's project root, not the harness
|
|
849
849
|
// package dir: `$CLAUDE_PROJECT_DIR` when the host sets it (`hookProjectDir`), because
|
|
850
850
|
// SessionStart also fires on resume/compact/clear, after the agent may have `cd`'d away.
|
|
851
|
+
// `args.cwd` is the payload's `cwd`, which the hook entry already parsed: Bob sets no such
|
|
852
|
+
// variable, and its payload names the root workspace.
|
|
851
853
|
// The only two `resolvePath` calls in this file whose argument can be a `~user` path the
|
|
852
854
|
// user typed — `$GENESEED_ROOT` and `--root` — and `resolvePath` expands, so both can now
|
|
853
855
|
// throw. Every other caller either builds its argument by `path.join` from an absolute
|
|
@@ -857,7 +859,7 @@ export function cmdContext(args) {
|
|
|
857
859
|
let hookRoot;
|
|
858
860
|
try {
|
|
859
861
|
({ root, hookRoot } = withDiscardableStderr(() => ({
|
|
860
|
-
root: resolvePath(process.env.GENESEED_ROOT || hookProjectDir()),
|
|
862
|
+
root: resolvePath(process.env.GENESEED_ROOT || hookProjectDir(args && args.cwd)),
|
|
861
863
|
hookRoot: args.root ? resolvePath(args.root) : null,
|
|
862
864
|
})));
|
|
863
865
|
} catch {
|