react-native-ai-debugger 1.1.6 → 1.4.33

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 (168) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +386 -45
  3. package/build/__tests__/helpers/tap-test-helpers.d.ts +36 -0
  4. package/build/__tests__/helpers/tap-test-helpers.d.ts.map +1 -0
  5. package/build/__tests__/helpers/tap-test-helpers.js +130 -0
  6. package/build/__tests__/helpers/tap-test-helpers.js.map +1 -0
  7. package/build/__tests__/integration/connection-health.test.js +12 -6
  8. package/build/__tests__/integration/connection-health.test.js.map +1 -1
  9. package/build/__tests__/integration/execute-in-app.test.js +2 -1
  10. package/build/__tests__/integration/execute-in-app.test.js.map +1 -1
  11. package/build/__tests__/integration/tap-strategies.test.d.ts +2 -0
  12. package/build/__tests__/integration/tap-strategies.test.d.ts.map +1 -0
  13. package/build/__tests__/integration/tap-strategies.test.js +329 -0
  14. package/build/__tests__/integration/tap-strategies.test.js.map +1 -0
  15. package/build/__tests__/integration/tools.test.js +9 -10
  16. package/build/__tests__/integration/tools.test.js.map +1 -1
  17. package/build/__tests__/unit/burst.test.d.ts +2 -0
  18. package/build/__tests__/unit/burst.test.d.ts.map +1 -0
  19. package/build/__tests__/unit/burst.test.js +50 -0
  20. package/build/__tests__/unit/burst.test.js.map +1 -0
  21. package/build/__tests__/unit/connection-health.test.js +26 -16
  22. package/build/__tests__/unit/connection-health.test.js.map +1 -1
  23. package/build/__tests__/unit/fiberMatch.test.d.ts +2 -0
  24. package/build/__tests__/unit/fiberMatch.test.d.ts.map +1 -0
  25. package/build/__tests__/unit/fiberMatch.test.js +114 -0
  26. package/build/__tests__/unit/fiberMatch.test.js.map +1 -0
  27. package/build/__tests__/unit/fingerprint.test.d.ts +2 -0
  28. package/build/__tests__/unit/fingerprint.test.d.ts.map +1 -0
  29. package/build/__tests__/unit/fingerprint.test.js +89 -0
  30. package/build/__tests__/unit/fingerprint.test.js.map +1 -0
  31. package/build/__tests__/unit/imageBuffer.test.d.ts +2 -0
  32. package/build/__tests__/unit/imageBuffer.test.d.ts.map +1 -0
  33. package/build/__tests__/unit/imageBuffer.test.js +128 -0
  34. package/build/__tests__/unit/imageBuffer.test.js.map +1 -0
  35. package/build/__tests__/unit/logs.test.js +9 -0
  36. package/build/__tests__/unit/logs.test.js.map +1 -1
  37. package/build/__tests__/unit/networkInterceptor.test.d.ts +2 -0
  38. package/build/__tests__/unit/networkInterceptor.test.d.ts.map +1 -0
  39. package/build/__tests__/unit/networkInterceptor.test.js +104 -0
  40. package/build/__tests__/unit/networkInterceptor.test.js.map +1 -0
  41. package/build/__tests__/unit/screenshot-diff.test.d.ts +2 -0
  42. package/build/__tests__/unit/screenshot-diff.test.d.ts.map +1 -0
  43. package/build/__tests__/unit/screenshot-diff.test.js +97 -0
  44. package/build/__tests__/unit/screenshot-diff.test.js.map +1 -0
  45. package/build/__tests__/unit/tap.test.js +542 -25
  46. package/build/__tests__/unit/tap.test.js.map +1 -1
  47. package/build/core/android.d.ts.map +1 -1
  48. package/build/core/android.js +104 -113
  49. package/build/core/android.js.map +1 -1
  50. package/build/core/appDetection.d.ts +8 -0
  51. package/build/core/appDetection.d.ts.map +1 -0
  52. package/build/core/appDetection.js +115 -0
  53. package/build/core/appDetection.js.map +1 -0
  54. package/build/core/bundle.d.ts.map +1 -1
  55. package/build/core/bundle.js +15 -23
  56. package/build/core/bundle.js.map +1 -1
  57. package/build/core/config.d.ts +8 -0
  58. package/build/core/config.d.ts.map +1 -0
  59. package/build/core/config.js +27 -0
  60. package/build/core/config.js.map +1 -0
  61. package/build/core/connection.d.ts +47 -3
  62. package/build/core/connection.d.ts.map +1 -1
  63. package/build/core/connection.js +519 -124
  64. package/build/core/connection.js.map +1 -1
  65. package/build/core/executor.d.ts +82 -14
  66. package/build/core/executor.d.ts.map +1 -1
  67. package/build/core/executor.js +1869 -418
  68. package/build/core/executor.js.map +1 -1
  69. package/build/core/feedback.d.ts +18 -0
  70. package/build/core/feedback.d.ts.map +1 -0
  71. package/build/core/feedback.js +73 -0
  72. package/build/core/feedback.js.map +1 -0
  73. package/build/core/fiberMatch.d.ts +25 -0
  74. package/build/core/fiberMatch.d.ts.map +1 -0
  75. package/build/core/fiberMatch.js +35 -0
  76. package/build/core/fiberMatch.js.map +1 -0
  77. package/build/core/fingerprint.d.ts +4 -0
  78. package/build/core/fingerprint.d.ts.map +1 -0
  79. package/build/core/fingerprint.js +47 -0
  80. package/build/core/fingerprint.js.map +1 -0
  81. package/build/core/guides.d.ts.map +1 -1
  82. package/build/core/guides.js +66 -3
  83. package/build/core/guides.js.map +1 -1
  84. package/build/core/imageBuffer.d.ts +37 -0
  85. package/build/core/imageBuffer.d.ts.map +1 -0
  86. package/build/core/imageBuffer.js +58 -0
  87. package/build/core/imageBuffer.js.map +1 -0
  88. package/build/core/index.d.ts +22 -17
  89. package/build/core/index.d.ts.map +1 -1
  90. package/build/core/index.js +23 -19
  91. package/build/core/index.js.map +1 -1
  92. package/build/core/ios.d.ts +36 -7
  93. package/build/core/ios.d.ts.map +1 -1
  94. package/build/core/ios.js +561 -326
  95. package/build/core/ios.js.map +1 -1
  96. package/build/core/license.d.ts +38 -0
  97. package/build/core/license.d.ts.map +1 -0
  98. package/build/core/license.js +243 -0
  99. package/build/core/license.js.map +1 -0
  100. package/build/core/logbox.d.ts +57 -0
  101. package/build/core/logbox.d.ts.map +1 -0
  102. package/build/core/logbox.js +282 -0
  103. package/build/core/logbox.js.map +1 -0
  104. package/build/core/logs.d.ts +1 -0
  105. package/build/core/logs.d.ts.map +1 -1
  106. package/build/core/logs.js +5 -0
  107. package/build/core/logs.js.map +1 -1
  108. package/build/core/metro.d.ts +8 -0
  109. package/build/core/metro.d.ts.map +1 -1
  110. package/build/core/metro.js +28 -0
  111. package/build/core/metro.js.map +1 -1
  112. package/build/core/networkInterceptor.d.ts +29 -2
  113. package/build/core/networkInterceptor.d.ts.map +1 -1
  114. package/build/core/networkInterceptor.js +195 -191
  115. package/build/core/networkInterceptor.js.map +1 -1
  116. package/build/core/ocr.d.ts +8 -3
  117. package/build/core/ocr.d.ts.map +1 -1
  118. package/build/core/ocr.js +116 -15
  119. package/build/core/ocr.js.map +1 -1
  120. package/build/core/posthog.d.ts +5 -0
  121. package/build/core/posthog.d.ts.map +1 -0
  122. package/build/core/posthog.js +46 -0
  123. package/build/core/posthog.js.map +1 -0
  124. package/build/core/sdkBridge.d.ts +67 -0
  125. package/build/core/sdkBridge.d.ts.map +1 -0
  126. package/build/core/sdkBridge.js +148 -0
  127. package/build/core/sdkBridge.js.map +1 -0
  128. package/build/core/state.d.ts +25 -5
  129. package/build/core/state.d.ts.map +1 -1
  130. package/build/core/state.js +79 -10
  131. package/build/core/state.js.map +1 -1
  132. package/build/core/telemetry.d.ts +21 -1
  133. package/build/core/telemetry.d.ts.map +1 -1
  134. package/build/core/telemetry.js +166 -10
  135. package/build/core/telemetry.js.map +1 -1
  136. package/build/core/types.d.ts +11 -0
  137. package/build/core/types.d.ts.map +1 -1
  138. package/build/index.js +1490 -324
  139. package/build/index.js.map +1 -1
  140. package/build/pro/screenshot-diff.d.ts +10 -0
  141. package/build/pro/screenshot-diff.d.ts.map +1 -0
  142. package/build/pro/screenshot-diff.js +38 -0
  143. package/build/pro/screenshot-diff.js.map +1 -0
  144. package/build/pro/tap.d.ts +84 -2
  145. package/build/pro/tap.d.ts.map +1 -1
  146. package/build/pro/tap.js +835 -129
  147. package/build/pro/tap.js.map +1 -1
  148. package/build/tools/accountTools.d.ts +44 -0
  149. package/build/tools/accountTools.d.ts.map +1 -0
  150. package/build/tools/accountTools.js +217 -0
  151. package/build/tools/accountTools.js.map +1 -0
  152. package/package.json +8 -7
  153. package/build/core/httpServer.d.ts +0 -14
  154. package/build/core/httpServer.d.ts.map +0 -1
  155. package/build/core/httpServer.js +0 -2459
  156. package/build/core/httpServer.js.map +0 -1
  157. package/build/core/httpServerProcess.d.ts +0 -25
  158. package/build/core/httpServerProcess.d.ts.map +0 -1
  159. package/build/core/httpServerProcess.js +0 -153
  160. package/build/core/httpServerProcess.js.map +0 -1
  161. package/build/core/tap.d.ts +0 -91
  162. package/build/core/tap.d.ts.map +0 -1
  163. package/build/core/tap.js +0 -542
  164. package/build/core/tap.js.map +0 -1
  165. package/build/httpServerStandalone.d.ts +0 -7
  166. package/build/httpServerStandalone.d.ts.map +0 -1
  167. package/build/httpServerStandalone.js +0 -31
  168. package/build/httpServerStandalone.js.map +0 -1
