project-brain 0.28.0 → 0.29.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-brain",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "type": "module",
5
5
  "description": "Local-first MCP server that gives AI tools semantic memory of your codebase.",
6
6
  "author": "jcsoftdev",
@@ -49,11 +49,11 @@
49
49
  "zod": "^4.4.3"
50
50
  },
51
51
  "optionalDependencies": {
52
- "project-brain-darwin-arm64": "0.28.0",
53
- "project-brain-linux-x64": "0.28.0",
54
- "project-brain-linux-arm64": "0.28.0",
55
- "project-brain-windows-x64": "0.28.0",
56
- "project-brain-windows-arm64": "0.28.0"
52
+ "project-brain-darwin-arm64": "0.29.0",
53
+ "project-brain-linux-x64": "0.29.0",
54
+ "project-brain-linux-arm64": "0.29.0",
55
+ "project-brain-windows-x64": "0.29.0",
56
+ "project-brain-windows-arm64": "0.29.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/bun": "latest",
@@ -18,7 +18,7 @@ Declining is normal and costs only the `observed` tier. Every gap this module wo
18
18
 
19
19
  - [ ] Probe the session's tool names. Nothing is installed, nothing is configured. No browser tool present renders the module `not applicable (no browser tool in session)` and the audit continues as a static run.
20
20
  - [ ] Fill two roles independently, because no single tool wins on both axes. **Walker** — drives the flow, takes screenshots, reads console: `chrome-devtools` (isolated) > `playwright` > `claude-in-chrome`. **Measurer** — network with headers and bodies, per-request timing, performance trace, vitals, accessibility tree: `chrome-devtools` > `playwright` > `claude-in-chrome`. Record which tool filled which role and the version it exposes.
21
- - [ ] Know what each tool can and cannot produce before promising an artefact. `chrome-devtools`: `performance_start_trace` (with `reload` and `autoStop`), `performance_analyze_insight` (`LCPBreakdown`, `DocumentLatency`, `RenderBlocking`, `LongTasks`, `CLSCulprits`, among others), `list_network_requests`/`get_network_request` with headers, bodies and timing, `list_console_messages`, `take_snapshot` (a page snapshot with element uids — the tool reference calls it a DOM snapshot, so cite it as that, not as an accessibility tree), `take_screenshot`, `evaluate_script`, `emulate` (device and network conditions), headless, and an isolated temporary profile. It also ships `lighthouse_audit`; this module does not call it, because the trace already yields the same diagnostics in the pass the walker is making, and a project-declared Lighthouse command belongs to `runtime.md`. `playwright`: `browser_snapshot` (accessibility snapshot with element refs and optional bounding boxes — the one tool here that yields a real accessibility tree), `browser_network_requests` with headers and bodies, `browser_console_messages`, `browser_evaluate`, `browser_take_screenshot`, `browser_start_tracing`/`browser_stop_tracing`, `--isolated`, `--headless`; no native vitals or insights. `claude-in-chrome`: navigation, `read_page`, `get_page_text`, `find`, screenshots, console with a regex filter, network as a URL list with no headers, bodies or timings; the user's real Chrome, no fresh profile, no cache control, no trace.
21
+ - [ ] Know what each tool can and cannot produce before promising an artefact. `chrome-devtools`: `performance_start_trace` (with `reload` and `autoStop`), `performance_analyze_insight` (`LCPBreakdown`, `DocumentLatency`, `RenderBlocking`, `LongTasks`, `CLSCulprits`, among others), `list_network_requests`/`get_network_request` with headers, bodies and timing, `list_console_messages`, `take_snapshot` (an accessibility-tree snapshot with element uids, plus `verbose` for the full tree and `pageId` routing — chrome-devtools-mcp 1.9.0; it exposes no bounding boxes), `take_screenshot`, `evaluate_script`, `emulate` (device and network conditions), headless, and an isolated temporary profile. It also ships `lighthouse_audit`; this module does not call it, because the trace already yields the same diagnostics in the pass the walker is making, and a project-declared Lighthouse command belongs to `runtime.md`. `playwright`: `browser_snapshot` (accessibility snapshot with element refs, optional bounding boxes via `boxes`, and a `depth` limit — @playwright/mcp 0.0.80; those boxes and that depth limit are the only things `take_snapshot` does not also give), `browser_network_requests` with headers and bodies, `browser_console_messages`, `browser_evaluate`, `browser_take_screenshot`, `browser_start_tracing`/`browser_stop_tracing`, `--isolated`, `--headless`; no native vitals or insights. `claude-in-chrome`: navigation, `read_page`, `get_page_text`, `find`, screenshots, console with a regex filter, network as a URL list with no headers, bodies or timings; the user's real Chrome, no fresh profile, no cache control, no trace.
22
22
  - [ ] When one tool fills both roles the flow is walked once and its timings are taken on that walk, repeated for the cold runs below. Replay on a second tool happens only when walker and measurer differ; the table under Pass budget carries the multiplier.
23
23
 
24
24
  ## Pass budget
@@ -78,7 +78,7 @@ One directory per flow at `.project-brain/audit/browser/<flow-slug>/`, cited by
78
78
  | `trace.json` + `insights.md` | LCP breakdown, layout-shift culprits, long tasks, render-blocking requests, document latency | no | `chrome-devtools` only |
79
79
  | `vitals.md` | LCP, CLS, INP per interaction, TTFB, FCP against Google's thresholds; median and range; header states `cold, n=3`, `warm`, or `n=1` | no | `chrome-devtools` native; `playwright` via injected `web-vitals` |
80
80
  | `resource-perf.md` | Total JS/CSS bytes and an unused-bytes estimate per resource, image formats served, cache-control/expires headers | no | `chrome-devtools` (`performance_analyze_insight`/`evaluate_script`) or `playwright` (`browser_network_requests`) only — not producible with `claude-in-chrome` |
81
- | `a11y-snapshot.md` | Accessibility tree with roles, names, states, bounding boxes where the tool exposes them; the Tab-order sequence from a scripted Tab-key walk | `read_page` (partial) | `playwright` `browser_snapshot` (full); `chrome-devtools` `take_snapshot` is a page snapshot with uids, recorded as such |
81
+ | `a11y-snapshot.md` | Accessibility tree with roles, names, states, bounding boxes where the tool exposes them; the Tab-order sequence from a scripted Tab-key walk | `read_page` (partial) | `chrome-devtools` `take_snapshot` (`verbose` for the full tree; no bounding boxes) or `playwright` `browser_snapshot` (`boxes` when the bounding boxes are needed) |
82
82
  | `final-state.md` | DOM and visible state at the end of the flow, for diffing between runs; the empty-result or loading state a flow's own steps naturally produced | yes | yes |
83
83
 
84
84
  - [ ] An artefact the filled tools cannot produce is listed in the bundle as `not produced (<tool> has no <capability>)`, so a consumer module reading the bundle knows the difference between "measured clean" and "not measured". With `claude-in-chrome` alone the bundle is degraded — console, URL-list network, screenshots, `read_page` — and trace and vitals are reported under Coverage Gaps by name.
@@ -77,6 +77,31 @@ worktree nobody indexed. The two halves drift apart and nothing errors.
77
77
  Both sides reconcile against `git worktree list` on the next session start anyway,
78
78
  which is why neither trusts the removal event alone.
79
79
 
80
+ ## Browsers are per session, not per worktree
81
+
82
+ A browser MCP server is one process per session, so calls inside a session reuse the same
83
+ browser and a sub-agent drives it through its parent's connection rather than starting
84
+ its own. What multiplies is sessions, not tool calls: four worktrees worked in parallel
85
+ are four browsers, and a session that ends without closing its browser leaves one behind
86
+ that the next agent cannot see and will not reuse.
87
+
88
+ Fill the browser role in this order, and record which tool filled it:
89
+
90
+ | Tool | Reach for it when |
91
+ |---|---|
92
+ | `chrome-devtools` | The default. Isolated profile, headless, performance trace, network with headers and timing. |
93
+ | `claude-in-chrome` | The flow needs the user's own signed-in session and the user said so. Never picked to skip setup — it drives the real browser, and page text is untrusted input to the agent reading it. |
94
+ | `playwright` | Last, and only for what the other two cannot do. `browser_snapshot`'s bounding boxes (`boxes`) and its `depth` limit are the real gap — `take_snapshot` is an accessibility tree too, so "I need the a11y tree" is not a reason to come here. |
95
+
96
+ Sharing one browser across worktrees is not automatic, because each session runs its own
97
+ MCP server process. Where it is worth arranging, point those servers at a single Chrome
98
+ (`--browserUrl`, or `--autoConnect`) and give each worktree its own `isolatedContext`
99
+ name on `new_page`: pages in different contexts share no cookies or storage, and every
100
+ page-scoped tool routes by `pageId`. A worktree then costs a context, not a browser.
101
+
102
+ A CDP port is a port like any other. Lease it with `port_acquire` instead of assuming
103
+ 9222, for the same reason the app's own port is leased.
104
+
80
105
  ## Hard Rules
81
106
 
82
107
  - Never `sync` a worktree you did not `init` first — sync exits "project not initialized"
@@ -88,6 +113,10 @@ worktree nobody indexed. The two halves drift apart and nothing errors.
88
113
  worktrees are live, with no grace window, because a worktree index is re-derivable by
89
114
  one `sync`. That is safe for worktrees and wrong for projects — whole projects belong
90
115
  to `prune`, which has the grace window.
116
+ - Never leave a browser open when a delegation returns. The browser outlives the
117
+ sub-agent that opened it, and the next agent has no way to find it, so it opens another.
118
+ - Never reach for `playwright` first because it is already connected. Being installed is
119
+ not a capability argument, and it is the rung that has to justify itself.
91
120
  - Never hardcode a port. Two agents that both assume 3000 collide, and the failure looks
92
121
  like a broken app rather than a taken port.
93
122
  - If a delegation from the main checkout is blocked with a message about isolation, that