claude-mpm 3.5.2__py3-none-any.whl → 3.5.6__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 (53) hide show
  1. claude_mpm/.claude-mpm/logs/hooks_20250728.log +10 -0
  2. claude_mpm/VERSION +1 -1
  3. claude_mpm/agents/INSTRUCTIONS.md +14 -13
  4. claude_mpm/agents/agent-template.yaml +83 -0
  5. claude_mpm/agents/agent_loader.py +109 -15
  6. claude_mpm/agents/base_agent.json +1 -1
  7. claude_mpm/agents/frontmatter_validator.py +448 -0
  8. claude_mpm/agents/templates/data_engineer.json +4 -3
  9. claude_mpm/agents/templates/documentation.json +4 -3
  10. claude_mpm/agents/templates/engineer.json +4 -3
  11. claude_mpm/agents/templates/ops.json +4 -3
  12. claude_mpm/agents/templates/pm.json +5 -4
  13. claude_mpm/agents/templates/qa.json +4 -3
  14. claude_mpm/agents/templates/research.json +8 -7
  15. claude_mpm/agents/templates/security.json +4 -3
  16. claude_mpm/agents/templates/test_integration.json +4 -3
  17. claude_mpm/agents/templates/version_control.json +4 -3
  18. claude_mpm/cli/README.md +108 -0
  19. claude_mpm/cli/commands/agents.py +373 -7
  20. claude_mpm/cli/commands/run.py +4 -11
  21. claude_mpm/cli/parser.py +36 -0
  22. claude_mpm/cli/utils.py +9 -1
  23. claude_mpm/cli_module/refactoring_guide.md +253 -0
  24. claude_mpm/config/async_logging_config.yaml +145 -0
  25. claude_mpm/constants.py +2 -0
  26. claude_mpm/core/.claude-mpm/logs/hooks_20250730.log +34 -0
  27. claude_mpm/core/agent_registry.py +4 -1
  28. claude_mpm/core/claude_runner.py +297 -20
  29. claude_mpm/core/config_paths.py +0 -1
  30. claude_mpm/core/factories.py +9 -3
  31. claude_mpm/dashboard/.claude-mpm/memories/README.md +36 -0
  32. claude_mpm/dashboard/README.md +121 -0
  33. claude_mpm/dashboard/static/js/dashboard.js.backup +1973 -0
  34. claude_mpm/dashboard/templates/.claude-mpm/memories/README.md +36 -0
  35. claude_mpm/dashboard/templates/.claude-mpm/memories/engineer_agent.md +39 -0
  36. claude_mpm/dashboard/templates/.claude-mpm/memories/version_control_agent.md +38 -0
  37. claude_mpm/hooks/README.md +96 -0
  38. claude_mpm/init.py +83 -13
  39. claude_mpm/schemas/agent_schema.json +435 -0
  40. claude_mpm/services/agents/deployment/agent_deployment.py +204 -18
  41. claude_mpm/services/agents/management/agent_management_service.py +2 -1
  42. claude_mpm/services/agents/registry/agent_registry.py +22 -1
  43. claude_mpm/services/framework_claude_md_generator/README.md +92 -0
  44. claude_mpm/services/framework_claude_md_generator/section_generators/agents.py +3 -3
  45. claude_mpm/services/framework_claude_md_generator/section_generators/claude_pm_init.py +2 -2
  46. claude_mpm/services/version_control/VERSION +1 -0
  47. claude_mpm/validation/agent_validator.py +56 -1
  48. {claude_mpm-3.5.2.dist-info → claude_mpm-3.5.6.dist-info}/METADATA +60 -3
  49. {claude_mpm-3.5.2.dist-info → claude_mpm-3.5.6.dist-info}/RECORD +53 -36
  50. {claude_mpm-3.5.2.dist-info → claude_mpm-3.5.6.dist-info}/WHEEL +0 -0
  51. {claude_mpm-3.5.2.dist-info → claude_mpm-3.5.6.dist-info}/entry_points.txt +0 -0
  52. {claude_mpm-3.5.2.dist-info → claude_mpm-3.5.6.dist-info}/licenses/LICENSE +0 -0
  53. {claude_mpm-3.5.2.dist-info → claude_mpm-3.5.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,36 @@
1
+ # Agent Memory System
2
+
3
+ ## Purpose
4
+ Each agent maintains project-specific knowledge in these files. Agents read their memory file before tasks and update it when they learn something new.
5
+
6
+ ## Manual Editing
7
+ Feel free to edit these files to:
8
+ - Add project-specific guidelines
9
+ - Remove outdated information
10
+ - Reorganize for better clarity
11
+ - Add domain-specific knowledge
12
+
13
+ ## Memory Limits
14
+ - Max file size: 8KB (~2000 tokens)
15
+ - Max sections: 10
16
+ - Max items per section: 15
17
+ - Files auto-truncate when limits exceeded
18
+
19
+ ## File Format
20
+ Standard markdown with structured sections. Agents expect:
21
+ - Project Architecture
22
+ - Implementation Guidelines
23
+ - Common Mistakes to Avoid
24
+ - Current Technical Context
25
+
26
+ ## How It Works
27
+ 1. Agents read their memory file before starting tasks
28
+ 2. Agents add learnings during or after task completion
29
+ 3. Files automatically enforce size limits
30
+ 4. Developers can manually edit for accuracy
31
+
32
+ ## Memory File Lifecycle
33
+ - Created automatically when agent first runs
34
+ - Updated through hook system after delegations
35
+ - Manually editable by developers
36
+ - Version controlled with project
@@ -0,0 +1,39 @@
1
+ # Engineer Agent Memory - templates
2
+
3
+ <!-- MEMORY LIMITS: 8KB max | 10 sections max | 15 items per section -->
4
+ <!-- Last Updated: 2025-08-07 18:26:34 | Auto-updated by: engineer -->
5
+
6
+ ## Project Context
7
+ templates: mixed standard application
8
+
9
+ ## Project Architecture
10
+ - Standard Application with mixed implementation
11
+
12
+ ## Coding Patterns Learned
13
+ <!-- Items will be added as knowledge accumulates -->
14
+
15
+ ## Implementation Guidelines
16
+ <!-- Items will be added as knowledge accumulates -->
17
+
18
+ ## Domain-Specific Knowledge
19
+ <!-- Agent-specific knowledge for templates domain -->
20
+ - Key project terms: templates
21
+ - Focus on implementation patterns, coding standards, and best practices
22
+
23
+ ## Effective Strategies
24
+ <!-- Successful approaches discovered through experience -->
25
+
26
+ ## Common Mistakes to Avoid
27
+ <!-- Items will be added as knowledge accumulates -->
28
+
29
+ ## Integration Points
30
+ <!-- Items will be added as knowledge accumulates -->
31
+
32
+ ## Performance Considerations
33
+ <!-- Items will be added as knowledge accumulates -->
34
+
35
+ ## Current Technical Context
36
+ <!-- Items will be added as knowledge accumulates -->
37
+
38
+ ## Recent Learnings
39
+ <!-- Most recent discoveries and insights -->
@@ -0,0 +1,38 @@
1
+ # Version Control Agent Memory - templates
2
+
3
+ <!-- MEMORY LIMITS: 8KB max | 10 sections max | 15 items per section -->
4
+ <!-- Last Updated: 2025-08-07 18:28:51 | Auto-updated by: version_control -->
5
+
6
+ ## Project Context
7
+ templates: mixed standard application
8
+
9
+ ## Project Architecture
10
+ - Standard Application with mixed implementation
11
+
12
+ ## Coding Patterns Learned
13
+ <!-- Items will be added as knowledge accumulates -->
14
+
15
+ ## Implementation Guidelines
16
+ <!-- Items will be added as knowledge accumulates -->
17
+
18
+ ## Domain-Specific Knowledge
19
+ <!-- Agent-specific knowledge for templates domain -->
20
+ - Key project terms: templates
21
+
22
+ ## Effective Strategies
23
+ <!-- Successful approaches discovered through experience -->
24
+
25
+ ## Common Mistakes to Avoid
26
+ <!-- Items will be added as knowledge accumulates -->
27
+
28
+ ## Integration Points
29
+ <!-- Items will be added as knowledge accumulates -->
30
+
31
+ ## Performance Considerations
32
+ <!-- Items will be added as knowledge accumulates -->
33
+
34
+ ## Current Technical Context
35
+ <!-- Items will be added as knowledge accumulates -->
36
+
37
+ ## Recent Learnings
38
+ <!-- Most recent discoveries and insights -->
@@ -0,0 +1,96 @@
1
+ # Claude Code Hooks System
2
+
3
+ This directory contains the Claude Code hook integration for claude-mpm.
4
+
5
+ ## Overview
6
+
7
+ The hook system allows claude-mpm to intercept and handle commands typed in Claude Code, particularly the `/mpm` commands.
8
+
9
+ ## Structure
10
+
11
+ ```
12
+ hooks/
13
+ └── claude_hooks/ # Claude Code hook implementation
14
+ ├── hook_handler.py # Main Python handler that processes events
15
+ └── hook_wrapper.sh # Shell wrapper script (this is what gets installed in ~/.claude/settings.json)
16
+ ```
17
+
18
+ ## Claude Code Hooks
19
+
20
+ The Claude Code hooks are the primary integration point between claude-mpm and Claude Code. They allow:
21
+
22
+ - Intercepting `/mpm` commands before they reach the LLM
23
+ - Providing custom responses and actions
24
+ - Blocking LLM processing when appropriate
25
+
26
+ ### Installation
27
+
28
+ To install the Claude Code hooks:
29
+
30
+ ```bash
31
+ python scripts/install_hooks.py
32
+ ```
33
+
34
+ This will:
35
+ 1. Create/update `~/.claude/settings.json` with hook configuration
36
+ 2. Point to the `hook_wrapper.sh` script
37
+ 3. Copy any custom commands to `~/.claude/commands/`
38
+
39
+ ### How It Works
40
+
41
+ 1. When you type in Claude Code, it triggers hook events
42
+ 2. Claude Code calls `hook_wrapper.sh` (the path in `~/.claude/settings.json`)
43
+ 3. The wrapper script:
44
+ - Detects if it's running from a local dev environment, npm, or PyPI installation
45
+ - Activates the appropriate Python environment
46
+ - Runs `hook_handler.py` with the event data
47
+ 4. The handler processes various event types:
48
+ - **UserPromptSubmit**: Checks if the prompt starts with `/mpm` and handles commands
49
+ - **PreToolUse**: Logs tool usage before execution
50
+ - **PostToolUse**: Logs tool results after execution
51
+ - **Stop**: Logs when a session or task stops
52
+ - **SubagentStop**: Logs when a subagent completes with agent type and ID
53
+ 5. For `/mpm` commands, it returns exit code 2 to block LLM processing
54
+ 6. All events are logged to project-specific log files in `.claude-mpm/logs/`
55
+
56
+ ### Available Commands
57
+
58
+ - `/mpm` - Show help and available commands
59
+ - `/mpm status` - Show claude-mpm status and environment
60
+ - `/mpm help` - Show detailed help
61
+
62
+ ### Debugging
63
+
64
+ To enable debug logging for hooks:
65
+
66
+ ```bash
67
+ export CLAUDE_MPM_LOG_LEVEL=DEBUG
68
+ ```
69
+
70
+ Then run Claude Code from that terminal. Hook events will be logged to `~/.claude-mpm/logs/`.
71
+
72
+ ## Legacy Hook System (Removed)
73
+
74
+ The `builtin/` directory that contained the old internal hook system has been removed. All hook functionality is now handled through the Claude Code hooks system.
75
+
76
+ ## Development
77
+
78
+ To add new `/mpm` commands:
79
+
80
+ 1. Edit `hook_handler.py` to handle the new command
81
+ 2. Update the help text in the `handle_mpm_help()` function
82
+ 3. Test by running Claude Code with the new command
83
+
84
+ ## Exit Codes
85
+
86
+ The hook system uses specific exit codes:
87
+
88
+ - `0` - Success, continue normal processing
89
+ - `2` - Block LLM processing (command was handled)
90
+ - Other - Error occurred
91
+
92
+ ## Environment Variables
93
+
94
+ - `CLAUDE_MPM_LOG_LEVEL` - Set to DEBUG for detailed logging
95
+ - `HOOK_EVENT_TYPE` - Set by Claude Code (UserPromptSubmit, PreToolUse, PostToolUse)
96
+ - `HOOK_DATA` - JSON data from Claude Code with event details
claude_mpm/init.py CHANGED
@@ -68,8 +68,7 @@ class ProjectInitializer:
68
68
 
69
69
  Creates:
70
70
  - .claude-mpm/
71
- - agents/
72
- - project-specific/
71
+ - agents/ (for project agent JSON files)
73
72
  - config/
74
73
  - responses/
75
74
  - logs/
@@ -80,20 +79,33 @@ class ProjectInitializer:
80
79
  project_root = project_path
81
80
  self.project_dir = project_path / ".claude-mpm"
82
81
  else:
83
- # Always use current working directory for project directories
84
- # This ensures .claude-mpm is created where the user launches the tool
85
- project_root = Path.cwd()
82
+ # Check for the user's original working directory from launch script
83
+ # The launch script sets CLAUDE_MPM_USER_PWD before changing to framework directory
84
+ user_pwd = os.environ.get('CLAUDE_MPM_USER_PWD')
85
+
86
+ if user_pwd:
87
+ # Use the original user working directory
88
+ project_root = Path(user_pwd)
89
+ self.logger.debug(f"Using user working directory from CLAUDE_MPM_USER_PWD: {project_root}")
90
+ else:
91
+ # Fallback to current working directory (backward compatibility)
92
+ project_root = Path.cwd()
93
+ self.logger.debug(f"CLAUDE_MPM_USER_PWD not set, using cwd: {project_root}")
94
+
86
95
  self.project_dir = project_root / ".claude-mpm"
87
96
 
88
97
  # Check if directory already exists
89
98
  directory_existed = self.project_dir.exists()
90
99
 
100
+ # Migrate existing agents from project-specific subdirectory if needed
101
+ self._migrate_project_agents()
102
+
91
103
  # Create project directory
92
104
  self.project_dir.mkdir(exist_ok=True)
93
105
 
94
106
  # Create subdirectories
95
107
  directories = [
96
- self.project_dir / "agents" / "project-specific",
108
+ self.project_dir / "agents", # Direct agents directory for project agents
97
109
  self.project_dir / "config",
98
110
  self.project_dir / "responses",
99
111
  self.project_dir / "logs",
@@ -122,6 +134,12 @@ class ProjectInitializer:
122
134
  else:
123
135
  print(f"✓ Initialized .claude-mpm/ in {project_root}")
124
136
 
137
+ # Check if migration happened
138
+ agents_dir = self.project_dir / "agents"
139
+ if agents_dir.exists() and any(agents_dir.glob("*.json")):
140
+ agent_count = len(list(agents_dir.glob("*.json")))
141
+ print(f"✓ Found {agent_count} project agent(s) in .claude-mpm/agents/")
142
+
125
143
  return True
126
144
 
127
145
  except Exception as e:
@@ -129,6 +147,54 @@ class ProjectInitializer:
129
147
  print(f"✗ Failed to create .claude-mpm/ directory: {e}")
130
148
  return False
131
149
 
150
+ def _migrate_project_agents(self):
151
+ """Migrate agents from old subdirectory structure to direct agents directory.
152
+
153
+ WHY: We're simplifying the directory structure to match the deployment expectations.
154
+ The old structure had a subdirectory but the deployment now looks for agents
155
+ directly in .claude-mpm/agents/.
156
+ """
157
+ if not self.project_dir:
158
+ return
159
+
160
+ old_agents_dir = self.project_dir / "agents" / "project-specific"
161
+ new_agents_dir = self.project_dir / "agents"
162
+
163
+ # Check if old directory exists with JSON files
164
+ if old_agents_dir.exists() and old_agents_dir.is_dir():
165
+ json_files = list(old_agents_dir.glob("*.json"))
166
+ if json_files:
167
+ self.logger.info(f"Migrating {len(json_files)} agents from old subdirectory")
168
+
169
+ # Ensure new agents directory exists
170
+ new_agents_dir.mkdir(parents=True, exist_ok=True)
171
+
172
+ # Move each JSON file
173
+ migrated_count = 0
174
+ for json_file in json_files:
175
+ try:
176
+ target_file = new_agents_dir / json_file.name
177
+ if not target_file.exists():
178
+ # Move the file
179
+ shutil.move(str(json_file), str(target_file))
180
+ migrated_count += 1
181
+ self.logger.debug(f"Migrated {json_file.name} to agents directory")
182
+ else:
183
+ self.logger.debug(f"Skipping {json_file.name} - already exists in target")
184
+ except Exception as e:
185
+ self.logger.error(f"Failed to migrate {json_file.name}: {e}")
186
+
187
+ if migrated_count > 0:
188
+ print(f"✓ Migrated {migrated_count} agent(s) from old location to agents/")
189
+
190
+ # Remove old directory if empty
191
+ try:
192
+ if not any(old_agents_dir.iterdir()):
193
+ old_agents_dir.rmdir()
194
+ self.logger.debug("Removed empty old subdirectory")
195
+ except Exception as e:
196
+ self.logger.debug(f"Could not remove old directory: {e}")
197
+
132
198
  def _find_project_root(self) -> Optional[Path]:
133
199
  """Find project root by looking for .git or other project markers."""
134
200
  current = Path.cwd()
@@ -237,19 +303,23 @@ class ProjectInitializer:
237
303
 
238
304
  Shows clear information about where directories are being created.
239
305
  """
240
- # Show working directory info at startup
241
- cwd = Path.cwd()
242
- framework_path = Path(__file__).parent.parent.parent
306
+ # Determine actual working directory
307
+ user_pwd = os.environ.get('CLAUDE_MPM_USER_PWD')
308
+ if user_pwd:
309
+ actual_wd = Path(user_pwd)
310
+ self.logger.info(f"User working directory (from CLAUDE_MPM_USER_PWD): {actual_wd}")
311
+ else:
312
+ actual_wd = Path.cwd()
313
+ self.logger.info(f"Working directory: {actual_wd}")
243
314
 
244
- # Log startup context
245
- self.logger.info(f"Working directory: {cwd}")
315
+ framework_path = Path(__file__).parent.parent.parent
246
316
  self.logger.info(f"Framework path: {framework_path}")
247
317
 
248
318
  # Initialize user directory (in home)
249
319
  user_ok = self.initialize_user_directory()
250
320
 
251
- # Initialize project directory (in current working directory)
252
- self.logger.info(f"Checking for .claude-mpm/ in {cwd}")
321
+ # Initialize project directory (in user's actual working directory)
322
+ self.logger.info(f"Checking for .claude-mpm/ in {actual_wd}")
253
323
  project_ok = self.initialize_project_directory()
254
324
 
255
325
  return user_ok and project_ok