Support extensions with shared namespace prefixes#8137
Conversation
Two extensions can now coexist under a shared namespace prefix (e.g. `ai` + `ai.finetune`) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Register metadata command on the ai root, not per-subtree
1208136 to
5384556
Compare
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
|
Team agreed to create separate |
Closes #8109
This PR lets two extensions coexist under a shared namespace prefix — for example one claiming
aiand another claimingai.finetune— in either install order.azd aiinvokes the leaf extension,azd ai finetuneroutes to the nested one, andazd ai --help/azd help airender a single merged Available Commands block listing both extensions' contributions. Previously the second install of any prefix-overlapping pair was rejected at install time.What you can now install together
How it works
bindExtensionmerges the cobra tree. Instead of creating duplicate nodes, the binder finds-or-reuses an existing extension-owned namespace node. A node can end up as both a leaf (carrying one extension's action and annotations) and a parent (with child subcommands contributed by other extensions). Cobra natively supports this hybrid shape — subcommand resolution runs before action invocation — soazd ai finetunedeterministically routes to the nested extension, and unmatched args pass through to the leaf binary.Hybrid leaves carry a generic header. Once a namespace is shared, the node's
Short/LongbecomesCommands for the <prefix> extension namespace.rather than any one extension's description. Each extension's own description remains reachable from its internal subcommand help (e.g.azd ai agent --help).Help is rendered by azd for hybrid leaves. A
HelpFuncis installed on every extension leaf. When the leaf is hybrid at render time and its metadata is on disk, the func injects synthetic cobra children derived from the metadata, swaps in a freshly-built template, and delegates rendering to an ancestor'sHelpFunc. Bothazd <leaf> --help(RunE →cmd.Help()) andazd help <leaf>(cobra's built-in help) flow through this hook and produce identical output. When metadata isn't available, the func is a no-op. The figspec autocomplete output performs the equivalent merge so VS Code IntelliSense mirrors the terminal.Install-time policy
Install-time checks are intentionally minimal — cobra's runtime resolution and the merged help renderer cover the rest:
auth,init,deploy, …) → rejected at bind time.Two extensions claiming the exact same namespace with disjoint internal subcommands remains unsupported — that would require redesigning the leaf as a per-extension dispatcher and is out of scope.
Follow-up
Updating the official registry to change an extension's published namespace (e.g.
azure.ai.agentsfromai.agenttoai) is not safe today becausenamespacelives at the extension level, not per-version. Tracked in #8135, which adds a per-version namespace override onExtensionVersionplus a guard inazd x publish.