Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config loads hmm's set-it-once configuration file — provider, model, and provider keys, so a plain `hmm "question"` needs no flags and no env vars. Precedence lives in the CLI: flag > env > this file > built-in defaults.

The file is a deliberately tiny TOML subset — flat `key = value` lines with strings, integers, booleans, and # comments. No tables, no arrays: hmm's config is flat, and an unknown key is an error naming the line, not a silently ignored typo.

Index

Constants

View Source
const Template = `` /* 891-byte string literal not displayed */

Template is what `hmm config init` writes: everything commented, one of each kind, ready to edit.

Variables

This section is empty.

Functions

func Init

func Init(path string) (bool, error)

Init writes Template to path with 0600 permissions, refusing to overwrite an existing file. Returns whether it wrote.

func Path

func Path() (string, error)

Path is the config file hmm reads: $HMM_CONFIG (legacy $BOBINA_CONFIG), else ~/.config/hmm/config.toml — falling back to the pre-rename ~/.config/bobina/config.toml when only that exists.

func SetModel

func SetModel(path, provider, model string) error

SetModel persists `<provider>_model = "model"` with a targeted edit: the existing line (commented or not) is replaced in place, everything else in the file — comments, other keys — is left byte-identical. A missing file becomes a minimal one (0600).

Types

type Config

type Config struct {
	Provider     string
	Model        string // global fallback for any provider
	SystemAppend string // --system: appended to the default prompt
	MaxSteps     int    // 0 keeps weft's default
	Sequential   bool
	Yolo         bool

	AnthropicModel string // per-provider model; beats Model for that
	OpenAIModel    string // provider, so a default for one never
	GoogleModel    string // leaks into another (a config for kimi
	ZaiModel       string // must not name kimi-latest to z.ai)
	KimiModel      string

	AnthropicKey string
	OpenAIKey    string
	GoogleKey    string
	ZaiKey       string
	KimiKey      string
}

Config is the parsed file. Zero values mean "not set" — the caller falls through to the next precedence source.

func Load

func Load() (Config, string, error)

Load reads the config file. A missing file is an empty config, not an error; anything else wrong with it is.

func (Config) Insecure

func (c Config) Insecure(path string) bool

Insecure reports whether the file holds keys and is readable beyond its owner.

func (Config) KeyFor

func (c Config) KeyFor(provider string) string

KeyFor returns the file's key for a provider ("", when unset).

func (Config) ModelFor

func (c Config) ModelFor(provider string) string

ModelFor returns the file's model for a provider: the provider's own key when set, else the global Model, else "" (fall through).

Jump to

Keyboard shortcuts

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