react-native-ai-debugger 1.0.25 → 1.0.27

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 CHANGED
@@ -6,6 +6,7 @@ An MCP (Model Context Protocol) server for AI-powered React Native debugging. En
6
6
 
7
7
  - Captures `console.log`, `console.warn`, `console.error` from React Native apps
8
8
  - **Network request tracking** - capture HTTP requests/responses with headers, timing, and status
9
+ - **React component inspection** - inspect component tree, props, state/hooks, and layout styles at runtime
9
10
  - **Debug Web Dashboard** - browser-based UI to view logs and network requests in real-time
10
11
  - Supports both **Expo SDK 54+** (React Native Bridgeless) and **RN 0.70+** (Hermes)
11
12
  - **Auto-connect on startup** - automatically scans and connects to Metro when the server starts
@@ -136,6 +137,15 @@ Requires VS Code 1.102+ with Copilot ([docs](https://code.visualstudio.com/docs/
136
137
  | `reload_app` | Reload the app (auto-connects if needed). Use sparingly - Fast Refresh handles most changes |
137
138
  | `get_debug_server` | Get the debug HTTP server URL for browser-based viewing |
138
139
 
140
+ ### React Component Inspection
141
+
142
+ | Tool | Description |
143
+ | -------------------- | ------------------------------------------------------------------- |
144
+ | `get_component_tree` | Get React component hierarchy from the running app (TONL format by default) |
145
+ | `get_screen_layout` | Get all components with layout styles (padding, margin, flex, etc.) |
146
+ | `inspect_component` | Inspect a specific component's props, state/hooks, and children |
147
+ | `find_components` | Find components matching a regex pattern with paths and layout info |
148
+
139
149
  ### Android (ADB)
140
150
 
141
151
  | Tool | Description |
@@ -540,6 +550,162 @@ execute_in_app with expression="AsyncStorage.getItem('userToken')"
540
550
 
541
551
  Set `awaitPromise=false` for synchronous execution only.
542
552
 
553
+ ## React Component Inspection
554
+
555
+ Inspect React components at runtime via the React DevTools hook. These tools let you debug component state, verify layouts, and understand app structure without adding console.logs.
556
+
557
+ ### Get Component Tree
558
+
559
+ View the React component hierarchy:
560
+
561
+ ```
562
+ get_component_tree
563
+ ```
564
+
565
+ Output (TONL format by default, ~50% smaller than JSON):
566
+
567
+ ```
568
+ App
569
+ ErrorBoundary
570
+ SafeAreaProvider
571
+ Provider
572
+ HomeScreen
573
+ Header
574
+ FlatList
575
+ Footer
576
+ ```
577
+
578
+ Options:
579
+ - `hideInternals=false` - Show internal RN components (RCTView, RNS*, etc.)
580
+ - `includeProps=true` - Include component props
581
+ - `format="json"` - Get structured JSON instead of TONL
582
+
583
+ ### Find Components by Pattern
584
+
585
+ Search for components matching a regex:
586
+
587
+ ```
588
+ find_components with pattern="Screen$"
589
+ ```
590
+
591
+ Output:
592
+
593
+ ```
594
+ pattern: Screen$
595
+ found: 5
596
+ #found{component,path,depth,key,layout}
597
+ HomeScreen|... > Navigator > HomeScreen|45||
598
+ SettingsScreen|... > Navigator > SettingsScreen|45||
599
+ ProfileScreen|... > Navigator > ProfileScreen|45||
600
+ ```
601
+
602
+ Options:
603
+ - `summary=true` - Get counts only (e.g., "HomeScreen: 1, SettingsScreen: 1")
604
+ - `includeLayout=true` - Include flex, padding, margin values
605
+ - `maxResults=10` - Limit number of results
606
+
607
+ ### Inspect Component State
608
+
609
+ Debug a specific component's props and hooks:
610
+
611
+ ```
612
+ inspect_component with componentName="HomeScreen"
613
+ ```
614
+
615
+ Output:
616
+
617
+ ```json
618
+ {
619
+ "component": "HomeScreen",
620
+ "path": "... > Navigator > HomeScreen",
621
+ "props": {
622
+ "navigation": "[Object]",
623
+ "route": { "name": "Home", "key": "home-xyz" }
624
+ },
625
+ "hooks": [
626
+ { "hookIndex": 0, "value": false },
627
+ { "hookIndex": 1, "value": { "current": null } },
628
+ { "hookIndex": 3, "value": 42 }
629
+ ]
630
+ }
631
+ ```
632
+
633
+ Options:
634
+ - `includeChildren=true` - List direct children component names
635
+ - `includeState=false` - Skip hooks/state (faster)
636
+ - `index=1` - Inspect 2nd instance if multiple exist
637
+
638
+ ### Get Screen Layout
639
+
640
+ View all components with their layout styles:
641
+
642
+ ```
643
+ get_screen_layout with summary=true
644
+ ```
645
+
646
+ Output:
647
+
648
+ ```
649
+ #summary total=320
650
+ View:83
651
+ RCTView:65
652
+ TouchableOpacity:12
653
+ Text:8
654
+ HomeScreen:1
655
+ ```
656
+
657
+ Full layout mode (`summary=false`):
658
+
659
+ ```
660
+ #elements{component,path,depth,layout,id}
661
+ View|... > HomeScreen > View|46|flex:1|
662
+ Header|... > View > Header|47|height:60;padding:16|header
663
+ ```
664
+
665
+ ### Use Cases
666
+
667
+ **Debug Navigation Issues**
668
+ ```
669
+ # Find which screen is currently mounted
670
+ find_components with pattern="Screen$"
671
+
672
+ # Check if a screen rendered multiple times (memory leak)
673
+ find_components with pattern="HomeScreen" summary=true
674
+ ```
675
+
676
+ **Debug State Without console.log**
677
+ ```
678
+ # Check current hook values
679
+ inspect_component with componentName="LoginForm"
680
+ # → hookIndex 2: false (isLoading)
681
+ # → hookIndex 3: "" (errorMessage)
682
+
683
+ # After user action, check if state changed
684
+ inspect_component with componentName="LoginForm"
685
+ # → hookIndex 2: true (isLoading changed!)
686
+ ```
687
+
688
+ **Verify Layout Styles**
689
+ ```
690
+ # Check if padding was applied correctly
691
+ get_screen_layout with componentsOnly=true
692
+
693
+ # Find components with specific layout issues
694
+ find_components with pattern="Card" includeLayout=true
695
+ ```
696
+
697
+ **Understand Unfamiliar Codebase**
698
+ ```
699
+ # Get app structure overview
700
+ get_component_tree with maxDepth=10
701
+
702
+ # Find all button variants
703
+ find_components with pattern="Button"
704
+
705
+ # Find all context providers
706
+ find_components with pattern="Provider$"
707
+ ```
708
+
543
709
  ## Device Interaction
544
710
 
545
711
  ### Android (requires ADB)
@@ -3,4 +3,46 @@ export declare function executeInApp(expression: string, awaitPromise?: boolean,
3
3
  export declare function listDebugGlobals(): Promise<ExecutionResult>;
4
4
  export declare function inspectGlobal(objectName: string): Promise<ExecutionResult>;
5
5
  export declare function reloadApp(): Promise<ExecutionResult>;
6
+ /**
7
+ * Get the React component tree from the running app.
8
+ * This traverses the fiber tree to extract component hierarchy with names.
9
+ */
10
+ export declare function getComponentTree(options?: {
11
+ maxDepth?: number;
12
+ includeProps?: boolean;
13
+ includeStyles?: boolean;
14
+ hideInternals?: boolean;
15
+ format?: 'json' | 'tonl';
16
+ }): Promise<ExecutionResult>;
17
+ /**
18
+ * Get layout styles for all components on the current screen.
19
+ * Useful for verifying layout without screenshots.
20
+ */
21
+ export declare function getScreenLayout(options?: {
22
+ maxDepth?: number;
23
+ componentsOnly?: boolean;
24
+ shortPath?: boolean;
25
+ summary?: boolean;
26
+ format?: 'json' | 'tonl';
27
+ }): Promise<ExecutionResult>;
28
+ /**
29
+ * Inspect a specific component by name, returning its props, state, and layout.
30
+ */
31
+ export declare function inspectComponent(componentName: string, options?: {
32
+ index?: number;
33
+ includeState?: boolean;
34
+ includeChildren?: boolean;
35
+ shortPath?: boolean;
36
+ simplifyHooks?: boolean;
37
+ }): Promise<ExecutionResult>;
38
+ /**
39
+ * Find all components matching a name pattern and return summary info.
40
+ */
41
+ export declare function findComponents(pattern: string, options?: {
42
+ maxResults?: number;
43
+ includeLayout?: boolean;
44
+ shortPath?: boolean;
45
+ summary?: boolean;
46
+ format?: 'json' | 'tonl';
47
+ }): Promise<ExecutionResult>;
6
48
  //# sourceMappingURL=executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/core/executor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA8N7D,wBAAsB,YAAY,CAC9B,UAAU,EAAE,MAAM,EAClB,YAAY,GAAE,OAAc,EAC5B,OAAO,GAAE,cAAmB,GAC7B,OAAO,CAAC,eAAe,CAAC,CAoF1B;AAGD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,eAAe,CAAC,CAkBjE;AAGD,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAsBhF;AAGD,wBAAsB,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC,CA0H1D"}
1
+ {"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