browsertrack 0.2.0 → 0.2.2

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 (67) hide show
  1. package/AGENTS.md +11 -6
  2. package/README.md +2 -0
  3. package/dist/{chunk-WB7ZKWK7.js → chunk-4HRLW6YF.js} +509 -109
  4. package/dist/chunk-4HRLW6YF.js.map +1 -0
  5. package/dist/{chunk-3HOXPTM2.js → chunk-AYSVE6NG.js} +808 -53
  6. package/dist/chunk-AYSVE6NG.js.map +1 -0
  7. package/dist/{chunk-6VA7GBAO.js → chunk-QRZ57ME3.js} +70 -2
  8. package/dist/chunk-QRZ57ME3.js.map +1 -0
  9. package/dist/{chunk-UP5JKCFY.js → chunk-TWEYRBDU.js} +281 -44
  10. package/dist/chunk-TWEYRBDU.js.map +1 -0
  11. package/dist/cli/index.js +1040 -546
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/client/index.cjs +536 -109
  14. package/dist/client/index.d.ts +36 -4
  15. package/dist/client/index.js +8 -4
  16. package/dist/client.iife.js +42 -19
  17. package/dist/{notes-BMnonq46.d.ts → commands-fjuqKzkm.d.ts} +125 -114
  18. package/dist/core/index.d.ts +26 -3
  19. package/dist/core/index.js +9 -1
  20. package/dist/daemon/index.d.ts +4 -4
  21. package/dist/daemon/index.js +6 -8
  22. package/dist/{engine-B43IohQY.d.ts → engine-CmchnMDq.d.ts} +2 -2
  23. package/dist/index.d.ts +5 -5
  24. package/dist/index.js +14 -7
  25. package/dist/mcp/index.d.ts +4 -4
  26. package/dist/mcp/index.js +7 -4
  27. package/dist/{projects-D5J-egVN.d.ts → projects-DB7S312i.d.ts} +1 -1
  28. package/dist/{server-BztYp1Zc.d.ts → server-DjV7RWQM.d.ts} +10 -2
  29. package/docs/cli.md +4 -1
  30. package/docs/component-resolver.md +108 -0
  31. package/docs/getting-started.md +60 -6
  32. package/docs/index.md +1 -0
  33. package/docs/mcp-reference.md +44 -2
  34. package/docs/visual-notes.md +36 -0
  35. package/package.json +1 -1
  36. package/packages/cli/src/index.ts +247 -151
  37. package/packages/client/src/client.ts +18 -1
  38. package/packages/client/src/config.ts +84 -1
  39. package/packages/client/src/index.ts +4 -1
  40. package/packages/client/src/interceptors/interaction.ts +3 -0
  41. package/packages/client/src/interceptors/navigation.ts +38 -26
  42. package/packages/client/src/interceptors/network.ts +22 -17
  43. package/packages/client/src/notes/inspector.ts +186 -51
  44. package/packages/client/src/source/resolver.ts +278 -0
  45. package/packages/client/src/transport/websocket.ts +23 -18
  46. package/packages/core/src/index.ts +1 -0
  47. package/packages/core/src/safety.ts +86 -0
  48. package/packages/core/src/types/events.ts +3 -0
  49. package/packages/core/src/types/notes.ts +11 -0
  50. package/packages/daemon/src/server/daemon.ts +7 -1
  51. package/packages/daemon/src/server/http.ts +125 -5
  52. package/packages/daemon/src/server/ws.ts +33 -29
  53. package/packages/daemon/src/storage/db.ts +57 -35
  54. package/packages/mcp/src/handlers.ts +115 -45
  55. package/packages/mcp/src/server.ts +202 -2
  56. package/test/client/component-resolver.test.ts +141 -0
  57. package/test/client/interceptors.test.ts +56 -0
  58. package/test/core/safety.test.ts +106 -0
  59. package/test/daemon/storage.test.ts +36 -0
  60. package/test/e2e/daemon-mcp-e2e.test.ts +10 -0
  61. package/test/mcp/auto-start.test.ts +87 -0
  62. package/dist/chunk-3HOXPTM2.js.map +0 -1
  63. package/dist/chunk-6VA7GBAO.js.map +0 -1
  64. package/dist/chunk-7OCOQGDN.js +0 -635
  65. package/dist/chunk-7OCOQGDN.js.map +0 -1
  66. package/dist/chunk-UP5JKCFY.js.map +0 -1
  67. package/dist/chunk-WB7ZKWK7.js.map +0 -1
