setting

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const KeyDefaultModel = "default_model"

Well-known setting keys.

Variables

View Source
var DefaultModels = []ModelOption{
	{Value: "haiku", Label: "Haiku"},
	{Value: "sonnet", Label: "Sonnet"},
	{Value: "opus", Label: "Opus"},
}

DefaultModels is the built-in list of Claude model options when CLAUDE_MODELS is not set.

View Source
var ErrNotFound = errors.New("setting not found")

ErrNotFound is returned when a setting key does not exist.

Functions

This section is empty.

Types

type ModelOption

type ModelOption struct {
	Value string `json:"value"`
	Label string `json:"label"`
}

ModelOption describes an available model for the UI.

func ParseModelsEnv

func ParseModelsEnv(s string) []ModelOption

ParseModelsEnv parses a comma-separated CLAUDE_MODELS environment variable into a slice of ModelOption. Each entry is "value" or "value:label". Example: "haiku,sonnet,opus" or "claude-3-haiku:Haiku,claude-3-sonnet:Sonnet".

type Repository

type Repository interface {
	UpsertSetting(ctx context.Context, key, value string) error
	ReadSetting(ctx context.Context, key string) (string, error)
	DeleteSetting(ctx context.Context, key string) error
	ListSettings(ctx context.Context) (map[string]string, error)
}

Repository defines data access for key-value settings.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides cached access to key-value settings.

func NewService

func NewService(repo Repository) *Service

NewService creates a new settings service.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, key string) error

Delete removes a setting from the database and cache.

func (*Service) Get

func (s *Service) Get(key string) string

Get returns the cached value for a key, or empty string if not set.

func (*Service) Load

func (s *Service) Load(ctx context.Context) error

Load reads all settings from the database into the cache.

func (*Service) Set

func (s *Service) Set(ctx context.Context, key, value string) error

Set writes a setting to the database and updates the cache.

Jump to

Keyboard shortcuts

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