Introduce new `agent` command that scans .go files in the project, generates an AI-driven plan for changes based on user instruction, and applies edits with previews and backups. Includes integration with Grok client for planning and content generation. Update existing files with timestamp comments as part of the agent's editing demonstration. Add agentCmd to root command.
34 lines
876 B
Go
34 lines
876 B
Go
// Updated at current time: 2023-10-05 14:32:00 UTC
|
|
|
|
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 := git.Run([]string{"log", "--oneline", "-10"})
|
|
if log == "" {
|
|
color.Yellow("No commits found.")
|
|
return
|
|
}
|
|
|
|
modelFlag, _ := cmd.Flags().GetString("model")
|
|
model := config.GetModel(modelFlag)
|
|
|
|
client := grok.NewClient()
|
|
messages := []map[string]string{
|
|
{"role": "system", "content": "Summarize the recent git history in 3-5 bullet points."},
|
|
{"role": "user", "content": log},
|
|
}
|
|
color.Yellow("Summarizing recent commits...")
|
|
client.Stream(messages, model)
|
|
},
|
|
} |