claude-mpm 3.1.3__py3-none-any.whl → 3.3.0__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.
- claude_mpm/__init__.py +3 -3
 - claude_mpm/__main__.py +0 -17
 - claude_mpm/agents/INSTRUCTIONS.md +149 -17
 - claude_mpm/agents/backups/INSTRUCTIONS.md +238 -0
 - claude_mpm/agents/base_agent.json +1 -1
 - claude_mpm/agents/templates/pm.json +25 -0
 - claude_mpm/agents/templates/research.json +2 -1
 - claude_mpm/cli/__init__.py +19 -23
 - claude_mpm/cli/commands/__init__.py +3 -1
 - claude_mpm/cli/commands/agents.py +7 -18
 - claude_mpm/cli/commands/info.py +5 -10
 - claude_mpm/cli/commands/memory.py +232 -0
 - claude_mpm/cli/commands/run.py +501 -28
 - claude_mpm/cli/commands/tickets.py +10 -17
 - claude_mpm/cli/commands/ui.py +15 -37
 - claude_mpm/cli/parser.py +91 -1
 - claude_mpm/cli/utils.py +9 -28
 - claude_mpm/config/socketio_config.py +256 -0
 - claude_mpm/constants.py +9 -0
 - claude_mpm/core/__init__.py +2 -2
 - claude_mpm/core/agent_registry.py +4 -4
 - claude_mpm/core/claude_runner.py +919 -0
 - claude_mpm/core/config.py +21 -1
 - claude_mpm/core/factories.py +1 -1
 - claude_mpm/core/hook_manager.py +196 -0
 - claude_mpm/core/pm_hook_interceptor.py +205 -0
 - claude_mpm/core/service_registry.py +1 -1
 - claude_mpm/core/simple_runner.py +323 -33
 - claude_mpm/core/socketio_pool.py +582 -0
 - claude_mpm/core/websocket_handler.py +233 -0
 - claude_mpm/deployment_paths.py +261 -0
 - claude_mpm/hooks/builtin/memory_hooks_example.py +67 -0
 - claude_mpm/hooks/claude_hooks/hook_handler.py +667 -679
 - claude_mpm/hooks/claude_hooks/hook_wrapper.sh +9 -4
 - claude_mpm/hooks/memory_integration_hook.py +312 -0
 - claude_mpm/models/__init__.py +9 -91
 - claude_mpm/orchestration/__init__.py +1 -1
 - claude_mpm/scripts/claude-mpm-socketio +32 -0
 - claude_mpm/scripts/claude_mpm_monitor.html +567 -0
 - claude_mpm/scripts/install_socketio_server.py +407 -0
 - claude_mpm/scripts/launch_monitor.py +132 -0
 - claude_mpm/scripts/launch_socketio_dashboard.py +261 -0
 - claude_mpm/scripts/manage_version.py +479 -0
 - claude_mpm/scripts/socketio_daemon.py +181 -0
 - claude_mpm/scripts/socketio_server_manager.py +428 -0
 - claude_mpm/services/__init__.py +5 -0
 - claude_mpm/services/agent_lifecycle_manager.py +76 -25
 - claude_mpm/services/agent_memory_manager.py +684 -0
 - claude_mpm/services/agent_modification_tracker.py +98 -17
 - claude_mpm/services/agent_persistence_service.py +33 -13
 - claude_mpm/services/agent_registry.py +82 -43
 - claude_mpm/services/hook_service.py +362 -0
 - claude_mpm/services/socketio_client_manager.py +474 -0
 - claude_mpm/services/socketio_server.py +922 -0
 - claude_mpm/services/standalone_socketio_server.py +631 -0
 - claude_mpm/services/ticket_manager.py +4 -5
 - claude_mpm/services/{ticket_manager_dependency_injection.py → ticket_manager_di.py} +12 -39
 - claude_mpm/services/{legacy_ticketing_service.py → ticketing_service_original.py} +9 -16
 - claude_mpm/services/version_control/semantic_versioning.py +9 -10
 - claude_mpm/services/websocket_server.py +376 -0
 - claude_mpm/utils/dependency_manager.py +211 -0
 - claude_mpm/utils/import_migration_example.py +80 -0
 - claude_mpm/utils/path_operations.py +0 -20
 - claude_mpm/web/open_dashboard.py +34 -0
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/METADATA +20 -9
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/RECORD +71 -50
 - claude_mpm-3.3.0.dist-info/entry_points.txt +7 -0
 - claude_mpm/cli_old.py +0 -728
 - claude_mpm/models/common.py +0 -41
 - claude_mpm/models/lifecycle.py +0 -97
 - claude_mpm/models/modification.py +0 -126
 - claude_mpm/models/persistence.py +0 -57
 - claude_mpm/models/registry.py +0 -91
 - claude_mpm/security/__init__.py +0 -8
 - claude_mpm/security/bash_validator.py +0 -393
 - claude_mpm-3.1.3.dist-info/entry_points.txt +0 -4
 - /claude_mpm/{cli_enhancements.py → experimental/cli_enhancements.py} +0 -0
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/WHEEL +0 -0
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/licenses/LICENSE +0 -0
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/top_level.txt +0 -0
 
