brainclaw 1.24.0 → 1.26.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 (46) hide show
  1. package/dist/brainclaw-vscode.vsix +0 -0
  2. package/dist/cli/register-code-map.js +9 -2
  3. package/dist/commands/code-map.js +120 -6
  4. package/dist/commands/mcp-catalog.js +46 -0
  5. package/dist/commands/mcp.js +58 -6
  6. package/dist/commands/session-start.js +84 -13
  7. package/dist/core/bootstrap.js +28 -4
  8. package/dist/core/code-map/aggregate.js +36 -31
  9. package/dist/core/code-map/backend.js +162 -5
  10. package/dist/core/code-map/core.js +1 -0
  11. package/dist/core/code-map/export.js +212 -0
  12. package/dist/core/code-map/finalizer.js +57 -2
  13. package/dist/core/code-map/freshness.js +81 -15
  14. package/dist/core/code-map/impact.js +409 -0
  15. package/dist/core/code-map/indexes.js +64 -3
  16. package/dist/core/code-map/lang/python/index.js +4 -2
  17. package/dist/core/code-map/lang/query-runtime.js +2 -0
  18. package/dist/core/code-map/lang/typescript/config.js +271 -0
  19. package/dist/core/code-map/lang/typescript/index.js +24 -6
  20. package/dist/core/code-map/lang/usages.js +333 -0
  21. package/dist/core/code-map/memory-reader.js +15 -0
  22. package/dist/core/code-map/query.js +285 -71
  23. package/dist/core/code-map/refresh.js +0 -0
  24. package/dist/core/code-map/resolve.js +28 -2
  25. package/dist/core/code-map/store.js +1 -0
  26. package/dist/core/code-map/types.js +70 -9
  27. package/dist/core/code-map/vocabulary.js +6 -0
  28. package/dist/core/code-map/work-section.js +12 -14
  29. package/dist/core/context-diff.js +17 -3
  30. package/dist/core/entity-operations.js +14 -2
  31. package/dist/core/federation-pull.js +151 -3
  32. package/dist/core/federation-push.js +16 -3
  33. package/dist/core/hint-aging.js +4 -1
  34. package/dist/core/identity.js +69 -17
  35. package/dist/core/io.js +27 -0
  36. package/dist/core/project-discovery.js +7 -1
  37. package/dist/core/protocol-tool-policy.js +3 -0
  38. package/dist/core/runtime.js +23 -0
  39. package/dist/core/worktree.js +89 -2
  40. package/dist/facts.js +15 -12
  41. package/dist/facts.json +14 -11
  42. package/docs/cli.md +8 -0
  43. package/docs/code-map.md +60 -28
  44. package/docs/integrations/mcp.md +5 -2
  45. package/docs/mcp-schema-changelog.md +11 -1
  46. package/package.json +1 -1
package/docs/code-map.md CHANGED
@@ -24,6 +24,7 @@ rebuilds it.
24
24
  brainclaw memory.
25
25
  - **To locate** a function/class/component/hook by name without grepping:
26
26
  `code-map find <query>` (or `bclaw_code_find`).
27
+ - **To inspect a bounded local dependency neighborhood**: `code-map export <symbol-or-path>` (or `bclaw_code_export`) returns compact nodes and edges, not a repository graph dump.
27
28
  - **To check coverage / staleness**: `code-map status` (or `bclaw_code_status`).
28
29
  - **After pulling changes or doing work**: `code-map refresh` to bring the index
29
30
  back to `fresh`.
@@ -95,9 +96,30 @@ Read-only. Builds a reading brief for a symbol or file: a ranked
95
96
  brainclaw code-map brief App
