grokkit/cmd/history.go
Gregory Gauthier 24be047322
All checks were successful
CI / Test (push) Successful in 30s
CI / Lint (push) Successful in 25s
CI / Build (push) Successful in 19s
feat(config): add per-command model defaults
Introduce support for per-command model defaults in config.toml, overriding global default if set. Update GetModel to accept command name and prioritize: flag > command default > global default. Add example config file and adjust all commands to pass their name. Update tests accordingly.
2026-03-02 16:56:56 +00:00

37 lines
919 B
Go

package cmd
import (
"github.com/fatih/color"
"github.com/spf13/cobra"
"gmgauthier.com/grokkit/config"
"gmgauthier.com/grokkit/internal/git"
"gmgauthier.com/grokkit/internal/grok"
)
var historyCmd = &cobra.Command{
Use: "history",
Short: "Summarize recent git history",
Run: func(cmd *cobra.Command, args []string) {
log, err := git.Run([]string{"log", "--oneline", "-10"})
if err != nil {
color.Red("Failed to get git log: %v", err)
return
}
if log == "" {
color.Yellow("No commits found.")
return
}
modelFlag, _ := cmd.Flags().GetString("model")
model := config.GetModel("history", modelFlag)
client := grok.NewClient()
messages := []map[string]string{
{"role": "system", "content": "Summarize the recent git history in 3-5 bullet points."},
{"role": "user", "content": log},
}
color.Yellow("Summarizing recent commits...")
client.Stream(messages, model)
},
}