Skip to content

feat: adopt azdext SDK helpers — full extension framework migration#39

Merged
jongio merged 6 commits intomainfrom
feature/ext-framework-sdk-helpers
Mar 2, 2026
Merged

feat: adopt azdext SDK helpers — full extension framework migration#39
jongio merged 6 commits intomainfrom
feature/ext-framework-sdk-helpers

Conversation

@jongio
Copy link
Owner

@jongio jongio commented Feb 26, 2026

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

  • \mcp_ratelimit.go\ — rate limiting now built into \MCPServerBuilder\

Impact

Metric Change
Files changed 12
Lines removed 573
Lines added 233
Net reduction -340 lines
Custom arg helpers Deleted (17 lines)
Rate limiter file Deleted entirely

Testing

  • \go build ./...\ ✅
  • \go test ./...\ ✅

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>
github-actions bot added a commit that referenced this pull request Feb 26, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

🚀 Website Preview

Your PR preview was available here.

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>
github-actions bot added a commit that referenced this pull request Feb 26, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

🚀 Test This PR

A preview build (0.3.8-pr39) is ready for testing!

🌐 Website Preview

Live 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-pr39

Uninstall

When 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 39

Build Info:

What to Test:
Please review the PR description and test the changes described there.

@jongio
Copy link
Owner Author

jongio commented Feb 26, 2026

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:

  1. Update go.mod to reference the new tagged version (replace the go.work local override)
  2. Run go mod tidy
  3. Verify build + tests
  4. Merge

Watching Azure/azure-dev for release notifications.

jongio and others added 2 commits February 27, 2026 23:28
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>
github-actions bot added a commit that referenced this pull request Feb 28, 2026
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>
github-actions bot added a commit that referenced this pull request Feb 28, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Feb 28, 2026
@jongio jongio merged commit 7ac164c into main Mar 2, 2026
15 checks passed
@jongio jongio deleted the feature/ext-framework-sdk-helpers branch March 2, 2026 16:27
github-actions bot added a commit that referenced this pull request Mar 2, 2026
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.

1 participant