claude-mpm 5.0.9__py3-none-any.whl → 5.4.41__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 (263) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/__init__.py +4 -0
  3. claude_mpm/agents/BASE_AGENT.md +164 -0
  4. claude_mpm/agents/{PM_INSTRUCTIONS_TEACH.md → CLAUDE_MPM_TEACHER_OUTPUT_STYLE.md} +721 -41
  5. claude_mpm/agents/MEMORY.md +1 -1
  6. claude_mpm/agents/PM_INSTRUCTIONS.md +468 -468
  7. claude_mpm/agents/WORKFLOW.md +5 -254
  8. claude_mpm/agents/agent_loader.py +13 -44
  9. claude_mpm/agents/base_agent.json +1 -1
  10. claude_mpm/agents/frontmatter_validator.py +70 -2
  11. claude_mpm/agents/templates/circuit-breakers.md +431 -45
  12. claude_mpm/cli/__init__.py +0 -1
  13. claude_mpm/cli/__main__.py +4 -0
  14. claude_mpm/cli/chrome_devtools_installer.py +175 -0
  15. claude_mpm/cli/commands/agent_state_manager.py +18 -27
  16. claude_mpm/cli/commands/agents.py +175 -37
  17. claude_mpm/cli/commands/auto_configure.py +723 -236
  18. claude_mpm/cli/commands/config.py +88 -2
  19. claude_mpm/cli/commands/configure.py +1262 -157
  20. claude_mpm/cli/commands/configure_agent_display.py +25 -6
  21. claude_mpm/cli/commands/mpm_init/core.py +225 -46
  22. claude_mpm/cli/commands/mpm_init/knowledge_extractor.py +481 -0
  23. claude_mpm/cli/commands/mpm_init/prompts.py +280 -0
  24. claude_mpm/cli/commands/postmortem.py +1 -1
  25. claude_mpm/cli/commands/profile.py +277 -0
  26. claude_mpm/cli/commands/skills.py +214 -189
  27. claude_mpm/cli/commands/summarize.py +413 -0
  28. claude_mpm/cli/executor.py +21 -3
  29. claude_mpm/cli/interactive/agent_wizard.py +85 -10
  30. claude_mpm/cli/parsers/agents_parser.py +54 -9
  31. claude_mpm/cli/parsers/auto_configure_parser.py +13 -138
  32. claude_mpm/cli/parsers/base_parser.py +12 -0
  33. claude_mpm/cli/parsers/config_parser.py +153 -83
  34. claude_mpm/cli/parsers/profile_parser.py +148 -0
  35. claude_mpm/cli/parsers/skills_parser.py +3 -2
  36. claude_mpm/cli/startup.py +879 -149
  37. claude_mpm/commands/mpm-config.md +28 -0
  38. claude_mpm/commands/mpm-doctor.md +9 -22
  39. claude_mpm/commands/mpm-help.md +5 -287
  40. claude_mpm/commands/mpm-init.md +81 -507
  41. claude_mpm/commands/mpm-monitor.md +15 -402
  42. claude_mpm/commands/mpm-organize.md +120 -0
  43. claude_mpm/commands/mpm-postmortem.md +6 -108
  44. claude_mpm/commands/mpm-session-resume.md +12 -363
  45. claude_mpm/commands/mpm-status.md +5 -69
  46. claude_mpm/commands/mpm-ticket-view.md +52 -495
  47. claude_mpm/commands/mpm-version.md +5 -107
  48. claude_mpm/config/agent_sources.py +27 -0
  49. claude_mpm/core/config.py +2 -4
  50. claude_mpm/core/framework/formatters/content_formatter.py +3 -13
  51. claude_mpm/core/framework/loaders/agent_loader.py +8 -5
  52. claude_mpm/core/framework/loaders/instruction_loader.py +52 -11
  53. claude_mpm/core/framework_loader.py +4 -2
  54. claude_mpm/core/logger.py +13 -0
  55. claude_mpm/core/optimized_startup.py +59 -0
  56. claude_mpm/core/output_style_manager.py +173 -43
  57. claude_mpm/core/shared/config_loader.py +1 -1
  58. claude_mpm/core/socketio_pool.py +3 -3
  59. claude_mpm/core/unified_agent_registry.py +134 -16
  60. claude_mpm/core/unified_config.py +22 -0
  61. claude_mpm/dashboard/static/svelte-build/_app/env.js +1 -0
  62. claude_mpm/dashboard/static/svelte-build/_app/immutable/assets/0.B_FtCwCQ.css +1 -0
  63. claude_mpm/dashboard/static/svelte-build/_app/immutable/assets/2.Cl_eSA4x.css +1 -0
  64. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/BgChzWQ1.js +1 -0
  65. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CIXEwuWe.js +1 -0
  66. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CWc5urbQ.js +1 -0
  67. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DMkZpdF2.js +2 -0
  68. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DjhvlsAc.js +1 -0
  69. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/N4qtv3Hx.js +2 -0
  70. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/uj46x2Wr.js +1 -0
  71. claude_mpm/dashboard/static/svelte-build/_app/immutable/entry/app.DTL5mJO-.js +2 -0
  72. claude_mpm/dashboard/static/svelte-build/_app/immutable/entry/start.DzuEhzqh.js +1 -0
  73. claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/0.CAGBuiOw.js +1 -0
  74. claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/1.DFLC8jdE.js +1 -0
  75. claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/2.DPvEihJJ.js +10 -0
  76. claude_mpm/dashboard/static/svelte-build/_app/version.json +1 -0
  77. claude_mpm/dashboard/static/svelte-build/favicon.svg +7 -0
  78. claude_mpm/dashboard/static/svelte-build/index.html +36 -0
  79. claude_mpm/hooks/claude_hooks/__pycache__/__init__.cpython-311.pyc +0 -0
  80. claude_mpm/hooks/claude_hooks/__pycache__/correlation_manager.cpython-311.pyc +0 -0
  81. claude_mpm/hooks/claude_hooks/__pycache__/event_handlers.cpython-311.pyc +0 -0
  82. claude_mpm/hooks/claude_hooks/__pycache__/hook_handler.cpython-311.pyc +0 -0
  83. claude_mpm/hooks/claude_hooks/__pycache__/installer.cpython-311.pyc +0 -0
  84. claude_mpm/hooks/claude_hooks/__pycache__/memory_integration.cpython-311.pyc +0 -0
  85. claude_mpm/hooks/claude_hooks/__pycache__/response_tracking.cpython-311.pyc +0 -0
  86. claude_mpm/hooks/claude_hooks/__pycache__/tool_analysis.cpython-311.pyc +0 -0
  87. claude_mpm/hooks/claude_hooks/correlation_manager.py +60 -0
  88. claude_mpm/hooks/claude_hooks/event_handlers.py +211 -78
  89. claude_mpm/hooks/claude_hooks/hook_handler.py +155 -1
  90. claude_mpm/hooks/claude_hooks/installer.py +33 -10
  91. claude_mpm/hooks/claude_hooks/memory_integration.py +28 -0
  92. claude_mpm/hooks/claude_hooks/response_tracking.py +2 -3
  93. claude_mpm/hooks/claude_hooks/services/__pycache__/__init__.cpython-311.pyc +0 -0
  94. claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager.cpython-311.pyc +0 -0
  95. claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager_http.cpython-311.pyc +0 -0
  96. claude_mpm/hooks/claude_hooks/services/__pycache__/duplicate_detector.cpython-311.pyc +0 -0
  97. claude_mpm/hooks/claude_hooks/services/__pycache__/state_manager.cpython-311.pyc +0 -0
  98. claude_mpm/hooks/claude_hooks/services/__pycache__/subagent_processor.cpython-311.pyc +0 -0
  99. claude_mpm/hooks/claude_hooks/services/connection_manager.py +30 -6
  100. claude_mpm/hooks/memory_integration_hook.py +46 -1
  101. claude_mpm/init.py +63 -19
  102. claude_mpm/models/agent_definition.py +7 -0
  103. claude_mpm/models/git_repository.py +3 -3
  104. claude_mpm/scripts/claude-hook-handler.sh +58 -18
  105. claude_mpm/scripts/launch_monitor.py +93 -13
  106. claude_mpm/scripts/start_activity_logging.py +0 -0
  107. claude_mpm/services/agents/agent_builder.py +3 -3
  108. claude_mpm/services/agents/agent_recommendation_service.py +278 -0
  109. claude_mpm/services/agents/agent_review_service.py +280 -0
  110. claude_mpm/services/agents/cache_git_manager.py +6 -6
  111. claude_mpm/services/agents/deployment/agent_deployment.py +29 -7
  112. claude_mpm/services/agents/deployment/agent_discovery_service.py +4 -5
  113. claude_mpm/services/agents/deployment/agent_template_builder.py +5 -3
  114. claude_mpm/services/agents/deployment/agents_directory_resolver.py +2 -2
  115. claude_mpm/services/agents/deployment/multi_source_deployment_service.py +320 -29
  116. claude_mpm/services/agents/deployment/remote_agent_discovery_service.py +546 -68
  117. claude_mpm/services/agents/git_source_manager.py +36 -2
  118. claude_mpm/services/agents/loading/base_agent_manager.py +1 -13
  119. claude_mpm/services/agents/recommender.py +5 -3
  120. claude_mpm/services/agents/single_tier_deployment_service.py +2 -2
  121. claude_mpm/services/agents/sources/git_source_sync_service.py +13 -6
  122. claude_mpm/services/agents/startup_sync.py +22 -2
  123. claude_mpm/services/agents/toolchain_detector.py +10 -6
  124. claude_mpm/services/analysis/__init__.py +11 -1
  125. claude_mpm/services/analysis/clone_detector.py +1030 -0
  126. claude_mpm/services/command_deployment_service.py +81 -10
  127. claude_mpm/services/diagnostics/checks/agent_check.py +2 -2
  128. claude_mpm/services/diagnostics/checks/agent_sources_check.py +1 -1
  129. claude_mpm/services/event_bus/config.py +3 -1
  130. claude_mpm/services/git/git_operations_service.py +101 -16
  131. claude_mpm/services/monitor/daemon.py +9 -2
  132. claude_mpm/services/monitor/daemon_manager.py +39 -3
  133. claude_mpm/services/monitor/management/lifecycle.py +8 -1
  134. claude_mpm/services/monitor/server.py +698 -22
  135. claude_mpm/services/pm_skills_deployer.py +676 -0
  136. claude_mpm/services/profile_manager.py +331 -0
  137. claude_mpm/services/project/project_organizer.py +4 -0
  138. claude_mpm/services/self_upgrade_service.py +120 -12
  139. claude_mpm/services/skills/__init__.py +3 -0
  140. claude_mpm/services/skills/git_skill_source_manager.py +130 -2
  141. claude_mpm/services/skills/selective_skill_deployer.py +704 -0
  142. claude_mpm/services/skills/skill_to_agent_mapper.py +406 -0
  143. claude_mpm/services/skills_deployer.py +126 -9
  144. claude_mpm/services/socketio/dashboard_server.py +1 -0
  145. claude_mpm/services/socketio/event_normalizer.py +51 -6
  146. claude_mpm/services/socketio/server/core.py +386 -108
  147. claude_mpm/services/version_control/git_operations.py +103 -0
  148. claude_mpm/skills/skill_manager.py +92 -3
  149. claude_mpm/utils/agent_dependency_loader.py +14 -2
  150. claude_mpm/utils/agent_filters.py +17 -44
  151. claude_mpm/utils/gitignore.py +3 -0
  152. claude_mpm/utils/migration.py +4 -4
  153. claude_mpm/utils/robust_installer.py +47 -3
  154. {claude_mpm-5.0.9.dist-info → claude_mpm-5.4.41.dist-info}/METADATA +57 -87
  155. {claude_mpm-5.0.9.dist-info → claude_mpm-5.4.41.dist-info}/RECORD +160 -211
  156. claude_mpm-5.4.41.dist-info/entry_points.txt +5 -0
  157. claude_mpm-5.4.41.dist-info/licenses/LICENSE +94 -0
  158. claude_mpm-5.4.41.dist-info/licenses/LICENSE-FAQ.md +153 -0
  159. claude_mpm/agents/BASE_AGENT_TEMPLATE.md +0 -292
  160. claude_mpm/agents/BASE_DOCUMENTATION.md +0 -53
  161. claude_mpm/agents/BASE_OPS.md +0 -219
  162. claude_mpm/agents/BASE_PM.md +0 -480
  163. claude_mpm/agents/BASE_PROMPT_ENGINEER.md +0 -787
  164. claude_mpm/agents/BASE_QA.md +0 -167
  165. claude_mpm/agents/BASE_RESEARCH.md +0 -53
  166. claude_mpm/agents/base_agent_loader.py +0 -601
  167. claude_mpm/cli/commands/agents_detect.py +0 -380
  168. claude_mpm/cli/commands/agents_recommend.py +0 -309
  169. claude_mpm/cli/ticket_cli.py +0 -35
  170. claude_mpm/commands/mpm-agents-auto-configure.md +0 -278
  171. claude_mpm/commands/mpm-agents-detect.md +0 -177
  172. claude_mpm/commands/mpm-agents-list.md +0 -131
  173. claude_mpm/commands/mpm-agents-recommend.md +0 -223
  174. claude_mpm/commands/mpm-config-view.md +0 -150
  175. claude_mpm/commands/mpm-ticket-organize.md +0 -304
  176. claude_mpm/dashboard/analysis_runner.py +0 -455
  177. claude_mpm/dashboard/index.html +0 -13
  178. claude_mpm/dashboard/open_dashboard.py +0 -66
  179. claude_mpm/dashboard/static/css/activity.css +0 -1958
  180. claude_mpm/dashboard/static/css/connection-status.css +0 -370
  181. claude_mpm/dashboard/static/css/dashboard.css +0 -4701
  182. claude_mpm/dashboard/static/js/components/activity-tree.js +0 -1871
  183. claude_mpm/dashboard/static/js/components/agent-hierarchy.js +0 -777
  184. claude_mpm/dashboard/static/js/components/agent-inference.js +0 -956
  185. claude_mpm/dashboard/static/js/components/build-tracker.js +0 -333
  186. claude_mpm/dashboard/static/js/components/code-simple.js +0 -857
  187. claude_mpm/dashboard/static/js/components/connection-debug.js +0 -654
  188. claude_mpm/dashboard/static/js/components/diff-viewer.js +0 -891
  189. claude_mpm/dashboard/static/js/components/event-processor.js +0 -542
  190. claude_mpm/dashboard/static/js/components/event-viewer.js +0 -1155
  191. claude_mpm/dashboard/static/js/components/export-manager.js +0 -368
  192. claude_mpm/dashboard/static/js/components/file-change-tracker.js +0 -443
  193. claude_mpm/dashboard/static/js/components/file-change-viewer.js +0 -690
  194. claude_mpm/dashboard/static/js/components/file-tool-tracker.js +0 -724
  195. claude_mpm/dashboard/static/js/components/file-viewer.js +0 -580
  196. claude_mpm/dashboard/static/js/components/hud-library-loader.js +0 -211
  197. claude_mpm/dashboard/static/js/components/hud-manager.js +0 -671
  198. claude_mpm/dashboard/static/js/components/hud-visualizer.js +0 -1718
  199. claude_mpm/dashboard/static/js/components/module-viewer.js +0 -2764
  200. claude_mpm/dashboard/static/js/components/session-manager.js +0 -579
  201. claude_mpm/dashboard/static/js/components/socket-manager.js +0 -368
  202. claude_mpm/dashboard/static/js/components/ui-state-manager.js +0 -749
  203. claude_mpm/dashboard/static/js/components/unified-data-viewer.js +0 -1824
  204. claude_mpm/dashboard/static/js/components/working-directory.js +0 -920
  205. claude_mpm/dashboard/static/js/connection-manager.js +0 -536
  206. claude_mpm/dashboard/static/js/dashboard.js +0 -1914
  207. claude_mpm/dashboard/static/js/extension-error-handler.js +0 -164
  208. claude_mpm/dashboard/static/js/socket-client.js +0 -1474
  209. claude_mpm/dashboard/static/js/tab-isolation-fix.js +0 -185
  210. claude_mpm/dashboard/static/socket.io.min.js +0 -7
  211. claude_mpm/dashboard/static/socket.io.v4.8.1.backup.js +0 -7
  212. claude_mpm/dashboard/templates/code_simple.html +0 -153
  213. claude_mpm/dashboard/templates/index.html +0 -606
  214. claude_mpm/dashboard/test_dashboard.html +0 -372
  215. claude_mpm/hooks/claude_hooks/__pycache__/__init__.cpython-313.pyc +0 -0
  216. claude_mpm/hooks/claude_hooks/__pycache__/event_handlers.cpython-313.pyc +0 -0
  217. claude_mpm/hooks/claude_hooks/__pycache__/hook_handler.cpython-313.pyc +0 -0
  218. claude_mpm/hooks/claude_hooks/__pycache__/memory_integration.cpython-313.pyc +0 -0
  219. claude_mpm/hooks/claude_hooks/__pycache__/response_tracking.cpython-313.pyc +0 -0
  220. claude_mpm/hooks/claude_hooks/__pycache__/tool_analysis.cpython-313.pyc +0 -0
  221. claude_mpm/hooks/claude_hooks/services/__pycache__/__init__.cpython-313.pyc +0 -0
  222. claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager_http.cpython-313.pyc +0 -0
  223. claude_mpm/hooks/claude_hooks/services/__pycache__/duplicate_detector.cpython-313.pyc +0 -0
  224. claude_mpm/hooks/claude_hooks/services/__pycache__/state_manager.cpython-313.pyc +0 -0
  225. claude_mpm/hooks/claude_hooks/services/__pycache__/subagent_processor.cpython-313.pyc +0 -0
  226. claude_mpm/scripts/mcp_server.py +0 -75
  227. claude_mpm/scripts/mcp_wrapper.py +0 -39
  228. claude_mpm/services/mcp_gateway/__init__.py +0 -159
  229. claude_mpm/services/mcp_gateway/auto_configure.py +0 -369
  230. claude_mpm/services/mcp_gateway/config/__init__.py +0 -17
  231. claude_mpm/services/mcp_gateway/config/config_loader.py +0 -296
  232. claude_mpm/services/mcp_gateway/config/config_schema.py +0 -243
  233. claude_mpm/services/mcp_gateway/config/configuration.py +0 -429
  234. claude_mpm/services/mcp_gateway/core/__init__.py +0 -43
  235. claude_mpm/services/mcp_gateway/core/base.py +0 -312
  236. claude_mpm/services/mcp_gateway/core/exceptions.py +0 -253
  237. claude_mpm/services/mcp_gateway/core/interfaces.py +0 -443
  238. claude_mpm/services/mcp_gateway/core/process_pool.py +0 -977
  239. claude_mpm/services/mcp_gateway/core/singleton_manager.py +0 -315
  240. claude_mpm/services/mcp_gateway/core/startup_verification.py +0 -316
  241. claude_mpm/services/mcp_gateway/main.py +0 -589
  242. claude_mpm/services/mcp_gateway/registry/__init__.py +0 -12
  243. claude_mpm/services/mcp_gateway/registry/service_registry.py +0 -412
  244. claude_mpm/services/mcp_gateway/registry/tool_registry.py +0 -489
  245. claude_mpm/services/mcp_gateway/server/__init__.py +0 -15
  246. claude_mpm/services/mcp_gateway/server/mcp_gateway.py +0 -414
  247. claude_mpm/services/mcp_gateway/server/stdio_handler.py +0 -372
  248. claude_mpm/services/mcp_gateway/server/stdio_server.py +0 -712
  249. claude_mpm/services/mcp_gateway/tools/__init__.py +0 -36
  250. claude_mpm/services/mcp_gateway/tools/base_adapter.py +0 -485
  251. claude_mpm/services/mcp_gateway/tools/document_summarizer.py +0 -789
  252. claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +0 -654
  253. claude_mpm/services/mcp_gateway/tools/health_check_tool.py +0 -456
  254. claude_mpm/services/mcp_gateway/tools/hello_world.py +0 -551
  255. claude_mpm/services/mcp_gateway/tools/kuzu_memory_service.py +0 -555
  256. claude_mpm/services/mcp_gateway/utils/__init__.py +0 -14
  257. claude_mpm/services/mcp_gateway/utils/package_version_checker.py +0 -160
  258. claude_mpm/services/mcp_gateway/utils/update_preferences.py +0 -170
  259. claude_mpm-5.0.9.dist-info/entry_points.txt +0 -10
  260. claude_mpm-5.0.9.dist-info/licenses/LICENSE +0 -21
  261. /claude_mpm/agents/{OUTPUT_STYLE.md → CLAUDE_MPM_OUTPUT_STYLE.md} +0 -0
  262. {claude_mpm-5.0.9.dist-info → claude_mpm-5.4.41.dist-info}/WHEEL +0 -0
  263. {claude_mpm-5.0.9.dist-info → claude_mpm-5.4.41.dist-info}/top_level.txt +0 -0
