geneseed 5.0.0 → 5.0.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/SHIPPED.md +1 -1
  3. package/adapters/opencode/plugins/geneseed-context.js +1 -1
  4. package/adapters/opencode/plugins/geneseed-guard.js +1 -1
  5. package/docs/PRD.md +1 -1
  6. package/docs/concepts/hooks.md +1 -1
  7. package/docs/concepts/shared-tier.md +4 -4
  8. package/docs/guides/migrate.md +4 -2
  9. package/docs/guides/upgrade-to-5.md +6 -4
  10. package/docs/web-ui.md +11 -4
  11. package/harness.config.json +1 -1
  12. package/js/README.md +2 -1
  13. package/js/build/fold.mjs +7 -7
  14. package/js/build/rule-decide.mjs +273 -0
  15. package/js/cli-table.json +1 -1
  16. package/js/hosts/hooks-context.mjs +1 -1
  17. package/js/hosts/installs.mjs +4 -4
  18. package/js/hosts/memory-files.mjs +2 -2
  19. package/js/hosts/store-watch.mjs +5 -3
  20. package/js/inspect/registry.mjs +4 -2
  21. package/js/lib/paths.mjs +13 -0
  22. package/js/maintain/migrate.mjs +58 -20
  23. package/js/web/api.mjs +13 -6
  24. package/js/web/handler.mjs +2 -0
  25. package/js/web/routes.mjs +7 -3
  26. package/js/web/update-check.mjs +2 -2
  27. package/js/web/user-files.mjs +38 -11
  28. package/package.json +1 -1
  29. package/src/skills/rule/approve.md +11 -5
  30. package/src/skills/rule.md +2 -1
  31. package/web/dist/assets/{Activity-D8G4eClY.js → Activity-Ci4PZco3.js} +1 -1
  32. package/web/dist/assets/{ActivityDetail-BtOBYk3M.js → ActivityDetail-C8hroCND.js} +1 -1
  33. package/web/dist/assets/{Bonsai-B_y20b3i.js → Bonsai-C1iBAt4v.js} +1 -1
  34. package/web/dist/assets/{CopyButton-CHQte7Ap.js → CopyButton-DJ3a4N88.js} +1 -1
  35. package/web/dist/assets/{Dashboard-B8uXeJZ_.js → Dashboard-C_On4KXw.js} +2 -2
  36. package/web/dist/assets/{Docs-Dgv_MWfT.js → Docs-Kffdg5uV.js} +1 -1
  37. package/web/dist/assets/{GreenhouseView-CSzTMSl_.js → GreenhouseView-k56_cBSF.js} +1 -1
  38. package/web/dist/assets/{Installs-BDk9lqBI.js → Installs-DtEKLC9h.js} +2 -2
  39. package/web/dist/assets/{JournalView-CvRk1-m5.js → JournalView-RQnk5l7I.js} +1 -1
  40. package/web/dist/assets/{Kits-CoITzxWM.js → Kits-CXkEBpnf.js} +1 -1
  41. package/web/dist/assets/{Laws-Ctf5r9rE.js → Laws-DhhIVqmh.js} +1 -1
  42. package/web/dist/assets/{Library-DNwHYVXt.js → Library-CAUiEoJo.js} +1 -1
  43. package/web/dist/assets/{Loops-S85PMQ8m.js → Loops-LKD8mF4E.js} +1 -1
  44. package/web/dist/assets/{OperatorHudView-DuGz_sTk.js → OperatorHudView-CM5jNPwL.js} +1 -1
  45. package/web/dist/assets/Personal-B6Uoly3C.js +2 -0
  46. package/web/dist/assets/{RailCats-AW92uhsX.js → RailCats-DQxxYBEP.js} +1 -1
  47. package/web/dist/assets/{Settings-CGDFz-6j.js → Settings-BTe6-wda.js} +1 -1
  48. package/web/dist/assets/{Tabs-1qLrnqmn.js → Tabs-CbdDWTp_.js} +1 -1
  49. package/web/dist/assets/api-D_r0Jtla.js +1 -0
  50. package/web/dist/assets/{index-COTd4TRZ.js → index-HfGmYXab.js} +3 -3
  51. package/web/dist/assets/index-ao3M-Fhm.css +1 -0
  52. package/web/dist/index.html +3 -3
  53. package/web/dist/assets/Personal-afJNwvRS.js +0 -2
  54. package/web/dist/assets/api-C46vAuqp.js +0 -1
  55. package/web/dist/assets/index-CtorA7uK.css +0 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,22 @@ label. For the capability ↔ spec map, see [SHIPPED.md](SHIPPED.md).
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [5.0.1] — 2026-11-06
12
+
13
+ The migration can finish in the console: a preview, and Approve and Reject on pending rules.
14
+
15
+ ### Added
16
+ - **The console finishes the 5.0 migration with no terminal.** *Preview next rebuild* on the Installs page shows what each global install would fold, and any orphans, and writes nothing. It is the fold and orphan half of `geneseed migrate --dry-run`, through one new function (`migratePreview`) and one read-only route.
17
+ - **Approve and Reject on the Rules page.** The *Pending* section now decides what the fold drafted: *Approve* and *Reject* on a rule, and for a profile or wiki pointer the two files with *Use the host file*, *Use the shared file* and *Keep both*. The steps are the rule skill's own, in one module (`js/build/rule-decide.mjs`): target file, ledger row, draft, so a failed step leaves the rule in force. A stale page reloads and applies nothing. A decision that moves a file offers *Rebuild all*, and none applies while a job runs. Only what the fold drafted is decidable. The change report lists a decision like any other console write, and its line now says one may be yours: the console's token is readable by anything on the machine, so the console is no boundary against an agent with a shell.
18
+
19
+ ### Changed
20
+ - **A real `geneseed migrate` runs only from the npm package.** From a git clone or a bundle it refuses with exit 3 before any write, and says to use `geneseed update`: the rebuild there would point the hook shim back at the same copy. An npx cache counts as outside the package. `--dry-run` works from anywhere, and there it says a real run would refuse instead of listing re-emits. A run from the npm package does not change. The guides and `migrate --help` now say that the rebuild, not `migrate`, rewrites the shim, and that it names whichever Geneseed ran it.
21
+ - **The rule skill's approval flow names the console as a second decider**, and reads the retired files of each host's config directory: `installs.json` holds project roots only, so the old wording found none.
22
+
23
+ ### Fixed
24
+ - **The sidebar no longer says `built never` on a live Claude-family install.** The Overview read the mtime of `AGENT.md`, which such an install lacks. It now reads the version marker, as the fleet does.
25
+ - **`geneseed migrate --dry-run` writes nothing, as it says.** It used to prune dead rows from `installs.json` while it listed the installs.
26
+
11
27
  ## [5.0.0] — 2026-11-06
