| | |
| | """ |
| | Professional CLI Interface Module |
| | ไธไธCLI็้ขๆจกๅ - ๅ
ๅซlogoใ้ข่ฒๅฎไนๅ็้ข็ปไปถ |
| | """ |
| |
|
| | import os |
| | import time |
| | import platform |
| | from pathlib import Path |
| | from typing import Optional |
| | import tkinter as tk |
| | from tkinter import filedialog |
| |
|
| |
|
| | class Colors: |
| | """ANSI color codes for terminal styling""" |
| |
|
| | HEADER = "\033[95m" |
| | OKBLUE = "\033[94m" |
| | OKCYAN = "\033[96m" |
| | OKGREEN = "\033[92m" |
| | WARNING = "\033[93m" |
| | FAIL = "\033[91m" |
| | ENDC = "\033[0m" |
| | BOLD = "\033[1m" |
| | UNDERLINE = "\033[4m" |
| |
|
| | |
| | PURPLE = "\033[35m" |
| | MAGENTA = "\033[95m" |
| | BLUE = "\033[34m" |
| | CYAN = "\033[36m" |
| | GREEN = "\033[32m" |
| | YELLOW = "\033[33m" |
| |
|
| |
|
| | class CLIInterface: |
| | """Professional CLI interface with modern styling""" |
| |
|
| | def __init__(self): |
| | self.uploaded_file = None |
| | self.is_running = True |
| |
|
| | |
| | self.tkinter_available = True |
| | try: |
| | import tkinter as tk |
| |
|
| | |
| | test_root = tk.Tk() |
| | test_root.withdraw() |
| | test_root.destroy() |
| | except Exception: |
| | self.tkinter_available = False |
| |
|
| | def clear_screen(self): |
| | """Clear terminal screen""" |
| | os.system("cls" if os.name == "nt" else "clear") |
| |
|
| | def print_logo(self): |
| | """Print a beautiful ASCII logo with gradient colors and tech elements""" |
| | |
| | logo = f""" |
| | {Colors.CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ โ |
| | โ {Colors.BOLD}{Colors.MAGENTA}โโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโ โโโโโโโ โโโโโโ โโโ{Colors.CYAN} โ |
| | โ {Colors.BOLD}{Colors.PURPLE}โโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโ{Colors.CYAN} โ |
| | โ {Colors.BOLD}{Colors.BLUE}โโโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโโ{Colors.CYAN} โ |
| | โ {Colors.BOLD}{Colors.OKBLUE}โโโโโโโโ โโโโโโ โโโโโโโ โโโโโโโโโโโ โโโ โโโโโโโโโโโ{Colors.CYAN} โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โโโ โโโ โโโโโโโโโโโ โโโ โโโโโโโโโโโโ โโโ โโโโโโ{Colors.CYAN} โ |
| | โ {Colors.BOLD}{Colors.GREEN}โโโ โโโ โโโโโโโโโโโ โโโ โโโ โโโโโโโ โโโ โโโโโโ{Colors.CYAN} โ |
| | โ โ |
| | โ {Colors.BOLD}{Colors.YELLOW}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.CYAN} โ |
| | โ {Colors.BOLD}{Colors.YELLOW}โ ๐ค AI-POWERED RESEARCH PAPER REPRODUCTION ENGINE ๐ โ{Colors.CYAN} โ |
| | โ {Colors.BOLD}{Colors.YELLOW}โ โก INTELLIGENT โข AUTOMATED โข CUTTING-EDGE โก โ{Colors.CYAN} โ |
| | โ {Colors.BOLD}{Colors.YELLOW}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.CYAN} โ |
| | โ โ |
| | โ {Colors.BOLD}{Colors.GREEN}๐ CORE CAPABILITIES:{Colors.ENDC} {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โถ Neural PDF Analysis & Code Extraction {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โถ Advanced Document Processing Engine {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โถ Multi-Format Support (PDFโขDOCXโขPPTXโขHTML) {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โถ Smart File Upload Interface {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โถ Automated Repository Management {Colors.CYAN}โ |
| | โ โ |
| | โ {Colors.BOLD}{Colors.PURPLE}๐ฌ TECH STACK: PythonโขAIโขMCPโขDoclingโขLLM {Colors.CYAN}โ |
| | โ โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """ |
| | print(logo) |
| |
|
| | def print_welcome_banner(self): |
| | """Print welcome banner with version info""" |
| | banner = f""" |
| | {Colors.BOLD}{Colors.CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ WELCOME TO ReproAI โ |
| | โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ |
| | โ โ |
| | โ {Colors.YELLOW}Version: 2.0.0 | Build: Professional Edition {Colors.CYAN}โ |
| | โ {Colors.GREEN}Status: Ready | Engine: Initialized {Colors.CYAN}โ |
| | โ {Colors.PURPLE}Author: AI Research Team | License: MIT {Colors.CYAN}โ |
| | โ โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """ |
| | print(banner) |
| |
|
| | def print_separator(self, char="โ", length=79, color=Colors.CYAN): |
| | """Print a styled separator line""" |
| | print(f"{color}{char * length}{Colors.ENDC}") |
| |
|
| | def print_status(self, message: str, status_type: str = "info"): |
| | """Print status message with appropriate styling""" |
| | status_styles = { |
| | "success": f"{Colors.OKGREEN}โ
", |
| | "error": f"{Colors.FAIL}โ", |
| | "warning": f"{Colors.WARNING}โ ๏ธ ", |
| | "info": f"{Colors.OKBLUE}โน๏ธ ", |
| | "processing": f"{Colors.YELLOW}โณ", |
| | "upload": f"{Colors.PURPLE}๐", |
| | "download": f"{Colors.CYAN}๐ฅ", |
| | "analysis": f"{Colors.MAGENTA}๐", |
| | } |
| |
|
| | icon = status_styles.get(status_type, status_styles["info"]) |
| | print(f"{icon} {Colors.BOLD}{message}{Colors.ENDC}") |
| |
|
| | def create_menu(self): |
| | """Create an interactive menu""" |
| | menu = f""" |
| | {Colors.BOLD}{Colors.CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ MAIN MENU โ |
| | โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ |
| | โ โ |
| | โ {Colors.OKGREEN}๐ [U] Process URL {Colors.CYAN}โ {Colors.PURPLE}๐ [F] Upload File {Colors.CYAN}โ {Colors.FAIL}โ [Q] Quit{Colors.CYAN} โ |
| | โ โ |
| | โ {Colors.YELLOW}๐ Enter a research paper URL (arXiv, IEEE, ACM, etc.) {Colors.CYAN}โ |
| | โ {Colors.YELLOW} or upload a PDF/DOC file for intelligent analysis {Colors.CYAN}โ |
| | โ โ |
| | โ {Colors.OKCYAN}๐ก Tip: Press 'F' to open file browser or 'U' to enter URL manually {Colors.CYAN}โ |
| | โ โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """ |
| | print(menu) |
| |
|
| | def get_user_input(self): |
| | """Get user input with styled prompt""" |
| | print(f"\n{Colors.BOLD}{Colors.OKCYAN}โค Your choice: {Colors.ENDC}", end="") |
| | return input().strip().lower() |
| |
|
| | def upload_file_gui(self) -> Optional[str]: |
| | """Modern file upload interface using tkinter with cross-platform compatibility""" |
| | |
| | if not self.tkinter_available: |
| | self.print_status("GUI file dialog not available on this system", "warning") |
| | self.print_status("Using manual file path input instead", "info") |
| | return self._get_manual_file_path() |
| |
|
| | def select_file(): |
| | try: |
| | |
| | root = tk.Tk() |
| | root.withdraw() |
| |
|
| | |
| | system = platform.system() |
| |
|
| | if system == "Darwin": |
| | |
| | try: |
| | root.call("wm", "attributes", ".", "-topmost", True) |
| | except Exception: |
| | pass |
| |
|
| | |
| | file_types = [ |
| | ("PDF Files", ".pdf"), |
| | ("Word Documents", ".docx .doc"), |
| | ("PowerPoint Files", ".pptx .ppt"), |
| | ("HTML Files", ".html .htm"), |
| | ("Text Files", ".txt .md"), |
| | ("All Files", ".*"), |
| | ] |
| | else: |
| | |
| | root.attributes("-topmost", True) |
| |
|
| | |
| | file_types = [ |
| | ("PDF Files", "*.pdf"), |
| | ("Word Documents", "*.docx;*.doc"), |
| | ("PowerPoint Files", "*.pptx;*.ppt"), |
| | ("HTML Files", "*.html;*.htm"), |
| | ("Text Files", "*.txt;*.md"), |
| | ("All Files", "*.*"), |
| | ] |
| |
|
| | |
| | root.title("Repro-AI - File Selector") |
| |
|
| | try: |
| | |
| | file_path = filedialog.askopenfilename( |
| | title="Select Research Paper File", |
| | filetypes=file_types, |
| | initialdir=os.getcwd(), |
| | ) |
| | except Exception as e: |
| | self.print_status(f"File dialog error: {str(e)}", "error") |
| | return None |
| | finally: |
| | |
| | try: |
| | root.destroy() |
| | except Exception: |
| | pass |
| |
|
| | return file_path |
| |
|
| | except Exception as e: |
| | |
| | try: |
| | if "root" in locals(): |
| | root.destroy() |
| | except Exception: |
| | pass |
| |
|
| | |
| | self.print_status(f"GUI file dialog failed: {str(e)}", "error") |
| | self.print_status( |
| | "Please use manual file path input instead", "warning" |
| | ) |
| | return self._get_manual_file_path() |
| |
|
| | self.print_status("Opening file browser dialog...", "upload") |
| | file_path = select_file() |
| |
|
| | if file_path: |
| | |
| | if not os.path.exists(file_path): |
| | self.print_status("File not found!", "error") |
| | return None |
| |
|
| | file_size = os.path.getsize(file_path) / (1024 * 1024) |
| | file_ext = Path(file_path).suffix.lower() |
| |
|
| | |
| | file_name = Path(file_path).name |
| | directory = str(Path(file_path).parent) |
| |
|
| | |
| | if len(file_name) > 50: |
| | display_name = file_name[:47] + "..." |
| | else: |
| | display_name = file_name |
| |
|
| | if len(directory) > 49: |
| | display_dir = "..." + directory[-46:] |
| | else: |
| | display_dir = directory |
| |
|
| | print(f""" |
| | {Colors.OKGREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ FILE SELECTED โ |
| | โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ |
| | โ โ |
| | โ {Colors.BOLD}๐ File Name:{Colors.ENDC} {Colors.CYAN}{display_name:<50}{Colors.OKGREEN}โ |
| | โ {Colors.BOLD}๐ Directory:{Colors.ENDC} {Colors.YELLOW}{display_dir:<49}{Colors.OKGREEN}โ |
| | โ {Colors.BOLD}๐ File Size:{Colors.ENDC} {Colors.PURPLE}{file_size:.2f} MB{Colors.OKGREEN} โ |
| | โ {Colors.BOLD}๐ File Type:{Colors.ENDC} {Colors.MAGENTA}{file_ext.upper():<50}{Colors.OKGREEN}โ |
| | โ โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """) |
| |
|
| | self.print_status(f"File successfully selected: {file_name}", "success") |
| | return file_path |
| | else: |
| | self.print_status("No file selected", "warning") |
| | return None |
| |
|
| | def _get_manual_file_path(self) -> Optional[str]: |
| | """Fallback method for manual file path input when GUI fails""" |
| | print( |
| | f"\n{Colors.BOLD}{Colors.CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" |
| | ) |
| | print( |
| | "โ MANUAL FILE INPUT โ" |
| | ) |
| | print( |
| | f"โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC}" |
| | ) |
| |
|
| | print(f"\n{Colors.YELLOW}๐ Supported file types:{Colors.ENDC}") |
| | print(f" {Colors.CYAN}โข PDF files (.pdf)") |
| | print(f" {Colors.CYAN}โข Word documents (.docx, .doc)") |
| | print(f" {Colors.CYAN}โข PowerPoint files (.pptx, .ppt)") |
| | print(f" {Colors.CYAN}โข HTML files (.html, .htm)") |
| | print(f" {Colors.CYAN}โข Text files (.txt, .md){Colors.ENDC}") |
| |
|
| | print( |
| | f"\n{Colors.BOLD}{Colors.OKCYAN}๐ Enter file path (or drag & drop): {Colors.ENDC}", |
| | end="", |
| | ) |
| | file_path = input().strip() |
| |
|
| | |
| | file_path = file_path.strip("\"'") |
| |
|
| | if file_path: |
| | |
| | file_path = os.path.expanduser(file_path) |
| |
|
| | |
| | if os.path.exists(file_path): |
| | self.print_status( |
| | f"File found: {os.path.basename(file_path)}", "success" |
| | ) |
| | return file_path |
| | else: |
| | self.print_status("File not found at the specified path", "error") |
| | return None |
| | else: |
| | self.print_status("No file path provided", "warning") |
| | return None |
| |
|
| | def get_url_input(self) -> str: |
| | """Get URL input with validation and examples""" |
| | print( |
| | f"\n{Colors.BOLD}{Colors.CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" |
| | ) |
| | print( |
| | "โ URL INPUT โ" |
| | ) |
| | print( |
| | f"โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC}" |
| | ) |
| |
|
| | print(f"\n{Colors.YELLOW}๐ Supported URL Examples:{Colors.ENDC}") |
| | print(f" {Colors.CYAN}โข arXiv: https://arxiv.org/pdf/2403.00813") |
| | print(f" {Colors.CYAN}โข arXiv: @https://arxiv.org/pdf/2403.00813") |
| | print(f" {Colors.CYAN}โข IEEE: https://ieeexplore.ieee.org/document/...") |
| | print(f" {Colors.CYAN}โข ACM: https://dl.acm.org/doi/...") |
| | print( |
| | f" {Colors.CYAN}โข Direct PDF: https://example.com/paper.pdf{Colors.ENDC}" |
| | ) |
| |
|
| | print( |
| | f"\n{Colors.BOLD}{Colors.OKCYAN}๐ Enter paper URL: {Colors.ENDC}", end="" |
| | ) |
| | url = input().strip() |
| |
|
| | if url: |
| | |
| | if any( |
| | domain in url.lower() |
| | for domain in ["arxiv.org", "ieee", "acm.org", ".pdf", "researchgate"] |
| | ): |
| | self.print_status(f"URL received: {url}", "success") |
| | return url |
| | else: |
| | self.print_status("URL appears valid, proceeding...", "info") |
| | return url |
| | else: |
| | self.print_status("No URL provided", "warning") |
| | return "" |
| |
|
| | def show_progress_bar(self, message: str, duration: float = 2.0): |
| | """Show a progress animation with enhanced styling""" |
| | print(f"\n{Colors.YELLOW}{message}{Colors.ENDC}") |
| |
|
| | |
| | bar_length = 50 |
| | for i in range(bar_length + 1): |
| | percent = (i / bar_length) * 100 |
| | filled = "โ" * i |
| | empty = "โ" * (bar_length - i) |
| |
|
| | |
| | if percent < 33: |
| | color = Colors.FAIL |
| | elif percent < 66: |
| | color = Colors.WARNING |
| | else: |
| | color = Colors.OKGREEN |
| |
|
| | print( |
| | f"\r{color}[{filled}{empty}] {percent:6.1f}%{Colors.ENDC}", |
| | end="", |
| | flush=True, |
| | ) |
| | time.sleep(duration / bar_length) |
| |
|
| | print(f"\n{Colors.OKGREEN}โ
{message} completed!{Colors.ENDC}\n") |
| |
|
| | def show_spinner(self, message: str, duration: float = 1.0): |
| | """Show a spinner animation""" |
| | spinner_chars = "โ โ โ นโ ธโ ผโ ดโ ฆโ งโ โ " |
| | end_time = time.time() + duration |
| |
|
| | while time.time() < end_time: |
| | for char in spinner_chars: |
| | print( |
| | f"\r{Colors.CYAN}{char} {Colors.BOLD}{message}{Colors.ENDC}", |
| | end="", |
| | flush=True, |
| | ) |
| | time.sleep(0.1) |
| | if time.time() >= end_time: |
| | break |
| |
|
| | print(f"\r{Colors.OKGREEN}โ
{Colors.BOLD}{message} - Done!{Colors.ENDC}") |
| |
|
| | def print_results_header(self): |
| | """Print results section header""" |
| | header = f""" |
| | {Colors.OKGREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ PROCESSING RESULTS โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """ |
| | print(header) |
| |
|
| | def print_error_box(self, title: str, error_msg: str): |
| | """Print error message in a styled box""" |
| | print(f""" |
| | {Colors.FAIL}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ ERROR โ |
| | โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ |
| | โ โ |
| | โ {Colors.BOLD}Title: {title:<66}{Colors.FAIL}โ |
| | โ {Colors.BOLD}Error: {error_msg:<66}{Colors.FAIL}โ |
| | โ โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """) |
| |
|
| | def print_goodbye(self): |
| | """Print goodbye message""" |
| | goodbye = f""" |
| | {Colors.BOLD}{Colors.YELLOW}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ GOODBYE! โ |
| | โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ |
| | โ โ |
| | โ {Colors.CYAN}Thank you for using ReproAI! {Colors.YELLOW}โ |
| | โ {Colors.GREEN}๐ Star us on GitHub: https://github.com/your-repo {Colors.YELLOW}โ |
| | โ {Colors.PURPLE}๐ง Contact: support@reproai.com {Colors.YELLOW}โ |
| | โ {Colors.MAGENTA}๐ Report issues: https://github.com/your-repo/issues {Colors.YELLOW}โ |
| | โ โ |
| | โ {Colors.OKGREEN}โจ Happy coding! See you next time! โจ {Colors.YELLOW}โ |
| | โ โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """ |
| | print(goodbye) |
| |
|
| | def ask_continue(self) -> bool: |
| | """Ask user if they want to continue""" |
| | print( |
| | f"\n{Colors.BOLD}{Colors.CYAN}Press Enter to continue or 'q' to quit: {Colors.ENDC}", |
| | end="", |
| | ) |
| | choice = input().strip().lower() |
| | return choice not in ["q", "quit", "exit"] |
| |
|