File size: 3,629 Bytes
94f31ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
"""
Input Pre-processor

Deterministic transformation that extracts key information from raw project
descriptions and formats as a structured brief for the Product Owner agent.
Replaces the project_refiner agent with a zero-LLM-call alternative.
"""



def preprocess_input(description: str) -> str:
    """
    Extract key information from a raw project description and format
    as a structured brief for the Product Owner agent.

    Args:
        description: Raw project description from user

    Returns:
        Structured brief string
    """
    if not description or not description.strip():
        return "No project description provided."

    # Extract potential project type indicators
    project_types = {
        "web application": "Web Application",
        "mobile app": "Mobile Application",
        "api": "API Service",
        "dashboard": "Dashboard",
        "e-commerce": "E-Commerce Platform",
        "saas": "SaaS Platform",
        "cms": "Content Management System",
        "crm": "CRM System",
        "tutoring": "Educational Platform",
        "learning": "Educational Platform",
        "social": "Social Platform",
        "analytics": "Analytics Platform",
    }

    desc_lower = description.lower()
    detected_type = "General Software Project"
    for keyword, ptype in project_types.items():
        if keyword in desc_lower:
            detected_type = ptype
            break

    # Extract potential audience indicators
    audience_indicators = {
        "students": "Students and educators",
        "teachers": "Teachers and educators",
        "enterprise": "Enterprise users",
        "consumer": "General consumers",
        "developer": "Developers",
        "admin": "Administrators",
        "manager": "Managers and team leads",
        "professional": "Professionals",
        "team": "Teams and organizations",
    }

    detected_audience = "Not specified"
    for keyword, audience in audience_indicators.items():
        if keyword in desc_lower:
            detected_audience = audience
            break

    # Count potential feature indicators
    feature_keywords = [
        "authentication",
        "login",
        "signup",
        "dashboard",
        "report",
        "notification",
        "search",
        "filter",
        "upload",
        "download",
        "payment",
        "subscription",
        "analytics",
        "admin",
        "api",
        "integration",
        "export",
        "import",
        "chat",
        "messaging",
        "calendar",
        "scheduling",
        "workflow",
        "automation",
    ]
    detected_features = [kw for kw in feature_keywords if kw in desc_lower]

    # Extract constraint indicators
    constraint_keywords = [
        "must use",
        "required to use",
        "existing",
        "legacy",
        "compliance",
        "gdpr",
        "hipaa",
        "soc2",
        "budget",
        "timeline",
        "deadline",
        "limited",
        "constraint",
    ]
    detected_constraints = [kw for kw in constraint_keywords if kw in desc_lower]

    # Build structured brief
    brief_parts = [
        f"**Project Type:** {detected_type}",
        f"**Target Audience:** {detected_audience}",
        f"**Key Features Detected:** {', '.join(detected_features) if detected_features else 'To be determined from full description'}",
        f"**Potential Constraints:** {', '.join(detected_constraints) if detected_constraints else 'None explicitly stated'}",
        "",
        "**Full Description:**",
        description.strip(),
    ]

    return "\n".join(brief_parts)