react-native-debug-toolkit 3.1.4 → 3.2.0

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 (125) hide show
  1. package/README.md +88 -65
  2. package/README.zh-CN.md +87 -64
  3. package/bin/debug-toolkit.js +10 -2
  4. package/lib/commonjs/core/initialize.js +5 -3
  5. package/lib/commonjs/core/initialize.js.map +1 -1
  6. package/lib/commonjs/features/devConnect/DevConnectQrScanner.js +146 -0
  7. package/lib/commonjs/features/devConnect/DevConnectQrScanner.js.map +1 -0
  8. package/lib/commonjs/features/devConnect/DevConnectTab.js +426 -0
  9. package/lib/commonjs/features/devConnect/DevConnectTab.js.map +1 -0
  10. package/lib/commonjs/features/devConnect/cameraKit.js +54 -0
  11. package/lib/commonjs/features/devConnect/cameraKit.js.map +1 -0
  12. package/lib/commonjs/features/devConnect/devConnectPreferences.js +35 -0
  13. package/lib/commonjs/features/devConnect/devConnectPreferences.js.map +1 -0
  14. package/lib/commonjs/features/devConnect/devConnectUtils.js +53 -0
  15. package/lib/commonjs/features/devConnect/devConnectUtils.js.map +1 -0
  16. package/lib/commonjs/features/devConnect/index.js +92 -0
  17. package/lib/commonjs/features/devConnect/index.js.map +1 -0
  18. package/lib/commonjs/features/devConnect/platformDetect.js +30 -0
  19. package/lib/commonjs/features/devConnect/platformDetect.js.map +1 -0
  20. package/lib/commonjs/features/devConnect/types.js +2 -0
  21. package/lib/commonjs/features/devConnect/types.js.map +1 -0
  22. package/lib/commonjs/features/network/NetworkLogTab.js +7 -3
  23. package/lib/commonjs/features/network/NetworkLogTab.js.map +1 -1
  24. package/lib/commonjs/index.js +7 -0
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/ui/DebugView.js +1 -0
  27. package/lib/commonjs/ui/DebugView.js.map +1 -1
  28. package/lib/commonjs/ui/panel/DebugPanel.js +0 -25
  29. package/lib/commonjs/ui/panel/DebugPanel.js.map +1 -1
  30. package/lib/commonjs/utils/DaemonClient.js +25 -1
  31. package/lib/commonjs/utils/DaemonClient.js.map +1 -1
  32. package/lib/commonjs/utils/debugPreferences.js +2 -1
  33. package/lib/commonjs/utils/debugPreferences.js.map +1 -1
  34. package/lib/commonjs/utils/deviceReport.js +1 -0
  35. package/lib/commonjs/utils/deviceReport.js.map +1 -1
  36. package/lib/module/core/initialize.js +5 -3
  37. package/lib/module/core/initialize.js.map +1 -1
  38. package/lib/module/features/devConnect/DevConnectQrScanner.js +141 -0
  39. package/lib/module/features/devConnect/DevConnectQrScanner.js.map +1 -0
  40. package/lib/module/features/devConnect/DevConnectTab.js +421 -0
  41. package/lib/module/features/devConnect/DevConnectTab.js.map +1 -0
  42. package/lib/module/features/devConnect/cameraKit.js +49 -0
  43. package/lib/module/features/devConnect/cameraKit.js.map +1 -0
  44. package/lib/module/features/devConnect/devConnectPreferences.js +29 -0
  45. package/lib/module/features/devConnect/devConnectPreferences.js.map +1 -0
  46. package/lib/module/features/devConnect/devConnectUtils.js +47 -0
  47. package/lib/module/features/devConnect/devConnectUtils.js.map +1 -0
  48. package/lib/module/features/devConnect/index.js +52 -0
  49. package/lib/module/features/devConnect/index.js.map +1 -0
  50. package/lib/module/features/devConnect/platformDetect.js +26 -0
  51. package/lib/module/features/devConnect/platformDetect.js.map +1 -0
  52. package/lib/module/features/devConnect/types.js +2 -0
  53. package/lib/module/features/devConnect/types.js.map +1 -0
  54. package/lib/module/features/network/NetworkLogTab.js +7 -3
  55. package/lib/module/features/network/NetworkLogTab.js.map +1 -1
  56. package/lib/module/index.js +1 -1
  57. package/lib/module/index.js.map +1 -1
  58. package/lib/module/ui/DebugView.js +1 -0
  59. package/lib/module/ui/DebugView.js.map +1 -1
  60. package/lib/module/ui/panel/DebugPanel.js +1 -26
  61. package/lib/module/ui/panel/DebugPanel.js.map +1 -1
  62. package/lib/module/utils/DaemonClient.js +25 -1
  63. package/lib/module/utils/DaemonClient.js.map +1 -1
  64. package/lib/module/utils/debugPreferences.js +2 -1
  65. package/lib/module/utils/debugPreferences.js.map +1 -1
  66. package/lib/module/utils/deviceReport.js +1 -0
  67. package/lib/module/utils/deviceReport.js.map +1 -1
  68. package/lib/typescript/src/core/initialize.d.ts +1 -0
  69. package/lib/typescript/src/core/initialize.d.ts.map +1 -1
  70. package/lib/typescript/src/features/devConnect/DevConnectQrScanner.d.ts +9 -0
  71. package/lib/typescript/src/features/devConnect/DevConnectQrScanner.d.ts.map +1 -0
  72. package/lib/typescript/src/features/devConnect/DevConnectTab.d.ts +5 -0
  73. package/lib/typescript/src/features/devConnect/DevConnectTab.d.ts.map +1 -0
  74. package/lib/typescript/src/features/devConnect/cameraKit.d.ts +47 -0
  75. package/lib/typescript/src/features/devConnect/cameraKit.d.ts.map +1 -0
  76. package/lib/typescript/src/features/devConnect/devConnectPreferences.d.ts +7 -0
  77. package/lib/typescript/src/features/devConnect/devConnectPreferences.d.ts.map +1 -0
  78. package/lib/typescript/src/features/devConnect/devConnectUtils.d.ts +12 -0
  79. package/lib/typescript/src/features/devConnect/devConnectUtils.d.ts.map +1 -0
  80. package/lib/typescript/src/features/devConnect/index.d.ts +7 -0
  81. package/lib/typescript/src/features/devConnect/index.d.ts.map +1 -0
  82. package/lib/typescript/src/features/devConnect/platformDetect.d.ts +2 -0
  83. package/lib/typescript/src/features/devConnect/platformDetect.d.ts.map +1 -0
  84. package/lib/typescript/src/features/devConnect/types.d.ts +7 -0
  85. package/lib/typescript/src/features/devConnect/types.d.ts.map +1 -0
  86. package/lib/typescript/src/features/network/NetworkLogTab.d.ts.map +1 -1
  87. package/lib/typescript/src/index.d.ts +2 -0
  88. package/lib/typescript/src/index.d.ts.map +1 -1
  89. package/lib/typescript/src/types/feature.d.ts +1 -1
  90. package/lib/typescript/src/types/feature.d.ts.map +1 -1
  91. package/lib/typescript/src/ui/DebugView.d.ts.map +1 -1
  92. package/lib/typescript/src/ui/panel/DebugPanel.d.ts.map +1 -1
  93. package/lib/typescript/src/utils/DaemonClient.d.ts +1 -0
  94. package/lib/typescript/src/utils/DaemonClient.d.ts.map +1 -1
  95. package/lib/typescript/src/utils/debugPreferences.d.ts +1 -0
  96. package/lib/typescript/src/utils/debugPreferences.d.ts.map +1 -1
  97. package/lib/typescript/src/utils/deviceReport.d.ts +6 -0
  98. package/lib/typescript/src/utils/deviceReport.d.ts.map +1 -1
  99. package/node/daemon/src/console/console.html +166 -27
  100. package/node/daemon/src/store.js +45 -6
  101. package/package.json +15 -3
  102. package/src/core/initialize.ts +7 -1
  103. package/src/features/devConnect/DevConnectQrScanner.tsx +122 -0
  104. package/src/features/devConnect/DevConnectTab.tsx +357 -0
  105. package/src/features/devConnect/cameraKit.ts +93 -0
  106. package/src/features/devConnect/devConnectPreferences.ts +33 -0
  107. package/src/features/devConnect/devConnectUtils.ts +59 -0
  108. package/src/features/devConnect/index.ts +64 -0
  109. package/src/features/devConnect/platformDetect.ts +26 -0
  110. package/src/features/devConnect/types.ts +6 -0
  111. package/src/features/network/NetworkLogTab.tsx +6 -3
  112. package/src/index.ts +2 -0
  113. package/src/types/feature.ts +2 -1
  114. package/src/ui/DebugView.tsx +1 -0
  115. package/src/ui/panel/DebugPanel.tsx +1 -23
  116. package/src/utils/DaemonClient.ts +26 -1
  117. package/src/utils/debugPreferences.ts +1 -0
  118. package/src/utils/deviceReport.ts +8 -1
  119. package/lib/commonjs/ui/panel/StreamingSettingsModal.js +0 -495
  120. package/lib/commonjs/ui/panel/StreamingSettingsModal.js.map +0 -1
  121. package/lib/module/ui/panel/StreamingSettingsModal.js +0 -490
  122. package/lib/module/ui/panel/StreamingSettingsModal.js.map +0 -1
  123. package/lib/typescript/src/ui/panel/StreamingSettingsModal.d.ts +0 -8
  124. package/lib/typescript/src/ui/panel/StreamingSettingsModal.d.ts.map +0 -1
  125. package/src/ui/panel/StreamingSettingsModal.tsx +0 -528