| 
         @@ -7,12 +7,9 @@ and cleaning agent deployments. 
     | 
|
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            from pathlib import Path
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
            from  
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            get_logger = safe_import('claude_mpm.core.logger', None, ['get_logger'])
         
     | 
| 
       14 
     | 
    
         
            -
            AgentCommands = safe_import('claude_mpm.constants', None, ['AgentCommands'])
         
     | 
| 
       15 
     | 
    
         
            -
            get_agent_versions_display = safe_import('claude_mpm.cli.utils', None, ['get_agent_versions_display'])
         
     | 
| 
      
 10 
     | 
    
         
            +
            from ...core.logger import get_logger
         
     | 
| 
      
 11 
     | 
    
         
            +
            from ...constants import AgentCommands
         
     | 
| 
      
 12 
     | 
    
         
            +
            from ..utils import get_agent_versions_display
         
     | 
| 
       16 
13 
     | 
    
         | 
| 
       17 
14 
     | 
    
         | 
| 
       18 
15 
     | 
    
         
             
            def manage_agents(args):
         
     | 
| 
         @@ -30,19 +27,8 @@ def manage_agents(args): 
     | 
|
| 
       30 
27 
     | 
    
         
             
                """
         
     | 
| 
       31 
28 
     | 
    
         
             
                logger = get_logger("cli")
         
     | 
| 
       32 
29 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                # Import AgentDeploymentService using safe_import pattern
         
     | 
| 
       34 
     | 
    
         
            -
                AgentDeploymentService = safe_import(
         
     | 
| 
       35 
     | 
    
         
            -
                    'claude_mpm.services.agent_deployment',
         
     | 
| 
       36 
     | 
    
         
            -
                    None,
         
     | 
| 
       37 
     | 
    
         
            -
                    ['AgentDeploymentService']
         
     | 
| 
       38 
     | 
    
         
            -
                )
         
     | 
| 
       39 
     | 
    
         
            -
                
         
     | 
| 
       40 
     | 
    
         
            -
                if not AgentDeploymentService:
         
     | 
| 
       41 
     | 
    
         
            -
                    logger.error("Agent deployment service not available")
         
     | 
| 
       42 
     | 
    
         
            -
                    print("Error: Agent deployment service not available")
         
     | 
| 
       43 
     | 
    
         
            -
                    return
         
     | 
| 
       44 
     | 
    
         
            -
                
         
     | 
| 
       45 
30 
     | 
    
         
             
                try:
         
     | 
| 
      
 31 
     | 
    
         
            +
                    from ...services.agent_deployment import AgentDeploymentService
         
     | 
| 
       46 
32 
     | 
    
         
             
                    deployment_service = AgentDeploymentService()
         
     | 
| 
       47 
33 
     | 
    
         | 
| 
       48 
34 
     | 
    
         
             
                    if not args.agents_command:
         
     | 
| 
         @@ -69,6 +55,9 @@ def manage_agents(args): 
     | 
|
| 
       69 
55 
     | 
    
         
             
                    elif args.agents_command == AgentCommands.CLEAN.value:
         
     | 
| 
       70 
56 
     | 
    
         
             
                        _clean_agents(args, deployment_service)
         
     | 
| 
       71 
57 
     | 
    
         | 
| 
      
 58 
     | 
    
         
            +
                except ImportError:
         
     | 
| 
      
 59 
     | 
    
         
            +
                    logger.error("Agent deployment service not available")
         
     | 
| 
      
 60 
     | 
    
         
            +
                    print("Error: Agent deployment service not available")
         
     | 
| 
       72 
61 
     | 
    
         
             
                except Exception as e:
         
     | 
| 
       73 
62 
     | 
    
         
             
                    logger.error(f"Error managing agents: {e}")
         
     | 
| 
       74 
63 
     | 
    
         
             
                    print(f"Error: {e}")
         
     | 
    
        claude_mpm/cli/commands/info.py
    CHANGED
    
    | 
         @@ -8,10 +8,7 @@ users understand their claude-mpm setup and troubleshoot issues. 
     | 
|
| 
       8 
8 
     | 
    
         
             
            import shutil
         
     | 
| 
       9 
9 
     | 
    
         
             
            from pathlib import Path
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
            from  
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            # Import logger using safe_import pattern
         
     | 
| 
       14 
     | 
    
         
            -
            get_logger = safe_import('claude_mpm.core.logger', None, ['get_logger'])
         
     | 
| 
      
 11 
     | 
    
         
            +
            from ...core.logger import get_logger
         
     | 
| 
       15 
12 
     | 
    
         | 
| 
       16 
13 
     | 
    
         | 
| 
       17 
14 
     | 
    
         
             
            def show_info(args):
         
     | 
| 
         @@ -28,12 +25,10 @@ def show_info(args): 
     | 
|
| 
       28 
25 
     | 
    
         
             
                Args:
         
     | 
| 
       29 
26 
     | 
    
         
             
                    args: Parsed command line arguments
         
     | 
| 
       30 
27 
     | 
    
         
             
                """
         
     | 
