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
|
|
|
)
|
2026-02-28 18:28:27 +00:00
|
|
|
|
|
|
|
|
var prDescribeCmd = &cobra.Command{
|
|
|
|
|
Use: "pr-describe",
|
|
|
|
|
Short: "Generate full PR description from current branch",
|
2026-03-02 20:47:16 +00:00
|
|
|
Run: runPRDescribe,
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 18:11:28 +00:00
|
|
|
func init() {
|
|
|
|
|
prDescribeCmd.Flags().StringP("base", "b", "master", "Base branch to compare against")
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-02 20:47:16 +00:00
|
|
|
func runPRDescribe(cmd *cobra.Command, args []string) {
|
2026-03-04 18:11:28 +00:00
|
|
|
base, _ := cmd.Flags().GetString("base")
|
|
|
|
|
|
|
|
|
|
diff, err := gitRun([]string{"diff", fmt.Sprintf("%s..HEAD", base), "--no-color"})
|
2026-03-02 20:47:16 +00:00
|
|
|
if err != nil || diff == "" {
|
2026-03-04 18:11:28 +00:00
|
|
|
diff, err = gitRun([]string{"diff", fmt.Sprintf("origin/%s..HEAD", base), "--no-color"})
|
2026-03-02 20:47:16 +00:00
|
|
|
if err != nil {
|
|
|
|
|
color.Red("Failed to get branch diff: %v", err)
|
2026-02-28 19:56:23 +00:00
|
|
|
return
|
|
|
|
|
}
|
2026-03-02 20:47:16 +00:00
|
|
|
}
|
|
|
|
|
if diff == "" {
|
2026-03-04 18:11:28 +00:00
|
|
|
color.Yellow("No changes on this branch compared to %s/origin/%s.", base, base)
|
2026-03-02 20:47:16 +00:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
modelFlag, _ := cmd.Flags().GetString("model")
|
|
|
|
|
model := config.GetModel("prdescribe", modelFlag)
|
2026-02-28 20:52:03 +00:00
|
|
|
|
2026-03-02 20:47:16 +00:00
|
|
|
client := newGrokClient()
|
|
|
|
|
messages := buildPRDescribeMessages(diff)
|
|
|
|
|
color.Yellow("Writing PR description...")
|
|
|
|
|
client.Stream(messages, model)
|
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 buildPRDescribeMessages(diff string) []map[string]string {
|
|
|
|
|
return []map[string]string{
|
|
|
|
|
{"role": "system", "content": "Write a professional GitHub PR title + detailed body (changes, motivation, testing notes)."},
|
|
|
|
|
{"role": "user", "content": fmt.Sprintf("Diff:\n%s", diff)},
|
|
|
|
|
}
|
|
|
|
|
}
|