help --json catalog + opt-in dynamic command discovery (Phase 2)#405
Merged
Conversation
…pire (Phase 2) Phase 2 of the JasperFx.Aspire work (closes #403): make the dashboard buttons self-describing by discovering a service's actual verbs instead of relying only on the curated list. Core — `help --json`: - New --json flag on `help` writes the command catalog ([{name, description}], sorted) to stdout via Utf8JsonWriter (no reflection — trim/AOT safe). Pure introspection: no host is built, so it's cheap and needs no DB/broker. Chosen over `describe --json` precisely because describe builds the host. HelpCommand .ToCommandCatalogJson is public + unit-tested. JasperFx.Aspire — opt-in dynamic discovery: - JasperFxCommandOptions.DiscoverCommands (+ DiscoveryTimeout). When set, WithJasperFxCommands runs `help --json` against the already-built project at AppHost build time (dotnet run --no-build), parses the catalog, and renders one button per discovered verb — picking up product-specific and custom commands. - JasperFxVerbCatalog.ResolveDiscovered maps discovered verbs through the existing TemplateFor (known verbs keep curated metadata; unknown → mutating), honoring the same IncludeMutating/Include/Exclude gating; run/help are never shown. - Best-effort: the catalog parser locates the JSON array within noisy stdout (the framework prints "Searching '...' for commands" before it); any failure/timeout/ parse error falls back to the curated catalog. Default behavior is unchanged. 11 new tests (catalog JSON; noisy-output parsing; discovered-verb gating). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #403. Phase 2 of the JasperFx.Aspire work (A1 #402, A2 #404): make the dashboard buttons self-describing by discovering a service's actual verbs instead of relying only on the curated list.
Core —
help --jsonA new
--jsonflag on thehelpcommand writes the command catalog to stdout as JSON — each verb'snameanddescription, sorted:dotnet run -- help --json[ { "name": "check-env", "description": "Execute all environment checks ..." }, ... ]Utf8JsonWriter(no reflection → trim/AOT safe).help --jsonwas chosen over the design'sdescribe --jsonlean:describebuilds the host.HelpCommand.ToCommandCatalogJsonis public and unit-tested.JasperFx.Aspire — opt-in dynamic discovery
DiscoverCommandsis set,WithJasperFxCommandsrunshelp --jsonagainst the already-built project at AppHost build time (dotnet run --no-build), parses the catalog, and renders one button per discovered verb — picking up product-specific and custom commands automatically.JasperFxVerbCatalog.ResolveDiscoveredmaps discovered verbs through the existingTemplateFor(known verbs keep their curated icon/confirmation/mutating flag; unknown verbs → mutating), honoring the sameIncludeMutatingCommands/IncludeVerbs/ExcludeVerbsgating.run/helpare never shown.Searching '...' for commandsbefore it). Any failure/timeout/parse error falls back to the curated catalog — default behavior is unchanged.Verification
dotnet build jasperfx.slnx -c Releaseclean; VitePress docs build clean.dotnet run -- help --jsonoutput (clean JSON after the framework's search noise — the parser handles it).On the mutating classification (#403)
The "mutating vs read-only" source of truth stays in JasperFx.Aspire's catalog (convention + safe-default-to-mutating for unknowns) rather than adding a mutating concept to JasperFx core — core JSON is just
{ name, description }.Docs
New "Dynamic command discovery" section on
/cli/aspire, plus a general "Machine-readable command catalog" note in the CLI index.🤖 Generated with Claude Code