AGENT SKILL

Twoslash 示例校验与修复

twoslash-validator

为 aspire.dev 校验并修复双斜杠(twoslash)TypeScript 示例。在添加或编辑 `twoslash` 代码块、TypeScript AppHost 示例、生成的 TypeScript API 数据,或处理 `bun run test:unit:twoslash-blocks` 的失败时使用。

使用场景代码实现
License 许可
MIT
最近更新
2026-11-15
Stars
★ 206
Forks
99

01 前言 Front Matter

name
twoslash-validator
description
Validate and fix two-slash TypeScript examples for aspire.dev. Use when adding or editing `twoslash` code fences, TypeScript AppHost samples, generated TypeScript API data, or failures from `bun run test:unit:twoslash-blocks`.

03 SKILL.md 正文

Two-slash Validator Skill

Use this skill to keep aspire.dev from shipping rendered two-slash error UI. Any TypeScript diagnostic in a twoslash code block renders an error box on the site, so diagnostics must be fixed rather than suppressed.

When to use this skill

  • Adding or editing a TypeScript code fence with the twoslash meta flag
  • Updating TypeScript AppHost examples that import './.aspire/modules/aspire.mjs'
  • Refreshing src/frontend/src/data/ts-modules/ or src/frontend/src/data/twoslash/aspire.d.ts
  • Investigating failures from bun run test:unit:twoslash-blocks
  • Reviewing docs changes that affect TypeScript sample rendering

Core rule

Do not add diagnostic allowlists or suppressions. A two-slash diagnostic is user-visible output on aspire.dev. Fix the docs sample, fix/regenerate the generated type surface, or remove the twoslash meta until the sample compiles cleanly.

Validation workflow

Run commands from the repository root unless noted.

  1. Ensure dependencies are installed:

    Set-Location -Path .\src\frontend
    bun install --frozen-lockfile
    
  2. If TypeScript API JSON changed, regenerate the two-slash declaration bundle:

    bun run twoslash-types
    
  3. Run the two-slash block gate:

    bun run test:unit:twoslash-blocks
    
  4. If the test fails, read every reported file, line, block number, and ts(...) code. Fix every diagnostic before considering the work complete.

Fix strategy

Use this order when deciding what to change:

  1. Docs sample bug: If the TypeScript snippet calls the wrong API, uses the wrong argument shape, has a stale model name, or chains incompatible resources, fix the MDX sample.
  2. Generated type data stale: If the sample matches the product API but src/frontend/src/data/twoslash/aspire.d.ts is stale, run bun run twoslash-types and commit the regenerated bundle.
  3. Generator type-shape gap: If regeneration is not enough because scripts/generate-twoslash-types.ts loses valid SDK shape, fix the generator and regenerate aspire.d.ts.
  4. Feature not representable yet: If a correct sample cannot be represented by the current two-slash type data, remove the twoslash meta from that block and leave the code sample visible without two-slash rendering. Do not leave a rendered diagnostic.

What not to do

  • Do not reintroduce KNOWN_TYPE_BUGS, per-page diagnostic budgets, or equivalent allowlists.
  • Do not disable TWOSLASH_ENABLED to make the test pass.
  • Do not change noErrorValidation as a substitute for fixing diagnostics; it exists so the audit can collect all failures at once.
  • Do not hide failures by changing the fence language away from TypeScript unless the sample is not TypeScript.
  • Do not edit generated aspire.d.ts by hand; update the generator or source JSON and regenerate.

Expected final checks

Before finishing a two-slash-related change, run:

Set-Location -Path .\src\frontend
bun run test:unit:twoslash-blocks

If you changed the generator, also run:

bun run test:unit:twoslash-types

04 同仓库更多 Skills

microsoft
microsoft/aspire.dev

Aspire 入门指南

getting-started-with-aspire

当开发者询问如何开始使用 Aspire 时使用本技能——包括安装 Aspire CLI、创建新的 Aspire 应用、在本地运行,或在 aspire.dev 上查找权威文档、集成目录或 API 参考。适用于“如何安装 aspire?”“如何创建新的 aspire 应用?”“如何运行我的 aspire 应用?”“aspire 的文档在哪里?”等问题。不适用于:操作现有的 Aspire AppHost(使用 github.com/microsoft/aspire/tree/main/.agents/skills/aspire 上的官方 `aspire` 技能)、编写 AppHost 代码,或向现有应用添加集成。

软件开发工程师学习引导
★ 206
microsoft
microsoft/aspire.dev

Aspire 新特性发布说明编写

whatsnew

这是一个带步骤参数的技能,将编写 Aspire “What's new in N.N” 发布说明页面(src/frontend/src/content/docs/whats-new/aspire-N-N.mdx)规范为一套可重复的生命周期流程。以 `/whatsnew {modality}` 形式调用,其中 modality 为以下之一:draft/scaffold(init,初始化)、research(研究)、critique(评审)、validate(验证)、polish(润色)、review(审查)。适用于:为某个版本启动/搭建新的“新特性”页面,将版本变更研究整理成资料档案并撰写草稿正文,评审草稿,对差异进行事实核查/验证,润色并执行数据导入,或对 PR 做最终签核。不适用于:通用文档页面(使用 doc-writer)、审查任意文档 PR(使用 doc-pr-reviewer),或产品仓库的改动。编排的技能包括:doc-writer、doc-pr-reviewer、doc-tester、twoslash-validator、update-integrations、update-samples、container-images。

技术文档工程师技术文档编写
★ 206
microsoft
microsoft/aspire.dev

Aspire 示例数据同步

update-samples

通过从 microsoft/aspire-samples GitHub 仓库获取示例元数据来更新示例数据文件。在添加新示例、刷新示例数据,或确保 samples.json 与上游仓库保持同步时使用。

软件开发工程师示例与演示技能
★ 206
microsoft
microsoft/aspire.dev

集成文档与 API 参考同步

update-integrations

通过将 NuGet 包名与其文档 URL 同步,并生成每个包的 API schema,来更新集成文档链接和 API 参考数据。在添加新集成、刷新包数据、确保 integration-docs.json 与 aspire-integrations.json 保持同步,或重新生成 API 参考 JSON 文件时使用。

技术文档工程师技术文档编写
★ 206
microsoft
microsoft/aspire.dev

Playwright 浏览器自动化测试

playwright-cli

自动化浏览器交互,用于 Web 测试、表单填写、截图和数据提取。当用户需要浏览网站、与网页交互、填写表单、截取截图、测试 Web 应用或从网页提取信息时使用。

测试工程师测试与质量保障
★ 206
microsoft
microsoft/aspire.dev

终端应用自动化操作

hex1b

用于自动化任何终端应用程序的 CLI 工具——TUI 应用、shell、CLI 工具、REPL 等。当需要在虚拟终端中启动进程、捕获其屏幕输出、注入键盘或鼠标输入、截取屏幕截图、录制会话或对可见内容进行断言时使用。

软件开发工程师桌面自动化与界面操作
★ 206