setup

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OllamaDefaultBaseURL = "http://localhost:11434"
)

Variables

View Source
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

func Apply(choices Choices) *config.Config

Apply produces a Config from collected choices. Defaults from config.Default fill in everything not covered by the wizard.

func GlobalConfigPath

func GlobalConfigPath() (string, error)

GlobalConfigPath returns the canonical user-level config path.

func OllamaModels

func OllamaModels(ctx context.Context, baseURL string) ([]string, error)

OllamaModels queries <baseURL>/api/tags and returns the names of the locally installed models. An empty baseURL falls back to the default.

func RepoConfigPath

func RepoConfigPath(repoRoot string) string

RepoConfigPath returns the canonical repo-level config path.

func Run

func Run(ctx context.Context, opts RunOptions) (*config.Config, error)

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

func TestConnection(ctx context.Context, name string, cfg config.ProviderConfig) error

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

func WriteConfig(path string, cfg *config.Config) error

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

func WriteRepoConfig(repoRoot string, cfg *config.Config) (gitignoreUpdated bool, err error)

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 Choices

type Choices struct {
	Provider string
	APIKey   string
	Model    string
	BaseURL  string
	Lang     string
}

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL