config

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config provides cross-platform configuration path management. It follows platform conventions:

  • macOS: ~/Library/Application Support/Aster
  • Linux: ~/.config/aster (XDG_CONFIG_HOME)
  • Windows: %APPDATA%/Aster

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() string

CacheDir returns the cache directory. This is for temporary data that can be safely deleted.

func ConfigDir

func ConfigDir() string

ConfigDir returns the configuration directory. This is where config.yaml, recipes, and extensions are stored.

func ConfigFile

func ConfigFile() string

ConfigFile returns the path to the main configuration file.

func DataDir

func DataDir() string

DataDir returns the data directory. This is where sessions, memories, and persistent data are stored.

func DatabaseFile

func DatabaseFile() string

DatabaseFile returns the path to the SQLite database file.

func EnsureAllDirs

func EnsureAllDirs() error

EnsureAllDirs creates all necessary directories.

func EnsureDir

func EnsureDir(path string) error

EnsureDir creates a directory if it doesn't exist.

func ExtensionsDir

func ExtensionsDir() string

ExtensionsDir returns the path to the extensions directory.

func LoadDefault

func LoadDefault() (*types.AgentConfig, error)

LoadDefault 从默认位置加载配置 查找顺序: 1. ./agent.yaml 2. ./config/agent.yaml 3. ~/.aster/agent.yaml

func LogDir

func LogDir() string

LogDir returns the log directory.

func MemoriesDir

func MemoriesDir() string

MemoriesDir returns the path to the memories directory.

func MergeConfigs

func MergeConfigs(base *types.AgentConfig, overlays ...*types.AgentConfig) *types.AgentConfig

MergeConfigs 合并多个配置(后面的覆盖前面的)

func MustLoad

func MustLoad(path string) *types.AgentConfig

MustLoad 必须成功加载配置,否则 panic

func ProjectConfigFile

func ProjectConfigFile(startDir string) string

ProjectConfigFile returns the path to project-level config file. It searches from the current directory upward for .aster/config.yaml

func RecipesDir

func RecipesDir() string

RecipesDir returns the path to the recipes directory.

func ResolveConfigFile

func ResolveConfigFile(workDir string) string

ResolveConfigFile returns the effective config file path. Priority: project config > global config

func SessionsDir

func SessionsDir() string

SessionsDir returns the path to the sessions directory.

Types

type Loader

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

Loader YAML 配置加载器 支持从文件加载配置,并展开环境变量

func NewLoader

func NewLoader(opts ...LoaderOption) *Loader

NewLoader 创建配置加载器

func (*Loader) LoadAgentConfig

func (l *Loader) LoadAgentConfig(path string) (*types.AgentConfig, error)

LoadAgentConfig 从文件加载 AgentConfig

func (*Loader) LoadFromString

func (l *Loader) LoadFromString(content string, v any) error

LoadFromString 从字符串加载配置

func (*Loader) LoadModelConfig

func (l *Loader) LoadModelConfig(path string) (*types.ModelConfig, error)

LoadModelConfig 从文件加载 ModelConfig

type LoaderOption

type LoaderOption func(*Loader)

LoaderOption 加载器选项

func WithEnvExpansion

func WithEnvExpansion(enabled bool) LoaderOption

WithEnvExpansion 启用环境变量展开

func WithEnvPrefix

func WithEnvPrefix(prefix string) LoaderOption

WithEnvPrefix 设置环境变量前缀

func WithVariables

func WithVariables(vars map[string]string) LoaderOption

WithVariables 设置自定义变量

Jump to

Keyboard shortcuts

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