Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .claude/skills/maui-devflow-debug/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
---
name: maui-devflow-debug
description: >-
Run DevFlow inspect-and-fix loops for MAUI apps. USE FOR: launch, device selection, agent recovery, broker/port/adb, tree/screenshot, Blazor CDP, iterative UI debugging. DO NOT USE FOR: first-time setup or non-MAUI automation. INVOKES: `maui devflow`, `dotnet`, `adb`, `simctl`.
Run DevFlow inspect-and-fix loops for MAUI apps. USE FOR: launch, device
selection, agent recovery, broker/port/adb, tree/screenshot, Blazor CDP, and
iterative UI debugging. DO NOT USE FOR: first-time setup or non-MAUI
automation. INVOKES: DevFlow `maui_*` MCP tools when available; `maui
devflow` CLI as fallback; `dotnet`, `adb`, and `simctl` for build, deployment,
and connectivity work.
---

# DevFlow Debug
Expand Down
8 changes: 5 additions & 3 deletions .claude/skills/maui-devflow-debug/references/ios-and-mac.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ the standard error envelope:
### Pre-grant permissions (prevents dialogs from appearing)

**Prefer the `maui` CLI** — `maui apple simulator privacy` now wraps `simctl privacy`
(the `bundle-id` is optional, so you can grant for all apps), and `maui devflow ui permission`
drives it for the agent-detected simulator:
(the `bundle-id` is optional, so you can grant for all apps). For
`maui devflow ui permission`, pass `--udid` to target the intended simulator.
Without it, the command selects the first booted simulator, not the simulator
associated with the connected agent.
```bash
maui apple simulator privacy grant <UDID> location --bundle-id com.company.appid
maui apple simulator privacy grant <UDID> photos # all apps (no bundle id)
maui devflow ui permission grant location --bundle-id com.company.appid
maui devflow ui permission grant location --udid <UDID> --bundle-id com.company.appid
```

Raw `xcrun simctl` fallback (only if the `maui` CLI is unavailable):
Expand Down
28 changes: 15 additions & 13 deletions .claude/skills/maui-devflow-debug/references/linux.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Linux / GTK Platform Guide

Platform-specific setup and usage for .NET MAUI apps running on Linux via Maui.Gtk (GTK4).
Platform-specific setup and usage for .NET MAUI apps running on Linux via Microsoft.Maui.Platforms.Linux.Gtk4.

## Overview

Maui.Gtk apps target `net10.0` (not a platform-specific TFM like `net10.0-ios`) and use
Microsoft.Maui.Platforms.Linux.Gtk4 apps target `net10.0` (not a platform-specific TFM like `net10.0-ios`) and use
GTK4 via GirCore bindings. MAUI DevFlow provides dedicated Linux packages that work with
this architecture.

Expand Down Expand Up @@ -45,18 +45,20 @@ builder.AddMauiBlazorDevFlowTools(); // Blazor Hybrid only

### Application Startup

The agent must be started after the MAUI Application is available. In your GTK app
startup (e.g., `GtkMauiApplication.OnActivate` or equivalent):
`AddMauiDevFlowAgent()` starts automatically on the GTK thread after the first window is
created. Use the current `Microsoft.Maui.Platforms.Linux.Gtk4` backend, not the superseded
`Platform.Maui.Linux.Gtk4` packages. No manual call is required.

An explicit hook is available in a `GtkMauiApplication.OnStarted()` override:

```csharp
protected override void OnStarted()
{
base.OnStarted();
#if DEBUG
app.StartDevFlowAgent();

// For Blazor Hybrid, wire CDP to the agent:
var blazorService = app.Handler?.MauiContext?.Services
.GetService<GtkBlazorWebViewDebugService>();
blazorService?.WireBlazorCdpToAgent();
this.StartDevFlowAgent();
#endif
}
```

