grokkit/cmd/history.go

57 lines
1.1 KiB
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 (
"fmt"
"os"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"gmgauthier.com/grokkit/internal/git"
"gmgauthier.com/grokkit/internal/grok"
)
2026-02-28 18:28:27 +00:00
var historyCmd = &cobra.Command{
Use: "history",
Short: "Summarize recent git history",
Run: func(cmd *cobra.Command, args []string) {
2026-02-28 19:56:23 +00:00
model := viper.GetString("model")
client := grok.NewClient()
if !git.IsRepo() {
color.Red("Error: Not inside a git repository")
os.Exit(1)
}
logOutput := git.Run([]string{"log", "--oneline", "-10"})
if logOutput == "" {
color.Red("Error: No git history found.")
os.Exit(1)
}
systemPrompt := `You are a git workflow expert.
Summarize the recent git history:
- Key changes and themes
- Potential issues or todos
- Suggestions for next steps or refactoring
Format as bullet points.`
messages := []map[string]string{
{"role": "system", "content": systemPrompt},
{"role": "user", "content": logOutput},
}
summary := client.Stream(messages, model)
fmt.Println(color.YellowString("📜 Git History Summary:"))
fmt.Println()
fmt.Print(color.CyanString(summary))
fmt.Println()
2026-02-28 18:28:27 +00:00
},
}