brainclaw 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +631 -499
  2. package/dist/brainclaw-vscode.vsix +0 -0
  3. package/dist/cli.js +18 -1
  4. package/dist/commands/code-map.js +129 -0
  5. package/dist/commands/codev.js +7 -0
  6. package/dist/commands/harvest.js +1 -1
  7. package/dist/commands/hooks.js +73 -73
  8. package/dist/commands/init.js +1 -1
  9. package/dist/commands/install-hooks.js +78 -78
  10. package/dist/commands/mcp-read-handlers.js +57 -14
  11. package/dist/commands/mcp.js +200 -13
  12. package/dist/commands/run-profile.js +3 -2
  13. package/dist/commands/switch.js +125 -93
  14. package/dist/commands/version.js +1 -1
  15. package/dist/core/agent-capability.js +19 -4
  16. package/dist/core/agent-files.js +131 -119
  17. package/dist/core/code-map/backend.js +123 -0
  18. package/dist/core/code-map/core.js +81 -0
  19. package/dist/core/code-map/drafts.js +2 -0
  20. package/dist/core/code-map/extractor.js +29 -0
  21. package/dist/core/code-map/finalizer.js +191 -0
  22. package/dist/core/code-map/freshness.js +108 -0
  23. package/dist/core/code-map/ids.js +0 -0
  24. package/dist/core/code-map/importable.js +35 -0
  25. package/dist/core/code-map/indexes.js +197 -0
  26. package/dist/core/code-map/lang/java/imports.scm +17 -0
  27. package/dist/core/code-map/lang/java/index.js +254 -0
  28. package/dist/core/code-map/lang/java/tags.scm +48 -0
  29. package/dist/core/code-map/lang/php/imports.scm +21 -0
  30. package/dist/core/code-map/lang/php/index.js +251 -0
  31. package/dist/core/code-map/lang/php/tags.scm +44 -0
  32. package/dist/core/code-map/lang/provider.js +9 -0
  33. package/dist/core/code-map/lang/providers.js +24 -0
  34. package/dist/core/code-map/lang/python/imports.scm +90 -0
  35. package/dist/core/code-map/lang/python/index.js +364 -0
  36. package/dist/core/code-map/lang/python/tags.scm +81 -0
  37. package/dist/core/code-map/lang/query-runtime.js +374 -0
  38. package/dist/core/code-map/lang/registry.js +125 -0
  39. package/dist/core/code-map/lang/typescript/imports.scm +90 -0
  40. package/dist/core/code-map/lang/typescript/index.js +306 -0
  41. package/dist/core/code-map/lang/typescript/tags.js.scm +106 -0
  42. package/dist/core/code-map/lang/typescript/tags.scm +151 -0
  43. package/dist/core/code-map/lock.js +210 -0
  44. package/dist/core/code-map/materialized.js +51 -0
  45. package/dist/core/code-map/memory-reader.js +59 -0
  46. package/dist/core/code-map/paths.js +53 -0
  47. package/dist/core/code-map/query.js +568 -0
  48. package/dist/core/code-map/refresh.js +0 -0
  49. package/dist/core/code-map/resolve.js +177 -0
  50. package/dist/core/code-map/store.js +206 -0
  51. package/dist/core/code-map/types.js +288 -0
  52. package/dist/core/code-map/vocabulary.js +57 -0
  53. package/dist/core/code-map/wasm-loader.js +294 -0
  54. package/dist/core/code-map/work-section.js +206 -0
  55. package/dist/core/codev-prompts.js +38 -38
  56. package/dist/core/codev-rounds.js +4 -0
  57. package/dist/core/default-profiles/doctor.yaml +11 -11
  58. package/dist/core/default-profiles/janitor.yaml +11 -11
  59. package/dist/core/default-profiles/onboarder.yaml +11 -11
  60. package/dist/core/default-profiles/reviewer.yaml +13 -13
  61. package/dist/core/dispatcher.js +1 -1
  62. package/dist/core/entity-operations.js +29 -3
  63. package/dist/core/execution-adapters.js +11 -10
  64. package/dist/core/execution-profile.js +58 -0
  65. package/dist/core/execution.js +1 -1
  66. package/dist/core/facade-schema.js +9 -0
  67. package/dist/core/instruction-templates.js +2 -0
  68. package/dist/core/loops/verbs.js +0 -1
  69. package/dist/core/mcp-command-resolution.js +3 -1
  70. package/dist/core/messaging.js +2 -2
  71. package/dist/core/protocol-skills.js +164 -164
  72. package/dist/core/runtime-signals.js +1 -1
  73. package/dist/core/search.js +19 -2
  74. package/dist/core/security-guard.js +207 -207
  75. package/dist/core/spawn-check.js +16 -2
  76. package/dist/core/staleness.js +1 -1
  77. package/dist/core/store-resolution.js +67 -11
  78. package/dist/core/worktree.js +18 -18
  79. package/dist/facts.js +9 -5
  80. package/dist/facts.json +8 -4
  81. package/dist/vendor/web-tree-sitter/tree-sitter.js +3980 -0
  82. package/dist/vendor/web-tree-sitter/tree-sitter.wasm +0 -0
  83. package/dist/wasm/tree-sitter-java.wasm +0 -0
  84. package/dist/wasm/tree-sitter-javascript.wasm +0 -0
  85. package/dist/wasm/tree-sitter-php.wasm +0 -0
  86. package/dist/wasm/tree-sitter-python.wasm +0 -0
  87. package/dist/wasm/tree-sitter-tsx.wasm +0 -0
  88. package/dist/wasm/tree-sitter-typescript.wasm +0 -0
  89. package/dist/wasm/tree-sitter.wasm +0 -0
  90. package/docs/PROTOCOL.md +1 -1
  91. package/docs/adapters/openclaw.md +43 -43
  92. package/docs/architecture/project-refs.md +328 -328
  93. package/docs/cli.md +2131 -2093
  94. package/docs/code-map.md +198 -0
  95. package/docs/concepts/coordination.md +52 -52
  96. package/docs/concepts/coordinator-runbook.md +129 -129
  97. package/docs/concepts/dispatch-lifecycle.md +245 -245
  98. package/docs/concepts/event-log-store.md +928 -928
  99. package/docs/concepts/ideation-loop.md +317 -317
  100. package/docs/concepts/loop-engine.md +520 -511
  101. package/docs/concepts/mcp-governance.md +268 -268
  102. package/docs/concepts/memory.md +84 -84
  103. package/docs/concepts/multi-agent-workflows.md +167 -167
  104. package/docs/concepts/observer-protocol.md +361 -361
  105. package/docs/concepts/plans-and-claims.md +217 -217
  106. package/docs/concepts/project-md-convention.md +35 -35
  107. package/docs/concepts/runtime-notes.md +38 -38
  108. package/docs/concepts/troubleshooting.md +254 -254
  109. package/docs/concepts/workspace-bootstrapping.md +142 -142
  110. package/docs/context-format-changelog.md +35 -35
  111. package/docs/context-format.md +48 -48
  112. package/docs/index.md +65 -65
  113. package/docs/integrations/agents.md +158 -158
  114. package/docs/integrations/claude-code.md +23 -23
  115. package/docs/integrations/cline.md +77 -77
  116. package/docs/integrations/continue.md +55 -55
  117. package/docs/integrations/copilot.md +68 -68
  118. package/docs/integrations/cursor.md +23 -23
  119. package/docs/integrations/kilocode.md +72 -72
  120. package/docs/integrations/mcp.md +385 -378
  121. package/docs/integrations/mistral-vibe.md +122 -122
  122. package/docs/integrations/openclaw.md +92 -92
  123. package/docs/integrations/opencode.md +84 -84
  124. package/docs/integrations/overview.md +115 -115
  125. package/docs/integrations/roo.md +71 -71
  126. package/docs/integrations/windsurf.md +77 -77
  127. package/docs/mcp-schema-changelog.md +364 -356
  128. package/docs/playbooks/integration/index.md +121 -121
  129. package/docs/playbooks/orchestration.md +37 -0
  130. package/docs/playbooks/productivity/index.md +99 -99
  131. package/docs/playbooks/team/index.md +117 -117
  132. package/docs/product/agent-first-model.md +184 -184
  133. package/docs/product/entity-model-audit.md +462 -462
  134. package/docs/product/positioning.md +86 -86
  135. package/docs/quickstart-existing-project.md +107 -107
  136. package/docs/quickstart.md +183 -183
  137. package/docs/release-maintenance.md +79 -79
  138. package/docs/reputation.md +52 -52
  139. package/docs/review.md +45 -45
  140. package/docs/security.md +212 -212
  141. package/docs/server-operations.md +118 -118
  142. package/docs/storage.md +106 -106
  143. package/package.json +86 -66
  144. package/docs/concepts/event-log-store-critique-A.md +0 -333
  145. package/docs/concepts/event-log-store-critique-B.md +0 -353
  146. package/docs/concepts/event-log-store-phase0-measurements.md +0 -58
  147. package/docs/concepts/event-log-store-proposal-A.md +0 -365
  148. package/docs/concepts/event-log-store-proposal-B.md +0 -404
  149. package/docs/concepts/identity-model-proposal.md +0 -371
