Introduce new `agent` command that scans .go files in the project, generates an AI-driven plan for changes based on user instruction, and applies edits with previews and backups. Includes integration with Grok client for planning and content generation. Update existing files with timestamp comments as part of the agent's editing demonstration. Add agentCmd to root command.
38 lines
829 B
Go
38 lines
829 B
Go
// 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")
|
|
} |