@@ -10,7 +10,9 @@ from pathlib import Path
10
10
  from typing import Any, Dict, Optional
11
11
 
12
12
  __all__ = [
13
+ "build_enhanced_update_prompt",
13
14
  "build_initialization_prompt",
15
+ "build_prompt_engineer_optimization_prompt",
14
16
  "build_research_context_prompt",
15
17
  "build_update_prompt",
16
18
  ]
@@ -305,6 +307,208 @@ preserving valuable project-specific information while refreshing standard secti
305
307
  return prompt
306
308
 
307
309
 
310
+ def build_enhanced_update_prompt(
311
+ project_path: Path,
312
+ doc_analysis: Dict[str, Any],
313
+ git_insights: Dict[str, Any],
314
+ log_insights: Dict[str, Any],
315
+ memory_insights: Dict[str, Any],
316
+ project_type: Optional[str] = None,
317
+ framework: Optional[str] = None,
318
+ ast_analysis: bool = True,
319
+ preserve_custom: bool = True,
320
+ ) -> str:
321
+ """
322
+ Build enhanced update prompt with extracted knowledge from multiple sources.
323
+
324
+ This is the AUTO-DETECTED update mode that enriches CLAUDE.md with:
325
+ - Git history insights (architectural decisions, tech changes, workflows)
326
+ - Session log learnings (completed work, patterns)
327
+ - Memory file knowledge (accumulated project wisdom)
328
+
329
+ Args:
330
+ project_path: Path to the project directory
331
+ doc_analysis: Analysis results from DocumentationManager
332
+ git_insights: Extracted git history insights
333
+ log_insights: Extracted session log insights
334
+ memory_insights: Extracted memory file insights
335
+ project_type: Type of project (web, api, cli, library, etc.)
336
+ framework: Specific framework if applicable
337
+ ast_analysis: Enable AST analysis for enhanced documentation
338
+ preserve_custom: Preserve custom sections when updating
339
+
340
+ Returns:
341
+ Formatted prompt string for enhanced update mode
342
+ """
343
+ prompt = f"""Please delegate this task to the Agentic Coder Optimizer agent:
344
+
345
+ ENHANCED UPDATE of existing CLAUDE.md documentation with extracted project knowledge.
346
+
347
+ Project Path: {project_path}
348
+ Update Mode: Knowledge-enriched smart merge
349
+ """
350
+ if project_type:
351
+ prompt += f"Project Type: {project_type}\n"
352
+ if framework:
353
+ prompt += f"Framework: {framework}\n"
354
+
355
+ prompt += f"""
356
+ Existing Documentation Analysis:
357
+ - Current CLAUDE.md: {doc_analysis.get("size", 0):,} characters, {doc_analysis.get("lines", 0)} lines
358
+ - Has Priority Index: {"Yes" if doc_analysis.get("has_priority_index") else "No"}
359
+ - Custom Sections: {len(doc_analysis.get("custom_sections", []))} found
360
+ """
361
+ if preserve_custom and doc_analysis.get("custom_sections"):
362
+ prompt += f"- Preserve Custom Sections: {', '.join(doc_analysis['custom_sections'][:5])}\n"
363
+
364
+ # Add extracted knowledge sections
365
+ prompt += "\n## Extracted Project Knowledge\n\n"
366
+
367
+ # Git insights
368
+ if git_insights.get("available"):
369
+ prompt += "### From Git History (last 90 days):\n\n"
370
+
371
+ if git_insights.get("architectural_decisions"):
372
+ prompt += "**Architectural Patterns Detected:**\n"
373
+ for decision in git_insights["architectural_decisions"][:10]:
374
+ prompt += f"- {decision}\n"
375
+ prompt += "\n"
376
+
377
+ if git_insights.get("tech_stack_changes"):
378
+ prompt += "**Tech Stack Changes:**\n"
379
+ for change in git_insights["tech_stack_changes"][:10]:
380
+ prompt += f"- {change}\n"
381
+ prompt += "\n"
382
+
383
+ if git_insights.get("workflow_patterns"):
384
+ prompt += "**Common Workflows:**\n"
385
+ for workflow in git_insights["workflow_patterns"][:8]:
386
+ prompt += f"- {workflow}\n"
387
+ prompt += "\n"
388
+
389
+ if git_insights.get("hot_files"):
390
+ prompt += "**Hot Files (frequently modified):**\n"
391
+ for file_info in git_insights["hot_files"][:10]:
392
+ prompt += (
393
+ f"- {file_info['path']} ({file_info['modifications']} changes)\n"
394
+ )
395
+ prompt += "\n"
396
+
397
+ # Session log insights
398
+ if log_insights.get("available") and log_insights.get("learnings"):
399
+ prompt += "### From Session Logs:\n\n"
400
+ prompt += "**Recent Learnings from PM Summaries:**\n"
401
+ for learning in log_insights["learnings"][:10]:
402
+ source = learning.get("source", "unknown")
403
+ content = learning.get("content", "")
404
+ # Truncate long content
405
+ if len(content) > 200:
406
+ content = content[:200] + "..."
407
+ prompt += f"- [{source}] {content}\n"
408
+ prompt += "\n"
409
+
410
+ if log_insights.get("common_patterns"):
411
+ prompt += "**Common Task Patterns:**\n"
412
+ prompt += f"- {', '.join(log_insights['common_patterns'][:10])}\n\n"
413
+
414
+ # Memory insights
415
+ if memory_insights.get("available"):
416
+ has_content = False
417
+
418
+ if memory_insights.get("architectural_knowledge"):
419
+ has_content = True
420
+ prompt += "### From Agent Memories:\n\n"
421
+ prompt += "**Architectural Knowledge:**\n"
422
+ for item in memory_insights["architectural_knowledge"][:8]:
423
+ prompt += f"- {item}\n"
424
+ prompt += "\n"
425
+
426
+ if memory_insights.get("implementation_guidelines"):
427
+ if not has_content:
428
+ prompt += "### From Agent Memories:\n\n"
429
+ has_content = True
430
+ prompt += "**Implementation Guidelines:**\n"
431
+ for item in memory_insights["implementation_guidelines"][:8]:
432
+ prompt += f"- {item}\n"
433
+ prompt += "\n"
434
+
435
+ if memory_insights.get("common_mistakes"):
436
+ if not has_content:
437
+ prompt += "### From Agent Memories:\n\n"
438
+ has_content = True
439
+ prompt += "**Common Mistakes to Avoid:**\n"
440
+ for item in memory_insights["common_mistakes"][:8]:
441
+ prompt += f"- {item}\n"
442
+ prompt += "\n"
443
+
444
+ if memory_insights.get("technical_context"):
445
+ if not has_content:
446
+ prompt += "### From Agent Memories:\n\n"
447
+ prompt += "**Current Technical Context:**\n"
448
+ for item in memory_insights["technical_context"][:8]:
449
+ prompt += f"- {item}\n"
450
+ prompt += "\n"
451
+
452
+ # Add update instructions
453
+ prompt += """
454
+ ## UPDATE Tasks with Knowledge Integration:
455
+
456
+ 1. **Review Existing Content**:
457
+ - Analyze current CLAUDE.md structure and content
458
+ - Identify outdated or missing information
459
+ - Preserve valuable custom sections and project-specific knowledge
460
+
461
+ 2. **Integrate Extracted Knowledge**:
462
+ - Merge architectural decisions from git history into Architecture section
463
+ - Add tech stack changes to Technology/Dependencies sections
464
+ - Update workflow patterns in Development Guidelines
465
+ - Incorporate session learnings into relevant sections
466
+ - Merge memory insights into appropriate documentation areas
467
+ - Highlight hot files as critical components
468
+
469
+ 3. **Smart Content Merge**:
470
+ - Update project overview with recent developments
471
+ - Refresh architecture documentation with detected patterns
472
+ - Update development workflows with discovered common patterns
473
+ - Ensure single-path principle (ONE way to do each task)
474
+ - Remove duplicate or contradictory information
475
+
476
+ 4. **Update Priority Organization**:
477
+ - Reorganize content with priority markers (🔴🟡🟢⚪)
478
+ - Ensure critical instructions are at the top
479
+ - Update priority index with all important items
480
+ - Promote frequently-modified files to IMPORTANT sections
481
+
482
+ 5. **Refresh Technical Content**:
483
+ - Update build/test/deploy commands based on workflow patterns
484
+ - Verify tool configurations match tech stack changes
485
+ - Update dependency information with detected changes
486
+ - Refresh API documentation if applicable
487
+ """
488
+ if ast_analysis:
489
+ prompt += """
490
+ 6. **Update Code Documentation** (using Code Analyzer agent):
491
+ - Re-analyze code structure for changes
492
+ - Update API documentation
493
+ - Refresh architecture diagrams
494
+ - Document hot files and critical components
495
+ """
496
+ prompt += """
497
+ 7. **Final Optimization**:
498
+ - Ensure single-path principle throughout
499
+ - Validate all links and references
500
+ - Add/update timestamp in meta section
501
+ - Add "Last Updated" note mentioning knowledge extraction
502
+ - Verify AI agent readability
503
+
504
+ IMPORTANT: This is an ENHANCED UPDATE operation with extracted knowledge.
505
+ Intelligently merge insights from git history, session logs, and agent memories
506
+ into the existing CLAUDE.md while preserving valuable custom content.
507
+ The goal is to create a living document that reflects actual project evolution.
508
+ """
509
+ return prompt
510
+
511
+
308
512
  def build_research_context_prompt(git_analysis: Dict[str, Any], days: int) -> str:
