geneseed 5.4.0 → 5.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/README.md +31 -1
- 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 +11 -2
- 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 +226 -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 +12 -17
- 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 +10 -4
- 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/autonomous.json +14 -0
- package/profiles/corporate.json +14 -0
- package/profiles/guillaume-claude-global.json +16 -0
- package/profiles/mentor.json +13 -0
- package/profiles/minimal.json +15 -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 +7 -6
- 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 +4 -2
- 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 +4 -4
- package/src/agents/spring-reviewer.md +5 -3
- 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/codebase-design.md +2 -2
- package/src/skills/daydream/VENDOR.md +6 -0
- package/src/skills/diagram-design/SKILL.md +12 -7
- package/src/skills/diagram-design/VENDOR.md +23 -14
- package/src/skills/diagram-design/references/layout-budget.md +7 -1
- package/src/skills/diagram-design/references/onboarding.md +1 -1
- package/src/skills/diagram-design/references/primitives-core.md +1 -1
- package/src/skills/diagram-design/references/semantic-patterns.md +1 -1
- package/src/skills/diagram-design/references/style-guide.md +1 -1
- package/src/skills/diagram-design/references/type-dependency.md +69 -0
- package/src/skills/diagram-design/references/type-event-modeling.md +36 -0
- package/src/skills/diagram-design/references/type-requirement-traceability.md +45 -0
- package/src/skills/diagram-design/references/type-sbgn.md +80 -0
- package/src/skills/diagram-design/references/type-scatter.md +1 -1
- package/src/skills/diagram-design/references/type-steps.md +180 -0
- package/src/skills/diagram-design/references/type-unit-grid.md +63 -0
- package/src/skills/explain-changes/VENDOR.md +5 -1
- package/src/skills/geneseed-code-review.md +2 -1
- package/src/skills/parallel-agents.md +12 -1
- package/src/skills/pipeline.md +3 -3
- package/src/skills/plan.md +5 -4
- package/src/skills/react-view-transitions/AGENTS.md +26 -26
- package/src/skills/react-view-transitions/SKILL.md +1 -1
- package/src/skills/react-view-transitions/VENDOR.md +19 -4
- 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/spring-boot/cloud.md +19 -1
- package/src/skills/spring-boot/logging.md +5 -3
- package/src/skills/spring-boot/web.md +27 -2
- package/src/skills/spring-boot.md +4 -2
- package/src/skills/spring-data-jpa.md +18 -4
- package/src/skills/spring-testing.md +4 -0
- package/src/skills/token-report/VENDOR.md +5 -1
- package/src/upstreams.json +6 -6
- 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-bUSPM3Dl.js} +1 -1
- package/web/dist/assets/{ActivityDetail-By3xOr21.js → ActivityDetail-AHRoXeFN.js} +1 -1
- package/web/dist/assets/{Bonsai-CBWDTBA4.js → Bonsai-B5XY9pid.js} +1 -1
- package/web/dist/assets/{CopyButton-BVbpriMB.js → CopyButton-C0wwRR9H.js} +1 -1
- package/web/dist/assets/{Dashboard-CIJLPHM9.js → Dashboard-DPAA96EI.js} +2 -2
- package/web/dist/assets/{Docs-CiRRIELs.js → Docs-CpGDq165.js} +1 -1
- package/web/dist/assets/{Factories-DhyK0O8d.js → Factories-cNhETa5Q.js} +1 -1
- package/web/dist/assets/{GreenhouseView-DW3PgTPy.js → GreenhouseView-DO3ADmT9.js} +1 -1
- package/web/dist/assets/Installs-D3dDyq10.js +3 -0
- package/web/dist/assets/{JournalView-O65qEWfp.js → JournalView--W-Lw_V9.js} +1 -1
- package/web/dist/assets/{Kits-C5U-yT6Z.js → Kits-ChfehxY6.js} +1 -1
- package/web/dist/assets/Laws-CNxYmV36.js +4 -0
- package/web/dist/assets/{LibRows-D6-CVa3K.js → LibRows-CiPvsRYB.js} +1 -1
- package/web/dist/assets/{Library-CzPlerd6.js → Library-BxQvbwVU.js} +1 -1
- package/web/dist/assets/{Loops-CqNF_-nS.js → Loops-DAblKkyq.js} +1 -1
- package/web/dist/assets/{OperatorHudView-BNr8K5qj.js → OperatorHudView-QtSaSyYm.js} +1 -1
- package/web/dist/assets/{Personal-DeDb9e8O.js → Personal-DxSGv638.js} +1 -1
- package/web/dist/assets/{Settings-B8MPN_AD.js → Settings-CgTbhvRv.js} +1 -1
- package/web/dist/assets/{Tabs-DJzAez4h.js → Tabs-Cf4X1hdz.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-BL3P-9Rg.js → index-B_pTwZra.js} +4 -4
- package/web/dist/assets/index-CzfImiYb.css +1 -0
- package/web/dist/index.html +3 -3
- package/web/dist/assets/Installs-B6nlo-Ly.js +0 -3
- package/web/dist/assets/Laws-CuTw_XNf.js +0 -4
- package/web/dist/assets/api-DLDVY3K-.js +0 -1
- package/web/dist/assets/index-CRWqKxfY.css +0 -1
package/js/cli-table.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"commands": [
|
|
4
4
|
{
|
|
5
5
|
"name": "activity",
|
|
6
|
-
"help": "UserPromptSubmit/SessionEnd hook: records the session into <root>/activity/ for the web console's live view
|
|
6
|
+
"help": "UserPromptSubmit/SessionEnd hook: records the session into <root>/activity/ for the web console's live view (off with $GENESEED_ACTIVITY=off or the console toggle), and counts a typed /<skill> into <root>/notebook/usage.jsonl (off with $GENESEED_NO_USAGE or .usage-off); decides nothing and prints nothing",
|
|
7
7
|
"description": "",
|
|
8
8
|
"positionals": [],
|
|
9
9
|
"options": [
|
|
@@ -235,6 +235,21 @@
|
|
|
235
235
|
"type": null,
|
|
236
236
|
"hidden": false
|
|
237
237
|
},
|
|
238
|
+
{
|
|
239
|
+
"names": [
|
|
240
|
+
"--context-window"
|
|
241
|
+
],
|
|
242
|
+
"dest": "context_window",
|
|
243
|
+
"metavar": null,
|
|
244
|
+
"help": "the model context window the install is built for: 200k|1m (default: 200k). On Claude Code it sets the skill-listing budget in settings.json so every skill keeps a description; other hosts record it and write nothing",
|
|
245
|
+
"choices": null,
|
|
246
|
+
"default": null,
|
|
247
|
+
"required": false,
|
|
248
|
+
"nargs": null,
|
|
249
|
+
"is_flag": false,
|
|
250
|
+
"type": null,
|
|
251
|
+
"hidden": false
|
|
252
|
+
},
|
|
238
253
|
{
|
|
239
254
|
"names": [
|
|
240
255
|
"--out"
|
|
@@ -488,6 +503,21 @@
|
|
|
488
503
|
"is_flag": true,
|
|
489
504
|
"type": null,
|
|
490
505
|
"hidden": false
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
"names": [
|
|
509
|
+
"--scores"
|
|
510
|
+
],
|
|
511
|
+
"dest": "scores",
|
|
512
|
+
"metavar": null,
|
|
513
|
+
"help": "with the agents section: each agent's recorded runs per spec hash, from each active install's notebook/agent-runs.jsonl (read-only)",
|
|
514
|
+
"choices": null,
|
|
515
|
+
"default": false,
|
|
516
|
+
"required": false,
|
|
517
|
+
"nargs": "0",
|
|
518
|
+
"is_flag": true,
|
|
519
|
+
"type": null,
|
|
520
|
+
"hidden": false
|
|
491
521
|
}
|
|
492
522
|
],
|
|
493
523
|
"mutex": []
|
|
@@ -1579,6 +1609,120 @@
|
|
|
1579
1609
|
],
|
|
1580
1610
|
"mutex": []
|
|
1581
1611
|
},
|
|
1612
|
+
{
|
|
1613
|
+
"name": "profile",
|
|
1614
|
+
"help": "apply an install profile, or save an install as one",
|
|
1615
|
+
"description": "apply an install profile globally or to one project folder, or save an existing install as one. Profiles come from two sources: Shipped (profiles/ in this checkout) and Personal (profiles/ in the machine-wide Geneseed folder, beside memory and rules). apply builds the profile into each host it names that this machine has (--hosts narrows it) and touches no other install; it puts nothing on PATH and starts no console. save copies every build setting of one install as it is, gates switched off included, writes a Personal profile unless --shipped, and prints how it differs from starter. It reads no user rules, profile, memory, wiki or notebook",
|
|
1616
|
+
"positionals": [
|
|
1617
|
+
{
|
|
1618
|
+
"names": [],
|
|
1619
|
+
"dest": "action",
|
|
1620
|
+
"metavar": null,
|
|
1621
|
+
"help": "save — write NAME.json from the install named by --from; apply — build profile NAME into this machine's hosts",
|
|
1622
|
+
"choices": [
|
|
1623
|
+
"save",
|
|
1624
|
+
"apply"
|
|
1625
|
+
],
|
|
1626
|
+
"default": null,
|
|
1627
|
+
"required": true,
|
|
1628
|
+
"nargs": null,
|
|
1629
|
+
"is_flag": false,
|
|
1630
|
+
"type": null,
|
|
1631
|
+
"hidden": false
|
|
1632
|
+
},
|
|
1633
|
+
{
|
|
1634
|
+
"names": [],
|
|
1635
|
+
"dest": "name",
|
|
1636
|
+
"metavar": null,
|
|
1637
|
+
"help": "the profile name (a file stem: letters, digits, '.', '_' and '-')",
|
|
1638
|
+
"choices": null,
|
|
1639
|
+
"default": null,
|
|
1640
|
+
"required": true,
|
|
1641
|
+
"nargs": null,
|
|
1642
|
+
"is_flag": false,
|
|
1643
|
+
"type": null,
|
|
1644
|
+
"hidden": false
|
|
1645
|
+
}
|
|
1646
|
+
],
|
|
1647
|
+
"options": [
|
|
1648
|
+
{
|
|
1649
|
+
"names": [
|
|
1650
|
+
"--from"
|
|
1651
|
+
],
|
|
1652
|
+
"dest": "from",
|
|
1653
|
+
"metavar": "EMIT",
|
|
1654
|
+
"help": "save: the install to read — opencode-global, claude-global, bob-global or openclaude-global, or a bare host (opencode, claude, bob, openclaude) with --project for a project install",
|
|
1655
|
+
"choices": null,
|
|
1656
|
+
"default": null,
|
|
1657
|
+
"required": false,
|
|
1658
|
+
"nargs": null,
|
|
1659
|
+
"is_flag": false,
|
|
1660
|
+
"type": null,
|
|
1661
|
+
"hidden": false
|
|
1662
|
+
},
|
|
1663
|
+
{
|
|
1664
|
+
"names": [
|
|
1665
|
+
"--project"
|
|
1666
|
+
],
|
|
1667
|
+
"dest": "project",
|
|
1668
|
+
"metavar": "DIR",
|
|
1669
|
+
"help": "apply: build into this project folder instead of globally; save: the folder of the project install --from names",
|
|
1670
|
+
"choices": null,
|
|
1671
|
+
"default": null,
|
|
1672
|
+
"required": false,
|
|
1673
|
+
"nargs": null,
|
|
1674
|
+
"is_flag": false,
|
|
1675
|
+
"type": null,
|
|
1676
|
+
"hidden": false
|
|
1677
|
+
},
|
|
1678
|
+
{
|
|
1679
|
+
"names": [
|
|
1680
|
+
"--hosts"
|
|
1681
|
+
],
|
|
1682
|
+
"dest": "hosts",
|
|
1683
|
+
"metavar": "HOSTS",
|
|
1684
|
+
"help": "apply: comma-separated hosts to build, a subset of the profile's (default: each of them this machine has)",
|
|
1685
|
+
"choices": null,
|
|
1686
|
+
"default": null,
|
|
1687
|
+
"required": false,
|
|
1688
|
+
"nargs": null,
|
|
1689
|
+
"is_flag": false,
|
|
1690
|
+
"type": null,
|
|
1691
|
+
"hidden": false
|
|
1692
|
+
},
|
|
1693
|
+
{
|
|
1694
|
+
"names": [
|
|
1695
|
+
"--shipped"
|
|
1696
|
+
],
|
|
1697
|
+
"dest": "shipped",
|
|
1698
|
+
"metavar": null,
|
|
1699
|
+
"help": "save: write profiles/NAME.json in this checkout (a git clone only) instead of a Personal profile",
|
|
1700
|
+
"choices": null,
|
|
1701
|
+
"default": false,
|
|
1702
|
+
"required": false,
|
|
1703
|
+
"nargs": "0",
|
|
1704
|
+
"is_flag": true,
|
|
1705
|
+
"type": null,
|
|
1706
|
+
"hidden": false
|
|
1707
|
+
},
|
|
1708
|
+
{
|
|
1709
|
+
"names": [
|
|
1710
|
+
"--force"
|
|
1711
|
+
],
|
|
1712
|
+
"dest": "force",
|
|
1713
|
+
"metavar": null,
|
|
1714
|
+
"help": "save: replace NAME.json when it already exists in the same source (that file only)",
|
|
1715
|
+
"choices": null,
|
|
1716
|
+
"default": false,
|
|
1717
|
+
"required": false,
|
|
1718
|
+
"nargs": "0",
|
|
1719
|
+
"is_flag": true,
|
|
1720
|
+
"type": null,
|
|
1721
|
+
"hidden": false
|
|
1722
|
+
}
|
|
1723
|
+
],
|
|
1724
|
+
"mutex": []
|
|
1725
|
+
},
|
|
1582
1726
|
{
|
|
1583
1727
|
"name": "prompt",
|
|
1584
1728
|
"help": "emit a self-contained install prompt",
|
|
@@ -1780,10 +1924,26 @@
|
|
|
1780
1924
|
},
|
|
1781
1925
|
{
|
|
1782
1926
|
"name": "setup",
|
|
1783
|
-
"help": "
|
|
1784
|
-
"description": "",
|
|
1927
|
+
"help": "install wizard; --profile NAME installs a profile with no questions",
|
|
1928
|
+
"description": "interactive install wizard (dependency-free, all OSes). With --profile <name>, it asks nothing: it installs that profile (Shipped, from profiles/ in this checkout, or Personal, from profiles/ in the machine-wide Geneseed folder) globally into each AI coding tool the profile lists that is found on this machine, puts geneseed on PATH, sets the web console to start at login, starts it, and runs the doctor",
|
|
1785
1929
|
"positionals": [],
|
|
1786
|
-
"options": [
|
|
1930
|
+
"options": [
|
|
1931
|
+
{
|
|
1932
|
+
"names": [
|
|
1933
|
+
"--profile"
|
|
1934
|
+
],
|
|
1935
|
+
"dest": "profile",
|
|
1936
|
+
"metavar": "NAME",
|
|
1937
|
+
"help": "install profile NAME (Shipped, in profiles/, or Personal, in the machine-wide profiles/) globally with no questions (e.g. starter); works without a terminal",
|
|
1938
|
+
"choices": null,
|
|
1939
|
+
"default": null,
|
|
1940
|
+
"required": false,
|
|
1941
|
+
"nargs": null,
|
|
1942
|
+
"is_flag": false,
|
|
1943
|
+
"type": null,
|
|
1944
|
+
"hidden": false
|
|
1945
|
+
}
|
|
1946
|
+
],
|
|
1787
1947
|
"mutex": []
|
|
1788
1948
|
},
|
|
1789
1949
|
{
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE AGENT OUTCOME LEDGER — did a spec refinement make an agent better? One line per finished
|
|
3
|
+
* sub-agent, appended to `<install>/notebook/agent-runs.jsonl` beside `usage.jsonl`:
|
|
4
|
+
* `{"ts":"2026-11-14","agent":"developer","spec":"56510da85fb8","done":"ended","blocks":0,
|
|
5
|
+
* "tools":42,"refused":1,"feedback":0,"report":true}`. `spec` is a short hash of the agent's
|
|
6
|
+
* rendered spec, so the runs before and after a spec edit fall into two rows of
|
|
7
|
+
* `geneseed catalog agents --scores` (js/inspect/agent-scores.mjs).
|
|
8
|
+
*
|
|
9
|
+
* MECHANICAL ONLY (user decision 2026-11-14, "v1 mechanical only"). Every field is a fact the hook
|
|
10
|
+
* reads off the transcript, the install or the done gate's own state, never a score the agent gives
|
|
11
|
+
* itself, and nothing waits on a model remembering a step: that is what kept the spec-feedback loop
|
|
12
|
+
* empty until the hook captured it (./spec-feedback.mjs).
|
|
13
|
+
*
|
|
14
|
+
* WHAT `done` CAN SAY. On SubagentStop, `doneGate` (./hooks-done.mjs) returns 'block' or null, and
|
|
15
|
+
* a block returns before this runs, so a line is written only for a stop that ended the turn.
|
|
16
|
+
* Pass, advisory, cap reached and a skipped gate all return null, so they cannot be told apart
|
|
17
|
+
* here: `done` is "ended" (the gate ran over a transcript and let the turn end), "not-judged" (the
|
|
18
|
+
* gate ran with no transcript to read, or on Bob) or null (the gate did not run: switched off, or a
|
|
19
|
+
* manual `--file` run). `blocks` is how many times the gate blocked this turn before it ended, read
|
|
20
|
+
* from the cap state the gate itself wrote (`blocksOf`). A richer verdict needs a richer `doneGate`
|
|
21
|
+
* return, which is that file's change to make.
|
|
22
|
+
*
|
|
23
|
+
* The same privacy rules as `usage.jsonl` (./usage.mjs): counts only, the day not the instant,
|
|
24
|
+
* never a prompt, an argument or a path. Off when `GENESEED_NO_USAGE` is set or `.usage-off` exists,
|
|
25
|
+
* and only when `<install>/notebook` exists (never created here).
|
|
26
|
+
*
|
|
27
|
+
* ON THE HOOK PATH: builtins and sibling hook modules only, no spawn, nothing printed, and every
|
|
28
|
+
* error swallowed. Parallel sub-agents end together; each line is one `appendFileSync` of well
|
|
29
|
+
* under a page, as `usage.jsonl` is written, so each lands whole without a lock.
|
|
30
|
+
*/
|
|
31
|
+
import { createHash } from 'node:crypto';
|
|
32
|
+
import { appendFileSync, existsSync, readFileSync, statSync } from 'node:fs';
|
|
33
|
+
import path from 'node:path';
|
|
34
|
+
import { GLOBAL_MANIFEST } from './hosts.mjs';
|
|
35
|
+
import { SECRET_RE, splitLines } from './hooks-prims.mjs';
|
|
36
|
+
import { specFeedbackOf } from './spec-feedback.mjs';
|
|
37
|
+
import { capFile, isPrompt } from './hooks-done.mjs';
|
|
38
|
+
import { RUNS_LEDGER, USAGE_OFF } from './usage.mjs';
|
|
39
|
+
|
|
40
|
+
export { RUNS_LEDGER };
|
|
41
|
+
|
|
42
|
+
// ---- agent-runs twin: BEGIN — adapters/opencode/plugins/geneseed-learn.js carries everything down
|
|
43
|
+
// to the END marker verbatim, with `export ` dropped (`node tests/twins.mjs --write` after a change).
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A refused tool call: the result text a host or a gate gives a call it did not run. Only the
|
|
47
|
+
* result's FIRST line is read, and every marker is anchored at its start (a host prefix of at most
|
|
48
|
+
* 80 characters allowed for Geneseed's own words): a red test or a search that QUOTES a gate's text
|
|
49
|
+
* further down its output is an error, not a refusal. One row each, with where its text comes from:
|
|
50
|
+
* - Geneseed's own refusal (`gateText` mode `refused`, js/hosts/hooks-prims.mjs), and the text
|
|
51
|
+
* said when that text fails (`GATE_UNSAID`), behind a host's prefix ("PreToolUse:Bash hook …").
|
|
52
|
+
* - The OpenCode guard: V1 throws `[geneseed-guard] blocked: …`; V2 renames the call, and core
|
|
53
|
+
* answers `No tool named "BLOCKED, not a missing tool: …"` (geneseed-guard.js, seen on 2.2.6).
|
|
54
|
+
* - Claude Code's auto-mode classifier, seen live 2026-11-14: "Permission for this action was
|
|
55
|
+
* denied by the Claude Code auto mode classifier."
|
|
56
|
+
* - Claude Code's worktree isolation, seen live 2026-11-14: "This agent is isolated in the
|
|
57
|
+
* worktree …, but this command … Refusing to run it — …".
|
|
58
|
+
* - Claude Code's permission rule deny and a user's "no" to an ask: UNVERIFIED wording.
|
|
59
|
+
*/
|
|
60
|
+
export const REFUSAL_MARKERS = [
|
|
61
|
+
/^.{0,80}?Tell the user this, word for word:/,
|
|
62
|
+
/^.{0,80}?Geneseed could not describe this call\./,
|
|
63
|
+
/^\[geneseed-guard\] blocked:/,
|
|
64
|
+
/^No tool named "BLOCKED, not a missing tool:/,
|
|
65
|
+
/^Permission for this action was denied\b/,
|
|
66
|
+
/^This agent is isolated in the worktree .{1,600}? Refusing to run it\b/,
|
|
67
|
+
/^Permission to use \S.{0,300}? has been denied\b/,
|
|
68
|
+
/^The user doesn't want to (?:proceed with|take) this/,
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* True when the first line of `text` (a tool result) says the call was refused. Each marker is
|
|
73
|
+
* anchored with `^` (no `m` flag) and its `.` never crosses a line break, so a marker can only
|
|
74
|
+
* match on the first line.
|
|
75
|
+
*/
|
|
76
|
+
export function isRefusal(text) {
|
|
77
|
+
const t = String(text ?? '').trimStart();
|
|
78
|
+
return REFUSAL_MARKERS.some((re) => re.test(t));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The short hash of a rendered spec: sha256 of its text with line endings folded to LF, 12 hex. */
|
|
82
|
+
export function specHashOf(text) {
|
|
83
|
+
return createHash('sha256').update(String(text).replace(/\r\n?/g, '\n'), 'utf8').digest('hex').slice(0, 12);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The ledger line, field order fixed. `ts` is the UTC day, as `usage.jsonl` stamps it. */
|
|
87
|
+
export function agentRunLine(run, now = new Date()) {
|
|
88
|
+
return `${JSON.stringify({
|
|
89
|
+
ts: now.toISOString().slice(0, 10), agent: run.agent, spec: run.spec ?? null, done: run.done ?? null,
|
|
90
|
+
blocks: run.blocks ?? null, tools: run.tools ?? null, refused: run.refused ?? null,
|
|
91
|
+
feedback: run.feedback ?? 0, report: Boolean(run.report),
|
|
92
|
+
})}\n`;
|
|
93
|
+
}
|
|
94
|
+
// ---- agent-runs twin: END
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* `<install>/agents/<agent>.md`'s hash when Geneseed ships it there (its manifest's `owned` names
|
|
98
|
+
* it), else null: general-purpose, Explore and a user's own agent have no rendered spec to compare.
|
|
99
|
+
*/
|
|
100
|
+
export function specOf(install, agent) {
|
|
101
|
+
try {
|
|
102
|
+
const owned = JSON.parse(readFileSync(path.join(install, GLOBAL_MANIFEST), 'utf8')).owned;
|
|
103
|
+
const rel = `agents/${agent}.md`;
|
|
104
|
+
if (!Array.isArray(owned) || !owned.includes(rel)) return null;
|
|
105
|
+
return specHashOf(readFileSync(path.join(install, 'agents', `${agent}.md`), 'utf8'));
|
|
106
|
+
} catch { return null; }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** A tool result's text: a string, or its text blocks joined. */
|
|
110
|
+
function resultText(b) {
|
|
111
|
+
if (typeof b.content === 'string') return b.content;
|
|
112
|
+
if (!Array.isArray(b.content)) return '';
|
|
113
|
+
return b.content.filter((x) => x && x.type === 'text' && typeof x.text === 'string').map((x) => x.text).join('\n');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* `{ tools, refused, opening }` for the current turn of a sub-agent transcript's TEXT, or null when
|
|
118
|
+
* `whole` is false and the text holds no prompt (the tail reader then reads further back).
|
|
119
|
+
* `opening` is the gate's key for the turn (`turnOf`): the prompt line's `uuid`, else its content.
|
|
120
|
+
*/
|
|
121
|
+
export function runCounts(raw, whole = true) {
|
|
122
|
+
const entries = [];
|
|
123
|
+
for (const line of splitLines(raw)) {
|
|
124
|
+
if (!line.trim()) continue;
|
|
125
|
+
try { entries.push(JSON.parse(line)); } catch { /* a torn line is no call */ }
|
|
126
|
+
}
|
|
127
|
+
let start = -1;
|
|
128
|
+
// The gate's own rule (./hooks-done.mjs `isPrompt`, sidechain mode). A resumed sub-agent appends
|
|
129
|
+
// its next turn to the same file, so the counts are the CURRENT turn's, as the gate judges it.
|
|
130
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) if (entries[i] && isPrompt(entries[i], true)) { start = i + 1; break; }
|
|
131
|
+
if (start === -1) {
|
|
132
|
+
if (!whole) return null;
|
|
133
|
+
start = 0;
|
|
134
|
+
}
|
|
135
|
+
const first = entries[start - 1];
|
|
136
|
+
const opening = !first ? '' : typeof first.uuid === 'string' ? first.uuid
|
|
137
|
+
: JSON.stringify(first.message && first.message.content).slice(0, 300);
|
|
138
|
+
let tools = 0;
|
|
139
|
+
let refused = 0;
|
|
140
|
+
for (const obj of entries.slice(start)) {
|
|
141
|
+
const content = obj.message && obj.message.content;
|
|
142
|
+
if (!Array.isArray(content)) continue;
|
|
143
|
+
for (const b of content) {
|
|
144
|
+
if (!b || typeof b !== 'object') continue;
|
|
145
|
+
if (b.type === 'tool_use') tools += 1;
|
|
146
|
+
else if (b.type === 'tool_result' && b.is_error === true && isRefusal(resultText(b))) refused += 1;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { tools, refused, opening };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* How many times the done gate blocked this sub-agent's turn: `total` in the cap state it saved
|
|
154
|
+
* (./hooks-done.mjs `capFile`), when that state is this turn's (same `opening`); 0 with no state,
|
|
155
|
+
* or another turn's.
|
|
156
|
+
*/
|
|
157
|
+
export function blocksOf(install, meta, opening) {
|
|
158
|
+
const file = install ? capFile(install, { ...meta, hook_event_name: 'SubagentStop' }) : null;
|
|
159
|
+
if (!file) return 0;
|
|
160
|
+
try {
|
|
161
|
+
const state = JSON.parse(readFileSync(file, 'utf8'));
|
|
162
|
+
if (!state || state.opening !== opening) return 0;
|
|
163
|
+
return Number.isInteger(state.total) ? state.total : Number.isInteger(state.blocks) ? state.blocks : 0;
|
|
164
|
+
} catch { return 0; }
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** True when the ledger is switched off for `install`, or has nowhere to go. */
|
|
168
|
+
function ledgerOff(install) {
|
|
169
|
+
if (!install || process.env.GENESEED_NO_USAGE) return true;
|
|
170
|
+
if (existsSync(path.join(install, USAGE_OFF))) return true;
|
|
171
|
+
try { return !statSync(path.join(install, 'notebook')).isDirectory(); } catch { return true; }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The SubagentStop write: one line for `agent`'s finished turn. `done` is `cmdLearn`'s reading of
|
|
176
|
+
* the gate (see the header), `report` the sub-agent's final report text (`subagentReport`), `read`
|
|
177
|
+
* the Stop's shared transcript reader. Returns the line written, or null. Never throws.
|
|
178
|
+
* @param {string | null} install
|
|
179
|
+
* @param {string | null} agent
|
|
180
|
+
* @param {Record<string, any>} meta
|
|
181
|
+
* @param {{ done?: string | null, report?: string, read?: Function | null }} [opts]
|
|
182
|
+
* @param {Date} [now]
|
|
183
|
+
*/
|
|
184
|
+
export function recordAgentRun(install, agent, meta, { done = null, report = '', read } = {}, now = new Date()) {
|
|
185
|
+
try {
|
|
186
|
+
if (!agent || ledgerOff(install)) return null;
|
|
187
|
+
const tp = typeof meta.agent_transcript_path === 'string' && meta.agent_transcript_path ? meta.agent_transcript_path : null;
|
|
188
|
+
let counts = null;
|
|
189
|
+
if (tp && read) {
|
|
190
|
+
try { counts = read(tp, (raw, whole) => runCounts(raw, whole)); } catch { counts = null; }
|
|
191
|
+
}
|
|
192
|
+
const line = agentRunLine({
|
|
193
|
+
agent, spec: specOf(install, agent), done,
|
|
194
|
+
blocks: done === 'ended' && counts ? blocksOf(install, meta, counts.opening) : null,
|
|
195
|
+
tools: counts ? counts.tools : null, refused: counts ? counts.refused : null,
|
|
196
|
+
// The agent's own lines: a `[skill:…]` line it relays is about a skill, not its spec.
|
|
197
|
+
feedback: specFeedbackOf(report, SECRET_RE).filter((f) => !f.skill).length, report: Boolean(String(report || '').trim()),
|
|
198
|
+
}, now);
|
|
199
|
+
const file = path.join(install, RUNS_LEDGER);
|
|
200
|
+
// One line in one `appendFileSync` (O_APPEND), as usage.jsonl is written: parallel stops each
|
|
201
|
+
// land a whole line, so there is no lock to wait on.
|
|
202
|
+
appendFileSync(file, line);
|
|
203
|
+
return line;
|
|
204
|
+
} catch { return null; }
|
|
205
|
+
}
|
package/js/hosts/done-checks.mjs
CHANGED
|
@@ -82,7 +82,9 @@ export const INFERRED_FROM = ['package.json', ...MANIFEST_CHECKS.map(([f]) => /*
|
|
|
82
82
|
* - the git root's manifests only — a monorepo's subprojects (`pnpm -r test`,
|
|
83
83
|
* `./gradlew :app:test`, `mvn -pl core test`) are neither inferred nor matched;
|
|
84
84
|
* - a sibling script (`npm run test:unit`) or a runner called directly (`npx vitest`);
|
|
85
|
-
* - a prefix before the command (`CI=1 npm test`, `mvn -q test`): forms match verbatim
|
|
85
|
+
* - a prefix before the command (`CI=1 npm test`, `mvn -q test`): forms match verbatim, save
|
|
86
|
+
* for `npm --prefix <project>`, `git -C <project>` and `--test-concurrency N`, which
|
|
87
|
+
* `normalizeRun` (`./hooks-done.mjs`) takes off both sides.
|
|
86
88
|
*/
|
|
87
89
|
export function inferDoneChecks(root) {
|
|
88
90
|
const has = (f) => existsSync(path.join(root, f));
|
package/js/hosts/hooks-done.mjs
CHANGED
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
* whose result is not an error (a denied write changed nothing);
|
|
49
49
|
* - a pass is a Bash/PowerShell call whose command contains one of the check's forms UNPIPED (a pipe
|
|
50
50
|
* takes the exit code of its last stage: `npm test | tail` exits 0 on a red suite), not MASKED
|
|
51
|
-
* after it (`|| true`, `; exit 0` — see `runsUnpiped`),
|
|
51
|
+
* after it (`|| true`, `; exit 0` — see `runsUnpiped`), compared after `normalizeRun` takes
|
|
52
|
+
* `npm --prefix <project>`, `git -C <project>` and `--test-concurrency N` off both sides, and whose
|
|
52
53
|
* result is not `is_error` — every non-zero exit, denial and timeout carries it (checked on
|
|
53
54
|
* 14 000+ real Claude Code results, 2026-10-17);
|
|
54
55
|
* - a BACKGROUND run (`run_in_background: true`, or moved there after its foreground timeout)
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
* stderr line says the total ceiling was reached. The count lives in a per-session file under the install; without one,
|
|
82
83
|
* `stop_hook_active` (true when this Stop follows a block) ends the turn at once.
|
|
83
84
|
*/
|
|
84
|
-
import { mkdirSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
85
|
+
import { mkdirSync, readdirSync, readFileSync, realpathSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
85
86
|
import path from 'node:path';
|
|
86
87
|
import { printOut as out, printErr as err } from '../lib/fs.mjs';
|
|
87
88
|
import { within } from '../lib/paths.mjs';
|
|
@@ -149,19 +150,87 @@ export function runsUnpiped(command, line) {
|
|
|
149
150
|
return false;
|
|
150
151
|
}
|
|
151
152
|
|
|
153
|
+
/**
|
|
154
|
+
* `command` with the flags that name WHERE a check runs, or how many workers run it, taken out,
|
|
155
|
+
* so a check line and the command that proves it compare on what is tested (user decision
|
|
156
|
+
* 2026-11-14: workers in worktrees ran `npm --prefix <worktree> run lint` and the suite at the
|
|
157
|
+
* default concurrency, all green, and the gate blocked them). Applied to both sides before the
|
|
158
|
+
* prefix match (`groupPasses`). Removed, and nothing else:
|
|
159
|
+
* - `--prefix <dir>` / `--prefix=<dir>` in a segment opened by `npm`, before any `--`;
|
|
160
|
+
* - `-C <dir>` right after `git` (its global options only, so `make -C` and `tar -C` stay);
|
|
161
|
+
* - `--test-concurrency=N` / `--test-concurrency N` (N digits) in a `node` segment holding `--test`.
|
|
162
|
+
* A `<dir>` is removed only when `sameProject(dir)` says it names the judged project (`projectDir`):
|
|
163
|
+
* a check run in another project still counts as not run. Separators (`&&`, `||`, `|`, `;`,
|
|
164
|
+
* newlines) are kept as they stand, so the piping and masking rules of `runsUnpiped` read the
|
|
165
|
+
* same line. shortcut: a segment is tokenized on spaces with quoted runs kept whole; a segment
|
|
166
|
+
* left unchanged keeps its text byte for byte. Pure: the plugin twin is a copy.
|
|
167
|
+
*/
|
|
168
|
+
export function normalizeRun(command, sameProject) {
|
|
169
|
+
const cmd = String(command).replace(/[ \t]+/g, ' ');
|
|
170
|
+
return cmd.split(/(&&|\|\||[|;\n])/).map((seg, k) => {
|
|
171
|
+
if (k % 2) return seg;
|
|
172
|
+
const toks = seg.trim().match(/(?:"[^"]*"|'[^']*'|[^ "']|["'])+/g);
|
|
173
|
+
if (!toks) return seg;
|
|
174
|
+
const [tool] = toks;
|
|
175
|
+
const test = tool === 'node' && toks.includes('--test');
|
|
176
|
+
const out = [tool];
|
|
177
|
+
let opts = true;
|
|
178
|
+
for (let i = 1; i < toks.length; i += 1) {
|
|
179
|
+
const t = toks[i];
|
|
180
|
+
if (t === '--') opts = false;
|
|
181
|
+
if (opts && tool === 'npm') {
|
|
182
|
+
if (t === '--prefix' && i + 1 < toks.length && sameProject(toks[i + 1])) { i += 1; continue; }
|
|
183
|
+
if (t.startsWith('--prefix=') && sameProject(t.slice(9))) continue;
|
|
184
|
+
}
|
|
185
|
+
if (tool === 'git' && out.length === 1 && t === '-C' && i + 1 < toks.length && sameProject(toks[i + 1])) { i += 1; continue; }
|
|
186
|
+
if (opts && test) {
|
|
187
|
+
if (/^--test-concurrency=\d+$/.test(t)) continue;
|
|
188
|
+
if (t === '--test-concurrency' && /^\d+$/.test(toks[i + 1] ?? '')) { i += 1; continue; }
|
|
189
|
+
}
|
|
190
|
+
out.push(t);
|
|
191
|
+
}
|
|
192
|
+
if (out.length === toks.length) return seg;
|
|
193
|
+
return `${seg.startsWith(' ') ? ' ' : ''}${out.join(' ')}${seg.endsWith(' ') ? ' ' : ''}`;
|
|
194
|
+
}).join('');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The `sameProject` of `normalizeRun` for the project at `root`, a dir resolved against `cwd`:
|
|
199
|
+
* true only when it is the judged root ITSELF (real paths, so a junction or symlink to it counts;
|
|
200
|
+
* case-blind on Windows). The root may be a linked worktree. A sibling worktree or the main checkout
|
|
201
|
+
* of the same repository is false (user ruling 2026-11-14): a run there never saw this tree's
|
|
202
|
+
* edits. So are a subfolder, another repository, and a dir that does not exist. shortcut: a Git
|
|
203
|
+
* Bash path (`/c/Users/...`) does not resolve to a drive path here, so it reads as another
|
|
204
|
+
* project — the closed direction.
|
|
205
|
+
*/
|
|
206
|
+
export function projectDir(root, cwd) {
|
|
207
|
+
const key = (p) => (process.platform === 'win32' ? p.toLowerCase() : p);
|
|
208
|
+
let me;
|
|
209
|
+
try { me = key(realpathSync(root)); } catch { return () => false; }
|
|
210
|
+
return (dir) => {
|
|
211
|
+
const bare = /^(["'])(.*)\1$/.exec(dir)?.[2] ?? dir;
|
|
212
|
+
if (!bare) return false;
|
|
213
|
+
try { return key(realpathSync(path.resolve(cwd, bare))) === me; } catch { return false; }
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
152
217
|
/**
|
|
153
218
|
* True when `command` proves the check group `g`: one of its forms runs unpiped and unmasked
|
|
154
219
|
* (`runsUnpiped`), and — when the group names `refuse`, the flags that skip the tests
|
|
155
220
|
* (`mvn install -DskipTests`, `gradle build -x test`, `cargo test --no-run`) — some unpiped
|
|
156
|
-
* segment opening with a form carries none of them.
|
|
157
|
-
*
|
|
221
|
+
* segment opening with a form carries none of them. Both sides go through `normalizeRun` first;
|
|
222
|
+
* without `sameProject` no `--prefix`/`-C` dir counts, so only the concurrency flag goes.
|
|
223
|
+
* shortcut: segments split on `&&`, `||`, `;` and newlines without reading quotes; a quoted
|
|
224
|
+
* separator only makes a refusal more likely.
|
|
158
225
|
*/
|
|
159
|
-
export function groupPasses(command, g) {
|
|
160
|
-
|
|
226
|
+
export function groupPasses(command, g, sameProject = () => false) {
|
|
227
|
+
const run = normalizeRun(command, sameProject);
|
|
228
|
+
const forms = g.forms.map((f) => normalizeRun(f, sameProject));
|
|
229
|
+
if (!forms.some((f) => runsUnpiped(run, f))) return false;
|
|
161
230
|
if (!g.refuse) return true;
|
|
162
|
-
return
|
|
231
|
+
return run.split(/&&|\|\||;|\n/).map((s) => s.trim())
|
|
163
232
|
.some((s) => !s.includes('|') && !g.refuse.test(s)
|
|
164
|
-
&&
|
|
233
|
+
&& forms.some((f) => s === f || s.startsWith(`${f} `)));
|
|
165
234
|
}
|
|
166
235
|
|
|
167
236
|
const NOTE_OPEN = '<task-notification>';
|
|
@@ -222,8 +291,11 @@ const BACKGROUNDED = /^(?:Command running in background with ID: |Command was mo
|
|
|
222
291
|
const resultText = (b) => (typeof b.content === 'string' ? b.content
|
|
223
292
|
: Array.isArray(b.content) && b.content[0] && typeof b.content[0].text === 'string' ? b.content[0].text : '');
|
|
224
293
|
|
|
225
|
-
/**
|
|
226
|
-
|
|
294
|
+
/**
|
|
295
|
+
* A user line that opens a turn: the user typed it, it is not a tool result, a meta note or a task notification.
|
|
296
|
+
* Exported for ./agent-runs.mjs, which counts the same turn the gate judges.
|
|
297
|
+
*/
|
|
298
|
+
export function isPrompt(obj, sidechain = false) {
|
|
227
299
|
if (obj.type !== 'user' || obj.isMeta || (obj.isSidechain && !sidechain)) return false;
|
|
228
300
|
if (notificationText(obj)) return false;
|
|
229
301
|
const c = obj.message && obj.message.content;
|
|
@@ -367,13 +439,14 @@ function missingChecks({ calls, results, background, finished }, checks, root, c
|
|
|
367
439
|
calls.forEach((c, i) => { if (editTarget(c, results, root, cwd)) lastEdit = i; });
|
|
368
440
|
if (lastEdit === -1) return [];
|
|
369
441
|
const passed = new Set();
|
|
442
|
+
const same = projectDir(root, cwd);
|
|
370
443
|
calls.slice(lastEdit + 1).forEach((c) => {
|
|
371
444
|
const command = SHELL_TOOLS.has(c.name) && c.input && c.input.command;
|
|
372
445
|
// A call with no result yet (the host has not flushed it) is not a pass.
|
|
373
446
|
if (typeof command !== 'string' || results.get(c.id) !== false) return;
|
|
374
447
|
// A background launch's result only says it started: its notification is the verdict.
|
|
375
448
|
if (background.has(c.id) && finished.get(c.id) !== true) return;
|
|
376
|
-
for (const g of groups) if (groupPasses(command, g)) passed.add(g.label);
|
|
449
|
+
for (const g of groups) if (groupPasses(command, g, same)) passed.add(g.label);
|
|
377
450
|
});
|
|
378
451
|
return groups.map((g) => g.label).filter((l) => !passed.has(l));
|
|
379
452
|
}
|
|
@@ -438,15 +511,16 @@ export const turnCeilingReached = (state, opening) =>
|
|
|
438
511
|
* the last background run of one of its forms, launched with no completion seen, or completed with
|
|
439
512
|
* anything but exit 0. A check never run in the background has no entry.
|
|
440
513
|
*/
|
|
441
|
-
function backgroundOwed({ calls, results, background, finished }, checks, owedLabels, lastEdit) {
|
|
514
|
+
function backgroundOwed({ calls, results, background, finished }, checks, owedLabels, lastEdit, root, cwd) {
|
|
442
515
|
const states = new Map();
|
|
516
|
+
const same = projectDir(root, cwd);
|
|
443
517
|
let after = lastEdit === null;
|
|
444
518
|
for (const c of calls) {
|
|
445
519
|
if (!after) { after = c.id === lastEdit; continue; }
|
|
446
520
|
const command = SHELL_TOOLS.has(c.name) && c.input && c.input.command;
|
|
447
521
|
if (typeof command !== 'string' || results.get(c.id) !== false || !background.has(c.id)) continue;
|
|
448
522
|
for (const g of checks) {
|
|
449
|
-
if (!owedLabels.has(g.label) || !groupPasses(command, g)) continue;
|
|
523
|
+
if (!owedLabels.has(g.label) || !groupPasses(command, g, same)) continue;
|
|
450
524
|
states.set(g.label, finished.has(c.id) ? (finished.get(c.id) ? 'passed' : 'failed') : 'pending');
|
|
451
525
|
}
|
|
452
526
|
}
|
|
@@ -457,9 +531,10 @@ function backgroundOwed({ calls, results, background, finished }, checks, owedLa
|
|
|
457
531
|
/**
|
|
458
532
|
* The cap's state file, one per session (and sub-agent), under the install's notebook — the
|
|
459
533
|
* store-watch baseline pattern (`./store-watch.mjs`). Read and written only on a Stop with owed
|
|
460
|
-
* checks, so an allowed Stop costs nothing here. Unreadable reads as none.
|
|
534
|
+
* checks, so an allowed Stop costs nothing here. Unreadable reads as none. Exported for
|
|
535
|
+
* ./agent-runs.mjs, which reads a finished sub-agent's block count back from it.
|
|
461
536
|
*/
|
|
462
|
-
function capFile(install, meta) {
|
|
537
|
+
export function capFile(install, meta) {
|
|
463
538
|
const key = [meta.session_id, meta.hook_event_name === 'SubagentStop' ? meta.agent_id : null]
|
|
464
539
|
.filter((k) => typeof k === 'string' && k).join('~');
|
|
465
540
|
return key ? path.join(install, CAP_DIR, `${key.replace(/[^\w.~-]/g, '_').slice(0, 160)}.json`) : null;
|
|
@@ -571,7 +646,7 @@ export function doneGate(meta, args, install, read = tailReader()) {
|
|
|
571
646
|
const active = meta.stop_hook_active === true;
|
|
572
647
|
const capPath = install ? capFile(install, meta) : null;
|
|
573
648
|
// The owed checks whose proof is a background run still pending, or one that reported a failure.
|
|
574
|
-
const bg = owed.flatMap((r) => [...backgroundOwed(turn, r.checks, new Set(r.missing), lastEditId(turn, [r.root], at))]
|
|
649
|
+
const bg = owed.flatMap((r) => [...backgroundOwed(turn, r.checks, new Set(r.missing), lastEditId(turn, [r.root], at), r.root, at)]
|
|
575
650
|
.map(([l, st]) => [`${tag(r)}${l}`, st]));
|
|
576
651
|
const verdict = bg.map(([l, st]) => `${l}=${st}`).sort().join('\n');
|
|
577
652
|
// Without an install or a session id there is nowhere to count: one block per turn, as before.
|