geneseed 4.29.0 → 4.30.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 (39) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/SHIPPED.md +1 -1
  3. package/adapters/opencode/plugins/geneseed-activity.js +22 -20
  4. package/docs/concepts/hooks.md +1 -1
  5. package/docs/concepts/ownership.md +3 -3
  6. package/docs/guides/set-up-ownership.md +1 -1
  7. package/docs/reference/plugin-activity.md +1 -1
  8. package/docs/web-ui.md +21 -0
  9. package/harness.config.json +1 -1
  10. package/js/README.md +3 -3
  11. package/js/hosts/hooks.mjs +6 -4
  12. package/js/web/actions.mjs +31 -0
  13. package/js/web/handler.mjs +35 -11
  14. package/js/web/routes.mjs +27 -6
  15. package/js/web/state.mjs +22 -2
  16. package/package.json +1 -1
  17. package/src/skills/_checkpoints.md +13 -3
  18. package/src/skills/learn-mode.md +11 -11
  19. package/src/skills/ownership.md +19 -18
  20. package/web/dist/assets/{Activity-DfETiyWm.js → Activity-C8pQvnos.js} +1 -1
  21. package/web/dist/assets/{ActivityDetail-CnP3GPAN.js → ActivityDetail-D_8Bx-QO.js} +1 -1
  22. package/web/dist/assets/{CopyButton-CRAUXSG7.js → CopyButton-CYljsnLo.js} +1 -1
  23. package/web/dist/assets/{Dashboard-CaqOqtkG.js → Dashboard-DkUm4XMu.js} +2 -2
  24. package/web/dist/assets/{Docs-BFxyAVdN.js → Docs-DE04qOKj.js} +1 -1
  25. package/web/dist/assets/{GreenhouseView-19roNb5W.js → GreenhouseView-DPwhFO_j.js} +1 -1
  26. package/web/dist/assets/{Installs-BSoQN7w7.js → Installs-DmPzD4BW.js} +1 -1
  27. package/web/dist/assets/{JournalView-BgU2ybaq.js → JournalView-DQlDC-7i.js} +1 -1
  28. package/web/dist/assets/{KitApply-Ckc0P5kt.js → KitApply-BN2Az7dc.js} +1 -1
  29. package/web/dist/assets/{Kits-BZqWGWMu.js → Kits-C9qVd466.js} +1 -1
  30. package/web/dist/assets/{Laws-CnUWiNIx.js → Laws-T2wbwMmB.js} +1 -1
  31. package/web/dist/assets/{Library-rYO8owx_.js → Library-t3KocV0-.js} +1 -1
  32. package/web/dist/assets/{Loops-CljFhhQV.js → Loops-6lNY-9uR.js} +1 -1
  33. package/web/dist/assets/{OperatorHudView-xs7SCwCe.js → OperatorHudView-CLN6Qn25.js} +1 -1
  34. package/web/dist/assets/{Personal-CMPwtl36.js → Personal-xjoSqCzr.js} +1 -1
  35. package/web/dist/assets/{Tabs-CEfSUVQp.js → Tabs-DaExAgql.js} +1 -1
  36. package/web/dist/assets/api-LvBC0CnK.js +1 -0
  37. package/web/dist/assets/{index-FLVXXvV3.js → index-DhNNxhfg.js} +3 -3
  38. package/web/dist/index.html +2 -2
  39. package/web/dist/assets/api-BfpZmUMI.js +0 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,33 @@ label. For the capability ↔ spec map, see [SHIPPED.md](SHIPPED.md).
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [4.30.1] — 2026-10-31
12
+
13
+ Patch: Bob can read a protected check again (a regression in 4.29.0 and 4.30.0). Run `geneseed rebuild-all` once after updating.
14
+
15
+ ### Changed
16
+ - **The web console: each request may name its install.** Reads take `?host=&path=` and install-scoped writes take `{host, path}`, so a page that picks its own install no longer re-points every other page through one shared viewed install. A request without the pair still uses the viewed install, and an unknown pair is refused (404). No page names its install yet, so nothing changes on screen.
17
+
18
+ ### Fixed
19
+ - **Bob can read a protected check again.** Bob runs the gate on every tool, reads included, and since 4.29.0 a project emit seeds `.geneseed/protected-checks.txt` with the manifests, CI files and lint/test config. The gate refused every Bob read of those files, `package.json` included; now only a Bob write to a protected check, the list or `.geneseed/done-checks.txt` is blocked. A write is told by its tool name (`write`, `edit`, `diff`, `replace`, `insert`), the same rule the gate-configuration check already used.
20
+
21
+ ## [4.30.0] — 2026-10-31
22
+
23
+ Minor: the ownership and learn-mode state files stay short (general preferences, no per-checkpoint writes), and OpenCode activity cards land on their own repo shelf. Run `geneseed rebuild-all` once after updating to get the new Rite text.
24
+
25
+ ### Changed
26
+
27
+ - **The learn-mode and ownership state files stay short.** `.geneseed/ownership.md` and `.geneseed/learn.md` lose `## Pending`: the open checkpoint lives in the conversation, nothing is written per checkpoint, and after a restart or compaction the agent re-asks any step the visible conversation did not approve. The dated `## Decisions` log becomes `## Preferences`: general rules ("show the test first"), rewritten in place, about 10 lines at most, proposed only when the user states a rule generally or makes the same choice a third time in a session, and always asked. In ownership, a rule about the code is proposed as a one-line `AGENTS.md` convention instead. learn-mode's `## Understood` becomes one line per topic with a `not yet:` part, about 15 lines at most. An old-format file is condensed only on the user's yes.
28
+
29
+ ### Fixed
30
+ - **OpenCode activity cards land on their own repo shelf.** The activity plugin took `root`
31
+ and `repo` from its plugin instance's worktree. One `opencode serve` hosts an instance per
32
+ opened project, and every instance hears every session, so each stamped its own root on
33
+ all of them: a session in `~/dev-home` showed under another project, a card flipped between
34
+ roots, and files lost their repo-relative paths and dropped out of collision grouping. Both
35
+ OpenCode 1 and 2 now read the root from the session's own directory (`null` outside any
36
+ repository).
37
+
11
38
  ## [4.29.0] — 2026-10-29