309
513
  """
310
514
  Build structured Research agent delegation prompt from git analysis.
@@ -440,3 +644,79 @@ Keep it concise (<1000 words) but actionable.
440
644
  """
441
645
 
442
646
  return prompt
647
+
648
+
649
+ def build_prompt_engineer_optimization_prompt(
650
+ content: str, estimated_tokens: int
651
+ ) -> str:
652
+ """
653
+ Build prompt for prompt-engineer to optimize CLAUDE.md.
654
+
655
+ Args:
656
+ content: Current CLAUDE.md content to optimize
657
+ estimated_tokens: Estimated token count of current content
658
+
659
+ Returns:
660
+ Formatted prompt string for prompt-engineer optimization
661
+ """
662
+ return f"""Please delegate this task to the Prompt Engineer agent:
663
+
664
+ Optimize this CLAUDE.md file for conciseness, clarity, and token efficiency while preserving all critical information.
665
+
666
+ ## Current CLAUDE.md Statistics
667
+ - Estimated tokens: {estimated_tokens:,}
668
+ - Target reduction: 20-30% if possible
669
+ - Priority: Preserve ALL CRITICAL (🔴) and IMPORTANT (🟡) information
670
+
671
+ ## Optimization Goals
672
+
673
+ 1. **Remove Redundancy**:
674
+ - Eliminate duplicate information across sections
675
+ - Consolidate similar instructions
676
+ - Remove verbose explanations where brevity suffices
677
+
678
+ 2. **Tighten Language**:
679
+ - Use fewer words to convey the same meaning
680
+ - Replace wordy phrases with concise alternatives
681
+ - Remove filler words and unnecessary qualifiers
682
+
683
+ 3. **Improve Structure**:
684
+ - Ensure clear hierarchical organization
685
+ - Use priority markers (🔴 🟡 🟢 ⚪) effectively
686
+ - Group related information logically
687
+ - Maintain scannable headings
688
+
689
+ 4. **Preserve Critical Content**:
690
+ - Keep ALL security and data handling rules (🔴)
691
+ - Maintain core business logic and constraints (🔴)
692
+ - Preserve architectural decisions (🟡)
693
+ - Keep essential workflows intact (🟡)
694
+
695
+ 5. **Apply Claude Best Practices**:
696
+ - Use high-level guidance over prescriptive checklists
697
+ - Provide context for WHY, not just WHAT
698
+ - Ensure instructions are actionable and unambiguous
699
+ - Optimize for AI agent understanding
700
+
701
+ ## Current CLAUDE.md Content
702
+
703
+ {content}
704
+
705
+ ## Output Requirements
706
+
707
+ Return ONLY the optimized CLAUDE.md content with NO additional explanations.
708
+ The optimized version should:
709
+ - Reduce token count by 20-30% if feasible
710
+ - Maintain all CRITICAL and IMPORTANT instructions
711
+ - Improve clarity and scannability
712
+ - Follow the same structural template (Priority Index, sections with markers)
713
+
714
+ ## Quality Criteria
715
+
716
+ ✅ All 🔴 CRITICAL items preserved
717
+ ✅ All 🟡 IMPORTANT items preserved
718
+ ✅ No contradictory instructions
719
+ ✅ Clear, concise language throughout
720
+ ✅ Logical organization maintained
721
+ ✅ Token count reduced meaningfully
722
+ """
@@ -317,7 +317,7 @@ def _create_prs(report, verbose: bool) -> int:
317
317
  print(f"\n🤖 Creating {len(pr_actions)} PR(s) for agent improvements...")
