Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ai_pr_reviewer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import requests
import subprocess
from groq import Groq
from dotenv import load_dotenv

Expand All @@ -19,8 +20,17 @@

def get_pr_diff():
if not PR_NUMBER or not GITHUB_TOKEN or not REPO_NAME:
print("Missing GitHub credentials. Cannot fetch PR diff.")
return None
print("Missing GitHub credentials. Attempting to fetch local git diff...")
try:
# Try to get diff against main (simulating a PR)
result = subprocess.run(["git", "diff", "main"], capture_output=True, text=True)
if not result.stdout.strip():
# Fallback to uncommitted/staged changes if no difference with main
result = subprocess.run(["git", "diff", "HEAD"], capture_output=True, text=True)
return result.stdout if result.stdout.strip() else None
except Exception as e:
print(f"Failed to fetch local git diff: {e}")
return None

url = f"https://api.github.com/repos/{REPO_NAME}/pulls/{PR_NUMBER}"
headers = {
Expand Down
67 changes: 67 additions & 0 deletions aiops_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import os
import sys
import subprocess

# ANSI color codes
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
CYAN = '\033[96m'
RESET = '\033[0m'
BOLD = '\033[1m'

def print_header():
header = f"""
{CYAN}====================================================
{BOLD} DevScope AIOps Toolkit
{RESET}{CYAN}===================================================={RESET}
"""
print(header)

def run_script(script_name):
print(f"\n{YELLOW}Running {script_name}...{RESET}\n")
try:
subprocess.run([sys.executable, script_name], check=True)
print(f"\n{GREEN}✔ {script_name} executed successfully.{RESET}\n")
except subprocess.CalledProcessError:
print(f"\n{RED}✖ {script_name} encountered an error.{RESET}\n")
except FileNotFoundError:
print(f"\n{RED}✖ Could not find {script_name}. Ensure you are in the correct directory.{RESET}\n")

def main():
while True:
print_header()
print("Please choose an action:")
print(f" {BOLD}1.{RESET} Inspect and Validate CI/CD Pipelines (ai_pipeline_reviewer.py)")
print(f" {BOLD}2.{RESET} Security Gatekeeper for Terraform (ai_reviewer.py)")
print(f" {BOLD}3.{RESET} Kubernetes Monitoring and Self-Healing (ai_k8s_agent.py)")
print(f" {BOLD}4.{RESET} AI PR Code Reviewer (ai_pr_reviewer.py)")
print(f" {BOLD}5.{RESET} Cost Estimate Functionality (cost_estimate.py)")
print(f" {BOLD}6.{RESET} IaC Generator with AI (iac_generator.py)")
print(f" {BOLD}7.{RESET} Exit")

choice = input(f"\n{CYAN}Enter your choice (1-7): {RESET}")

if choice == '1':
run_script("ai_pipeline_reviewer.py")
elif choice == '2':
run_script("ai_reviewer.py")
elif choice == '3':
run_script("ai_k8s_agent.py")
elif choice == '4':
run_script("ai_pr_reviewer.py")
elif choice == '5':
run_script("cost_estimate.py")
elif choice == '6':
run_script("iac_generator.py")
elif choice == '7':
print(f"\n{GREEN}Exiting DevScope AIOps Toolkit. Goodbye!{RESET}")
sys.exit(0)
else:
print(f"\n{RED}Invalid choice. Please enter a number between 1 and 7.{RESET}\n")

input(f"{YELLOW}Press Enter to continue...{RESET}")
os.system('cls' if os.name == 'nt' else 'clear')

if __name__ == "__main__":
main()
Loading