[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FKWW5NEQZTK42F4H5BQZAQ":3,"skill-same:01M6FKWW5NEQZTK42F4H5BQZAQ":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":33,"linkOnly":34,"markdownContent":35,"markdownBody":36,"frontMatter":37,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":41,"repositoryHtmlUrl":42,"repositoryHomepageUrl":43,"ownerHtmlUrl":44,"ownerBlogUrl":45,"ownerDescription":46,"updatedAt":47,"install":48,"resources":61},"01M6FKWW5NEQZTK42F4H5BQZAQ","cli-e2e-testing",null,"Use when creating, modifying, debugging, or reviewing Aspire CLI end-to-end tests that use Hex1b terminal automation under tests\u002FAspire.Cli.EndToEnd.Tests\u002F.","microsoft\u002Faspire","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M6FKTZ7ND1S9JN6JTVK7A7MD",6426,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcli-e2e-testing\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32],"testing","cli","e2e testing","e2e","cli e2e testing","terminal","automation","aspire","debugging","hex1b","use","tests","end","when","2026-11-10 10:12:30",false,"---\nname: cli-e2e-testing\ndescription: Use when creating, modifying, debugging, or reviewing Aspire CLI end-to-end tests that use Hex1b terminal automation under tests\u002FAspire.Cli.EndToEnd.Tests\u002F.\n---\n\n# Aspire CLI End-to-End Testing with Hex1b\n\nThis skill provides patterns and practices for writing end-to-end tests for the Aspire CLI using the Hex1b terminal automation library.\n\n## Overview\n\nCLI E2E tests use the Hex1b library to automate terminal sessions, simulating real user interactions with the Aspire CLI. Tests run in CI with asciinema recordings for debugging.\n\n**Location**: `tests\u002FAspire.Cli.EndToEnd.Tests\u002F`\n\n**Supported Platforms**: Linux only. Hex1b requires a Linux terminal environment. Tests are configured to skip on Windows and macOS in CI.\n\n## Key Components\n\n### Core Classes\n\n- **`Hex1bTerminal`**: The main terminal class from the Hex1b library for terminal automation\n- **`Hex1bTerminalAutomator`**: Async\u002Fawait API for driving a `Hex1bTerminal` — the preferred approach for new tests\n- **`Hex1bAutomatorTestHelpers`** (shared helpers): Async extension methods on `Hex1bTerminalAutomator` (`WaitForSuccessPromptAsync`, `AspireNewAsync`, etc.)\n- **`CliE2EAutomatorHelpers`** (`Helpers\u002FCliE2EAutomatorHelpers.cs`): CLI-specific async extension methods on `Hex1bTerminalAutomator` (`PrepareDockerEnvironmentAsync`, `InstallAspireCliAsync`, etc.)\n- **`CellPatternSearcher`**: Pattern matching for terminal cell content\n- **`SequenceCounter`** (`Helpers\u002FSequenceCounter.cs`): Tracks command execution count for deterministic prompt detection\n- **`CliE2ETestHelpers`** (`Helpers\u002FCliE2ETestHelpers.cs`): Environment variable helpers and terminal factory methods\n- **`TemporaryWorkspace`**: Creates isolated temporary directories for test execution\n- **`Hex1bTerminalInputSequenceBuilder`** *(legacy)*: Fluent builder API for building sequences of terminal input\u002Foutput operations. Prefer `Hex1bTerminalAutomator` for new tests.\n\n### Test Architecture\n\nEach test:\n1. Creates a `TemporaryWorkspace` for isolation\n2. Builds a `Hex1bTerminal` with headless mode and asciinema recording\n3. Creates a `Hex1bTerminalAutomator` wrapping the terminal\n4. Drives the terminal with async\u002Fawait calls and awaits completion\n\n## Test Structure\n\n```csharp\npublic sealed class SmokeTests(ITestOutputHelper output)\n{\n    [Fact]\n    public async Task MyCliTest()\n    {\n        var repoRoot = CliE2ETestHelpers.GetRepoRoot();\n        var strategy = CliInstallStrategy.Detect(output.WriteLine);\n        var workspace = TemporaryWorkspace.Create(output);\n\n        using var terminal = CliE2ETestHelpers.CreateDockerTestTerminal(repoRoot, strategy, output, workspace: workspace);\n\n        var counter = new SequenceCounter();\n        var auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500));\n        await using var terminalRun = CliE2ETestHelpers.StartRun(terminal, workspace, auto, counter, output, TestContext.Current.CancellationToken);\n\n        await auto.PrepareDockerEnvironmentAsync(counter, workspace);\n        await auto.InstallAspireCliAsync(strategy, counter);\n\n        await auto.TypeAsync(\"aspire --version\");\n        await auto.EnterAsync();\n        await auto.WaitForSuccessPromptAsync(counter);\n    }\n}\n```\n\n### TerminalRun Pattern\n\n**Always use `CliE2ETestHelpers.StartRun`** to wrap the terminal run. This returns a `TerminalRun` (implements `IAsyncDisposable`) that automatically:\n1. Captures Aspire diagnostics via `CaptureAspireDiagnosticsAsync` (best effort)\n2. Types `exit` and presses Enter to close the terminal\n3. Awaits the pending run task\n\nThis eliminates the need for manual `exit`\u002F`await pendingRun` at the end of every test and ensures diagnostics are always captured, even when tests fail.\n\n```csharp\n\u002F\u002F DO: Use StartRun for consistent diagnostics capture and cleanup\nusing var terminal = CliE2ETestHelpers.CreateDockerTestTerminal(repoRoot, strategy, output, workspace: workspace);\n\nvar counter = new SequenceCounter();\nvar auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500));\nawait using var terminalRun = CliE2ETestHelpers.StartRun(terminal, workspace, auto, counter, output, TestContext.Current.CancellationToken);\n\n\u002F\u002F ... test body — no exit\u002FpendingRun needed at the end\n\n\u002F\u002F DON'T: Manually handle exit and pendingRun\nvar pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);\n\u002F\u002F ... test body ...\nawait auto.TypeAsync(\"exit\");\nawait auto.EnterAsync();\nawait pendingRun;\n```\n\n## Running Tests Locally\n\nCLI E2E tests run inside Docker containers on Linux. The workflow is: build a portable archive with `localhive`, then point the tests at it. This is the primary way to iterate on E2E tests during development.\n\n### Prerequisites\n\n- Docker Desktop running (with Linux containers)\n- .NET 10 SDK (installed via `.\u002Frestore.sh` or `.\\restore.cmd`)\n\n### Quick Start (macOS \u002F Linux)\n\n```bash\n# 1. Build a portable archive with CLI + packages + bundle\n#    Use linux-arm64 on Apple Silicon, linux-x64 on Intel\u002FLinux\n.\u002Flocalhive.sh -o \u002Ftmp\u002Faspire-e2e -r linux-arm64 --archive\n\n# 2. Run a specific test\nASPIRE_E2E_ARCHIVE=\u002Ftmp\u002Faspire-e2e.tar.gz \\\n  dotnet test tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-method \"*.CreateAndRunAspireStarterProject\"\n\n# 3. Run all tests in a class\nASPIRE_E2E_ARCHIVE=\u002Ftmp\u002Faspire-e2e.tar.gz \\\n  dotnet test tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-class \"*.SmokeTests\"\n```\n\n### Quick Start (Windows \u002F PowerShell)\n\n```powershell\n# 1. Build a portable archive (Docker Desktop uses linux-x64 via WSL2)\n.\\localhive.ps1 -o C:\\tmp\\aspire-e2e -r linux-x64 -Archive\n\n# 2. Run a specific test\n$env:ASPIRE_E2E_ARCHIVE = \"C:\\tmp\\aspire-e2e.tar.gz\"\ndotnet test tests\\Aspire.Cli.EndToEnd.Tests\\Aspire.Cli.EndToEnd.Tests.csproj `\n  -- --filter-method \"*.CreateAndRunAspireStarterProject\"\n\n# 3. Run all tests in a class\ndotnet test tests\\Aspire.Cli.EndToEnd.Tests\\Aspire.Cli.EndToEnd.Tests.csproj `\n  -- --filter-class \"*.SmokeTests\"\n```\n\n### Choosing the Right RID\n\nThe archive must match the Docker container's architecture:\n\n| Host | Docker Desktop | RID |\n|------|---------------|-----|\n| Apple Silicon Mac | Linux arm64 containers | `linux-arm64` |\n| Intel Mac | Linux x64 containers | `linux-x64` |\n| Windows (any) | WSL2 Linux x64 | `linux-x64` |\n| Linux x64 | Native | `linux-x64` |\n| Linux arm64 | Native | `linux-arm64` |\n\n### Development Workflow\n\nThe typical loop when writing or debugging E2E tests:\n\n```bash\n# 1. Make your code changes (CLI, hosting, templates, etc.)\n\n# 2. Rebuild the archive (picks up all changes — ~3 min)\n.\u002Flocalhive.sh -o \u002Ftmp\u002Faspire-e2e -r linux-arm64 --archive\n\n# 3. Run the specific test you're working on\nASPIRE_E2E_ARCHIVE=\u002Ftmp\u002Faspire-e2e.tar.gz \\\n  dotnet test tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-method \"*.YourTestName\"\n\n# 4. If it fails, check the asciinema recording\n#    Recordings are saved under the test output TestResults\u002Frecordings\u002F directory\n#    Play with: asciinema play \u002Fpath\u002Fto\u002FYourTestName.cast\n\n# 5. Fix and repeat from step 1 or 2\n```\n\n### Install Modes\n\nThe `CliInstallStrategy` class auto-detects how to install the CLI in the test container. You can override via environment variables:\n\n| Env Var | Mode | Example |\n|---------|------|---------|\n| `ASPIRE_E2E_ARCHIVE` | LocalHive — extract archive into container | `\u002Ftmp\u002Faspire-e2e.tar.gz` |\n| `ASPIRE_E2E_QUALITY` | Install script with quality | `dev`, `staging`, `release` |\n| `ASPIRE_E2E_VERSION` | Install script with version | `13.2.1` |\n| *(none, in CI)* | PullRequest — install from PR artifacts | Auto-detected |\n| *(none, locally)* | InstallScript (latest GA) | Auto-detected |\n\n**LocalHive** (via `ASPIRE_E2E_ARCHIVE`) is the recommended mode for local development — it uses your locally-built CLI, packages, and bundle so you test exactly what you've changed.\n\n### Testing Against Released Versions\n\nUseful for verifying tests pass against shipped versions or catching regressions:\n\n```bash\n# Test against latest GA release\nASPIRE_E2E_QUALITY=release dotnet test tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-method \"*.CreateAndRunAspireStarterProject\"\n\n# Test against daily builds\nASPIRE_E2E_QUALITY=dev dotnet test ...\n\n# Test against a specific version\nASPIRE_E2E_VERSION=13.2.1 dotnet test ...\n```\n\n### Emulated channel matrix tests (identity sidecar)\n\nA set of tests validates the **CLI identity sidecar** — the ability to make a locally built CLI\nemulate a different channel\u002Fversion via `ASPIRE_CLI_*` env vars. They form an AppHost-language ×\nchannel-emulation matrix (one test per language because C# and TypeScript scaffold through different\ncode paths and have diverged before):\n\n| Class | Channel emulated | `Aspire*` source | NuGet.config dropped? |\n|-------|------------------|------------------|------------------------|\n| `EmulatedReleasedBuildTests` | `stable` (latest shipped) | nuget.org | No (C# and TS) |\n| `EmulatedStagingBuildTests` | `staging` (latest darc build) | `darc-pub-...` feed | Yes — darc feed pin |\n| `EmulatedLocalReleaseBuildTests` | `stable` (**future, local-only**) | local hive via `ASPIRE_CLI_PACKAGES` | No (C# and TS) |\n\n`EmulatedLocalReleaseBuildTests` is the **all-local \"future release\"** row: it emulates a version\n(e.g. `13.5.0`) that exists only in a locally built hive, so a successful resolve proves the CLI\nconsulted `ASPIRE_CLI_PACKAGES` rather than nuget.org. Run it by building a **stable-shaped** archive\nwith `localhive --version`:\n\n```bash\n# 1. Build a stable-shaped archive (note: --version X.Y.Z, NOT a prerelease suffix)\n.\u002Flocalhive.sh --version 13.5.0 -o \u002Ftmp\u002Faspire-localrelease -r linux-arm64 --archive\n\n# 2. Run the all-local class\nASPIRE_E2E_ARCHIVE=\u002Ftmp\u002Faspire-localrelease.tar.gz \\\n  dotnet test --project tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-class \"*.EmulatedLocalReleaseBuildTests\"\n```\n\nThese tests **skip** unless the CLI was installed from a `LocalHive` archive *and* that archive is\nstable-shaped (no prerelease suffix). In default CI the archive is a prerelease `LocalArchive`, so they\nskip and add zero CI cost — CI relies on `--ignore-exit-code 8` (set in `eng\u002FTesting.targets`\n`MtpBaseArgs`) so an all-skipped class job still passes. The test also registers the hive as an\n**ambient** NuGet source (`dotnet nuget add source`) because MSBuild resolves the apphost's\n`Aspire.AppHost.Sdk` before restore from nuget.config sources only, ignoring `ASPIRE_CLI_PACKAGES`.\n\n> **⚠️ Local rebuilds: isolate the NuGet global cache.** This only affects **local** iteration of a\n> stable-shaped emulation (the E2E tests run in fresh Docker containers, so CI is immune). NuGet's\n> global packages folder (`~\u002F.nuget\u002Fpackages\u002F\u003Cid>\u002F\u003Cversion>\u002F`) caches **extracted** packages keyed by\n> version. When you emulate a *fixed* stable version (e.g. `13.5.0`) and **rebuild** it, a stale\n> `13.5.0` in that shared cache silently shadows the freshly built one — same version, different\n> content — so restore drifts (the stale AppHost SDK injects a prerelease floor and you get `NU1603`\n> warnings binding the graph to a stray `13.5.0-pr.…`). **Fix:** point `NUGET_PACKAGES` at a\n> per-emulation directory (`export NUGET_PACKAGES=\u002Ftmp\u002Faspire-localrelease\u002F.nuget-packages`).\n> `localhive … -o DIR`'s generated `activate.sh`\u002F`activate.ps1` already sets this up. See the cache\n> hazard note in `.agents\u002Fskills\u002Fcli-channel-debugging\u002FSKILL.md` (Scenario 7c) for the full mechanism.\n\n## SequenceCounter and Prompt Detection\n\nThe `SequenceCounter` class tracks the number of shell commands executed. This enables deterministic waiting for command completion via a custom shell prompt.\n\n### How It Works\n\n1. `PrepareDockerEnvironmentAsync()` configures the shell with a custom prompt: `[N OK] $ ` or `[N ERR:code] $ `\n2. Each command increments the counter\n3. `WaitForSuccessPromptAsync(counter)` waits for a prompt showing the current count with `OK`\n\n```csharp\nvar counter = new SequenceCounter();\nvar auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500));\n\nawait auto.PrepareDockerEnvironmentAsync(counter, workspace);  \u002F\u002F Sets up prompt, counter starts at 1\n\nawait auto.TypeAsync(\"echo hello\");\nawait auto.EnterAsync();\nawait auto.WaitForSuccessPromptAsync(counter);  \u002F\u002F Waits for \"[1 OK] $ \", then increments to 2\n\nawait auto.TypeAsync(\"ls -la\");\nawait auto.EnterAsync();\nawait auto.WaitForSuccessPromptAsync(counter);  \u002F\u002F Waits for \"[2 OK] $ \", then increments to 3\n\nawait auto.TypeAsync(\"exit\");\nawait auto.EnterAsync();\n```\n\nThis approach is more reliable than arbitrary timeouts because it deterministically waits for each command to complete.\n\n## Pattern Searching with CellPatternSearcher\n\nUse `CellPatternSearcher` to find text patterns in terminal output:\n\n```csharp\n\u002F\u002F Simple text search (literal string matching - PREFERRED)\nvar waitingForPrompt = new CellPatternSearcher()\n    .Find(\"Enter the project name\");\n\n\u002F\u002F Literal string with special characters (use Find, not FindPattern!)\nvar waitingForTemplate = new CellPatternSearcher()\n    .Find(\"> Starter App (FastAPI\u002FReact)\");  \u002F\u002F Parentheses and slashes are literal\n\n\u002F\u002F Regex pattern (only when you need wildcards\u002Fregex features)\nvar waitingForAnyStarter = new CellPatternSearcher()\n    .FindPattern(\"> Starter App.*\");  \u002F\u002F .* matches anything\n\n\u002F\u002F Chained patterns (find \"b\", then scan right until \"$\", then right of \" \")\nvar waitingForShell = new CellPatternSearcher()\n    .Find(\"b\").RightUntil(\"$\").Right(' ').Right(' ');\n\n\u002F\u002F Use in WaitUntilAsync\nawait auto.WaitUntilAsync(\n    snapshot => waitingForPrompt.Search(snapshot).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for prompt\");\n```\n\n### Find vs FindPattern\n\n- **`Find(string)`**: Literal string matching. Use this for most cases.\n- **`FindPattern(string)`**: Regex pattern matching. Use only when you need regex features like wildcards.\n\n**Important**: If your search string contains regex special characters like `(`, `)`, `\u002F`, `.`, `*`, `+`, `?`, `[`, `]`, `{`, `}`, `^`, `$`, `|`, or `\\`, use `Find()` instead of `FindPattern()` to avoid regex interpretation.\n\n## Extension Methods\n\n### Hex1bAutomatorTestHelpers Extensions (Shared — Automator API)\n\n| Method | Description |\n|--------|-------------|\n| `WaitForSuccessPromptAsync(counter, timeout?)` | Waits for `[N OK] $ ` prompt, fails immediately if error prompt appears, and increments counter |\n| `WaitForAnyPromptAsync(counter, timeout?)` | Waits for any prompt (`OK` or `ERR`) and increments counter |\n| `WaitForErrorPromptAsync(counter, timeout?)` | Waits for `[N ERR:code] $ ` prompt and increments counter |\n| `RunCommandAsync(command, counter, timeout?)` | Types a command, presses Enter, and waits for success prompt (fails fast on error) |\n| `DeclineAgentInitPromptAsync()` | Declines the `aspire agent init` prompt if it appears |\n| `AspireNewAsync(projectName, counter, template?, useRedisCache?)` | Runs `aspire new` interactively, handling template selection, project name, output path, URLs, Redis, and test project prompts |\n\nSee [AspireNew Helper](#aspirenew-helper) below for detailed usage.\n\n### CliE2EAutomatorHelpers Extensions on Hex1bTerminalAutomator\n\n| Method | Description |\n|--------|-------------|\n| `PrepareDockerEnvironmentAsync(counter, workspace)` | Sets up Docker container environment with custom prompt and command tracking |\n| `InstallAspireCliAsync(installMode, counter)` | Installs the Aspire CLI inside the Docker container |\n| `ClearScreenAsync(counter)` | Clears the terminal screen and waits for prompt |\n\n### SequenceCounterExtensions\n\n| Method | Description |\n|--------|-------------|\n| `IncrementSequence(counter)` | Manually increments the counter |\n\n### Legacy Builder Extensions\n\nThe following extensions on `Hex1bTerminalInputSequenceBuilder` are still available but should not be used in new tests:\n\n| Method | Description |\n|--------|-------------|\n| `WaitForSuccessPrompt(counter, timeout?)` | *(legacy)* Waits for `[N OK] $ ` prompt and increments counter |\n| `PrepareEnvironment(workspace, counter)` | *(legacy)* Sets up custom prompt with command tracking |\n| `SourceAspireBundleEnvironment(counter)` | *(legacy)* Sources bundle PATH environment variables |\n\n## DO: Use CellPatternSearcher for Output Detection\n\nWait for specific output patterns rather than arbitrary delays:\n\n```csharp\nvar waitingForMessage = new CellPatternSearcher()\n    .Find(\"Project created successfully.\");\n\nawait auto.TypeAsync(\"aspire new\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitingForMessage.Search(s).Count > 0,\n    TimeSpan.FromMinutes(2),\n    description: \"waiting for project created message\");\n```\n\n## DO: Use WaitForSuccessPromptAsync After Commands\n\nAfter running shell commands, use `WaitForSuccessPromptAsync()` to wait for the command to complete:\n\n```csharp\nawait auto.TypeAsync(\"dotnet build\");\nawait auto.EnterAsync();\nawait auto.WaitForSuccessPromptAsync(counter);  \u002F\u002F Waits for prompt, verifies success\n\nawait auto.TypeAsync(\"dotnet run\");\nawait auto.EnterAsync();\nawait auto.WaitForSuccessPromptAsync(counter);\n```\n\n## AspireNew Helper\n\nThe `AspireNew` extension method centralizes the multi-step `aspire new` interactive flow. Use it instead of manually building the prompt sequence.\n\n### AspireTemplate Enum\n\n| Value | Template | Arrow Keys |\n|-------|----------|------------|\n| `Starter` (default) | Starter App (Blazor) | None (first option) |\n| `JsReact` | Starter App (ASP.NET Core\u002FReact) | Down ×1 |\n| `PythonReact` | Starter App (FastAPI\u002FReact) | Down ×2 |\n| `ExpressReact` | Starter App (Express\u002FReact) | Down ×3 |\n| `EmptyAppHost` | Empty AppHost | Down ×4 |\n\n### Parameters\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `projectName` | (required) | Project name typed at the prompt |\n| `counter` | (required) | `SequenceCounter` for prompt tracking |\n| `template` | `AspireTemplate.Starter` | Which template to select |\n| `useRedisCache` | `true` | Accept Redis (Enter) or decline (Down+Enter). Only applies to Starter, JsReact, PythonReact. |\n\n### Usage Examples\n\n```csharp\n\u002F\u002F Starter template with defaults (Redis=Yes, TestProject=No)\nawait auto.AspireNewAsync(\"MyProject\", counter);\n\n\u002F\u002F Starter template, no Redis\nawait auto.AspireNewAsync(\"MyProject\", counter, useRedisCache: false);\n\n\u002F\u002F JsReact template, no Redis\nawait auto.AspireNewAsync(\"MyProject\", counter, template: AspireTemplate.JsReact, useRedisCache: false);\n\n\u002F\u002F PythonReact template\nawait auto.AspireNewAsync(\"MyProject\", counter,\n    template: AspireTemplate.PythonReact,\n    useRedisCache: false);\n\n\u002F\u002F Empty app host\nawait auto.AspireNewAsync(\"MyProject\", counter, template: AspireTemplate.EmptyAppHost);\n```\n\n## DO: Handle Interactive Prompts\n\nFor `aspire new`, use the `AspireNewAsync` helper instead of manually building the prompt sequence:\n\n```csharp\n\u002F\u002F DO: Use the helper\nawait auto.AspireNewAsync(\"MyProject\", counter);\n\n\u002F\u002F DON'T: Manually build the sequence (this is what AspireNewAsync does internally)\nvar waitingForTemplatePrompt = new CellPatternSearcher()\n    .FindPattern(\"> Starter App\");\nvar waitingForProjectNamePrompt = new CellPatternSearcher()\n    .Find(\"Enter the project name\");\nawait auto.TypeAsync(\"aspire new\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitingForTemplatePrompt.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for template prompt\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitingForProjectNamePrompt.Search(s).Count > 0,\n    TimeSpan.FromSeconds(10),\n    description: \"waiting for project name prompt\");\nawait auto.TypeAsync(\"MyProject\");\nawait auto.EnterAsync();\n```\n\nFor other interactive CLI commands, wait for each prompt before responding:\n\n```csharp\nvar waitingForPrompt = new CellPatternSearcher()\n    .Find(\"Enter your choice\");\n\nawait auto.TypeAsync(\"aspire some-command\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitingForPrompt.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for choice prompt\");\nawait auto.EnterAsync();\n```\n\n## DO: Use Ctrl+C to Stop Long-Running Processes\n\nFor processes like `aspire run` that don't exit on their own:\n\n```csharp\nusing Hex1b.Input;\n\nawait auto.TypeAsync(\"aspire run\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitForCtrlCMessage.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for Ctrl+C message\");\nawait auto.Ctrl().KeyAsync(Hex1bKey.C);  \u002F\u002F Send Ctrl+C\nawait auto.WaitForSuccessPromptAsync(counter);\n```\n\n## DO: Check IsRunningInCI for CI-Only Operations\n\nSome operations only apply in CI (like installing CLI from PR artifacts):\n\n```csharp\nvar installMode = CliInstallStrategy.Detect(output.WriteLine);\n\nawait auto.PrepareDockerEnvironmentAsync(counter, workspace);\nawait auto.InstallAspireCliAsync(installMode, counter);\n\n\u002F\u002F Continue with test commands...\n```\n\n## DO: Get Environment Variables Using Helpers\n\nUse `CliE2ETestHelpers` for CI environment variables:\n\n```csharp\nvar prNumber = CliE2ETestHelpers.GetRequiredPrNumber();   \u002F\u002F GITHUB_PR_NUMBER (0 when local)\nvar commitSha = CliE2ETestHelpers.GetRequiredCommitSha(); \u002F\u002F GITHUB_PR_HEAD_SHA (\"local0000\" when local)\nvar isCI = CliE2ETestHelpers.IsRunningInCI;               \u002F\u002F true when both env vars set\n```\n\n## DO: Always Include `description:` on WaitUntilAsync\n\nEvery `WaitUntilAsync` call requires a named `description:` parameter. This description appears in logs and asciinema recordings to make debugging easier when a wait times out.\n\n```csharp\n\u002F\u002F DON'T: Missing description\nawait auto.WaitUntilAsync(\n    s => pattern.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30));\n\n\u002F\u002F DO: Include a meaningful description\nawait auto.WaitUntilAsync(\n    s => pattern.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for build output\");\n```\n\n## DO: Inline Code Where `ExecuteCallback` Was Used\n\nThe old builder API used `ExecuteCallback()` to run synchronous operations mid-sequence. With the automator API, simply inline the code directly — no special wrapper is needed.\n\n```csharp\n\u002F\u002F Old builder API (DON'T use in new tests)\nsequenceBuilder\n    .ExecuteCallback(() => File.WriteAllText(configPath, newConfig))\n    .Type(\"aspire run\")\n    .Enter();\n\n\u002F\u002F Automator API (DO)\nFile.WriteAllText(configPath, newConfig);\nawait auto.TypeAsync(\"aspire run\");\nawait auto.EnterAsync();\n```\n\n## DON'T: Use Hard-coded Delays\n\nUse `WaitUntilAsync()` with specific output patterns instead of arbitrary delays:\n\n```csharp\n\u002F\u002F DON'T: Arbitrary delays\nawait Task.Delay(TimeSpan.FromSeconds(30));\n\n\u002F\u002F DO: Wait for specific output\nawait auto.WaitUntilAsync(\n    snapshot => pattern.Search(snapshot).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for expected output\");\n```\n\n## DON'T: Hard-code Prompt Sequence Numbers\n\nDon't hard-code the sequence numbers in `WaitForSuccessPromptAsync` calls. Use the counter:\n\n```csharp\n\u002F\u002F DON'T: Hard-coded sequence numbers\nawait auto.WaitUntilAsync(\n    s => s.GetScreenText().Contains(\"[3 OK] $ \"),\n    timeout,\n    description: \"waiting for prompt\");\n\n\u002F\u002F DO: Use the counter\nawait auto.WaitForSuccessPromptAsync(counter);\n```\n\nThe counter automatically tracks which command you're waiting for, even if command sequences change.\n\n## Writing New Tests with Hex1b MCP Server\n\nWhen writing new CLI E2E tests, use the **Hex1b MCP server** to interactively explore what terminal output to expect. The MCP server provides tools to start terminal sessions, send commands, and capture screenshots—helping you discover the exact strings and prompts to use in `CellPatternSearcher`.\n\n### Workflow for Discovering Patterns\n\n1. **Start a bash terminal session** using the MCP server's terminal creation tools\n2. **Send commands** (like `aspire new` or `aspire run`) and observe the output\n3. **Capture terminal screenshots** (SVG or text) to see exact formatting\n4. **Use captured text** to build your `CellPatternSearcher` patterns\n\n### Example: Finding Prompt Text for `aspire new`\n\nAsk the MCP server to:\n1. Start a new bash terminal\n2. Run `aspire new` interactively\n3. Capture the terminal text at each prompt\n\nThis reveals the exact strings like:\n- `\"> Starter App\"` for template selection\n- `\"Enter the project name\"` for name input\n- `\"Press Ctrl+C to stop...\"` for run completion\n\n### Benefits\n\n- **See real output**: No guessing what text appears in the terminal\n- **Exact formatting**: Capture shows spacing, ANSI codes stripped, actual cell content\n- **Interactive exploration**: Try different inputs and see responses before writing test code\n- **Debug patterns**: If a `CellPatternSearcher` isn't matching, capture current terminal state to compare\n\n### Tips\n\n- Use `Capture Terminal Text` to get plain text for pattern matching\n- Use `Capture Terminal Screenshot` (SVG) for visual debugging\n- The `Wait for Terminal Text` tool works similarly to `WaitUntil` in tests\n- Terminal sessions persist, so you can step through multi-command sequences\n\n## Adding New Extension Methods\n\nWhen adding new CLI operations as extension methods, define them on `Hex1bTerminalAutomator`:\n\n```csharp\ninternal static async Task MyNewOperationAsync(\n    this Hex1bTerminalAutomator auto,\n    string arg,\n    SequenceCounter counter,\n    TimeSpan? timeout = null)\n{\n    var expectedOutput = new CellPatternSearcher()\n        .Find(\"Expected output\");\n\n    await auto.TypeAsync($\"aspire my-command {arg}\");\n    await auto.EnterAsync();\n    await auto.WaitUntilAsync(\n        snapshot => expectedOutput.Search(snapshot).Count > 0,\n        timeout ?? TimeSpan.FromSeconds(30),\n        description: \"waiting for expected output from my-command\");\n    await auto.WaitForSuccessPromptAsync(counter);\n}\n```\n\nKey points:\n1. Define as async extension method on `Hex1bTerminalAutomator`\n2. Accept `SequenceCounter` parameter for prompt tracking\n3. Use `CellPatternSearcher` for output detection\n4. Always include `description:` on `WaitUntilAsync` calls\n5. Call `WaitForSuccessPromptAsync(counter)` after command completion\n6. Return `Task` (no fluent chaining needed with async\u002Fawait)\n\n## CI Configuration\n\nEnvironment variables set in CI:\n- `GITHUB_PR_NUMBER`: PR number for downloading CLI artifacts\n- `GITHUB_PR_HEAD_SHA`: PR head commit SHA for version verification (not the merge commit)\n- `GH_TOKEN`: GitHub token for API access\n- `GITHUB_WORKSPACE`: Workspace root for artifact paths\n\nEach test class runs as a separate CI job via the unified `TestEnumerationRunsheetBuilder` infrastructure (using `SplitTestsOnCI=true`) for parallel execution.\n\n## CI Troubleshooting\n\nWhen CLI E2E tests fail in CI, follow these steps to diagnose the issue:\n\n> **Flaky test investigation:** for recurring\u002Fintermittent failures, see [`troubleshooting.md`](.\u002Ftroubleshooting.md) for a catalog of known flake classes (Y\u002Fn input race, prompt-counter desync, etc.) and the recipes to identify them from `.cast` recordings.\n\n### VS Code Extension E2E Diagnostics\n\nFor VS Code extension behavior or extension\u002FCLI integration issues, strongly prefer adding or\nupdating a reproducible test under `extension\u002Fsrc\u002Ftest-e2e\u002F`. Use agent-driven Playwright\u002FVS Code UI\ndriving only as exploratory diagnosis when the E2E scenario is not clear yet; convert any successful\nmanual reproduction into an E2E test before fixing the bug unless there is a strong, explicit reason\nnot to.\n\nWhen running extension E2E tests against an older published CLI for compatibility validation, set\n`ASPIRE_EXTENSION_E2E_SKIP_CURRENT_CLI_REGRESSIONS=true` to skip tests that intentionally cover bugs\nfixed only by the current repo-built CLI.\n\nVS Code extension E2E jobs upload shard-specific diagnostics as `extension-e2e-diagnostics-\u003Crid>-\u003Cshard>-attempt\u003CN>` artifacts. Linux shards include `.mp4` display recordings from Xvfb by default; Windows shards do not record video and instead rely on screenshots, VS Code logs, state files, and workspace diagnostics.\n\n```bash\n# List VS Code extension E2E diagnostic artifacts for a run.\ngh api \"repos\u002Fmicrosoft\u002Faspire\u002Factions\u002Fruns\u002F\u003Crun-id>\u002Fartifacts?per_page=100\" --paginate \\\n  --jq '.artifacts[] | select(.name | startswith(\"extension-e2e-diagnostics\")) | \"\\(.size_in_bytes)\\t\\(.name)\"'\n\n# Download one shard's diagnostics. The artifact contains .mp4 recordings\n# on Linux, .ffmpeg.log files, screenshots, VS Code logs, state files, and\n# captured workspace diagnostics.\nmkdir -p .\u002Fe2e-diagnostics && cd .\u002Fe2e-diagnostics\ngh run download \u003Crun-id> --repo microsoft\u002Faspire \\\n  -n extension-e2e-diagnostics-linux-x64-\u003Cshard>-attempt\u003CN> \\\n  -D \u003Cshard>\n```\n\nImportant paths inside the downloaded shard:\n\n```text\n\u003Cshard>\u002F.test-recordings\u002F\u003Cshard>\u002F\u003CrunId>.mp4\n\u003Cshard>\u002F.test-recordings\u002F\u003Cshard>\u002F\u003CrunId>.ffmpeg.log\n\u003Cshard>\u002F.test-storage\u002F**\u002Fscreenshots\u002F\n\u003Cshard>\u002F.test-results\u002Fe2e\u002F\u003Cshard>\u002Fextension-state.json\n```\n\nThe workflow keeps Linux recordings by default with `ASPIRE_EXTENSION_E2E_RECORDING_MODE=always`. Use `failure` to keep only failed-run videos or `off` to disable recording for local runs.\n\n### Quick Start: Download and Play Recordings\n\nThe fastest way to debug a CLI E2E test failure is to download and play the asciinema recording.\n\n**Using the helper scripts (recommended):**\n\n```bash\n# Linux\u002FmacOS - Download and play recording from latest CI run on current branch\n.\u002Feng\u002Fscripts\u002Fget-cli-e2e-recording.sh -p\n\n# List available test recordings\n.\u002Feng\u002Fscripts\u002Fget-cli-e2e-recording.sh -l\n\n# Download specific test\n.\u002Feng\u002Fscripts\u002Fget-cli-e2e-recording.sh -t SmokeTests -p\n\n# Download from specific run\n.\u002Feng\u002Fscripts\u002Fget-cli-e2e-recording.sh -r 20944531393 -p\n```\n\n```powershell\n# Windows PowerShell\n.\\eng\\scripts\\get-cli-e2e-recording.ps1 -Play\n\n# List available recordings\n.\\eng\\scripts\\get-cli-e2e-recording.ps1 -List\n\n# Download specific test\n.\\eng\\scripts\\get-cli-e2e-recording.ps1 -TestName SmokeTests -Play\n\n# Download from specific run\n.\\eng\\scripts\\get-cli-e2e-recording.ps1 -RunId 20944531393 -Play\n```\n\n**Manual download steps:**\n\n### Step 1: Find the CI Run\n\n```bash\n# List recent CI runs for your branch\ngh run list --branch $(git branch --show-current) --workflow CI --limit 5\n\n# Get the run ID from the output or use:\nRUN_ID=$(gh run list --branch $(git branch --show-current) --workflow CI --limit 1 --json databaseId --jq '.[0].databaseId')\necho \"Run ID: $RUN_ID\"\necho \"URL: https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Factions\u002Fruns\u002F$RUN_ID\"\n```\n\n### Step 2: Find CLI E2E Test Artifacts\n\nJob names follow the pattern: `Tests \u002F Cli E2E Linux (\u003CTestClass>) \u002F \u003CTestClass> (ubuntu-latest)`\n\nArtifact names follow the pattern: `logs-\u003CTestClass>-ubuntu-latest`\n\n```bash\n# Check if CLI E2E tests ran and their status\ngh run view $RUN_ID --json jobs --jq '.jobs[] | select(.name | test(\"Cli E2E\")) | {name, conclusion}'\n\n# List available CLI E2E artifacts\ngh api --paginate \"repos\u002Fmicrosoft\u002Faspire\u002Factions\u002Fruns\u002F$RUN_ID\u002Fartifacts\" \\\n  --jq '.artifacts[].name' | grep -i \"smoke\"\n```\n\n### Step 3: Download and Play Recording\n\n```bash\n# Download the artifact\nmkdir -p \u002Ftmp\u002Fcli-e2e-debug\ngh run download $RUN_ID -n logs-SmokeTests-ubuntu-latest -D \u002Ftmp\u002Fcli-e2e-debug\n\n# Find the recording\nfind \u002Ftmp\u002Fcli-e2e-debug -name \"*.cast\"\n\n# Play it (requires asciinema: pip install asciinema)\nasciinema play \u002Ftmp\u002Fcli-e2e-debug\u002Ftestresults\u002Frecordings\u002FCreateAndRunAspireStarterProject.cast\n\n# Or view raw content for AI analysis\nhead -100 \u002Ftmp\u002Fcli-e2e-debug\u002Ftestresults\u002Frecordings\u002FCreateAndRunAspireStarterProject.cast\n```\n\n### Artifact Contents\n\nDownloaded artifacts contain:\n\n```\ntestresults\u002F\n├── \u003CTestClass>_net10.0_*.trx          # Test results XML\n├── Aspire.Cli.EndToEnd.Tests_*.log     # Console output log\n├── *.crash.dmp                        # Crash dump (if test crashed)\n├── test.binlog                        # MSBuild binary log\n├── recordings\u002F\n│   ├── CreateAndRunAspireStarterProject.cast   # Asciinema recording\n│   └── ...\n└── workspaces\u002F                        # Captured project workspaces (on failure)\n    └── TestClassName.MethodName\u002F      # Full generated project for debugging\n        ├── apphost.ts\n        ├── aspire.config.json\n        ├── .aspire\u002Fmodules\u002F                  # Generated SDK - check aspire.js for exports\n        └── ...\n```\n\n### Workspace Capture\n\nTests annotated with `[CaptureWorkspaceOnFailure]` automatically copy the generated project workspace into the test artifacts when a test fails. This is invaluable for debugging template generation or `aspire run` failures — you can inspect the exact generated files including the SDK output in `.aspire\u002Fmodules\u002Faspire.js`.\n\nTo add workspace capture to a new test:\n```csharp\n[Fact]\n[CaptureWorkspaceOnFailure]\npublic async Task MyTemplateTest()\n{\n    var workspace = TemporaryWorkspace.Create(output);\n    \u002F\u002F ... test code — workspace is automatically registered for capture ...\n}\n```\n```\n\n### One-Liner: Download Latest Recording\n\n```bash\n# Download and play the latest CLI E2E recording from current branch\nRUN_ID=$(gh run list --branch $(git branch --show-current) --workflow CI --limit 1 --json databaseId --jq '.[0].databaseId') && \\\n  rm -rf \u002Ftmp\u002Fcli-e2e-debug && mkdir -p \u002Ftmp\u002Fcli-e2e-debug && \\\n  gh run download $RUN_ID -n logs-SmokeTests-ubuntu-latest -D \u002Ftmp\u002Fcli-e2e-debug && \\\n  CAST=$(find \u002Ftmp\u002Fcli-e2e-debug -name \"*.cast\" | head -1) && \\\n  echo \"Recording: $CAST\" && \\\n  asciinema play \"$CAST\"\n```\n\n### Common Issues and Solutions\n\n| Symptom | Likely Cause | Solution |\n|---------|--------------|----------|\n| Timeout waiting for prompt | Command failed or hung | Check recording to see terminal output at timeout |\n| `[N ERR:code] $ ` in prompt | Previous command exited with non-zero | Check recording to see which command failed |\n| Pattern not found | Output format changed | Update `CellPatternSearcher` patterns |\n| Pattern not found but text is visible | Using `FindPattern` with regex special chars | Use `Find()` instead of `FindPattern()` for literal strings containing `(`, `)`, `\u002F`, etc. |\n| Test hangs indefinitely | Waiting for wrong prompt number | Verify `SequenceCounter` usage matches commands |\n| Timeout waiting for dashboard URL | Project failed to build\u002Frun | Check recording for build errors |\n","# Aspire CLI End-to-End Testing with Hex1b\n\nThis skill provides patterns and practices for writing end-to-end tests for the Aspire CLI using the Hex1b terminal automation library.\n\n## Overview\n\nCLI E2E tests use the Hex1b library to automate terminal sessions, simulating real user interactions with the Aspire CLI. Tests run in CI with asciinema recordings for debugging.\n\n**Location**: `tests\u002FAspire.Cli.EndToEnd.Tests\u002F`\n\n**Supported Platforms**: Linux only. Hex1b requires a Linux terminal environment. Tests are configured to skip on Windows and macOS in CI.\n\n## Key Components\n\n### Core Classes\n\n- **`Hex1bTerminal`**: The main terminal class from the Hex1b library for terminal automation\n- **`Hex1bTerminalAutomator`**: Async\u002Fawait API for driving a `Hex1bTerminal` — the preferred approach for new tests\n- **`Hex1bAutomatorTestHelpers`** (shared helpers): Async extension methods on `Hex1bTerminalAutomator` (`WaitForSuccessPromptAsync`, `AspireNewAsync`, etc.)\n- **`CliE2EAutomatorHelpers`** (`Helpers\u002FCliE2EAutomatorHelpers.cs`): CLI-specific async extension methods on `Hex1bTerminalAutomator` (`PrepareDockerEnvironmentAsync`, `InstallAspireCliAsync`, etc.)\n- **`CellPatternSearcher`**: Pattern matching for terminal cell content\n- **`SequenceCounter`** (`Helpers\u002FSequenceCounter.cs`): Tracks command execution count for deterministic prompt detection\n- **`CliE2ETestHelpers`** (`Helpers\u002FCliE2ETestHelpers.cs`): Environment variable helpers and terminal factory methods\n- **`TemporaryWorkspace`**: Creates isolated temporary directories for test execution\n- **`Hex1bTerminalInputSequenceBuilder`** *(legacy)*: Fluent builder API for building sequences of terminal input\u002Foutput operations. Prefer `Hex1bTerminalAutomator` for new tests.\n\n### Test Architecture\n\nEach test:\n1. Creates a `TemporaryWorkspace` for isolation\n2. Builds a `Hex1bTerminal` with headless mode and asciinema recording\n3. Creates a `Hex1bTerminalAutomator` wrapping the terminal\n4. Drives the terminal with async\u002Fawait calls and awaits completion\n\n## Test Structure\n\n```csharp\npublic sealed class SmokeTests(ITestOutputHelper output)\n{\n    [Fact]\n    public async Task MyCliTest()\n    {\n        var repoRoot = CliE2ETestHelpers.GetRepoRoot();\n        var strategy = CliInstallStrategy.Detect(output.WriteLine);\n        var workspace = TemporaryWorkspace.Create(output);\n\n        using var terminal = CliE2ETestHelpers.CreateDockerTestTerminal(repoRoot, strategy, output, workspace: workspace);\n\n        var counter = new SequenceCounter();\n        var auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500));\n        await using var terminalRun = CliE2ETestHelpers.StartRun(terminal, workspace, auto, counter, output, TestContext.Current.CancellationToken);\n\n        await auto.PrepareDockerEnvironmentAsync(counter, workspace);\n        await auto.InstallAspireCliAsync(strategy, counter);\n\n        await auto.TypeAsync(\"aspire --version\");\n        await auto.EnterAsync();\n        await auto.WaitForSuccessPromptAsync(counter);\n    }\n}\n```\n\n### TerminalRun Pattern\n\n**Always use `CliE2ETestHelpers.StartRun`** to wrap the terminal run. This returns a `TerminalRun` (implements `IAsyncDisposable`) that automatically:\n1. Captures Aspire diagnostics via `CaptureAspireDiagnosticsAsync` (best effort)\n2. Types `exit` and presses Enter to close the terminal\n3. Awaits the pending run task\n\nThis eliminates the need for manual `exit`\u002F`await pendingRun` at the end of every test and ensures diagnostics are always captured, even when tests fail.\n\n```csharp\n\u002F\u002F DO: Use StartRun for consistent diagnostics capture and cleanup\nusing var terminal = CliE2ETestHelpers.CreateDockerTestTerminal(repoRoot, strategy, output, workspace: workspace);\n\nvar counter = new SequenceCounter();\nvar auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500));\nawait using var terminalRun = CliE2ETestHelpers.StartRun(terminal, workspace, auto, counter, output, TestContext.Current.CancellationToken);\n\n\u002F\u002F ... test body — no exit\u002FpendingRun needed at the end\n\n\u002F\u002F DON'T: Manually handle exit and pendingRun\nvar pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);\n\u002F\u002F ... test body ...\nawait auto.TypeAsync(\"exit\");\nawait auto.EnterAsync();\nawait pendingRun;\n```\n\n## Running Tests Locally\n\nCLI E2E tests run inside Docker containers on Linux. The workflow is: build a portable archive with `localhive`, then point the tests at it. This is the primary way to iterate on E2E tests during development.\n\n### Prerequisites\n\n- Docker Desktop running (with Linux containers)\n- .NET 10 SDK (installed via `.\u002Frestore.sh` or `.\\restore.cmd`)\n\n### Quick Start (macOS \u002F Linux)\n\n```bash\n# 1. Build a portable archive with CLI + packages + bundle\n#    Use linux-arm64 on Apple Silicon, linux-x64 on Intel\u002FLinux\n.\u002Flocalhive.sh -o \u002Ftmp\u002Faspire-e2e -r linux-arm64 --archive\n\n# 2. Run a specific test\nASPIRE_E2E_ARCHIVE=\u002Ftmp\u002Faspire-e2e.tar.gz \\\n  dotnet test tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-method \"*.CreateAndRunAspireStarterProject\"\n\n# 3. Run all tests in a class\nASPIRE_E2E_ARCHIVE=\u002Ftmp\u002Faspire-e2e.tar.gz \\\n  dotnet test tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-class \"*.SmokeTests\"\n```\n\n### Quick Start (Windows \u002F PowerShell)\n\n```powershell\n# 1. Build a portable archive (Docker Desktop uses linux-x64 via WSL2)\n.\\localhive.ps1 -o C:\\tmp\\aspire-e2e -r linux-x64 -Archive\n\n# 2. Run a specific test\n$env:ASPIRE_E2E_ARCHIVE = \"C:\\tmp\\aspire-e2e.tar.gz\"\ndotnet test tests\\Aspire.Cli.EndToEnd.Tests\\Aspire.Cli.EndToEnd.Tests.csproj `\n  -- --filter-method \"*.CreateAndRunAspireStarterProject\"\n\n# 3. Run all tests in a class\ndotnet test tests\\Aspire.Cli.EndToEnd.Tests\\Aspire.Cli.EndToEnd.Tests.csproj `\n  -- --filter-class \"*.SmokeTests\"\n```\n\n### Choosing the Right RID\n\nThe archive must match the Docker container's architecture:\n\n| Host | Docker Desktop | RID |\n|------|---------------|-----|\n| Apple Silicon Mac | Linux arm64 containers | `linux-arm64` |\n| Intel Mac | Linux x64 containers | `linux-x64` |\n| Windows (any) | WSL2 Linux x64 | `linux-x64` |\n| Linux x64 | Native | `linux-x64` |\n| Linux arm64 | Native | `linux-arm64` |\n\n### Development Workflow\n\nThe typical loop when writing or debugging E2E tests:\n\n```bash\n# 1. Make your code changes (CLI, hosting, templates, etc.)\n\n# 2. Rebuild the archive (picks up all changes — ~3 min)\n.\u002Flocalhive.sh -o \u002Ftmp\u002Faspire-e2e -r linux-arm64 --archive\n\n# 3. Run the specific test you're working on\nASPIRE_E2E_ARCHIVE=\u002Ftmp\u002Faspire-e2e.tar.gz \\\n  dotnet test tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-method \"*.YourTestName\"\n\n# 4. If it fails, check the asciinema recording\n#    Recordings are saved under the test output TestResults\u002Frecordings\u002F directory\n#    Play with: asciinema play \u002Fpath\u002Fto\u002FYourTestName.cast\n\n# 5. Fix and repeat from step 1 or 2\n```\n\n### Install Modes\n\nThe `CliInstallStrategy` class auto-detects how to install the CLI in the test container. You can override via environment variables:\n\n| Env Var | Mode | Example |\n|---------|------|---------|\n| `ASPIRE_E2E_ARCHIVE` | LocalHive — extract archive into container | `\u002Ftmp\u002Faspire-e2e.tar.gz` |\n| `ASPIRE_E2E_QUALITY` | Install script with quality | `dev`, `staging`, `release` |\n| `ASPIRE_E2E_VERSION` | Install script with version | `13.2.1` |\n| *(none, in CI)* | PullRequest — install from PR artifacts | Auto-detected |\n| *(none, locally)* | InstallScript (latest GA) | Auto-detected |\n\n**LocalHive** (via `ASPIRE_E2E_ARCHIVE`) is the recommended mode for local development — it uses your locally-built CLI, packages, and bundle so you test exactly what you've changed.\n\n### Testing Against Released Versions\n\nUseful for verifying tests pass against shipped versions or catching regressions:\n\n```bash\n# Test against latest GA release\nASPIRE_E2E_QUALITY=release dotnet test tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-method \"*.CreateAndRunAspireStarterProject\"\n\n# Test against daily builds\nASPIRE_E2E_QUALITY=dev dotnet test ...\n\n# Test against a specific version\nASPIRE_E2E_VERSION=13.2.1 dotnet test ...\n```\n\n### Emulated channel matrix tests (identity sidecar)\n\nA set of tests validates the **CLI identity sidecar** — the ability to make a locally built CLI\nemulate a different channel\u002Fversion via `ASPIRE_CLI_*` env vars. They form an AppHost-language ×\nchannel-emulation matrix (one test per language because C# and TypeScript scaffold through different\ncode paths and have diverged before):\n\n| Class | Channel emulated | `Aspire*` source | NuGet.config dropped? |\n|-------|------------------|------------------|------------------------|\n| `EmulatedReleasedBuildTests` | `stable` (latest shipped) | nuget.org | No (C# and TS) |\n| `EmulatedStagingBuildTests` | `staging` (latest darc build) | `darc-pub-...` feed | Yes — darc feed pin |\n| `EmulatedLocalReleaseBuildTests` | `stable` (**future, local-only**) | local hive via `ASPIRE_CLI_PACKAGES` | No (C# and TS) |\n\n`EmulatedLocalReleaseBuildTests` is the **all-local \"future release\"** row: it emulates a version\n(e.g. `13.5.0`) that exists only in a locally built hive, so a successful resolve proves the CLI\nconsulted `ASPIRE_CLI_PACKAGES` rather than nuget.org. Run it by building a **stable-shaped** archive\nwith `localhive --version`:\n\n```bash\n# 1. Build a stable-shaped archive (note: --version X.Y.Z, NOT a prerelease suffix)\n.\u002Flocalhive.sh --version 13.5.0 -o \u002Ftmp\u002Faspire-localrelease -r linux-arm64 --archive\n\n# 2. Run the all-local class\nASPIRE_E2E_ARCHIVE=\u002Ftmp\u002Faspire-localrelease.tar.gz \\\n  dotnet test --project tests\u002FAspire.Cli.EndToEnd.Tests\u002FAspire.Cli.EndToEnd.Tests.csproj \\\n  -- --filter-class \"*.EmulatedLocalReleaseBuildTests\"\n```\n\nThese tests **skip** unless the CLI was installed from a `LocalHive` archive *and* that archive is\nstable-shaped (no prerelease suffix). In default CI the archive is a prerelease `LocalArchive`, so they\nskip and add zero CI cost — CI relies on `--ignore-exit-code 8` (set in `eng\u002FTesting.targets`\n`MtpBaseArgs`) so an all-skipped class job still passes. The test also registers the hive as an\n**ambient** NuGet source (`dotnet nuget add source`) because MSBuild resolves the apphost's\n`Aspire.AppHost.Sdk` before restore from nuget.config sources only, ignoring `ASPIRE_CLI_PACKAGES`.\n\n> **⚠️ Local rebuilds: isolate the NuGet global cache.** This only affects **local** iteration of a\n> stable-shaped emulation (the E2E tests run in fresh Docker containers, so CI is immune). NuGet's\n> global packages folder (`~\u002F.nuget\u002Fpackages\u002F\u003Cid>\u002F\u003Cversion>\u002F`) caches **extracted** packages keyed by\n> version. When you emulate a *fixed* stable version (e.g. `13.5.0`) and **rebuild** it, a stale\n> `13.5.0` in that shared cache silently shadows the freshly built one — same version, different\n> content — so restore drifts (the stale AppHost SDK injects a prerelease floor and you get `NU1603`\n> warnings binding the graph to a stray `13.5.0-pr.…`). **Fix:** point `NUGET_PACKAGES` at a\n> per-emulation directory (`export NUGET_PACKAGES=\u002Ftmp\u002Faspire-localrelease\u002F.nuget-packages`).\n> `localhive … -o DIR`'s generated `activate.sh`\u002F`activate.ps1` already sets this up. See the cache\n> hazard note in `.agents\u002Fskills\u002Fcli-channel-debugging\u002FSKILL.md` (Scenario 7c) for the full mechanism.\n\n## SequenceCounter and Prompt Detection\n\nThe `SequenceCounter` class tracks the number of shell commands executed. This enables deterministic waiting for command completion via a custom shell prompt.\n\n### How It Works\n\n1. `PrepareDockerEnvironmentAsync()` configures the shell with a custom prompt: `[N OK] $ ` or `[N ERR:code] $ `\n2. Each command increments the counter\n3. `WaitForSuccessPromptAsync(counter)` waits for a prompt showing the current count with `OK`\n\n```csharp\nvar counter = new SequenceCounter();\nvar auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500));\n\nawait auto.PrepareDockerEnvironmentAsync(counter, workspace);  \u002F\u002F Sets up prompt, counter starts at 1\n\nawait auto.TypeAsync(\"echo hello\");\nawait auto.EnterAsync();\nawait auto.WaitForSuccessPromptAsync(counter);  \u002F\u002F Waits for \"[1 OK] $ \", then increments to 2\n\nawait auto.TypeAsync(\"ls -la\");\nawait auto.EnterAsync();\nawait auto.WaitForSuccessPromptAsync(counter);  \u002F\u002F Waits for \"[2 OK] $ \", then increments to 3\n\nawait auto.TypeAsync(\"exit\");\nawait auto.EnterAsync();\n```\n\nThis approach is more reliable than arbitrary timeouts because it deterministically waits for each command to complete.\n\n## Pattern Searching with CellPatternSearcher\n\nUse `CellPatternSearcher` to find text patterns in terminal output:\n\n```csharp\n\u002F\u002F Simple text search (literal string matching - PREFERRED)\nvar waitingForPrompt = new CellPatternSearcher()\n    .Find(\"Enter the project name\");\n\n\u002F\u002F Literal string with special characters (use Find, not FindPattern!)\nvar waitingForTemplate = new CellPatternSearcher()\n    .Find(\"> Starter App (FastAPI\u002FReact)\");  \u002F\u002F Parentheses and slashes are literal\n\n\u002F\u002F Regex pattern (only when you need wildcards\u002Fregex features)\nvar waitingForAnyStarter = new CellPatternSearcher()\n    .FindPattern(\"> Starter App.*\");  \u002F\u002F .* matches anything\n\n\u002F\u002F Chained patterns (find \"b\", then scan right until \"$\", then right of \" \")\nvar waitingForShell = new CellPatternSearcher()\n    .Find(\"b\").RightUntil(\"$\").Right(' ').Right(' ');\n\n\u002F\u002F Use in WaitUntilAsync\nawait auto.WaitUntilAsync(\n    snapshot => waitingForPrompt.Search(snapshot).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for prompt\");\n```\n\n### Find vs FindPattern\n\n- **`Find(string)`**: Literal string matching. Use this for most cases.\n- **`FindPattern(string)`**: Regex pattern matching. Use only when you need regex features like wildcards.\n\n**Important**: If your search string contains regex special characters like `(`, `)`, `\u002F`, `.`, `*`, `+`, `?`, `[`, `]`, `{`, `}`, `^`, `$`, `|`, or `\\`, use `Find()` instead of `FindPattern()` to avoid regex interpretation.\n\n## Extension Methods\n\n### Hex1bAutomatorTestHelpers Extensions (Shared — Automator API)\n\n| Method | Description |\n|--------|-------------|\n| `WaitForSuccessPromptAsync(counter, timeout?)` | Waits for `[N OK] $ ` prompt, fails immediately if error prompt appears, and increments counter |\n| `WaitForAnyPromptAsync(counter, timeout?)` | Waits for any prompt (`OK` or `ERR`) and increments counter |\n| `WaitForErrorPromptAsync(counter, timeout?)` | Waits for `[N ERR:code] $ ` prompt and increments counter |\n| `RunCommandAsync(command, counter, timeout?)` | Types a command, presses Enter, and waits for success prompt (fails fast on error) |\n| `DeclineAgentInitPromptAsync()` | Declines the `aspire agent init` prompt if it appears |\n| `AspireNewAsync(projectName, counter, template?, useRedisCache?)` | Runs `aspire new` interactively, handling template selection, project name, output path, URLs, Redis, and test project prompts |\n\nSee [AspireNew Helper](#aspirenew-helper) below for detailed usage.\n\n### CliE2EAutomatorHelpers Extensions on Hex1bTerminalAutomator\n\n| Method | Description |\n|--------|-------------|\n| `PrepareDockerEnvironmentAsync(counter, workspace)` | Sets up Docker container environment with custom prompt and command tracking |\n| `InstallAspireCliAsync(installMode, counter)` | Installs the Aspire CLI inside the Docker container |\n| `ClearScreenAsync(counter)` | Clears the terminal screen and waits for prompt |\n\n### SequenceCounterExtensions\n\n| Method | Description |\n|--------|-------------|\n| `IncrementSequence(counter)` | Manually increments the counter |\n\n### Legacy Builder Extensions\n\nThe following extensions on `Hex1bTerminalInputSequenceBuilder` are still available but should not be used in new tests:\n\n| Method | Description |\n|--------|-------------|\n| `WaitForSuccessPrompt(counter, timeout?)` | *(legacy)* Waits for `[N OK] $ ` prompt and increments counter |\n| `PrepareEnvironment(workspace, counter)` | *(legacy)* Sets up custom prompt with command tracking |\n| `SourceAspireBundleEnvironment(counter)` | *(legacy)* Sources bundle PATH environment variables |\n\n## DO: Use CellPatternSearcher for Output Detection\n\nWait for specific output patterns rather than arbitrary delays:\n\n```csharp\nvar waitingForMessage = new CellPatternSearcher()\n    .Find(\"Project created successfully.\");\n\nawait auto.TypeAsync(\"aspire new\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitingForMessage.Search(s).Count > 0,\n    TimeSpan.FromMinutes(2),\n    description: \"waiting for project created message\");\n```\n\n## DO: Use WaitForSuccessPromptAsync After Commands\n\nAfter running shell commands, use `WaitForSuccessPromptAsync()` to wait for the command to complete:\n\n```csharp\nawait auto.TypeAsync(\"dotnet build\");\nawait auto.EnterAsync();\nawait auto.WaitForSuccessPromptAsync(counter);  \u002F\u002F Waits for prompt, verifies success\n\nawait auto.TypeAsync(\"dotnet run\");\nawait auto.EnterAsync();\nawait auto.WaitForSuccessPromptAsync(counter);\n```\n\n## AspireNew Helper\n\nThe `AspireNew` extension method centralizes the multi-step `aspire new` interactive flow. Use it instead of manually building the prompt sequence.\n\n### AspireTemplate Enum\n\n| Value | Template | Arrow Keys |\n|-------|----------|------------|\n| `Starter` (default) | Starter App (Blazor) | None (first option) |\n| `JsReact` | Starter App (ASP.NET Core\u002FReact) | Down ×1 |\n| `PythonReact` | Starter App (FastAPI\u002FReact) | Down ×2 |\n| `ExpressReact` | Starter App (Express\u002FReact) | Down ×3 |\n| `EmptyAppHost` | Empty AppHost | Down ×4 |\n\n### Parameters\n\n| Parameter | Default | Description |\n|-----------|---------|-------------|\n| `projectName` | (required) | Project name typed at the prompt |\n| `counter` | (required) | `SequenceCounter` for prompt tracking |\n| `template` | `AspireTemplate.Starter` | Which template to select |\n| `useRedisCache` | `true` | Accept Redis (Enter) or decline (Down+Enter). Only applies to Starter, JsReact, PythonReact. |\n\n### Usage Examples\n\n```csharp\n\u002F\u002F Starter template with defaults (Redis=Yes, TestProject=No)\nawait auto.AspireNewAsync(\"MyProject\", counter);\n\n\u002F\u002F Starter template, no Redis\nawait auto.AspireNewAsync(\"MyProject\", counter, useRedisCache: false);\n\n\u002F\u002F JsReact template, no Redis\nawait auto.AspireNewAsync(\"MyProject\", counter, template: AspireTemplate.JsReact, useRedisCache: false);\n\n\u002F\u002F PythonReact template\nawait auto.AspireNewAsync(\"MyProject\", counter,\n    template: AspireTemplate.PythonReact,\n    useRedisCache: false);\n\n\u002F\u002F Empty app host\nawait auto.AspireNewAsync(\"MyProject\", counter, template: AspireTemplate.EmptyAppHost);\n```\n\n## DO: Handle Interactive Prompts\n\nFor `aspire new`, use the `AspireNewAsync` helper instead of manually building the prompt sequence:\n\n```csharp\n\u002F\u002F DO: Use the helper\nawait auto.AspireNewAsync(\"MyProject\", counter);\n\n\u002F\u002F DON'T: Manually build the sequence (this is what AspireNewAsync does internally)\nvar waitingForTemplatePrompt = new CellPatternSearcher()\n    .FindPattern(\"> Starter App\");\nvar waitingForProjectNamePrompt = new CellPatternSearcher()\n    .Find(\"Enter the project name\");\nawait auto.TypeAsync(\"aspire new\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitingForTemplatePrompt.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for template prompt\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitingForProjectNamePrompt.Search(s).Count > 0,\n    TimeSpan.FromSeconds(10),\n    description: \"waiting for project name prompt\");\nawait auto.TypeAsync(\"MyProject\");\nawait auto.EnterAsync();\n```\n\nFor other interactive CLI commands, wait for each prompt before responding:\n\n```csharp\nvar waitingForPrompt = new CellPatternSearcher()\n    .Find(\"Enter your choice\");\n\nawait auto.TypeAsync(\"aspire some-command\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitingForPrompt.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for choice prompt\");\nawait auto.EnterAsync();\n```\n\n## DO: Use Ctrl+C to Stop Long-Running Processes\n\nFor processes like `aspire run` that don't exit on their own:\n\n```csharp\nusing Hex1b.Input;\n\nawait auto.TypeAsync(\"aspire run\");\nawait auto.EnterAsync();\nawait auto.WaitUntilAsync(\n    s => waitForCtrlCMessage.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for Ctrl+C message\");\nawait auto.Ctrl().KeyAsync(Hex1bKey.C);  \u002F\u002F Send Ctrl+C\nawait auto.WaitForSuccessPromptAsync(counter);\n```\n\n## DO: Check IsRunningInCI for CI-Only Operations\n\nSome operations only apply in CI (like installing CLI from PR artifacts):\n\n```csharp\nvar installMode = CliInstallStrategy.Detect(output.WriteLine);\n\nawait auto.PrepareDockerEnvironmentAsync(counter, workspace);\nawait auto.InstallAspireCliAsync(installMode, counter);\n\n\u002F\u002F Continue with test commands...\n```\n\n## DO: Get Environment Variables Using Helpers\n\nUse `CliE2ETestHelpers` for CI environment variables:\n\n```csharp\nvar prNumber = CliE2ETestHelpers.GetRequiredPrNumber();   \u002F\u002F GITHUB_PR_NUMBER (0 when local)\nvar commitSha = CliE2ETestHelpers.GetRequiredCommitSha(); \u002F\u002F GITHUB_PR_HEAD_SHA (\"local0000\" when local)\nvar isCI = CliE2ETestHelpers.IsRunningInCI;               \u002F\u002F true when both env vars set\n```\n\n## DO: Always Include `description:` on WaitUntilAsync\n\nEvery `WaitUntilAsync` call requires a named `description:` parameter. This description appears in logs and asciinema recordings to make debugging easier when a wait times out.\n\n```csharp\n\u002F\u002F DON'T: Missing description\nawait auto.WaitUntilAsync(\n    s => pattern.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30));\n\n\u002F\u002F DO: Include a meaningful description\nawait auto.WaitUntilAsync(\n    s => pattern.Search(s).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for build output\");\n```\n\n## DO: Inline Code Where `ExecuteCallback` Was Used\n\nThe old builder API used `ExecuteCallback()` to run synchronous operations mid-sequence. With the automator API, simply inline the code directly — no special wrapper is needed.\n\n```csharp\n\u002F\u002F Old builder API (DON'T use in new tests)\nsequenceBuilder\n    .ExecuteCallback(() => File.WriteAllText(configPath, newConfig))\n    .Type(\"aspire run\")\n    .Enter();\n\n\u002F\u002F Automator API (DO)\nFile.WriteAllText(configPath, newConfig);\nawait auto.TypeAsync(\"aspire run\");\nawait auto.EnterAsync();\n```\n\n## DON'T: Use Hard-coded Delays\n\nUse `WaitUntilAsync()` with specific output patterns instead of arbitrary delays:\n\n```csharp\n\u002F\u002F DON'T: Arbitrary delays\nawait Task.Delay(TimeSpan.FromSeconds(30));\n\n\u002F\u002F DO: Wait for specific output\nawait auto.WaitUntilAsync(\n    snapshot => pattern.Search(snapshot).Count > 0,\n    TimeSpan.FromSeconds(30),\n    description: \"waiting for expected output\");\n```\n\n## DON'T: Hard-code Prompt Sequence Numbers\n\nDon't hard-code the sequence numbers in `WaitForSuccessPromptAsync` calls. Use the counter:\n\n```csharp\n\u002F\u002F DON'T: Hard-coded sequence numbers\nawait auto.WaitUntilAsync(\n    s => s.GetScreenText().Contains(\"[3 OK] $ \"),\n    timeout,\n    description: \"waiting for prompt\");\n\n\u002F\u002F DO: Use the counter\nawait auto.WaitForSuccessPromptAsync(counter);\n```\n\nThe counter automatically tracks which command you're waiting for, even if command sequences change.\n\n## Writing New Tests with Hex1b MCP Server\n\nWhen writing new CLI E2E tests, use the **Hex1b MCP server** to interactively explore what terminal output to expect. The MCP server provides tools to start terminal sessions, send commands, and capture screenshots—helping you discover the exact strings and prompts to use in `CellPatternSearcher`.\n\n### Workflow for Discovering Patterns\n\n1. **Start a bash terminal session** using the MCP server's terminal creation tools\n2. **Send commands** (like `aspire new` or `aspire run`) and observe the output\n3. **Capture terminal screenshots** (SVG or text) to see exact formatting\n4. **Use captured text** to build your `CellPatternSearcher` patterns\n\n### Example: Finding Prompt Text for `aspire new`\n\nAsk the MCP server to:\n1. Start a new bash terminal\n2. Run `aspire new` interactively\n3. Capture the terminal text at each prompt\n\nThis reveals the exact strings like:\n- `\"> Starter App\"` for template selection\n- `\"Enter the project name\"` for name input\n- `\"Press Ctrl+C to stop...\"` for run completion\n\n### Benefits\n\n- **See real output**: No guessing what text appears in the terminal\n- **Exact formatting**: Capture shows spacing, ANSI codes stripped, actual cell content\n- **Interactive exploration**: Try different inputs and see responses before writing test code\n- **Debug patterns**: If a `CellPatternSearcher` isn't matching, capture current terminal state to compare\n\n### Tips\n\n- Use `Capture Terminal Text` to get plain text for pattern matching\n- Use `Capture Terminal Screenshot` (SVG) for visual debugging\n- The `Wait for Terminal Text` tool works similarly to `WaitUntil` in tests\n- Terminal sessions persist, so you can step through multi-command sequences\n\n## Adding New Extension Methods\n\nWhen adding new CLI operations as extension methods, define them on `Hex1bTerminalAutomator`:\n\n```csharp\ninternal static async Task MyNewOperationAsync(\n    this Hex1bTerminalAutomator auto,\n    string arg,\n    SequenceCounter counter,\n    TimeSpan? timeout = null)\n{\n    var expectedOutput = new CellPatternSearcher()\n        .Find(\"Expected output\");\n\n    await auto.TypeAsync($\"aspire my-command {arg}\");\n    await auto.EnterAsync();\n    await auto.WaitUntilAsync(\n        snapshot => expectedOutput.Search(snapshot).Count > 0,\n        timeout ?? TimeSpan.FromSeconds(30),\n        description: \"waiting for expected output from my-command\");\n    await auto.WaitForSuccessPromptAsync(counter);\n}\n```\n\nKey points:\n1. Define as async extension method on `Hex1bTerminalAutomator`\n2. Accept `SequenceCounter` parameter for prompt tracking\n3. Use `CellPatternSearcher` for output detection\n4. Always include `description:` on `WaitUntilAsync` calls\n5. Call `WaitForSuccessPromptAsync(counter)` after command completion\n6. Return `Task` (no fluent chaining needed with async\u002Fawait)\n\n## CI Configuration\n\nEnvironment variables set in CI:\n- `GITHUB_PR_NUMBER`: PR number for downloading CLI artifacts\n- `GITHUB_PR_HEAD_SHA`: PR head commit SHA for version verification (not the merge commit)\n- `GH_TOKEN`: GitHub token for API access\n- `GITHUB_WORKSPACE`: Workspace root for artifact paths\n\nEach test class runs as a separate CI job via the unified `TestEnumerationRunsheetBuilder` infrastructure (using `SplitTestsOnCI=true`) for parallel execution.\n\n## CI Troubleshooting\n\nWhen CLI E2E tests fail in CI, follow these steps to diagnose the issue:\n\n> **Flaky test investigation:** for recurring\u002Fintermittent failures, see [`troubleshooting.md`](.\u002Ftroubleshooting.md) for a catalog of known flake classes (Y\u002Fn input race, prompt-counter desync, etc.) and the recipes to identify them from `.cast` recordings.\n\n### VS Code Extension E2E Diagnostics\n\nFor VS Code extension behavior or extension\u002FCLI integration issues, strongly prefer adding or\nupdating a reproducible test under `extension\u002Fsrc\u002Ftest-e2e\u002F`. Use agent-driven Playwright\u002FVS Code UI\ndriving only as exploratory diagnosis when the E2E scenario is not clear yet; convert any successful\nmanual reproduction into an E2E test before fixing the bug unless there is a strong, explicit reason\nnot to.\n\nWhen running extension E2E tests against an older published CLI for compatibility validation, set\n`ASPIRE_EXTENSION_E2E_SKIP_CURRENT_CLI_REGRESSIONS=true` to skip tests that intentionally cover bugs\nfixed only by the current repo-built CLI.\n\nVS Code extension E2E jobs upload shard-specific diagnostics as `extension-e2e-diagnostics-\u003Crid>-\u003Cshard>-attempt\u003CN>` artifacts. Linux shards include `.mp4` display recordings from Xvfb by default; Windows shards do not record video and instead rely on screenshots, VS Code logs, state files, and workspace diagnostics.\n\n```bash\n# List VS Code extension E2E diagnostic artifacts for a run.\ngh api \"repos\u002Fmicrosoft\u002Faspire\u002Factions\u002Fruns\u002F\u003Crun-id>\u002Fartifacts?per_page=100\" --paginate \\\n  --jq '.artifacts[] | select(.name | startswith(\"extension-e2e-diagnostics\")) | \"\\(.size_in_bytes)\\t\\(.name)\"'\n\n# Download one shard's diagnostics. The artifact contains .mp4 recordings\n# on Linux, .ffmpeg.log files, screenshots, VS Code logs, state files, and\n# captured workspace diagnostics.\nmkdir -p .\u002Fe2e-diagnostics && cd .\u002Fe2e-diagnostics\ngh run download \u003Crun-id> --repo microsoft\u002Faspire \\\n  -n extension-e2e-diagnostics-linux-x64-\u003Cshard>-attempt\u003CN> \\\n  -D \u003Cshard>\n```\n\nImportant paths inside the downloaded shard:\n\n```text\n\u003Cshard>\u002F.test-recordings\u002F\u003Cshard>\u002F\u003CrunId>.mp4\n\u003Cshard>\u002F.test-recordings\u002F\u003Cshard>\u002F\u003CrunId>.ffmpeg.log\n\u003Cshard>\u002F.test-storage\u002F**\u002Fscreenshots\u002F\n\u003Cshard>\u002F.test-results\u002Fe2e\u002F\u003Cshard>\u002Fextension-state.json\n```\n\nThe workflow keeps Linux recordings by default with `ASPIRE_EXTENSION_E2E_RECORDING_MODE=always`. Use `failure` to keep only failed-run videos or `off` to disable recording for local runs.\n\n### Quick Start: Download and Play Recordings\n\nThe fastest way to debug a CLI E2E test failure is to download and play the asciinema recording.\n\n**Using the helper scripts (recommended):**\n\n```bash\n# Linux\u002FmacOS - Download and play recording from latest CI run on current branch\n.\u002Feng\u002Fscripts\u002Fget-cli-e2e-recording.sh -p\n\n# List available test recordings\n.\u002Feng\u002Fscripts\u002Fget-cli-e2e-recording.sh -l\n\n# Download specific test\n.\u002Feng\u002Fscripts\u002Fget-cli-e2e-recording.sh -t SmokeTests -p\n\n# Download from specific run\n.\u002Feng\u002Fscripts\u002Fget-cli-e2e-recording.sh -r 20944531393 -p\n```\n\n```powershell\n# Windows PowerShell\n.\\eng\\scripts\\get-cli-e2e-recording.ps1 -Play\n\n# List available recordings\n.\\eng\\scripts\\get-cli-e2e-recording.ps1 -List\n\n# Download specific test\n.\\eng\\scripts\\get-cli-e2e-recording.ps1 -TestName SmokeTests -Play\n\n# Download from specific run\n.\\eng\\scripts\\get-cli-e2e-recording.ps1 -RunId 20944531393 -Play\n```\n\n**Manual download steps:**\n\n### Step 1: Find the CI Run\n\n```bash\n# List recent CI runs for your branch\ngh run list --branch $(git branch --show-current) --workflow CI --limit 5\n\n# Get the run ID from the output or use:\nRUN_ID=$(gh run list --branch $(git branch --show-current) --workflow CI --limit 1 --json databaseId --jq '.[0].databaseId')\necho \"Run ID: $RUN_ID\"\necho \"URL: https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Factions\u002Fruns\u002F$RUN_ID\"\n```\n\n### Step 2: Find CLI E2E Test Artifacts\n\nJob names follow the pattern: `Tests \u002F Cli E2E Linux (\u003CTestClass>) \u002F \u003CTestClass> (ubuntu-latest)`\n\nArtifact names follow the pattern: `logs-\u003CTestClass>-ubuntu-latest`\n\n```bash\n# Check if CLI E2E tests ran and their status\ngh run view $RUN_ID --json jobs --jq '.jobs[] | select(.name | test(\"Cli E2E\")) | {name, conclusion}'\n\n# List available CLI E2E artifacts\ngh api --paginate \"repos\u002Fmicrosoft\u002Faspire\u002Factions\u002Fruns\u002F$RUN_ID\u002Fartifacts\" \\\n  --jq '.artifacts[].name' | grep -i \"smoke\"\n```\n\n### Step 3: Download and Play Recording\n\n```bash\n# Download the artifact\nmkdir -p \u002Ftmp\u002Fcli-e2e-debug\ngh run download $RUN_ID -n logs-SmokeTests-ubuntu-latest -D \u002Ftmp\u002Fcli-e2e-debug\n\n# Find the recording\nfind \u002Ftmp\u002Fcli-e2e-debug -name \"*.cast\"\n\n# Play it (requires asciinema: pip install asciinema)\nasciinema play \u002Ftmp\u002Fcli-e2e-debug\u002Ftestresults\u002Frecordings\u002FCreateAndRunAspireStarterProject.cast\n\n# Or view raw content for AI analysis\nhead -100 \u002Ftmp\u002Fcli-e2e-debug\u002Ftestresults\u002Frecordings\u002FCreateAndRunAspireStarterProject.cast\n```\n\n### Artifact Contents\n\nDownloaded artifacts contain:\n\n```\ntestresults\u002F\n├── \u003CTestClass>_net10.0_*.trx          # Test results XML\n├── Aspire.Cli.EndToEnd.Tests_*.log     # Console output log\n├── *.crash.dmp                        # Crash dump (if test crashed)\n├── test.binlog                        # MSBuild binary log\n├── recordings\u002F\n│   ├── CreateAndRunAspireStarterProject.cast   # Asciinema recording\n│   └── ...\n└── workspaces\u002F                        # Captured project workspaces (on failure)\n    └── TestClassName.MethodName\u002F      # Full generated project for debugging\n        ├── apphost.ts\n        ├── aspire.config.json\n        ├── .aspire\u002Fmodules\u002F                  # Generated SDK - check aspire.js for exports\n        └── ...\n```\n\n### Workspace Capture\n\nTests annotated with `[CaptureWorkspaceOnFailure]` automatically copy the generated project workspace into the test artifacts when a test fails. This is invaluable for debugging template generation or `aspire run` failures — you can inspect the exact generated files including the SDK output in `.aspire\u002Fmodules\u002Faspire.js`.\n\nTo add workspace capture to a new test:\n```csharp\n[Fact]\n[CaptureWorkspaceOnFailure]\npublic async Task MyTemplateTest()\n{\n    var workspace = TemporaryWorkspace.Create(output);\n    \u002F\u002F ... test code — workspace is automatically registered for capture ...\n}\n```\n```\n\n### One-Liner: Download Latest Recording\n\n```bash\n# Download and play the latest CLI E2E recording from current branch\nRUN_ID=$(gh run list --branch $(git branch --show-current) --workflow CI --limit 1 --json databaseId --jq '.[0].databaseId') && \\\n  rm -rf \u002Ftmp\u002Fcli-e2e-debug && mkdir -p \u002Ftmp\u002Fcli-e2e-debug && \\\n  gh run download $RUN_ID -n logs-SmokeTests-ubuntu-latest -D \u002Ftmp\u002Fcli-e2e-debug && \\\n  CAST=$(find \u002Ftmp\u002Fcli-e2e-debug -name \"*.cast\" | head -1) && \\\n  echo \"Recording: $CAST\" && \\\n  asciinema play \"$CAST\"\n```\n\n### Common Issues and Solutions\n\n| Symptom | Likely Cause | Solution |\n|---------|--------------|----------|\n| Timeout waiting for prompt | Command failed or hung | Check recording to see terminal output at timeout |\n| `[N ERR:code] $ ` in prompt | Previous command exited with non-zero | Check recording to see which command failed |\n| Pattern not found | Output format changed | Update `CellPatternSearcher` patterns |\n| Pattern not found but text is visible | Using `FindPattern` with regex special chars | Use `Find()` instead of `FindPattern()` for literal strings containing `(`, `)`, `\u002F`, etc. |\n| Test hangs indefinitely | Waiting for wrong prompt number | Verify `SequenceCounter` usage matches commands |\n| Timeout waiting for dashboard URL | Project failed to build\u002Frun | Check recording for build errors |\n",{"name":5,"description":7},"main","cec61ac9b795bbfd9913f0c7196689b0d7a215d7",".agents\u002Fskills\u002Fcli-e2e-testing",1039,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire","https:\u002F\u002Faspire.dev","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-15 00:32:23",{"source":8,"skillName":5,"commands":49,"prompt":59,"zipAvailable":60},[50,53,56],{"tool":51,"command":52},"npx","npx skills add microsoft\u002Faspire --skill cli-e2e-testing",{"tool":54,"command":55},"bunx","bunx skills add microsoft\u002Faspire --skill cli-e2e-testing",{"tool":57,"command":58},"pnpm","pnpm dlx skills add microsoft\u002Faspire --skill cli-e2e-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcli-e2e-testing\u002FSKILL.md",true,[62],{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"troubleshooting.md","REFERENCE","参考文档",9607,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcli-e2e-testing\u002Ftroubleshooting.md",[69,89,111,122,140,166],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":33},"01M6FKZQPMA7VRA0PRBZRDFJTX","vscode-extension","Use when investigating, developing, debugging, testing, or reviewing Aspire VS Code extension behavior under extension\u002F, including extension UI, command, debugger, RPC, DCP, MCP, and CLI-integration issues or features.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fvscode-extension\u002FSKILL.md",[],[76,77,78,19,79,20,26,27,80,81,82,83,84,85,86,87,29,88,32],"vscode","vscode extension","extension","MCP","code","issues","rpc","ui","integration","debugger","command","behavior","features",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":33},"01M6FKZJG81XP80SVWFBJVMDWN","update-container-images","Updates Docker container image tags used by Aspire hosting integrations. Queries registries for newer tags, uses LLM to determine version-compatible updates, and applies changes. Use this when asked to update container image versions.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fupdate-container-images\u002FSKILL.md",[],[96,97,98,99,100,101,102,26,103,29,104,105,106,107,108,109,110,32],"container images","update","container","images","update container images","image","docker","integrations","version","hosting","queries","tags","updates","for","changes",{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":33},"01M6FKZDY1MY0QA62EYSDG5NHW","test-management","Quarantines or disables flaky\u002Fproblematic tests using the QuarantineTools utility","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftest-management\u002FSKILL.md",[],[118,119,120,30,121],"test","management","test management","utility",{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":33},"01M6FKZAQ428JX8F6NSA19XBQJ","startup-perf","Measures Aspire startup profiling with CLI self-profile capture and dashboard export traces.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fstartup-perf\u002FSKILL.md",[],[129,130,131,20,132,26,133,134,135,136,137,138,139],"perf","startup","startup perf","dashboard","profiling","capture","profile","export","self","with","traces",{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":33},"01M6FKZ4W4J0ET0Q0C2Z30HYRV","reviewing-aspire-architecture","Use only when the user explicitly requests a deep Aspire architectural or pattern review of an existing PR or diff, or when a generic reviewer escalates a named Aspire-domain question it cannot resolve. Do not use for ordinary review, implementation, debugging, explanation, or design discussion—even when a PR is referenced—and never select it from changed file paths alone.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Freviewing-aspire-architecture\u002FSKILL.md",[],[147,26,148,149,150,151,27,152,153,154,155,29,156,157,158,159,160,161,162,163,109,164,165,32],"architecture","reviewing aspire architecture","design","review","pr","file","select","reviewer","question","diff","never","only","do","domain","pattern","deep","paths","Existing","generic",{"skillNo":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":33},"01M6FKYZ44BEPJNV8VQ0X73CZR","pr-testing","Use when asked to test a microsoft\u002Faspire pull request, including CLI, hosting, dashboard, component, template, and VS Code extension changes. Also covers testing PRs that change CI infrastructure — GitHub Actions (workflows, actions, gh-aw agentic workflows, CI scripts under .github\u002F and eng\u002F) and Azure DevOps pipelines (eng\u002Fpipelines, eng\u002Fcommon).","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Faspire\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpr-testing\u002FSKILL.md",[],[19,151,173,20,174,175,132,176,177,178,179,180,26,181,80,182,183,184,185,186,29,187,105,188,78,189,110,190],"pr testing","github","agentic","workflows","change","component","agentic workflows","azure devops","infrastructure","actions","ci","github actions","template","common","devops","pipelines","scripts","prs"]