96
97
  ```
97
98
 
99
+ ### `brainclaw code-map export <symbol-or-path>`
100
+
101
+ Read-only export of a **local** persisted subgraph around one symbol or file. It
102
+ never refreshes, reparses, calls a service, or silently turns into a whole-project
103
+ graph export. The default is one hop in both directions; limits are always
104
+ reported and hard-capped at depth 4, 100 nodes, and 200 edges.
105
+
106
+ ```bash
107
+ brainclaw code-map export useAuth --direction incoming --depth 2 --json
108
+ brainclaw code-map export src/hooks/useAuth.ts --format mermaid
109
+ ```
110
+
111
+ `--direction` is `outgoing`, `incoming`, or `both` (default). `--max-nodes` and
112
+ `--max-edges` can tighten the response only; `--min-confidence` cannot be set
113
+ below 0.5. JSON is canonical and includes compact `nodes`, `edges`, root IDs,
114
+ limits, truncation flags, and a freshness badge. Every edge retains `kind`,
115
+ `source`, and `confidence`; low-confidence nodes/relations are excluded so an
116
+ extraction heuristic cannot appear indistinguishable from a high-confidence
117
+ relation. `--format mermaid` adds a Mermaid rendering projected from those exact
118
+ JSON nodes and edges—never from a second traversal.
119
+
98
120
  ## MCP tools
99
121
 
100
- Capable agents should prefer the MCP surface. The four tools mirror the CLI and
122
+ Capable agents should prefer the MCP surface. The read tools mirror the CLI and
101
123
  all return a `freshness_badge`:
102
124
 
103
125
  | Tool | Kind | Purpose |
@@ -105,6 +127,7 @@ all return a `freshness_badge`:
105
127
  | `bclaw_code_status` | read | Store presence, freshness badge, index stats. Never refreshes. |
106
128
  | `bclaw_code_find` | read | Ranked symbol-index search (`query`, optional `limit`). Never refreshes. |
107
129
  | `bclaw_code_brief` | read | Reading brief for a symbol/path (`target`, optional `limit`, files capped at 12). Never refreshes. |
130
+ | `bclaw_code_export` | read | Bounded local subgraph around required `target`; direction/depth/node/edge caps, confidence filtering, and optional Mermaid projection. Never refreshes. |
108
131
  | `bclaw_code_refresh` | write | Rebuild the index. `scope` = `"changed"` (default) or `"all"`. Fails fast on a live lock. |
109
132
 
110
133
  The read tools never trigger a parse — if `bclaw_code_status` /
@@ -113,35 +136,44 @@ call `bclaw_code_refresh` and retry.
113
136
 
114
137
  ## Freshness badge model
115
138
 
116
- Every Code Map response carries a freshness badge so a stale index is always
117
- visible rather than silently misleading. The status is one of:
139
+ Every Code Map response has one top-level `freshness` field:
140
+ `fresh`, `stale`, `partial`, or `missing`. It is the synthetic index signal that
141
+ an agent uses to decide whether to refresh, and it has the same meaning on
142
+ `bclaw_work`, `bclaw_code_status`, `bclaw_code_find`, and `bclaw_code_brief`.
143
+
144
+ ```json
145
+ {
146
+ "freshness": "fresh",
147
+ "details": {
148
+ "index": {
149
+ "status": "fresh",
150
+ "stale_file_count": 0,
151
+ "partial_reason": null,
152
+ "git_head_changed": null
153
+ },
154
+ "spot_check": {
155
+ "status": "stale",
156
+ "checked_files": 1,
157
+ "stale_changed_files": ["src/example.ts"],
158
+ "deleted_files": [],
159
+ "unchecked_files": [],
160
+ "budget_exhausted": false,
161
+ "partial_reason": null
162
+ }
163
+ }
164
+ }
165
+ ```
118
166
 
119
- | Status | Meaning | Fix |
120
- |---|---|---|
121
- | `fresh` | Index matches the working tree, the extractor config, and the parser binaries. | — |
122
- | `stale_changed_files` | One or more indexed files have changed on disk since they were parsed. | `refresh --changed` |
123
- | `stale_extractor` | The extractor configuration (ignore rules, size caps, supported extensions, query budget, or active language set) changed since these shards were produced. | `refresh --changed` (heals on the cheap path) |
124
- | `stale_grammar` | A Tree-sitter grammar (or the engine glue) binary changed since these shards were produced. | `refresh --changed` (heals on the cheap path) |
125
- | `partial` | The index could not be fully read/built this pass (e.g. the project lock was held by a live writer). | retry |
126
- | `missing_index` | No index exists yet for this project. | `refresh --all` |
127
-
128
- Staleness reasons are kept separate on purpose: a content change
129
- (`stale_changed_files`) is independent from a config change (`stale_extractor`)
130
- which is independent from a parser-binary change (`stale_grammar`). The badge
131
- surfaces the dominant reason; `--json` output and the manifest carry the per-file
132
- counts.
133
-
134
- **Index freshness vs this call's spot-check.** `bclaw_code_status` reports the
135
- *index* freshness (the manifest state). `bclaw_code_find` / `bclaw_code_brief`
136
- additionally run a bounded, per-query *spot-check* of the files they actually
137
- touch — so a single call can read `stale_changed_files` (a file it looked at
138
- changed on disk) or `partial` (the spot-check hit its budget) even while the index
139
- itself is `fresh`. When the call-level status diverges from the index, the badge
140
- carries an `index_status` detail so the two are not confused, e.g.
141
- `{ status: "partial", details: { index_status: "fresh", partial_reason:
142
- "lazy_check_budget_exhausted" } }` reads as *"index fresh, this call's spot-check
143
- incomplete (budget)"* — not a contradiction with a `fresh` `status()`.
167
+ `details.index` is the index diagnosis: its detailed `status` may be
168
+ `stale_changed_files`, `stale_extractor`, `stale_grammar`, or
169
+ `stale_git_head`. `details.spot_check` is a bounded, read-only observation of
170
+ the candidates touched by `find` or `brief`; it is `not_run` on `status` and on
171
+ a work section with no query. A stale or partial spot-check never silently
172
+ changes the shared top-level signal. It gives the agent precise evidence for an
173
+ explicit `bclaw_code_refresh(scope="changed")`, then a retry.
144
174
 
175
+ No read command parses files or refreshes the index. `bclaw_work` can suggest
176
+ that explicit refresh, but never performs it lazily.
145
177
  ## Lifecycle — pull-based, no daemon
146
178
 
147
179
  Code Map never runs in the background and never auto-reindexes. The model is lazy
@@ -25,7 +25,7 @@ The default dynamic workflow is:
25
25
  1. `bclaw_work` to start the session and load the relevant context in one call (returns compact payload by default — pass `compact: false` for the full context result)
26
26
  2. `bclaw_context({ kind: "execution" })` early when the agent needs local tooling signals or package update visibility
27
27
  3. `bclaw_context({ kind: "memory" })`, `bclaw_context({ kind: "board" })`, or `bclaw_context({ kind: "delta" })` when the target path changes or full memory is needed beyond the compact summary
28
- 4. `bclaw_code_brief({ target })` / `bclaw_code_find({ query })` before editing unfamiliar code — get a ranked reading list (with related decisions/traps) and locate symbols from the Code Map instead of grepping blind. A `missing_index` badge means run `bclaw_code_refresh` first. See [code map](../code-map.md)
28
+ 4. `bclaw_code_brief({ target })` / `bclaw_code_find({ query })` before editing unfamiliar code — get a ranked reading list (with related decisions/traps) and locate symbols from the Code Map instead of grepping blind. Use `bclaw_code_impact({ target, depth: 2 })` when you need an explainable local blast radius; its `tests_for` separates resolved imports from low-confidence filename suggestions. Use `bclaw_code_export({ target, direction, depth, maxNodes, maxEdges })` when you need a compact bounded subgraph; every returned edge keeps `kind`, `source`, and `confidence`, and `format: 'mermaid'` is projected from that same JSON model. A `missing_index` badge means run `bclaw_code_refresh` first. See [code map](../code-map.md)
29
29
  5. `bclaw_find` / `bclaw_get` / `bclaw_create` / `bclaw_update` / `bclaw_remove` / `bclaw_transition` for entity reads and writes
30
30
  6. `bclaw_coordinate`, `bclaw_dispatch`, or `bclaw_loop` for assign, consult, review, reroute, summarize, dispatch, or multi-turn loop flows
31
31
  7. `bclaw_read_inbox` when resuming delegated work
@@ -47,7 +47,7 @@ Every tool has one of three tiers in its `annotations.tier` field:
47
47
  - **standard** — Day-to-day coordination tools: plans, claims, messaging, sequences, dispatch, review, memory. Returned by default alongside facades.
48
48
  - **advanced** — Specialized governance, audit, registry, and power tools.
49
49
 
50
- By default, `tools/list` returns **facade + standard** tools (46 tools). To get all tools including advanced, pass `{ "catalog": "all" }`, `{ "include": "all" }`, or `{ "advanced": true }`. To filter by a single tier, pass `{ "tier": "facade" }`, `{ "tier": "standard" }`, or `{ "tier": "advanced" }`.
50
+ By default, `tools/list` returns **facade + standard** tools (49 tools). To get all tools including advanced, pass `{ "catalog": "all" }`, `{ "include": "all" }`, or `{ "advanced": true }`. To filter by a single tier, pass `{ "tier": "facade" }`, `{ "tier": "standard" }`, or `{ "tier": "advanced" }`.
51
51
 
52
52
  Published tools remain callable regardless of catalog filtering — the tier only affects discovery via `tools/list`.
53
53
 
@@ -111,6 +111,9 @@ Each tool also has an `annotations.category` field: `session`, `context`, `memor
111
111
  | `bclaw_code_status` | discovery | Code Map freshness badge + index stats (store presence, files/nodes/edges) |
