-
Notifications
You must be signed in to change notification settings - Fork 8k
feature: interactive setup wizard #14
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
Closed
Closed
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
6fad2f6
fix: typo
l0gicgate 25bac47
fix: add initialization logic for setup dialog
l0gicgate 92fac03
fix: split out bedrock models
l0gicgate 1a99269
feat: add setup complete and update logic
l0gicgate eff2322
feat: add setup dialog
l0gicgate d4648c2
fix: sort models by alphabetical order
l0gicgate 735ddc5
fix: add api key validation & blinking
l0gicgate 98de5ba
refactor: extract setup in module
l0gicgate 08df5ec
fix: tweak styles
l0gicgate 63d45c4
refactor: render help
l0gicgate 3a68df5
fix: q -> s
l0gicgate cdd2299
Merge branch 'sst:dev' into feature/setup-dialog
l0gicgate 455e5c1
fix: move model/provider utils
l0gicgate 71b017c
fix: show setup dialog again after quit attempt
l0gicgate 4e47ad6
refactor: use simple-list component
l0gicgate 90808bb
Merge branch 'dev' into feature/setup-dialog
l0gicgate 6110a0c
fix: show setup dialog when no selected in quit dialog
l0gicgate d18e33b
fix: remove debug
l0gicgate 5a2c093
fix: temporarily disable bedrock and vertex
l0gicgate eea5e42
fix: tweak list styling
l0gicgate 2dd9692
fix: reinitialize model dialog after setup
l0gicgate 7d53155
Merge branch 'sst:dev' into feature/setup-dialog
l0gicgate 9e274d0
fix: move setup initialization
l0gicgate f417494
Merge branch 'sst:dev' into feature/setup-dialog
l0gicgate d55d7af
Merge branch 'dev' into feature/setup-dialog
l0gicgate fabf639
fix: auto initialize project
l0gicgate 9b81d7b
fix: auto initialize project
l0gicgate 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
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
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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package agent | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "github.com/sst/opencode/internal/config" | ||
| "github.com/sst/opencode/internal/llm/models" | ||
| "github.com/sst/opencode/internal/llm/provider" | ||
| "github.com/sst/opencode/internal/message" | ||
| ) | ||
|
|
||
| type setupAgent struct { | ||
| } | ||
|
|
||
| func NewSetupAgent() (Service, error) { | ||
| agent := &setupAgent{} | ||
|
|
||
| return agent, nil | ||
| } | ||
|
|
||
| func (a *setupAgent) Cancel(sessionID string) { | ||
|
|
||
| } | ||
|
|
||
| func (a *setupAgent) IsBusy() bool { | ||
| return true | ||
| } | ||
|
|
||
| func (a *setupAgent) IsSessionBusy(sessionID string) bool { | ||
| return true | ||
| } | ||
|
|
||
| func (a *setupAgent) Run(ctx context.Context, sessionID string, content string, attachments ...message.Attachment) (<-chan AgentEvent, error) { | ||
| return nil, ErrSessionBusy | ||
| } | ||
|
|
||
| func (a *setupAgent) GetUsage(ctx context.Context, sessionID string) (*int64, error) { | ||
| usage := int64(0) | ||
|
|
||
| return &usage, nil | ||
| } | ||
|
|
||
| func (a *setupAgent) EstimateContextWindowUsage(ctx context.Context, sessionID string) (float64, bool, error) { | ||
| return 0, false, nil | ||
| } | ||
|
|
||
| func (a *setupAgent) TrackUsage(ctx context.Context, sessionID string, model models.Model, usage provider.TokenUsage) error { | ||
| return nil | ||
| } | ||
|
|
||
| func (a *setupAgent) Update(agentName config.AgentName, modelID models.ModelID) (models.Model, error) { | ||
| return models.Model{}, fmt.Errorf("cannot change model while processing requests") | ||
| } | ||
|
|
||
| func (a *setupAgent) CompactSession(ctx context.Context, sessionID string, force bool) error { | ||
| return nil | ||
| } | ||
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
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 |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package setup | ||
|
|
||
| import ( | ||
| "github.com/sst/opencode/internal/config" | ||
| "github.com/sst/opencode/internal/llm/models" | ||
| "log/slog" | ||
| ) | ||
|
|
||
| // Global variable to track if setup is complete | ||
| var setupComplete = false | ||
|
|
||
| // IsSetupComplete checks if the setup is complete | ||
| func IsSetupComplete() bool { | ||
| return setupComplete | ||
| } | ||
|
|
||
| func markSetupComplete() { | ||
| setupComplete = true | ||
| } | ||
|
|
||
| func Init() { | ||
| cfg := config.Get() | ||
| if cfg == nil || len(cfg.Agents) < 1 { | ||
| return | ||
| } | ||
|
|
||
| // Ensure primary agent is set | ||
| _, exists := cfg.Agents[config.AgentPrimary] | ||
| if exists { | ||
| markSetupComplete() | ||
| } | ||
| } | ||
|
|
||
| func CompleteSetup(provider models.ModelProvider, model models.Model, apiKey string) { | ||
| err := config.Update(func(cfg *config.Config) { | ||
| // Add Agent | ||
| if cfg.Agents == nil { | ||
| cfg.Agents = make(map[config.AgentName]config.Agent) | ||
| } | ||
| cfg.Agents[config.AgentPrimary] = config.Agent{ | ||
| Model: model.ID, | ||
| MaxTokens: model.DefaultMaxTokens, | ||
| } | ||
| cfg.Agents[config.AgentTitle] = config.Agent{ | ||
| Model: model.ID, | ||
| MaxTokens: 80, | ||
| } | ||
| cfg.Agents[config.AgentTask] = config.Agent{ | ||
| Model: model.ID, | ||
| MaxTokens: model.DefaultMaxTokens, | ||
| } | ||
|
|
||
| // Add Provider | ||
| if cfg.Providers == nil { | ||
| cfg.Providers = make(map[models.ModelProvider]config.Provider) | ||
| } | ||
|
|
||
| cfg.Providers[provider] = config.Provider{ | ||
| APIKey: apiKey, | ||
| } | ||
| }) | ||
|
|
||
| if err != nil { | ||
| slog.Debug("Failed to complete setup", "error", err) | ||
| panic(err) | ||
| } | ||
|
|
||
| markSetupComplete() | ||
| } |
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.