claude-mpm 3.1.2__py3-none-any.whl → 3.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. claude_mpm/__init__.py +3 -3
  2. claude_mpm/agents/INSTRUCTIONS.md +80 -2
  3. claude_mpm/agents/backups/INSTRUCTIONS.md +238 -0
  4. claude_mpm/agents/base_agent.json +1 -1
  5. claude_mpm/agents/templates/pm.json +25 -0
  6. claude_mpm/agents/templates/research.json +2 -1
  7. claude_mpm/cli/__init__.py +6 -1
  8. claude_mpm/cli/commands/__init__.py +3 -1
  9. claude_mpm/cli/commands/memory.py +232 -0
  10. claude_mpm/cli/commands/run.py +496 -8
  11. claude_mpm/cli/parser.py +91 -1
  12. claude_mpm/config/socketio_config.py +256 -0
  13. claude_mpm/constants.py +9 -0
  14. claude_mpm/core/__init__.py +2 -2
  15. claude_mpm/core/claude_runner.py +919 -0
  16. claude_mpm/core/config.py +21 -1
  17. claude_mpm/core/hook_manager.py +196 -0
  18. claude_mpm/core/pm_hook_interceptor.py +205 -0
  19. claude_mpm/core/simple_runner.py +296 -16
  20. claude_mpm/core/socketio_pool.py +582 -0
  21. claude_mpm/core/websocket_handler.py +233 -0
  22. claude_mpm/deployment_paths.py +261 -0
  23. claude_mpm/hooks/builtin/memory_hooks_example.py +67 -0
  24. claude_mpm/hooks/claude_hooks/hook_handler.py +669 -632
  25. claude_mpm/hooks/claude_hooks/hook_wrapper.sh +9 -4
  26. claude_mpm/hooks/memory_integration_hook.py +312 -0
  27. claude_mpm/orchestration/__init__.py +1 -1
  28. claude_mpm/scripts/claude-mpm-socketio +32 -0
  29. claude_mpm/scripts/claude_mpm_monitor.html +567 -0
  30. claude_mpm/scripts/install_socketio_server.py +407 -0
  31. claude_mpm/scripts/launch_monitor.py +132 -0
  32. claude_mpm/scripts/manage_version.py +479 -0
  33. claude_mpm/scripts/socketio_daemon.py +181 -0
  34. claude_mpm/scripts/socketio_server_manager.py +428 -0
  35. claude_mpm/services/__init__.py +5 -0
  36. claude_mpm/services/agent_memory_manager.py +684 -0
  37. claude_mpm/services/hook_service.py +362 -0
  38. claude_mpm/services/socketio_client_manager.py +474 -0
  39. claude_mpm/services/socketio_server.py +698 -0
  40. claude_mpm/services/standalone_socketio_server.py +631 -0
  41. claude_mpm/services/websocket_server.py +376 -0
  42. claude_mpm/utils/dependency_manager.py +211 -0
  43. claude_mpm/web/open_dashboard.py +34 -0
  44. {claude_mpm-3.1.2.dist-info → claude_mpm-3.2.1.dist-info}/METADATA +20 -1
  45. {claude_mpm-3.1.2.dist-info → claude_mpm-3.2.1.dist-info}/RECORD +50 -24
  46. claude_mpm-3.2.1.dist-info/entry_points.txt +7 -0
  47. claude_mpm/cli_old.py +0 -728
  48. claude_mpm-3.1.2.dist-info/entry_points.txt +0 -4
  49. /claude_mpm/{cli_enhancements.py → experimental/cli_enhancements.py} +0 -0
  50. {claude_mpm-3.1.2.dist-info → claude_mpm-3.2.1.dist-info}/WHEEL +0 -0
  51. {claude_mpm-3.1.2.dist-info → claude_mpm-3.2.1.dist-info}/licenses/LICENSE +0 -0
  52. {claude_mpm-3.1.2.dist-info → claude_mpm-3.2.1.dist-info}/top_level.txt +0 -0
@@ -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")