@@ -1,118 +1,118 @@
1
- # Server And Remote Operations
2
-
3
- This guide is for complex operator environments such as DGX hosts, remote Linux servers, SSH-driven workflows, and multi-project workspaces where Brainclaw is not being used from a single local IDE.
4
-
5
- ## When this guide matters
6
-
7
- Use this path when one or more of these are true:
8
-
9
- - Brainclaw runs on a remote machine over SSH
10
- - multiple repos or child projects live under one server workspace
11
- - different agents resume each other over time on the same host
12
- - the operator sometimes uses CLI directly instead of MCP
13
-
14
- ## Recommended baseline
15
-
16
- Prefer a disciplined single-environment workflow on the server:
17
-
18
- 1. choose one canonical checkout per active task
19
- 2. initialize Brainclaw in the target project before starting coordination work
20
- 3. avoid mixing multiple shells, PATH setups, or Node installations during the same session
21
- 4. treat shared-checkout parallel editing as risky unless each session gets a dedicated worktree
22
-
23
- ## Multi-project targeting
24
-
25
- If the server workspace contains several Brainclaw projects, resolve the target project first.
26
-
27
- ```bash
28
- brainclaw switch --list
29
- brainclaw switch apps/trainer
30
- brainclaw status
31
- ```
32
-
33
- You can also use:
34
-
35
- - `BRAINCLAW_PROJECT` for a shell-scoped default
36
- - `brainclaw --cwd <path> ...` for a one-off override
37
-
38
- The goal is to avoid writing memory into the wrong store when the operator is launched from a workspace root.
39
-
40
- ## Recommended session flow
41
-
42
- For MCP-capable agents:
43
-
44
- 1. `bclaw_work(intent="execute", scope=...)` — opens a session, loads context, and claims the scope (with a per-claim git worktree) in a single call. Returns a compact payload by default; pass `compact: false` for the full memory dump or call `bclaw_context(kind="memory")` after.
45
- 2. `bclaw_context(kind="execution")` — when local tooling / brainclaw version visibility is needed (already loaded implicitly by `bclaw_work`).
46
- 3. `bclaw_write_note` / `bclaw_create(entity=...)` / `bclaw_update(entity=...)` — record observations, plans, decisions, or traps via the canonical grammar.
47
- 4. `bclaw_session_end(narrative=..., auto_release: true)` — close cleanly; releases active claims and hands off the session record.
48
-
49
- For direct CLI operation:
50
-
51
- ```bash
52
- brainclaw session-start --agent codex
53
- brainclaw plan list --all
54
- brainclaw claim create "Investigate training config drift" --scope configs/training/
55
- brainclaw runtime-note "Observed host-specific CUDA mismatch on dgx-a"
56
- brainclaw session-end --auto-release
57
- ```
58
-
59
- `brainclaw runtime-note` is the CLI equivalent of `bclaw_write_note`.
60
- `brainclaw note create "..."` is accepted as a resource-style alias if that fits the operator workflow better.
61
-
62
- ## Isolation and worktrees
63
-
64
- The safest default remains sequential collaboration: one active agent per checkout, then handoff.
65
-
66
- If you need stronger isolation:
67
-
68
- ```bash
69
- brainclaw worktree create feat/dgx-audit
70
- brainclaw worktree list
71
- ```
72
-
73
- In MCP flows, `bclaw_claim` can also create a dedicated worktree automatically when supported by the current Brainclaw version and configuration.
74
-
75
- Use dedicated worktrees when:
76
-
77
- - two sessions need to touch the same repo without sharing a checkout
78
- - an operator wants to preserve a clean main checkout while an agent runs elsewhere
79
- - a remote machine hosts long-lived or resumable agent sessions
80
-
81
- ## Plan and step semantics
82
-
83
- Be explicit about the difference between plan items and plan steps:
84
-
85
- - `brainclaw plan show <id>` reads a single plan item
86
- - `brainclaw plan get <id>` is accepted as a read alias, but `brainclaw plan show <id>` remains the canonical form
87
- - `brainclaw plan update <id>` expects a `pln_*` plan ID
88
- - `brainclaw complete-step <planId> <stepId>` is the canonical way to complete a step
89
-
90
- If you only have a step ID, inspect the parent plan first with `plan show` or `plan list --json`.
91
-
92
- ## Notes, decisions, and traps
93
-
94
- Do not use `decision` as a workaround for a session observation.
95
-
96
- Use:
97
-
98
- - `brainclaw runtime-note` for in-session observations
99
- - `brainclaw reflect-runtime-note` when the note may deserve promotion
100
- - `brainclaw decision` only for a durable decision
101
- - `brainclaw trap` only for a reusable pitfall
102
-
103
- This keeps canonical memory cleaner on long-lived server projects.
104
-
105
- ## Common failure modes
106
-
107
- - Wrong project selected: use `brainclaw switch --list` and verify `brainclaw status`
108
- - Shared-checkout collisions: prefer a worktree per session when parallel activity is unavoidable
109
- - Confusion between plan IDs and step IDs: use `plan show` before `plan update`
110
- - Lost operator observations: record them with `runtime-note` instead of temporary shell notes
111
-
112
- ## Recommended reading
113
-
114
- - [quickstart.md](quickstart.md)
115
- - [cli.md](cli.md)
116
- - [integrations/mcp.md](integrations/mcp.md)
117
- - [concepts/plans-and-claims.md](concepts/plans-and-claims.md)
118
- - [concepts/runtime-notes.md](concepts/runtime-notes.md)
1
+ # Server And Remote Operations
2
+
3
+ This guide is for complex operator environments such as DGX hosts, remote Linux servers, SSH-driven workflows, and multi-project workspaces where Brainclaw is not being used from a single local IDE.
4
+
5
+ ## When this guide matters
6
+
7
+ Use this path when one or more of these are true:
8
+
9
+ - Brainclaw runs on a remote machine over SSH
10
+ - multiple repos or child projects live under one server workspace
11
+ - different agents resume each other over time on the same host
12
+ - the operator sometimes uses CLI directly instead of MCP
13
+
14
+ ## Recommended baseline
15
+
16
+ Prefer a disciplined single-environment workflow on the server:
17
+
18
+ 1. choose one canonical checkout per active task
19
+ 2. initialize Brainclaw in the target project before starting coordination work
20
+ 3. avoid mixing multiple shells, PATH setups, or Node installations during the same session
21
+ 4. treat shared-checkout parallel editing as risky unless each session gets a dedicated worktree
22
+
23
+ ## Multi-project targeting
24
+
25
+ If the server workspace contains several Brainclaw projects, resolve the target project first.
26
+
27
+ ```bash
28
+ brainclaw switch --list
29
+ brainclaw switch apps/trainer
30
+ brainclaw status
31
+ ```
32
+
33
+ You can also use:
34
+
35
+ - `BRAINCLAW_PROJECT` for a shell-scoped default
36
+ - `brainclaw --cwd <path> ...` for a one-off override
37
+
38
+ The goal is to avoid writing memory into the wrong store when the operator is launched from a workspace root.
39
+
40
+ ## Recommended session flow
41
+
42
+ For MCP-capable agents:
43
+
44
+ 1. `bclaw_work(intent="execute", scope=...)` — opens a session, loads context, and claims the scope (with a per-claim git worktree) in a single call. Returns a compact payload by default; pass `compact: false` for the full memory dump or call `bclaw_context(kind="memory")` after.
45
+ 2. `bclaw_context(kind="execution")` — when local tooling / brainclaw version visibility is needed (already loaded implicitly by `bclaw_work`).
46
+ 3. `bclaw_write_note` / `bclaw_create(entity=...)` / `bclaw_update(entity=...)` — record observations, plans, decisions, or traps via the canonical grammar.
47
+ 4. `bclaw_session_end(narrative=..., auto_release: true)` — close cleanly; releases active claims and hands off the session record.
48
+
49
+ For direct CLI operation:
50
+
51
+ ```bash
52
+ brainclaw session-start --agent codex
53
+ brainclaw plan list --all
54
+ brainclaw claim create "Investigate training config drift" --scope configs/training/
55
+ brainclaw runtime-note "Observed host-specific CUDA mismatch on dgx-a"
56
+ brainclaw session-end --auto-release
57
+ ```
58
+
59
+ `brainclaw runtime-note` is the CLI equivalent of `bclaw_write_note`.
60
+ `brainclaw note create "..."` is accepted as a resource-style alias if that fits the operator workflow better.
61
+
62
+ ## Isolation and worktrees
63
+
64
+ The safest default remains sequential collaboration: one active agent per checkout, then handoff.
65
+
66
+ If you need stronger isolation:
67
+
68
+ ```bash
69
+ brainclaw worktree create feat/dgx-audit
70
+ brainclaw worktree list
71
+ ```
72
+
73
+ In MCP flows, `bclaw_claim` can also create a dedicated worktree automatically when supported by the current Brainclaw version and configuration.
74
+
75
+ Use dedicated worktrees when:
76
+
77
+ - two sessions need to touch the same repo without sharing a checkout
78
+ - an operator wants to preserve a clean main checkout while an agent runs elsewhere
79
+ - a remote machine hosts long-lived or resumable agent sessions
80
+
81
+ ## Plan and step semantics
82
+
83
+ Be explicit about the difference between plan items and plan steps:
84
+
85
+ - `brainclaw plan show <id>` reads a single plan item
86
+ - `brainclaw plan get <id>` is accepted as a read alias, but `brainclaw plan show <id>` remains the canonical form
87
+ - `brainclaw plan update <id>` expects a `pln_*` plan ID
88
+ - `brainclaw complete-step <planId> <stepId>` is the canonical way to complete a step
89
+
90
+ If you only have a step ID, inspect the parent plan first with `plan show` or `plan list --json`.
91
+
92
+ ## Notes, decisions, and traps
93
+
94
+ Do not use `decision` as a workaround for a session observation.
95
+
96
+ Use:
97
+
98
+ - `brainclaw runtime-note` for in-session observations
99
+ - `brainclaw reflect-runtime-note` when the note may deserve promotion
100
+ - `brainclaw decision` only for a durable decision
101
+ - `brainclaw trap` only for a reusable pitfall
102
+
103
+ This keeps canonical memory cleaner on long-lived server projects.
104
+
105
+ ## Common failure modes
106
+
107
+ - Wrong project selected: use `brainclaw switch --list` and verify `brainclaw status`
108
+ - Shared-checkout collisions: prefer a worktree per session when parallel activity is unavoidable
109
+ - Confusion between plan IDs and step IDs: use `plan show` before `plan update`
110
+ - Lost operator observations: record them with `runtime-note` instead of temporary shell notes
111
+
112
+ ## Recommended reading
113
+
114
+ - [quickstart.md](quickstart.md)
115
+ - [cli.md](cli.md)
116
+ - [integrations/mcp.md](integrations/mcp.md)
117
+ - [concepts/plans-and-claims.md](concepts/plans-and-claims.md)
118
+ - [concepts/runtime-notes.md](concepts/runtime-notes.md)
package/docs/storage.md CHANGED
@@ -1,110 +1,110 @@
1
- # Storage Model
2
-
3
- brainclaw is local-first and workspace-centric.
4
-
5
- ## Default structure
6
-
7
- ```text
8
- .brainclaw/
9
- config.yaml ← Project configuration
1
+ # Storage Model
2
+
3
+ brainclaw is local-first and workspace-centric.
4
+
5
+ ## Default structure
6
+
7
+ ```text
8
+ .brainclaw/
9
+ config.yaml ← Project configuration
10
10
  project.md ← Legacy derived readable view (best-effort, regenerable)
