package cmd import ( "github.com/fatih/color" "github.com/spf13/cobra" "gmgauthier.com/grokkit/config" "gmgauthier.com/grokkit/internal/grok" ) var queryCmd = &cobra.Command{ Use: "query [question]", Short: "One-shot non-interactive query to Grok (programming focused)", Long: `Ask Grok a single technical question and get a concise, actionable answer. Default mode is factual and brief. Use --wordy for longer, more explanatory answers.`, Args: cobra.MinimumNArgs(1), Run: runQuery, } func init() { queryCmd.Flags().Bool("wordy", false, "Give a longer, more detailed answer") rootCmd.AddCommand(queryCmd) } func runQuery(cmd *cobra.Command, args []string) { wordy, _ := cmd.Flags().GetBool("wordy") question := args[0] // Use fast model by default for quick queries model := config.GetModel("query", "") client := grok.NewClient() systemPrompt := `You are Grok, a helpful and truthful AI built by xAI. Focus on programming, software engineering, and technical questions. Be concise, factual, and actionable. Include code snippets when helpful. Do not add unnecessary fluff.` if wordy { systemPrompt = `You are Grok, a helpful and truthful AI built by xAI. Give thorough, detailed, textbook-style answers to technical questions. Explain concepts clearly, include examples, and allow light humour where appropriate. Be comprehensive but still clear and well-structured.` } messages := []map[string]string{ {"role": "system", "content": systemPrompt}, {"role": "user", "content": question}, } color.Yellow("Asking Grok...") client.Stream(messages, model) }