brainclaw 1.8.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/README.md +592 -505
  2. package/dist/brainclaw-vscode.vsix +0 -0
  3. package/dist/cli.js +138 -13
  4. package/dist/commands/add-step.js +1 -1
  5. package/dist/commands/bootstrap.js +2 -26
  6. package/dist/commands/check-security-mcp.js +50 -33
  7. package/dist/commands/check-security.js +86 -43
  8. package/dist/commands/claim.js +22 -21
  9. package/dist/commands/confirm.js +26 -0
  10. package/dist/commands/context-diff.js +1 -1
  11. package/dist/commands/dispatch-watch.js +142 -0
  12. package/dist/commands/doctor.js +113 -2
  13. package/dist/commands/estimation-report.js +115 -16
  14. package/dist/commands/harvest.js +286 -23
  15. package/dist/commands/hooks.js +73 -73
  16. package/dist/commands/init.js +124 -22
  17. package/dist/commands/install-hooks.js +78 -78
  18. package/dist/commands/loops-handlers.js +4 -0
  19. package/dist/commands/mcp-read-handlers.js +253 -41
  20. package/dist/commands/mcp.js +664 -102
  21. package/dist/commands/memory.js +21 -17
  22. package/dist/commands/migrate.js +81 -17
  23. package/dist/commands/prune.js +78 -4
  24. package/dist/commands/reflect.js +26 -20
  25. package/dist/commands/register-agent.js +57 -1
  26. package/dist/commands/repair.js +20 -0
  27. package/dist/commands/session-end.js +15 -6
  28. package/dist/commands/session-start.js +18 -1
  29. package/dist/commands/setup-security.js +39 -18
  30. package/dist/commands/setup.js +26 -27
  31. package/dist/commands/stale.js +16 -2
  32. package/dist/commands/switch.js +26 -5
  33. package/dist/commands/uninstall.js +126 -34
  34. package/dist/commands/update-step.js +6 -0
  35. package/dist/commands/version.js +1 -1
  36. package/dist/commands/worktree.js +60 -0
  37. package/dist/core/actions.js +12 -3
  38. package/dist/core/agent-capability.js +30 -17
  39. package/dist/core/agent-files.js +963 -666
  40. package/dist/core/agent-integrations.js +0 -3
  41. package/dist/core/agent-inventory.js +67 -0
  42. package/dist/core/agent-registry.js +163 -29
  43. package/dist/core/agentrun-reconciler.js +33 -2
  44. package/dist/core/agentruns.js +7 -1
  45. package/dist/core/ai-agent-detection.js +31 -44
  46. package/dist/core/archival.js +15 -9
  47. package/dist/core/assignment-reconciler.js +56 -0
  48. package/dist/core/assignment-sweeper.js +127 -4
  49. package/dist/core/assignments.js +69 -11
  50. package/dist/core/bootstrap.js +233 -67
  51. package/dist/core/brainclaw-version.js +22 -0
  52. package/dist/core/candidates.js +21 -1
  53. package/dist/core/claims.js +313 -150
  54. package/dist/core/codev-prompts.js +38 -38
  55. package/dist/core/config.js +6 -1
  56. package/dist/core/context-diff.js +148 -20
  57. package/dist/core/context.js +129 -8
  58. package/dist/core/coordination.js +22 -3
  59. package/dist/core/default-profiles/doctor.yaml +11 -11
  60. package/dist/core/default-profiles/janitor.yaml +11 -11
  61. package/dist/core/default-profiles/onboarder.yaml +11 -11
  62. package/dist/core/default-profiles/reviewer.yaml +13 -13
  63. package/dist/core/dispatch-status.js +79 -5
  64. package/dist/core/dispatcher.js +65 -12
  65. package/dist/core/entity-operations.js +74 -27
  66. package/dist/core/entity-registry.js +31 -5
  67. package/dist/core/event-log.js +138 -21
  68. package/dist/core/events/checkpoint.js +258 -0
  69. package/dist/core/events/genesis.js +220 -0
  70. package/dist/core/events/journal.js +507 -0
  71. package/dist/core/events/materialize.js +126 -0
  72. package/dist/core/events/registry-post-image.js +110 -0
  73. package/dist/core/events/verify.js +109 -0
  74. package/dist/core/execution-adapters.js +23 -0
  75. package/dist/core/execution.js +1 -1
  76. package/dist/core/facade-schema.js +38 -0
  77. package/dist/core/gc-semantic.js +130 -5
  78. package/dist/core/handoff-snapshot.js +68 -0
  79. package/dist/core/ids.js +19 -8
  80. package/dist/core/instruction-templates.js +34 -115
  81. package/dist/core/io.js +39 -3
  82. package/dist/core/json-store.js +10 -1
  83. package/dist/core/lock.js +153 -28
  84. package/dist/core/loops/bootstrap-acquire.js +25 -1
  85. package/dist/core/loops/facade-schema.js +2 -0
  86. package/dist/core/loops/hooks/survey-signals-baseline.js +36 -0
  87. package/dist/core/loops/index.js +1 -0
  88. package/dist/core/loops/presets/bootstrap.js +7 -0
  89. package/dist/core/loops/store.js +17 -0
  90. package/dist/core/loops/verbs.js +24 -2
  91. package/dist/core/markdown.js +8 -76
  92. package/dist/core/mcp-command-resolution.js +245 -0
  93. package/dist/core/memory-compactor.js +5 -3
  94. package/dist/core/memory-lifecycle.js +282 -0
  95. package/dist/core/merge-risk.js +150 -0
  96. package/dist/core/messaging.js +10 -3
  97. package/dist/core/migration.js +11 -1
  98. package/dist/core/observer-mode.js +26 -0
  99. package/dist/core/operations/memory-mutation.js +90 -65
  100. package/dist/core/operations/plan.js +27 -1
  101. package/dist/core/protocol-skills.js +210 -0
  102. package/dist/core/reflection-safety.js +6 -7
  103. package/dist/core/reputation.js +84 -2
  104. package/dist/core/runtime-signals.js +72 -10
  105. package/dist/core/runtime.js +84 -1
  106. package/dist/core/schema.js +114 -0
  107. package/dist/core/search.js +19 -2
  108. package/dist/core/security-detectors.js +125 -0
  109. package/dist/core/security-extract.js +189 -0
  110. package/dist/core/security-guard.js +217 -139
  111. package/dist/core/security-packages.js +121 -0
  112. package/dist/core/security-scoring.js +76 -9
  113. package/dist/core/security.js +34 -2
  114. package/dist/core/sequence.js +11 -2
  115. package/dist/core/setup-flow.js +141 -13
  116. package/dist/core/spawn-check.js +16 -2
  117. package/dist/core/staleness.js +73 -2
  118. package/dist/core/state.js +250 -54
  119. package/dist/core/store-resolution.js +45 -12
  120. package/dist/core/worktree.js +90 -26
  121. package/dist/facts.js +8 -8
  122. package/dist/facts.json +7 -7
  123. package/docs/PROTOCOL.md +223 -0
  124. package/docs/adapters/openclaw.md +43 -43
  125. package/docs/architecture/project-refs.md +328 -328
  126. package/docs/cli.md +2097 -2096
  127. package/docs/concepts/coordination.md +52 -52
  128. package/docs/concepts/coordinator-runbook.md +129 -0
  129. package/docs/concepts/dispatch-lifecycle.md +245 -245
  130. package/docs/concepts/event-log-store.md +928 -0
  131. package/docs/concepts/ideation-loop.md +317 -317
  132. package/docs/concepts/loop-engine.md +520 -511
  133. package/docs/concepts/mcp-governance.md +268 -268
  134. package/docs/concepts/memory.md +89 -88
  135. package/docs/concepts/multi-agent-workflows.md +167 -167
  136. package/docs/concepts/observer-protocol.md +361 -0
  137. package/docs/concepts/parallel-merge-protocol.md +71 -0
  138. package/docs/concepts/plans-and-claims.md +217 -174
  139. package/docs/concepts/project-md-convention.md +35 -35
  140. package/docs/concepts/runtime-notes.md +38 -38
  141. package/docs/concepts/skills.md +78 -0
  142. package/docs/concepts/troubleshooting.md +254 -254
  143. package/docs/concepts/workspace-bootstrapping.md +142 -81
  144. package/docs/context-format-changelog.md +35 -35
  145. package/docs/context-format.md +48 -48
  146. package/docs/index.md +65 -65
  147. package/docs/integrations/agents.md +162 -162
  148. package/docs/integrations/claude-code.md +23 -23
  149. package/docs/integrations/cline.md +87 -88
  150. package/docs/integrations/codex.md +2 -2
  151. package/docs/integrations/continue.md +60 -60
  152. package/docs/integrations/copilot.md +82 -80
  153. package/docs/integrations/cursor.md +23 -23
  154. package/docs/integrations/kilocode.md +72 -72
  155. package/docs/integrations/mcp.md +377 -377
  156. package/docs/integrations/mistral-vibe.md +122 -122
  157. package/docs/integrations/openclaw.md +99 -98
  158. package/docs/integrations/opencode.md +84 -84
  159. package/docs/integrations/overview.md +122 -122
  160. package/docs/integrations/roo.md +74 -74
  161. package/docs/integrations/windsurf.md +83 -83
  162. package/docs/mcp-schema-changelog.md +360 -329
  163. package/docs/playbooks/integration/index.md +121 -121
  164. package/docs/playbooks/orchestration.md +37 -0
  165. package/docs/playbooks/productivity/index.md +99 -99
  166. package/docs/playbooks/team/index.md +117 -117
  167. package/docs/product/agent-first-model.md +184 -184
  168. package/docs/product/entity-model-audit.md +462 -462
  169. package/docs/product/positioning.md +86 -86
  170. package/docs/quickstart-existing-project.md +107 -107
  171. package/docs/quickstart.md +148 -147
  172. package/docs/release-maintenance.md +79 -79
  173. package/docs/reputation.md +52 -52
  174. package/docs/review.md +45 -45
  175. package/docs/security.md +212 -53
  176. package/docs/server-operations.md +118 -118
  177. package/docs/storage.md +110 -108
  178. package/package.json +86 -69
