brainclaw 1.9.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.
- package/README.md +585 -499
- package/dist/brainclaw-vscode.vsix +0 -0
- package/dist/commands/harvest.js +1 -1
- package/dist/commands/hooks.js +73 -73
- package/dist/commands/init.js +1 -1
- package/dist/commands/install-hooks.js +78 -78
- package/dist/commands/mcp-read-handlers.js +57 -14
- package/dist/commands/mcp.js +79 -13
- package/dist/commands/switch.js +26 -5
- package/dist/commands/version.js +1 -1
- package/dist/core/agent-capability.js +19 -4
- package/dist/core/agent-files.js +119 -119
- package/dist/core/codev-prompts.js +38 -38
- package/dist/core/default-profiles/doctor.yaml +11 -11
- package/dist/core/default-profiles/janitor.yaml +11 -11
- package/dist/core/default-profiles/onboarder.yaml +11 -11
- package/dist/core/default-profiles/reviewer.yaml +13 -13
- package/dist/core/dispatcher.js +1 -1
- package/dist/core/entity-operations.js +29 -3
- package/dist/core/execution.js +1 -1
- package/dist/core/loops/verbs.js +0 -1
- package/dist/core/messaging.js +2 -2
- package/dist/core/protocol-skills.js +164 -164
- package/dist/core/runtime-signals.js +1 -1
- package/dist/core/search.js +19 -2
- package/dist/core/security-guard.js +207 -207
- package/dist/core/spawn-check.js +16 -2
- package/dist/core/staleness.js +1 -1
- package/dist/core/store-resolution.js +26 -7
- package/dist/core/worktree.js +18 -18
- package/dist/facts.js +3 -3
- package/dist/facts.json +2 -2
- package/docs/PROTOCOL.md +1 -1
- package/docs/adapters/openclaw.md +43 -43
- package/docs/architecture/project-refs.md +328 -328
- package/docs/cli.md +2093 -2093
- package/docs/concepts/coordination.md +52 -52
- package/docs/concepts/coordinator-runbook.md +129 -129
- package/docs/concepts/dispatch-lifecycle.md +245 -245
- package/docs/concepts/event-log-store.md +928 -928
- package/docs/concepts/ideation-loop.md +317 -317
- package/docs/concepts/loop-engine.md +520 -511
- package/docs/concepts/mcp-governance.md +268 -268
- package/docs/concepts/memory.md +84 -84
- package/docs/concepts/multi-agent-workflows.md +167 -167
- package/docs/concepts/observer-protocol.md +361 -361
- package/docs/concepts/plans-and-claims.md +217 -217
- package/docs/concepts/project-md-convention.md +35 -35
- package/docs/concepts/runtime-notes.md +38 -38
- package/docs/concepts/troubleshooting.md +254 -254
- package/docs/concepts/workspace-bootstrapping.md +142 -142
- package/docs/context-format-changelog.md +35 -35
- package/docs/context-format.md +48 -48
- package/docs/index.md +65 -65
- package/docs/integrations/agents.md +158 -158
- package/docs/integrations/claude-code.md +23 -23
- package/docs/integrations/cline.md +77 -77
- package/docs/integrations/continue.md +55 -55
- package/docs/integrations/copilot.md +68 -68
- package/docs/integrations/cursor.md +23 -23
- package/docs/integrations/kilocode.md +72 -72
- package/docs/integrations/mcp.md +377 -377
- package/docs/integrations/mistral-vibe.md +122 -122
- package/docs/integrations/openclaw.md +92 -92
- package/docs/integrations/opencode.md +84 -84
- package/docs/integrations/overview.md +115 -115
- package/docs/integrations/roo.md +71 -71
- package/docs/integrations/windsurf.md +77 -77
- package/docs/mcp-schema-changelog.md +360 -356
- package/docs/playbooks/integration/index.md +121 -121
- package/docs/playbooks/orchestration.md +37 -0
- package/docs/playbooks/productivity/index.md +99 -99
- package/docs/playbooks/team/index.md +117 -117
- package/docs/product/agent-first-model.md +184 -184
- package/docs/product/entity-model-audit.md +462 -462
- package/docs/product/positioning.md +86 -86
- package/docs/quickstart-existing-project.md +107 -107
- package/docs/quickstart.md +183 -183
- package/docs/release-maintenance.md +79 -79
- package/docs/reputation.md +52 -52
- package/docs/review.md +45 -45
- package/docs/security.md +212 -212
- package/docs/server-operations.md +118 -118
- package/docs/storage.md +106 -106
- package/package.json +80 -65
- package/docs/concepts/event-log-store-critique-A.md +0 -333
- package/docs/concepts/event-log-store-critique-B.md +0 -353
- package/docs/concepts/event-log-store-phase0-measurements.md +0 -58
- package/docs/concepts/event-log-store-proposal-A.md +0 -365
- package/docs/concepts/event-log-store-proposal-B.md +0 -404
- package/docs/concepts/identity-model-proposal.md +0 -371
|
@@ -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.
|