WinAppVSCE / vsce-testing
AGENTS.md13 starsChanged 5 months agoMITView on GitHub
Read this first. It is the onboarding contract for any agent/session working in vsce-testing. It encodes the validated way to drive the WinApp VS Code extension (microsoft-winappcli.winapp) inside a live VS Code instance, plus every gotcha that has already cost hours to rediscover. Follow the "Getting started" checklist before doing anything else. This directory lives inside the WinAppVSCE repo at .github/skills/vsce-testing/. It provides the infrastructure for an agent to launch an isolated VS Code instance with the WinApp extension installed…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- pr-reviewSkill
- vsce-testingSkill
The file
We split this AGENTS.md into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Check for a stuck VS Code updater FIRST: If fresh instances mysteriously die ~35s after launch, a background update is holding the …
- Very specific: line 37
If a CodeSetup-stable-*.exe is running, every fresh --user-data-dir launch waits 30s then exits with Error: Code is currently being updated.
- Distinctive: line 49
If missing, (re)build + install:
- Distinctive: line 59
Sanity-check the mechanism: before doing real work:
- Very specific: line 94
Discipline before every action: focus → verify page → act: Never fire a command while a blocking modal is up.
- Very specific: line 132
Process-kill safety: only Stop-Process -Id <PID> for OUR instances (match drive-udd-* / .diag-* in the cmdline, or orphaned helpers whose …
- Very specific: line 148
Only typed when a #32770 native dialog is foreground.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — WinApp Extension Live-Drive Harness
Read this first. It is the onboarding contract for any agent/session working in
vsce-testing. It encodes the validated way to drive the WinApp VS Code extension (microsoft-winappcli.winapp) inside a live VS Code instance, plus every gotcha that has already cost hours to rediscover. Follow the "Getting started" checklist before doing anything else.
This directory lives inside the WinAppVSCE repo at .github/skills/vsce-testing/.
It provides the infrastructure for an agent to launch an isolated VS Code instance with the WinApp
extension installed and programmatically interact with the extension to test any piece of
functionality live.
TL;DR — how we actually drive the extension
Synthetic keyboard input is blocked in this environment, so we do not type into the Command
Palette. Instead we run a companion driver-extension (driver-extension/) inside the target VS
Code instance. It exposes a file-based command queue: we drop req-<id>.json into a queue dir and
it runs the real command via vscode.commands.executeCommand / vscode.debug.startDebugging, then
writes res-<id>.json. This drives the real extension and produces real effects (e.g.
devcert.pfx). UIA (winapp ui) is used only to click/read — dismiss modals, verify state,
screenshot. All of this is wrapped by scripts/vscode-drive.psm1.
Validated end-to-end by scripts/test-driver-queue.ps1 →
RESULT: editor=True driverDone=True certCreated=True.
Getting started (do these in order, every fresh session)
- Check for a stuck VS Code updater FIRST. If fresh instances mysteriously die ~35s after
launch, a background update is holding the InnoSetup
vscode-updatingmutex:
If aGet-CimInstance Win32_Process -Filter "Name LIKE 'CodeSetup%'" | Select ProcessId,CommandLineCodeSetup-stable-*.exeis running, every fresh--user-data-dirlaunch waits 30s then exits withError: Code is currently being updated. Wait for it to finish (build hash under%LOCALAPPDATA%\Programs\Microsoft VS Codechanges) or let the user complete it. Reusing an already-open instance is unaffected — only fresh-profile launches are blocked. - Ensure the winapp extension is installed into the isolated extensions dir (NOT the user's
global VS Code). A fresh
--user-data-dirstill uses the shared global extensions dir, so we pin our own--extensions-dir=.drive-extensions:
If missing, (re)build + install:code --extensions-dir="$PWD\.drive-extensions" --list-extensions --show-versions # expect: microsoft-winappcli.winapp@<version># From the repo root (4 levels up from this skill directory): $repoRoot = Resolve-Path "$PSScriptRoot\..\..\..\.." & "$repoRoot\scripts\build-vsce.ps1" -Package $vsix = Get-ChildItem "$repoRoot\artifacts\*.vsix" | sort LastWriteTime -desc | select -First 1 code --extensions-dir="$PWD\.drive-extensions" --install-extension $vsix.FullName --forceStart-VSCodeDriveauto-adds--extensions-dir=.drive-extensionswhen that dir exists. - Sanity-check the mechanism before doing real work:
pwsh -NoProfile -File scripts\test-driver-queue.ps1 -Project <path-to-a-winui-project> # PASS = "RESULT: editor=True driverDone=True certCreated=True"
The canonical live-drive workflow
Import-Module .\scripts\vscode-drive.psm1 -Force
$proj = "<path-to-your-winui-project>"
$file = "$proj\App.xaml.cs"
# 1. Launch an isolated, live instance WITH the driver-extension + command queue.
$ctx = Start-VSCodeDrive -Folder $proj -OpenFile $file -WithDriverExtension -SettleSec 24
# 2. Focus + clear the first-run modals, then confirm we're on the editor.
Set-VSCodeFocus -Ctx $ctx | Out-Null
$onEditor = Confirm-VSCodeEditor -Ctx $ctx -OpenFileIfNeeded $file
# 3. Push REAL extension commands to the LIVE instance and verify their effects.
Invoke-VSCodeDriverCommand -Ctx $ctx -CommandId 'winapp.certGenerate' -Answers @(@{accept=$true})
Invoke-VSCodeDriverCommand -Ctx $ctx -CommandId 'some.command' -Arguments @('value', 42)
Invoke-VSCodeDriverDebug -Ctx $ctx -InputFolder "$proj\bin\x64\Debug\net8.0-windows10.0.19041.0\win-x64"
Invoke-VSCodeDriverOpenFile -Ctx $ctx -Path "$proj\Package.appxmanifest"
# 4. Observe: screenshot the integrated terminal / editor.
winapp ui screenshot -w $ctx.Hwnd -o .\logs\step.png
# 5. Always tear down (removes the udd + queue dir).
Stop-VSCodeDrive -Ctx $ctxDiscipline before every action: focus → verify page → act. Never fire a command while a blocking
modal is up. Confirm-VSCodeEditor handles that; if you act manually, call Clear-VSCodeOverlays first.
Hard-won gotchas (do not relearn these)
- Synthetic keyboard injection is blocked environment-wide.
SendInputreturns success but reaches NO window (proven vs Notepad AND VS Code). The Command Palette (type-to-filter) cannot be driven.Send-VSCodeText/Chord/KeyandInvoke-VSCodeCommandexist but are non-functional here — use the driver queue instead. winapp ui set-valueis a no-op on VS Code inputs (Monaco/contentEditable). There is no way to type into VS Code inputs; commands needing a free-textshowInputBoxcan't be auto-answered.winapp ui invoke/click/search/screenshotDO work (UIA, no foreground needed). This is the usable "interact with controls" layer.- Match OUR window strictly by the
(Code, PID <n>)tag.winapp ui list-windowsWRAPS long lines — flatten whitespace first. NEVER title-match on "Visual Studio Code": the user's browser tabs (e.g. "Publishing Extensions | Visual Studio Code Extension API", shown as explorer TabProxyWindows) contain that phrase and get falsely selected — which leaves the real sign-in modal up.Get-VSCodeWindowalready does this correctly. - VS Code windows only appear in the UIA tree with
--force-renderer-accessibility(already passed byStart-VSCodeDrive). - First-run modals on a fresh udd (in order), even with seeded settings:
- "Sign in to use GitHub Copilot" modal → click "Continue without Signing In"
(
Close-VSCodeSignIn). Window survives. Always do this before firing commands. - "Make It Yours" walkthrough modal overlay (color-theme picker) → click its OWN close × whose
y-coordinate is >100 (
Close-VSCodeWalkthrough). NEVER the title-bar × (y<~80) — that destroys the whole instance.
- "Sign in to use GitHub Copilot" modal → click "Continue without Signing In"
(
- Editor detection:
workbench.parts.editoronly shows at UIAinspect --depth 12+; instead we cheaply search for the open file's tab basename (stored in$ctx.EditorFile). code --reuse-window --gotoMUST include--user-data-dir=$ctx.Uddor it targets the default profile, not our drive instance.- Most extension commands run fire-and-forget in an integrated terminal (
terminal.sendText).executeCommandreturns before the CLI finishes — poll for the effect, do not check immediately. Exception:winapp.certGeneratespawns the CLI directly and awaits its exit code, so its notifications appear without polling. command 'winapp.certGenerate' not foundmeans the winapp extension isn't loaded in that instance → fix the--extensions-dir(step 2 above), it's not a code bug.- Process-kill safety: only
Stop-Process -Id <PID>for OUR instances (matchdrive-udd-*/.diag-*in the cmdline, or orphaned helpers whose parent is dead — e.g. a leakeddotnet.exeRoslyn BuildHost holdingexthost.log). NEVER kill the user's VS Code, the node runtime, or Notepad (Win11 Notepad is single-process; PID-killing it closes the user's tabs).
Driver command IDs & answer schemas
Real command IDs: winapp.getWinappPath, winapp.init, winapp.restore, winapp.manifestGenerate,
winapp.certGenerate, winapp.pack, winapp.run, winapp.createDebugIdentity, winapp.sign,
winapp.certInstall, winapp.unregister, winapp.manifestAddAlias, …
Answers (ordered, one per prompt the command raises):
@{accept=$true}— accept the selected QuickPick item (e.g. certGenerate's Install Yes/No).@{nativeDialogPath='<path>'}— ashowOpenDialogfolder picker (pack/run). Only typed when a#32770native dialog is foreground; a Chromium dialog isSKIPPED.@{nativeFileDialogPath='<path>'}— ashowOpenDialogfile picker (createDebugIdentity, sign, certInstall). Targets theFile name:edit field and clicksOpen.- Free-text
showInputBoxprompts (e.g. cert password) cannot be auto-answered — avoid or accept defaults.
winapp.certGenerate prompt sequence (it is no longer a single Yes/No):
- Install QuickPick — "Generate only" vs "Generate and install (requires admin)" →
@{accept=$true}. - Publisher
showInputBox— raised when the resolved project directory holds no canonically named manifest (Package.appxmanifest/AppxManifest.xmldirectly in that directory). A normal project has one, so the publisher comes from it and this prompt does not appear. There is no manifest picker: nothing else is offered as a substitute. This is a free-text prompt and therefore not auto-answerable: drive certGenerate against a project that contains a canonically named manifest so the prompt never appears. - Overwrite warning — raised when the certificate already exists. Its actions
("Overwrite Existing Cert" / "Use Existing Cert") are notification buttons, which UIA does not
expose; only the aria-live label text is readable. Delete the stale
.pfxfirst for a clean run.
Command arguments are passed with -Arguments; queue/script JSON uses args. Descriptors with
kind: activeDocumentUri, fileUri, or position resolve to the corresponding VS Code API object.
Legacy steps with type: commandArgs remain supported.
debug steps use launch.json's inputFolder (the app's built win-x64 output). No dialogs.
Learned behaviors — pack / sign / F5
- Native folder dialogs ARE now automatable via UIA.
SendKeysis blocked, butwinapp ui set-valuedoes work on the native#32770"Folder:" edit (unlike Monaco). The driver'stypeIntoNativeDialog(extension.js) was rewritten to: poll for a foreground#32770, resolve the "Folder:" Edit slug viaset-value's own disambiguation output,set-valuethe path, thenwinapp ui invoke "Select Folder". This unblocked pack/run/createDebugIdentity/F5-packaging. winapp.packneeds the BUILD-OUTPUT folder (bin\…\win-x64, containing the.exe), NOT the project source folder (the dialog's default). Wrong folder ⇒ "no .exe files were found in the input folder." Pack then raises two QuickPicks: "Generate and install a development certificate?" and "Bundle Windows App SDK runtime (self-contained)?" → answer order for the driver is@(@{nativeDialogPath=$buildOutput}, @{accept=$true}, @{accept=$true}).- Pack is slow + fire-and-forget. The driver returns
donein ~11s butwinapp packkeeps building in the terminal; poll for the MSIX (up to ~2 min). Output lands at<proj>\.winapp\self-contained\<arch>\extracted\MSIX\Main.msix(hidden, generically named). - F5 /
Invoke-VSCodeDriverDebugworks with a validlaunch.jsoninputFolder= thewin-x64build output containing the exe:sessionEventsshowsstart:coreclr:…and the app process comes up. NOTEstartDebuggingreturns false even on success — key onlaunched(astart:coreclrevent), notstarted. IfinputFolderis empty/wrong, F5 silently falls back to the pack folder picker. - The WinApp debugger requires
ms-dotnettools.csharp(coreclr) — install it into.drive-extensionstoo:code --extensions-dir=.drive-extensions --install-extension ms-dotnettools.csharp. Without it F5 shows an "Install Extension" prompt. signuses a FILE picker ("Select file to sign", button "Open"), not a folder picker — use@{nativeFileDialogPath='<path-to-msix>'}to answer it. ThecreateDebugIdentitycommand also uses a file picker ("Select executable") — use@{nativeFileDialogPath='<path-to-exe>'}.
Key files
scripts/vscode-drive.psm1— the automation module. Working:Start-VSCodeDrive,Set-VSCodeFocus,Get-VSCodeState,Close-VSCodeSignIn,Clear-VSCodeOverlays,Close-VSCodeWalkthrough,Confirm-VSCodeEditor,Invoke-VSCodeElement, and the RELIABLEInvoke-VSCodeDriver{Step,Command,Debug,OpenFile}.Stop-VSCodeDrivecleans up.driver-extension/extension.js— the in-VS-Code driver:startQueuePoller()watchesWINAPP_UX_QUEUE\req-*.json; also runs a one-shot batch fromWINAPP_UX_SCRIPT.scripts/test-driver-queue.ps1— end-to-end validation (run to confirm the mechanism works).scripts/test-vscode-drive.ps1— complementary smoke test: launches VS Code, verifies focus/editor, then exercises the queue-based command flow viaInvoke-VSCodeDriverCommand.scripts/drive-extension.ps1— batch launcher (WINAPP_UX_SCRIPT) for running scripted step sequences.scripts/install-extension.ps1— builds the local VSIX and installs it into VS Code.scripts/probe-*.ps1— targeted probes for specific features (F5 debug, pack, native dialogs)..drive-extensions/— isolated extensions dir holding the installed winapp extension.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

