mcli-framework 7.12.0__py3-none-any.whl โ 7.12.3__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.
Potentially problematic release.
This version of mcli-framework might be problematic. Click here for more details.
- mcli/app/__init__.py +0 -2
- mcli/app/commands_cmd.py +19 -23
- mcli/app/completion_helpers.py +5 -5
- mcli/app/init_cmd.py +10 -10
- mcli/app/lock_cmd.py +82 -27
- mcli/app/main.py +4 -50
- mcli/app/model/model.py +5 -10
- mcli/app/store_cmd.py +8 -8
- mcli/app/video/__init__.py +0 -2
- mcli/app/video/video.py +1 -14
- mcli/chat/chat.py +90 -108
- mcli/chat/command_rag.py +0 -4
- mcli/chat/enhanced_chat.py +32 -41
- mcli/chat/system_controller.py +37 -37
- mcli/chat/system_integration.py +4 -5
- mcli/cli.py +2 -3
- mcli/lib/api/api.py +4 -9
- mcli/lib/api/daemon_client.py +19 -20
- mcli/lib/api/daemon_client_local.py +1 -3
- mcli/lib/api/daemon_decorator.py +6 -6
- mcli/lib/api/mcli_decorators.py +4 -8
- mcli/lib/auth/__init__.py +0 -1
- mcli/lib/auth/auth.py +4 -5
- mcli/lib/auth/mcli_manager.py +7 -12
- mcli/lib/auth/token_util.py +5 -5
- mcli/lib/config/__init__.py +29 -1
- mcli/lib/config/config.py +0 -1
- mcli/lib/custom_commands.py +1 -1
- mcli/lib/discovery/command_discovery.py +15 -15
- mcli/lib/erd/erd.py +7 -7
- mcli/lib/files/files.py +1 -1
- mcli/lib/fs/__init__.py +31 -1
- mcli/lib/fs/fs.py +12 -13
- mcli/lib/lib.py +0 -1
- mcli/lib/logger/logger.py +7 -10
- mcli/lib/performance/optimizer.py +25 -27
- mcli/lib/performance/rust_bridge.py +22 -27
- mcli/lib/performance/uvloop_config.py +0 -1
- mcli/lib/pickles/__init__.py +0 -1
- mcli/lib/pickles/pickles.py +0 -2
- mcli/lib/secrets/commands.py +0 -2
- mcli/lib/secrets/manager.py +0 -1
- mcli/lib/secrets/repl.py +2 -3
- mcli/lib/secrets/store.py +1 -2
- mcli/lib/services/data_pipeline.py +34 -34
- mcli/lib/services/lsh_client.py +38 -40
- mcli/lib/shell/shell.py +2 -2
- mcli/lib/toml/__init__.py +0 -1
- mcli/lib/ui/styling.py +0 -1
- mcli/lib/ui/visual_effects.py +33 -41
- mcli/lib/watcher/watcher.py +0 -1
- mcli/ml/__init__.py +1 -1
- mcli/ml/api/__init__.py +1 -1
- mcli/ml/api/app.py +8 -9
- mcli/ml/api/middleware.py +10 -10
- mcli/ml/api/routers/__init__.py +1 -1
- mcli/ml/api/routers/admin_router.py +3 -3
- mcli/ml/api/routers/auth_router.py +17 -18
- mcli/ml/api/routers/backtest_router.py +2 -2
- mcli/ml/api/routers/data_router.py +2 -2
- mcli/ml/api/routers/model_router.py +14 -15
- mcli/ml/api/routers/monitoring_router.py +2 -2
- mcli/ml/api/routers/portfolio_router.py +2 -2
- mcli/ml/api/routers/prediction_router.py +10 -9
- mcli/ml/api/routers/trade_router.py +2 -2
- mcli/ml/api/routers/websocket_router.py +6 -7
- mcli/ml/api/schemas.py +2 -2
- mcli/ml/auth/__init__.py +1 -1
- mcli/ml/auth/auth_manager.py +22 -23
- mcli/ml/auth/models.py +17 -17
- mcli/ml/auth/permissions.py +17 -17
- mcli/ml/backtesting/__init__.py +1 -1
- mcli/ml/backtesting/backtest_engine.py +31 -35
- mcli/ml/backtesting/performance_metrics.py +12 -14
- mcli/ml/backtesting/run.py +1 -2
- mcli/ml/cache.py +35 -36
- mcli/ml/cli/__init__.py +1 -1
- mcli/ml/cli/main.py +21 -24
- mcli/ml/config/__init__.py +1 -1
- mcli/ml/config/settings.py +28 -29
- mcli/ml/configs/__init__.py +1 -1
- mcli/ml/configs/dvc_config.py +14 -15
- mcli/ml/configs/mlflow_config.py +12 -13
- mcli/ml/configs/mlops_manager.py +19 -21
- mcli/ml/dashboard/__init__.py +4 -4
- mcli/ml/dashboard/app.py +20 -30
- mcli/ml/dashboard/app_supabase.py +16 -19
- mcli/ml/dashboard/app_training.py +11 -14
- mcli/ml/dashboard/cli.py +2 -2
- mcli/ml/dashboard/common.py +2 -3
- mcli/ml/dashboard/components/__init__.py +1 -1
- mcli/ml/dashboard/components/charts.py +13 -11
- mcli/ml/dashboard/components/metrics.py +7 -7
- mcli/ml/dashboard/components/tables.py +12 -9
- mcli/ml/dashboard/overview.py +2 -2
- mcli/ml/dashboard/pages/__init__.py +1 -1
- mcli/ml/dashboard/pages/cicd.py +15 -18
- mcli/ml/dashboard/pages/debug_dependencies.py +7 -7
- mcli/ml/dashboard/pages/monte_carlo_predictions.py +11 -18
- mcli/ml/dashboard/pages/predictions_enhanced.py +24 -32
- mcli/ml/dashboard/pages/scrapers_and_logs.py +22 -24
- mcli/ml/dashboard/pages/test_portfolio.py +3 -6
- mcli/ml/dashboard/pages/trading.py +16 -18
- mcli/ml/dashboard/pages/workflows.py +20 -30
- mcli/ml/dashboard/utils.py +9 -9
- mcli/ml/dashboard/warning_suppression.py +3 -3
- mcli/ml/data_ingestion/__init__.py +1 -1
- mcli/ml/data_ingestion/api_connectors.py +41 -46
- mcli/ml/data_ingestion/data_pipeline.py +36 -46
- mcli/ml/data_ingestion/stream_processor.py +43 -46
- mcli/ml/database/__init__.py +1 -1
- mcli/ml/database/migrations/env.py +2 -2
- mcli/ml/database/models.py +22 -24
- mcli/ml/database/session.py +14 -14
- mcli/ml/experimentation/__init__.py +1 -1
- mcli/ml/experimentation/ab_testing.py +45 -46
- mcli/ml/features/__init__.py +1 -1
- mcli/ml/features/ensemble_features.py +22 -27
- mcli/ml/features/recommendation_engine.py +30 -30
- mcli/ml/features/stock_features.py +29 -32
- mcli/ml/features/test_feature_engineering.py +10 -11
- mcli/ml/logging.py +4 -4
- mcli/ml/mlops/__init__.py +1 -1
- mcli/ml/mlops/data_versioning.py +29 -30
- mcli/ml/mlops/experiment_tracker.py +24 -24
- mcli/ml/mlops/model_serving.py +31 -34
- mcli/ml/mlops/pipeline_orchestrator.py +27 -35
- mcli/ml/models/__init__.py +5 -6
- mcli/ml/models/base_models.py +23 -23
- mcli/ml/models/ensemble_models.py +31 -31
- mcli/ml/models/recommendation_models.py +18 -19
- mcli/ml/models/test_models.py +14 -16
- mcli/ml/monitoring/__init__.py +1 -1
- mcli/ml/monitoring/drift_detection.py +32 -36
- mcli/ml/monitoring/metrics.py +2 -2
- mcli/ml/optimization/__init__.py +1 -1
- mcli/ml/optimization/optimize.py +1 -2
- mcli/ml/optimization/portfolio_optimizer.py +30 -32
- mcli/ml/predictions/__init__.py +1 -1
- mcli/ml/preprocessing/__init__.py +1 -1
- mcli/ml/preprocessing/data_cleaners.py +22 -23
- mcli/ml/preprocessing/feature_extractors.py +23 -26
- mcli/ml/preprocessing/ml_pipeline.py +23 -23
- mcli/ml/preprocessing/test_preprocessing.py +7 -8
- mcli/ml/scripts/populate_sample_data.py +0 -4
- mcli/ml/serving/serve.py +1 -2
- mcli/ml/tasks.py +17 -17
- mcli/ml/tests/test_integration.py +29 -30
- mcli/ml/tests/test_training_dashboard.py +21 -21
- mcli/ml/trading/__init__.py +1 -1
- mcli/ml/trading/migrations.py +5 -5
- mcli/ml/trading/models.py +21 -23
- mcli/ml/trading/paper_trading.py +16 -13
- mcli/ml/trading/risk_management.py +17 -18
- mcli/ml/trading/trading_service.py +25 -28
- mcli/ml/training/__init__.py +1 -1
- mcli/ml/training/train.py +0 -1
- mcli/public/oi/oi.py +1 -2
- mcli/self/completion_cmd.py +6 -10
- mcli/self/logs_cmd.py +19 -24
- mcli/self/migrate_cmd.py +22 -20
- mcli/self/redis_cmd.py +10 -11
- mcli/self/self_cmd.py +62 -18
- mcli/self/store_cmd.py +10 -12
- mcli/self/visual_cmd.py +9 -14
- mcli/self/zsh_cmd.py +2 -4
- mcli/workflow/daemon/async_command_database.py +23 -24
- mcli/workflow/daemon/async_process_manager.py +27 -29
- mcli/workflow/daemon/client.py +27 -33
- mcli/workflow/daemon/daemon.py +32 -36
- mcli/workflow/daemon/enhanced_daemon.py +24 -33
- mcli/workflow/daemon/process_cli.py +11 -12
- mcli/workflow/daemon/process_manager.py +23 -26
- mcli/workflow/daemon/test_daemon.py +4 -5
- mcli/workflow/dashboard/dashboard_cmd.py +0 -1
- mcli/workflow/doc_convert.py +15 -17
- mcli/workflow/gcloud/__init__.py +0 -1
- mcli/workflow/gcloud/gcloud.py +11 -8
- mcli/workflow/git_commit/ai_service.py +14 -15
- mcli/workflow/lsh_integration.py +9 -11
- mcli/workflow/model_service/client.py +26 -31
- mcli/workflow/model_service/download_and_run_efficient_models.py +10 -14
- mcli/workflow/model_service/lightweight_embedder.py +25 -35
- mcli/workflow/model_service/lightweight_model_server.py +26 -32
- mcli/workflow/model_service/lightweight_test.py +7 -10
- mcli/workflow/model_service/model_service.py +80 -91
- mcli/workflow/model_service/ollama_efficient_runner.py +14 -18
- mcli/workflow/model_service/openai_adapter.py +23 -23
- mcli/workflow/model_service/pdf_processor.py +21 -26
- mcli/workflow/model_service/test_efficient_runner.py +12 -16
- mcli/workflow/model_service/test_example.py +11 -13
- mcli/workflow/model_service/test_integration.py +3 -5
- mcli/workflow/model_service/test_new_features.py +7 -8
- mcli/workflow/notebook/converter.py +1 -1
- mcli/workflow/notebook/notebook_cmd.py +5 -6
- mcli/workflow/notebook/schema.py +0 -1
- mcli/workflow/notebook/validator.py +7 -3
- mcli/workflow/openai/openai.py +1 -2
- mcli/workflow/registry/registry.py +4 -1
- mcli/workflow/repo/repo.py +6 -7
- mcli/workflow/scheduler/cron_parser.py +16 -19
- mcli/workflow/scheduler/job.py +10 -10
- mcli/workflow/scheduler/monitor.py +15 -15
- mcli/workflow/scheduler/persistence.py +17 -18
- mcli/workflow/scheduler/scheduler.py +37 -38
- mcli/workflow/secrets/__init__.py +1 -1
- mcli/workflow/sync/test_cmd.py +0 -1
- mcli/workflow/wakatime/__init__.py +5 -9
- mcli/workflow/wakatime/wakatime.py +1 -2
- {mcli_framework-7.12.0.dist-info โ mcli_framework-7.12.3.dist-info}/METADATA +1 -1
- mcli_framework-7.12.3.dist-info/RECORD +279 -0
- mcli_framework-7.12.0.dist-info/RECORD +0 -279
- {mcli_framework-7.12.0.dist-info โ mcli_framework-7.12.3.dist-info}/WHEEL +0 -0
- {mcli_framework-7.12.0.dist-info โ mcli_framework-7.12.3.dist-info}/entry_points.txt +0 -0
- {mcli_framework-7.12.0.dist-info โ mcli_framework-7.12.3.dist-info}/licenses/LICENSE +0 -0
- {mcli_framework-7.12.0.dist-info โ mcli_framework-7.12.3.dist-info}/top_level.txt +0 -0
mcli/chat/command_rag.py
CHANGED
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
RAG-based Command Search and Self-Referential System for MCLI Chatbot
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import asyncio
|
|
6
|
-
import json
|
|
7
|
-
import os
|
|
8
5
|
import re
|
|
9
6
|
import subprocess
|
|
10
|
-
import sys
|
|
11
7
|
from dataclasses import asdict, dataclass
|
|
12
8
|
from pathlib import Path
|
|
13
9
|
from typing import Any, Dict, List, Optional, Tuple
|
mcli/chat/enhanced_chat.py
CHANGED
|
@@ -3,25 +3,18 @@ Enhanced MCLI Chat Assistant with Self-Referential Capabilities and RAG-based Co
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
import asyncio
|
|
6
|
-
import json
|
|
7
6
|
import os
|
|
8
7
|
import re
|
|
9
|
-
import readline
|
|
10
8
|
from datetime import datetime
|
|
11
|
-
from typing import Any, Dict,
|
|
9
|
+
from typing import Any, Dict, Optional
|
|
12
10
|
|
|
13
|
-
import requests
|
|
14
11
|
from rich.console import Console
|
|
15
12
|
from rich.panel import Panel
|
|
16
13
|
from rich.table import Table
|
|
17
|
-
from rich.text import Text
|
|
18
14
|
|
|
19
|
-
from mcli.chat.command_rag import get_command_rag_system
|
|
20
|
-
from mcli.chat.system_integration import handle_system_request
|
|
21
15
|
from mcli.lib.api.daemon_client import get_daemon_client
|
|
22
16
|
from mcli.lib.logger.logger import get_logger
|
|
23
17
|
from mcli.lib.toml.toml import read_from_toml
|
|
24
|
-
from mcli.lib.ui.styling import console
|
|
25
18
|
|
|
26
19
|
logger = get_logger(__name__)
|
|
27
20
|
|
|
@@ -81,7 +74,7 @@ I can execute system commands and searches to provide real-time information and
|
|
|
81
74
|
|
|
82
75
|
|
|
83
76
|
class EnhancedChatClient:
|
|
84
|
-
"""Enhanced chat client with RAG-based command search and self-referential capabilities"""
|
|
77
|
+
"""Enhanced chat client with RAG-based command search and self-referential capabilities."""
|
|
85
78
|
|
|
86
79
|
def __init__(self, use_remote: bool = False, model_override: str = None):
|
|
87
80
|
self.daemon = get_daemon_client()
|
|
@@ -125,7 +118,7 @@ class EnhancedChatClient:
|
|
|
125
118
|
self.commands_list = []
|
|
126
119
|
|
|
127
120
|
async def _initialize_rag_system(self):
|
|
128
|
-
"""Initialize the RAG system for command search"""
|
|
121
|
+
"""Initialize the RAG system for command search."""
|
|
129
122
|
try:
|
|
130
123
|
# Use a simplified command discovery for now to avoid hanging
|
|
131
124
|
from mcli.lib.discovery.command_discovery import ClickCommandDiscovery
|
|
@@ -152,9 +145,7 @@ class EnhancedChatClient:
|
|
|
152
145
|
self.simple_command_lookup = {}
|
|
153
146
|
|
|
154
147
|
def _configure_model_settings(self):
|
|
155
|
-
"""Configure model settings with enhanced system prompt"""
|
|
156
|
-
global config
|
|
157
|
-
|
|
148
|
+
"""Configure model settings with enhanced system prompt."""
|
|
158
149
|
if not self.use_remote:
|
|
159
150
|
config.update(
|
|
160
151
|
{
|
|
@@ -175,7 +166,7 @@ class EnhancedChatClient:
|
|
|
175
166
|
self._configure_model_settings()
|
|
176
167
|
|
|
177
168
|
def _ensure_daemon_running(self):
|
|
178
|
-
"""Ensure the daemon is running for system integration"""
|
|
169
|
+
"""Ensure the daemon is running for system integration."""
|
|
179
170
|
try:
|
|
180
171
|
if not self.daemon.health_check():
|
|
181
172
|
self.daemon.start_daemon()
|
|
@@ -183,7 +174,7 @@ class EnhancedChatClient:
|
|
|
183
174
|
logger.debug(f"Daemon check failed: {e}")
|
|
184
175
|
|
|
185
176
|
async def _enrich_message_with_context(self, user_message: str) -> str:
|
|
186
|
-
"""Enrich user message with relevant command context and system information"""
|
|
177
|
+
"""Enrich user message with relevant command context and system information."""
|
|
187
178
|
enriched_parts = [user_message]
|
|
188
179
|
|
|
189
180
|
# Initialize RAG system if not already done
|
|
@@ -195,7 +186,7 @@ class EnhancedChatClient:
|
|
|
195
186
|
# Add system status only
|
|
196
187
|
system_status = await self._get_system_status()
|
|
197
188
|
if system_status:
|
|
198
|
-
enriched_parts.append(
|
|
189
|
+
enriched_parts.append("\n--- SYSTEM STATUS ---")
|
|
199
190
|
enriched_parts.append(system_status)
|
|
200
191
|
|
|
201
192
|
except Exception as e:
|
|
@@ -204,7 +195,7 @@ class EnhancedChatClient:
|
|
|
204
195
|
return "\n".join(enriched_parts)
|
|
205
196
|
|
|
206
197
|
async def _get_system_status(self) -> str:
|
|
207
|
-
"""Get current system status for context"""
|
|
198
|
+
"""Get current system status for context."""
|
|
208
199
|
status_parts = []
|
|
209
200
|
|
|
210
201
|
try:
|
|
@@ -221,7 +212,7 @@ class EnhancedChatClient:
|
|
|
221
212
|
status_parts.append("Redis cache: Active")
|
|
222
213
|
else:
|
|
223
214
|
status_parts.append("Redis cache: Inactive")
|
|
224
|
-
except:
|
|
215
|
+
except Exception:
|
|
225
216
|
pass
|
|
226
217
|
|
|
227
218
|
try:
|
|
@@ -235,13 +226,13 @@ class EnhancedChatClient:
|
|
|
235
226
|
)
|
|
236
227
|
else:
|
|
237
228
|
status_parts.append("Rust extensions: Inactive")
|
|
238
|
-
except:
|
|
229
|
+
except Exception:
|
|
239
230
|
pass
|
|
240
231
|
|
|
241
232
|
return " | ".join(status_parts) if status_parts else "System status unavailable"
|
|
242
233
|
|
|
243
234
|
def start_interactive_session(self):
|
|
244
|
-
"""Start enhanced interactive chat session"""
|
|
235
|
+
"""Start enhanced interactive chat session."""
|
|
245
236
|
self.console.print("\n๐ค MCLI Enhanced Chat Assistant", style="bold cyan")
|
|
246
237
|
self.console.print(
|
|
247
238
|
"I can help you discover and use MCLI commands through intelligent search!",
|
|
@@ -287,7 +278,7 @@ class EnhancedChatClient:
|
|
|
287
278
|
self.console.print(f"โ Error: {e}", style="red")
|
|
288
279
|
|
|
289
280
|
async def _process_enhanced_message(self, user_message: str):
|
|
290
|
-
"""Process message with RAG enhancement"""
|
|
281
|
+
"""Process message with RAG enhancement."""
|
|
291
282
|
try:
|
|
292
283
|
# Enrich message with command context
|
|
293
284
|
enriched_message = await self._enrich_message_with_context(user_message)
|
|
@@ -317,7 +308,7 @@ class EnhancedChatClient:
|
|
|
317
308
|
self.console.print(f"โ Error processing message: {e}", style="red")
|
|
318
309
|
|
|
319
310
|
async def _get_ai_response(self, message: str) -> Optional[str]:
|
|
320
|
-
"""Get AI response using configured provider"""
|
|
311
|
+
"""Get AI response using configured provider."""
|
|
321
312
|
try:
|
|
322
313
|
if self.use_remote and config.get("openai_api_key"):
|
|
323
314
|
return await self._get_openai_response(message)
|
|
@@ -330,7 +321,7 @@ class EnhancedChatClient:
|
|
|
330
321
|
return None
|
|
331
322
|
|
|
332
323
|
async def _get_openai_response(self, message: str) -> str:
|
|
333
|
-
"""Get response from OpenAI"""
|
|
324
|
+
"""Get response from OpenAI."""
|
|
334
325
|
try:
|
|
335
326
|
import openai
|
|
336
327
|
|
|
@@ -355,7 +346,7 @@ class EnhancedChatClient:
|
|
|
355
346
|
return None
|
|
356
347
|
|
|
357
348
|
async def _get_anthropic_response(self, message: str) -> str:
|
|
358
|
-
"""Get response from Anthropic"""
|
|
349
|
+
"""Get response from Anthropic."""
|
|
359
350
|
try:
|
|
360
351
|
import anthropic
|
|
361
352
|
|
|
@@ -375,7 +366,7 @@ class EnhancedChatClient:
|
|
|
375
366
|
return None
|
|
376
367
|
|
|
377
368
|
async def _get_local_response(self, message: str) -> str:
|
|
378
|
-
"""Get response from local lightweight model"""
|
|
369
|
+
"""Get response from local lightweight model."""
|
|
379
370
|
try:
|
|
380
371
|
# Use improved command matching for local responses
|
|
381
372
|
if hasattr(self, "commands_list") and self.commands_list:
|
|
@@ -392,7 +383,7 @@ class EnhancedChatClient:
|
|
|
392
383
|
cmd_name_clean = cmd.full_name.lower().replace(".", " ")
|
|
393
384
|
if user_lower in cmd_name_clean:
|
|
394
385
|
score += 10
|
|
395
|
-
matched_reasons.append(
|
|
386
|
+
matched_reasons.append("exact phrase match")
|
|
396
387
|
|
|
397
388
|
# High priority: Check if user input matches command structure
|
|
398
389
|
user_parts = user_lower.split()
|
|
@@ -404,7 +395,7 @@ class EnhancedChatClient:
|
|
|
404
395
|
for user_word in user_parts
|
|
405
396
|
):
|
|
406
397
|
score += 8
|
|
407
|
-
matched_reasons.append(
|
|
398
|
+
matched_reasons.append("matches command structure")
|
|
408
399
|
|
|
409
400
|
# Medium priority: Individual word matches in name
|
|
410
401
|
for word in user_words:
|
|
@@ -422,7 +413,7 @@ class EnhancedChatClient:
|
|
|
422
413
|
keyword_map = {
|
|
423
414
|
"video": ["video", "mp4", "avi", "mov", "ffmpeg", "frames"],
|
|
424
415
|
"redis": ["redis", "cache"],
|
|
425
|
-
"file": ["file", "convert", "
|
|
416
|
+
"file": ["file", "convert", "pd", "oxps"],
|
|
426
417
|
"daemon": ["daemon", "service", "api"],
|
|
427
418
|
"workflow": ["workflow", "automation"],
|
|
428
419
|
"system": ["system", "status", "monitor"],
|
|
@@ -468,9 +459,9 @@ class EnhancedChatClient:
|
|
|
468
459
|
# Suggest broader search
|
|
469
460
|
return (
|
|
470
461
|
f"I didn't find specific commands for '{message}', but I can help you explore!\n\n"
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
462
|
+
"Try these approaches:\n"
|
|
463
|
+
"โข Use 'commands' to browse all available commands\n"
|
|
464
|
+
"โข Ask about specific topics like 'video processing', 'file conversion', 'system monitoring'\n"
|
|
474
465
|
f"โข I have {len(self.commands_list)} commands available across categories like workflow, redis, files, and more!"
|
|
475
466
|
)
|
|
476
467
|
|
|
@@ -478,10 +469,10 @@ class EnhancedChatClient:
|
|
|
478
469
|
|
|
479
470
|
except Exception as e:
|
|
480
471
|
logger.error(f"Local response failed: {e}")
|
|
481
|
-
return
|
|
472
|
+
return "I'm here to help with MCLI commands. Try asking about specific tasks like 'video processing' or 'file conversion'."
|
|
482
473
|
|
|
483
474
|
def _display_response(self, response: str):
|
|
484
|
-
"""Display AI response with enhanced formatting"""
|
|
475
|
+
"""Display AI response with enhanced formatting."""
|
|
485
476
|
# Create a panel for the response
|
|
486
477
|
panel = Panel(
|
|
487
478
|
response,
|
|
@@ -493,7 +484,7 @@ class EnhancedChatClient:
|
|
|
493
484
|
self.console.print(panel)
|
|
494
485
|
|
|
495
486
|
async def _highlight_mcli_commands(self, response: str):
|
|
496
|
-
"""Extract and highlight MCLI commands from response"""
|
|
487
|
+
"""Extract and highlight MCLI commands from response."""
|
|
497
488
|
# Look for command patterns in the response
|
|
498
489
|
command_pattern = r"`mcli\s+([^`]+)`|mcli\s+([\w\s\-\.]+)"
|
|
499
490
|
matches = re.findall(command_pattern, response, re.IGNORECASE)
|
|
@@ -506,7 +497,7 @@ class EnhancedChatClient:
|
|
|
506
497
|
self.console.print(f" โข `mcli {command.strip()}`", style="green")
|
|
507
498
|
|
|
508
499
|
async def _handle_command_search(self, query: str):
|
|
509
|
-
"""Handle command search queries"""
|
|
500
|
+
"""Handle command search queries."""
|
|
510
501
|
search_term = query[8:].strip() if len(query) > 8 else "" # Remove "commands"
|
|
511
502
|
|
|
512
503
|
if not self.rag_system:
|
|
@@ -524,7 +515,7 @@ class EnhancedChatClient:
|
|
|
524
515
|
await self._search_and_display_commands(search_term)
|
|
525
516
|
|
|
526
517
|
def _show_command_categories(self, capabilities: Dict[str, Any]):
|
|
527
|
-
"""Show command categories"""
|
|
518
|
+
"""Show command categories."""
|
|
528
519
|
table = Table(title="๐ MCLI Command Categories")
|
|
529
520
|
table.add_column("Category", style="cyan")
|
|
530
521
|
table.add_column("Commands", justify="right", style="magenta")
|
|
@@ -543,7 +534,7 @@ class EnhancedChatClient:
|
|
|
543
534
|
)
|
|
544
535
|
|
|
545
536
|
async def _search_and_display_commands(self, search_term: str):
|
|
546
|
-
"""Search and display matching commands"""
|
|
537
|
+
"""Search and display matching commands."""
|
|
547
538
|
try:
|
|
548
539
|
results = await self.rag_system.search_commands(search_term, limit=8)
|
|
549
540
|
|
|
@@ -569,7 +560,7 @@ class EnhancedChatClient:
|
|
|
569
560
|
self.console.print(f"โ Search failed: {e}", style="red")
|
|
570
561
|
|
|
571
562
|
async def _show_system_status(self):
|
|
572
|
-
"""Show comprehensive system status"""
|
|
563
|
+
"""Show comprehensive system status."""
|
|
573
564
|
try:
|
|
574
565
|
status_info = await self._get_system_status()
|
|
575
566
|
|
|
@@ -590,7 +581,7 @@ class EnhancedChatClient:
|
|
|
590
581
|
self.console.print(f"โ Status check failed: {e}", style="red")
|
|
591
582
|
|
|
592
583
|
def _show_help(self):
|
|
593
|
-
"""Show enhanced help information"""
|
|
584
|
+
"""Show enhanced help information."""
|
|
594
585
|
help_text = """
|
|
595
586
|
๐ค **MCLI Enhanced Chat Assistant Help**
|
|
596
587
|
|
|
@@ -629,7 +620,7 @@ class EnhancedChatClient:
|
|
|
629
620
|
self.console.print(help_panel)
|
|
630
621
|
|
|
631
622
|
def _handle_quit(self):
|
|
632
|
-
"""Handle quit command"""
|
|
623
|
+
"""Handle quit command."""
|
|
633
624
|
self.session_active = False
|
|
634
625
|
self.console.print("\n๐ฏ **Session Summary:**")
|
|
635
626
|
if self.conversation_context:
|
|
@@ -648,5 +639,5 @@ class EnhancedChatClient:
|
|
|
648
639
|
def create_enhanced_chat_client(
|
|
649
640
|
use_remote: bool = False, model_override: str = None
|
|
650
641
|
) -> EnhancedChatClient:
|
|
651
|
-
"""Create enhanced chat client instance"""
|
|
642
|
+
"""Create enhanced chat client instance."""
|
|
652
643
|
return EnhancedChatClient(use_remote=use_remote, model_override=model_override)
|
mcli/chat/system_controller.py
CHANGED
|
@@ -9,7 +9,7 @@ import subprocess
|
|
|
9
9
|
import time
|
|
10
10
|
from datetime import datetime
|
|
11
11
|
from pathlib import Path
|
|
12
|
-
from typing import Any, Dict, List
|
|
12
|
+
from typing import Any, Dict, List
|
|
13
13
|
|
|
14
14
|
from mcli.lib.logger.logger import get_logger
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ logger = get_logger(__name__)
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class SystemController:
|
|
20
|
-
"""Handles real-time system control for MCLI chat"""
|
|
20
|
+
"""Handles real-time system control for MCLI chat."""
|
|
21
21
|
|
|
22
22
|
def __init__(self):
|
|
23
23
|
self.system = platform.system()
|
|
@@ -25,7 +25,7 @@ class SystemController:
|
|
|
25
25
|
self.current_directory = os.getcwd() # Track current working directory
|
|
26
26
|
|
|
27
27
|
def execute_command(self, command: str, description: str = "") -> Dict[str, Any]:
|
|
28
|
-
"""Execute a system command and return results"""
|
|
28
|
+
"""Execute a system command and return results."""
|
|
29
29
|
try:
|
|
30
30
|
logger.info(f"Executing: {description or command}")
|
|
31
31
|
|
|
@@ -57,7 +57,7 @@ class SystemController:
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
def open_textedit_and_write(self, text: str, filename: str = None) -> Dict[str, Any]:
|
|
60
|
-
"""Open TextEdit, write text, and optionally save to file"""
|
|
60
|
+
"""Open TextEdit, write text, and optionally save to file."""
|
|
61
61
|
if self.system != "Darwin":
|
|
62
62
|
return {
|
|
63
63
|
"success": False,
|
|
@@ -93,7 +93,7 @@ class SystemController:
|
|
|
93
93
|
)
|
|
94
94
|
|
|
95
95
|
def control_application(self, app_name: str, action: str, **kwargs) -> Dict[str, Any]:
|
|
96
|
-
"""Control various applications with different actions"""
|
|
96
|
+
"""Control various applications with different actions."""
|
|
97
97
|
|
|
98
98
|
if self.system == "Darwin": # macOS
|
|
99
99
|
return self._control_macos_app(app_name, action, **kwargs)
|
|
@@ -103,7 +103,7 @@ class SystemController:
|
|
|
103
103
|
return self._control_linux_app(app_name, action, **kwargs)
|
|
104
104
|
|
|
105
105
|
def _control_macos_app(self, app_name: str, action: str, **kwargs) -> Dict[str, Any]:
|
|
106
|
-
"""Control macOS applications using AppleScript"""
|
|
106
|
+
"""Control macOS applications using AppleScript."""
|
|
107
107
|
|
|
108
108
|
if action == "open":
|
|
109
109
|
applescript = f'tell application "{app_name}" to activate'
|
|
@@ -149,7 +149,7 @@ class SystemController:
|
|
|
149
149
|
return self.execute_command(f"osascript -e '{applescript}'", f"{action} {app_name}")
|
|
150
150
|
|
|
151
151
|
def _control_windows_app(self, app_name: str, action: str, **kwargs) -> Dict[str, Any]:
|
|
152
|
-
"""Control Windows applications using PowerShell"""
|
|
152
|
+
"""Control Windows applications using PowerShell."""
|
|
153
153
|
|
|
154
154
|
if action == "open":
|
|
155
155
|
# Try to start the application
|
|
@@ -173,7 +173,7 @@ class SystemController:
|
|
|
173
173
|
return self.execute_command(command, f"{action} {app_name}")
|
|
174
174
|
|
|
175
175
|
def _control_linux_app(self, app_name: str, action: str, **kwargs) -> Dict[str, Any]:
|
|
176
|
-
"""Control Linux applications using various tools"""
|
|
176
|
+
"""Control Linux applications using various tools."""
|
|
177
177
|
|
|
178
178
|
if action == "open":
|
|
179
179
|
# Try different methods to open applications
|
|
@@ -212,7 +212,7 @@ class SystemController:
|
|
|
212
212
|
return self.execute_command(command, f"{action} {app_name}")
|
|
213
213
|
|
|
214
214
|
def get_system_info(self) -> Dict[str, Any]:
|
|
215
|
-
"""Get comprehensive system information"""
|
|
215
|
+
"""Get comprehensive system information."""
|
|
216
216
|
try:
|
|
217
217
|
import platform
|
|
218
218
|
from datetime import datetime
|
|
@@ -261,7 +261,7 @@ class SystemController:
|
|
|
261
261
|
|
|
262
262
|
# Disk information
|
|
263
263
|
disk_info = []
|
|
264
|
-
try:
|
|
264
|
+
try: # noqa: SIM105
|
|
265
265
|
for partition in psutil.disk_partitions():
|
|
266
266
|
try:
|
|
267
267
|
partition_usage = psutil.disk_usage(partition.mountpoint)
|
|
@@ -278,7 +278,7 @@ class SystemController:
|
|
|
278
278
|
),
|
|
279
279
|
}
|
|
280
280
|
)
|
|
281
|
-
except
|
|
281
|
+
except OSError:
|
|
282
282
|
# Skip partitions we can't access
|
|
283
283
|
continue
|
|
284
284
|
except Exception:
|
|
@@ -291,12 +291,12 @@ class SystemController:
|
|
|
291
291
|
"connections": 0,
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
try:
|
|
294
|
+
try: # noqa: SIM105
|
|
295
295
|
network_info["connections"] = len(psutil.net_connections())
|
|
296
296
|
except Exception:
|
|
297
297
|
pass
|
|
298
298
|
|
|
299
|
-
try:
|
|
299
|
+
try: # noqa: SIM105
|
|
300
300
|
for interface, addresses in psutil.net_if_addrs().items():
|
|
301
301
|
network_info["interfaces"][interface] = []
|
|
302
302
|
for addr in addresses:
|
|
@@ -365,7 +365,7 @@ class SystemController:
|
|
|
365
365
|
return {"success": False, "error": str(e), "description": "Get system information"}
|
|
366
366
|
|
|
367
367
|
def get_system_time(self) -> Dict[str, Any]:
|
|
368
|
-
"""Get current system time and timezone information"""
|
|
368
|
+
"""Get current system time and timezone information."""
|
|
369
369
|
try:
|
|
370
370
|
import time
|
|
371
371
|
from datetime import datetime
|
|
@@ -388,7 +388,7 @@ class SystemController:
|
|
|
388
388
|
return {"success": False, "error": str(e), "description": "Get system time"}
|
|
389
389
|
|
|
390
390
|
def get_memory_usage(self) -> Dict[str, Any]:
|
|
391
|
-
"""Get detailed memory usage information"""
|
|
391
|
+
"""Get detailed memory usage information."""
|
|
392
392
|
try:
|
|
393
393
|
import psutil
|
|
394
394
|
|
|
@@ -443,7 +443,7 @@ class SystemController:
|
|
|
443
443
|
return {"success": False, "error": str(e), "description": "Get memory usage"}
|
|
444
444
|
|
|
445
445
|
def get_disk_usage(self) -> Dict[str, Any]:
|
|
446
|
-
"""Get detailed disk usage information"""
|
|
446
|
+
"""Get detailed disk usage information."""
|
|
447
447
|
try:
|
|
448
448
|
import psutil
|
|
449
449
|
|
|
@@ -503,7 +503,7 @@ class SystemController:
|
|
|
503
503
|
return {"success": False, "error": str(e), "description": "Get disk usage"}
|
|
504
504
|
|
|
505
505
|
def clear_system_caches(self) -> Dict[str, Any]:
|
|
506
|
-
"""Clear system caches and temporary files"""
|
|
506
|
+
"""Clear system caches and temporary files."""
|
|
507
507
|
try:
|
|
508
508
|
cleared_items = []
|
|
509
509
|
total_freed_mb = 0
|
|
@@ -598,22 +598,22 @@ class SystemController:
|
|
|
598
598
|
return {"success": False, "error": str(e), "description": "Clear system caches"}
|
|
599
599
|
|
|
600
600
|
def _get_directory_size(self, path: str) -> int:
|
|
601
|
-
"""Get total size of directory in bytes"""
|
|
601
|
+
"""Get total size of directory in bytes."""
|
|
602
602
|
total_size = 0
|
|
603
|
-
try:
|
|
603
|
+
try: # noqa: SIM105
|
|
604
604
|
for dirpath, dirnames, filenames in os.walk(path):
|
|
605
605
|
for filename in filenames:
|
|
606
606
|
file_path = os.path.join(dirpath, filename)
|
|
607
607
|
try:
|
|
608
608
|
total_size += os.path.getsize(file_path)
|
|
609
|
-
except
|
|
609
|
+
except OSError:
|
|
610
610
|
continue
|
|
611
611
|
except Exception:
|
|
612
612
|
pass
|
|
613
613
|
return total_size
|
|
614
614
|
|
|
615
615
|
def get_running_applications(self) -> List[str]:
|
|
616
|
-
"""Get list of currently running applications"""
|
|
616
|
+
"""Get list of currently running applications."""
|
|
617
617
|
try:
|
|
618
618
|
if self.system == "Darwin":
|
|
619
619
|
result = subprocess.run(
|
|
@@ -664,7 +664,7 @@ class SystemController:
|
|
|
664
664
|
return []
|
|
665
665
|
|
|
666
666
|
def take_screenshot(self, filename: str = None) -> Dict[str, Any]:
|
|
667
|
-
"""Take a screenshot and save it"""
|
|
667
|
+
"""Take a screenshot and save it."""
|
|
668
668
|
if not filename:
|
|
669
669
|
timestamp = time.strftime("%Y%m%d_%H%M%S")
|
|
670
670
|
filename = f"mcli_screenshot_{timestamp}.png"
|
|
@@ -694,7 +694,7 @@ class SystemController:
|
|
|
694
694
|
}
|
|
695
695
|
|
|
696
696
|
def open_file_or_url(self, path_or_url: str) -> Dict[str, Any]:
|
|
697
|
-
"""Open a file or URL using the system default application"""
|
|
697
|
+
"""Open a file or URL using the system default application."""
|
|
698
698
|
try:
|
|
699
699
|
if self.system == "Darwin":
|
|
700
700
|
command = f"open '{path_or_url}'"
|
|
@@ -709,7 +709,7 @@ class SystemController:
|
|
|
709
709
|
return {"success": False, "error": str(e), "description": f"Open: {path_or_url}"}
|
|
710
710
|
|
|
711
711
|
def change_directory(self, path: str) -> Dict[str, Any]:
|
|
712
|
-
"""Navigate to a directory and update current working directory"""
|
|
712
|
+
"""Navigate to a directory and update current working directory."""
|
|
713
713
|
try:
|
|
714
714
|
# Expand user path and resolve relative paths
|
|
715
715
|
expanded_path = os.path.expanduser(path)
|
|
@@ -751,7 +751,7 @@ class SystemController:
|
|
|
751
751
|
def list_directory(
|
|
752
752
|
self, path: str = None, show_hidden: bool = False, detailed: bool = False
|
|
753
753
|
) -> Dict[str, Any]:
|
|
754
|
-
"""List contents of a directory"""
|
|
754
|
+
"""List contents of a directory."""
|
|
755
755
|
try:
|
|
756
756
|
target_path = path if path else self.current_directory
|
|
757
757
|
expanded_path = os.path.expanduser(target_path)
|
|
@@ -826,7 +826,7 @@ class SystemController:
|
|
|
826
826
|
}
|
|
827
827
|
|
|
828
828
|
def clean_simulator_data(self) -> Dict[str, Any]:
|
|
829
|
-
"""Clean iOS/watchOS simulator data specifically"""
|
|
829
|
+
"""Clean iOS/watchOS simulator data specifically."""
|
|
830
830
|
try:
|
|
831
831
|
if self.system != "Darwin":
|
|
832
832
|
return {
|
|
@@ -910,7 +910,7 @@ class SystemController:
|
|
|
910
910
|
return {"success": False, "error": str(e), "description": "Clean simulator data"}
|
|
911
911
|
|
|
912
912
|
def execute_shell_command(self, command: str, working_directory: str = None) -> Dict[str, Any]:
|
|
913
|
-
"""Execute a shell command in a specific directory"""
|
|
913
|
+
"""Execute a shell command in a specific directory."""
|
|
914
914
|
try:
|
|
915
915
|
# Use working directory if specified, otherwise use current directory
|
|
916
916
|
cwd = working_directory if working_directory else self.current_directory
|
|
@@ -959,52 +959,52 @@ system_controller = SystemController()
|
|
|
959
959
|
|
|
960
960
|
# Helper functions for easy use in chat
|
|
961
961
|
def open_textedit_and_write(text: str, filename: str = None) -> Dict[str, Any]:
|
|
962
|
-
"""Helper function to open TextEdit and write text"""
|
|
962
|
+
"""Helper function to open TextEdit and write text."""
|
|
963
963
|
return system_controller.open_textedit_and_write(text, filename)
|
|
964
964
|
|
|
965
965
|
|
|
966
966
|
def control_app(app_name: str, action: str, **kwargs) -> Dict[str, Any]:
|
|
967
|
-
"""Helper function to control applications"""
|
|
967
|
+
"""Helper function to control applications."""
|
|
968
968
|
return system_controller.control_application(app_name, action, **kwargs)
|
|
969
969
|
|
|
970
970
|
|
|
971
971
|
def execute_system_command(command: str, description: str = "") -> Dict[str, Any]:
|
|
972
|
-
"""Helper function to execute system commands"""
|
|
972
|
+
"""Helper function to execute system commands."""
|
|
973
973
|
return system_controller.execute_command(command, description)
|
|
974
974
|
|
|
975
975
|
|
|
976
976
|
def take_screenshot(filename: str = None) -> Dict[str, Any]:
|
|
977
|
-
"""Helper function to take screenshots"""
|
|
977
|
+
"""Helper function to take screenshots."""
|
|
978
978
|
return system_controller.take_screenshot(filename)
|
|
979
979
|
|
|
980
980
|
|
|
981
981
|
def open_file_or_url(path_or_url: str) -> Dict[str, Any]:
|
|
982
|
-
"""Helper function to open files or URLs"""
|
|
982
|
+
"""Helper function to open files or URLs."""
|
|
983
983
|
return system_controller.open_file_or_url(path_or_url)
|
|
984
984
|
|
|
985
985
|
|
|
986
986
|
def change_directory(path: str) -> Dict[str, Any]:
|
|
987
|
-
"""Helper function to navigate to a directory"""
|
|
987
|
+
"""Helper function to navigate to a directory."""
|
|
988
988
|
return system_controller.change_directory(path)
|
|
989
989
|
|
|
990
990
|
|
|
991
991
|
def list_directory(
|
|
992
992
|
path: str = None, show_hidden: bool = False, detailed: bool = False
|
|
993
993
|
) -> Dict[str, Any]:
|
|
994
|
-
"""Helper function to list directory contents"""
|
|
994
|
+
"""Helper function to list directory contents."""
|
|
995
995
|
return system_controller.list_directory(path, show_hidden, detailed)
|
|
996
996
|
|
|
997
997
|
|
|
998
998
|
def clean_simulator_data() -> Dict[str, Any]:
|
|
999
|
-
"""Helper function to clean iOS/watchOS simulator data"""
|
|
999
|
+
"""Helper function to clean iOS/watchOS simulator data."""
|
|
1000
1000
|
return system_controller.clean_simulator_data()
|
|
1001
1001
|
|
|
1002
1002
|
|
|
1003
1003
|
def execute_shell_command(command: str, working_directory: str = None) -> Dict[str, Any]:
|
|
1004
|
-
"""Helper function to execute shell commands"""
|
|
1004
|
+
"""Helper function to execute shell commands."""
|
|
1005
1005
|
return system_controller.execute_shell_command(command, working_directory)
|
|
1006
1006
|
|
|
1007
1007
|
|
|
1008
1008
|
def get_current_directory() -> str:
|
|
1009
|
-
"""Helper function to get current working directory"""
|
|
1009
|
+
"""Helper function to get current working directory."""
|
|
1010
1010
|
return system_controller.current_directory
|
mcli/chat/system_integration.py
CHANGED
|
@@ -3,8 +3,7 @@ System Integration for MCLI Chat
|
|
|
3
3
|
Provides system control capabilities directly within chat conversations
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
from typing import Any, Dict, List
|
|
6
|
+
from typing import Any, Dict
|
|
8
7
|
|
|
9
8
|
from mcli.lib.logger.logger import get_logger
|
|
10
9
|
|
|
@@ -692,7 +691,7 @@ class ChatSystemIntegration:
|
|
|
692
691
|
swap = memory_data["swap_memory"]
|
|
693
692
|
|
|
694
693
|
summary = [
|
|
695
|
-
|
|
694
|
+
"๐พ Memory Usage:",
|
|
696
695
|
f" RAM: {vm['used_gb']:.1f}GB used / {vm['total_gb']:.1f}GB total ({vm['usage_percent']}%)",
|
|
697
696
|
f" Available: {vm['available_gb']:.1f}GB",
|
|
698
697
|
f" Swap: {swap['used_gb']:.1f}GB used / {swap['total_gb']:.1f}GB total ({swap['usage_percent']}%)",
|
|
@@ -723,7 +722,7 @@ class ChatSystemIntegration:
|
|
|
723
722
|
if result["success"]:
|
|
724
723
|
disk_data = result["data"]
|
|
725
724
|
|
|
726
|
-
summary = [
|
|
725
|
+
summary = ["๐ฝ Disk Usage:"]
|
|
727
726
|
|
|
728
727
|
# Show main disk first
|
|
729
728
|
if disk_data["total_disk_gb"] > 0:
|
|
@@ -763,7 +762,7 @@ class ChatSystemIntegration:
|
|
|
763
762
|
if result["success"]:
|
|
764
763
|
cache_data = result["data"]
|
|
765
764
|
|
|
766
|
-
summary = [
|
|
765
|
+
summary = ["๐งน Cache Cleanup Results:"]
|
|
767
766
|
|
|
768
767
|
if cache_data["cleared_items"]:
|
|
769
768
|
for item in cache_data["cleared_items"]:
|
mcli/cli.py
CHANGED
|
@@ -5,8 +5,7 @@ from mcli.lib.api.mcli_decorators import chat
|
|
|
5
5
|
|
|
6
6
|
@click.group()
|
|
7
7
|
def cli():
|
|
8
|
-
"""MCLI - Modern Command Line Interface"""
|
|
9
|
-
pass
|
|
8
|
+
"""MCLI - Modern Command Line Interface."""
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
# Add the chat command group
|
|
@@ -15,7 +14,7 @@ cli.add_command(chat(name="chat"))
|
|
|
15
14
|
|
|
16
15
|
@cli.command()
|
|
17
16
|
def version():
|
|
18
|
-
"""Show MCLI version"""
|
|
17
|
+
"""Show MCLI version."""
|
|
19
18
|
from mcli import __version__
|
|
20
19
|
|
|
21
20
|
click.echo(f"MCLI version {__version__}")
|