Add action explanation and follow-up functionality to MachaChatSession
- Introduced `explain_action` method to provide detailed explanations for pending actions in the approval queue. - Added `answer_action_followup` method to handle user follow-up questions regarding proposed actions. - Updated `main` function to support discussion mode with action explanations and follow-ups. - Refactored `conversation.py` to utilize the unified chat implementation from `chat.py`, enhancing compatibility and functionality. - Enhanced error handling for file operations and user input validation in both new methods.
This commit is contained in:
@@ -20,6 +20,7 @@ from remote_monitor import RemoteMonitor
|
||||
from config_parser import ConfigParser
|
||||
from system_discovery import SystemDiscovery
|
||||
from issue_tracker import IssueTracker
|
||||
from git_context import GitContext
|
||||
from typing import List
|
||||
|
||||
|
||||
@@ -63,6 +64,20 @@ class MachaOrchestrator:
|
||||
except Exception as e:
|
||||
self._log(f"Warning: Could not initialize config parser: {e}")
|
||||
|
||||
# Initialize git context
|
||||
self.git_context = None
|
||||
if self.config_parser:
|
||||
try:
|
||||
# Use the same local repo path as config_parser
|
||||
local_repo_path = Path("/var/lib/macha/config-repo")
|
||||
if local_repo_path.exists():
|
||||
self.git_context = GitContext(repo_path=str(local_repo_path))
|
||||
self._log(f"Git context initialized for {local_repo_path}")
|
||||
else:
|
||||
self._log(f"Warning: Config repo not found at {local_repo_path}")
|
||||
except Exception as e:
|
||||
self._log(f"Warning: Could not initialize git context: {e}")
|
||||
|
||||
# Initialize components
|
||||
self.monitor = SystemMonitor(state_dir)
|
||||
self.agent = MachaAgent(
|
||||
@@ -667,6 +682,22 @@ class MachaOrchestrator:
|
||||
if self._cycle_count % 10 == 1: # First cycle and every 10th
|
||||
self._update_service_registry()
|
||||
|
||||
# Refresh configuration repository every 3 cycles (~15 min) to keep git context current
|
||||
# This ensures git_context has up-to-date information about recent config changes
|
||||
if self._cycle_count % 3 == 1 and self.config_parser:
|
||||
try:
|
||||
self._log("Refreshing configuration repository...")
|
||||
if self.config_parser.ensure_repo():
|
||||
self._log("✓ Configuration repository updated")
|
||||
# Reinitialize git_context if it exists to pick up fresh data
|
||||
if self.git_context:
|
||||
local_repo_path = Path("/var/lib/macha/config-repo")
|
||||
self.git_context = GitContext(repo_path=str(local_repo_path))
|
||||
else:
|
||||
self._log("⚠ Could not refresh configuration repository")
|
||||
except Exception as e:
|
||||
self._log(f"⚠ Error refreshing config repo: {e}")
|
||||
|
||||
# Step 1: Monitor system
|
||||
self._log("Collecting system health data...")
|
||||
monitoring_data = self.monitor.collect_all()
|
||||
|
||||
Reference in New Issue
Block a user