browsertrack 0.0.1 → 0.1.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.
Files changed (110) hide show
  1. package/.github/workflows/docs.yml +54 -0
  2. package/AGENTS.md +133 -0
  3. package/README.md +143 -0
  4. package/dist/chunk-6VA7GBAO.js +246 -0
  5. package/dist/chunk-6VA7GBAO.js.map +1 -0
  6. package/dist/chunk-G2Y3CXCY.js +659 -0
  7. package/dist/chunk-G2Y3CXCY.js.map +1 -0
  8. package/dist/chunk-ILRYKMME.js +1228 -0
  9. package/dist/chunk-ILRYKMME.js.map +1 -0
  10. package/dist/chunk-SKCMT2DE.js +2641 -0
  11. package/dist/chunk-SKCMT2DE.js.map +1 -0
  12. package/dist/chunk-SPCIROIU.js +616 -0
  13. package/dist/chunk-SPCIROIU.js.map +1 -0
  14. package/dist/cli/index.js +2942 -0
  15. package/dist/cli/index.js.map +1 -0
  16. package/dist/client/index.cjs +2780 -0
  17. package/dist/client/index.d.ts +211 -0
  18. package/dist/client/index.js +20 -0
  19. package/dist/client/index.js.map +1 -0
  20. package/dist/client.iife.js +630 -0
  21. package/dist/core/index.d.ts +86 -0
  22. package/dist/core/index.js +37 -0
  23. package/dist/core/index.js.map +1 -0
  24. package/dist/daemon/index.d.ts +58 -0
  25. package/dist/daemon/index.js +32 -0
  26. package/dist/daemon/index.js.map +1 -0
  27. package/dist/engine-CeT9URuN.d.ts +161 -0
  28. package/dist/index.d.ts +11 -0
  29. package/dist/index.js +56 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/mcp/index.d.ts +11 -0
  32. package/dist/mcp/index.js +12 -0
  33. package/dist/mcp/index.js.map +1 -0
  34. package/dist/notes-CBvN91Wf.d.ts +260 -0
  35. package/dist/projects-CY8ungMt.d.ts +99 -0
  36. package/dist/server-Dd8NX2Mk.d.ts +55 -0
  37. package/docboot.config.js +16 -0
  38. package/docs/cli.md +51 -0
  39. package/docs/closed-loop-verification.md +57 -0
  40. package/docs/getting-started.md +122 -0
  41. package/docs/incidents-diagnostics.md +61 -0
  42. package/docs/index.md +46 -0
  43. package/docs/mcp-reference.md +128 -0
  44. package/docs/security-privacy.md +32 -0
  45. package/docs/visual-notes.md +67 -0
  46. package/examples/test-app/index.html +299 -0
  47. package/package.json +56 -7
  48. package/packages/cli/src/index.ts +413 -0
  49. package/packages/client/package.json +28 -0
  50. package/packages/client/src/breadcrumbs.ts +30 -0
  51. package/packages/client/src/client.ts +278 -0
  52. package/packages/client/src/commands/handler.ts +301 -0
  53. package/packages/client/src/config.ts +37 -0
  54. package/packages/client/src/index.ts +50 -0
  55. package/packages/client/src/interceptors/console.ts +68 -0
  56. package/packages/client/src/interceptors/interaction.ts +119 -0
  57. package/packages/client/src/interceptors/navigation.ts +93 -0
  58. package/packages/client/src/interceptors/network.ts +165 -0
  59. package/packages/client/src/interceptors/runtime.ts +65 -0
  60. package/packages/client/src/notes/inspector.ts +1553 -0
  61. package/packages/client/src/screenshot/browser-script-driver.ts +192 -0
  62. package/packages/client/src/screenshot/driver.ts +14 -0
  63. package/packages/client/src/transport/websocket.ts +194 -0
  64. package/packages/client/tsconfig.json +8 -0
  65. package/packages/core/package.json +26 -0
  66. package/packages/core/src/fingerprint.ts +120 -0
  67. package/packages/core/src/index.ts +9 -0
  68. package/packages/core/src/redaction.ts +174 -0
  69. package/packages/core/src/selector.ts +77 -0
  70. package/packages/core/src/types/commands.ts +101 -0
  71. package/packages/core/src/types/events.ts +108 -0
  72. package/packages/core/src/types/incidents.ts +54 -0
  73. package/packages/core/src/types/notes.ts +106 -0
  74. package/packages/core/src/types/probes.ts +44 -0
  75. package/packages/core/src/types/projects.ts +20 -0
  76. package/packages/core/tsconfig.json +8 -0
  77. package/packages/daemon/src/config.ts +29 -0
  78. package/packages/daemon/src/incidents/engine.ts +211 -0
  79. package/packages/daemon/src/index.ts +18 -0
  80. package/packages/daemon/src/notes/engine.ts +92 -0
  81. package/packages/daemon/src/notes/verification.ts +191 -0
  82. package/packages/daemon/src/server/daemon.ts +112 -0
  83. package/packages/daemon/src/server/http.ts +165 -0
  84. package/packages/daemon/src/server/ws.ts +246 -0
  85. package/packages/daemon/src/session/manager.ts +147 -0
  86. package/packages/daemon/src/storage/db.ts +742 -0
  87. package/packages/daemon/src/storage/screenshot-store.ts +49 -0
  88. package/packages/daemon/src/verification/engine.ts +264 -0
  89. package/packages/mcp/src/handlers.ts +398 -0
  90. package/packages/mcp/src/index.ts +3 -0
  91. package/packages/mcp/src/server.ts +86 -0
  92. package/packages/mcp/src/tools.ts +236 -0
  93. package/src/index.ts +4 -0
  94. package/test/client/interceptors.test.ts +130 -0
  95. package/test/core/fingerprint.test.ts +53 -0
  96. package/test/core/notes.test.ts +66 -0
  97. package/test/core/redaction.test.ts +60 -0
  98. package/test/daemon/incident-engine.test.ts +98 -0
  99. package/test/daemon/notes-storage.test.ts +130 -0
  100. package/test/daemon/notes-verification.test.ts +135 -0
  101. package/test/daemon/storage.test.ts +123 -0
  102. package/test/daemon/verification-engine.test.ts +88 -0
  103. package/test/e2e/daemon-mcp-e2e.test.ts +153 -0
  104. package/test/e2e/visual-notes-e2e.test.ts +205 -0
  105. package/test/mcp/handlers.test.ts +116 -0
  106. package/test/mcp/notes.test.ts +107 -0
  107. package/tsconfig.base.json +17 -0
  108. package/tsconfig.json +26 -0
  109. package/tsup.config.ts +54 -0
  110. package/vitest.config.ts +9 -0