## Building and Running
Expand Down Expand Up @@ -131,7 +133,7 @@ Only the driver backend should reach for `xdotool` or `ydotool`.
| NuGet packages | `Agent`, `Blazor` | `Agent.Gtk`, `Blazor.Gtk` |
| TFM | `net10.0-<platform>` | `net10.0` |
| Build command | `dotnet build -f $TFM -t:Run` | `dotnet run --project <path>` |
| Agent startup | Automatic (lifecycle hook) | Manual (`app.StartDevFlowAgent()`) |
| Agent startup | Automatic (lifecycle hook) | Automatic (first GTK window created) |
| Network | Varies by platform | Direct localhost |
| Screenshots | `VisualDiagnostics` | GTK `WidgetPaintable` → `Texture.SaveToPng()` |
| Native tap | Platform gesture system | `Gtk.Widget.Activate()` |
Expand All @@ -143,8 +145,8 @@ Only the driver backend should reach for `xdotool` or `ydotool`.

### Agent Not Starting

1. Ensure `app.StartDevFlowAgent()` is called after the app is activated
2. Check that `Application.Current` is available when `StartDevFlowAgent()` runs
1. Ensure `builder.AddMauiDevFlowAgent()` is called and the host uses `Microsoft.Maui.Platforms.Linux.Gtk4`
2. For explicit startup, call `this.StartDevFlowAgent()` from `GtkMauiApplication.OnStarted()`, not `CreateMauiApp()`
3. Verify the port isn't in use: `lsof -i :<port>` or `ss -tlnp | grep <port>`

