Skip to content

Add aspire docs api * sub-commands to expose aspire.dev reference material#15814

Open
IEvangelist wants to merge 23 commits intomainfrom
dapine/aspire-api-docs-commands
Open

Add aspire docs api * sub-commands to expose aspire.dev reference material#15814
IEvangelist wants to merge 23 commits intomainfrom
dapine/aspire-api-docs-commands

Conversation

@IEvangelist
Copy link
Copy Markdown
Member

@IEvangelist IEvangelist commented Apr 2, 2026

Summary

  • Add aspire docs api list|search|get to browse Aspire API reference material from aspire.dev
  • Build the API index from https://aspire.dev/sitemap-0.xml and fetch API page markdown directly from the matching reference pages
  • Share CLI documentation infrastructure for conditional fetches, ETag handling, caching, persistence, and scoring between prose docs and API docs
  • Fix the prose docs follow-up issues uncovered during this work: friendly docs cache filenames and malformed aspire docs list rows from extra landing-page H1 content

Details

  • The final CLI surface is aspire docs api ... rather than a top-level aspire api ...
  • C# and TypeScript API hierarchies are modeled from sitemap routes today, with language scaffolding in place for java, go, python, and rust
  • get returns markdown and renders it through the shared interaction-service markdown renderer
  • The API docs pipeline stays CLI-native and is not coupled to MCP
  • Shared documentation code now lives under Aspire.Cli.Documentation, with prose docs in Documentation.Docs and API docs in Documentation.ApiDocs
  • Review follow-ups included in this PR:
    • preserve cancellation in CachedHttpDocumentFetcher
    • restore cache-first cold-start behavior for prose docs in DocsIndexService
    • keep API command strings in the normal XLF generation flow
    • reuse the shared markdown display path
    • migrate docs source cache files to friendly llms-small.txt and llms-small.etag.txt
    • stop LlmsTxtParser from splitting landing-page hero H1 content into bogus extra documents

Testing

  • Added or updated command tests for docs api list|search|get
  • Added or updated sitemap parser and API index tests
  • Added or updated docs fetch/cache/parser tests for shared documentation behavior and the two prose docs regressions

Fixes #14911
Fixes #14346
Fixes #15840

Dependencies

None

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15814

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15814"

@IEvangelist IEvangelist force-pushed the dapine/aspire-api-docs-commands branch from 15ed66f to 5fa4582 Compare April 6, 2026 19:25
- Added Turkish, Simplified Chinese, and Traditional Chinese translations for API command strings.
- Implemented TerminalMarkdownFormatter for formatting markdown content in terminal output.
- Created comprehensive tests for API commands, including help display, listing entries, and searching with filters.
- Developed ApiDocsIndexService tests to validate API documentation indexing and retrieval.
- Introduced ApiSitemapParser tests to ensure correct parsing of API sitemap structures.
- Added TestApiDocsFetcher for testing purposes, providing a mock implementation of IApiDocsFetcher.
@IEvangelist IEvangelist force-pushed the dapine/aspire-api-docs-commands branch from 9aad93b to b3a9869 Compare April 7, 2026 16:28
@IEvangelist IEvangelist force-pushed the dapine/aspire-api-docs-commands branch from 06a9cee to 6d218ba Compare April 8, 2026 20:23
@IEvangelist IEvangelist marked this pull request as ready for review April 8, 2026 20:23
Copilot AI review requested due to automatic review settings April 8, 2026 20:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new aspire api command group (list/search/get) backed by an indexed aspire.dev API sitemap, refactors docs caching/indexing into a shared documentation infrastructure, and introduces new resource strings plus localization artifacts.

Changes:

  • Implement aspire api commands and an API docs indexing pipeline (sitemap parsing, caching, search/list/get).
  • Refactor docs fetching/caching to a shared Documentation layer (fingerprinting, file-backed cache, lexical scoring, terminal markdown formatting).
  • Add/adjust CLI tests and agent skill docs to cover and document the new API commands.

Reviewed changes