package/README.md CHANGED
@@ -1,27 +1,24 @@
1
1
  # React Native Debug Toolkit
2
2
 
3
- [中文](README.zh-CN.md)
3
+ ![demo](demo.gif)
4
4
 
5
- Dev-only React Native inspector with a local log bridge.
5
+ [中文](README.zh-CN.md)
6
6
 
7
- It shows app logs on device, then can send the same device log stream to a local daemon for browser, curl, scripts, or MCP.
7
+ React Native Debug Toolkit is a dev-only local debugging toolkit for React Native apps.
8
8
 
9
- ## Model
9
+ Use it to inspect app logs on device, stream logs to a desktop Web Console, and let AI coding agents read real runtime evidence through HTTP or MCP.
10
10
 
11
11
  ```text
12
- RN App logs -> Debug Panel -> local daemon -> Web Console / HTTP / MCP
12
+ RN App -> Debug Panel -> local daemon -> Web Console / HTTP API / MCP
13
13
  ```
14
14
 
15
- Captured logs:
16
-
17
- - Network
18
- - Console
19
- - Navigation
20
- - Track
21
- - Zustand
15
+ ## What You Get
22
16
 
23
- The CLI daemon persists device logs to `~/.react-native-debug-toolkit/daemon-devices.json`.
24
- Use `DELETE /devices` to clear stored logs.
17
+ - In-app debug panel with Network, Console, Navigation, Track, Zustand, Environment, and Clipboard logs.
18
+ - Desktop Web Console for simulator and real-device logs.
19
+ - Local HTTP API for curl, scripts, Codex, Claude Code, and other AI agents with shell access.
20
+ - Optional MCP server with `list_app_devices` and `get_app_logs`.
21
+ - Local-first workflow. No cloud service. No AI API call inside the package.
25
22
 