### xdotool / ydotool Not Working
Expand Down
15 changes: 4 additions & 11 deletions .claude/skills/maui-devflow-debug/references/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,9 @@ builder.AddMauiBlazorDevFlowTools(); // Blazor Hybrid only
#endif
```

After the MAUI app is activated (e.g., in `OnActivate` or after `Application.Current` is available):

```csharp
#if DEBUG
app.StartDevFlowAgent();
// For Blazor, wire CDP to agent:
var blazorService = app.Handler?.MauiContext?.Services.GetService<GtkBlazorWebViewDebugService>();
blazorService?.WireBlazorCdpToAgent();
#endif
```
With `Microsoft.Maui.Platforms.Linux.Gtk4`, builder registration starts the agent automatically
after the first window is created. For an explicit host hook, call `this.StartDevFlowAgent()`
from `GtkMauiApplication.OnStarted()`. See [linux.md](linux.md).

**Agent options:**
- `Port` — HTTP port for the agent REST API (default: 9223). Also configurable via `.mauidevflow` or `-p:MauiDevFlowPort=XXXX`.
Expand Down Expand Up @@ -300,7 +293,7 @@ For an AI agent setting up MAUI DevFlow in a new project:
5. [ ] Chobitsu auto-injected via JS initializer (Blazor Hybrid — no manual step needed)
6. [ ] Mac Catalyst entitlements include `network.server` (Mac Catalyst only)
7. [ ] `adb reverse tcp:19223` for broker + `adb forward tcp:<port>` for agent (Android only)
8. [ ] Linux/GTK: `app.StartDevFlowAgent()` called after app activation
8. [ ] Linux/GTK: current `Microsoft.Maui.Platforms.Linux.Gtk4` backend and GTK agent registered
9. [ ] macOS (AppKit): `UseMauiAppMacOS()`, `AddMacOSEssentials()`, `MacOSBlazorWebView` — see [macos.md](macos.md)
10. [ ] Verify with `maui devflow list` and `maui devflow ui status`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Always pass `--json` to any `maui` command an agent will parse, and `--ci` for
non-interactive failure-fast runs.

The full `--json` error envelope contract (schema, code categories, worked examples, PowerShell and Bash consumers) is documented in
[`src/Cli/README.md` — Error envelope](../../../../../src/Cli/README.md#error-envelope).
[`src/Cli/README.md` — Error envelope](https://github.com/dotnet/maui-labs/blob/main/src/Cli/README.md#error-envelope).

**Quick reference** — when a non-DevFlow command fails with `--json`, stdout is a top-level JSON object (no `"error"` wrapper). Note: `maui devflow ...` uses a different JSON error shape and writes errors to stderr.

Expand Down
24 changes: 11 additions & 13 deletions .claude/skills/maui-devflow-onboard/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
---
name: maui-devflow-onboard
description: >-
Add DevFlow to a MAUI app. USE FOR: package refs, `MauiProgram` registration, Blazor WebView/GTK variants, verification after `maui devflow init`. DO NOT USE FOR: troubleshooting, debugging, UI inspection, or build failures. INVOKES: `maui devflow`, `dotnet`.
Add MAUI DevFlow to a .NET MAUI project with agent package references,
MauiProgram.cs registration, Blazor WebView support, GTK variants, Central
Package Management guidance, and verification commands. USE FOR: first-time
DevFlow setup, reviewing what files to edit, choosing DevFlow packages, or
continuing after `maui devflow init` installs skills. DO NOT USE FOR:
troubleshooting an already-integrated app that cannot connect, iterative app
debugging, UI inspection, or generic MAUI build failures (use
maui-devflow-debug). INVOKES: maui devflow CLI and dotnet CLI.
---

# DevFlow Onboard
Expand All @@ -21,13 +28,6 @@ Use this skill to add MAUI DevFlow to a project after `maui devflow init` has in
- If package references and `AddMauiDevFlowAgent()` are already present but the CLI cannot connect, use `maui-devflow-debug`.
- If an agent is reachable and the user wants to inspect, tap, screenshot, or debug UI, use `maui-devflow-debug`.

## Optional Session Feedback Nudge

If onboarding required repeated DevFlow attempts, unclear package/version
workarounds, or a long setup session, ask whether the user wants to run
`maui-devflow-session-review` to summarize friction for MAUI DevFlow product
feedback. Do not run it automatically.

## Workflow

1. Optionally run `maui devflow skills check` and update bundled skills before editing if it reports `update-available-from-current-cli`.
Expand Down Expand Up @@ -70,7 +70,7 @@ If verification fails after integration, switch to `maui-devflow-debug` for conn

Blazor WebView indicators include a `Microsoft.AspNetCore.Components.WebView.Maui` package reference or `AddMauiBlazorWebView()` in `MauiProgram.cs`.

GTK indicators include package references such as `Maui.Gtk`, `Platform.Maui.Linux.Gtk4`, `GirCore.Gtk-4.0`, or `Platform.Maui.Linux.Gtk4.BlazorWebView`.
GTK indicators include `Microsoft.Maui.Platforms.Linux.Gtk4` or `Microsoft.Maui.Platforms.Linux.Gtk4.BlazorWebView`. Migrate superseded `Platform.Maui.Linux.Gtk4*` references before adding the current GTK DevFlow packages; do not mix the two backends.

## Central Package Management

Expand Down Expand Up @@ -114,7 +114,7 @@ builder.AddMauiBlazorDevFlowTools();
#endif
```

For GTK, use the `.Gtk` namespaces and packages. GTK apps also need to start the agent after app activation, for example `app.StartDevFlowAgent()` in the platform app activation flow.
For GTK, use the `.Gtk` namespaces and packages. `AddMauiDevFlowAgent()` starts automatically when `GtkMauiApplication` creates its first window. An explicit `this.StartDevFlowAgent()` hook is also available inside a `GtkMauiApplication.OnStarted()` override; builder registration is still required.

For Mac Catalyst, ensure the Debug entitlements allow the in-app HTTP server:

Expand All @@ -128,12 +128,10 @@ For Mac Catalyst, ensure the Debug entitlements allow the in-app HTTP server:
- `MauiProgram.cs` registers DevFlow only in Debug builds.
- The app project references the package flavor that matches the target platform.
- Blazor DevFlow tools are added only when the app uses Blazor WebView.
- GTK apps start the DevFlow agent after app activation.
- GTK apps use the current backend and start the DevFlow agent automatically after the first window is created.
- Mac Catalyst Debug entitlements include `com.apple.security.network.server`.
- `dotnet build` succeeds.
- Important controls in the flows you plan to automate have stable `AutomationId`s.
- A running app appears in `maui devflow list`.
- `maui devflow agent status` returns the expected app name and platform.
- `maui devflow ui tree --depth 1` returns a visual tree.