package/LICENSE CHANGED
@@ -4,7 +4,7 @@ The code in this repository is dual-licensed:
4
4
  the MIT License (see below).
5
5
 
6
6
  2. Code in the src/pro/ directory is licensed under the
7
- react-native-ai-debugger Commercial License. A valid license key is
7
+ react-native-ai-devtools Commercial License. A valid license key is
8
8
  required for use. See src/pro/LICENSE for terms.
9
9
 
10
10
  ---
package/README.md CHANGED
@@ -1,54 +1,395 @@
1
- # ⚠️ react-native-ai-debugger has been renamed!
1
+ # React Native AI DevTools
2
2
 
3
- > **CRITICAL NOTICE:** This package has been renamed to `react-native-ai-devtools`.
3
+ An MCP server that gives AI assistants real-time access to a running React Native app. It bridges the gap between static code and live runtime, turning AI assistants from guessing machines into informed development partners.
4
4
 
5
- **This repository and NPM package will no longer receive updates.**
5
+ <p align="center">
6
+ <img src="https://raw.githubusercontent.com/igorzheludkov/react-native-ai-devtools/main/docs/demo/get_logs_demo.gif" alt="React Native AI DevTools demo" width="800" />
7
+ </p>
6
8
 
7
- Please migrate to the new package and repository immediately.
9
+ **Positioning:** This is not a debugger. This is not a QA tool. This is a Runtime AI Bridge — the missing layer between AI coding assistants and live mobile applications. Without it, your AI assistant is blind. With it, the AI sees everything happening in your app in real time.
8
10
 
