Documentation
¶
Overview ¶
Package profile manages named provider/model configuration profiles stored globally in ~/.cloop/profiles.yaml.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply overlays the non-empty fields from p onto cfg. Provider and Model override the top-level config fields. BaseURL and APIKey are applied to the matching provider sub-config.
func GetActive ¶
func GetActive() string
GetActive returns the name of the active profile, or "" if none is set.
func SaveProfiles ¶
SaveProfiles writes the profiles slice to ~/.cloop/profiles.yaml.
The write is atomic — data is staged in a sibling .tmp file, fsynced, then renamed into place. profiles.yaml may contain API keys, so a torn write (crash, ENOSPC, or two cloop instances saving simultaneously) would silently drop credentials and break every profile-driven run until the user re-pasted them.
func SetActive ¶
SetActive writes the active profile name to ~/.cloop/active_profile. Pass "" to clear the active profile.
The write is atomic and serialised — a partial write here would resolve to the wrong profile (or none) on the next run, silently swapping which API key/model gets used.
func Upsert ¶
Upsert adds a new profile or replaces an existing one with the same name.
The load → modify → save cycle runs under profilesMu so two concurrent Upsert calls in the same process can't read the same baseline and drop one of the writes. Cross-process safety still relies on the atomic rename in saveProfilesLocked.
Types ¶
type Profile ¶
type Profile struct {
Name string `yaml:"name"`
Provider string `yaml:"provider,omitempty"`
Model string `yaml:"model,omitempty"`
BaseURL string `yaml:"base_url,omitempty"`
APIKey string `yaml:"api_key,omitempty"`
Description string `yaml:"description,omitempty"`
}
Profile is a named set of provider/model configuration overrides.
func LoadProfiles ¶
LoadProfiles reads all profiles from ~/.cloop/profiles.yaml. Returns an empty slice (not an error) if the file does not exist.
Reads don't take profilesMu — the atomic-rename writers always present a complete file, so a concurrent reader sees either the previous version or the new one, never a torn one.