26
23
  ## Install
27
24
 
@@ -29,14 +26,16 @@ Use `DELETE /devices` to clear stored logs.
29
26
  npm install react-native-debug-toolkit
30
27
  ```
31
28
 
32
- Optional:
29
+ Optional dependencies:
33
30
 
34
31
  ```bash
35
32
  npm install @react-native-clipboard/clipboard
36
33
  npm install @react-native-async-storage/async-storage
37
34
  ```
38
35
 
39
- ## App Usage
36
+ ## Quick Start
37
+
38
+ Wrap your app:
40
39
 
41
40
  ```tsx
42
41
  import { DebugView } from 'react-native-debug-toolkit';
@@ -50,70 +49,60 @@ export function App() {
50
49
  }
51
50
  ```
52
51
 
53
- Open app in dev mode. Tap `DBG`.
52
+ Run the app in dev mode, then tap `DBG`.
54
53
 
55
- Disable features:
54
+ Start the desktop daemon:
56
55
 
57
- ```tsx
58
- <DebugView features={{ clipboard: false, zustand: false }}>
59
- <AppContent />
60
- </DebugView>
56
+ ```bash
57
+ npm exec debug-toolkit --daemon-only
58
+ # or: npx debug-toolkit --daemon-only
61
59
  ```
62
60
 
63
- Navigation tracking:
61
+ Open the Web Console:
64
62
 
65
- ```tsx
66
- <DebugView navigationRef={navigationRef}>
67
- <NavigationContainer ref={navigationRef}>
68
- <AppContent />
69
- </NavigationContainer>
70
- </DebugView>
63
+ ```text
64
+ http://127.0.0.1:3799/console
71
65
  ```
72
66
 
73
- Zustand:
67
+ In the app, open Debug Panel -> `DevConnect` -> `Send Once` or `Start Live Sync`.
74
68
 
75
- ```tsx
76
- import { zustandLogMiddleware } from 'react-native-debug-toolkit';
77
- ```
78
-
79
- Track:
69
+ DevConnect auto-detects simulator/emulator and uses `localhost` automatically. On real devices, enter your computer IP to connect.
80
70
 
81
- ```tsx
82
- import { addTrackLog } from 'react-native-debug-toolkit';
71
+ QR scan is optional. Install `react-native-camera-kit` or `expo-camera` in the app to enable the scan button. The app must request camera permission before scanning.
83
72
 
84
- addTrackLog({ eventName: 'button_click' });
85
- ```
73
+ ## Device Setup
86
74
 
87
- ## Desktop Logs
75
+ | Runtime | App endpoint |
76
+ | --- | --- |
77
+ | iOS simulator | `http://localhost:3799` |
78
+ | Android emulator | `http://10.0.2.2:3799` |
79
+ | Real device | `http://<mac-ip>:3799` |
88
80
 
89
- Start daemon:
81
+ For a real device, first open this URL in the phone browser:
90
82
 
91
- ```bash
92
- npx debug-toolkit --daemon-only
83
+ ```text
84
+ http://<mac-ip>:3799/health
93
85
  ```
94
86
 
95
- The default device log store is `~/.react-native-debug-toolkit/daemon-devices.json`.
96
- Override it with `--store /path/to/devices.json` or `DEBUG_TOOLKIT_DAEMON_STORE`.
87
+ If it does not open, check Mac firewall, Wi-Fi isolation, VPN, local network permission, and cleartext HTTP settings.
97
88
 
98
- Open:
89
+ The daemon stores logs at:
99
90
 
100
91
  ```text
