2026-02-28 18:03:12 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
|
2026-03-01 23:25:31 +00:00
|
|
|
"fmt"
|
2026-02-28 18:03:12 +00:00
|
|
|
"github.com/spf13/cobra"
|
2026-02-28 19:56:23 +00:00
|
|
|
"gmgauthier.com/grokkit/config"
|
feat: add CI/CD workflows, persistent chat, shell completions, and testing
- Add Gitea CI workflow for testing, linting, and building
- Add release workflow for multi-platform builds and GitHub releases
- Implement persistent chat history with JSON storage
- Add shell completion generation for bash, zsh, fish, powershell
- Introduce custom error types and logging system
- Add interfaces for git and AI client for better testability
- Enhance config with temperature and timeout settings
- Add comprehensive unit tests for config, errors, git, grok, and logger
- Update README with installation, features, and development instructions
- Make model flag persistent across commands
- Add context timeouts to API requests
2026-03-01 12:17:22 +00:00
|
|
|
"gmgauthier.com/grokkit/internal/logger"
|
2026-03-01 23:25:31 +00:00
|
|
|
"gmgauthier.com/grokkit/internal/version"
|
2026-02-28 18:03:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var rootCmd = &cobra.Command{
|
|
|
|
|
Use: "grokkit",
|
|
|
|
|
Short: "Personal Grok / xAI command-line toolkit",
|
|
|
|
|
Long: `A fast, native Go CLI for Grok. Chat, edit files, and supercharge your git workflow.`,
|
2026-02-28 20:52:03 +00:00
|
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
|
|
|
config.Load()
|
2026-03-01 12:35:21 +00:00
|
|
|
|
|
|
|
|
// Determine log level: flag > config > default
|
|
|
|
|
logLevel := config.GetLogLevel()
|
|
|
|
|
if debug, _ := cmd.Flags().GetBool("debug"); debug {
|
|
|
|
|
logLevel = "debug"
|
|
|
|
|
}
|
|
|
|
|
if verbose, _ := cmd.Flags().GetBool("verbose"); verbose {
|
|
|
|
|
logLevel = "info"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_ = logger.Init(logLevel) // Logging is optional, don't fail if it errors
|
|
|
|
|
logger.Info("grokkit starting", "command", cmd.Name(), "log_level", logLevel)
|
2026-02-28 20:52:03 +00:00
|
|
|
},
|
2026-02-28 18:03:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Execute() {
|
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-01 23:25:31 +00:00
|
|
|
var versionCmd = &cobra.Command{
|
|
|
|
|
Use: "version",
|
|
|
|
|
Short: "Print the version information",
|
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
|
fmt.Printf("grokkit version %s (commit %s)\\n", version.Version, version.Commit)
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-28 18:03:12 +00:00
|
|
|
func init() {
|
|
|
|
|
rootCmd.AddCommand(chatCmd)
|
|
|
|
|
rootCmd.AddCommand(editCmd)
|
|
|
|
|
rootCmd.AddCommand(reviewCmd)
|
|
|
|
|
rootCmd.AddCommand(commitMsgCmd)
|
|
|
|
|
rootCmd.AddCommand(commitCmd)
|
|
|
|
|
rootCmd.AddCommand(prDescribeCmd)
|
|
|
|
|
rootCmd.AddCommand(historyCmd)
|
2026-02-28 22:29:16 +00:00
|
|
|
rootCmd.AddCommand(agentCmd)
|
feat: add CI/CD workflows, persistent chat, shell completions, and testing
- Add Gitea CI workflow for testing, linting, and building
- Add release workflow for multi-platform builds and GitHub releases
- Implement persistent chat history with JSON storage
- Add shell completion generation for bash, zsh, fish, powershell
- Introduce custom error types and logging system
- Add interfaces for git and AI client for better testability
- Enhance config with temperature and timeout settings
- Add comprehensive unit tests for config, errors, git, grok, and logger
- Update README with installation, features, and development instructions
- Make model flag persistent across commands
- Add context timeouts to API requests
2026-03-01 12:17:22 +00:00
|
|
|
rootCmd.AddCommand(completionCmd)
|
2026-03-01 23:25:31 +00:00
|
|
|
rootCmd.AddCommand(versionCmd)
|
feat: add CI/CD workflows, persistent chat, shell completions, and testing
- Add Gitea CI workflow for testing, linting, and building
- Add release workflow for multi-platform builds and GitHub releases
- Implement persistent chat history with JSON storage
- Add shell completion generation for bash, zsh, fish, powershell
- Introduce custom error types and logging system
- Add interfaces for git and AI client for better testability
- Enhance config with temperature and timeout settings
- Add comprehensive unit tests for config, errors, git, grok, and logger
- Update README with installation, features, and development instructions
- Make model flag persistent across commands
- Add context timeouts to API requests
2026-03-01 12:17:22 +00:00
|
|
|
|
|
|
|
|
// Add model flag to all commands
|
|
|
|
|
rootCmd.PersistentFlags().StringP("model", "m", "", "Grok model to use (overrides config)")
|
2026-03-01 12:35:21 +00:00
|
|
|
|
|
|
|
|
// Add logging flags
|
|
|
|
|
rootCmd.PersistentFlags().Bool("debug", false, "Enable debug logging (logs to stderr and file)")
|
|
|
|
|
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "Enable verbose logging")
|
2026-02-28 22:59:16 +00:00
|
|
|
}
|