grokkit/cmd/review.go
Greg Gauthier f0322a84bd
Some checks failed
CI / Test (push) Successful in 33s
CI / Lint (push) Failing after 17s
CI / Build (push) Successful in 21s
chore(lint): enhance golangci configuration and add security annotations
- Expand .golangci.yml with more linters (bodyclose, errcheck, etc.), settings for govet, revive, gocritic, gosec
- Add // nolint:gosec comments for intentional file operations and subprocesses
- Change file write permissions from 0644 to 0600 for better security
- Refactor loops, error handling, and test parallelism with t.Parallel()
- Minor fixes: ignore unused args, use errors.Is, adjust mkdir permissions to 0750
2026-03-04 20:00:32 +00:00

44 lines
1.1 KiB
Go

package cmd
import (
"fmt"
"github.com/fatih/color"
"github.com/spf13/cobra"
"gmgauthier.com/grokkit/config"
)
var reviewCmd = &cobra.Command{
Use: "review [path]",
Short: "Review the current repository or directory",
Run: runReview,
}
func runReview(cmd *cobra.Command, _ []string) {
modelFlag, _ := cmd.Flags().GetString("model")
model := config.GetModel("review", modelFlag)
diff, err := gitRun([]string{"diff", "--no-color"})
if err != nil {
color.Red("Failed to get git diff: %v", err)
return
}
status, err := gitRun([]string{"status", "--short"})
if err != nil {
color.Red("Failed to get git status: %v", err)
return
}
client := newGrokClient()
messages := buildReviewMessages(status, diff)
color.Yellow("Grok is reviewing the repo...")
client.Stream(messages, model)
}
func buildReviewMessages(status, diff string) []map[string]string {
return []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)},
}
}