geneseed 5.4.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +30 -0
  3. package/SHIPPED.md +1 -1
  4. package/adapters/bob/README.md +12 -1
  5. package/adapters/opencode/README.md +2 -1
  6. package/adapters/opencode/plugins/geneseed-context.js +71 -10
  7. package/adapters/opencode/plugins/geneseed-guard.js +101 -19
  8. package/adapters/opencode/plugins/geneseed-learn.js +641 -6
  9. package/bin/geneseed-cli.mjs +3 -0
  10. package/bin/geneseed-hook.mjs +2 -1
  11. package/docs/concepts/agents.md +13 -1
  12. package/docs/concepts/enforcement-table.md +1 -1
  13. package/docs/concepts/foreman-mode.md +22 -3
  14. package/docs/concepts/hook-gates.md +1 -1
  15. package/docs/concepts/hooks.md +22 -5
  16. package/docs/concepts/host-matrix.md +2 -2
  17. package/docs/concepts/hosts.md +1 -1
  18. package/docs/concepts/shared-tier.md +1 -1
  19. package/docs/concepts/skills.md +21 -1
  20. package/docs/concepts/themes.md +1 -1
  21. package/docs/extending.md +10 -1
  22. package/docs/guides/install-clone.md +18 -0
  23. package/docs/guides/install-scripted.md +8 -2
  24. package/docs/guides/install.md +19 -1
  25. package/docs/guides/upgrade.md +1 -1
  26. package/docs/reference/env-context.md +1 -1
  27. package/docs/reference/environment.md +1 -1
  28. package/docs/reference/plugin-learn.md +4 -0
  29. package/docs/reference/profiles.md +142 -0
  30. package/docs/token-footprint.md +9 -4
  31. package/docs/understand/design-choices-engineering.md +1 -1
  32. package/docs/web-ui.md +3 -1
  33. package/harness.config.json +1 -1
  34. package/js/README.md +9 -2
  35. package/js/build/args.mjs +4 -3
  36. package/js/build/catalog.mjs +11 -1
  37. package/js/build/driver.mjs +42 -11
  38. package/js/build/emit-claude.mjs +24 -1
  39. package/js/build/emit-opencode.mjs +3 -0
  40. package/js/build/export.mjs +1 -1
  41. package/js/build/generate.mjs +2 -1
  42. package/js/build/notes-migrate.mjs +99 -0
  43. package/js/build/profile.mjs +14 -6
  44. package/js/build/render.mjs +34 -10
  45. package/js/build/source.mjs +85 -2
  46. package/js/cli-table.json +164 -4
  47. package/js/hosts/agent-runs.mjs +205 -0
  48. package/js/hosts/done-checks.mjs +3 -1
  49. package/js/hosts/hooks-done.mjs +91 -16
  50. package/js/hosts/hooks-learn.mjs +85 -0
  51. package/js/hosts/hooks-prims.mjs +39 -1
  52. package/js/hosts/hooks.mjs +6 -3
  53. package/js/hosts/hosts.mjs +10 -0
  54. package/js/hosts/installs.mjs +25 -1
  55. package/js/hosts/link.mjs +45 -10
  56. package/js/hosts/native.mjs +42 -5
  57. package/js/hosts/opencode.mjs +1 -1
  58. package/js/hosts/settings.mjs +72 -0
  59. package/js/hosts/spec-feedback.mjs +538 -0
  60. package/js/hosts/usage.mjs +67 -8
  61. package/js/inspect/agent-scores.mjs +118 -0
  62. package/js/inspect/checks-authoring.mjs +2 -1
  63. package/js/inspect/checks-build.mjs +20 -4
  64. package/js/inspect/checks-repo.mjs +27 -2
  65. package/js/inspect/cost.mjs +6 -5
  66. package/js/inspect/diff.mjs +25 -5
  67. package/js/inspect/doctor.mjs +4 -0
  68. package/js/inspect/status.mjs +3 -1
  69. package/js/inspect/validate.mjs +1 -0
  70. package/js/lib/machine-dir.mjs +8 -0
  71. package/js/lib/paths.mjs +4 -1
  72. package/js/maintain/profile-scope.mjs +145 -0
  73. package/js/maintain/profiles.mjs +486 -0
  74. package/js/maintain/setup.mjs +409 -15
  75. package/js/maintain/uninstall.mjs +4 -1
  76. package/js/maintain/update.mjs +1 -1
  77. package/js/web/actions.mjs +28 -38
  78. package/js/web/api.mjs +7 -2
  79. package/js/web/handler.mjs +8 -0
  80. package/js/web/jobs.mjs +5 -4
  81. package/js/web/profiles-api.mjs +201 -0
  82. package/js/web/routes.mjs +5 -0
  83. package/package.json +2 -1
  84. package/profiles/guillaume-claude-global.json +16 -0
  85. package/profiles/starter.json +14 -0
  86. package/src/AGENT.md.tmpl +1 -1
  87. package/src/agents/_self-improvement.md +15 -7
  88. package/src/agents/_template.md +4 -2
  89. package/src/agents/advocate.md +1 -1
  90. package/src/agents/architect.md +1 -1
  91. package/src/agents/developer.md +10 -3
  92. package/src/agents/devops-engineer.md +1 -1
  93. package/src/agents/docker-expert.md +1 -1
  94. package/src/agents/docs.md +1 -1
  95. package/src/agents/empiricist.md +1 -1
  96. package/src/agents/explorer.md +4 -2
  97. package/src/agents/framer.md +1 -1
  98. package/src/agents/historian.md +1 -1
  99. package/src/agents/kubernetes-specialist.md +1 -1
  100. package/src/agents/memory-curator.md +1 -1
  101. package/src/agents/operator.md +1 -1
  102. package/src/agents/performance.md +1 -1
  103. package/src/agents/pragmatist.md +1 -1
  104. package/src/agents/react-engineer.md +1 -1
  105. package/src/agents/react-reviewer.md +1 -1
  106. package/src/agents/researcher.md +1 -1
  107. package/src/agents/reviewer.md +10 -3
  108. package/src/agents/security.md +1 -1
  109. package/src/agents/skeptic.md +1 -1
  110. package/src/agents/spring-boot-engineer.md +1 -1
  111. package/src/agents/spring-reviewer.md +1 -1
  112. package/src/agents/spring-security.md +1 -1
  113. package/src/agents/steward.md +1 -1
  114. package/src/agents/tester.md +4 -2
  115. package/src/agents/user-advocate.md +1 -1
  116. package/src/agents/visionary.md +1 -1
  117. package/src/memory/README.md +12 -2
  118. package/src/modes/foreman.md +23 -10
  119. package/src/skill-descriptions.json +63 -0
  120. package/src/skills/_self-improvement.md +42 -26
  121. package/src/skills/_template.md +3 -1
  122. package/src/skills/brainstorm.md +35 -22
  123. package/src/skills/daydream/VENDOR.md +6 -0
  124. package/src/skills/diagram-design/VENDOR.md +4 -0
  125. package/src/skills/explain-changes/VENDOR.md +5 -1
  126. package/src/skills/parallel-agents.md +11 -0
  127. package/src/skills/pipeline.md +3 -3
  128. package/src/skills/plan.md +5 -4
  129. package/src/skills/react-view-transitions/VENDOR.md +7 -1
  130. package/src/skills/release.md +7 -2
  131. package/src/skills/rule/approve.md +2 -1
  132. package/src/skills/skill-forge.md +5 -3
  133. package/src/skills/token-report/VENDOR.md +5 -1
  134. package/src/upstreams.json +2 -2
  135. package/themes/README.md +3 -1
  136. package/web/dist/assets/{ActiveLoops-BJJN3P-V.js → ActiveLoops-DOJCPPPc.js} +1 -1
  137. package/web/dist/assets/{Activity-D2kOc3yi.js → Activity-LKsDzsnK.js} +1 -1
  138. package/web/dist/assets/{ActivityDetail-By3xOr21.js → ActivityDetail-DhwTfPm6.js} +1 -1
  139. package/web/dist/assets/{Bonsai-CBWDTBA4.js → Bonsai-CePMLrpr.js} +1 -1
  140. package/web/dist/assets/{CopyButton-BVbpriMB.js → CopyButton-CuoaJ6k7.js} +1 -1
  141. package/web/dist/assets/{Dashboard-CIJLPHM9.js → Dashboard-D1VKuvLe.js} +2 -2
  142. package/web/dist/assets/{Docs-CiRRIELs.js → Docs-CUrHJKaU.js} +1 -1
  143. package/web/dist/assets/{Factories-DhyK0O8d.js → Factories-Ci1XfmSy.js} +1 -1
  144. package/web/dist/assets/{GreenhouseView-DW3PgTPy.js → GreenhouseView-CNfH2lPK.js} +1 -1
  145. package/web/dist/assets/Installs-ZHQZM1iS.js +3 -0
  146. package/web/dist/assets/{JournalView-O65qEWfp.js → JournalView-CMsWahkS.js} +1 -1
  147. package/web/dist/assets/{Kits-C5U-yT6Z.js → Kits-CkliyK0n.js} +1 -1
  148. package/web/dist/assets/{Laws-CuTw_XNf.js → Laws-hh4O3HZ4.js} +1 -1
  149. package/web/dist/assets/{LibRows-D6-CVa3K.js → LibRows-Brv0Hmkr.js} +1 -1
  150. package/web/dist/assets/{Library-CzPlerd6.js → Library-BYmiLjJr.js} +1 -1
  151. package/web/dist/assets/{Loops-CqNF_-nS.js → Loops-ytm-xJ68.js} +1 -1
  152. package/web/dist/assets/{OperatorHudView-BNr8K5qj.js → OperatorHudView-KaqCx_HP.js} +1 -1
  153. package/web/dist/assets/{Personal-DeDb9e8O.js → Personal-CmcnRKYE.js} +1 -1
  154. package/web/dist/assets/{Settings-B8MPN_AD.js → Settings-tUrpdOfq.js} +1 -1
  155. package/web/dist/assets/{Tabs-DJzAez4h.js → Tabs-CD7etcGD.js} +1 -1
  156. package/web/dist/assets/api-CZ-x0iWG.js +1 -0
  157. package/web/dist/assets/{controls-D4wmg_pl.js → controls-CK7qHA8H.js} +1 -1
  158. package/web/dist/assets/{index-CRWqKxfY.css → index-Ba_Kg3Af.css} +1 -1
  159. package/web/dist/assets/{index-BL3P-9Rg.js → index-COKbhFNo.js} +3 -3
  160. package/web/dist/index.html +3 -3
  161. package/web/dist/assets/Installs-B6nlo-Ly.js +0 -3
  162. package/web/dist/assets/api-DLDVY3K-.js +0 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,40 @@ label. For the capability ↔ spec map, see [SHIPPED.md](SHIPPED.md).
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [5.5.0] — 2026-11-15
12
+
13
+ **Upgrade note.** The new behaviour reaches an install only when it is emitted again: `geneseed upgrade` (or `rebuild-all`) does it for every active install. An existing install reads as `--context-window 200k`, so on a machine whose model has a 1M-token window, rebuild it once with `--context-window 1m` or apply a profile that says `1m`. Project notes written by earlier versions move to `<project>/notebook/` on that rebuild, with no loss.
14
+
15
+ ### Added
16
+ - **Feedback notes have a machine and a project scope.** A `spec-feedback:` line now picks where it goes by its tag, not by the install kind: `[agent]`, `[general]`, `[skill:<id>]` and `[skill:<id>:general]` go to the machine notes in the shared tier (`~/.config/geneseed/notes/`), for every host and install kind, because a defect of a spec is true in every repo; `[agent:project]`, `[general:project]`, `[skill:<id>:project]` and `[skill:<id>:general:project]` go to `<project>/notebook/{agent,skill}-notes/`, one folder for every host, for a fact true only in that repo. Step 0 of every agent and skill reads the machine notes, then the project notes, which win where they disagree. The project folders are kept out of git through a marked block in the clone's `.git/info/exclude`; no `.gitignore` is written into the project. On the next project emit, notes written by earlier versions in a host's own notebook (`.claude`, `.bob`, `.openclaude`, `.opencode`) merge into the project notebook as project notes, read back before the originals move to an archive beside them. An OpenClaude project install now reads its notes where it writes them.
17
+ - **Install profiles: a one-line install with no questions.** `.\install.cmd --profile starter` (Windows) or `./install --profile starter` (macOS, Linux) from a fresh clone installs the `starter` profile globally into every AI coding tool found on the machine, puts `geneseed` on `PATH`, sets the web console to start at login, starts it (or restarts it when it runs), runs the doctor and prints an ASCII summary with the console address. It needs no terminal. A failure on one tool does not stop the others; the run then exits 1. A second run is an update and a repair: it puts each setting back to the profile's value and names every setting it put back. On macOS and Linux it writes the PATH block into the shell's startup file without asking and names the file. Without `--profile`, `setup` and both install scripts are unchanged. See `docs/reference/profiles.md`.
18
+ - **`profiles/<name>.json`**, shipped in the package and the clone, checked against the generator's own value lists (an unknown key is an error) and by `geneseed doctor`. Two ship: `starter` (neutral, peer, direct, all packs, every gate armed except the ownership gate, all four tools) and `guillaume-claude-global` (the author's Claude Code setup: imperial, expert, foreman, six rules excluded, the deletion, ownership and external gates off).
19
+ - **The agent outcome ledger: did a spec change help?** When a named subagent finishes, the SubagentStop hook appends one line to `notebook/agent-runs.jsonl` in the install: the day, the agent, a 12-hex hash of its rendered spec (none for an agent Geneseed does not ship), whether the done gate let the turn end and how often it blocked it first, the tool calls and refused calls of that turn, the `spec-feedback:` lines and whether a report came back. Only facts the hook reads, no self-score and no model call; a stop the gate blocks writes no line. `geneseed catalog agents --scores` prints one row per agent and spec hash (runs, judged runs never blocked as `n/judged`, mean refused and mean tools with their run counts, shown from 3 runs, feedback lines, reports, first and last day), so the runs before and after a spec edit compare. A refused call is read off the first line of a tool result only, so a red test that quotes a gate's words is not one. The OpenCode learn plugin writes the same line for a named child session, without the done-gate fields, and with empty tool counts when it sees no tool part it knows (the OpenCode 2 shape is unverified). Off with `GENESEED_NO_USAGE` or `.usage-off`, as `usage.jsonl` is. Bob has no subagent-finished event, so it writes nothing.
20
+ - **`geneseed profile save <name> --from <host>-global`** writes a profile from an existing global install, every setting as it is, gates off included, and prints how it differs from `starter`, gates first. It refuses an existing file without `--force` and reads no personal file (user rules, profile, memory, wiki, notebook).
21
+ - **Personal install profiles.** Profiles come from two sources: Shipped (`profiles/` in the checkout, added by pull request) and Personal (`~/.config/geneseed/profiles/`, beside memory and rules; an update never touches it). `geneseed profile save` writes a Personal profile by default; `--shipped` writes the checkout's `profiles/`, and only a git clone takes it. A Personal profile may not reuse a Shipped name: `save` refuses it, `--force` included, and `geneseed doctor` names a clash made by hand (the Shipped profile is the one that loads). `profile save` also reads a project install: `--from <host> --project <dir>`.
22
+ - **`geneseed profile apply <name> [--project <dir>] [--hosts a,b]`** applies a profile globally, or to one project folder (`--emit <host> --out <dir> --root <dir>` per tool). A profile has no scope of its own. It builds only the tools the profile lists that this machine has (`--hosts` narrows them), touches no other install, and does none of the onboarding of `setup --profile` (no `PATH`, login item, console or doctor). Like `setup --profile`, a failure on one tool does not stop the others, and the summary lists every setting a build put back. In project scope, a tool whose global install is active gets one more line: both root files load, and it names the global gates that still run in the project.
23
+ - **A profile may carry `sharedTier`.** A project apply passes it (`--shared-tier on`); a global apply ignores it.
24
+ - **Skills keep their own feedback, with no model call.** When a skill hindered the work, the reply ends with `spec-feedback: [skill:<id>] <fix> [— situation: …] — seen: …` (`[skill:<id>:general]` goes to `skill-notes/_general.md`); each skill's real id is rendered into its text. The Stop hook copies the line into `skill-notes/<id>.md`, which the skill reads at step 0, before the done gate's verdict, so a blocked turn keeps it; the sub-agent capture gets the same fix. Not captured: a skill the install does not ship, a malformed skill tag, a line inside inline code or a fence, an excluded folder. The OpenCode learn plugin does the same at turn end (V1 reads one message per turn). Bob's Stop carries no reply, so there the skill text has the model append the line itself. The hook marks its own bullets `(<writer>, date)` and the caps drop only those: a hand-written line is never dropped. In 30 days, 20 of 73 skill runs hit friction and no skill note was ever written. Run `geneseed rebuild-all`: an install captures nothing until it is re-emitted.
25
+ - **`--context-window 200k|1m` sets Claude Code's skill-listing budget** (default `200k`). Claude Code lists skills under about 6 000 characters on a 200k-context model and 30 000 on 1M, and drops the descriptions of low-usage skills first, so a fresh install on a 200k model showed none of Geneseed's. The Claude Code emits write `skillListingMaxDescChars` 80 and `skillListingBudgetFraction` 0.013 (`200k`) or `skillListingMaxDescChars` 120 (`1m`) into the settings file Geneseed already merges, values set by a simulation of the listing. A value set by hand is never touched; uninstall removes only what Geneseed wrote; a project never undercuts a key the user-level settings set, and a new project takes the machine's window. In profiles (`contextWindow`: `starter` 200k, `guillaume-claude-global` 1m) and the web console. OpenCode and Bob do not cap the list: the setting writes nothing there. **Upgrade:** an existing install reads as `200k`, so its next rebuild writes 80 and 0.013 and prints one line; on a 1M-token model, rebuild once with `--context-window 1m` or apply a profile that says `1m`.
26
+ - **Installs › Profiles in the web console.** One card per profile of both sources (tools, settings, the gates it turns off, the installs that follow it), an Apply panel (Global or One project, a tool checklist, what each build would put back, the global install that keeps running beside a project), and a Save panel (an active install as a Personal or Shipped profile, with its difference from `starter`). The Selected install panel names the profiles its install follows and has a **Save as profile…** button. Both writes are background jobs that run the CLI command.
27
+
28
+ ### Changed
29
+ - **One theme-neutral catalogue line of at most 80 characters per skill.** `src/skill-descriptions.json` holds one line per skill, purpose and trigger, trigger first; it is the model-visible description on every host and in the export, and the themed purpose stays in the body (this reverses the 2026-11-11 decision for the frontmatter line only). A vendored skill keeps its upstream description as the first body line. The default install's skill listing drops from 8 836 to 3 971 characters, so it fits a 200k model's budget; the routing probe went from 35 to 38 of 43 cases, with no negative case lost. A doctor check and an emit check fail on a line over 80. The `grill-me` alias of brainstorm is retired (a user's own grill-me skill is left alone; an old `Excluded skills: grill-me` still resolves).
30
+ - **Release, brainstorm, plan and rule take what their runs showed.** **release:** fires only when the user asks to cut or publish a release; lands its PR with `gh pr merge --squash --auto`, never `--admin` or a direct push; waits with `gh run watch --exit-status`, never sleep-then-poll. **brainstorm:** a "go" on the decision ledger approves the ledger, not the build; in a worktree the spec is committed on the worktree's branch. **plan:** the plan goes beside its spec in the project's spec or plan home when one exists, else the notebook. **rule:** approval names the items or says approve; a remark is not approval. Text only; reaches an install on its next emit.
31
+ - **The brief checklist names the worker's model tier, the done gate and where the report goes.** The parent picks each worker's tier per task and names it in the brief: the strongest is its own current model (no override), and it steps down, never up — intermediate for scoped writing, light for read-only search and digests, its own for judgement and a retry; on a host whose model names are unknown (OpenCode), inherit. A project's done-gate checks run unpiped and a background suite is waited on; paths outside a worktree may be refused; a stand-down across a global and a project install holds only for records every copy sees alike, never a verdict; the worker writes its full report to a file and replies with the path. Text only; reaches an install on its next emit.
32
+ - **Foreman mode falls back to direct work when the session holds no dispatch tool.** With no tool that can start a writing (developer) worker (`Agent` on Claude Code and OpenClaude, `subagent`/`task` on OpenCode, `spawn_subagent` on Bob), the session does each task itself, one at a time, in one tree, and says so once; the pipeline skill makes such a session its own crew lead. The check is on the tool, not the host: Bob IDE and Bob Shell read the same `~/.bob` install, Bob IDE gives `spawn_subagent` only to modes whose groups hold `subagent`, and its `ask` mode may start only `explore`. Bob's `start_subtask` does not count, as it appears to make the parent wait (inferred from the bundle, not observed live). The Bob facts are corrected, the host matrix included: a Bob subagent cannot spawn another (Bob IDE 2.2.3), so a Bob worker has no sub-workers and a Bob crew lead plays the roles in turn; Bob Shell has no subagents at all (reported by Bob Shell itself, not read in code). Text only; reaches an install on its next emit.
33
+ - **Foreman mode names how each host resumes a worker, and lets a settled worker take a related task.** A follow-up goes back to its worker by `SendMessage` on Claude Code (on OpenClaude only in its agent-teams mode) and by the `subagent` tool with the worker's `sessionID` on OpenCode (V1: `task` with `task_id`); Bob has no resume. A new task still gets a new worker by default, but it may go to an idle worker whose own task is merged or dropped when it works in the same files or context and that worker's context is still light; the worker starts it on a new branch from the current BASE, under a new ledger line, and never holds two live tasks. The pipeline skill names the same per-host resume for a crew lead. Text only; reaches an install on its next emit.
34
+ - **The four most-used agent specs take what their own feedback reported.** A digest of the 47 real `spec-feedback:` lines of 2026-10 and 11, attributed per agent from the transcripts, gave these edits. **developer:** it may install dependencies only when the brief allows it. In a worktree it runs one plain command per call (`git -C`, no `cd … &&`, no heredocs) and keeps a `\u` escape an escape. As a Foreman worker it hands back a full run with its count line, and calls a failure pre-existing only after reproducing it on a clean BASE. **reviewer:** a diff with nothing to run is traced against its readers by hand. A new entry in a family (theme, host, world) is checked against every per-entry test list. The ref is authoritative over a diff file. **explorer:** it skips its reads on a context-only brief and names the commit it read. **tester:** it re-runs a failure seen only in a concurrent run alone before diagnosing it. **Every agent:** a refused step-0 read is skipped and named in the report, never a stop. Text only; reaches an install on its next emit.
35
+ - **One brief checklist for dispatched workers.** Step 3 of the parallel-agents skill now carries a **Brief checklist** with six items: the git ref and diff state, the whole write set (other call sites, twin copies), a scratch path and a load cap per worker, long suites in the background, whether a dependency install is allowed, and the host's shell limits. The Foreman mode and the pipeline skill point to it instead of restating it. The 5.4.0 rule against opening a worker command with `cd` into the worktree moved into that checklist. Text only; reaches an install on its next emit.
36
+ - **The brainstorm skill takes the lessons of Superpowers 7.0.2.** It reads what the user pointed at before the first question and never asks what that answers; a request clear from the start is restated with any constraint or cheaper path found, and confirmed; for a project, the 2–3 approaches go in a message of their own, picked before any design is written, and the spec records them; where the spec goes is the agent's call; and a brainstorm that started on its own offers to just start, stating any platform, language or tool chosen when the user takes it. The `superpowers` pin moves to v7.0.2. Its subagent-driven-development changes mostly moved text into reference files; the rest (running its scripts from the working tree) is already in the Brief checklist, so parallel-agents and pipeline are unchanged. Text only; reaches an install on its next emit.
37
+
38
+ ### Fixed
39
+ - **The usage ledger counts a typed `/skill`, and each call once.** A skill typed as `/name` made no Skill tool call and was never counted; the UserPromptSubmit hook (Claude Code, OpenClaude, Bob) now records it with `via: "slash"` when the skill is installed, and OpenCode 1 on `command.execute.before` (OpenCode 2 has no command hook). A global install beside a live project install counted every call twice; the global copy now stands down when the project copy can count, and on OpenCode exactly one copy counts, the nearest live project's. An excluded folder stays out, counting included. Name and day only.
40
+ - **On an OpenCode project install, the gate log, agent runs and notes reach the console and the agents.** The plugins wrote `usage.jsonl`, `gates.jsonl`, `agent-runs.jsonl` and the spec-feedback notes under `<repo>/.opencode/notebook`, a folder no emit creates; they now use `<repo>/notebook`, as the emit and the console do. Each guard copy records its own refusals, since a global and a project copy judge a call from their own config. Re-emit OpenCode project installs.
41
+ - **The routing probe tells an outage from a miss.** `tests/skill_triggers.mjs` scored a run that ended on an API error (a usage limit, for one) as "the skill did not fire", failing every positive and passing every negative; such a run is now left out, and a case with too few valid runs is inconclusive (exit 1). A max-turns stop is still a miss. Cases added for release, pipeline, parallel-agents, refactor, deck and workflow.
42
+ - **The done gate accepts a check run from a worktree or at another concurrency.** Workers in worktrees ran `npm --prefix <worktree> run lint` and the suite without `--test-concurrency=8`, as their brief asks, all green, and the gate still blocked their SubagentStop 5 to 7 times each, because those commands do not start with the listed line. Before the prefix match, the gate now removes from both the line and the command `--prefix <dir>` on `npm` and `-C <dir>` right after `git`, only when `<dir>` is the judged project's own root (the worktree whose files were edited, by real path), and `--test-concurrency N` on `node --test`. Nothing else changes: another project's dir, a sibling worktree or the main checkout, a changed glob or reporter, a pipe or a masked exit code still read as not run. The gate does not follow `cd`: it reads the command line only. The OpenCode reminder does the same.
43
+ - **The agents' self-improvement loop keeps what they report.** The `spec-feedback:` lines a subagent ends its report with were meant to be written down by the caller, which never happened, and the agents read another file anyway. Now the SubagentStop hook copies each line, with no model call and whether or not `GENESEED_LLM` is set, into `agent-notes/<name>.md` (the tier's `notes/` on a global install, else the install's `notebook/`), a `general` line into `agent-notes/_general.md` instead: one dated bullet each, appended under a file lock, no duplicates, quoted and fenced lines skipped, capped at 100 bullets an agent file, 30 in `_general.md` and 8 000 characters a file (only the hook's own bullets ever drop). Every agent's step 0 now reads those notes beside `memory/agents/<name>.md`. The OpenCode learn plugin does the same for a named child session (V1 and V2). Bob has no subagent-finished event; there the caller still copies the line. Run `geneseed rebuild-all` to get the new agent text.
44
+
11
45
  ## [5.4.0] — 2026-11-13