101
- http://127.0.0.1:3799/console
92
+ ~/.react-native-debug-toolkit/daemon-devices.json
102
93
  ```
103
94
 
104
- In app: Debug Panel -> gear -> `Send Once` or `Start Live Sync`.
105
-
106
- Endpoints:
95
+ Custom store path:
107
96
 
108
- | Runtime | Endpoint |
109
- | --- | --- |
110
- | iOS simulator | `http://localhost:3799` |
111
- | Android emulator | `http://10.0.2.2:3799` |
112
- | Real device | `http://<mac-ip>:3799` |
97
+ ```bash
98
+ npm exec debug-toolkit --daemon-only --store /path/to/devices.json
99
+ # or: npx debug-toolkit --daemon-only --store /path/to/devices.json
100
+ DEBUG_TOOLKIT_DAEMON_STORE=/path/to/devices.json npm exec debug-toolkit --daemon-only
101
+ ```
113
102
 
114
- Real device rule: phone browser must open `http://<mac-ip>:3799/health`. If not, check firewall, Wi-Fi isolation, VPN, and cleartext HTTP.
103
+ ## Read Logs With HTTP
115
104
 
116
- ## HTTP
105
+ HTTP is the best path when your AI agent or script has shell access.
117
106
 
118
107
  ```bash
119
108
  BASE=http://127.0.0.1:3799
@@ -124,12 +113,11 @@ curl "$BASE/devices/latest"
124
113
 
125
114
  DEVICE_ID=$(curl -s "$BASE/devices" | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>console.log((JSON.parse(s).devices||[])[0]?.deviceId||''))")
126
115
 
127
- curl "$BASE/devices/$DEVICE_ID"
128
116
  curl "$BASE/devices/$DEVICE_ID/logs?limit=100"
129
- curl "$BASE/devices/$DEVICE_ID/logs?limit=100&includeBodies=true"
130
117
  curl "$BASE/devices/$DEVICE_ID/logs?type=network&failedOnly=true&limit=50"
131
118
  curl "$BASE/devices/$DEVICE_ID/logs?type=console&limit=100"
132
119
  curl "$BASE/devices/$DEVICE_ID/logs?entryId=<entryId>"
120
+ curl "$BASE/devices/$DEVICE_ID/logs?limit=100&includeBodies=true"
133
121
  curl -X DELETE "$BASE/devices"
134
122
  ```
135
123
 
@@ -148,18 +136,53 @@ GET /events
148
136
  GET /console
149
137
  ```
150
138
 
151
- ## MCP
139
+ ## Use MCP
152
140
 
153
141
  ```bash
154
- claude mcp add debug-toolkit -- npx debug-toolkit
142
+ claude mcp add debug-toolkit -- npm exec debug-toolkit
143
+ # or: claude mcp add debug-toolkit -- npx debug-toolkit
155
144
  ```
156
145
 
157
146
  Tools:
158
147
 
159
148
  - `list_app_devices`
160
- - `get_app_logs` — bodies excluded by default; set `includeBodies=true` or pass `entryId` for details
149
+ - `get_app_logs`
150
+
151
+ `get_app_logs` excludes bodies by default to reduce tokens. Set `includeBodies=true` or pass `entryId` to fetch one full log entry.
152
+
153
+ ## App Options
154
+
155
+ Disable features:
161
156
 
162
- Use curl when shell is available.
157
+ ```tsx
158
+ <DebugView features={{ clipboard: false, zustand: false }}>
159
+ <AppContent />
160
+ </DebugView>
161
+ ```
162
+
163
+ Navigation tracking:
164
+
165
+ ```tsx
166
+ <DebugView navigationRef={navigationRef}>
167
+ <NavigationContainer ref={navigationRef}>
168
+ <AppContent />
169
+ </NavigationContainer>
170
+ </DebugView>
171
+ ```
172
+
173
+ Zustand:
174
+
175
+ ```tsx
176
+ import { zustandLogMiddleware } from 'react-native-debug-toolkit';
177
+ ```
178
+
179
+ Track:
180
+
181
+ ```tsx
182
+ import { addTrackLog } from 'react-native-debug-toolkit';
183
+
184
+ addTrackLog({ eventName: 'button_click' });
185
+ ```
163
186
 
164
187
  ## Exports
165
188
 
@@ -175,11 +198,11 @@ Use curl when shell is available.
175
198
  - `autoDetectDaemonIp`
176
199
  - feature factories and types
177
200
 
178
- ## Boundaries
201
+ ## Limits
179
202
 
180
203
  - Dev tool, not production monitoring.
181
204
  - Local daemon, not cloud replay.
182
- - Network logs are observed traffic, not auth/token analysis.
205
+ - Network capture observes traffic; it does not analyze auth, tokens, or business errors.
183
206
  - No default redaction.
184
207
  - Not a React Native DevTools replacement.
185
208
 
package/README.zh-CN.md CHANGED
@@ -1,27 +1,24 @@
1
1
  # React Native Debug Toolkit
2
2
 
3
- [English](README.md)
3
+ ![demo](demo.gif)
4
4
 
5
- React Native 开发期调试面板 + 本地日志桥。
5
+ [English](README.md)
6
6
 
7
- 它能在 App 内看日志,也能把同一台设备的日志流发到本机 daemon,供浏览器、curl、脚本、MCP 读取。
7
+ React Native Debug Toolkit 是 React Native 开发期本地调试工具。
8
8
 
9
- ## 模型
9
+ 它可以在 App 内查看日志,把模拟器或真机日志同步到桌面 Web Console,也可以让 AI 编程工具通过 HTTP 或 MCP 直接读取真实运行日志。
10
10
 
11
11
  ```text