12
39
 
13
40
  Minor: the done gate works with no file (inferred checks, advisory in this release) and no longer passes a masked check; a project install arms the protected-checks gate; the gates protect their own configuration; ownership can be declined per repo; two new skills (`adhd`, `diagram-design`). Run `geneseed rebuild-all` once after updating to seed `protected-checks.txt` in existing project installs and to pick up the new gate configuration.
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: **4.29.0**.
23
+ > string. Current label: **4.30.1**.
24
24
 
25
25
  ## Capabilities
26
26
 
@@ -21,8 +21,8 @@
21
21
  // distil sessions are skipped entirely, and so is a child whose parent this process does not
22
22
  // track.
23
23
  //
24
- // Snapshot v2 (the Activity garden) adds `files[].path` and `files[].by`, `root` (OpenCode's
25
- // own worktree), `repo` (its main checkout), `agents`, `turns`, `context` and the compaction
24
+ // Snapshot v2 (the Activity garden) adds `files[].path` and `files[].by`, `root` (the git root
25
+ // of the session's own directory), `repo` (its main checkout), `agents`, `turns`, `context` and the compaction
26
26
  // trio — see docs/reference/opencode-plugins.md.
27
27
  //
28
28
  // v1.1 enriches each entry from events/fields it already receives or one `case` away:
@@ -134,8 +134,8 @@ function acctTotals(map, msgId, cost, tokens) {
134
134
  return { cost: c, tokens: t }
135
135
  }
136
136
 
137
- // Where a FileDiff's file is, for the garden: OpenCode's own path (relative to the worktree,
138
- // `/`-separated) when there is a root, else null — as for anything that would leave the root
137
+ // Where a FileDiff's file is, for the garden: OpenCode's own path (relative to the session's
138
+ // checkout, `/`-separated) when the session has a root, else null — as for anything that would leave the root
139
139
  // or is absolute (`../`, `/`, a drive, a UNC path). Never an absolute path on disk, and never
140
140
  // a basename in `path`, where it would collide with a same-named file at the top of the repo.
141
141
  function relPath(file, root) {
@@ -235,13 +235,14 @@ function mainWorktreeOf(cwd) {
235
235
  }
236
236
  }
237
237
 