318
318
 
319
319
  # Check if we're in the agent cache git repo
320
- agent_cache_path = Path.home() / ".claude-mpm" / "cache" / "remote-agents"
320
+ agent_cache_path = Path.home() / ".claude-mpm" / "cache" / "agents"
321
321
 
322
322
  if not agent_cache_path.exists():
323
323
  print(f"❌ Agent cache not found at: {agent_cache_path}")
@@ -0,0 +1,277 @@
1
+ """
2
+ Profile management commands for claude-mpm CLI.
3
+
4
+ WHY: Users need a simple way to manage deployment profiles from the command
5
+ line. Profiles control which agents and skills are deployed, reducing context
6
+ usage by limiting available agents to only what's needed.
7
+
8
+ DESIGN DECISIONS:
9
+ - Use BaseCommand for consistent CLI patterns
10
+ - Provide clear, actionable output with standardized error handling
11
+ - Support profile listing, activation, and status reporting
12
+ - Integrate with ConfigLoader for profile persistence
13
+ """
14
+
15
+ from pathlib import Path
16
+ from typing import Any, Dict
17
+
18
+ import yaml
19
+ from rich.console import Console
20
+ from rich.table import Table
21
+
22
+ from ...core.shared.config_loader import ConfigLoader
23
+ from ...services.profile_manager import ProfileManager
24
+ from ...utils.console import console
25
+ from ..shared import BaseCommand, CommandResult
26
+
27
+
28
+ class ProfileCommand(BaseCommand):
29
+ """Profile management command for agents and skills filtering."""
30
+
31
+ def __init__(self):
32
+ super().__init__("profile")
33
+ # ProfileManager will auto-detect project directory
34
+ self.profile_manager = ProfileManager()
35
+ self.config_loader = ConfigLoader()
36
+
37
+ def validate_args(self, args) -> str:
38
+ """Validate command arguments."""
39
+ if not hasattr(args, "profile_command") or not args.profile_command:
40
+ return "Profile command required. Use: list, set, status, or show"
41
+
42
+ valid_commands = ["list", "set", "status", "show"]
43
+ if args.profile_command not in valid_commands:
44
+ return (
45
+ f"Unknown profile command: {args.profile_command}. "
46
+ f"Valid commands: {', '.join(valid_commands)}"
47
+ )
48
+
49
+ # Validate set command has profile name
50
+ if args.profile_command == "set":
51
+ if not hasattr(args, "profile_name") or not args.profile_name:
52
+ return "Profile name required for 'set' command"
53
+
54
+ # Validate show command has profile name
55
+ if args.profile_command == "show":
56
+ if not hasattr(args, "profile_name") or not args.profile_name:
57
+ return "Profile name required for 'show' command"
58
+
59
+ return None
60
+
61
+ def run(self, args) -> CommandResult:
62
+ """Execute the profile command."""
63
+ try:
64
+ if args.profile_command == "list":
65
+ return self._list_profiles(args)
66
+ elif args.profile_command == "set":
67
+ return self._set_profile(args)
68
+ elif args.profile_command == "status":
69
+ return self._show_status(args)
70
+ elif args.profile_command == "show":
71
+ return self._show_profile(args)
72
+ else:
73
+ return CommandResult.error_result(
74
+ f"Unknown profile command: {args.profile_command}"
75
+ )
76
+ except Exception as e:
77
+ return CommandResult.error_result(f"Profile command failed: {e}")
78
+
79
+ def _list_profiles(self, args) -> CommandResult:
80
+ """List all available profiles."""
81
+ profiles = self.profile_manager.list_available_profiles()
82
+
83
+ if not profiles:
84
+ console.print("[yellow]No profiles found in .claude-mpm/profiles/[/yellow]")
85
+ return CommandResult.success_result("No profiles available")
86
+
87
+ # Load current active profile
88
+ main_config = self.config_loader.load_main_config()
89
+ active_profile = main_config.get("active_profile")
90
+
91
+ # Create table
92
+ table = Table(title="Available Deployment Profiles")
93
+ table.add_column("Profile", style="cyan", no_wrap=True)
94
+ table.add_column("Description", style="white")
95
+ table.add_column("Status", style="green")
96
+
97
+ for profile_name in profiles:
98
+ description = self.profile_manager.get_profile_description(profile_name)
99
+ status = "✓ Active" if profile_name == active_profile else ""
100
+
101
+ table.add_row(
102
+ profile_name, description or "(no description)", status or "-"
103
+ )
104
+
105
+ console.print(table)
106
+
107
+ return CommandResult.success_result(
108
+ f"Found {len(profiles)} profile(s)", {"profiles": profiles}
109
+ )
110
+
111
+ def _set_profile(self, args) -> CommandResult:
112
+ """Set active profile."""
113
+ profile_name = args.profile_name
114
+
115
+ # Validate profile exists
116
+ available_profiles = self.profile_manager.list_available_profiles()
117
+ if profile_name not in available_profiles:
118
+ return CommandResult.error_result(
119
+ f"Profile '{profile_name}' not found. "
120
+ f"Available profiles: {', '.join(available_profiles)}"
121
+ )
122
+
123
+ # Load profile to validate it
124
+ success = self.profile_manager.load_profile(profile_name)
125
+ if not success:
126
+ return CommandResult.error_result(
127
+ f"Failed to load profile '{profile_name}'"
128
+ )
129
+
130
+ # Update configuration.yaml
131
+ config_path = Path.cwd() / ".claude-mpm" / "configuration.yaml"
132
+ if not config_path.exists():
133
+ # Create configuration.yaml if it doesn't exist
134
+ config_path.parent.mkdir(parents=True, exist_ok=True)
135
+ config_data = {"active_profile": profile_name}
136
+ else:
137
+ # Load existing configuration
138
+ with config_path.open("r") as f:
139
+ config_data = yaml.safe_load(f) or {}
140
+ config_data["active_profile"] = profile_name
141
+
142
+ # Save configuration
143
+ with config_path.open("w") as f:
144
+ yaml.safe_dump(config_data, f, default_flow_style=False, sort_keys=False)
145
+
146
+ # Show summary
147
+ summary = self.profile_manager.get_filtering_summary()
148
+ console.print(f"[green]✓[/green] Active profile set to: [cyan]{profile_name}[/cyan]")
149
+ console.print(
150
+ f" Agents enabled: [cyan]{summary['enabled_agents_count']}[/cyan]"
151
+ )
152
+ console.print(
153
+ f" Skills enabled: [cyan]{summary['enabled_skills_count']}[/cyan]"
154
+ )
155
+ console.print(
156
+ f" Skill patterns disabled: [cyan]{summary['disabled_patterns_count']}[/cyan]"
157
+ )
158
+ console.print(
159
+ "\n[yellow]Note:[/yellow] Restart Claude Code or run [cyan]claude-mpm init[/cyan] "
160
+ "to apply profile filtering."
161
+ )
162
+
163
+ return CommandResult.success_result(
164
+ f"Profile '{profile_name}' activated",
165
+ {"profile": profile_name, "summary": summary},
166
+ )
167
+
168
+ def _show_status(self, args) -> CommandResult:
169
+ """Show current profile status."""
170
+ # Load current active profile
171
+ main_config = self.config_loader.load_main_config()
172
+ active_profile = main_config.get("active_profile")
173
+
174
+ if not active_profile:
175
+ console.print(
176
+ "[yellow]No active profile[/yellow] - All agents and skills enabled"
177
+ )
178
+ return CommandResult.success_result(
179
+ "No active profile", {"active_profile": None}
180
+ )
181
+
182
+ # Load profile
183
+ success = self.profile_manager.load_profile(active_profile)
184
+ if not success:
185
+ return CommandResult.error_result(
186
+ f"Failed to load active profile '{active_profile}'"
187
+ )
188
+
189
+ # Get summary
190
+ summary = self.profile_manager.get_filtering_summary()
191
+
192
+ # Display status
193
+ console.print(f"[green]Active Profile:[/green] [cyan]{active_profile}[/cyan]")
194
+ console.print()
195
+
196
+ # Agents section
197
+ console.print("[bold]Agents:[/bold]")
198
+ console.print(f" Enabled: [cyan]{summary['enabled_agents_count']}[/cyan]")
199
+ console.print(f" Disabled: [cyan]{summary['disabled_agents_count']}[/cyan]")
200
+
201
+ # Skills section
202
+ console.print()
203
+ console.print("[bold]Skills:[/bold]")
204
+ console.print(f" Enabled: [cyan]{summary['enabled_skills_count']}[/cyan]")
205
+ console.print(
206
+ f" Disabled patterns: [cyan]{summary['disabled_patterns_count']}[/cyan]"
207
+ )
208
+
209
+ return CommandResult.success_result(
210
+ f"Profile '{active_profile}' status",
211
+ {"active_profile": active_profile, "summary": summary},
212
+ )
213
+
214
+ def _show_profile(self, args) -> CommandResult:
215
+ """Show detailed profile configuration."""
216
+ profile_name = args.profile_name
217
+
218
+ # Validate profile exists
219
+ available_profiles = self.profile_manager.list_available_profiles()
220
+ if profile_name not in available_profiles:
221
+ return CommandResult.error_result(
222
+ f"Profile '{profile_name}' not found. "
223
+ f"Available profiles: {', '.join(available_profiles)}"
224
+ )
225
+
226
+ # Load profile
227
+ success = self.profile_manager.load_profile(profile_name)
228
+ if not success:
229
+ return CommandResult.error_result(
230
+ f"Failed to load profile '{profile_name}'"
231
+ )
232
+
233
+ # Display profile details
234
+ console.print(f"[bold]Profile:[/bold] [cyan]{profile_name}[/cyan]")
235
+ console.print()
236
+
237
+ # Show enabled agents
238
+ enabled_agents = self.profile_manager.get_enabled_agents()
239
+ if enabled_agents:
240
+ console.print("[bold]Enabled Agents:[/bold]")
241
+ for agent in sorted(enabled_agents):
242
+ console.print(f" • {agent}")
243
+ console.print()
244
+
245
+ # Show disabled agents
246
+ disabled_agents = self.profile_manager.get_disabled_agents()
247
+ if disabled_agents:
248
+ console.print("[bold]Disabled Agents:[/bold]")
249
+ for agent in sorted(disabled_agents):
250
+ console.print(f" • {agent}")
251
+ console.print()
252
+
253
+ # Show enabled skills
254
+ enabled_skills = self.profile_manager.get_enabled_skills()
255
+ if enabled_skills:
256
+ console.print("[bold]Enabled Skills:[/bold]")
257
+ for skill in sorted(enabled_skills):
258
+ console.print(f" • {skill}")
259
+ console.print()
260
+
261
+ # Show disabled skill patterns
262
+ disabled_patterns = self.profile_manager.get_disabled_skill_patterns()
263
+ if disabled_patterns:
264
+ console.print("[bold]Disabled Skill Patterns:[/bold]")
265
+ for pattern in disabled_patterns:
266
+ console.print(f" • {pattern}")
267
+
268
+ return CommandResult.success_result(
269
+ f"Profile '{profile_name}' details",
270
+ {
271
+ "profile": profile_name,
272
+ "enabled_agents": list(enabled_agents),
273
+ "disabled_agents": list(disabled_agents),
274
+ "enabled_skills": list(enabled_skills),
275
+ "disabled_patterns": disabled_patterns,
276
+ },
277
+ )