| 
       31 
     | 
    
         
            -
                 
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                     
     | 
| 
       35 
     | 
    
         
            -
                    ['FrameworkLoader']
         
     | 
| 
       36 
     | 
    
         
            -
                )
         
     | 
| 
      
 28 
     | 
    
         
            +
                try:
         
     | 
| 
      
 29 
     | 
    
         
            +
                    from ...core.framework_loader import FrameworkLoader
         
     | 
| 
      
 30 
     | 
    
         
            +
                except ImportError:
         
     | 
| 
      
 31 
     | 
    
         
            +
                    from claude_mpm.core.framework_loader import FrameworkLoader
         
     | 
| 
       37 
32 
     | 
    
         | 
| 
       38 
33 
     | 
    
         
             
                print("Claude MPM - Multi-Agent Project Manager")
         
     | 
| 
       39 
34 
     | 
    
         
             
                print("=" * 50)
         
     | 
| 
         @@ -0,0 +1,232 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            """
         
     | 
| 
      
 2 
     | 
    
         
            +
            Memory command implementation for claude-mpm.
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            WHY: This module provides CLI commands for managing agent memory files,
         
     | 
| 
      
 5 
     | 
    
         
            +
            allowing users to view, add, and manage persistent learnings across sessions.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            DESIGN DECISION: We follow the existing CLI pattern using a main function
         
     | 
| 
      
 8 
     | 
    
         
            +
            that dispatches to specific subcommand handlers. This maintains consistency
         
     | 
| 
      
 9 
     | 
    
         
            +
            with other command modules like agents.py.
         
     | 
| 
      
 10 
     | 
    
         
            +
            """
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            import json
         
     | 
