blob: d91c2fd27a03699c61daaaf31da75f2db1b4b1d3 [file] [log] [blame]
iomodod9ff8da2025-07-28 11:42:22 +04001package main
2
3import (
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
15func 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}