Copilot reviewed 69 out of 70 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs Registers API docs services/commands in test DI container.
tests/Aspire.Cli.Tests/TestServices/TestDocsFetcher.cs Updates test fetcher namespace after docs refactor.
tests/Aspire.Cli.Tests/TestServices/TestApiDocsFetcher.cs Adds a minimal test double for IApiDocsFetcher.
tests/Aspire.Cli.Tests/Mcp/TestDocsIndexService.cs Updates test index service namespace after docs refactor.
tests/Aspire.Cli.Tests/Mcp/Docs/LlmsTxtParserTests.cs Moves tests to the new Documentation.Docs namespace.
tests/Aspire.Cli.Tests/Mcp/Docs/DocsSearchServiceTests.cs Updates namespace and adapts to new cache fingerprint API.
tests/Aspire.Cli.Tests/Mcp/Docs/DocsIndexServiceTests.cs Adds tests for cached-index rebuild and offline-cache fallback behavior.
tests/Aspire.Cli.Tests/Mcp/Docs/DocsFetcherTests.cs Updates fetcher construction to include configuration; adapts cache interface.
tests/Aspire.Cli.Tests/Mcp/ApiDocs/ApiSitemapParserTests.cs Adds coverage for sitemap filtering and segment parsing rules.
tests/Aspire.Cli.Tests/Mcp/ApiDocs/ApiDocsSourceConfigurationTests.cs Adds coverage for cache keys and host rebasing behavior.
tests/Aspire.Cli.Tests/Mcp/ApiDocs/ApiDocsIndexServiceTests.cs Adds coverage for API index hierarchy, search, get, rebasing, and cache rebuild.
tests/Aspire.Cli.Tests/Commands/DocsCommandTests.cs Updates tests to new docs namespace.
tests/Aspire.Cli.Tests/Commands/ApiCommandTests.cs Adds end-to-end CLI tests for aspire api behaviors.
src/Aspire.Cli/Utils/TerminalMarkdownFormatter.cs Centralizes terminal-friendly markdown formatting.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.zh-Hant.xlf Adds Traditional Chinese XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.zh-Hans.xlf Adds Simplified Chinese XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.tr.xlf Adds Turkish XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.ru.xlf Adds Russian XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.pt-BR.xlf Adds Portuguese (Brazil) XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.pl.xlf Adds Polish XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.ko.xlf Adds Korean XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.ja.xlf Adds Japanese XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.it.xlf Adds Italian XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.fr.xlf Adds French XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.es.xlf Adds Spanish XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.de.xlf Adds German XLF file for API command strings.
src/Aspire.Cli/Resources/xlf/ApiCommandStrings.cs.xlf Adds Czech XLF file for API command strings.
src/Aspire.Cli/Resources/ApiCommandStrings.resx Adds API command string resources.
src/Aspire.Cli/Resources/ApiCommandStrings.Designer.cs Adds generated strongly-typed accessor for API command strings.
src/Aspire.Cli/README.md Documents the new api command and provides example usage.
src/Aspire.Cli/Program.cs Wires API docs services + commands into the CLI host.
src/Aspire.Cli/Mcp/Tools/SearchDocsTool.cs Updates docs tool to new docs namespace.
src/Aspire.Cli/Mcp/Tools/ListDocsTool.cs Updates docs tool to new docs namespace.
src/Aspire.Cli/Mcp/Tools/GetDocTool.cs Updates docs tool to new docs namespace.
src/Aspire.Cli/Mcp/Tools/DocsToolHelper.cs Updates docs tool helper to new docs namespace.
src/Aspire.Cli/Mcp/Docs/DocsFetcher.cs Removes old MCP docs fetcher (moved/refactored).
src/Aspire.Cli/Mcp/Docs/DocsCache.cs Removes old MCP docs cache (moved/refactored).
src/Aspire.Cli/JsonSourceGenerationContext.cs Adds JSON source-gen metadata for API docs models and new namespaces.
src/Aspire.Cli/Documentation/SourceContentFingerprint.cs Adds stable fingerprinting for cached source content changes.
src/Aspire.Cli/Documentation/LexicalScoring.cs Extracts shared tokenization and scoring helpers.
src/Aspire.Cli/Documentation/IDocumentContentCache.cs Refactors base cache interface into shared documentation namespace.
src/Aspire.Cli/Documentation/FileBackedDocumentContentCache.cs Introduces shared file-backed cache for text/ETag/JSON payloads.
src/Aspire.Cli/Documentation/Docs/LlmsTxtParser.cs Moves parser into new docs namespace.
src/Aspire.Cli/Documentation/Docs/IDocsCache.cs Adds docs cache interface including index fingerprint support.
src/Aspire.Cli/Documentation/Docs/DocsSourceConfiguration.cs Adds config for overriding llms.txt source and cache key derivation.
src/Aspire.Cli/Documentation/Docs/DocsSearchService.cs Moves docs search service into new docs namespace.
src/Aspire.Cli/Documentation/Docs/DocsIndexService.cs Adds fingerprint-based cache rebuild and shared lexical scoring usage.
src/Aspire.Cli/Documentation/Docs/DocsFetcher.cs Adds configurable docs fetcher using shared cached HTTP fetch helper.
src/Aspire.Cli/Documentation/Docs/DocsCache.cs Implements docs cache using the shared file-backed cache.
src/Aspire.Cli/Documentation/CachedHttpDocumentFetcher.cs Adds shared ETag-aware HTTP fetch + cache fallback behavior.
src/Aspire.Cli/Documentation/ApiDocs/IApiDocsCache.cs Defines cache interface for API docs including index fingerprint support.
src/Aspire.Cli/Documentation/ApiDocs/ApiSitemapParser.cs Implements sitemap parsing and route extraction for modeled languages.
src/Aspire.Cli/Documentation/ApiDocs/ApiDocsSourceConfiguration.cs Adds config for sitemap URL override and host rebasing/markdown URL rules.
src/Aspire.Cli/Documentation/ApiDocs/ApiDocsIndexService.cs Implements API index build/list/search/get models and scoring.
src/Aspire.Cli/Documentation/ApiDocs/ApiDocsFetcher.cs Implements API sitemap/page fetcher using shared cached HTTP helper.
src/Aspire.Cli/Documentation/ApiDocs/ApiDocsCache.cs Implements API docs cache using shared file-backed cache.
src/Aspire.Cli/Commands/RootCommand.cs Adds api to the root command subcommands.
src/Aspire.Cli/Commands/DocsSearchCommand.cs Updates docs command to new docs namespace.
src/Aspire.Cli/Commands/DocsListCommand.cs Updates docs command to new docs namespace.
src/Aspire.Cli/Commands/DocsGetCommand.cs Uses shared TerminalMarkdownFormatter and new docs namespace.
src/Aspire.Cli/Commands/ApiSearchCommand.cs Adds aspire api search command implementation.
src/Aspire.Cli/Commands/ApiListCommand.cs Adds aspire api list command implementation.
src/Aspire.Cli/Commands/ApiGetCommand.cs Adds aspire api get command implementation.
src/Aspire.Cli/Commands/ApiCommand.cs Adds aspire api parent command wiring list/search/get.
src/Aspire.Cli/Commands/AgentMcpCommand.cs Updates docs dependency to new docs namespace.
docs/specs/api-docs-commands.md Adds a spec describing the new API docs command surface and behavior.
.agents/skills/aspire/SKILL.md Updates agent guidance to use aspire api for reference lookups.
.agents/skills/aspire/references/tools-and-configuration.md Documents aspire api alongside aspire docs for workflows.
.agents/skills/aspire/references/csharp-apphosts.md Adds API-reference lookup guidance for C# AppHost work.
.agents/skills/aspire/references/agent-workflows.md Updates workflows to include API reference commands.
Files not reviewed (1)
  • src/Aspire.Cli/Resources/ApiCommandStrings.Designer.cs: Language not supported

