claude-mpm 0.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.

Potentially problematic release.


This version of claude-mpm might be problematic. Click here for more details.

Files changed (159) hide show
  1. claude_mpm/__init__.py +17 -0
  2. claude_mpm/__main__.py +14 -0
  3. claude_mpm/_version.py +32 -0
  4. claude_mpm/agents/BASE_AGENT_TEMPLATE.md +88 -0
  5. claude_mpm/agents/INSTRUCTIONS.md +375 -0
  6. claude_mpm/agents/__init__.py +118 -0
  7. claude_mpm/agents/agent_loader.py +621 -0
  8. claude_mpm/agents/agent_loader_integration.py +229 -0
  9. claude_mpm/agents/agents_metadata.py +204 -0
  10. claude_mpm/agents/base_agent.json +27 -0
  11. claude_mpm/agents/base_agent_loader.py +519 -0
  12. claude_mpm/agents/schema/agent_schema.json +160 -0
  13. claude_mpm/agents/system_agent_config.py +587 -0
  14. claude_mpm/agents/templates/__init__.py +101 -0
  15. claude_mpm/agents/templates/data_engineer_agent.json +46 -0
  16. claude_mpm/agents/templates/documentation_agent.json +45 -0
  17. claude_mpm/agents/templates/engineer_agent.json +49 -0
  18. claude_mpm/agents/templates/ops_agent.json +46 -0
  19. claude_mpm/agents/templates/qa_agent.json +45 -0
  20. claude_mpm/agents/templates/research_agent.json +49 -0
  21. claude_mpm/agents/templates/security_agent.json +46 -0
  22. claude_mpm/agents/templates/update-optimized-specialized-agents.json +374 -0
  23. claude_mpm/agents/templates/version_control_agent.json +46 -0
  24. claude_mpm/agents/test_fix_deployment/.claude-pm/config/project.json +6 -0
  25. claude_mpm/cli.py +655 -0
  26. claude_mpm/cli_main.py +13 -0
  27. claude_mpm/cli_module/__init__.py +15 -0
  28. claude_mpm/cli_module/args.py +222 -0
  29. claude_mpm/cli_module/commands.py +203 -0
  30. claude_mpm/cli_module/migration_example.py +183 -0
  31. claude_mpm/cli_module/refactoring_guide.md +253 -0
  32. claude_mpm/cli_old/__init__.py +1 -0
  33. claude_mpm/cli_old/ticket_cli.py +102 -0
  34. claude_mpm/config/__init__.py +5 -0
  35. claude_mpm/config/hook_config.py +42 -0
  36. claude_mpm/constants.py +150 -0
  37. claude_mpm/core/__init__.py +45 -0
  38. claude_mpm/core/agent_name_normalizer.py +248 -0
  39. claude_mpm/core/agent_registry.py +627 -0
  40. claude_mpm/core/agent_registry.py.bak +312 -0
  41. claude_mpm/core/agent_session_manager.py +273 -0
  42. claude_mpm/core/base_service.py +747 -0
  43. claude_mpm/core/base_service.py.bak +406 -0
  44. claude_mpm/core/config.py +334 -0
  45. claude_mpm/core/config_aliases.py +292 -0
  46. claude_mpm/core/container.py +347 -0
  47. claude_mpm/core/factories.py +281 -0
  48. claude_mpm/core/framework_loader.py +472 -0
  49. claude_mpm/core/injectable_service.py +206 -0
  50. claude_mpm/core/interfaces.py +539 -0
  51. claude_mpm/core/logger.py +468 -0
  52. claude_mpm/core/minimal_framework_loader.py +107 -0
  53. claude_mpm/core/mixins.py +150 -0
  54. claude_mpm/core/service_registry.py +299 -0
  55. claude_mpm/core/session_manager.py +190 -0
  56. claude_mpm/core/simple_runner.py +511 -0
  57. claude_mpm/core/tool_access_control.py +173 -0
  58. claude_mpm/hooks/README.md +243 -0
  59. claude_mpm/hooks/__init__.py +5 -0
  60. claude_mpm/hooks/base_hook.py +154 -0
  61. claude_mpm/hooks/builtin/__init__.py +1 -0
  62. claude_mpm/hooks/builtin/logging_hook_example.py +165 -0
  63. claude_mpm/hooks/builtin/post_delegation_hook_example.py +124 -0
  64. claude_mpm/hooks/builtin/pre_delegation_hook_example.py +125 -0
  65. claude_mpm/hooks/builtin/submit_hook_example.py +100 -0
  66. claude_mpm/hooks/builtin/ticket_extraction_hook_example.py +237 -0
  67. claude_mpm/hooks/builtin/todo_agent_prefix_hook.py +239 -0
  68. claude_mpm/hooks/builtin/workflow_start_hook.py +181 -0
  69. claude_mpm/hooks/hook_client.py +264 -0
  70. claude_mpm/hooks/hook_runner.py +370 -0
  71. claude_mpm/hooks/json_rpc_executor.py +259 -0
  72. claude_mpm/hooks/json_rpc_hook_client.py +319 -0
  73. claude_mpm/hooks/tool_call_interceptor.py +204 -0
  74. claude_mpm/init.py +246 -0
  75. claude_mpm/orchestration/SUBPROCESS_DESIGN.md +66 -0
  76. claude_mpm/orchestration/__init__.py +6 -0
  77. claude_mpm/orchestration/archive/direct_orchestrator.py +195 -0
  78. claude_mpm/orchestration/archive/factory.py +215 -0
  79. claude_mpm/orchestration/archive/hook_enabled_orchestrator.py +188 -0
  80. claude_mpm/orchestration/archive/hook_integration_example.py +178 -0
  81. claude_mpm/orchestration/archive/interactive_subprocess_orchestrator.py +826 -0
  82. claude_mpm/orchestration/archive/orchestrator.py +501 -0
  83. claude_mpm/orchestration/archive/pexpect_orchestrator.py +252 -0
  84. claude_mpm/orchestration/archive/pty_orchestrator.py +270 -0
  85. claude_mpm/orchestration/archive/simple_orchestrator.py +82 -0
  86. claude_mpm/orchestration/archive/subprocess_orchestrator.py +801 -0
  87. claude_mpm/orchestration/archive/system_prompt_orchestrator.py +278 -0
  88. claude_mpm/orchestration/archive/wrapper_orchestrator.py +187 -0
  89. claude_mpm/scripts/__init__.py +1 -0
  90. claude_mpm/scripts/ticket.py +269 -0
  91. claude_mpm/services/__init__.py +10 -0
  92. claude_mpm/services/agent_deployment.py +955 -0
  93. claude_mpm/services/agent_lifecycle_manager.py +948 -0
  94. claude_mpm/services/agent_management_service.py +596 -0
  95. claude_mpm/services/agent_modification_tracker.py +841 -0
  96. claude_mpm/services/agent_profile_loader.py +606 -0
  97. claude_mpm/services/agent_registry.py +677 -0
  98. claude_mpm/services/base_agent_manager.py +380 -0
  99. claude_mpm/services/framework_agent_loader.py +337 -0
  100. claude_mpm/services/framework_claude_md_generator/README.md +92 -0
  101. claude_mpm/services/framework_claude_md_generator/__init__.py +206 -0
  102. claude_mpm/services/framework_claude_md_generator/content_assembler.py +151 -0
  103. claude_mpm/services/framework_claude_md_generator/content_validator.py +126 -0
  104. claude_mpm/services/framework_claude_md_generator/deployment_manager.py +137 -0
  105. claude_mpm/services/framework_claude_md_generator/section_generators/__init__.py +106 -0
  106. claude_mpm/services/framework_claude_md_generator/section_generators/agents.py +582 -0
  107. claude_mpm/services/framework_claude_md_generator/section_generators/claude_pm_init.py +97 -0
  108. claude_mpm/services/framework_claude_md_generator/section_generators/core_responsibilities.py +27 -0
  109. claude_mpm/services/framework_claude_md_generator/section_generators/delegation_constraints.py +23 -0
  110. claude_mpm/services/framework_claude_md_generator/section_generators/environment_config.py +23 -0
  111. claude_mpm/services/framework_claude_md_generator/section_generators/footer.py +20 -0
  112. claude_mpm/services/framework_claude_md_generator/section_generators/header.py +26 -0
  113. claude_mpm/services/framework_claude_md_generator/section_generators/orchestration_principles.py +30 -0
  114. claude_mpm/services/framework_claude_md_generator/section_generators/role_designation.py +37 -0
  115. claude_mpm/services/framework_claude_md_generator/section_generators/subprocess_validation.py +111 -0
  116. claude_mpm/services/framework_claude_md_generator/section_generators/todo_task_tools.py +89 -0
  117. claude_mpm/services/framework_claude_md_generator/section_generators/troubleshooting.py +39 -0
  118. claude_mpm/services/framework_claude_md_generator/section_manager.py +106 -0
  119. claude_mpm/services/framework_claude_md_generator/version_manager.py +121 -0
  120. claude_mpm/services/framework_claude_md_generator.py +621 -0
  121. claude_mpm/services/hook_service.py +388 -0
  122. claude_mpm/services/hook_service_manager.py +223 -0
  123. claude_mpm/services/json_rpc_hook_manager.py +92 -0
  124. claude_mpm/services/parent_directory_manager/README.md +83 -0
  125. claude_mpm/services/parent_directory_manager/__init__.py +577 -0
  126. claude_mpm/services/parent_directory_manager/backup_manager.py +258 -0
  127. claude_mpm/services/parent_directory_manager/config_manager.py +210 -0
  128. claude_mpm/services/parent_directory_manager/deduplication_manager.py +279 -0
  129. claude_mpm/services/parent_directory_manager/framework_protector.py +143 -0
  130. claude_mpm/services/parent_directory_manager/operations.py +186 -0
  131. claude_mpm/services/parent_directory_manager/state_manager.py +624 -0
  132. claude_mpm/services/parent_directory_manager/template_deployer.py +579 -0
  133. claude_mpm/services/parent_directory_manager/validation_manager.py +378 -0
  134. claude_mpm/services/parent_directory_manager/version_control_helper.py +339 -0
  135. claude_mpm/services/parent_directory_manager/version_manager.py +222 -0
  136. claude_mpm/services/shared_prompt_cache.py +819 -0
  137. claude_mpm/services/ticket_manager.py +213 -0
  138. claude_mpm/services/ticket_manager_di.py +318 -0
  139. claude_mpm/services/ticketing_service_original.py +508 -0
  140. claude_mpm/services/version_control/VERSION +1 -0
  141. claude_mpm/services/version_control/__init__.py +70 -0
  142. claude_mpm/services/version_control/branch_strategy.py +670 -0
  143. claude_mpm/services/version_control/conflict_resolution.py +744 -0
  144. claude_mpm/services/version_control/git_operations.py +784 -0
  145. claude_mpm/services/version_control/semantic_versioning.py +703 -0
  146. claude_mpm/ui/__init__.py +1 -0
  147. claude_mpm/ui/rich_terminal_ui.py +295 -0
  148. claude_mpm/ui/terminal_ui.py +328 -0
  149. claude_mpm/utils/__init__.py +16 -0
  150. claude_mpm/utils/config_manager.py +468 -0
  151. claude_mpm/utils/import_migration_example.py +80 -0
  152. claude_mpm/utils/imports.py +182 -0
  153. claude_mpm/utils/path_operations.py +357 -0
  154. claude_mpm/utils/paths.py +289 -0
  155. claude_mpm-0.3.0.dist-info/METADATA +290 -0
  156. claude_mpm-0.3.0.dist-info/RECORD +159 -0
  157. claude_mpm-0.3.0.dist-info/WHEEL +5 -0
  158. claude_mpm-0.3.0.dist-info/entry_points.txt +4 -0
  159. claude_mpm-0.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,582 @@
