deepcode-hku 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cli/__init__.py +18 -0
- cli/cli_app.py +296 -0
- cli/cli_interface.py +744 -0
- cli/cli_launcher.py +155 -0
- cli/main_cli.py +243 -0
- cli/workflows/__init__.py +11 -0
- cli/workflows/cli_workflow_adapter.py +336 -0
- deepcode.py +219 -0
- deepcode_hku-1.0.1.dist-info/METADATA +695 -0
- deepcode_hku-1.0.1.dist-info/RECORD +44 -0
- deepcode_hku-1.0.1.dist-info/WHEEL +5 -0
- deepcode_hku-1.0.1.dist-info/entry_points.txt +2 -0
- deepcode_hku-1.0.1.dist-info/licenses/LICENSE +21 -0
- deepcode_hku-1.0.1.dist-info/top_level.txt +6 -0
- tools/__init__.py +0 -0
- tools/code_implementation_server.py +1045 -0
- tools/code_indexer.py +1657 -0
- tools/code_reference_indexer.py +486 -0
- tools/command_executor.py +324 -0
- tools/git_command.py +356 -0
- tools/pdf_converter.py +640 -0
- tools/pdf_downloader.py +1370 -0
- tools/pdf_utils.py +52 -0
- ui/__init__.py +43 -0
- ui/app.py +13 -0
- ui/components.py +1450 -0
- ui/handlers.py +773 -0
- ui/layout.py +106 -0
- ui/streamlit_app.py +38 -0
- ui/styles.py +2116 -0
- utils/__init__.py +17 -0
- utils/cli_interface.py +459 -0
- utils/dialogue_logger.py +671 -0
- utils/file_processor.py +426 -0
- utils/simple_llm_logger.py +198 -0
- workflows/__init__.py +31 -0
- workflows/agent_orchestration_engine.py +1371 -0
- workflows/agents/__init__.py +13 -0
- workflows/agents/code_implementation_agent.py +1093 -0
- workflows/agents/memory_agent_concise.py +923 -0
- workflows/agents/memory_agent_concise_index.py +935 -0
- workflows/code_implementation_workflow.py +924 -0
- workflows/code_implementation_workflow_index.py +931 -0
- workflows/codebase_index_workflow.py +726 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CLI Workflow Adapter for Agent Orchestration Engine
|
|
3
|
+
CLI工作流适配器 - 智能体编排引擎
|
|
4
|
+
|
|
5
|
+
This adapter provides CLI-optimized interface to the latest agent orchestration engine,
|
|
6
|
+
with enhanced progress reporting, error handling, and CLI-specific optimizations.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
from typing import Callable, Dict, Any
|
|
11
|
+
from mcp_agent.app import MCPApp
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CLIWorkflowAdapter:
|
|
15
|
+
"""
|
|
16
|
+
CLI-optimized workflow adapter for the intelligent agent orchestration engine.
|
|
17
|
+
|
|
18
|
+
This adapter provides:
|
|
19
|
+
- Enhanced CLI progress reporting
|
|
20
|
+
- Optimized error handling for CLI environments
|
|
21
|
+
- Streamlined interface for command-line usage
|
|
22
|
+
- Integration with the latest agent orchestration engine
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(self, cli_interface=None):
|
|
26
|
+
"""
|
|
27
|
+
Initialize CLI workflow adapter.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
cli_interface: CLI interface instance for progress reporting
|
|
31
|
+
"""
|
|
32
|
+
self.cli_interface = cli_interface
|
|
33
|
+
self.app = None
|
|
34
|
+
self.logger = None
|
|
35
|
+
self.context = None
|
|
36
|
+
|
|
37
|
+
async def initialize_mcp_app(self) -> Dict[str, Any]:
|
|
38
|
+
"""
|
|
39
|
+
Initialize MCP application for CLI usage.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
dict: Initialization result
|
|
43
|
+
"""
|
|
44
|
+
try:
|
|
45
|
+
if self.cli_interface:
|
|
46
|
+
self.cli_interface.show_spinner(
|
|
47
|
+
"🚀 Initializing Agent Orchestration Engine", 2.0
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# Initialize MCP application
|
|
51
|
+
self.app = MCPApp(name="cli_agent_orchestration")
|
|
52
|
+
self.app_context = self.app.run()
|
|
53
|
+
agent_app = await self.app_context.__aenter__()
|
|
54
|
+
|
|
55
|
+
self.logger = agent_app.logger
|
|
56
|
+
self.context = agent_app.context
|
|
57
|
+
|
|
58
|
+
# Configure filesystem access
|
|
59
|
+
import os
|
|
60
|
+
|
|
61
|
+
self.context.config.mcp.servers["filesystem"].args.extend([os.getcwd()])
|
|
62
|
+
|
|
63
|
+
if self.cli_interface:
|
|
64
|
+
self.cli_interface.print_status(
|
|
65
|
+
"🧠 Agent Orchestration Engine initialized successfully", "success"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
"status": "success",
|
|
70
|
+
"message": "MCP application initialized successfully",
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
except Exception as e:
|
|
74
|
+
error_msg = f"Failed to initialize MCP application: {str(e)}"
|
|
75
|
+
if self.cli_interface:
|
|
76
|
+
self.cli_interface.print_status(error_msg, "error")
|
|
77
|
+
return {"status": "error", "message": error_msg}
|
|
78
|
+
|
|
79
|
+
async def cleanup_mcp_app(self):
|
|
80
|
+
"""
|
|
81
|
+
Clean up MCP application resources.
|
|
82
|
+
"""
|
|
83
|
+
if hasattr(self, "app_context"):
|
|
84
|
+
try:
|
|
85
|
+
await self.app_context.__aexit__(None, None, None)
|
|
86
|
+
if self.cli_interface:
|
|
87
|
+
self.cli_interface.print_status(
|
|
88
|
+
"🧹 Resources cleaned up successfully", "info"
|
|
89
|
+
)
|
|
90
|
+
except Exception as e:
|
|
91
|
+
if self.cli_interface:
|
|
92
|
+
self.cli_interface.print_status(
|
|
93
|
+
f"⚠️ Cleanup warning: {str(e)}", "warning"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
def create_cli_progress_callback(self) -> Callable:
|
|
97
|
+
"""
|
|
98
|
+
Create CLI-optimized progress callback function.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
Callable: Progress callback function
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
def progress_callback(progress: int, message: str):
|
|
105
|
+
if self.cli_interface:
|
|
106
|
+
# Map progress to CLI stages
|
|
107
|
+
if progress <= 10:
|
|
108
|
+
self.cli_interface.display_processing_stages(1)
|
|
109
|
+
elif progress <= 25:
|
|
110
|
+
self.cli_interface.display_processing_stages(2)
|
|
111
|
+
elif progress <= 40:
|
|
112
|
+
self.cli_interface.display_processing_stages(3)
|
|
113
|
+
elif progress <= 50:
|
|
114
|
+
self.cli_interface.display_processing_stages(4)
|
|
115
|
+
elif progress <= 60:
|
|
116
|
+
self.cli_interface.display_processing_stages(5)
|
|
117
|
+
elif progress <= 70:
|
|
118
|
+
self.cli_interface.display_processing_stages(6)
|
|
119
|
+
elif progress <= 85:
|
|
120
|
+
self.cli_interface.display_processing_stages(7)
|
|
121
|
+
else:
|
|
122
|
+
self.cli_interface.display_processing_stages(8)
|
|
123
|
+
|
|
124
|
+
# Display status message
|
|
125
|
+
self.cli_interface.print_status(message, "processing")
|
|
126
|
+
|
|
127
|
+
return progress_callback
|
|
128
|
+
|
|
129
|
+
async def execute_full_pipeline(
|
|
130
|
+
self, input_source: str, enable_indexing: bool = True
|
|
131
|
+
) -> Dict[str, Any]:
|
|
132
|
+
"""
|
|
133
|
+
Execute the complete intelligent multi-agent research orchestration pipeline.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
input_source: Research input source (file path, URL, or preprocessed analysis)
|
|
137
|
+
enable_indexing: Whether to enable advanced intelligence analysis
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
dict: Comprehensive pipeline execution result
|
|
141
|
+
"""
|
|
142
|
+
try:
|
|
143
|
+
# Import the latest agent orchestration engine
|
|
144
|
+
from workflows.agent_orchestration_engine import (
|
|
145
|
+
execute_multi_agent_research_pipeline,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# Create CLI progress callback
|
|
149
|
+
progress_callback = self.create_cli_progress_callback()
|
|
150
|
+
|
|
151
|
+
# Display pipeline start
|
|
152
|
+
if self.cli_interface:
|
|
153
|
+
mode = "comprehensive" if enable_indexing else "optimized"
|
|
154
|
+
self.cli_interface.print_status(
|
|
155
|
+
f"🚀 Starting {mode} agent orchestration pipeline...", "processing"
|
|
156
|
+
)
|
|
157
|
+
self.cli_interface.display_processing_stages(0)
|
|
158
|
+
|
|
159
|
+
# Execute the pipeline
|
|
160
|
+
result = await execute_multi_agent_research_pipeline(
|
|
161
|
+
input_source=input_source,
|
|
162
|
+
logger=self.logger,
|
|
163
|
+
progress_callback=progress_callback,
|
|
164
|
+
enable_indexing=enable_indexing,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# Display completion
|
|
168
|
+
if self.cli_interface:
|
|
169
|
+
self.cli_interface.display_processing_stages(8)
|
|
170
|
+
self.cli_interface.print_status(
|
|
171
|
+
"🎉 Agent orchestration pipeline completed successfully!",
|
|
172
|
+
"complete",
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
"status": "success",
|
|
177
|
+
"result": result,
|
|
178
|
+
"pipeline_mode": "comprehensive" if enable_indexing else "optimized",
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
except Exception as e:
|
|
182
|
+
error_msg = f"Pipeline execution failed: {str(e)}"
|
|
183
|
+
if self.cli_interface:
|
|
184
|
+
self.cli_interface.print_status(error_msg, "error")
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
"status": "error",
|
|
188
|
+
"error": error_msg,
|
|
189
|
+
"pipeline_mode": "comprehensive" if enable_indexing else "optimized",
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async def execute_chat_pipeline(self, user_input: str) -> Dict[str, Any]:
|
|
193
|
+
"""
|
|
194
|
+
Execute the chat-based planning and implementation pipeline.
|
|
195
|
+
|
|
196
|
+
Args:
|
|
197
|
+
user_input: User's coding requirements and description
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
dict: Chat pipeline execution result
|
|
201
|
+
"""
|
|
202
|
+
try:
|
|
203
|
+
# Import the chat-based pipeline
|
|
204
|
+
from workflows.agent_orchestration_engine import (
|
|
205
|
+
execute_chat_based_planning_pipeline,
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
# Create CLI progress callback for chat mode
|
|
209
|
+
def chat_progress_callback(progress: int, message: str):
|
|
210
|
+
if self.cli_interface:
|
|
211
|
+
# Map progress to CLI stages for chat mode
|
|
212
|
+
if progress <= 5:
|
|
213
|
+
self.cli_interface.display_processing_stages(
|
|
214
|
+
0, chat_mode=True
|
|
215
|
+
) # Initialize
|
|
216
|
+
elif progress <= 30:
|
|
217
|
+
self.cli_interface.display_processing_stages(
|
|
218
|
+
1, chat_mode=True
|
|
219
|
+
) # Planning
|
|
220
|
+
elif progress <= 50:
|
|
221
|
+
self.cli_interface.display_processing_stages(
|
|
222
|
+
2, chat_mode=True
|
|
223
|
+
) # Setup
|
|
224
|
+
elif progress <= 70:
|
|
225
|
+
self.cli_interface.display_processing_stages(
|
|
226
|
+
3, chat_mode=True
|
|
227
|
+
) # Save Plan
|
|
228
|
+
else:
|
|
229
|
+
self.cli_interface.display_processing_stages(
|
|
230
|
+
4, chat_mode=True
|
|
231
|
+
) # Implement
|
|
232
|
+
|
|
233
|
+
# Display status message
|
|
234
|
+
self.cli_interface.print_status(message, "processing")
|
|
235
|
+
|
|
236
|
+
# Display pipeline start
|
|
237
|
+
if self.cli_interface:
|
|
238
|
+
self.cli_interface.print_status(
|
|
239
|
+
"🚀 Starting chat-based planning pipeline...", "processing"
|
|
240
|
+
)
|
|
241
|
+
self.cli_interface.display_processing_stages(0, chat_mode=True)
|
|
242
|
+
|
|
243
|
+
# Execute the chat pipeline with indexing enabled for enhanced code understanding
|
|
244
|
+
result = await execute_chat_based_planning_pipeline(
|
|
245
|
+
user_input=user_input,
|
|
246
|
+
logger=self.logger,
|
|
247
|
+
progress_callback=chat_progress_callback,
|
|
248
|
+
enable_indexing=True, # Enable indexing for better code implementation
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
# Display completion
|
|
252
|
+
if self.cli_interface:
|
|
253
|
+
self.cli_interface.display_processing_stages(
|
|
254
|
+
4, chat_mode=True
|
|
255
|
+
) # Final stage for chat mode
|
|
256
|
+
self.cli_interface.print_status(
|
|
257
|
+
"🎉 Chat-based planning pipeline completed successfully!",
|
|
258
|
+
"complete",
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
return {"status": "success", "result": result, "pipeline_mode": "chat"}
|
|
262
|
+
|
|
263
|
+
except Exception as e:
|
|
264
|
+
error_msg = f"Chat pipeline execution failed: {str(e)}"
|
|
265
|
+
if self.cli_interface:
|
|
266
|
+
self.cli_interface.print_status(error_msg, "error")
|
|
267
|
+
|
|
268
|
+
return {"status": "error", "error": error_msg, "pipeline_mode": "chat"}
|
|
269
|
+
|
|
270
|
+
async def process_input_with_orchestration(
|
|
271
|
+
self, input_source: str, input_type: str, enable_indexing: bool = True
|
|
272
|
+
) -> Dict[str, Any]:
|
|
273
|
+
"""
|
|
274
|
+
Process input using the intelligent agent orchestration engine.
|
|
275
|
+
|
|
276
|
+
This is the main CLI interface to the latest agent orchestration capabilities.
|
|
277
|
+
|
|
278
|
+
Args:
|
|
279
|
+
input_source: Input source (file path or URL)
|
|
280
|
+
input_type: Type of input ('file' or 'url')
|
|
281
|
+
enable_indexing: Whether to enable advanced intelligence analysis
|
|
282
|
+
|
|
283
|
+
Returns:
|
|
284
|
+
dict: Processing result with status and details
|
|
285
|
+
"""
|
|
286
|
+
pipeline_result = None
|
|
287
|
+
|
|
288
|
+
try:
|
|
289
|
+
# Initialize MCP app
|
|
290
|
+
init_result = await self.initialize_mcp_app()
|
|
291
|
+
if init_result["status"] != "success":
|
|
292
|
+
return init_result
|
|
293
|
+
|
|
294
|
+
# Process file:// URLs for traditional file/URL inputs
|
|
295
|
+
if input_source.startswith("file://"):
|
|
296
|
+
file_path = input_source[7:]
|
|
297
|
+
if os.name == "nt" and file_path.startswith("/"):
|
|
298
|
+
file_path = file_path.lstrip("/")
|
|
299
|
+
input_source = file_path
|
|
300
|
+
|
|
301
|
+
# Execute appropriate pipeline based on input type
|
|
302
|
+
if input_type == "chat":
|
|
303
|
+
# Use chat-based planning pipeline for user requirements
|
|
304
|
+
pipeline_result = await self.execute_chat_pipeline(input_source)
|
|
305
|
+
else:
|
|
306
|
+
# Use traditional multi-agent research pipeline for files/URLs
|
|
307
|
+
pipeline_result = await self.execute_full_pipeline(
|
|
308
|
+
input_source, enable_indexing=enable_indexing
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
"status": pipeline_result["status"],
|
|
313
|
+
"analysis_result": "Integrated into agent orchestration pipeline",
|
|
314
|
+
"download_result": "Integrated into agent orchestration pipeline",
|
|
315
|
+
"repo_result": pipeline_result.get("result", ""),
|
|
316
|
+
"pipeline_mode": pipeline_result.get("pipeline_mode", "comprehensive"),
|
|
317
|
+
"error": pipeline_result.get("error"),
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
except Exception as e:
|
|
321
|
+
error_msg = f"Error during orchestrated processing: {str(e)}"
|
|
322
|
+
if self.cli_interface:
|
|
323
|
+
self.cli_interface.print_status(error_msg, "error")
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
"status": "error",
|
|
327
|
+
"error": error_msg,
|
|
328
|
+
"analysis_result": "",
|
|
329
|
+
"download_result": "",
|
|
330
|
+
"repo_result": "",
|
|
331
|
+
"pipeline_mode": "comprehensive" if enable_indexing else "optimized",
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
finally:
|
|
335
|
+
# Clean up resources
|
|
336
|
+
await self.cleanup_mcp_app()
|
deepcode.py
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
DeepCode - AI Research Engine Launcher
|
|
4
|
+
|
|
5
|
+
🧬 Next-Generation AI Research Automation Platform
|
|
6
|
+
⚡ Transform research papers into working code automatically
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
import subprocess
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def check_dependencies():
|
|
16
|
+
"""Check if necessary dependencies are installed"""
|
|
17
|
+
import importlib.util
|
|
18
|
+
|
|
19
|
+
print("🔍 Checking dependencies...")
|
|
20
|
+
|
|
21
|
+
missing_deps = []
|
|
22
|
+
missing_system_deps = []
|
|
23
|
+
|
|
24
|
+
# Check Streamlit availability
|
|
25
|
+
if importlib.util.find_spec("streamlit") is not None:
|
|
26
|
+
print("✅ Streamlit is installed")
|
|
27
|
+
else:
|
|
28
|
+
missing_deps.append("streamlit>=1.28.0")
|
|
29
|
+
|
|
30
|
+
# Check PyYAML availability
|
|
31
|
+
if importlib.util.find_spec("yaml") is not None:
|
|
32
|
+
print("✅ PyYAML is installed")
|
|
33
|
+
else:
|
|
34
|
+
missing_deps.append("pyyaml")
|
|
35
|
+
|
|
36
|
+
# Check asyncio availability
|
|
37
|
+
if importlib.util.find_spec("asyncio") is not None:
|
|
38
|
+
print("✅ Asyncio is available")
|
|
39
|
+
else:
|
|
40
|
+
missing_deps.append("asyncio")
|
|
41
|
+
|
|
42
|
+
# Check PDF conversion dependencies
|
|
43
|
+
if importlib.util.find_spec("reportlab") is not None:
|
|
44
|
+
print("✅ ReportLab is installed (for text-to-PDF conversion)")
|
|
45
|
+
else:
|
|
46
|
+
missing_deps.append("reportlab")
|
|
47
|
+
print("⚠️ ReportLab not found (text files won't convert to PDF)")
|
|
48
|
+
|
|
49
|
+
# Check LibreOffice for Office document conversion
|
|
50
|
+
try:
|
|
51
|
+
import subprocess
|
|
52
|
+
import platform
|
|
53
|
+
|
|
54
|
+
subprocess_kwargs = {
|
|
55
|
+
"capture_output": True,
|
|
56
|
+
"text": True,
|
|
57
|
+
"timeout": 5,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if platform.system() == "Windows":
|
|
61
|
+
subprocess_kwargs["creationflags"] = 0x08000000 # Hide console window
|
|
62
|
+
|
|
63
|
+
# Try different LibreOffice commands
|
|
64
|
+
libreoffice_found = False
|
|
65
|
+
for cmd in ["libreoffice", "soffice"]:
|
|
66
|
+
try:
|
|
67
|
+
result = subprocess.run([cmd, "--version"], **subprocess_kwargs)
|
|
68
|
+
if result.returncode == 0:
|
|
69
|
+
print(
|
|
70
|
+
"✅ LibreOffice is installed (for Office document conversion)"
|
|
71
|
+
)
|
|
72
|
+
libreoffice_found = True
|
|
73
|
+
break
|
|
74
|
+
except (
|
|
75
|
+
subprocess.CalledProcessError,
|
|
76
|
+
FileNotFoundError,
|
|
77
|
+
subprocess.TimeoutExpired,
|
|
78
|
+
):
|
|
79
|
+
continue
|
|
80
|
+
|
|
81
|
+
if not libreoffice_found:
|
|
82
|
+
missing_system_deps.append("LibreOffice")
|
|
83
|
+
print("⚠️ LibreOffice not found (Office documents won't convert to PDF)")
|
|
84
|
+
|
|
85
|
+
except Exception:
|
|
86
|
+
missing_system_deps.append("LibreOffice")
|
|
87
|
+
print("⚠️ Could not check LibreOffice installation")
|
|
88
|
+
|
|
89
|
+
# Display missing dependencies
|
|
90
|
+
if missing_deps or missing_system_deps:
|
|
91
|
+
print("\n📋 Dependency Status:")
|
|
92
|
+
|
|
93
|
+
if missing_deps:
|
|
94
|
+
print("❌ Missing Python dependencies:")
|
|
95
|
+
for dep in missing_deps:
|
|
96
|
+
print(f" - {dep}")
|
|
97
|
+
print(f"\nInstall with: pip install {' '.join(missing_deps)}")
|
|
98
|
+
|
|
99
|
+
if missing_system_deps:
|
|
100
|
+
print("\n⚠️ Missing system dependencies (optional for full functionality):")
|
|
101
|
+
for dep in missing_system_deps:
|
|
102
|
+
print(f" - {dep}")
|
|
103
|
+
print("\nInstall LibreOffice:")
|
|
104
|
+
print(" - Windows: Download from https://www.libreoffice.org/")
|
|
105
|
+
print(" - macOS: brew install --cask libreoffice")
|
|
106
|
+
print(" - Ubuntu/Debian: sudo apt-get install libreoffice")
|
|
107
|
+
|
|
108
|
+
# Only fail if critical Python dependencies are missing
|
|
109
|
+
if missing_deps:
|
|
110
|
+
return False
|
|
111
|
+
else:
|
|
112
|
+
print("\n✅ Core dependencies satisfied (optional dependencies missing)")
|
|
113
|
+
else:
|
|
114
|
+
print("✅ All dependencies satisfied")
|
|
115
|
+
|
|
116
|
+
return True
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def cleanup_cache():
|
|
120
|
+
"""Clean up Python cache files"""
|
|
121
|
+
try:
|
|
122
|
+
print("🧹 Cleaning up cache files...")
|
|
123
|
+
# Clean up __pycache__ directories
|
|
124
|
+
os.system('find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null')
|
|
125
|
+
# Clean up .pyc files
|
|
126
|
+
os.system('find . -name "*.pyc" -delete 2>/dev/null')
|
|
127
|
+
print("✅ Cache cleanup completed")
|
|
128
|
+
except Exception as e:
|
|
129
|
+
print(f"⚠️ Cache cleanup failed: {e}")
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def print_banner():
|
|
133
|
+
"""Display startup banner"""
|
|
134
|
+
banner = """
|
|
135
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
136
|
+
║ ║
|
|
137
|
+
║ 🧬 DeepCode - AI Research Engine ║
|
|
138
|
+
║ ║
|
|
139
|
+
║ ⚡ NEURAL • AUTONOMOUS • REVOLUTIONARY ⚡ ║
|
|
140
|
+
║ ║
|
|
141
|
+
║ Transform research papers into working code ║
|
|
142
|
+
║ Next-generation AI automation platform ║
|
|
143
|
+
║ ║
|
|
144
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
145
|
+
"""
|
|
146
|
+
print(banner)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def main():
|
|
150
|
+
"""Main function"""
|
|
151
|
+
print_banner()
|
|
152
|
+
|
|
153
|
+
# Check dependencies
|
|
154
|
+
if not check_dependencies():
|
|
155
|
+
print("\n🚨 Please install missing dependencies and try again.")
|
|
156
|
+
sys.exit(1)
|
|
157
|
+
|
|
158
|
+
# Get current script directory
|
|
159
|
+
current_dir = Path(__file__).parent
|
|
160
|
+
streamlit_app_path = current_dir / "ui" / "streamlit_app.py"
|
|
161
|
+
|
|
162
|
+
# Check if streamlit_app.py exists
|
|
163
|
+
if not streamlit_app_path.exists():
|
|
164
|
+
print(f"❌ UI application file not found: {streamlit_app_path}")
|
|
165
|
+
print("Please ensure the ui/streamlit_app.py file exists.")
|
|
166
|
+
sys.exit(1)
|
|
167
|
+
|
|
168
|
+
print(f"\n📁 UI App location: {streamlit_app_path}")
|
|
169
|
+
print("🌐 Starting DeepCode web interface...")
|
|
170
|
+
print("🚀 Launching on http://localhost:8501")
|
|
171
|
+
print("=" * 70)
|
|
172
|
+
print("💡 Tip: Keep this terminal open while using the application")
|
|
173
|
+
print("🛑 Press Ctrl+C to stop the server")
|
|
174
|
+
print("=" * 70)
|
|
175
|
+
|
|
176
|
+
# Launch Streamlit application
|
|
177
|
+
try:
|
|
178
|
+
cmd = [
|
|
179
|
+
sys.executable,
|
|
180
|
+
"-m",
|
|
181
|
+
"streamlit",
|
|
182
|
+
"run",
|
|
183
|
+
str(streamlit_app_path),
|
|
184
|
+
"--server.port",
|
|
185
|
+
"8501",
|
|
186
|
+
"--server.address",
|
|
187
|
+
"localhost",
|
|
188
|
+
"--browser.gatherUsageStats",
|
|
189
|
+
"false",
|
|
190
|
+
"--theme.base",
|
|
191
|
+
"dark",
|
|
192
|
+
"--theme.primaryColor",
|
|
193
|
+
"#4dd0e1",
|
|
194
|
+
"--theme.backgroundColor",
|
|
195
|
+
"#0a0e27",
|
|
196
|
+
"--theme.secondaryBackgroundColor",
|
|
197
|
+
"#1a1f3a",
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
subprocess.run(cmd, check=True)
|
|
201
|
+
|
|
202
|
+
except subprocess.CalledProcessError as e:
|
|
203
|
+
print(f"\n❌ Failed to start DeepCode: {e}")
|
|
204
|
+
print("Please check if Streamlit is properly installed.")
|
|
205
|
+
sys.exit(1)
|
|
206
|
+
except KeyboardInterrupt:
|
|
207
|
+
print("\n\n🛑 DeepCode server stopped by user")
|
|
208
|
+
print("Thank you for using DeepCode! 🧬")
|
|
209
|
+
except Exception as e:
|
|
210
|
+
print(f"\n❌ Unexpected error: {e}")
|
|
211
|
+
print("Please check your Python environment and try again.")
|
|
212
|
+
sys.exit(1)
|
|
213
|
+
finally:
|
|
214
|
+
# Clean up cache files
|
|
215
|
+
cleanup_cache()
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
if __name__ == "__main__":
|
|
219
|
+
main()
|