| 
      
 13 
     | 
    
         
            +
            from datetime import datetime
         
     | 
| 
      
 14 
     | 
    
         
            +
            from pathlib import Path
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            import click
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            from ...core.logger import get_logger
         
     | 
| 
      
 19 
     | 
    
         
            +
            from ...core.config import Config
         
     | 
| 
      
 20 
     | 
    
         
            +
            from ...services.agent_memory_manager import AgentMemoryManager
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            def manage_memory(args):
         
     | 
| 
      
 24 
     | 
    
         
            +
                """
         
     | 
| 
      
 25 
     | 
    
         
            +
                Manage agent memory files.
         
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
      
 27 
     | 
    
         
            +
                WHY: Agents need persistent memory to maintain learnings across sessions.
         
     | 
| 
      
 28 
     | 
    
         
            +
                This command provides a unified interface for memory-related operations.
         
     | 
| 
      
 29 
     | 
    
         
            +
                
         
     | 
| 
      
 30 
     | 
    
         
            +
                DESIGN DECISION: When no subcommand is provided, we show memory status
         
     | 
| 
      
 31 
     | 
    
         
            +
                as the default action, giving users a quick overview of the memory system.
         
     | 
| 
      
 32 
     | 
    
         
            +
                
         
     | 
| 
      
 33 
     | 
    
         
            +
                Args:
         
     | 
| 
      
 34 
     | 
    
         
            +
                    args: Parsed command line arguments with memory_command attribute
         
     | 
| 
      
 35 
     | 
    
         
            +
                """
         
     | 
| 
      
 36 
     | 
    
         
            +
                logger = get_logger("cli")
         
     | 
| 
      
 37 
     | 
    
         
            +
                
         
     | 
| 
      
 38 
     | 
    
         
            +
                try:
         
     | 
| 
      
 39 
     | 
    
         
            +
                    # Load configuration for memory manager
         
     | 
| 
      
 40 
     | 
    
         
            +
                    config = Config()
         
     | 
| 
      
 41 
     | 
    
         
            +
                    memory_manager = AgentMemoryManager(config)
         
     | 
| 
      
 42 
     | 
    
         
            +
                    
         
     | 
| 
      
 43 
     | 
    
         
            +
                    if not args.memory_command:
         
     | 
| 
      
 44 
     | 
    
         
            +
                        # No subcommand - show status
         
     | 
| 
      
 45 
     | 
    
         
            +
                        _show_status(memory_manager)
         
     | 
| 
      
 46 
     | 
    
         
            +
                        return
         
     | 
| 
      
 47 
     | 
    
         
            +
                    
         
     | 
| 
      
 48 
     | 
    
         
            +
                    if args.memory_command == "status":
         
     | 
| 
      
 49 
     | 
    
         
            +
                        _show_status(memory_manager)
         
     | 
| 
      
 50 
     | 
    
         
            +
                    
         
     | 
| 
      
 51 
     | 
    
         
            +
                    elif args.memory_command == "view":
         
     | 
| 
      
 52 
     | 
    
         
            +
                        _view_memory(args, memory_manager)
         
     | 
| 
      
 53 
     | 
    
         
            +
                    
         
     | 
| 
      
 54 
     | 
    
         
            +
                    elif args.memory_command == "add":
         
     | 
| 
      
 55 
     | 
    
         
            +
                        _add_learning(args, memory_manager)
         
     | 
| 
      
 56 
     | 
    
         
            +
                    
         
     | 
| 
      
 57 
     | 
    
         
            +
                    elif args.memory_command == "clean":
         
     | 
| 
      
 58 
     | 
    
         
            +
                        _clean_memory(args, memory_manager)
         
     | 
| 
      
 59 
     | 
    
         
            +
                    
         
     | 
| 
      
 60 
     | 
    
         
            +
                except Exception as e:
         
     | 
| 
      
 61 
     | 
    
         
            +
                    logger.error(f"Error managing memory: {e}")
         
     | 
