config

package
v0.0.0-...-16efc32 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigDir           = ".grepai"
	ConfigFileName      = "config.yaml"
	IndexFileName       = "index.gob"
	SymbolIndexFileName = "symbols.gob"
)
View Source
const (
	MachineConfigFileName = "machine.yaml"
)
View Source
const (
	ProjectsConfigFileName = "projects.yaml"
)
View Source
const (
	WorkspaceConfigFileName = "workspace.yaml"
)

Variables

This section is empty.

Functions

func ContractPath

func ContractPath(absPath string) string

ContractPath replaces home directory with ~ for portability.

func Exists

func Exists(projectRoot string) bool

func ExpandPath

func ExpandPath(path string) string

ExpandPath expands ~ to the actual home directory.

func FindProjectRoot

func FindProjectRoot() (string, error)

func GenerateProjectID

func GenerateProjectID() string

GenerateProjectID generates a new UUID v4 for project identification

func GetConfigDir

func GetConfigDir(projectRoot string) string

func GetConfigPath

func GetConfigPath(projectRoot string) string

func GetGlobalConfigDir

func GetGlobalConfigDir() (string, error)

GetGlobalConfigDir returns the global grepai config directory path. ~/.grepai on Unix-like systems

func GetHomeDir

func GetHomeDir() string

GetHomeDir retourne le dossier global grepai : ~/.grepai

func GetIndexPath

func GetIndexPath(projectRoot string) string

func GetMachineConfigPath

func GetMachineConfigPath() string

GetMachineConfigPath returns the path to the machine configuration file

func GetProjectsConfigPath

func GetProjectsConfigPath() string

GetProjectsConfigPath returns the path to the projects config file. ~/.grepai/projects.yaml

func GetSymbolIndexPath

func GetSymbolIndexPath(projectRoot string) string

func GetVenvDir

func GetVenvDir() string

GetVenvDir retourne le chemin global du venv Python : ~/.grepai/venv

func GetWorkspaceConfigPath

func GetWorkspaceConfigPath() (string, error)

GetWorkspaceConfigPath returns the path to the workspace config file.

func MachineConfigExists

func MachineConfigExists() bool

MachineConfigExists returns true if the machine configuration file exists

func MaskDSN

func MaskDSN(dsn string) string

MaskDSN masks the password in a PostgreSQL DSN for display Example: postgres://user:secret@localhost:5432/db -> postgres://user:****@localhost:5432/db

func SaveMachineConfig

func SaveMachineConfig(cfg *MachineConfig) error

SaveMachineConfig saves the machine configuration to ~/.grepai/machine.yaml

func SaveProjectsConfig

func SaveProjectsConfig(cfg *ProjectsConfig) error

SaveProjectsConfig saves the projects configuration to ~/.grepai/projects.yaml.

func SaveWorkspaceConfig

func SaveWorkspaceConfig(cfg *WorkspaceConfig) error

SaveWorkspaceConfig saves the workspace configuration to ~/.grepai/workspace.yaml.

func ValidateWorkspaceBackend

func ValidateWorkspaceBackend(ws *Workspace) error

