c1r3x commited on
Commit
4b6e45c
·
verified ·
1 Parent(s): fb919d6

Review Agent: first commit

Browse files
Files changed (8) hide show
  1. .gitignore +126 -0
  2. Dockerfile +39 -0
  3. LICENSE +21 -0
  4. app.py +48 -0
  5. docker-compose.yml +17 -0
  6. modal_deploy.py +64 -0
  7. requirements.txt +36 -0
  8. sample.env +28 -0
.gitignore ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # PyInstaller
28
+ *.manifest
29
+ *.spec
30
+
31
+ # Installer logs
32
+ pip-log.txt
33
+ pip-delete-this-directory.txt
34
+
35
+ # Unit test / coverage reports
36
+ htmlcov/
37
+ .tox/
38
+ .coverage
39
+ .coverage.*
40
+ .cache
41
+ nosetests.xml
42
+ coverage.xml
43
+ *.cover
44
+ .hypothesis/
45
+
46
+ # Translations
47
+ *.mo
48
+ *.pot
49
+
50
+ # Django stuff:
51
+ *.log
52
+ local_settings.py
53
+
54
+ # Flask stuff:
55
+ instance/
56
+ .webassets-cache
57
+
58
+ # Scrapy stuff:
59
+ .scrapy
60
+
61
+ # Sphinx documentation
62
+ docs/_build/
63
+
64
+ # PyBuilder
65
+ target/
66
+
67
+ # Jupyter Notebook
68
+ .ipynb_checkpoints
69
+
70
+ # pyenv
71
+ .python-version
72
+
73
+ # celery beat schedule file
74
+ celerybeat-schedule
75
+
76
+ # SageMath parsed files
77
+ *.sage.py
78
+
79
+ # Environments
80
+ .env
81
+ .venv
82
+ env/
83
+ venv/
84
+ ENV/
85
+ env.bak/
86
+ venv.bak/
87
+
88
+ # Spyder project settings
89
+ .spyderproject
90
+ .spyproject
91
+
92
+ # Rope project settings
93
+ .ropeproject
94
+
95
+ # mkdocs documentation
96
+ /site
97
+
98
+ # mypy
99
+ .mypy_cache/
100
+
101
+ # IDE specific files
102
+ .idea/
103
+ .vscode/
104
+ *.swp
105
+ *.swo
106
+
107
+ # Project specific
108
+ reports/
109
+ temp_repos/
110
+ logs/
111
+
112
+ # Environment variables
113
+ .env
114
+
115
+ # Temporary files
116
+ *.tmp
117
+
118
+ # OS specific
119
+ .DS_Store
120
+ Thumbs.db
121
+
122
+ # Costume files
123
+ DEPLOYMENT_GUIDE.md
124
+ setup.py
125
+ reports
126
+ run.py
Dockerfile ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE=1 \
6
+ PYTHONUNBUFFERED=1 \
7
+ PIP_NO_CACHE_DIR=off \
8
+ PIP_DISABLE_PIP_VERSION_CHECK=on
9
+
10
+ # Set the working directory
11
+ WORKDIR /app
12
+
13
+ # Install system dependencies
14
+ RUN apt-get update && apt-get install -y --no-install-recommends \
15
+ git \
16
+ wkhtmltopdf \
17
+ && apt-get clean \
18
+ && rm -rf /var/lib/apt/lists/*
19
+
20
+ # Copy requirements file
21
+ COPY requirements.txt .
22
+
23
+ # Install Python dependencies
24
+ RUN pip install --no-cache-dir -r requirements.txt
25
+
26
+ # Copy the project code
27
+ COPY . .
28
+
29
+ # Create necessary directories
30
+ RUN mkdir -p reports logs temp_repos
31
+
32
+ # Make the run script executable
33
+ RUN chmod +x run.py
34
+
35
+ # Expose the port the app runs on
36
+ EXPOSE 7860
37
+
38
+ # Command to run the application
39
+ CMD ["python", "run.py"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Code Review Agent
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """
5
+ Code Review Agent - Hugging Face Spaces Entry Point
6
+
7
+ This module serves as the entry point for the Code Review Agent application
8
+ when deployed to Hugging Face Spaces.
9
+ """
10
+
11
+ import os
12
+ import sys
13
+ import logging
14
+ from dotenv import load_dotenv
15
+
16
+ # Add the project root to the Python path
17
+ sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
18
+
19
+ # Import application modules
20
+ from src.ui.gradio_app import create_gradio_app
21
+ from src.core.agent_manager import AgentManager
22
+
23
+ # Configure logging
24
+ logging.basicConfig(
25
+ level=logging.INFO,
26
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
27
+ handlers=[
28
+ logging.StreamHandler()
29
+ ]
30
+ )
31
+
32
+ logger = logging.getLogger(__name__)
33
+
34
+ # Load environment variables
35
+ load_dotenv()
36
+
37
+ # Create logs directory if it doesn't exist
38
+ logs_dir = os.path.join(os.path.dirname(__file__), 'logs')
39
+ os.makedirs(logs_dir, exist_ok=True)
40
+
41
+ # Initialize the agent manager
42
+ agent_manager = AgentManager()
43
+
44
+ # Create the Gradio app
45
+ app = create_gradio_app(agent_manager)
46
+
47
+ # For Hugging Face Spaces, we don't need to call app.launch() as it's handled by the platform
48
+ # The app object is automatically detected and launched
docker-compose.yml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ code-review-agent:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ container_name: code-review-agent
9
+ ports:
10
+ - "7860:7860"
11
+ volumes:
12
+ - ./reports:/app/reports
13
+ - ./logs:/app/logs
14
+ - ./.env:/app/.env
15
+ environment:
16
+ - LOG_LEVEL=INFO
17
+ restart: unless-stopped
modal_deploy.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # modal_deploy.py
2
+ from modal import Image, Stub, asgi_app
3
+ import sys
4
+
5
+ # Create a Modal image with the required dependencies
6
+ image = Image.debian_slim().pip_install_from_requirements("requirements.txt")
7
+
8
+ # Create a Modal Stub
9
+ stub = Stub("code-review-agent")
10
+
11
+ @stub.function(image=image, timeout=600)
12
+ @asgi_app()
13
+ def app():
14
+ """
15
+ Deploy the Code Review Agent as an ASGI app on Modal.
16
+
17
+ This function sets up the Gradio application and returns it as an ASGI app
18
+ that Modal can serve. The app will be accessible via a URL provided by Modal
19
+ after deployment.
20
+
21
+ Returns:
22
+ ASGI application: The Gradio app as an ASGI application
23
+ """
24
+ import os
25
+ import sys
26
+ import logging
27
+ from dotenv import load_dotenv
28
+
29
+ # Add the project root to the Python path
30
+ sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
31
+
32
+ # Import application modules
33
+ from src.ui.gradio_app import create_gradio_app
34
+ from src.core.agent_manager import AgentManager
35
+
36
+ # Configure logging
37
+ logging.basicConfig(
38
+ level=logging.INFO,
39
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
40
+ )
41
+
42
+ # Load environment variables
43
+ load_dotenv()
44
+
45
+ # Create logs directory if it doesn't exist
46
+ logs_dir = os.path.join(os.path.dirname(__file__), 'logs')
47
+ os.makedirs(logs_dir, exist_ok=True)
48
+
49
+ # Initialize the agent manager
50
+ agent_manager = AgentManager()
51
+
52
+ # Create the Gradio app
53
+ gradio_app = create_gradio_app(agent_manager)
54
+
55
+ # Return the Gradio app as an ASGI app
56
+ return gradio_app.app
57
+
58
+
59
+ if __name__ == "__main__":
60
+ # For local testing
61
+ stub.serve()
62
+
63
+ # For deployment
64
+ # Run: modal deploy modal_deploy.py
requirements.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Code Review Agent Dependencies
2
+
3
+ # Core Dependencies
4
+ gradio
5
+ requests
6
+ gitpython
7
+ python-dotenv
8
+
9
+ # UI Dependencies
10
+ markdown
11
+ pydantic
12
+
13
+ # Code Analysis
14
+ astroid # Python AST parsing
15
+ pylint # Python linting
16
+ esprima # JavaScript parsing
17
+ jsbeautifier # JavaScript formatting
18
+ # Note: javascript-obfuscator was removed as it's not available on PyPI
19
+ pyright # TypeScript type checking
20
+
21
+ # Security Analysis
22
+ bandit # Python security scanning
23
+ safety # Dependency vulnerability checking
24
+
25
+ # Performance Analysis
26
+ psutil # System utilization
27
+ memory-profiler # Memory profiling
28
+
29
+ # MCP Integration
30
+ openai # OpenAI API client for Nebius integration
31
+
32
+ # Deployment
33
+ modal
34
+
35
+
36
+ pdfkit
sample.env ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Code Review Agent Environment Variables
2
+
3
+ # MCP Integration
4
+ NEBIUS_API_KEY=your_nebius_api_key_here
5
+
6
+ # GitHub Authentication (optional, for private repositories)
7
+ # GITHUB_TOKEN=your_github_token_here
8
+
9
+ # Logging Configuration
10
+ LOG_LEVEL=INFO
11
+
12
+ # Output Directory for Reports
13
+ REPORT_OUTPUT_DIR=reports
14
+
15
+ # Temporary Directory for Cloned Repositories
16
+ REPO_TEMP_DIR=temp_repos
17
+
18
+ # Maximum Repository Size (in MB) to analyze
19
+ MAX_REPO_SIZE_MB=100
20
+
21
+ # Maximum number of files to analyze per language
22
+ MAX_FILES_PER_LANGUAGE=100
23
+
24
+ # Enable/Disable specific analysis features (true/false)
25
+ ENABLE_CODE_ANALYSIS=true
26
+ ENABLE_SECURITY_SCAN=true
27
+ ENABLE_PERFORMANCE_ANALYSIS=true
28
+ ENABLE_AI_REVIEW=true