11
- events.jsonl ← Append-only event log (agent notifications)
12
- audit.log ← Append-only audit trail (before/after snapshots)
13
- memory/
14
- constraints/ ← Canonical constraint entries (one JSON per entity)
15
- decisions/ ← Canonical decision entries
16
- traps/ ← Canonical trap entries
17
- instructions/ ← Layered shared instructions
18
- coordination/
19
- plans/ ← Shared plan items
20
- claims/ ← Active scope claims
21
- handoffs/ ← Handoff records
22
- sessions/ ← Session state
23
- runtime/ ← Runtime notes (shared, machine, private)
24
- inbox/ ← Candidate review queue
25
- discovery/
26
- bootstrap/ ← Bootstrap profiles and seeds
27
- agents/ ← Agent registration and identity
28
- ```
29
-
30
- ## Design principles
31
-
32
- ### Canonical state is split
33
- Each entity is stored as its own JSON file (e.g. `memory/decisions/dec_abc123.json`).
34
-
35
- Benefits:
36
-
37
- - readable diffs in `.brainclaw/.git`
38
- - easier merges
39
- - clear provenance per entity
40
- - O(1) lookup by ID (direct file access)
41
- - no giant monolithic memory blob
42
- - isolated corruption (one bad file does not affect others)
43
-
44
- ### Derived views are best-effort
11
+ events.jsonl ← Append-only event log (agent notifications)
12
+ audit.log ← Append-only audit trail (before/after snapshots)
13
+ memory/
14
+ constraints/ ← Canonical constraint entries (one JSON per entity)
15
+ decisions/ ← Canonical decision entries
16
+ traps/ ← Canonical trap entries
17
+ instructions/ ← Layered shared instructions
18
+ coordination/
19
+ plans/ ← Shared plan items
20
+ claims/ ← Active scope claims
21
+ handoffs/ ← Handoff records
22
+ sessions/ ← Session state
23
+ runtime/ ← Runtime notes (shared, machine, private)
24
+ inbox/ ← Candidate review queue
25
+ discovery/
26
+ bootstrap/ ← Bootstrap profiles and seeds
27
+ agents/ ← Agent registration and identity
28
+ ```
29
+
30
+ ## Design principles
31
+
32
+ ### Canonical state is split
33
+ Each entity is stored as its own JSON file (e.g. `memory/decisions/dec_abc123.json`).
34
+
35
+ Benefits:
36
+
37
+ - readable diffs in `.brainclaw/.git`
38
+ - easier merges
39
+ - clear provenance per entity
40
+ - O(1) lookup by ID (direct file access)
41
+ - no giant monolithic memory blob
42
+ - isolated corruption (one bad file does not affect others)
43
+
44
+ ### Derived views are best-effort
45
45
  `.brainclaw/project.md` is a **legacy derived view** regenerated from canonical state via `rebuildProjectMd()`. It is not a write target and no longer carries live claims, plans, handoffs, or runtime state — use `brainclaw agent-board`, `brainclaw context`, or MCP board/context tools for that operational data.
