react-native-ai-debugger 1.0.45 → 1.0.46
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/README.md +8 -0
- package/build/core/guides.d.ts +14 -0
- package/build/core/guides.d.ts.map +1 -0
- package/build/core/guides.js +240 -0
- package/build/core/guides.js.map +1 -0
- package/build/index.js +162 -235
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -158,6 +158,14 @@ Requires VS Code 1.102+ with Copilot ([docs](https://code.visualstudio.com/docs/
|
|
|
158
158
|
|
|
159
159
|
## Available Tools
|
|
160
160
|
|
|
161
|
+
### Usage Guide
|
|
162
|
+
|
|
163
|
+
| Tool | Description |
|
|
164
|
+
| ----------------- | --------------------------------------------------------------------------- |
|
|
165
|
+
| `get_usage_guide` | Get recommended workflows for all tools. Call without params for overview, with a topic (`setup`, `inspect`, `layout`, `interact`, `logs`, `network`, `state`, `bundle`) for the full guide |
|
|
166
|
+
|
|
167
|
+
The server also sends instructions on connection, so MCP clients automatically learn about `get_usage_guide`.
|
|
168
|
+
|
|
161
169
|
### Connection & Logs
|
|
162
170
|
|
|
163
171
|
| Tool | Description |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage guides for MCP tools.
|
|
3
|
+
* Returned by the get_usage_guide tool to help agents understand recommended workflows.
|
|
4
|
+
*/
|
|
5
|
+
export interface Guide {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
summary: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function getGuideOverview(): string;
|
|
12
|
+
export declare function getGuideByTopic(topic: string): string | null;
|
|
13
|
+
export declare function getAvailableTopics(): string[];
|
|
14
|
+
//# sourceMappingURL=guides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guides.d.ts","sourceRoot":"","sources":["../../src/core/guides.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,KAAK;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB;AA4ND,wBAAgB,gBAAgB,IAAI,MAAM,CAUzC;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI5D;AAED,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAE7C"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage guides for MCP tools.
|
|
3
|
+
* Returned by the get_usage_guide tool to help agents understand recommended workflows.
|
|
4
|
+
*/
|
|
5
|
+
const guides = [
|
|
6
|
+
{
|
|
7
|
+
id: "setup",
|
|
8
|
+
title: "Session Setup",
|
|
9
|
+
summary: "Connect to a running React Native app via Metro bundler",
|
|
10
|
+
content: `# Session Setup
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
1. scan_metro — auto-discovers Metro on common ports (8081, 8082, 19000-19002) and connects
|
|
14
|
+
2. get_apps — verify the app appears in connected list
|
|
15
|
+
3. get_connection_status — check connection health
|
|
16
|
+
|
|
17
|
+
## If No App Running
|
|
18
|
+
- list_ios_simulators / list_android_devices — find available devices
|
|
19
|
+
- ios_boot_simulator — boot an iOS simulator if needed
|
|
20
|
+
- ios_launch_app / android_launch_app — launch the app
|
|
21
|
+
- Wait 2-3 seconds, then scan_metro
|
|
22
|
+
|
|
23
|
+
## Key Tools
|
|
24
|
+
- scan_metro: auto-discover and connect (preferred)
|
|
25
|
+
- connect_metro: connect to specific port (when you know it)
|
|
26
|
+
- ensure_connection: health check with healthCheck=true
|
|
27
|
+
- get_connection_status: check uptime and gaps`
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "inspect",
|
|
31
|
+
title: "Component Inspection",
|
|
32
|
+
summary: "Identify which React component renders a UI element, get hierarchy and file paths",
|
|
33
|
+
content: `# Component Inspection
|
|
34
|
+
|
|
35
|
+
## Recommended Workflow: Identify a Component on Screen
|
|
36
|
+
1. Take a screenshot (ios_screenshot / android_screenshot) or use ocr_screenshot
|
|
37
|
+
2. Identify the target element visually, estimate its coordinates
|
|
38
|
+
3. Convert screenshot pixels to points: divide by device pixel ratio (e.g. pixel_x / 3 for @3x iPhones)
|
|
39
|
+
4. Call get_inspector_selection(x, y) — returns clean component hierarchy with file paths
|
|
40
|
+
Example output: HomeScreen(./(tabs)/index.tsx) > SneakerCard > PulseActionButton
|
|
41
|
+
5. If you also need layout details, call inspect_at_point(x, y) on the same coordinates
|
|
42
|
+
|
|
43
|
+
## When to Use Which Tool
|
|
44
|
+
- get_inspector_selection(x, y) — finding component NAMES and screen structure. Returns hierarchy with source file paths. Auto-enables the Element Inspector, taps at coordinates, reads the result.
|
|
45
|
+
- inspect_at_point(x, y) — layout debugging. Returns component props, measured frame (position/size in dp), and path. Skips RN primitives and common library wrappers (Expo, SVG, gesture handlers).
|
|
46
|
+
- find_components(pattern) — search for components by name regex across the entire fiber tree.
|
|
47
|
+
- get_component_tree — full tree overview. Use focusedOnly=true and structureOnly=true for a compact view.
|
|
48
|
+
- inspect_component(name) — deep dive into a specific component's props, state, and hooks.
|
|
49
|
+
|
|
50
|
+
## Tips
|
|
51
|
+
- Both inspect_at_point and get_inspector_selection work on Paper and Fabric (New Architecture)
|
|
52
|
+
- get_inspector_selection returns the most complete hierarchy — prefer it for finding component names
|
|
53
|
+
- toggle_element_inspector is rarely needed — get_inspector_selection auto-enables the inspector`
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "layout",
|
|
57
|
+
title: "Layout Debugging",
|
|
58
|
+
summary: "Capture screenshots, verify UI changes, inspect layout frames and styles",
|
|
59
|
+
content: `# Layout Debugging
|
|
60
|
+
|
|
61
|
+
## Verify UI Changes
|
|
62
|
+
1. ios_screenshot / android_screenshot — capture current screen
|
|
63
|
+
2. Compare visually against expected result or Figma design
|
|
64
|
+
3. If an issue is spotted, drill down with inspection tools
|
|
65
|
+
|
|
66
|
+
## Inspect Layout at a Point
|
|
67
|
+
1. inspect_at_point(x, y) — returns component frame (position, size in dp), props, and styles
|
|
68
|
+
2. Use includeProps=true (default) to see style objects, colors, flex properties
|
|
69
|
+
3. Use includeFrame=true (default) to see exact position and dimensions
|
|
70
|
+
|
|
71
|
+
## Identify Component to Fix
|
|
72
|
+
1. get_inspector_selection(x, y) — returns hierarchy with file paths
|
|
73
|
+
Example: HomeScreen(./(tabs)/index.tsx) > SneakerCard > PulseActionButton
|
|
74
|
+
2. Use the file path to find and edit the source code
|
|
75
|
+
|
|
76
|
+
## Full Screen Layout
|
|
77
|
+
- get_screen_layout — full layout data for all components
|
|
78
|
+
- Use componentsOnly=true to hide host components (View, Text) and see only custom components
|
|
79
|
+
- find_components with includeLayout=true for targeted layout info
|
|
80
|
+
|
|
81
|
+
## Key Tools
|
|
82
|
+
- ios_screenshot / android_screenshot: visual capture
|
|
83
|
+
- ocr_screenshot: screenshot with text recognition and tap coordinates
|
|
84
|
+
- inspect_at_point: frame measurements, props, styles
|
|
85
|
+
- get_inspector_selection: component names and source files`
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "interact",
|
|
89
|
+
title: "Device Interaction",
|
|
90
|
+
summary: "Tap buttons, swipe, type text, and navigate the app UI",
|
|
91
|
+
content: `# Device Interaction
|
|
92
|
+
|
|
93
|
+
## Pressing Buttons (Fallback Chain)
|
|
94
|
+
1. press_element(text="Login") — try text match first (preferred, works via JS fiber tree)
|
|
95
|
+
2. If text fails (icon-only buttons): use find_components to discover names, then press_element(component="ButtonName", index=N)
|
|
96
|
+
3. If press_element fails + has visible text: ocr_screenshot -> ios_tap/android_tap with coordinates
|
|
97
|
+
4. If press_element fails + no visible text: ios_tap_element/android_tap_element (accessibility tree)
|
|
98
|
+
5. Coordinate-based ios_tap/android_tap as last resort
|
|
99
|
+
|
|
100
|
+
## Non-ASCII Text (Cyrillic, CJK, Arabic)
|
|
101
|
+
press_element(text=...) only supports ASCII (Hermes limitation). Use testID or component params instead, or fall back to ocr_screenshot -> coordinate tap.
|
|
102
|
+
|
|
103
|
+
## Other Interactions
|
|
104
|
+
- ios_swipe / android_swipe: swipe/scroll with start/end coordinates
|
|
105
|
+
- ios_input_text / android_input_text: type text (tap input field first)
|
|
106
|
+
- ios_button / android_key_event: hardware buttons (HOME, BACK, etc.)
|
|
107
|
+
- ios_open_url: deep links and universal links
|
|
108
|
+
|
|
109
|
+
## After Interactions
|
|
110
|
+
- ios_wait_for_element / android_wait_for_element: wait for UI to update
|
|
111
|
+
- Take a screenshot to verify the result`
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "logs",
|
|
115
|
+
title: "Debug Logs",
|
|
116
|
+
summary: "Read console logs, errors, and warnings from the running app",
|
|
117
|
+
content: `# Debug Logs
|
|
118
|
+
|
|
119
|
+
## Workflow
|
|
120
|
+
1. get_logs with summary=true — get counts by level and last 5 messages (overview first)
|
|
121
|
+
2. Based on what you see:
|
|
122
|
+
- get_logs with level="error" — errors only
|
|
123
|
+
- search_logs with text="..." — find specific messages
|
|
124
|
+
- get_logs with verbose=true and maxLogs=10 — full details for recent entries
|
|
125
|
+
3. clear_logs — reset buffer, then re-capture after a specific action
|
|
126
|
+
|
|
127
|
+
## Key Tools
|
|
128
|
+
- get_logs: retrieve logs with filtering (level, maxLogs, summary, verbose, startFromText)
|
|
129
|
+
- search_logs: text search across all captured logs
|
|
130
|
+
- clear_logs: reset the log buffer
|
|
131
|
+
|
|
132
|
+
## Tips
|
|
133
|
+
- Always start with summary=true to avoid token overload
|
|
134
|
+
- Use verbose=true with low maxLogs for full error details
|
|
135
|
+
- Use startFromText to begin reading from a specific point`
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: "network",
|
|
139
|
+
title: "Network Inspection",
|
|
140
|
+
summary: "Debug API calls, check request/response data, find failed requests",
|
|
141
|
+
content: `# Network Inspection
|
|
142
|
+
|
|
143
|
+
## Workflow
|
|
144
|
+
1. get_network_stats or get_network_requests with summary=true — overview of all requests
|
|
145
|
+
2. Filter by what you need:
|
|
146
|
+
- get_network_requests with urlPattern, method, or status filters
|
|
147
|
+
- search_network with urlPattern for text search
|
|
148
|
+
3. get_request_details with requestId — full headers, body, timing for a specific request
|
|
149
|
+
4. clear_network — reset buffer, then re-capture
|
|
150
|
+
|
|
151
|
+
## Key Tools
|
|
152
|
+
- get_network_requests: list requests with filters (urlPattern, method, status, summary)
|
|
153
|
+
- get_network_stats: quick stats overview
|
|
154
|
+
- search_network: search by URL pattern
|
|
155
|
+
- get_request_details: full request/response details (use verbose=true for large payloads)
|
|
156
|
+
- clear_network: reset the request buffer
|
|
157
|
+
|
|
158
|
+
## Tips
|
|
159
|
+
- Start with summary=true to see the request landscape
|
|
160
|
+
- Use get_request_details with verbose=true for full JSON payloads
|
|
161
|
+
- Increase maxBodyLength for large request/response bodies`
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: "state",
|
|
165
|
+
title: "App State",
|
|
166
|
+
summary: "Inspect Redux store, global variables, and execute JavaScript in the app",
|
|
167
|
+
content: `# App State
|
|
168
|
+
|
|
169
|
+
## Workflow
|
|
170
|
+
1. list_debug_globals — discover what's exposed (Redux store, navigation refs, action creators)
|
|
171
|
+
2. inspect_global with objectName — see properties and methods before calling them
|
|
172
|
+
3. execute_in_app — run JavaScript expressions in the app context
|
|
173
|
+
|
|
174
|
+
## Common Patterns
|
|
175
|
+
- Read Redux: execute_in_app("globalThis.__REDUX_STORE__.getState().sliceName")
|
|
176
|
+
- Dispatch action: execute_in_app("globalThis.__dispatch__(globalThis.__REDUX_ACTIONS__.slice.action(args))")
|
|
177
|
+
- Navigate: execute_in_app("globalThis.__navigate__('ScreenName')")
|
|
178
|
+
- Current route: execute_in_app("globalThis.__getCurrentRoute__()")
|
|
179
|
+
|
|
180
|
+
## Hermes Limitations
|
|
181
|
+
- NO require() or import — only pre-existing globals
|
|
182
|
+
- NO async/await — use simple expressions or .then() chains
|
|
183
|
+
- NO emoji or non-ASCII in string literals
|
|
184
|
+
- Use globalThis instead of global
|
|
185
|
+
|
|
186
|
+
## Tips
|
|
187
|
+
- Always inspect_global before calling methods on unfamiliar objects
|
|
188
|
+
- Use verbose=true with caution — Redux stores can return 10KB+
|
|
189
|
+
- Set higher maxResultLength when default 2000 chars isn't enough`
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: "bundle",
|
|
193
|
+
title: "Bundle Health",
|
|
194
|
+
summary: "Check Metro bundler status, fix compilation errors, reload the app",
|
|
195
|
+
content: `# Bundle Health
|
|
196
|
+
|
|
197
|
+
## Workflow
|
|
198
|
+
1. get_bundle_status — check if Metro is running and its build state
|
|
199
|
+
2. get_bundle_errors — check for compilation/bundling errors
|
|
200
|
+
3. Fix errors in code
|
|
201
|
+
4. clear_bundle_errors — clear the error buffer
|
|
202
|
+
5. reload_app — trigger full JS bundle reload (only if needed)
|
|
203
|
+
|
|
204
|
+
## When to Reload
|
|
205
|
+
React Native has Fast Refresh by default. Only reload_app when:
|
|
206
|
+
- Changes aren't appearing after a few seconds
|
|
207
|
+
- App is in a broken/error state
|
|
208
|
+
- Need to reset full app state (navigation, context)
|
|
209
|
+
- Made changes to native code or config files
|
|
210
|
+
|
|
211
|
+
## Red Screen Errors
|
|
212
|
+
If no errors captured via CDP, use get_bundle_errors with platform="ios" or "android" — this triggers screenshot+OCR fallback to read errors from the device screen.
|
|
213
|
+
|
|
214
|
+
## Key Tools
|
|
215
|
+
- get_bundle_status: Metro health check
|
|
216
|
+
- get_bundle_errors: compilation errors
|
|
217
|
+
- clear_bundle_errors: clear error buffer
|
|
218
|
+
- reload_app: full JS bundle reload
|
|
219
|
+
- ensure_connection: verify connection with healthCheck=true`
|
|
220
|
+
}
|
|
221
|
+
];
|
|
222
|
+
export function getGuideOverview() {
|
|
223
|
+
const lines = ["Available usage guides:\n"];
|
|
224
|
+
for (const guide of guides) {
|
|
225
|
+
lines.push(` ${guide.id} — ${guide.summary}`);
|
|
226
|
+
}
|
|
227
|
+
lines.push("\nCall get_usage_guide with a topic parameter for the full guide.");
|
|
228
|
+
lines.push("\nQuick start: scan_metro → get_logs / search_logs (console debugging) → ios_screenshot → get_inspector_selection(x, y) (identify components)");
|
|
229
|
+
return lines.join("\n");
|
|
230
|
+
}
|
|
231
|
+
export function getGuideByTopic(topic) {
|
|
232
|
+
const guide = guides.find((g) => g.id === topic.toLowerCase());
|
|
233
|
+
if (!guide)
|
|
234
|
+
return null;
|
|
235
|
+
return guide.content;
|
|
236
|
+
}
|
|
237
|
+
export function getAvailableTopics() {
|
|
238
|
+
return guides.map((g) => g.id);
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=guides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guides.js","sourceRoot":"","sources":["../../src/core/guides.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,MAAM,MAAM,GAAY;IACpB;QACI,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,eAAe;QACtB,OAAO,EAAE,yDAAyD;QAClE,OAAO,EAAE;;;;;;;;;;;;;;;;;+CAiB8B;KAC1C;IACD;QACI,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,sBAAsB;QAC7B,OAAO,EAAE,mFAAmF;QAC5F,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;iGAoBgF;KAC5F;IACD;QACI,EAAE,EAAE,QAAQ;QACZ,KAAK,EAAE,kBAAkB;QACzB,OAAO,EAAE,0EAA0E;QACnF,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;4DA0B2C;KACvD;IACD;QACI,EAAE,EAAE,UAAU;QACd,KAAK,EAAE,oBAAoB;QAC3B,OAAO,EAAE,wDAAwD;QACjE,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;yCAoBwB;KACpC;IACD;QACI,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,YAAY;Q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