Copy link
Copy Markdown
Member

@JamesNK JamesNK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues flagged: 1 bug (cancellation swallowed in shared HTTP fetcher), 1 behavioral change (docs index now requires network on every cold start).

@IEvangelist IEvangelist changed the title Add localization support and API command enhancements Add aspire api * commands to expose aspire.dev reference material Apr 9, 2026
IEvangelist and others added 3 commits April 9, 2026 10:39
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@IEvangelist IEvangelist changed the title Add aspire api * commands to expose aspire.dev reference material Add aspire docs api * sub-commands to expose aspire.dev reference material Apr 9, 2026
IEvangelist and others added 6 commits April 9, 2026 14:51
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Parse C# type markdown overview links into a lazily-built cached member index so api search and anchored get can resolve member-level results like WithCommand without crawling every member-group page.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Load the grouped-member index when base route hits still need member results, and build member items from member-group parents discovered from routes instead of C#-specific member-index assumptions.

Add WithEnv and generic parser regressions for grouped member links.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stop building the grouped-member cache for the entire API corpus on the first search. Member containers are now loaded and persisted only as search, list, and get touch them, with batched search expansion instead of a full eager crawl.

Also rewrite site-relative API markdown links to configured-host absolute URLs so returned markdown is clickable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- shorten synthetic member ids for readability while keeping overloads distinct
- improve broad prefix ranking so coarse queries prefer closer type hits
- fix markdown link rewriting for bracketed signatures in returned API markdown

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
IEvangelist and others added 7 commits April 10, 2026 09:41
- handle bracketed link text in the Spectre markdown converter used by docs api get
- add exact distributedapplication regressions for link rewriting and displayed output

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- read llms.txt and API sitemap overrides from aspire config paths
- model and migrate the docs settings in local/global config files
- add config command, schema, and source configuration regressions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
IEvangelist and others added 2 commits April 10, 2026 13:57
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 58 recordings uploaded (commit bf4ee3c)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AllPublishMethodsBuildDockerImages ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24260910289

Comment on lines +49 to +52
aspire docs api list java
aspire docs api list go
aspire docs api list rust
aspire docs api list python
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work, lets remove this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspire docs list has formatting issues Generate custom API docs for polyglot SDKs Docs cache file name is weird

4 participants