claude-mpm 3.7.8__py3-none-any.whl → 3.9.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.
Files changed (100) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/agents/BASE_PM.md +0 -106
  3. claude_mpm/agents/INSTRUCTIONS.md +0 -96
  4. claude_mpm/agents/MEMORY.md +94 -0
  5. claude_mpm/agents/WORKFLOW.md +86 -0
  6. claude_mpm/agents/templates/code_analyzer.json +2 -2
  7. claude_mpm/agents/templates/data_engineer.json +1 -1
  8. claude_mpm/agents/templates/documentation.json +1 -1
  9. claude_mpm/agents/templates/engineer.json +1 -1
  10. claude_mpm/agents/templates/ops.json +1 -1
  11. claude_mpm/agents/templates/qa.json +1 -1
  12. claude_mpm/agents/templates/research.json +1 -1
  13. claude_mpm/agents/templates/security.json +1 -1
  14. claude_mpm/agents/templates/ticketing.json +3 -8
  15. claude_mpm/agents/templates/version_control.json +1 -1
  16. claude_mpm/agents/templates/web_qa.json +2 -2
  17. claude_mpm/agents/templates/web_ui.json +2 -2
  18. claude_mpm/cli/__init__.py +2 -2
  19. claude_mpm/cli/commands/__init__.py +2 -1
  20. claude_mpm/cli/commands/agents.py +8 -3
  21. claude_mpm/cli/commands/tickets.py +596 -19
  22. claude_mpm/cli/parser.py +217 -5
  23. claude_mpm/config/__init__.py +30 -39
  24. claude_mpm/config/socketio_config.py +8 -5
  25. claude_mpm/constants.py +13 -0
  26. claude_mpm/core/__init__.py +8 -18
  27. claude_mpm/core/cache.py +596 -0
  28. claude_mpm/core/claude_runner.py +166 -622
  29. claude_mpm/core/config.py +7 -3
  30. claude_mpm/core/constants.py +339 -0
  31. claude_mpm/core/container.py +548 -38
  32. claude_mpm/core/exceptions.py +392 -0
  33. claude_mpm/core/framework_loader.py +249 -93
  34. claude_mpm/core/interactive_session.py +479 -0
  35. claude_mpm/core/interfaces.py +424 -0
  36. claude_mpm/core/lazy.py +467 -0
  37. claude_mpm/core/logging_config.py +444 -0
  38. claude_mpm/core/oneshot_session.py +465 -0
  39. claude_mpm/core/optimized_agent_loader.py +485 -0
  40. claude_mpm/core/optimized_startup.py +490 -0
  41. claude_mpm/core/service_registry.py +52 -26
  42. claude_mpm/core/socketio_pool.py +162 -5
  43. claude_mpm/core/types.py +292 -0
  44. claude_mpm/core/typing_utils.py +477 -0
  45. claude_mpm/hooks/claude_hooks/hook_handler.py +213 -99
  46. claude_mpm/init.py +2 -1
  47. claude_mpm/services/__init__.py +78 -14
  48. claude_mpm/services/agent/__init__.py +24 -0
  49. claude_mpm/services/agent/deployment.py +2548 -0
  50. claude_mpm/services/agent/management.py +598 -0
  51. claude_mpm/services/agent/registry.py +813 -0
  52. claude_mpm/services/agents/deployment/agent_deployment.py +728 -308
  53. claude_mpm/services/agents/memory/agent_memory_manager.py +160 -4
  54. claude_mpm/services/async_session_logger.py +8 -3
  55. claude_mpm/services/communication/__init__.py +21 -0
  56. claude_mpm/services/communication/socketio.py +1933 -0
  57. claude_mpm/services/communication/websocket.py +479 -0
  58. claude_mpm/services/core/__init__.py +123 -0
  59. claude_mpm/services/core/base.py +247 -0
  60. claude_mpm/services/core/interfaces.py +951 -0
  61. claude_mpm/services/framework_claude_md_generator/__init__.py +10 -3
  62. claude_mpm/services/framework_claude_md_generator/deployment_manager.py +14 -11
  63. claude_mpm/services/framework_claude_md_generator/section_generators/todo_task_tools.py +23 -23
  64. claude_mpm/services/framework_claude_md_generator.py +3 -2
  65. claude_mpm/services/health_monitor.py +4 -3
  66. claude_mpm/services/hook_service.py +64 -4
  67. claude_mpm/services/infrastructure/__init__.py +21 -0
  68. claude_mpm/services/infrastructure/logging.py +202 -0
  69. claude_mpm/services/infrastructure/monitoring.py +893 -0
  70. claude_mpm/services/memory/indexed_memory.py +648 -0
  71. claude_mpm/services/project/__init__.py +21 -0
  72. claude_mpm/services/project/analyzer.py +864 -0
  73. claude_mpm/services/project/registry.py +608 -0
  74. claude_mpm/services/project_analyzer.py +95 -2
  75. claude_mpm/services/recovery_manager.py +15 -9
  76. claude_mpm/services/response_tracker.py +3 -5
  77. claude_mpm/services/socketio/__init__.py +25 -0
  78. claude_mpm/services/socketio/handlers/__init__.py +25 -0
  79. claude_mpm/services/socketio/handlers/base.py +121 -0
  80. claude_mpm/services/socketio/handlers/connection.py +198 -0
  81. claude_mpm/services/socketio/handlers/file.py +213 -0
  82. claude_mpm/services/socketio/handlers/git.py +723 -0
  83. claude_mpm/services/socketio/handlers/memory.py +27 -0
  84. claude_mpm/services/socketio/handlers/project.py +25 -0
  85. claude_mpm/services/socketio/handlers/registry.py +145 -0
  86. claude_mpm/services/socketio_client_manager.py +12 -7
  87. claude_mpm/services/socketio_server.py +156 -30
  88. claude_mpm/services/ticket_manager.py +172 -9
  89. claude_mpm/services/ticket_manager_di.py +1 -1
  90. claude_mpm/services/version_control/semantic_versioning.py +80 -7
  91. claude_mpm/services/version_control/version_parser.py +528 -0
  92. claude_mpm/utils/error_handler.py +1 -1
  93. claude_mpm/validation/agent_validator.py +27 -14
  94. claude_mpm/validation/frontmatter_validator.py +231 -0
  95. {claude_mpm-3.7.8.dist-info → claude_mpm-3.9.0.dist-info}/METADATA +38 -128
  96. {claude_mpm-3.7.8.dist-info → claude_mpm-3.9.0.dist-info}/RECORD +100 -59
  97. {claude_mpm-3.7.8.dist-info → claude_mpm-3.9.0.dist-info}/WHEEL +0 -0
  98. {claude_mpm-3.7.8.dist-info → claude_mpm-3.9.0.dist-info}/entry_points.txt +0 -0
  99. {claude_mpm-3.7.8.dist-info → claude_mpm-3.9.0.dist-info}/licenses/LICENSE +0 -0
  100. {claude_mpm-3.7.8.dist-info → claude_mpm-3.9.0.dist-info}/top_level.txt +0 -0
