blob: 67aac9b1e10e2e98e0f83ddeec1eb88f9f4c3cbe [file] [log] [blame]
user5a7d60d2025-07-27 21:22:04 +04001package commands
2
3import (
4 "fmt"
5
6 "github.com/spf13/cobra"
7)
8
9var configCheckCmd = &cobra.Command{
10 Use: "config-check",
11 Short: "Check configuration validity",
12 Long: `Check the current configuration for errors and display settings.
13
14Examples:
15 staff config-check`,
16 RunE: runConfigCheck,
17}
18
19func 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
iomodo578f5042025-07-28 20:46:02 +040036 // Check Git provider configuration
37 fmt.Printf("\nGit Provider: %s\n", cfg.GetPrimaryGitProvider())
iomodo13a10fc2025-07-31 17:47:06 +040038
user5a7d60d2025-07-27 21:22:04 +040039 // Check GitHub configuration
iomodo578f5042025-07-28 20:46:02 +040040 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)")
user5a7d60d2025-07-27 21:22:04 +040045 }
iomodo13a10fc2025-07-31 17:47:06 +040046
47 // Check Gerrit configuration
iomodo578f5042025-07-28 20:46:02 +040048 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)")
user5a7d60d2025-07-27 21:22:04 +040053 }
iomodo13a10fc2025-07-31 17:47:06 +040054
iomodo578f5042025-07-28 20:46:02 +040055 if !cfg.HasGitHubConfig() && !cfg.HasGerritConfig() {
56 fmt.Println("❌ No Git provider configured (need GitHub or Gerrit)")
user5a7d60d2025-07-27 21:22:04 +040057 }
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
iomodo50598c62025-07-27 22:06:32 +040085}