brainclaw 1.5.5 → 1.7.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 (58) hide show
  1. package/README.md +5 -4
  2. package/dist/brainclaw-vscode.vsix +0 -0
  3. package/dist/cli.js +124 -7
  4. package/dist/commands/bootstrap-loop.js +206 -0
  5. package/dist/commands/loop.js +156 -0
  6. package/dist/commands/loops-handlers.js +110 -55
  7. package/dist/commands/mcp-read-handlers.js +37 -0
  8. package/dist/commands/mcp-schemas.generated.js +33 -0
  9. package/dist/commands/mcp.js +661 -207
  10. package/dist/commands/questions.js +180 -0
  11. package/dist/commands/reply.js +190 -0
  12. package/dist/commands/session-end.js +105 -3
  13. package/dist/commands/session-start.js +32 -53
  14. package/dist/commands/setup.js +64 -13
  15. package/dist/commands/switch.js +17 -1
  16. package/dist/core/agent-capability.js +19 -0
  17. package/dist/core/agent-files.js +86 -0
  18. package/dist/core/agent-integrations.js +34 -0
  19. package/dist/core/agent-inventory.js +27 -0
  20. package/dist/core/agentrun-reconciler.js +130 -0
  21. package/dist/core/ai-agent-detection.js +17 -1
  22. package/dist/core/claims.js +54 -3
  23. package/dist/core/dirty-scope.js +242 -0
  24. package/dist/core/dispatch-status.js +219 -0
  25. package/dist/core/entity-operations.js +128 -9
  26. package/dist/core/execution-adapters.js +38 -2
  27. package/dist/core/facade-schema.js +71 -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 +30 -2
  44. package/dist/core/state.js +62 -0
  45. package/dist/core/worktree.js +58 -0
  46. package/dist/facts.js +360 -5
  47. package/dist/facts.json +359 -4
  48. package/docs/cli.md +10 -7
  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 +36 -2
  53. package/docs/index.md +4 -3
  54. package/docs/integrations/hermes.md +78 -0
  55. package/docs/integrations/overview.md +22 -18
  56. package/docs/mcp-schema-changelog.md +8 -1
  57. package/docs/quickstart-existing-project.md +1 -1
  58. package/package.json +5 -4
@@ -163,6 +163,60 @@ interface LoopConflictRecord {
163
163
  }
164
164
  ```
165
165
 
166
+ ## Artifact body shapes
167
+
168
+ `LoopArtifact.body` has two known shape categories. Ref-based bodies keep large
169
+ content out of the loop thread JSON and store only file metadata in `body`.
170
+ Inline bodies keep the whole structured payload in `body` for small artifacts
171
+ such as operator questions and answers.
172
+
173
+ Ref-based bodies are JSON encoded as `RefBasedArtifactBody`:
174
+
175
+ - `ref`: string filename within the loop's `artifacts/` directory.
176
+ - `byte_count`: exact byte length of the referenced file at attach time.
177
+ - `sha256`: lowercase hex SHA-256 digest of the referenced file content.
178
+
179
+ The referenced file lives at
180
+ `.brainclaw/loops/threads/<loop_id>/artifacts/<ref>`. The champion or driver
181
+ code that calls `complete_turn` / `add_artifact` is responsible for writing the
182
+ file before or during the attach call, then attaching only
183
+ `JSON.stringify({ ref, byte_count, sha256 })` as the artifact body.
184
+
185
+ These artifact types use the ref-based shape:
186
+
187
+ - `signals_report`: structured discovery or bootstrap signals, often larger
188
+ than the inline body cap.
189
+ - `project_md_draft`: draft `PROJECT.md` content prepared by a loop slot.
190
+ - `project_md_final`: final `PROJECT.md` content accepted by the loop.
191
+ - `file_diff`: unified diff or patch content produced for review or apply.
192
+
193
+ Typical attach flow:
194
+
195
+ ```ts
196
+ const body = '<content>';
197
+ const ref = `<artifact-id>.<ext>`;
198
+ const artifactsDir = path.join(memoryDir(cwd), 'loops', 'threads', loopId, 'artifacts');
199
+ fs.mkdirSync(artifactsDir, { recursive: true });
200
+ fs.writeFileSync(path.join(artifactsDir, ref), body, 'utf8');
201
+ const byte_count = Buffer.byteLength(body, 'utf8');
202
+ const sha256 = crypto.createHash('sha256').update(body, 'utf8').digest('hex');
203
+ complete_turn(
204
+ {
205
+ ...,
206
+ artifact: {
207
+ phase,
208
+ type,
209
+ body: JSON.stringify({ ref, byte_count, sha256 }),
210
+ },
211
+ },
212
+ cwd,
213
+ );
214
+ ```
215
+
216
+ `RefBasedArtifactBodySchema` in `src/core/loops/types.ts` is the authoritative
217
+ validator for this metadata shape. `KNOWN_ARTIFACT_BODY_SCHEMAS` in the same
218
+ file lists which artifact types are ref-based and which use inline JSON bodies.
219
+
166
220
  ## Lifecycle verbs
167
221
 
168
222
  The engine exposes four active verbs. Each one mutates state, appends an event, and returns the updated `LoopThread`. **All verbs are strictly synchronous-on-state and asynchronous-on-work**: any downstream dispatch (spawning a CLI, calling another MCP tool) is fire-and-forget from the commit window, so the per-loop lock is always released quickly.
@@ -450,6 +504,7 @@ Status after Codex schema review (cnd#574 / `dec_be66ccbf`, verdict `needs_revis
450
504
 
