Add Agent manager
Change-Id: Iaa68e9228165bd274f9c5be9d4320ef49a009ca8
diff --git a/server/cmd/commands/assign_task.go b/server/cmd/commands/assign_task.go
index 4bb6f75..23c0a56 100644
--- a/server/cmd/commands/assign_task.go
+++ b/server/cmd/commands/assign_task.go
@@ -40,4 +40,4 @@
fmt.Printf("Status: %s\n", task.Status)
return nil
-}
\ No newline at end of file
+}
diff --git a/server/cmd/commands/cleanup_clones.go b/server/cmd/commands/cleanup_clones.go
index 344c4f3..88467be 100644
--- a/server/cmd/commands/cleanup_clones.go
+++ b/server/cmd/commands/cleanup_clones.go
@@ -48,6 +48,6 @@
fmt.Println("✅ All agent Git clones have been cleaned up successfully!")
fmt.Println("💡 Clones will be recreated automatically when agents start working on tasks")
-
+
return nil
-}
\ No newline at end of file
+}
diff --git a/server/cmd/commands/config_check.go b/server/cmd/commands/config_check.go
index 4813ee8..ec8c894 100644
--- a/server/cmd/commands/config_check.go
+++ b/server/cmd/commands/config_check.go
@@ -78,4 +78,4 @@
fmt.Println("\nConfiguration check complete!")
return nil
-}
\ No newline at end of file
+}
diff --git a/server/cmd/commands/create_task.go b/server/cmd/commands/create_task.go
index 4bb57d9..70009e9 100644
--- a/server/cmd/commands/create_task.go
+++ b/server/cmd/commands/create_task.go
@@ -37,7 +37,7 @@
func runCreateTask(cmd *cobra.Command, args []string) error {
title := args[0]
-
+
// Validate priority
priority := tm.TaskPriority(taskPriority)
if priority != tm.PriorityLow && priority != tm.PriorityMedium && priority != tm.PriorityHigh {
@@ -74,7 +74,7 @@
fmt.Printf("Title: %s\n", task.Title)
fmt.Printf("Priority: %s\n", task.Priority)
fmt.Printf("Status: %s\n", task.Status)
-
+
// Auto-assign if assignee is specified
if taskAssignee != "" {
task.Assignee = taskAssignee
@@ -86,4 +86,4 @@
}
return nil
-}
\ No newline at end of file
+}
diff --git a/server/cmd/commands/list_agents.go b/server/cmd/commands/list_agents.go
index 7d0ac86..50c0845 100644
--- a/server/cmd/commands/list_agents.go
+++ b/server/cmd/commands/list_agents.go
@@ -48,10 +48,10 @@
temp = *agent.Temperature
}
- fmt.Printf("%-20s %-15s %-12.1f %-10s %-30s\n",
- agent.Name,
- agent.Model,
- temp,
+ fmt.Printf("%-20s %-15s %-12.1f %-10s %-30s\n",
+ agent.Name,
+ agent.Model,
+ temp,
status,
role)
}
@@ -60,4 +60,4 @@
fmt.Printf("Use 'staff stop-agent <agent-name>' to stop a running agent\n")
return nil
-}
\ No newline at end of file
+}
diff --git a/server/cmd/commands/list_tasks.go b/server/cmd/commands/list_tasks.go
index 09cc20b..3605c09 100644
--- a/server/cmd/commands/list_tasks.go
+++ b/server/cmd/commands/list_tasks.go
@@ -41,12 +41,12 @@
func runListTasks(cmd *cobra.Command, args []string) error {
// Build filter
filter := &tm.TaskFilter{}
-
+
if filterStatus != "" {
status := tm.TaskStatus(filterStatus)
filter.Status = &status
}
-
+
if filterPriority != "" {
priority := tm.TaskPriority(filterPriority)
filter.Priority = &priority
@@ -87,17 +87,17 @@
if assignee == "" {
assignee = "unassigned"
}
-
+
title := task.Title
if len(title) > 47 {
title = title[:47] + "..."
}
- fmt.Printf("%-20s %-10s %-10s %-15s %-50s\n",
- task.ID,
- string(task.Status),
- string(task.Priority),
- assignee,
+ fmt.Printf("%-20s %-10s %-10s %-15s %-50s\n",
+ task.ID,
+ string(task.Status),
+ string(task.Priority),
+ assignee,
title)
}
@@ -106,4 +106,4 @@
}
return nil
-}
\ No newline at end of file
+}
diff --git a/server/cmd/commands/root.go b/server/cmd/commands/root.go
index 165d109..63e0d8f 100644
--- a/server/cmd/commands/root.go
+++ b/server/cmd/commands/root.go
@@ -18,7 +18,7 @@
// Global variables for the MVP
var (
- agentManager *agent.SimpleAgentManager
+ agentManager *agent.Manager
taskManager tm.TaskManager
cfg *config.Config
)
@@ -75,11 +75,11 @@
Level: slog.LevelInfo,
}))
- gitInterface := git.DefaultGit(".")
- taskManager = git_tm.NewGitTaskManagerWithLogger(gitInterface, ".", logger)
+ gitInterface := git.DefaultGit("../")
+ taskManager = git_tm.NewGitTaskManagerWithLogger(gitInterface, "../", logger)
// Initialize agent manager
- agentManager, err = agent.NewSimpleAgentManager(cfg, taskManager)
+ agentManager, err = agent.NewManager(cfg, taskManager)
if err != nil {
return fmt.Errorf("failed to initialize agent manager: %w", err)
}
diff --git a/server/cmd/commands/server.go b/server/cmd/commands/server.go
new file mode 100644
index 0000000..e0b6674
--- /dev/null
+++ b/server/cmd/commands/server.go
@@ -0,0 +1,70 @@
+package commands
+
+import (
+ "fmt"
+ "log/slog"
+ "os"
+ "os/signal"
+ "syscall"
+
+ "github.com/iomodo/staff/server"
+ "github.com/spf13/cobra"
+)
+
+var serverCmd = &cobra.Command{
+ Use: "server",
+ Short: "Start the Staff server with automatic agent startup",
+ Long: `Start the Staff server which automatically loads configuration from config.yaml
+and starts all configured agents to process tasks continuously.
+
+The server will:
+- Load agent configurations from config.yaml
+- Start all configured agents in the background
+- Continuously process assigned tasks
+- Create GitHub PRs for completed tasks
+- Run until manually stopped with Ctrl+C
+
+Example:
+ staff server # Start server with default config.yaml
+ staff server --config custom.yaml # Start server with custom config`,
+ RunE: runServer,
+}
+
+var configPath string
+
+func init() {
+ serverCmd.Flags().StringVarP(&configPath, "config", "c", "config.yaml", "Path to configuration file")
+ rootCmd.AddCommand(serverCmd)
+}
+
+func runServer(cmd *cobra.Command, args []string) error {
+ // Create logger
+ logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
+ Level: slog.LevelInfo,
+ }))
+
+ // Create server instance
+ srv, err := server.NewServer(logger, configPath)
+ if err != nil {
+ return fmt.Errorf("failed to create server: %w", err)
+ }
+
+ // Start server
+ if err := srv.Start(); err != nil {
+ return fmt.Errorf("failed to start server: %w", err)
+ }
+
+ // Setup graceful shutdown
+ sigChan := make(chan os.Signal, 1)
+ signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
+
+ logger.Info("Server is running. Press Ctrl+C to stop...")
+
+ // Wait for shutdown signal
+ <-sigChan
+
+ logger.Info("Shutdown signal received, stopping server...")
+ srv.Shutdown()
+
+ return nil
+}
diff --git a/server/cmd/commands/start_agent.go b/server/cmd/commands/start_agent.go
index 8c951c8..e283e4f 100644
--- a/server/cmd/commands/start_agent.go
+++ b/server/cmd/commands/start_agent.go
@@ -81,4 +81,4 @@
fmt.Printf("Agent %s stopped\n", agentName)
return nil
-}
\ No newline at end of file
+}
diff --git a/server/cmd/commands/stop_agent.go b/server/cmd/commands/stop_agent.go
index e80d527..4f4b39a 100644
--- a/server/cmd/commands/stop_agent.go
+++ b/server/cmd/commands/stop_agent.go
@@ -28,4 +28,4 @@
fmt.Printf("Agent %s stopped successfully\n", agentName)
return nil
-}
\ No newline at end of file
+}
diff --git a/server/cmd/commands/version.go b/server/cmd/commands/version.go
index b6f2720..bbb8091 100644
--- a/server/cmd/commands/version.go
+++ b/server/cmd/commands/version.go
@@ -24,4 +24,4 @@
fmt.Printf("Built: %s\n", BuildDate)
fmt.Printf("Commit: %s\n", GitCommit)
fmt.Printf("AI Multi-Agent Development System\n")
-}
\ No newline at end of file
+}