react-native-debug-toolkit 3.1.3 → 3.1.5
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 +83 -65
- package/README.zh-CN.md +82 -64
- package/bin/debug-toolkit.js +10 -2
- package/lib/commonjs/core/DebugToolkit.js +118 -97
- package/lib/commonjs/core/DebugToolkit.js.map +1 -1
- package/lib/commonjs/core/initialize.js +4 -4
- package/lib/commonjs/core/initialize.js.map +1 -1
- package/lib/commonjs/features/environment/index.js +22 -24
- package/lib/commonjs/features/environment/index.js.map +1 -1
- package/lib/commonjs/features/network/NetworkLogTab.js +7 -3
- package/lib/commonjs/features/network/NetworkLogTab.js.map +1 -1
- package/lib/commonjs/features/network/index.js +25 -47
- package/lib/commonjs/features/network/index.js.map +1 -1
- package/lib/commonjs/features/network/networkInterceptor.js +3 -3
- package/lib/commonjs/features/network/networkInterceptor.js.map +1 -1
- package/lib/commonjs/index.js +0 -30
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/DaemonClient.js +37 -51
- package/lib/commonjs/utils/DaemonClient.js.map +1 -1
- package/lib/commonjs/utils/createChannelFeature.js +8 -1
- package/lib/commonjs/utils/createChannelFeature.js.map +1 -1
- package/lib/commonjs/utils/deviceReport.js +3 -1
- package/lib/commonjs/utils/deviceReport.js.map +1 -1
- package/lib/commonjs/utils/urlRewriter.js +15 -0
- package/lib/commonjs/utils/urlRewriter.js.map +1 -0
- package/lib/module/core/DebugToolkit.js +117 -96
- package/lib/module/core/DebugToolkit.js.map +1 -1
- package/lib/module/core/initialize.js +6 -7
- package/lib/module/core/initialize.js.map +1 -1
- package/lib/module/features/environment/index.js +22 -24
- package/lib/module/features/environment/index.js.map +1 -1
- package/lib/module/features/network/NetworkLogTab.js +7 -3
- package/lib/module/features/network/NetworkLogTab.js.map +1 -1
- package/lib/module/features/network/index.js +25 -46
- package/lib/module/features/network/index.js.map +1 -1
- package/lib/module/features/network/networkInterceptor.js +3 -3
- package/lib/module/features/network/networkInterceptor.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/DaemonClient.js +38 -42
- package/lib/module/utils/DaemonClient.js.map +1 -1
- package/lib/module/utils/createChannelFeature.js +8 -1
- package/lib/module/utils/createChannelFeature.js.map +1 -1
- package/lib/module/utils/deviceReport.js +4 -2
- package/lib/module/utils/deviceReport.js.map +1 -1
- package/lib/module/utils/urlRewriter.js +10 -0
- package/lib/module/utils/urlRewriter.js.map +1 -0
- package/lib/typescript/src/core/DebugToolkit.d.ts +23 -10
- package/lib/typescript/src/core/DebugToolkit.d.ts.map +1 -1
- package/lib/typescript/src/core/initialize.d.ts.map +1 -1
- package/lib/typescript/src/features/environment/index.d.ts.map +1 -1
- package/lib/typescript/src/features/network/NetworkLogTab.d.ts.map +1 -1
- package/lib/typescript/src/features/network/index.d.ts +3 -3
- package/lib/typescript/src/features/network/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/feature.d.ts +5 -0
- package/lib/typescript/src/types/feature.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/DaemonClient.d.ts +5 -11
- package/lib/typescript/src/utils/DaemonClient.d.ts.map +1 -1
- package/lib/typescript/src/utils/createChannelFeature.d.ts +4 -0
- package/lib/typescript/src/utils/createChannelFeature.d.ts.map +1 -1
- package/lib/typescript/src/utils/deviceReport.d.ts +10 -1
- package/lib/typescript/src/utils/deviceReport.d.ts.map +1 -1
- package/lib/typescript/src/utils/urlRewriter.d.ts +5 -0
- package/lib/typescript/src/utils/urlRewriter.d.ts.map +1 -0
- package/node/daemon/src/console/console.html +197 -27
- package/node/daemon/src/server.js +32 -2
- package/node/daemon/src/store.js +45 -6
- package/node/mcp/src/logs.js +15 -4
- package/node/mcp/src/tools.js +4 -2
- package/package.json +6 -2
- package/src/core/DebugToolkit.tsx +119 -105
- package/src/core/initialize.ts +7 -8
- package/src/features/environment/index.ts +25 -27
- package/src/features/network/NetworkLogTab.tsx +6 -3
- package/src/features/network/index.ts +30 -52
- package/src/features/network/networkInterceptor.ts +3 -3
- package/src/index.ts +3 -8
- package/src/types/feature.ts +6 -0
- package/src/types/index.ts +1 -0
- package/src/utils/DaemonClient.ts +39 -56
- package/src/utils/createChannelFeature.ts +12 -1
- package/src/utils/deviceReport.ts +12 -3
- package/src/utils/urlRewriter.ts +11 -0
- package/lib/commonjs/utils/urlRewriterRegistry.js +0 -14
- package/lib/commonjs/utils/urlRewriterRegistry.js.map +0 -1
- package/lib/module/utils/urlRewriterRegistry.js +0 -10
- package/lib/module/utils/urlRewriterRegistry.js.map +0 -1
- package/lib/typescript/src/utils/urlRewriterRegistry.d.ts +0 -7
- package/lib/typescript/src/utils/urlRewriterRegistry.d.ts.map +0 -1
- package/src/utils/urlRewriterRegistry.ts +0 -10
package/README.md
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
# React Native Debug Toolkit
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[中文](README.zh-CN.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
React Native Debug Toolkit is a dev-only local debugging toolkit for React Native apps.
|
|
8
8
|
|
|
9
|
-
|
|
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
|
|
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
|
+
## What You Get
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
##
|
|
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,54 @@ export function App() {
|
|
|
50
49
|
}
|
|
51
50
|
```
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Disable features:
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
<DebugView features={{ clipboard: false, zustand: false }}>
|
|
59
|
-
<AppContent />
|
|
60
|
-
</DebugView>
|
|
61
|
-
```
|
|
52
|
+
Run the app in dev mode, then tap `DBG`.
|
|
62
53
|
|
|
63
|
-
|
|
54
|
+
Start the desktop daemon:
|
|
64
55
|
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
<NavigationContainer ref={navigationRef}>
|
|
68
|
-
<AppContent />
|
|
69
|
-
</NavigationContainer>
|
|
70
|
-
</DebugView>
|
|
56
|
+
```bash
|
|
57
|
+
npx debug-toolkit --daemon-only
|
|
71
58
|
```
|
|
72
59
|
|
|
73
|
-
|
|
60
|
+
Open the Web Console:
|
|
74
61
|
|
|
75
|
-
```
|
|
76
|
-
|
|
62
|
+
```text
|
|
63
|
+
http://127.0.0.1:3799/console
|
|
77
64
|
```
|
|
78
65
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```tsx
|
|
82
|
-
import { addTrackLog } from 'react-native-debug-toolkit';
|
|
66
|
+
In the app, open Debug Panel -> gear -> `Send Once` or `Start Live Sync`.
|
|
83
67
|
|
|
84
|
-
|
|
85
|
-
```
|
|
68
|
+
## Device Setup
|
|
86
69
|
|
|
87
|
-
|
|
70
|
+
| Runtime | App endpoint |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| iOS simulator | `http://localhost:3799` |
|
|
73
|
+
| Android emulator | `http://10.0.2.2:3799` |
|
|
74
|
+
| Real device | `http://<mac-ip>:3799` |
|
|
88
75
|
|
|
89
|
-
|
|
76
|
+
For a real device, first open this URL in the phone browser:
|
|
90
77
|
|
|
91
|
-
```
|
|
92
|
-
|
|
78
|
+
```text
|
|
79
|
+
http://<mac-ip>:3799/health
|
|
93
80
|
```
|
|
94
81
|
|
|
95
|
-
|
|
96
|
-
Override it with `--store /path/to/devices.json` or `DEBUG_TOOLKIT_DAEMON_STORE`.
|
|
82
|
+
If it does not open, check Mac firewall, Wi-Fi isolation, VPN, local network permission, and cleartext HTTP settings.
|
|
97
83
|
|
|
98
|
-
|
|
84
|
+
The daemon stores logs at:
|
|
99
85
|
|
|
100
86
|
```text
|
|
101
|
-
|
|
87
|
+
~/.react-native-debug-toolkit/daemon-devices.json
|
|
102
88
|
```
|
|
103
89
|
|
|
104
|
-
|
|
90
|
+
Custom store path:
|
|
105
91
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
| iOS simulator | `http://localhost:3799` |
|
|
111
|
-
| Android emulator | `http://10.0.2.2:3799` |
|
|
112
|
-
| Real device | `http://<mac-ip>:3799` |
|
|
92
|
+
```bash
|
|
93
|
+
npx debug-toolkit --daemon-only --store /path/to/devices.json
|
|
94
|
+
DEBUG_TOOLKIT_DAEMON_STORE=/path/to/devices.json npx debug-toolkit --daemon-only
|
|
95
|
+
```
|
|
113
96
|
|
|
114
|
-
|
|
97
|
+
## Read Logs With HTTP
|
|
115
98
|
|
|
116
|
-
|
|
99
|
+
HTTP is the best path when your AI agent or script has shell access.
|
|
117
100
|
|
|
118
101
|
```bash
|
|
119
102
|
BASE=http://127.0.0.1:3799
|
|
@@ -124,10 +107,11 @@ curl "$BASE/devices/latest"
|
|
|
124
107
|
|
|
125
108
|
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
109
|
|
|
127
|
-
curl "$BASE/devices/$DEVICE_ID"
|
|
128
110
|
curl "$BASE/devices/$DEVICE_ID/logs?limit=100"
|
|
129
111
|
curl "$BASE/devices/$DEVICE_ID/logs?type=network&failedOnly=true&limit=50"
|
|
130
112
|
curl "$BASE/devices/$DEVICE_ID/logs?type=console&limit=100"
|
|
113
|
+
curl "$BASE/devices/$DEVICE_ID/logs?entryId=<entryId>"
|
|
114
|
+
curl "$BASE/devices/$DEVICE_ID/logs?limit=100&includeBodies=true"
|
|
131
115
|
curl -X DELETE "$BASE/devices"
|
|
132
116
|
```
|
|
133
117
|
|
|
@@ -140,13 +124,13 @@ POST /ingest
|
|
|
140
124
|
GET /devices
|
|
141
125
|
GET /devices/latest
|
|
142
126
|
GET /devices/:deviceId
|
|
143
|
-
GET /devices/:deviceId/logs
|
|
127
|
+
GET /devices/:deviceId/logs?type=&limit=&failedOnly=&includeBodies=&entryId=
|
|
144
128
|
DELETE /devices
|
|
145
129
|
GET /events
|
|
146
130
|
GET /console
|
|
147
131
|
```
|
|
148
132
|
|
|
149
|
-
## MCP
|
|
133
|
+
## Use MCP
|
|
150
134
|
|
|
151
135
|
```bash
|
|
152
136
|
claude mcp add debug-toolkit -- npx debug-toolkit
|
|
@@ -157,7 +141,41 @@ Tools:
|
|
|
157
141
|
- `list_app_devices`
|
|
158
142
|
- `get_app_logs`
|
|
159
143
|
|
|
160
|
-
|
|
144
|
+
`get_app_logs` excludes bodies by default to reduce tokens. Set `includeBodies=true` or pass `entryId` to fetch one full log entry.
|
|
145
|
+
|
|
146
|
+
## App Options
|
|
147
|
+
|
|
148
|
+
Disable features:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
<DebugView features={{ clipboard: false, zustand: false }}>
|
|
152
|
+
<AppContent />
|
|
153
|
+
</DebugView>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Navigation tracking:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<DebugView navigationRef={navigationRef}>
|
|
160
|
+
<NavigationContainer ref={navigationRef}>
|
|
161
|
+
<AppContent />
|
|
162
|
+
</NavigationContainer>
|
|
163
|
+
</DebugView>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Zustand:
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { zustandLogMiddleware } from 'react-native-debug-toolkit';
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Track:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import { addTrackLog } from 'react-native-debug-toolkit';
|
|
176
|
+
|
|
177
|
+
addTrackLog({ eventName: 'button_click' });
|
|
178
|
+
```
|
|
161
179
|
|
|
162
180
|
## Exports
|
|
163
181
|
|
|
@@ -173,11 +191,11 @@ Use curl when shell is available.
|
|
|
173
191
|
- `autoDetectDaemonIp`
|
|
174
192
|
- feature factories and types
|
|
175
193
|
|
|
176
|
-
##
|
|
194
|
+
## Limits
|
|
177
195
|
|
|
178
196
|
- Dev tool, not production monitoring.
|
|
179
197
|
- Local daemon, not cloud replay.
|
|
180
|
-
- Network
|
|
198
|
+
- Network capture observes traffic; it does not analyze auth, tokens, or business errors.
|
|
181
199
|
- No default redaction.
|
|
182
200
|
- Not a React Native DevTools replacement.
|
|
183
201
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
# React Native Debug Toolkit
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[English](README.md)
|
|
6
6
|
|
|
7
|
-
|
|
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
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
##
|
|
36
|
+
## 快速开始
|
|
37
|
+
|
|
38
|
+
包住你的 App:
|
|
40
39
|
|
|
41
40
|
```tsx
|
|
42
41
|
import { DebugView } from 'react-native-debug-toolkit';
|
|
@@ -50,70 +49,54 @@ export function App() {
|
|
|
50
49
|
}
|
|
51
50
|
```
|
|
52
51
|
|
|
53
|
-
开发模式打开 App
|
|
54
|
-
|
|
55
|
-
禁用功能:
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
<DebugView features={{ clipboard: false, zustand: false }}>
|
|
59
|
-
<AppContent />
|
|
60
|
-
</DebugView>
|
|
61
|
-
```
|
|
52
|
+
开发模式打开 App,点击 `DBG`。
|
|
62
53
|
|
|
63
|
-
|
|
54
|
+
启动桌面 daemon:
|
|
64
55
|
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
<NavigationContainer ref={navigationRef}>
|
|
68
|
-
<AppContent />
|
|
69
|
-
</NavigationContainer>
|
|
70
|
-
</DebugView>
|
|
56
|
+
```bash
|
|
57
|
+
npx debug-toolkit --daemon-only
|
|
71
58
|
```
|
|
72
59
|
|
|
73
|
-
|
|
60
|
+
打开 Web Console:
|
|
74
61
|
|
|
75
|
-
```
|
|
76
|
-
|
|
62
|
+
```text
|
|
63
|
+
http://127.0.0.1:3799/console
|
|
77
64
|
```
|
|
78
65
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```tsx
|
|
82
|
-
import { addTrackLog } from 'react-native-debug-toolkit';
|
|
66
|
+
App 内打开 Debug Panel -> 齿轮 -> `Send Once` 或 `Start Live Sync`。
|
|
83
67
|
|
|
84
|
-
|
|
85
|
-
```
|
|
68
|
+
## 设备连接
|
|
86
69
|
|
|
87
|
-
|
|
70
|
+
| 运行时 | App endpoint |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| iOS simulator | `http://localhost:3799` |
|
|
73
|
+
| Android emulator | `http://10.0.2.2:3799` |
|
|
74
|
+
| 真机 | `http://<mac-ip>:3799` |
|
|
88
75
|
|
|
89
|
-
|
|
76
|
+
真机先用手机浏览器打开:
|
|
90
77
|
|
|
91
|
-
```
|
|
92
|
-
|
|
78
|
+
```text
|
|
79
|
+
http://<mac-ip>:3799/health
|
|
93
80
|
```
|
|
94
81
|
|
|
95
|
-
|
|
96
|
-
可用 `--store /path/to/devices.json` 或 `DEBUG_TOOLKIT_DAEMON_STORE` 覆盖。
|
|
82
|
+
打不开就检查 Mac 防火墙、Wi-Fi 隔离、VPN、本地网络权限、明文 HTTP 配置。
|
|
97
83
|
|
|
98
|
-
|
|
84
|
+
daemon 默认日志文件:
|
|
99
85
|
|
|
100
86
|
```text
|
|
101
|
-
|
|
87
|
+
~/.react-native-debug-toolkit/daemon-devices.json
|
|
102
88
|
```
|
|
103
89
|
|
|
104
|
-
|
|
90
|
+
自定义存储路径:
|
|
105
91
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
| iOS simulator | `http://localhost:3799` |
|
|
111
|
-
| Android emulator | `http://10.0.2.2:3799` |
|
|
112
|
-
| 真机 | `http://<mac-ip>:3799` |
|
|
92
|
+
```bash
|
|
93
|
+
npx debug-toolkit --daemon-only --store /path/to/devices.json
|
|
94
|
+
DEBUG_TOOLKIT_DAEMON_STORE=/path/to/devices.json npx debug-toolkit --daemon-only
|
|
95
|
+
```
|
|
113
96
|
|
|
114
|
-
|
|
97
|
+
## 用 HTTP 读取日志
|
|
115
98
|
|
|
116
|
-
|
|
99
|
+
AI 或脚本有 shell 时,优先用 HTTP。
|
|
117
100
|
|
|
118
101
|
```bash
|
|
119
102
|
BASE=http://127.0.0.1:3799
|
|
@@ -124,10 +107,11 @@ curl "$BASE/devices/latest"
|
|
|
124
107
|
|
|
125
108
|
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
109
|
|
|
127
|
-
curl "$BASE/devices/$DEVICE_ID"
|
|
128
110
|
curl "$BASE/devices/$DEVICE_ID/logs?limit=100"
|
|
129
111
|
curl "$BASE/devices/$DEVICE_ID/logs?type=network&failedOnly=true&limit=50"
|
|
130
112
|
curl "$BASE/devices/$DEVICE_ID/logs?type=console&limit=100"
|
|
113
|
+
curl "$BASE/devices/$DEVICE_ID/logs?entryId=<entryId>"
|
|
114
|
+
curl "$BASE/devices/$DEVICE_ID/logs?limit=100&includeBodies=true"
|
|
131
115
|
curl -X DELETE "$BASE/devices"
|
|
132
116
|
```
|
|
133
117
|
|
|
@@ -140,13 +124,13 @@ POST /ingest
|
|
|
140
124
|
GET /devices
|
|
141
125
|
GET /devices/latest
|
|
142
126
|
GET /devices/:deviceId
|
|
143
|
-
GET /devices/:deviceId/logs
|
|
127
|
+
GET /devices/:deviceId/logs?type=&limit=&failedOnly=&includeBodies=&entryId=
|
|
144
128
|
DELETE /devices
|
|
145
129
|
GET /events
|
|
146
130
|
GET /console
|
|
147
131
|
```
|
|
148
132
|
|
|
149
|
-
## MCP
|
|
133
|
+
## 使用 MCP
|
|
150
134
|
|
|
151
135
|
```bash
|
|
152
136
|
claude mcp add debug-toolkit -- npx debug-toolkit
|
|
@@ -157,7 +141,41 @@ claude mcp add debug-toolkit -- npx debug-toolkit
|
|
|
157
141
|
- `list_app_devices`
|
|
158
142
|
- `get_app_logs`
|
|
159
143
|
|
|
160
|
-
|
|
144
|
+
`get_app_logs` 默认不返回 body,减少 token。设置 `includeBodies=true` 或传 `entryId` 可读取单条完整日志。
|
|
145
|
+
|
|
146
|
+
## App 配置
|
|
147
|
+
|
|
148
|
+
禁用功能:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
<DebugView features={{ clipboard: false, zustand: false }}>
|
|
152
|
+
<AppContent />
|
|
153
|
+
</DebugView>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
导航追踪:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<DebugView navigationRef={navigationRef}>
|
|
160
|
+
<NavigationContainer ref={navigationRef}>
|
|
161
|
+
<AppContent />
|
|
162
|
+
</NavigationContainer>
|
|
163
|
+
</DebugView>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Zustand:
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { zustandLogMiddleware } from 'react-native-debug-toolkit';
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Track:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import { addTrackLog } from 'react-native-debug-toolkit';
|
|
176
|
+
|
|
177
|
+
addTrackLog({ eventName: 'button_click' });
|
|
178
|
+
```
|
|
161
179
|
|
|
162
180
|
## 导出
|
|
163
181
|
|
|
@@ -177,7 +195,7 @@ claude mcp add debug-toolkit -- npx debug-toolkit
|
|
|
177
195
|
|
|
178
196
|
- 开发工具,不是生产监控。
|
|
179
197
|
- 本地 daemon,不是云 replay。
|
|
180
|
-
- Network
|
|
198
|
+
- Network 只观察流量,不自动分析 auth、token、业务错误。
|
|
181
199
|
- 不默认脱敏。
|
|
182
200
|
- 不替代 React Native DevTools。
|
|
183
201
|
|
package/bin/debug-toolkit.js
CHANGED
|
@@ -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`);
|