File size: 5,546 Bytes
74d8e8f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
#!/usr/bin/env python3
"""
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 = []
# Check asyncio availability
if importlib.util.find_spec("asyncio") is not None:
print("โ
Asyncio is available")
else:
missing_deps.append("asyncio")
# Check PyYAML availability
if importlib.util.find_spec("yaml") is not None:
print("โ
PyYAML is installed")
else:
missing_deps.append("pyyaml")
# Check Tkinter availability
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")
# Check for MCP agent dependencies
if importlib.util.find_spec("mcp_agent.app") is not None:
print("โ
MCP Agent framework is available")
else:
missing_deps.append("mcp-agent")
# Check for workflow dependencies
# ๆทปๅ ้กน็ฎๆ น็ฎๅฝๅฐ่ทฏๅพ
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")
# Check for CLI components
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()
# ๆฃๆฅไพ่ต / Check dependencies
if not check_dependencies():
print("\n๐จ Please install missing dependencies and try again.")
sys.exit(1)
# ่ทๅๅฝๅ่ๆฌ็ฎๅฝ / Get current script directory
current_dir = Path(__file__).parent
project_root = current_dir.parent
cli_app_path = current_dir / "cli_app.py"
# ๆฃๆฅcli_app.pyๆฏๅฆๅญๅจ / Check if cli_app.py exists
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)
# ๅฏๅจCLIๅบ็จ / Launch CLI application
try:
# ๅฏผๅ
ฅๅนถ่ฟ่กCLIๅบ็จ
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...")
# ไฝฟ็จasyncio่ฟ่กไธปๅฝๆฐ
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()
|