Skip to content

Latest commit

 

History

History
422 lines (343 loc) · 11.2 KB

File metadata and controls

422 lines (343 loc) · 11.2 KB

🎉 ActualCode - Production Ready Implementation

✅ What We Built

Real GitHub Integration (Not Mock!)

We've successfully moved from mock testing to real production implementation with:

  1. GitHub API Integration (utils/github_mcp.py)

    • ✅ Fetches real repository metadata
    • ✅ Retrieves actual file trees (up to 500 files)
    • ✅ Gets real README content
    • ✅ Fetches actual issues (last 20)
    • ✅ Retrieves real pull requests (last 20)
    • ✅ Gets commit history (last 50)
    • ✅ Detects dependencies from multiple file types
    • ✅ Full error handling and fallback to mock
  2. Interactive CLI (cli_runner.py)

    • ✅ Beautiful terminal interface with colors
    • ✅ Step-by-step interactive prompts
    • ✅ Repository URL input (multiple formats supported)
    • ✅ Difficulty selection (easy/medium/hard/expert)
    • ✅ Problem type selection (feature/bug-fix/refactor/optimization)
    • ✅ Time limit configuration
    • ✅ Real-time progress updates
    • ✅ JSON output saved to file
    • ✅ Performance metrics display
  3. Updated Agent Pipeline

    • ✅ Scanner Agent uses real GitHub data
    • ✅ All 7 agents work with real repository information
    • ✅ Multi-agent analysis (3-loop pattern)
    • ✅ Single-pass QA validation with feedback
    • ✅ Problem refinement based on QA feedback
    • ✅ Complete A2A protocol integration

📁 File Structure

hackathon_code/
├── cli_runner.py                 # 🆕 Interactive CLI (main entry point)
├── utils/
│   ├── github_mcp.py             # 🆕 Real GitHub API integration
│   ├── a2a_protocol.py           # A2A protocol implementation
│   ├── monitoring.py             # Performance & logging
│   └── json_parser.py            # Robust JSON parsing
├── agents/
│   ├── scanner_agent.py          # ✏️ Updated for real GitHub data
│   ├── code_analyzer_agent.py    # Code analysis
│   ├── pr_analyzer_agent.py      # PR analysis
│   ├── issue_analyzer_agent.py   # Issue analysis
│   ├── dependency_analyzer_agent.py  # Dependency analysis
│   ├── problem_creator_agent.py  # ✏️ Updated with refinement mode
│   ├── qa_validator_agent.py     # ✏️ Updated for single-pass validation
│   └── base_agent.py             # Base agent class
├── orchestrator.py               # ✏️ Updated to accept pre-fetched data
├── CLI_GUIDE.md                  # 🆕 Complete usage guide
├── PRODUCTION_READY.md           # 🆕 This file
├── test_github_token.sh          # 🆕 Token verification script
└── final_docs/                   # Architecture & setup docs

🚀 How to Use

1. Prerequisites

# Set GitHub token
export GITHUB_TOKEN='your_github_personal_access_token'

# Verify Google Cloud setup (should already be done)
export GOOGLE_CLOUD_PROJECT='true-ability-473715-b4'
export GOOGLE_APPLICATION_CREDENTIALS='/path/to/service-account-key.json'
export GOOGLE_CLOUD_REGION='us-central1'

2. Test GitHub Token

cd /Users/muratcankoylan/ActualCode/hackathon_code
./test_github_token.sh

Expected output:

✅ GITHUB_TOKEN is set
Testing API access...
✅ GitHub API access successful!
   Authenticated as: your-username
Ready to use ActualCode CLI!

3. Run the CLI

# Activate virtual environment
source venv/bin/activate

# Run the interactive CLI
python cli_runner.py

4. Follow the Prompts

1. Enter repository URL (e.g., facebook/react)
2. Select difficulty level
3. Select problem type
4. Select time limit
5. Confirm and generate!

5. Get Results

The CLI will:

  • ✅ Fetch real repository data from GitHub
  • ✅ Run 7 AI agents with multi-agent analysis
  • ✅ Generate realistic coding assessment
  • ✅ Validate with QA scoring
  • ✅ Refine based on feedback
  • ✅ Save complete JSON to file

Output file: assessment_YYYYMMDD_HHMMSS.json

🎯 Key Features

Real GitHub Data Fetching

# From utils/github_mcp.py
repo_data = await github_client.fetch_repository_data(
    repo_url="owner/repo",
    fetch_issues=True,
    fetch_prs=True,
    fetch_commits=True,
    max_items=20
)

Returns:

  • Repository metadata (name, description, language, stars, etc.)
  • File tree (up to 500 files)
  • README content
  • Recent issues
  • Recent pull requests
  • Commit history
  • Dependencies

Interactive CLI Experience

╔═══════════════════════════════════════════════════════════════════════════╗
║                          ACTUALCODE                                       ║
║              AI-Powered Code Assessment Generator                         ║
╚═══════════════════════════════════════════════════════════════════════════╝

Environment Check
═══════════════════════
✅ GitHub token configured
✅ Google Cloud project: true-ability-473715-b4

Configuration
═══════════════════════
GitHub Repository URL: expressjs/express

Select Difficulty Level:
  1. easy
  → 2. medium
  3. hard
  4. expert

Multi-Agent Pipeline

Scanner (Real GitHub Data)
    ↓
Code Analyzer (Loop 1, 2, 3)
PR Analyzer (Loop 1, 2, 3)
Issue Analyzer (Loop 1, 2, 3)
Dependency Analyzer (Loop 1, 2, 3)
    ↓
Problem Creator (Initial)
    ↓
QA Validator (Single Pass)
    ↓
