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 (
|
|
|
|
|
"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 historyCmd = &cobra.Command{
|
|
|
|
|
Use: "history",
|
|
|
|
|
Short: "Summarize recent git history",
|
2026-03-02 20:47:16 +00:00
|
|
|
Run: runHistory,
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
func runHistory(cmd *cobra.Command, _ []string) {
|
2026-03-02 20:47:16 +00:00
|
|
|
log, err := gitRun([]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
|
|
|
|
|
}
|
2026-02-28 20:52:03 +00:00
|
|
|
|
2026-03-02 20:47:16 +00:00
|
|
|
modelFlag, _ := cmd.Flags().GetString("model")
|
|
|
|
|
model := config.GetModel("history", modelFlag)
|
2026-02-28 20:52:03 +00:00
|
|
|
|
2026-03-02 20:47:16 +00:00
|
|
|
client := newGrokClient()
|
|
|
|
|
messages := buildHistoryMessages(log)
|
|
|
|
|
color.Yellow("Summarizing recent commits...")
|
|
|
|
|
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 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},
|
|
|
|
|
}
|
|
|
|
|
}
|