Add positional argument support to agent init#7636
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for a single optional positional argument to azd ai agent init, auto-classifying it as a manifest pointer (URL/file) or a source directory, while keeping explicit flags (--manifest, --src) authoritative and producing structured validation errors for conflicts.
Changes:
- Updated
agent initcommand usage/arg validation to accept up to one positional argument and resolve it into--manifestor--src. - Added positional-argument parsing helpers and new structured validation error codes for invalid/overlapping inputs.
- Added unit tests covering positional argument resolution and basic flag/positional conflict cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
cli/azd/extensions/azure.ai.agents/internal/exterrors/codes.go |
Adds new validation error codes for positional-argument validation/conflicts. |
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go |
Implements positional argument handling and maps it onto existing init flags. |
cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go |
Adds unit tests for positional argument resolution and conflict detection. |
…registry URLs, and improve handling of non-existent YAML paths as manifest pointers.
jongio
left a comment
There was a problem hiding this comment.
Clean implementation. URL detection via :// handles all schemes nicely, and the heuristic for non-existent paths (yaml extension = manifest, other = src directory) is a smart UX choice.
One minor note: CodeInvalidPositionalArg in codes.go is defined but never referenced - the updated resolvePositionalArg never returns an error. Not blocking, just a cleanup opportunity.
trangevi
left a comment
There was a problem hiding this comment.
I don't really like that it can be either manifest or source dir, but not going to block it.
Fixes #7510
azd ai agent init now accepts an optional positional argument that is auto-disambiguated between url, manifest file, or directory.
Explicit flags (--manifest, --src) still take priority. Passing both a positional arg and the corresponding flag produces a clear validation error with a suggestion.
Before
❯ azd ai agent init C:\path\to\my-agent
ERROR: unknown command "C:\path\to\my-agent" for "agent init"
After
❯ azd ai agent init C:\path\to\my-agent
Equivalent to: azd ai agent init --src C:\path\to\my-agent