ValidateWorkspaceBackend validates that the workspace uses a supported backend. GOB backend is not supported for workspaces (file-based, can't be shared).

Types

type BoostConfig

type BoostConfig struct {
	Enabled   bool        `yaml:"enabled"`
	Penalties []BoostRule `yaml:"penalties"`
	Bonuses   []BoostRule `yaml:"bonuses"`
}

type BoostRule

type BoostRule struct {
	Pattern string  `yaml:"pattern"`
	Factor  float32 `yaml:"factor"`
}

type ChunkingConfig

type ChunkingConfig struct {
	Size    int `yaml:"size"`
	Overlap int `yaml:"overlap"`
}

type Config

type Config struct {
	Version           int            `yaml:"version"`
	ProjectID         string         `yaml:"project_id,omitempty"`
	ProjectName       string         `yaml:"project_name,omitempty"`
	Embedder          EmbedderConfig `yaml:"embedder"`
	Store             StoreConfig    `yaml:"store"`
	Chunking          ChunkingConfig `yaml:"chunking"`
	Watch             WatchConfig    `yaml:"watch"`
	Search            SearchConfig   `yaml:"search"`
	Trace             TraceConfig    `yaml:"trace"`
	Update            UpdateConfig   `yaml:"update"`
	Ignore            []string       `yaml:"ignore"`
	ExternalGitignore string         `yaml:"external_gitignore,omitempty"`
}

func DefaultConfig

func DefaultConfig() *Config

func Load

func Load(projectRoot string) (*Config, error)

func (*Config) Save

func (c *Config) Save(projectRoot string) error

type DatabaseConfig

type DatabaseConfig struct {
	DSN string `yaml:"dsn"` // PostgreSQL connection string
}

DatabaseConfig holds database connection settings

type EmbedderConfig

type EmbedderConfig struct {
	ModelPath  string `yaml:"model_path"`           // Path to E5 model directory
	Dimensions int    `yaml:"dimensions,omitempty"` // Auto-detected from worker, default 1024
}

type HybridConfig

type HybridConfig struct {
	Enabled bool    `yaml:"enabled"`
	K       float32 `yaml:"k"` // RRF constant (default: 60)
}

type MachineConfig

type MachineConfig struct {
	Version     int               `yaml:"version"`
	Database    DatabaseConfig    `yaml:"database"`
	Embedder    MachineEmbedder   `yaml:"embedder"`
	Preferences PreferencesConfig `yaml:"preferences"`
	Paths       PathsConfig       `yaml:"paths"`
}

MachineConfig holds machine-level configuration that applies to all projects. This configuration is stored in ~/.grepai/machine.yaml

func DefaultMachineConfig

func DefaultMachineConfig() *MachineConfig

DefaultMachineConfig returns a MachineConfig with sensible defaults

func LoadMachineConfig

func LoadMachineConfig() (*MachineConfig, error)

LoadMachineConfig loads the machine configuration from ~/.grepai/machine.yaml

type MachineEmbedder

type MachineEmbedder struct {
	ModelPath string `yaml:"model_path"` // Path to E5 model directory
}

MachineEmbedder holds machine-level embedder settings

type PathsConfig

type PathsConfig struct {
	Venv  string `yaml:"venv"`  // Path to Python venv
	Cache string `yaml:"cache"` // Path to cache directory
}

PathsConfig holds system paths

type PostgresConfig

type PostgresConfig struct {
	DSN string `yaml:"dsn"`
}

type PreferencesConfig

type PreferencesConfig struct {
	DefaultLimit int  `yaml:"default_limit"` // Default number of search results
	JSONOutput   bool `yaml:"json_output"`   // Default output format
}

PreferencesConfig holds user preferences

type ProjectEntry

type ProjectEntry struct {
	Name string `yaml:"name"`
	Path string `yaml:"path"`
}

ProjectEntry represents a single project within a workspace.

type ProjectStatus

type ProjectStatus string

ProjectStatus represents the indexing status of a project.

const (
	ProjectStatusIndexed    ProjectStatus = "indexed"
	ProjectStatusWatching   ProjectStatus = "watching"
	ProjectStatusNotIndexed ProjectStatus = "not indexed"
)

func GetProjectStatus

func GetProjectStatus(absPath string) ProjectStatus

GetProjectStatus returns the status of a project based on its .grepai directory.

type ProjectsConfig

type ProjectsConfig struct {
	Version  int                          `yaml:"version"`
	Projects map[string]RegisteredProject `yaml:"projects"`
	Groups   map[string][]string          `yaml:"groups,omitempty"`
}

ProjectsConfig holds global projects registry. Stored at ~/.grepai/projects.yaml

func DefaultProjectsConfig

func DefaultProjectsConfig() *ProjectsConfig

DefaultProjectsConfig returns an empty projects configuration.

func LoadProjectsConfig

func LoadProjectsConfig() (*ProjectsConfig, error)

LoadProjectsConfig loads the projects configuration from ~/.grepai/projects.yaml. Returns an empty config (not nil) if the file doesn't exist.

func (*ProjectsConfig) AddProject

func (c *ProjectsConfig) AddProject(name, absPath string) error

AddProject adds a new project to the registry. The path is stored in portable format (with ~).

func (*ProjectsConfig) FindProjectByPath

func (c *ProjectsConfig) FindProjectByPath(path string) (string, *RegisteredProject, error)

FindProjectByPath finds a project by its path (accepts both portable and absolute).

func (*ProjectsConfig) GetProject

func (c *ProjectsConfig) GetProject(name string) (*RegisteredProject, error)

GetProject returns a project by name.

func (*ProjectsConfig) ListProjects

func (c *ProjectsConfig) ListProjects() []string

ListProjects returns a sorted list of all project names.

func (*ProjectsConfig) RemoveProject

func (c *ProjectsConfig) RemoveProject(name string) error

RemoveProject removes a project from the registry.

func (*ProjectsConfig) UpdateProjectFramework

func (c *ProjectsConfig) UpdateProjectFramework(name string, framework string) error

UpdateProjectFramework updates the detected framework for a project.

func (*ProjectsConfig) UpdateProjectLanguages

func (c *ProjectsConfig) UpdateProjectLanguages(name string, languages []string) error

UpdateProjectLanguages updates the detected languages for a project.

type QdrantConfig

type QdrantConfig struct {
	Endpoint   string `yaml:"endpoint"`             // e.g., "http://localhost" or "localhost"
	Port       int    `yaml:"port,omitempty"`       // e.g., 6333
	Collection string `yaml:"collection,omitempty"` // Optional, defaults from project path
	APIKey     string `yaml:"api_key,omitempty"`    // Optional, for Qdrant Cloud
	UseTLS     bool   `yaml:"use_tls,omitempty"`    // Enable TLS (for Qdrant Cloud)
}

type RegisteredProject

type RegisteredProject struct {
	Path      string   `yaml:"path"`                // Uses ~ for portability
	Languages []string `yaml:"languages,omitempty"` // Detected languages (e.g., go, python, typescript)
	Framework string   `yaml:"framework,omitempty"` // Detected framework (e.g., react, django, gin)
	AddedAt   string   `yaml:"added_at,omitempty"`  // RFC3339 timestamp
}

RegisteredProject represents a registered project in the global registry.

type SearchConfig

type SearchConfig struct {
	Boost  BoostConfig  `yaml:"boost"`
	Hybrid HybridConfig `yaml:"hybrid"`
}

type StoreConfig

type StoreConfig struct {
	Backend  string         `yaml:"backend"` // gob | postgres | qdrant
	Postgres PostgresConfig `yaml:"postgres,omitempty"`
	Qdrant   QdrantConfig   `yaml:"qdrant,omitempty"`
}

type TraceConfig

type TraceConfig struct {
	Mode             string   `yaml:"mode"`              // fast or precise
	EnabledLanguages []string `yaml:"enabled_languages"` // File extensions to index
	ExcludePatterns  []string `yaml:"exclude_patterns"`  // Patterns to exclude
}

type UpdateConfig

type UpdateConfig struct {
	CheckOnStartup bool `yaml:"check_on_startup"` // Check for updates when running commands
}

UpdateConfig holds auto-update settings

type WatchConfig

type WatchConfig struct {
	DebounceMs    int       `yaml:"debounce_ms"`
	LastIndexTime time.Time `yaml:"last_index_time,omitempty"`
}

type Workspace

type Workspace struct {
	Name     string         `yaml:"name"`
	Store    StoreConfig    `yaml:"store"`
	Embedder EmbedderConfig `yaml:"embedder"`
	Projects []ProjectEntry `yaml:"projects"`
}

Workspace represents a multi-project workspace configuration.

type WorkspaceConfig

type WorkspaceConfig struct {
	Version    int                  `yaml:"version"`
	Workspaces map[string]Workspace `yaml:"workspaces"`
}

WorkspaceConfig holds global workspace configuration. Stored at ~/.grepai/workspace.yaml

func DefaultWorkspaceConfig

func DefaultWorkspaceConfig() *WorkspaceConfig

DefaultWorkspaceConfig returns an empty workspace configuration.

func LoadWorkspaceConfig

func LoadWorkspaceConfig() (*WorkspaceConfig, error)

LoadWorkspaceConfig loads the workspace configuration from ~/.grepai/workspace.yaml. Returns nil, nil if the file doesn't exist.

func (*WorkspaceConfig) AddProject

func (c *WorkspaceConfig) AddProject(workspaceName string, project ProjectEntry) error

AddProject adds a project to a workspace.

func (*WorkspaceConfig) AddWorkspace

func (c *WorkspaceConfig) AddWorkspace(ws Workspace) error

AddWorkspace adds a new workspace to the configuration.

func (*WorkspaceConfig) GetWorkspace

func (c *WorkspaceConfig) GetWorkspace(name string) (*Workspace, error)

GetWorkspace returns a workspace by name.

func (*WorkspaceConfig) ListWorkspaces

func (c *WorkspaceConfig) ListWorkspaces() []string

ListWorkspaces returns a list of all workspace names.

func (*WorkspaceConfig) RemoveProject

func (c *WorkspaceConfig) RemoveProject(workspaceName, projectName string) error

RemoveProject removes a project from a workspace.

func (*WorkspaceConfig) RemoveWorkspace

func (c *WorkspaceConfig) RemoveWorkspace(name string) error

RemoveWorkspace removes a workspace from the configuration.

Jump to

Keyboard shortcuts

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