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"
|
2026-02-28 20:52:03 +00:00
|
|
|
"gmgauthier.com/grokkit/config"
|
2026-02-28 19:56:23 +00:00
|
|
|
"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 20:52:03 +00:00
|
|
|
modelFlag, _ := cmd.Flags().GetString("model")
|
2026-03-02 16:56:56 +00:00
|
|
|
model := config.GetModel("review", modelFlag)
|
2026-02-28 20:52:03 +00:00
|
|
|
|
2026-02-28 19:56:23 +00:00
|
|
|
client := grok.NewClient()
|
2026-03-01 12:08:49 +00:00
|
|
|
diff, err := git.Run([]string{"diff", "--no-color"})
|
|
|
|
|
if err != nil {
|
|
|
|
|
color.Red("Failed to get git diff: %v", err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
status, err := git.Run([]string{"status", "--short"})
|
|
|
|
|
if err != nil {
|
|
|
|
|
color.Red("Failed to get git status: %v", err)
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-02-28 19:56:23 +00:00
|
|
|
|
feat(cmd): add AI documentation generation and command tests
- Implemented `grokkit docs` command for generating language-specific documentation comments (godoc, PEP 257, Doxygen, etc.) with previews, backups, and auto-apply option
- Extracted message builder functions for commit, history, pr-describe, and review commands
- Added comprehensive unit tests for all command message builders (commit_test.go, docs_test.go, history_test.go, lint_test.go, prdescribe_test.go, review_test.go)
- Enforced 70% test coverage threshold in CI workflow
- Added .golangci.yml configuration with linters like govet, errcheck, staticcheck
- Updated Makefile to include -race in tests and add help target
- Updated README.md with new docs command details, workflows, and quality features
- Added .claude/ to .gitignore
- Configured default model for docs command in config.go
2026-03-02 20:13:50 +00:00
|
|
|
messages := buildReviewMessages(status, diff)
|
2026-02-28 20:17:12 +00:00
|
|
|
color.Yellow("Grok is reviewing the repo...")
|
2026-02-28 20:52:03 +00:00
|
|
|
client.Stream(messages, model)
|
2026-02-28 18:28:27 +00:00
|
|
|
},
|
2026-02-28 22:59:16 +00:00
|
|
|
}
|
feat(cmd): add AI documentation generation and command tests
- Implemented `grokkit docs` command for generating language-specific documentation comments (godoc, PEP 257, Doxygen, etc.) with previews, backups, and auto-apply option
- Extracted message builder functions for commit, history, pr-describe, and review commands
- Added comprehensive unit tests for all command message builders (commit_test.go, docs_test.go, history_test.go, lint_test.go, prdescribe_test.go, review_test.go)
- Enforced 70% test coverage threshold in CI workflow
- Added .golangci.yml configuration with linters like govet, errcheck, staticcheck
- Updated Makefile to include -race in tests and add help target
- Updated README.md with new docs command details, workflows, and quality features
- Added .claude/ to .gitignore
- Configured default model for docs command in config.go
2026-03-02 20:13:50 +00:00
|
|
|
|
|
|
|
|
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)},
|
|
|
|
|
}
|
|
|
|
|
}
|