- 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
41 lines
1013 B
Go
41 lines
1013 B
Go
package cmd
|
|
|
|
import (
|
|
"github.com/fatih/color"
|
|
"github.com/spf13/cobra"
|
|
"gmgauthier.com/grokkit/config"
|
|
"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) {
|
|
log, err := git.Run([]string{"log", "--oneline", "-10"})
|
|
if err != nil {
|
|
color.Red("Failed to get git log: %v", err)
|
|
return
|
|
}
|
|
if log == "" {
|
|
color.Yellow("No commits found.")
|
|
return
|
|
}
|
|
|
|
modelFlag, _ := cmd.Flags().GetString("model")
|
|
model := config.GetModel("history", modelFlag)
|
|
|
|
client := grok.NewClient()
|
|
messages := buildHistoryMessages(log)
|
|
color.Yellow("Summarizing recent commits...")
|
|
client.Stream(messages, model)
|
|
},
|
|
}
|
|
|
|
func buildHistoryMessages(log string) []map[string]string {
|
|
return []map[string]string{
|
|
{"role": "system", "content": "Summarize the recent git history in 3-5 bullet points."},
|
|
{"role": "user", "content": log},
|
|
}
|
|
}
|