| 
      
 62 
     | 
    
         
            +
                    print(f"❌ Error: {e}")
         
     | 
| 
      
 63 
     | 
    
         
            +
                    return 1
         
     | 
| 
      
 64 
     | 
    
         
            +
                
         
     | 
| 
      
 65 
     | 
    
         
            +
                return 0
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            def _show_status(memory_manager):
         
     | 
| 
      
 69 
     | 
    
         
            +
                """
         
     | 
| 
      
 70 
     | 
    
         
            +
                Show memory file status.
         
     | 
| 
      
 71 
     | 
    
         
            +
                
         
     | 
| 
      
 72 
     | 
    
         
            +
                WHY: Users need to see what memory files exist, their sizes, and
         
     | 
| 
      
 73 
     | 
    
         
            +
                when they were last updated to understand the memory system state.
         
     | 
| 
      
 74 
     | 
    
         
            +
                
         
     | 
| 
      
 75 
     | 
    
         
            +
                Args:
         
     | 
| 
      
 76 
     | 
    
         
            +
                    memory_manager: AgentMemoryManager instance
         
     | 
| 
      
 77 
     | 
    
         
            +
                """
         
     | 
| 
      
 78 
     | 
    
         
            +
                print("Agent Memory Status")
         
     | 
| 
      
 79 
     | 
    
         
            +
                print("-" * 80)
         
     | 
| 
      
 80 
     | 
    
         
            +
                
         
     | 
| 
      
 81 
     | 
    
         
            +
                memory_dir = memory_manager.memories_dir
         
     | 
| 
      
 82 
     | 
    
         
            +
                if not memory_dir.exists():
         
     | 
| 
      
 83 
     | 
    
         
            +
                    print("📁 Memory directory not found - no agent memories stored yet")
         
     | 
| 
      
 84 
     | 
    
         
            +
                    print(f"   Expected location: {memory_dir}")
         
     | 
| 
      
 85 
     | 
    
         
            +
                    return
         
     | 
| 
      
 86 
     | 
    
         
            +
                
         
     | 
| 
      
 87 
     | 
    
         
            +
                memory_files = list(memory_dir.glob("*_agent.md"))
         
     | 
| 
      
 88 
     | 
    
         
            +
                
         
     | 
| 
      
 89 
     | 
    
         
            +
                if not memory_files:
         
     | 
| 
      
 90 
     | 
    
         
            +
                    print("📭 No memory files found")
         
     | 
| 
      
 91 
     | 
    
         
            +
                    print(f"   Memory directory: {memory_dir}")
         
     | 
| 
      
 92 
     | 
    
         
            +
                    return
         
     | 
| 
      
 93 
     | 
    
         
            +
                
         
     | 
| 
      
 94 
     | 
    
         
            +
                print(f"📁 Memory directory: {memory_dir}")
         
     | 
| 
      
 95 
     | 
    
         
            +
                print(f"📊 Total memory files: {len(memory_files)}")
         
     | 
| 
      
 96 
     | 
    
         
            +
                print()
         
     | 
| 
      
 97 
     | 
    
         
            +
                
         
     | 
| 
      
 98 
     | 
    
         
            +
                total_size = 0
         
     | 
| 
      
 99 
     | 
    
         
            +
                for file_path in sorted(memory_files):
         
     | 
| 
      
 100 
     | 
    
         
            +
                    stat = file_path.stat()
         
     | 
| 
      
 101 
     | 
    
         
            +
                    size_kb = stat.st_size / 1024
         
     | 
| 
      
 102 
     | 
    
         
            +
                    total_size += stat.st_size
         
     | 
| 
      
 103 
     | 
    
         
            +
                    
         
     | 
| 
      
 104 
     | 
    
         
            +
                    # Extract agent ID from filename (remove '_agent' suffix)
         
     | 
| 
      
 105 
     | 
    
         
            +
                    agent_id = file_path.stem.replace('_agent', '')
         
     | 