@@ -26,6 +26,8 @@ browsertrack start
26
26
 
27
27
  This will initialize the local server at `http://127.0.0.1:7331` (WebSocket bridge on `ws://127.0.0.1:7331`) and SQLite database at `~/.browsertrack/browsertrack.db`.
28
28
 
29
+ > **⚡ Zero-Config Auto-Start**: If you configure BrowserTrack via MCP in your AI coding editor (Cursor, Antigravity, Claude Desktop), you do **not** need to manually run `browsertrack start`. The MCP server automatically launches and manages the HTTP and WebSocket background daemon on port `7331`!
30
+
29
31
  ---
30
32
 
31
33
  ## 2. Connect Your Web Application
@@ -80,25 +82,77 @@ const client = new BrowserTrackClient({
80
82
 
81
83
  Add BrowserTrack MCP server to your AI editor configuration:
82
84
 
83
- ### Antigravity (`~/.gemini/antigravity-ide/mcp_config.json`)
85
+ ### Standard Configuration
84
86
  ```json
85
87
  {
86
88
  "mcpServers": {
87
89
  "browsertrack": {
88
- "command": "browsertrack",
89
- "args": ["mcp"]
90
+ "command": "npx",
91
+ "args": ["-y", "browsertrack@latest", "mcp"]
90
92
  }
91
93
  }
92
94
  }
93
95
  ```
94
96
 
95
- ### Cursor (`~/.cursor/mcp.json`) & Claude Code
97
+ ---
98
+
99
+ ### ⚠️ Troubleshooting: `executable file not found in $PATH`
100
+
101
+ If your editor throws an error like:
102
+ ```text
103
+ Error: exec: "browsertrack": executable file not found in $PATH
104
+ # or
105
+ Error: exec: "npx": executable file not found in $PATH
106
+ ```
107
+
108
+ #### Why does this happen?
109
+ GUI applications on macOS and Linux (Antigravity, Cursor, Claude Desktop, VS Code) are launched by the desktop window manager (such as `launchd` on macOS), **not** from your terminal shell. Therefore, they do **not** automatically source your `~/.zshrc`, `~/.bashrc`, or environment managers like **NVM**, **fnm**, **asdf**, **Volta**, or **Homebrew** (`/opt/homebrew/bin`).
110
+
111
+ #### Solutions:
112
+
113
+ ##### Option A: Use Absolute Path to `npx` with `PATH` environment (Recommended)
114
+ Find your `npx` and `node` bin directory in your terminal:
115
+ ```bash
116
+ which npx
117
+ # Example output: /Users/username/.nvm/versions/node/v20.19.5/bin/npx
118
+ ```
119
+
120
+ Configure your MCP config with the full path, the `-y` flag (to prevent interactive installation prompts from stalling stdio), and the `PATH` environment variable:
96
121
  ```json
97
122
  {
98
123
  "mcpServers": {
99
124
  "browsertrack": {
100
- "command": "npx",
101
- "args": ["browsertrack", "mcp"]
125
+ "command": "/Users/username/.nvm/versions/node/v20.19.5/bin/npx",
126
+ "args": ["-y", "browsertrack@latest", "mcp"],
127
+ "env": {
128
+ "PATH": "/Users/username/.nvm/versions/node/v20.19.5/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
129
+ }
130
+ }
131
+ }
132
+ }
133
+ ```
134
+
135
+ ##### Option B: Run Directly via Node (Fastest for Local Development)
136
+ If you are developing or running BrowserTrack locally, bypass `npx` completely and execute the CLI entry script directly with `node`:
137
+ ```json
138
+ {
139
+ "mcpServers": {
140
+ "browsertrack": {
141
+ "command": "/Users/username/.nvm/versions/node/v20.19.5/bin/node",
142
+ "args": ["/absolute/path/to/browsertrack/dist/cli/index.js", "mcp"]
143
+ }
144
+ }
145
+ }
146
+ ```
147
+
148
+ ##### Option C: Wrap with Login Shell (`/bin/zsh -lc`)
149
+ Use your interactive login shell to automatically source your `~/.zshrc` and all environment variables:
150
+ ```json
151
+ {
152
+ "mcpServers": {
153
+ "browsertrack": {
154
+ "command": "/bin/zsh",
155
+ "args": ["-lc", "npx -y browsertrack mcp"]
102
156
  }
103
157
  }
104
158
  }
package/docs/index.md CHANGED
@@ -40,6 +40,7 @@ graph TD
40
40
  - [Getting Started](./getting-started.md) — Quick installation and setup in under 2 minutes.
41
41
  - [Visual Notes & Annotations](./visual-notes.md) — Screen notes, region selection, and persistent markers.
42
42
  - [Multi-Step Scenarios & Flows](./scenarios-flows.md) — Sequential reproduction flows, Save & Next Step, and stepper walk-throughs.
43
+ - [Component & Source Resolver](./component-resolver.md) — Map live DOM elements to React Fiber, Vue VNode, Svelte, and exact source file locations.
43
44
  - [Incidents & Error Diagnostics](./incidents-diagnostics.md) — Ingest runtime errors, stack traces, and breadcrumbs.
44
45
  - [Closed-Loop Verification](./closed-loop-verification.md) — Automated bug-fix and layout verification.
45
46
  - [MCP Tool Reference](./mcp-reference.md) — Complete guide to all MCP tools.
@@ -8,6 +8,8 @@ order: 6
8
8
 
9
9
  BrowserTrack exposes 16 specialized Model Context Protocol (MCP) tools for AI agents.
10
10
 
11
+ > **⚡ Automatic Server Lifecycle**: When your IDE starts the MCP server (`browsertrack mcp`), BrowserTrack automatically checks if the background daemon is already running. If not, it **automatically starts the HTTP (`http://127.0.0.1:7331`) and WebSocket (`ws://127.0.0.1:7331`) server** in the background, so your browser can connect immediately with zero manual terminal commands. If you already have a running daemon, MCP seamlessly connects to it.
12
+
11
13
  ---
12
14
 
13
15
  ## 📋 Incidents & Error Diagnostics
@@ -24,7 +26,7 @@ Lists recorded browser runtime errors, unhandled rejections, and console errors
24
26
  Retrieves compact, high-signal debugging context for an error incident.
25
27
  - **Arguments**:
26
28
  - `incidentId` (`string`, *required*): The unique ID of the incident (e.g. `inc_19a31a28`).
27
- - **Returns**: Stack trace, normalized error message, breadcrumbs timeline, failed network calls, last interacted element, error screenshot.
29
+ - **Returns**: Stack trace, normalized error message, breadcrumbs timeline, failed network calls, last interacted element (with `componentSource`: component name, source file, line number, hierarchy), and error screenshot.
28
30
 
29
31
  ### `get_console`
30
32
  Fetches recent console logs, warnings, and errors from a browser session.
@@ -84,7 +86,7 @@ Retrieves full chronological step-by-step reproduction flow with selectors, rout
84
86
  Retrieves full debugging context for a visual note.
85
87
  - **Arguments**:
86
88
  - `noteId` (`string`, *required*): The unique ID of the visual note (e.g. `note_30a89599`).
87
- - **Returns**: Note message, route, viewport dimensions, target element selector, DOM context, screenshot file path, scenario metadata.
89
+ - **Returns**: Note message, route, viewport dimensions, target element selector, DOM context (including `componentSource` with framework, component name, source file path, and line number), screenshot file path, scenario metadata.
88
90
 
89
91
  ### `capture_note_context`
90
92
  Inspects live DOM context, bounding box, overflow, and computed styles for a target element.
@@ -139,3 +141,43 @@ Triggers closed-loop bug fix verification (reloads browser, evaluates probes, ca
139
141
  Retrieves latest verification result and before/after screenshots for an incident.
140
142
  - **Arguments**:
141
143
  - `incidentId` (`string`, *required*): The ID of the incident.
144
+
145
+ ---
146
+
147
+ ## ⚠️ Troubleshooting MCP Client Setup
148
+
149
+ If your AI editor fails to launch the MCP server with:
150
+ ```text
151
+ Error: exec: "browsertrack": executable file not found in $PATH
152
+ ```
153
+
154
+ This occurs because GUI applications (Cursor, Antigravity, VS Code, Claude Desktop) run without loading terminal shell rc files (`~/.zshrc`, `~/.bashrc`), leaving version managers like **NVM**, **fnm**, **asdf**, or **Homebrew** out of `$PATH`.
155
+
156
+ ### Recommended Fix
157
+ Specify the absolute path to `npx` (find it with `which npx`), include `-y`, and explicitly set `PATH`:
158
+
159
+ ```json
160
+ {
161
+ "mcpServers": {
162
+ "browsertrack": {
163
+ "command": "/Users/username/.nvm/versions/node/v20.19.5/bin/npx",
164
+ "args": ["-y", "browsertrack@latest", "mcp"],
165
+ "env": {
166
+ "PATH": "/Users/username/.nvm/versions/node/v20.19.5/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
167
+ }
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ Or run directly via `node` for local projects:
174
+ ```json
175
+ {
176
+ "mcpServers": {
177
+ "browsertrack": {
178
+ "command": "/Users/username/.nvm/versions/node/v20.19.5/bin/node",
179
+ "args": ["/path/to/browsertrack/dist/cli/index.js", "mcp"]
180
+ }
181
+ }
182
+ }
183
+ ```
@@ -64,4 +64,40 @@ The bottom-right floating toolbar gives quick access:
64
64
  - **`🎯 Element`**: Toggle element inspection mode.
65
65
  - **`📐 Region`**: Activate rectangle drag mode.
66
66
  - **`📄 Page`**: Open full-page note modal.
67
+ - **`🎬 Flow`**: Start/finish sequential scenario recording.
67
68
  - **`📌 Notes (N)`**: Toggle visibility of all note markers on screen.
69
+
70
+ ---
71
+
72
+ ## 🙈 Hiding the Tool via Query String (Headless / Clean Mode)
73
+
74
+ When running automated visual regression tests, Cypress, Playwright, or giving clean demo presentations, you can hide the visible BrowserTrack UI (dock, pins, overlays) completely using URL query parameters:
75
+
76
+ ### 1. Built-in Query Parameters
77
+ Simply append any of the following to your page URL:
78
+ - `?bt=0` or `?bt=false` or `?bt=hidden` or `?bt=off`
79
+ - `?browsertrack=false` or `?browsertrack=0` or `?browsertrack=hidden`
80
+ - `?no_bt` / `?no_bt=1` or `?no_browsertrack=1`
81
+ - `?hide_bt=1` or `?hide_browsertrack=1`
82
+
83
+ ```text
84
+ http://localhost:3000/dashboard?bt=false
85
+ ```
86
+
87
+ ### 2. Custom Query Parameter Configuration
88
+ You can also define your own custom query parameters in client options:
89
+ ```typescript
90
+ import { init } from 'browsertrack/client';
91
+
92
+ init({
93
+ hideQueryParam: ['cypress', 'clean_view', 'no_ui'],
94
+ // or hide by default in specific environments:
95
+ hidden: process.env.NODE_ENV === 'test',
96
+ });
97
+ ```
98
+
99
+ When hidden:
100
+ - The floating toolbar and on-screen note pins are not displayed.
101
+ - Alt+Click hover highlights and selection shortcuts are inactive.
102
+ - Background diagnostics (runtime errors, console capture, network logging, MCP command execution) continue working seamlessly in headless mode.
103
+ - Programmatic visibility can be restored anytime via `client.setUIVisible(true)`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browsertrack",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Local browser diagnostics + MCP bridge for coding agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",