adaptai / projects /ui /DeepCode /cli /cli_launcher.py
ADAPT-Chase's picture
Add files using upload-large-folder tool
74d8e8f verified
#!/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()