brainclaw 1.5.4 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +52 -28
  2. package/dist/brainclaw-vscode.vsix +0 -0
  3. package/dist/cli.js +159 -12
  4. package/dist/commands/assignment-resource.js +182 -0
  5. package/dist/commands/bootstrap-loop.js +206 -0
  6. package/dist/commands/init.js +158 -22
  7. package/dist/commands/loop.js +156 -0
  8. package/dist/commands/loops-handlers.js +110 -55
  9. package/dist/commands/mcp-read-handlers.js +45 -4
  10. package/dist/commands/mcp.js +628 -205
  11. package/dist/commands/questions.js +180 -0
  12. package/dist/commands/reply.js +190 -0
  13. package/dist/commands/session-end.js +105 -3
  14. package/dist/commands/session-start.js +32 -53
  15. package/dist/commands/setup.js +87 -48
  16. package/dist/commands/switch.js +21 -1
  17. package/dist/core/agentrun-reconciler.js +65 -0
  18. package/dist/core/agentruns.js +10 -0
  19. package/dist/core/assignments.js +29 -10
  20. package/dist/core/claims.js +29 -0
  21. package/dist/core/context.js +1 -1
  22. package/dist/core/coordination.js +1 -1
  23. package/dist/core/dispatch-status.js +219 -0
  24. package/dist/core/entity-operations.js +166 -10
  25. package/dist/core/entity-registry.js +11 -10
  26. package/dist/core/execution-adapters.js +38 -2
  27. package/dist/core/facade-schema.js +55 -0
  28. package/dist/core/federation-cloud.js +27 -12
  29. package/dist/core/federation-materialize.js +57 -0
  30. package/dist/core/instruction-templates.js +2 -0
  31. package/dist/core/loops/bootstrap-acquire.js +195 -0
  32. package/dist/core/loops/facade-schema.js +68 -1
  33. package/dist/core/loops/hooks/bootstrap-write.js +144 -0
  34. package/dist/core/loops/hooks/notify-operator.js +148 -0
  35. package/dist/core/loops/hooks/survey-source-reader.js +256 -0
  36. package/dist/core/loops/index.js +8 -2
  37. package/dist/core/loops/next-expected.js +63 -0
  38. package/dist/core/loops/presets/bootstrap.js +75 -0
  39. package/dist/core/loops/presets/index.js +16 -0
  40. package/dist/core/loops/store.js +224 -4
  41. package/dist/core/loops/types.js +346 -1
  42. package/dist/core/loops/verbs.js +739 -6
  43. package/dist/core/schema.js +31 -2
  44. package/dist/core/state.js +62 -0
  45. package/dist/core/store-resolution.js +26 -16
  46. package/dist/facts.js +7 -5
  47. package/dist/facts.json +6 -4
  48. package/docs/cli.md +115 -30
  49. package/docs/concepts/dispatch-lifecycle.md +228 -0
  50. package/docs/concepts/loop-engine.md +55 -0
  51. package/docs/concepts/multi-agent-workflows.md +167 -166
  52. package/docs/concepts/troubleshooting.md +10 -2
  53. package/docs/integrations/agents.md +14 -14
  54. package/docs/integrations/codex.md +15 -12
  55. package/docs/integrations/mcp.md +10 -4
  56. package/docs/integrations/overview.md +11 -0
  57. package/docs/playbooks/productivity/index.md +3 -3
  58. package/docs/quickstart-existing-project.md +48 -28
  59. package/docs/quickstart.md +42 -28
  60. package/package.json +1 -1