238
- // `root` from OpenCode's own worktree: V1 passes the checkout's top level (a linked worktree
239
- // is its own root), or "/" for a project outside a repository — as is the drive root a
240
- // global project resolves to, so a filesystem root is no root. `repo` is the main checkout,
241
- // the root itself on a main checkout.
242
- function rootsOf(worktree) {
243
- if (typeof worktree !== "string" || !worktree) return { root: null, repo: null }
244
- const root = path.resolve(worktree)
238
+ // `top` is the git root above the SESSION's own directory (gitRootOf), or null outside any
239
+ // repository — never the plugin instance's worktree: one `opencode serve` hosts an instance per
240
+ // opened project, every instance hears every session, and each would otherwise stamp its own
241
+ // root on all of them. `root` is that top level (a linked worktree is its own root); a
242
+ // filesystem root is no root. `repo` is the main checkout, the root itself on a main checkout.
243
+ function rootsOf(top) {
244
+ if (typeof top !== "string" || !top) return { root: null, repo: null }
245
+ const root = path.resolve(top)
245
246
  if (root === path.parse(root).root) return { root: null, repo: null }
246
247
  return { root, repo: mainWorktreeOf(root) ?? root }
247
248
  }
@@ -316,8 +317,8 @@ function removeDetail(sid) { try { fs.unlinkSync(detailPath(sid)) } catch {} }
316
317
 
317
318
  // --- plugin ------------------------------------------------------------------
318
319
 
319
- export const GeneseedActivity = async (input) => {
320
- const { root, repo } = rootsOf(input?.worktree) // once: one OpenCode instance, one worktree
320
+ // `input` (V1's worktree) is not read: root/repo are per session (see rootsOf).
321
+ export const GeneseedActivity = async (_input) => {
321
322
  const owned = new Map() // sid -> entry (top-level sessions this process tracks)
322
323
  const skipped = new Set() // sid -> geneseed throwaway / orphan child, ignored from here on
323
324
  const childOf = new Map() // child sid -> the owned root session it is a sub-agent of
@@ -366,12 +367,13 @@ export const GeneseedActivity = async (input) => {
366
367
  }
367
368
  const wideDiff = (sid, list) => {
368
369
  if (!Array.isArray(list) || !owned.has(sid)) return false
369
- detFor(sid).wideDiff = list.map((d) => slimDiff(d, null, root))
370
+ detFor(sid).wideDiff = list.map((d) => slimDiff(d, null, owned.get(sid).root))
370
371
  return !detFor(sid).turnDiffs.size // write only when it is the source in force
371
372
  }
372
373
  // A turn's diff list (user message `id` of session `owner`; `by` the child that ran it).
374
+ // Paths are relative to the owner's root: a sub-agent works in its parent's checkout.
373
375
  const turnDiff = (owner, id, list, by) => {
374
- detFor(owner).turnDiffs.set(id, list.map((d) => slimDiff(d, by, root)))
376
+ detFor(owner).turnDiffs.set(id, list.map((d) => slimDiff(d, by, owned.get(owner)?.root ?? null)))
375
377
  }
376
378
  const agentsOf = (sid) => { let m = agentRows.get(sid); if (!m) { m = new Map(); agentRows.set(sid, m) } return m }
377
379
  // Create or update a sub-agent row of `owner`; writes only on a change.
@@ -537,7 +539,7 @@ export const GeneseedActivity = async (input) => {
537
539
  }
538
540
  if (event.type !== "session.created" && !owned.has(sid)) return
539
541
  const ev = { type: event.type, title: info.title ?? null, cwd: info.directory }
540
- if (!owned.has(sid)) Object.assign(ev, { root, repo, agents: [], turns: 0, context: null,
542
+ if (!owned.has(sid)) Object.assign(ev, { ...rootsOf(info.directory && gitRootOf(info.directory)), agents: [], turns: 0, context: null,
541
543
  compactions: 0, compacted_at: null, context_at_compaction: null })
542
544
  // A session summary is a files source only when it carries diffs (see setFiles):
543
545
  // 1.19 sends it zeroed on every step, which must not wipe the card.
@@ -804,13 +806,13 @@ function toV1Events(ev, tools) {
804
806
  }
805
807
 
806
808
  async function setupV2(ctx) {
807
- // V2 passes no worktree path (ctx.worktree is the worktree API), so the root is the
808
- // checkout's top level above the instance directory, read off disk like V1's input. Step
809
- // files are relative to the same tree (core snapshot.ts: git.repo.discover on
809
+ // As on V1, each session's root is the checkout's top level above its own directory
810
+ // (session.created's `location.directory`, carried by toV1Events), never this instance's.
811
+ // Step files are relative to the same tree (core snapshot.ts: git.repo.discover on
810
812
  // location.project.directory, which project.ts resolves from the nearest `.git` above the
811
813
  // directory), but OpenCode takes its realPath: through a symlinked path the two spellings
812
814
  // of the root differ, while the relative file paths do not.
813
- const hooks = await GeneseedActivity({ worktree: gitRootOf(ctx?.location?.directory) })
815
+ const hooks = await GeneseedActivity()
814
816
  const tools = new Map()
815
817
  // The user's prompt, as V1's chat.message hook received it.
816
818
  await ctx.session.hook("prompt", async (event) => {
@@ -30,7 +30,7 @@ Every hook above also feeds the [Activity view](../reference/plugin-activity.md)
30
30
 
31
31
  What that file holds for the Activity garden:
32
32
  - **Files.** Each changed file is stored relative to the session's git root, with `/` separators. A file outside the root, or a session outside any repo, gets no path (`path: null`) and keeps only its basename, so it never matches a file of the same name inside the repo. A path is never stored absolute. Each file also records who changed it: the session, or the subagent's `agent_id`.
33
- - **Where the session runs.** `root` is the worktree's git root and `repo` is the main repository's root, so the linked worktrees of one repo can be grouped together. Only the session's own events set them; a subagent working in another worktree does not move them.
33
+ - **Where the session runs.** `root` is the git root of the checkout holding the session's own directory and `repo` is that checkout's main repository root, so the linked worktrees of one repo can be grouped together. Only the session's own events set them; a subagent working in another worktree does not move them.
34
34
  - **Subagents.** `agents` lists each subagent with its type and `running` or `done`.
35
35
  - **Turns and context.** `turns` counts your prompts. `context` is the size of the context now, taken from the transcript's last assistant message. The window size is an estimate: 200k, or 1M once the context is past 200k.
36
36
  - **Compactions.** `compactions`, `compacted_at` and `context_at_compaction` record each compaction (on `PreCompact`). After a compaction, `context` is unknown (`null`) until the next `Stop` reads it again. Claude Code's `<synthetic>` messages and messages with no input-side tokens never change it.
@@ -30,7 +30,7 @@ sensitive: # always a checkpoint, whatever the granularity
30
30
  - src/main/resources/db/migration/**
31
31
  ```
32
32
 
33
- The rest of `AGENTS.md` holds the project's coding rules: conventions, build and test commands, project rules. Each developer's own state — a finer granularity, the pending checkpoint, the log of decisions — lives in `.geneseed/ownership.md`. That file is created only when there is such state to keep, and no file means the team granularity, nothing pending and no decisions. It is never committed: from its first write, `.geneseed/` gets a `.gitignore` that ignores everything in it except the team's files — the `.gitignore` itself, `bricks/`, `loops/`, `protected-checks.txt` and `done-checks.txt`. [Set up ownership](../guides/set-up-ownership.md) walks through the setup, which writes `AGENTS.md` only.
33
+ The rest of `AGENTS.md` holds the project's coding rules: conventions, build and test commands, project rules. Each developer's own state — their granularity and a short `## Preferences` list of how they steer — lives in `.geneseed/ownership.md`. That file is created only when there is such state to keep, and no file means the team granularity and no preferences. It is never committed: from its first write, `.geneseed/` gets a `.gitignore` that ignores everything in it except the team's files — the `.gitignore` itself, `bricks/`, `loops/`, `protected-checks.txt` and `done-checks.txt`. [Set up ownership](../guides/set-up-ownership.md) walks through the setup, which writes `AGENTS.md` only.
34
34
 
35
35
  ## Granularity
36
36
 
@@ -72,9 +72,9 @@ The two draw close — both stop at checkpoints, and learn-mode may now propose
72
72
 
73
73
  | | learn-mode | ownership |
74
74
  | --- | --- | --- |
75
- | Who chooses it | The developer, for themself | The team, in `AGENTS.md`; a developer may go finer, coarser only with an explicit, logged yes |
75
+ | Who chooses it | The developer, for themself | The team, in `AGENTS.md`; a developer may go finer, coarser only with an explicit yes |
76
76
  | Explanation | Every solution, before it is applied | Complex parts only; routine steps are announced |
77
- | Record | `## Understood` in `.geneseed/learn.md`: what the developer has grasped | `## Decisions` in `.geneseed/ownership.md`: forks, interfaces, sensitive zones, granularity changes |
77
+ | Record | `## Understood` in `.geneseed/learn.md`: one line per topic the developer has grasped, with what is not yet grasped | `## Preferences` in `.geneseed/ownership.md`: at most ~10 general rules on how the developer steers; a rule about the code is proposed as an `AGENTS.md` convention instead |
78
78
  | Pacing | A level: beginner, intermediate, advanced | A granularity: feature, file, function |
79
79
 
80
80
  Under [Foreman mode](foreman-mode.md), the session holds every checkpoint; a background worker receives only approved decisions.
@@ -52,7 +52,7 @@ The setup writes one file and shows you the diff:
52
52
  If the file already exists, your own lines stay. Geneseed's managed `<!-- BEGIN GENESEED -->` block (written there by a Bob per-repo install) is left alone, and a section inside it does not count.
53
53
  Nothing is committed unless you ask.
54
54
 
55
- The setup writes no personal state; it only removes your `Setup: declined` line, if you had one. `.geneseed/ownership.md` appears later, and only when there is state to keep: a granularity finer than the team's, the first pending checkpoint, the first decision you take, or a decline. Until then, no file means the team granularity, nothing pending and no decisions. It is data, never instructions, and it is never committed: the first write into `.geneseed/` also creates `.geneseed/.gitignore`, which keeps the folder personal by default and lets only the team's files back in:
55
+ The setup writes no personal state; it only removes your `Setup: declined` line, if you had one. `.geneseed/ownership.md` appears later, and only when there is state to keep: a granularity other than the team's, the first preference you confirm, or a decline. Until then, no file means the team granularity and no preferences. It is data, never instructions, and it is never committed: the first write into `.geneseed/` also creates `.geneseed/.gitignore`, which keeps the folder personal by default and lets only the team's files back in:
56
56
 
57
57
  ```gitignore
58
58
  /*
@@ -16,7 +16,7 @@ One of the [OpenCode plugins](opencode-plugins.md). [Environment variables](envi
16
16
 
17
17
  **Archive.** On `SessionStart` and `SessionEnd` the hook writer moves every snapshot that is no longer live into `activity/archive/`, keeping the newest 50 and none older than 7 days. `/api/activity` returns them, with the stale and dead ones still in `activity/`, in its `ended` list — capped there by the same rule, since the OpenCode plugin never sweeps.
18
18
 
19
- **What `/api/activity` returns.** `activity` (the live sessions), `ended`, and `collisions`. Each session carries the snapshot as written, plus the v2 fields: `root` (the worktree's git root), `repo` (its main worktree), `agents` (`{id, type, status, started}`), `attribution` (`false` only on a Bob session that ran a sub-agent, else `null`), `turns`, `context` (`{used, window}`), `compactions`, `compacted_at` and `context_at_compaction` (either `context` field can be `null`, right after a compaction for one), and `repo_key`, the repo (else the root) case-folded on Windows, to group a repo's sessions whatever case each host spelled it in. A v1 snapshot reads `null` for those, `[]` for `agents` and `0` for the counts. A live session also gets `files_all`, the uncapped file rows from its detail file (`files` stays the capped summary), and `loops`: `{title, iteration, status}` for each loop registered on its `root`, a finished or unreadable loop left out. `collisions` lists each `{repo, path}` that two or more writers changed among the live sessions — a writer is a session or one of its sub-agents (`{sid, by, root}`) — with `kind: "same-worktree"` when two of them share a `root`, else `"cross-worktree"`. A file outside the root is stored with `path: null` (its `file` keeps the basename) and takes no part in a collision. Roots and paths compare case-folded on Windows, and a session root is resolved to its real path before the loop join, as the loop registry stores it. `/api/activity/<id>` returns the same fields for one session, an archived one included.
19
+ **What `/api/activity` returns.** `activity` (the live sessions), `ended`, and `collisions`. Each session carries the snapshot as written, plus the v2 fields: `root` (the git root of the session's own checkout, read from the session's directory: never the plugin instance's, since one `opencode serve` hosts an instance per opened project and each hears every session; `null` outside any repository), `repo` (its main worktree), `agents` (`{id, type, status, started}`), `attribution` (`false` only on a Bob session that ran a sub-agent, else `null`), `turns`, `context` (`{used, window}`), `compactions`, `compacted_at` and `context_at_compaction` (either `context` field can be `null`, right after a compaction for one), and `repo_key`, the repo (else the root) case-folded on Windows, to group a repo's sessions whatever case each host spelled it in. A v1 snapshot reads `null` for those, `[]` for `agents` and `0` for the counts. A live session also gets `files_all`, the uncapped file rows from its detail file (`files` stays the capped summary), and `loops`: `{title, iteration, status}` for each loop registered on its `root`, a finished or unreadable loop left out. `collisions` lists each `{repo, path}` that two or more writers changed among the live sessions — a writer is a session or one of its sub-agents (`{sid, by, root}`) — with `kind: "same-worktree"` when two of them share a `root`, else `"cross-worktree"`. A file outside the root is stored with `path: null` (its `file` keeps the basename) and takes no part in a collision. Roots and paths compare case-folded on Windows, and a session root is resolved to its real path before the loop join, as the loop registry stores it. `/api/activity/<id>` returns the same fields for one session, an archived one included.
20
20
 
21
21
  **What you see.** A card per live session in **Activity** (`geneseed web`).
22
22
 
package/docs/web-ui.md CHANGED
@@ -53,6 +53,27 @@ strict CSP (`frame-ancestors 'none'`, same-origin only, the one inline token scr
53
53
  a per-response nonce). `?fresh=1` on the doctor re-runs at most once per 3 s, and the server
54
54
  drops a request whose headers take over 10 s or whose whole request takes over 30 s.
55
55
 
56
+ ## Which install a request reads
57
+
58
+ A request can name the install it reads or writes. A read takes two query parameters,
59
+ `?host=<host>&path=<install root>` (two, because a Windows path holds a colon). A write takes
60
+ `host` and `path` in its JSON body. The pair is a row of `/api/installs`, and the server checks
61
+ it against the same detected-install allowlist as the install toggle. An unknown or half pair
62
+ 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`,
64
+ and the `restore` and `build` actions. In `/api/view`, `/api/install`, the `install` and
65
+ `deploy` actions, `/api/excludes` and `/api/reveal`, `host`/`path` keep their own meaning.
66
+
67
+ Every `/api/*` read takes and checks the pair, with these exceptions:
68
+ - `/api/ping` and `/api/jobs` ignore it.
69
+ - The machine-wide reads also ignore it: `/api/update`, `/api/installs`, `/api/fleet`,
70
+ `/api/kits`, `/api/usage`, `/api/gates`, `/api/excludes`, `/api/mcp` and `/api/loops/active`.
71
+ Such a read does not check the pair, and its answer does not change with the pair.
72
+
73
+ A request that names no install reads the install the topbar picker selected (`POST /api/view`).
74
+ Each named install keeps its own cached doctor run and inventory, and a mutation refreshes all
75
+ of them.
76
+
56
77
  ## The rail
57
78
 
58
79
  The left rail mirrors the harness's own shape:
@@ -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": "4.29.0"
5
+ "version": "4.30.1"
6
6
  }
package/js/README.md CHANGED
@@ -239,15 +239,15 @@ the deployed harness as JSON.
239
239
  |---|---|
240
240
  | `server.mjs` | `serve()`/`cmdWeb`: UI-build precheck, socket bind, token mint, daemon record wiring |
241
241
  | `routes.mjs` | The route tables — `STATE_ROUTES`, `PREFIX_ROUTES`, `POST_ROUTES` (+ its 409 column) — and the inline lists |
242
- | `handler.mjs` | One function per request: dispatch, gzip, `requestGuard` (Host+port, Origin/Sec-Fetch-Site on `/api`, constant-time CSRF token) and body cap (before the body is read), `securityHeaders` (CSP nonce, framing), static SPA fallback |
243
- | `state.mjs` | `webState` — the resolved install view every endpoint reads, with its cached inventory and doctor |
242
+ | `handler.mjs` | One function per request: per-request install (`?host=&path=` on every read but `MACHINE_GETS`, or the body on `VIEW_POSTS`), dispatch, gzip, `requestGuard` (Host+port, Origin/Sec-Fetch-Site on `/api`, constant-time CSRF token) and body cap (before the body is read), `securityHeaders` (CSP nonce, framing), static SPA fallback |
243
+ | `state.mjs` | `webState` — the resolved install view every endpoint reads, with its cached inventory and doctor; per-install views (`installView` in `actions.mjs`) hang off it, pinned, refreshed with it |
244
244
  | `catalog.mjs` | The Library read model: inventory, constitution tiers, memory/notebook/wiki/config items, `apiCatalog`/`apiItem`, `NotFound` |
245
245
  | `api.mjs` | The dashboard and settings reads: overview, recent, themes, setup, doctor, diff, installs, excludes, loops |
246
246
  | `update-check.mjs` | Is a newer release on npm? Answers from memory, refreshes in the background (a day when it got an answer, an hour when it did not), `null` on any failure, never asked under `node --test` |
247
247
  | `gates-api.mjs` | `GET /api/gates`: gate asks per rule per day over 30 days, read off every installed harness's `notebook/gates.jsonl` (the Overview's sparklines) |
248
248
  | `usage-api.mjs` | `GET /api/usage`: the 30-day skill and agent call counts across every installed harness, the never-fired list, a fleet-wide `names` list (per-name 30-day counts, installs, daily series, last day seen), and skips lines older than 90 days in each `notebook/usage.jsonl` |
249
249
  | `user-files.mjs` | The fingerprint-guarded editors for `user-rules.md` (incl. memory promotion) and `PROFILE.md`, read and write |
250
- | `actions.mjs` | The other mutating endpoints — memory delete, MCP, excludes, installs, view, restore — plus install/deploy argv |
250
+ | `actions.mjs` | The other mutating endpoints — memory delete, MCP, excludes, installs, view, restore — plus install/deploy argv, and `installView`, the per-request install behind the one (host, path) allowlist |
251
251
  | `daemon.mjs` | Detached web start/stop/status/restart, the `.geneseed-web.json` record, and `openUrl` |
252
252
  | `jobs.mjs` | `JobManager` and the action→argv table. The only module here that spawns job children |
253
253
  | `docs.mjs` | The Docs tab: the `docs/<folder>/` page registry, `?harness=` filtering, link rewriting, the six page kinds |
@@ -769,17 +769,19 @@ function ruleDecide(args, payload) {
769
769
  + 'credential-shaped string. Secrets live in .env or a secret manager, never in a '
770
770
  + 'tracked file.');
771
771
  }
772
- const sensor = protectedCheck(p);
772
+ // Bob routes reads here too (`read_file` carries a path): only a write is External Gate's business.
773
+ // shortcut: a write is told by its tool name, so a Bob write tool named outside WRITE_NAME_RE
774
+ // passes both gates; switch to an allowlist of Bob's read tools if Bob adds or renames one.
775
+ const bobRead = HOST === 'bob' && !WRITE_NAME_RE.test(String((payload && payload.tool_name) || ''));
776
+ const sensor = !bobRead && protectedCheck(p);
773
777
  if (sensor) {
774
778
  return ask(args, 'rule-gate', 'rigor-5', `Geneseed (External Gate) — ${p} is a protected `
775
779
  + `check (${sensor === DONE_LIST ? 'the done gate list itself'
776
780
  : `${sensor}, listed in ${SENSOR_LIST}`}). A check the agent can edit is not a `
777
781
  + 'check: fix the code, not the check, unless the user asks for this edit.');
778
782
  }
779
- // Bob routes reads here too (`read_file` carries a path): only a write is this gate's business.
780
783
  // Bob never reads `opencode.json(c)`, OpenCode's whole host config: it is not gated from Bob.
781
- const bobWrite = HOST !== 'bob' || (WRITE_NAME_RE.test(String((payload && payload.tool_name) || ''))
782
- && !/^opencode\.jsonc?$/i.test(path.basename(p)));
784
+ const bobWrite = !bobRead && !(HOST === 'bob' && /^opencode\.jsonc?$/i.test(path.basename(p)));
783
785
  if (bobWrite && gateConfig(p, args.root)) {
784
786
  // Bob: a hook-settings file is the user's shared host config — refused only when the write
785
787
  // touches Geneseed's wiring (`bobSettingsChange`); a pass falls through to the checks below.
@@ -65,6 +65,7 @@ import { memoryDelete } from '../maintain/memory.mjs';
65
65
  import { installDeactivate, installReactivate, installUninstall } from '../maintain/uninstall.mjs';
66
66
  import { emitChoices, themeChoices, viewCfg } from './api.mjs';
67
67
  import { actionCommands } from './jobs.mjs';
68
+ import { webState } from './state.mjs';
68
69
  import { NotFound, deployed, memoryDir } from './catalog.mjs';
69
70
 
70
71
  /** One body field, `dflt` when the body is not an object or does not carry the key. */
@@ -192,6 +193,36 @@ function detectedInstall(body) {
192
193
  return hit;
193
194
  }
194
195
 
196
+ /**
197
+ * The state a request reads: the install its `{host, path}` names, or `base` (the daemon's
198
+ * own, the topbar selector's view) when it names neither — so a client that sends no install
199
+ * keeps today's answers.
200
+ *
201
+ * NAMING ONE IS AN ALLOWLIST LOOKUP, EVERY TIME: `detectedInstall` runs on a cache hit too, so
202
+ * a half pair, an unknown pair or an install removed since is a `NotFound` (404), never a fall
203
+ * through to another dir. The state is cached per install on `base._views` because its doctor
204
+ * and inventory caching is behaviour (see `webState`); it is PINNED, so `refresh` never
205
+ * re-points it, and its `refresh` is `base.refresh`, which reaches every view. The daemon's
206
+ * own hooks (`daemonStale`, `jobBusy`) are read through to `base`, where `serve()` sets them.
207
+ */
208
+ export function installView(base, sel) {
209
+ if (bget(sel, 'host') == null && bget(sel, 'path') == null) return base;
210
+ const [host, scope, root] = detectedInstall(sel);
211
+ const key = JSON.stringify([host, String(root)]);
212
+ let v = base._views.get(key);
213
+ if (v === undefined) {
214
+ const target = viewCfg(host, scope, root);
215
+ v = webState(null, target);
216
+ v.selectView(target, root);
217
+ v.pinned = true;
218
+ v.refresh = base.refresh;
219
+ v.daemonStale = () => base.daemonStale?.();
220
+ v.jobBusy = () => base.jobBusy?.();
221
+ base._views.set(key, v);
222
+ }
223
+ return v;
224
+ }
225
+
195
226
  // ---- OS-native folder picker ---------------------------------------------------------------
196
227
 
197
228
  /**
@@ -15,13 +15,16 @@ import { resolvePath } from '../hosts/hosts.mjs';
15
15
  import { isTruthy, jsonDumpsCompact } from '../lib/json.mjs';
16
16
  import { parseIntStrict, percentDecode } from '../lib/text.mjs';
17
17
  import {
18
- apiDeployCmd, apiInstallCmd, apiPickFolder, apiRestore, buildActionCmds, mcpTargetPaths, rebuildCmds,
18
+ apiDeployCmd, apiInstallCmd, apiPickFolder, apiRestore, buildActionCmds, installView, mcpTargetPaths,
19
+ rebuildCmds,
19
20
  } from './actions.mjs';
20
21
  import { BadRequest, NotFound } from './catalog.mjs';
21
22
  import { openFolder, requestRestart } from './daemon.mjs';
22
23
  import { apiDocs, apiDocsPage } from './docs.mjs';
23
24
  import { actionCommands, updatePlan } from './jobs.mjs';
24
- import { POST_ROUTES, PREFIX_ROUTES, STATE_ROUTES, readJsonBody } from './routes.mjs';
25
+ import {
26
+ MACHINE_GETS, POST_ROUTES, PREFIX_ROUTES, STATE_ROUTES, VIEW_POSTS, readJsonBody,
27
+ } from './routes.mjs';
25
28
  import { installKind } from './update-check.mjs';
26
29
  import { isFile } from '../lib/fs.mjs';
27
30
  import { randomBytes, timingSafeEqual } from 'node:crypto';
@@ -198,22 +201,27 @@ export function makeHandler(state, jm, token, dist, holder = null) {
198
201
  }
199
202
 
200
203
  function doGet(req, res, path, ae) {
204
+ // The install the request names (`?host=&path=`), else the daemon's view; an unknown pair
205
+ // throws `NotFound` here, before any route reads a dir. Not for ping, jobs, static files or
206
+ // the machine-wide reads (`MACHINE_GETS`), which ignore the pair.
207
+ const st = (path.startsWith('/api/') && path !== '/api/ping' && !path.startsWith('/api/jobs')
208
+ && !MACHINE_GETS.has(path)) ? installView(state, installParams(req.url)) : state;
201
209
  const route = STATE_ROUTES[path];
202
- if (route !== undefined) return sendJson(res, route(state, req.url), 200, ae);
210
+ if (route !== undefined) return sendJson(res, route(st, req.url), 200, ae);
203
211
  // `pid` is what a restarting client waits on: the OLD server keeps answering this ping for
204
212
  // a moment after `/api/restart` returns, and a reload onto it fetches the old token.
205
213
  if (path === '/api/ping') {
206
214
  return sendJson(res, { ok: true, theme: state.theme, pid: process.pid }, 200, ae);
207
215
  }
208
216
  for (const [prefix, handler] of PREFIX_ROUTES) {
209
- if (path.startsWith(prefix)) return sendJson(res, handler(state, path), 200, ae);
217
+ if (path.startsWith(prefix)) return sendJson(res, handler(st, path), 200, ae);
210
218
  }
211
219
  if (path === '/api/docs') {
212
- return sendJson(res, apiDocs(state, harnessParam(req.url)), 200, ae);
220
+ return sendJson(res, apiDocs(st, harnessParam(req.url)), 200, ae);
213
221
  }
214
222
  if (path.startsWith('/api/docs/page/')) {
215
223
  const pid = percentDecode(path.slice('/api/docs/page/'.length));
216
- return sendJson(res, apiDocsPage(state, pid, harnessParam(req.url)), 200, ae);
224
+ return sendJson(res, apiDocsPage(st, pid, harnessParam(req.url)), 200, ae);
217
225
  }
218
226
  if (path === '/api/jobs') return sendJson(res, { jobs: jm.recent() }, 200, ae);
219
227
  if (path.startsWith('/api/jobs/')) {
@@ -290,10 +298,16 @@ export function makeHandler(state, jm, token, dist, holder = null) {
290
298
  apiPickFolder((result) => sendJson(res, result, 200, ae));
291
299
  return;
292
300
  }
301
+ // The install a body `{host, path}` names, on the routes that read one (`VIEW_POSTS`).
302
+ // An action is looked up on the SAME segment `doAction` dispatches on (the last), so
303
+ // `/api/actions/x/restore` cannot run a restore on the daemon's install instead.
304
+ const key = path.startsWith('/api/actions/')
305
+ ? `/api/actions/${path.slice(path.lastIndexOf('/') + 1)}` : path;
306
+ const st = VIEW_POSTS.has(key) ? installView(state, readJsonBody(body)) : state;
293
307
  const route = POST_ROUTES.get(path);
294
308
  if (route !== undefined) {
295
309
  const [fn, okIs409] = route;
296
- const obj = fn(state, readJsonBody(body));
310
+ const obj = fn(st, readJsonBody(body));
297
311
  return sendJson(res, obj, (okIs409 && !isTruthy(obj.ok)) ? 409 : 200, ae);
298
312
  }
299
313
  if (path.startsWith('/api/jobs/') && path.endsWith('/cancel')) {
@@ -304,7 +318,7 @@ export function makeHandler(state, jm, token, dist, holder = null) {
304
318
  : sendJson(res, { error: 'no running job by that id' }, 404, ae);
305
319
  }
306
320
  if (path.startsWith('/api/actions/')) {
307
- return doAction(res, path.slice(path.lastIndexOf('/') + 1), readJsonBody(body), ae);
321
+ return doAction(res, path.slice(path.lastIndexOf('/') + 1), readJsonBody(body), ae, st);
308
322
  }
309
323
  return sendJson(res, { error: 'not found' }, 404, ae);
310
324
  }
@@ -333,9 +347,9 @@ export function makeHandler(state, jm, token, dist, holder = null) {
333
347
  *
334
348
  * THEN the table, which answers a 404 for any action it does not name.
335
349
  */
336
- function doAction(res, action, body, ae) {
350
+ function doAction(res, action, body, ae, st = state) {
337
351
  if (action === 'restore') {
338
- return sendJson(res, apiRestore(state, isTruthy(body.files) ? body.files : []), 200, ae);
352
+ return sendJson(res, apiRestore(st, isTruthy(body.files) ? body.files : []), 200, ae);
339
353
  }
340
354
  if (action === 'install') {
341
355
  const plan = apiInstallCmd(state, body);
@@ -396,7 +410,7 @@ export function makeHandler(state, jm, token, dist, holder = null) {
396
410
  }
397
411
  // Build resolves its argv off the install (`buildActionCmds`); the other actions take no
398
412
  // axes and self-resolve the deployed theme downstream.
399
- const cmds = action === 'build' ? buildActionCmds(state, body) : actionCommands(action);
413
+ const cmds = action === 'build' ? buildActionCmds(st, body) : actionCommands(action);
400
414
  if (cmds && Object.hasOwn(cmds, 'error')) return sendJson(res, cmds, 400, ae);
401
415
  if (!isTruthy(cmds)) {
402
416
  return sendJson(res, { error: `unknown action ${action}` }, 404, ae);
@@ -521,6 +535,16 @@ function harnessParam(url) {
521
535
  return new URL(url || '', 'http://x').searchParams.get('harness') || null;
522
536
  }
523
537
 
538
+ /**
539
+ * `{host, path}` off the query, each `null` when absent — two params, not one string, because a
540
+ * Windows path holds a colon. A BLANK value is kept as `''`, unlike `harnessParam`: `?host=` names
541
+ * an install, a bad one, and `installView` must refuse it rather than read it as "none named".
542
+ */
543
+ function installParams(url) {
544
+ const q = new URL(url || '', 'http://x').searchParams;
545
+ return { host: q.get('host'), path: q.get('path') };
546
+ }
547
+
524
548
  function readBody(req, length, done) {
525
549
  if (!(length > 0)) {
526
550
  req.resume();
package/js/web/routes.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * WHAT THE WEB API ANSWERS — as a declaration, separate from the dispatcher that honours it.
3
3
  *
4
- * Four tables and two inline lists. The two GET tables (`STATE_ROUTES`, `PREFIX_ROUTES`) used
5
- * to live in `api.mjs`, which made it import every route module that also imported it. None of
6
- * this is documentation: `tests/unit/web_server.test.mjs` holds their union against a surface
7
- * list written out in the test, and probes the real handler, because a declaration is not a
8
- * dispatcher — a route can be declared here and missing from the dispatch, and nothing but a
9
- * probe notices.
4
+ * Four tables, two inline lists, and the two install-scope sets (`VIEW_POSTS`, `MACHINE_GETS`).
5
+ * The two GET tables (`STATE_ROUTES`, `PREFIX_ROUTES`) used to live in `api.mjs`, which made it
6
+ * import every route module that also imported it. None of this is documentation:
7
+ * `tests/unit/web_server.test.mjs` holds their union against a surface list written out in the
8
+ * test, and probes the real handler, because a declaration is not a dispatcher — a route can be
9
+ * declared here and missing from the dispatch, and nothing but a probe notices.
10
10
  *
11
11
  * This file used to also carry the Python→Node port's NOT_PORTED / DECLINED partition — five
12
12
  * sets, all empty once the port finished. They were deleted when the port bookkeeping retired
@@ -62,6 +62,27 @@ export const POST_ROUTES = new Map([
62
62
  ['/api/loops/preset', [apiLoopsPresetMutate, false]],
63
63
  ]);
64
64
 
65
+ /**
66
+ * The POSTs whose body `{host, path}` names the install they act on (`installView`), opt-in
67
+ * rather than every POST: in `/api/view`, `/api/install` and `/api/actions/install` the pair is
68
+ * the target the route resolves itself, and in `/api/actions/deploy`, `/api/excludes` and
69
+ * `/api/reveal` a `path` is a folder or a config file, not an install. The two `actions/` rows
70
+ * are the only actions that read the viewed install.
71
+ */
72
+ export const VIEW_POSTS = new Set(['/api/activity', '/api/memory/delete', '/api/rules',
73
+ '/api/rules/promote', '/api/profile', '/api/actions/restore', '/api/actions/build']);
74
+
75
+ /**
76
+ * The GETs that answer for the whole machine, not one install: they IGNORE a `?host=&path=`
77
+ * pair (it is neither checked nor used) and always read the daemon's state. Ignored rather
78
+ * than refused, so a client may send its install on every read. On the daemon's state, not a
79
+ * view, because `/api/update` keeps its daily check and the `.git`-lock guard
80
+ * (`_behind.inflight`) there, and the update job checks only that one. Every other `/api/*`
81
+ * GET, ping and jobs aside, takes the pair and refuses an unknown one.
82
+ */
83
+ export const MACHINE_GETS = new Set(['/api/update', '/api/installs', '/api/fleet', '/api/kits',
84
+ '/api/usage', '/api/gates', '/api/excludes', '/api/mcp', '/api/loops/active']);
85
+
65
86
  /**
66
87
  * The 409 column, exported so a test can assert it directly. Giving `/api/activity` the 409
67
88
  * treatment is the invisible mutation: nothing in normal use can force the `ok: false` arm
package/js/web/state.mjs CHANGED
@@ -74,6 +74,10 @@ export function stampMinute(ms) {
74
74
  * the hook shim, the hook shell, the OpenCode config dirs, the deployed install): a memory
75
75
  * delete passes `{ doctor: false }` and keeps the ~3.6 s verdict. Rule and profile writes do not
76
76
  * call `refresh()` at all. Every other caller keeps the default, so a new one is slow, never stale.
77
+ *
78
+ * A request may name another install (`installView` in actions.mjs): that one gets its OWN
79
+ * state, made by this factory, cached in `_views` and `pinned`, so the caching above holds per
80
+ * install. `refresh()` on the daemon's state reaches every view.
77
81
  */
78
82
  export function webState(theme = null, target = null) {
79
83
  const st = {
@@ -96,6 +100,12 @@ export function webState(theme = null, target = null) {
96
100
  // `diffCollect`'s memo of `expected` renders, made on first use by `api.mjs` (`memoOf`);
97
101
  // it re-renders on its own key change, so `refresh()` leaves it alone.
98
102
  renderMemo: null,
103
+ // True for a per-install view (`installView` in actions.mjs): `refresh` must never re-point
104
+ // it at another install, since the request named THIS one.
105
+ pinned: false,
106
+ // The per-install views made off this daemon's state, keyed `[host, root]` — see
107
+ // `installView`. Kept here, not at module level, so each handler (each test's) has its own.
108
+ _views: new Map(),
99
109
  };
100
110
  // The INSTALL ROOT (== build --out). For globals it IS the data dir; a claude/bob/openclaude
101
111
  // PROJECT install keeps its data under <repo>/.claude|.bob|.openclaude while the markers
@@ -183,11 +193,13 @@ export function webState(theme = null, target = null) {
183
193
  st._inv = null;
184
194
  st._doctor = null;
185
195
  };
186
- st.refresh = ({ doctor = true } = {}) => {
196
+ /** This state alone. `refresh` below is what callers use: it also reaches every view. */
197
+ st.refreshOwn = ({ doctor = true } = {}) => {
187
198
  // A job may have deployed the first install while the view still points at an empty
188
199
  // default (the onboarding Build), or removed the one in view: follow it to one that exists.
189
200
  // Only on a full refresh: `{ doctor: false }` marks a mutation that cannot change installs.
190
- const fallback = doctor ? fallbackView(st.target) : null;
201
+ // Never for a pinned view: it answers for the install its request named, or is refused.
202
+ const fallback = doctor && !st.pinned ? fallbackView(st.target) : null;
191
203
  if (fallback) { st.selectView(...fallback); return; }
192
204
  st._inv = null;
193
205
  if (doctor) st._doctor = null;
@@ -196,6 +208,14 @@ export function webState(theme = null, target = null) {
196
208
  st.theme = themeOfDir(st.root, host) || themeOfDir(st.target, host) || st.theme;
197
209
  readMarkers(host);
198
210
  };
211
+ /**
212
+ * After a mutation, this state AND every per-install view made off it: a job or a write
213
+ * through one view can change what any other one reads (the same install, seen twice).
214
+ */
215
+ st.refresh = (opts = {}) => {
216
+ st.refreshOwn(opts);
217
+ for (const v of st._views.values()) v.refreshOwn(opts);
218
+ };
199
219
  return st;
200
220
  }
201
221
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "//": "Every field here is argued and gated in tests/unit/package_manifest.test.mjs. `files`, `bin` and `engines` each have a test that fails when reality drifts from this file; `version` mirrors harness.config.json and is gated too. Read that docblock before editing this one.",
3
3
  "name": "geneseed",
4
- "version": "4.29.0",
4
+ "version": "4.30.1",
5
5
  "description": "A portable, theme-able harness you implant once and use everywhere to grow a disciplined AI coding agent.",
6
6
  "keywords": [
7
7
  "ai",
@@ -18,9 +18,19 @@ These rules hold for every checkpoint this {{SKILL}} raises.
18
18
  !/protected-checks.txt
19
19
  !/done-checks.txt
20
20
  ```
21
- - **One open checkpoint.** Write the open checkpoint under `## Pending` before you wait; clear it
22
- once answered. A restart or a compaction is never an approval.
23
- - **The decision log.** Record each decision the user takes under `## Decisions`.
21
+ - **No write per checkpoint.** The open checkpoint lives in the conversation, not the file. A
22
+ restart or a compaction is never an approval: after one, re-ask any step not approved in the
23
+ visible conversation.
24
+ - **Preferences, not a log.** `## Preferences` holds general rules phrased as rules, never dated
25
+ events; one-off decisions stay in the chat and the commit message. Propose one only on a
26
+ general signal, and always ask: the user states it generally ("always…", "from now on…", "in
27
+ this repo…"), or makes the same choice a third time in the visible conversation. Never infer
28
+ one from a single decision. Rewrite in place: merge overlaps, replace what is superseded. At
29
+ about 10 lines, propose merging or dropping one.
30
+ - **Old-format file.** A file with `## Pending`, dated `## Decisions` or an `## Understood`
31
+ without one line per topic: propose it condensed (pending steps re-asked; one-off decisions
32
+ dropped; only general or repeated ones kept, at most 10 Preferences; the rest reshaped by this
33
+ {{SKILL}}); show it, write only on yes; after a no, do not ask again this session.
24
34
  - **No code without an answer.** Write no code until the checkpoint that approves it is answered.
25
35
  - **Cadence.** Never trigger a checkpoint by time or tool count. Honour "just implement this one",
26
36
  "fewer checkpoints", "skip" at once, unless the {{SKILL}} marks a checkpoint as mandatory.