#!/usr/bin/env python3
"""
Generate the remaining 11 test scenarios for agent user testing
"""

import os
from pathlib import Path

# Define the remaining scenarios
scenarios = [
    {
        "id": "04-financial-compliance",
        "title": "Financial Services - Regulatory Compliance Research",
        "industry": "Financial Services",
        "role": "Compliance Officer",
        "task": "Research financial regulations and compliance requirements for investment advisory services",
        "folder": "financial-compliance-research",
        "description": "You work as a compliance officer at a mid-size investment advisory firm. With changing regulations and recent updates to SEC requirements, you need to research current compliance standards, reporting obligations, and best practices to ensure the firm meets all regulatory requirements and avoids penalties.",
        "materials": [
            "SEC regulations for investment advisors (forms ADV, compliance manuals)",
            "FINRA rules and requirements documentation", 
            "Anti-money laundering (AML) and Know Your Customer (KYC) guidelines",
            "Fiduciary duty requirements and best practices",
            "Cybersecurity frameworks for financial institutions"
        ],
        "sources": [
            "SEC.gov official guidance documents",
            "FINRA regulatory notices and requirements",
            "Financial industry compliance handbooks", 
            "Cybersecurity frameworks (NIST, ISO 27001)",
            "Industry compliance best practices guides"
        ],
        "questions": [
            "What are the reporting requirements for Form ADV updates?",
            "How often must AML policies be reviewed and updated?",
            "What cybersecurity measures are required for client data protection?",
            "What documentation is required for demonstrating fiduciary duty?",
            "What are the penalties for non-compliance with SEC regulations?"
        ],
        "findings": [
            "Key regulatory requirements and deadlines",
            "Compliance monitoring and reporting procedures",
            "Risk assessment and mitigation strategies",
            "Documentation and record-keeping requirements",
            "Training and certification needs for staff"
        ]
    },
    {
        "id": "05-medical-research",
        "title": "Medical Research - Clinical Trial Protocol Development",
        "industry": "Healthcare/Medical Research",
        "role": "Clinical Research Coordinator",
        "task": "Research regulations and best practices for designing Phase II clinical trials",
        "folder": "clinical-trial-research",
        "description": "You're a clinical research coordinator at a pharmaceutical company developing a new diabetes medication. Your team needs to design a Phase II clinical trial protocol that meets FDA requirements and follows good clinical practice (GCP) guidelines.",
        "materials": [
            "FDA clinical trial guidance documents",
            "ICH Good Clinical Practice guidelines",
            "IRB/Ethics committee requirements",
            "Patient safety and adverse event reporting protocols",
            "Statistical analysis plans for clinical trials"
        ],
        "sources": [
            "FDA.gov clinical trial guidance documents",
            "International Council for Harmonisation (ICH) guidelines",
            "Good Clinical Practice training materials",
            "Clinical research regulatory handbooks",
            "Biostatistics and clinical trial design resources"
        ],
        "questions": [
            "What are the FDA requirements for Phase II trial design?",
            "How should adverse events be classified and reported?",
            "What statistical power calculations are needed for efficacy endpoints?",
            "What informed consent elements are required?",
            "How should patient eligibility criteria be defined?"
        ],
        "findings": [
            "FDA regulatory requirements for Phase II trials",
            "Patient safety monitoring and reporting procedures",
            "Statistical analysis and sample size calculations",
            "Informed consent and ethical considerations",
            "Protocol development timeline and milestones"
        ]
    },
    {
        "id": "06-real-estate-development",
        "title": "Real Estate Development - Zoning & Environmental Compliance",
        "industry": "Real Estate Development",
        "role": "Development Project Manager",
        "task": "Research zoning regulations and environmental requirements for mixed-use development",
        "folder": "development-compliance-research",
        "description": "You're managing a mixed-use development project combining residential, commercial, and retail spaces. You need to research local zoning ordinances, environmental regulations, and permitting requirements to ensure the project meets all legal requirements.",
        "materials": [
            "Local zoning ordinances and land use regulations",
            "Environmental impact assessment requirements",
            "Building codes and safety standards",
            "Permitting processes and timelines",
            "Historic preservation and cultural resource guidelines"
        ],
        "sources": [
            "City planning and zoning department documents",
            "Environmental Protection Agency guidelines",
            "State and local building codes",
            "Historic preservation commission requirements",
            "Development industry best practices guides"
        ],
        "questions": [
            "What are the density limitations for mixed-use developments?",
            "What environmental studies are required before construction?",
            "How long does the permitting process typically take?",
            "What parking requirements exist for mixed-use projects?",
            "Are there historic preservation considerations for this site?"
        ],
        "findings": [
            "Zoning compliance requirements and restrictions",
            "Environmental assessment and mitigation needs",
            "Permitting timeline and required documentation",
            "Building design and safety standards",
            "Community impact and public consultation requirements"
        ]
    },
    {
        "id": "07-agriculture-sustainability",
        "title": "Agriculture - Sustainable Farming Practices Research",
        "industry": "Agriculture/Farming",
        "role": "Farm Operations Manager",
        "task": "Research sustainable farming techniques and certification requirements for organic agriculture",
        "folder": "sustainable-farming-research",
        "description": "You manage a 500-acre family farm transitioning from conventional to organic agriculture. You need to research sustainable farming practices, organic certification requirements, and soil health management techniques to ensure successful transition and long-term sustainability.",
        "materials": [
            "USDA organic certification standards and procedures",
            "Sustainable agriculture practices and case studies",
            "Soil health assessment and improvement techniques",
            "Integrated pest management (IPM) strategies",
            "Water conservation and irrigation efficiency guides"
        ],
        "sources": [
            "USDA National Organic Program documentation",
            "Sustainable agriculture research institutions",
            "Extension service publications and guides",
            "Organic farming certification bodies",
            "Agricultural sustainability research papers"
        ],
        "questions": [
            "What is the transition period required for organic certification?",
            "Which sustainable practices provide the best soil health benefits?",
            "How can integrated pest management reduce chemical inputs?",
            "What water conservation techniques work best for our crop types?",
            "What record-keeping is required for organic certification?"
        ],
        "findings": [
            "Organic certification timeline and requirements",
            "Soil health improvement strategies and techniques",
            "Sustainable pest and disease management approaches",
            "Water conservation and efficiency measures",
            "Economic analysis of sustainable farming practices"
        ]
    },
    {
        "id": "08-education-technology",
        "title": "Education Technology - Digital Learning Platform Research",
        "industry": "Education/EdTech",
        "role": "Educational Technology Coordinator",
        "task": "Research best practices for implementing digital learning platforms in K-12 education",
        "folder": "edtech-implementation-research",
        "description": "You're coordinating the implementation of new digital learning platforms across a school district. You need to research best practices for EdTech integration, accessibility requirements, student data privacy regulations, and teacher training methodologies.",
        "materials": [
            "Digital learning platform evaluation criteria",
            "FERPA and student data privacy requirements",
            "Accessibility standards for educational technology (WCAG)",
            "Teacher professional development and training resources",
            "Digital equity and inclusion best practices"
        ],
        "sources": [
            "Department of Education technology guidelines",
            "EdTech research organizations and publications",
            "Accessibility compliance resources (Section 508, WCAG)",
            "Professional development frameworks for educators",
            "Digital equity research and case studies"
        ],
        "questions": [
            "What are the key evaluation criteria for selecting learning platforms?",
            "How should student data privacy be protected in digital learning?",
            "What accessibility features are required for inclusive education?",
            "What training approach works best for teacher adoption?",
            "How can digital equity gaps be addressed effectively?"
        ],
        "findings": [
            "Platform selection criteria and evaluation framework",
            "Student data privacy compliance requirements",
            "Accessibility standards and implementation guidelines",
            "Teacher training and professional development strategies",
            "Digital equity initiatives and best practices"
        ]
    },
    {
        "id": "09-construction-safety",
        "title": "Construction - Workplace Safety & OSHA Compliance",
        "industry": "Construction",
        "role": "Safety Manager",
        "task": "Research OSHA regulations and safety best practices for commercial construction projects",
        "folder": "construction-safety-research",
        "description": "You're the safety manager for a construction company working on high-rise commercial buildings. With recent OSHA updates and increasing safety requirements, you need to research current safety regulations, fall protection standards, and hazard communication requirements.",
        "materials": [
            "OSHA construction safety standards (29 CFR Part 1926)",
            "Fall protection and scaffolding safety requirements",
            "Hazard communication and chemical safety protocols",
            "Personal protective equipment (PPE) standards",
            "Safety training and certification requirements"
        ],
        "sources": [
            "OSHA.gov construction safety standards",
            "National Institute for Occupational Safety and Health (NIOSH) guidelines",
            "Construction industry safety organizations",
            "Safety training and certification programs",
            "Construction accident prevention resources"
        ],
        "questions": [
            "What are the current fall protection requirements for heights over 6 feet?",
            "How should hazardous chemicals be communicated to workers?",
            "What PPE is required for different construction activities?",
            "How often must safety training be conducted and documented?",
            "What are the inspection requirements for scaffolding and equipment?"
        ],
        "findings": [
            "OSHA compliance requirements and recent updates",
            "Fall protection and scaffolding safety procedures",
            "Hazard communication and chemical safety protocols",
            "PPE selection and usage guidelines",
            "Safety training and documentation requirements"
        ]
    },
    {
        "id": "10-nonprofit-fundraising",
        "title": "Nonprofit - Grant Writing & Fundraising Strategy",
        "industry": "Nonprofit/Social Services",
        "role": "Development Director",
        "task": "Research grant opportunities and fundraising best practices for environmental conservation programs",
        "folder": "nonprofit-fundraising-research",
        "description": "You're the development director at an environmental conservation nonprofit. Your organization needs to expand funding sources and develop comprehensive grant writing strategies to support habitat restoration and education programs.",
        "materials": [
            "Federal and state environmental grant programs",
            "Foundation giving guidelines and priorities",
            "Grant writing best practices and templates",
            "Nonprofit fundraising strategies and case studies",
            "Impact measurement and reporting frameworks"
        ],
        "sources": [
            "Federal grant databases (Grants.gov, EPA grants)",
            "Foundation directories and giving databases",
            "Nonprofit fundraising organizations and resources",
            "Grant writing training materials and guides",
            "Impact measurement and evaluation resources"
        ],
        "questions": [
            "What federal grants are available for habitat restoration projects?",
            "How should environmental impact be measured and reported?",
            "What elements make grant proposals most successful?",
            "How can donor retention rates be improved?",
            "What matching fund requirements exist for environmental grants?"
        ],
        "findings": [
            "Grant opportunity identification and assessment",
            "Proposal writing strategies and best practices",
            "Impact measurement and evaluation frameworks",
            "Donor engagement and retention strategies",
            "Compliance and reporting requirements for grants"
        ]
    },
    {
        "id": "11-cybersecurity-compliance",
        "title": "Cybersecurity - Framework Implementation & Risk Assessment",
        "industry": "Cybersecurity/IT",
        "role": "Information Security Manager",
        "task": "Research cybersecurity frameworks and compliance requirements for financial services organization",
        "folder": "cybersecurity-framework-research",
        "description": "You're implementing a comprehensive cybersecurity program for a financial services company. You need to research security frameworks (NIST, ISO 27001), compliance requirements, and risk assessment methodologies to protect customer data and meet regulatory obligations.",
        "materials": [
            "NIST Cybersecurity Framework documentation",
            "ISO 27001 information security standards",
            "Financial services cybersecurity regulations",
            "Risk assessment methodologies and tools",
            "Incident response planning and procedures"
        ],
        "sources": [
            "NIST cybersecurity framework and guidelines",
            "ISO 27001 documentation and certification guides",
            "Financial industry cybersecurity regulations",
            "Cybersecurity risk assessment frameworks",
            "Incident response and business continuity resources"
        ],
        "questions": [
            "How should the NIST Framework be implemented in financial services?",
            "What are the key controls required by ISO 27001?",
            "How should cybersecurity risks be assessed and prioritized?",
            "What incident response procedures are required?",
            "How can employee security awareness be improved?"
        ],
        "findings": [
            "Framework implementation roadmap and priorities",
            "Security control selection and implementation",
            "Risk assessment methodology and tools",
            "Incident response and recovery procedures",
            "Employee training and awareness strategies"
        ]
    },
    {
        "id": "12-retail-ecommerce",
        "title": "Retail E-commerce - Digital Marketing & Customer Experience",
        "industry": "Retail/E-commerce",
        "role": "Digital Marketing Manager",
        "task": "Research digital marketing strategies and customer experience optimization for online retail",
        "folder": "ecommerce-marketing-research",
        "description": "You're managing digital marketing for a growing e-commerce retailer specializing in sustainable home goods. You need to research modern digital marketing techniques, customer experience optimization, and data privacy compliance to increase sales and improve customer satisfaction.",
        "materials": [
            "Digital marketing best practices and case studies",
            "E-commerce conversion optimization techniques",
            "Customer experience design and journey mapping",
            "Data privacy regulations (GDPR, CCPA) for e-commerce",
            "Social media marketing and influencer strategies"
        ],
        "sources": [
            "Digital marketing industry publications and guides",
            "E-commerce platform documentation and best practices",
            "Customer experience research organizations",
            "Data privacy and compliance resources",
            "Social media marketing and advertising platforms"
        ],
        "questions": [
            "What are the most effective customer acquisition strategies for e-commerce?",
            "How can website conversion rates be optimized?",
            "What data privacy compliance is required for customer data?",
            "How should customer journey mapping be conducted?",
            "What social media strategies work best for sustainable products?"
        ],
        "findings": [
            "Digital marketing strategy and channel optimization",
            "Website conversion optimization techniques",
            "Customer experience improvement recommendations",
            "Data privacy compliance requirements and procedures",
            "Social media and content marketing strategies"
        ]
    },
    {
        "id": "13-hospitality-operations",
        "title": "Hospitality - Hotel Operations & Guest Experience Management",
        "industry": "Hospitality/Tourism",
        "role": "Hotel Operations Manager",
        "task": "Research hotel operations best practices and guest experience optimization strategies",
        "folder": "hotel-operations-research",
        "description": "You're managing operations for a boutique hotel chain focusing on sustainable tourism. You need to research modern hotel management practices, guest experience optimization, sustainability initiatives, and staff training programs to improve operational efficiency and guest satisfaction.",
        "materials": [
            "Hotel operations management best practices",
            "Guest experience optimization and service design",
            "Sustainable hospitality practices and certifications",
            "Staff training and development programs",
            "Revenue management and pricing strategies"
        ],
        "sources": [
            "Hospitality industry associations and publications",
            "Hotel management training resources",
            "Sustainable tourism certification organizations",
            "Guest experience and service design resources",
            "Revenue management and hospitality technology guides"
        ],
        "questions": [
            "What are the key performance indicators for hotel operations?",
            "How can guest satisfaction scores be improved?",
            "What sustainable practices can reduce operational costs?",
            "How should staff training programs be structured?",
            "What revenue management strategies maximize profitability?"
        ],
        "findings": [
            "Operational efficiency metrics and improvement strategies",
            "Guest experience enhancement recommendations",
            "Sustainability initiatives and certification requirements",
            "Staff development and training program design",
            "Revenue optimization and pricing strategies"
        ]
    },
    {
        "id": "14-software-development",
        "title": "Software Development - API Design & Documentation Best Practices",
        "industry": "Software Development/Tech",
        "role": "Technical Lead",
        "task": "Research API design patterns and documentation strategies for microservices architecture",
        "folder": "api-design-research",
        "description": "You're leading the development of a microservices platform for a SaaS company. You need to research REST API design best practices, OpenAPI documentation standards, authentication patterns, and testing strategies to ensure scalable and maintainable system architecture.",
        "materials": [
            "REST API design principles and best practices",
            "OpenAPI specification and documentation standards",
            "API authentication and security patterns",
            "Microservices architecture design guidelines",
            "API testing and monitoring strategies"
        ],
        "sources": [
            "API design and development best practices guides",
            "OpenAPI and Swagger documentation resources",
            "Microservices architecture patterns and case studies",
            "API security and authentication frameworks",
            "Software testing and quality assurance resources"
        ],
        "questions": [
            "What are the REST API design principles for scalable systems?",
            "How should API documentation be structured using OpenAPI?",
            "What authentication patterns work best for microservices?",
            "How should API versioning be managed?",
            "What testing strategies ensure API reliability?"
        ],
        "findings": [
            "API design patterns and architectural principles",
            "Documentation standards and tooling recommendations",
            "Security and authentication implementation strategies",
            "Version management and backward compatibility",
            "Testing and monitoring framework recommendations"
        ]
    },
    {
        "id": "15-environmental-consulting",
        "title": "Environmental Consulting - Impact Assessment & Remediation Planning",
        "industry": "Environmental Consulting",
        "role": "Environmental Scientist",
        "task": "Research environmental impact assessment methodologies and soil contamination remediation techniques",
        "folder": "environmental-assessment-research",
        "description": "You're an environmental scientist working on a contaminated industrial site remediation project. You need to research environmental impact assessment procedures, soil contamination analysis methods, and remediation technologies to develop a comprehensive cleanup plan.",
        "materials": [
            "Environmental impact assessment (EIA) guidelines",
            "Soil contamination testing and analysis procedures",
            "Remediation technology options and case studies",
            "EPA regulations for contaminated site cleanup",
            "Groundwater monitoring and protection strategies"
        ],
        "sources": [
            "EPA environmental assessment and remediation guidelines",
            "Environmental consulting industry standards",
            "Soil science and remediation technology research",
            "Groundwater protection and monitoring resources",
            "Environmental impact assessment methodologies"
        ],
        "questions": [
            "What are the standard procedures for environmental impact assessment?",
            "How should soil contamination be analyzed and categorized?",
            "What remediation technologies are most effective for industrial contamination?",
            "What monitoring is required during and after remediation?",
            "How should community stakeholders be engaged in the process?"
        ],
        "findings": [
            "Environmental impact assessment framework and procedures",
            "Soil contamination analysis and risk assessment methods",
            "Remediation technology selection and implementation",
            "Monitoring and compliance requirements",
            "Stakeholder engagement and communication strategies"
        ]
    }
]

