| 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") |
| } |