task: task-1753636924-a1d4c708 - created

Change-Id: Ic78528c47ae38114b9b7504f1c4a76f95e93eb13
diff --git a/server/cmd/commands/start_agent.go b/server/cmd/commands/start_agent.go
new file mode 100644
index 0000000..8c951c8
--- /dev/null
+++ b/server/cmd/commands/start_agent.go
@@ -0,0 +1,84 @@
+package commands
+
+import (
+	"context"
+	"fmt"
+	"os"
+	"os/signal"
+	"syscall"
+	"time"
+
+	"github.com/spf13/cobra"
+)
+
+var startAgentCmd = &cobra.Command{
+	Use:   "start-agent [agent-name]",
+	Short: "Start an agent to process tasks",
+	Long: `Start a specific agent to continuously process assigned tasks.
+
+The agent will:
+1. Check for assigned tasks every 30 seconds
+2. Process tasks using the configured LLM
+3. Create GitHub PRs for solutions
+4. Mark tasks as completed
+
+Examples:
+  staff start-agent backend-engineer
+  staff start-agent frontend-engineer`,
+	Args: cobra.ExactArgs(1),
+	RunE: runStartAgent,
+}
+
+var (
+	agentInterval time.Duration = 30 * time.Second
+)
+
+func init() {
+	startAgentCmd.Flags().DurationVar(&agentInterval, "interval", 30*time.Second, "Task check interval")
+}
+
+func runStartAgent(cmd *cobra.Command, args []string) error {
+	agentName := args[0]
+
+	// Check if agent exists in configuration
+	var agentExists bool
+	for _, agent := range cfg.Agents {
+		if agent.Name == agentName {
+			agentExists = true
+			break
+		}
+	}
+
+	if !agentExists {
+		return fmt.Errorf("agent '%s' not found in configuration", agentName)
+	}
+
+	fmt.Printf("Starting agent: %s\n", agentName)
+	fmt.Printf("Task check interval: %v\n", agentInterval)
+	fmt.Printf("Press Ctrl+C to stop the agent\n\n")
+
+	// Set up signal handling for graceful shutdown
+	ctx, cancel := context.WithCancel(context.Background())
+	defer cancel()
+
+	sigChan := make(chan os.Signal, 1)
+	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
+
+	go func() {
+		<-sigChan
+		fmt.Printf("\nReceived shutdown signal, stopping agent...\n")
+		cancel()
+	}()
+
+	// Start the agent
+	err := agentManager.StartAgent(agentName, agentInterval)
+	if err != nil {
+		return fmt.Errorf("failed to start agent: %w", err)
+	}
+
+	// Wait for context cancellation (Ctrl+C)
+	<-ctx.Done()
+
+	fmt.Printf("Agent %s stopped\n", agentName)
+	return nil
+}
\ No newline at end of file