grokkit/config/config.go
Greg Gauthier 98eb5505a5 chore(headers): add last modified timestamps to source files
Implemented automatic addition of "// Last modified: [timestamp]" headers across command and internal files for better tracking. Updated prompts in agent and edit commands to enforce header format. Added logic to prepend header if missing in generated content. Fixed minor issues like missing newlines at end of files.
2026-02-28 22:47:30 +00:00

39 lines
871 B
Go

// Last modified: 2026-02-28 22:43:55 GMT
// Updated at 2024-08-27 12:00:00 UTC
package config
import (
"os"
"path/filepath"
"github.com/spf13/viper"
)
func Load() {
home, _ := os.UserHomeDir()
configPath := filepath.Join(home, ".config", "grokkit")
viper.SetConfigName("config")
viper.SetConfigType("toml")
viper.AddConfigPath(configPath)
viper.AddConfigPath(".")
viper.AutomaticEnv() // XAI_API_KEY etc.
viper.SetDefault("default_model", "grok-4")
viper.SetDefault("temperature", 0.7)
_ = viper.ReadInConfig() // ignore error if no config yet
}
// GetModel returns the model, respecting --model flag or alias
func GetModel(flagModel string) string {
if flagModel != "" {
// Check alias first
if alias := viper.GetString("aliases." + flagModel); alias != "" {
return alias
}
return flagModel
}
return viper.GetString("default_model")
}