- Enhance error checking in all commands using git.Run - Refactor git helper to return errors properly - Fix README.md filename typo - Update .gitignore with additional ignores - Add fallback for config home dir - Improve request handling in grok client
40 lines
794 B
Go
40 lines
794 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func Load() {
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
// Fall back to current directory if home not found
|
|
home = "."
|
|
}
|
|
configPath := filepath.Join(home, ".config", "grokkit")
|
|
|
|
viper.SetConfigName("config")
|
|
viper.SetConfigType("toml")
|
|
viper.AddConfigPath(configPath)
|
|
viper.AddConfigPath(".")
|
|
viper.AutomaticEnv()
|
|
|
|
viper.SetDefault("default_model", "grok-4")
|
|
viper.SetDefault("temperature", 0.7)
|
|
|
|
// Config file is optional, so we ignore read errors
|
|
_ = viper.ReadInConfig()
|
|
}
|
|
|
|
func GetModel(flagModel string) string {
|
|
if flagModel != "" {
|
|
if alias := viper.GetString("aliases." + flagModel); alias != "" {
|
|
return alias
|
|
}
|
|
return flagModel
|
|
}
|
|
return viper.GetString("default_model")
|
|
}
|