12
46
 
13
47
  **Upgrade note.** *Consent Before Push* changes meaning: run `geneseed rebuild-all` after the
package/README.md CHANGED
@@ -27,6 +27,18 @@
27
27
 
28
28
  **Geneseed compiles your agent's rules instead of asking you to write them.** One source in `src/` renders into a ready-made harness for OpenCode, Claude Code, Bob, OpenClaude, or any `AGENT.md` tool: a constitution of laws and doctrines, a roster of capability agents, native skills, a memory convention — and, wherever the host has a hook surface, gates that *enforce* the laws at the tool boundary instead of hoping the model remembers them.
29
29
 
30
+ **New here? One line, no questions** — it clones Geneseed and installs the [`starter` profile](#-new-to-ai-agents-one-line-no-questions). You need git and Node ≥ 22.7.
31
+
32
+ ```bat
33
+ git clone https://github.com/Arylmera/Geneseed.git && cd Geneseed && .\install.cmd --profile starter
34
+ ```
35
+
36
+ ```bash
37
+ git clone https://github.com/Arylmera/Geneseed.git && cd Geneseed && ./install --profile starter
38
+ ```
39
+
40
+ The first line is for Windows (cmd or PowerShell 7), the second for macOS and Linux. Windows PowerShell 5.1 has no `&&`: there, put `;` in its place. Want to choose the theme, the host and the rest yourself? Run the wizard instead:
41
+
30
42
  ```bash
31
43
  npx geneseed setup
32
44
  ```
@@ -74,6 +86,24 @@ geneseed-build --theme imperial # Warhammer 40k voice, identical structure
74
86
 
75
87
  ## 🚀 2 · Setup
76
88
 
89
+ ### 🧭 New to AI agents? One line, no questions
90
+
91
+ Clone Geneseed where you like, then run one command at the root of the clone. It installs the **`starter`** profile into every AI coding tool it finds (OpenCode, IBM Bob, Claude Code, OpenClaude), puts `geneseed` on your `PATH`, sets the web console to start at login, starts it, runs the health check and prints the console's address. It asks nothing.
92
+
93
+ Windows (cmd or PowerShell 7; on Windows PowerShell 5.1, put `;` in place of each `&&`):
94
+
95
+ ```bat
96
+ git clone https://github.com/Arylmera/Geneseed.git && cd Geneseed && .\install.cmd --profile starter
97
+ ```
98
+
99
+ macOS, Linux:
100
+
101
+ ```bash
102
+ git clone https://github.com/Arylmera/Geneseed.git && cd Geneseed && ./install --profile starter
103
+ ```
104
+
105
+ `starter` is a neutral voice, a candid peer posture, the agent working each task itself, and every guardrail armed except the ownership gate. Run the same line again to update and repair. `geneseed profile save <name> --from claude-global` writes your own install as a Personal profile (in `~/.config/geneseed/profiles/`); with `--shipped`, from a clone, it writes [`profiles/`](profiles/) for a pull request, which is how a team adds one. `geneseed profile apply <name>` applies a profile globally, or with `--project <dir>` to one project folder. See [Install profiles](docs/reference/profiles.md).
106
+
77
107
  ### ⚡ The short way — `npx`
78
108
 
79
109
  The harness is published on npm as **[`geneseed`](https://www.npmjs.com/package/geneseed)** — three commands (`geneseed`, `geneseed-hook`, `geneseed-build`), zero dependencies. One command, nothing cloned, nothing else to install. The only prerequisite is **Node ≥ 22.7**.
package/SHIPPED.md CHANGED
@@ -20,7 +20,7 @@ historical references, not files distributed with the repo.
20
20
  > **On version numbers.** [`harness.config.json`](harness.config.json)'s `version` is a
21
21
  > human-readable label only. The canonical identity of an installed harness is the
22
22
  > **source fingerprint** stamped in `.geneseed-version` (see `geneseed version`), not the
23
- > string. Current label: **5.4.0**.
23
+ > string. Current label: **5.5.0**.
24
24
 
25
25
  ## Capabilities
26
26
 
@@ -125,6 +125,12 @@ id), `cwd` (the root workspace, with a lower-case drive letter on Windows), and
125
125
  parent's hooks with the parent's `session_id` and no sub-agent id. Activity therefore shows
126
126
  such a sub-agent as a branch with no id, which the next `Stop` closes, and marks the session
127
127
  `attribution: false`: its files cannot be told from the parent's.
128
+ - `spawn_subagent` is registered only when `session.subagents` is on (the default), and only
129
+ for a mode whose groups hold `subagent`: `agent` and `plan` get every subagent, `ask` only
130
+ `explore`. A subagent can never spawn another (`SUBAGENT_FORBIDDEN_TOOLS` holds
131
+ `spawn_subagent`, and `start_subtask` too), so the depth is one level. Bob Shell, which reads the same `~/.bob`
132
+ install, reports that it has no subagents at all (reported by Bob Shell itself, not read in
133
+ code). So Foreman mode on Bob runs as direct wherever the tool is absent.
128
134
  - After a compaction, Bob fires `SessionStart` with `source: "compact"`. The writer counts a
129
135
  compaction there; any other Bob `SessionStart` is not recorded, because the first prompt's
130
136
  `UserPromptSubmit` records the session right after it.
@@ -155,7 +161,12 @@ reports one that does not start.
155
161
 
156
162
  **What fires.** `tool-gate` also counts skill and sub-agent calls for the web console's
157
163
  Overview: `spawn_subagent` by its `name`, `start_subtask` by its `mode`. A subtask's `title` is
158
- never recorded: it is free text, and the count keeps no prompt.
164
+ never recorded: it is free text, and the count keeps no prompt. A message typed as `/<skill>`
165
+ is counted on `UserPromptSubmit` when that skill is installed, from the payload's `prompt` field
166
+ as Claude Code sends it; that field is not verified on a live Bob session. Beside a Bob project
167
+ install the global install's count stands down, and it finds the project folder from the payload's
168
+ `cwd`. If that `cwd` follows a `cd` into another repo with a Bob project install that Bob never
169
+ loaded, the call is counted by neither install. This is not verified on a live Bob session either.
159
170
 
160
171
  **Migration.** A re-emit over an older install unwires Geneseed's groups from the flat
161
172
  `~/.bob/settings.json` (your own keys there are kept) and writes the new set to the
@@ -397,7 +397,8 @@ behaviour** — nothing changes the machine's current agent/model unless you opt
397
397
  `.env` writes. `GENESEED_GUARD=off` disables it, `=warn` downgrades
398
398
  blocks to warnings. Every **block** appends one line to the install's
399
399
  `notebook/gates.jsonl` (rule `law-1` / `law-4` / `process-1` / `wiki` / `ownership`, a timestamp,
400
- never the path or command) — the same ledger the Claude-family hooks write, so
400
+ never the path or command; `<repo>/notebook` for a project install) — the same ledger the
401
+ Claude-family hooks write, so
401
402
  `geneseed status` counts what the boundary caught on every host. Warnings are not