@@ -187,17 +187,24 @@ brainclaw stale resolve <plan_id> # → dropped (default for stale)
187
187
  ```bash
188
188
  # 1. Is the worker process still alive?
189
189
  ps -ef | grep <agent-binary> # codex, claude, copilot, …
190
+ # Windows: Get-Process -Id <pid> # or `tasklist /FI "PID eq <pid>"`
190
191
 
191
192
  # 2. Did the brief-ack file land?
192
193
  ls .brainclaw/coordination/runtime/ack/<assignment_id>.ack
193
194
  # If yes → spawn started, worker is somewhere in its loop
194
195
  # If no → spawn never started or died before the wrap shell ran touch
195
196
 
196
- # 3. Inspect the worktree for activity
197
+ # 3. (pln#504) What did the worker actually say? stdout/stderr capture
198
+ # Spawned workers now route their streams to per-assignment log files. If the
199
+ # worker died silently, the error usually shows up here.
200
+ cat .brainclaw/coordination/runtime/log/<assignment_id>.stdout.log
201
+ cat .brainclaw/coordination/runtime/log/<assignment_id>.stderr.log
202
+
203
+ # 4. Inspect the worktree for activity
197
204
  git -C <worktree> log --oneline -5
198
205
  git -C <worktree> status
199
206
 
200
- # 4. Check the run log
207
+ # 5. Check the run log
201
208
  brainclaw inbox list --agent <agent>
202
209
  # or via MCP: bclaw_assignment_events(assignmentId="<id>")
203
210
  ```
@@ -213,6 +220,7 @@ brainclaw inbox list --agent <agent>
213
220
 
214
221
  ## See also
215
222
 
223
+ - [`docs/concepts/dispatch-lifecycle.md`](dispatch-lifecycle.md) — the entity model + FSMs + observability decision tree underlying every diagnostic step on this page
216
224
  - [`docs/concepts/memory-staleness.md`](memory-staleness.md) — staleness signals and resolve flow in depth
217
225
  - [`docs/concepts/loop-engine.md`](loop-engine.md) — multi-turn loops (review-fix), recovery semantics for in-flight loops
218
226
  - [`docs/concepts/upgrade-cli.md`](upgrade-cli.md) — `brainclaw upgrade` design + rollback path
@@ -62,20 +62,20 @@ Skill-based integration via `skills/<agent>/SKILL.md`:
62
62
 
63
63
  ## Setting up agent integration
64
64
 
65
- ### Automatic (recommended)
66
-
67
- ```bash
68
- brainclaw setup # machine-level: detects agents, creates global configs
69
- brainclaw init # project-level: creates .brainclaw/, writes agent files
70
- ```
71
-
72
- Or ask your coding agent to do it:
73
-
74
- ```
75
- "Install and initialize brainclaw in this project"
76
- ```
77
-
78
- The agent can use `bclaw_setup` to walk through the process interactively.
65
+ ### Automatic (recommended)
66
+
67
+ ```bash
68
+ brainclaw setup-machine # machine-level: detects agents, creates global configs
69
+ brainclaw init # project-level: creates or refreshes .brainclaw/, writes agent files
70
+ ```
71
+
72
+ Or ask your coding agent to do it:
73
+
74
+ ```
75
+ "Inspect this package, explain what brainclaw does, then install it and initialize or join this project"
76
+ ```
77
+
78
+ The agent can use `bclaw_setup` to walk through the process interactively.
79
79
 
80
80
  ### Per-agent manual setup
81
81
 
@@ -4,7 +4,14 @@ brainclaw integrates with OpenAI's Codex CLI through MCP tools and shared instru
4
4
 
5
5
  ## Auto-setup
6
6
 
7
- `brainclaw init` detects Codex (the presence of `~/.codex/`) and writes `AGENTS.md` to the project root. The MCP server is registered machine-wide at `~/.codex/mcp-config.json`. To regenerate manually:
7
+ Codex setup is split across machine and project scope:
8
+
9
+ - `brainclaw setup-machine --agents codex --yes` writes the machine-level MCP config at `~/.codex/config.toml`
10
+ - `brainclaw init` creates or refreshes the current project's Brainclaw state and writes `AGENTS.md`
11
+
12
+ If the project already has `.brainclaw/`, rerunning `brainclaw init` is safe and refreshes the managed Brainclaw/Codex files for the current machine.
13
+
14
+ To regenerate project instructions manually:
8
15
 
