| user | 5a7d60d | 2025-07-27 21:22:04 +0400 | [diff] [blame] | 1 | package commands |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "github.com/spf13/cobra" |
| 7 | ) |
| 8 | |
| 9 | var configCheckCmd = &cobra.Command{ |
| 10 | Use: "config-check", |
| 11 | Short: "Check configuration validity", |
| 12 | Long: `Check the current configuration for errors and display settings. |
| 13 | |
| 14 | Examples: |
| 15 | staff config-check`, |
| 16 | RunE: runConfigCheck, |
| 17 | } |
| 18 | |
| 19 | func runConfigCheck(cmd *cobra.Command, args []string) error { |
| 20 | fmt.Println("Configuration Check:") |
| 21 | fmt.Println("==================") |
| 22 | |
| 23 | // Check OpenAI configuration |
| 24 | if cfg.OpenAI.APIKey == "" { |
| 25 | fmt.Println("❌ OpenAI API key is missing") |
| 26 | } else { |
| 27 | fmt.Printf("✅ OpenAI API key configured (ends with: ...%s)\n", cfg.OpenAI.APIKey[len(cfg.OpenAI.APIKey)-4:]) |
| 28 | } |
| 29 | |
| 30 | if cfg.OpenAI.BaseURL == "" { |
| 31 | fmt.Println("ℹ️ OpenAI Base URL using default") |
| 32 | } else { |
| 33 | fmt.Printf("ℹ️ OpenAI Base URL: %s\n", cfg.OpenAI.BaseURL) |
| 34 | } |
| 35 | |
| iomodo | 578f504 | 2025-07-28 20:46:02 +0400 | [diff] [blame] | 36 | // Check Git provider configuration |
| 37 | fmt.Printf("\nGit Provider: %s\n", cfg.GetPrimaryGitProvider()) |
| iomodo | 13a10fc | 2025-07-31 17:47:06 +0400 | [diff] [blame] | 38 | |
| user | 5a7d60d | 2025-07-27 21:22:04 +0400 | [diff] [blame] | 39 | // Check GitHub configuration |
| iomodo | 578f504 | 2025-07-28 20:46:02 +0400 | [diff] [blame] | 40 | if cfg.HasGitHubConfig() { |
| 41 | fmt.Printf("✅ GitHub configured (ends with: ...%s)\n", cfg.GitHub.Token[len(cfg.GitHub.Token)-4:]) |
| 42 | fmt.Printf(" Owner: %s, Repo: %s\n", cfg.GitHub.Owner, cfg.GitHub.Repo) |
| 43 | } else if cfg.GitHub.Token != "" || cfg.GitHub.Owner != "" || cfg.GitHub.Repo != "" { |
| 44 | fmt.Println("⚠️ GitHub partially configured (incomplete)") |
| user | 5a7d60d | 2025-07-27 21:22:04 +0400 | [diff] [blame] | 45 | } |
| iomodo | 13a10fc | 2025-07-31 17:47:06 +0400 | [diff] [blame] | 46 | |
| 47 | // Check Gerrit configuration |
| iomodo | 578f504 | 2025-07-28 20:46:02 +0400 | [diff] [blame] | 48 | if cfg.HasGerritConfig() { |
| 49 | fmt.Printf("✅ Gerrit configured (user: %s)\n", cfg.Gerrit.Username) |
| 50 | fmt.Printf(" Base URL: %s, Project: %s\n", cfg.Gerrit.BaseURL, cfg.Gerrit.Project) |
| 51 | } else if cfg.Gerrit.Username != "" || cfg.Gerrit.BaseURL != "" || cfg.Gerrit.Project != "" { |
| 52 | fmt.Println("⚠️ Gerrit partially configured (incomplete)") |
| user | 5a7d60d | 2025-07-27 21:22:04 +0400 | [diff] [blame] | 53 | } |
| iomodo | 13a10fc | 2025-07-31 17:47:06 +0400 | [diff] [blame] | 54 | |
| iomodo | 578f504 | 2025-07-28 20:46:02 +0400 | [diff] [blame] | 55 | if !cfg.HasGitHubConfig() && !cfg.HasGerritConfig() { |
| 56 | fmt.Println("❌ No Git provider configured (need GitHub or Gerrit)") |
| user | 5a7d60d | 2025-07-27 21:22:04 +0400 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | // Check agents configuration |
| 60 | fmt.Printf("\nAgents: %d configured\n", len(cfg.Agents)) |
| 61 | for i, agent := range cfg.Agents { |
| 62 | temp := 0.7 |
| 63 | if agent.Temperature != nil { |
| 64 | temp = *agent.Temperature |
| 65 | } |
| 66 | fmt.Printf(" %d. %s (model: %s, temp: %.1f)\n", i+1, agent.Name, agent.Model, temp) |
| 67 | } |
| 68 | |
| 69 | // Check task manager |
| 70 | if taskManager == nil { |
| 71 | fmt.Println("❌ Task manager not initialized") |
| 72 | } else { |
| 73 | fmt.Println("✅ Task manager initialized") |
| 74 | } |
| 75 | |
| 76 | // Check agent manager |
| 77 | if agentManager == nil { |
| 78 | fmt.Println("❌ Agent manager not initialized") |
| 79 | } else { |
| 80 | fmt.Println("✅ Agent manager initialized") |
| 81 | } |
| 82 | |
| 83 | fmt.Println("\nConfiguration check complete!") |
| 84 | return nil |
| iomodo | 50598c6 | 2025-07-27 22:06:32 +0400 | [diff] [blame] | 85 | } |