Documentation
¶
Index ¶
- Constants
- Variables
- func Apply(choices Choices) *config.Config
- func GlobalConfigPath() (string, error)
- func OllamaModels(ctx context.Context, baseURL string) ([]string, error)
- func RepoConfigPath(repoRoot string) string
- func Run(ctx context.Context, opts RunOptions) (*config.Config, error)
- func TestConnection(ctx context.Context, name string, cfg config.ProviderConfig) error
- func WriteConfig(path string, cfg *config.Config) error
- func WriteRepoConfig(repoRoot string, cfg *config.Config) (gitignoreUpdated bool, err error)
- type Choices
- type ProviderSpec
- type RunOptions
Constants ¶
const (
OllamaDefaultBaseURL = "http://localhost:11434"
)
Variables ¶
var DefaultSpecs = []ProviderSpec{ { Name: "anthropic", Label: "Anthropic (Claude)", NeedsKey: true, Models: []string{"claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"}, APIKeyHelp: "Get an API key from https://console.anthropic.com/", }, { Name: "openai", Label: "OpenAI (GPT)", NeedsKey: true, Models: []string{"gpt-4o", "gpt-4o-mini"}, APIKeyHelp: "Get an API key from https://platform.openai.com/", }, { Name: "gemini", Label: "Google Gemini", NeedsKey: true, Models: []string{"gemini-2.5-pro", "gemini-2.5-flash", "gemini-1.5-flash"}, APIKeyHelp: "Get an API key from https://aistudio.google.com/", }, { Name: "ollama", Label: "Ollama (local, no API key needed)", NeedsURL: true, }, }
DefaultSpecs lists the providers shown in the wizard. The Models slice is the user-facing static list; for Ollama (NeedsURL=true) the models are discovered dynamically via OllamaModels.
Functions ¶
func Apply ¶
Apply produces a Config from collected choices. Defaults from config.Default fill in everything not covered by the wizard.
func GlobalConfigPath ¶
GlobalConfigPath returns the canonical user-level config path.
func OllamaModels ¶
OllamaModels queries <baseURL>/api/tags and returns the names of the locally installed models. An empty baseURL falls back to the default.
func RepoConfigPath ¶
RepoConfigPath returns the canonical repo-level config path.
func Run ¶
Run drives the interactive wizard via huh. The terminal must support a TTY; callers should branch on non-TTY environments before invoking. Returns the final config (already persisted to disk per opts).
func TestConnection ¶
TestConnection instantiates the named provider with cfg and runs its TestConnection method. Errors flow through wrapped (provider sentinels preserved); a nil error means the credentials reached the backend and got a non-error response.
func WriteConfig ¶
WriteConfig serializes cfg to YAML at path. Parent directory is created with 0700 (config may contain API keys). Write is atomic: temp + rename.
func WriteRepoConfig ¶
WriteRepoConfig saves cfg under <repoRoot>/.commitbrief/config.yml and makes sure the repo's .gitignore excludes the .commitbrief/ directory. Returns whether .gitignore was modified so callers can surface a notice.
Types ¶
type ProviderSpec ¶
type ProviderSpec struct {
Name string
Label string
NeedsKey bool
NeedsURL bool
Models []string
APIKeyHelp string
}
func FindSpec ¶
func FindSpec(name string) *ProviderSpec
type RunOptions ¶
type RunOptions struct {
Local bool
RepoRoot string
GlobalPath string
// Specs overrides DefaultSpecs (test injection).
Specs []ProviderSpec
}