Skip to content

Conversation

@JeffreyCA
Copy link
Contributor

@JeffreyCA JeffreyCA commented Jan 9, 2026

Fixes #5975
Fixes #6440

This PR improves the validation and UX when initializing agents from a local manifest file (azd ai agent init -m <local path>) and when initializing from GitHub URL in an unauthenticated/expired auth state.

Changes

  1. Add warning and confirmation prompt when agent initialization would result in copying more than 10 top-level files/folders (with preview):
    image

  2. Prevent initialization when target dir is inside the manifest dir to avoid accidentally copying the entire project into itself:
    image

  3. Fix panic when providing path to non-existent file
    image

  4. Improve in-place initialization when the manifest already lives in the target directory (skips copying):
    image

  5. Update github.com/azure/azure-dev/cli/azd in go.mod with GitHub URL parsing fix from Check GitHub authentication before branch resolution in ParseGitHubUrl #6478

@JeffreyCA JeffreyCA changed the title Jeffreyca/ext agents local validation azure.ai.agents - Improve validation when initializing from local manifest file Jan 9, 2026
@JeffreyCA JeffreyCA force-pushed the jeffreyca/ext-agents-local-validation branch from 321de6f to d16ceaa Compare January 9, 2026 02:30
@JeffreyCA JeffreyCA changed the title azure.ai.agents - Improve validation when initializing from local manifest file azure.ai.agents - Improve azd ai agent init -m validation Jan 9, 2026
@JeffreyCA JeffreyCA marked this pull request as ready for review January 9, 2026 19:13
Copilot AI review requested due to automatic review settings January 9, 2026 19:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the validation and user experience when initializing AI agents from local manifest files, specifically improving the azd ai agent init -m <local path> command. The changes focus on preventing common errors and providing better warnings when copying files.

Key changes:

  • Added comprehensive validation to prevent copying directories into themselves or their subtrees
  • Implemented a confirmation prompt with preview when copying more than 10 files/folders
  • Fixed panic when providing paths to non-existent files by adding proper error handling
  • Improved in-place re-initialization by detecting when manifest already exists in target directory

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go Added unit tests for copy validation logic, including subtree prevention and same-path handling
cli/azd/extensions/azure.ai.agents/internal/cmd/init_copy.go New file containing refactored copy validation and directory operations with safety checks
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Refactored to use new validation functions, improved error handling for non-existent files, and better in-place initialization logic
cli/azd/extensions/azure.ai.agents/go.mod Updated azd CLI dependency version
cli/azd/extensions/azure.ai.agents/go.sum Updated checksums for new azd CLI dependency

@JeffreyCA JeffreyCA merged commit 51d232f into Azure:main Jan 9, 2026
18 checks passed
@JeffreyCA JeffreyCA deleted the jeffreyca/ext-agents-local-validation branch January 9, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants