claude-mpm 3.5.1__py3-none-any.whl → 3.5.4__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 (30) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/agents/INSTRUCTIONS.md +29 -2
  3. claude_mpm/agents/agent_loader.py +109 -15
  4. claude_mpm/agents/base_agent.json +1 -1
  5. claude_mpm/agents/frontmatter_validator.py +448 -0
  6. claude_mpm/agents/templates/data_engineer.json +4 -3
  7. claude_mpm/agents/templates/documentation.json +4 -3
  8. claude_mpm/agents/templates/engineer.json +4 -3
  9. claude_mpm/agents/templates/ops.json +4 -3
  10. claude_mpm/agents/templates/pm.json +5 -4
  11. claude_mpm/agents/templates/qa.json +4 -3
  12. claude_mpm/agents/templates/research.json +8 -7
  13. claude_mpm/agents/templates/security.json +4 -3
  14. claude_mpm/agents/templates/test_integration.json +4 -3
  15. claude_mpm/agents/templates/version_control.json +4 -3
  16. claude_mpm/cli/__main__.py +24 -0
  17. claude_mpm/cli/commands/agents.py +354 -6
  18. claude_mpm/cli/parser.py +36 -0
  19. claude_mpm/constants.py +2 -0
  20. claude_mpm/core/agent_registry.py +4 -1
  21. claude_mpm/core/claude_runner.py +224 -8
  22. claude_mpm/services/agents/deployment/agent_deployment.py +39 -9
  23. claude_mpm/services/agents/registry/agent_registry.py +22 -1
  24. claude_mpm/validation/agent_validator.py +56 -1
  25. {claude_mpm-3.5.1.dist-info → claude_mpm-3.5.4.dist-info}/METADATA +18 -3
  26. {claude_mpm-3.5.1.dist-info → claude_mpm-3.5.4.dist-info}/RECORD +30 -28
  27. {claude_mpm-3.5.1.dist-info → claude_mpm-3.5.4.dist-info}/WHEEL +0 -0
  28. {claude_mpm-3.5.1.dist-info → claude_mpm-3.5.4.dist-info}/entry_points.txt +0 -0
  29. {claude_mpm-3.5.1.dist-info → claude_mpm-3.5.4.dist-info}/licenses/LICENSE +0 -0
  30. {claude_mpm-3.5.1.dist-info → claude_mpm-3.5.4.dist-info}/top_level.txt +0 -0
claude_mpm/VERSION CHANGED
@@ -1 +1 @@
1
- 3.5.1
1
+ 3.5.4
@@ -1,4 +1,4 @@
1
- <!-- FRAMEWORK_VERSION: 0009 -->
1
+ <!-- FRAMEWORK_VERSION: 0010 -->
2
2
  <!-- LAST_MODIFIED: 2025-08-10T00:00:00Z -->
3
3
 
4
4
  # Claude Multi-Agent Project Manager Instructions
@@ -33,11 +33,11 @@
33
33
  ## Communication Standards
34
34
 
35
35
  - **Tone**: Professional, neutral by default
36
- - **Avoid**: "Excellent!", "Perfect!", "Amazing!", "You're absolutely right!" (and similar unwarrented phrasing)
37
36
  - **Use**: "Understood", "Confirmed", "Noted"
38
37
  - **No simplification** without explicit user request
39
38
  - **No mocks** outside test environments
40
39
  - **Complete implementations** only - no placeholders
40
+ - **FORBIDDEN**: "Excellent!", "Perfect!", "Amazing!", "You're absolutely right!" (and similar unwarrented phrasing)
41
41
 
42
42
  ## Mandatory Workflow Sequence
43
43
 
@@ -183,6 +183,32 @@ Context:
183
183
  5. **Monitoring**: Track progress via TodoWrite, handle errors, dynamic adjustment
184
184
  6. **Integration**: Synthesize results (NO TOOLS), validate outputs, report or re-delegate
185
185
 
186
+ ## Agent Response Format
187
+
188
+ When completing tasks, all agents should structure their responses with:
189
+
190
+ ```
191
+ ## Summary
192
+ **Task Completed**: <brief description of what was done>
193
+ **Approach**: <how the task was accomplished>
194
+ **Key Changes**:
195
+ - <change 1>
196
+ - <change 2>
197
+ **Remember**: <list of universal learnings, or null if none>
198
+ - Format: ["Learning 1", "Learning 2"] or null
199
+ - ONLY include information that should be remembered for ALL future requests
200
+ - Most tasks won't generate universal memories
201
+ - Examples of valid memories:
202
+ - "This project uses Python 3.11 with strict type checking"
203
+ - "All API endpoints require JWT authentication"
204
+ - "Database queries must use parameterized statements"
205
+ - Not valid for memory (too specific/temporary):
206
+ - "Fixed bug in user.py line 42"
207
+ - "Added login endpoint"
208
+ - "Refactored payment module"
209
+ **Issues/Notes**: <any problems encountered or important observations>
210
+ ```
211
+
186
212
  ## Completion Summary Format
187
213
 
188
214
  When all tasks complete:
@@ -194,6 +220,7 @@ When all tasks complete:
194
220
  1. <achievement 1>
195
221
  2. <achievement 2>
196
222
  **Files Modified**: <list of changed files>
223
+ **Remember**: <aggregated list of universal learnings from all agents, or null>
197
224
  **Next Steps**: <user actions needed>
198
225
  ```
199
226
 
@@ -15,7 +15,7 @@ standardized schema before being registered for use.
15
15
 
16
16
  Key Features:
17
17
  -------------
18
- - Automatic agent discovery from src/claude_mpm/agents/templates/*.json files
18
+ - Automatic agent discovery from JSON files in configured agent directories
19
19
  - Schema validation ensures all agents conform to the expected structure
20
20
  - Intelligent caching using SharedPromptCache for performance optimization
21
21
  - Dynamic model selection based on task complexity analysis
@@ -70,6 +70,7 @@ from ..validation.agent_validator import AgentValidator, ValidationResult
70
70
  from ..utils.paths import PathResolver
71
71
  from ..core.agent_name_normalizer import AgentNameNormalizer
72
72
  from ..core.config_paths import ConfigPaths
73
+ from .frontmatter_validator import FrontmatterValidator
73
74
 
74
75
  # Temporary placeholders for missing module
75
76
  # WHY: These classes would normally come from a task_complexity module, but
@@ -101,12 +102,12 @@ class AgentTier(Enum):
101
102
 
102
103
  def _get_agent_templates_dirs() -> Dict[AgentTier, Optional[Path]]:
103
104
  """
104
- Get directories containing agent template JSON files across all tiers.
105
+ Get directories containing agent JSON files across all tiers.
105
106
 
106
- Returns a dictionary mapping tiers to their template directories:
107
- - PROJECT: .claude-mpm/agents/templates in the current working directory
108
- - USER: ~/.claude-mpm/agents/templates
109
- - SYSTEM: Built-in templates relative to this module
107
+ Returns a dictionary mapping tiers to their agent directories:
108
+ - PROJECT: .claude-mpm/agents in the current working directory
109
+ - USER: ~/.claude-mpm/agents
110
+ - SYSTEM: Built-in agents relative to this module
110
111
 
111
112
  WHY: We support multiple tiers to allow project-specific customization
112
113
  while maintaining backward compatibility with system agents.
@@ -118,7 +119,7 @@ def _get_agent_templates_dirs() -> Dict[AgentTier, Optional[Path]]:
118
119
 
119
120
  # PROJECT tier - ALWAYS check current working directory dynamically
120
121
  # This ensures we pick up project agents even if CWD changes
121
- project_dir = Path.cwd() / ConfigPaths.CONFIG_DIR / "agents" / "templates"
122
+ project_dir = Path.cwd() / ConfigPaths.CONFIG_DIR / "agents"
122
123
  if project_dir.exists():
123
124
  dirs[AgentTier.PROJECT] = project_dir
124
125
  logger.debug(f"Found PROJECT agents at: {project_dir}")
@@ -126,12 +127,12 @@ def _get_agent_templates_dirs() -> Dict[AgentTier, Optional[Path]]:
126
127
  # USER tier - check user home directory
127
128
  user_config_dir = ConfigPaths.get_user_config_dir()
128
129
  if user_config_dir:
129
- user_agents_dir = user_config_dir / "agents" / "templates"
130
+ user_agents_dir = user_config_dir / "agents"
130
131
  if user_agents_dir.exists():
131
132
  dirs[AgentTier.USER] = user_agents_dir
132
133
  logger.debug(f"Found USER agents at: {user_agents_dir}")
133
134
 
134
- # SYSTEM tier - built-in templates
135
+ # SYSTEM tier - built-in agents
135
136
  system_dir = Path(__file__).parent / "templates"
136
137
  if system_dir.exists():
137
138
  dirs[AgentTier.SYSTEM] = system_dir
@@ -142,18 +143,18 @@ def _get_agent_templates_dirs() -> Dict[AgentTier, Optional[Path]]:
142
143
 
143
144
  def _get_agent_templates_dir() -> Path:
144
145
  """
145
- Get the primary directory containing agent template JSON files.
146
+ Get the primary directory containing agent JSON files.
146
147
 
147
148
  DEPRECATED: Use _get_agent_templates_dirs() for tier-aware loading.
148
149
  This function is kept for backward compatibility.
149
150
 
150
151
  Returns:
151
- Path: Absolute path to the system templates directory
152
+ Path: Absolute path to the system agents directory
152
153
  """
153
154
  return Path(__file__).parent / "templates"
154
155
 
155
156
 
156
- # Agent templates directory - where all agent JSON files are stored
157
+ # Agent directory - where all agent JSON files are stored
157
158
  AGENT_TEMPLATES_DIR = _get_agent_templates_dir()
158
159
 
159
160
  # Cache prefix for agent prompts - versioned to allow cache invalidation on schema changes
@@ -186,7 +187,7 @@ class AgentLoader:
186
187
  Central registry for loading and managing agent configurations.
187
188
 
188
189
  This class implements the core agent discovery and management system. It:
189
- 1. Discovers agent JSON files from the templates directory
190
+ 1. Discovers agent JSON files from the agents directory
190
191
  2. Validates each agent against the standardized schema
191
192
  3. Maintains an in-memory registry of valid agents
192
193
  4. Provides caching for performance optimization
@@ -198,7 +199,7 @@ class AgentLoader:
198
199
  - Agent usage frequency and patterns
199
200
  - Model selection distribution
200
201
  - Task complexity analysis results
201
- - Memory usage for agent templates
202
+ - Memory usage for agent definitions
202
203
  - Error rates during loading/validation
203
204
  - Agent prompt size distributions
204
205
 
@@ -243,6 +244,9 @@ class AgentLoader:
243
244
  # Track which tier each agent came from for debugging
244
245
  self._agent_tiers: Dict[str, AgentTier] = {}
245
246
 
247
+ # Initialize frontmatter validator for .md agent files
248
+ self.frontmatter_validator = FrontmatterValidator()
249
+
246
250
  # METRICS: Initialize performance tracking
247
251
  # This structure collects valuable telemetry for AI agent performance
248
252
  self._metrics = {
@@ -285,11 +289,14 @@ class AgentLoader:
285
289
  - Schema validation failures are logged with details
286
290
  - The system continues to function with whatever valid agents it finds
287
291
  """
288
- # Dynamically discover template directories at load time
292
+ # Dynamically discover agent directories at load time
289
293
  self._template_dirs = _get_agent_templates_dirs()
290
294
 
291
295
  logger.info(f"Loading agents from {len(self._template_dirs)} tier(s)")
292
296
 
297
+ # Perform startup validation check for .md agent files
298
+ self._validate_markdown_agents()
299
+
293
300
  # Process tiers in REVERSE precedence order (SYSTEM first, PROJECT last)
294
301
  # This ensures PROJECT agents override USER/SYSTEM agents
295
302
  for tier in [AgentTier.SYSTEM, AgentTier.USER, AgentTier.PROJECT]:
@@ -353,6 +360,93 @@ class AgentLoader:
353
360
  # Log loading errors but don't crash - system should be resilient
354
361
  logger.error(f"Failed to load {json_file.name}: {e}")
355
362
 
363
+ def _validate_markdown_agents(self) -> None:
364
+ """
365
+ Validate frontmatter in all .md agent files at startup.
366
+
367
+ This method performs validation and reports issues found in agent files.
368
+ It checks all tiers and provides a summary of validation results.
369
+ Auto-correction is applied in memory but not written to files.
370
+ """
371
+ validation_summary = {
372
+ 'total_checked': 0,
373
+ 'valid': 0,
374
+ 'corrected': 0,
375
+ 'errors': 0,
376
+ 'by_tier': {}
377
+ }
378
+
379
+ # Check the .claude/agents directory for .md files
380
+ claude_agents_dir = Path.cwd() / ".claude" / "agents"
381
+ if claude_agents_dir.exists():
382
+ logger.info("Validating agent files in .claude/agents directory...")
383
+
384
+ for md_file in claude_agents_dir.glob("*.md"):
385
+ validation_summary['total_checked'] += 1
386
+
387
+ # Validate the file
388
+ result = self.frontmatter_validator.validate_file(md_file)
389
+
390
+ if result.is_valid and not result.corrections:
391
+ validation_summary['valid'] += 1
392
+ elif result.corrections:
393
+ validation_summary['corrected'] += 1
394
+ logger.info(f"Auto-corrected frontmatter in {md_file.name}:")
395
+ for correction in result.corrections:
396
+ logger.info(f" - {correction}")
397
+
398
+ if result.errors:
399
+ validation_summary['errors'] += 1
400
+ logger.warning(f"Validation errors in {md_file.name}:")
401
+ for error in result.errors:
402
+ logger.warning(f" - {error}")
403
+
404
+ if result.warnings:
405
+ for warning in result.warnings:
406
+ logger.debug(f" Warning in {md_file.name}: {warning}")
407
+
408
+ # Check template directories for .md files
409
+ for tier, templates_dir in self._template_dirs.items():
410
+ if not templates_dir:
411
+ continue
412
+
413
+ tier_stats = {'checked': 0, 'valid': 0, 'corrected': 0, 'errors': 0}
414
+
415
+ for md_file in templates_dir.glob("*.md"):
416
+ validation_summary['total_checked'] += 1
417
+ tier_stats['checked'] += 1
418
+
419
+ # Validate the file
420
+ result = self.frontmatter_validator.validate_file(md_file)
421
+
422
+ if result.is_valid and not result.corrections:
423
+ validation_summary['valid'] += 1
424
+ tier_stats['valid'] += 1
425
+ elif result.corrections:
426
+ validation_summary['corrected'] += 1
427
+ tier_stats['corrected'] += 1
428
+ logger.debug(f"Auto-corrected {tier.value} agent {md_file.name}")
429
+
430
+ if result.errors:
431
+ validation_summary['errors'] += 1
432
+ tier_stats['errors'] += 1
433
+
434
+ if tier_stats['checked'] > 0:
435
+ validation_summary['by_tier'][tier.value] = tier_stats
436
+
437
+ # Log validation summary
438
+ if validation_summary['total_checked'] > 0:
439
+ logger.info(
440
+ f"Agent validation summary: "
441
+ f"{validation_summary['total_checked']} files checked, "
442
+ f"{validation_summary['valid']} valid, "
443
+ f"{validation_summary['corrected']} auto-corrected, "
444
+ f"{validation_summary['errors']} with errors"
445
+ )
446
+
447
+ # Store in metrics for reporting
448
+ self._metrics['validation_summary'] = validation_summary
449
+
356
450
  def get_agent(self, agent_id: str) -> Optional[Dict[str, Any]]:
357
451
  """
358
452
  Retrieve agent configuration by ID.
@@ -6,7 +6,7 @@
6
6
  "instructions": "# Claude MPM Framework Agent\n\nYou are a specialized agent in the Claude MPM framework. Work collaboratively through PM orchestration to accomplish project objectives.\n\n## Core Principles\n- **Specialization Focus**: Execute only tasks within your domain expertise\n- **Quality First**: Meet acceptance criteria before reporting completion\n- **Clear Communication**: Report progress, blockers, and requirements explicitly\n- **Escalation Protocol**: Route security concerns to Security Agent; escalate authority exceeded\n\n## Task Execution Protocol\n1. **Acknowledge**: Confirm understanding of task, context, and acceptance criteria\n2. **Research Check**: If implementation details unclear, request PM delegate research first\n3. **Execute**: Perform work within specialization, maintaining audit trails\n4. **Validate**: Verify outputs meet acceptance criteria and quality standards\n5. **Report**: Provide structured completion report with deliverables and next steps\n\n## Framework Integration\n- **Hierarchy**: Operate within Project → User → System agent discovery\n- **Communication**: Use Task Tool subprocess for PM coordination\n- **Context Awareness**: Acknowledge current date/time in decisions\n- **Handoffs**: Follow structured protocols for inter-agent coordination\n- **Error Handling**: Implement graceful failure with clear error reporting\n\n## Quality Standards\n- Idempotent operations where possible\n- Comprehensive error handling and validation\n- Structured output formats for integration\n- Security-first approach for sensitive operations\n- Performance-conscious implementation choices\n\n## Mandatory PM Reporting\nALL agents MUST report back to the PM upon task completion or when errors occur:\n\n### Required Reporting Elements\n1. **Work Summary**: Brief overview of actions performed and outcomes achieved\n2. **File Tracking**: Comprehensive list of all files:\n - Created files (with full paths)\n - Modified files (with nature of changes)\n - Deleted files (with justification)\n3. **Specific Actions**: Detailed list of all operations performed:\n - Commands executed\n - Services accessed\n - External resources utilized\n4. **Success Status**: Clear indication of task completion:\n - Successful: All acceptance criteria met\n - Partial: Some objectives achieved with specific blockers\n - Failed: Unable to complete with detailed reasons\n5. **Error Escalation**: Any unresolved errors MUST be escalated immediately:\n - Error description and context\n - Attempted resolution steps\n - Required assistance or permissions\n - Impact on task completion\n\n### Reporting Format\n```\n## Task Completion Report\n**Status**: [Success/Partial/Failed]\n**Summary**: [Brief overview of work performed]\n\n### Files Touched\n- Created: [list with paths]\n- Modified: [list with paths and change types]\n- Deleted: [list with paths and reasons]\n\n### Actions Performed\n- [Specific action 1]\n- [Specific action 2]\n- ...\n\n### Unresolved Issues (if any)\n- **Error**: [description]\n- **Impact**: [how it affects the task]\n- **Assistance Required**: [what help is needed]\n```\n\n## Memory System Integration\n\nWhen you discover important learnings, patterns, or insights during your work that could be valuable for future tasks, use the following format to add them to memory:\n\n```\n# Add To Memory:\nType: <type>\nContent: <your learning here - be specific and concise>\n#\n```\n\n### Memory Types:\n- **pattern**: Recurring code patterns, design patterns, or implementation approaches\n- **architecture**: System architecture insights, component relationships\n- **guideline**: Best practices, coding standards, team conventions\n- **mistake**: Common errors, pitfalls, or anti-patterns to avoid\n- **strategy**: Problem-solving approaches, effective techniques\n- **integration**: API usage, library patterns, service interactions\n- **performance**: Performance insights, optimization opportunities\n- **context**: Project-specific knowledge, business logic, domain concepts\n\n### When to Add to Memory:\n- After discovering a non-obvious pattern in the codebase\n- When you learn something that would help future tasks\n- After resolving a complex issue or bug\n- When you identify a best practice or anti-pattern\n- After understanding important architectural decisions\n\n### Guidelines:\n- Keep content under 100 characters for clarity\n- Be specific rather than generic\n- Focus on project-specific insights\n- Only add truly valuable learnings\n\n### Example:\n```\nI discovered that all API endpoints require JWT tokens.\n\n# Add To Memory:\nType: pattern\nContent: All API endpoints use JWT bearer tokens with 24-hour expiration\n#\n```"
7
7
  },
8
8
  "configuration_fields": {
9
- "model": "claude-4-sonnet-20250514",
9
+ "model": "sonnet",
10
10
  "file_access": "project",
11
11
  "dangerous_tools": false,
12
12
  "review_required": false,