|
|
|
|
|
""" |
|
|
DeepCode - CLI Research Engine Launcher |
|
|
DeepCode - CLI็ ็ฉถๅผๆๅฏๅจๅจ |
|
|
|
|
|
๐งฌ Open-Source Code Agent by Data Intelligence Lab @ HKU (CLI Edition) |
|
|
โก Revolutionizing research reproducibility through collaborative AI via command line |
|
|
""" |
|
|
|
|
|
import sys |
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
def check_dependencies(): |
|
|
"""ๆฃๆฅๅฟ
่ฆ็ไพ่ตๆฏๅฆๅทฒๅฎ่ฃ
/ Check if necessary dependencies are installed""" |
|
|
import importlib.util |
|
|
|
|
|
print("๐ Checking CLI dependencies...") |
|
|
|
|
|
missing_deps = [] |
|
|
|
|
|
|
|
|
if importlib.util.find_spec("asyncio") is not None: |
|
|
print("โ
Asyncio is available") |
|
|
else: |
|
|
missing_deps.append("asyncio") |
|
|
|
|
|
|
|
|
if importlib.util.find_spec("yaml") is not None: |
|
|
print("โ
PyYAML is installed") |
|
|
else: |
|
|
missing_deps.append("pyyaml") |
|
|
|
|
|
|
|
|
if importlib.util.find_spec("tkinter") is not None: |
|
|
print("โ
Tkinter is available (for file dialogs)") |
|
|
else: |
|
|
print("โ ๏ธ Tkinter not available - file dialogs will use manual input") |
|
|
|
|
|
|
|
|
if importlib.util.find_spec("mcp_agent.app") is not None: |
|
|
print("โ
MCP Agent framework is available") |
|
|
else: |
|
|
missing_deps.append("mcp-agent") |
|
|
|
|
|
|
|
|
|
|
|
current_dir = Path(__file__).parent |
|
|
project_root = current_dir.parent |
|
|
if str(project_root) not in sys.path: |
|
|
sys.path.insert(0, str(project_root)) |
|
|
|
|
|
if importlib.util.find_spec("workflows.agent_orchestration_engine") is not None: |
|
|
print("โ
Workflow modules are available") |
|
|
else: |
|
|
print("โ ๏ธ Workflow modules may not be properly configured") |
|
|
|
|
|
|
|
|
if importlib.util.find_spec("cli.cli_app") is not None: |
|
|
print("โ
CLI application components are available") |
|
|
else: |
|
|
print("โ CLI application components missing") |
|
|
missing_deps.append("cli-components") |
|
|
|
|
|
if missing_deps: |
|
|
print("\nโ Missing dependencies:") |
|
|
for dep in missing_deps: |
|
|
print(f" - {dep}") |
|
|
print("\nPlease install missing dependencies using:") |
|
|
print( |
|
|
f"pip install {' '.join([d for d in missing_deps if d != 'cli-components'])}" |
|
|
) |
|
|
if "cli-components" in missing_deps: |
|
|
print( |
|
|
"CLI components appear to be missing - please check the cli/ directory" |
|
|
) |
|
|
return False |
|
|
|
|
|
print("โ
All CLI dependencies satisfied") |
|
|
return True |
|
|
|
|
|
|
|
|
def print_banner(): |
|
|
"""ๆพ็คบCLIๅฏๅจๆจชๅน
/ Display CLI startup banner""" |
|
|
banner = """ |
|
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
|
|
โ โ |
|
|
โ ๐งฌ DeepCode - Open-Source Code Agent โ |
|
|
โ โ |
|
|
โ โก DATA INTELLIGENCE LAB @ HKU โก โ |
|
|
โ โ |
|
|
โ โ |
|
|
โ โ |
|
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ |
|
|
""" |
|
|
print(banner) |
|
|
|
|
|
|
|
|
def main(): |
|
|
"""ไธปๅฝๆฐ / Main function""" |
|
|
print_banner() |
|
|
|
|
|
|
|
|
if not check_dependencies(): |
|
|
print("\n๐จ Please install missing dependencies and try again.") |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
current_dir = Path(__file__).parent |
|
|
project_root = current_dir.parent |
|
|
cli_app_path = current_dir / "cli_app.py" |
|
|
|
|
|
|
|
|
if not cli_app_path.exists(): |
|
|
print(f"โ CLI application file not found: {cli_app_path}") |
|
|
print("Please ensure the cli/cli_app.py file exists.") |
|
|
sys.exit(1) |
|
|
|
|
|
print(f"\n๐ CLI App location: {cli_app_path}") |
|
|
print("๐ฅ๏ธ Starting DeepCode CLI interface...") |
|
|
print("๐ Initializing command line application") |
|
|
print("=" * 70) |
|
|
print("๐ก Tip: Follow the interactive prompts to process your research") |
|
|
print("๐ Press Ctrl+C to exit at any time") |
|
|
print("=" * 70) |
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
if str(project_root) not in sys.path: |
|
|
sys.path.insert(0, str(project_root)) |
|
|
from cli.cli_app import main as cli_main |
|
|
|
|
|
print("\n๐ฏ Launching CLI application...") |
|
|
|
|
|
|
|
|
import asyncio |
|
|
|
|
|
asyncio.run(cli_main()) |
|
|
|
|
|
except KeyboardInterrupt: |
|
|
print("\n\n๐ DeepCode CLI stopped by user") |
|
|
print("Thank you for using DeepCode CLI! ๐งฌ") |
|
|
except ImportError as e: |
|
|
print(f"\nโ Failed to import CLI application: {e}") |
|
|
print("Please check if all modules are properly installed.") |
|
|
sys.exit(1) |
|
|
except Exception as e: |
|
|
print(f"\nโ Unexpected error: {e}") |
|
|
print("Please check your Python environment and try again.") |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
|