grokkit/cmd/history.go

41 lines
938 B
Go
Raw Normal View History

2026-02-28 18:03:12 +00:00
package cmd
2026-02-28 18:28:27 +00:00
2026-02-28 19:56:23 +00:00
import (
"github.com/fatih/color"
"github.com/spf13/cobra"
"gmgauthier.com/grokkit/config"
2026-02-28 19:56:23 +00:00
)
2026-02-28 18:28:27 +00:00
var historyCmd = &cobra.Command{
Use: "history",
Short: "Summarize recent git history",
Run: runHistory,
}
func runHistory(cmd *cobra.Command, _ []string) {
log, err := gitRun([]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 := newGrokClient()
messages := buildHistoryMessages(log)
color.Yellow("Summarizing recent commits...")
client.Stream(messages, model)
}
func buildHistoryMessages(log string) []map[string]string {
return []map[string]string{
{"role": "system", "content": "Summarize the recent git history in 3-5 bullet points."},
{"role": "user", "content": log},
}
}