9
16
  ```bash
10
17
  brainclaw export --format agents-md --write
@@ -12,17 +19,13 @@ brainclaw export --format agents-md --write
12
19
 
13
20
  ## MCP configuration
14
21
 
15
- Codex reads MCP servers from a machine-level config (`~/.codex/mcp-config.json` on most installs). brainclaw is registered as:
16
-
17
- ```json
18
- {
19
- "mcpServers": {
20
- "brainclaw": {
21
- "command": "npx",
22
- "args": ["-y", "brainclaw@latest", "mcp"]
23
- }
24
- }
25
- }
22
+ Codex reads MCP servers from a machine-level config (`~/.codex/config.toml` on most installs). brainclaw is registered as:
23
+
24
+ ```toml
25
+ [mcp_servers.brainclaw]
26
+ command = "npx"
27
+ args = ["-y", "brainclaw@latest", "mcp"]
28
+ startup_timeout_ms = 20000
26
29
  ```
27
30
 
28
31
  Per-session MCP config can also be passed via `--additional-mcp-config @<file>` when invoking Codex.
@@ -156,10 +156,16 @@ for the full 1.0.0 changelog.
156
156
  | `bclaw_remove(entity, id, purge?)` | Archive (default) or hard-delete | `bclaw_delete_memory`, `bclaw_delete_plan` |
157
157
  | `bclaw_transition(entity, id, to, reason?)` | State machine transition with side-effect tags | `bclaw_accept`, `bclaw_reject`, status-update flows |
158
158
 
159
- Supported entities: plan, decision, constraint, trap, handoff,
160
- runtime_note, candidate, claim, action, assignment, agent_run
161
- (read-only for the latter four). Declarative transition matrix +
162
- updatable field list live in [src/core/entity-registry.ts](../../src/core/entity-registry.ts).
159
+ Supported entities: plan, decision, constraint, trap, handoff,
160
+ runtime_note, candidate, claim, action, assignment, agent_run
161
+ (with assignment lifecycle now writable through `bclaw_transition` and
162
+ `bclaw_remove`; `agent_run` remains read-only). Declarative transition matrix +
163
+ updatable field list live in [src/core/entity-registry.ts](../../src/core/entity-registry.ts).
164
+
165
+ For assignments specifically:
166
+ - `bclaw_transition(entity="assignment", id=..., to="cancelled", reason=...)` is the canonical supervisor/admin cancel path.
167
+ - `bclaw_remove(entity="assignment", id=...)` archives by cancelling the assignment.
168
+ - `bclaw_remove(entity="assignment", id=..., purge=true)` hard-deletes the assignment record.
163
169
 
164
170
  ##### `bclaw_find` filter keys
165
171
 
@@ -2,6 +2,17 @@
2
2
 
3
3
  Brainclaw works alongside your existing coding agents. It does not replace them — it gives them a shared memory and coordination layer they can all read from and write to.
4
4
 
5
+ For coordination internals — what happens when brainclaw spawns or routes work to another agent (claims, assignments, brief-ack sentinels, stdout/stderr log files, FSM transitions) — see [../concepts/dispatch-lifecycle.md](../concepts/dispatch-lifecycle.md).
6
+
7
+ ## Onboarding model
8
+
9
+ There are two separate setup scopes:
10
+
11
+ - **Machine scope** — `brainclaw setup-machine` (or the broader `brainclaw setup`) detects agents on this machine and writes the machine-level MCP/user config Brainclaw manages.
12
+ - **Project scope** — `brainclaw init` creates or refreshes `.brainclaw/` for the current repository and rewrites the managed project/agent files safely.
13
+
14
+ That split is deliberate. A fresh machine may need MCP registration before any repository is touched, while an existing project may already have `.brainclaw/` and only need a safe refresh for the arriving agent.
15
+
5
16
  ## How agents connect to brainclaw
6
17
 
7
18
  Brainclaw reaches each agent through multiple surfaces. Not every agent supports every surface, and that's fine — brainclaw adapts what it writes based on what the agent can handle.
