feat: adopt azdext SDK helpers — full extension framework migration#39
Merged
feat: adopt azdext SDK helpers — full extension framework migration#39
Conversation
Migrates azd-exec to use the new azdext SDK helpers from Azure/azure-dev#6856, replacing hand-rolled boilerplate with the framework's built-in equivalents. Changes: - Root command: NewExtensionRootCommand() replaces manual Cobra setup - Metadata: NewMetadataCommand() replaces manual wrapper - Listen: NewListenCommand() replaces manual gRPC setup - Version: NewVersionCommand() replaces manual version command - MCP server: NewMCPServerBuilder() with WithRateLimit() replaces manual setup - Tool handlers: ToolArgs typed accessors replace getArgsMap/getStringParam helpers - Results: MCPJSONResult/MCPErrorResult replace manual construction - Deleted: mcp_ratelimit.go (rate limiting now in builder) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🚀 Website Preview
Preview has been cleaned up as the PR was closed. |
Fixes golangci-lint unparam warning. The error return was never non-nil, so removed it from the signature and updated callers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
🚀 Test This PRA preview build ( 🌐 Website PreviewLive Preview: https://jongio.github.io/azd-exec/pr/39/ One-Line Install (Recommended)PowerShell (Windows): iex "& { $(irm https://raw.githubusercontent.com/jongio/azd-exec/main/cli/scripts/install-pr.ps1) } -PrNumber 39 -Version 0.3.8-pr39"Bash (macOS/Linux): curl -fsSL https://raw.githubusercontent.com/jongio/azd-exec/main/cli/scripts/install-pr.sh | bash -s 39 0.3.8-pr39UninstallWhen you're done testing: PowerShell (Windows): iex "& { $(irm https://raw.githubusercontent.com/jongio/azd-exec/main/cli/scripts/uninstall-pr.ps1) } -PrNumber 39"Bash (macOS/Linux): curl -fsSL https://raw.githubusercontent.com/jongio/azd-exec/main/cli/scripts/uninstall-pr.sh | bash -s 39Build Info:
What to Test: |
Owner
Author
|
Blocked on next azd release. PR Azure/azure-dev#6856 (ext SDK helpers) merged to main but is not yet in a tagged release. Once the next azd version ships:
Watching Azure/azure-dev for release notifications. |
Remove replace directive pointing at fork. Use official release azure-dev-cli_1.23.7 which includes ext framework improvements (#6856) and security fix (#6907). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e to 86% Code review findings addressed: - Restore AZD_DEBUG and AZD_NO_PROMPT env var propagation in PersistentPreRunE that was lost during SDK migration (executor reads these from os.Getenv) - Add clarifying comment for PYTHON prefix in env var allowlist - Fix TestListenCommandExecution to log result instead of discarding it Test coverage improvements (59% → 86%): - Add MCP handler tests: marshalExecResult, handleListShells, handleExecInline, handleExecScript validation/execution, NewMCPCommand, NewMetadataCommand - Add executor tests: directory path, prepareEnvironment with mock resolver, StopOnKeyVaultError, getDefaultShellForOS - Add command_builder tests: quotePowerShellArg, buildPowerShellInlineCommand - Add skills_test.go for InstallSkill - Add main_test.go tests for debug/no-prompt env var propagation Co-authored-by: GitHub Copilot <noreply@github.com>
TestHandleExecInline_Execution/executes_cmd_inline_on_Windows tries to invoke cmd.exe which doesn't exist on Linux/macOS CI runners. Add runtime.GOOS check to skip on non-Windows platforms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Summary
Migrates azd-exec to use the new \�zdext\ SDK helpers from Azure/azure-dev#6856, replacing hand-rolled boilerplate with the framework's built-in equivalents. Net result: -340 lines.
Depends on: Azure/azure-dev#6856 (merged)
Related: jongio/azd-core#22, jongio/azd-app#145
What changed
Root command (\main.go)
Before: ~150 lines of manual Cobra setup with 8 package-level flag variables, manual PersistentPreRunE handling OTel, debug, no-prompt, cwd, environment loading.
After: \�zdext.NewExtensionRootCommand()\ — standard flags handled automatically. Extension-specific flags (--shell, --interactive, --stop-on-keyvault-error) and special Cobra settings (\FParseErrWhitelist, \SetInterspersed(false)) preserved.
Metadata / Listen / Version commands
Before: Manual implementations.
After: \�zdext.NewMetadataCommand(), \�zdext.NewListenCommand(nil), \�zdext.NewVersionCommand().
MCP server (\mcp.go)
Before: Manual \server.NewMCPServer()\ + \s.AddTools()\ + custom \getArgsMap()/\getStringParam()\ helpers (17 lines) + global rate limiter.
After: \�zdext.NewMCPServerBuilder()\ with .WithRateLimit(10, 1.0). Helper functions deleted.
All 4 MCP tool handlers
Before: \getArgsMap(request)\ → \getStringParam(args, key)\ + \mcp.NewToolResultError()\ + manual JSON marshal + per-handler rate limit checks.
After: \�rgs.RequireString(key)\ / \�rgs.OptionalString(key, default)\ + \�zdext.MCPJSONResult()\ / \MCPErrorResult(). Rate limiting in builder.
Deleted files
Impact
Testing