From 97c3d952d78af07c0eada85074b75a9e2ceea1fb Mon Sep 17 00:00:00 2001 From: PedroS42 Date: Mon, 27 Apr 2026 11:29:14 +0100 Subject: [PATCH 1/2] Add CLI for DevScope AIOps Toolkit with interactive script selection --- aiops_cli.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 aiops_cli.py diff --git a/aiops_cli.py b/aiops_cli.py new file mode 100644 index 0000000..6cca7c6 --- /dev/null +++ b/aiops_cli.py @@ -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() \ No newline at end of file From 1e65f14f34440a82d9937bebe4c0bf61cd3aa897 Mon Sep 17 00:00:00 2001 From: PedroS42 Date: Mon, 27 Apr 2026 11:29:25 +0100 Subject: [PATCH 2/2] Enhance PR diff fetching by adding local git diff --- ai_pr_reviewer.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ai_pr_reviewer.py b/ai_pr_reviewer.py index 89693ec..7b1f12a 100644 --- a/ai_pr_reviewer.py +++ b/ai_pr_reviewer.py @@ -1,6 +1,7 @@ import os import sys import requests +import subprocess from groq import Groq from dotenv import load_dotenv @@ -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 = {