46
46
 
47
47
  Root `PROJECT.md` is different: it is the durable project vision and should contain stable product, architecture, and contribution guidance that does not expire every session.
48
-
49
- Failures to regenerate `project.md` are logged but never block mutations. If it gets stale, `brainclaw doctor` detects the drift.
50
-
51
- ### All mutations go through a single pipeline
52
- Every write to `.brainclaw/` is serialized through `mutate()` (`src/core/mutation-pipeline.ts`):
53
-
54
- 1. **Store-wide lock** — advisory file lock at `.brainclaw/.store-mutation` (5s timeout, 10s expiry)
55
- 2. **Reentrant** — nested mutations within the same process are safe
56
- 3. **Atomic writes** — individual files use temp-file + rename pattern
57
- 4. **Git versioned** — `.brainclaw/.git` tracks all changes for rollback
58
-
59
- For agents using MCP (the recommended path), mutations are additionally serialized by the MCP server's `McpTaskRunner` — a FIFO queue that runs one task at a time. This provides two layers of write safety:
60
-
61
- | Layer | Scope | Mechanism |
62
- |---|---|---|
63
- | **McpTaskRunner** | Single MCP server process | FIFO queue, one active Worker thread |
64
- | **mutate() file lock** | Cross-process (CLI + MCP) | Advisory `.store-mutation` lock file |
65
-
66
- Agents should always use MCP tools for mutations. The CLI is for human operators, scripting, and fallback workflows.
67
-
68
- ### Topology can vary
69
-
70
- Depending on configuration, storage may be:
71
-
72
- | Topology | Behavior |
73
- |---|---|
74
- | `embedded` (default) | `.brainclaw/` inside the repo, tracked by Git |
75
- | `sidecar` | `.brainclaw/` inside the repo but gitignored |
76
- | `local-only` | Outside the repo, never tracked |
77
-
78
- ## What belongs in canonical memory
79
-
80
- - decisions
81
- - constraints
82
- - traps
83
- - layered instructions
84
- - handoffs
85
- - plans
86
-
87
- ## What stays operational
88
-
89
- - machine-local runtime notes
90
- - private notes
91
- - short-lived observations (with optional TTL)
92
- - reflective candidates awaiting review
93
- - event log and audit trail
94
-
95
- ## Why this model matters
96
-
97
- The storage model is part of the product value:
98
-
99
- - local-first — no cloud dependency
100
- - inspectable — plain text + JSON
101
- - Git-friendly — entity-per-file, readable diffs
102
- - reversible — `.brainclaw/.git` history + rollback
103
- - mutation-safe — serialized writes, atomic file operations
104
- - suitable for both humans and agents
105
-
106
- ## Related pages
107
-
108
- - [concepts/memory.md](concepts/memory.md)
109
- - [concepts/runtime-notes.md](concepts/runtime-notes.md)
110
- - [security.md](security.md)
48
+
49
+ Failures to regenerate `project.md` are logged but never block mutations. If it gets stale, `brainclaw doctor` detects the drift.
50
+
51
+ ### All mutations go through a single pipeline
52
+ Every write to `.brainclaw/` is serialized through `mutate()` (`src/core/mutation-pipeline.ts`):
53
+
54
+ 1. **Store-wide lock** — advisory file lock at `.brainclaw/.store-mutation` (5s timeout, 10s expiry)
55
+ 2. **Reentrant** — nested mutations within the same process are safe
56
+ 3. **Atomic writes** — individual files use temp-file + rename pattern
57
+ 4. **Git versioned** — `.brainclaw/.git` tracks all changes for rollback
58
+
59
+ For agents using MCP (the recommended path), mutations are additionally serialized by the MCP server's `McpTaskRunner` — a FIFO queue that runs one task at a time. This provides two layers of write safety:
60
+
61
+ | Layer | Scope | Mechanism |
62
+ |---|---|---|
63
+ | **McpTaskRunner** | Single MCP server process | FIFO queue, one active Worker thread |
64
+ | **mutate() file lock** | Cross-process (CLI + MCP) | Advisory `.store-mutation` lock file |
65
+
66
+ Agents should always use MCP tools for mutations. The CLI is for human operators, scripting, and fallback workflows.
67
+
68
+ ### Topology can vary
69
+
70
+ Depending on configuration, storage may be:
71
+
72
+ | Topology | Behavior |
73
+ |---|---|
74
+ | `embedded` (default) | `.brainclaw/` inside the repo, tracked by Git |
75
+ | `sidecar` | `.brainclaw/` inside the repo but gitignored |
76
+ | `local-only` | Outside the repo, never tracked |
77
+
78
+ ## What belongs in canonical memory
79
+
80
+ - decisions
81
+ - constraints
82
+ - traps
83
+ - layered instructions
84
+ - handoffs
85
+ - plans
86
+
87
+ ## What stays operational
88
+
89
+ - machine-local runtime notes
90
+ - private notes
91
+ - short-lived observations (with optional TTL)
92
+ - reflective candidates awaiting review
93
+ - event log and audit trail
94
+
95
+ ## Why this model matters
96
+
97
+ The storage model is part of the product value:
98
+
99
+ - local-first — no cloud dependency
100
+ - inspectable — plain text + JSON
101
+ - Git-friendly — entity-per-file, readable diffs
102
+ - reversible — `.brainclaw/.git` history + rollback
103
+ - mutation-safe — serialized writes, atomic file operations
104
+ - suitable for both humans and agents
105
+
106
+ ## Related pages
107
+
108
+ - [concepts/memory.md](concepts/memory.md)
109
+ - [concepts/runtime-notes.md](concepts/runtime-notes.md)
110
+ - [security.md](security.md)
package/package.json CHANGED
@@ -1,71 +1,91 @@
1
- {
2
- "name": "brainclaw",
3
- "version": "1.9.0",
4
- "description": "Shared project memory for humans and coding agents.",
5
- "type": "module",
6
- "bin": {
7
- "brainclaw": "dist/cli.js",
8
- "bclaw": "dist/cli.js"
9
- },
10
- "files": [
11
- "dist/**/*.js",
12
- "dist/core/default-profiles/*.yaml",
13
- "dist/brainclaw-vscode.vsix",
14
- "dist/facts.json",
15
- "docs/**/*.md",
16
- "README.md",
17
- "LICENSE"
18
- ],
19
- "publishConfig": {
20
- "access": "public"
21
- },
22
- "engines": {
23
- "node": ">=20.0.0"
24
- },
25
- "scripts": {
26
- "clean:build": "node scripts/clean-build.mjs dist dist-test",
27
- "clean:dist": "node scripts/clean-build.mjs dist",
28
- "clean:dist-test": "node scripts/clean-build.mjs dist-test",
1
+ {
2
+ "name": "brainclaw",
3
+ "version": "1.10.0",
4
+ "description": "Shared project memory for humans and coding agents.",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/jberdah/brainclaw.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/jberdah/brainclaw/issues"
12
+ },
13
+ "homepage": "https://brainclaw.dev",
14
+ "bin": {
15
+ "brainclaw": "dist/cli.js",
16
+ "bclaw": "dist/cli.js"
17
+ },
18
+ "files": [
19
+ "dist/**/*.js",
20
+ "dist/core/default-profiles/*.yaml",
21
+ "dist/core/code-map/lang/**/*.scm",
22
+ "dist/wasm/*.wasm",
23
+ "dist/vendor/web-tree-sitter/*.wasm",
24
+ "dist/brainclaw-vscode.vsix",
25
+ "dist/facts.json",
26
+ "docs/**/*.md",
27
+ "!docs/concepts/*proposal*.md",
28
+ "!docs/concepts/*critique*.md",
29
+ "!docs/concepts/*phase0-measurements*.md",
30
+ "README.md",
31
+ "LICENSE"
32
+ ],
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "engines": {
37
+ "node": ">=22.12.0"
38
+ },
39
+ "scripts": {
40
+ "clean:build": "node scripts/clean-build.mjs dist dist-test",
41
+ "clean:dist": "node scripts/clean-build.mjs dist",
42
+ "clean:dist-test": "node scripts/clean-build.mjs dist-test",
29
43
  "build": "npm run build:cli && node scripts/build-vsix.mjs --optional",
30
- "build:cli": "npm run clean:dist && tsc && node scripts/copy-default-profiles.mjs",
44
+ "build:cli": "npm run clean:dist && tsc && node scripts/copy-default-profiles.mjs && node scripts/copy-code-map-wasm.mjs",
31
45
  "build:release": "npm run build:cli && node scripts/emit-site-facts.mjs && node scripts/build-vsix.mjs",
32
46
  "emit:facts": "npm run build:cli && node scripts/emit-site-facts.mjs",
33
- "dev": "npm run clean:dist && tsc && node scripts/copy-default-profiles.mjs && node dist/cli.js",
34
- "dev:mcp": "tsc && node scripts/copy-default-profiles.mjs",
35
- "build:mcp-schemas": "npm run clean:dist && tsc && node scripts/build-mcp-schemas.mjs",
36
- "dev:link": "npm link && echo 'Symlink created: global brainclaw → local repo. MCP agents now use dist/ directly.'",
47
+ "dev": "npm run clean:dist && tsc && node scripts/copy-default-profiles.mjs && node dist/cli.js",
48
+ "dev:mcp": "tsc && node scripts/copy-default-profiles.mjs",
49
+ "build:mcp-schemas": "npm run clean:dist && tsc && node scripts/build-mcp-schemas.mjs",
50
+ "dev:link": "npm link && echo 'Symlink created: global brainclaw → local repo. MCP agents now use dist/ directly.'",
37
51
  "build:test": "npm run build:cli && npm run clean:dist-test && tsc -p tsconfig.test.json",
38
- "pack:check": "node scripts/check-pack.mjs",
39
- "test": "npm run build:test && node scripts/run-tests.mjs default",
40
- "test:unit": "npm run build:test && node scripts/run-tests.mjs unit",
41
- "test:smoke": "npm run build:test && node scripts/run-tests.mjs smoke",
42
- "test:e2e": "npm run build:test && node scripts/run-tests.mjs e2e",
43
- "test:all": "npm run build:test && node scripts/run-tests.mjs all",
44
- "test:cross": "npm run build:test && node scripts/test-cross.mjs default",
45
- "test:coverage": "npm run build:test && c8 --all --src dist-test/src --reporter=text-summary --reporter=lcov --exclude=dist-test/tests/** --exclude=dist-test/scripts/** node scripts/run-tests.mjs default",
46
- "test:coverage:check": "npm run build:test && c8 --all --check-coverage --lines 55 --functions 60 --branches 65 --statements 55 --src dist-test/src --reporter=text-summary --exclude=dist-test/tests/** --exclude=dist-test/scripts/** node scripts/run-tests.mjs default",
52
+ "pack:check": "node scripts/check-pack.mjs",
53
+ "lint": "eslint .",
54
+ "lint:fix": "eslint . --fix",
55
+ "test": "npm run build:test && node scripts/run-tests.mjs default",
56
+ "test:unit": "npm run build:test && node scripts/run-tests.mjs unit",
57
+ "test:smoke": "npm run build:test && node scripts/run-tests.mjs smoke",
58
+ "test:e2e": "npm run build:test && node scripts/run-tests.mjs e2e",
59
+ "test:all": "npm run build:test && node scripts/run-tests.mjs all",
60
+ "test:cross": "npm run build:test && node scripts/test-cross.mjs default",
61
+ "test:coverage": "npm run build:test && c8 --all --src dist-test/src --reporter=text-summary --reporter=lcov --exclude=dist-test/tests/** --exclude=dist-test/scripts/** node scripts/run-tests.mjs default",
62
+ "test:coverage:check": "npm run build:test && c8 --all --check-coverage --lines 55 --functions 60 --branches 65 --statements 55 --src dist-test/src --reporter=text-summary --exclude=dist-test/tests/** --exclude=dist-test/scripts/** node scripts/run-tests.mjs default",
47
63
  "prepublishOnly": "npm run build:release && npm run pack:check"
48
- },
49
- "keywords": [
50
- "cli",
51
- "memory",
52
- "agents",
53
- "coding-agents",
54
- "project-context",
55
- "handoff",
56
- "local-first"
57
- ],
58
- "license": "MIT",
59
- "homepage": "https://brainclaw.dev",
60
- "dependencies": {
61
- "commander": "^14.0.3",
62
- "yaml": "^2.7.1",
63
- "zod": "^4.4.3"
64
- },
65
- "devDependencies": {
66
- "@types/node": "^24.12.2",
67
- "ajv": "^8.20.0",
68
- "c8": "^11.0.0",
69
- "typescript": "^6.0.3"
70
- }
71
- }
64
+ },
65
+ "keywords": [
66
+ "cli",
67
+ "memory",
68
+ "agents",
69
+ "coding-agents",
70
+ "project-context",
71
+ "handoff",
72
+ "local-first"
73
+ ],
74
+ "license": "MIT",
75
+ "dependencies": {
76
+ "commander": "^15.0.0",
77
+ "yaml": "^2.7.1",
78
+ "zod": "^4.4.3"
79
+ },
80
+ "devDependencies": {
81
+ "@eslint/js": "^10.0.1",
82
+ "@types/node": "^25.9.3",
83
+ "ajv": "^8.20.0",
84
+ "c8": "^11.0.0",
85
+ "eslint": "^10.5.0",
86
+ "tree-sitter-wasms": "^0.1.13",
87
+ "typescript": "^6.0.3",
88
+ "typescript-eslint": "^8.61.1",
89
+ "web-tree-sitter": "^0.25.10"
90
+ }
91
+ }