12
- RN App logs -> Debug Panel -> local daemon -> Web Console / HTTP / MCP
12
+ RN App -> Debug Panel -> local daemon -> Web Console / HTTP API / MCP
13
13
  ```
14
14
 
15
- 采集:
16
-
17
- - Network
18
- - Console
19
- - Navigation
20
- - Track
21
- - Zustand
15
+ ## 能做什么
22
16
 
23
- CLI daemon 默认把设备日志持久化到 `~/.react-native-debug-toolkit/daemon-devices.json`。
24
- `DELETE /devices` 清空已存日志。
17
+ - App 内调试面板:Network、Console、Navigation、Track、Zustand、Environment、Clipboard。
18
+ - 桌面 Web Console:查看模拟器和真机日志。
19
+ - 本地 HTTP API:给 curl、脚本、Codex、Claude Code、其他有 shell 的 AI 读取。
20
+ - 可选 MCP:提供 `list_app_devices` 和 `get_app_logs`。
21
+ - 本地优先:不接云服务,包内不调用 AI API。
25
22
 
26
23
  ## 安装
27
24
 
@@ -29,14 +26,16 @@ CLI daemon 默认把设备日志持久化到 `~/.react-native-debug-toolkit/daem
29
26
  npm install react-native-debug-toolkit
30
27
  ```
31
28
 
32
- 可选:
29
+ 可选依赖:
33
30
 
34
31
  ```bash
35
32
  npm install @react-native-clipboard/clipboard
36
33
  npm install @react-native-async-storage/async-storage
37
34
  ```
38
35
 
39
- ## App 接入
36
+ ## 快速开始
37
+
38
+ 包住你的 App:
40
39
 
41
40
  ```tsx
42
41
  import { DebugView } from 'react-native-debug-toolkit';
@@ -50,70 +49,60 @@ export function App() {
50
49
  }
51
50
  ```
52
51
 
53
- 开发模式打开 App。点击 `DBG`。
52
+ 开发模式打开 App,点击 `DBG`。
54
53
 
55
- 禁用功能:
54
+ 启动桌面 daemon:
56
55
 
57
- ```tsx
58
- <DebugView features={{ clipboard: false, zustand: false }}>
59
- <AppContent />
60
- </DebugView>
56
+ ```bash
57
+ npm exec debug-toolkit --daemon-only
58
+ # 或:npx debug-toolkit --daemon-only
61
59
  ```
62
60
 
63
- 导航追踪:
61
+ 打开 Web Console:
64
62
 
65
- ```tsx
66
- <DebugView navigationRef={navigationRef}>
67
- <NavigationContainer ref={navigationRef}>
68
- <AppContent />
69
- </NavigationContainer>
70
- </DebugView>
63
+ ```text
64
+ http://127.0.0.1:3799/console
71
65
  ```
72
66
 
73
- Zustand:
67
+ App 内打开 Debug Panel -> `DevConnect` -> `Send Once` 或 `Start Live Sync`。
74
68
 
75
- ```tsx
76
- import { zustandLogMiddleware } from 'react-native-debug-toolkit';
77
- ```
78
-
79
- Track:
69
+ DevConnect 自动识别模拟器/真机,模拟器下自动使用 `localhost`。真机需输入电脑 IP 地址。
80
70
 
81
- ```tsx
82
- import { addTrackLog } from 'react-native-debug-toolkit';
71
+ 扫码是可选能力。App 安装 `react-native-camera-kit` 或 `expo-camera` 后,DevConnect 才显示扫码按钮。App 仍需自己配置相机权限文案,并在使用扫码前申请相机权限。
83
72
 
84
- addTrackLog({ eventName: 'button_click' });
85
- ```
73
+ ## 设备连接
86
74
 
87
- ## Desktop Logs
75
+ | 运行时 | App endpoint |
76
+ | --- | --- |
77
+ | iOS simulator | `http://localhost:3799` |
78
+ | Android emulator | `http://10.0.2.2:3799` |
79
+ | 真机 | `http://<mac-ip>:3799` |
88
80
 