112
112
  | `bclaw_code_find` | discovery | Search the Code Map symbol index by name (function/class/component/hook/type) |
113
113
  | `bclaw_code_brief` | discovery | Ranked reading list + related decisions/traps before editing a symbol or path |
114
+ | `bclaw_code_impact` | discovery | Explainable local blast radius from resolved imports: definition, direct dependents, opt-in bounded transitives, tests, and count-based risk |
115
+ | `bclaw_code_export` | discovery | Compact bounded local nodes/edges around one symbol or file; preserves edge kind/source/confidence, with optional Mermaid projection |
116
+ | `bclaw_code_outline` | discovery | Source-ordered symbols of one indexed file (span, exported, confidence) — no reparse |
114
117
  | `bclaw_code_refresh` | discovery | Rebuild the Code Map index (`scope: changed \| all`) |
115
118
 
116
119
  See [code map](../code-map.md) for the full Code Map reference (CLI, freshness model, supported languages).
@@ -408,7 +408,17 @@ will still succeed. A follow-up PR will strip the dead handler code.
408
408
  changelog records the published MCP surface fingerprint. When a tool
409
409
  name, tier, category, or input schema changes, the test fails until
410
410
  this section is updated.
411
- - MCP public surface fingerprint: `sha256:8241fa50b8cb4805`
411
+ - MCP public surface fingerprint: `sha256:b8dbb80bae8f6e36`
412
+ (updated 2026-08-10 for pln#665: `bclaw_code_export` — additive Tier-B read tool for a required, bounded local Code Map subgraph. Its target, direction, depth, node/edge caps, confidence threshold, and optional Mermaid projection are explicit; JSON retains each relation's kind/source/confidence and never defaults to a whole-graph export.)
413
+ Previous: `sha256:9ed35ed6cc49ea9a`
414
+ (updated 2026-08-10 for pln#661: `bclaw_code_impact` — additive Tier-B read tool
415
+ for local, resolved-import impact analysis. It exposes definition, direct causes,
416
+ optional bounded transitives, tests, and a count-based risk score; its required
417
+ `target` plus optional `depth` and `limit` input surface are explicitly bounded.)
418
+ Previous: `sha256:2a9f7d4cd72609df`
419
+ (updated 2026-08-10 for pln#660: `bclaw_code_outline` — new Tier-B read tool,
420
+ source-ordered symbols of one indexed file from the existing shard; no reparse,
421
+ no mutation, bounded output. Purely additive.)
412
422
  (updated 2026-07-25 for pln#632: `bclaw_loop` gains the `bind` intent — an
413
423
  implementation loop dispatches its linked sequence and advances bind→execute — plus
414
424
  its typed inputSchema properties `dry_run`, `lanes`, `auto_execute`, `model`, and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainclaw",
3
- "version": "1.24.0",
3
+ "version": "1.26.0",
4
4
  "description": "Shared project memory for humans and coding agents.",
5
5
  "type": "module",
6
6
  "repository": {