def generate_scenario_files(scenario):
    """Generate instruction and results files for a scenario"""
    
    # Create scenario directory
    scenario_dir = Path(f"agent-user-testing/{scenario['id']}")
    scenario_dir.mkdir(exist_ok=True)
    
    # Generate instructions file
    instructions_content = f"""# Test Scenario {scenario['id'].split('-')[0].zfill(2)}: {scenario['title']}

## 🏢 **Industry Context**: {scenario['industry']}
**Role**: {scenario['role']}  
**Task**: {scenario['task']}

## 📋 **Scenario Description**
{scenario['description']}

## 🎯 **Your Mission (Completely Autonomous)**

### **Step 1: Setup FSS-Mini-RAG**
1. Read the repository README.md to understand how to install FSS-Mini-RAG
2. Follow the installation instructions for your platform
3. Verify the installation works by running `rag-mini --help`

### **Step 2: Gather Research Materials**
Create a folder called `{scenario['folder']}` and populate it with relevant documentation:"""

    for material in scenario['materials']:
        instructions_content += f"\n- {material}"
    
    instructions_content += f"""

**Sources to explore**:"""
    
    for source in scenario['sources']:
        instructions_content += f"\n- {source}"
    
    instructions_content += f"""

### **Step 3: Index and Search**
1. Use FSS-Mini-RAG to index your `{scenario['folder']}` folder
2. Perform searches to answer these questions:"""
    
    for question in scenario['questions']:
        instructions_content += f"\n   - \"{question}\""
    
    instructions_content += f"""

### **Step 4: Document Your Findings**
Write your findings in `RESULTS.md` including:"""
    
    for finding in scenario['findings']:
        instructions_content += f"\n- {finding}"
    
    instructions_content += f"""

### **Step 5: Evaluation**
Rate FSS-Mini-RAG's effectiveness for:
- Finding specific information across multiple documents
- Searching complex documentation efficiently
- Helping with research and analysis workflows
- Overall usefulness for {scenario['industry'].lower()} industry applications

## 📁 **Deliverables**
- `{scenario['folder']}/` folder with research materials
- `RESULTS.md` with findings and FSS-Mini-RAG evaluation
- Documentation of your search queries and discoveries

## ⏱️ **Expected Duration**: 2-3 hours

## 🎓 **Learning Objectives**
- Test FSS-Mini-RAG with {scenario['industry'].lower()} industry content
- Evaluate search effectiveness with domain-specific documentation
- Assess usefulness for professional research workflows in {scenario['industry'].lower()}"""

    # Write instructions file
    with open(scenario_dir / "INSTRUCTIONS.md", 'w') as f:
        f.write(instructions_content)
    
    # Generate results placeholder
    results_content = f"""# Results Placeholder - {scenario['title']}

*Agent will document findings here after completing the research task*

## Research Findings
*To be completed by agent*

## FSS-Mini-RAG Evaluation
*Agent evaluation of tool effectiveness for {scenario['industry'].lower()} workflows*

## Search Queries Used
*Document the specific searches performed*

## Professional Recommendations
*Agent recommendations for {scenario['industry'].lower()} industry applications*"""

    # Write results file
    with open(scenario_dir / "RESULTS.md", 'w') as f:
        f.write(results_content)

def main():
    print("Generating agent user testing scenarios...")
    
    for scenario in scenarios:
        print(f"Creating scenario: {scenario['id']}")
        generate_scenario_files(scenario)
    
    print(f"Successfully generated {len(scenarios)} test scenarios!")

if __name__ == "__main__":
    main()