geneseed 4.26.0 → 4.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/DESIGN.md +6 -5
- package/README.md +10 -6
- package/SHIPPED.md +4 -3
- package/adapters/bob/README.md +1 -1
- package/adapters/claude-code/README.md +5 -1
- package/adapters/claude-code/skills/geneseed/SKILL.md +2 -2
- package/adapters/opencode/HOW-OPENCODE-LOADS.md +1 -1
- package/adapters/opencode/README.md +5 -2
- package/adapters/opencode/plugins/geneseed-guard.js +79 -4
- package/bin/geneseed-hook.mjs +9 -3
- package/docs/concepts/enforcement-table.md +12 -0
- package/docs/concepts/exclusions.md +15 -1
- package/docs/concepts/hook-gates.md +1 -1
- package/docs/concepts/hooks.md +2 -1
- package/docs/concepts/ownership.md +79 -0
- package/docs/concepts/rules.md +1 -1
- package/docs/guides/set-up-ownership.md +77 -0
- package/docs/reference/glossary.md +1 -1
- package/docs/reference/plugin-guard.md +1 -0
- package/docs/reference/troubleshoot-doctor.md +2 -2
- package/docs/understand/enforced-vs-asked.md +3 -2
- package/docs/understand/machine-bob.md +1 -1
- package/docs/understand/machine-claude.md +1 -1
- package/docs/understand/machine-opencode.md +1 -1
- package/docs/web-ui.md +6 -4
- package/harness.config.json +1 -1
- package/js/README.md +1 -0
- package/js/build/render.mjs +1 -1
- package/js/build/source.mjs +5 -1
- package/js/cli-table.json +46 -1
- package/js/hosts/hooks.mjs +45 -5
- package/js/hosts/ownership-gate.mjs +105 -0
- package/js/hosts/settings.mjs +8 -3
- package/js/inspect/cost.mjs +1 -1
- package/js/inspect/inventory.mjs +1 -1
- package/js/inspect/status.mjs +1 -1
- package/package.json +1 -1
- package/registry.json +7 -0
- package/src/AGENT.md.tmpl +5 -0
- package/src/agents/developer.md +7 -1
- package/src/modes/foreman.md +4 -1
- package/src/ontology/universal.md +19 -0
- package/src/skills/_checkpoints.md +15 -0
- package/src/skills/develop.md +4 -0
- package/src/skills/document-project.md +2 -1
- package/src/skills/learn-mode.md +13 -17
- package/src/skills/ownership.md +139 -0
- package/src/skills/pipeline.md +1 -1
- package/themes/README.md +2 -2
- package/themes/_TEMPLATE.json +1 -0
- package/themes/biker.json +1 -0
- package/themes/commentator.json +1 -0
- package/themes/cyberpunk.json +1 -0
- package/themes/gamer.json +1 -0
- package/themes/imperial.json +1 -0
- package/themes/joker.json +1 -0
- package/themes/marvin.json +1 -0
- package/themes/mean.json +1 -0
- package/themes/military.json +1 -0
- package/themes/neutral.json +1 -0
- package/themes/pirate.json +1 -0
- package/themes/sports.json +1 -0
- package/themes/verstappen.json +1 -0
- package/themes/wizard.json +1 -0
- package/web/dist/assets/Activity-DfETiyWm.js +1 -0
- package/web/dist/assets/{ActivityDetail-BIxt9mAe.js → ActivityDetail-CnP3GPAN.js} +1 -1
- package/web/dist/assets/{CopyButton-DmXwAzBl.js → CopyButton-CRAUXSG7.js} +1 -1
- package/web/dist/assets/{Dashboard-BsevsUea.js → Dashboard-CaqOqtkG.js} +2 -2
- package/web/dist/assets/{Docs-BkipFlm8.js → Docs-BFxyAVdN.js} +1 -1
- package/web/dist/assets/{GreenhouseView-BJmyqf49.js → GreenhouseView-19roNb5W.js} +1 -1
- package/web/dist/assets/{Installs-CICECChj.js → Installs-BSoQN7w7.js} +1 -1
- package/web/dist/assets/{JournalView-BOyq2Abk.js → JournalView-BgU2ybaq.js} +1 -1
- package/web/dist/assets/{KitApply-BRSZjM_N.js → KitApply-Ckc0P5kt.js} +1 -1
- package/web/dist/assets/{Kits-DPGxX2Vv.js → Kits-BZqWGWMu.js} +1 -1
- package/web/dist/assets/{Laws-CY0hBpkK.js → Laws-CnUWiNIx.js} +1 -1
- package/web/dist/assets/{Library-PzXbaBWz.js → Library-rYO8owx_.js} +1 -1
- package/web/dist/assets/{Loops-DflSj8Pz.js → Loops-CljFhhQV.js} +1 -1
- package/web/dist/assets/{OperatorHudView-CjJlJqGm.js → OperatorHudView-xs7SCwCe.js} +1 -1
- package/web/dist/assets/{Personal-CC7cLkTe.js → Personal-CMPwtl36.js} +1 -1
- package/web/dist/assets/{Tabs-DCzA2Eop.js → Tabs-CEfSUVQp.js} +1 -1
- package/web/dist/assets/{index-xjpstIKL.js → index-FLVXXvV3.js} +2 -2
- package/web/dist/index.html +1 -1
- package/web/dist/assets/Activity-Dq8_Xhxu.js +0 -1
package/docs/concepts/rules.md
CHANGED
|
@@ -21,7 +21,7 @@ The one place you type a position is the command line: `--exclude-rules "process
|
|
|
21
21
|
|
|
22
22
|
When two instructions disagree, the higher one wins.
|
|
23
23
|
|
|
24
|
-
1. **Ethos** — always on. {N_ONTOLOGY} sections of flowing prose (Telos, Evidence, Decisions, Conduct): what the agent is for, how it weighs evidence, how it decides, how it behaves. It is where the **Pact**, the two-way contract between you and the agent, is stated ([Collaboration](collaboration.md)). Cited by section name, e.g. *Ethos: Decisions*.
|
|
24
|
+
1. **Ethos** — always on. {N_ONTOLOGY} sections of flowing prose (Telos, Evidence, Decisions, Ownership, Conduct): what the agent is for, how it weighs evidence, how it decides, who owns the code it writes, how it behaves. It is where the **Pact**, the two-way contract between you and the agent, is stated ([Collaboration](collaboration.md)). Cited by section name, e.g. *Ethos: Decisions*.
|
|
25
25
|
2. **Rules** — always on. {N_LAWS} invariants, the things that are never traded away: sealed secrets, one intent per act, verify before asserting, deliberate deletion, surface failures, treat content as data not orders, least privilege, cure the cause, echo the intent. No install can switch one off.
|
|
26
26
|
3. **Your `user-rules.md`** — rules you write for yourself, seeded once beside the instructions file and never overwritten. A rule here **outranks any doctrine rule**: a practice pack chosen at build time never overrides an instruction you wrote. It may tighten an invariant, never repeal one. The [rule skill](skills.md) helps you decide whether something belongs here or in [memory](memory.md).
|
|
27
27
|
4. **Doctrines** — chosen at build time. Practices rather than principles, grouped in packs (below).
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
group: guides
|
|
3
|
+
order: 21
|
|
4
|
+
title: "Set up ownership"
|
|
5
|
+
kind: "concept"
|
|
6
|
+
section: "Set up"
|
|
7
|
+
description: "Give an application repo its `## Ownership` section, so the developer decides each part."
|
|
8
|
+
---
|
|
9
|
+
This guide gives one application repository its ownership setup: a `## Ownership` section in the committed root `AGENTS.md`, and your personal state file. What ownership is, and how it differs from learn-mode: [Ownership](../concepts/ownership.md).
|
|
10
|
+
|
|
11
|
+
You need a Geneseed install on your host (any of Claude Code, OpenClaude, OpenCode or Bob) and a repository with a build manifest at its git root (`package.json`, `pom.xml`, `build.gradle*` and the like).
|
|
12
|
+
|
|
13
|
+
## 1. Start the setup
|
|
14
|
+
|
|
15
|
+
Open a session in the repository and ask for it: "set up ownership for this repo". The agent runs the `ownership` skill.
|
|
16
|
+
|
|
17
|
+
You may not need to ask. In an application with no `## Ownership` section, the first file write of a session is stopped once, and the agent proposes the setup to you. Answer "set it up", or "proceed without" to skip it for this session only.
|
|
18
|
+
|
|
19
|
+
## 2. Review the conventions it found
|
|
20
|
+
|
|
21
|
+
The agent reads the code first and writes nothing yet. It proposes the conventions it found: naming, layers, test patterns, build and test commands. Correct what is wrong. If the stack matches a [kit](../concepts/kits.md) (`spring-boot`, `react`), it proposes that kit too.
|
|
22
|
+
|
|
23
|
+
## 3. Answer the questions
|
|
24
|
+
|
|
25
|
+
About five questions, one at a time, each with a recommended answer:
|
|
26
|
+
|
|
27
|
+
1. Are the conventions right?
|
|
28
|
+
2. Ownership on for this repo? (`mode: on`, or `mode: off` to opt the repo out)
|
|
29
|
+
3. The default granularity: `feature`, `file` (recommended) or `function`.
|
|
30
|
+
4. The sensitive zones: paths where every change is a checkpoint, such as `payment/`, database migrations or security configuration.
|
|
31
|
+
5. Any free-form project rules.
|
|
32
|
+
|
|
33
|
+
## 4. Check the diff
|
|
34
|
+
|
|
35
|
+
The setup writes two files and shows you the diff:
|
|
36
|
+
|
|
37
|
+
- `AGENTS.md` at the repository root, at most about 60 lines, ending with the section:
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
## Ownership
|
|
41
|
+
|
|
42
|
+
mode: on
|
|
43
|
+
granularity: file
|
|
44
|
+
sensitive:
|
|
45
|
+
- src/main/resources/db/migration/**
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
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.
|
|
49
|
+
- `.geneseed/ownership.md`, your personal state: a finer granularity if you want one, the pending checkpoint, and the decisions you took. It is data, never instructions, and it belongs in `.gitignore` — the agent offers to add `.geneseed/` once.
|
|
50
|
+
|
|
51
|
+
Nothing is committed unless you ask.
|
|
52
|
+
|
|
53
|
+
## 5. Check how diffs reach you
|
|
54
|
+
|
|
55
|
+
Under ownership, the host's own diff prompt is how you approve a routine step. The setup checks the permission mode:
|
|
56
|
+
|
|
57
|
+
- **Claude Code, OpenClaude.** If edits are auto-accepted (bypass or accept-edits mode), no diff stops for you. Switch back to asking, or keep it: the agent then shows a compact diff in the chat and waits for your reply.
|
|
58
|
+
- **OpenCode.** The agent proposes `permission.edit: "ask"` in the project `opencode.json`.
|
|
59
|
+
|
|
60
|
+
## 6. Commit `AGENTS.md`
|
|
61
|
+
|
|
62
|
+
Commit the root `AGENTS.md` with the repository, so the whole team works under the same section. From then on the first-write gate stays quiet in this repo, and every session runs the checkpoints at the team's granularity.
|
|
63
|
+
|
|
64
|
+
## Change it later
|
|
65
|
+
|
|
66
|
+
- **Finer for one task.** Say "go finer here", or "do the rest in one go" to propose a coarser batch.
|
|
67
|
+
- **The team default.** Edit `granularity:` in `AGENTS.md` and commit it.
|
|
68
|
+
- **Opt the repo out.** Set `mode: off`. The gate stays quiet, and no checkpoint runs.
|
|
69
|
+
- **Opt the whole install out of the gate.** Rebuild with the flag, as [Exclusions](../concepts/exclusions.md) shows:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
geneseed build --emit claude-global --no-ownership-gate
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Verify
|
|
76
|
+
|
|
77
|
+
In a fresh session, ask for a small change in the repository. The agent should announce the file it will touch, or ask at a real fork, before the edit — and the first write should pass without the gate stopping it.
|
|
@@ -12,7 +12,7 @@ Every word Geneseed uses that you would not find in a general programming glossa
|
|
|
12
12
|
|---|---|---|---|
|
|
13
13
|
| Harness | — | everything Geneseed installs around the model: the rules it loads, the gates that run before its actions, the workflows it can call | git hooks + CI + a runbook, for an agent |
|
|
14
14
|
| Hook | — | a command your tool runs before or after an agent action; Geneseed's hooks gate risky actions and load context | a git hook, fired on every tool call |
|
|
15
|
-
| Ethos (Ontology) | ONTOLOGY | the always-on worldview under the rules — telos, evidence, decisions, conduct; it holds the Pact | the team's engineering principles |
|
|
15
|
+
| Ethos (Ontology) | ONTOLOGY | the always-on worldview under the rules — telos, evidence, decisions, ownership, conduct; it holds the Pact | the team's engineering principles |
|
|
16
16
|
| Rule (Law) | LAW | one of the nine always-on invariants: what is never done | a lint rule set to error |
|
|
17
17
|
| Rules (Laws) | LAWS | the body of always-on invariants | the error-level rule set |
|
|
18
18
|
| Doctrine | DOCTRINE | one practice rule, cited `<pack> <n>` — how work is done here | a team convention in CONTRIBUTING.md |
|
|
@@ -11,6 +11,7 @@ One of the [OpenCode plugins](opencode-plugins.md). [Environment variables](envi
|
|
|
11
11
|
**What it does.** Enforces the safety rules at the tool boundary — before a tool call runs, not after. High-confidence patterns only, so legitimate work is not caught.
|
|
12
12
|
|
|
13
13
|
- **Blocks** writes to private-key and credential files and writes whose content carries a credential (*Sealed Secrets*; an install built `--no-secrets-gate` carries `Secrets gate: off` in its `AGENT.md`, read once at load, and both stop blocking), catastrophic shell commands such as deleting the filesystem root and every command that would really lose data — a protected branch deleted or force-pushed, an unpushed unmerged branch deleted, a protected branch force-moved off commits nothing else holds, unpushed commits abandoned by `reset --hard`, uncommitted work discarded other than by `reset --hard`, a stash dropped, files git cannot restore removed — judged against the repository's state, the same decisions the Claude/Bob hook makes (*Deletion Is Deliberate*; `reflog expire` and `gc --prune` are left to the `permission.bash` ask; an install built `--no-deletion-gate` carries `Deletion gate: off` in its `AGENT.md`, which the plugin reads once at load and then stops blocking real loss — catastrophic commands still block), a recursive scan rooted at a whole filesystem such as `find /` (*Commands Must Return* — search a specific directory instead), and any change — write, move, rename, delete — under a wiki folder declared `protected` in `geneseed-wiki.jsonc`, and writes to a check listed in the project's `.geneseed/protected-checks.txt` (*External Gate* — see [Hooks](../concepts/hooks.md)).
|
|
14
|
+
- **Refuses once** the first write of a session in an application repo (a git root holding a build manifest) whose root `AGENTS.md` has no `## Ownership` section, so the agent proposes the [ownership](../concepts/ownership.md) setup first; the next write passes, and a sub-agent's session never triggers it. Off per repo with `mode: off` in that section; an install built `--no-ownership-gate` carries `Ownership gate: off` in its `AGENT.md`, read once at load.
|
|
14
15
|
- **Warns** (logged, allowed) on `.env` writes.
|
|
15
16
|
- **Speed-bumps** the *first* write to `user-rules.md` or a memory file: it is refused once, naming *Persist Insight* — whether something is a standing rule or a fact to remember is your call, settled through the `rule` skill. The re-issued write goes through.
|
|
16
17
|
|
|
@@ -43,8 +43,8 @@ These come only from `geneseed doctor --probe`. It runs each installed gate exac
|
|
|
43
43
|
settings spell it, through the host's own shell, on `git reflog expire --expire=now --all` (which must be refused)
|
|
44
44
|
and `git status` (which must go through). A gate wired with `--no-deletion-gate` lets the first one
|
|
45
45
|
through by design, so it is probed on `find / -name geneseed-probe` instead — a root-wide scan it
|
|
46
|
-
must still refuse. `--no-secrets-gate` and `--no-
|
|
47
|
-
shell command. An OpenCode install's guard plugin has no command to
|
|
46
|
+
must still refuse. `--no-secrets-gate`, `--no-done-gate` and `--no-ownership-gate` change nothing here: none
|
|
47
|
+
judges a shell command. An OpenCode install's guard plugin has no command to
|
|
48
48
|
run: the probe imports it and calls its hook through both plugin APIs (V1 and V2), with `rm -rf /`
|
|
49
49
|
as the call it must refuse. `GENESEED_GUARD=off` or `warn` in your terminal makes that a note,
|
|
50
50
|
not a failure.
|
|
@@ -27,11 +27,12 @@ On Claude Code and OpenClaude the hooks never block silently. They make the host
|
|
|
27
27
|
- **A scan of a whole filesystem**: a recursive `find`, `du`, `grep -r`, `rg` or `Get-ChildItem -Recurse` rooted at `/`, `/c` or `C:\`, which in Git Bash walks every drive for hours. Wired in every build.
|
|
28
28
|
- **Credentials**: a write or edit whose content looks like a real key (AWS, GitHub, Anthropic, Slack, or a private-key block), anywhere except a `.env` file.
|
|
29
29
|
- **Your rules and memory**: any write by the agent to `user-rules.md` or to the memory store. Whether something is a standing rule or a fact to remember is your call.
|
|
30
|
+
- **The first write in an application with no ownership setup**: in a repo with a build manifest whose root `AGENTS.md` has no `## Ownership` section, the session's first write is refused once, with the reason sent to the agent rather than to you: it then asks you to set [ownership](../concepts/ownership.md) up or proceed without. Off per repo with `mode: off`, per install with `--no-ownership-gate`.
|
|
30
31
|
- **Ending a turn without the proof**: only in a project that lists its checks in `.geneseed/done-checks.txt`. A turn that edited files cannot end until every listed check has passed since the last edit. The agent is stopped once, then the turn may end.
|
|
31
32
|
|
|
32
33
|
If a gate crashes, it asks instead of letting the call through. If it cannot start at all (a deleted or broken shim) or times out, Claude Code blocks the call instead: see [Troubleshoot hooks](../reference/troubleshoot-hooks.md) to recover. Other shell commands go through Claude Code's normal permission flow; an `rm` of files git cannot restore is the real-loss case above.
|
|
33
34
|
|
|
34
|
-
**Bob** runs one combined gate and has no "ask": it refuses with exit code 2, and only for the rules that admit no judgement call: credentials, destructive git, a scan of a whole filesystem, and a write under a project's own protected-checks list. The commit/push and memory checks become a log line, and the call goes through. Bob's hook wiring follows its documentation but has not been tested on a live Bob install.
|
|
35
|
+
**Bob** runs one combined gate and has no "ask": it refuses with exit code 2, and only for the rules that admit no judgement call: credentials, destructive git, a scan of a whole filesystem, and a write under a project's own protected-checks list. The commit/push and memory checks become a log line, and the call goes through. The ownership gate also refuses with exit 2, but once: the same write passes after you answer. Bob's hook wiring follows its documentation but has not been tested on a live Bob install.
|
|
35
36
|
|
|
36
37
|
<!--/harness-->
|
|
37
38
|
<!--harness:opencode-->
|
|
@@ -40,7 +41,7 @@ If a gate crashes, it asks instead of letting the call through. If it cannot sta
|
|
|
40
41
|
On OpenCode, two mechanisms enforce rules:
|
|
41
42
|
|
|
42
43
|
- **OpenCode's own permission prompt**, which Geneseed configures in `opencode.json`. It asks you before `git reflog expire`, `git gc --prune` and a force-push or delete of `main`/`master`, and, when the **process** pack is on, before every commit and push.
|
|
43
|
-
- **The guard plugin**, which blocks outright: writes to key and credential files (`id_rsa`, `*.pem`, `.ssh/`, `.npmrc`…), catastrophic commands (`rm -rf /`, `rm -rf ~`, formatting or overwriting a disk), every other real data loss (the same state-aware decisions as the hook), a recursive scan of a whole filesystem (`find /`, `du -sh /`, `Get-ChildItem C:\ -Recurse`), and any change inside a folder your wiki marks `protected`. It also refuses the first write to `user-rules.md` or memory once. Re-issue the write and it goes through.
|
|
44
|
+
- **The guard plugin**, which blocks outright: writes to key and credential files (`id_rsa`, `*.pem`, `.ssh/`, `.npmrc`…), catastrophic commands (`rm -rf /`, `rm -rf ~`, formatting or overwriting a disk), every other real data loss (the same state-aware decisions as the hook), a recursive scan of a whole filesystem (`find /`, `du -sh /`, `Get-ChildItem C:\ -Recurse`), and any change inside a folder your wiki marks `protected`. It also refuses the first write to `user-rules.md` or memory once. Re-issue the write and it goes through. And in an application repo with no `## Ownership` section in its root `AGENTS.md`, it refuses the session's first write once, so the agent proposes the [ownership](../concepts/ownership.md) setup (off with `mode: off` or `--no-ownership-gate`).
|
|
44
45
|
|
|
45
46
|
The guard only warns on `.env` edits. It checks credentials by **file path**, not by content, so a key pasted into an ordinary source file is not caught here. One caveat about the process pack: if your `opencode.json` already has a `git commit*` entry, a rebuild without the pack leaves that entry in place and reports it. Geneseed cannot tell its own entry from one you typed.
|
|
46
47
|
|
|
@@ -8,7 +8,7 @@ description: "Where an install lands on IBM Bob or as a plain AGENT.md bundle, a
|
|
|
8
8
|
---
|
|
9
9
|
Bob and the plain bundle carry the same rules, agents and skills as the other hosts. What differs is where they land and how much of it is enforced. The **Kind** words are explained in [What lands on your machine](on-your-machine.md).
|
|
10
10
|
|
|
11
|
-
**Bob.** A global install writes to `~/.bob/`, or `BOB_CONFIG_DIR`. Bob does not load a global `AGENTS.md`, so the rules go into `~/.bob/rules/geneseed.md`. A per-repo install writes `AGENTS.md` instead. Hooks live in `~/.bob/settings/settings.json`. Bob runs three of them: context at session start, one combined gate before each tool call, and learn at session end. Bob has no "ask" prompt, so the gate refuses outright, and only for the checks that admit no judgement call: credentials, destructive git, and a write under a project's own protected-checks list. The commit/push and memory questions become log lines.
|
|
11
|
+
**Bob.** A global install writes to `~/.bob/`, or `BOB_CONFIG_DIR`. Bob does not load a global `AGENTS.md`, so the rules go into `~/.bob/rules/geneseed.md`. A per-repo install writes `AGENTS.md` instead. Hooks live in `~/.bob/settings/settings.json`. Bob runs three of them: context at session start, one combined gate before each tool call, and learn at session end. Bob has no "ask" prompt, so the gate refuses outright, and only for the checks that admit no judgement call: credentials, destructive git, and a write under a project's own protected-checks list. The commit/push and memory questions become log lines. One more refusal happens only once: in an application repo whose root `AGENTS.md` has no `## Ownership` section, the session's first write is refused so the agent proposes the [ownership](../concepts/ownership.md) setup, and the same write passes after you answer. Turn it off per repo with `mode: off` in that section, or per install with `--no-ownership-gate`.
|
|
12
12
|
|
|
13
13
|
**Plain bundle.** The `files` target writes `AGENT.md` and the same folders into `./Harness/` for any tool that reads `AGENT.md`. It installs no hooks and no plugins, so nothing in it is enforced.
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@ What a Claude Code or OpenClaude install writes, piece by piece. The **Kind** wo
|
|
|
16
16
|
| `PROFILE.md` | Who you are and how you like answers pitched. Fill it with the `profile` skill | asked | 0 until you fill it | Leave the seeded text untouched |
|
|
17
17
|
| context hook | At session start, and again after a resume or compaction, puts your repo's README, CONTRIBUTING and a listing of `docs/` in front of the agent, with your rules, profile, memory index and wiki | automatic | Your docs, capped at 16 KB a file and 48 KB a session | `geneseed exclude add <folder>` silences every hook in that folder |
|
|
18
18
|
| git-gate hook | Before each shell command: asks you before any `git commit` or `git push`, and before a command that would really lose data — a force-push to `main`, a `reset --hard` that abandons unpushed commits, `branch -D` of an unpushed branch, an `rm` git cannot undo | enforced | ~14 ms per shell call | The commit/push question goes away if you build without the **process** pack; the destructive-git question has no switch except `geneseed exclude` |
|
|
19
|
-
| rule-gate hook | Before each write or edit: asks you when the file would carry a credential-shaped string (outside `.env`), or when the agent writes to `user-rules.md` or memory | enforced | ~14 ms per write | `geneseed exclude add <folder
|
|
19
|
+
| rule-gate hook | Before each write or edit: asks you when the file would carry a credential-shaped string (outside `.env`), or when the agent writes to `user-rules.md` or memory. In an application repo with no `## Ownership` section in its root `AGENTS.md`, stops the session's first write once so the agent proposes the [ownership](../concepts/ownership.md) setup | enforced | ~14 ms per write | `geneseed exclude add <folder>`; the ownership stop alone: `mode: off` in the repo's `## Ownership`, or rebuild with `--no-ownership-gate` |
|
|
20
20
|
| learn hook | When the agent finishes a reply, and before compaction, distils durable facts from the recent conversation into `memory/`. Off until you set `GENESEED_LLM` to a model command such as `claude -p` | automatic | One model call each time it runs, once enabled | Leave `GENESEED_LLM` unset (the default) |
|
|
21
21
|
| `skills/` | Written procedures you call by name, such as `brainstorm` or `plan` | on demand | ~4.1k tokens for names and descriptions; a skill's body loads only when called | No per-skill switch; `geneseed uninstall` removes them all |
|
|
22
22
|
| `agents/` | Specialists the agent can delegate to, such as `reviewer` or `tester` | on demand | ~0.5k tokens | `geneseed uninstall` |
|
|
@@ -16,7 +16,7 @@ What an OpenCode install writes, piece by piece. The **Kind** words are explaine
|
|
|
16
16
|
| `PROFILE.md` | Who you are and how you like answers pitched. Fill it with the `profile` skill | asked | 0 until you fill it | Leave the seeded text untouched |
|
|
17
17
|
| `opencode.json` entries | `instructions` points OpenCode at `AGENT.md`. `permission.bash` makes OpenCode ask before `git reflog expire`, `git gc --prune` or a force-push or delete of `main`/`master`, and before every commit and push when the **process** pack is on. `permission.skill` denies each user-only skill, so the model never starts it but `/name` still runs it; Geneseed takes back only the denies it wrote | enforced | No tokens | Edit the `permission` block yourself. The commit/push questions follow the **process** pack |
|
|
18
18
|
| context plugin | Puts your repo's README, CONTRIBUTING and a listing of `docs/` in front of the agent, with your rules, profile, memory index and wiki | automatic | Your docs, capped at 16 KB a file and 48 KB a session | `GENESEED_CONTEXT_INJECT=off` |
|
|
19
|
-
| guard plugin | Blocks writes to key and credential files (`id_rsa`, `.pem`, `.ssh/`…), catastrophic commands (`rm -rf /`, formatting a disk), every other real data loss judged against the repository's state, a recursive scan of a whole filesystem (`find /`), and changes inside your wiki's protected folders. Refuses the first write to `user-rules.md` or memory once, so the choice is yours | enforced | No tokens | `GENESEED_GUARD=off`, or `GENESEED_GUARD=warn` to log instead of block |
|
|
19
|
+
| guard plugin | Blocks writes to key and credential files (`id_rsa`, `.pem`, `.ssh/`…), catastrophic commands (`rm -rf /`, formatting a disk), every other real data loss judged against the repository's state, a recursive scan of a whole filesystem (`find /`), and changes inside your wiki's protected folders. Refuses the first write to `user-rules.md` or memory once, so the choice is yours. In an application repo with no `## Ownership` section in its root `AGENTS.md`, refuses the session's first write once so the agent proposes the [ownership](../concepts/ownership.md) setup | enforced | No tokens | `GENESEED_GUARD=off`, or `GENESEED_GUARD=warn` to log instead of block; the ownership refusal alone: `mode: off` in the repo's `## Ownership`, or rebuild with `--no-ownership-gate` |
|
|
20
20
|
| learn plugin | Once a session has been quiet for 60 seconds, distils durable facts into `memory/` with the model the session already uses | automatic | One model call per quiet session | `geneseed exclude add <folder>` silences it in that folder |
|
|
21
21
|
| activity plugin | Writes one small file per session that the web console's Activity view shows: what the session does now, its sub-agents, the files each of them changed (by path inside the repository), its turns, how full its context is and its compactions | automatic | No tokens | `GENESEED_ACTIVITY=off` |
|
|
22
22
|
| notify plugin | A desktop notification when a turn took longer than 30 seconds | automatic | No tokens | `GENESEED_NOTIFY=off` |
|
package/docs/web-ui.md
CHANGED
|
@@ -111,13 +111,14 @@ streams the output of background jobs and keeps their history across reloads.
|
|
|
111
111
|
content the page last read — if an agent session edited the file meanwhile, the save
|
|
112
112
|
409s and the page reloads instead of clobbering it.
|
|
113
113
|
- **Constitution** (`#/laws`) — the whole governance surface on one page, in three bands:
|
|
114
|
-
the **Ethos** (
|
|
114
|
+
the **Ethos** (five prose sections), the **Dictates** (the nine numbered Rules, with
|
|
115
115
|
a class facet — only non-empty classes render, and two of the six have had no invariant
|
|
116
116
|
since the split), and the **Doctrines** (one group per pack, each marked active or not for
|
|
117
117
|
this install). Rules I, III and IV each carry a switch for the install's hook gate — the
|
|
118
118
|
secrets gate, the done gate and the deletion gate (`--no-secrets-gate`, `--no-done-gate`,
|
|
119
119
|
`--no-deletion-gate`; *Enforced by* reads *Gate off* while one is off) — flipping one asks,
|
|
120
|
-
then rebuilds the install once; the other Rules read *no gate*.
|
|
120
|
+
then rebuilds the install once; the other Rules read *no gate*. The ownership gate belongs
|
|
121
|
+
to no Rule, so it has no switch here: rebuild with `--no-ownership-gate` instead. A precedence ladder heads the page (a state pill per rung; ranks 5–6 below). *Gated* and *Changed* narrow the rows; packs fold; staged doctrine changes collect in a sticky *Unapplied changes* bar that holds Revert and the page's one Apply. Every row expands to its full body, lazily fetched. The rail entry is
|
|
121
122
|
labelled *Constitution* while the route, the id and the badge key stay `laws`; deep links
|
|
122
123
|
are `#/item/law/ont:telos`, `#/item/law/IV` and `#/item/law/process.5` — three address
|
|
123
124
|
shapes that cannot collide, because a slug carries a colon no numeral has and a doctrine
|
|
@@ -187,8 +188,9 @@ streams the output of background jobs and keeps their history across reloads.
|
|
|
187
188
|
the files it touched and its todo progress; open one for its detail. Sessions that ended in the last 7 days are listed under
|
|
188
189
|
**Recently ended**, below the live ones. Every host records it:
|
|
189
190
|
the OpenCode plugin, and `geneseed-hook activity` on Claude Code, OpenClaude and Bob.
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
The live sessions open in the **Garden** by default; a **List | Garden** switch (kept in the
|
|
192
|
+
URL with the filters, which apply to both) shows them as a list of cards instead. The Garden
|
|
193
|
+
shows them as pixel bonsai: one shelf per repository (worktrees stand on their
|
|
192
194
|
repo's shelf, tagged ⎇), one tree per session. The pot's glaze is the host (clay Claude Code,
|
|
193
195
|
blue Bob, grey OpenCode, violet OpenClaude); the tree grows taller with turns, its crown
|
|
194
196
|
with context fill, and the tips yellow past 80 %. A compaction cuts the crown flat (it
|
package/harness.config.json
CHANGED
|
@@ -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.
|
|
5
|
+
"version": "4.27.0"
|
|
6
6
|
}
|
package/js/README.md
CHANGED
|
@@ -91,6 +91,7 @@ user co-owns, and the hook verbs those emitted configs then run.
|
|
|
91
91
|
| `hosts.mjs` | The four host config dirs (opencode/claude/bob/openclaude), their `family` (`CLAUDE_STYLE`), plus `resolvePath`/`expanduser` |
|
|
92
92
|
| `hooks.mjs` | The gate verbs, run on every tool call: `git-gate`, `rule-gate`, `tool-gate` (the two gates fused, for Bob), plus `ask`/the gate ledger/`guardGate`. `--host` picks the verdict dialect |
|
|
93
93
|
| `hooks-context.mjs` | The `context` verb — SessionStart: session files plus the repo's context docs |
|
|
94
|
+
| `ownership-gate.mjs` | The ownership first-write gate, last in `rule-gate`: in an application repo (git root + build manifest) whose root `AGENTS.md` has no `## Ownership` section, denies the session's first write once (a tmpdir marker per session). Builtins + `gitRootOf` only. Twin: the OpenCode guard plugin |
|
|
94
95
|
| `hooks-done.mjs` | The done gate (#289): on Stop, inside `learn` and before its spawn, blocks a turn that edited files until `.geneseed/done-checks.txt`'s checks passed after the last edit |
|
|
95
96
|
| `hooks-learn.mjs` | The `learn` verb — Stop/SubagentStop/PreCompact distiller; the hook path's ONE spawn (`$GENESEED_LLM`) |
|
|
96
97
|
| `hooks-prims.mjs` | The Python path/text primitives the hook verbs share (`splitLines`, `readStdin`, a never-throwing `isFile`), plus the activity off switch (`activityOn`) and the do-nothing `activity` verb |
|
package/js/build/render.mjs
CHANGED
|
@@ -54,7 +54,7 @@ export const STRUCTURE = {
|
|
|
54
54
|
// `({{ONTOLOGY}}: {{ONT_TELOS}})` — token on both sides, so the heading and every
|
|
55
55
|
// reference to it move together and a rename can never desync them.
|
|
56
56
|
ONT_TELOS: 'Telos', ONT_EVIDENCE: 'Evidence', ONT_DECISIONS: 'Decisions',
|
|
57
|
-
ONT_CONDUCT: 'Conduct',
|
|
57
|
+
ONT_OWNERSHIP: 'Ownership', ONT_CONDUCT: 'Conduct',
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
/**
|
package/js/build/source.mjs
CHANGED
|
@@ -524,7 +524,8 @@ export function resolveSkillNames(names, {
|
|
|
524
524
|
}
|
|
525
525
|
|
|
526
526
|
/**
|
|
527
|
-
* The
|
|
527
|
+
* The hook gates an install can switch off (the laws', in law order, then the ownership gate,
|
|
528
|
+
* which has no law: `law: null`): the cfg/profile key, the
|
|
528
529
|
* build flag, the carrier marker (`<marker>: off`, written only when off) and the law. ONE
|
|
529
530
|
* table, so the flag, the marker, the rebuild argv, the read-back and `status` cannot drift
|
|
530
531
|
* apart. Every gate is ARMED by default and the law's text binds either way. The deletion row
|
|
@@ -534,6 +535,9 @@ export const GATE_SWITCHES = [
|
|
|
534
535
|
{ key: 'secretsGate', flag: '--no-secrets-gate', arg: 'noSecretsGate', marker: 'Secrets gate', law: 'I' },
|
|
535
536
|
{ key: 'doneGate', flag: '--no-done-gate', arg: 'noDoneGate', marker: 'Done gate', law: 'III' },
|
|
536
537
|
{ key: 'deletionGate', flag: '--no-deletion-gate', arg: 'noDeletionGate', marker: 'Deletion gate', law: 'IV' },
|
|
538
|
+
// Not a law's gate (`law: null`): the ownership first-write gate (js/hosts/ownership-gate.mjs,
|
|
539
|
+
// ruling D25). Its off switch is this flag, never `harness.config.json` (args.mjs says why).
|
|
540
|
+
{ key: 'ownershipGate', flag: '--no-ownership-gate', arg: 'noOwnershipGate', marker: 'Ownership gate', law: null },
|
|
537
541
|
];
|
|
538
542
|
|
|
539
543
|
/**
|
package/js/cli-table.json
CHANGED
|
@@ -336,6 +336,21 @@
|
|
|
336
336
|
"is_flag": true,
|
|
337
337
|
"type": null,
|
|
338
338
|
"hidden": false
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"names": [
|
|
342
|
+
"--no-ownership-gate"
|
|
343
|
+
],
|
|
344
|
+
"dest": "no_ownership_gate",
|
|
345
|
+
"metavar": null,
|
|
346
|
+
"help": "switch the ownership first-write gate off for this install: an application repo with no '## Ownership' section in its root AGENTS.md is no longer stopped once per session before its first write (not a law's gate); written to the carrier as 'Ownership gate: off' and replayed by rebuilds",
|
|
347
|
+
"choices": null,
|
|
348
|
+
"default": false,
|
|
349
|
+
"required": false,
|
|
350
|
+
"nargs": "0",
|
|
351
|
+
"is_flag": true,
|
|
352
|
+
"type": null,
|
|
353
|
+
"hidden": false
|
|
339
354
|
}
|
|
340
355
|
],
|
|
341
356
|
"mutex": []
|
|
@@ -1216,7 +1231,7 @@
|
|
|
1216
1231
|
},
|
|
1217
1232
|
{
|
|
1218
1233
|
"name": "rule-gate",
|
|
1219
|
-
"help": "PreToolUse hook: force an ASK before any write to user-rules.md or memory (Persist Insight backstop)",
|
|
1234
|
+
"help": "PreToolUse hook: force an ASK before any write to user-rules.md or memory (Persist Insight backstop), and stop the first write of a session once in an application repo with no ## Ownership section in its root AGENTS.md (the ownership gate)",
|
|
1220
1235
|
"description": "",
|
|
1221
1236
|
"positionals": [],
|
|
1222
1237
|
"options": [
|
|
@@ -1264,6 +1279,21 @@
|
|
|
1264
1279
|
"is_flag": true,
|
|
1265
1280
|
"type": null,
|
|
1266
1281
|
"hidden": false
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
"names": [
|
|
1285
|
+
"--no-ownership-gate"
|
|
1286
|
+
],
|
|
1287
|
+
"dest": "no_ownership_gate",
|
|
1288
|
+
"metavar": null,
|
|
1289
|
+
"help": "skip the ownership first-write gate (set by the emit when the install was built --no-ownership-gate); every other check still runs",
|
|
1290
|
+
"choices": null,
|
|
1291
|
+
"default": false,
|
|
1292
|
+
"required": false,
|
|
1293
|
+
"nargs": "0",
|
|
1294
|
+
"is_flag": true,
|
|
1295
|
+
"type": null,
|
|
1296
|
+
"hidden": false
|
|
1267
1297
|
}
|
|
1268
1298
|
],
|
|
1269
1299
|
"mutex": []
|
|
@@ -1556,6 +1586,21 @@
|
|
|
1556
1586
|
"is_flag": true,
|
|
1557
1587
|
"type": null,
|
|
1558
1588
|
"hidden": false
|
|
1589
|
+
},
|
|
1590
|
+
{
|
|
1591
|
+
"names": [
|
|
1592
|
+
"--no-ownership-gate"
|
|
1593
|
+
],
|
|
1594
|
+
"dest": "no_ownership_gate",
|
|
1595
|
+
"metavar": null,
|
|
1596
|
+
"help": "skip the ownership first-write gate (set by the emit when the install was built --no-ownership-gate); every other check still runs",
|
|
1597
|
+
"choices": null,
|
|
1598
|
+
"default": false,
|
|
1599
|
+
"required": false,
|
|
1600
|
+
"nargs": "0",
|
|
1601
|
+
"is_flag": true,
|
|
1602
|
+
"type": null,
|
|
1603
|
+
"hidden": false
|
|
1559
1604
|
}
|
|
1560
1605
|
],
|
|
1561
1606
|
"mutex": []
|
package/js/hosts/hooks.mjs
CHANGED
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
*
|
|
11
11
|
* THREE HOSTS, TWO DIALECTS. `--host` names the host that will read the verdict. Claude Code
|
|
12
12
|
* (the default) reads `hookSpecificOutput.permissionDecision: "ask"` and shows the user a
|
|
13
|
-
* prompt
|
|
14
|
-
*
|
|
13
|
+
* prompt; the one `"deny"` (the ownership first-write gate, `./ownership-gate.mjs`) carries
|
|
14
|
+
* its reason to the MODEL instead. `--host bob` is Bob's own protocol: PreToolUse ignores stdout and refuses only on
|
|
15
|
+
* EXIT CODE 2, so `BLOCK_RULES` (Laws I and IV, plus rigor-5 and ops-2) exit 2 with the reason on stderr,
|
|
16
|
+
* as does the ownership gate (through `deny`, with a one-time tail in place of `BOB_FINAL`),
|
|
15
17
|
* and the rest is a stderr line with exit 0; SessionStart context is plain stdout, as on
|
|
16
18
|
* Claude. `--host openclaude` speaks Claude's dialect verbatim (OpenClaude is a Claude Code
|
|
17
19
|
* fork); the flag only picks which root file counts as native for `context`'s discovery.
|
|
@@ -63,6 +65,7 @@ import { currentBranch, gitRootOf, loopLaunched } from './gitref.mjs';
|
|
|
63
65
|
import { LOSS_CANDIDATE_RE, catastrophic, lossReason, stripStructure } from './loss.mjs';
|
|
64
66
|
import { selfAndParents, readStdin, SECRET_RE } from './hooks-prims.mjs';
|
|
65
67
|
import { recordUse } from './usage.mjs';
|
|
68
|
+
import { ownershipBlock } from './ownership-gate.mjs';
|
|
66
69
|
|
|
67
70
|
// ======================================================================================
|
|
68
71
|
// git-gate — Doctrine process 5's tool-boundary backstop
|
|
@@ -175,10 +178,20 @@ export function loopExempt(command, cwd) {
|
|
|
175
178
|
* 378-line module parse, being the only thing on the gate path that needed it.
|
|
176
179
|
* `tests/unit/hook_gates.test.mjs` holds the two byte-identical over non-ASCII reasons.
|
|
177
180
|
*/
|
|
178
|
-
export function askDecision(reason) {
|
|
181
|
+
export function askDecision(reason) { return decisionDoc('ask', reason); }
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The `permissionDecision: "deny"` twin of `askDecision`, same spelling. Claude Code shows an
|
|
185
|
+
* ask's reason to the USER and a deny's reason to the MODEL (hooks reference, the
|
|
186
|
+
* `permissionDecisionReason` row), so a gate whose reason is an instruction to the agent (the
|
|
187
|
+
* ownership gate: "propose the setup") must deny, not ask.
|
|
188
|
+
*/
|
|
189
|
+
export function denyDecision(reason) { return decisionDoc('deny', reason); }
|
|
190
|
+
|
|
191
|
+
function decisionDoc(decision, reason) {
|
|
179
192
|
const value = JSON.stringify(reason)
|
|
180
193
|
.replace(/[\u007f-]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
|
181
|
-
return
|
|
194
|
+
return `{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "${decision}", `
|
|
182
195
|
+ `"permissionDecisionReason": ${value}}}\n`;
|
|
183
196
|
}
|
|
184
197
|
|
|
@@ -284,6 +297,28 @@ function ask(args, verb, rule, reason) {
|
|
|
284
297
|
return 0;
|
|
285
298
|
}
|
|
286
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Said after Bob's ownership block, in place of `BOB_FINAL`: this block is NOT final. The
|
|
302
|
+
* marker was written before the refusal, so the same write passes once the developer answered.
|
|
303
|
+
*/
|
|
304
|
+
const BOB_ONCE = ' On Bob this block is one-time, not final: the same write passes once the '
|
|
305
|
+
+ 'developer has answered.';
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Refuse, and record it, for a gate whose reason the AGENT must read (`denyDecision`), not a
|
|
309
|
+
* prompt for the user. Not `ask`: the ownership rule is not in `BLOCK_RULES`, so on Bob `ask`
|
|
310
|
+
* would warn and let the call through. Bob: exit 2 with `BOB_ONCE`, never `BOB_FINAL`.
|
|
311
|
+
*/
|
|
312
|
+
function deny(args, verb, rule, reason) {
|
|
313
|
+
ledger(args && args.root, verb, rule);
|
|
314
|
+
if (HOST === 'bob') {
|
|
315
|
+
err(`[geneseed] BLOCKED: ${reason}${BOB_ONCE}\n`);
|
|
316
|
+
return BOB_DENY_EXIT;
|
|
317
|
+
}
|
|
318
|
+
out(denyDecision(reason));
|
|
319
|
+
return 0;
|
|
320
|
+
}
|
|
321
|
+
|
|
287
322
|
/**
|
|
288
323
|
* FAIL CLOSED. Wraps a gate verb so that any throw — a payload that is not JSON, a path
|
|
289
324
|
* primitive refusing a form, a bug — becomes an `ask` carrying the error, never a silent
|
|
@@ -615,7 +650,12 @@ function ruleDecide(args, payload) {
|
|
|
615
650
|
+ 'check: fix the code, not the check, unless the user asks for this edit.');
|
|
616
651
|
}
|
|
617
652
|
const target = ruleGateTarget(p, args.root);
|
|
618
|
-
if (!target)
|
|
653
|
+
if (!target) {
|
|
654
|
+
// The ownership first-write gate (./ownership-gate.mjs), last: every rule above outranks it.
|
|
655
|
+
// `--no-ownership-gate`: the install switched it off (D25).
|
|
656
|
+
const why = args.noOwnershipGate ? null : ownershipBlock(p, payload, body, args.root);
|
|
657
|
+
return why ? deny(args, 'rule-gate', 'ownership', why) : 0;
|
|
658
|
+
}
|
|
619
659
|
return ask(args, 'rule-gate', 'process-1', `Geneseed (Persist Insight) \u2014 writing to `
|
|
620
660
|
+ `${target}: a standing rule, or a fact to remember? That choice is the user's. Run the `
|
|
621
661
|
+ 'rule skill first.');
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ownership first-write gate — the hook half of the ownership skill (`src/skills/ownership.md`).
|
|
3
|
+
*
|
|
4
|
+
* In an APPLICATION repo (a git root holding a build manifest) whose root `AGENTS.md` has no
|
|
5
|
+
* `## Ownership` section outside Geneseed's managed block, the first write of a session is
|
|
6
|
+
* refused once, with a reason telling the agent to propose the setup to the developer. The hook
|
|
7
|
+
* never sees the developer's answer, so "once" is a marker: the root is recorded per session
|
|
8
|
+
* BEFORE the refusal, and every later write in that (session, repo) passes. The `AGENT.md`
|
|
9
|
+
* pointer line carries the rest, shell writes included (this gate sees Write|Edit|NotebookEdit,
|
|
10
|
+
* and Bob's write tools, only).
|
|
11
|
+
*
|
|
12
|
+
* ON THE HOOK PATH, so builtins plus `gitRootOf` and `normcase` only — both already loaded by
|
|
13
|
+
* `./hooks.mjs`. `managedBlockWrite`'s delimiters are inlined, not imported: `settings.mjs` is a
|
|
14
|
+
* 1 200-line module the gate path must not parse. NEVER THROWS: a throw would reach `guardGate`
|
|
15
|
+
* and become a gate-error ask on every write in every repo; any surprise is a defer.
|
|
16
|
+
*
|
|
17
|
+
* The OpenCode guard (`adapters/opencode/plugins/geneseed-guard.js`, `ownershipBlock`) is this
|
|
18
|
+
* file's twin and cannot import it — keep the two in step.
|
|
19
|
+
*/
|
|
20
|
+
import { appendFileSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
|
|
21
|
+
import os from 'node:os';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import { normcase } from '../lib/paths.mjs';
|
|
24
|
+
import { gitRootOf } from './gitref.mjs';
|
|
25
|
+
|
|
26
|
+
// D5: the build manifests that make a git root an "application". Exact names, plus two families.
|
|
27
|
+
const MANIFESTS = new Set(['package.json', 'pom.xml', 'pyproject.toml', 'go.mod', 'Cargo.toml',
|
|
28
|
+
'composer.json', 'Gemfile']);
|
|
29
|
+
const isManifest = (n) => MANIFESTS.has(n) || n.startsWith('build.gradle') || n.endsWith('.csproj');
|
|
30
|
+
|
|
31
|
+
// `managedBlockWrite`'s delimiters (js/hosts/settings.mjs `delimiters('GENESEED')`). On a Bob
|
|
32
|
+
// project install the block holds the whole carrier, `#### Ownership` included — hence the strip
|
|
33
|
+
// and the exact `##` heading match. `\r?`: a CRLF file's `$` sits after the `\r`.
|
|
34
|
+
const MANAGED_BLOCK_RE = /<!-- BEGIN GENESEED -->[\s\S]*?<!-- END GENESEED -->/g;
|
|
35
|
+
const SECTION_RE = /^## Ownership[ \t]*\r?$/m;
|
|
36
|
+
|
|
37
|
+
// Write-shaped tool names (Bob's `tool-gate` also routes reads here: `read_file` carries a path).
|
|
38
|
+
const WRITE_NAME_RE = /write|edit|diff|replace|insert/i;
|
|
39
|
+
|
|
40
|
+
// js/hosts/activity.mjs `safeStem`, copied (that module is not on the gate path): a hostile
|
|
41
|
+
// session id can never steer the marker join out of its directory.
|
|
42
|
+
const safeStem = (sid) => String(sid).replace(/[^A-Za-z0-9_.-]/gu, '_').slice(0, 128);
|
|
43
|
+
|
|
44
|
+
// The marker folder is PER USER: on a shared POSIX /tmp, one folder for everyone would let a
|
|
45
|
+
// second user's marker (or a file planted at the folder's name) silently disarm the gate for
|
|
46
|
+
// the first. The uid where there is one; else the user name; Windows' tmpdir is per user anyway.
|
|
47
|
+
function userTag() {
|
|
48
|
+
if (typeof process.getuid === 'function') return String(process.getuid());
|
|
49
|
+
try { return safeStem(os.userInfo().username); } catch { return 'user'; }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const TAIL = 'Opt out per repo: `## Ownership` with `mode: off` in the root `AGENTS.md`; per '
|
|
53
|
+
+ 'install: rebuild with `--no-ownership-gate`. Offer the full documentation '
|
|
54
|
+
+ '(`/document-project`) as yes / later. Stop and ask the developer now; re-issue the write only '
|
|
55
|
+
+ 'after they answer. This gate fires once per session and repo.';
|
|
56
|
+
const REASON_NONE = 'Geneseed (Ownership) — this application has no `AGENTS.md` with '
|
|
57
|
+
+ '`## Ownership`. Before writing, propose to the developer: set it up (ownership skill), or '
|
|
58
|
+
+ `proceed without for this session. ${TAIL}`;
|
|
59
|
+
const REASON_NO_SECTION = 'Geneseed (Ownership) — this application\'s `AGENTS.md` has no '
|
|
60
|
+
+ '`## Ownership` section. Before writing, ask the developer: add the Ownership section '
|
|
61
|
+
+ `(ownership skill), or proceed without for this session? ${TAIL}`;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The refusal reason for this write, or null to defer. `p` is the write target as the payload
|
|
65
|
+
* names it; `body` is the text the write carries (`ruleDecide` already joined it); `installRoot`
|
|
66
|
+
* is the install's own dir (`--root`), whose bookkeeping (memory, notebook) never spends the block.
|
|
67
|
+
*/
|
|
68
|
+
export function ownershipBlock(p, payload, body, installRoot = null) {
|
|
69
|
+
try {
|
|
70
|
+
const sid = payload && payload.session_id;
|
|
71
|
+
if (typeof sid !== 'string' || !sid) return null;
|
|
72
|
+
// D29: a sub-agent cannot ask the user, and must not spend the session's one block.
|
|
73
|
+
if (payload.agent_id) return null;
|
|
74
|
+
if (!body && !WRITE_NAME_RE.test(String(payload.tool_name || ''))) return null;
|
|
75
|
+
const target = path.resolve(typeof payload.cwd === 'string' ? payload.cwd : '.', p);
|
|
76
|
+
const root = gitRootOf(path.dirname(target));
|
|
77
|
+
if (!root || !readdirSync(root).some(isManifest)) return null;
|
|
78
|
+
// Writing the setup itself is never what the gate stops.
|
|
79
|
+
const rel = normcase(path.relative(root, target));
|
|
80
|
+
if (rel === normcase('AGENTS.md') || rel.startsWith(normcase('.geneseed/'))) return null;
|
|
81
|
+
if (installRoot) {
|
|
82
|
+
const inInstall = path.relative(path.resolve(installRoot), target);
|
|
83
|
+
if (!inInstall.startsWith('..') && !path.isAbsolute(inInstall)) return null;
|
|
84
|
+
}
|
|
85
|
+
let text = null;
|
|
86
|
+
try { text = readFileSync(path.join(root, 'AGENTS.md'), 'utf8'); } catch { /* none: gate */ }
|
|
87
|
+
const own = text === null ? '' : text.replace(MANAGED_BLOCK_RE, '');
|
|
88
|
+
if (SECTION_RE.test(own)) return null; // on or off, the team has decided
|
|
89
|
+
// shortcut: one small marker file per session, never pruned (the OS temp cleaner owns it);
|
|
90
|
+
// prune here if the folder is ever seen to grow past a few thousand files.
|
|
91
|
+
const dir = path.join(os.tmpdir(), `geneseed-ownership-${userTag()}`);
|
|
92
|
+
const marker = path.join(dir, safeStem(sid));
|
|
93
|
+
const key = normcase(root);
|
|
94
|
+
let seen = '';
|
|
95
|
+
try { seen = readFileSync(marker, 'utf8'); } catch { /* first gated write of the session */ }
|
|
96
|
+
if (seen.split('\n').includes(key)) return null;
|
|
97
|
+
// Recorded BEFORE refusing: a marker that cannot be written must defer, or every write of
|
|
98
|
+
// the session would be refused.
|
|
99
|
+
mkdirSync(dir, { recursive: true });
|
|
100
|
+
appendFileSync(marker, `${key}\n`);
|
|
101
|
+
return own.trim() ? REASON_NO_SECTION : REASON_NONE;
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
package/js/hosts/settings.mjs
CHANGED
|
@@ -728,7 +728,7 @@ export function mergeOpencodeJson(p, agentPath, doctrines = null, excluded = [],
|
|
|
728
728
|
export function claudeHookGroups(cfg, hookOpts, doctrines = null, excluded = [], host = 'claude',
|
|
729
729
|
gates = {}) {
|
|
730
730
|
// One object keyed as `GATE_SWITCHES` keys it; only an explicit `false` disarms a gate.
|
|
731
|
-
const { secretsGate = true, doneGate = true, deletionGate = true } = gates ?? {};
|
|
731
|
+
const { secretsGate = true, doneGate = true, deletionGate = true, ownershipGate = true } = gates ?? {};
|
|
732
732
|
const run = hookPrefix(hookOpts);
|
|
733
733
|
const mem = `--memory "${path.join(cfg, 'memory')}"`;
|
|
734
734
|
// --root carries the install's own dir so a GLOBAL hook can stand down when a live, wired
|
|
@@ -767,6 +767,8 @@ export function claudeHookGroups(cfg, hookOpts, doctrines = null, excluded = [],
|
|
|
767
767
|
// 2026-10-18): each flag only when that gate is off.
|
|
768
768
|
const sg = secretsGate === false ? ' --no-secrets-gate' : '';
|
|
769
769
|
const dn = doneGate === false ? ' --no-done-gate' : '';
|
|
770
|
+
// The ownership first-write gate (js/hosts/ownership-gate.mjs), the same contract.
|
|
771
|
+
const og = ownershipGate === false ? ' --no-ownership-gate' : '';
|
|
770
772
|
return {
|
|
771
773
|
SessionStart: [{ hooks: [{ type: 'command', command: `${run} context --root "${cfg}"${b} || exit 0` }] }],
|
|
772
774
|
// One group, both gates: process 5's consent is a stderr line here (Bob has no ask
|
|
@@ -775,7 +777,7 @@ export function claudeHookGroups(cfg, hookOpts, doctrines = null, excluded = [],
|
|
|
775
777
|
// `--no-deletion-gate`), and for a
|
|
776
778
|
// write under a project's own `.geneseed/protected-checks.txt` — the project opted in —
|
|
777
779
|
// and for a recursive scan rooted at a whole filesystem (ops 2, the root-scan check).
|
|
778
|
-
PreToolUse: [{ hooks: [{ type: 'command', command: `${run} tool-gate --root "${cfg}"${b}${sg}${dg}` }] }],
|
|
780
|
+
PreToolUse: [{ hooks: [{ type: 'command', command: `${run} tool-gate --root "${cfg}"${b}${sg}${dg}${og}` }] }],
|
|
779
781
|
// Bob's Stop payload never carries `transcript_path` (I2) — `learn` reads `--host bob`
|
|
780
782
|
// and returns immediately rather than wasting a model call on the bare envelope. KEPT
|
|
781
783
|
// rather than DROPPED: the stand-down costs nothing (no transcript read, no spawn), and
|
|
@@ -800,7 +802,10 @@ export function claudeHookGroups(cfg, hookOpts, doctrines = null, excluded = [],
|
|
|
800
802
|
// `--no-secrets-gate` skips only rule-gate's credential scan (rigor 5 and process 1 still
|
|
801
803
|
// run); `--no-done-gate` only learn's done check, never the distillation. One `learn` string
|
|
802
804
|
// feeds Stop, SubagentStop and PreCompact, and the flag sits before `|| exit 0`.
|
|
803
|
-
|
|
805
|
+
// `--no-ownership-gate` (the ownership first-write gate) rides rule-gate only, never the
|
|
806
|
+
// `Skill|Agent|Task` tool-gate below, which judges no write.
|
|
807
|
+
const ruleGate = `${run} rule-gate --root "${cfg}"${secretsGate === false ? ' --no-secrets-gate' : ''}`
|
|
808
|
+
+ (ownershipGate === false ? ' --no-ownership-gate' : '');
|
|
804
809
|
const learn = `${run} learn ${mem}${h}${doneGate === false ? ' --no-done-gate' : ''} || exit 0`;
|
|
805
810
|
const activity = `${run} activity --root "${cfg}"${h} || exit 0`;
|
|
806
811
|
// Claude Code only (hooks.md, v2.1.295+; Task 1): a `command` hook that can't start, times
|
package/js/inspect/cost.mjs
CHANGED
|
@@ -35,7 +35,7 @@ import { isFile, readText } from '../lib/fs.mjs';
|
|
|
35
35
|
* console draws it on the cost chart, so it lives here, once, where both read it. Raise it by
|
|
36
36
|
* exactly the measured overrun and say why in that test's docblock, which keeps its history.
|
|
37
37
|
*/
|
|
38
|
-
export const CARRIER_CEILING = { full:
|
|
38
|
+
export const CARRIER_CEILING = { full: 65_715, lean: 41_085 };
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* A frontmatter value as the host shows it. The emit writes descriptions JSON-escaped
|
package/js/inspect/inventory.mjs
CHANGED
|
@@ -95,7 +95,7 @@ export const SKILL_CLASS = {
|
|
|
95
95
|
'codebase-design': 'design', wayfinder: 'design',
|
|
96
96
|
develop: 'build', refactor: 'build', debug: 'build', dependencies: 'build',
|
|
97
97
|
'frontend-design': 'build', prototype: 'build', deck: 'build',
|
|
98
|
-
'forge-mcp': 'build', bruno: 'build', worktree: 'build',
|
|
98
|
+
'forge-mcp': 'build', bruno: 'build', worktree: 'build', ownership: 'build',
|
|
99
99
|
'spring-boot': 'build', 'spring-data-jpa': 'build', 'spring-testing': 'build',
|
|
100
100
|
react: 'build', 'react-testing': 'build',
|
|
101
101
|
'geneseed-code-review': 'review', 'fresh-eyes': 'review', 'security-audit': 'review',
|
package/js/inspect/status.mjs
CHANGED
|
@@ -461,7 +461,7 @@ export function statusLines(d, color = false) {
|
|
|
461
461
|
...(p.kits?.length ? [`kits: ${p.kits.join(',')}`] : []),
|
|
462
462
|
// Each elided when armed. The law's text still binds; only its tool-boundary gate is off.
|
|
463
463
|
...GATE_SWITCHES.filter((g) => p[g.key] === false)
|
|
464
|
-
.map((g) => `${g.marker.toLowerCase()}: off (Law ${g.law} text still binds)`)]
|
|
464
|
+
.map((g) => `${g.marker.toLowerCase()}: off${g.law ? ` (Law ${g.law} text still binds)` : ''}`)]
|
|
465
465
|
.join(` ${DOT} `) + where]);
|
|
466
466
|
// R6: a member its owner edited outlives its kit; name it, so turning the kit off is visible.
|
|
467
467
|
for (const [kit, rels] of Object.entries(p.keptKitFiles ?? {})) {
|