winmd-api-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWinMD API Search
WinMD API搜索
This skill helps you find the right Windows API for any capability and get its full details. It searches a local cache of all WinMD metadata from:
- Windows Platform SDK — all WinRT APIs (always available, no restore needed)
Windows.* - WinAppSDK / WinUI — bundled as a baseline in the cache generator (always available, no restore needed)
- NuGet packages — any additional packages in restored projects that contain files
.winmd - Project-output WinMD — class libraries (C++/WinRT, C#) that produce as build output
.winmd
Even on a fresh clone with no restore or build, you still get full Platform SDK + WinAppSDK coverage.
这个技能可以帮助你为任意功能找到合适的Windows API并获取其完整详情。它会搜索所有WinMD元数据的本地缓存,这些元数据来自:
- Windows Platform SDK — 所有WinRT API(始终可用,无需还原)
Windows.* - WinAppSDK / WinUI — 作为基线捆绑在缓存生成器中(始终可用,无需还原)
- NuGet packages — 已还原项目中所有包含文件的额外依赖包
.winmd - Project-output WinMD — 生成作为构建输出的类库(C++/WinRT、C#)
.winmd
即使是刚克隆、没有执行过还原或构建的项目,你也能获得完整的Platform SDK + WinAppSDK覆盖。
When to Use This Skill
何时使用这个技能
- User wants to build a feature and you need to find which API provides that capability
- User asks "how do I do X?" where X involves a platform feature (camera, files, notifications, sensors, AI, etc.)
- You need the exact methods, properties, events, or enumeration values of a type before writing code
- You're unsure which control, class, or interface to use for a UI or system task
- 用户想要构建某个功能,你需要找到哪个API提供了对应的能力
- 用户询问「我如何实现X?」,其中X涉及平台功能(相机、文件、通知、传感器、AI等)
- 你需要在编写代码前获取某个类型的精确方法、属性、事件或枚举值
- 你不确定应该为UI或系统任务使用哪个控件、类或接口
Prerequisites
前置要求
- .NET SDK 8.0 or later — required to build the cache generator. Install from dotnet.microsoft.com if not available.
- .NET SDK 8.0 或更高版本 — 构建缓存生成器的必要条件。如果未安装,可以从dotnet.microsoft.com下载安装。
Cache Setup (Required Before First Use)
缓存设置(首次使用前必须配置)
All query and search commands read from a local JSON cache. You must generate the cache before running any queries.
powershell
undefined所有查询和搜索命令都从本地JSON缓存读取数据。运行任何查询前你必须先生成缓存。
powershell
undefinedAll projects in the repo (recommended for first run)
仓库内所有项目(首次运行推荐)
..github\skills\winmd-api-search\scripts\Update-WinMdCache.ps1
..github\skills\winmd-api-search\scripts\Update-WinMdCache.ps1
Single project
单个项目
..github\skills\winmd-api-search\scripts\Update-WinMdCache.ps1 -ProjectDir <project-folder>
No project restore or build is needed for baseline coverage (Platform SDK + WinAppSDK). For additional NuGet packages, the project needs `dotnet restore` (which generates `project.assets.json`) or a `packages.config` file.
Cache is stored at `Generated Files\winmd-cache\`, deduplicated per-package+version...github\skills\winmd-api-search\scripts\Update-WinMdCache.ps1 -ProjectDir <project-folder>
基线覆盖(Platform SDK + WinAppSDK)不需要项目还原或构建。如果需要包含额外的NuGet包,项目需要执行`dotnet restore`(会生成`project.assets.json`)或者有`packages.config`文件。
缓存存储在`Generated Files\winmd-cache\`下,按包+版本去重。What gets indexed
索引内容
| Source | When available |
|---|---|
| Windows Platform SDK | Always (reads from local SDK install) |
| WinAppSDK (latest) | Always (bundled as baseline in cache generator) |
| WinAppSDK Runtime | When installed on the system (detected via |
| Project NuGet packages | After |
Project-output | After project build (class libraries that produce WinMD) |
Note: This cache directory should be in— it's generated, not source..gitignore
| 来源 | 可用条件 |
|---|---|
| Windows Platform SDK | 始终可用(从本地SDK安装路径读取) |
| WinAppSDK(最新版) | 始终可用(作为基线捆绑在缓存生成器中) |
| WinAppSDK Runtime | 系统已安装时(通过 |
| 项目NuGet包 | 执行 |
项目输出 | 项目构建后(生成WinMD的类库) |
注意: 该缓存目录应该加入— 它是生成的文件,不属于源码。.gitignore
How to Use
使用方法
Pick the path that matches the situation:
选择符合场景的路径:
Discover — "I don't know which API to use"
探索 —「我不知道该用哪个API」
The user describes a capability in their own words. You need to find the right API.
0. Ensure the cache exists
If the cache hasn't been generated yet, run first — see Cache Setup above.
Update-WinMdCache.ps11. Translate user language → search keywords
Map the user's daily language to programming terms. Try multiple variations:
| User says | Search keywords to try (in order) |
|---|---|
| "take a picture" | |
| "load from disk" | |
| "describe what's in it" | |
| "show a popup" | |
| "drag and drop" | |
| "save settings" | |
Start with simple everyday words. If results are weak or irrelevant, try the more technical variation.
2. Run searches
powershell
.\.github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action search -Query "<keyword>"This returns ranked namespaces with top matching types and the JSON file path.
If results have low scores (below 60) or are irrelevant, fall back to searching online documentation:
- Use web search to find the right API on Microsoft Learn, for example:
- for
site:learn.microsoft.com/uwp/api <capability keywords>APIsWindows.* - for
site:learn.microsoft.com/windows/windows-app-sdk/api/winrt <capability keywords>WinAppSDK APIsMicrosoft.*
- Read the documentation pages to identify which type matches the user's requirement.
- Once you know the type name, come back and use or
-Action membersto get the exact local signatures.-Action enums
3. Read the JSON to choose the right API
Read the file at the path(s) from the top results. The JSON has all types in that namespace — full members, signatures, parameters, return types, enumeration values.
Read and decide which types and members fit the user's requirement.
4. Look up official documentation for context
The cache contains only signatures — no descriptions or usage guidance. For explanations, examples, and remarks, look up the type on Microsoft Learn:
| Namespace prefix | Documentation base URL |
|---|---|
| |
| |
For example, maps to:
Microsoft.UI.Xaml.Controls.NavigationViewhttps://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.navigationview5. Use the API knowledge to answer or write code
用户用自己的话描述所需的能力,你需要找到合适的API。
0. 确认缓存已存在
如果还没生成缓存,先运行 — 参考上文缓存设置。
Update-WinMdCache.ps11. 将用户语言转换为搜索关键词
将用户的日常语言映射为编程术语,尝试多种变体:
| 用户表述 | 可尝试的搜索关键词(按顺序) |
|---|---|
| "拍照" | |
| "从磁盘加载" | |
| "描述里面的内容" | |
| "显示弹窗" | |
| "拖拽" | |
| "保存设置" | |
先从简单的日常用词开始,如果结果得分低或不相关,再尝试更专业的变体。
2. 执行搜索
powershell
.\.github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action search -Query "<keyword>"这会返回排序后的命名空间,包含匹配度最高的类型以及JSON文件路径。
如果结果得分低(低于60)或不相关,可以回退到在线文档搜索:
- 使用网页搜索在Microsoft Learn上找到合适的API,例如:
- 用于查找
site:learn.microsoft.com/uwp/api <capability keywords>APIsWindows.* - 用于查找
site:learn.microsoft.com/windows/windows-app-sdk/api/winrt <capability keywords>WinAppSDK APIsMicrosoft.*
- 阅读文档页面,找到符合用户需求的类型。
- 知道类型名称后,回到这里使用或
-Action members获取精确的本地签名。-Action enums
3. 读取JSON选择合适的API
读取顶部结果中路径对应的文件,JSON包含该命名空间下的所有类型 — 完整的成员、签名、参数、返回类型、枚举值。
阅读并判断哪些类型和成员符合用户需求。
4. 查阅官方文档获取上下文
缓存仅包含签名 — 没有描述或使用指引。如需解释、示例和备注,可以在Microsoft Learn上查找对应类型:
| 命名空间前缀 | 文档基础URL |
|---|---|
| |
| |
例如,对应的URL是:
Microsoft.UI.Xaml.Controls.NavigationViewhttps://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.navigationview5. 利用API知识回答问题或编写代码
Lookup — "I know the API, show me the details"
查找 —「我知道这个API,给我看详情」
You already know (or suspect) the type or namespace name. Go direct:
powershell
undefined你已经知道(或猜测)类型或命名空间名称,可以直接查询:
powershell
undefinedGet all members of a known type
获取已知类型的所有成员
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action members -TypeName "Microsoft.UI.Xaml.Controls.NavigationView"
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action members -TypeName "Microsoft.UI.Xaml.Controls.NavigationView"
Get enum values
获取枚举值
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action enums -TypeName "Microsoft.UI.Xaml.Visibility"
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action enums -TypeName "Microsoft.UI.Xaml.Visibility"
List all types in a namespace
列出命名空间下的所有类型
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action types -Namespace "Microsoft.UI.Xaml.Controls"
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action types -Namespace "Microsoft.UI.Xaml.Controls"
Browse namespaces
浏览命名空间
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action namespaces -Filter "Microsoft.UI"
If you need full detail beyond what `-Action members` shows, use `-Action search` to get the JSON file path, then read the JSON file directly.
---..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action namespaces -Filter "Microsoft.UI"
如果需要比`-Action members`显示的更完整的详情,可以使用`-Action search`获取JSON文件路径,然后直接读取JSON文件。
---Other Commands
其他命令
powershell
undefinedpowershell
undefinedList cached projects
列出已缓存的项目
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action projects
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action projects
List packages for a project
列出项目的依赖包
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action packages
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action packages
Show stats
显示统计信息
..github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action stats
> If only one project is cached, `-Project` is auto-selected.
> If multiple projects exist, add `-Project <name>` (use `-Action projects` to see available names).
> In scan mode, manifest names include a short hash suffix to avoid collisions; you can pass the base project name without the suffix if it's unambiguous...github\skills\winmd-api-search\scripts\Invoke-WinMdQuery.ps1 -Action stats
> 如果仅缓存了一个项目,`-Project`会自动选中。
> 如果存在多个项目,添加`-Project <name>`(使用`-Action projects`查看可用名称)。
> 在扫描模式下,清单名称包含短哈希后缀以避免冲突;如果没有歧义,你可以传递不带后缀的基础项目名称。Search Scoring
搜索评分
The search ranks type names and member names against your query:
| Score | Match type | Example |
|---|---|---|
| 100 | Exact name | |
| 80 | Starts with | |
| 60 | Contains | |
| 50 | PascalCase initials | |
| 40 | Multi-keyword AND | |
| 20 | Fuzzy character match | |
Results are grouped by namespace. Higher-scored namespaces appear first.
搜索会根据你的查询对类型名称和成员名称进行排名:
| 得分 | 匹配类型 | 示例 |
|---|---|---|
| 100 | 完全匹配名称 | |
| 80 | 前缀匹配 | |
| 60 | 包含匹配 | |
| 50 | PascalCase首字母匹配 | |
| 40 | 多关键词与匹配 | |
| 20 | 模糊字符匹配 | |
结果按命名空间分组,得分更高的命名空间排在前面。
Troubleshooting
故障排查
| Issue | Fix |
|---|---|
| "Cache not found" | Run |
| "Multiple projects cached" | Add |
| "Namespace not found" | Use |
| "Type not found" | Use fully qualified name (e.g., |
| Stale after NuGet update | Re-run |
| Cache in git history | Add |
| 问题 | 解决方法 |
|---|---|
| "Cache not found" | 运行 |
| "Multiple projects cached" | 添加 |
| "Namespace not found" | 使用 |
| "Type not found" | 使用完全限定名(例如 |
| NuGet更新后缓存过期 | 重新运行 |
| 缓存出现在git历史中 | 将 |
References
参考
- Windows Platform SDK API reference — documentation for namespaces
Windows.* - Windows App SDK API reference — documentation for WinAppSDK namespaces
Microsoft.*
- Windows Platform SDK API reference — 命名空间的文档
Windows.* - Windows App SDK API reference — WinAppSDK命名空间的文档
Microsoft.*