| 
      
 106 
     | 
    
         
            +
                    
         
     | 
| 
      
 107 
     | 
    
         
            +
                    # Try to count sections in markdown file
         
     | 
| 
      
 108 
     | 
    
         
            +
                    try:
         
     | 
| 
      
 109 
     | 
    
         
            +
                        content = file_path.read_text()
         
     | 
| 
      
 110 
     | 
    
         
            +
                        # Count level 2 headers (sections)
         
     | 
| 
      
 111 
     | 
    
         
            +
                        section_count = len([line for line in content.splitlines() if line.startswith('## ')])
         
     | 
| 
      
 112 
     | 
    
         
            +
                        # Count bullet points (learnings)
         
     | 
| 
      
 113 
     | 
    
         
            +
                        learning_count = len([line for line in content.splitlines() if line.strip().startswith('- ')])
         
     | 
| 
      
 114 
     | 
    
         
            +
                    except:
         
     | 
| 
      
 115 
     | 
    
         
            +
                        section_count = "?"
         
     | 
| 
      
 116 
     | 
    
         
            +
                        learning_count = "?"
         
     | 
| 
      
 117 
     | 
    
         
            +
                    
         
     | 
| 
      
 118 
     | 
    
         
            +
                    print(f"🧠 {agent_id}")
         
     | 
| 
      
 119 
     | 
    
         
            +
                    print(f"   Size: {size_kb:.1f} KB")
         
     | 
| 
      
 120 
     | 
    
         
            +
                    print(f"   Sections: {section_count}")
         
     | 
| 
      
 121 
     | 
    
         
            +
                    print(f"   Items: {learning_count}")
         
     | 
| 
      
 122 
     | 
    
         
            +
                    print(f"   Last modified: {datetime.fromtimestamp(stat.st_mtime).strftime('%Y-%m-%d %H:%M:%S')}")
         
     | 
| 
      
 123 
     | 
    
         
            +
                    print()
         
     | 
| 
      
 124 
     | 
    
         
            +
                
         
     | 
| 
      
 125 
     | 
    
         
            +
                print(f"💾 Total size: {total_size / 1024:.1f} KB")
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            def _view_memory(args, memory_manager):
         
     | 
| 
      
 129 
     | 
    
         
            +
                """
         
     | 
| 
      
 130 
     | 
    
         
            +
                View agent memory file contents.
         
     | 
| 
      
 131 
     | 
    
         
            +
                
         
     | 
| 
      
 132 
     | 
    
         
            +
                WHY: Users need to inspect what learnings an agent has accumulated
         
     | 
| 
      
 133 
     | 
    
         
            +
                to understand its behavior and debug issues.
         
     | 
| 
      
 134 
     | 
    
         
            +
                
         
     | 
| 
      
 135 
     | 
    
         
            +
                Args:
         
     | 
| 
      
 136 
     | 
    
         
            +
                    args: Command arguments with agent_id
         
     | 
| 
      
 137 
     | 
    
         
            +
                    memory_manager: AgentMemoryManager instance
         
     | 
| 
      
 138 
     | 
    
         
            +
                """
         
     | 
| 
      
 139 
     | 
    
         
            +
                agent_id = args.agent_id
         
     | 
| 
      
 140 
     | 
    
         
            +
                
         
     | 
| 
      
 141 
     | 
    
         
            +
                try:
         
     | 
| 
      
 142 
     | 
    
         
            +
                    memory_content = memory_manager.load_agent_memory(agent_id)
         
     | 
| 
      
 143 
     | 
    
         
            +
                    
         
     | 
| 
      
 144 
     | 
    
         
            +
                    if not memory_content:
         
     | 
| 
      
 145 
     | 
    
         
            +
                        print(f"📭 No memory found for agent: {agent_id}")
         
     | 
| 
      
 146 
     | 
    
         
            +
                        return
         
     | 
| 
      
 147 
     | 
    
         
            +
                    
         
     | 
