<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Documentation | The .NET Blog</title><link>https://thedotnetblog.com/zh/tags/documentation/</link><description>Articles, tutorials and insights from the .NET community.</description><generator>Hugo</generator><language>zh</language><managingEditor>@thedotnetblog (The .NET Blog)</managingEditor><webMaster>@thedotnetblog</webMaster><lastBuildDate>Sat, 04 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://thedotnetblog.com/zh/tags/documentation/index.xml" rel="self" type="application/rss+xml"/><item><title>Aspire 13.2 自带文档 CLI — 你的 AI 代理也能用</title><link>https://thedotnetblog.com/zh/news/emiliano-montesdeoca/aspire-docs-cli-ai-skills/</link><pubDate>Sat, 04 Apr 2026 00:00:00 +0000</pubDate><author>Emiliano Montesdeoca</author><guid>https://thedotnetblog.com/zh/news/emiliano-montesdeoca/aspire-docs-cli-ai-skills/</guid><description>.NET Aspire 13.2 新增了 aspire docs — 一个无需离开终端即可搜索、浏览和阅读官方文档的 CLI。它也可以作为 AI 代理的工具。这就是为什么这很重要。</description><content:encoded>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;本文为自动翻译。查看原文请&lt;a href="https://thedotnetblog.com/zh/news/emiliano-montesdeoca/aspire-docs-cli-ai-skills/"&gt;点击此处&lt;/a&gt;。&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;你知道那种时刻吗——你正深入一个 Aspire AppHost，接入各种集成，然后需要确认 Redis 集成到底需要哪些参数？你 Alt-Tab 切到浏览器，在 aspire.dev 上翻来翻去，眯着眼看 API 文档，然后切回编辑器。上下文没了，心流断了。&lt;/p&gt;
&lt;p&gt;Aspire 13.2 刚刚&lt;a href="https://devblogs.microsoft.com/aspire/aspire-docs-in-your-terminal/"&gt;发布了解决方案&lt;/a&gt;。&lt;code&gt;aspire docs&lt;/code&gt; CLI 让你直接从终端搜索、浏览和阅读 Aspire 官方文档。而且因为它由可复用的服务支撑，AI 代理和技能可以使用同样的命令来查找文档，而不是幻想出不存在的 API。&lt;/p&gt;
&lt;h2 id="这到底解决了什么问题"&gt;这到底解决了什么问题&lt;/h2&gt;
&lt;p&gt;David Pine 在原文中说得很到位：AI 代理在帮助开发者构建 Aspire 应用方面&lt;em&gt;糟糕透了&lt;/em&gt;。它们推荐 &lt;code&gt;dotnet run&lt;/code&gt; 而不是 &lt;code&gt;aspire run&lt;/code&gt;，引用 learn.microsoft.com 来查找实际在 aspire.dev 上的文档，建议过时的 NuGet 包，还有——我个人最喜欢的——幻想出根本不存在的 API。&lt;/p&gt;
&lt;p&gt;为什么？因为 Aspire 作为 .NET 专属工具的时间远比它成为多语言工具的时间长，而且 LLM 使用的训练数据早于最新功能。当你给 AI 代理真正查找当前文档的能力时，它就不再猜测，开始变得有用了。&lt;/p&gt;
&lt;h2 id="三个命令零个浏览器标签页"&gt;三个命令，零个浏览器标签页&lt;/h2&gt;
&lt;p&gt;CLI 简洁得令人耳目一新：&lt;/p&gt;
&lt;h3 id="列出所有文档"&gt;列出所有文档&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aspire docs list
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;返回 aspire.dev 上所有可用的文档页面。需要机器可读的输出？加上 &lt;code&gt;--format Json&lt;/code&gt;。&lt;/p&gt;
&lt;h3 id="搜索主题"&gt;搜索主题&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aspire docs search &lt;span class="s2"&gt;&amp;#34;redis&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;同时搜索标题和内容，使用加权相关性评分。与内部驱动文档工具的搜索引擎完全一样。你会得到带有标题、slug 和相关性分数的排名结果。&lt;/p&gt;
&lt;h3 id="阅读完整页面或仅一个章节"&gt;阅读完整页面（或仅一个章节）&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aspire docs get redis-integration
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;将完整页面以 markdown 格式流式传输到你的终端。只需要一个章节？&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aspire docs get redis-integration --section &lt;span class="s2"&gt;&amp;#34;Add Redis resource&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;精准定位。不用滚动 500 行。只看你需要的部分。&lt;/p&gt;
&lt;h2 id="ai-代理的视角"&gt;AI 代理的视角&lt;/h2&gt;
&lt;p&gt;对于我们这些使用 AI 工具进行开发的人来说，这才是真正有趣的地方。同样的 &lt;code&gt;aspire docs&lt;/code&gt; 命令可以作为 AI 代理的工具——通过技能、MCP 服务器或简单的 CLI 封装。&lt;/p&gt;
&lt;p&gt;你的 AI 助手不再根据过时的训练数据编造 Aspire API，而是可以调用 &lt;code&gt;aspire docs search &amp;quot;postgres&amp;quot;&lt;/code&gt;，找到官方集成文档，阅读正确的页面，给你文档记录的方案。实时的、最新的文档——而不是模型六个月前记住的内容。&lt;/p&gt;
&lt;p&gt;背后的架构是有意为之的。Aspire 团队构建了可复用的服务（&lt;code&gt;IDocsIndexService&lt;/code&gt;、&lt;code&gt;IDocsSearchService&lt;/code&gt;、&lt;code&gt;IDocsFetcher&lt;/code&gt;、&lt;code&gt;IDocsCache&lt;/code&gt;），而不是一次性集成。这意味着同一个搜索引擎为终端中的人类、编辑器中的 AI 代理以及 CI 流水线中的自动化服务。&lt;/p&gt;
&lt;h2 id="真实场景"&gt;真实场景&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;终端快速查询：&lt;/strong&gt; 你已经深入到第三个文件，需要 Redis 配置参数。两个命令，九十秒，回去干活：&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aspire docs search &lt;span class="s2"&gt;&amp;#34;redis&amp;#34;&lt;/span&gt; --limit &lt;span class="m"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aspire docs get redis-integration --section &lt;span class="s2"&gt;&amp;#34;Configuration&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;AI 辅助开发：&lt;/strong&gt; 你的 VS Code 技能封装了 CLI 命令。你问&amp;quot;给我的 AppHost 添加一个 PostgreSQL 数据库&amp;quot;，代理在回答之前先查阅真实文档。没有幻觉。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;CI/CD 验证：&lt;/strong&gt; 你的流水线以编程方式根据官方文档验证 AppHost 配置。&lt;code&gt;--format Json&lt;/code&gt; 输出可以干净地通过管道传递给 &lt;code&gt;jq&lt;/code&gt; 和其他工具。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;自定义知识库：&lt;/strong&gt; 在构建自己的 AI 工具？将结构化 JSON 输出直接导入你的知识库：&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;aspire docs search &lt;span class="s2"&gt;&amp;#34;monitoring&amp;#34;&lt;/span&gt; --format Json &lt;span class="p"&gt;|&lt;/span&gt; jq &lt;span class="s1"&gt;&amp;#39;[.[] | {slug, title, summary}]&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;不需要网页抓取。不需要 API 密钥。与文档工具内部使用的完全一样的结构化数据。&lt;/p&gt;
&lt;h2 id="文档始终是最新的"&gt;文档始终是最新的&lt;/h2&gt;
&lt;p&gt;这是我最欣赏的部分。CLI 不会下载快照——它通过基于 ETag 的缓存查询 aspire.dev。文档一旦更新，你的 CLI 和构建在其之上的所有技能都会反映出来。没有过时的副本，没有&amp;quot;但是 wiki 上说的是&amp;hellip;&amp;ldquo;的尴尬时刻。&lt;/p&gt;
&lt;h2 id="总结"&gt;总结&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;aspire docs&lt;/code&gt; 是那种以简洁方式解决真实问题的小功能之一。人类获得了终端原生的文档访问。AI 代理获得了停止猜测、开始引用真实文档的方式。而且一切都由同一个事实来源支撑。&lt;/p&gt;
&lt;p&gt;如果你正在使用 .NET Aspire 开发，还没试过这个 CLI，运行 &lt;code&gt;aspire docs search &amp;quot;你的主题&amp;quot;&lt;/code&gt; 看看感觉如何。然后考虑将这些命令封装到你正在使用的任何 AI 技能或自动化设置中——你的代理会感谢你的。&lt;/p&gt;
&lt;p&gt;查看 &lt;a href="https://davidpine.dev/posts/aspire-docs-mcp-tools/"&gt;David Pine 的深入分析&lt;/a&gt;了解文档工具是如何构建的，以及&lt;a href="https://aspire.dev/reference/cli/commands/aspire-docs/"&gt;官方 CLI 参考&lt;/a&gt;获取所有细节。&lt;/p&gt;</content:encoded></item></channel></rss>