89
- 启动 daemon:
81
+ 真机先用手机浏览器打开:
90
82
 
91
- ```bash
92
- npx debug-toolkit --daemon-only
83
+ ```text
84
+ http://<mac-ip>:3799/health
93
85
  ```
94
86
 
95
- 默认设备日志存储文件:`~/.react-native-debug-toolkit/daemon-devices.json`。
96
- 可用 `--store /path/to/devices.json` 或 `DEBUG_TOOLKIT_DAEMON_STORE` 覆盖。
87
+ 打不开就检查 Mac 防火墙、Wi-Fi 隔离、VPN、本地网络权限、明文 HTTP 配置。
97
88
 
98
- 打开:
89
+ daemon 默认日志文件:
99
90
 
100
91
  ```text
101
- http://127.0.0.1:3799/console
92
+ ~/.react-native-debug-toolkit/daemon-devices.json
102
93
  ```
103
94
 
104
- App 内:Debug Panel -> 齿轮 -> `Send Once` 或 `Start Live Sync`。
105
-
106
- Endpoint:
95
+ 自定义存储路径:
107
96
 
108
- | 运行时 | Endpoint |
109
- | --- | --- |
110
- | iOS simulator | `http://localhost:3799` |
111
- | Android emulator | `http://10.0.2.2:3799` |
112
- | 真机 | `http://<mac-ip>:3799` |
97
+ ```bash
98
+ npm exec debug-toolkit --daemon-only --store /path/to/devices.json
99
+ # 或:npx debug-toolkit --daemon-only --store /path/to/devices.json
100
+ DEBUG_TOOLKIT_DAEMON_STORE=/path/to/devices.json npm exec debug-toolkit --daemon-only
101
+ ```
113
102
 
114
- 真机规则:手机浏览器必须能打开 `http://<mac-ip>:3799/health`。打不开就查防火墙、Wi-Fi 隔离、VPN、明文 HTTP。
103
+ ## HTTP 读取日志
115
104
 
116
- ## HTTP
105
+ AI 或脚本有 shell 时,优先用 HTTP
117
106
 
118
107
  ```bash
119
108
  BASE=http://127.0.0.1:3799
@@ -124,12 +113,11 @@ curl "$BASE/devices/latest"
124
113
 
125
114
  DEVICE_ID=$(curl -s "$BASE/devices" | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>console.log((JSON.parse(s).devices||[])[0]?.deviceId||''))")
126
115
 
127
- curl "$BASE/devices/$DEVICE_ID"
128
116
  curl "$BASE/devices/$DEVICE_ID/logs?limit=100"
129
- curl "$BASE/devices/$DEVICE_ID/logs?limit=100&includeBodies=true"
130
117
  curl "$BASE/devices/$DEVICE_ID/logs?type=network&failedOnly=true&limit=50"
131
118
  curl "$BASE/devices/$DEVICE_ID/logs?type=console&limit=100"
132
119
  curl "$BASE/devices/$DEVICE_ID/logs?entryId=<entryId>"
120
+ curl "$BASE/devices/$DEVICE_ID/logs?limit=100&includeBodies=true"
133
121
  curl -X DELETE "$BASE/devices"
134
122
  ```
135
123
 
@@ -148,18 +136,53 @@ GET /events
148
136
  GET /console
149
137
  ```
150
138
 
151
- ## MCP
139
+ ## 使用 MCP
152
140
 
153
141
  ```bash
