Skip to content

[Agents Extension] Init from agent template#7147

Open
trangevi wants to merge 4 commits intomainfrom
trangevi/agent-template-init
Open

[Agents Extension] Init from agent template#7147
trangevi wants to merge 4 commits intomainfrom
trangevi/agent-template-init

Conversation

@trangevi
Copy link
Member

Adds handling to prompt the user when they don't provide a manifest, to select to either use code in the current directory, or select from a curated list of agent templates.

Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
Signed-off-by: trangevi <trangevi@microsoft.com>
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

Adds an interactive “start from a template” initialization flow to the azure.ai.agents extension, while refactoring the existing manifest-based init logic into a shared helper.

Changes:

  • Extract common manifest initialization logic into runInitFromManifest.
  • Add template-catalog fetching, interactive selection, and post-azd init -t manifest discovery.
  • Add unit tests for template type detection, template fetching (via test helper), and manifest discovery.

Reviewed changes

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

File Description
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Refactors manifest init into a helper and adds a new interactive branching flow (from code vs template).
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_templates_helpers.go Implements template catalog retrieval, init-mode/language/template prompts, and manifest search.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_templates_helpers_test.go Adds tests for EffectiveType and findAgentManifest, plus HTTP-fetch parsing via a test helper.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +206 to 214
} else {
// No manifest provided - prompt user for init mode
initMode, err := promptInitMode(ctx, azdClient)
if err != nil {
return exterrors.Auth(
exterrors.CodeCredentialCreationFailed,
fmt.Sprintf("failed to create Azure credential: %s", err),
"run 'azd auth login' to authenticate",
)
}

console := input.NewConsole(
false, // noPrompt
true, // isTerminal
input.Writers{Output: os.Stdout},
input.ConsoleHandles{
Stderr: os.Stderr,
Stdin: os.Stdin,
Stdout: os.Stdout,
},
nil, // formatter
nil, // externalPromptCfg
)

action := &InitAction{
azdClient: azdClient,
// azureClient: azure.NewAzureClient(credential),
azureContext: azureContext,
// composedResources: getComposedResourcesResponse.Resources,
console: console,
credential: credential,
projectConfig: projectConfig,
environment: environment,
flags: flags,
httpClient: httpClient,
}

if err := action.Run(ctx); err != nil {
if exterrors.IsCancellation(err) {
return exterrors.Cancelled("initialization was cancelled")
}
return err
}
Comment on lines +69 to +72
resp, err := azdClient.Prompt().Select(ctx, &azdext.SelectRequest{
Options: &azdext.SelectOptions{
Message: "How do you want to initialize your agent?",
Choices: choices,
Comment on lines +140 to +145
langResp, err := azdClient.Prompt().Select(ctx, &azdext.SelectRequest{
Options: &azdext.SelectOptions{
Message: "Select a language:",
Choices: languageChoices,
},
})
Comment on lines +177 to +182
templateResp, err := azdClient.Prompt().Select(ctx, &azdext.SelectRequest{
Options: &azdext.SelectOptions{
Message: "Select an agent template:",
Choices: templateChoices,
},
})
Signed-off-by: trangevi <trangevi@microsoft.com>
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.

2 participants