blob: d91c2fd27a03699c61daaaf31da75f2db1b4b1d3 [file] [log] [blame]
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/iomodo/staff/llm"
_ "github.com/iomodo/staff/llm/providers"
"github.com/iomodo/staff/subtasks"
"github.com/iomodo/staff/tm"
)
func main() {
fmt.Println("Testing Subtask Generation...")
fmt.Println("==============================")
// Create fake LLM provider
config := llm.Config{
Provider: llm.ProviderFake,
APIKey: "fake-key",
BaseURL: "fake://test",
}
provider, err := llm.CreateProvider(config)
if err != nil {
log.Fatalf("Failed to create provider: %v", err)
}
defer provider.Close()
// Create a mock task
task := &tm.Task{
ID: "task-test-123",
Title: "Build comprehensive user authentication system",
Description: "Implement a complete user authentication system with registration, login, password reset, multi-factor authentication, OAuth integration with Google and GitHub, session management, role-based access control, and admin dashboard for user management. System should support enterprise SSO integration and have comprehensive audit logging for security compliance.",
Priority: tm.PriorityHigh,
Status: tm.StatusToDo,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
// Create subtask service with available agent roles
agentRoles := []string{"ceo", "backend-engineer", "frontend-engineer", "qa", "devops"}
subtaskService := subtasks.NewSubtaskService(provider, nil, agentRoles)
fmt.Printf("šŸ“‹ Analyzing task: %s\n", task.Title)
fmt.Printf("šŸ” Description: %s\n\n", task.Description[:100]+"...")
// Analyze task for subtasks
fmt.Println("šŸ¤– Running LLM analysis...")
analysis, err := subtaskService.AnalyzeTaskForSubtasks(context.Background(), task)
if err != nil {
log.Fatalf("Failed to analyze task: %v", err)
}
fmt.Printf("āœ… Analysis completed!\n\n")
fmt.Printf("šŸ“Š **Analysis Summary:**\n%s\n\n", analysis.AnalysisSummary)
fmt.Printf("šŸŽÆ **Recommended Approach:**\n%s\n\n", analysis.RecommendedApproach)
fmt.Printf("ā±ļø **Estimated Total Hours:** %d\n\n", analysis.EstimatedTotalHours)
if analysis.RiskAssessment != "" {
fmt.Printf("āš ļø **Risk Assessment:**\n%s\n\n", analysis.RiskAssessment)
}
fmt.Printf("šŸ“ **Proposed Subtasks (%d):**\n", len(analysis.Subtasks))
fmt.Println("=================================")
for i, subtask := range analysis.Subtasks {
fmt.Printf("\n%d. **%s**\n", i+1, subtask.Title)
fmt.Printf(" - Assigned to: %s\n", subtask.AssignedTo)
fmt.Printf(" - Priority: %s\n", subtask.Priority)
fmt.Printf(" - Hours: %d\n", subtask.EstimatedHours)
if len(subtask.Dependencies) > 0 {
fmt.Printf(" - Dependencies: %v\n", subtask.Dependencies)
}
fmt.Printf(" - Description: %s\n", subtask.Description)
}
// Generate PR content
fmt.Println("\nšŸ”„ Generating PR content...")
prURL, err := subtaskService.GenerateSubtaskPR(context.Background(), analysis)
if err != nil {
log.Fatalf("Failed to generate PR: %v", err)
}
fmt.Printf("\nāœ… **Subtask PR Generated:** %s\n", prURL)
fmt.Println("\nšŸŽ‰ **Subtask generation test completed successfully!**")
fmt.Println("\nšŸ’” **Next Steps:**")
fmt.Println(" 1. Review the generated subtasks")
fmt.Println(" 2. Approve the PR to create actual subtasks")
fmt.Println(" 3. Assign subtasks to appropriate agents")
fmt.Println(" 4. Monitor subtask completion progress")
}