config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config manages the user's Supermodel configuration stored at ~/.supermodel/config.yaml. It handles loading, saving, and validating config values such as the API key, default output format, and API base URL.

This is a shared kernel package. It must contain no business logic. Slice packages under internal/ may import it freely.

Index

Constants

View Source
const DefaultAPIBase = "https://api.supermodeltools.com"

DefaultAPIBase is the production Supermodel API endpoint.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir returns the Supermodel config directory (~/.supermodel).

func Path

func Path() string

Path returns the full path to the config file.

Types

type Config

type Config struct {
	APIKey  string `yaml:"api_key,omitempty"`
	APIBase string `yaml:"api_base,omitempty"`
	Output  string `yaml:"output,omitempty"` // "human" | "json"
	Shards  *bool  `yaml:"shards,omitempty"`
}

Config holds user-level settings persisted at ~/.supermodel/config.yaml.

func Load

func Load() (*Config, error)

Load reads the config file. Returns defaults when the file does not exist. Environment variables override file values:

  • SUPERMODEL_API_KEY overrides api_key
  • SUPERMODEL_API_BASE overrides api_base

func (*Config) RequireAPIKey

func (c *Config) RequireAPIKey() error

RequireAPIKey returns an actionable error if no API key is configured.

func (*Config) Save

func (c *Config) Save() error

Save writes the config to disk, creating the directory if necessary. The file is written with mode 0600 (owner-readable only). Uses a tmp→rename pattern so a partial write (e.g. killed process) can never leave a corrupt config file.

func (*Config) ShardsEnabled added in v0.4.1

func (c *Config) ShardsEnabled() bool

ShardsEnabled reports whether shard mode is on. Defaults to true.

Jump to

Keyboard shortcuts

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