fix(figspec): fix generated completions for azd extension install#8887
azd extension install#8887Conversation
- Add FigGenFilepathsZip constant and filepathsHelperImport for VS Code's
filepaths({ extensions: ['zip'] }) helper
- Add Generators []string to Arg struct (takes precedence over Generator);
remove unused Template string field
- Update typescript_renderer to emit the filepaths import preamble and
render Generators as an array when multiple entries are present
- Switch azd extension install customization to use
Generators: [listExtensions, filepaths({extensions:['zip']})]
- Update tests and snapshot accordingly
- Update docs/fig-spec.md: add listConfigKeys table row and filepaths
helper subsection
Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates azd’s Fig spec generation (used for VS Code terminal IntelliSense) so azd extension install completions can combine extension-ID suggestions with .zip-scoped file path suggestions using VS Code’s filepaths helper API.
Changes:
- Extends the Fig spec arg model to support multi-generator args via a new
Arg.Generators []stringfield (taking precedence overArg.Generator) and removes the unusedTemplatefield. - Updates the TypeScript renderer to emit
generators: [...]when multiple generators are present and to add afilepathshelper import to the generated spec output. - Adds a
FigGenFilepathsZipconstant and updatesazd extension installcustomization, docs, and the Fig spec snapshot accordingly.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/internal/figspec/typescript_renderer.go | Renders multi-generator args and injects a filepaths import into generated TypeScript. |
| cli/azd/internal/figspec/typescript_renderer_test.go | Updates renderer tests for multi-generator output and import presence. |
| cli/azd/internal/figspec/types.go | Adds Arg.Generators []string and removes the dead Template field. |
| cli/azd/internal/figspec/fig_generators.go | Adds FigGenFilepathsZip and the filepaths import constant. |
| cli/azd/internal/figspec/customizations.go | Uses the new multi-generator form for azd extension install. |
| cli/azd/internal/figspec/customizations_test.go | Updates customization assertions for multi-generator args. |
| cli/azd/docs/fig-spec.md | Documents the new multi-generator usage and filepaths import behavior; adds missing generator doc row. |
| cli/azd/cmd/testdata/TestFigSpec.ts | Snapshot updated to include the new import preamble and generator array form. |
Review details
Comments suppressed due to low confidence (1)
cli/azd/internal/figspec/typescript_renderer.go:59
- azd-code-reviewer:
ToTypeScriptcurrently injectsfilepathsHelperImportunconditionally. That hard-codes the generated spec to VS Code’s repo layout even when the spec doesn’t usefilepaths(...)(e.g.,TestToTypeScript_Empty), and can also become a TS compile/lint failure iffilepathsusage is removed later (unused/missing-module import). Consider emitting this import only when the rendered spec actually contains afilepaths(generator (or whenFigGenFilepathsZipis present in any arg).
data := map[string]string{
"Name": s.Name,
"Description": s.Description,
"Import": filepathsHelperImport,
"Generators": figGeneratorDefinitionsTS,
"Subcommands": renderSubcommands(s.Subcommands, 2),
"Options": renderOptions(s.Options, 2, false),
}
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Low
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
/azp run azure-dev - cli |
|
Azure Pipelines successfully started running 1 pipeline(s). |
azd extension install
jongio
left a comment
There was a problem hiding this comment.
One optional note below on the generated filepaths import. Otherwise this looks correct: the old Template field is fully removed with no remaining references, and the multi-generator rendering, updated tests, and regenerated Fig spec snapshot all pass locally.
| data := map[string]string{ | ||
| "Name": s.Name, | ||
| "Description": s.Description, | ||
| "Import": filepathsHelperImport, |
There was a problem hiding this comment.
This injects the filepaths import into every generated spec, whether or not any arg actually uses filepaths. It's fine today because azd extension install always needs it, but if that usage ever goes away the generated spec keeps an unused import, which trips no-unused-vars in the VS Code repo where the spec lives. Consider gating the import on whether the rendered output actually references filepaths so the preamble stays in sync with real usage.
Related to #8416 and microsoft/vscode#321221
Summary
This PR updates azd's Fig spec generator to preserve VS Code's corrected completions for
azd extension install.Issue
The generator still emitted the legacy
template: 'filepaths'fallback, while the VS Code spec now combines extension ID suggestions with.zipfile paths. Regenerating the spec could therefore overwrite the fix from microsoft/vscode#321221.Changes
.zip-only file path suggestions forazd extension install.filepathshelper import and removes the obsolete argument template field.Behavior at a glance
azd extension install <arg>.zipfile path completionTesting
Updated unit coverage for multi-generator rendering and extension install customization, along with the generated Fig spec snapshot.