154
- claude mcp add debug-toolkit -- npx debug-toolkit
142
+ claude mcp add debug-toolkit -- npm exec debug-toolkit
143
+ # 或:claude mcp add debug-toolkit -- npx debug-toolkit
155
144
  ```
156
145
 
157
146
  工具:
158
147
 
159
148
  - `list_app_devices`
160
- - `get_app_logs` — 默认不含 body;设置 `includeBodies=true` 或传 `entryId` 获取详情
149
+ - `get_app_logs`
150
+
151
+ `get_app_logs` 默认不返回 body,减少 token。设置 `includeBodies=true` 或传 `entryId` 可读取单条完整日志。
152
+
153
+ ## App 配置
154
+
155
+ 禁用功能:
161
156
 
162
- 有 shell 时优先 curl。
157
+ ```tsx
158
+ <DebugView features={{ clipboard: false, zustand: false }}>
159
+ <AppContent />
160
+ </DebugView>
161
+ ```
162
+
163
+ 导航追踪:
164
+
165
+ ```tsx
166
+ <DebugView navigationRef={navigationRef}>
167
+ <NavigationContainer ref={navigationRef}>
168
+ <AppContent />
169
+ </NavigationContainer>
170
+ </DebugView>
171
+ ```
172
+
173
+ Zustand:
174
+
175
+ ```tsx
176
+ import { zustandLogMiddleware } from 'react-native-debug-toolkit';
177
+ ```
178
+
179
+ Track:
180
+
181
+ ```tsx
182
+ import { addTrackLog } from 'react-native-debug-toolkit';
183
+
184
+ addTrackLog({ eventName: 'button_click' });
185
+ ```
163
186
 
164
187
  ## 导出
165
188
 
@@ -179,7 +202,7 @@ claude mcp add debug-toolkit -- npx debug-toolkit
179
202
 
180
203
  - 开发工具,不是生产监控。
181
204
  - 本地 daemon,不是云 replay。
182
- - Network 日志只是监测流量,不做 auth/token 分析。
205
+ - Network 只观察流量,不自动分析 authtoken、业务错误。
183
206
  - 不默认脱敏。
184
207
  - 不替代 React Native DevTools。
185
208
 
@@ -6,6 +6,7 @@ const {
6
6
  DAEMON_NAME,
7
7
  DEFAULT_HOST,
8
8
  DEFAULT_PORT,
9
+ getDefaultDeviceStorePath,
9
10
  getLanIPs,
10
11
  } = require('../node/daemon/src/constants');
11
12
  const { createDaemonServer } = require('../node/daemon/src/server');
@@ -25,7 +26,7 @@ function hasHelpFlag(args) {
25
26
 
26
27
  function printHelp() {
27
28
  process.stderr.write(
28
- 'Usage: debug-toolkit [--host 0.0.0.0] [--port 3799] [--token dev-token] [--daemon-only]\n'
29
+ 'Usage: debug-toolkit [--host 0.0.0.0] [--port 3799] [--token dev-token] [--store ~/.react-native-debug-toolkit/daemon-devices.json] [--daemon-only]\n'
29
30
  + '\n'
30
31
  + 'Starts the debug toolkit: daemon (HTTP + Web Console) and MCP stdio server.\n'
31
32
  + '\n'
@@ -33,6 +34,7 @@ function printHelp() {
33
34
  + ' --host <addr> Host to bind (default: 0.0.0.0)\n'
34
35
  + ' --port <port> Port to bind (default: 3799)\n'
35
36
  + ' --token <str> Auth token for daemon endpoints\n'
37
+ + ' --store <path> Device log store path\n'
36
38
  + ' --daemon-only Start only the HTTP daemon and Web Console\n'
37
39
  + ' -h, --help Show this help\n',
38
40
  );
@@ -58,6 +60,11 @@ async function main() {
58
60
  const host = readOption(args, '--host', process.env.DEBUG_TOOLKIT_DAEMON_HOST || DEFAULT_HOST);
59
61
  const port = Number(readOption(args, '--port', process.env.DEBUG_TOOLKIT_DAEMON_PORT || DEFAULT_PORT));
60
62
  const token = readOption(args, '--token', process.env.DEBUG_TOOLKIT_DAEMON_TOKEN || '');
63
+ const deviceStorePath = readOption(
64
+ args,
65
+ '--store',
66
+ process.env.DEBUG_TOOLKIT_DAEMON_STORE || getDefaultDeviceStorePath(),
67
+ );
61
68
  const daemonOnly = hasDaemonOnlyFlag(args);
62
69
 
63
70
  if (!Number.isFinite(port) || port <= 0) {
@@ -67,7 +74,7 @@ async function main() {
67
74
  }
68
75
 
69
76
  // Start daemon HTTP server in-process
70
- const { server } = createDaemonServer({ token });
77
+ const { server } = createDaemonServer({ token, deviceStorePath });
71
78
 
72
79
  server.on('error', (error) => {
73
80
  process.stderr.write(`${DAEMON_NAME} failed to start: ${error.message}\n`);
@@ -79,6 +86,7 @@ async function main() {
79
86
  const consolePath = token ? `/console?token=${encodeURIComponent(token)}` : '/console';
80
87
  process.stderr.write(`${DAEMON_NAME} listening on http://${host}:${port}\n`);
81
88
  process.stderr.write(`Web Console: ${getLocalOrigin(host, port)}${consolePath}\n`);
89
+ process.stderr.write(`Device store: ${deviceStorePath}\n`);
82
90
  const lanIPs = getLanIPs();