451
505
  - [plans-and-claims.md](plans-and-claims.md)
452
506
  - [coordination.md](coordination.md)
507
+ - [dispatch-lifecycle.md](dispatch-lifecycle.md) — entity FSMs (loop / assignment / agent_run / claim), brief-ack semantics, log-file diagnostic playbook
453
508
  - [runtime-notes.md](runtime-notes.md)
454
509
  - pln#394 `feat/loop-engine-mvp`
455
510
  - pln#395 `feat/review-loop-protocol`
@@ -1,166 +1,167 @@
1
- # Multi-Agent Workflows
2
-
3
- brainclaw is built around a small set of memory primitives — **plans**, **claims**, **handoffs**, **decisions**, **traps**, and **runtime notes** — that work the same way whether you're orchestrating multiple agents in parallel right now or letting the next agent (or the next you) pick up the work next week.
4
-
5
- This doc walks through four concrete scenarios. Pick the one that matches what you're doing.
6
-
7
- ---
8
-
9
- ## 1. Active orchestration — parallel work across agent instances
10
-
11
- **Scenario** — you have a sequence of independent lanes and want several agents (same agent, different instances, or several different agents) to work on them in parallel.
12
-
13
- **Walkthrough**:
14
-
15
- 1. Capture the work as plans, then group them into a sequence with explicit lane labels and dependencies:
16
-
17
- ```text
18
- bclaw_create(entity="plan", data={ text: "Refactor auth module", … })
19
- bclaw_create(entity="plan", data={ text: "Add e2e tests", … })
20
-
21
- # Then, via CLI or a follow-up call:
22
- brainclaw sequence create "auth-refactor-cycle" --items '[
23
- {"planId":"pln_aaa","rank":1,"lane":"refactor"},
24
- {"planId":"pln_bbb","rank":2,"lane":"tests","hard_after":["pln_aaa"]}
25
- ]' --status active
26
- ```
27
-
28
- 2. Dispatch the sequence — the dispatcher picks up the ready lanes (no `hard_after` blocking), creates one claim + worktree per lane, and routes inbox messages by `claim_id`:
29
-
30
- ```text
31
- bclaw_dispatch(intent="execute", agents=[<your agents>])
32
- ```
33
-
34
- 3. Each spawned worker runs in its own worktree (so concurrent edits don't collide), reads its inbox, and progresses the plan. Coordinator polls `bclaw_context(kind="board")` to follow progress.
35
-
36
- 4. As each lane lands a commit, merge it into master and release the claim. Lanes with `hard_after` unblock automatically once their predecessors are `done`.
37
-
38
- **What the primitives do here**: claims isolate scope per lane, the sequence's `hard_after` graph orders the work, and worktrees give Git-level isolation so parallel commits don't conflict.
39
-
40
- ---
41
-
42
- ## 2. Agent switching — when an agent runs out of credits mid-task
43
-
44
- **Scenario** — your active agent hits a credit/quota limit while a task is half-done. You want the next agent (a different model, a fresh instance, anything you have available) to resume cleanly without re-explaining the whole project.
45
-
46
- **Walkthrough**:
47
-
48
- 1. Before the active agent shuts down, close out properly:
49
-
50
- ```text
51
- bclaw_session_end(narrative="Implemented X. Need to finish Y. Tests for Z still pending.")
52
- ```
53
-
54
- This snapshots the session, releases the active claims, and writes a handoff with the narrative + commit list.
55
-
56
- 2. Bring up the next agent (any compatible one). Its first call is `bclaw_work(intent="resume")`:
57
-
58
- ```text
59
- bclaw_work(intent="resume")
60
- ```
61
-
62
- This returns the session context: open plans, recent decisions, active constraints, known traps, the latest handoff narrative, and any unfinished claims it can adopt.
63
-
64
- 3. The new agent reads the handoff, picks up the right plan, and either creates a fresh claim on the same scope or adopts the existing one:
65
-
66
- ```text
67
- bclaw_work(intent="execute", planId="pln_…", scope="src/...")
68
- ```
69
-
70
- 4. From here on it's a normal session — the new agent has all the context the previous one had.
71
-
72
- **What the primitives do here**: the handoff carries the narrative and the file delta, the session record carries the runtime context, and shared memory (decisions, constraints, traps) means the new agent doesn't relearn what the previous one already knows.
73
-
74
- ---
75
-
76
- ## 3. Project recovery — returning to a project after weeks
77
-
78
- **Scenario** — you (or an agent on your behalf) come back to a project after a couple of weeks. You don't remember exactly where things stood. You want to ramp back up in a few minutes, not an afternoon.
79
-
80
- **Walkthrough**:
81
-
82
- 1. From the project root, ask any compatible agent to load context with the canonical facade:
83
-
84
- ```text
85
- bclaw_work(intent="resume")
86
- ```
87
-
88
- You get back: in-progress plans, blocked plans, decisions taken since you left, active constraints, known traps, recent handoffs, and a session continuity hint (where the last session left off).
89
-
90
- 2. If you want a narrower view focused on one area:
91
-
92
- ```text
93
- bclaw_context(kind="memory", path="src/auth", profile="briefing")
94
- ```
95
-
96
- 3. Capture the things you remember in the moment — even rough — as runtime notes. They live in memory and can be promoted later to durable decisions or traps:
97
-
98
- ```text
99
- bclaw_create(entity="runtime_note", data={ text: "Token rotation logic was the next thing to ship" })
100
- ```
101
-
102
- 4. Pick the next plan, claim its scope, and start working. The agent has everything it needs.
103
-
104
- **What the primitives do here**: durable memory means decisions and constraints survive long absences, the session continuity record bridges the gap between runs, and runtime notes give a low-friction way to capture half-formed ideas as they come back to you.
105
-
106
- ---
107
-
108
- ## 4. Team async — multiple humans and agents on the same project
109
-
110
- **Scenario** — two or more people work on the same project, possibly with their own agents. Everyone needs to see the same plans, the same constraints, the same decisions, without constant Slack pings.
111
-
112
- **Walkthrough**:
113
-
114
- 1. Whenever someone takes a non-trivial decision (architecture, library choice, naming convention), capture it once:
115
-
116
- ```text
117
- bclaw_create(entity="decision", data={ text: "Use OAuth 2.0 with PKCE", outcome: "approved" })
118
- bclaw_create(entity="constraint", data={ text: "All auth endpoints must rate-limit", category: "security" })
119
- bclaw_create(entity="trap", data={ text: "Don't import from src/legacy/", severity: "high" })
120
- ```
121
-
122
- These become visible to every agent (and every teammate's agent) on the next `bclaw_context` call.
123
-
124
- 2. When someone starts a non-trivial chunk of work, claim its scope so others can see it:
125
-
126
- ```text
127
- bclaw_work(intent="execute", scope="src/auth", task="Token rotation rework")
128
- ```
129
-
130
- The agent board (`bclaw_context(kind="board")` or `brainclaw agent-board`) now shows that scope as taken — anyone considering the same area sees the claim and either coordinates or picks something else.
131
-
132
- 3. When work is ready for review, hand it off explicitly. The handoff includes the file delta, the narrative, and any open questions:
133
-
134
- ```text
135
- bclaw_coordinate(intent="review", task="Auth refactor ready for review", scope="src/auth")
136
- ```
137
-
138
- 4. Reviewers pick up the handoff via inbox (`bclaw_read_inbox`) and respond either by accepting + closing it, or by sending back fixes through the same coordination loop.
139
-
140
- **What the primitives do here**: shared memory means every teammate's agent operates with the same constraints and traps, claims prevent double-work even without coordination meetings, and handoffs replace ad-hoc "hey, can you look at this?" pings with auditable artifacts.
141
-
142
- ---
143
-
144
- ## How the four scenarios share the same model
145
-
146
- Notice that the four walkthroughs above use the **same primitives**, just composed differently:
147
-
148
- | Primitive | Active orchestration | Agent switching | Project recovery | Team async |
149
- |---|---|---|---|---|
150
- | **plan** | unit of work in a lane | what the next agent picks up | what you ramp back into | what teammates see in the board |
151
- | **claim** | scope lock per lane | snapshotted on session_end, adoptable later | shows what was in flight | prevents teammates from double-editing |
152
- | **handoff** | between sequential lanes | carries the narrative + delta | bridges across the gap | replaces "ping me when ready" |
153
- | **decision / constraint / trap** | guides every spawned worker | survives the credit-limit cutover | reminds you of past choices | propagates team knowledge |
154
- | **runtime_note** | per-lane observations | quick captures before shutdown | half-formed thoughts on return | informal observations to share |
155
-
156
- You don't pick a "mode" up front. You compose the primitives in whatever way fits the moment, and brainclaw keeps them durable across all of it.
157
-
158
- ---
159
-
160
- ## Next reads
161
-
162
- - [memory.md](memory.md) — what counts as memory and how it's organized
163
- - [plans-and-claims.md](plans-and-claims.md) — coordination layer in depth
164
- - [loop-engine.md](loop-engine.md) — structured multi-turn protocols (review loops, ideation, etc.)
165
- - [memory-staleness.md](memory-staleness.md) — how brainclaw signals when stored items may be outdated
166
- - [../integrations/overview.md](../integrations/overview.md) — connecting your specific agent
1
+ # Multi-Agent Workflows
2
+
3
+ brainclaw is built around a small set of memory primitives — **plans**, **claims**, **handoffs**, **decisions**, **traps**, and **runtime notes** — that work the same way whether you're orchestrating multiple agents in parallel right now or letting the next agent (or the next you) pick up the work next week.
4
+
5
+ This doc walks through four concrete scenarios. Pick the one that matches what you're doing.
6
+
7
+ ---
8
+
9
+ ## 1. Active orchestration — parallel work across agent instances
10
+
11
+ **Scenario** — you have a sequence of independent lanes and want several agents (same agent, different instances, or several different agents) to work on them in parallel.
12
+
13
+ **Walkthrough**:
14
+
15
+ 1. Capture the work as plans, then group them into a sequence with explicit lane labels and dependencies:
16
+
17
+ ```text
18
+ bclaw_create(entity="plan", data={ text: "Refactor auth module", … })
19
+ bclaw_create(entity="plan", data={ text: "Add e2e tests", … })
20
+
21
+ # Then, via CLI or a follow-up call:
22
+ brainclaw sequence create "auth-refactor-cycle" --items '[
23
+ {"planId":"pln_aaa","rank":1,"lane":"refactor"},
24
+ {"planId":"pln_bbb","rank":2,"lane":"tests","hard_after":["pln_aaa"]}
25
+ ]' --status active
26
+ ```
27
+
28
+ 2. Dispatch the sequence — the dispatcher picks up the ready lanes (no `hard_after` blocking), creates one claim + worktree per lane, and routes inbox messages by `claim_id`:
29
+
30
+ ```text
31
+ bclaw_dispatch(intent="execute", agents=[<your agents>])
32
+ ```
33
+
34
+ 3. Each spawned worker runs in its own worktree (so concurrent edits don't collide), reads its inbox, and progresses the plan. Coordinator polls `bclaw_context(kind="board")` to follow progress.
35
+
36
+ 4. As each lane lands a commit, merge it into master and release the claim. Lanes with `hard_after` unblock automatically once their predecessors are `done`.
37
+
38
+ **What the primitives do here**: claims isolate scope per lane, the sequence's `hard_after` graph orders the work, and worktrees give Git-level isolation so parallel commits don't conflict.
39
+
40
+ ---
41
+
42
+ ## 2. Agent switching — when an agent runs out of credits mid-task
43
+
44
+ **Scenario** — your active agent hits a credit/quota limit while a task is half-done. You want the next agent (a different model, a fresh instance, anything you have available) to resume cleanly without re-explaining the whole project.
45
+
46
+ **Walkthrough**:
47
+
48
+ 1. Before the active agent shuts down, close out properly:
49
+
50
+ ```text
51
+ bclaw_session_end(narrative="Implemented X. Need to finish Y. Tests for Z still pending.")
52
+ ```
53
+
54
+ This snapshots the session, releases the active claims, and writes a handoff with the narrative + commit list.
55
+
56
+ 2. Bring up the next agent (any compatible one). Its first call is `bclaw_work(intent="resume")`:
57
+
58
+ ```text
59
+ bclaw_work(intent="resume")
60
+ ```
61
+
62
+ This returns the session context: open plans, recent decisions, active constraints, known traps, the latest handoff narrative, and any unfinished claims it can adopt.
63
+
64
+ 3. The new agent reads the handoff, picks up the right plan, and either creates a fresh claim on the same scope or adopts the existing one:
65
+
66
+ ```text
67
+ bclaw_work(intent="execute", planId="pln_…", scope="src/...")
68
+ ```
69
+
70
+ 4. From here on it's a normal session — the new agent has all the context the previous one had.
71
+
72
+ **What the primitives do here**: the handoff carries the narrative and the file delta, the session record carries the runtime context, and shared memory (decisions, constraints, traps) means the new agent doesn't relearn what the previous one already knows.
73
+
74
+ ---
75
+
76
+ ## 3. Project recovery — returning to a project after weeks
77
+
78
+ **Scenario** — you (or an agent on your behalf) come back to a project after a couple of weeks. You don't remember exactly where things stood. You want to ramp back up in a few minutes, not an afternoon.
79
+
80
+ **Walkthrough**:
81
+
82
+ 1. From the project root, ask any compatible agent to load context with the canonical facade:
83
+
84
+ ```text
85
+ bclaw_work(intent="resume")
86
+ ```
87
+
88
+ You get back: in-progress plans, blocked plans, decisions taken since you left, active constraints, known traps, recent handoffs, and a session continuity hint (where the last session left off).
89
+
90
+ 2. If you want a narrower view focused on one area:
91
+
92
+ ```text
93
+ bclaw_context(kind="memory", path="src/auth", profile="briefing")
94
+ ```
95
+
96
+ 3. Capture the things you remember in the moment — even rough — as runtime notes. They live in memory and can be promoted later to durable decisions or traps:
97
+
98
+ ```text
99
+ bclaw_create(entity="runtime_note", data={ text: "Token rotation logic was the next thing to ship" })
100
+ ```
101
+
102
+ 4. Pick the next plan, claim its scope, and start working. The agent has everything it needs.
103
+
104
+ **What the primitives do here**: durable memory means decisions and constraints survive long absences, the session continuity record bridges the gap between runs, and runtime notes give a low-friction way to capture half-formed ideas as they come back to you.
105
+
106
+ ---
107
+
108
+ ## 4. Team async — multiple humans and agents on the same project
109
+
110
+ **Scenario** — two or more people work on the same project, possibly with their own agents. Everyone needs to see the same plans, the same constraints, the same decisions, without constant Slack pings.
111
+
112
+ **Walkthrough**:
113
+
114
+ 1. Whenever someone takes a non-trivial decision (architecture, library choice, naming convention), capture it once:
115
+
116
+ ```text
117
+ bclaw_create(entity="decision", data={ text: "Use OAuth 2.0 with PKCE", outcome: "approved" })
118
+ bclaw_create(entity="constraint", data={ text: "All auth endpoints must rate-limit", category: "security" })
119
+ bclaw_create(entity="trap", data={ text: "Don't import from src/legacy/", severity: "high" })
120
+ ```
121
+
122
+ These become visible to every agent (and every teammate's agent) on the next `bclaw_context` call.
123
+
124
+ 2. When someone starts a non-trivial chunk of work, claim its scope so others can see it:
125
+
126
+ ```text
127
+ bclaw_work(intent="execute", scope="src/auth", task="Token rotation rework")
128
+ ```
129
+
130
+ The agent board (`bclaw_context(kind="board")` or `brainclaw agent-board`) now shows that scope as taken — anyone considering the same area sees the claim and either coordinates or picks something else.
131
+
132
+ 3. When work is ready for review, hand it off explicitly. The handoff includes the file delta, the narrative, and any open questions:
133
+
134
+ ```text
135
+ bclaw_coordinate(intent="review", task="Auth refactor ready for review", scope="src/auth")
136
+ ```
137
+
138
+ 4. Reviewers pick up the handoff via inbox (`bclaw_read_inbox`) and respond either by accepting + closing it, or by sending back fixes through the same coordination loop.
139
+
140
+ **What the primitives do here**: shared memory means every teammate's agent operates with the same constraints and traps, claims prevent double-work even without coordination meetings, and handoffs replace ad-hoc "hey, can you look at this?" pings with auditable artifacts.
141
+
142
+ ---
143
+
144
+ ## How the four scenarios share the same model
145
+
146
+ Notice that the four walkthroughs above use the **same primitives**, just composed differently:
147
+
148
+ | Primitive | Active orchestration | Agent switching | Project recovery | Team async |
149
+ |---|---|---|---|---|
150
+ | **plan** | unit of work in a lane | what the next agent picks up | what you ramp back into | what teammates see in the board |
151
+ | **claim** | scope lock per lane | snapshotted on session_end, adoptable later | shows what was in flight | prevents teammates from double-editing |
152
+ | **handoff** | between sequential lanes | carries the narrative + delta | bridges across the gap | replaces "ping me when ready" |
153
+ | **decision / constraint / trap** | guides every spawned worker | survives the credit-limit cutover | reminds you of past choices | propagates team knowledge |
154
+ | **runtime_note** | per-lane observations | quick captures before shutdown | half-formed thoughts on return | informal observations to share |
155
+
156
+ You don't pick a "mode" up front. You compose the primitives in whatever way fits the moment, and brainclaw keeps them durable across all of it.
157
+
158
+ ---
159
+
160
+ ## Next reads
161
+
162
+ - [memory.md](memory.md) — what counts as memory and how it's organized
163
+ - [plans-and-claims.md](plans-and-claims.md) — coordination layer in depth
164
+ - [loop-engine.md](loop-engine.md) — structured multi-turn protocols (review loops, ideation, etc.)
165
+ - [dispatch-lifecycle.md](dispatch-lifecycle.md) — what actually happens when a dispatch goes wrong: 6-entity dance, brief-ack sentinel, stdout/stderr logs, observability decision tree
166
+ - [memory-staleness.md](memory-staleness.md) — how brainclaw signals when stored items may be outdated
167
+ - [../integrations/overview.md](../integrations/overview.md) — connecting your specific agent
@@ -54,6 +54,32 @@ brainclaw stale resolve <id>
54
54
 
55
55
  ---
56
56
 
57
+ ## `bclaw_coordinate` refused with `dirty_working_tree`
58
+
59
+ **Symptom**: an `assign` / `review` / `reroute` dispatch returns
60
+ `dirty_working_tree` instead of spawning.
61
+
62
+ **Why**: the worker spawns from a worktree branched at HEAD, so uncommitted
63
+ edits in the source repo are invisible to it. The guard (trp#371) is
64
+ scope-aware — it refuses only when the uncommitted files **overlap**, or
65
+ cannot be proven disjoint from, the dispatch `scope`. `.brainclaw/` and
66
+ `.git/` are always ignored, and `consult` / `ideate` / `summarize` are never
67
+ guarded (they spawn no worktree). A scope that is not a resolvable file path
68
+ (a plan-id, loop-ref, or prose) cannot be proven disjoint, so the guard stays
69
+ conservative and refuses while the tree is dirty.
70
+
71
+ **Fixes**:
72
+
73
+ - Commit or stash the overlapping files, then re-dispatch (cleanest).
74
+ - Pass `allow_dirty: true` to proceed anyway — the block becomes a warning
75
+ that lists the overlapping files.
76
+ - Pass a resolvable file `scope` (e.g. `src/foo.ts`) so the guard can prove the
77
+ dirty files are out of scope.
78
+ - Pass `ref: <commit|branch|tag>` to build the worktree from an explicit ref —
79
+ uncommitted working-tree changes are then intentionally out of scope.
80
+
81
+ ---
82
+
57
83
  ## Dispatched worker finished work but never committed
58
84
 
59
85
  **Symptom**: a sequence's lane shows the worker as "task_complete" in the run log, but `git -C <worktree-path> status` shows uncommitted changes.
@@ -187,17 +213,24 @@ brainclaw stale resolve <plan_id> # → dropped (default for stale)
187
213
  ```bash
188
214
  # 1. Is the worker process still alive?
189
215
  ps -ef | grep <agent-binary> # codex, claude, copilot, …
216
+ # Windows: Get-Process -Id <pid> # or `tasklist /FI "PID eq <pid>"`
190
217
 
191
218
  # 2. Did the brief-ack file land?
192
219
  ls .brainclaw/coordination/runtime/ack/<assignment_id>.ack
193
220
  # If yes → spawn started, worker is somewhere in its loop
194
221
  # If no → spawn never started or died before the wrap shell ran touch
195
222
 
196
- # 3. Inspect the worktree for activity
223
+ # 3. (pln#504) What did the worker actually say? stdout/stderr capture
224
+ # Spawned workers now route their streams to per-assignment log files. If the
225
+ # worker died silently, the error usually shows up here.
226
+ cat .brainclaw/coordination/runtime/log/<assignment_id>.stdout.log
227
+ cat .brainclaw/coordination/runtime/log/<assignment_id>.stderr.log
228
+
229
+ # 4. Inspect the worktree for activity
197
230
  git -C <worktree> log --oneline -5
198
231
  git -C <worktree> status
199
232
 
200
- # 4. Check the run log
233
+ # 5. Check the run log
201
234
  brainclaw inbox list --agent <agent>
202
235
  # or via MCP: bclaw_assignment_events(assignmentId="<id>")
203
236
  ```
@@ -213,6 +246,7 @@ brainclaw inbox list --agent <agent>
213
246
 
214
247
  ## See also
215
248
 
249
+ - [`docs/concepts/dispatch-lifecycle.md`](dispatch-lifecycle.md) — the entity model + FSMs + observability decision tree underlying every diagnostic step on this page
216
250
  - [`docs/concepts/memory-staleness.md`](memory-staleness.md) — staleness signals and resolve flow in depth
217
251
  - [`docs/concepts/loop-engine.md`](loop-engine.md) — multi-turn loops (review-fix), recovery semantics for in-flight loops
218
252
  - [`docs/concepts/upgrade-cli.md`](upgrade-cli.md) — `brainclaw upgrade` design + rollback path
package/docs/index.md CHANGED
@@ -49,9 +49,10 @@ Use this page as the entry point into the packaged Markdown documentation.
49
49
  - [integrations/roo.md](integrations/roo.md)
50
50
  - [integrations/windsurf.md](integrations/windsurf.md)
51
51
  - [integrations/opencode.md](integrations/opencode.md)
52
- - [integrations/kilocode.md](integrations/kilocode.md)
53
- - [integrations/mistral-vibe.md](integrations/mistral-vibe.md)
54
- - [integrations/openclaw.md](integrations/openclaw.md)
52
+ - [integrations/kilocode.md](integrations/kilocode.md)
53
+ - [integrations/mistral-vibe.md](integrations/mistral-vibe.md)
54
+ - [integrations/hermes.md](integrations/hermes.md)
55
+ - [integrations/openclaw.md](integrations/openclaw.md)
55
56
 
56
57
  ## Audience Design Constraints
57
58
 
@@ -0,0 +1,78 @@
1
+ # Hermes Agent
2
+
3
+ brainclaw integrates with **Hermes Agent** through its native MCP client and
4
+ skill system. Hermes is treated as a Tier B autonomous agent today: MCP + the
5
+ universal `.agents/skills/brainclaw/SKILL.md` skill, without Brainclaw-managed
6
+ session hooks until a dedicated Hermes plugin is implemented and validated.
7
+
8
+ ## Surfaces
9
+
10
+ - `~/.hermes/config.yaml` — machine-level Hermes config with the Brainclaw MCP
11
+ server under `mcp_servers.brainclaw`.
12
+ - `.agents/skills/brainclaw/SKILL.md` — universal Brainclaw skill. Hermes can
13
+ use this alongside its own `~/.hermes/skills/` skills.
14
+ - `AGENTS.md` — stable project instructions for shared coding-agent workflows.
15
+
16
+ ## Setup
17
+
18
+ ```bash
19
+ brainclaw setup-machine --agents hermes --yes
20
+ brainclaw enable-agent hermes
21
+ ```
22
+
23
+ The machine setup writes `~/.hermes/config.yaml`. The project enable step writes
24
+ the universal Brainclaw skill into `.agents/skills/brainclaw/SKILL.md` and
25
+ adds the project `.agents/skills` directory to Hermes `skills.external_dirs`.
26
+
27
+ The generated MCP entry is intentionally filtered to the facade and canonical
28
+ grammar tools:
29
+
30
+ ```yaml
31
+ skills:
32
+ external_dirs:
33
+ - /path/to/project/.agents/skills
34
+
35
+ mcp_servers:
36
+ brainclaw:
37
+ command: node
38
+ args: [/path/to/brainclaw/dist/cli.js, mcp]
39
+ env:
40
+ BRAINCLAW_AGENT: hermes
41
+ tools:
42
+ include:
43
+ - bclaw_work
44
+ - bclaw_context
45
+ - bclaw_find
46
+ - bclaw_get
47
+ - bclaw_create
48
+ - bclaw_update
49
+ - bclaw_transition
50
+ prompts: false
51
+ resources: false
52
+ ```
53
+
54
+ ## Memory Boundary
55
+
56
+ Hermes skills are procedural memory: reusable ways to perform work. Brainclaw
57
+ memory is coordination memory: plans, claims, decisions, constraints, traps,
58
+ handoffs, candidates, and runtime notes.
59
+
60
+ When Hermes learns a reusable technique, it can create or update a Hermes skill.
61
+ When Hermes discovers project state that affects other agents, it should write
62
+ to Brainclaw through `bclaw_create` or `bclaw_update`.
63
+
64
+ ## Caveats
65
+
66
+ - Hermes plugin hooks are not configured by Brainclaw yet. Session start still
67
+ depends on the skill/instruction contract: call `bclaw_work(intent=...)`
68
+ before significant work.
69
+ - Hermes should not be added to high-trust dispatch allowlists until its
70
+ lifecycle behavior is validated: brief acknowledgement, MCP write reliability,
71
+ and `bclaw_assignment_update(status="completed")`.
72
+ - The machine-level config does not set `BRAINCLAW_CWD`; Hermes should run from
73
+ the project directory or rely on Brainclaw project switching.
74
+
75
+ ## References
76
+
77
+ - [Hermes Agent documentation](https://hermes-agent.nousresearch.com/docs/)
78
+ - [Hermes Agent GitHub repository](https://github.com/NousResearch/hermes-agent)
@@ -1,15 +1,17 @@
1
1
  # Integration Overview
2
2
 
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
-
5
- ## Onboarding model
6
-
7
- There are two separate setup scopes:
8
-
9
- - **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.
10
- - **Project scope** — `brainclaw init` creates or refreshes `.brainclaw/` for the current repository and rewrites the managed project/agent files safely.
11
-
12
- 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.
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
+
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.
13
15
 
14
16
  ## How agents connect to brainclaw
15
17
 
@@ -52,11 +54,11 @@ The agent gets dynamic context injected at every prompt. The instruction file ca
52
54
 
53
55
  **Today:** Claude Code
54
56
 
55
- ### Standard integration (MCP, no hooks)
57
+ ### Standard integration (MCP, no hooks)
56
58
 
57
59
  The agent can call brainclaw tools but doesn't get automatic context injection. The instruction file is more directive — it tells the agent it MUST call specific tools before working, and includes the most critical traps statically. For agents without hooks, an opt-in `.live.md` companion (regenerated on session-end and handoff) carries plans, claims, traps, candidates, and handoffs as a parity backstop.
58
60
 
59
- **Today:** Cursor, Windsurf, Cline, Roo, Continue, Kilocode, OpenCode, Codex, GitHub Copilot, Antigravity/Gemini CLI, Mistral Vibe
61
+ **Today:** Cursor, Windsurf, Cline, Roo, Continue, Kilocode, OpenCode, Codex, GitHub Copilot, Antigravity/Gemini CLI, Mistral Vibe, Hermes
60
62
 
61
63
  ### Limited integration (no MCP)
62
64
 
@@ -78,9 +80,10 @@ The agent cannot call brainclaw tools at all. The instruction file or SKILL.md b
78
80
  | **OpenCode** | ✔ project | AGENTS.md | — | — | — |
79
81
  | **Codex** | ✔ global | AGENTS.md | — | — | — |
80
82
  | **Gemini CLI** | ✔ global | GEMINI.md | — | — | — |
81
- | **GitHub Copilot** | ✔ global + project | .github/copilot-instructions.md | — | manual (per-call) | ✔ brainclaw-context |
82
- | **Mistral Vibe** | ✔ project + user (TOML) | AGENTS.md | — | `--auto-approve` flag | ✔ universal skill |
83
- | **OpenClaw** | | | — | — | ✔ brainclaw skill |
83
+ | **GitHub Copilot** | ✔ global + project | .github/copilot-instructions.md | — | manual (per-call) | ✔ brainclaw-context |
84
+ | **Mistral Vibe** | ✔ project + user (TOML) | AGENTS.md | — | `--auto-approve` flag | ✔ universal skill |
85
+ | **Hermes** | global (YAML) | AGENTS.md | — | — | ✔ universal skill |
86
+ | **OpenClaw** | — | — | — | — | ✔ brainclaw skill |
84
87
 
85
88
  **Legend:** ✔ = fully supported, ◐ = partial (static trigger, not dynamic injection), — = not available
86
89
 
@@ -120,7 +123,8 @@ See the README's "Current state" section for the full list of what works today a
120
123
  - [roo.md](roo.md)
121
124
  - [windsurf.md](windsurf.md)
122
125
  - [cline.md](cline.md)
123
- - [kilocode.md](kilocode.md)
124
- - [mistral-vibe.md](mistral-vibe.md)
125
- - [opencode.md](opencode.md)
126
+ - [kilocode.md](kilocode.md)
127
+ - [mistral-vibe.md](mistral-vibe.md)
128
+ - [hermes.md](hermes.md)
129
+ - [opencode.md](opencode.md)
126
130
  - [openclaw.md](openclaw.md)
@@ -82,7 +82,14 @@ will still succeed. A follow-up PR will strip the dead handler code.
82
82
  changelog records the published MCP surface fingerprint. When a tool
83
83
  name, tier, category, or input schema changes, the test fails until
84
84
  this section is updated.
85
- - MCP public surface fingerprint: `sha256:724085642dc3e2d7`
85
+ - MCP public surface fingerprint: `sha256:4a6f612ad952fb52`
86
+ (updated 2026-05-27: added the `ref` property to the bclaw_coordinate
87
+ inputSchema — pln#520 Tier 2 / trp#371, the scope-aware dirty guard;
88
+ `ref` lets a dispatch build its worktree from an explicit git ref.
89
+ Prior value `sha256:0a4ba280aeff142b` exposed `allow_dirty` in the
90
+ bclaw_coordinate inputSchema. `sha256:e88c1a97fc29cfd1` came from the
91
+ pln#520 LoopPhase/LoopSlotInput schema resync, which itself reconciled
92
+ earlier unrecorded drift from `sha256:724085642dc3e2d7`.)
86
93
 
87
94
  See `docs/integrations/mcp.md` for the full canonical surface + an
88
95
  example gallery per verb. See `docs/concepts/mcp-governance.md` for