12
28
 
13
29
  Memory, rules, profile and the wiki move to one machine-wide shared tier at `~/.config/geneseed`, and existing stores fold into it on the next global emit. Breaking: see Removed.
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.0.0**.
23
+ > string. Current label: **5.0.1**.
24
24
 
25
25
  ## Capabilities
26
26
 
@@ -280,7 +280,7 @@ async function draftLine() {
280
280
  try {
281
281
  const { items } = JSON.parse(await fs.readFile(path.join(machineDir(), ".fold-state.json"), "utf8"))
282
282
  const n = Object.values(items ?? {}).filter((i) => i?.state === "pending").length
283
- return n ? `[drafts] ${n} drafted item${n === 1 ? "" : "s"} in user-rules.draft.md wait${n === 1 ? "s" : ""} for the user's decision (the rule skill).` : null
283
+ return n ? `[drafts] ${n} drafted item${n === 1 ? "" : "s"} in user-rules.draft.md wait${n === 1 ? "s" : ""} for the user's decision (the rule skill or the web console).` : null
284
284
  } catch { return null }
285
285
  }
286
286
 
@@ -1457,7 +1457,7 @@ const storeLine = (files) => {
1457
1457
  const shown = files.slice(0, 5).map((f) => f.split(/[\\/]/).slice(-2).join("/")).join(", ")
1458
1458
  const more = files.length > 5 ? ` (+${files.length - 5} more)` : ""
1459
1459
  return `Geneseed change report: ${files.length} rule or memory file${files.length === 1 ? "" : "s"} ` +
1460
- `changed outside this session's approved writes (another session may have made it): ${shown}${more}. This detects a change; it prevented nothing.`
1460
+ `changed outside this session's approved writes (another session, or a decision of yours in the web console, may have made it): ${shown}${more}. This detects a change; it prevented nothing.`
1461
1461
  }
