| package commands |
| |
| import ( |
| "fmt" |
| |
| "github.com/spf13/cobra" |
| ) |
| |
| var configCheckCmd = &cobra.Command{ |
| Use: "config-check", |
| Short: "Check configuration validity", |
| Long: `Check the current configuration for errors and display settings. |
| |
| Examples: |
| staff config-check`, |
| RunE: runConfigCheck, |
| } |
| |
| func runConfigCheck(cmd *cobra.Command, args []string) error { |
| fmt.Println("Configuration Check:") |
| fmt.Println("==================") |
| |
| // Check OpenAI configuration |
| if cfg.OpenAI.APIKey == "" { |
| fmt.Println("❌ OpenAI API key is missing") |
| } else { |
| fmt.Printf("✅ OpenAI API key configured (ends with: ...%s)\n", cfg.OpenAI.APIKey[len(cfg.OpenAI.APIKey)-4:]) |
| } |
| |
| if cfg.OpenAI.BaseURL == "" { |
| fmt.Println("ℹ️ OpenAI Base URL using default") |
| } else { |
| fmt.Printf("ℹ️ OpenAI Base URL: %s\n", cfg.OpenAI.BaseURL) |
| } |
| |
| // Check Git provider configuration |
| fmt.Printf("\nGit Provider: %s\n", cfg.GetPrimaryGitProvider()) |
| |
| // Check GitHub configuration |
| if cfg.HasGitHubConfig() { |
| fmt.Printf("✅ GitHub configured (ends with: ...%s)\n", cfg.GitHub.Token[len(cfg.GitHub.Token)-4:]) |
| fmt.Printf(" Owner: %s, Repo: %s\n", cfg.GitHub.Owner, cfg.GitHub.Repo) |
| } else if cfg.GitHub.Token != "" || cfg.GitHub.Owner != "" || cfg.GitHub.Repo != "" { |
| fmt.Println("⚠️ GitHub partially configured (incomplete)") |
| } |
| |
| // Check Gerrit configuration |
| if cfg.HasGerritConfig() { |
| fmt.Printf("✅ Gerrit configured (user: %s)\n", cfg.Gerrit.Username) |
| fmt.Printf(" Base URL: %s, Project: %s\n", cfg.Gerrit.BaseURL, cfg.Gerrit.Project) |
| } else if cfg.Gerrit.Username != "" || cfg.Gerrit.BaseURL != "" || cfg.Gerrit.Project != "" { |
| fmt.Println("⚠️ Gerrit partially configured (incomplete)") |
| } |
| |
| if !cfg.HasGitHubConfig() && !cfg.HasGerritConfig() { |
| fmt.Println("❌ No Git provider configured (need GitHub or Gerrit)") |
| } |
| |
| // Check agents configuration |
| fmt.Printf("\nAgents: %d configured\n", len(cfg.Agents)) |
| for i, agent := range cfg.Agents { |
| temp := 0.7 |
| if agent.Temperature != nil { |
| temp = *agent.Temperature |
| } |
| fmt.Printf(" %d. %s (model: %s, temp: %.1f)\n", i+1, agent.Name, agent.Model, temp) |
| } |
| |
| // Check task manager |
| if taskManager == nil { |
| fmt.Println("❌ Task manager not initialized") |
| } else { |
| fmt.Println("✅ Task manager initialized") |
| } |
| |
| // Check agent manager |
| if agentManager == nil { |
| fmt.Println("❌ Agent manager not initialized") |
| } else { |
| fmt.Println("✅ Agent manager initialized") |
| } |
| |
| fmt.Println("\nConfiguration check complete!") |
| return nil |
| } |