@@ -1,174 +1,217 @@
1
- # Plans and Claims
2
-
3
- Plans and claims are where brainclaw starts to feel less like a note system and more like a coordination layer.
4
-
5
- ## Plans
6
-
7
- Plans provide a shared view of intended work.
8
-
9
- They help teams and agents answer questions like:
10
-
11
- - what are we trying to ship?
12
- - what is in progress?
13
- - what is blocked?
14
- - what is done?
15
- - who is responsible right now?
16
-
17
- ### Plan statuses
18
-
19
- | Status | Meaning |
20
- |--------|---------|
21
- | `todo` | Not started yet |
22
- | `in_progress` | Actively being worked on |
23
- | `done` | Completed |
24
- | `blocked` | Waiting on something external |
25
- | `dropped` | Dropped |
26
-
27
- ### Creating plans
28
-
29
- ```bash
30
- brainclaw plan create "implement login flow"
31
- brainclaw plan create "refactor auth module" --priority high --estimate 120
32
- ```
33
-
34
- The `--estimate` flag accepts a **positive integer in minutes**. Example: `--estimate 30` means 30 minutes, `--estimate 120` means 2 hours.
35
-
36
- ### Updating plans
37
-
38
- ```bash
39
- brainclaw plan update <id> --status in_progress
40
- brainclaw plan update <id> --status done --actual-effort 45min
41
- ```
42
-
43
- When marking a plan `in_progress` for the first time, `started_at` is automatically recorded.
44
- When marking a plan `done`, `completed_at` is automatically recorded.
45
-
46
- ### Plan steps
47
-
48
- Plans can have sub-steps for multi-phase work:
49
-
50
- ```bash
51
- brainclaw add-step <plan-id> "write unit tests"
52
- brainclaw add-step <plan-id> "update docs"
53
- brainclaw complete-step <plan-id> <step-id>
54
- ```
55
-
56
- Steps show up in `brainclaw context` and `brainclaw board` so other agents and humans can see granular progress.
57
- `brainclaw plan update` changes the parent plan item only; step completion is handled through `complete-step`.
58
-
59
- ### Estimation and calibration
60
-
61
- When both `estimated_effort` and `actual_effort` are present on completed plans, brainclaw can compute an accuracy report:
62
-
63
- ```bash
64
- brainclaw estimation-report
65
- brainclaw estimation-report --agent my-agent
66
- ```
67
-
68
- This shows a ratio chart (actual / estimate) and a calibration hint:
69
-
70
- ```
71
- task with estimate est:30min actual:45min [ratio:1.5x]
72
- [0.0x ░░░░░░░░░░│████████████████████░░░░░░░░░░░░░░░░░ 2.0x+]
73
- OVER +50%
74
- ```
75
-
76
- A ratio below 1.0 means the task finished faster than expected (early). Above 1.0 means it took longer (over).
77
-
78
- ## Claims
79
-
80
- Claims make current ownership explicit.
81
-
82
- A claim can represent:
83
-
84
- - a file
85
- - a folder
86
- - a feature area
87
- - a work scope linked to a plan item
88
-
89
- Claims help reduce collisions when multiple humans or agents work in parallel.
90
-
91
- ### Creating claims
92
-
93
- ```bash
94
- brainclaw claim create "refactoring auth module" --scope src/auth/
95
- brainclaw claim create "updating docs" --scope docs/ --ttl 4h
96
- brainclaw claim create "fixing login bug" --scope src/auth/ --plan <plan-id>
97
- ```
98
-
99
- The `--ttl` flag sets a time-to-live for the claim. After expiry, the claim is no longer considered active by other agents. Valid formats: `30min`, `2h`, `1d`.
100
-
101
- ### Listing and releasing claims
102
-
103
- ```bash
104
- brainclaw claim list
105
- brainclaw claim release <id>
106
- ```
107
-
108
- `claim list` shows who holds each claim and whether it is still active. If a claim has a `session_id`, the last 8 characters are shown so you can correlate with the agent session that created it.
109
-
110
- ### Automatic claim release
111
-
112
- Claims are automatically released after a `git merge` if the post-merge hook is installed (installed by default by `brainclaw init`). The hook matches merged file paths against active claim scopes and releases overlapping claims.
113
-
114
- You can also install or reinstall the hook manually:
115
-
116
- ```bash
117
- brainclaw install-hooks
118
- ```
119
-
120
- ## Why claims matter
121
-
122
- Without claims, multiple agents can easily touch the same area at once and generate conflicting changes.
123
- Claims are not necessarily hard file locks.
124
- They are a shared coordination signal.
125
-
126
- ## Policy checks
127
-
128
- Before editing a scope, agents can verify governance compliance using `check-policy`:
129
-
130
- ```bash
131
- brainclaw check-policy --scope src/core/auth.ts --agent claude-code
132
- ```
133
-
134
- Or via MCP:
135
-
136
- ```
137
- bclaw_check_policy(scope: "src/core/auth.ts", agent: "claude-code")
138
- ```
139
-
140
- The check is fully **deterministic** (no AI involved) and verifies:
141
-
142
- - **Claim active** Does the agent have a claim on this scope? (BLOCK if not)
143
- - **Claim conflict** — Is another agent claiming this scope? (BLOCK)
144
- - **Constraints** Do any active constraints with matching `related_paths` apply? (WARN)
145
- - **Traps** — Are there known pitfalls for this scope? (WARN)
146
- - **Governance context** — Active global instructions are surfaced for reference.
147
-
148
- Policy warnings are also **automatically included** in the `bclaw_claim` response — agents get constraint and trap alerts at claim time without an extra call.
149
-
150
- ## Recommended workflow
151
-
152
- 1. create a plan item
153
- 2. claim the target scope — `bclaw_claim` (or `bclaw_work(intent="execute", scope=…, planId=…)`) creates an isolated git worktree under `~/.brainclaw/worktrees/<project-hash>/` automatically; policy warnings are surfaced as part of the response
154
- 3. work on the implementation inside the worktree
155
- 4. update the plan status (`bclaw_transition(entity="plan", id, to="in_progress" | "done")`)
156
- 5. commit and merge back; release the claim when done or blocked
157
- 6. create a handoff if another actor should continue
158
-
159
- ## Session hygiene
160
-
161
- Before finishing a session, always:
162
-
163
- - release active claims: `brainclaw claim release <id>`
164
- - update plan items: `brainclaw plan update <id> --status done`
165
- - or use `brainclaw session-end --auto-release` to clean up automatically
166
-
167
- `session-end --auto-release` releases all claims held by the current agent and marks any `in_progress` plans as needing attention.
168
-
169
- ## Plans + claims together
170
-
171
- Plans describe what should happen.
172
- Claims describe who is currently working where.
173
-
174
- That combination is much more useful than either one alone.
1
+ # Plans and Claims
2
+
3
+ Plans and claims are where brainclaw starts to feel less like a note system and more like a coordination layer.
4
+
5
+ ## Plans
6
+
7
+ Plans provide a shared view of intended work.
8
+
9
+ They help teams and agents answer questions like:
10
+
11
+ - what are we trying to ship?
12
+ - what is in progress?
13
+ - what is blocked?
14
+ - what is done?
15
+ - who is responsible right now?
16
+
17
+ ### Plan statuses
18
+
19
+ | Status | Meaning |
20
+ |--------|---------|
21
+ | `todo` | Not started yet |
22
+ | `in_progress` | Actively being worked on |
23
+ | `done` | Completed |
24
+ | `blocked` | Waiting on something external |
25
+ | `dropped` | Dropped |
26
+
27
+ ### Creating plans
28
+
29
+ ```bash
30
+ brainclaw plan create "implement login flow"
31
+ brainclaw plan create "refactor auth module" --priority high --estimate 120
32
+ ```
33
+
34
+ The `--estimate` flag accepts a **positive integer in minutes**. Example: `--estimate 30` means 30 minutes, `--estimate 120` means 2 hours.
35
+
36
+ ### Updating plans
37
+
38
+ ```bash
39
+ brainclaw plan update <id> --status in_progress
40
+ brainclaw plan update <id> --status done --actual-effort 45min
41
+ ```
42
+
43
+ When marking a plan `in_progress` for the first time, `started_at` is automatically recorded.
44
+ When marking a plan `done`, `completed_at` is automatically recorded.
45
+
46
+ ### Plan steps
47
+
48
+ Plans can have sub-steps for multi-phase work:
49
+
50
+ ```bash
51
+ brainclaw add-step <plan-id> "write unit tests"
52
+ brainclaw add-step <plan-id> "update docs"
53
+ brainclaw complete-step <plan-id> <step-id>
54
+ ```
55
+
56
+ Steps show up in `brainclaw context` and `brainclaw board` so other agents and humans can see granular progress.
57
+ `brainclaw plan update` changes the parent plan item only; step completion is handled through `complete-step`.
58
+
59
+ ### Estimation and calibration
60
+
61
+ When both `estimated_effort` and `actual_effort` are present on completed plans, brainclaw can compute an accuracy report:
62
+
63
+ ```bash
64
+ brainclaw estimation-report
65
+ brainclaw estimation-report --agent my-agent
66
+ ```
67
+
68
+ This shows a ratio chart (actual / estimate) and a calibration hint:
69
+
70
+ ```
71
+ task with estimate est:30min actual:45min [ratio:1.5x]
72
+ [0.0x ░░░░░░░░░░│████████████████████░░░░░░░░░░░░░░░░░ 2.0x+]
73
+ OVER +50%
74
+ ```
75
+
76
+ A ratio below 1.0 means the task finished faster than expected (early). Above 1.0 means it took longer (over).
77
+
78
+ ### Step-level estimation (pln#495)
79
+
80
+ Estimation can be captured per **step**, not just per plan — which removes a real
81
+ source of noise. A plan's wall-clock span (`created_at`→`completed_at`) counts
82
+ the idle time *between* steps as if it were work: if steps 1–5 finish in a
83
+ morning and step 6 lands the next day, the plan-level elapsed smears an 18h gap
84
+ that was never effort. Summing per-step durations excludes those gaps.
85
+
86
+ Set step estimates and actuals via `add-step` / `update-step`:
87
+
88
+ ```bash
89
+ brainclaw add-step <plan-id> "write unit tests" --estimate 30
90
+ brainclaw update-step <plan-id> <step-id> --status in_progress # stamps started_at
91
+ brainclaw update-step <plan-id> <step-id> --status done # stamps completed_at
92
+ # or record an explicit actual:
93
+ brainclaw update-step <plan-id> <step-id> --actual-effort 45m
94
+ ```
95
+
96
+ `estimated_effort` accepts the same forms as the plan-level `--estimate` (an
97
+ integer of minutes, or a legacy duration string like `2h` / `30m`).
98
+
99
+ `estimation-report` then prefers step-level data and tags each plan with its
100
+ **measurement source**:
101
+
102
+ - **`step`** — the highest quality: `estimated_minutes` is the sum of step
103
+ estimates (used only when *every* step has one), and `elapsed_minutes` is the
104
+ sum of per-step durations (used only when *every* step is measurable, via an
105
+ explicit `actual_effort` or both `started_at`+`completed_at`). Idle gaps
106
+ between steps are excluded.
107
+ - **`plan_string`** — fell back to the plan-level `actual_effort` string.
108
+ - **`plan_wallclock`** fell back to the plan's `created_at`→`completed_at`
109
+ span (the noisiest; what older plans use).
110
+
111
+ The report's summary breaks the median ratio down per source
112
+ (`step-derived: 1.0x · plan-wallclock: 0.4x …`) so you can see how much
113
+ calibration error was wall-clock contamination vs real estimation drift, and the
114
+ chart tags each line (`✓step` / `~wall`).
115
+
116
+ **Migration:** none required. A plan whose steps carry no estimation data — or a
117
+ plan with no steps at all — keeps working exactly as before via the fallback
118
+ chain. Mixed plans (some steps estimated, some not) fall back to plan-level
119
+ entirely rather than reporting a misleading partial sum.
120
+
121
+ ## Claims
122
+
123
+ Claims make current ownership explicit.
124
+
125
+ A claim can represent:
126
+
127
+ - a file
128
+ - a folder
129
+ - a feature area
130
+ - a work scope linked to a plan item
131
+
132
+ Claims help reduce collisions when multiple humans or agents work in parallel.
133
+
134
+ ### Creating claims
135
+
136
+ ```bash
137
+ brainclaw claim create "refactoring auth module" --scope src/auth/
138
+ brainclaw claim create "updating docs" --scope docs/ --ttl 4h
139
+ brainclaw claim create "fixing login bug" --scope src/auth/ --plan <plan-id>
140
+ ```
141
+
142
+ The `--ttl` flag sets a time-to-live for the claim. After expiry, the claim is no longer considered active by other agents. Valid formats: `30min`, `2h`, `1d`.
143
+
144
+ ### Listing and releasing claims
145
+
146
+ ```bash
147
+ brainclaw claim list
148
+ brainclaw claim release <id>
149
+ ```
150
+
151
+ `claim list` shows who holds each claim and whether it is still active. If a claim has a `session_id`, the last 8 characters are shown so you can correlate with the agent session that created it.
152
+
153
+ ### Automatic claim release
154
+
155
+ Claims are automatically released after a `git merge` if the post-merge hook is installed (installed by default by `brainclaw init`). The hook matches merged file paths against active claim scopes and releases overlapping claims.
156
+
157
+ You can also install or reinstall the hook manually:
158
+
159
+ ```bash
160
+ brainclaw install-hooks
161
+ ```
162
+
163
+ ## Why claims matter
164
+
165
+ Without claims, multiple agents can easily touch the same area at once and generate conflicting changes.
166
+ Claims are not necessarily hard file locks.
167
+ They are a shared coordination signal.
168
+
169
+ ## Policy checks
170
+
171
+ Before editing a scope, agents can verify governance compliance using `check-policy`:
172
+
173
+ ```bash
174
+ brainclaw check-policy --scope src/core/auth.ts --agent claude-code
175
+ ```
176
+
177
+ Or via MCP:
178
+
179
+ ```
180
+ bclaw_check_policy(scope: "src/core/auth.ts", agent: "claude-code")
181
+ ```
182
+
183
+ The check is fully **deterministic** (no AI involved) and verifies:
184
+
185
+ - **Claim active** — Does the agent have a claim on this scope? (BLOCK if not)
186
+ - **Claim conflict** — Is another agent claiming this scope? (BLOCK)
187
+ - **Constraints** — Do any active constraints with matching `related_paths` apply? (WARN)
188
+ - **Traps** — Are there known pitfalls for this scope? (WARN)
189
+ - **Governance context** — Active global instructions are surfaced for reference.
190
+
191
+ Policy warnings are also **automatically included** in the `bclaw_claim` response — agents get constraint and trap alerts at claim time without an extra call.
192
+
193
+ ## Recommended workflow
194
+
195
+ 1. create a plan item
196
+ 2. claim the target scope — `bclaw_claim` (or `bclaw_work(intent="execute", scope=…, planId=…)`) creates an isolated git worktree under `~/.brainclaw/worktrees/<project-hash>/` automatically; policy warnings are surfaced as part of the response
197
+ 3. work on the implementation inside the worktree
198
+ 4. update the plan status (`bclaw_transition(entity="plan", id, to="in_progress" | "done")`)
199
+ 5. commit and merge back; release the claim when done or blocked
200
+ 6. create a handoff if another actor should continue
201
+
202
+ ## Session hygiene
203
+
204
+ Before finishing a session, always:
205
+
206
+ - release active claims: `brainclaw claim release <id>`
207
+ - update plan items: `brainclaw plan update <id> --status done`
208
+ - or use `brainclaw session-end --auto-release` to clean up automatically
209
+
210
+ `session-end --auto-release` releases all claims held by the current agent and marks any `in_progress` plans as needing attention.
211
+
212
+ ## Plans + claims together
213
+
214
+ Plans describe what should happen.
215
+ Claims describe who is currently working where.
216
+
217
+ That combination is much more useful than either one alone.
@@ -1,35 +1,35 @@
1
- # The PROJECT.md Convention (Instruction Layering)
2
-
3
- When working with AI agents, balancing **context freshness** against **context bloat** is an ongoing challenge. If you feed an agent too many rules, it consumes tokens and increases the risk of "lazy" behavior or hallucinated context loss.
4
-
5
- Brainclaw enforces a strict separation of concerns via "Instruction Layering":
6
-
7
- 1. **Coordination Rules (The `brainclaw` context):** Managed completely by Brainclaw. This covers memory synchronization, plans, handoffs, and team coordination.
8
- 2. **Domain Rules (The Project context):** Managed entirely by you. This covers tech stack features, architecture standards, UI guidelines, and test instructions.
9
-
10
- To link these two seamlessly, Brainclaw introduces the canonical **`PROJECT.md` Convention**.
11
-
12
- ## The Mechanism
13
-
14
- Brainclaw treats the `PROJECT.md` file at the root of a workspace as the definitive source of truth for your domain rules.
15
-
16
- When Brainclaw updates the surface instruction files for agents (`CLAUDE.md`, `copilot-instructions.md`, `.cursor/rules`, etc.), it automatically extracts and routes your project vision using a **hybrid injection technique**.
17
-
18
- ### 1. The "Inject Content" Mode (Short Files, <=20 lines)
19
- If your `PROJECT.md` is concise and serves as a simple "pitch" for the project (under 20 lines), Brainclaw will literally copy its content into the agent surface files under the `## brainclaw — this project` header.
20
- - **Benefit:** Zero tool calls required by the agent. It gets the pitch instantly on session start.
21
-
22
- ### 2. The "Inject Pointer" Mode (Detailed Files, >20 lines)
23
- For larger, production-grade projects, your domain rules will easily exceed 20 lines. If Brainclaw injected 300 lines of coding guidelines into every agent prompt file, it would destroy your context window.
24
- Instead, when your `PROJECT.md` exceeds 20 lines, Brainclaw injects a rigid pointer:
25
-
26
- > **Project Domain Rules**
27
- > This project maintains detailed domain rules and architecture externally to avoid context bloat.
28
- > You MUST read `PROJECT.md` in the workspace root to understand the project constraints, tech stack, and conventions before coding.
29
-
30
- - **Benefit:** Prevents context bloat. The agent uses a targeted file read (`read_file`) only when necessary to acquire deep codebase context.
31
-
32
- ## Best Practices
33
-
34
- - Always keep architecture guidelines, testing boundaries, and specific rules in `PROJECT.md` (or link out to other docs from it).
35
- - Never edit the `<!-- brainclaw:start -->` wrapped contents in surface files manually. They will be overwritten during the next `brainclaw export` cycle.
1
+ # The PROJECT.md Convention (Instruction Layering)
2
+
3
+ When working with AI agents, balancing **context freshness** against **context bloat** is an ongoing challenge. If you feed an agent too many rules, it consumes tokens and increases the risk of "lazy" behavior or hallucinated context loss.
4
+
5
+ Brainclaw enforces a strict separation of concerns via "Instruction Layering":
6
+
7
+ 1. **Coordination Rules (The `brainclaw` context):** Managed completely by Brainclaw. This covers memory synchronization, plans, handoffs, and team coordination.
8
+ 2. **Domain Rules (The Project context):** Managed entirely by you. This covers tech stack features, architecture standards, UI guidelines, and test instructions.
9
+
10
+ To link these two seamlessly, Brainclaw introduces the canonical **`PROJECT.md` Convention**.
11
+
12
+ ## The Mechanism
13
+
14
+ Brainclaw treats the `PROJECT.md` file at the root of a workspace as the definitive source of truth for your domain rules.
15
+
16
+ When Brainclaw updates the surface instruction files for agents (`CLAUDE.md`, `copilot-instructions.md`, `.cursor/rules`, etc.), it automatically extracts and routes your project vision using a **hybrid injection technique**.
17
+
18
+ ### 1. The "Inject Content" Mode (Short Files, <=20 lines)
19
+ If your `PROJECT.md` is concise and serves as a simple "pitch" for the project (under 20 lines), Brainclaw will literally copy its content into the agent surface files under the `## brainclaw — this project` header.
20
+ - **Benefit:** Zero tool calls required by the agent. It gets the pitch instantly on session start.
21
+
22
+ ### 2. The "Inject Pointer" Mode (Detailed Files, >20 lines)
23
+ For larger, production-grade projects, your domain rules will easily exceed 20 lines. If Brainclaw injected 300 lines of coding guidelines into every agent prompt file, it would destroy your context window.
24
+ Instead, when your `PROJECT.md` exceeds 20 lines, Brainclaw injects a rigid pointer:
25
+
26
+ > **Project Domain Rules**
27
+ > This project maintains detailed domain rules and architecture externally to avoid context bloat.
28
+ > You MUST read `PROJECT.md` in the workspace root to understand the project constraints, tech stack, and conventions before coding.
29
+
30
+ - **Benefit:** Prevents context bloat. The agent uses a targeted file read (`read_file`) only when necessary to acquire deep codebase context.
31
+
32
+ ## Best Practices
33
+
34
+ - Always keep architecture guidelines, testing boundaries, and specific rules in `PROJECT.md` (or link out to other docs from it).
35
+ - Never edit the `<!-- brainclaw:start -->` wrapped contents in surface files manually. They will be overwritten during the next `brainclaw export` cycle.
@@ -1,38 +1,38 @@
1
- # Runtime Notes
2
-
3
- Runtime notes capture operational observations made during work.
4
-
5
- They help bridge the gap between live execution and durable project memory.
6
-
7
- ## Examples
8
-
9
- - a local environment quirk
10
- - a host-specific issue
11
- - a temporary blocker
12
- - a short-lived implementation observation
13
- - a note worth later reflection
14
-
15
- ## Visibility modes
16
-
17
- Depending on configuration and use, runtime notes may be:
18
-
19
- - shared
20
- - machine-local
21
- - private
22
-
23
- This lets teams keep transient or host-specific context available without polluting canonical project memory too early.
24
-
25
- ## Reflection workflow
26
-
27
- A runtime note does not have to become durable memory immediately.
28
- A useful pattern is:
29
-
30
- 1. capture the observation quickly
31
- 2. keep it visible in runtime state
32
- 3. reflect it into a candidate if it seems reusable
33
- 4. accept or reject it later through review
34
-
35
- ## Why this matters
36
-
37
- This creates a safer bridge from ephemeral facts to durable memory.
38
- Not every operational observation deserves instant promotion.
1
+ # Runtime Notes
2
+
3
+ Runtime notes capture operational observations made during work.
4
+
5
+ They help bridge the gap between live execution and durable project memory.
6
+
7
+ ## Examples
8
+
9
+ - a local environment quirk
10
+ - a host-specific issue
11
+ - a temporary blocker
12
+ - a short-lived implementation observation
13
+ - a note worth later reflection
14
+
15
+ ## Visibility modes
16
+
17
+ Depending on configuration and use, runtime notes may be:
18
+
19
+ - shared
20
+ - machine-local
21
+ - private
22
+
23
+ This lets teams keep transient or host-specific context available without polluting canonical project memory too early.
24
+
25
+ ## Reflection workflow
26
+
27
+ A runtime note does not have to become durable memory immediately.
28
+ A useful pattern is:
29
+
30
+ 1. capture the observation quickly
31
+ 2. keep it visible in runtime state
32
+ 3. reflect it into a candidate if it seems reusable
33
+ 4. accept or reject it later through review
34
+
35
+ ## Why this matters
36
+
37
+ This creates a safer bridge from ephemeral facts to durable memory.
38
+ Not every operational observation deserves instant promotion.
@@ -0,0 +1,78 @@
1
+ # Skills — agent-profile vs workflow-protocol
2
+
3
+ Brainclaw writes two orthogonal kinds of agent skill. The same agent can load
4
+ both; they answer different questions.
5
+
6
+ ## Agent-profile skills
7
+
8
+ The agent's **landing page** for brainclaw — one per agent profile
9
+ (`openclaw`, `nanoclaw`, `nemoclaw`, `picoclaw`, `zeroclaw`) plus the universal
10
+ `.agents/skills/brainclaw/SKILL.md` discovered by every agent that honors the
11
+ shared `.agents/skills/` convention (Cursor, Copilot, Roo, OpenCode, Codex,
12
+ Kilo, Mistral…). It answers *"what is brainclaw and how do I load context here?"*
13
+ and points at `bclaw_work` as the entry verb.
14
+
15
+ Source: `src/core/agent-files.ts` (`ensureUniversalBrainclawSkill`, the per-profile
16
+ writers). These files are **generated, not committed** — they are gitignored and
17
+ materialized by `brainclaw export` / setup, so the source of truth is the code,
18
+ never a checked-in `SKILL.md`.
19
+
20
+ ## Workflow-protocol skills (pln#519)
21
+
22
+ **Workflow-decomposed** skills that package a critical brainclaw protocol so the
23
+ agent loads *the right one at the right moment* instead of skimming a monolithic
24
+ AGENTS.md. Three ship today, namespaced `brainclaw-*`:
25
+
26
+ | Skill | Trigger |
27
+ |---|---|
28
+ | `brainclaw-session` | starting / resuming / closing a session; before claiming a scope |
29
+ | `brainclaw-memory-capture` | recording a decision / constraint / trap / handoff at the right type |
30
+ | `brainclaw-multi-agent` | delegating, reviewing, dispatching, driving a loop |
31
+
32
+ They carry `metadata.protocol: true` in frontmatter so skill-loader UIs can list
33
+ protocols separately from profile skills, and `metadata.brainclaw_version` (set
34
+ to `package.json:version` at write time) so a loader can detect a cached skill
35
+ that predates a brainclaw upgrade. Each follows the "process not prose" shape:
36
+ **When to use → Workflow → Anti-rationalizations → Red flags → Verification**.
37
+
38
+ Source: `src/core/protocol-skills.ts` (single source of truth; content is
39
+ embedded, not read from a repo file, so it installs identically from source or
40
+ an npm install). Written to `.agents/skills/<id>/SKILL.md` by
41
+ `ensureProtocolSkills`, wired into `writeDetectedAgentAutoConfig` for every agent
42
+ whose capability profile declares `hasSkills: true`. Generated + gitignored, like
43
+ the profile skills.
44
+
45
+ ### Design invariants
46
+
47
+ - **No dynamic state.** A protocol-skill never embeds a concrete `claim_id` /
48
+ `loop_id` / `plan_id` — it tells the agent *when* to call a facade and *how to
49
+ read* live state, never *what the current state is*. (Enforced by a test.)
50
+ - **Facade-only.** Skills reference canonical-grammar / facade verbs by name;
51
+ they never re-implement `mcp.ts` logic. A protocol change updates the skill,
52
+ not the other way round.
53
+ - **Both MCP and CLI.** Each workflow shows the MCP call AND the `brainclaw …`
54
+ CLI fallback, because MCP is not always wired (cold start; a dispatched worker
55
+ in a worktree without `.brainclaw/`, trp#336).
56
+ - **Capped at 3.** Setup and troubleshooting protocols are deferred until an
57
+ empirical friction shows the three are insufficient (design §E.2). A 4th
58
+ protocol needs a runtime_note documenting the gap it closes.
59
+
60
+ ## Namespace claim
61
+
62
+ Brainclaw owns the `brainclaw-*` prefix under `.agents/skills/`. Other tools that
63
+ install skills into the shared directory must avoid `brainclaw-` ids to prevent
64
+ collisions.
65
+
66
+ ## Supply chain
67
+
68
+ Protocol-skills ship **inside the npm package**. Brainclaw does **not** currently
69
+ support installing external skills (no `brainclaw skill install <url>`, no loading
70
+ from arbitrary paths). If external installs are ever added they will require a
71
+ deliberate trust boundary (local-only or brainclaw-signed); that is out of scope
72
+ today.
73
+
74
+ ## Staleness
75
+
76
+ If `brainclaw --version` reports newer than a skill's `brainclaw_version`,
77
+ re-run `brainclaw export --all --write` to regenerate. The version tag lets a
78
+ caching loader detect drift; it does not self-heal.