83
91
  if (lanIPs.length > 0) {
84
92
  process.stderr.write(`LAN IPs: ${lanIPs.join(', ')}\n`);
@@ -12,6 +12,7 @@ var _navigation = require("../features/navigation");
12
12
  var _track = require("../features/track");
13
13
  var _environment = require("../features/environment");
14
14
  var _clipboard = require("../features/clipboard");
15
+ var _devConnect = require("../features/devConnect");
15
16
  var _DaemonClient = require("../utils/DaemonClient");
16
17
  const isDebugMode = __DEV__;
17
18
 
@@ -27,9 +28,10 @@ const featureRegistry = {
27
28
  navigation: _navigation.createNavigationLogFeature,
28
29
  track: _track.createTrackFeature,
29
30
  environment: _environment.createEnvironmentFeature,
30
- clipboard: _clipboard.createClipboardFeature
31
+ clipboard: _clipboard.createClipboardFeature,
32
+ devConnect: _devConnect.createDevConnectFeature
31
33
  };
32
- const DEFAULT_FEATURES = ['network', 'console', 'navigation', 'zustand', 'track', 'clipboard'];
34
+ const DEFAULT_FEATURES = ['network', 'console', 'navigation', 'zustand', 'track', 'clipboard', 'devConnect'];
33
35
  function resolveFeatureConfigs(configs) {
34
36
  const features = [];
35
37
  const entries = Object.entries(configs);
@@ -79,7 +81,7 @@ function initializeDebugToolkit(options) {
79
81
  } else {
80
82
  _DebugToolkit.DebugToolkit.hideLauncher();
81
83
  }
82
- _DaemonClient.daemonClient.restore().catch(() => {});
84
+ (0, _devConnect.restoreDevConnectSettingsToDaemon)().then(() => _DaemonClient.daemonClient.restore(), () => _DaemonClient.daemonClient.restore()).catch(() => {});
83
85
  return _DebugToolkit.DebugToolkit;
84
86
  } catch (error) {
85
87
  console.error('[DebugToolkit] Initialization failed:', error);
@@ -1 +1 @@
1
- {"version":3,"names":["_DebugToolkit","require","_network","_console","_zustand","_navigation","_track","_environment","_clipboard","_DaemonClient","isDebugMode","__DEV__","featureRegistry","network","createNetworkFeature","console","createConsoleLogFeature","zustand","createZustandLogFeature","navigation","createNavigationLogFeature","track","createTrackFeature","environment","createEnvironmentFeature","clipboard","createClipboardFeature","DEFAULT_FEATURES","resolveFeatureConfigs","configs","features","entries","Object","name","config","creator","warn","undefined","push","resolveDefaultFeatures","map","initializeDebugToolkit","options","enabled","resolvedFeatures","DebugToolkit","setEnabled","reset","replaceFeatures","daemonClient","setEndpointDetector","url","addToBlacklist","hasFeatures","showLauncher","hideLauncher","restore","catch","error"],"sourceRoot":"../../../src","sources":["core/initialize.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAGA,MAAMS,WAAW,GAAGC,OAAO;;AAE3B;;AAgBA;AACA;AACA;AACA,MAAMC,eAA8E,GAAG;EACrFC,OAAO,EAAEC,6BAAoB;EAC7BC,OAAO,EAAEC,gCAAuB;EAChCC,OAAO,EAAEC,gCAAuB;EAChCC,UAAU,EAAEC,sCAA0B;EACtCC,KAAK,EAAEC,yBAAkB;EACzBC,WAAW,EAAEC,qCAAwB;EACrCC,SAAS,EAAEC;AACb,CAAC;AAED,MAAMC,gBAAsC,GAAG,CAC7C,SAAS,EACT,SAAS,EACT,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AE;MACZE,0BAAY,CAACE,KAAK,CAAC,CAAC;MACpB,OAAOF,0BAAY;IACrB;IAEAA,0BAAY,CAACG,eAAe,CAACJ,gBAAgB,CAAC;IAE9CK,0BAAY,CAACC,mBAAmB,CAAEC,GAAG,IAAK;MACxC,IAAAC,uBAAc,EAACD,GAAG,CAAC;IACrB,CAAC,CAAC;IAEF,IAAIN,0BAAY,CAACQ,WAAW,CAAC,CAAC,EAAE;MAC9BR,0BAAY,CAACS,YAAY,CAAC,CAAC;IAC7B,CAAC,MAAM;MACLT,0BAAY,CAACU,YAAY,CAAC,CAAC;IAC7B;IAEAN,0BAAY,CAACO,OAAO,CAAC,CAAC,CAACC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAEtC,OAAOZ,0BAAY;EACrB,CAAC,CAAC,OAAOa,KAAK,EAAE;IACd3C,OAAO,CAAC2C,KAAK,CAAC,uCAAuC,EAAEA,KAAK,CAAC;IAC7D,OAAOb,0BAAY;EACrB;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_DebugToolkit","require","_network","_console","_zustand","_navigation","_track","_environment","_clipboard","_devConnect","_DaemonClient","isDebugMode","__DEV__","featureRegistry","network","createNetworkFeature","console","createConsoleLogFeature","zustand","createZustandLogFeature","navigation","createNavigationLogFeature","track","createTrackFeature","environment","createEnvironmentFeature","clipboard","createClipboardFeature","devConnect","createDevConnectFeature","DEFAULT_FEATURES","resolveFeatureConfigs","configs","features","entries","Object","name","config","creator","warn","undefined","push","resolveDefaultFeatures","map","initializeDebugToolkit","options","enabled","resolvedFeatures","DebugToolkit","setEnabled","reset","replaceFeatures","daemonClient","setEndpointDetector","url","addToBlacklist","hasFeatures","showLauncher","hideLauncher","restoreDevConnectSettingsToDaemon","then","restore","catch","error"],"sourceRoot":"../../../src","sources":["core/initialize.ts"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AA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