task: task-1753636924-a1d4c708 - created
Change-Id: Ic78528c47ae38114b9b7504f1c4a76f95e93eb13
diff --git a/server/cmd/commands/root.go b/server/cmd/commands/root.go
index 088e7ff..165d109 100644
--- a/server/cmd/commands/root.go
+++ b/server/cmd/commands/root.go
@@ -1,62 +1,88 @@
package commands
import (
+ "fmt"
"log/slog"
"os"
- "os/signal"
- "syscall"
- "github.com/iomodo/staff/server"
+ "github.com/iomodo/staff/agent"
+ "github.com/iomodo/staff/config"
+ "github.com/iomodo/staff/git"
+ "github.com/iomodo/staff/tm"
+ "github.com/iomodo/staff/tm/git_tm"
"github.com/spf13/cobra"
)
// Command is an abstraction of the cobra Command
type Command = cobra.Command
+// Global variables for the MVP
+var (
+ agentManager *agent.SimpleAgentManager
+ taskManager tm.TaskManager
+ cfg *config.Config
+)
+
// Run function starts the application
func Run(args []string) error {
rootCmd.SetArgs(args)
return rootCmd.Execute()
}
-// rootCmd is a command to run the server.
+// rootCmd is the main command for Staff MVP
var rootCmd = &cobra.Command{
- Use: "server",
- Short: "Runs a server",
- Long: `Runs a server. Killing the process will stop the server`,
- RunE: serverCmdF,
+ Use: "staff",
+ Short: "Staff - AI Multi-Agent Development System",
+ Long: `Staff MVP - AI agents that autonomously handle development tasks and create GitHub PRs.
+
+Examples:
+ staff create-task "Add user authentication" --priority high --agent backend-engineer
+ staff start-agent backend-engineer
+ staff list-tasks
+ staff list-agents`,
+ PersistentPreRunE: initializeApp,
}
-func serverCmdF(_ *cobra.Command, _ []string) error {
- srv, err := runServer()
- if err != nil {
- return err
+func init() {
+ // Add all commands
+ rootCmd.AddCommand(createTaskCmd)
+ rootCmd.AddCommand(assignTaskCmd)
+ rootCmd.AddCommand(startAgentCmd)
+ rootCmd.AddCommand(stopAgentCmd)
+ rootCmd.AddCommand(listTasksCmd)
+ rootCmd.AddCommand(listAgentsCmd)
+ rootCmd.AddCommand(configCheckCmd)
+ rootCmd.AddCommand(cleanupClonesCmd)
+ rootCmd.AddCommand(versionCmd)
+}
+
+// initializeApp loads configuration and sets up managers
+func initializeApp(cmd *cobra.Command, args []string) error {
+ // Skip initialization for help and version commands
+ if cmd.Name() == "help" || cmd.Name() == "version" {
+ return nil
}
- defer srv.Shutdown()
- // wait for kill signal before attempting to gracefully shutdown
- // the running service
- interruptChan := make(chan os.Signal, 1)
- signal.Notify(interruptChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
- <-interruptChan
- return nil
-}
+ // Load configuration
+ var err error
+ cfg, err = config.LoadConfigWithEnvOverrides("config.yaml")
+ if err != nil {
+ return fmt.Errorf("failed to load config: %w", err)
+ }
-func runServer() (*server.Server, error) {
+ // Initialize task manager
logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
- Level: slog.LevelDebug,
+ Level: slog.LevelInfo,
}))
- srv, err := server.NewServer(logger)
+ gitInterface := git.DefaultGit(".")
+ taskManager = git_tm.NewGitTaskManagerWithLogger(gitInterface, ".", logger)
+
+ // Initialize agent manager
+ agentManager, err = agent.NewSimpleAgentManager(cfg, taskManager)
if err != nil {
- logger.Error(err.Error())
- return nil, err
+ return fmt.Errorf("failed to initialize agent manager: %w", err)
}
- serverErr := srv.Start()
- if serverErr != nil {
- logger.Error(serverErr.Error())
- return nil, serverErr
- }
- return srv, nil
+ return nil
}