Aion-Instruct-Preview-Sample
Copilot instructions27 starsChanged 6 months agoMITView on GitHub
You are working in the consumer sample for the Aion Instruct Preview SDK: an on-device language model that runs locally on the Copilot+ PC NPU — QNN on Snapdragon (ARM64). x64 (Intel/AMD, OpenVINO) support is coming soon. A certified NPU EP is required (no CPU fallback, no cloud calls). This repo shows a third-party developer how to (1) consume the SDK's framework package, (2) wire it into their own app, and (3) build + run a working chat app. Use…
The file
We split this copilot-instructions.md into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 146
The framework MSIX is GitHub-release-only — by design: Do not add it to a NuGet/public feed or suggest distributing it.
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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
Copilot instructions — Aion Instruct Preview Chat sample
You are working in the consumer sample for the Aion Instruct Preview SDK: an on-device
language model that runs locally on the Copilot+ PC NPU — QNN on Snapdragon (ARM64). x64 (Intel/AMD,
OpenVINO) support is coming soon. A certified NPU EP is required (no CPU fallback, no cloud calls).
This repo shows a
third-party developer how to (1) consume the SDK's framework package, (2) wire it into their own
app, and (3) build + run a working chat app. Use this file to orient fast; the
README.md has the deep dives and is the source of truth — cross-references below
point at its sections.
What this repo contains
Three consumption patterns of the same SDK, so a developer can copy whichever matches their app:
| Path | Project | Identity model | Framework dependency taken |
| Packaged WinUI 3 (canonical) | AionInstructPreview.Chat.csproj (repo root) | MSIX package identity | Build-time: SDK targets inject a <PackageDependency> into Package.appxmanifest |
| Unpackaged console | unpackaged-console/AionInstructPreview.Chat.Console.csproj | none (plain exe) | Runtime: FrameworkDependency.cs via TryCreatePackageDependency / AddPackageDependency |
| Unpackaged WPF | unpackaged-wpf/AionInstructPreview.Chat.Wpf.csproj | none (plain exe) | Runtime: same dynamic-dependency pattern as console |
The root WinUI app is the one most consumers should copy. The unpackaged variants exist for apps that can't adopt MSIX identity; they take the same framework dependency at runtime instead of via a manifest.
The mental model (read this before changing build wiring)
There are two distinct things with similar names; never conflate them:
- The SDK NuGet —
AionInstructPreview.Text.Framework(aPackageReference). This is build-time only. Its build hooks:AionInstructPreview.Text.Framework.propsaddsAionInstructPreview.Text.winmdto$(CsWinRTInputs)so CsWinRT projects the WinRT runtimeclasses into C# types you can call.AionInstructPreview.Text.Framework.targetsinjects the runtime<PackageDependency>into a packaged app'sAppxManifest(no-ops for unpackaged apps, which have no manifest).
- The framework MSIX —
Microsoft.AionInstructPreview.Framework.1.0(installed system-wide). This is the runtime that actually holdsAionInstructPreview.Text.dll,muffinapi.dll, and the ONNX model files. It is not on any public feed — it ships only as a GitHub release asset of this repo (by design; this is a developer preview).Bootstrap.ps1downloads and installs it.
A build error almost never means a runtime component is missing, and vice-versa. See README → Prerequisites.
Build & run the sample
Prereqs: .NET 9 SDK + Developer Mode on. That's it — no Visual Studio and no registry-installed Windows SDK are required; everything else (Windows App SDK, CsWinRT, SDK build tools, the Windows metadata ref pack, MSIX loose-layout tooling) is restored from NuGet.
One-shot quickstart (downloads + installs the framework MSIX from this repo's GitHub release via
gh, drops the SDK NuGet into ./nuget-local/, then builds and launches):
./Bootstrap.ps1Manual build + run (packaged WinUI app). This preview targets ARM64 Snapdragon Copilot+ PCs
(NPU via QNN) — build with -p:Platform=ARM64. x64 (Intel/AMD) support is coming soon. The csproj
defaults $(Platform) to the box's native arch, so a bare dotnet build on an ARM64 box already
does the right thing.
dotnet run --project AionInstructPreview.Chat.csproj --launch-profile "AionInstructPreview.Chat" -c Release -p:Platform=ARM64 # Snapdragon (QNN NPU)dotnet run registers the build output as a loose-layout development package (this is what
gives the app the package identity it needs for cross-package WinRT activation) and launches it —
no signing cert, no separate Add-AppxPackage. Developer Mode is required for that registration.
Unpackaged variants: cd unpackaged-console (or unpackaged-wpf) then ./Run.ps1 — it checks
the framework package is installed, builds, and runs. These have no MSIX identity and pull the
framework dependency at runtime.
Visual Studio: the F5 path is supported on Visual Studio 2026 (18.x) only, with the
(MSIX) launch profile (never the Project profile — that runs the bare exe without identity and
crashes with REGDB_E_CLASSNOTREG). VS 2022 (17.x) cannot F5 this Windows App SDK 2.0 app. Select the
Solution Platform set to ARM64 — a non-ARM64 platform makes F5 report
"The project needs to be deployed. Please enable Deploy in the Configuration Manager" even though
Deploy is enabled. Exact required VS 2026 components are in
README → Visual Studio 2026 setup.
Consume the SDK in your OWN app
Minimum wiring to call the model from a new project (full guide: README → Use Aion Instruct Preview in your own app):
- Feed: copy this repo's
nuget.config— it adds./nuget-local/where the SDK.nupkglives until a public feed exists. DropAionInstructPreview.Text.Framework.<version>.nupkgthere. - PackageReferences (CsWinRT is mandatory and must be referenced directly — picking it up
transitively does NOT import its source-generator targets, and you'll get a wall of
CS0246 LanguageModel not found):
A packaged app additionally needs<PackageReference Include="AionInstructPreview.Text.Framework" Version="1.0.*" /> <PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.5" />Microsoft.WindowsAppSDK,Microsoft.Windows.SDK.BuildTools, and (fordotnet runwithout VS)Microsoft.Windows.SDK.BuildTools.WinApp— see the rootAionInstructPreview.Chat.csprojfor the exact set and the comments explaining each. - Identity:
- Packaged: nothing extra — the SDK
.targetsinject the framework<PackageDependency>into yourAppxManifestautomatically at build. - Unpackaged: copy
unpackaged-console/FrameworkDependency.csand callFrameworkDependency.EnsureLoaded()once at startup, before the firstLanguageModel.CreateAsync().
- Packaged: nothing extra — the SDK
- Runtime, on the end-user machine: the framework MSIX installed (GitHub release), WindowsAppRuntime 2, and the .NET 9 desktop runtime.
The API (what the SDK actually exposes)
Namespace AionInstructPreview.Text. Canonical usage lives in
AionInstructClient.cs. Shape:
using AionInstructPreview.Text;
LanguageModel model = await LanguageModel.CreateAsync(); // first launch: ~3-5 min NPU compile; warm ~30s
LanguageModelContext ctx = model.CreateContext(); // carries multi-turn history
var op = model.GenerateResponseAsync(ctx, prompt);
op.Progress = (_, token) => { /* streamed token delta — marshal to UI thread yourself */ };
LanguageModelResponseResult result = await op;- First
CreateAsync()per process is slow (~4-5 min cold while QNN compiles the QDQ ONNX to the NPU; ~30s warm from cache). Keep loading UI up; never assume it's hung. - Multi-turn is automatic via the
LanguageModelContext— reuse it; callCreateContext()again to start a fresh conversation. Progresscallbacks fire on a WinRT-chosen thread — the caller marshals back to the UI thread.- Dispose
LanguageModelContextthenLanguageModel(IClosableprojects toIDisposable).
API reference: README → API surface used.
Hard rules / gotchas (do not violate)
- This preview targets ARM64 Snapdragon (QNN NPU) only. Build with
-p:Platform=ARM64. x64 (Intel/AMD, OpenVINO) support is coming soon. The csproj defaults$(Platform)to the box's native arch — don't break that logic. - Never build under
C:\Windows\System32(the default dir of an elevated prompt). UAC file virtualization corrupts CsWinRT / XAML codegen (cswinrt.exe exited with code 1). Build non-elevated from your user profile. - CsWinRT must be a direct
PackageReference(see above). - For VS F5 pick the
(MSIX)profile, notProject. TheProjectprofile →REGDB_E_CLASSNOTREG. - The framework MSIX is GitHub-release-only — by design. Do not add it to a NuGet/public feed or suggest distributing it; it's a developer preview, not for redistribution.
- Don't add MSIX signing/
.pfx/packaging knobs to the sample. The dev loop isdotnet run(loose-layout dev registration); a signing cert is intentionally not used. - Stay on a feature branch for changes; open PRs against the repo's default branch.
Where to look
README.md— authoritative; prereqs, quickstart, per-pattern integration, troubleshooting, API reference, project layout.AionInstructPreview.Chat.csproj— heavily commented; explains every non-obvious build property.AionInstructClient.cs— the clean API-usage example.unpackaged-console/FrameworkDependency.cs— the runtime framework-dependency pattern for unpackaged apps.Bootstrap.ps1— end-to-end setup; mirrors the manual steps in the README.TRANSPARENCY_NOTES.md— model capabilities, limitations, responsible-AI guidance.
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.