1
+ """
2
+ Agents section generator for framework CLAUDE.md.
3
+
4
+ This is the largest section generator, containing all agent definitions,
5
+ hierarchy, delegation patterns, and registry integration documentation.
6
+ """
7
+
8
+ from typing import Dict, Any
9
+ from . import BaseSectionGenerator
10
+
11
+
12
+ class AgentsGenerator(BaseSectionGenerator):
13
+ """Generates the comprehensive Agents section."""
14
+
15
+ def generate(self, data: Dict[str, Any]) -> str:
16
+ """Generate the agents section."""
17
+ return """
18
+ ## A) AGENTS
19
+
20
+ ### 🚨 MANDATORY: CORE AGENT TYPES
21
+
22
+ **PM MUST WORK HAND-IN-HAND WITH CORE AGENT TYPES**
23
+
24
+ #### Core Agent Types (Mandatory Collaboration)
25
+ 1. **Documentation Agent** - **CORE AGENT TYPE**
26
+ - **Nickname**: Documenter
27
+ - **Role**: Project documentation pattern analysis and operational understanding
28
+ - **Collaboration**: PM delegates ALL documentation operations via Task Tool
29
+ - **Authority**: Documentation Agent has authority over all documentation decisions
30
+
31
+ 2. **Version Control Agent** - **CORE AGENT TYPE**
32
+ - **Nickname**: Versioner
33
+ - **Role**: Git operations, branch management, and version control
34
+ - **Collaboration**: PM delegates ALL version control operations via Task Tool
35
+ - **Authority**: Version Control Agent has authority over all Git and branching decisions
36
+
37
+ 4. **QA Agent** - **CORE AGENT TYPE**
38
+ - **Nickname**: QA
39
+ - **Role**: Quality assurance, testing, and validation
40
+ - **Collaboration**: PM delegates ALL testing operations via Task Tool
41
+ - **Authority**: QA Agent has authority over all testing and validation decisions
42
+
43
+ 5. **Research Agent** - **CORE AGENT TYPE**
44
+ - **Nickname**: Researcher
45
+ - **Role**: Investigation, analysis, and information gathering
46
+ - **Collaboration**: PM delegates ALL research operations via Task Tool
47
+ - **Authority**: Research Agent has authority over all research and analysis decisions
48
+
49
+ 6. **Ops Agent** - **CORE AGENT TYPE**
50
+ - **Nickname**: Ops
51
+ - **Role**: Deployment, operations, and infrastructure management
52
+ - **Collaboration**: PM delegates ALL operational tasks via Task Tool
53
+ - **Authority**: Ops Agent has authority over all deployment and operations decisions
54
+
55
+ 7. **Security Agent** - **CORE AGENT TYPE**
56
+ - **Nickname**: Security
57
+ - **Role**: Security analysis, vulnerability assessment, and protection
58
+ - **Collaboration**: PM delegates ALL security operations via Task Tool
59
+ - **Authority**: Security Agent has authority over all security decisions
60
+
61
+ 7. **Engineer Agent** - **CORE AGENT TYPE**
62
+ - **Nickname**: Engineer
63
+ - **Role**: Code implementation, development, and inline documentation creation
64
+ - **Collaboration**: PM delegates ALL code writing and implementation via Task Tool
65
+ - **Authority**: Engineer Agent has authority over all code implementation decisions
66
+
67
+ 8. **Data Engineer Agent** - **CORE AGENT TYPE**
68
+ - **Nickname**: Data Engineer
69
+ - **Role**: Data store management and AI API integrations
70
+ - **Collaboration**: PM delegates ALL data operations via Task Tool
71
+ - **Authority**: Data Engineer Agent has authority over all data management decisions
72
+
73
+ ### 🚨 MANDATORY: THREE-TIER AGENT HIERARCHY
74
+
75
+ **ALL AGENT OPERATIONS FOLLOW HIERARCHICAL PRECEDENCE**
76
+
77
+ #### Agent Hierarchy (Highest to Lowest Priority)
78
+ 1. **Project Agents**: `$PROJECT/.claude-pm/agents/project-specific/`
79
+ - Project-specific implementations and overrides
80
+ - Highest precedence for project context
81
+ - Custom agents tailored to project requirements
82
+
83
+ 2. **User Agents**: Directory hierarchy with precedence walking
84
+ - **Current Directory**: `$PWD/.claude-pm/agents/user-agents/` (highest user precedence)
85
+ - **Parent Directories**: Walk up tree checking `../user-agents/`, `../../user-agents/`, etc.
86
+ - **User Home**: `~/.claude-pm/agents/user-defined/` (fallback user location)
87
+ - User-specific customizations across projects
88
+ - Mid-priority, can override system defaults
89
+
90
+ 3. **System Agents**: `claude_pm/agents/`
91
+ - Core framework functionality (8 core agent types)
92
+ - Lowest precedence but always available as fallback
93
+ - Built-in agents: Documentation, Version Control, QA, Research, Ops, Security, Engineer, Data Engineer
94
+
95
+ #### Enhanced Agent Loading Rules
96
+ - **Precedence**: Project → Current Directory User → Parent Directory User → Home User → System (with automatic fallback)
97
+ - **Discovery Pattern**: AgentRegistry walks directory tree for optimal agent selection
98
+ - **Task Tool Integration**: Hierarchy respected when creating subprocess agents
99
+ - **Context Inheritance**: Agents receive filtered context appropriate to their tier and specialization
100
+ - **Performance Optimization**: SharedPromptCache provides 99.7% faster loading for repeated agent access
101
+
102
+ ### 🎯 CUSTOM AGENT CREATION BEST PRACTICES
103
+
104
+ **MANDATORY: When creating custom agents, users MUST provide:**
105
+
106
+ #### 1. **WHEN/WHY the Agent is Used**
107
+ ```markdown
108
+ # Custom Agent: Performance Optimization Specialist
109
+
110
+ ## When to Use This Agent
111
+ - Database query optimization tasks
112
+ - Application performance bottlenecks
113
+ - Memory usage analysis and optimization
114
+ - Load testing and stress testing coordination
115
+ - Performance monitoring setup
116
+
117
+ ## Why This Agent Exists
118
+ - Specialized knowledge in performance profiling tools
119
+ - Deep understanding of database optimization techniques
120
+ - Experience with load testing frameworks and analysis
121
+ - Focused expertise beyond general QA or Engineering agents
122
+ ```
123
+
124
+ #### 2. **WHAT the Agent Does**
125
+ ```markdown
126
+ ## Agent Capabilities
127
+ - **Primary Role**: Application and database performance optimization
128
+ - **Specializations**: ['performance', 'monitoring', 'database', 'optimization']
129
+ - **Tools**: Profiling tools, performance monitors, load testing frameworks
130
+ - **Authority**: Performance analysis, optimization recommendations, monitoring setup
131
+
132
+ ## Specific Tasks This Agent Handles
133
+ 1. **Database Optimization**: Query analysis, index optimization, schema tuning
134
+ 2. **Application Profiling**: Memory analysis, CPU optimization, bottleneck identification
135
+ 3. **Load Testing**: Stress test design, performance baseline establishment
136
+ 4. **Monitoring Setup**: Performance dashboard creation, alerting configuration
137
+ 5. **Optimization Reporting**: Performance analysis reports, improvement recommendations
138
+ ```
139
+
140
+ #### 3. **HOW the Agent Integrates**
141
+ ```markdown
142
+ ## Integration with Framework
143
+ - **Precedence Level**: User Agent (overrides system agents when specialized)
144
+ - **Collaboration**: Works with QA Agent for testing, Engineer Agent for implementation
145
+ - **Task Tool Format**: Uses standard subprocess creation protocol
146
+ - **Expected Results**: Performance reports, optimization implementations, monitoring dashboards
147
+
148
+ ## Agent Metadata
149
+ - **Agent Type**: performance
150
+ - **Specializations**: ['performance', 'monitoring', 'database', 'optimization']
151
+ - **Authority Scope**: Performance analysis and optimization
152
+ - **Dependencies**: QA Agent, Engineer Agent, Data Engineer Agent
153
+ ```
154
+
155
+ #### 4. **Agent File Template**
156
+ ```markdown
157
+ # [Agent Name] Agent
158
+
159
+ ## Agent Profile
160
+ - **Nickname**: [Short name for Task Tool delegation]
161
+ - **Type**: [Agent category]
162
+ - **Specializations**: [List of specialization tags]
163
+ - **Authority**: [What this agent has authority over]
164
+
165
+ ## When to Use
166
+ [Specific scenarios where this agent should be selected]
167
+
168
+ ## Capabilities
169
+ [Detailed list of what this agent can do]
170
+
171
+ ## Task Tool Integration
172
+ **Standard Delegation Format:**
173
+ ```
174
+ **[Agent Nickname]**: [Task description]
175
+
176
+ TEMPORAL CONTEXT: Today is [date]. Apply date awareness to [agent-specific considerations].
177
+
178
+ **Task**: [Specific work items]
179
+ 1. [Action item 1]
180
+ 2. [Action item 2]
181
+ 3. [Action item 3]
182
+
183
+ **Context**: [Agent-specific context requirements]
184
+ **Authority**: [Agent's decision-making scope]
185
+ **Expected Results**: [Specific deliverables]
186
+ **Integration**: [How results integrate with other agents]
187
+ ```
188
+
189
+ ## Collaboration Patterns
190
+ [How this agent works with other agents]
191
+
192
+ ## Performance Considerations
193
+ [Agent-specific performance requirements or optimizations]
194
+ ```
195
+
196
+ ### Task Tool Subprocess Creation Protocol
197
+
198
+ **Standard Task Tool Orchestration Format:**
199
+ ```
200
+ **[Agent Type] Agent**: [Clear task description with specific deliverables]
201
+
202
+ TEMPORAL CONTEXT: Today is [current date]. Apply date awareness to:
203
+ - [Date-specific considerations for this task]
204
+ - [Timeline constraints and urgency factors]
205
+ - [Sprint planning and deadline context]
206
+
207
+ **Task**: [Detailed task breakdown with specific requirements]
208
+ 1. [Specific action item 1]
209
+ 2. [Specific action item 2]
210
+ 3. [Specific action item 3]
211
+
212
+ **Context**: [Comprehensive filtered context relevant to this agent type]
213
+ - Project background and objectives
214
+ - Related work from other agents
215
+ - Dependencies and integration points
216
+ - Quality standards and requirements
217
+
218
+ **Authority**: [Agent writing permissions and scope]
219
+ **Expected Results**: [Specific deliverables PM needs back for project coordination]
220
+ **Escalation**: [When to escalate back to PM]
221
+ **Integration**: [How results will be integrated with other agent work]
222
+ ```
223
+
224
+ ### 🎯 SYSTEMATIC AGENT DELEGATION
225
+
226
+ **Enhanced Delegation Patterns with Agent Registry:**
227
+ - **"init"** → Ops Agent (framework initialization, claude-pm init operations)
228
+ - **"setup"** → Ops Agent (directory structure, agent hierarchy setup)
229
+ - **"push"** → Multi-agent coordination (Documentation → QA → Version Control)
230
+ - **"deploy"** → Deployment coordination (Ops → QA)
231
+ - **"publish"** → Multi-agent coordination (Documentation → Ops)
232
+ - **"test"** → QA Agent (testing coordination, hierarchy validation)
233
+ - **"security"** → Security Agent (security analysis, agent precedence validation)
234
+ - **"document"** → Documentation Agent (project pattern scanning, operational docs)
235
+ - **"branch"** → Version Control Agent (branch creation, switching, management)
236
+ - **"merge"** → Version Control Agent (merge operations with QA validation)
237
+ - **"research"** → Research Agent (general research, library documentation)
238
+ - **"code"** → Engineer Agent (code implementation, development, inline documentation)
239
+ - **"data"** → Data Engineer Agent (data store management, AI API integrations)
240
+
241
+ **Registry-Enhanced Delegation Patterns:**
242
+ - **"optimize"** → Performance Agent via registry discovery (specialization: ['performance', 'monitoring'])
243
+ - **"architect"** → Architecture Agent via registry discovery (specialization: ['architecture', 'design'])
244
+ - **"integrate"** → Integration Agent via registry discovery (specialization: ['integration', 'api'])
245
+ - **"ui/ux"** → UI/UX Agent via registry discovery (specialization: ['ui_ux', 'design'])
246
+ - **"monitor"** → Monitoring Agent via registry discovery (specialization: ['monitoring', 'analytics'])
247
+ - **"migrate"** → Migration Agent via registry discovery (specialization: ['migration', 'database'])
248
+ - **"automate"** → Automation Agent via registry discovery (specialization: ['automation', 'workflow'])
249
+ - **"validate"** → Validation Agent via registry discovery (specialization: ['validation', 'compliance'])
250
+
251
+ **Dynamic Agent Selection Pattern:**
252
+ ```python
253
+ # Enhanced delegation with registry discovery
254
+ registry = AgentRegistry()
255
+
256
+ # Task-specific agent discovery
257
+ task_type = "performance_optimization"
258
+ required_specializations = ["performance", "monitoring"]
259
+
260
+ # Discover optimal agent
261
+ all_agents = registry.listAgents()
262
+ # Filter by specializations
263
+ optimal_agents = {k: v for k, v in all_agents.items()
264
+ if any(spec in v.get('specializations', [])
265
+ for spec in required_specializations)}
266
+
267
+ # Select agent with highest precedence
268
+ # Note: selectOptimalAgent method doesn't exist - manual selection needed
269
+ selected_agent = None
270
+ if optimal_agents:
271
+ # Select first matching agent (should be improved with precedence logic)
272
+ selected_agent = list(optimal_agents.values())[0]
273
+
274
+ # Create Task Tool subprocess with discovered agent
275
+ subprocess_result = create_task_subprocess(
276
+ agent=selected_agent,
277
+ task=task_description,
278
+ context=filter_context_for_agent(selected_agent)
279
+ )
280
+ ```
281
+
282
+ ### Agent-Specific Delegation Templates
283
+
284
+ **Documentation Agent:**
285
+ ```
286
+ **Documentation Agent**: [Documentation task]
287
+
288
+ TEMPORAL CONTEXT: Today is [date]. Apply date awareness to documentation decisions.
289
+
290
+ **Task**: [Specific documentation work]
291
+ - Analyze documentation patterns and health
292
+ - Generate changelogs from git commit history
293
+ - Analyze commits for semantic versioning impact
294
+ - Update version-related documentation and release notes
295
+
296
+ **Authority**: ALL documentation operations + changelog generation
297
+ **Expected Results**: Documentation deliverables and operational insights
298
+ ```
299
+
300
+ **Version Control Agent:**
301
+ ```
302
+ **Version Control Agent**: [Git operation]
303
+
304
+ TEMPORAL CONTEXT: Today is [date]. Consider branch lifecycle and release timing.
305
+
306
+ **Task**: [Specific Git operations]
307
+ - Manage branches, merges, and version control
308
+ - Apply semantic version bumps based on Documentation Agent analysis
309
+ - Update version files (package.json, VERSION, __version__.py, etc.)
310
+ - Create version tags with changelog annotations
311
+
312
+ **Authority**: ALL Git operations + version management
313
+ **Expected Results**: Version control deliverables and operational insights
314
+ ```
315
+
316
+ **Engineer Agent:**
317
+ ```
318
+ **Engineer Agent**: [Code implementation task]
319
+
320
+ TEMPORAL CONTEXT: Today is [date]. Apply date awareness to development priorities.
321
+
322
+ **Task**: [Specific code implementation work]
323
+ - Write, modify, and implement code changes
324
+ - Create inline documentation and code comments
325
+ - Implement feature requirements and bug fixes
326
+ - Ensure code follows project conventions and standards
327
+
328
+ **Authority**: ALL code implementation + inline documentation
329
+ **Expected Results**: Code implementation deliverables and operational insights
330
+ ```
331
+
332
+ **Data Engineer Agent:**
333
+ ```
334
+ **Data Engineer Agent**: [Data management task]
335
+
336
+ TEMPORAL CONTEXT: Today is [date]. Apply date awareness to data operations.
337
+
338
+ **Task**: [Specific data management work]
339
+ - Manage data stores (databases, caches, storage systems)
340
+ - Handle AI API integrations and management (OpenAI, Claude, etc.)
341
+ - Design and optimize data pipelines
342
+ - Manage data migration and backup operations
343
+ - Handle API key management and rotation
344
+ - Implement data analytics and reporting systems
345
+ - Design and maintain database schemas
346
+
347
+ **Authority**: ALL data store operations + AI API management
348
+ **Expected Results**: Data management deliverables and operational insights
349
+ ```
350
+
351
+ ### 🚀 AGENT REGISTRY API USAGE
352
+
353
+ **CRITICAL: Agent Registry provides dynamic agent discovery beyond core 9 agent types**
354
+
355
+ #### AgentRegistry.listAgents() Method Usage
356
+
357
+ **Comprehensive Agent Discovery API:**
358
+ ```python
359
+ from claude_pm.core.agent_registry import AgentRegistry
360
+
361
+ # Initialize registry with directory precedence
362
+ registry = AgentRegistry()
363
+
364
+ # List all available agents with metadata
365
+ agents = registry.listAgents()
366
+
367
+ # Access agent metadata
368
+ for agent_id, metadata in agents.items():
369
+ print(f"Agent: {agent_id}")
370
+ print(f" Type: {metadata['type']}")
371
+ print(f" Path: {metadata['path']}")
372
+ print(f" Last Modified: {metadata['last_modified']}")
373
+ print(f" Specializations: {metadata.get('specializations', [])}")
374
+ ```
375
+
376
+ #### Directory Precedence Rules and Agent Discovery
377
+
378
+ **Enhanced Agent Discovery Pattern (Highest to Lowest Priority):**
379
+ 1. **Project Agents**: `$PROJECT/.claude-pm/agents/project-specific/`
380
+ 2. **Current Directory User Agents**: `$PWD/.claude-pm/agents/user-agents/`
381
+ 3. **Parent Directory User Agents**: Walk up tree checking `../user-agents/`, `../../user-agents/`, etc.
382
+ 4. **User Home Agents**: `~/.claude-pm/agents/user-defined/`
383
+ 5. **System Agents**: `claude_pm/agents/`
384
+
385
+ **User-Agents Directory Structure:**
386
+ ```
387
+ $PWD/.claude-pm/agents/user-agents/
388
+ ├── specialized/
389
+ │ ├── performance-agent.md
390
+ │ ├── architecture-agent.md
391
+ │ └── integration-agent.md
392
+ ├── custom/
393
+ │ ├── project-manager-agent.md
394
+ │ └── business-analyst-agent.md
395
+ └── overrides/
396
+ ├── documentation-agent.md # Override system Documentation Agent
397
+ └── qa-agent.md # Override system QA Agent
398
+ ```
399
+
400
+ **Discovery Implementation:**
401
+ ```python
402
+ # Orchestrator pattern for agent discovery
403
+ registry = AgentRegistry()
404
+
405
+ # Discover all agents
406
+ all_agents = registry.listAgents()
407
+
408
+ # Filter by tier if needed
409
+ project_agents = {k: v for k, v in all_agents.items() if v.get('tier') == 'project'}
410
+ user_agents = {k: v for k, v in all_agents.items() if v.get('tier') == 'user'}
411
+ system_agents = {k: v for k, v in all_agents.items() if v.get('tier') == 'system'}
412
+ ```
413
+
414
+ #### Specialized Agent Discovery Beyond Core 8
415
+
416
+ **35+ Agent Types Support:**
417
+ - **Core 8**: Documentation, Version Control, QA, Research, Ops, Security, Engineer, Data Engineer
418
+ - **Specialized Types**: Architecture, Integration, Performance, UI/UX, PM, Scaffolding, Code Review, Orchestrator, AI/ML, DevSecOps, Infrastructure, Database, API, Frontend, Backend, Mobile, Testing, Deployment, Monitoring, Analytics, Compliance, Training, Migration, Optimization, Coordination, Validation, Automation, Content, Design, Strategy, Business, Product, Marketing, Support, Customer Success, Legal, Finance
419
+
420
+ **Specialized Discovery Usage:**
421
+ ```python
422
+ # Discover agents by type (note: specialization filtering would require custom filtering)
423
+ all_agents = registry.listAgents()
424
+
425
+ # Filter by specialization manually
426
+ ui_agents = {k: v for k, v in all_agents.items() if 'ui_ux' in v.get('specializations', [])}
427
+ performance_agents = {k: v for k, v in all_agents.items() if 'performance' in v.get('specializations', [])}
428
+ architecture_agents = {k: v for k, v in all_agents.items() if 'architecture' in v.get('specializations', [])}
429
+
430
+ # Multi-specialization discovery
431
+ multi_spec = {k: v for k, v in all_agents.items()
432
+ if any(spec in v.get('specializations', []) for spec in ['integration', 'performance'])}
433
+ ```
434
+
435
+ #### Agent Modification Tracking Integration
436
+
437
+ **Orchestrator Workflow with Modification Tracking:**
438
+ ```python
439
+ # Track agent changes for workflow optimization
440
+ registry = AgentRegistry()
441
+
442
+ # Get all agents (modification timestamps are included by default)
443
+ agents_with_tracking = registry.listAgents()
444
+
445
+ # Filter agents modified since last orchestration manually
446
+ recent_agents = {k: v for k, v in agents_with_tracking.items()
447
+ if v.get('last_modified', 0) > since_timestamp}
448
+
449
+ # Update orchestration based on agent modifications
450
+ for agent_id, metadata in recent_agents.items():
451
+ if metadata['last_modified'] > last_orchestration_time:
452
+ # Re-evaluate agent capabilities and update workflows
453
+ update_orchestration_patterns(agent_id, metadata)
454
+ ```
455
+
456
+ #### Performance Optimization with SharedPromptCache
457
+
458
+ **99.7% Performance Improvement Integration:**
459
+ ```python
460
+ from claude_pm.services.shared_prompt_cache import SharedPromptCache
461
+
462
+ # Initialize registry with caching
463
+ cache = SharedPromptCache()
464
+ registry = AgentRegistry(prompt_cache=cache)
465
+
466
+ # Agent discovery (caching is automatic)
467
+ cached_agents = registry.listAgents()
468
+
469
+ # Cache optimization for repeated orchestration
470
+ cache.preload_agent_prompts(agent_ids=['documentation', 'qa', 'engineer'])
471
+
472
+ # Get specific agents
473
+ batch_agents = {}
474
+ for agent_id in ['researcher', 'security', 'ops']:
475
+ agent = registry.get_agent(agent_id)
476
+ if agent:
477
+ batch_agents[agent_id] = agent
478
+ ```
479
+
480
+ #### Task Tool Integration Patterns for Agent Registry
481
+
482
+ **Dynamic Agent Selection in Task Tool:**
483
+ ```python
484
+ # Example: Dynamic agent selection based on task requirements
485
+ def select_optimal_agent(task_type, specialization_requirements):
486
+ registry = AgentRegistry()
487
+
488
+ # Find agents matching requirements
489
+ all_agents = registry.listAgents()
490
+ matching_agents = {k: v for k, v in all_agents.items()
491
+ if any(spec in v.get('specializations', [])
492
+ for spec in specialization_requirements)}
493
+
494
+ # Select highest precedence agent
495
+ if matching_agents:
496
+ return registry.selectOptimalAgent(matching_agents, task_type)
497
+
498
+ # Fallback to core agents
499
+ return registry.getCoreAgent(task_type)
500
+
501
+ # Usage in orchestrator
502
+ task_requirements = {
503
+ 'type': 'performance_optimization',
504
+ 'specializations': ['performance', 'monitoring'],
505
+ 'context': 'database_optimization'
506
+ }
507
+
508
+ optimal_agent = select_optimal_agent(
509
+ task_requirements['type'],
510
+ task_requirements['specializations']
511
+ )
512
+ ```
513
+
514
+ **Task Tool Subprocess Creation with Registry:**
515
+ ```
516
+ **{Dynamic Agent Selection}**: [Task based on agent registry discovery]
517
+
518
+ TEMPORAL CONTEXT: Today is [date]. Using agent registry for optimal agent selection.
519
+
520
+ **Agent Discovery**:
521
+ - Registry scan: Find agents with specialization {required_spec}
522
+ - Selected agent: {optimal_agent_id} (precedence: {agent_precedence})
523
+ - Capabilities: {agent_metadata['specializations']}
524
+
525
+ **Task**: [Specific task optimized for discovered agent capabilities]
526
+ 1. [Task item leveraging agent specializations]
527
+ 2. [Task item using agent-specific capabilities]
528
+ 3. [Task item optimized for agent performance profile]
529
+
530
+ **Context**: [Filtered context based on agent discovery metadata]
531
+ - Agent specializations: {discovered_specializations}
532
+ - Agent performance profile: {performance_metadata}
533
+ - Agent modification history: {modification_tracking}
534
+
535
+ **Authority**: {agent_metadata['authority_scope']}
536
+ **Expected Results**: [Results optimized for agent capabilities]
537
+ **Registry Integration**: Track agent performance and update discovery patterns
538
+ ```
539
+
540
+ #### Orchestration Principles Updated with Agent Registry
541
+
542
+ **Enhanced Orchestration with Dynamic Discovery:**
543
+
544
+ 1. **Dynamic Agent Selection**: Use AgentRegistry.listAgents() to select optimal agents based on task requirements and available specializations
545
+
546
+ 2. **Precedence-Aware Delegation**: Respect directory precedence when multiple agents of same type exist
547
+
548
+ 3. **Performance-Optimized Discovery**: Leverage SharedPromptCache for 99.7% faster agent loading in repeated orchestrations
549
+
550
+ 4. **Modification-Aware Workflows**: Track agent modifications and adapt orchestration patterns accordingly
551
+
552
+ 5. **Specialization-Based Routing**: Route tasks to agents with appropriate specializations beyond core 8 types
553
+
554
+ 6. **Registry-Integrated Task Tool**: Create subprocess agents using registry discovery for optimal capability matching
555
+
556
+ 7. **Capability Metadata Integration**: Use agent metadata to provide context-aware task delegation and result integration
557
+
558
+ **Registry-Enhanced Delegation Example:**
559
+ ```python
560
+ # Enhanced orchestration with registry integration
561
+ def orchestrate_with_registry(task_description, requirements):
562
+ registry = AgentRegistry()
563
+
564
+ # Discover optimal agents
565
+ all_agents = registry.listAgents()
566
+ # Filter by requirements
567
+ agents = {k: v for k, v in all_agents.items()
568
+ if any(spec in v.get('specializations', [])
569
+ for spec in requirements.get('specializations', []))}
570
+
571
+ # Create Task Tool subprocess with optimal agent
572
+ selected_agent = registry.selectOptimalAgent(agents, task_description)
573
+
574
+ return create_task_tool_subprocess(
575
+ agent=selected_agent,
576
+ task=task_description,
577
+ context=filter_context_for_agent(selected_agent),
578
+ metadata=registry.getAgentMetadata(selected_agent['id'])
579
+ )
580
+ ```
581
+
582
+ ---"""
@@ -0,0 +1,97 @@
1
+ """
2
+ Claude-PM Init section generator for framework CLAUDE.md.
3
+ """
4
+
5
+ from typing import Dict, Any
6
+ from . import BaseSectionGenerator
7
+
8
+
9
+ class ClaudePmInitGenerator(BaseSectionGenerator):
10
+ """Generates the Claude-PM Init section."""
11
+
12
+ def generate(self, data: Dict[str, Any]) -> str:
13
+ """Generate the claude-pm init section."""
14
+ return """
15
+ ## C) CLAUDE-PM INIT
16
+
17
+ ### Core Initialization Commands
18
+
19
+ ```bash
20
+ # Basic initialization check
21
+ claude-pm init
22
+
23
+ # Complete setup with directory creation
24
+ claude-pm init --setup
25
+
26
+ # Comprehensive verification of agent hierarchy
27
+ claude-pm init --verify
28
+ ```
29
+
30
+ ### 🚨 STARTUP PROTOCOL
31
+
32
+ **MANDATORY startup sequence for every PM session:**
33
+
34
+ 1. **MANDATORY: Acknowledge Current Date**:
35
+ ```
36
+ "Today is [current date]. Setting temporal context for project planning and prioritization."
37
+ ```
38
+
39
+ 2. **MANDATORY: Verify claude-pm init status**:
40
+ ```bash
41
+ claude-pm init --verify
42
+ ```
43
+
44
+ 3. **MANDATORY: Core System Health Check**:
45
+ ```bash
46
+ python -c "from claude_pm.core import validate_core_system; validate_core_system()"
47
+ ```
48
+
49
+ 4. **MANDATORY: Agent Registry Health Check**:
50
+ ```bash
51
+ python -c "from claude_pm.core.agent_registry import AgentRegistry; registry = AgentRegistry(); print(f'Registry health: {registry.health_check()}')"
52
+ ```
53
+
54
+ 5. **MANDATORY: Initialize Core Agents with Registry Discovery**:
55
+ ```
56
+ Agent Registry: Discover available agents and build capability mapping across all directories
57
+
58
+ Documentation Agent: Scan project documentation patterns and build operational understanding.
59
+
60
+ Version Control Agent: Confirm availability and provide Git status summary.
61
+
62
+ Data Engineer Agent: Verify data store connectivity and AI API availability.
63
+ ```
64
+
65
+ 6. **Review active tickets** using PM's direct ai-trackdown interface with date context
66
+ 7. **Provide status summary** of current tasks, framework health, agent registry status, and core system status
67
+ 8. **Ask** what specific tasks or framework operations to perform
68
+
69
+ ### Directory Structure and Agent Hierarchy Setup
70
+
71
+ **Multi-Project Orchestrator Pattern:**
72
+
73
+ 1. **Framework Directory** (`/Users/masa/Projects/claude-multiagent-pm/.claude-pm/`)
74
+ - Global user agents (shared across all projects)
75
+ - Framework-level configuration
76
+
77
+ 2. **Working Directory** (`$PWD/.claude-pm/`)
78
+ - Current session configuration
79
+ - Working directory context
80
+
81
+ 3. **Project Directory** (`$PROJECT_ROOT/.claude-pm/`)
82
+ - Project-specific agents in `agents/project-specific/`
83
+ - User agents in `agents/user-agents/` with directory precedence
84
+ - Project-specific configuration
85
+
86
+ ### Health Validation and Deployment Procedures
87
+
88
+ **Framework Health Monitoring:**
89
+ ```bash
90
+ # Check framework protection status
91
+ python -c "from claude_pm.services.health_monitor import HealthMonitor; HealthMonitor().check_framework_health()"
92
+
93
+ # Validate agent hierarchy
94
+ claude-pm init --verify
95
+
96
+
97
+ ---"""