Skip to content

Add positional argument support to agent init#7636

Merged
trangevi merged 2 commits into
Azure:mainfrom
therealjohn:fix-7510
Apr 10, 2026
Merged

Add positional argument support to agent init#7636
trangevi merged 2 commits into
Azure:mainfrom
therealjohn:fix-7510

Conversation

@therealjohn

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 init command usage/arg validation to accept up to one positional argument and resolve it into --manifest or --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.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go Outdated
…registry URLs, and improve handling of non-existent YAML paths as manifest pointers.

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 trangevi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't really like that it can be either manifest or source dir, but not going to block it.

@trangevi trangevi merged commit d98b8cc into Azure:main Apr 10, 2026
19 checks passed
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.

ERROR: unknown command when passing positional argument to azd ai agent init

4 participants