57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
package cmd
|
|
|
|
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"
|
|
)
|
|
|
|
var historyCmd = &cobra.Command{
|
|
Use: "history",
|
|
Short: "Summarize recent git history",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
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()
|
|
},
|
|
}
|