@@ -29,10 +29,11 @@ from claude_mpm.core.config import Config
29
29
  from claude_mpm.core.mixins import LoggerMixin
30
30
  from claude_mpm.utils.paths import PathResolver
31
31
  from claude_mpm.services.project_analyzer import ProjectAnalyzer
32
+ from claude_mpm.core.interfaces import MemoryServiceInterface
32
33
  # Socket.IO notifications are optional - we'll skip them if server is not available
33
34
 
34
35
 
35
- class AgentMemoryManager:
36
+ class AgentMemoryManager(MemoryServiceInterface):
36
37
  """Manages agent memory files with size limits and validation.
37
38
 
38
39
  WHY: Agents need to accumulate project-specific knowledge over time to become
@@ -43,13 +44,14 @@ class AgentMemoryManager:
43
44
  to keep them organized and separate from other project files. Files follow a
44
45
  standardized markdown format with enforced size limits to prevent unbounded growth.
45
46
 
46
- The 8KB limit (~2000 tokens) balances comprehensive knowledge storage with
47
+ The 80KB limit (~20k tokens) balances comprehensive knowledge storage with
47
48
  reasonable context size for agent prompts.
48
49
  """
49
50
 
50
51
  # Default limits - will be overridden by configuration
52
+ # Updated to support 20k tokens (~80KB) for enhanced memory capacity
51
53
  DEFAULT_MEMORY_LIMITS = {
52
- 'max_file_size_kb': 8,
54
+ 'max_file_size_kb': 80, # Increased from 8KB to 80KB (20k tokens)
53
55
  'max_sections': 10,
54
56
  'max_items_per_section': 15,
55
57
  'max_line_length': 120
@@ -1364,7 +1366,7 @@ Feel free to edit these files to:
1364
1366
  - Add domain-specific knowledge
1365
1367
 
1366
1368
  ## Memory Limits
1367
- - Max file size: 8KB (~2000 tokens)
1369
+ - Max file size: 80KB (~20k tokens)
1368
1370
  - Max sections: 10
1369
1371
  - Max items per section: 15
1370
1372
  - Files auto-truncate when limits exceeded
@@ -1394,6 +1396,160 @@ Standard markdown with structured sections. Agents expect:
1394
1396
  except Exception as e:
1395
1397
  self.logger.error(f"Error ensuring memories directory: {e}")
1396
1398
  # Continue anyway - memory system should not block operations
1399
+
1400
+ # ================================================================================
1401
+ # Interface Adapter Methods
1402
+ # ================================================================================
1403
+ # These methods adapt the existing implementation to comply with MemoryServiceInterface
1404
+
1405
+ def load_memory(self, agent_id: str) -> Optional[str]:
1406
+ """Load memory for a specific agent.
1407
+
1408
+ WHY: This adapter method provides interface compliance by wrapping
1409
+ the existing load_agent_memory method.
1410
+
1411
+ Args:
1412
+ agent_id: Identifier of the agent
1413
+
1414
+ Returns:
1415
+ Memory content as string or None if not found
1416
+ """
1417
+ try:
1418
+ content = self.load_agent_memory(agent_id)
1419
+ return content if content else None
1420
+ except Exception as e:
1421
+ self.logger.error(f"Failed to load memory for {agent_id}: {e}")
1422
+ return None
1423
+
1424
+ def save_memory(self, agent_id: str, content: str) -> bool:
1425
+ """Save memory for a specific agent.
1426
+
1427
+ WHY: This adapter method provides interface compliance. The existing
1428
+ implementation uses update_agent_memory for modifications, so we
1429
+ implement a full save by writing directly to the file.
1430
+
1431
+ Args:
1432
+ agent_id: Identifier of the agent
1433
+ content: Memory content to save
1434
+
1435
+ Returns:
1436
+ True if save successful
1437
+ """
1438
+ try:
1439
+ memory_path = self.memories_dir / f"{agent_id}_agent.md"
1440
+
1441
+ # Validate size before saving
1442
+ is_valid, error_msg = self.validate_memory_size(content)
1443
+ if not is_valid:
1444
+ self.logger.error(f"Memory validation failed: {error_msg}")
1445
+ return False
1446
+
1447
+ # Write the content
1448
+ memory_path.write_text(content, encoding='utf-8')
1449
+ self.logger.info(f"Saved memory for agent {agent_id}")
1450
+ return True
1451
+
1452
+ except Exception as e:
1453
+ self.logger.error(f"Failed to save memory for {agent_id}: {e}")
1454
+ return False
1455
+
1456
+ def validate_memory_size(self, content: str) -> tuple[bool, Optional[str]]:
1457
+ """Validate memory content size and structure.
1458
+
1459
+ WHY: This adapter method provides interface compliance by implementing
1460
+ validation based on configured limits.
1461
+
1462
+ Args:
1463
+ content: Memory content to validate
1464
+
1465
+ Returns:
1466
+ Tuple of (is_valid, error_message)
1467
+ """
1468
+ try:
1469
+ # Check file size
1470
+ size_kb = len(content.encode('utf-8')) / 1024
1471
+ max_size_kb = self.memory_limits.get('max_file_size_kb', 8)
1472
+
1473
+ if size_kb > max_size_kb:
1474
+ return False, f"Memory size {size_kb:.1f}KB exceeds limit of {max_size_kb}KB"
1475
+
1476
+ # Check section count
1477
+ sections = re.findall(r'^##\s+(.+)$', content, re.MULTILINE)
1478
+ max_sections = self.memory_limits.get('max_sections', 10)
1479
+
1480
+ if len(sections) > max_sections:
1481
+ return False, f"Too many sections: {len(sections)} (max {max_sections})"
1482
+
1483
+ # Check for required sections
1484
+ required = set(self.REQUIRED_SECTIONS)
1485
+ found = set(sections)
1486
+ missing = required - found
1487
+
1488
+ if missing:
1489
+ return False, f"Missing required sections: {', '.join(missing)}"
1490
+
1491
+ return True, None
1492
+
1493
+ except Exception as e:
1494
+ return False, f"Validation error: {str(e)}"
1495
+
1496
+ def get_memory_metrics(self, agent_id: Optional[str] = None) -> Dict[str, Any]:
1497
+ """Get memory usage metrics.
1498
+
1499
+ WHY: This adapter method provides interface compliance by gathering
1500
+ metrics about memory usage.
1501
+
1502
+ Args:
1503
+ agent_id: Optional specific agent ID, or None for all
1504
+
1505
+ Returns:
1506
+ Dictionary with memory metrics
1507
+ """
1508
+ metrics = {
1509
+ "total_memories": 0,
1510
+ "total_size_kb": 0,
1511
+ "agent_metrics": {},
1512
+ "limits": self.memory_limits.copy()
1513
+ }
1514
+
1515
+ try:
1516
+ if agent_id:
1517
+ # Get metrics for specific agent
1518
+ memory_path = self.memories_dir / f"{agent_id}_agent.md"
1519
+ if memory_path.exists():
1520
+ content = memory_path.read_text(encoding='utf-8')
1521
+ size_kb = len(content.encode('utf-8')) / 1024
1522
+ sections = re.findall(r'^##\s+(.+)$', content, re.MULTILINE)
1523
+
1524
+ metrics["agent_metrics"][agent_id] = {
1525
+ "size_kb": round(size_kb, 2),
1526
+ "sections": len(sections),
1527
+ "exists": True
1528
+ }
1529
+ metrics["total_memories"] = 1
1530
+ metrics["total_size_kb"] = round(size_kb, 2)
1531
+ else:
1532
+ # Get metrics for all agents
1533
+ for memory_file in self.memories_dir.glob("*_agent.md"):
1534
+ agent_name = memory_file.stem.replace("_agent", "")
1535
+ content = memory_file.read_text(encoding='utf-8')
1536
+ size_kb = len(content.encode('utf-8')) / 1024
1537
+ sections = re.findall(r'^##\s+(.+)$', content, re.MULTILINE)
1538
+
1539
+ metrics["agent_metrics"][agent_name] = {
1540
+ "size_kb": round(size_kb, 2),
1541
+ "sections": len(sections),
1542
+ "exists": True
1543
+ }
1544
+ metrics["total_memories"] += 1
1545
+ metrics["total_size_kb"] += size_kb
1546
+
1547
+ metrics["total_size_kb"] = round(metrics["total_size_kb"], 2)
1548
+
1549
+ except Exception as e:
1550
+ self.logger.error(f"Failed to get memory metrics: {e}")
1551
+
1552
+ return metrics
1397
1553
 
1398
1554
 
1399
1555
  # Convenience functions for external use
@@ -27,6 +27,11 @@ import logging
27
27
  import logging.handlers
28
28
  from dataclasses import dataclass, asdict
29
29
  from enum import Enum
30
+ from claude_mpm.core.constants import (
31
+ SystemLimits,
32
+ TimeoutConfig,
33
+ PerformanceConfig
34
+ )
30
35
 
31
36
  # Import configuration manager
32
37
  from ..core.config import Config
@@ -108,7 +113,7 @@ class AsyncSessionLogger:
108
113
  else:
109
114
  self.log_format = LogFormat.JSON
110
115
 
111
- self.max_queue_size = max_queue_size if max_queue_size is not None else response_config.get('max_queue_size', 10000)
116
+ self.max_queue_size = max_queue_size if max_queue_size is not None else response_config.get('max_queue_size', SystemLimits.MAX_QUEUE_SIZE)
112
117
 
113
118
  # Handle async configuration with backward compatibility
114
119
  if enable_async is not None:
@@ -223,12 +228,12 @@ class AsyncSessionLogger:
223
228
  while not self._shutdown:
224
229
  try:
225
230
  # Get entry with timeout to allow shutdown checks
226
- entry = self._queue.get(timeout=0.1)
231
+ entry = self._queue.get(timeout=TimeoutConfig.QUEUE_GET_TIMEOUT)
227
232
 
228
233
  # Time the write operation
229
234
  start_time = time.perf_counter()
230
235
  self._write_entry(entry)
231
- write_time = (time.perf_counter() - start_time) * 1000
236
+ write_time = (time.perf_counter() - start_time) * PerformanceConfig.SECONDS_TO_MS
232
237
 
233
238
  # Update statistics
234
239
  write_times.append(write_time)
@@ -0,0 +1,21 @@
1
+ """
2
+ Communication Services Module
3
+ ============================
4
+
5
+ This module contains all communication-related services including
6
+ SocketIO server and WebSocket utilities.
7
+
8
+ Part of TSK-0046: Service Layer Architecture Reorganization
9
+
10
+ Services:
11
+ - SocketIOServer: Main SocketIO server for real-time communication
12
+ - WebSocketClientManager: WebSocket client management utilities
13
+ """
14
+
15
+ from .socketio import SocketIOServer
16
+ from .websocket import SocketIOClientManager
17
+
18
+ __all__ = [
19
+ 'SocketIOServer',
20
+ 'SocketIOClientManager',
21
+ ]