402
403
  recorded.
403
404
  - **Invisible context injection** (the default). The context plugin delivers via
@@ -1382,14 +1382,68 @@ function runsUnpiped(command, line) {
1382
1382
  return false;
1383
1383
  }
1384
1384
 
1385
- // The twin of hooks-done.mjs's `groupPasses`: a form runs unpiped, and no flag in `refuse`
1386
- // skips the tests in the segment that ran it. Held equal by tests/plugins/context_done.test.mjs.
1387
- function groupPasses(command, g) {
1388
- if (!g.forms.some((f) => runsUnpiped(command, f))) return false
1385
+ // `normalizeRun` is js/hosts/hooks-done.mjs's, copied by `node tests/twins.mjs --write`.
1386
+ function normalizeRun(command, sameProject) {
1387
+ const cmd = String(command).replace(/[ \t]+/g, ' ');
1388
+ return cmd.split(/(&&|\|\||[|;\n])/).map((seg, k) => {
1389
+ if (k % 2) return seg;
1390
+ const toks = seg.trim().match(/(?:"[^"]*"|'[^']*'|[^ "']|["'])+/g);
1391
+ if (!toks) return seg;
1392
+ const [tool] = toks;
1393
+ const test = tool === 'node' && toks.includes('--test');
1394
+ const out = [tool];
1395
+ let opts = true;
1396
+ for (let i = 1; i < toks.length; i += 1) {
1397
+ const t = toks[i];
1398
+ if (t === '--') opts = false;
1399
+ if (opts && tool === 'npm') {
1400
+ if (t === '--prefix' && i + 1 < toks.length && sameProject(toks[i + 1])) { i += 1; continue; }
1401
+ if (t.startsWith('--prefix=') && sameProject(t.slice(9))) continue;
1402
+ }
1403
+ if (tool === 'git' && out.length === 1 && t === '-C' && i + 1 < toks.length && sameProject(toks[i + 1])) { i += 1; continue; }
1404
+ if (opts && test) {
1405
+ if (/^--test-concurrency=\d+$/.test(t)) continue;
1406
+ if (t === '--test-concurrency' && /^\d+$/.test(toks[i + 1] ?? '')) { i += 1; continue; }
1407
+ }
1408
+ out.push(t);
1409
+ }
1410
+ if (out.length === toks.length) return seg;
1411
+ return `${seg.startsWith(' ') ? ' ' : ''}${out.join(' ')}${seg.endsWith(' ') ? ' ' : ''}`;
1412
+ }).join('');
1413
+ }
1414
+
1415
+ // The twin of hooks-done.mjs's `groupPasses`: both sides normalized (`normalizeRun`), a form
1416
+ // runs unpiped, and no flag in `refuse` skips the tests in the segment that ran it. Held equal
1417
+ // by tests/plugins/context_done.test.mjs.
1418
+ function groupPasses(command, g, sameProject = () => false) {
1419
+ const run = normalizeRun(command, sameProject)
1420
+ const forms = g.forms.map((f) => normalizeRun(f, sameProject))
1421
+ if (!forms.some((f) => runsUnpiped(run, f))) return false
1389
1422
  if (!g.refuse) return true
1390
- return String(command).replace(/[ \t]+/g, " ").split(/&&|\|\||;|\n/).map((s) => s.trim())
1423
+ return run.split(/&&|\|\||;|\n/).map((s) => s.trim())
1391
1424
  .some((s) => !s.includes("|") && !g.refuse.test(s)
1392
- && g.forms.some((f) => s === f || s.startsWith(`${f} `)))
1425
+ && forms.some((f) => s === f || s.startsWith(`${f} `)))
1426
+ }
1427
+
1428
+ // The twin of hooks-done.mjs's `projectDir`, async and over a known list: the `dirs` (as
1429
+ // `normalizeRun` hands them, quotes and all) that are the judged `root` ITSELF, by real path
1430
+ // (case-blind on Windows); a sibling worktree or the main checkout is not. A Set, so the sync
1431
+ // `normalizeRun` can ask it; a Git Bash `/c/...` path is not one. ONE DIFFERENCE FROM THE HOOK, in
1432
+ // the closed direction: a relative dir resolves against the git root here (the transform sees no
1433
+ // session cwd), against the session's cwd there, so `--prefix .` from a subfolder counts only in
1434
+ // the hook. The caller's probe answers true, so every dir `normalizeRun` could ask is collected,
1435
+ // a second `git -C` included.
1436
+ async function projectDirs(dirs, root, cwd) {
1437
+ const key = (p) => (process.platform === "win32" ? p.toLowerCase() : p)
1438
+ const ok = new Set()
1439
+ let me
1440
+ try { me = key(await fs.realpath(root)) } catch { return ok }
1441
+ for (const dir of new Set(dirs)) {
1442
+ const bare = /^(["'])(.*)\1$/.exec(dir)?.[2] ?? dir
1443
+ if (!bare) continue
1444
+ try { if (key(await fs.realpath(path.resolve(cwd, bare))) === me) ok.add(dir) } catch { /* not one */ }
1445
+ }
1446
+ return ok
1393
1447
  }
1394
1448
 
1395
1449
  // An `apply_patch` call names its targets only in `patchText` markers. Copied from
@@ -1427,7 +1481,7 @@ function patchSections(patchText) {
1427
1481
  // binary, 2026-11), but V2 is not judged. Whether V1's bash tool has a background mode is
1428
1482
  // UNVERIFIED (no V1 binary was inspected); if it has one, a launch would pass here, since only a
1429
1483
  // numeric non-zero `metadata.exit` refuses a completed call.
1430
- function doneOwed(messages, checks, root) {
1484
+ async function doneOwed(messages, checks, root) {
1431
1485
  const groups = checks.map((c) => (typeof c === "string" ? { label: c, forms: [c] } : c))
1432
1486
  const prompts = []
1433
1487
  messages.forEach((m, i) => {
@@ -1456,14 +1510,21 @@ function doneOwed(messages, checks, root) {
1456
1510
  lastEdit = i
1457
1511
  })
1458
1512
  if (lastEdit === -1) return []
1459
- const passed = new Set()
1513
+ const runs = []
1460
1514
  for (const p of tools.slice(lastEdit + 1)) {
1461
1515
  const command = DONE_SHELL_TOOLS.has(String(p.tool).toLowerCase()) && p.state.input?.command
1462
1516
  if (typeof command !== "string" || p.state.status !== "completed") continue
1463
1517
  const exit = p.state.metadata?.exit
1464
1518
  if (typeof exit === "number" && exit !== 0) continue
1465
- for (const g of groups) if (groupPasses(command, g)) passed.add(g.label)
1519
+ runs.push(command)
1466
1520
  }
1521
+ // The dirs `normalizeRun` would ask about, resolved once off disk (it is sync, this reads async).
1522
+ const asked = []
1523
+ for (const c of [...runs, ...groups.flatMap((g) => g.forms)]) normalizeRun(c, (d) => { asked.push(d); return true })
1524
+ const ok = await projectDirs(asked, root, root)
1525
+ const same = (d) => ok.has(d)
1526
+ const passed = new Set()
1527
+ for (const command of runs) for (const g of groups) if (groupPasses(command, g, same)) passed.add(g.label)
1467
1528
  return groups.map((g) => g.label).filter((l) => !passed.has(l))
1468
1529
  }
1469
1530
 
@@ -1642,7 +1703,7 @@ export const GeneseedContext = async (ctx) => {
1642
1703
  if (await doneGateOff()) return
1643
1704
  const { root: gitRoot, source, blocking, checks } = await doneChecks(root)
1644
1705
  if (!checks.length) return
1645
- const owed = doneOwed(output.messages, checks, gitRoot)
1706
+ const owed = await doneOwed(output.messages, checks, gitRoot)
1646
1707
  if (!owed.length) return
1647
1708
  const stamp = Date.now()
1648
1709
  output.messages.push({
@@ -19,9 +19,10 @@
19
19
  // the developer's personal `.geneseed/ownership.md` holds `Setup: declined <date>`.
20
20
  // High-confidence patterns only, so legitimate work is never caught. Borderline cases
21
21
  // (.env edits) are WARNED, not blocked. Every block is recorded in the gate
22
- // ledger (`<cfg>/notebook/gates.jsonl`) under the hook's rule key (`law-1`, `rigor-5`,
22
+ // ledger (the install's `notebook/gates.jsonl`, `notebookHome`) under the hook's rule key (`law-1`, `rigor-5`,
23
23
  // `law-4`, `ops-2`, `process-1`, `wiki`, `ownership`); every skill or subagent call, blocked or not, is
24
- // counted in `<cfg>/notebook/usage.jsonl` when that `notebook/` exists and `.usage-off` does not.
24
+ // counted in the install's `notebook/usage.jsonl` (`usageHome`) when that `notebook/` exists and
25
+ // `.usage-off` does not, and so is a V1 `/skill` command.
25
26
  //
26
27
  // GENESEED_GUARD=off disable entirely.
27
28
  // GENESEED_GUARD=warn downgrade every block to a warning (log, but allow).
@@ -210,13 +211,16 @@ function say(msg, level = "warn") {
210
211
  const log = (msg) => say(msg)
211
212
 
212
213
  // ---- the gate ledger ------------------------------------------------------------
213
- // The twin of `ledger()` in js/hosts/hooks.mjs: one JSON line per BLOCK into
214
- // `<cfg>/notebook/gates.jsonl`, the rule and never the content, so `geneseed status` can
215
- // count what the boundary actually caught on an OpenCode install too. Until this the
216
- // recommended install was the one with no gate evidence at all. A warning is not recorded
217
- // (nothing was refused) and neither is `GENESEED_GUARD=warn`. `notebook/` is never created
218
- // here — an install without one (or a test importing this file) records nothing. Capped
219
- // at the newest MAX_LEDGER_LINES like the hook's; never throws, never decides.
214
+ // The twin of `ledger()` in js/hosts/hooks.mjs: one JSON line per BLOCK into the install's
215
+ // `notebook/gates.jsonl` (`notebookHome`: `<cfg>/notebook` for a global install,
216
+ // `<repo>/notebook` for a project one), the rule and never the content, so `geneseed status`
217
+ // and the console can count what the boundary actually caught on an OpenCode install too. A
218
+ // warning is not recorded (nothing was refused) and neither is `GENESEED_GUARD=warn`.
219
+ // `notebook/` is never created here — an install without one (or a test importing this file)
220
+ // records nothing. Each loaded copy records its OWN refusals, with no stand-down: a global and a
221
+ // project copy judge a call each from its own carrier AGENT.md (gates, packs, excluded rules), so
222
+ // the copy that can record is not always the copy that refused. Capped at the newest
223
+ // MAX_LEDGER_LINES like the hook's; never throws, never decides.
220
224
  const MAX_LEDGER_LINES = 1000
221
225
  async function ledger(rule) {
222
226
  // `geneseed doctor --probe` blocks on purpose; its blocks are not the user's (the twin of
@@ -225,7 +229,8 @@ async function ledger(rule) {
225
229
  try {
226
230
  const bases = []
227
231
  if (process.env.GENESEED_HARNESS) bases.push(process.env.GENESEED_HARNESS)
228
- bases.push(path.dirname(PLUGIN_DIR))
232
+ const own = notebookHome()
233
+ if (own) bases.push(own)
229
234
  for (const base of bases) {
230
235
  const dir = path.join(base, "notebook")
231
236
  if (!(await isDir(dir))) continue
@@ -2488,7 +2493,7 @@ function argPaths(v, key = "", out = [], depth = 0) {
2488
2493
 
2489
2494
  // Usage counting: the same rules as js/hosts/usage.mjs, inline because a plugin cannot import
2490
2495
  // from the repo (V2 loads every .js in plugins/ as a plugin). One line per skill or subagent
2491
- // call, the day and the name only, under <cfg>/notebook/usage.jsonl. Silent and never throws:
2496
+ // call, the day and the name only, under the install's notebook/usage.jsonl. Silent and never throws:
2492
2497
  // a counter must not change, slow or fail a tool call. tests/unit/usage.test.mjs holds this
2493
2498
  // copy and the hook's to one table. `usageOf` is by hand (no Bob shapes here); `NAME_RE` is the
2494
2499
  // hook's line, kept by `node tests/twins.mjs --write`.
@@ -2504,18 +2509,88 @@ function usageOf(tool, args) {
2504
2509
  name = name.trim().replace(/^\/+/, "")
2505
2510
  return NAME_RE.test(name) ? { kind, name } : null
2506
2511
  }
2507
- async function recordUse(tool, args) {
2512
+ // WHERE EVERY LEDGER IS: the dir that holds the install's own `notebook/` (usage.jsonl,
2513
+ // gates.jsonl, agent-runs.jsonl, the agent notes). A global install keeps it beside plugins/
2514
+ // (`<cfg>/notebook`); a PROJECT install keeps its plugins in `<repo>/.opencode/plugins` and its
2515
+ // notebook at `<repo>/notebook`, where the bundle writes it (js/build/bundle.mjs) and the console
2516
+ // reads it (js/web/api.mjs `activeInstalls` -> the root). Only the first was tried once, and a
2517
+ // project install recorded nothing. null: no notebook. Sync and `statSync`-only, because
2518
+ // `countingCopy` asks it of other installs' dirs and geneseed-learn.js carries a copy.
2519
+ function notebookHome(cfg = path.dirname(PLUGIN_DIR)) {
2520
+ const isDirSync = (p) => { try { return statSync(p).isDirectory() } catch { return false } }
2521
+ if (isDirSync(path.join(cfg, "notebook"))) return cfg
2522
+ if (path.basename(cfg) === ".opencode" && isDirSync(path.join(path.dirname(cfg), "notebook"))) return path.dirname(cfg)
2523
+ return null
2524
+ }
2525
+ // The notebook home when counting is on there: null with no notebook, or `.usage-off` in it.
2526
+ function usageHome(cfg = path.dirname(PLUGIN_DIR)) {
2527
+ const home = notebookHome(cfg)
2528
+ return home && !existsSync(path.join(home, ".usage-off")) ? home : null
2529
+ }
2530
+ // The twin of `globalHookStandingDown` for the counter only. OpenCode loads the global plugins/
2531
+ // AND every project `.opencode/plugins/` from the session's directory up to its worktree (it
2532
+ // dedups npm plugins, not local files), so beside a project install several guards see each call,
2533
+ // and the console, which sums every install, would read it several times. ONE copy counts: the
2534
+ // guard of the NEAREST project dir, from `directory` up to `worktree`, that can count (a guard
2535
+ // file and a live `usageHome`). With none, every copy counts as before — the global alone, in the
2536
+ // usual case. Nearest, not "any other guard exists": with `repo/` and `repo/pkg/` both installed
2537
+ // and a session in pkg, that rule had every copy stand down and nothing counted. A project guard
2538
+ // that cannot count (no notebook, `.usage-off`) silences nothing, as a hook a project does not
2539
+ // wire silences nothing on the Claude side. `GENESEED_STACK_GLOBAL` stacks them, as for the hooks.
2540
+ function countingCopy(here) {
2541
+ const [directory, worktree] = here || []
2542
+ if (!directory) return null
2543
+ const start = path.resolve(directory)
2544
+ const top = worktree ? path.resolve(worktree) : start
2545
+ const rel = path.relative(top, start)
2546
+ // Nearest first. `directory` not under `worktree`: test the two and walk nothing.
2547
+ const dirs = [start]
2548
+ if (rel.startsWith("..") || path.isAbsolute(rel)) dirs.push(top)
2549
+ else for (let d = start; norm(d) !== norm(top) && path.dirname(d) !== d;) { d = path.dirname(d); dirs.push(d) }
2550
+ for (const dir of dirs) {
2551
+ const plugins = path.join(dir, ".opencode", "plugins")
2552
+ if (existsSync(path.join(plugins, "geneseed-guard.js")) && usageHome(path.join(dir, ".opencode"))) return norm(plugins)
2553
+ }
2554
+ return null
2555
+ }
2556
+ function anotherCopyCounts(here) {
2557
+ if (process.env.GENESEED_STACK_GLOBAL) return false
2558
+ try {
2559
+ const winner = countingCopy(here)
2560
+ return winner !== null && winner !== norm(PLUGIN_DIR)
2561
+ } catch { return false /* cannot tell: count */ }
2562
+ }
2563
+ async function appendUse(use, here) {
2564
+ const home = usageHome()
2565
+ if (!home || anotherCopyCounts(here)) return
2566
+ await fs.appendFile(path.join(home, "notebook", "usage.jsonl"),
2567
+ `${JSON.stringify({ ts: new Date().toISOString().slice(0, 10), ...use })}\n`)
2568
+ }
2569
+ async function recordUse(tool, args, here) {
2508
2570
  try {
2509
2571
  if (process.env.GENESEED_NO_USAGE) return
2510
2572
  const use = usageOf(tool, args)
2511
- if (!use) return
2512
- const cfg = path.dirname(PLUGIN_DIR)
2513
- if (existsSync(path.join(cfg, ".usage-off"))) return
2514
- if (!(await isDir(path.join(cfg, "notebook")))) return
2515
- await fs.appendFile(path.join(cfg, "notebook", "usage.jsonl"),
2516
- `${JSON.stringify({ ts: new Date().toISOString().slice(0, 10), ...use })}\n`)
2573
+ if (use) await appendUse(use, here)
2517
2574
  } catch { /* a counter never fails a tool call */ }
2518
2575
  }
2576
+ // A V1 slash command that runs an installed skill: `command.execute.before` names the command,
2577
+ // and it counts when `<layer>/skills/<name>/SKILL.md` exists — the plugin's own layer, the host's
2578
+ // global config dir, then the project's `.opencode/skills`. The twin of the hook's `recordSlash` (js/hosts/usage.mjs); a
2579
+ // command is a name, never its arguments. Not on V2: it has no command hook, and its prompt hook
2580
+ // sees the expanded template, with no name to count. A renamed command (`/code-review` runs
2581
+ // `geneseed-code-review`) or an alias counts only where a skill of that name exists.
2582
+ async function recordSlash(command, here) {
2583
+ try {
2584
+ if (process.env.GENESEED_NO_USAGE || typeof command !== "string") return
2585
+ const name = command.trim().replace(/^\/+/, "")
2586
+ if (/[/\\:]|\.\./.test(name) || !NAME_RE.test(name)) return
2587
+ // The host's global config too: beside a project install the global copy stands down, so a
2588
+ // skill only the global holds would otherwise be counted by neither.
2589
+ const layers = [path.dirname(PLUGIN_DIR), hostConfigDir(), ...(here || []).filter(Boolean).map((d) => path.join(d, ".opencode"))]
2590
+ if (!layers.some((l) => existsSync(path.join(l, "skills", name, "SKILL.md")))) return
2591
+ await appendUse({ kind: "skill", name, via: "slash" }, here)
2592
+ } catch { /* a counter never fails a command */ }
2593
+ }
2519
2594
 
2520
2595
  // ---- a gate that fails -----------------------------------------------------------
2521
2596
  // An error's text, from anything a gate can throw: reading it must not throw in turn.
@@ -2643,12 +2718,19 @@ export const GeneseedGuard = async (ctx) => {
2643
2718
  }
2644
2719
  } catch (err) { log(`change report error (ignored): ${err?.message ?? err}`) }
2645
2720
  },
2721
+ // V1 only (V2 has no command hook): a `/skill` command counts as the skill (`recordSlash`).
2722
+ "command.execute.before": async (input) => {
2723
+ try {
2724
+ if (await sovereignBypass(root())) return
2725
+ await recordSlash(input?.command, [ctx?.directory, ctx?.worktree])
2726
+ } catch { /* a counter never fails a command */ }
2727
+ },
2646
2728
  "tool.execute.before": async (input, output) => {
2647
2729
  // Bypass before counting, the order Claude's toolGate keeps: an excluded repo is
2648
2730
  // dormant, so nothing is written there. GENESEED_GUARD=off still counts — Claude's
2649
2731
  // hook has no such switch; GENESEED_NO_USAGE / .usage-off stop the counter.
2650
2732
  if (await sovereignBypass(root())) return
2651
- await recordUse(input?.tool || input?.name, output?.args || input?.args)
2733
+ await recordUse(input?.tool || input?.name, output?.args || input?.args, [ctx?.directory, ctx?.worktree])
2652
2734
  if (OFF) return
2653
2735
  // A session that predates this plugin never sent `session.created`. Once per session.
2654
2736
  try { await watch(input?.sessionID) } catch { /* the report never decides a tool call */ }