tauri-plugin-debug-tools 0.1.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 (82) hide show
  1. package/AGENTS.md +346 -0
  2. package/LICENSE +21 -0
  3. package/README.md +303 -0
  4. package/dist-js/consoleLogger.d.ts +92 -0
  5. package/dist-js/consoleLogger.d.ts.map +1 -0
  6. package/dist-js/consoleLogger.js +317 -0
  7. package/dist-js/debugBridge.d.ts +50 -0
  8. package/dist-js/debugBridge.d.ts.map +1 -0
  9. package/dist-js/debugBridge.js +66 -0
  10. package/dist-js/index.d.ts +3 -0
  11. package/dist-js/index.d.ts.map +1 -0
  12. package/dist-js/index.js +2 -0
  13. package/dist-js/logAdapter.d.ts +36 -0
  14. package/dist-js/logAdapter.d.ts.map +1 -0
  15. package/dist-js/logAdapter.js +42 -0
  16. package/dist-js/screenshotHelper.d.ts +60 -0
  17. package/dist-js/screenshotHelper.d.ts.map +1 -0
  18. package/dist-js/screenshotHelper.js +100 -0
  19. package/examples/.vscode/extensions.json +3 -0
  20. package/examples/README.md +51 -0
  21. package/examples/bun.lock +265 -0
  22. package/examples/package.json +19 -0
  23. package/examples/src/assets/javascript.svg +1 -0
  24. package/examples/src/assets/tauri.svg +6 -0
  25. package/examples/src/index.html +56 -0
  26. package/examples/src/main.js +91 -0
  27. package/examples/src/styles.css +112 -0
  28. package/examples/src-tauri/Cargo.lock +5674 -0
  29. package/examples/src-tauri/Cargo.toml +25 -0
  30. package/examples/src-tauri/build.rs +3 -0
  31. package/examples/src-tauri/capabilities/default.json +7 -0
  32. package/examples/src-tauri/icons/128x128.png +0 -0
  33. package/examples/src-tauri/icons/128x128@2x.png +0 -0
  34. package/examples/src-tauri/icons/32x32.png +0 -0
  35. package/examples/src-tauri/icons/Square107x107Logo.png +0 -0
  36. package/examples/src-tauri/icons/Square142x142Logo.png +0 -0
  37. package/examples/src-tauri/icons/Square150x150Logo.png +0 -0
  38. package/examples/src-tauri/icons/Square284x284Logo.png +0 -0
  39. package/examples/src-tauri/icons/Square30x30Logo.png +0 -0
  40. package/examples/src-tauri/icons/Square310x310Logo.png +0 -0
  41. package/examples/src-tauri/icons/Square44x44Logo.png +0 -0
  42. package/examples/src-tauri/icons/Square71x71Logo.png +0 -0
  43. package/examples/src-tauri/icons/Square89x89Logo.png +0 -0
  44. package/examples/src-tauri/icons/StoreLogo.png +0 -0
  45. package/examples/src-tauri/icons/icon.icns +0 -0
  46. package/examples/src-tauri/icons/icon.ico +0 -0
  47. package/examples/src-tauri/icons/icon.png +0 -0
  48. package/examples/src-tauri/src/lib.rs +15 -0
  49. package/examples/src-tauri/src/main.rs +6 -0
  50. package/examples/src-tauri/tauri.conf.json +33 -0
  51. package/examples/tests/e2e.mac.test.ts +203 -0
  52. package/examples/tests/e2e.test.ts +131 -0
  53. package/examples/vitest.config.ts +10 -0
  54. package/guest-js/consoleLogger.ts +369 -0
  55. package/guest-js/debugBridge.ts +93 -0
  56. package/guest-js/index.ts +2 -0
  57. package/guest-js/logAdapter.ts +62 -0
  58. package/guest-js/screenshotHelper.ts +122 -0
  59. package/package.json +84 -0
  60. package/permissions/autogenerated/commands/append_debug_logs.toml +13 -0
  61. package/permissions/autogenerated/commands/capture_webview_state.toml +13 -0
  62. package/permissions/autogenerated/commands/get_console_logs.toml +13 -0
  63. package/permissions/autogenerated/commands/reset_debug_logs.toml +13 -0
  64. package/permissions/autogenerated/commands/send_debug_command.toml +13 -0
  65. package/permissions/autogenerated/commands/write_debug_snapshot.toml +13 -0
  66. package/permissions/autogenerated/reference.md +201 -0
  67. package/permissions/debug-with-logging.toml +26 -0
  68. package/permissions/default.toml +26 -0
  69. package/permissions/schemas/schema.json +384 -0
  70. package/skills/debug-tauri/SKILL.md +114 -0
  71. package/skills/debug-tauri/references/IPC_COMMANDS.md +196 -0
  72. package/skills/debug-tauri/references/LOGGING.md +195 -0
  73. package/skills/debug-tauri/references/MIGRATION.md +487 -0
  74. package/skills/debug-tauri/references/REFERENCE.md +206 -0
  75. package/skills/debug-tauri/references/REPORT_TEMPLATE.md +166 -0
  76. package/skills/debug-tauri/references/SCREENSHOTS.md +193 -0
  77. package/skills/debug-tauri/references/TROUBLESHOOTING.md +144 -0
  78. package/skills/debug-tauri/scripts/analyze_logs.sh +127 -0
  79. package/skills/debug-tauri/scripts/capture.sh +89 -0
  80. package/skills/debug-tauri/scripts/validate_setup.sh +181 -0
  81. package/src/commands.rs +147 -0
  82. package/src/lib.rs +41 -0
