2026-02-28 22:29:16 +00:00
|
|
|
// Current time: 2023-10-05 14:30:00
|
|
|
|
|
|
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 prDescribeCmd = &cobra.Command{
|
|
|
|
|
Use: "pr-describe",
|
|
|
|
|
Short: "Generate full PR description from current branch",
|
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2026-02-28 20:17:12 +00:00
|
|
|
diff := git.Run([]string{"diff", "main..HEAD", "--no-color"})
|
|
|
|
|
if diff == "" {
|
|
|
|
|
diff = git.Run([]string{"diff", "origin/main..HEAD", "--no-color"})
|
2026-02-28 19:56:23 +00:00
|
|
|
}
|
2026-02-28 20:17:12 +00:00
|
|
|
if diff == "" {
|
|
|
|
|
color.Yellow("No changes on this branch compared to main/origin/main.")
|
2026-02-28 19:56:23 +00:00
|
|
|
return
|
|
|
|
|
}
|
2026-02-28 20:52:03 +00:00
|
|
|
modelFlag, _ := cmd.Flags().GetString("model")
|
|
|
|
|
model := config.GetModel(modelFlag)
|
|
|
|
|
|
2026-02-28 20:17:12 +00:00
|
|
|
client := grok.NewClient()
|
2026-02-28 19:56:23 +00:00
|
|
|
messages := []map[string]string{
|
2026-02-28 20:17:12 +00:00
|
|
|
{"role": "system", "content": "Write a professional GitHub PR title + detailed body (changes, motivation, testing notes)."},
|
|
|
|
|
{"role": "user", "content": fmt.Sprintf("Diff:\n%s", diff)},
|
2026-02-28 19:56:23 +00:00
|
|
|
}
|
2026-02-28 20:17:12 +00:00
|
|
|
color.Yellow("Writing PR description...")
|
2026-02-28 20:52:03 +00:00
|
|
|
client.Stream(messages, model)
|
2026-02-28 18:28:27 +00:00
|
|
|
},
|
2026-02-28 22:29:16 +00:00
|
|
|
}
|