initial
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,55 @@
|
||||
from crewai import CrewBase, Agent, Task, Crew
|
||||
from crewai_tools import MCPServerAdapter
|
||||
from mcp import StdioServerParameters
|
||||
import os
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
class CodeReviewCrew(CrewBase):
|
||||
"""Code Review Crew for conducting code quality reviews."""
|
||||
|
||||
agents_config = "config/agents.yaml"
|
||||
tasks_config = "config/tasks.yaml"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# Configure Semgrep MCP server connection
|
||||
self.semgrep_server_params = StdioServerParameters(
|
||||
command="semgrep",
|
||||
args=["--metrics=off", "--json", "--stdin-display-name", "scanned_code", "--"],
|
||||
env={
|
||||
**os.environ,
|
||||
"SEMGRAPH_APP_URL": os.getenv("SEMGRAPH_APP_URL", ""),
|
||||
"SEMGRAPH_API_TOKEN": os.getenv("SEMGRAPH_API_TOKEN", ""),
|
||||
}
|
||||
)
|
||||
|
||||
@Agent
|
||||
def code_reviewer(self) -> Agent:
|
||||
"""Senior Software Engineer agent for code review."""
|
||||
return Agent(
|
||||
config=self.agents_config["code_reviewer"],
|
||||
tools=[], # Tools will be added via MCP adapter in the task
|
||||
verbose=True
|
||||
)
|
||||
|
||||
@Task
|
||||
def code_review_task(self) -> Task:
|
||||
"""Task for conducting code review."""
|
||||
return Task(
|
||||
config=self.tasks_config["code_review_task"],
|
||||
)
|
||||
|
||||
@Crew
|
||||
def crew(self) -> Crew:
|
||||
"""Create the Code Review crew."""
|
||||
# Create MCP server adapter for Semgrep
|
||||
semgrep_adapter = MCPServerAdapter(self.semgrep_server_params)
|
||||
|
||||
return Crew(
|
||||
agents=[self.code_reviewer()],
|
||||
tasks=[self.code_review_task()],
|
||||
process="sequential",
|
||||
verbose=True,
|
||||
tools=semgrep_adapter.tools if hasattr(semgrep_adapter, 'tools') else [],
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
# Code Review Crew Agents Configuration
|
||||
code_reviewer:
|
||||
role: Senior Software Engineer
|
||||
goal: Conduct thorough code reviews focusing on code quality, best practices, and maintainability
|
||||
backstory: You are an experienced software engineer with a keen eye for detail and a passion for clean code. You have reviewed thousands of pull requests and helped teams improve their code quality.
|
||||
verbose: true
|
||||
allow_delegation: false
|
||||
@@ -0,0 +1,16 @@
|
||||
# Code Review Crew Tasks Configuration
|
||||
code_review_task:
|
||||
description: |
|
||||
Review the code changes in the pull request for quality, best practices, and maintainability.
|
||||
PR Title: {pr_title}
|
||||
PR Description: {pr_description}
|
||||
Files to review: {files}
|
||||
Context: {context}
|
||||
expected_output: |
|
||||
A detailed code review report including:
|
||||
- Summary of changes
|
||||
- Code quality issues (if any)
|
||||
- Best practices violations (if any)
|
||||
- Suggestions for improvement
|
||||
- Overall rating (e.g., Approved, Changes Needed)
|
||||
agent: code_reviewer
|
||||
Reference in New Issue
Block a user