-
Notifications
You must be signed in to change notification settings - Fork 267
make azd init alpha feature more discoverable #6499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hemarina
wants to merge
8
commits into
Azure:main
Choose a base branch
from
hemarina:fix-6488
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+42
−12
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0467df4
update workflow
hemarina 9e9e68c
Merge branch 'main' of https://github.com/Azure/azure-dev into fix-6488
hemarina 6ddcf30
Update cli/azd/cmd/init.go
hemarina 9289e6c
add suggestion on error message
hemarina 94779f5
Merge branch 'fix-6488' of https://github.com/hemarina/azure-dev into…
hemarina 4423dbe
address feedback
hemarina dd8840e
lll
hemarina 4332732
address feedback
hemarina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
| "github.com/azure/azure-dev/cli/azd/internal/tracing" | ||
| "github.com/azure/azure-dev/cli/azd/internal/tracing/fields" | ||
| "github.com/azure/azure-dev/cli/azd/pkg/alpha" | ||
| "github.com/azure/azure-dev/cli/azd/pkg/config" | ||
| "github.com/azure/azure-dev/cli/azd/pkg/environment" | ||
| "github.com/azure/azure-dev/cli/azd/pkg/environment/azdcontext" | ||
| "github.com/azure/azure-dev/cli/azd/pkg/exec" | ||
|
|
@@ -141,6 +142,7 @@ type initAction struct { | |
| azd workflow.AzdCommandRunner | ||
| agentFactory *agent.AgentFactory | ||
| consentManager consent.ConsentManager | ||
| configManager config.UserConfigManager | ||
| } | ||
|
|
||
| func newInitAction( | ||
|
|
@@ -157,6 +159,7 @@ func newInitAction( | |
| azd workflow.AzdCommandRunner, | ||
| agentFactory *agent.AgentFactory, | ||
| consentManager consent.ConsentManager, | ||
| configManager config.UserConfigManager, | ||
| ) actions.Action { | ||
| return &initAction{ | ||
| lazyAzdCtx: lazyAzdCtx, | ||
|
|
@@ -172,6 +175,7 @@ func newInitAction( | |
| azd: azd, | ||
| agentFactory: agentFactory, | ||
| consentManager: consentManager, | ||
| configManager: configManager, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -252,7 +256,7 @@ func (i *initAction) Run(ctx context.Context) (*actions.ActionResult, error) { | |
| initTypeSelect = initEnvironment | ||
| } else { | ||
| // Prompt for init type for new projects | ||
| initTypeSelect, err = promptInitType(i.console, ctx, i.featuresManager) | ||
| initTypeSelect, err = promptInitType(i.console, ctx, i.featuresManager, i.configManager) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
@@ -590,15 +594,16 @@ const ( | |
| initWithAgent | ||
| ) | ||
|
|
||
| func promptInitType(console input.Console, ctx context.Context, featuresManager *alpha.FeatureManager) (initType, error) { | ||
| func promptInitType( | ||
| console input.Console, | ||
| ctx context.Context, | ||
| featuresManager *alpha.FeatureManager, | ||
| configManager config.UserConfigManager, | ||
| ) (initType, error) { | ||
| options := []string{ | ||
| "Scan current directory", // This now covers minimal project creation too | ||
| "Select a template", | ||
| } | ||
|
|
||
| // Only include AZD agent option if the LLM feature is enabled | ||
| if featuresManager.IsEnabled(llm.FeatureLlm) { | ||
| options = append(options, fmt.Sprintf("Use agent mode %s", color.YellowString("(Alpha)"))) | ||
| fmt.Sprintf("Use agent mode %s", color.YellowString("(Alpha)")), | ||
| } | ||
|
|
||
| selection, err := console.Select(ctx, input.ConsoleOptions{ | ||
|
|
@@ -615,11 +620,35 @@ func promptInitType(console input.Console, ctx context.Context, featuresManager | |
| case 1: | ||
| return initAppTemplate, nil | ||
| case 2: | ||
| // Only return initWithCopilot if the LLM feature is enabled and we have 3 options | ||
| if featuresManager.IsEnabled(llm.FeatureLlm) { | ||
| return initWithAgent, nil | ||
| if !featuresManager.IsEnabled(llm.FeatureLlm) { | ||
| azdConfig, err := configManager.Load() | ||
| if err != nil { | ||
| return initUnknown, fmt.Errorf("failed to load config: %w", err) | ||
| } | ||
|
|
||
| err = azdConfig.Set("alpha.llm", "on") | ||
| if err != nil { | ||
| return initUnknown, fmt.Errorf("failed to set alpha.llm config: %w", err) | ||
| } | ||
|
|
||
| err = configManager.Save(azdConfig) | ||
| if err != nil { | ||
| return initUnknown, fmt.Errorf("failed to save config: %w", err) | ||
| } | ||
|
|
||
| console.Message(ctx, "\nThe azd agent feature has been enabled to support this new experience."+ | ||
| " To turn off in the future run `azd config unset alpha.llm`.") | ||
|
|
||
| err = azdConfig.Set("ai.agent.model.type", "github-copilot") | ||
| if err != nil { | ||
| return initUnknown, fmt.Errorf("failed to set ai.agent.model.type config: %w", err) | ||
| } | ||
|
Comment on lines
+642
to
+645
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be called before calling I don't see a new call to save the config after this, so the setting might be applied only on memory but not persisted? |
||
|
|
||
| console.Message(ctx, "\nGitHub Copilot has been enabled to support this new experience."+ | ||
| " To turn off in the future run `azd config unset ai.agent.model.type`.") | ||
| } | ||
| fallthrough | ||
|
|
||
| return initWithAgent, nil | ||
| default: | ||
| panic("unhandled selection") | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.