grokkit/cmd/prdescribe.go
Gregory Gauthier 24be047322
All checks were successful
CI / Test (push) Successful in 30s
CI / Lint (push) Successful in 25s
CI / Build (push) Successful in 19s
feat(config): add per-command model defaults
Introduce support for per-command model defaults in config.toml, overriding global default if set. Update GetModel to accept command name and prioritize: flag > command default > global default. Add example config file and adjust all commands to pass their name. Update tests accordingly.
2026-03-02 16:56:56 +00:00

41 lines
1.2 KiB
Go

package cmd
import (
"fmt"
"github.com/fatih/color"
"github.com/spf13/cobra"
"gmgauthier.com/grokkit/config"
"gmgauthier.com/grokkit/internal/git"
"gmgauthier.com/grokkit/internal/grok"
)
var prDescribeCmd = &cobra.Command{
Use: "pr-describe",
Short: "Generate full PR description from current branch",
Run: func(cmd *cobra.Command, args []string) {
diff, err := git.Run([]string{"diff", "main..HEAD", "--no-color"})
if err != nil || diff == "" {
diff, err = git.Run([]string{"diff", "origin/main..HEAD", "--no-color"})
if err != nil {
color.Red("Failed to get branch diff: %v", err)
return
}
}
if diff == "" {
color.Yellow("No changes on this branch compared to main/origin/main.")
return
}
modelFlag, _ := cmd.Flags().GetString("model")
model := config.GetModel("prdescribe", modelFlag)
client := grok.NewClient()
messages := []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)},
}
color.Yellow("Writing PR description...")
client.Stream(messages, model)
},
}