tauri-agent-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 (73) hide show
  1. package/.agents/skills/tauri-agent-tools/SKILL.md +104 -0
  2. package/.agents/skills/tauri-bridge-setup/SKILL.md +95 -0
  3. package/AGENTS.md +30 -0
  4. package/LICENSE +21 -0
  5. package/README.md +338 -0
  6. package/dist/bridge/client.d.ts +15 -0
  7. package/dist/bridge/client.js +119 -0
  8. package/dist/bridge/client.js.map +1 -0
  9. package/dist/bridge/tokenDiscovery.d.ts +3 -0
  10. package/dist/bridge/tokenDiscovery.js +77 -0
  11. package/dist/bridge/tokenDiscovery.js.map +1 -0
  12. package/dist/cli.d.ts +2 -0
  13. package/dist/cli.js +49 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/commands/consoleMonitor.d.ts +2 -0
  16. package/dist/commands/consoleMonitor.js +133 -0
  17. package/dist/commands/consoleMonitor.js.map +1 -0
  18. package/dist/commands/dom.d.ts +2 -0
  19. package/dist/commands/dom.js +186 -0
  20. package/dist/commands/dom.js.map +1 -0
  21. package/dist/commands/eval.d.ts +2 -0
  22. package/dist/commands/eval.js +27 -0
  23. package/dist/commands/eval.js.map +1 -0
  24. package/dist/commands/info.d.ts +3 -0
  25. package/dist/commands/info.js +28 -0
  26. package/dist/commands/info.js.map +1 -0
  27. package/dist/commands/ipcMonitor.d.ts +2 -0
  28. package/dist/commands/ipcMonitor.js +122 -0
  29. package/dist/commands/ipcMonitor.js.map +1 -0
  30. package/dist/commands/listWindows.d.ts +3 -0
  31. package/dist/commands/listWindows.js +58 -0
  32. package/dist/commands/listWindows.js.map +1 -0
  33. package/dist/commands/pageState.d.ts +2 -0
  34. package/dist/commands/pageState.js +43 -0
  35. package/dist/commands/pageState.js.map +1 -0
  36. package/dist/commands/screenshot.d.ts +3 -0
  37. package/dist/commands/screenshot.js +81 -0
  38. package/dist/commands/screenshot.js.map +1 -0
  39. package/dist/commands/shared.d.ts +7 -0
  40. package/dist/commands/shared.js +27 -0
  41. package/dist/commands/shared.js.map +1 -0
  42. package/dist/commands/storage.d.ts +2 -0
  43. package/dist/commands/storage.js +110 -0
  44. package/dist/commands/storage.js.map +1 -0
  45. package/dist/commands/wait.d.ts +3 -0
  46. package/dist/commands/wait.js +63 -0
  47. package/dist/commands/wait.js.map +1 -0
  48. package/dist/platform/detect.d.ts +11 -0
  49. package/dist/platform/detect.js +73 -0
  50. package/dist/platform/detect.js.map +1 -0
  51. package/dist/platform/macos.d.ts +8 -0
  52. package/dist/platform/macos.js +111 -0
  53. package/dist/platform/macos.js.map +1 -0
  54. package/dist/platform/wayland.d.ts +10 -0
  55. package/dist/platform/wayland.js +98 -0
  56. package/dist/platform/wayland.js.map +1 -0
  57. package/dist/platform/x11.d.ts +8 -0
  58. package/dist/platform/x11.js +78 -0
  59. package/dist/platform/x11.js.map +1 -0
  60. package/dist/types.d.ts +32 -0
  61. package/dist/types.js +2 -0
  62. package/dist/types.js.map +1 -0
  63. package/dist/util/exec.d.ts +9 -0
  64. package/dist/util/exec.js +31 -0
  65. package/dist/util/exec.js.map +1 -0
  66. package/dist/util/image.d.ts +10 -0
  67. package/dist/util/image.js +23 -0
  68. package/dist/util/image.js.map +1 -0
  69. package/examples/tauri-bridge/Cargo.toml +13 -0
  70. package/examples/tauri-bridge/src/dev_bridge.rs +146 -0
  71. package/examples/tauri-bridge/src/main.rs +16 -0
  72. package/package.json +70 -0
  73. package/rust-bridge/README.md +80 -0
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: tauri-agent-tools
3
+ description: CLI for inspecting Tauri desktop apps — DOM queries, screenshots, IPC/console monitoring, storage, and page state
4
+ version: 0.1.0
5
+ tags: [tauri, desktop, debugging, screenshot, dom, inspection]
6
+ ---
7
+
8
+ # tauri-agent-tools
9
+
10
+ CLI tool for agent-driven inspection of Tauri desktop applications. All commands are **read-only** — no input injection, no writes, no side effects.
11
+
12
+ ## Prerequisites
13
+
14
+ ```bash
15
+ # Check if installed
16
+ which tauri-agent-tools
17
+
18
+ # Install globally if missing
19
+ npm install -g tauri-agent-tools
20
+ ```
21
+
22
+ **System dependencies by platform:**
23
+
24
+ | Platform | Requirements |
25
+ |----------|-------------|
26
+ | Linux X11 | `xdotool`, `imagemagick` (`sudo apt install xdotool imagemagick`) |
27
+ | Linux Wayland/Sway | `swaymsg`, `grim`, `imagemagick` |
28
+ | macOS | `imagemagick` (`brew install imagemagick`), Screen Recording permission |
29
+
30
+ ## Bridge vs Standalone
31
+
32
+ Some commands require the Rust dev bridge running inside the Tauri app. Others work standalone.
33
+
34
+ **Bridge required** (needs running Tauri app with bridge):
35
+ `screenshot --selector`, `dom`, `eval`, `wait --selector`, `wait --eval`, `ipc-monitor`, `console-monitor`, `storage`, `page-state`
36
+
37
+ **Standalone** (no bridge needed):
38
+ `screenshot --title` (full window only), `wait --title`, `list-windows`, `info`
39
+
40
+ The bridge auto-discovers via token files in `/tmp/tauri-dev-bridge-*.token`. No manual port/token configuration needed.
41
+
42
+ ## Core Workflows
43
+
44
+ ### Inspect DOM then screenshot an element
45
+
46
+ ```bash
47
+ # 1. Find the target app
48
+ tauri-agent-tools list-windows --tauri
49
+
50
+ # 2. Explore DOM structure
51
+ tauri-agent-tools dom --depth 3
52
+
53
+ # 3. Narrow down to a specific subtree
54
+ tauri-agent-tools dom ".sidebar" --depth 2 --styles
55
+
56
+ # 4. Screenshot the element
57
+ tauri-agent-tools screenshot --selector ".sidebar .nav-item.active" -o /tmp/nav.png
58
+ ```
59
+
60
+ ### Monitor IPC calls
61
+
62
+ ```bash
63
+ # Watch all IPC calls for 10 seconds
64
+ tauri-agent-tools ipc-monitor --duration 10000 --json
65
+
66
+ # Filter to specific commands
67
+ tauri-agent-tools ipc-monitor --filter "get_*" --duration 5000 --json
68
+ ```
69
+
70
+ ### Diagnose app state
71
+
72
+ ```bash
73
+ # Check page URL, title, viewport, scroll position
74
+ tauri-agent-tools page-state --json
75
+
76
+ # Inspect storage
77
+ tauri-agent-tools storage --type local --json
78
+
79
+ # Check console for errors
80
+ tauri-agent-tools console-monitor --level error --duration 5000 --json
81
+ ```
82
+
83
+ ## Command Reference
84
+
85
+ | Command | Key Flags | Bridge? | Description |
86
+ |---------|-----------|---------|-------------|
87
+ | `screenshot` | `--selector <css>`, `--title <regex>`, `-o <path>`, `--max-width <n>` | selector: yes, title: no | Capture window or DOM element screenshot |
88
+ | `dom` | `[selector]`, `--depth <n>`, `--styles`, `--mode accessibility`, `--json` | yes | Query DOM structure |
89
+ | `eval` | `<js-expression>` | yes | Evaluate JavaScript in webview |
90
+ | `wait` | `--selector <css>`, `--eval <js>`, `--title <regex>`, `--timeout <ms>` | selector/eval: yes | Wait for a condition |
91
+ | `list-windows` | `--tauri`, `--json` | no | List visible windows |
92
+ | `info` | `--title <regex>`, `--json` | no | Window geometry and display info |
93
+ | `ipc-monitor` | `--filter <cmd>`, `--duration <ms>`, `--json` | yes | Monitor Tauri IPC calls |
94
+ | `console-monitor` | `--level <lvl>`, `--filter <regex>`, `--duration <ms>`, `--json` | yes | Monitor console output |
95
+ | `storage` | `--type <local\|session\|cookies\|all>`, `--key <name>`, `--json` | yes | Inspect browser storage |
96
+ | `page-state` | `--json` | yes | URL, title, viewport, scroll, document size |
97
+
98
+ ## Important Notes
99
+
100
+ - **All read-only.** No commands modify app state, inject input, or write to storage.
101
+ - **Use `--json`** for structured, parseable output in automation.
102
+ - **Always use `--duration`** with `ipc-monitor` and `console-monitor` — without it, they run indefinitely.
103
+ - **`screenshot --selector`** requires both the bridge AND platform screenshot tools (`imagemagick`).
104
+ - **One bridge at a time.** Auto-discovery picks the first token file found. If multiple Tauri apps run simultaneously, use `--port` and `--token` explicitly.
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: tauri-bridge-setup
3
+ description: How to add the tauri-agent-tools Rust dev bridge to a Tauri application
4
+ version: 0.1.0
5
+ tags: [tauri, rust, bridge, setup, integration]
6
+ ---
7
+
8
+ # Tauri Dev Bridge Setup
9
+
10
+ Add the dev bridge to a Tauri app so `tauri-agent-tools` can inspect DOM, evaluate JS, monitor IPC, and take element screenshots.
11
+
12
+ The bridge runs **only in debug builds** and is stripped from release builds automatically.
13
+
14
+ ## Step 1 — Add Cargo dependencies
15
+
16
+ Add to your Tauri app's `src-tauri/Cargo.toml` under `[dependencies]`:
17
+
18
+ ```toml
19
+ tiny_http = "0.12"
20
+ serde = { version = "1", features = ["derive"] }
21
+ serde_json = "1"
22
+ scopeguard = "1"
23
+ rand = "0.8"
24
+ ```
25
+
26
+ ## Step 2 — Copy the bridge module
27
+
28
+ Copy `dev_bridge.rs` from the tauri-agent-tools package into your project:
29
+
30
+ ```bash
31
+ # Find the installed package location
32
+ TOOLS_DIR=$(npm root -g)/tauri-agent-tools
33
+
34
+ # Copy the bridge module
35
+ cp "$TOOLS_DIR/examples/tauri-bridge/src/dev_bridge.rs" src-tauri/src/dev_bridge.rs
36
+ ```
37
+
38
+ If installed locally (not globally):
39
+
40
+ ```bash
41
+ cp node_modules/tauri-agent-tools/examples/tauri-bridge/src/dev_bridge.rs src-tauri/src/dev_bridge.rs
42
+ ```
43
+
44
+ ## Step 3 — Wire up in main.rs
45
+
46
+ Add the module declaration and start the bridge in your `src-tauri/src/main.rs`:
47
+
48
+ ```rust
49
+ mod dev_bridge;
50
+
51
+ fn main() {
52
+ tauri::Builder::default()
53
+ .setup(|app| {
54
+ if cfg!(debug_assertions) {
55
+ if let Err(e) = dev_bridge::start_bridge(app.handle()) {
56
+ eprintln!("Warning: Failed to start dev bridge: {e}");
57
+ }
58
+ }
59
+ Ok(())
60
+ })
61
+ .run(tauri::generate_context!())
62
+ .expect("error while running tauri application");
63
+ }
64
+ ```
65
+
66
+ If you already have a `.setup()` call, add the `if cfg!(debug_assertions) { ... }` block inside it.
67
+
68
+ ## Step 4 — Verify
69
+
70
+ Build and run the Tauri app in dev mode, then:
71
+
72
+ ```bash
73
+ # Should show your app with a bridge indicator
74
+ tauri-agent-tools list-windows --tauri
75
+
76
+ # Should return DOM tree
77
+ tauri-agent-tools dom --depth 2
78
+ ```
79
+
80
+ Both commands succeeding confirms the bridge is working.
81
+
82
+ ## Troubleshooting
83
+
84
+ **"No bridge found" error:**
85
+ - Is the app running in dev/debug mode? The bridge only starts when `cfg!(debug_assertions)` is true.
86
+ - Check for token files: `ls /tmp/tauri-dev-bridge-*.token`
87
+ - The app process must be running — the bridge starts during `setup()`.
88
+
89
+ **Stale token files:**
90
+ - If the app crashed without cleanup, old token files may remain: `rm /tmp/tauri-dev-bridge-*.token`
91
+ - Restart the Tauri app after cleaning.
92
+
93
+ **Port conflicts:**
94
+ - The bridge picks a random port. If it fails, check the app's stderr for "Failed to start dev bridge".
95
+ - Ensure no firewall blocks localhost connections.
package/AGENTS.md ADDED
@@ -0,0 +1,30 @@
1
+ # tauri-agent-tools
2
+
3
+ CLI tool for agent-driven inspection of Tauri desktop applications. **Not an MCP server** — invoke commands directly via shell.
4
+
5
+ ## Agent Skills
6
+
7
+ This package includes two [Agent Skills](https://agentskills.io):
8
+
9
+ | Skill | Path | Purpose |
10
+ |-------|------|---------|
11
+ | `tauri-agent-tools` | `.agents/skills/tauri-agent-tools/SKILL.md` | Using the 11 CLI commands to inspect Tauri apps |
12
+ | `tauri-bridge-setup` | `.agents/skills/tauri-bridge-setup/SKILL.md` | Adding the Rust dev bridge to a Tauri project |
13
+
14
+ ## Quick Reference
15
+
16
+ **Install:** `npm install -g tauri-agent-tools`
17
+
18
+ **All commands are read-only.** No input injection, no writes, no side effects.
19
+
20
+ **Standalone commands** (no bridge needed):
21
+ `list-windows`, `info`, `screenshot --title`, `wait --title`
22
+
23
+ **Bridge-required commands** (Tauri app must have dev bridge running):
24
+ `dom`, `eval`, `screenshot --selector`, `wait --selector/--eval`, `ipc-monitor`, `console-monitor`, `storage`, `page-state`
25
+
26
+ **Bridge auto-discovery:** The CLI finds the running bridge via token files in `/tmp/tauri-dev-bridge-*.token`. No manual configuration needed.
27
+
28
+ **Structured output:** Use `--json` on any command for machine-readable output.
29
+
30
+ **Monitors:** Always pass `--duration <ms>` to `ipc-monitor` and `console-monitor` to avoid indefinite execution.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Cesar Andres Lopez
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,338 @@
1
+ <div align="center">
2
+
3
+ # tauri-agent-tools
4
+
5
+ **Agent-driven inspection toolkit for Tauri desktop apps**
6
+
7
+ 11 read-only commands to screenshot, inspect, and monitor Tauri apps from the CLI.
8
+
9
+ [![CI](https://github.com/cesarandreslopez/tauri-agent-tools/actions/workflows/ci.yml/badge.svg)](https://github.com/cesarandreslopez/tauri-agent-tools/actions/workflows/ci.yml)
10
+ [![npm version](https://img.shields.io/npm/v/tauri-agent-tools.svg)](https://www.npmjs.com/package/tauri-agent-tools)
11
+ [![npm downloads](https://img.shields.io/npm/dm/tauri-agent-tools.svg)](https://www.npmjs.com/package/tauri-agent-tools)
12
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
13
+ [![Node >= 20](https://img.shields.io/badge/Node-%3E%3D20-green.svg)](https://nodejs.org)
14
+
15
+ </div>
16
+
17
+ ## The Problem
18
+
19
+ Debugging frontend issues in Tauri desktop apps requires manually screenshotting, cropping, and describing what you see. Existing tools either hijack your cursor (xcap-based), render DOM to canvas (html2canvas — can't capture WebGL/video/canvas), or have no authentication.
20
+
21
+ ## The Solution
22
+
23
+ Combine a bridge's knowledge of element positions (`getBoundingClientRect`) with real pixel screenshots (`import -window` + ImageMagick crop). No other tool does this.
24
+
25
+ ```bash
26
+ # Screenshot a specific DOM element with real pixels
27
+ tauri-agent-tools screenshot --selector ".wf-toolbar" -o /tmp/toolbar.png
28
+ tauri-agent-tools screenshot --selector "#canvas-area" -o /tmp/canvas.png
29
+
30
+ # Explore DOM structure first
31
+ tauri-agent-tools dom --depth 3
32
+ tauri-agent-tools dom ".wf-canvas" --depth 4
33
+
34
+ # Then screenshot what you found
35
+ tauri-agent-tools screenshot --selector ".wf-canvas .block-node" -o /tmp/block.png
36
+ ```
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ npm install -g tauri-agent-tools
42
+ ```
43
+
44
+ **System requirements:**
45
+ - **Linux X11:** `xdotool`, `imagemagick` (`sudo apt install xdotool imagemagick`)
46
+ - **Linux Wayland/Sway:** `swaymsg`, `grim`, `imagemagick`
47
+ - **macOS:** `imagemagick` (`brew install imagemagick`) — all other tools are built-in. Grant Screen Recording permission in System Settings → Privacy & Security → Screen Recording.
48
+
49
+ ## Quick Start
50
+
51
+ ### 1. Add the bridge to your Tauri app
52
+
53
+ See [rust-bridge/README.md](rust-bridge/README.md) for step-by-step integration (~120 lines of Rust).
54
+
55
+ The bridge runs a localhost-only, token-authenticated HTTP server during development. It auto-cleans up on exit.
56
+
57
+ ### 2. Use the CLI
58
+
59
+ ```bash
60
+ # DOM-targeted screenshot (needs bridge)
61
+ tauri-agent-tools screenshot --selector ".toolbar" -o /tmp/toolbar.png
62
+ tauri-agent-tools screenshot --selector "#main-canvas" --max-width 800 -o /tmp/canvas.png
63
+
64
+ # Full window screenshot (no bridge needed, works with any window)
65
+ tauri-agent-tools screenshot --title "My App" -o /tmp/full.png
66
+
67
+ # Explore DOM
68
+ tauri-agent-tools dom --depth 3
69
+ tauri-agent-tools dom ".sidebar" --depth 2 --styles
70
+
71
+ # Evaluate JS
72
+ tauri-agent-tools eval "document.title"
73
+ tauri-agent-tools eval "document.querySelectorAll('.item').length"
74
+
75
+ # Wait for conditions
76
+ tauri-agent-tools wait --selector ".toast-message" --timeout 5000
77
+ tauri-agent-tools wait --title "My App" --timeout 10000
78
+
79
+ # Window info
80
+ tauri-agent-tools info --title "My App" --json
81
+ ```
82
+
83
+ ## Commands
84
+
85
+ ### `screenshot`
86
+
87
+ Capture a screenshot of a window or DOM element.
88
+
89
+ | Option | Description |
90
+ |--------|-------------|
91
+ | `-s, --selector <css>` | CSS selector — screenshot just this element (requires bridge) |
92
+ | `-t, --title <regex>` | Window title to match |
93
+ | `-o, --output <path>` | Output file path (default: auto-named) |
94
+ | `--format <png\|jpg>` | Output format (default: png) |
95
+ | `--max-width <number>` | Resize to max width |
96
+ | `--port <number>` | Bridge port (auto-discover if omitted) |
97
+ | `--token <string>` | Bridge token (auto-discover if omitted) |
98
+
99
+ ### `dom`
100
+
101
+ Query DOM structure from the Tauri app.
102
+
103
+ | Option | Description |
104
+ |--------|-------------|
105
+ | `[selector]` | Root element to explore (default: body) |
106
+ | `--mode <mode>` | Output mode: `dom` (default) or `accessibility` |
107
+ | `--depth <number>` | Max child depth (default: 3) |
108
+ | `--tree` | Compact tree view (default) |
109
+ | `--styles` | Include computed styles |
110
+ | `--count` | Just output match count |
111
+ | `--first` | Only return first match |
112
+ | `--json` | Full structured JSON output |
113
+
114
+ ### `eval`
115
+
116
+ Evaluate a JavaScript expression in the Tauri app.
117
+
118
+ ```bash
119
+ tauri-agent-tools eval "document.title"
120
+ ```
121
+
122
+ ### `wait`
123
+
124
+ Wait for a condition to be met.
125
+
126
+ | Option | Description |
127
+ |--------|-------------|
128
+ | `-s, --selector <css>` | Wait for CSS selector to match |
129
+ | `-e, --eval <js>` | Wait for JS expression to be truthy |
130
+ | `-t, --title <regex>` | Wait for window with title (no bridge) |
131
+ | `--timeout <ms>` | Maximum wait time (default: 10000) |
132
+ | `--interval <ms>` | Polling interval (default: 500) |
133
+
134
+ ### `info`
135
+
136
+ Show window geometry and display server info.
137
+
138
+ ```bash
139
+ tauri-agent-tools info --title "My App" --json
140
+ ```
141
+
142
+ ### `list-windows`
143
+
144
+ List all visible windows, marking Tauri apps.
145
+
146
+ | Option | Description |
147
+ |--------|-------------|
148
+ | `--json` | Output as JSON |
149
+ | `--tauri` | Only show Tauri app windows |
150
+
151
+ ### `ipc-monitor`
152
+
153
+ Monitor Tauri IPC calls in real-time (read-only). Monkey-patches `window.__TAURI__.core.invoke` to capture calls, then polls and restores on exit.
154
+
155
+ | Option | Description |
156
+ |--------|-------------|
157
+ | `--filter <command>` | Only show specific IPC commands (supports `*` wildcards) |
158
+ | `--interval <ms>` | Poll interval in milliseconds (default: 500) |
159
+ | `--duration <ms>` | Auto-stop after N milliseconds |
160
+ | `--json` | Output one JSON object per line |
161
+
162
+ ### `console-monitor`
163
+
164
+ Monitor console output (log/warn/error/info/debug) in real-time. Monkey-patches console methods to capture entries, then polls and restores on exit.
165
+
166
+ | Option | Description |
167
+ |--------|-------------|
168
+ | `--level <level>` | Filter by level (log, warn, error, info, debug) |
169
+ | `--filter <regex>` | Filter messages by regex pattern |
170
+ | `--interval <ms>` | Poll interval in milliseconds (default: 500) |
171
+ | `--duration <ms>` | Auto-stop after N milliseconds |
172
+ | `--json` | Output one JSON object per line |
173
+
174
+ ### `storage`
175
+
176
+ Inspect localStorage, sessionStorage, and cookies from the Tauri webview. One-shot read — no writes.
177
+
178
+ | Option | Description |
179
+ |--------|-------------|
180
+ | `--type <type>` | Storage type: `local`, `session`, `cookies`, `all` (default: all) |
181
+ | `--key <name>` | Get a specific key's value |
182
+ | `--json` | Output as JSON |
183
+
184
+ ### `page-state`
185
+
186
+ Query webview page state: URL, title, viewport, scroll position, document size, and Tauri detection.
187
+
188
+ | Option | Description |
189
+ |--------|-------------|
190
+ | `--json` | Output as JSON |
191
+
192
+ ## How It Works
193
+
194
+ ```
195
+ screenshot --selector ".toolbar" --title "My App"
196
+
197
+ ├─► Bridge client ──► POST /eval ──► getBoundingClientRect(".toolbar")
198
+ │ returns { x, y, width, height }
199
+
200
+ ├─► Platform adapter ──► import -window WID png:- (capture full window)
201
+
202
+ ├─► Compute crop region:
203
+ │ element rect from bridge + viewport offset (outerHeight - innerHeight)
204
+
205
+ └─► convert png:- -crop WxH+X+Y +repage png:- (crop to element)
206
+ ```
207
+
208
+ The crop accounts for window decoration (title bar, borders) by comparing `window.innerHeight` from the bridge with the actual window height from `xdotool`.
209
+
210
+ ## Platform Support
211
+
212
+ | Platform | Display Server | Status |
213
+ |----------|---------------|--------|
214
+ | Linux | X11 | Supported |
215
+ | Linux | Wayland (Sway) | Supported |
216
+ | macOS | CoreGraphics | Supported |
217
+ | Windows | - | Planned |
218
+
219
+ ## Design Decisions
220
+
221
+ ### Why no write operations
222
+
223
+ All commands are read-only. We don't inject clicks, keystrokes, scroll events, or any input into the Tauri webview. Reasons:
224
+
225
+ - **Native input injection is risky.** X11 input injection (e.g. via `xdotool`) operates system-wide, not per-window — it can grab the mouse cursor and require a hard reboot to recover.
226
+ - **Simulated events don't work.** `dispatchEvent()` creates events with `isTrusted: false`. Frameworks (React, Vue, Angular) and browsers reject untrusted events for security-sensitive operations.
227
+ - **Input injection is fragile across platforms.** X11 (`xdotool`), Wayland (no global input protocol by design), and macOS (requires Accessibility permission + sandbox restrictions) each have different security models. A cross-platform injection layer would be unreliable.
228
+ - **Read-only is a safer contract for dev tool automation.** Tools that can only observe cannot corrupt application state, trigger unintended side effects, or create security vulnerabilities in CI pipelines.
229
+
230
+ ### Why no MCP server mode
231
+
232
+ This tool is a CLI that runs commands and exits — not a persistent MCP server. Reasons:
233
+
234
+ - **No daemon to manage.** No port to monitor, no process to restart, no state to leak between sessions.
235
+ - **No `.mcp.json` auto-start risk.** MCP servers start automatically when a project opens in supporting editors. A dev tool that auto-starts and connects to your running app on project open is a footgun.
236
+ - **No transport complexity.** No WebSocket/stdio state machine, no reconnection logic, no transport-layer bugs.
237
+ - **Composable with any agent framework.** Commands return structured output (`--json`) that any tool-use system can call directly. Define each command as a tool — no MCP SDK dependency required.
238
+
239
+ ## Safety Guarantees
240
+
241
+ - **No input injection** — no mouse moves, clicks, keystrokes, or cursor changes
242
+ - **No xcap crate** — uses `xdotool` + ImageMagick `import` (read-only X11 operations)
243
+ - **No daemon** — CLI runs and exits, no background processes
244
+ - **No `.mcp.json`** — never auto-starts
245
+ - **All OS interactions read-only** — `xdotool search`, `getwindowgeometry`, `import -window`
246
+ - **Token authenticated bridge** — random 32-char token, localhost-only
247
+ - **`execFile` (array args)** — never `exec` (shell string), prevents command injection
248
+ - **Window ID validated** — must match `/^\d+$/`
249
+
250
+ ## Agent Integration
251
+
252
+ This package ships [Agent Skills](https://agentskills.io) so AI coding agents can automatically learn how to use the CLI and set up the bridge.
253
+
254
+ | Skill | Description |
255
+ |-------|-------------|
256
+ | `tauri-agent-tools` | Using all 11 CLI commands to inspect Tauri apps |
257
+ | `tauri-bridge-setup` | Adding the Rust dev bridge to a Tauri project |
258
+
259
+ <details>
260
+ <summary><strong>Claude Code</strong></summary>
261
+
262
+ Claude Code auto-discovers skills from `.agents/skills/` in the current project. If you installed `tauri-agent-tools` globally and want skills available everywhere:
263
+
264
+ ```bash
265
+ cp -r "$(npm root -g)/tauri-agent-tools/.agents" ~/.agents
266
+ ```
267
+ </details>
268
+
269
+ <details>
270
+ <summary><strong>Codex</strong></summary>
271
+
272
+ Codex reads `AGENTS.md` at the repo root and skills from `node_modules`. Install locally:
273
+
274
+ ```bash
275
+ npm install tauri-agent-tools
276
+ ```
277
+
278
+ Codex will pick up `AGENTS.md` and `.agents/skills/` automatically.
279
+ </details>
280
+
281
+ <details>
282
+ <summary><strong>Cursor / VS Code Copilot</strong></summary>
283
+
284
+ Copy skills into your project so the agent can discover them:
285
+
286
+ ```bash
287
+ cp -r node_modules/tauri-agent-tools/.agents .agents
288
+ ```
289
+
290
+ Or if installed globally:
291
+
292
+ ```bash
293
+ cp -r "$(npm root -g)/tauri-agent-tools/.agents" .agents
294
+ ```
295
+ </details>
296
+
297
+ <details>
298
+ <summary><strong>Other agents</strong></summary>
299
+
300
+ Any [agentskills.io](https://agentskills.io)-compatible agent can read the skills from `.agents/skills/` in this package. Install globally or locally and point the agent at the skill directory.
301
+ </details>
302
+
303
+ ## Documentation
304
+
305
+ Full documentation is available at the [docs site](https://cesarandreslopez.github.io/tauri-agent-tools/):
306
+
307
+ - [Installation](https://cesarandreslopez.github.io/tauri-agent-tools/getting-started/installation/) — system requirements and setup
308
+ - [Quick Start](https://cesarandreslopez.github.io/tauri-agent-tools/getting-started/quick-start/) — get running in 5 minutes
309
+ - [Bridge Setup](https://cesarandreslopez.github.io/tauri-agent-tools/getting-started/bridge-setup/) — integrate the Rust bridge into your Tauri app
310
+ - [Command Reference](https://cesarandreslopez.github.io/tauri-agent-tools/commands/) — all 11 commands with examples
311
+ - [Platform Support](https://cesarandreslopez.github.io/tauri-agent-tools/platform-support/) — X11, Wayland, macOS details
312
+ - [Architecture](https://cesarandreslopez.github.io/tauri-agent-tools/architecture/overview/) — how it works under the hood
313
+
314
+ ## Development
315
+
316
+ ```bash
317
+ npm install
318
+ npm run build
319
+ npm test
320
+ ```
321
+
322
+ ## Contributing
323
+
324
+ Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for:
325
+
326
+ - Development setup and prerequisites
327
+ - Code style and conventions
328
+ - Branch naming and commit message format
329
+ - Pull request process
330
+
331
+ ## Community
332
+
333
+ - [Open an issue](https://github.com/cesarandreslopez/tauri-agent-tools/issues) for bugs or feature requests
334
+ - Star the repo if you find it useful
335
+
336
+ ## License
337
+
338
+ MIT
@@ -0,0 +1,15 @@
1
+ import type { BridgeConfig, ElementRect } from '../types.js';
2
+ export declare class BridgeClient {
3
+ private baseUrl;
4
+ private token;
5
+ constructor(config: BridgeConfig);
6
+ eval(js: string, timeout?: number): Promise<unknown>;
7
+ getElementRect(selector: string): Promise<ElementRect | null>;
8
+ getViewportSize(): Promise<{
9
+ width: number;
10
+ height: number;
11
+ }>;
12
+ getDocumentTitle(): Promise<string>;
13
+ getAccessibilityTree(selector?: string, depth?: number): Promise<unknown>;
14
+ ping(): Promise<boolean>;
15
+ }