Repository navigation
Agent-first winapp ui help and unknown-command suggestions - #942
Nikola Metulev (nmetulev) merged 3 commits into
Conversation
- Generalize #942's ui help renderer and unknown-command handling to any compact help group; winapp ui output is unchanged apart from one pointer line. - winapp devtools --help: purpose, the main workflow, what -a and <selector> mean, commands grouped by task, and when to use winapp ui instead. Every devtools command has examples, stored as data and parsed in tests. Unknown devtools commands suggest the closest one. - Root help gets a short 'Start here' block for winapp ui and winapp devtools. - A winapp ui command whose target has the DevTools agent prints one tip line on stderr (not with --json or --quiet). Co-authored-by: Copilot App <[email protected]>
#942 added the options to ui record; the hand-written argument builder did not forward them, which failed the generated-options sync test. Co-authored-by: Copilot App <[email protected]>
A Type argument cannot be serialized for discovery, so the two rows were discovered as one case and ran as two. CI's CLI shard 2 requires the reported total to match discovery exactly, which failed on #942 and here. Co-authored-by: Copilot App <[email protected]>
winapp ui help, unknown-command suggestions, and hosted-app targetingwinapp ui help and unknown-command suggestions
Build Metrics ReportValidation passed. All required build and validation jobs succeeded. Binary Sizes
.NET Test Results (TRX reports)Other suites are reflected in the overall validation status above. ✅ 8238 passed, 37 skipped out of 8275 tests in 1086.3s (+127 tests, -5.7s vs. baseline) Test Coverage✅ 86.6% line coverage, 81.2% branch coverage · ✅ no change vs. baseline CLI Startup Time62ms median (x64, Try This BuildInstalls the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing. & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 942Switching between builds often?Put the tool on your PATH once: & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPathThen this build is just: winapp-pr 942Run Updated 2026-10-08 03:42:07 UTC · commit |
a865a23 to
cb65152
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Filtered targeting can select ambiguous controls, and disappearing targets can silently broaden requested output.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Makes winapp ui easier for agents and scripts to discover and use, building on the selector filters from #932.
Changes:
- Adds compact, task-grouped help and per-command examples.
- Reports unknown commands with text or JSON suggestions before sandbox routing.
- Extends filtered targeting, identity checks, tests, documentation, and npm support.
| File | Description |
|---|---|
src/winapp-npm/src/winapp-commands.ts |
Regenerates descriptions and filter options. |
src/winapp-npm/src/ui-record-guard.ts |
Forwards recording filters. |
src/winapp-CLI/WinApp.UIAutomation/Services/UiAutomationService.cs |
Adds live element identity comparison. |
src/winapp-CLI/WinApp.UIAutomation/Services/IUiAutomation.cs |
Declares identity comparison contract. |
src/winapp-CLI/WinApp.UIAutomation.TestSupport/FakeUiServices.cs |
Supports targeting and identity tests. |
src/winapp-CLI/WinApp.UIAutomation.Tests/RealUiAutomationTests.ExplicitActions.cs |
Tests filtered actions and provider identity. |
src/winapp-CLI/WinApp.UIAutomation.Tests/GestureTargetingTests.cs |
Updates the automation test implementation. |
src/winapp-CLI/WinApp.Cli/Program.cs |
Adds early suggestions and shorter parse errors. |
src/winapp-CLI/WinApp.Cli/Helpers/UiUnknownCommand.cs |
Detects unknown commands and suggests alternatives. |
src/winapp-CLI/WinApp.Cli/Helpers/UiJsonError.cs |
Emits command suggestions in errors. |
src/winapp-CLI/WinApp.Cli/Helpers/UiJsonContext.cs |
Adds the JSON suggestions field. |
src/winapp-CLI/WinApp.Cli/Helpers/UiHelpRenderer.cs |
Renders compact plain-text UI help. |
src/winapp-CLI/WinApp.Cli/Helpers/UiErrors.cs |
Supports explicit error-output destinations. |
src/winapp-CLI/WinApp.Cli/Helpers/PointerCommandSupport.cs |
Applies filters to pointer targets. |
src/winapp-CLI/WinApp.Cli/Helpers/CustomHelpAction.cs |
Routes UI help and adds root guidance. |
src/winapp-CLI/WinApp.Cli/Commands/UiYieldCommand.cs |
Adds concise help and an example. |
src/winapp-CLI/WinApp.Cli/Commands/UiWaitForCommand.cs |
Adds wait examples and clearer summary. |
src/winapp-CLI/WinApp.Cli/Commands/UiTouchCommand.cs |
Adds help, filters, and validation. |
src/winapp-CLI/WinApp.Cli/Commands/UiStatusCommand.cs |
Adds connection examples. |
src/winapp-CLI/WinApp.Cli/Commands/UiSetValueCommand.cs |
Adds examples and filtered selection. |
src/winapp-CLI/WinApp.Cli/Commands/UiSendKeysCommand.cs |
Adds keyboard guidance and examples. |
src/winapp-CLI/WinApp.Cli/Commands/UiSearchCommand.cs |
Adds filtered-search examples. |
src/winapp-CLI/WinApp.Cli/Commands/UiScrollIntoViewCommand.cs |
Adds examples and selector filters. |
src/winapp-CLI/WinApp.Cli/Commands/UiScrollCommand.cs |
Adds examples and filtered scrolling. |
src/winapp-CLI/WinApp.Cli/Commands/UiScreenshotCommand.cs |
Adds capture help and filtered selection. |
src/winapp-CLI/WinApp.Cli/Commands/UiRecordCommand.cs |
Adds recording help and filtered selection. |
src/winapp-CLI/WinApp.Cli/Commands/UiQueryOptions.cs |
Shares filter validation and slug resolution. |
src/winapp-CLI/WinApp.Cli/Commands/UiPenCommand.cs |
Adds examples, filters, and coordinate validation. |
src/winapp-CLI/WinApp.Cli/Commands/UiListWindowsCommand.cs |
Adds window-discovery guidance. |
src/winapp-CLI/WinApp.Cli/Commands/UiInvokeCommand.cs |
Adds filtered uniqueness and identity checks. |
src/winapp-CLI/WinApp.Cli/Commands/UiInspectCommand.cs |
Adds inspection help and filtered subtrees. |
src/winapp-CLI/WinApp.Cli/Commands/UiHoverCommand.cs |
Adds examples and filtered targeting. |
src/winapp-CLI/WinApp.Cli/Commands/UiGetValueCommand.cs |
Adds value-reading examples. |
src/winapp-CLI/WinApp.Cli/Commands/UiGetPropertyCommand.cs |
Adds property-reading examples. |
src/winapp-CLI/WinApp.Cli/Commands/UiGetFocusedCommand.cs |
Adds a focus-query example. |
src/winapp-CLI/WinApp.Cli/Commands/UiFocusCommand.cs |
Adds examples and selector filters. |
src/winapp-CLI/WinApp.Cli/Commands/UiDragCommand.cs |
Adds selector and coordinate examples. |
src/winapp-CLI/WinApp.Cli/Commands/UiCommand.cs |
Defines the core workflow and help categories. |
src/winapp-CLI/WinApp.Cli/Commands/UiClickCommand.cs |
Adds examples and filtered clicking. |
src/winapp-CLI/WinApp.Cli/Commands/SharedUiOptions.cs |
Simplifies shared option descriptions. |
src/winapp-CLI/WinApp.Cli/Commands/IShortDescription.cs |
Defines structured help examples. |
src/winapp-CLI/WinApp.Cli/Commands/GuestDesktopCaptureCommand.cs |
Adapts shared recording dependencies. |
src/winapp-CLI/WinApp.Cli.Tests/UiHelpTests.cs |
Tests help, examples, and suggestions. |
src/winapp-CLI/WinApp.Cli.Tests/UiCommandTests.Screenshot.cs |
Updates screenshot test dependencies. |
src/winapp-CLI/WinApp.Cli.Tests/UiCommandTests.Record.Stdin.cs |
Updates recording test construction. |
src/winapp-CLI/WinApp.Cli.Tests/UiCommandTests.Query.cs |
Tests filter scope and validation. |
src/winapp-CLI/WinApp.Cli.Tests/UiCommandTests.Invoke.cs |
Tests filtered invocation safety. |
src/winapp-CLI/WinApp.Cli.Tests/RealRecordingTests.Helpers.cs |
Forwards identity comparisons. |
src/winapp-CLI/WinApp.Cli.Tests/DesktopCaptureTests.cs |
Updates guest recording test dependencies. |
plugins/winapp/skills/winapp-ui-automation/SKILL.md |
Documents filtered actions. |
plugins/winapp/skills/winapp-ui-automation/references/ui-json-envelope.md |
Documents command suggestions. |
docs/usage.md |
Introduces help discovery and filters. |
docs/ui-automation.md |
Explains the workflow and filtered targeting. |
docs/cli-schema.json |
Regenerates command descriptions and options. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ery command (#1116) ## What and why `winapp --help` used to open with a "Start here" block that only pointed to `ui` and `devtools`. Those are advanced features, while the first steps (`new`, `init`, `run`, `package`) only appeared further down, in the command panels. The help page of each command was a different problem: a long description line, then an ungrouped wall of options. **Root help** now opens with a **Quick start** of four workflows: build a WinUI app, add winapp to an existing app, package for install, and automate any app's UI. Each step is a real command with a few words on what it does. An **All commands:** heading introduces the full list below it, so every command is still listed. - Seven panels become four. Get Started and Run & Debug merge into **Set Up & Run**. Discovery, UI Automation and Performance merge into **Develop & Test**. - About 11 command short descriptions are shorter, so no row wraps at 80 columns. - The npm wrapper (`npx winapp --help`) adds an **Electron quick start**, because Electron uses the wrapper's `node` commands instead of `winapp run`. **Every other command's `--help`** now uses one layout: a summary, a short explanation, usage, examples, arguments, subcommands, and options. - **Color, in a terminal only:** headings are blue, commands and options bright white, and `<placeholders>` grey. Text after the first sentence of a description is grey, so you can skim, and multi-line entries get a blank line between them. Piped output, which agents read, stays plain text with no extra lines. - **`run`, `package` and `init`** get described examples that can use other commands. For example, `package` starts with `winapp cert generate` and ends with `Add-AppxPackage`. Their options are grouped by purpose, for example `run`'s Build, Launch, Package layout, and Debug and profile groups. Long placeholders are shorter: `-c <name>`, `-f <tfm>`, `--exe <path>`. - **Command groups** such as `cert`, `config` and `manifest` list their subcommands. The help pages that used the old default layout still show option defaults, allowed values (`--if-exists <Error|Overwrite|Skip>`), `(REQUIRED)` markers, and arguments `store` and `tool` pass through. - **`ui` and `devtools` pages:** unchanged when piped. Six `run`/`package` option descriptions drop internal detail. For example, `--debug-output` no longer explains the `WINAPP_DBGTOOLS_DIR` variable. `--cli-schema` shows the same shorter text. The CLI still rejects the combinations they no longer mention, with a clear error. ## Before / after **Root help, before**  **Root help, after** (top of the page)  **`winapp run --help`, before** (the options in an 88-column terminal)  **`winapp run --help`, after, piped** (the plain text agents read)  **In a terminal:** `winapp cert --help`, and the end of `winapp package --help`   <details><summary>After: the command panels below Quick start</summary> ``` All commands: ┌─Set Up & Run───────────────────────────────────────────────────────────────┐ │ new Create a new WinUI app │ │ init Add a manifest and SDK packages to a project │ │ restore Restore SDK packages for an initialized project │ │ update Update packages in winapp.yaml │ │ run Run an app from a project, .cs file, or folder │ │ create-debug-identity Add package identity to an exe for debugging │ │ unregister Unregister a sideloaded development package │ │ target Run commands and copy files on an execution target │ └────────────────────────────────────────────────────────────────────────────┘ ┌─Develop & Test────────────────────────────────────────────────────┐ │ find-ui Search WinUI controls and samples for working code │ │ find-api Search the Windows APIs your project references │ │ devtools Inspect and live-edit a running WinUI app's XAML │ │ ui Inspect and interact with running Windows app UIs │ │ perf Record WinUI timings, GC context, and process counters │ └───────────────────────────────────────────────────────────────────┘ ┌─Package, Sign & Publish─────────────────────────────────┐ │ package Create MSIX package or bundle │ │ manifest Create and modify Package.appxmanifest files │ │ cert Development certificates for code signing │ │ sign Code-sign an MSIX package or executable │ │ az-sign Code-sign a file using Azure Trusted Signing │ │ store Run a Microsoft Store Developer CLI command │ └─────────────────────────────────────────────────────────┘ ┌─Advanced───────────────────────────────────────────────────────────────────┐ │ embed-identity Add sparse package identity to an app's manifest │ │ create-external-catalog Create CodeIntegrityExternal.cat (TrustedLaunch) │ │ tool Run Windows SDK tools (makeappx, signtool, etc.) │ │ get-winapp-path Print the path to the global .winapp directory │ │ config Show or change your per-user winapp settings │ └────────────────────────────────────────────────────────────────────────────┘ ``` npm wrapper, appended after the existing Node.js section: ``` Electron quick start: npx winapp init add a manifest and Windows SDKs npx winapp node add-electron-debug-identity run with package identity npx winapp node create-addon call Windows APIs from a native addon ``` </details> ## Not tested / risks - I didn't run `npx winapp --help` end to end. I ran the npm unit tests (346 passed), including the one for the `init --help` wrapper option, which now prints under its own `npm wrapper` heading. - Colors appear only where winapp already uses them: Windows Terminal or VS Code, with UTF-8 output that isn't piped. Other terminals get the plain layout. - Quick start and the examples are hand-written. To keep them from going stale, tests parse every `winapp` line in them against the real CLI and fail on a misspelled command or option. `Add-AppxPackage` and `npx` lines aren't checked. ## Checklist - [x] Tests added or updated: `CompactCommandHelpTests` covers several things. Every command's help lists its subcommands and options and fits 88 columns. Colored help has the same text as plain help. Defaults, allowed values, `(REQUIRED)` and argument shapes are kept, and the `ui` pages are unchanged. Every option is in one group, and every example parses. `RootHelp_*` covers the Quick start. Command: `dotnet run --project src\winapp-CLI\WinApp.Cli.Tests\WinApp.Cli.Tests.csproj -c Release --no-build -- --filter "FullyQualifiedName~CompactCommandHelpTests|FullyQualifiedName~UiHelpTests|FullyQualifiedName~CustomHelpTests|FullyQualifiedName~DevToolsHelpTests|FullyQualifiedName~TargetSelectionParser|FullyQualifiedName~ConfigCommandTests|FullyQualifiedName~UiCommandTests|FullyQualifiedName~Perf"`. Result: passed, 1370 total and 0 failed. The full suite locally: every failure was environmental (nuget.org blocked on a corp machine, native test fixture not built, npm `dist` not built). - [x] Tested locally on Windows: Release build with 0 warnings, and the help rendered in Windows Terminal as shown above. - [x] Docs, samples, and `plugins/winapp/skills/`: none quote the help output or the changed descriptions. `docs\usage.md` keeps the full detail for the shortened options. <details><summary>Notes for reviewers</summary> - Quick start shows `ui` and `devtools` as `--help` on purpose. Those help pages are curated guides for agents (#942, #943). - `package` says `<.csproj|folder>` because it doesn't accept a `.vcxproj`, while `run` does (#1115). - Colors are raw terminal codes written only when `BannerHelper.UseEmoji` is true. Widths are computed on the plain text, so the layout is identical with and without color. - The new placeholder names (`HelpName`) contain no `|`. The npm generator turns `|` into a TypeScript union type, so these don't change the npm API. - `restore` now reads "Restore SDK packages for an initialized project". .NET projects set up by `init` have no `winapp.yaml`. </details> --------- Co-authored-by: Nikola Metulev <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: cefdbcd6-bef0-4fde-a18d-b01c7060aadb

Description
Agents driving an app with
winapp uihad to read a 6.5 KB help page with no starting point. They guessed command names that don't exist (ui dump,ui tree) and got either a generic parse error or, with--help, the same long page with exit 0.This PR makes
winapp uihelp usable as an agent's first read:winapp ui --help: plain text that starts with the golden path (inspect --interactive→invoke/set-value→get-value), defines-aand<selector>, then lists commands grouped by task: Discover, Act, Read and wait, Capture, Gestures, Workflow coordination. Edge-case commands say when to use them. 2,741 bytes, down from 6,538.uicommand, also plain text: summary, usage, 1–3 examples (placeholders only), arguments, options, and oneGlobal options:line. Examples are stored as data, and a test parses each one against its command. Help for other command groups is unchanged.winapp ui dumpexits 1 withDid you mean 'inspect'?and a pointer towinapp ui --help(a short command list appears only when there is no suggestion). This holds even with--help, and it happens before--on sandboxrouting, so no sandbox starts. With--jsonit emits the existing UI error envelope pluserror.suggestions. Common guesses from other tools map to the right command (dump/tree/snapshot→inspect,find/query→search,type→send-keys,press→invoke, …); anything else falls back to edit distance.Driving an app's UI from an agent or script? Start with 'winapp ui --help'.winapp ui invoke Cancel -w) now prints the error andRun 'winapp ui invoke --help' for usage.instead of the full help.The golden path's
"Save" --type Buttonadvice relies on #932, which lets every single-element command take--type/--root/--class-name.Usage Example
Observed with the built CLI (win-x64 NativeAOT):
New
winapp ui --help(full output, 2,741 bytes):Related Issue
Stacked on #932 (element filters on every single-element
uicommand). The twowinapp uibug fixes that were previously in this PR (-afor hosted apps like Calculator, editable elements ininspect --interactive) moved to their own PR intomain: #993.Type of Change
Checklist
plugins/winapp/skills/(if CLI commands/workflows changed)Screenshots / Demo
Not applicable: these are text-only CLI changes. See the observed output above.
Additional Notes
Compatibility:
winapp ui <unknown> --helpchanged from exit 0 (it printed theuihelp) to exit 1 with an error. No known consumer depends on that. Theuigroup description in--cli-schemais now one line; the golden-path block is rendered only bywinapp ui --help.Validation:
.\scripts\build-cli.ps1 -SkipTests -SkipMsixsucceeded..\scripts\validate-plugin-package.ps1 -CliSchemaPath <schema>passes, including the skill command examples.UiHelpTests,UiCommandTests,DesktopCaptureTests,ProgramTests,CustomHelpTests,CliSchemaTests(926 run, 925 passed, 1 interactive-only skip); npm tests 304/304.uicommand is in exactly one help category; every example parses against its command; help size and format; unknown-command text and JSON envelopes (including--help,--on sandbox,--json=false); suggestion mapping; barewinapp uistill shows group help;winapp ui -a Notepadreports the normal parse error rather thanUnknown command 'Notepad'.Limitations:
ui invoke --helpis about 1.6 KB because it keeps the full action and filter explanations. JSON error strings escape'as\u0027, the same as existing UI errors.AI Description
This section is auto-generated by AI when the PR is opened or updated. To opt out, delete this entire section including the marker comments.