config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidProvider indicates an unsupported embedding provider
	ErrInvalidProvider = errors.New("invalid embedding provider")

	// ErrInvalidDimensions indicates invalid embedding dimensions
	ErrInvalidDimensions = errors.New("invalid embedding dimensions")

	// ErrInvalidChunkSize indicates invalid chunk size configuration
	ErrInvalidChunkSize = errors.New("invalid chunk size")

	// ErrInvalidOverlap indicates invalid overlap configuration
	ErrInvalidOverlap = errors.New("invalid overlap")

	// ErrEmptyEndpoint indicates missing embedding endpoint
	ErrEmptyEndpoint = errors.New("empty embedding endpoint")

	// ErrEmptyModel indicates missing embedding model
	ErrEmptyModel = errors.New("empty embedding model")

	// ErrEmptyStrategy indicates missing chunking strategies
	ErrEmptyStrategy = errors.New("empty chunking strategies")
)

Functions

func Validate

func Validate(cfg *Config) error

Validate checks that the configuration is valid and complete.

Types

type ChunkingConfig

type ChunkingConfig struct {
	Strategies    []string `yaml:"strategies" mapstructure:"strategies"`           // e.g., ["symbols", "definitions", "data"]
	DocChunkSize  int      `yaml:"doc_chunk_size" mapstructure:"doc_chunk_size"`   // max tokens per doc chunk
	CodeChunkSize int      `yaml:"code_chunk_size" mapstructure:"code_chunk_size"` // max characters per code chunk
	Overlap       int      `yaml:"overlap" mapstructure:"overlap"`                 // token overlap between chunks
}

ChunkingConfig defines how content is chunked for indexing.

type Config

type Config struct {
	Embedding EmbeddingConfig `yaml:"embedding" mapstructure:"embedding"`
	Paths     PathsConfig     `yaml:"paths" mapstructure:"paths"`
	Chunking  ChunkingConfig  `yaml:"chunking" mapstructure:"chunking"`
}

Config represents the complete cortex configuration. It can be loaded from .cortex/config.yml with environment variable overrides.

func Default

func Default() *Config

Default returns a configuration with sensible defaults.

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig is a convenience function that creates a loader and loads config. It uses the current working directory as the root.

func LoadConfigFromDir

func LoadConfigFromDir(rootDir string) (*Config, error)

LoadConfigFromDir loads configuration from a specific directory.

func (*Config) ToIndexerConfig

func (c *Config) ToIndexerConfig(rootDir string) *indexer.Config

ToIndexerConfig converts a Config to an indexer.Config. The rootDir parameter specifies the root directory of the codebase to index.

type EmbeddingConfig

type EmbeddingConfig struct {
	Provider   string `yaml:"provider" mapstructure:"provider"`     // "local" or "openai"
	Model      string `yaml:"model" mapstructure:"model"`           // e.g., "BAAI/bge-small-en-v1.5"
	Dimensions int    `yaml:"dimensions" mapstructure:"dimensions"` // embedding vector dimensions
	Endpoint   string `yaml:"endpoint" mapstructure:"endpoint"`     // embedding service endpoint URL
}

EmbeddingConfig configures the embedding provider.

type Loader

type Loader interface {
	// Load loads configuration from file and environment variables.
	// Priority: defaults → config file → environment variables (env wins)
	Load() (*Config, error)
}

Loader provides configuration loading capabilities.

func NewLoader

func NewLoader(rootDir string) Loader

NewLoader creates a new configuration loader for the given root directory.

type PathsConfig

type PathsConfig struct {
	Code   []string `yaml:"code" mapstructure:"code"`     // glob patterns for code files
	Docs   []string `yaml:"docs" mapstructure:"docs"`     // glob patterns for documentation
	Ignore []string `yaml:"ignore" mapstructure:"ignore"` // glob patterns to ignore
}

PathsConfig defines which files to index and which to ignore.

Jump to

Keyboard shortcuts

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