9
- * **New NPM Package:** [react-native-ai-devtools](https://www.npmjs.com/package/react-native-ai-devtools)
10
- * **GitHub Repository:** [https://github.com/igorzheludkov/react-native-ai-devtools](https://github.com/igorzheludkov/react-native-ai-devtools)
11
11
 
12
- ## Migration Guide for Claude Code / Cursor
12
+ ## Get started
13
13
 
14
- You must update your local MCP configuration files to use the new package name.
14
+ 1. [Setup rn-ai-devtools as an MCP server for your agent of choice](#claude-code-setup)
15
+ 2. [Setup UI automation helpers](#ios-simulator--ui-automation-setup)
15
16
 
16
- ### Claude Code
17
+ ## Feedback & Feature Requests
18
+
19
+ Have an idea or found something that could be better? Head over to [GitHub Discussions](https://github.com/igorzheludkov/react-native-ai-devtools/discussions) to share feedback, request features, and vote on what gets built next.
20
+
21
+
22
+ ## Features
23
+
24
+ ### Runtime Interaction
25
+
26
+ - **Console Log Capture** - Capture `console.log`, `warn`, `error`, `info`, `debug` with filtering and search. Note: on a cold start (first app launch), logs emitted before the MCP server connects are missed — subsequent reloads capture everything. Install the optional [SDK](https://www.npmjs.com/package/react-native-ai-devtools-sdk) to buffer logs from the very first line of app startup
27
+ - **Network Request Tracking** - Monitor HTTP requests/responses with headers, timing, and body content. Like logs, early network requests on cold start may be missed before the connection is established. Install the optional [SDK](https://www.npmjs.com/package/react-native-ai-devtools-sdk) for full capture from app startup including request/response bodies
28
+ - **JavaScript Execution** - Run code directly in your app (REPL-style) and inspect results
29
+ - **Global State Debugging** - Discover and inspect Apollo Client, Redux stores, Expo Router, and custom globals
30
+ - **Bundle Error Detection** - Get Metro bundler errors and compilation issues with file locations
31
+
32
+ ### Device Control
33
+
34
+ - **iOS Simulator** - Screenshots, app management, URL handling, boot/terminate (via simctl)
35
+ - **Android Devices** - Screenshots, app install/launch, package management (via ADB)
36
+ - **Unified Tap** - Single `tap` tool with automatic fallback chain: fiber tree → accessibility → OCR → coordinates. Auto-detects platform, accepts pixels from screenshots. Returns post-tap screenshot and verifies visual change by default
37
+ - **UI Automation** - Swipe, long press, text input, and key events on both platforms
38
+ - **Accessibility Inspection** - Query UI hierarchy to find elements by text, label, or resource ID
39
+ - **OCR Text Extraction** - Extract visible text with tap-ready coordinates via Google Cloud Vision (works on any screen content)
40
+
41
+ ### Multi-Device Debugging
42
+
43
+ - **Connect All Devices** - `scan_metro` automatically discovers and connects to all Bridgeless targets on each Metro port
44
+ - **Device Targeting** - Every tool accepts an optional `device` parameter for targeting specific devices by name (case-insensitive substring match)
45
+ - **Per-Device Buffers** - Logs and network requests are captured separately per device for clean debugging
46
+ - **Cross-Platform Comparison** - Debug iOS and Android side-by-side, comparing logs, network traffic, and component trees
47
+
48
+ ### Under the Hood
49
+
50
+ - **Auto-Discovery** - Scans Metro on ports 8081, 8082, 19000-19002 automatically
51
+ - **Multi-Device Support** - Connects to all Bridgeless targets simultaneously, with per-device log and network buffers
52
+ - **Auto-Reconnection** - Exponential backoff (up to 8 attempts) when connection drops
53
+ - **Efficient Buffering** - Circular buffers: 500 logs, 200 network requests
54
+ - **Platform Support** - Expo SDK 54+ (Bridgeless) and React Native 0.70+ (Hermes)
55
+
56
+ ## Setup
57
+
58
+ ### Claude Code Setup
59
+
60
+ No installation required - Claude Code uses `npx` to run the latest version automatically.
61
+
62
+ #### Global (all projects)
17
63
 
18
- If you installed globally:
19
64
  ```bash
20
- claude mcp remove rn-debugger
21
- claude mcp add rn-debugger --scope user -- npx react-native-ai-devtools
22
- ```
23
-
24
- If you installed per-project, edit your project's `.mcp.json` file:
25
- ```diff
26
- {
27
- "mcpServers": {
28
- "rn-debugger": {
29
- "type": "stdio",
30
- "command": "npx",
31
- - "args": ["react-native-ai-debugger"]
32
- + "args": ["react-native-ai-devtools"]
33
- }
34
- }
35
- }
36
- ```
37
-
38
- ### Cursor
39
-
40
- Edit your global `~/.cursor/mcp.json` or project-level `.cursor/mcp.json` file:
41
- ```diff
42
- {
43
- "mcpServers": {
44
- "rn-debugger": {
45
- "command": "npx",
46
- - "args": ["-y", "react-native-ai-debugger"]
47
- + "args": ["-y", "react-native-ai-devtools"]
48
- }
49
- }
50
- }
51
- ```
52
-
53
- ---
54
- *Created by Ihor Zheludkov*
65
+ claude mcp add rn-ai-devtools --scope user -- npx react-native-ai-devtools
66
+ ```
67
+
68
+ #### Project-specific
69
+
70
+ ```bash
71
+ claude mcp add rn-ai-devtools --scope project -- npx react-native-ai-devtools
72
+ ```
73
+
74
+ #### Manual Configuration
75
+
76
+ Add to `~/.claude.json` (user scope) or `.mcp.json` (project scope):
77
+
78
+ ```json
79
+ {
80
+ "mcpServers": {
81
+ "rn-ai-devtools": {
82
+ "type": "stdio",
83
+ "command": "npx",
84
+ "args": ["react-native-ai-devtools"]
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ Restart Claude Code after adding the configuration.
91
+
92
+ ### VS Code Copilot Setup
93
+
94
+ Requires VS Code 1.102+ with Copilot ([docs](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)).
95
+
96
+ **Via Command Palette**: `Cmd+Shift+P` → "MCP: Add Server"
97
+
98
+ **Manual config** - add to `.vscode/mcp.json`:
99
+
100
+ ```json
101
+ {
102
+ "servers": {
103
+ "rn-ai-devtools": {
104
+ "type": "stdio",
105
+ "command": "npx",
106
+ "args": ["-y", "react-native-ai-devtools"]
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ ### Cursor Setup
113
+
114
+ [Docs](https://docs.cursor.com/context/model-context-protocol)
115
+
116
+ **Via Command Palette**: `Cmd+Shift+P` → "View: Open MCP Settings"
117
+
118
+ **Manual config** - add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
119
+
120
+ ```json
121
+ {
122
+ "mcpServers": {
123
+ "rn-ai-devtools": {
124
+ "command": "npx",
125
+ "args": ["-y", "react-native-ai-devtools"]
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Android
132
+
133
+ Android works out of the box — all device control tools use ADB, which ships with Android Studio. Verify it's available:
134
+
135
+ ```bash
136
+ adb devices
137
+ ```
138
+
139
+ ### iOS Simulator — UI Automation Setup
140
+
141
+ iOS UI automation tools (tap, swipe, text input, accessibility queries) require a UI driver. Install one of the following:
142
+
143
+ **Option A: AXe CLI (experimental)**
144
+
145
+ [AXe](https://github.com/cameroncooke/AXe) is a standalone CLI for iOS simulator automation. No daemon required — single binary, simple setup.
146
+
147
+ ```bash
148
+ brew install cameroncooke/axe/axe
149
+ ```
150
+
151
+ Verify: `axe --version`
152
+
153
+ Add `env` to your MCP server configuration:
154
+
155
+ ```json
156
+ {
157
+ "mcpServers": {
158
+ "rn-ai-devtools": {
159
+ "type": "stdio",
160
+ "command": "npx",
161
+ "args": ["react-native-ai-devtools"],
162
+ "env": { "IOS_DRIVER": "axe" }
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ > **Note:** AXe text input only supports US keyboard layout characters.
169
+
170
+ **Option B: IDB**
171
+
172
+ [IDB (iOS Development Bridge)](https://github.com/facebook/idb) is a tool built by Meta for automating iOS Simulators. Requires a background daemon.
173
+
174
+ ```bash
175
+ brew install idb-companion
176
+ ```
177
+
178
+ Verify: `idb_companion --list 1`
179
+
180
+ IDB is the default driver — no `IOS_DRIVER` env var needed.
181
+
182
+ **What works without a UI driver:**
183
+
184
+ | Capability | Without IDB/AXe | With IDB/AXe |
185
+ | --------------------------------- | --------------- | ------------ |
186
+ | Screenshots | Yes (simctl) | Yes |
187
+ | App install/launch/terminate | Yes (simctl) | Yes |
188
+ | URL opening | Yes (simctl) | Yes |
189
+ | Boot simulator | Yes (simctl) | Yes |
190
+ | **Tap / swipe / gestures** | **No** | Yes |
191
+ | **Text input** | **No** | Yes |
192
+ | **Accessibility tree queries** | **No** | Yes |
193
+ | **Element finding / waiting** | **No** | Yes |
194
+ | **Hardware buttons (Home, Lock)** | **No** | Yes |
195
+
196
+ > **Troubleshooting**: If you see errors like `"IDB is not installed"` or `"AXe is not installed"` in tap results, install the appropriate driver with the commands above and retry.
197
+
198
+ ## Requirements
199
+
200
+ - Node.js 18+
201
+ - React Native app running with Metro bundler
202
+ - **iOS UI automation**: [Facebook IDB](https://fbidb.io/) (`brew install idb-companion`) or [AXe CLI](https://github.com/cameroncooke/AXe) (`brew install cameroncooke/axe/axe`) — required for tap, swipe, text input, accessibility on iOS Simulator
203
+ - **Optional for offline OCR fallback**: Python 3.6+ (only needed when cloud OCR is unavailable, see [OCR Setup](#ocr-text-extraction))
204
+
205
+ ## Claude Code Skills
206
+
207
+ Pre-built skills for common debugging workflows — session setup, log inspection, network debugging, and more. See the [skills guide](docs/skills.md) for the full list and installation instructions.
208
+
209
+ ## Available Tools
210
+
211
+ See the [full tool reference](docs/tools.md) for all tools with descriptions. Key tools:
212
+
213
+ | Tool | Description |
214
+ | --------------------------------------- | ---------------------------------------------------------------------------------------- |
215
+ | `scan_metro` | **Start here** — scan for Metro servers and auto-connect |
216
+ | `get_logs` / `search_logs` | Capture and search console logs with filtering and summaries |
217
+ | `get_network_requests` | Monitor HTTP requests with method/status filtering |
218
+ | `get_screen_layout` | Screen map of visible components with positions, sizes, and text content |
219
+ | `tap` | **Unified tap** — auto-detects platform, tries fiber → accessibility → OCR → coordinates |
220
+ | `execute_in_app` | Run JS expressions in the app runtime (REPL-style) |
221
+ | `ios_screenshot` / `android_screenshot` | Take device screenshots |
222
+
223
+ ## Usage
224
+
225
+ 1. Start your React Native app:
226
+
227
+ ```bash
228
+ npm start
229
+ # or
230
+ expo start
231
+ ```
232
+
233
+ 2. In Claude Code, scan for Metro:
234
+
235
+ ```
236
+ Use scan_metro to find and connect to Metro
237
+ ```
238
+
239
+ 3. Get logs:
240
+ ```
241
+ Use get_logs to see recent console output
242
+ ```
243
+
244
+ ## Detailed Guides
245
+
246
+ | Guide | Description |
247
+ | ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
248
+ | [Console Logging](docs/logging.md) | `get_logs` parameters, filtering, summary mode, TONL format, token optimization |
249
+ | [Network Tracking](docs/network.md) | SDK setup for full capture, filtering, request details, statistics |
250
+ | [App Inspection](docs/app-inspection.md) | Debug globals (Apollo, Redux, Expo Router), `execute_in_app`, limitations |
251
+ | [Layout & Component Inspection](docs/layout-inspection.md) | `get_screen_layout`, component tree, `inspect_at_point`, `find_components` |
252
+ | [Device Interaction](docs/device-interaction.md) | Unified `tap`, platform-specific gestures, text input, key events |
253
+ | [OCR Text Extraction](docs/ocr.md) | Cloud Vision OCR, offline fallback, language config, workflows |
254
+ | [Claude Code Skills](docs/skills.md) | Pre-built skills for session setup, debugging, and automation |
255
+ | [Full Tool Reference](docs/tools.md) | Complete list of all 40+ tools with descriptions |
256
+
257
+ ## Supported React Native Versions
258
+
259
+ | Version | Architecture | Engine | Status |
260
+ | -------------- | --------------------- | ------------ | ------------------------------------------------ |
261
+ | Expo SDK 54+ | Bridgeless (New Arch) | Hermes | ✓ Fully supported |
262
+ | RN 0.76+ | Bridgeless (New Arch) | Hermes | ✓ Fully supported |
263
+ | RN 0.73 - 0.75 | Bridge (Old Arch) | Hermes | ✓ Fully supported (best network capture via CDP) |
264
+ | RN 0.70 - 0.72 | Bridge (Old Arch) | Hermes / JSC | ✓ Supported |
265
+ | RN < 0.70 | Bridge | JSC | Not tested |
266
+
267
+ ## How It Works
268
+
269
+ 1. Fetches device list from Metro's `/json` endpoint
270
+ 2. Connects to the main JS runtime via CDP (Chrome DevTools Protocol) WebSocket
271
+ 3. Enables `Runtime.enable` to receive `Runtime.consoleAPICalled` events
272
+ 4. Network capture via two paths:
273
+ - **With SDK**: Reads from the SDK's in-app buffer via `Runtime.evaluate` — captures all requests from startup with full headers and bodies, including cold-start events that CDP would miss
274
+ - **Without SDK**: Enables CDP `Network.enable` (on supported targets) or injects a JS fetch interceptor as fallback. On cold start, events emitted before the CDP connection is established are lost; subsequent reloads capture everything
275
+ 5. Stores logs and network requests in circular buffers for retrieval
276
+
277
+ ## Connection Management
278
+
279
+ ### Explicit Connection
280
+
281
+ The server does **not** auto-connect on startup. Call `scan_metro` to discover and connect to Metro servers. This prevents multiple MCP server instances (from parallel agent sessions) from competing for the single CDP WebSocket slot, which would cause connection thrashing and dropped tools.
282
+
283
+ ### Graceful Shutdown
284
+
285
+ When the MCP server process is terminated (`SIGINT`/`SIGTERM`), it closes all CDP WebSocket connections and cancels reconnection timers, freeing the CDP slot immediately for other sessions.
286
+
287
+ ### Reconnection on Disconnect
288
+
289
+ When the connection to Metro is lost (e.g., app restart, Metro restart, or network issues):
290
+
291
+ 1. The server automatically attempts to reconnect
292
+ 2. Uses exponential backoff: 500ms, 1s, 2s, 4s, 8s (up to 8 attempts)
293
+ 3. Re-fetches device list to handle new WebSocket URLs
294
+ 4. Preserves existing log and network buffers
295
+
296
+ ### Connection Gap Warnings
297
+
298
+ If there was a recent disconnect, `get_logs` and `get_network_requests` will include a warning:
299
+
300
+ ```
301
+ [WARNING] Connection was restored 5s ago. Some logs may have been missed during the 3s gap.
302
+ ```
303
+
304
+ ### Monitor Connection Health
305
+
306
+ Use `get_connection_status` to see detailed connection information:
307
+
308
+ ```
309
+ === Connection Status ===
310
+
311
+ --- React Native (Port 8081) ---
312
+ Status: CONNECTED
313
+ Connected since: 2:45:30 PM
314
+ Uptime: 5m 23s
315
+ Recent gaps: 1
316
+ - 2:43:15 PM (2s): Connection closed
317
+ ```
318
+
319
+ ## Troubleshooting
320
+
321
+ ### No devices found
322
+
323
+ - Make sure the app is running on a simulator/device
324
+ - Check that Metro bundler is running (`npm start`)
325
+
326
+ ### Wrong device connected
327
+
328
+ The server prioritizes devices in this order:
329
+
330
+ 1. React Native Bridgeless (SDK 54+)
331
+ 2. Hermes React Native
332
+ 3. Any React Native (excluding Reanimated/Experimental)
333
+
334
+ ### Logs not appearing
335
+
336
+ - Ensure the app is actively running (not just Metro)
337
+ - Try `clear_logs` then trigger some actions in the app
338
+ - Check `get_apps` to verify connection status
339
+ - **On cold start (first launch):** The CDP connection is established after the app's early initialization code has already run, so startup logs and network requests are missed. Once connected, use `reload_app` — the subsequent reload captures everything from the beginning because the connection is already in place. To capture startup events on every launch, install the optional [SDK](https://www.npmjs.com/package/react-native-ai-devtools-sdk)
340
+
341
+ ## Telemetry & Data Collection
342
+
343
+ This package collects anonymous usage telemetry to help improve the product. No personal information is collected.
344
+
345
+ ### What is collected
346
+
347
+ | Data | Purpose |
348
+ | ----------------- | ---------------------------------------- |
349
+ | Tool names | Which MCP tools are used most |
350
+ | Success/failure | Error rates for reliability improvements |
351
+ | Duration (ms) | Performance monitoring |
352
+ | Session start/end | Retention analysis |
353
+ | Platform | macOS/Linux/Windows distribution |
354
+ | Server version | Adoption of new versions |
355
+
356
+ **Not collected**: No file paths, code content, network data, or personally identifiable information.
357
+
358
+ ### Auto-registration
359
+
360
+ On first tool use, the package automatically registers your installation with our backend. No account or login is required — the Tool works fully out of the box.
361
+
362
+ **Why we do this:** The product roadmap includes features that build on installation identity — project memory (your AI assistant gets smarter with every session by remembering navigation maps, element signatures, and debug patterns), cloud sync across machines, team collaboration with shared debugging context, and a Pro dashboard for managing installations and subscriptions. Auto-registration lays the groundwork so these features work seamlessly when they ship, without requiring a disruptive setup step later.
363
+
364
+ **What is sent:**
365
+
366
+ - A random installation ID (UUID)
367
+ - A device fingerprint (one-way SHA-256 hash — cannot be reversed to recover its components)
368
+ - Platform, hostname, OS version, and server version
369
+
370
+ **What is NOT sent:** No source code, file paths, console logs, network data, component names, or any content from your app. The fingerprint exists solely to prevent installation hijacking — it ties your installation to your physical machine so no one else can claim it.
371
+
372
+ Registration is fire-and-forget — it never blocks your work, fails silently if the network is unavailable, and can be disabled entirely (see Opt-out below). See [PRIVACY.md](./PRIVACY.md) for full details on data handling, storage, and your rights.
373
+
374
+ ### Opt-out
375
+
376
+ To disable telemetry and auto-registration, add `RN_DEBUGGER_TELEMETRY` to the `env` field in your MCP server configuration:
377
+
378
+ ```json
379
+ {
380
+ "mcpServers": {
381
+ "rn-ai-devtools": {
382
+ "type": "stdio",
383
+ "command": "npx",
384
+ "args": ["react-native-ai-devtools"],
385
+ "env": { "RN_DEBUGGER_TELEMETRY": "false" }
386
+ }
387
+ }
388
+ }
389
+ ```
390
+
391
+ All debugging tools work normally with telemetry disabled. For the complete privacy policy, see [PRIVACY.md](./PRIVACY.md).
392
+
393
+ ## License
394
+
395
+ MIT
@@ -0,0 +1,36 @@
1
+ import type { TapResult } from "../../pro/tap.js";
2
+ export type Platform = "ios" | "android";
3
+ /**
4
+ * Detect which platform is available by checking for booted simulators/emulators.
5
+ * Returns the first available platform.
6
+ */
7
+ export declare function detectPlatform(): Promise<Platform>;
8
+ /**
9
+ * Connect to Metro and return the platform of the connected device.
10
+ */
11
+ export declare function connectToMetro(): Promise<Platform>;
12
+ /**
13
+ * Disconnect all apps and clean up state.
14
+ */
15
+ export declare function disconnectAll(): Promise<void>;
16
+ /**
17
+ * Read the test app's global state to verify a tap was registered.
18
+ * Returns { tapCount, lastTapped } or null if not available.
19
+ */
20
+ export declare function readTestState(): Promise<{
21
+ tapCount: number;
22
+ lastTapped: string;
23
+ } | null>;
24
+ /**
25
+ * Reset the test app's tap counter and last-tapped state.
26
+ */
27
+ export declare function resetTestState(): Promise<void>;
28
+ /**
29
+ * Assert that a tap result succeeded and the test app registered the tap on the expected element.
30
+ */
31
+ export declare function assertTapWorked(result: TapResult, expectedElement: string): Promise<void>;
32
+ /**
33
+ * Wait for a short duration (ms) to let UI settle.
34
+ */
35
+ export declare function sleep(ms: number): Promise<void>;
36
+ //# sourceMappingURL=tap-test-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tap-test-helpers.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/tap-test-helpers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AAEzC;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,CAYxD;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,CA+BxD;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAmBnD;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAU9F;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpD;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAW/F;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
@@ -0,0 +1,130 @@
1
+ // src/__tests__/helpers/tap-test-helpers.ts
2
+ import { scanMetroPorts, fetchDevices, selectMainDevice } from "../../core/metro.js";
3
+ import { connectToDevice } from "../../core/connection.js";
4
+ import { executeInApp } from "../../core/executor.js";
5
+ import { connectedApps, pendingExecutions } from "../../core/state.js";
6
+ import { cancelAllReconnectionTimers, clearAllConnectionState } from "../../core/connectionState.js";
7
+ /**
8
+ * Detect which platform is available by checking for booted simulators/emulators.
9
+ * Returns the first available platform.
10
+ */
11
+ export async function detectPlatform() {
12
+ const { execSync } = await import("child_process");
13
+ try {
14
+ const result = execSync("xcrun simctl list devices booted 2>/dev/null", { encoding: "utf-8" });
15
+ if (result.includes("Booted"))
16
+ return "ios";
17
+ }
18
+ catch { /* no iOS */ }
19
+ try {
20
+ const result = execSync("adb devices 2>/dev/null", { encoding: "utf-8" });
21
+ const lines = result.trim().split("\n").filter(l => l.includes("device") && !l.includes("List"));
22
+ if (lines.length > 0)
23
+ return "android";
24
+ }
25
+ catch { /* no Android */ }
26
+ throw new Error("No booted iOS simulator or Android emulator found");
27
+ }
28
+ /**
29
+ * Connect to Metro and return the platform of the connected device.
30
+ */
31
+ export async function connectToMetro() {
32
+ const ports = await scanMetroPorts();
33
+ if (ports.length === 0) {
34
+ throw new Error("No Metro bundler found. Start Metro with the test app first.");
35
+ }
36
+ for (const port of ports) {
37
+ const devices = await fetchDevices(port);
38
+ const main = selectMainDevice(devices);
39
+ if (main) {
40
+ await connectToDevice(main, port, {
41
+ reconnectionConfig: {
42
+ enabled: false,
43
+ maxAttempts: 0,
44
+ initialDelayMs: 0,
45
+ maxDelayMs: 0,
46
+ backoffMultiplier: 1,
47
+ },
48
+ });
49
+ // connectToDevice resolves with a message string, not the map key.
50
+ // Wait briefly for the async platform detection (findSimulatorByName)
51
+ // to complete, then read the first connected app's platform.
52
+ await new Promise((resolve) => setTimeout(resolve, 2000));
53
+ for (const app of connectedApps.values()) {
54
+ if (app.platform)
55
+ return app.platform;
56
+ }
57
+ }
58
+ }
59
+ throw new Error("Connected to Metro but could not determine platform");
60
+ }
61
+ /**
62
+ * Disconnect all apps and clean up state.
63
+ */
64
+ export async function disconnectAll() {
65
+ const closePromises = [];
66
+ for (const [key, app] of connectedApps.entries()) {
67
+ closePromises.push(new Promise((resolve) => {
68
+ if (app.ws.readyState === app.ws.CLOSED) {
69
+ resolve();
70
+ }
71
+ else {
72
+ app.ws.on("close", () => resolve());
73
+ try {
74
+ app.ws.close();
75
+ }
76
+ catch {
77
+ resolve();
78
+ }
79
+ }
80
+ }));
81
+ connectedApps.delete(key);
82
+ }
83
+ await Promise.all(closePromises);
84
+ pendingExecutions.clear();
85
+ cancelAllReconnectionTimers();
86
+ clearAllConnectionState();
87
+ }
88
+ /**
89
+ * Read the test app's global state to verify a tap was registered.
90
+ * Returns { tapCount, lastTapped } or null if not available.
91
+ */
92
+ export async function readTestState() {
93
+ const result = await executeInApp("JSON.stringify({ tapCount: global.__TEST_STATE__?.tapCount ?? -1, lastTapped: global.__TEST_STATE__?.lastTapped ?? 'unknown' })");
94
+ if (!result.success || !result.result)
95
+ return null;
96
+ try {
97
+ return JSON.parse(result.result);
98
+ }
99
+ catch {
100
+ return null;
101
+ }
102
+ }
103
+ /**
104
+ * Reset the test app's tap counter and last-tapped state.
105
+ */
106
+ export async function resetTestState() {
107
+ await executeInApp("global.__TEST_STATE__?.reset?.()");
108
+ }
109
+ /**
110
+ * Assert that a tap result succeeded and the test app registered the tap on the expected element.
111
+ */
112
+ export async function assertTapWorked(result, expectedElement) {
113
+ if (!result.success) {
114
+ throw new Error(`Tap failed: ${result.error ?? result.suggestion ?? "unknown reason"}`);
115
+ }
116
+ const state = await readTestState();
117
+ if (!state) {
118
+ throw new Error("Could not read test app state via execute_in_app");
119
+ }
120
+ if (state.lastTapped !== expectedElement) {
121
+ throw new Error(`Expected lastTapped="${expectedElement}" but got "${state.lastTapped}"`);
122
+ }
123
+ }
124
+ /**
125
+ * Wait for a short duration (ms) to let UI settle.
126
+ */
127
+ export function sleep(ms) {
128
+ return new Promise((resolve) => setTimeout(resolve, ms));
129
+ }
130
+ //# sourceMappingURL=tap-test-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tap-test-helpers.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/tap-test-helpers.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAKrG;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAChC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IACnD,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,8CAA8C,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/F,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,OAAO,KAAK,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IACxB,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,QAAQ,C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