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,328 +1,328 @@
1
- # Project Refs for Multi-Project Navigation
2
-
3
- > Proposal / design note: this document describes a target navigation model, not the currently shipped CLI or MCP surface. For implemented multi-project commands today, use `brainclaw switch` and `brainclaw projects`.
4
-
5
- ## Goal
6
-
7
- In a multi-project workspace, agents should be able to address any known project from anywhere in the workspace without depending on the current working directory.
8
-
9
- The core primitive for this is a stable `project_ref`.
10
-
11
- Examples:
12
-
13
- - `dev/repos/global`
14
- - `applications/lodestar`
15
- - `core_services/postgres`
16
-
17
- This lets Brainclaw support direct project navigation commands such as:
18
-
19
- - `brainclaw projects`
20
- - `brainclaw project applications/lodestar`
21
- - `brainclaw context --project applications/lodestar`
22
- - `brainclaw children dev/repos/global`
23
- - `brainclaw ancestors applications/lodestar`
24
- - `brainclaw dependencies applications/lodestar`
25
- - `brainclaw locate dev/repos/global/applications/lodestar/src/app.ts`
26
-
27
- The same addressing model must exist over MCP.
28
-
29
- ## Why
30
-
31
- Current workspace-centric behavior is still too dependent on `cwd` and path heuristics:
32
-
33
- - `brainclaw context --for <path>` can help rerank context
34
- - in folder-mode workspaces it can now resolve a child store for some path-shaped targets
35
- - but the mental model is still "where am I on disk?"
36
-
37
- For agents, this is weaker than "which project am I addressing?"
38
-
39
- `project_ref` should become the natural addressing unit for:
40
-
41
- - context lookup
42
- - workspace navigation
43
- - parent/child traversal
44
- - dependency traversal
45
- - future project-scoped MCP tools
46
-
47
- ## Core Model
48
-
49
- Each known project keeps its internal `project_id`.
50
-
51
- Each project also gets a stable human-readable `project_ref`:
52
-
53
- - derived from the workspace-relative path
54
- - normalized with forward slashes
55
- - unique within the workspace
56
-
57
- Examples:
58
-
59
- - workspace root: `.`
60
- - child repo: `dev/repos/global`
61
- - nested project: `dev/repos/global/applications/lodestar`
62
-
63
- The registry for a workspace project should expose at least:
64
-
65
- - `project_id`
66
- - `project_ref`
67
- - `project_name`
68
- - `relative_path`
69
- - `absolute_path`
70
- - `workspace_root`
71
- - `parent_ref`
72
- - `aliases`
73
- - `store_present`
74
- - `source`
75
- - `dependencies`
76
-
77
- ## Naming Rules
78
-
79
- Canonical rule:
80
-
81
- - `project_ref` is the workspace-relative path to the project root
82
-
83
- Short aliases:
84
-
85
- - the final path segment may be used as an alias
86
- - only when unique within the workspace
87
- - ambiguous aliases must fail with a disambiguation error
88
-
89
- Examples:
90
-
91
- - `applications/lodestar` may have alias `lodestar`
92
- - if two projects end with `api`, `brainclaw project api` must fail and suggest full refs
93
-
94
- This keeps the model simple:
95
-
96
- - canonical ref is always deterministic
97
- - short names are optional ergonomics, not identity
98
-
99
- ## Project Resolution
100
-
101
- Resolution should work from anywhere in the workspace.
102
-
103
- The resolver accepts:
104
-
105
- - exact `project_ref`
106
- - exact `project_id`
107
- - unique short alias
108
- - absolute path to a project root
109
- - absolute or relative path inside a project
110
-
111
- The resolver returns:
112
-
113
- - the matched project record
114
- - the resolved project root
115
- - the matched method: `ref`, `id`, `alias`, or `path`
116
-
117
- Resolution priority:
118
-
119
- 1. exact `project_ref`
120
- 2. exact `project_id`
121
- 3. unique alias
122
- 4. path-to-project containment
123
-
124
- If multiple matches remain, Brainclaw must stop and return a clear ambiguity error.
125
-
126
- ## CLI Surface
127
-
128
- The minimal agent-first CLI surface should be:
129
-
130
- ### `brainclaw projects`
131
-
132
- List known projects in the current workspace.
133
-
134
- Fields:
135
-
136
- - `project_ref`
137
- - `project_name`
138
- - `relative_path`
139
- - `parent_ref`
140
- - `store_present`
141
-
142
- ### `brainclaw project <ref>`
143
-
144
- Show a compact project card.
145
-
146
- Fields:
147
-
148
- - `project_id`
149
- - `project_ref`
150
- - `aliases`
151
- - `absolute_path`
152
- - `parent_ref`
153
- - `children`
154
- - `dependencies`
155
- - store health summary
156
-
157
- ### `brainclaw context --project <ref>`
158
-
159
- Resolve the target project first, then build context from that store.
160
-
161
- Notes:
162
-
163
- - this is stronger than `context --for`
164
- - `--for` still helps ranking within the resolved project
165
-
166
- Example:
167
-
168
- ```bash
169
- brainclaw context --project applications/lodestar --for src/app.ts
170
- ```
171
-
172
- ### `brainclaw children <ref>`
173
-
174
- Return direct child projects.
175
-
176
- ### `brainclaw ancestors <ref>`
177
-
178
- Return the project chain from parent to workspace root.
179
-
180
- ### `brainclaw dependencies <ref>`
181
-
182
- Return declared or detected project dependencies.
183
-
184
- ### `brainclaw locate <path>`
185
-
186
- Resolve any path to the owning project.
187
-
188
- This is especially useful for agents:
189
-
190
- - start from a changed file
191
- - ask Brainclaw which project owns it
192
- - then request context for that project
193
-
194
- ## MCP Surface
195
-
196
- The MCP equivalents should mirror the CLI rather than invent a second addressing model.
197
-
198
- Suggested tools:
199
-
200
- - `bclaw_list_projects`
201
- - `bclaw_get_project`
202
- - `bclaw_get_project_context`
203
- - `bclaw_list_project_children`
204
- - `bclaw_list_project_ancestors`
205
- - `bclaw_list_project_dependencies`
206
- - `bclaw_locate_project`
207
-
208
- All of them should accept `project_ref` as the primary selector.
209
-
210
- `bclaw_get_context` may continue to exist, but multi-project agents should prefer `bclaw_get_project_context`.
211
-
212
- ## Hierarchy Semantics
213
-
214
- Hierarchy comes from project roots on disk.
215
-
216
- Definitions:
217
-
218
- - parent: nearest known project root above the current project
219
- - child: known project whose nearest known parent is the current project
220
- - ancestor: repeated parent chain
221
-
222
- This is path-derived and deterministic.
223
-
224
- ## Dependency Semantics
225
-
226
- Dependencies are different from hierarchy.
227
-
228
- Dependencies should support two sources:
229
-
230
- - declared links in Brainclaw metadata
231
- - detected links from repo/workspace tooling when reliable
232
-
233
- Examples:
234
-
235
- - monorepo package dependencies
236
- - service depends on shared database project
237
- - app depends on auth service
238
-
239
- The first iteration should allow declared dependencies first.
240
-
241
- Auto-detection can remain additive.
242
-
243
- ## Storage Direction
244
-
245
- This does not require replacing current project ids or store layout.
246
-
247
- It requires a workspace project registry that can be rebuilt or refreshed non-destructively.
248
-
249
- Likely location:
250
-
251
- - workspace-level discovery inventory
252
-
253
- Likely persisted fields:
254
-
255
- - stable `project_ref`
256
- - alias set
257
- - hierarchy links
258
- - declared dependency links
259
-
260
- This should stay clearly separate from canonical memory items such as decisions and constraints.
261
-
262
- ## Implementation snapshot (v0.23.0, kept for design reference)
263
-
264
- > This section reflects what was shipped at the time the proposal was written (v0.23.0). For the implemented multi-project navigation surface today, refer to [docs/cli.md](../cli.md) (`brainclaw switch`, `brainclaw projects`, `BRAINCLAW_PROJECT`, `--cwd`).
265
-
266
- `brainclaw switch` provides the first layer of project navigation:
267
-
268
- - `brainclaw switch <name-or-path>` — set active project by name or relative path
269
- - `brainclaw switch --list` — discover available projects in workspace
270
- - `resolveProjectRef()` — shared resolver for CLI and MCP (name, path, registry lookup)
271
- - `resolveEffectiveCwd()` — single source of truth: `--cwd` > `BRAINCLAW_PROJECT` env > active-project > cwd
272
- - MCP tools automatically resolve the active project
273
-
274
- This covers the most common agent friction (cwd-dependent resolution) without requiring the full `project_ref` model yet.
275
-
276
- ## Migration Strategy
277
-
278
- The migration should be low-risk and incremental.
279
-
280
- Phase 0 (done):
281
-
282
- - `brainclaw switch` with name/path resolution
283
- - global `--cwd` option
284
- - `BRAINCLAW_PROJECT` environment variable
285
- - `resolveEffectiveCwd()` used by CLI and MCP
286
-
287
- Phase 1:
288
-
289
- - introduce `project_ref` in workspace discovery/registry
290
- - expose `brainclaw projects`
291
- - expose `brainclaw locate`
292
-
293
- Phase 2:
294
-
295
- - add `context --project <ref>`
296
- - keep current `context --for <path>` behavior
297
- - when `--project` is present, it wins over cwd heuristics
298
-
299
- Phase 3:
300
-
301
- - add `children` and `ancestors`
302
- - add MCP equivalents
303
-
304
- Phase 4:
305
-
306
- - add declared dependencies
307
- - optionally add auto-detection
308
-
309
- ## Non-Goals
310
-
311
- This design does not require:
312
-
313
- - replacing `project_id`
314
- - removing cwd-based commands
315
- - making aliases mandatory
316
- - making dependency inference perfect in the first release
317
-
318
- ## Recommendation
319
-
320
- The first implementation slice should be:
321
-
322
- 1. add `project_ref` to workspace project discovery
323
- 2. add a project resolver shared by CLI and MCP
324
- 3. add `brainclaw projects`
325
- 4. add `brainclaw context --project <ref>`
326
- 5. add `brainclaw locate <path>`
327
-
328
- That is enough to give agents a stable and simple project-addressing model without a risky refactor.
1
+ # Project Refs for Multi-Project Navigation
2
+
3
+ > Proposal / design note: this document describes a target navigation model, not the currently shipped CLI or MCP surface. For implemented multi-project commands today, use `brainclaw switch` and `brainclaw projects`.
4
+
5
+ ## Goal
6
+
7
+ In a multi-project workspace, agents should be able to address any known project from anywhere in the workspace without depending on the current working directory.
8
+
9
+ The core primitive for this is a stable `project_ref`.
10
+
11
+ Examples:
12
+
13
+ - `dev/repos/global`
14
+ - `applications/lodestar`
15
+ - `core_services/postgres`
16
+
17
+ This lets Brainclaw support direct project navigation commands such as:
18
+
19
+ - `brainclaw projects`
20
+ - `brainclaw project applications/lodestar`
21
+ - `brainclaw context --project applications/lodestar`
22
+ - `brainclaw children dev/repos/global`
23
+ - `brainclaw ancestors applications/lodestar`
24
+ - `brainclaw dependencies applications/lodestar`
25
+ - `brainclaw locate dev/repos/global/applications/lodestar/src/app.ts`
26
+
27
+ The same addressing model must exist over MCP.
28
+
29
+ ## Why
30
+
31
+ Current workspace-centric behavior is still too dependent on `cwd` and path heuristics:
32
+
33
+ - `brainclaw context --for <path>` can help rerank context
34
+ - in folder-mode workspaces it can now resolve a child store for some path-shaped targets
35
+ - but the mental model is still "where am I on disk?"
36
+
37
+ For agents, this is weaker than "which project am I addressing?"
38
+
39
+ `project_ref` should become the natural addressing unit for:
40
+
41
+ - context lookup
42
+ - workspace navigation
43
+ - parent/child traversal
44
+ - dependency traversal
45
+ - future project-scoped MCP tools
46
+
47
+ ## Core Model
48
+
49
+ Each known project keeps its internal `project_id`.
50
+
51
+ Each project also gets a stable human-readable `project_ref`:
52
+
53
+ - derived from the workspace-relative path
54
+ - normalized with forward slashes
55
+ - unique within the workspace
56
+
57
+ Examples:
58
+
59
+ - workspace root: `.`
60
+ - child repo: `dev/repos/global`
61
+ - nested project: `dev/repos/global/applications/lodestar`
62
+
63
+ The registry for a workspace project should expose at least:
64
+
65
+ - `project_id`
66
+ - `project_ref`
67
+ - `project_name`
68
+ - `relative_path`
69
+ - `absolute_path`
70
+ - `workspace_root`
71
+ - `parent_ref`
72
+ - `aliases`
73
+ - `store_present`
74
+ - `source`
75
+ - `dependencies`
76
+
77
+ ## Naming Rules
78
+
79
+ Canonical rule:
80
+
81
+ - `project_ref` is the workspace-relative path to the project root
82
+
83
+ Short aliases:
84
+
85
+ - the final path segment may be used as an alias
86
+ - only when unique within the workspace
87
+ - ambiguous aliases must fail with a disambiguation error
88
+
89
+ Examples:
90
+
91
+ - `applications/lodestar` may have alias `lodestar`
92
+ - if two projects end with `api`, `brainclaw project api` must fail and suggest full refs
93
+
94
+ This keeps the model simple:
95
+
96
+ - canonical ref is always deterministic
97
+ - short names are optional ergonomics, not identity
98
+
99
+ ## Project Resolution
100
+
101
+ Resolution should work from anywhere in the workspace.
102
+
103
+ The resolver accepts:
104
+
105
+ - exact `project_ref`
106
+ - exact `project_id`
107
+ - unique short alias
108
+ - absolute path to a project root
109
+ - absolute or relative path inside a project
110
+
111
+ The resolver returns:
112
+
113
+ - the matched project record
114
+ - the resolved project root
115
+ - the matched method: `ref`, `id`, `alias`, or `path`
116
+
117
+ Resolution priority:
118
+
119
+ 1. exact `project_ref`
120
+ 2. exact `project_id`
121
+ 3. unique alias
122
+ 4. path-to-project containment
123
+
124
+ If multiple matches remain, Brainclaw must stop and return a clear ambiguity error.
125
+
126
+ ## CLI Surface
127
+
128
+ The minimal agent-first CLI surface should be:
129
+
130
+ ### `brainclaw projects`
131
+
132
+ List known projects in the current workspace.
133
+
134
+ Fields:
135
+
136
+ - `project_ref`
137
+ - `project_name`
138
+ - `relative_path`
139
+ - `parent_ref`
140
+ - `store_present`
141
+
142
+ ### `brainclaw project <ref>`
143
+
144
+ Show a compact project card.
145
+
146
+ Fields:
147
+
148
+ - `project_id`
149
+ - `project_ref`
150
+ - `aliases`
151
+ - `absolute_path`
152
+ - `parent_ref`
153
+ - `children`
154
+ - `dependencies`
155
+ - store health summary
156
+
157
+ ### `brainclaw context --project <ref>`
158
+
159
+ Resolve the target project first, then build context from that store.
160
+
161
+ Notes:
162
+
163
+ - this is stronger than `context --for`
164
+ - `--for` still helps ranking within the resolved project
165
+
166
+ Example:
167
+
168
+ ```bash
169
+ brainclaw context --project applications/lodestar --for src/app.ts
170
+ ```
171
+
172
+ ### `brainclaw children <ref>`
173
+
174
+ Return direct child projects.
175
+
176
+ ### `brainclaw ancestors <ref>`
177
+
178
+ Return the project chain from parent to workspace root.
179
+
180
+ ### `brainclaw dependencies <ref>`
181
+
182
+ Return declared or detected project dependencies.
183
+
184
+ ### `brainclaw locate <path>`
185
+
186
+ Resolve any path to the owning project.
187
+
188
+ This is especially useful for agents:
189
+
190
+ - start from a changed file
191
+ - ask Brainclaw which project owns it
192
+ - then request context for that project
193
+
194
+ ## MCP Surface
195
+
196
+ The MCP equivalents should mirror the CLI rather than invent a second addressing model.
197
+
198
+ Suggested tools:
199
+
200
+ - `bclaw_list_projects`
201
+ - `bclaw_get_project`
202
+ - `bclaw_get_project_context`
203
+ - `bclaw_list_project_children`
204
+ - `bclaw_list_project_ancestors`
205
+ - `bclaw_list_project_dependencies`
206
+ - `bclaw_locate_project`
207
+
208
+ All of them should accept `project_ref` as the primary selector.
209
+
210
+ `bclaw_get_context` may continue to exist, but multi-project agents should prefer `bclaw_get_project_context`.
211
+
212
+ ## Hierarchy Semantics
213
+
214
+ Hierarchy comes from project roots on disk.
215
+
216
+ Definitions:
217
+
218
+ - parent: nearest known project root above the current project
219
+ - child: known project whose nearest known parent is the current project
220
+ - ancestor: repeated parent chain
221
+
222
+ This is path-derived and deterministic.
223
+
224
+ ## Dependency Semantics
225
+
226
+ Dependencies are different from hierarchy.
227
+
228
+ Dependencies should support two sources:
229
+
230
+ - declared links in Brainclaw metadata
231
+ - detected links from repo/workspace tooling when reliable
232
+
233
+ Examples:
234
+
235
+ - monorepo package dependencies
236
+ - service depends on shared database project
237
+ - app depends on auth service
238
+
239
+ The first iteration should allow declared dependencies first.
240
+
241
+ Auto-detection can remain additive.
242
+
243
+ ## Storage Direction
244
+
245
+ This does not require replacing current project ids or store layout.
246
+
247
+ It requires a workspace project registry that can be rebuilt or refreshed non-destructively.
248
+
249
+ Likely location:
250
+
251
+ - workspace-level discovery inventory
252
+
253
+ Likely persisted fields:
254
+
255
+ - stable `project_ref`
256
+ - alias set
257
+ - hierarchy links
258
+ - declared dependency links
259
+
260
+ This should stay clearly separate from canonical memory items such as decisions and constraints.
261
+
262
+ ## Implementation snapshot (v0.23.0, kept for design reference)
263
+
264
+ > This section reflects what was shipped at the time the proposal was written (v0.23.0). For the implemented multi-project navigation surface today, refer to [docs/cli.md](../cli.md) (`brainclaw switch`, `brainclaw projects`, `BRAINCLAW_PROJECT`, `--cwd`).
265
+
266
+ `brainclaw switch` provides the first layer of project navigation:
267
+
268
+ - `brainclaw switch <name-or-path>` — set active project by name or relative path
269
+ - `brainclaw switch --list` — discover available projects in workspace
270
+ - `resolveProjectRef()` — shared resolver for CLI and MCP (name, path, registry lookup)
271
+ - `resolveEffectiveCwd()` — single source of truth: `--cwd` > `BRAINCLAW_PROJECT` env > active-project > cwd
272
+ - MCP tools automatically resolve the active project
273
+
274
+ This covers the most common agent friction (cwd-dependent resolution) without requiring the full `project_ref` model yet.
275
+
276
+ ## Migration Strategy
277
+
278
+ The migration should be low-risk and incremental.
279
+
280
+ Phase 0 (done):
281
+
282
+ - `brainclaw switch` with name/path resolution
283
+ - global `--cwd` option
284
+ - `BRAINCLAW_PROJECT` environment variable
285
+ - `resolveEffectiveCwd()` used by CLI and MCP
286
+
287
+ Phase 1:
288
+
289
+ - introduce `project_ref` in workspace discovery/registry
290
+ - expose `brainclaw projects`
291
+ - expose `brainclaw locate`
292
+
293
+ Phase 2:
294
+
295
+ - add `context --project <ref>`
296
+ - keep current `context --for <path>` behavior
297
+ - when `--project` is present, it wins over cwd heuristics
298
+
299
+ Phase 3:
300
+
301
+ - add `children` and `ancestors`
302
+ - add MCP equivalents
303
+
304
+ Phase 4:
305
+
306
+ - add declared dependencies
307
+ - optionally add auto-detection
308
+
309
+ ## Non-Goals
310
+
311
+ This design does not require:
312
+
313
+ - replacing `project_id`
314
+ - removing cwd-based commands
315
+ - making aliases mandatory
316
+ - making dependency inference perfect in the first release
317
+
318
+ ## Recommendation
319
+
320
+ The first implementation slice should be:
321
+
322
+ 1. add `project_ref` to workspace project discovery
323
+ 2. add a project resolver shared by CLI and MCP
324
+ 3. add `brainclaw projects`
325
+ 4. add `brainclaw context --project <ref>`
326
+ 5. add `brainclaw locate <path>`
327
+
328
+ That is enough to give agents a stable and simple project-addressing model without a risky refactor.