1462
1462
  function noteForStatus(files) {
1463
1463
  try {
package/docs/PRD.md CHANGED
@@ -83,7 +83,7 @@ sequenceDiagram
83
83
  | FR-005 | OpenCode gets the same behaviour through plugins, on both plugin APIs. | The host loads every plugin | ✅ | `adapters/opencode/plugins/`, `tests/host_canary.mjs` |
84
84
  | FR-006 | Global installs share memory, rules, profile, wiki manifest, exclude paths and notes. | Every global install reads the tier; project over host over shared | ✅ | `js/lib/machine-dir.mjs`, `js/hosts/hooks-context.mjs` |
85
85
  | FR-007 | A global emit folds existing stores into the tier. | Copies read back before the old store moves; a second run writes nothing | ✅ | `js/build/fold.mjs` |
86
- | FR-008 | A rule, profile or wiki that needs a decision waits in a draft. | A drafted rule stays in force on its host; only the `rule` skill decides | ✅ | `js/build/fold.mjs`, `src/skills/rule/approve.md` |
86
+ | FR-008 | A rule, profile or wiki that needs a decision waits in a draft. | A drafted rule stays in force on its host; only the `rule` skill or the console's Pending section decides | ✅ | `js/build/fold.mjs`, `js/build/rule-decide.mjs`, `src/skills/rule/approve.md` |
87
87
  | FR-009 | A project install may opt in to read the tier. | Off by default; read-only and labelled; cost stated | ✅ | `js/inspect/cost.mjs`, `js/hosts/hooks-context.mjs` |
88
88
  | FR-010 | The agent's memory is one fact per file, with a two-level index. | `geneseed memory list`, `rm` archive; `learn` updates and does not duplicate | ✅ | `js/hosts/memory-files.mjs`, `js/maintain/memory.mjs` |
89
89
  | FR-011 | A folder can silence every global install. | `geneseed exclude add`; effect on the next tool call | ✅ | `js/inspect/excludes.mjs` |
@@ -103,4 +103,4 @@ Shell is not a boundary. The gates read only parsed forms of a command, and the
103
103
 
104
104
  Geneseed's own writers do not count. `learn`, `geneseed memory rm`, the OpenCode learn plugin and the fold snapshot the store around their run and log what moved to `memory/.own-writes.json`, as an exact size and time. A change that matches is excused. Two limits follow: anything else that writes during that run is excused too, and the log is a plain file an agent could edit.
105
105
 
106
- Other limits. Approval is per session and the shared tier is not, so another session's approved write is reported here too, and the line says it may be that. An edit in the web console during a session is reported, because it is not logged. On Claude Code a sub-agent's write sits in its own transcript, so it is reported the same way. The baseline is a plain file: an agent that can write there can edit it, or set a file's size and time back. The report is evidence, not a control. If a done-gate advisory already holds stdout at that Stop, the line goes to stderr and the `changes` row.
106
+ Other limits. Approval is per session and the shared tier is not, so another session's approved write is reported here too, and the line says it may be that. Any web console write during a session is reported, your own decision on a drafted item included, because a console request proves no click: anything on the machine that reads the console's token can send one. The line names that case, so a report right after your click may be that click. On Claude Code a sub-agent's write sits in its own transcript, so it is reported the same way. The baseline is a plain file: an agent that can write there can edit it, or set a file's size and time back. The report is evidence, not a control. If a done-gate advisory already holds stdout at that Stop, the line goes to stderr and the `changes` row.
@@ -46,7 +46,7 @@ The first global emit in a host's own config directory creates the folder and se
46
46
 
47
47
  ### The fold
48
48
 
49
- Each global emit, in the host's own config directory, moves that host's stores into the tier and prints one line, such as `[shared] claude: 12 facts folded, 1 collision, 2 rules to approve, old store moved aside`. A host with nothing to move prints nothing, and a second emit writes nothing. `geneseed migrate --dry-run` previews the fold for each host, and [Upgrade to 5.0](../guides/upgrade-to-5.md) walks through a first run.
49
+ Each global emit, in the host's own config directory, moves that host's stores into the tier and prints one line, such as `[shared] claude: 12 facts folded, 1 collision, 2 rules to approve, old store moved aside`. A host with nothing to move prints nothing, and a second emit writes nothing. `geneseed migrate --dry-run` previews the fold for each host, *Preview next rebuild* on the console's Installs page shows the same, and [Upgrade to 5.0](../guides/upgrade-to-5.md) walks through a first run.
50
50
 
51
51
  - **Facts** copy byte for byte. A fact with the same name and other text lands as `<name>-<host>.md`, then `-2`, `-3`. The memory-curator agent can merge them later. Agent lessons append to the tier's file for that agent.
52
52
  - **Notes** in `notebook/skill-notes/` and `notebook/agent-notes/` copy the same way. The rest of the notebook stays per host.
@@ -54,15 +54,15 @@ Each global emit, in the host's own config directory, moves that host's stores i
54
54
  - **Exclude paths** join the shared list, and a shared path the host never saw gets its wiring. The report line names each file this writes in your repo.
55
55
  - **`user-rules.md`** merges rule by rule. A rule with the same title and body as a shared rule leaves the host file. Any other rule goes to `user-rules.draft.md` with its host and old number, and stays in the host file, still binding. A host file with no rules left and nothing else of yours returns to its seed; hand-written text keeps the file as it is.
56
56
 
57
- **Approving a draft.** The [rule skill](skills.md) takes each item in turn; nothing else writes a decision. Approve a rule and it joins the shared file under a new number, and the next fold of that host removes the host copy. Reject it and it stays on that host only, and the fold never drafts it again. For a profile or wiki pointer, the file you choose becomes the shared one and the other moves aside, or you keep both and the host file goes on overriding. The draft is never loaded: a drafted rule binds only from its host file.
57
+ **Approving a draft.** The [rule skill](skills.md) takes each item in turn, and the console's **Pending** section decides the same items by the same steps; nothing else writes a decision. Approve a rule and it joins the shared file under a new number, and the next fold of that host removes the host copy. Reject it and it stays on that host only, and the fold never drafts it again. For a profile or wiki pointer, the file you choose becomes the shared one and the other moves aside, or you keep both and the host file goes on overriding. The draft is never loaded: a drafted rule binds only from its host file.
58
58
 
59
59
  Nothing is deleted. After every copy is read back, the old `memory/` moves to `archived-memory/<stamp>/` beside it, and the notes and whole files move to the same kind of folder. The host store returns to its seed and keeps its `README.md`. Hand-written index text and `archive/` stay in that folder, and the report line names every other file that stayed there and did not fold. A store or file already linked to the tier, in either direction, is left alone. If a copy fails, the old store stays readable, the emit reports it on stderr and goes on, and the next emit retries. There is no automatic way back: to downgrade, restore the archived folder by hand.
60
60
 
61
61
  ### The console
62
62
 
63
- The console has one hub and no install switch. On the **Personal** page, Rules, Profile and Memory list the shared store once, tagged `shared`, and name no harness; a project install keeps its own entry. Each rule row shows its token cost, and the page shows the total. There is no rule limit. A read-only **Pending** section shows what waits in the draft.
63
+ The console has one hub and no install switch. On the **Personal** page, Rules, Profile and Memory list the shared store once, tagged `shared`, and name no harness; a project install keeps its own entry. Each rule row shows its token cost, and the page shows the total. There is no rule limit. A **Pending** section shows what waits in the draft, with *Approve* and *Reject* on a rule, and the two files with three choices on a profile or wiki pointer. A decision that moves a file offers *Rebuild all*, which removes the host copy. An edit in another session makes the decision reload instead of applying, and no decision applies while a rebuild runs.
64
64
 
65
- On **Installs**, *Make default* on an active install picks the one the console's pickers start on and a request naming no install reads. The `install` and `theme` lines of `geneseed status` follow it. The pick is `default-install.json`; if that install goes away, the console returns to the fixed host order.
65
+ On **Installs**, *Preview next rebuild* shows what each global install would fold, and any orphans, and writes nothing. *Make default* on an active install picks the one the console's pickers start on and a request naming no install reads. The `install` and `theme` lines of `geneseed status` follow it. The pick is `default-install.json`; if that install goes away, the console returns to the fixed host order.
66
66
 
67
67
  ### Uninstall
68
68
 
@@ -14,14 +14,16 @@ Claude Code, Bob and OpenClaude call Geneseed's hooks through one small file, th
14
14
 
15
15
  ## Run it
16
16
 
17
- Install the package first (`npm install -g geneseed`, or prefix each command with `npx`), then:
17
+ Install the package first (`npm install -g geneseed`), then run these from it:
18
18
 
19
19
  ```
20
20
  geneseed migrate --dry-run # survey every install, print the plan and the fold report; writes nothing
21
21
  geneseed migrate # do it
22
22
  ```
23
23
 
24
- `migrate` rebuilds every registered install **with its own theme, host, footprint, posture and mode**. Nothing is reset to a default. It then rewrites the hook shim to point at the npm package, and reports anything it is not allowed to fix for you. A second run prints `already on the npm shape` and writes nothing.
24
+ `migrate` rebuilds every registered install **with its own theme, host, footprint, posture and mode**. Nothing is reset to a default. Each rebuild of a Claude Code, Bob or OpenClaude install rewrites the hook shim to name the Geneseed that runs the rebuild, so it now names the npm package. `migrate` does not write the shim itself, and OpenCode has none. It then reports anything it is not allowed to fix for you. A second run prints `already on the npm shape` and writes nothing.
25
+
26
+ **It runs only from the npm package.** From a git clone or a bundle, a real run has nothing to move: the rebuild would point the shim back at that same copy. So it refuses with exit 3 before it writes anything, and says to use `geneseed update`. An `npx` run refuses too: npm prunes that cache, and the shim would die with it. `--dry-run` works from anywhere. Outside the package it previews the fold, then says a real run would refuse.
25
27
 
26
28
  `--dry-run` also previews [the fold](../concepts/shared-tier.md#the-fold) for each global install, even on a machine that has already migrated, because the fold runs in every global emit. Each host is read against the shared tier as it stands, so two hosts that hold the same new fact both count it.
27
29
 
@@ -41,10 +41,12 @@ It writes nothing. It prints one line for each global install, read against the
41
41
  [migrate] --dry-run: nothing was written.
42
42
  ```
43
43
 
44
- **Use only the `--dry-run` form here.** The `would re-emit` lines are the plan of `geneseed migrate` itself, which moves a clone install to [the npm shape](migrate.md). That is not a 5.0 step.
44
+ **Use only the `--dry-run` form here.** The `would re-emit` lines are the plan of `geneseed migrate` itself, which moves a clone install to [the npm shape](migrate.md). That is not a 5.0 step. From a clone those lines do not appear: the preview ends by saying a real run would refuse, and a real `migrate` there exits 3 and changes nothing.
45
45
 
46
46
  It also lists orphans: a root `AGENT.md`, or the folder of a retired skill, that no manifest owns. Such a folder may be yours. Geneseed never moves it, so move it by hand if it is not.
47
47
 
48
+ **In the console.** With no terminal, there is no preview before the first fold: *Update* on a clone pulls and rebuilds in one job, so the fold runs in that click, and a 4.x console has no preview. Nothing is deleted, as step 3 shows. After that, *Preview next rebuild* on the Installs page, beside *Rebuild all*, shows the same fold lines and orphans for any later rebuild, without the `would re-emit` lines, and writes nothing.
49
+
48
50
  ## 3. Upgrade
49
51
 
50
52
  Use the route you always use. See [Upgrade](upgrade.md).
@@ -57,7 +59,7 @@ geneseed upgrade # from a clone
57
59
  Between the install and the end of the rebuild:
58
60
 
59
61
  - Hooks and running sessions stay safe. They read the host files until the rebuild moves them.
60
- - Do not use the web console until the rebuild ends.
62
+ - Do not change anything in the web console until the rebuild ends. *Rebuild all* on its Installs page is the same rebuild as `geneseed rebuild-all`.
61
63
  - The first `geneseed upgrade` from 4.x still runs the old doctor gate, which can take up to 300 seconds. Wait for it.
62
64
 
63
65
  Each global install in its host's own config directory prints what it moved, once:
@@ -85,14 +87,14 @@ A host installed after an `exclude add` also gets the repo-side wiring on this r
85
87
 
86
88
  `user-rules.draft.md` in the tier lists what the fold could not decide for you. It is never loaded: a drafted rule goes on binding from its host file until you decide.
87
89
 
88
- Ask the agent to review the pending rules. The `rule` skill is the only thing that writes a decision. It takes each item in turn:
90
+ Ask the agent to review the pending rules, or open **Pending** on the console's Personal page. The `rule` skill and that section are the only things that write a decision, and they take the same steps:
89
91
 
90
92
  - **Approve** moves the rule to the shared file under a new number. The next rebuild of that host removes the host copy.
91
93
  - **Reject** keeps the rule on that host only, and it is never drafted again.
92
94
  - **Later** leaves it pending.
93
95
  - For a profile or wiki pointer, you choose which file becomes the shared one.
94
96
 
95
- The console's Personal page shows the same items under **Pending**, read-only.
97
+ In the console, an item you leave alone stays pending. After a decision that moves a file, the page offers *Rebuild all*, which removes the host copy. If another session changed the draft, the page reloads and applies nothing.
96
98
 
97
99
  ## 5. Project installs
98
100
 
package/docs/web-ui.md CHANGED
@@ -44,6 +44,8 @@ so other sites can't trigger builds, deletes, or shutdown. Mutating actions (bui
44
44
  update, export, restore, memory-delete, uninstall) run in the background and report back
45
45
  as toasts (fire-and-notify). Read-only browsing needs no token.
46
46
 
47
+ **The token stops other sites, not other programs.** Anything on this machine that can read it, from the served page or `.geneseed-web.json`, can call the console API. So the console is no boundary against an agent with a shell, the same as the shell itself. That includes a rule decision: the [change report](concepts/hooks.md#the-change-report) still lists it, for this reason.
48
+
47
49
  Every request passes one guard first: the `Host` must be `127.0.0.1`, `localhost` or `[::1]`
48
50
  **at the server's own port** (DNS rebinding, other local servers), `/api/*` refuses a
49
51
  `Sec-Fetch-Site` of `cross-site`/`same-site` or a foreign `Origin` (so another site cannot read
@@ -60,13 +62,13 @@ A request can name the install it reads or writes. A read takes two query parame
60
62
  `host` and `path` in its JSON body. The pair is a row of `/api/installs`, and the server checks
61
63
  it against the same detected-install allowlist as the install toggle. An unknown or half pair
62
64
  gets a 404 and never falls through to another install's folder. The writes that take the pair
63
- are `/api/activity`, `/api/memory/delete`, `/api/rules`, `/api/rules/promote`, `/api/profile`,
65
+ are `/api/activity`, `/api/memory/delete`, `/api/rules`, `/api/rules/promote`, `/api/rules/decide`, `/api/profile`,
64
66
  and the `restore` and `build` actions. In `/api/install`, `/api/default-install`, the `install` and
65
67
  `deploy` actions, `/api/excludes` and `/api/reveal`, `host`/`path` keep their own meaning.
66
68
 
67
69
  Every `/api/*` read takes and checks the pair, with these exceptions:
68
70
  - `/api/ping` and `/api/jobs` ignore it.
69
- - The machine-wide reads also ignore it: `/api/update`, `/api/installs`, `/api/fleet`,
71
+ - The machine-wide reads also ignore it: `/api/update`, `/api/installs`, `/api/fleet`, `/api/migrate/preview`,
70
72
  `/api/kits`, `/api/usage`, `/api/gates`, `/api/excludes`, `/api/mcp`, `/api/loops/active`,
71
73
  `/api/activity`, and the Library's skill, agent, memory and notebook lists,
72
74
  `/api/catalog/skills`, `/api/catalog/agents`, `/api/catalog/memory` and
@@ -214,8 +216,13 @@ streams the output of background jobs and keeps their history across reloads.
214
216
  (code points / 4 of its own block), and each list's head shows the one rule count and total, such
215
217
  as `4 rules · ≈1,055 tokens every turn · scope global unless marked`, which counts the file's
216
218
  header too. A row shows a scope only when it differs from that. There is no ceiling.
217
- A **Pending** section lists what waits undecided in `user-rules.draft.md`: read-only, because
218
- the rule skill alone decides a draft, and a pending rule still binds on its host. Every write carries the fingerprint of the
219
+ A **Pending** section lists what waits undecided in `user-rules.draft.md`, and a pending rule still
220
+ binds on its host. *Approve* and *Reject* decide a rule; a profile or wiki pointer shows both files,
221
+ with *Use the host file*, *Use the shared file* and *Keep both*. These apply the rule skill's own
222
+ steps (`js/build/rule-decide.mjs`), and a decision that moves a file offers *Rebuild all*. No decision
223
+ applies while a job runs. The [change report](concepts/hooks.md#the-change-report) lists a decision like
224
+ any other console write, and says it may be yours.
225
+ Every write carries the fingerprint of the
219
226
  content the page last read — if an agent session edited the file meanwhile, the save
220
227
  409s and the page reloads instead of clobbering it.
221
228
  - **Constitution** (`#/laws`) — the whole governance surface on one page, in three bands:
@@ -2,5 +2,5 @@
2
2
  "_comment": "version is a human-readable release label only; the canonical identity of an installed harness is the source fingerprint stamped in .geneseed-version (see `harness version`), not this string.",
3
3
  "theme": "neutral",
4
4
  "product": "Geneseed",
5
- "version": "5.0.0"
5
+ "version": "5.0.1"
6
6
  }
package/js/README.md CHANGED
@@ -42,7 +42,7 @@ layers. These pairs import each other (relative imports between folders, measure
42
42
  | build ↔ web | 1 / 9 | `build/generate.mjs` lazily imports `web/daemon.mjs` to restart a stale console after `rebuild-all` |
43
43
  | hosts ↔ inspect | 1 / 36 | `hosts/installs.mjs` reads `inspect/registry.mjs`'s deploy roots |
44
44
  | ui ↔ web | 1 / 1 | `ui/menu.mjs` starts the daemon; `web/docs.mjs` renders `ui/cli.mjs`'s CLI reference |
45
- | maintain ↔ web | 1 / 6 | `maintain/update.mjs` lazily imports `web/daemon.mjs` for the same restart |
45
+ | maintain ↔ web | 1 / 7 | `maintain/update.mjs` lazily imports `web/daemon.mjs` for the same restart |
46
46
 
47
47
  The only gates over the import graph are the transitive closure walks in
48
48
  `tests/unit/hook_cli.test.mjs`. They pin which modules the generator and CLI entries may pull
@@ -65,6 +65,7 @@ as a per-host install at project or global scope.
65
65
  | `emit-opencode.mjs` | The OpenCode emits — a project's `.opencode/` and the global config dir. Deliberate twin of the above |
66
66
  | `emit-common.mjs` | Constants, tree walkers, and the three writers BOTH global emits share. Decides no host |
67
67
  | `fold.mjs` | The fold: moves a global install's stores into the shared tier, in the emit. Moves aside, never deletes; a second run writes nothing |
68
+ | `rule-decide.mjs` | The decisions on the draft: the approval flow of `src/skills/rule/approve.md`, as the console applies it. Write order: target, ledger, draft |
68
69
  | `stubs.mjs` | Write-once seed files: context, wiki, rules, excludes, profile, `.gitignore`, memory/notebook indexes |
69
70
  | `version.mjs` | The release marker: fingerprint the sources, read/compare/write an install's version, warn on downgrade |
70
71
  | `driver.mjs` | The generator driver: the nine emit targets, per-host emit orchestration, the prune and the manifest. `bin/build-driver.mjs` is only its entry |
package/js/build/fold.mjs CHANGED
@@ -45,11 +45,11 @@ const sha256 = (data) => createHash('sha256').update(data).digest('hex');
45
45
  const seedHash = (bytes) => sha256(bytes.toString('utf8').replaceAll('\r\n', '\n'));
46
46
  const WHOLE_FILE_SEEDS = new Set([sha256(SESSION_SEEDS['PROFILE.md']), sha256(SESSION_SEEDS[WIKI_FILE]),
47
47
  LEGACY_WIKI_SEED]);
48
- const isWholeFileSeed = (bytes) => WHOLE_FILE_SEEDS.has(seedHash(bytes));
48
+ export const isWholeFileSeed = (bytes) => WHOLE_FILE_SEEDS.has(seedHash(bytes));
49
49
 
50
50
  /** A folded store keeps these: the re-seed restores them, and their text never says "not folded". */
51
51
  const STORE_KEEPS = ['README.md', '.gitignore', '.own-writes.json'];
52
- const DRAFT_HEAD = '# User rules — draft\n\nNot active. The rule Rite applies decisions.\n';
52
+ const DRAFT_HEAD = '# User rules — draft\n\nNot active. The rule Rite or the console applies decisions.\n';
53
53
 
54
54
  /**
55
55
  * Claim `dest` with the finished bytes, or throw EEXIST: a rename would replace a file another
@@ -70,7 +70,7 @@ function claimFile(tmp, dest) {
70
70
  * `bytes` at `dest`, or nothing there: a short write fails on its temp name, never on `dest`.
71
71
  * `exclusive` is for a name the caller found free; without it the file is meant to be replaced.
72
72
  */
73
- function landFile(dest, bytes, { exclusive = false } = {}) {
73
+ export function landFile(dest, bytes, { exclusive = false } = {}) {
74
74
  mkdirSync(path.dirname(dest), { recursive: true });
75
75
  const tmp = `${dest}.${process.pid}.fold-tmp`;
76
76
  try {
@@ -297,7 +297,7 @@ function foldNotes(cfgDir, ctx) {
297
297
  }
298
298
  }
299
299
 
300
- const itemKey = (kind, host, bytes) => createHash('sha256').update(`${kind}\0${host}\0`).update(bytes).digest('hex');
300
+ export const itemKey = (kind, host, bytes) => createHash('sha256').update(`${kind}\0${host}\0`).update(bytes).digest('hex');
301
301
 
302
302
  /**
303
303
  * A block in the draft and a C7 record. The key names the host too, so two hosts holding the same
@@ -351,7 +351,7 @@ function foldWholeFile(kind, hostFiles, sharedFile, reseed, ctx) {
351
351
  }
352
352
 
353
353
  /** What makes two rules one (fold step 5): metadata and number do not. Line endings are already gone. */
354
- const ruleText = (r) => `${r.title}\n${r.body}`;
354
+ export const ruleText = (r) => `${r.title}\n${r.body}`;
355
355
 
356
356
  /**
357
357
  * A pending rule this host no longer holds waits for nothing: it merged, because another host's
@@ -392,8 +392,8 @@ function withoutRules(text, merged) {
392
392
  /**
393
393
  * Fold step 5. A rule the shared file holds word for word leaves the host file: it binds from
394
394
  * there. Any other goes to the draft and stays, so nothing stops binding before the user decides
395
- * (C8), and an approval needs no code here: the rule Rite puts it in the shared file, and the next
396
- * fold finds a duplicate. A rejected rule is the exception to the merge, because "keep it on this
395
+ * (C8), and an approval needs no code here: the rule Rite or the console (`rule-decide.mjs`) puts it
396
+ * in the shared file, and the next fold finds a duplicate. A rejected rule is the exception to the merge, because "keep it on this
397
397
  * host" holds even if the shared file later says the same.
398
398
  *
399
399
  * The old file is copied aside, not moved: the host file must exist at every moment, because the
@@ -0,0 +1,273 @@
1
+ /**
2
+ * THE DECISIONS ON THE DRAFT: what the fold left in `user-rules.draft.md`, applied as the rule
3
+ * Rite's approval flow says (src/skills/rule/approve.md). The console calls this; the Rite stays a
4
+ * written procedure, because an agent's write must pass the rule gate and a verb it could run would
5
+ * step around that prompt. So the two are held together by words: a change to one step here or there
6
+ * is a change to both, and `tests/unit/rule_decide.test.mjs` pins the formats they share.
7
+ *
8
+ * THE WRITE ORDER IS THE SAFETY: target file, ledger row, draft. A rule stays in force at every
9
+ * point, because nothing here touches a host's rule file: a stop leaves the rule bound from its
10
+ * host, and `settle` (the flow's step 2) or the next fold finishes the rest. A ledger that does not
11
+ * read fails before the first write.
12
+ *
13
+ * A POINTER IS DATA. An agent can write the draft past one prompt. So a `Rule from` block is
14
+ * decided only when its text hashes to its key, its ledger row is pending and it holds exactly one
15
+ * rule. A `Choose` block may only name a whole file by its own name, in its host's live config
16
+ * directory, compared as a string before any file call, so a forged path never reaches the disk.
17
+ * The shared side is always the tier's, whatever the block says. Nothing is deleted: a file that
18
+ * leaves goes to `archived-<file>/`.
19
+ *
20
+ * THE CHANGE REPORT SEES THESE WRITES (not Reject or Keep both: those touch only the unwatched
21
+ * draft and ledger), on purpose. The console's token is readable by anything on
22
+ * the machine, so a POST here proves no click, and logging it as Geneseed's own would let an agent
23
+ * blind the report. A false alarm on a real click is the safe direction, and the line names it.
24
+ */
25
+ import { copyFileSync, readFileSync, realpathSync } from 'node:fs';
26
+ import path from 'node:path';
27
+
28
+ import { HOSTS } from '../hosts/hosts.mjs';
29
+ import { readMaybe } from '../hosts/installs.mjs';
30
+ import { archiveStore, parseDraft, parseRules, readFoldState } from '../hosts/memory-files.mjs';
31
+ import { isFile, writeTextAtomic } from '../lib/fs.mjs';
32
+ import { jsonDumpsIndent } from '../lib/json.mjs';
33
+ import { WIKI_NAMES } from '../lib/machine-dir.mjs';
34
+ import { normcase } from '../lib/paths.mjs';
35
+ import { isWholeFileSeed, itemKey, landFile, ruleText } from './fold.mjs';
36
+
37
+ /** Where a retired rule goes: beside its `user-rules.md`, never loaded. */
38
+ export const RETIRED_RULES_FILE = 'user-rules-retired.md';
39
+
40
+ export const RULE_DECISIONS = ['approve', 'reject'];
41
+ export const CHOICE_DECISIONS = ['host', 'shared', 'both'];
42
+
43
+ const RENUMBERED = '## Renumbered';
44
+ const RULE_POINTER = /^\(source: .* \| old: R(\d+) \| sha256: \w+\)$/;
45
+ const CHOICE_POINTER = /^\(hosts: shared, (.+?) \| paths: (.*) \| sha256: \w+\)$/;
46
+ /** Where a block starts. A rule body holds no `## ` line (`settleRules` in fold.mjs says why). */
47
+ const pieces = (text) => text.split(/^(?=## )/m);
48
+
49
+ /** A host's live config directory, or null. `configDir` throws with no home directory. */
50
+ function configDirOf(host) {
51
+ try { return HOSTS.find((h) => h.host === host)?.configDir() ?? null; } catch { return null; }
52
+ }
53
+
54
+ /** Is `dir` that directory? Strings only: `dir` comes from the draft, and may name a share. */
55
+ const isConfigDir = (dir, host) => {
56
+ const cfg = configDirOf(host);
57
+ return cfg !== null && normcase(path.resolve(dir)) === normcase(path.resolve(cfg));
58
+ };
59
+
60
+ /** A `Choose` block's facts, or nothing when its pointer does not name a whole file. */
61
+ function choiceFacts(pointer, title, shared) {
62
+ const m = CHOICE_POINTER.exec(pointer);
63
+ const file = title.slice('Choose: '.length);
64
+ const whole = new Map([['PROFILE.md', ['profile', shared.profile, ['PROFILE.md']]],
65
+ [path.basename(shared.wiki), ['wiki', shared.wiki, WIKI_NAMES]]]).get(file);
66
+ if (!m || !whole) return {};
67
+ const [, chooser, paths] = m;
68
+ const at = paths.indexOf(`${file}, `);
69
+ const spelled = at < 0 ? '' : paths.slice(at + file.length + 2);
70
+ // Resolved, so a `sub/../` spelling cannot pass the compare and then walk a link on POSIX.
71
+ const hostFile = spelled && path.resolve(spelled);
72
+ const [kind, sharedFile, names] = whole;
73
+ const trusted = names.includes(path.basename(hostFile)) && isConfigDir(path.dirname(hostFile), chooser);
74
+ return trusted ? { file, chooser, kind, sharedFile, hostFile } : {};
75
+ }
76
+
77
+ /** The draft's blocks: `parseDraft`'s fields, the block's own text, and its pointer's facts. */
78
+ function blocksOf(text, shared) {
79
+ return pieces(text).flatMap((piece) => {
80
+ const [b] = parseDraft(piece);
81
+ if (!b) return [];
82
+ const pointer = piece.split('\n')[1]?.trim() ?? '';
83
+ if (!b.host) return [{ ...b, piece, ...choiceFacts(pointer, b.title, shared) }];
84
+ const m = RULE_POINTER.exec(pointer);
85
+ return [{ ...b, piece, ...(m ? { old: m[1] } : {}) }];
86
+ });
87
+ }
88
+
89
+ /**
90
+ * A `Rule from` block as the fold compares rules: its metadata and number do not count. Null unless
91
+ * it reads as exactly one rule: a `##\u00a0R900` line would raise a second one nobody was shown.
92
+ */
93
+ function blockRule(b) {
94
+ const [rules] = parseRules(`## R0 — ${b.title}\n${b.body}\n`);
95
+ return rules.length === 1 ? ruleText(rules[0]) : null;
96
+ }
97
+
98
+ /** The ledger row of `key`: a key is draft text, so `constructor` must not read as a row. */
99
+ const rowOf = (items, key) => (Object.hasOwn(items, key) ? items[key] : undefined);
100
+
101
+ /** The shared file's rules, as `ruleText -> number`. */
102
+ const heldRules = (shared) => new Map(parseRules(readMaybe(shared.rules) ?? '')[0].map((r) => [ruleText(r), r.id]));
103
+
104
+ /**
105
+ * Does a `Choose` block no longer ask anything (the flow's step 2)? An absent or seed shared file
106
+ * counts: there is nothing to choose, and *Use the shared file* would keep a seed over the user's
107
+ * text. The next fold moves the host file up.
108
+ */
109
+ function staleChoice(b) {
110
+ if (!isFile(b.hostFile) || !isFile(b.sharedFile)) return true;
111
+ const bytes = readFileSync(b.hostFile);
112
+ const held = readFileSync(b.sharedFile);
113
+ return isWholeFileSeed(bytes) || isWholeFileSeed(held) || held.equals(bytes)
114
+ || itemKey(b.kind, b.chooser, bytes) !== b.key;
115
+ }
116
+
117
+ const renumberedLine = (b, id) => `- ${b.host} R${b.old} -> R${id}: ${b.title}`;
118
+
119
+ /**
120
+ * The draft without `drop`, with `lines` under its `## Renumbered` heading. The heading can sit
121
+ * anywhere, because the fold appends after it. One write, so the record and the delete cannot part.
122
+ */
123
+ function rewritten(text, drop, lines = []) {
124
+ const kept = pieces(text).filter((p) => !drop.some((b) => b.piece === p));
125
+ const fresh = lines.filter((l) => !text.includes(l));
126
+ if (!fresh.length) return kept.join('');
127
+ const at = kept.findIndex((p) => p.startsWith(RENUMBERED));
128
+ if (at < 0) return `${kept.join('').replace(/\n+$/, '')}\n\n${RENUMBERED}\n${fresh.join('\n')}\n`;
129
+ const body = kept[at].replace(/\n+$/, '');
130
+ kept[at] = `${body}\n${fresh.join('\n')}${kept[at].slice(body.length) || '\n'}`;
131
+ return kept.join('');
132
+ }
133
+
134
+ const saveLedger = (shared, state, io) => io.text(shared.foldState, `${jsonDumpsIndent(state)}\n`);
135
+
136
+ /**
137
+ * The flow's step 2: finish what a stop left, and clear what no longer asks. A block the ledger
138
+ * already decided goes, its row stays, and an approved rule gets its `## Renumbered` line if the
139
+ * shared file still holds it. A stale `Choose` block goes with its row: the next fold asks about
140
+ * the current text. Row first, because this walk starts from the blocks: a block left without a row
141
+ * is found again, and a row left without a block would count as pending for ever.
142
+ */
143
+ function settle(shared, io) {
144
+ const text = readMaybe(shared.draft) ?? '';
145
+ const state = readFoldState(shared);
146
+ const held = heldRules(shared);
147
+ const drop = [];
148
+ const lines = [];
149
+ let rowsGone = false;
150
+ for (const b of blocksOf(text, shared)) {
151
+ const row = rowOf(state.items, b.key);
152
+ if (row && row.state !== 'pending') {
153
+ const id = held.get(b.host ? blockRule(b) : null);
154
+ if (row.state === 'approved' && b.old && id !== undefined) lines.push(renumberedLine(b, id));
155
+ drop.push(b);
156
+ } else if (b.hostFile && staleChoice(b)) {
157
+ delete state.items[b.key];
158
+ rowsGone = true;
159
+ drop.push(b);
160
+ }
161
+ }
162
+ if (!drop.length) return [];
163
+ if (rowsGone) saveLedger(shared, state, io);
164
+ io.text(shared.draft, rewritten(text, drop, lines));
165
+ return drop.map((b) => b.title);
166
+ }
167
+
168
+ /**
169
+ * One above the highest number in the shared file and in each retired file: the tier's and each
170
+ * host's. A host keeps its own retired rules, and a retired number is never reused. A block's
171
+ * `source` is read by nobody: the fold drafts only from these same directories, and a forged one
172
+ * would have this read reach wherever it points.
173
+ */
174
+ function nextRuleId(shared) {
175
+ const retired = [shared.root, ...HOSTS.map((h) => configDirOf(h.host)).filter(Boolean)]
176
+ .map((dir) => path.join(dir, RETIRED_RULES_FILE));
177
+ const ids = [shared.rules, ...retired].flatMap((f) => parseRules(readMaybe(f) ?? '')[0].map((r) => r.id));
178
+ return Math.max(0, ...ids) + 1;
179
+ }
180
+
181
+ /** `ok: false` as the rule routes answer it: the client reloads. */
182
+ const conflict = (detail, cleared) => ({ ok: false, error: 'conflict', detail, cleared });
183
+
184
+ /** The target file's write for a `Choose` decision. */
185
+ function applyChoice(b, decision, io) {
186
+ if (decision === 'both') return;
187
+ if (decision === 'shared') {
188
+ archiveStore(b.hostFile);
189
+ return;
190
+ }
191
+ const bytes = readFileSync(b.hostFile);
192
+ if (itemKey(b.kind, b.chooser, bytes) !== b.key) throw new Error(`${b.hostFile} changed just now`);
193
+ archiveStore(b.sharedFile, copyFileSync);
194
+ io.bytes(b.sharedFile, bytes);
195
+ }
196
+
197
+ function applyDecision(shared, key, decision, io, cleared) {
198
+ const text = readMaybe(shared.draft) ?? '';
199
+ const b = blocksOf(text, shared).find((x) => x.key === key);
200
+ if (!b) return conflict('That item is no longer in the draft.', cleared);
201
+ const state = readFoldState(shared);
202
+ const allowed = decisionsOf(b, heldRules(shared), state.items);
203
+ if (!allowed.includes(decision)) return conflict(`"${decision}" does not decide this item.`, cleared);
204
+ const lines = [];
205
+ let id;
206
+ if (decision === 'approve') {
207
+ id = nextRuleId(shared);
208
+ const base = (readMaybe(shared.rules) ?? '# User rules\n').replace(/\n+$/, '');
209
+ io.text(shared.rules, `${base}\n\n## R${id} — ${b.title}\n${b.body}\n`);
210
+ lines.push(renumberedLine(b, id));
211
+ } else if (b.hostFile) applyChoice(b, decision, io);
212
+ const kept = decision === 'reject' || decision === 'both';
213
+ state.items[key] = { ...state.items[key], kind: b.kind ?? 'rule', host: b.host ?? b.chooser,
214
+ state: kept ? 'rejected' : 'approved' };
215
+ saveLedger(shared, state, io);
216
+ io.text(shared.draft, rewritten(text, [b], lines));
217
+ return { ok: true, decision, key, id, rebuild: !kept, cleared };
218
+ }
219
+
220
+ /**
221
+ * What may decide a block now. Only what the fold drafted: a pending row, and for a rule its text
222
+ * hashing to its key. None for a rule the shared file already holds, which the next fold clears.
223
+ */
224
+ function decisionsOf(b, held, items) {
225
+ if (!b.key || rowOf(items, b.key)?.state !== 'pending') return [];
226
+ if (!b.host) return b.hostFile ? CHOICE_DECISIONS : [];
227
+ const rule = blockRule(b);
228
+ return b.old && rule !== null && itemKey('rule', b.host, rule) === b.key && !held.has(rule) ? RULE_DECISIONS : [];
229
+ }
230
+
231
+ /** `f` with its links resolved, so a tier file linked into a dotfiles repo stays a link. */
232
+ function through(f) {
233
+ try { return realpathSync.native(f); } catch { return f; }
234
+ }
235
+
236
+ /**
237
+ * Decide one item. Never throws for a failed step: it answers `ok: false`, and the steps already
238
+ * written stand, which is the state the flow's step 2 finishes. `io` is the two writers, so a test
239
+ * can fail each write in turn.
240
+ */
241
+ export function decideItem(shared, key, decision, io = {
242
+ text: (f, t) => writeTextAtomic(through(f), t),
243
+ bytes: (f, b) => landFile(through(f), b),
244
+ }) {
245
+ try {
246
+ return applyDecision(shared, key, decision, io, settle(shared, io));
247
+ } catch (e) {
248
+ return { ok: false, error: 'failed', detail: `The decision stopped: ${e.message}. The rule stays in force.` };
249
+ }
250
+ }
251
+
252
+ /**
253
+ * The draft as the console shows it: each block, with what may decide it and, for a `Choose`, both
254
+ * files' text, since the user picks between them.
255
+ */
256
+ export function draftItems(shared) {
257
+ const held = heldRules(shared);
258
+ let items = {};
259
+ try { items = readFoldState(shared).items; } catch { /* no ledger to read: nothing is decidable */ }
260
+ return blocksOf(readMaybe(shared.draft) ?? '', shared).map((b) => ({
261
+ title: b.title, host: b.host, body: b.body, key: b.key, decisions: decisionsOf(b, held, items),
262
+ ...(b.host && held.has(blockRule(b)) ? { held: true } : {}),
263
+ ...(b.hostFile ? { choice: { file: b.file, host: b.chooser, shared_path: b.sharedFile, host_path: b.hostFile,
264
+ shared_text: readMaybe(b.sharedFile), host_text: readMaybe(b.hostFile) } } : {}),
265
+ }));
266
+ }
267
+
268
+ /** Every text a decision rests on, for the fingerprint its POST must send back. */
269
+ export function decisionState(shared) {
270
+ const text = readMaybe(shared.draft) ?? '';
271
+ const files = blocksOf(text, shared).filter((b) => b.hostFile).flatMap((b) => [b.sharedFile, b.hostFile]);
272
+ return [text, ...[shared.rules, ...files].map((f) => readMaybe(f) ?? '')].join('\0');
273
+ }
package/js/cli-table.json CHANGED
@@ -1148,7 +1148,7 @@
1148
1148
  },
1149
1149
  {
1150
1150
  "name": "migrate",
1151
- "help": "move this machine from the git-checkout install shape to the npm one: re-emit every registered install, repoint the hook shim at the npm package, and report what must be fixed by hand. Use --dry-run alone to preview the shared-tier fold",
1151
+ "help": "move this machine from the git-checkout install shape to the npm one: run from the npm package, it re-emits every registered install, which points the hook shim at that package, and reports what must be fixed by hand. A git clone or a bundle is refused with exit 3. Use --dry-run alone, from anywhere, to preview the shared-tier fold",
1152
1152
  "description": "",
1153
1153
  "positionals": [],
1154
1154
  "options": [
@@ -281,7 +281,7 @@ export function pendingDrafts() {
281
281
  /** The session's reminder of them, or null. The OpenCode context plugin's `draftLine` is its twin. */
282
282
  function draftLine() {
283
283
  const n = pendingDrafts();
284
- return n ? `[drafts] ${n} drafted item${n === 1 ? '' : 's'} in user-rules.draft.md wait${n === 1 ? 's' : ''} for the user's decision (the rule skill).` : null;
284
+ return n ? `[drafts] ${n} drafted item${n === 1 ? '' : 's'} in user-rules.draft.md wait${n === 1 ? 's' : ''} for the user's decision (the rule skill or the web console).` : null;
285
285
  }
286
286
 
287
287
  /**
@@ -617,9 +617,9 @@ export function openclaudeDualHarnessRoots() {
617
617
  }
618
618
 
619
619
  /** (host, scope, root) for every registered root. */
620
- export function registeredTargets() {
620
+ export function registeredTargets(opts) {
621
621
  const out = [];
622
- for (const root of registryRoots()) {
622
+ for (const root of registryRoots(opts)) {
623
623
  const hs = emitHostScopeOf(root);
624
624
  if (hs) out.push([hs[0], hs[1], root]);
625
625
  }
@@ -637,7 +637,7 @@ export function registeredTargets() {
637
637
  * `Path.resolve()` returns the filesystem's own casing — on Windows two spellings of the same
638
638
  * directory differ as strings and not as installs, and this Set is keyed by string.
639
639
  */
640
- export function installTargets() {
640
+ export function installTargets(opts) {
641
641
  const out = [];
642
642
  const seen = new Set();
643
643
 
@@ -664,7 +664,7 @@ export function installTargets() {
664
664
  for (const { host, configDir } of HOSTS) {
665
665
  try { add(host, 'global', configDir()); } catch { /* a missing host dir is not fatal */ }
666
666
  }
667
- for (const [host, scope, root] of registeredTargets()) add(host, scope, root);
667
+ for (const [host, scope, root] of registeredTargets(opts)) add(host, scope, root);
668
668
  return out;
669
669
  }
670
670
 
@@ -564,8 +564,8 @@ export function parseRules(text) {
564
564
  return [rules, warnings];
565
565
  }
566
566
 
567
- // The draft's block headings: the fold writes them, `parseDraft` reads them, and the rule Rite's
568
- // approval flow (src/skills/rule/approve.md) names them, so a change here changes that file too.
567
+ // The draft's block headings: the fold writes them, `parseDraft` reads them, and the approval flow
568
+ // (src/skills/rule/approve.md, js/build/rule-decide.mjs) names them, so a change here changes both.
569
569
  export const draftRuleHead = (host, title) => `## Rule from ${host}: ${title}`;
570
570
  export const draftChoiceHead = (file) => `## Choose: ${file}`;
571
571
  const DRAFT_RULE_RE = /^## Rule from ([^:]+): (.+)$/;