| 
      
 148 
     | 
    
         
            +
                    print(f"🧠 Memory for agent: {agent_id}")
         
     | 
| 
      
 149 
     | 
    
         
            +
                    print("-" * 80)
         
     | 
| 
      
 150 
     | 
    
         
            +
                    print(memory_content)
         
     | 
| 
      
 151 
     | 
    
         
            +
                            
         
     | 
| 
      
 152 
     | 
    
         
            +
                except FileNotFoundError:
         
     | 
| 
      
 153 
     | 
    
         
            +
                    print(f"📭 No memory file found for agent: {agent_id}")
         
     | 
| 
      
 154 
     | 
    
         
            +
                except Exception as e:
         
     | 
| 
      
 155 
     | 
    
         
            +
                    print(f"❌ Error viewing memory: {e}")
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
            def _add_learning(args, memory_manager):
         
     | 
| 
      
 159 
     | 
    
         
            +
                """
         
     | 
| 
      
 160 
     | 
    
         
            +
                Manually add learning to agent memory.
         
     | 
| 
      
 161 
     | 
    
         
            +
                
         
     | 
| 
      
 162 
     | 
    
         
            +
                WHY: Allows manual injection of learnings for testing or correction
         
     | 
| 
      
 163 
     | 
    
         
            +
                purposes, useful for debugging and development.
         
     | 
| 
      
 164 
     | 
    
         
            +
                
         
     | 
| 
      
 165 
     | 
    
         
            +
                Args:
         
     | 
| 
      
 166 
     | 
    
         
            +
                    args: Command arguments with agent_id, learning_type, and content
         
     | 
| 
      
 167 
     | 
    
         
            +
                    memory_manager: AgentMemoryManager instance
         
     | 
| 
      
 168 
     | 
    
         
            +
                """
         
     | 
| 
      
 169 
     | 
    
         
            +
                agent_id = args.agent_id
         
     | 
| 
      
 170 
     | 
    
         
            +
                section = args.learning_type  # Map learning_type to section name
         
     | 
| 
      
 171 
     | 
    
         
            +
                content = args.content
         
     | 
| 
      
 172 
     | 
    
         
            +
                
         
     | 
| 
      
 173 
     | 
    
         
            +
                # Map learning types to appropriate sections
         
     | 
| 
      
 174 
     | 
    
         
            +
                section_map = {
         
     | 
| 
      
 175 
     | 
    
         
            +
                    "pattern": "Project Architecture",
         
     | 
| 
      
 176 
     | 
    
         
            +
                    "error": "Common Mistakes to Avoid",
         
     | 
| 
      
 177 
     | 
    
         
            +
                    "optimization": "Implementation Guidelines",
         
     | 
| 
      
 178 
     | 
    
         
            +
                    "preference": "Implementation Guidelines",
         
     | 
| 
      
 179 
     | 
    
         
            +
                    "context": "Current Technical Context"
         
     | 
| 
      
 180 
     | 
    
         
            +
                }
         
     | 
| 
      
 181 
     | 
    
         
            +
                
         
     | 
| 
      
 182 
     | 
    
         
            +
                section_name = section_map.get(section, "Current Technical Context")
         
     | 
| 
      
 183 
     | 
    
         
            +
                
         
     | 
| 
      
 184 
     | 
    
         
            +
                try:
         
     | 
| 
      
 185 
     | 
    
         
            +
                    success = memory_manager.update_agent_memory(agent_id, section_name, content)
         
     | 
| 
      
 186 
     | 
    
         
            +
                    
         
     | 
| 
      
 187 
     | 
    
         
            +
                    if success:
         
     | 
| 
      
 188 
     | 
    
         
            +
                        print(f"✅ Added {section} to {agent_id} memory in section: {section_name}")
         
     | 
| 
      
 189 
     | 
    
         
            +
                        print(f"   Content: {content[:100]}{'...' if len(content) > 100 else ''}")
         
     | 
| 
      
 190 
     | 
    
         
            +
                    else:
         
     | 
