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
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
# Infrastructure Review Crew Agents Configuration
|
||||
infra_reviewer:
|
||||
role: DevOps/Platform Engineer
|
||||
goal: Review infrastructure as code for correctness, security, and best practices
|
||||
backstory: You are an experienced DevOps engineer with expertise in infrastructure as code, Kubernetes, Docker, and cloud platforms. You help teams ensure their infrastructure is secure, scalable, and follows best practices.
|
||||
verbose: true
|
||||
allow_delegation: false
|
||||
@@ -0,0 +1,16 @@
|
||||
# Infrastructure Review Crew Tasks Configuration
|
||||
infra_review_task:
|
||||
description: |
|
||||
Review the infrastructure as code (IaC) in the pull request for correctness, security, and best practices.
|
||||
PR Title: {pr_title}
|
||||
PR Description: {pr_description}
|
||||
Files to review: {files}
|
||||
Context: {context}
|
||||
expected_output: |
|
||||
A detailed infrastructure review report including:
|
||||
- Summary of infrastructure changes
|
||||
- Issues found (misconfigurations, security vulnerabilities, etc.)
|
||||
- Best practices violations (if any)
|
||||
- Suggestions for improvement
|
||||
- Overall rating (e.g., Approved, Needs Changes)
|
||||
agent: infra_reviewer
|
||||
@@ -0,0 +1,65 @@
|
||||
from crewai import CrewBase, Agent, Task, Crew
|
||||
from crewai_tools import MCPServerAdapter
|
||||
from mcp import StdioServerParameters
|
||||
import os
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
class InfraReviewCrew(CrewBase):
|
||||
"""Infrastructure Review Crew for conducting infrastructure reviews."""
|
||||
|
||||
agents_config = "config/agents.yaml"
|
||||
tasks_config = "config/tasks.yaml"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# Configure Hadolint MCP server connection
|
||||
self.hadolint_server_params = StdioServerParameters(
|
||||
command="python",
|
||||
args=["/home/armistace/dev/pr_reviewer/mcp_servers/hadolint_mcp.py"],
|
||||
env=os.environ
|
||||
)
|
||||
# Configure Checkov MCP server connection
|
||||
self.checkov_server_params = StdioServerParameters(
|
||||
command="python",
|
||||
args=["/home/armistace/dev/pr_reviewer/mcp_servers/checkov_mcp.py"],
|
||||
env=os.environ
|
||||
)
|
||||
|
||||
@Agent
|
||||
def infra_reviewer(self) -> Agent:
|
||||
"""DevOps/Platform Engineer agent for infrastructure review."""
|
||||
return Agent(
|
||||
config=self.agents_config["infra_reviewer"],
|
||||
tools=[], # Tools will be added via MCP adapter in the task
|
||||
verbose=True
|
||||
)
|
||||
|
||||
@Task
|
||||
def infra_review_task(self) -> Task:
|
||||
"""Task for conducting infrastructure review."""
|
||||
return Task(
|
||||
config=self.tasks_config["infra_review_task"],
|
||||
)
|
||||
|
||||
@Crew
|
||||
def crew(self) -> Crew:
|
||||
"""Create the Infrastructure Review crew."""
|
||||
# Create MCP server adapters for Hadolint and Checkov
|
||||
hadolint_adapter = MCPServerAdapter(self.hadolint_server_params)
|
||||
checkov_adapter = MCPServerAdapter(self.checkov_server_params)
|
||||
|
||||
# Combine tools from both adapters
|
||||
all_tools = []
|
||||
if hasattr(hadolint_adapter, 'tools'):
|
||||
all_tools.extend(hadolint_adapter.tools)
|
||||
if hasattr(checkov_adapter, 'tools'):
|
||||
all_tools.extend(checkov_adapter.tools)
|
||||
|
||||
return Crew(
|
||||
agents=[self.infra_reviewer()],
|
||||
tasks=[self.infra_review_task()],
|
||||
process="sequential",
|
||||
verbose=True,
|
||||
tools=all_tools,
|
||||
)
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
# Security Review Crew Agents Configuration
|
||||
security_reviewer:
|
||||
role: Application Security Engineer
|
||||
goal: Identify security vulnerabilities and ensure security best practices are followed
|
||||
backstory: You are an experienced security engineer specialized in application security. You have extensive experience in penetration testing, code security analysis, and helping organizations build secure software.
|
||||
verbose: true
|
||||
allow_delegation: false
|
||||
@@ -0,0 +1,16 @@
|
||||
# Security Review Crew Tasks Configuration
|
||||
security_review_task:
|
||||
description: |
|
||||
Review the code changes in the pull request for security vulnerabilities and compliance with security best practices.
|
||||
PR Title: {pr_title}
|
||||
PR Description: {pr_description}
|
||||
Files to review: {files}
|
||||
Context: {context}
|
||||
expected_output: |
|
||||
A detailed security review report including:
|
||||
- Summary of security-related changes
|
||||
- Identified vulnerabilities (if any)
|
||||
- Security best practices violations (if any)
|
||||
- Suggestions for improving security posture
|
||||
- Overall security rating (e.g., Secure, Needs Improvement)
|
||||
agent: security_reviewer
|
||||
@@ -0,0 +1,51 @@
|
||||
from crewai import CrewBase, Agent, Task, Crew
|
||||
from crewai_tools import MCPServerAdapter
|
||||
from mcp import StdioServerParameters
|
||||
import os
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
class SecurityReviewCrew(CrewBase):
|
||||
"""Security Review Crew for conducting security reviews."""
|
||||
|
||||
agents_config = "config/agents.yaml"
|
||||
tasks_config = "config/tasks.yaml"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# Trivy uses native MCP server, so we don't need to configure a wrapper.
|
||||
# However, we might need to set up connection parameters if required by the native server.
|
||||
# For now, we assume the native Trivy MCP server is available at a known address or via stdio.
|
||||
# We'll leave the MCP server configuration empty and rely on the native server being available.
|
||||
self.trivy_server_params = None # Placeholder for if we need to configure stdio parameters
|
||||
|
||||
@Agent
|
||||
def security_reviewer(self) -> Agent:
|
||||
"""Application Security Engineer agent for security review."""
|
||||
return Agent(
|
||||
config=self.agents_config["security_reviewer"],
|
||||
tools=[], # Tools will be added via MCP adapter in the task
|
||||
verbose=True
|
||||
)
|
||||
|
||||
@Task
|
||||
def security_review_task(self) -> Task:
|
||||
"""Task for conducting security review."""
|
||||
return Task(
|
||||
config=self.tasks_config["security_review_task"],
|
||||
)
|
||||
|
||||
@Crew
|
||||
def crew(self) -> Crew:
|
||||
"""Create the Security Review crew."""
|
||||
# If we had an MCP server to wrap, we would create an adapter here.
|
||||
# Since Trivy is native, we don't add any tools via MCPServerAdapter.
|
||||
# However, the native server should be available in the MCP ecosystem.
|
||||
# We'll assume the tools are automatically available or will be handled differently.
|
||||
return Crew(
|
||||
agents=[self.security_reviewer()],
|
||||
tasks=[self.security_review_task()],
|
||||
process="sequential",
|
||||
verbose=True,
|
||||
# No additional tools from MCP wrapper for Trivy (native)
|
||||
)
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
# Summarizer Crew Agents Configuration
|
||||
summariser:
|
||||
role: Senior Code Review Coordinator
|
||||
goal: Synthesize individual review results into a cohesive, actionable review report
|
||||
backstory: You are a senior technical lead with extensive experience in code review practices across multiple domains. You excel at combining feedback from different reviewers into a clear, prioritized, and actionable summary that helps development teams improve their code efficiently.
|
||||
verbose: true
|
||||
allow_delegation: false
|
||||
@@ -0,0 +1,16 @@
|
||||
# Summarizer Crew Tasks Configuration
|
||||
summarise_task:
|
||||
description: |
|
||||
Synthesize the results from code, security, and infrastructure reviews into a cohesive review report.
|
||||
Code Review Results: {code_review_results}
|
||||
Security Review Results: {security_review_results}
|
||||
Infrastructure Review Results: {infra_review_results}
|
||||
Context: {context}
|
||||
expected_output: |
|
||||
A comprehensive review report that includes:
|
||||
- Executive summary of all findings
|
||||
- Prioritized list of issues (critical, high, medium, low)
|
||||
- Specific recommendations for each domain (code, security, infrastructure)
|
||||
- Overall assessment and recommendation (e.g., Approved, Approved with Minor Changes, Significant Changes Needed)
|
||||
- Summary of positive aspects of the PR
|
||||
agent: summariser
|
||||
@@ -0,0 +1,43 @@
|
||||
from crewai import CrewBase, Agent, Task, Crew
|
||||
from crewai_tools import MCPServerAdapter
|
||||
from mcp import StdioServerParameters
|
||||
import os
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
class SummariserCrew(CrewBase):
|
||||
"""Summariser Crew for synthesizing review results."""
|
||||
|
||||
agents_config = "config/agents.yaml"
|
||||
tasks_config = "config/tasks.yaml"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# The summarizer doesn't need MCP server connections as it works with text results
|
||||
|
||||
@Agent
|
||||
def summariser(self) -> Agent:
|
||||
"""Senior Code Review Coordinator agent for summarizing reviews."""
|
||||
return Agent(
|
||||
config=self.agents_config["summariser"],
|
||||
tools=[], # No tools needed for summarization
|
||||
verbose=True
|
||||
)
|
||||
|
||||
@Task
|
||||
def summarise_task(self) -> Task:
|
||||
"""Task for synthesizing review results."""
|
||||
return Task(
|
||||
config=self.tasks_config["summarise_task"],
|
||||
)
|
||||
|
||||
@Crew
|
||||
def crew(self) -> Crew:
|
||||
"""Create the Summariser crew."""
|
||||
return Crew(
|
||||
agents=[self.summariser()],
|
||||
tasks=[self.summarise_task()],
|
||||
process="sequential",
|
||||
verbose=True,
|
||||
# No additional tools needed
|
||||
)
|
||||
Reference in New Issue
Block a user