## References
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MAUI indicators:

- `<UseMaui>true</UseMaui>`;
- platform TFMs such as `net10.0-android`, `net10.0-ios`, `net10.0-maccatalyst`, or `net10.0-windows10.0.19041.0`;
- GTK package references such as `Maui.Gtk`, `Platform.Maui.Linux.Gtk4`, or `GirCore.Gtk-4.0`.
- GTK package references such as `Microsoft.Maui.Platforms.Linux.Gtk4` or `Microsoft.Maui.Platforms.Linux.Gtk4.BlazorWebView`. Superseded `Platform.Maui.Linux.Gtk4*` references must be migrated, not mixed with the current backend.

Blazor WebView indicators:

Expand Down
37 changes: 28 additions & 9 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,23 +264,42 @@ Use `@bind:event="oninput"` on inputs for this to work (requires `input` events,

The project uses [MAUI DevFlow](https://github.com/dotnet/maui-labs/tree/main/src/DevFlow) from the unified `Microsoft.Maui.Cli` tool for AI-assisted debugging. Broker discovery is preferred; no `.mauidevflow` file is committed in this repo.

Use the current upstream [debugging skill](https://github.com/dotnet/maui-labs/blob/main/.github/skills/maui-devflow-debug/SKILL.md)
and [onboarding skill](https://github.com/dotnet/maui-labs/blob/main/.github/skills/maui-devflow-onboard/SKILL.md)
as the source of truth. The local copies were refreshed from upstream revision
`e626474c39ffa234b88200f8ee5aea99c999d853`; only the troubleshooting link is
adapted to point back to the upstream repository. `maui devflow skills check`
compares against the installed CLI bundle, which may lag upstream `main`.
Prefer DevFlow `maui_*` MCP tools when available; otherwise use the CLI.
Discover the intended app with `wait`/`list`, verify its identity with
`agent status`, and pass its explicit port on subsequent commands.

```bash
# Always run CLI commands from src/MauiSherpa/ for auto port detection
# Discover the intended Sherpa instance, then use its returned port
cd src/MauiSherpa
dotnet maui devflow wait --wait-platform macOS --timeout 30
dotnet maui devflow list
dotnet maui devflow agent status --agent-port <port>

# Check agent connectivity
dotnet maui devflow ui status

# Take screenshots
dotnet maui devflow ui screenshot --output screen.png
# Keep genuine HiDPI pixels (the default screenshot command downsamples to 1x)
dotnet maui devflow ui screenshot --agent-port <port> --scale native --output screen.png

# Blazor DOM snapshot (best for AI)
dotnet maui devflow webview snapshot
dotnet maui devflow webview snapshot --agent-port <port>

# Inject dark/light mode for testing (avoids navigating to Settings)
dotnet maui devflow webview Runtime evaluate "document.body.classList.remove('theme-light'); document.body.classList.add('theme-dark'); document.querySelector('.main-layout').classList.remove('theme-light'); document.querySelector('.main-layout').classList.add('theme-dark');"
# Screenshot Mode: switch the actual app theme, including native chrome
dotnet maui devflow webview Runtime evaluate \
"window.sherpaScreenshot.setAppearance('dark')" --agent-port <port>
```

For website captures, follow [docs/SCREENSHOTS.md](docs/SCREENSHOTS.md).
Once the isolated fixture app is ready, ask the user whether they are ready to
leave it alone for the complete set. Wait for an explicit yes, then wait five
seconds before focusing the window and capturing uninterrupted. Close that
isolated app afterward. Never skip the readiness question or close another
session's app. The runner rejects focus loss instead of publishing an
inconsistent set.

## CI/CD

- **GitHub Actions runner:** `macos-26` (NOT `macos-26-arm64`)
Expand Down
Loading
Loading