| 
      
 191 
     | 
    
         
            +
                        print(f"❌ Failed to add learning to {agent_id} memory")
         
     | 
| 
      
 192 
     | 
    
         
            +
                        print("   Memory file may be at size limit or section may be full")
         
     | 
| 
      
 193 
     | 
    
         
            +
                        
         
     | 
| 
      
 194 
     | 
    
         
            +
                except Exception as e:
         
     | 
| 
      
 195 
     | 
    
         
            +
                    print(f"❌ Error adding learning: {e}")
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
            def _clean_memory(args, memory_manager):
         
     | 
| 
      
 199 
     | 
    
         
            +
                """
         
     | 
| 
      
 200 
     | 
    
         
            +
                Clean up old/unused memory files.
         
     | 
| 
      
 201 
     | 
    
         
            +
                
         
     | 
| 
      
 202 
     | 
    
         
            +
                WHY: Memory files can accumulate over time. This provides a way to
         
     | 
| 
      
 203 
     | 
    
         
            +
                clean up old or unused files to save disk space.
         
     | 
| 
      
 204 
     | 
    
         
            +
                
         
     | 
| 
      
 205 
     | 
    
         
            +
                DESIGN DECISION: For Phase 1, this is a stub implementation.
         
     | 
| 
      
 206 
     | 
    
         
            +
                Full cleanup logic will be implemented based on usage patterns.
         
     | 
| 
      
 207 
     | 
    
         
            +
                
         
     | 
| 
      
 208 
     | 
    
         
            +
                Args:
         
     | 
| 
      
 209 
     | 
    
         
            +
                    args: Command arguments
         
     | 
| 
      
 210 
     | 
    
         
            +
                    memory_manager: AgentMemoryManager instance
         
     | 
| 
      
 211 
     | 
    
         
            +
                """
         
     | 
| 
      
 212 
     | 
    
         
            +
                print("🧹 Memory cleanup")
         
     | 
| 
      
 213 
     | 
    
         
            +
                print("-" * 80)
         
     | 
| 
      
 214 
     | 
    
         
            +
                
         
     | 
| 
      
 215 
     | 
    
         
            +
                # For Phase 1, just show what would be cleaned
         
     | 
| 
      
 216 
     | 
    
         
            +
                memory_dir = memory_manager.memories_dir
         
     | 
| 
      
 217 
     | 
    
         
            +
                if not memory_dir.exists():
         
     | 
| 
      
 218 
     | 
    
         
            +
                    print("📁 No memory directory found - nothing to clean")
         
     | 
| 
      
 219 
     | 
    
         
            +
                    return
         
     | 
| 
      
 220 
     | 
    
         
            +
                
         
     | 
| 
      
 221 
     | 
    
         
            +
                memory_files = list(memory_dir.glob("*_agent.md"))
         
     | 
| 
      
 222 
     | 
    
         
            +
                if not memory_files:
         
     | 
| 
      
 223 
     | 
    
         
            +
                    print("📭 No memory files found - nothing to clean")
         
     | 
| 
      
 224 
     | 
    
         
            +
                    return
         
     | 
| 
      
 225 
     | 
    
         
            +
                
         
     | 
| 
      
 226 
     | 
    
         
            +
                print(f"📊 Found {len(memory_files)} memory files")
         
     | 
| 
      
 227 
     | 
    
         
            +
                print()
         
     | 
| 
      
 228 
     | 
    
         
            +
                print("⚠️  Cleanup not yet implemented in Phase 1")
         
     | 
| 
      
 229 
     | 
    
         
            +
                print("   Future cleanup will remove:")
         
     | 
| 
      
 230 
     | 
    
         
            +
                print("   - Memory files older than 30 days with no recent access")
         
     | 
| 
      
 231 
     | 
    
         
            +
                print("   - Corrupted memory files")
         
     | 
| 
      
 232 
     | 
    
         
            +
                print("   - Memory files for non-existent agents")
         
     |