grokkit/cmd/review.go

28 lines
802 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 (
"fmt"
"github.com/fatih/color"
"github.com/spf13/cobra"
"gmgauthier.com/grokkit/internal/git"
"gmgauthier.com/grokkit/internal/grok"
)
2026-02-28 18:28:27 +00:00
var reviewCmd = &cobra.Command{
Use: "review [path]",
Short: "Review the current repository or directory",
Run: func(cmd *cobra.Command, args []string) {
2026-02-28 19:56:23 +00:00
client := grok.NewClient()
diff := git.Run([]string{"diff", "--no-color"})
2026-02-28 19:56:23 +00:00
status := git.Run([]string{"status", "--short"})
messages := []map[string]string{
{"role": "system", "content": "You are an expert code reviewer. Give a concise summary + 3-5 actionable improvements."},
{"role": "user", "content": fmt.Sprintf("Git status:\n%s\n\nGit diff:\n%s", status, diff)},
2026-02-28 19:56:23 +00:00
}
color.Yellow("Grok is reviewing the repo...")
client.Stream(messages, "grok-4")
2026-02-28 18:28:27 +00:00
},
}