@@ -89,9 +89,9 @@ Context profiles are hardcoded in `context.ts` with fixed section weights (plans
89
89
  `rollback.ts` can revert a single item to its previous state via audit snapshots, but there is no batch undo ("undo all changes from session X"), no point-in-time restore, no "undo last 5 edits" convenience.
90
90
  **Impact:** If an agent writes bad memory, cleanup is manual and item-by-item.
91
91
 
92
- ### No init repair path
93
- If `brainclaw init` partially fails or produces a bad config, there is no `brainclaw repair` command. Re-init requires `--force` which risks destroying existing memory. `bclaw_doctor` checks for issues but auto-repairs very little.
94
- **Impact:** Corrupted setups require manual intervention that non-tech creators cannot do.
92
+ ### No init repair path
93
+ If `brainclaw init` partially fails or produces a bad config, there is still no focused `brainclaw repair-init` path. Re-running `brainclaw init` is now a safe upsert for existing projects, and `--force` rebuilds the managed setup from defaults while preserving canonical memory, but `bclaw_doctor` still auto-repairs very little.
94
+ **Impact:** Corrupted setups require manual intervention that non-tech creators cannot do.
95
95
 
96
96
  ### Cross-project learning is manual only
97
97
  Projects are siloed. Federation exists (`federation-transport.ts`) but requires explicit config and manual push/pull. There is no auto-detection of common learnings across projects (e.g., "3 projects use React, here are shared patterns"). No cross-project search.
@@ -6,13 +6,17 @@ If the repo is brand new and `.brainclaw/` is absent, see [quickstart.md](quicks
6
6
 
7
7
  ## When to use this page
8
8
 
9
- | Situation | Use |
10
- |---|---|
11
- | Repo has no `.brainclaw/` | [quickstart.md](quickstart.md) (`brainclaw init`) |
12
- | Repo has `.brainclaw/`, you've never worked here | **this page** (`brainclaw enable-agent` + discovery) |
13
- | Repo has memory but it was scraped from docs/git, not curated | [bootstrap](concepts/workspace-bootstrapping.md) (`brainclaw bootstrap --apply`) |
14
-
15
- The three commands target different lifecycle stages: `init` creates, `bootstrap` extracts, `enable-agent` joins.
9
+ | Situation | Use |
10
+ |---|---|
11
+ | Repo has no `.brainclaw/` | [quickstart.md](quickstart.md) (`brainclaw init`) |
12
+ | Repo has `.brainclaw/`, you've never worked here | **this page** (`brainclaw init` upsert + discovery) |
13
+ | Repo has memory but it was scraped from docs/git, not curated | [bootstrap](concepts/workspace-bootstrapping.md) (`brainclaw bootstrap --apply`) |
14
+
15
+ The three commands now target different lifecycle stages:
16
+ - `setup-machine` bootstraps the current machine
17
+ - `init` creates or refreshes project setup safely
18
+ - `bootstrap` extracts project context into memory
19
+ - `enable-agent` explicitly joins another agent to the same project
16
20
 
17
21
  ## Step 0 — verify your install is compatible
18
22
 
@@ -30,23 +34,39 @@ npm install -g brainclaw@latest
30
34
 
31
35
  (or pull the team's local-pack tarball from `.releases/` if the project doesn't publish to npm.)
32
36
 
33
- ## Step 1 — register your agent on this project
34
-
35
- ```bash
36
- brainclaw enable-agent <agent-name>
37
- ```
38
-
39
- `<agent-name>` is one of `claude-code`, `codex`, `copilot`, `cursor`, `cline`, `windsurf`, `continue`, `kilocode`, `roo`, `opencode`, `antigravity`, etc. (see [docs/integrations/overview.md](integrations/overview.md) for the full list).
40
-
41
- This command:
42
- - Detects the agent in your environment (env vars, installed CLIs, IDE)
43
- - Writes the agent's native instruction file (`CLAUDE.md`, `.cursor/rules/`, `AGENTS.md`, etc.) from the project's current memory
44
- - Wires the MCP server config so the agent can call brainclaw at runtime
45
- - Adds the generated files to `.gitignore` (they're regenerated locally per developer)
46
-
47
- If you use multiple agents on the same project, run `enable-agent` once per agent.
48
-
49
- ## Step 2 read what already exists
37
+ ## Step 1 — bootstrap this machine if needed
38
+
39
+ ```bash
40
+ brainclaw setup-machine --yes
41
+ ```
42
+
43
+ Run this once on a fresh machine so Brainclaw can configure the agents it detects before you touch any project-level state.
44
+
45
+ ## Step 2 — refresh project setup for the current agent
46
+
47
+ ```bash
48
+ brainclaw init
49
+ ```
50
+
51
+ On a project that already has `.brainclaw/`, `brainclaw init` acts as a safe upsert. It preserves the existing memory and refreshes the managed Brainclaw and detected-agent files for the machine you're using now.
52
+
53
+ If you want the explicit path for a different or additional agent, run:
54
+
55
+ ```bash
56
+ brainclaw enable-agent <agent-name>
57
+ ```
58
+
59
+ `<agent-name>` is one of `claude-code`, `codex`, `copilot`, `cursor`, `cline`, `windsurf`, `continue`, `kilocode`, `roo`, `opencode`, `antigravity`, etc. (see [docs/integrations/overview.md](integrations/overview.md) for the full list).
60
+
61
+ These commands:
62
+ - Detect the agent in your environment (env vars, installed CLIs, IDE)
63
+ - Writes the agent's native instruction file (`CLAUDE.md`, `.cursor/rules/`, `AGENTS.md`, etc.) from the project's current memory
64
+ - Wires the MCP server config so the agent can call brainclaw at runtime
65
+ - Adds the generated files to `.gitignore` (they're regenerated locally per developer)
66
+
67
+ If you use multiple agents on the same project, run `enable-agent` once per agent.
68
+
69
+ ## Step 3 — read what already exists
50
70
 
51
71
  Before touching code, load the project's accumulated knowledge so you don't re-discover what others already learned.
52
72
 
@@ -74,7 +94,7 @@ For a narrower view focused on the area you're about to touch:
74
94
  bclaw_context(kind="memory", path="src/<area>/")
75
95
  ```
76
96
 
77
- ## Step 3 — discover in-flight work
97
+ ## Step 4 — discover in-flight work
78
98
 
79
99
  Several things may be already underway when you arrive:
80
100
 
@@ -100,7 +120,7 @@ bclaw_context(kind="board")
100
120
 
101
121
  The board surfaces all four (plans, claims, sequences, handoffs) in one structured response.
102
122
 
103
- ## Step 4 — pick what to work on
123
+ ## Step 5 — pick what to work on
104
124
 
105
125
  You have a few honest options:
106
126
 
@@ -110,7 +130,7 @@ You have a few honest options:
110
130
 
111
131
  In all three cases, the workflow is then the same: `bclaw_work(intent="execute", scope=…, planId=…)` opens a session, claims the scope (with an isolated git worktree), and loads the relevant context.
112
132
 
113
- ## Step 5 — verify your setup is healthy before commiting changes
133
+ ## Step 6 — verify your setup is healthy before commiting changes
114
134
 
115
135
  Once you've started working, sanity-check:
116
136
 
@@ -124,7 +144,7 @@ This runs a series of checks: state validity, MCP runtime health (post-pln#478),
124
144
 
125
145
  - **Creating a new project** → [quickstart.md](quickstart.md)
126
146
  - **Extracting context from an existing repo without `.brainclaw/`** → [bootstrap](concepts/workspace-bootstrapping.md)
127
- - **Setting up brainclaw on your machine for the first time** → [docs/integrations/overview.md](integrations/overview.md) (the `brainclaw setup` flow)
147
+ - **Setting up brainclaw on your machine for the first time** → [docs/integrations/overview.md](integrations/overview.md) (`brainclaw setup-machine` or the broader `brainclaw setup` flow)
128
148
  - **Recovering from a degraded state** → [docs/concepts/troubleshooting.md](concepts/troubleshooting.md)
129
149
 
130
150
  ## See also
@@ -6,32 +6,46 @@ Get brainclaw running in your project in under 5 minutes.
6
6
 
7
7
  If you're about to cut a release that changes the CLI, MCP, or context surface, run the checklist in [release-maintenance.md](release-maintenance.md) before publishing a local pack or npm build.
8
8
 
9
- ## Step 1: Install
10
-
11
- ```bash
12
- npm install -g brainclaw
13
- ```
14
-
15
- Requires Node.js 20+. Verify with `brainclaw --version`.
16
-
17
- ## Step 2: Initialize your project
18
-
19
- ```bash
20
- cd your-project
21
- brainclaw init
22
- ```
23
-
24
- **What happens:**
25
- - Creates `.brainclaw/` directory (project memory store)
26
- - Detects your coding agent (Claude Code, Codex, Cursor, Copilot, Cline, Mistral Vibe, etc.)
27
- - Writes MCP configuration for the detected agent
28
- - Writes instruction files (`CLAUDE.md`, `AGENTS.md`, `.cursor/rules/brainclaw.md`, etc.)
29
- - Installs session hooks (if supported by your agent)
30
- - Adds `.brainclaw/` to `.gitignore`
31
-
32
- If you have multiple repos, use `brainclaw setup --yes` instead — it scans your project directories and initializes everything at once.
33
-
34
- ## Step 3: Restart your agent
9
+ ## Step 1: Install
10
+
11
+ ```bash
12
+ npm install -g brainclaw
13
+ ```
14
+
15
+ Requires Node.js 20+. Verify with `brainclaw --version`.
16
+
17
+ ## Step 2: Bootstrap this machine
18
+
19
+ ```bash
20
+ brainclaw setup-machine --yes
21
+ ```
22
+
23
+ This configures the agents Brainclaw can see on the current machine and writes the machine-level MCP/user files it manages. It does **not** initialize the current repository yet.
24
+
25
+ ## Step 3: Initialize or refresh your project
26
+
27
+ ```bash
28
+ cd your-project
29
+ brainclaw init
30
+ ```
31
+
32
+ **What happens:**
33
+ - Creates `.brainclaw/` when the project is new, or refreshes it safely when it already exists
34
+ - Detects your coding agent (Claude Code, Codex, Cursor, Copilot, Cline, Mistral Vibe, etc.)
35
+ - Refreshes the detected agent's project and machine integration files when applicable
36
+ - Writes instruction files (`CLAUDE.md`, `AGENTS.md`, `.cursor/rules/brainclaw.md`, etc.)
37
+ - Installs session hooks (if supported by your agent)
38
+ - Adds `.brainclaw/` to `.gitignore`
39
+
40
+ If you want the explicit path for a second or late-arriving agent on an already initialized project, use:
41
+
42
+ ```bash
43
+ brainclaw enable-agent <agent-name>
44
+ ```
45
+
46
+ If you have multiple repos, use `brainclaw setup --yes` instead — it bootstraps the machine, scans your project directories, and initializes everything at once.
47
+
48
+ ## Step 4: Restart your agent
35
49
 
36
50
  Your coding agent needs to reload to pick up the new MCP configuration.
37
51
 
@@ -44,7 +58,7 @@ Your coding agent needs to reload to pick up the new MCP configuration.
44
58
  | **Windsurf** | Reload the editor |
45
59
  | **Copilot** | Reload VS Code window (uses instruction file, not MCP) |
46
60
 
47
- ## Step 4: Verify it works
61
+ ## Step 5: Verify it works
48
62
 
49
63
  After reloading, tell your agent:
50
64
 
@@ -62,7 +76,7 @@ brainclaw agent-board # what each agent sees
62
76
  brainclaw context # current project memory
63
77
  ```
64
78
 
65
- ## Step 5: Start using brainclaw
79
+ ## Step 6: Start using brainclaw
66
80
 
67
81
  ### For agents with MCP (most agents)
68
82
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainclaw",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "Shared project memory for humans and coding agents.",
5
5
  "type": "module",
6
6
  "bin": {