| iomodo | d9ff8da | 2025-07-28 11:42:22 +0400 | [diff] [blame^] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "fmt" |
| 6 | "log" |
| 7 | "time" |
| 8 | |
| 9 | "github.com/iomodo/staff/llm" |
| 10 | _ "github.com/iomodo/staff/llm/providers" |
| 11 | "github.com/iomodo/staff/subtasks" |
| 12 | "github.com/iomodo/staff/tm" |
| 13 | ) |
| 14 | |
| 15 | func main() { |
| 16 | fmt.Println("Testing Subtask Generation...") |
| 17 | fmt.Println("==============================") |
| 18 | |
| 19 | // Create fake LLM provider |
| 20 | config := llm.Config{ |
| 21 | Provider: llm.ProviderFake, |
| 22 | APIKey: "fake-key", |
| 23 | BaseURL: "fake://test", |
| 24 | } |
| 25 | |
| 26 | provider, err := llm.CreateProvider(config) |
| 27 | if err != nil { |
| 28 | log.Fatalf("Failed to create provider: %v", err) |
| 29 | } |
| 30 | defer provider.Close() |
| 31 | |
| 32 | // Create a mock task |
| 33 | task := &tm.Task{ |
| 34 | ID: "task-test-123", |
| 35 | Title: "Build comprehensive user authentication system", |
| 36 | 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.", |
| 37 | Priority: tm.PriorityHigh, |
| 38 | Status: tm.StatusToDo, |
| 39 | CreatedAt: time.Now(), |
| 40 | UpdatedAt: time.Now(), |
| 41 | } |
| 42 | |
| 43 | // Create subtask service with available agent roles |
| 44 | agentRoles := []string{"ceo", "backend-engineer", "frontend-engineer", "qa", "devops"} |
| 45 | subtaskService := subtasks.NewSubtaskService(provider, nil, agentRoles) |
| 46 | |
| 47 | fmt.Printf("š Analyzing task: %s\n", task.Title) |
| 48 | fmt.Printf("š Description: %s\n\n", task.Description[:100]+"...") |
| 49 | |
| 50 | // Analyze task for subtasks |
| 51 | fmt.Println("š¤ Running LLM analysis...") |
| 52 | analysis, err := subtaskService.AnalyzeTaskForSubtasks(context.Background(), task) |
| 53 | if err != nil { |
| 54 | log.Fatalf("Failed to analyze task: %v", err) |
| 55 | } |
| 56 | |
| 57 | fmt.Printf("ā
Analysis completed!\n\n") |
| 58 | fmt.Printf("š **Analysis Summary:**\n%s\n\n", analysis.AnalysisSummary) |
| 59 | fmt.Printf("šÆ **Recommended Approach:**\n%s\n\n", analysis.RecommendedApproach) |
| 60 | fmt.Printf("ā±ļø **Estimated Total Hours:** %d\n\n", analysis.EstimatedTotalHours) |
| 61 | |
| 62 | if analysis.RiskAssessment != "" { |
| 63 | fmt.Printf("ā ļø **Risk Assessment:**\n%s\n\n", analysis.RiskAssessment) |
| 64 | } |
| 65 | |
| 66 | fmt.Printf("š **Proposed Subtasks (%d):**\n", len(analysis.Subtasks)) |
| 67 | fmt.Println("=================================") |
| 68 | |
| 69 | for i, subtask := range analysis.Subtasks { |
| 70 | fmt.Printf("\n%d. **%s**\n", i+1, subtask.Title) |
| 71 | fmt.Printf(" - Assigned to: %s\n", subtask.AssignedTo) |
| 72 | fmt.Printf(" - Priority: %s\n", subtask.Priority) |
| 73 | fmt.Printf(" - Hours: %d\n", subtask.EstimatedHours) |
| 74 | if len(subtask.Dependencies) > 0 { |
| 75 | fmt.Printf(" - Dependencies: %v\n", subtask.Dependencies) |
| 76 | } |
| 77 | fmt.Printf(" - Description: %s\n", subtask.Description) |
| 78 | } |
| 79 | |
| 80 | // Generate PR content |
| 81 | fmt.Println("\nš Generating PR content...") |
| 82 | prURL, err := subtaskService.GenerateSubtaskPR(context.Background(), analysis) |
| 83 | if err != nil { |
| 84 | log.Fatalf("Failed to generate PR: %v", err) |
| 85 | } |
| 86 | |
| 87 | fmt.Printf("\nā
**Subtask PR Generated:** %s\n", prURL) |
| 88 | fmt.Println("\nš **Subtask generation test completed successfully!**") |
| 89 | fmt.Println("\nš” **Next Steps:**") |
| 90 | fmt.Println(" 1. Review the generated subtasks") |
| 91 | fmt.Println(" 2. Approve the PR to create actual subtasks") |
| 92 | fmt.Println(" 3. Assign subtasks to appropriate agents") |
| 93 | fmt.Println(" 4. Monitor subtask completion progress") |
| 94 | } |