| | |
| | """ |
| | Enhanced CLI Interface Module for DeepCode |
| | ๅขๅผบ็CLI็้ขๆจกๅ - ไธไธบDeepCode่ฎพ่ฎก |
| | """ |
| |
|
| | import os |
| | import time |
| | import platform |
| | from typing import Optional |
| |
|
| |
|
| | 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: |
| | """Enhanced CLI interface with modern styling for DeepCode""" |
| |
|
| | def __init__(self): |
| | self.uploaded_file = None |
| | self.is_running = True |
| | self.processing_history = [] |
| | self.enable_indexing = True |
| | self.segmentation_enabled = True |
| | self.segmentation_threshold = 50000 |
| |
|
| | |
| | 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 enhanced ASCII logo for DeepCode CLI""" |
| | 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.GREEN}๐งฌ OPEN-SOURCE CODE AGENT โข DATA INTELLIGENCE LAB @ HKU ๐ {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.GREEN}โก REVOLUTIONIZING RESEARCH REPRODUCIBILITY โก {Colors.CYAN}โ |
| | โ โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """ |
| | print(logo) |
| |
|
| | def print_welcome_banner(self): |
| | """Print enhanced welcome banner""" |
| | banner = f""" |
| | {Colors.BOLD}{Colors.CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ WELCOME TO DEEPCODE CLI โ |
| | โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ |
| | โ {Colors.YELLOW}Open-Source Code Agent | Data Intelligence Lab @ HKU | MIT License {Colors.CYAN}โ |
| | โ {Colors.GREEN}Status: Ready | Engine: Multi-Agent Architecture Initialized {Colors.CYAN}โ |
| | โ {Colors.PURPLE}Mission: Revolutionizing Research Reproducibility {Colors.CYAN}โ |
| | โ โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}๐ CORE CAPABILITIES:{Colors.ENDC} {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โถ Automated Paper-to-Code Reproduction {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โถ Collaborative Multi-Agent Architecture {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โถ Intelligent Code Implementation & Validation {Colors.CYAN}โ |
| | โ {Colors.BOLD}{Colors.OKCYAN}โถ Future Vision: One Sentence โ Complete Codebase {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}๐", |
| | "implementation": f"{Colors.GREEN}โ๏ธ ", |
| | "complete": f"{Colors.OKGREEN}๐", |
| | } |
| |
|
| | icon = status_styles.get(status_type, status_styles["info"]) |
| | timestamp = time.strftime("%H:%M:%S") |
| | print( |
| | f"[{Colors.BOLD}{timestamp}{Colors.ENDC}] {icon} {Colors.BOLD}{message}{Colors.ENDC}" |
| | ) |
| |
|
| | def create_menu(self): |
| | """Create enhanced interactive menu""" |
| | |
| | pipeline_mode = "๐ง COMPREHENSIVE" if self.enable_indexing else "โก OPTIMIZED" |
| | index_status = "โ
Enabled" if self.enable_indexing else "๐ถ Disabled" |
| | segmentation_mode = ( |
| | "๐ SMART" if self.segmentation_enabled else "๐ TRADITIONAL" |
| | ) |
| |
|
| | menu = f""" |
| | {Colors.BOLD}{Colors.CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ MAIN MENU โ |
| | โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ |
| | โ {Colors.OKGREEN}๐ [U] Process URL {Colors.CYAN}โ {Colors.PURPLE}๐ [F] Upload File {Colors.CYAN}โ {Colors.MAGENTA}๐ฌ [T] Chat Input{Colors.CYAN} โ |
| | โ {Colors.OKCYAN}โ๏ธ [C] Configure {Colors.CYAN}โ {Colors.YELLOW}๐ [H] History {Colors.CYAN}โ {Colors.FAIL}โ [Q] Quit{Colors.CYAN} โ |
| | โ โ |
| | โ {Colors.BOLD}๐ค Current Pipeline Mode: {pipeline_mode}{Colors.CYAN} โ |
| | โ {Colors.BOLD}๐๏ธ Codebase Indexing: {index_status}{Colors.CYAN} โ |
| | โ {Colors.BOLD}๐ Document Processing: {segmentation_mode}{Colors.CYAN} โ |
| | โ โ |
| | โ {Colors.YELLOW}๐ URL Processing:{Colors.CYAN} โ |
| | โ {Colors.YELLOW} โถ Enter research paper URL (arXiv, IEEE, ACM, etc.) {Colors.CYAN}โ |
| | โ {Colors.YELLOW} โถ Supports direct PDF links and academic paper pages {Colors.CYAN}โ |
| | โ โ |
| | โ {Colors.PURPLE}๐ File Processing:{Colors.CYAN} โ |
| | โ {Colors.PURPLE} โถ Upload PDF, DOCX, PPTX, HTML, or TXT files {Colors.CYAN}โ |
| | โ {Colors.PURPLE} โถ Intelligent file format detection and processing {Colors.CYAN}โ |
| | โ โ |
| | โ {Colors.MAGENTA}๐ฌ Chat Input:{Colors.CYAN} โ |
| | โ {Colors.MAGENTA} โถ Describe your coding requirements in natural language {Colors.CYAN}โ |
| | โ {Colors.MAGENTA} โถ AI generates implementation plan and code automatically {Colors.CYAN}โ |
| | โ โ |
| | โ {Colors.OKCYAN}๐ Processing Pipeline:{Colors.CYAN} โ |
| | โ {Colors.OKCYAN} โถ Intelligent agent orchestration โ Code synthesis {Colors.CYAN}โ |
| | โ {Colors.OKCYAN} โถ Multi-agent coordination with progress tracking {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]: |
| | """Enhanced file upload interface with better error handling""" |
| | if not self.tkinter_available: |
| | self.print_status( |
| | "GUI file dialog not available - using manual input", "warning" |
| | ) |
| | return self._get_manual_file_path() |
| |
|
| | def select_file(): |
| | try: |
| | import tkinter as tk |
| | from tkinter import filedialog |
| |
|
| | root = tk.Tk() |
| | root.withdraw() |
| | root.attributes("-topmost", True) |
| |
|
| | file_types = [ |
| | ("Research Papers", "*.pdf;*.docx;*.doc"), |
| | ("PDF Files", "*.pdf"), |
| | ("Word Documents", "*.docx;*.doc"), |
| | ("PowerPoint Files", "*.pptx;*.ppt"), |
| | ("HTML Files", "*.html;*.htm"), |
| | ("Text Files", "*.txt;*.md"), |
| | ("All Files", "*.*"), |
| | ] |
| |
|
| | if platform.system() == "Darwin": |
| | file_types = [ |
| | ("Research Papers", ".pdf .docx .doc"), |
| | ("PDF Files", ".pdf"), |
| | ("Word Documents", ".docx .doc"), |
| | ("PowerPoint Files", ".pptx .ppt"), |
| | ("HTML Files", ".html .htm"), |
| | ("Text Files", ".txt .md"), |
| | ("All Files", ".*"), |
| | ] |
| |
|
| | file_path = filedialog.askopenfilename( |
| | title="Select Research File - DeepCode CLI", |
| | filetypes=file_types, |
| | initialdir=os.getcwd(), |
| | ) |
| |
|
| | root.destroy() |
| | return file_path |
| |
|
| | except Exception as e: |
| | self.print_status(f"File dialog error: {str(e)}", "error") |
| | return self._get_manual_file_path() |
| |
|
| | self.print_status("Opening file browser dialog...", "upload") |
| | file_path = select_file() |
| |
|
| | if file_path: |
| | self.print_status( |
| | f"File selected: {os.path.basename(file_path)}", "success" |
| | ) |
| | return file_path |
| | else: |
| | self.print_status("No file selected", "warning") |
| | return None |
| |
|
| | def _get_manual_file_path(self) -> Optional[str]: |
| | """Get file path through manual input with validation""" |
| | self.print_separator("โ", 79, Colors.YELLOW) |
| | print(f"{Colors.BOLD}{Colors.YELLOW}๐ Manual File Path Input{Colors.ENDC}") |
| | print( |
| | f"{Colors.CYAN}Please enter the full path to your research paper file:{Colors.ENDC}" |
| | ) |
| | print( |
| | f"{Colors.CYAN}Supported formats: PDF, DOCX, PPTX, HTML, TXT, MD{Colors.ENDC}" |
| | ) |
| | self.print_separator("โ", 79, Colors.YELLOW) |
| |
|
| | while True: |
| | print(f"\n{Colors.BOLD}{Colors.OKCYAN}๐ File path: {Colors.ENDC}", end="") |
| | file_path = input().strip() |
| |
|
| | if not file_path: |
| | self.print_status( |
| | "Empty path entered. Please try again or press Ctrl+C to cancel.", |
| | "warning", |
| | ) |
| | continue |
| |
|
| | file_path = os.path.expanduser(file_path) |
| | file_path = os.path.abspath(file_path) |
| |
|
| | if not os.path.exists(file_path): |
| | self.print_status(f"File not found: {file_path}", "error") |
| | retry = ( |
| | input(f"{Colors.YELLOW}Try again? (y/n): {Colors.ENDC}") |
| | .strip() |
| | .lower() |
| | ) |
| | if retry != "y": |
| | return None |
| | continue |
| |
|
| | if not os.path.isfile(file_path): |
| | self.print_status(f"Path is not a file: {file_path}", "error") |
| | continue |
| |
|
| | supported_extensions = { |
| | ".pdf", |
| | ".docx", |
| | ".doc", |
| | ".pptx", |
| | ".ppt", |
| | ".html", |
| | ".htm", |
| | ".txt", |
| | ".md", |
| | } |
| | file_ext = os.path.splitext(file_path)[1].lower() |
| |
|
| | if file_ext not in supported_extensions: |
| | self.print_status(f"Unsupported file format: {file_ext}", "warning") |
| | proceed = ( |
| | input(f"{Colors.YELLOW}Process anyway? (y/n): {Colors.ENDC}") |
| | .strip() |
| | .lower() |
| | ) |
| | if proceed != "y": |
| | continue |
| |
|
| | self.print_status( |
| | f"File validated: {os.path.basename(file_path)}", "success" |
| | ) |
| | return file_path |
| |
|
| | def get_url_input(self) -> str: |
| | """Enhanced URL input with validation""" |
| | self.print_separator("โ", 79, Colors.GREEN) |
| | print(f"{Colors.BOLD}{Colors.GREEN}๐ URL Input Interface{Colors.ENDC}") |
| | print( |
| | f"{Colors.CYAN}Enter a research paper URL from supported platforms:{Colors.ENDC}" |
| | ) |
| | print( |
| | f"{Colors.CYAN}โข arXiv (arxiv.org) โข IEEE Xplore (ieeexplore.ieee.org){Colors.ENDC}" |
| | ) |
| | print( |
| | f"{Colors.CYAN}โข ACM Digital Library โข SpringerLink โข Nature โข Science{Colors.ENDC}" |
| | ) |
| | print( |
| | f"{Colors.CYAN}โข Direct PDF links โข Academic publisher websites{Colors.ENDC}" |
| | ) |
| | self.print_separator("โ", 79, Colors.GREEN) |
| |
|
| | while True: |
| | print(f"\n{Colors.BOLD}{Colors.OKCYAN}๐ URL: {Colors.ENDC}", end="") |
| | url = input().strip() |
| |
|
| | if not url: |
| | self.print_status( |
| | "Empty URL entered. Please try again or press Ctrl+C to cancel.", |
| | "warning", |
| | ) |
| | continue |
| |
|
| | if not url.startswith(("http://", "https://")): |
| | self.print_status("URL must start with http:// or https://", "error") |
| | retry = ( |
| | input(f"{Colors.YELLOW}Try again? (y/n): {Colors.ENDC}") |
| | .strip() |
| | .lower() |
| | ) |
| | if retry != "y": |
| | return "" |
| | continue |
| |
|
| | academic_domains = [ |
| | "arxiv.org", |
| | "ieeexplore.ieee.org", |
| | "dl.acm.org", |
| | "link.springer.com", |
| | "nature.com", |
| | "science.org", |
| | "scholar.google.com", |
| | "researchgate.net", |
| | "semanticscholar.org", |
| | ] |
| |
|
| | is_academic = any(domain in url.lower() for domain in academic_domains) |
| | if not is_academic and not url.lower().endswith(".pdf"): |
| | self.print_status( |
| | "URL doesn't appear to be from a known academic platform", "warning" |
| | ) |
| | proceed = ( |
| | input(f"{Colors.YELLOW}Process anyway? (y/n): {Colors.ENDC}") |
| | .strip() |
| | .lower() |
| | ) |
| | if proceed != "y": |
| | continue |
| |
|
| | self.print_status(f"URL validated: {url}", "success") |
| | return url |
| |
|
| | def get_chat_input(self) -> str: |
| | """Enhanced chat input interface for coding requirements""" |
| | self.print_separator("โ", 79, Colors.PURPLE) |
| | print(f"{Colors.BOLD}{Colors.PURPLE}๐ฌ Chat Input Interface{Colors.ENDC}") |
| | print( |
| | f"{Colors.CYAN}Describe your coding requirements in natural language.{Colors.ENDC}" |
| | ) |
| | print( |
| | f"{Colors.CYAN}Our AI will analyze your needs and generate a comprehensive implementation plan.{Colors.ENDC}" |
| | ) |
| | self.print_separator("โ", 79, Colors.PURPLE) |
| |
|
| | |
| | print(f"\n{Colors.BOLD}{Colors.YELLOW}๐ก Examples:{Colors.ENDC}") |
| | print(f"{Colors.CYAN}Academic Research:{Colors.ENDC}") |
| | print( |
| | " โข 'I need to implement a reinforcement learning algorithm for robotic control'" |
| | ) |
| | print( |
| | " โข 'Create a neural network for image classification with attention mechanisms'" |
| | ) |
| | print(f"{Colors.CYAN}Engineering Projects:{Colors.ENDC}") |
| | print( |
| | " โข 'Develop a web application for project management with user authentication'" |
| | ) |
| | print(" โข 'Create a data visualization dashboard for sales analytics'") |
| | print(f"{Colors.CYAN}Mixed Projects:{Colors.ENDC}") |
| | print( |
| | " โข 'Implement a machine learning model with a web interface for real-time predictions'" |
| | ) |
| |
|
| | self.print_separator("โ", 79, Colors.PURPLE) |
| |
|
| | print( |
| | f"\n{Colors.BOLD}{Colors.OKCYAN}โ๏ธ Enter your coding requirements below:{Colors.ENDC}" |
| | ) |
| | print( |
| | f"{Colors.YELLOW}(Type your description, press Enter twice when finished, or Ctrl+C to cancel){Colors.ENDC}" |
| | ) |
| |
|
| | lines = [] |
| | empty_line_count = 0 |
| |
|
| | while True: |
| | try: |
| | if len(lines) == 0: |
| | print(f"{Colors.BOLD}> {Colors.ENDC}", end="") |
| | else: |
| | print(f"{Colors.BOLD} {Colors.ENDC}", end="") |
| |
|
| | line = input() |
| |
|
| | if line.strip() == "": |
| | empty_line_count += 1 |
| | if empty_line_count >= 2: |
| | |
| | break |
| | lines.append("") |
| | else: |
| | empty_line_count = 0 |
| | lines.append(line) |
| |
|
| | except KeyboardInterrupt: |
| | print(f"\n{Colors.WARNING}Input cancelled by user{Colors.ENDC}") |
| | return "" |
| |
|
| | |
| | user_input = "\n".join(lines).strip() |
| |
|
| | if not user_input: |
| | self.print_status("No input provided", "warning") |
| | return "" |
| |
|
| | if len(user_input) < 20: |
| | self.print_status( |
| | "Input too short. Please provide more detailed requirements (at least 20 characters)", |
| | "warning", |
| | ) |
| | retry = ( |
| | input(f"{Colors.YELLOW}Try again? (y/n): {Colors.ENDC}").strip().lower() |
| | ) |
| | if retry == "y": |
| | return self.get_chat_input() |
| | return "" |
| |
|
| | |
| | word_count = len(user_input.split()) |
| | char_count = len(user_input) |
| |
|
| | print(f"\n{Colors.BOLD}{Colors.GREEN}๐ Input Summary:{Colors.ENDC}") |
| | print(f" โข {Colors.CYAN}Word count: {word_count}{Colors.ENDC}") |
| | print(f" โข {Colors.CYAN}Character count: {char_count}{Colors.ENDC}") |
| |
|
| | |
| | preview = user_input[:200] + "..." if len(user_input) > 200 else user_input |
| | print(f"\n{Colors.BOLD}{Colors.CYAN}๐ Preview:{Colors.ENDC}") |
| | print(f"{Colors.YELLOW}{preview}{Colors.ENDC}") |
| |
|
| | |
| | confirm = ( |
| | input( |
| | f"\n{Colors.BOLD}{Colors.OKCYAN}Proceed with this input? (y/n): {Colors.ENDC}" |
| | ) |
| | .strip() |
| | .lower() |
| | ) |
| | if confirm != "y": |
| | retry = ( |
| | input(f"{Colors.YELLOW}Edit input? (y/n): {Colors.ENDC}") |
| | .strip() |
| | .lower() |
| | ) |
| | if retry == "y": |
| | return self.get_chat_input() |
| | return "" |
| |
|
| | self.print_status( |
| | f"Chat input captured: {word_count} words, {char_count} characters", |
| | "success", |
| | ) |
| | return user_input |
| |
|
| | def show_progress_bar(self, message: str, duration: float = 2.0): |
| | """Show animated progress bar""" |
| | print(f"\n{Colors.BOLD}{Colors.CYAN}{message}{Colors.ENDC}") |
| |
|
| | bar_length = 50 |
| | for i in range(bar_length + 1): |
| | percent = (i / bar_length) * 100 |
| | filled = "โ" * i |
| | empty = "โ" * (bar_length - i) |
| |
|
| | print( |
| | f"\r{Colors.OKGREEN}[{filled}{empty}] {percent:3.0f}%{Colors.ENDC}", |
| | end="", |
| | flush=True, |
| | ) |
| | time.sleep(duration / bar_length) |
| |
|
| | print(f"\n{Colors.OKGREEN}โ {message} completed{Colors.ENDC}") |
| |
|
| | def show_spinner(self, message: str, duration: float = 1.0): |
| | """Show spinner animation""" |
| | spinner_chars = "โ โ โ นโ ธโ ผโ ดโ ฆโ งโ โ " |
| | end_time = time.time() + duration |
| |
|
| | print( |
| | f"{Colors.BOLD}{Colors.CYAN}{message}... {Colors.ENDC}", end="", flush=True |
| | ) |
| |
|
| | i = 0 |
| | while time.time() < end_time: |
| | print( |
| | f"\r{Colors.BOLD}{Colors.CYAN}{message}... {Colors.YELLOW}{spinner_chars[i % len(spinner_chars)]}{Colors.ENDC}", |
| | end="", |
| | flush=True, |
| | ) |
| | time.sleep(0.1) |
| | i += 1 |
| |
|
| | print( |
| | f"\r{Colors.BOLD}{Colors.CYAN}{message}... {Colors.OKGREEN}โ{Colors.ENDC}" |
| | ) |
| |
|
| | def display_processing_stages( |
| | self, |
| | current_stage: int = 0, |
| | enable_indexing: bool = True, |
| | chat_mode: bool = False, |
| | ): |
| | """Display processing pipeline stages with current progress""" |
| | if chat_mode: |
| | |
| | stages = [ |
| | ("๐", "Initialize", "Setting up chat engine"), |
| | ("๐ฌ", "Planning", "Analyzing requirements"), |
| | ("๐๏ธ", "Setup", "Creating workspace"), |
| | ("๐", "Save Plan", "Saving implementation plan"), |
| | ("โ๏ธ", "Implement", "Generating code"), |
| | ] |
| | pipeline_mode = "CHAT PLANNING" |
| | elif enable_indexing: |
| | |
| | stages = [ |
| | ("๐", "Initialize", "Setting up AI engine"), |
| | ("๐", "Analyze", "Analyzing research content"), |
| | ("๐ฅ", "Download", "Processing document"), |
| | ("๐", "Plan", "Generating code architecture"), |
| | ("๐", "References", "Analyzing references"), |
| | ("๐ฆ", "Repos", "Downloading repositories"), |
| | ("๐๏ธ", "Index", "Building code index"), |
| | ("โ๏ธ", "Implement", "Implementing code"), |
| | ] |
| | pipeline_mode = "COMPREHENSIVE" |
| | else: |
| | |
| | stages = [ |
| | ("๐", "Initialize", "Setting up AI engine"), |
| | ("๐", "Analyze", "Analyzing research content"), |
| | ("๐ฅ", "Download", "Processing document"), |
| | ("๐", "Plan", "Generating code architecture"), |
| | ("โ๏ธ", "Implement", "Implementing code"), |
| | ] |
| | pipeline_mode = "OPTIMIZED" |
| |
|
| | print( |
| | f"\n{Colors.BOLD}{Colors.CYAN}๐ {pipeline_mode} PIPELINE STATUS{Colors.ENDC}" |
| | ) |
| | self.print_separator("โ", 79, Colors.CYAN) |
| |
|
| | for i, (icon, name, desc) in enumerate(stages): |
| | if i < current_stage: |
| | status = f"{Colors.OKGREEN}โ COMPLETED{Colors.ENDC}" |
| | elif i == current_stage: |
| | status = f"{Colors.YELLOW}โณ IN PROGRESS{Colors.ENDC}" |
| | else: |
| | status = f"{Colors.CYAN}โธ๏ธ PENDING{Colors.ENDC}" |
| |
|
| | print( |
| | f"{icon} {Colors.BOLD}{name:<12}{Colors.ENDC} โ {desc:<25} โ {status}" |
| | ) |
| |
|
| | self.print_separator("โ", 79, Colors.CYAN) |
| |
|
| | def print_results_header(self): |
| | """Print results section header""" |
| | header = f""" |
| | {Colors.BOLD}{Colors.OKGREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ PROCESSING RESULTS โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """ |
| | print(header) |
| |
|
| | def print_error_box(self, title: str, error_msg: str): |
| | """Print formatted error box""" |
| | print( |
| | f"\n{Colors.FAIL}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" |
| | ) |
| | print(f"โ {Colors.BOLD}ERROR: {title:<50}{Colors.FAIL} โ") |
| | print("โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ") |
| |
|
| | words = error_msg.split() |
| | lines = [] |
| | current_line = "" |
| |
|
| | for word in words: |
| | if len(current_line + word) <= 54: |
| | current_line += word + " " |
| | else: |
| | lines.append(current_line.strip()) |
| | current_line = word + " " |
| | if current_line: |
| | lines.append(current_line.strip()) |
| |
|
| | for line in lines: |
| | print(f"โ {line:<56} โ") |
| |
|
| | print( |
| | f"โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC}" |
| | ) |
| |
|
| | def cleanup_cache(self): |
| | """ๆธ
็Python็ผๅญๆไปถ / Clean up Python cache files""" |
| | try: |
| | self.print_status("Cleaning up cache files...", "info") |
| | |
| | os.system('find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null') |
| | |
| | os.system('find . -name "*.pyc" -delete 2>/dev/null') |
| | self.print_status("Cache cleanup completed", "success") |
| | except Exception as e: |
| | self.print_status(f"Cache cleanup failed: {e}", "warning") |
| |
|
| | def print_goodbye(self): |
| | """Print goodbye message""" |
| | |
| | self.cleanup_cache() |
| |
|
| | goodbye = f""" |
| | {Colors.BOLD}{Colors.CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ GOODBYE โ |
| | โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ |
| | โ {Colors.OKGREEN}๐ Thank you for using DeepCode CLI! {Colors.CYAN}โ |
| | โ โ |
| | โ {Colors.YELLOW}๐งฌ Join our community in revolutionizing research reproducibility {Colors.CYAN}โ |
| | โ {Colors.PURPLE}โก Together, we're building the future of automated code generation {Colors.CYAN}โ |
| | โ โ |
| | โ {Colors.OKCYAN}๐ก Questions? Contribute to our open-source mission at GitHub {Colors.CYAN}โ |
| | โ {Colors.GREEN}๐งน Cache files cleaned up for optimal performance {Colors.CYAN}โ |
| | โ โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """ |
| | print(goodbye) |
| |
|
| | def ask_continue(self) -> bool: |
| | """Ask if user wants to continue with another paper""" |
| | self.print_separator("โ", 79, Colors.YELLOW) |
| | print(f"\n{Colors.BOLD}{Colors.YELLOW}๐ Process another paper?{Colors.ENDC}") |
| | choice = input(f"{Colors.OKCYAN}Continue? (y/n): {Colors.ENDC}").strip().lower() |
| | return choice in ["y", "yes", "1", "true"] |
| |
|
| | def add_to_history(self, input_source: str, result: dict): |
| | """Add processing result to history""" |
| | entry = { |
| | "timestamp": time.strftime("%Y-%m-%d %H:%M:%S"), |
| | "input_source": input_source, |
| | "status": result.get("status", "unknown"), |
| | "result": result, |
| | } |
| | self.processing_history.append(entry) |
| |
|
| | def show_history(self): |
| | """Display processing history""" |
| | if not self.processing_history: |
| | self.print_status("No processing history available", "info") |
| | return |
| |
|
| | print(f"\n{Colors.BOLD}{Colors.CYAN}๐ PROCESSING HISTORY{Colors.ENDC}") |
| | self.print_separator("โ", 79, Colors.CYAN) |
| |
|
| | for i, entry in enumerate(self.processing_history, 1): |
| | status_icon = "โ
" if entry["status"] == "success" else "โ" |
| | source = entry["input_source"] |
| | if len(source) > 50: |
| | source = source[:47] + "..." |
| |
|
| | print(f"{i}. {status_icon} {entry['timestamp']} | {source}") |
| |
|
| | self.print_separator("โ", 79, Colors.CYAN) |
| |
|
| | def show_configuration_menu(self): |
| | """Show configuration options menu""" |
| | self.clear_screen() |
| |
|
| | |
| | segmentation_enabled = getattr(self, "segmentation_enabled", True) |
| | segmentation_threshold = getattr(self, "segmentation_threshold", 50000) |
| |
|
| | print(f""" |
| | {Colors.BOLD}{Colors.CYAN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
| | โ CONFIGURATION MENU โ |
| | โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ |
| | โ โ |
| | โ {Colors.BOLD}๐ค Agent Orchestration Engine Configuration{Colors.CYAN} โ |
| | โ โ |
| | โ {Colors.OKCYAN}[1] Pipeline Mode:{Colors.CYAN} โ |
| | โ {Colors.BOLD}๐ง Comprehensive Mode{Colors.CYAN} - Full intelligence analysis (Default) โ |
| | โ โ Research Analysis + Resource Processing โ |
| | โ โ Reference Intelligence Discovery โ |
| | โ โ Automated Repository Acquisition โ |
| | โ โ Codebase Intelligence Orchestration โ |
| | โ โ Intelligent Code Implementation Synthesis โ |
| | โ โ |
| | โ {Colors.BOLD}โก Optimized Mode{Colors.CYAN} - Fast processing (Skip indexing) โ |
| | โ โ Research Analysis + Resource Processing โ |
| | โ โ Code Architecture Synthesis โ |
| | โ โ Intelligent Code Implementation Synthesis โ |
| | โ โ Reference Intelligence Discovery (Skipped) โ |
| | โ โ Repository Acquisition (Skipped) โ |
| | โ โ Codebase Intelligence Orchestration (Skipped) โ |
| | โ โ |
| | โ {Colors.OKCYAN}[2] Document Processing:{Colors.CYAN} โ |
| | โ {Colors.BOLD}๐ Smart Segmentation{Colors.CYAN} - Intelligent document analysis (Default) โ |
| | โ โ Semantic boundary detection โ |
| | โ โ Algorithm integrity preservation โ |
| | โ โ Formula chain recognition โ |
| | โ โ Adaptive character limits โ |
| | โ โ |
| | โ {Colors.BOLD}๐ Traditional Processing{Colors.CYAN} - Full document reading โ |
| | โ โ Complete document analysis โ |
| | โ โ Smart segmentation (Disabled) โ |
| | โ โ |
| | โ {Colors.YELLOW}Current Settings:{Colors.CYAN} โ |
| | โ Pipeline: {'๐ง Comprehensive Mode' if self.enable_indexing else 'โก Optimized Mode'} โ |
| | โ Document: {'๐ Smart Segmentation' if segmentation_enabled else '๐ Traditional Processing'} โ |
| | โ Threshold: {segmentation_threshold} characters โ |
| | โ โ |
| | โ {Colors.OKGREEN}[T] Toggle Pipeline {Colors.BLUE}[S] Toggle Segmentation {Colors.FAIL}[B] Back{Colors.CYAN} โ |
| | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ{Colors.ENDC} |
| | """) |
| |
|
| | while True: |
| | print( |
| | f"\n{Colors.BOLD}{Colors.OKCYAN}โค Configuration choice: {Colors.ENDC}", |
| | end="", |
| | ) |
| | choice = input().strip().lower() |
| |
|
| | if choice in ["t", "toggle"]: |
| | self.enable_indexing = not self.enable_indexing |
| | mode = "๐ง Comprehensive" if self.enable_indexing else "โก Optimized" |
| | self.print_status(f"Pipeline mode switched to: {mode}", "success") |
| | time.sleep(1) |
| | self.show_configuration_menu() |
| | return |
| |
|
| | elif choice in ["s", "segmentation"]: |
| | current_state = getattr(self, "segmentation_enabled", True) |
| | self.segmentation_enabled = not current_state |
| | seg_mode = ( |
| | "๐ Smart Segmentation" |
| | if self.segmentation_enabled |
| | else "๐ Traditional Processing" |
| | ) |
| | self.print_status( |
| | f"Document processing switched to: {seg_mode}", "success" |
| | ) |
| | time.sleep(1) |
| | self.show_configuration_menu() |
| | return |
| |
|
| | elif choice in ["b", "back"]: |
| | return |
| |
|
| | else: |
| | self.print_status( |
| | "Invalid choice. Please enter 'T', 'S', or 'B'.", "warning" |
| | ) |
| |
|