@@ -0,0 +1,260 @@
1
+ type EventType = 'runtime_error' | 'unhandled_rejection' | 'console' | 'fetch' | 'xhr' | 'navigation' | 'interaction';
2
+ type ConsoleLevel = 'error' | 'warn' | 'info' | 'log' | 'debug';
3
+ interface ElementSummary {
4
+ selector: string;
5
+ tag: string;
6
+ id?: string;
7
+ classes?: string[];
8
+ attributes?: Record<string, string>;
9
+ outerHTML?: string;
10
+ innerText?: string;
11
+ boundingRect?: {
12
+ x: number;
13
+ y: number;
14
+ width: number;
15
+ height: number;
16
+ top: number;
17
+ left: number;
18
+ bottom: number;
19
+ right: number;
20
+ };
21
+ visible: boolean;
22
+ }
23
+ interface Breadcrumb {
24
+ id?: string;
25
+ type: 'navigation' | 'click' | 'submit' | 'fetch' | 'xhr' | 'console' | 'error';
26
+ category?: string;
27
+ message: string;
28
+ timestamp: number;
29
+ level?: 'info' | 'warn' | 'error';
30
+ data?: Record<string, any>;
31
+ element?: ElementSummary;
32
+ }
33
+ interface NetworkEvent {
34
+ id?: string;
35
+ url: string;
36
+ method: string;
37
+ status?: number;
38
+ statusText?: string;
39
+ durationMs: number;
40
+ error?: string;
41
+ aborted?: boolean;
42
+ timestamp: number;
43
+ requestHeaders?: Record<string, string>;
44
+ }
45
+ interface RuntimeErrorEvent {
46
+ message: string;
47
+ stack?: string;
48
+ filename?: string;
49
+ lineno?: number;
50
+ colno?: number;
51
+ errorType: string;
52
+ timestamp: number;
53
+ }
54
+ interface ConsoleEvent {
55
+ level: ConsoleLevel;
56
+ message: string;
57
+ args?: any[];
58
+ stack?: string;
59
+ timestamp: number;
60
+ }
61
+ interface NavigationEvent {
62
+ from?: string;
63
+ to: string;
64
+ type: 'pushState' | 'replaceState' | 'popstate' | 'hashchange' | 'initial';
65
+ timestamp: number;
66
+ }
67
+ interface HelloMessage {
68
+ type: 'hello';
69
+ origin: string;
70
+ url: string;
71
+ title: string;
72
+ userAgent: string;
73
+ timestamp: number;
74
+ projectId?: string;
75
+ }
76
+ interface ClientEventMessage {
77
+ type: 'event';
78
+ sessionId: string;
79
+ eventType: EventType;
80
+ payload: RuntimeErrorEvent | ConsoleEvent | NetworkEvent | NavigationEvent | Breadcrumb;
81
+ breadcrumbs?: Breadcrumb[];
82
+ lastElement?: ElementSummary;
83
+ route?: string;
84
+ url: string;
85
+ title?: string;
86
+ timestamp: number;
87
+ }
88
+
89
+ type CommandType = 'reload' | 'navigate' | 'get_page_state' | 'query_element' | 'capture_element' | 'check_overflow' | 'get_element_rect' | 'get_element_style';
90
+ interface ClientCommand<T = any> {
91
+ id: string;
92
+ type: CommandType;
93
+ params?: T;
94
+ }
95
+ interface ReloadParams {
96
+ force?: boolean;
97
+ }
98
+ interface NavigateParams {
99
+ url: string;
100
+ }
101
+ interface QueryElementParams {
102
+ selector: string;
103
+ }
104
+ interface CaptureElementParams {
105
+ selector?: string;
106
+ }
107
+ interface QueryElementResult {
108
+ exists: boolean;
109
+ visible?: boolean;
110
+ tag?: string;
111
+ id?: string;
112
+ classes?: string[];
113
+ boundingRect?: {
114
+ x: number;
115
+ y: number;
116
+ width: number;
117
+ height: number;
118
+ top: number;
119
+ left: number;
120
+ bottom: number;
121
+ right: number;
122
+ };
123
+ innerText?: string;
124
+ outerHTML?: string;
125
+ }
126
+ interface PageStateResult {
127
+ url: string;
128
+ route: string;
129
+ title: string;
130
+ readyState: string;
131
+ activeElement?: ElementSummary;
132
+ }
133
+ interface CaptureElementResult {
134
+ dataUrl?: string;
135
+ format?: string;
136
+ width?: number;
137
+ height?: number;
138
+ }
139
+ interface OverflowCheckResult {
140
+ selector: string;
141
+ overflow: boolean;
142
+ viewportWidth: number;
143
+ viewportHeight: number;
144
+ rect?: {
145
+ x: number;
146
+ y: number;
147
+ width: number;
148
+ height: number;
149
+ top: number;
150
+ left: number;
151
+ bottom: number;
152
+ right: number;
153
+ };
154
+ overflowRightPx: number;
155
+ overflowBottomPx: number;
156
+ parentOverflow?: boolean;
157
+ }
158
+ interface ElementStyleResult {
159
+ selector: string;
160
+ styles: Record<string, string>;
161
+ }
162
+ interface CommandResponse<T = any> {
163
+ id: string;
164
+ ok: boolean;
165
+ result?: T;
166
+ error?: string;
167
+ reason?: string;
168
+ }
169
+
170
+ type NoteType = 'element' | 'region' | 'page';
171
+ type NoteStatus = 'OPEN' | 'IN_PROGRESS' | 'VERIFYING' | 'READY_FOR_REVIEW' | 'VERIFIED' | 'RESOLVED' | 'FAILED' | 'INCONCLUSIVE';
172
+ interface ViewportContext {
173
+ width: number;
174
+ height: number;
175
+ devicePixelRatio: number;
176
+ }
177
+ interface ScrollContext {
178
+ scrollX: number;
179
+ scrollY: number;
180
+ }
181
+ interface DOMRectJson {
182
+ x: number;
183
+ y: number;
184
+ width: number;
185
+ height: number;
186
+ top: number;
187
+ left: number;
188
+ bottom: number;
189
+ right: number;
190
+ }
191
+ interface NoteTarget {
192
+ selector: string;
193
+ boundingRect: DOMRectJson;
194
+ visible: boolean;
195
+ confidence?: 'high' | 'medium' | 'low';
196
+ }
197
+ interface ElementContext {
198
+ selector: string;
199
+ tag: string;
200
+ attributes?: Record<string, string>;
201
+ outerHTML?: string;
202
+ innerText?: string;
203
+ parent?: {
204
+ selector: string;
205
+ tag: string;
206
+ };
207
+ }
208
+ interface RegionContext {
209
+ x: number;
210
+ y: number;
211
+ width: number;
212
+ height: number;
213
+ }
214
+ interface VisualNote {
215
+ id: string;
216
+ projectId: string;
217
+ sessionId: string;
218
+ type: NoteType;
219
+ message: string;
220
+ route: string;
221
+ url: string;
222
+ viewport: ViewportContext;
223
+ scroll: ScrollContext;
224
+ target?: NoteTarget;
225
+ elementContext?: ElementContext;
226
+ region?: RegionContext;
227
+ status: NoteStatus;
228
+ incidentId?: string;
229
+ screenshots?: {
230
+ original?: string;
231
+ after?: string;
232
+ };
233
+ createdAt: string;
234
+ updatedAt: string;
235
+ resolvedAt?: string;
236
+ }
237
+ interface NoteVerificationResult {
238
+ noteId: string;
239
+ status: NoteStatus;
240
+ checks: Array<{
241
+ type: string;
242
+ passed: boolean;
243
+ details?: string;
244
+ }>;
245
+ geometryDiff?: {
246
+ before?: DOMRectJson;
247
+ current?: DOMRectJson;
248
+ viewportWidth?: number;
249
+ overflowFixed?: boolean;
250
+ overflowPx?: number;
251
+ };
252
+ screenshots?: {
253
+ before?: string;
254
+ after?: string;
255
+ };
256
+ timestamp: string;
257
+ message?: string;
258
+ }
259
+
260
+ export type { Breadcrumb as B, CaptureElementParams as C, DOMRectJson as D, ElementContext as E, HelloMessage as H, NavigateParams as N, OverflowCheckResult as O, PageStateResult as P, QueryElementParams as Q, RegionContext as R, ScrollContext as S, ViewportContext as V, CaptureElementResult as a, ClientCommand as b, ClientEventMessage as c, CommandResponse as d, CommandType as e, ConsoleEvent as f, ConsoleLevel as g, ElementStyleResult as h, ElementSummary as i, EventType as j, NavigationEvent as k, NetworkEvent as l, NoteStatus as m, NoteTarget as n, NoteType as o, NoteVerificationResult as p, QueryElementResult as q, ReloadParams as r, RuntimeErrorEvent as s, VisualNote as t };
@@ -0,0 +1,99 @@
1
+ import { B as Breadcrumb, l as NetworkEvent, i as ElementSummary } from './notes-CBvN91Wf.js';
2
+
3
+ type IncidentStatus = 'OPEN' | 'FIX_ATTEMPTED' | 'VERIFYING' | 'VERIFIED' | 'FAILED' | 'INCONCLUSIVE';
4
+ type IncidentSeverity = 'error' | 'warn' | 'fatal';
5
+ interface IncidentSource {
6
+ file: string;
7
+ line: number;
8
+ column?: number;
9
+ }
10
+ interface Incident {
11
+ id: string;
12
+ projectId: string;
13
+ sessionId: string;
14
+ type: string;
15
+ severity: IncidentSeverity;
16
+ message: string;
17
+ source: IncidentSource;
18
+ fingerprint: string;
19
+ route: string;
20
+ firstSeen: string;
21
+ lastSeen: string;
22
+ occurrences: number;
23
+ status: IncidentStatus;
24
+ stack?: string;
25
+ breadcrumbs: Breadcrumb[];
26
+ networkFailures: NetworkEvent[];
27
+ lastElement?: ElementSummary;
28
+ screenshots?: {
29
+ error?: string;
30
+ before?: string;
31
+ after?: string;
32
+ };
33
+ }
34
+ interface IncidentOccurrence {
35
+ id: string;
36
+ incidentId: string;
37
+ sessionId: string;
38
+ timestamp: string;
39
+ route: string;
40
+ url: string;
41
+ stack?: string;
42
+ breadcrumbs: Breadcrumb[];
43
+ lastElement?: ElementSummary;
44
+ }
45
+
46
+ type ProbeType = 'element_exists' | 'element_visible' | 'text_contains' | 'route_is' | 'network_request_succeeded' | 'no_incident';
47
+ interface VerificationProbe {
48
+ type: ProbeType;
49
+ selector?: string;
50
+ text?: string;
51
+ route?: string;
52
+ fingerprint?: string;
53
+ urlPattern?: string;
54
+ timeoutMs?: number;
55
+ }
56
+ interface VerificationRecipe {
57
+ route?: string;
58
+ targetSelector?: string;
59
+ expect?: VerificationProbe[];
60
+ observationWindowMs?: number;
61
+ }
62
+ interface ProbeResult {
63
+ type: ProbeType;
64
+ passed: boolean;
65
+ details?: string;
66
+ }
67
+ interface VerificationResult {
68
+ incidentId: string;
69
+ status: IncidentStatus;
70
+ checks: ProbeResult[];
71
+ screenshots?: {
72
+ before?: string;
73
+ after?: string;
74
+ };
75
+ timestamp: string;
76
+ message?: string;
77
+ }
78
+
79
+ interface Project {
80
+ id: string;
81
+ name: string;
82
+ origin: string;
83
+ path?: string;
84
+ createdAt: string;
85
+ updatedAt: string;
86
+ }
87
+ interface Session {
88
+ id: string;
89
+ projectId: string;
90
+ origin: string;
91
+ url: string;
92
+ title: string;
93
+ userAgent: string;
94
+ connectedAt: string;
95
+ lastSeenAt: string;
96
+ active: boolean;
97
+ }
98
+
99
+ export type { Incident as I, ProbeResult as P, Session as S, VerificationProbe as V, IncidentOccurrence as a, IncidentSeverity as b, IncidentSource as c, IncidentStatus as d, ProbeType as e, Project as f, VerificationRecipe as g, VerificationResult as h };
@@ -0,0 +1,55 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { S as StorageDB, a as SessionManager, V as VerificationEngine, N as NoteVerificationEngine } from './engine-CeT9URuN.js';
3
+
4
+ interface McpContext {
5
+ db: StorageDB;
6
+ sessionManager?: SessionManager;
7
+ verificationEngine?: VerificationEngine;
8
+ noteVerificationEngine?: NoteVerificationEngine;
9
+ daemonUrl?: string;
10
+ }
11
+ declare function handleToolCall(name: string, args: any, ctx: McpContext): Promise<any>;
12
+
13
+ interface McpServerOptions {
14
+ dbPath?: string;
15
+ context?: Partial<McpContext>;
16
+ }
17
+ declare function createMcpServer(options?: McpServerOptions): {
18
+ server: Server<{
19
+ method: string;
20
+ params?: {
21
+ [x: string]: unknown;
22
+ _meta?: {
23
+ [x: string]: unknown;
24
+ progressToken?: string | number | undefined;
25
+ "io.modelcontextprotocol/related-task"?: {
26
+ taskId: string;
27
+ } | undefined;
28
+ } | undefined;
29
+ } | undefined;
30
+ }, {
31
+ method: string;
32
+ params?: {
33
+ [x: string]: unknown;
34
+ _meta?: {
35
+ [x: string]: unknown;
36
+ progressToken?: string | number | undefined;
37
+ "io.modelcontextprotocol/related-task"?: {
38
+ taskId: string;
39
+ } | undefined;
40
+ } | undefined;
41
+ } | undefined;
42
+ }, {
43
+ [x: string]: unknown;
44
+ _meta?: {
45
+ [x: string]: unknown;
46
+ progressToken?: string | number | undefined;
47
+ "io.modelcontextprotocol/related-task"?: {
48
+ taskId: string;
49
+ } | undefined;
50
+ } | undefined;
51
+ }>;
52
+ startStdio(): Promise<void>;
53
+ };
54
+
55
+ export { type McpContext as M, type McpServerOptions as a, createMcpServer as c, handleToolCall as h };
@@ -0,0 +1,16 @@
1
+ /** @type {import('docboot').DocbootConfig} */
2
+ export default {
3
+ title: "BrowserTrack",
4
+ description: "Local browser diagnostics shared with coding agents through MCP",
5
+ docs: "./docs",
6
+ out: "./dist-docs",
7
+ theme: {
8
+ preset: "zinc",
9
+ defaultMode: "dark"
10
+ },
11
+ search: {
12
+ fuzzy: 0.2,
13
+ prefix: true,
14
+ maxResults: 10
15
+ }
16
+ };
package/docs/cli.md ADDED
@@ -0,0 +1,51 @@
1
+ ---
2
+ title: CLI Reference
3
+ description: Command-line interface commands for daemon control, project tracking, error logs, and documentation
4
+ order: 8
5
+ ---
6
+
7
+ # CLI Reference 💻
8
+
9
+ BrowserTrack provides a complete command-line interface for managing the daemon, tracked projects, and runtime errors.
10
+
11
+ ---
12
+
13
+ ## ⚡ Commands
14
+
15
+ ### Daemon Management
16
+ ```bash
17
+ browsertrack start # Start local daemon on http://127.0.0.1:7331
18
+ browsertrack start --verbose # Start with verbose message logging
19
+ browsertrack stop # Stop running daemon process
20
+ browsertrack status # Check status and connected browser sessions
21
+ ```
22
+
23
+ ### Project Registry
24
+ ```bash
25
+ browsertrack projects # List all tracked projects
26
+ browsertrack project add <name> --origin <url> --path <path>
27
+ ```
28
+
29
+ ### Incident & Log Inspection
30
+ ```bash
31
+ browsertrack errors # List open runtime error incidents
32
+ browsertrack errors --project <name>
33
+ browsertrack clear # Wipe stored logs, screenshots, and incidents
34
+ ```
35
+
36
+ ### MCP Integration
37
+ ```bash
38
+ browsertrack mcp # Start Model Context Protocol server over stdio
39
+ ```
40
+
41
+ ---
42
+
43
+ ## 📖 Documentation Commands (Docboot)
44
+
45
+ To preview or build this documentation locally using [Docboot](https://github.com/litepacks/docboot):
46
+
47
+ ```bash
48
+ npm run docs:dev # Start live documentation server on http://localhost:3000
49
+ npm run docs:build # Build static production documentation to dist-docs/
50
+ npm run docs:serve # Preview production build locally
51
+ ```
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: Closed-Loop Verification
3
+ description: Automated bug-fix verification, visual layout probes, before/after screenshot comparisons, and resolution verdicts
4
+ order: 5
5
+ ---
6
+
7
+ # Closed-Loop Verification 🔄
8
+
9
+ BrowserTrack features an automated closed-loop verification engine for both runtime bug fixes and visual layout fixes.
10
+
11
+ ---
12
+
13
+ ## 🐞 Bug Fix Verification (`verify_incident`)
14
+
15
+ When an agent fixes a code bug, it triggers `verify_incident`:
16
+
17
+ 1. **Browser Reload**: Reloads the active browser tab (or navigates to the incident route).
18
+ 2. **Error Monitoring**: Watches for the incident fingerprint during an observation window (e.g. 2000ms).
19
+ 3. **Probe Evaluation**: Evaluates custom verification probes:
20
+ - `no_incident`: Confirms zero runtime errors occurred.
21
+ - `element_exists`: Checks if a specific selector exists in the DOM.
22
+ - `element_visible`: Confirms the target is rendered and visible.
23
+ - `text_contains`: Asserts expected text content.
24
+ - `route_is`: Verifies current SPA route.
25
+ 4. **After Screenshot**: Automatically captures an after-fix screenshot.
26
+ 5. **Verdict**: Returns `VERIFIED`, `FAILED`, or `INCONCLUSIVE`.
27
+
28
+ ```typescript
29
+ // Example MCP call
30
+ await client.callTool("verify_incident", {
31
+ incidentId: "inc_19a31a28",
32
+ expect: [
33
+ { type: "no_incident" },
34
+ { type: "element_visible", selector: "#user-card" }
35
+ ]
36
+ });
37
+ ```
38
+
39
+ ---
40
+
41
+ ## 📐 Layout & Visual Note Verification (`verify_note`)
42
+
43
+ When an agent modifies CSS or HTML to resolve visual feedback, it triggers `verify_note`:
44
+
45
+ 1. **Target Element Inspection**: Queries element visibility, bounding rect, and computed styles.
46
+ 2. **Viewport Overflow Probe**: Checks if `rect.right > viewportWidth` or if container has unintended horizontal scroll.
47
+ 3. **Geometry Diff**: Calculates before vs after dimensional delta (`widthDiff`, `heightDiff`, `overflowFixed`).
48
+ 4. **After Screenshot**: Captures an updated visual snapshot.
49
+ 5. **Verdict & Auto-Resolution**: If all checks pass and overflow is eliminated, returns `VERIFIED`.
50
+
51
+ ```typescript
52
+ // Example MCP call
53
+ await client.callTool("verify_note", {
54
+ noteId: "note_30a89599",
55
+ observationWindowMs: 1000
56
+ });
57
+ ```
@@ -0,0 +1,122 @@
1
+ ---
2
+ title: Getting Started
3
+ description: Installation, daemon setup, and browser client integration guide for BrowserTrack
4
+ order: 2
5
+ ---
6
+
7
+ # Getting Started 🚀
8
+
9
+ Follow this guide to get BrowserTrack up and running in under 2 minutes.
10
+
11
+ ---
12
+
13
+ ## 1. Install & Start Daemon
14
+
15
+ Install BrowserTrack globally via npm:
16
+
17
+ ```bash
18
+ npm install -g browsertrack
19
+ ```
20
+
21
+ Start the background diagnostics server:
22
+
23
+ ```bash
24
+ browsertrack start
25
+ ```
26
+
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
+
29
+ ---
30
+
31
+ ## 2. Connect Your Web Application
32
+
33
+ Choose the integration method that best suits your tech stack:
34
+
35
+ ### Option A: Zero-Install Script Tag (Plain HTML / Vite / Next.js / Astro)
36
+
37
+ Add the script tag to your root HTML or document layout:
38
+
39
+ ```html
40
+ <script src="http://127.0.0.1:7331/client.js"></script>
41
+ ```
42
+
43
+ > **Tip (Next.js / SSR)**: You can conditionally load this script tag only in development environments (`process.env.NODE_ENV !== 'production'`).
44
+
45
+ ### Option B: NPM Package (React / Vue / Svelte / Angular)
46
+
47
+ Install the client package:
48
+
49
+ ```bash
50
+ npm install -D browsertrack
51
+ ```
52
+
53
+ Import the client in your main application entry point (e.g. `main.ts` or `src/index.tsx`):
54
+
55
+ ```typescript
56
+ import 'browsertrack/client';
57
+ ```
58
+
59
+ Or configure custom options programmatically:
60
+
61
+ ```typescript
62
+ import { BrowserTrackClient } from 'browsertrack/client';
63
+
64
+ const client = new BrowserTrackClient({
65
+ daemonUrl: 'ws://127.0.0.1:7331',
66
+ captureErrors: true,
67
+ captureConsole: true,
68
+ captureNetwork: true,
69
+ captureInteractions: true,
70
+ notes: {
71
+ enabled: true,
72
+ shortcut: 'Alt+Click',
73
+ },
74
+ }).init();
75
+ ```
76
+
77
+ ---
78
+
79
+ ## 3. Configure Your IDE for MCP
80
+
81
+ Add BrowserTrack MCP server to your AI editor configuration:
82
+
83
+ ### Antigravity (`~/.gemini/antigravity-ide/mcp_config.json`)
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "browsertrack": {
88
+ "command": "browsertrack",
89
+ "args": ["mcp"]
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ ### Cursor (`~/.cursor/mcp.json`) & Claude Code
96
+ ```json
97
+ {
98
+ "mcpServers": {
99
+ "browsertrack": {
100
+ "command": "npx",
101
+ "args": ["browsertrack", "mcp"]
102
+ }
103
+ }
104
+ }
105
+ ```
106
+
107
+ ---
108
+
109
+ ## 4. Add Project Agent Guidelines
110
+
111
+ Place an `AGENTS.md` file in the root of your project to instruct AI agents on how and when to use BrowserTrack tools:
112
+
113
+ ```markdown
114
+ # AGENTS.md
115
+ This project is integrated with BrowserTrack MCP. Always check `list_incidents` and `list_notes` when debugging runtime errors or fixing layout feedback. Use `verify_incident` and `verify_note` after making code changes.
116
+ ```
117
+
118
+ ---
119
+
120
+ ## 5. Verify the Connection
121
+
122
+ Open your web application in any browser. You will see the floating BrowserTrack dock in the bottom-right corner with **Element**, **Region**, **Page**, and **Notes** controls!