Repository avatar
Other Tools
v0.7.0
active

tauri-hasgard

io.github.nyssance/tauri-hasgard

Inspect and drive a running Tauri app's native webviews: snapshot, click, type, screenshot.

Documentation

Tauri Hasgard

crates.io npm CI

Automation for Tauri 3 applications. Hasgard drives the real native webviews of a running app, so an AI client, a terminal or a Playwright test sees and clicks what a user would.

$ tauri-hasgard windows
main       tauri://localhost                 Hasgard Fixture
settings   tauri://localhost/settings.html   Settings
$ tauri-hasgard --window main snapshot -i
- textbox "Display name" [ref=e1]
- button "Save" [ref=e2]
- button "Open dialog" [ref=e3]
- button "Open settings" [ref=e4]
$ tauri-hasgard --window main click '@e2'
You want toUse
Let Claude Code or Codex drivetauri-hasgard mcp
Inspect and click by handtauri-hasgard CLI
Write E2E tests@nyssance/tauri-hasgard for Playwright

All three talk to one plugin inside your app.

Supported
Tauri3 (Tauri 2: use Hasgard 0.5.x)
WebviewWry by default, CEF opt-in
DesktopmacOS Apple Silicon, Windows x64, Linux x64

Register the plugin

cd src-tauri
cargo add tauri-plugin-hasgard tauri-runtime-wry@3.0.0-alpha.6
tauri::Builder::default()
    .runtime(tauri_runtime_wry::Wry::default())
    .plugin(tauri_plugin_hasgard::init())
    .run(tauri::generate_context!())
    .expect("failed to run Tauri application");

Add hasgard:default to a capability that covers every window you automate, for example src-tauri/capabilities/default.json:

{
  "windows": ["*"],
  "permissions": ["hasgard:default"]
}

Without that permission the client connects but every read fails with hasgard.__callback not allowed.

The plugin is active in every build that registers it, release builds included. Gate the .plugin(...) call yourself if shipped builds must not expose automation.

Connect Claude Code or Codex

Start your app, then run one command. Nothing else to install:

claude mcp add tauri-hasgard -- npx -y tauri-hasgard mcp   # Claude Code
codex mcp add tauri-hasgard -- npx -y tauri-hasgard mcp    # Codex

Check that it works, with your app running:

$ npx -y tauri-hasgard ping
✓ Connected. Plugin and CLI both 0.7.0.
$ claude mcp list        # or: codex mcp list

ping proves the CLI reaches your app; the list should show tauri-hasgard as connected. Then ask the client: "List the windows of my app."

An app that hosts its own agent can serve the same tools in process or over ACP, with no setup for its users. See the MCP guide.

Install the CLI

brew install nyssance/tap/tauri-hasgard        # macOS Apple Silicon
scoop bucket add nyssance https://github.com/nyssance/scoop-bucket
scoop install nyssance/tauri-hasgard           # Windows x64
npm install -g tauri-hasgard                   # any of the three platforms
cargo install tauri-hasgard-cli                # anywhere with Rust

Prebuilt binaries cover macOS Apple Silicon, Windows x64 and Linux x64; archives are on each release.

Use the CLI

tauri-hasgard ping                              # is an app reachable
tauri-hasgard windows                           # window labels
tauri-hasgard --window main snapshot -i         # interactive elements with refs
tauri-hasgard --window main click '@e3'         # by ref from the last snapshot
tauri-hasgard --window main fill '#name' 'Ny'   # by CSS selector
tauri-hasgard --window main press Enter
tauri-hasgard --window main screenshot out.png
tauri-hasgard --window main logs
tauri-hasgard --window main ipc my_command

A target is a snapshot ref (@e3) or a CSS selector. Refs expire when the UI changes; take a new snapshot. Add --json for machine-readable output. tauri-hasgard --help lists every command.

Write Playwright tests

test("opens settings", async ({ hasgard, window }) => {
  await window.getByRole("button", { name: "Settings", exact: true }).click()
  const settings = await hasgard.waitForWindow("settings", 5_000)
  await expect(settings.getByRole("heading", { name: "Settings" })).toBeVisible()
})

Setup is in the Playwright guide. Tests run against the real application; there is no page fixture and no mocked browser mode.

More

License

Apache-2.0. Upstream MIT notices are preserved in LICENSE and NOTICE.md.

NPM
tauri-hasgard
Install Command
npm install tauri-hasgard