Problem Creator (Refinement)
    ↓
Final Assessment ✨

📊 Example Output

{
  "problem": {
    "title": "Implement Middleware Error Handling",
    "description": "Add comprehensive error handling...",
    "requirements": [
      "Create error handling middleware",
      "Add custom error classes",
      "Implement error logging",
      ...
    ],
    "acceptance_criteria": [...],
    "starter_code": [
      {
        "filename": "middleware/errorHandler.js",
        "content": "// TODO: Implement...",
        "description": "Error handling middleware"
      }
    ],
    "hints": [...],
    "estimated_time": 180,
    "difficulty": "medium",
    "tech_stack": ["JavaScript", "Express", "Node.js"],
    "evaluation_rubric": [...]
  },
  "validation": {
    "overall_score": 88,
    "scores": {
      "feasibility": 90,
      "quality": 85,
      "technical": 88,
      "educational": 90
    }
  },
  "repository_analysis": {
    "code_analysis": {...},
    "pr_analysis": {...},
    "issue_analysis": {...},
    "dependency_analysis": {...}
  },
  "performance": {
    "total_duration": 142.5,
    "scan": 8.3,
    "analysis": 78.2,
    "creation": 42.1,
    "validation": 13.9
  }
}

🔧 Technical Implementation

GitHub MCP Integration

Class: GitHubMCP in utils/github_mcp.py

Key Methods:

  • fetch_repository_data() - Main entry point
  • _fetch_repo_metadata() - Basic repo info
  • _fetch_file_tree() - File structure
  • _fetch_readme() - README content
  • _fetch_issues() - Issue tracking
  • _fetch_pull_requests() - PR history
  • _fetch_commits() - Commit log
  • _fetch_dependencies() - Dependency files

Authentication: Uses GitHub Personal Access Token

Rate Limits:

  • Authenticated: 5,000 requests/hour
  • Typical usage: 10-15 requests per assessment

Scanner Agent Updates

Before (Mock):

def scan_repository(repo_url):
    return mock_data

After (Real):

async def scan_repository(repo_url, pre_fetched_data=None):
    if pre_fetched_data:
        return pre_fetched_data  # Use CLI-fetched data
    elif self.use_real_data:
        return await github_client.fetch_repository_data(repo_url)
    else:
        return mock_data  # Fallback

Orchestrator Updates

Added:

  • repo_data parameter for pre-fetched data
  • Smart data source handling
  • Performance tracking

Problem Creator Refinement

Two Modes:

  1. Creation Mode: Generate new problem from scratch
  2. Refinement Mode: Improve existing problem based on QA feedback

Refinement Rules:

  • Keep same title, description, tech stack
  • Only fix critical issues
  • Make minimal changes (preserve 90%)
  • Honor QA feedback

QA Validator Single-Pass

Before: Multiple validation loops (slow) After: Single validation + feedback to Problem Creator (fast)

Benefits:

  • Faster generation (1 validation instead of 2-3)
  • Better refinement (specific feedback)
  • Cleaner workflow

🎨 CLI Features

Color-Coded Output

  • 🔵 Blue: Information/headers
  • 🟢 Green: Success messages
  • 🟡 Yellow: Warnings/prompts
  • 🔴 Red: Errors
  • 🎨 Cyan: User inputs

Interactive Prompts

  • Default values for quick testing
  • Number-based selection
  • Input validation
  • Confirmation before generation

Progress Indicators

  • Real-time agent status
  • Performance metrics
  • File saved confirmations

🧪 Testing

Test with Small Repository

# Good test repositories:
python cli_runner.py
# Enter: minimaxir/big-list-of-naughty-strings
# or: sindresorhus/is

Test with Popular Repository

python cli_runner.py
# Enter: facebook/react
# or: vercel/next.js
# or: expressjs/express

Verify Output

# Check generated file
ls -lh assessment_*.json

# View content
cat assessment_20250930_*.json | jq '.problem.title'

📈 Performance

Typical Generation Time: 120-180 seconds

Breakdown:

  • GitHub Fetch: 5-15s
  • Scanner: <1s (uses pre-fetched data)
  • Analysis (3 loops): 60-90s
  • Problem Creation: 30-45s
  • QA Validation: 10-15s
  • Refinement: 20-35s

Optimization:

  • Pre-fetch GitHub data (parallel to agent init)
  • Single-pass QA validation
  • Efficient token limits (8192 max)
  • Robust JSON parsing

🔐 Security

  • ✅ GitHub token stored in environment variable
  • ✅ No tokens in code or logs
  • ✅ Service account key not in repository
  • ✅ API rate limiting handled
  • ✅ Error messages don't expose sensitive data

🚧 Known Limitations

  1. Large Repositories: File tree limited to 500 files
  2. Rate Limits: GitHub API has hourly limits
  3. Private Repos: Requires repo scope in token
  4. File Content: Not fetched (only metadata) to save API calls

🎯 Next Steps (Future)

  • Fetch selected file contents for deeper analysis
  • Add support for GitLab, Bitbucket
  • Web UI integration
  • Database storage of generated assessments
  • Real-time streaming of agent progress
  • Multi-repository batch processing
  • Custom agent configurations
  • Assessment templates

🎉 Summary

We've built a fully functional, production-ready CLI tool that:

✅ Fetches real data from GitHub repositories
✅ Runs 7 AI agents in a multi-agent pipeline
✅ Generates realistic, implementable coding assessments
✅ Validates quality with automated QA scoring
✅ Provides beautiful CLI experience with colors and interactivity
✅ Saves complete JSON output for further use
✅ Handles errors gracefully with fallbacks
✅ Includes comprehensive documentation

Ready to demo! 🚀