package/AGENTS.md ADDED
@@ -0,0 +1,346 @@
1
+ # Agent Development Guide
2
+
3
+ > Guidance for AI agents working with tauri-plugin-debug-tools
4
+
5
+ ## Project Overview
6
+
7
+ **tauri-plugin-debug-tools** is a Tauri plugin that provides comprehensive debugging utilities for WebView applications. It combines a Rust backend (Tauri plugin) with a TypeScript frontend (log collection and state inspection) and includes an AI-powered debugging skill for AI agents.
8
+
9
+ ## Architecture
10
+
11
+ ### Components
12
+
13
+ ```
14
+ tauri-plugin-debug-tools/
15
+ ├── src/ # Rust backend (Tauri plugin)
16
+ │ ├── lib.rs # Plugin initialization
17
+ │ └── commands.rs # Tauri command implementations
18
+ ├── guest-js/ # TypeScript frontend
19
+ │ ├── consoleLogger.ts # Log collection system
20
+ │ ├── debugBridge.ts # Backend IPC bridge
21
+ │ └── index.ts # Public exports
22
+ ├── skills/debug-tauri/ # Agent Skill
23
+ │ ├── SKILL.md # Skill definition
24
+ │ ├── references/REFERENCE.md # Technical reference
25
+ │ └── scripts/capture.sh # Screenshot helper script
26
+ ├── permissions/ # Tauri permission schemas
27
+ ├── build.rs # Build script
28
+ ├── Cargo.toml # Rust dependencies
29
+ ├── package.json # TypeScript dependencies
30
+ └── tsconfig.json # TypeScript configuration
31
+ ```
32
+
33
+ ### Key Technologies
34
+
35
+ - **Rust**: Tauri plugin backend (edition 2021)
36
+ - **TypeScript**: Frontend utilities (v5.0+)
37
+ - **Tauri**: v2.9.5
38
+ - **Bun**: Package manager & runtime
39
+ - **Biome**: Linting & formatting
40
+
41
+ ## Design Patterns
42
+
43
+ ### 1. Ring Buffer Log Collection
44
+
45
+ [guest-js/consoleLogger.ts](guest-js/consoleLogger.ts) implements a sophisticated logging system:
46
+
47
+ - **Ring Buffer**: Max 1,000 entries, auto-drops oldest
48
+ - **Batched Flushing**: Every 1s or 200 pending logs
49
+ - **Global Error Handling**: Captures `error` and `unhandledrejection` events
50
+ - **Stack Trace Normalization**: Filters internal frames
51
+ - **Zero Dependencies**: No Safari DevTools required
52
+
53
+ **Key Design Decision**: Logs are collected in-memory on the frontend and periodically flushed to the system temp directory (for example, `/tmp/tauri_console_logs.jsonl`) via Tauri IPC. This avoids blocking the main thread and provides resilience against IPC failures.
54
+
55
+ ### 2. Event-Based Debug Commands
56
+
57
+ Debug commands use Tauri's event system for safe, CSP-compliant communication:
58
+
59
+ ```rust
60
+ // src/commands.rs
61
+ window.emit("debug-command", (command, payload))
62
+ ```
63
+
64
+ This approach:
65
+
66
+ - Preserves Content Security Policy compliance
67
+ - Avoids dynamic code execution
68
+ - Allows frontend handlers to process commands safely
69
+
70
+ ### 3. System Command Integration
71
+
72
+ Screenshot functionality delegates to system commands (e.g., macOS `screencapture`) rather than implementing platform-specific capture logic. This reduces dependencies and leverages battle-tested tools.
73
+
74
+ ## Common Tasks
75
+
76
+ ### Adding a New Tauri Command
77
+
78
+ 1. **Define the command** in [src/commands.rs](src/commands.rs):
79
+
80
+ ```rust
81
+ #[tauri::command]
82
+ pub async fn my_new_command<R: Runtime>(
83
+ app: AppHandle<R>,
84
+ param: String,
85
+ ) -> Result<String, String> {
86
+ // Implementation
87
+ Ok("success".to_string())
88
+ }
89
+ ```
90
+
91
+ 1. **Register the command** in [src/lib.rs](src/lib.rs):
92
+
93
+ ```rust
94
+ .invoke_handler(tauri::generate_handler![
95
+ // ... existing commands
96
+ commands::my_new_command,
97
+ ])
98
+ ```
99
+
100
+ 1. **Add to build script** in [build.rs](build.rs):
101
+
102
+ ```rust
103
+ const COMMANDS: &[&str] = &[
104
+ // ... existing commands
105
+ "my_new_command",
106
+ ];
107
+ ```
108
+
109
+ 1. **Create TypeScript wrapper** in [guest-js/debugBridge.ts](guest-js/debugBridge.ts):
110
+
111
+ ```typescript
112
+ export async function myNewCommand(param: string): Promise<string> {
113
+ return await invoke<string>("plugin:debug-tools|my_new_command", { param });
114
+ }
115
+ ```
116
+
117
+ 1. **Update exports** in [guest-js/index.ts](guest-js/index.ts) if needed.
118
+
119
+ ### Extending Console Logger
120
+
121
+ To add custom log processing:
122
+
123
+ 1. **Modify [guest-js/consoleLogger.ts](guest-js/consoleLogger.ts)**:
124
+
125
+ ```typescript
126
+ class ConsoleLogCollector {
127
+ // Add new method
128
+ public filterByPattern(pattern: RegExp): ConsoleLogEntry[] {
129
+ return this.logs.filter(log => pattern.test(log.message));
130
+ }
131
+ }
132
+
133
+ // Export at bottom
134
+ export const filterLogsByPattern = (pattern: RegExp) =>
135
+ consoleLogger.filterByPattern(pattern);
136
+ ```
137
+
138
+ 1. **Update TypeScript types** if adding new log properties.
139
+
140
+ ### Modifying the Agent Skill
141
+
142
+ The skill is defined in [skills/debug-tauri/SKILL.md](skills/debug-tauri/SKILL.md):
143
+
144
+ - **Frontmatter**: Contains skill metadata (name, description)
145
+ - **Workflow Section**: Defines the debugging process
146
+ - **Debug Report Template**: Standardizes output format
147
+
148
+ When updating the skill:
149
+
150
+ 1. Modify the workflow steps to match new capabilities
151
+ 2. Update the debug report template if new data is collected
152
+ 3. Update [skills/debug-tauri/references/REFERENCE.md](skills/debug-tauri/references/REFERENCE.md) with new command documentation
153
+
154
+ ## Development Workflow
155
+
156
+ ### Building
157
+
158
+ ```bash
159
+ # Install dependencies
160
+ bun install
161
+
162
+ # Build TypeScript
163
+ npm run build
164
+
165
+ # This generates:
166
+ # - dist/index.js & dist/index.d.ts
167
+ # - dist/consoleLogger.js & dist/consoleLogger.d.ts
168
+ # - dist/debugBridge.js & dist/debugBridge.d.ts
169
+ ```
170
+
171
+ ### Linting & Formatting
172
+
173
+ ```bash
174
+ # Run all linters
175
+ npm run lint
176
+
177
+ # Check Biome rules
178
+ npm run lint:biome
179
+
180
+ # Check TypeScript types
181
+ npm run lint:tsc
182
+
183
+ # Auto-fix issues
184
+ npm run format
185
+ ```
186
+
187
+ ### Testing the Plugin
188
+
189
+ Since this is a Tauri plugin, testing requires a host Tauri application:
190
+
191
+ 1. Create a test Tauri app or use an existing one
192
+ 2. Add the plugin as a dependency:
193
+
194
+ ```toml
195
+ [dependencies]
196
+ tauri-plugin-debug-tools = { path = "../tauri-plugin-debug-tools" }
197
+ ```
198
+
199
+ 3. Register the plugin and enable permissions
200
+ 4. Run `tauri dev` and test IPC commands
201
+
202
+ ## Important Constraints
203
+
204
+ ### Platform-Specific Code
205
+
206
+ - **Log File Paths**: Currently hardcoded to `/tmp/` (Unix-like systems only)
207
+ - **Screenshot**: Uses macOS `screencapture` command
208
+ - **User-Agent**: Hardcoded to `"TauriWebView/2.0"` (TODO: fetch real UA)
209
+
210
+ For cross-platform support:
211
+
212
+ ```rust
213
+ // Use this instead of "/tmp/"
214
+ let temp_dir = std::env::temp_dir();
215
+ let log_path = temp_dir.join("tauri_console_logs.jsonl");
216
+ ```
217
+
218
+ ### Performance Considerations
219
+
220
+ - **Log Buffer Size**: Limited to 1,000 entries to prevent memory bloat
221
+ - **Batch Size**: Max 200 logs per flush to avoid blocking IPC
222
+ - **Screenshot**: Delegated to system command (no in-process capture)
223
+
224
+ ### Security Considerations
225
+
226
+ - **Event-Based Communication**: All commands use Tauri events (no dynamic code execution)
227
+ - **CSP Compliant**: No inline scripts or unsafe constructs
228
+ - **Sandboxed**: Tauri security model enforced
229
+ - **Log Sanitization**: Stack traces are normalized to remove sensitive paths
230
+
231
+ ## Code Style
232
+
233
+ ### Rust
234
+
235
+ - **Edition**: 2021
236
+ - **Style**: Standard Rust formatting (`rustfmt`)
237
+ - **Error Handling**: Return `Result<T, String>` from commands
238
+ - **Async**: Use `async fn` for all commands
239
+
240
+ ### TypeScript
241
+
242
+ - **Target**: ES2020+ (module)
243
+ - **Strict Mode**: Enabled
244
+ - **Formatting**: Biome (configured in [package.json](package.json))
245
+ - **Naming**:
246
+ - Functions: `camelCase`
247
+ - Types/Interfaces: `PascalCase`
248
+ - Constants: `UPPER_SNAKE_CASE` (if truly constant)
249
+
250
+ ### Documentation
251
+
252
+ - **README**: Comprehensive user guide with examples
253
+ - **AGENTS.md**: This file - agent development guide
254
+ - **SKILL.md**: Skill definition in YAML frontmatter + Markdown body
255
+ - **REFERENCE.md**: Technical reference for IPC commands
256
+ - **Inline Comments**: Explain "why", not "what"
257
+
258
+ ## Testing Strategy
259
+
260
+ ### Manual Testing Checklist
261
+
262
+ When making changes, verify:
263
+
264
+ - [ ] TypeScript builds without errors (`npm run build`)
265
+ - [ ] All linters pass (`npm run lint`)
266
+ - [ ] Plugin registers in host app without errors
267
+ - [ ] IPC commands return expected results
268
+ - [ ] Console logger captures logs correctly
269
+ - [ ] Logs flush to system temp dir (for example, `/tmp/tauri_console_logs.jsonl`)
270
+ - [ ] Agent skill can be invoked (`/debug-tauri`)
271
+ - [ ] Screenshot capture works (macOS)
272
+
273
+ ### Future: Automated Testing
274
+
275
+ Consider adding:
276
+
277
+ - Unit tests for TypeScript utilities (`vitest`)
278
+ - Integration tests for Tauri commands (`tauri-driver`)
279
+ - E2E tests for the agent skill
280
+
281
+ ## Common Pitfalls
282
+
283
+ ### 1. Window Label Mismatch
284
+
285
+ The plugin assumes the main window is labeled `"main"`. If your app uses a different label:
286
+
287
+ ```rust
288
+ // src/commands.rs - update this
289
+ let window = app.get_webview_window("main") // Change to your label
290
+ ```
291
+
292
+ ### 2. Permission Not Enabled
293
+
294
+ Users must add `"debug-tools:default"` to their app's capabilities. If commands fail with permission errors, this is likely the cause.
295
+
296
+ ### 3. Tauri Ready Event Timing
297
+
298
+ The console logger waits for `window.__TAURI__` or `tauri://ready` event before flushing logs. If logs aren't being saved, check that:
299
+
300
+ - Tauri API is loaded before the logger
301
+ - No JavaScript errors prevent the event from firing
302
+
303
+ ### 4. TypeScript Build Not Included
304
+
305
+ Remember to run `npm run build` before publishing or testing. The `dist/` folder is what gets imported by users.
306
+
307
+ ## Release Checklist
308
+
309
+ Before releasing a new version:
310
+
311
+ 1. [ ] Update version in [Cargo.toml](Cargo.toml) and [package.json](package.json)
312
+ 2. [ ] Update [README.md](README.md) with new features
313
+ 3. [ ] Run `npm run build` and commit `dist/`
314
+ 4. [ ] Run `npm run lint` (all checks must pass)
315
+ 5. [ ] Test with a real Tauri app
316
+ 6. [ ] Update [skills/debug-tauri/SKILL.md](skills/debug-tauri/SKILL.md) if workflow changed
317
+ 7. [ ] Tag release: `git tag v0.x.0`
318
+ 8. [ ] Push tag: `git push origin v0.x.0`
319
+
320
+ ## Resources
321
+
322
+ ### Official Documentation
323
+
324
+ - [Tauri Plugin Development](https://tauri.app/develop/plugins/)
325
+ - [Tauri IPC Guide](https://v2.tauri.app/develop/calling-rust/)
326
+ - [Claude Code Skills](https://code.claude.com/docs/skills)
327
+
328
+ ### Internal References
329
+
330
+ - [Technical Reference](skills/debug-tauri/references/REFERENCE.md) - IPC command details
331
+ - [Skill Definition](skills/debug-tauri/SKILL.md) - Agent workflow
332
+ - [README](README.md) - User documentation
333
+
334
+ ## Support
335
+
336
+ For questions or issues:
337
+
338
+ - GitHub Issues: (repository URL)
339
+ - Discord: (community link)
340
+ - Email: (maintainer email)
341
+
342
+ ---
343
+
344
+ **Last Updated**: 2025-12-31
345
+ **Version**: 0.1.0
346
+ **Maintainer**: (your name/team)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 sadao komaki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,303 @@
1
+ # tauri-plugin-debug-tools
2
+
3
+ Comprehensive debug utilities for Tauri WebView applications with AI-powered automated debugging workflows.
4
+
5
+ ## Features
6
+
7
+ - **WebView State Capture** - Capture URL, title, viewport, and User-Agent
8
+ - **Console Log Collection** - Ring-buffer based log collection with batched flushing
9
+ - **Screenshot Integration** - System screenshot command integration
10
+ - **AI Agent Skill** - Automated debugging workflow for AI agents
11
+ - **Debug Snapshots** - Save comprehensive debug state to disk
12
+ - **Event-based Communication** - Send debug commands to frontend via Tauri events
13
+
14
+ ## Quick Start
15
+
16
+ ### Installation
17
+
18
+ Add to your Tauri project's `Cargo.toml`:
19
+
20
+ ```toml
21
+ [dependencies]
22
+ tauri-plugin-debug-tools = "0.1.0"
23
+ ```
24
+
25
+ Install the frontend package:
26
+
27
+ ```bash
28
+ npm install tauri-plugin-debug-tools
29
+ # or
30
+ bun add tauri-plugin-debug-tools
31
+ ```
32
+
33
+ ### Setup
34
+
35
+ **1. Register the plugin** in your Tauri app:
36
+
37
+ ```rust
38
+ // src-tauri/src/main.rs or lib.rs
39
+ fn main() {
40
+ tauri::Builder::default()
41
+ .plugin(tauri_plugin_debug_tools::init())
42
+ .run(tauri::generate_context!())
43
+ .expect("error while running tauri application");
44
+ }
45
+ ```
46
+
47
+ **2. Configure the plugin (optional)** in your `tauri.conf.json` if you want to override defaults:
48
+
49
+ ```json
50
+ {
51
+ "plugins": {
52
+ "debug-tools": {
53
+ "timeout": 30
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ If you don't need custom configuration, you can omit this section.
60
+
61
+ **3. Enable permissions** in `src-tauri/capabilities/default.json`:
62
+
63
+ ```json
64
+ {
65
+ "permissions": [
66
+ "debug-tools:default"
67
+ ]
68
+ }
69
+ ```
70
+
71
+ **4. Initialize frontend logger** in your app entry point:
72
+
73
+ ```typescript
74
+ // src/main.ts or src/App.tsx
75
+ import { debugTools } from "tauri-plugin-debug-tools/consoleLogger";
76
+
77
+ // Use instead of console.*
78
+ debugTools.log("Application started");
79
+ debugTools.error("Something went wrong");
80
+
81
+ // Or import individual functions
82
+ import { log, error, warn } from "tauri-plugin-debug-tools/consoleLogger";
83
+ ```
84
+
85
+ ## Usage
86
+
87
+ ### Frontend API
88
+
89
+ #### Console Logging
90
+
91
+ ```typescript
92
+ import { debugTools, consoleLogger } from "tauri-plugin-debug-tools/consoleLogger";
93
+
94
+ // Log messages (automatically collected)
95
+ debugTools.log("Info message");
96
+ debugTools.warn("Warning message");
97
+ debugTools.error("Error message", { context: "data" });
98
+
99
+ // Retrieve logs
100
+ const allLogs = consoleLogger.getLogs();
101
+ const errors = consoleLogger.getErrors();
102
+ const recent = consoleLogger.getRecentLogs(50);
103
+
104
+ // Get statistics
105
+ const stats = consoleLogger.getStats();
106
+ // { total: 150, byLevel: { log: 100, warn: 30, error: 20, info: 0, debug: 0 } }
107
+ ```
108
+
109
+ #### WebView State Inspection
110
+
111
+ ```typescript
112
+ import { captureWebViewState } from "tauri-plugin-debug-tools/debugBridge";
113
+
114
+ const state = await captureWebViewState();
115
+ console.log(state);
116
+ // {
117
+ // url: "http://localhost:5173",
118
+ // title: "My App",
119
+ // user_agent: "TauriWebView/2.0",
120
+ // viewport: { width: 1200, height: 800 }
121
+ // }
122
+ ```
123
+
124
+ #### Debug Commands
125
+
126
+ ```typescript
127
+ import { sendDebugCommand } from "tauri-plugin-debug-tools/debugBridge";
128
+
129
+ // Send event-based commands to frontend
130
+ await sendDebugCommand("refresh_state", { force: true });
131
+ ```
132
+
133
+ ### Backend Commands
134
+
135
+ All commands are available through the Tauri IPC system:
136
+
137
+ | Command | Description | Output |
138
+ | ------- | ----------- | ------ |
139
+ | `capture_webview_state` | Capture WebView state | `WebViewState` JSON |
140
+ | `get_console_logs` | Legacy console logs | Empty array (use frontend logger) |
141
+ | `send_debug_command` | Send event to frontend | Success message |
142
+ | `append_debug_logs` | Append logs to file | System temp dir (e.g., `/tmp/tauri_console_logs.jsonl`) |
143
+ | `reset_debug_logs` | Clear log file | File path |
144
+ | `write_debug_snapshot` | Save debug snapshot | System temp dir (e.g., `/tmp/tauri_debug_snapshot_*.json`) |
145
+
146
+ ## AI Agent Skill
147
+
148
+ ### Skill Installation
149
+
150
+ Copy the bundled skill to your agent's skills directory:
151
+
152
+ (example: Codex)
153
+
154
+ ```bash
155
+ cp -R skills/debug-tauri ~/.codex/skills/debug-tauri
156
+ ```
157
+
158
+ Or for custom skill directories:
159
+
160
+ ```bash
161
+ cp -R skills/debug-tauri /path/to/your/skills/debug-tauri
162
+ ```
163
+
164
+ ### Skill Usage
165
+
166
+ Invoke the skill to start automated debugging:
167
+
168
+ ```bash
169
+ /debug-tauri
170
+ ```
171
+
172
+ The skill will:
173
+
174
+ 1. ✅ Verify the app process is running
175
+ 2. 📸 Capture a screenshot
176
+ 3. 📝 Collect console logs (via IPC)
177
+ 4. 🔍 Analyze visual and runtime state
178
+ 5. 📄 Generate a comprehensive debug report
179
+ 6. 💡 Propose fixes based on findings
180
+
181
+ ### Example Report
182
+
183
+ ```markdown
184
+ # Tauri Debug Report - 2025-12-31T22:00:00Z
185
+
186
+ ## Screenshot
187
+ /tmp/tauri_debug_1735689600.png
188
+
189
+ ## Process Status
190
+ - Status: Running
191
+ - PID: 12345
192
+
193
+ ## Console Logs
194
+ ### Recent Errors
195
+ - [ERROR] WebGL context lost (timestamp: 1735689550)
196
+ - [ERROR] Failed to load texture.png (timestamp: 1735689555)
197
+
198
+ ### Log Statistics
199
+ - Total: 1,234 logs
200
+ - Errors: 2
201
+ - Warnings: 15
202
+
203
+ ## Visual Analysis
204
+ ### UI State
205
+ Main window visible with rendering artifacts in canvas area.
206
+
207
+ ### Recommendations
208
+ 1. Investigate WebGL context loss - check GPU driver
209
+ 2. Verify texture.png exists in public/ directory
210
+ ```
211
+
212
+ ## Architecture
213
+
214
+ ```mermaid
215
+ flowchart TB
216
+ subgraph DevEnv["Development Environment"]
217
+ subgraph AIAgent["AI Agent (Codex/Claude Code)"]
218
+ Skill["debug-tauri skill<br/>- Process verification<br/>- Screenshot capture<br/>- Log collection<br/>- Analysis & reporting"]
219
+ end
220
+
221
+ subgraph Tauri["Tauri Application"]
222
+ subgraph Frontend["Frontend (TypeScript)"]
223
+ CL["consoleLogger<br/>- Ring buffer (1000 entries)<br/>- Auto flush (1s/200 logs)<br/>- Error handling"]
224
+ DB["debugBridge<br/>- State capture<br/>- Log retrieval<br/>- Debug commands"]
225
+ CL -->|"Logs"| DB
226
+ end
227
+
228
+ subgraph Backend["Backend (Rust)"]
229
+ Plugin["tauri-plugin-debug-tools<br/>- capture_webview_state<br/>- append_debug_logs<br/>- reset_debug_logs<br/>- write_debug_snapshot<br/>- send_debug_command"]
230
+ end
231
+
232
+ DB -->|"Tauri IPC"| Plugin
233
+ CL -->|"Batch flush"| Plugin
234
+ end
235
+
236
+ FS["File System<br/>Temp dir (logs & snapshots)<br/>e.g., /tmp/tauri_console_logs.jsonl"]
237
+
238
+ Plugin -->|"Write logs & snapshots"| FS
239
+ end
240
+
241
+ Skill -->|"1. Verify process"| Tauri
242
+ Skill -->|"2. Invoke IPC commands"| DB
243
+ Skill -->|"3. Read logs & snapshots"| FS
244
+ Skill -->|"4. Capture screenshot"| FS
245
+ FS -->|"5. Analyze & report"| Skill
246
+
247
+ style Frontend fill:#e1f5ff
248
+ style Backend fill:#ffe1e1
249
+ style FS fill:#fff4e1
250
+ style AIAgent fill:#f0e1ff
251
+ style Skill fill:#e8d4ff
252
+ ```
253
+
254
+ ## Log Collection System
255
+
256
+ The plugin uses a sophisticated ring-buffer based logging system:
257
+
258
+ - **Buffer Size**: Max 1,000 log entries (automatically drops oldest)
259
+ - **Batch Flushing**: Every 1 second or 200 pending logs
260
+ - **Auto-initialization**: Starts on module load
261
+ - **Error Handling**: Catches global `error` and `unhandledrejection` events
262
+ - **Stack Traces**: Automatically captures and normalizes stack traces
263
+ - **Zero Config**: No Safari DevTools required
264
+
265
+ ## Development
266
+
267
+ ```bash
268
+ # Install dependencies
269
+ bun install
270
+
271
+ # Build TypeScript
272
+ npm run build
273
+
274
+ # Lint
275
+ npm run lint
276
+
277
+ # Format
278
+ npm run format
279
+ ```
280
+
281
+ ## Platform Support
282
+
283
+ - ✅ macOS (tested)
284
+ - ⚠️ Windows (uses system temp directory for logs/snapshots)
285
+ - ⚠️ Linux (uses system temp directory for logs/snapshots)
286
+
287
+ ## License
288
+
289
+ This project is licensed under either of:
290
+
291
+ - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
292
+ - MIT license ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
293
+
294
+ at your option.
295
+
296
+ ## Contributing
297
+
298
+ Contributions are welcome! Please feel free to submit a Pull Request.
299
+
300
+ ## Related Projects
301
+
302
+ - [Tauri](https://tauri.app) - Build smaller, faster, and more secure desktop applications
303
+ - [Codex](https://github.com/anthropics/anthropic-sdk-typescript) - AI-powered code assistant