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 commitMsgCmd = &cobra.Command{
|
|
|
|
|
Use: "commit-msg",
|
|
|
|
|
Short: "Generate conventional commit message from staged changes",
|
2026-03-02 20:47:16 +00:00
|
|
|
Run: runCommitMsg,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func runCommitMsg(cmd *cobra.Command, args []string) {
|
|
|
|
|
diff, err := gitRun([]string{"diff", "--cached", "--no-color"})
|
|
|
|
|
if err != nil {
|
|
|
|
|
color.Red("Failed to get staged changes: %v", err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if diff == "" {
|
|
|
|
|
color.Yellow("No staged changes!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
modelFlag, _ := cmd.Flags().GetString("model")
|
|
|
|
|
model := config.GetModel("commitmsg", modelFlag)
|
2026-02-28 20:52:03 +00:00
|
|
|
|
2026-03-02 20:47:16 +00:00
|
|
|
client := newGrokClient()
|
|
|
|
|
messages := buildCommitMessages(diff)
|
|
|
|
|
color.Yellow("Generating commit message...")
|
|
|
|
|
client.Stream(messages, model)
|
2026-02-28 22:59:16 +00:00
|
|
|
}
|