nub/internal/config/schema.go
Tom a97013d876 initial commit
- v 0.1.0 siehe CHANGELOG.md
2026-07-25 11:08:01 +02:00

82 lines
2.4 KiB
Go

// Package config implementiert die geschichtete Konfiguration aus
// Abschnitt 4.7: Defaults -> ~/.config/nub/config.toml -> <repo>/.nub/config.toml
// -> Umgebungsvariablen. Spätere Schicht gewinnt.
package config
import "nub/internal/llm/registry"
type Config struct {
Version int `toml:"version"`
Model ModelConfig `toml:"model"`
Endpoints []Endpoint `toml:"endpoint"`
Context ContextConfig `toml:"context"`
Skills SkillsConfig `toml:"skills"`
MCP []MCPServer `toml:"mcp"`
Profiles map[string][]string `toml:"profiles"`
Permissions PermissionsConfig `toml:"permissions"`
}
type ModelConfig struct {
Default string `toml:"default"`
Endpoint string `toml:"endpoint"`
}
type Endpoint struct {
Name string `toml:"name"`
BaseURL string `toml:"base_url"`
APIKey string `toml:"api_key"`
Caps registry.CapsOverride `toml:"caps"`
}
type ContextConfig struct {
Files []string `toml:"files"`
WalkUp bool `toml:"walk_up"`
MaxTokens int `toml:"max_tokens"`
}
type SkillsConfig struct {
Paths []string `toml:"paths"`
}
type MCPServer struct {
Name string `toml:"name"`
Command string `toml:"command"`
Args []string `toml:"args"`
URL string `toml:"url"`
Tools []string `toml:"tools"`
}
type PermissionsConfig struct {
Read string `toml:"read"`
Glob string `toml:"glob"`
Grep string `toml:"grep"`
Write string `toml:"write"`
Edit string `toml:"edit"`
Bash string `toml:"bash"`
DenyPaths []string `toml:"deny_paths"`
DenyBash []string `toml:"deny_bash"`
}
// Defaults liefert die Konfiguration, die ohne jede Config-Datei gilt.
func Defaults() Config {
return Config{
Version: 1,
Model: ModelConfig{Default: "gpt-4o", Endpoint: "openai"},
Endpoints: []Endpoint{
{Name: "openai", BaseURL: "https://api.openai.com/v1", APIKey: "env:OPENAI_API_KEY"},
},
Context: ContextConfig{
Files: []string{"AGENTS.md", "REPOMAP.md"},
WalkUp: true,
MaxTokens: 20000,
},
Skills: SkillsConfig{
Paths: []string{"~/.nub/skills", ".nub/skills"},
},
Permissions: PermissionsConfig{
Read: "auto", Glob: "auto", Grep: "auto",
Write: "auto", Edit: "auto", Bash: "auto",
DenyPaths: []string{".git/**", "**/.env", "**/id_rsa*"},
},
}
}