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()