claude-mpm 3.9.11__py3-none-any.whl → 4.0.3__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 (419) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/__init__.py +2 -2
  3. claude_mpm/__main__.py +3 -2
  4. claude_mpm/agents/__init__.py +85 -79
  5. claude_mpm/agents/agent_loader.py +464 -1003
  6. claude_mpm/agents/agent_loader_integration.py +45 -45
  7. claude_mpm/agents/agents_metadata.py +29 -30
  8. claude_mpm/agents/async_agent_loader.py +156 -138
  9. claude_mpm/agents/base_agent.json +1 -1
  10. claude_mpm/agents/base_agent_loader.py +179 -151
  11. claude_mpm/agents/frontmatter_validator.py +229 -130
  12. claude_mpm/agents/schema/agent_schema.json +1 -1
  13. claude_mpm/agents/system_agent_config.py +213 -147
  14. claude_mpm/agents/templates/__init__.py +13 -13
  15. claude_mpm/agents/templates/code_analyzer.json +2 -2
  16. claude_mpm/agents/templates/data_engineer.json +1 -1
  17. claude_mpm/agents/templates/documentation.json +23 -11
  18. claude_mpm/agents/templates/engineer.json +22 -6
  19. claude_mpm/agents/templates/memory_manager.json +1 -1
  20. claude_mpm/agents/templates/ops.json +2 -2
  21. claude_mpm/agents/templates/project_organizer.json +1 -1
  22. claude_mpm/agents/templates/qa.json +1 -1
  23. claude_mpm/agents/templates/refactoring_engineer.json +222 -0
  24. claude_mpm/agents/templates/research.json +20 -14
  25. claude_mpm/agents/templates/security.json +1 -1
  26. claude_mpm/agents/templates/ticketing.json +1 -1
  27. claude_mpm/agents/templates/version_control.json +1 -1
  28. claude_mpm/agents/templates/web_qa.json +3 -1
  29. claude_mpm/agents/templates/web_ui.json +2 -2
  30. claude_mpm/cli/__init__.py +79 -51
  31. claude_mpm/cli/__main__.py +3 -2
  32. claude_mpm/cli/commands/__init__.py +20 -20
  33. claude_mpm/cli/commands/agents.py +279 -247
  34. claude_mpm/cli/commands/aggregate.py +138 -157
  35. claude_mpm/cli/commands/cleanup.py +147 -147
  36. claude_mpm/cli/commands/config.py +93 -76
  37. claude_mpm/cli/commands/info.py +17 -16
  38. claude_mpm/cli/commands/mcp.py +140 -905
  39. claude_mpm/cli/commands/mcp_command_router.py +139 -0
  40. claude_mpm/cli/commands/mcp_config_commands.py +20 -0
  41. claude_mpm/cli/commands/mcp_install_commands.py +20 -0
  42. claude_mpm/cli/commands/mcp_server_commands.py +175 -0
  43. claude_mpm/cli/commands/mcp_tool_commands.py +34 -0
  44. claude_mpm/cli/commands/memory.py +239 -203
  45. claude_mpm/cli/commands/monitor.py +203 -81
  46. claude_mpm/cli/commands/run.py +380 -429
  47. claude_mpm/cli/commands/run_config_checker.py +160 -0
  48. claude_mpm/cli/commands/socketio_monitor.py +235 -0
  49. claude_mpm/cli/commands/tickets.py +305 -197
  50. claude_mpm/cli/parser.py +24 -1156
  51. claude_mpm/cli/parsers/__init__.py +29 -0
  52. claude_mpm/cli/parsers/agents_parser.py +136 -0
  53. claude_mpm/cli/parsers/base_parser.py +331 -0
  54. claude_mpm/cli/parsers/config_parser.py +85 -0
  55. claude_mpm/cli/parsers/mcp_parser.py +152 -0
  56. claude_mpm/cli/parsers/memory_parser.py +138 -0
  57. claude_mpm/cli/parsers/monitor_parser.py +104 -0
  58. claude_mpm/cli/parsers/run_parser.py +147 -0
  59. claude_mpm/cli/parsers/tickets_parser.py +203 -0
  60. claude_mpm/cli/ticket_cli.py +7 -3
  61. claude_mpm/cli/utils.py +55 -37
  62. claude_mpm/cli_module/__init__.py +6 -6
  63. claude_mpm/cli_module/args.py +188 -140
  64. claude_mpm/cli_module/commands.py +79 -70
  65. claude_mpm/cli_module/migration_example.py +38 -60
  66. claude_mpm/config/__init__.py +32 -25
  67. claude_mpm/config/agent_config.py +151 -119
  68. claude_mpm/config/experimental_features.py +71 -73
  69. claude_mpm/config/paths.py +94 -208
  70. claude_mpm/config/socketio_config.py +84 -73
  71. claude_mpm/constants.py +35 -18
  72. claude_mpm/core/__init__.py +9 -6
  73. claude_mpm/core/agent_name_normalizer.py +68 -71
  74. claude_mpm/core/agent_registry.py +372 -521
  75. claude_mpm/core/agent_session_manager.py +74 -63
  76. claude_mpm/core/base_service.py +116 -87
  77. claude_mpm/core/cache.py +119 -153
  78. claude_mpm/core/claude_runner.py +425 -1120
  79. claude_mpm/core/config.py +263 -168
  80. claude_mpm/core/config_aliases.py +69 -61
  81. claude_mpm/core/config_constants.py +292 -0
  82. claude_mpm/core/constants.py +57 -99
  83. claude_mpm/core/container.py +211 -178
  84. claude_mpm/core/exceptions.py +233 -89
  85. claude_mpm/core/factories.py +92 -54
  86. claude_mpm/core/framework_loader.py +378 -220
  87. claude_mpm/core/hook_manager.py +198 -83
  88. claude_mpm/core/hook_performance_config.py +136 -0
  89. claude_mpm/core/injectable_service.py +61 -55
  90. claude_mpm/core/interactive_session.py +165 -155
  91. claude_mpm/core/interfaces.py +221 -195
  92. claude_mpm/core/lazy.py +96 -96
  93. claude_mpm/core/logger.py +133 -107
  94. claude_mpm/core/logging_config.py +185 -157
  95. claude_mpm/core/minimal_framework_loader.py +20 -15
  96. claude_mpm/core/mixins.py +30 -29
  97. claude_mpm/core/oneshot_session.py +215 -181
  98. claude_mpm/core/optimized_agent_loader.py +134 -138
  99. claude_mpm/core/optimized_startup.py +159 -157
  100. claude_mpm/core/pm_hook_interceptor.py +85 -72
  101. claude_mpm/core/service_registry.py +103 -101
  102. claude_mpm/core/session_manager.py +97 -87
  103. claude_mpm/core/socketio_pool.py +212 -158
  104. claude_mpm/core/tool_access_control.py +58 -51
  105. claude_mpm/core/types.py +46 -24
  106. claude_mpm/core/typing_utils.py +166 -82
  107. claude_mpm/core/unified_agent_registry.py +721 -0
  108. claude_mpm/core/unified_config.py +550 -0
  109. claude_mpm/core/unified_paths.py +549 -0
  110. claude_mpm/dashboard/index.html +1 -1
  111. claude_mpm/dashboard/open_dashboard.py +51 -17
  112. claude_mpm/dashboard/static/css/dashboard.css +27 -8
  113. claude_mpm/dashboard/static/dist/components/agent-inference.js +2 -0
  114. claude_mpm/dashboard/static/dist/components/event-processor.js +2 -0
  115. claude_mpm/dashboard/static/dist/components/event-viewer.js +2 -0
  116. claude_mpm/dashboard/static/dist/components/export-manager.js +2 -0
  117. claude_mpm/dashboard/static/dist/components/file-tool-tracker.js +2 -0
  118. claude_mpm/dashboard/static/dist/components/hud-library-loader.js +2 -0
  119. claude_mpm/dashboard/static/dist/components/hud-manager.js +2 -0
  120. claude_mpm/dashboard/static/dist/components/hud-visualizer.js +2 -0
  121. claude_mpm/dashboard/static/dist/components/module-viewer.js +2 -0
  122. claude_mpm/dashboard/static/dist/components/session-manager.js +2 -0
  123. claude_mpm/dashboard/static/dist/components/socket-manager.js +2 -0
  124. claude_mpm/dashboard/static/dist/components/ui-state-manager.js +2 -0
  125. claude_mpm/dashboard/static/dist/components/working-directory.js +2 -0
  126. claude_mpm/dashboard/static/dist/dashboard.js +2 -0
  127. claude_mpm/dashboard/static/dist/socket-client.js +2 -0
  128. claude_mpm/dashboard/static/js/components/agent-inference.js +80 -76
  129. claude_mpm/dashboard/static/js/components/event-processor.js +71 -67
  130. claude_mpm/dashboard/static/js/components/event-viewer.js +74 -70
  131. claude_mpm/dashboard/static/js/components/export-manager.js +31 -28
  132. claude_mpm/dashboard/static/js/components/file-tool-tracker.js +106 -92
  133. claude_mpm/dashboard/static/js/components/hud-library-loader.js +11 -11
  134. claude_mpm/dashboard/static/js/components/hud-manager.js +73 -73
  135. claude_mpm/dashboard/static/js/components/hud-visualizer.js +163 -163
  136. claude_mpm/dashboard/static/js/components/module-viewer.js +305 -233
  137. claude_mpm/dashboard/static/js/components/session-manager.js +32 -29
  138. claude_mpm/dashboard/static/js/components/socket-manager.js +27 -20
  139. claude_mpm/dashboard/static/js/components/ui-state-manager.js +21 -18
  140. claude_mpm/dashboard/static/js/components/working-directory.js +74 -71
  141. claude_mpm/dashboard/static/js/dashboard.js +178 -453
  142. claude_mpm/dashboard/static/js/extension-error-handler.js +164 -0
  143. claude_mpm/dashboard/static/js/socket-client.js +120 -54
  144. claude_mpm/dashboard/templates/index.html +40 -50
  145. claude_mpm/experimental/cli_enhancements.py +60 -58
  146. claude_mpm/generators/__init__.py +1 -1
  147. claude_mpm/generators/agent_profile_generator.py +75 -65
  148. claude_mpm/hooks/__init__.py +1 -1
  149. claude_mpm/hooks/base_hook.py +33 -28
  150. claude_mpm/hooks/claude_hooks/__init__.py +1 -1
  151. claude_mpm/hooks/claude_hooks/connection_pool.py +120 -0
  152. claude_mpm/hooks/claude_hooks/event_handlers.py +743 -0
  153. claude_mpm/hooks/claude_hooks/hook_handler.py +415 -1331
  154. claude_mpm/hooks/claude_hooks/hook_wrapper.sh +4 -4
  155. claude_mpm/hooks/claude_hooks/memory_integration.py +221 -0
  156. claude_mpm/hooks/claude_hooks/response_tracking.py +348 -0
  157. claude_mpm/hooks/claude_hooks/tool_analysis.py +230 -0
  158. claude_mpm/hooks/memory_integration_hook.py +140 -100
  159. claude_mpm/hooks/tool_call_interceptor.py +89 -76
  160. claude_mpm/hooks/validation_hooks.py +57 -49
  161. claude_mpm/init.py +145 -121
  162. claude_mpm/models/__init__.py +9 -9
  163. claude_mpm/models/agent_definition.py +33 -23
  164. claude_mpm/models/agent_session.py +228 -200
  165. claude_mpm/scripts/__init__.py +1 -1
  166. claude_mpm/scripts/socketio_daemon.py +192 -75
  167. claude_mpm/scripts/socketio_server_manager.py +328 -0
  168. claude_mpm/scripts/start_activity_logging.py +25 -22
  169. claude_mpm/services/__init__.py +68 -43
  170. claude_mpm/services/agent_capabilities_service.py +271 -0
  171. claude_mpm/services/agents/__init__.py +23 -32
  172. claude_mpm/services/agents/deployment/__init__.py +3 -3
  173. claude_mpm/services/agents/deployment/agent_config_provider.py +310 -0
  174. claude_mpm/services/agents/deployment/agent_configuration_manager.py +359 -0
  175. claude_mpm/services/agents/deployment/agent_definition_factory.py +84 -0
  176. claude_mpm/services/agents/deployment/agent_deployment.py +415 -2113
  177. claude_mpm/services/agents/deployment/agent_discovery_service.py +387 -0
  178. claude_mpm/services/agents/deployment/agent_environment_manager.py +293 -0
  179. claude_mpm/services/agents/deployment/agent_filesystem_manager.py +387 -0
  180. claude_mpm/services/agents/deployment/agent_format_converter.py +453 -0
  181. claude_mpm/services/agents/deployment/agent_frontmatter_validator.py +161 -0
  182. claude_mpm/services/agents/deployment/agent_lifecycle_manager.py +345 -495
  183. claude_mpm/services/agents/deployment/agent_metrics_collector.py +279 -0
  184. claude_mpm/services/agents/deployment/agent_restore_handler.py +88 -0
  185. claude_mpm/services/agents/deployment/agent_template_builder.py +406 -0
  186. claude_mpm/services/agents/deployment/agent_validator.py +352 -0
  187. claude_mpm/services/agents/deployment/agent_version_manager.py +313 -0
  188. claude_mpm/services/agents/deployment/agent_versioning.py +6 -9
  189. claude_mpm/services/agents/deployment/agents_directory_resolver.py +79 -0
  190. claude_mpm/services/agents/deployment/async_agent_deployment.py +298 -234
  191. claude_mpm/services/agents/deployment/config/__init__.py +13 -0
  192. claude_mpm/services/agents/deployment/config/deployment_config.py +182 -0
  193. claude_mpm/services/agents/deployment/config/deployment_config_manager.py +200 -0
  194. claude_mpm/services/agents/deployment/deployment_config_loader.py +54 -0
  195. claude_mpm/services/agents/deployment/deployment_type_detector.py +124 -0
  196. claude_mpm/services/agents/deployment/facade/__init__.py +18 -0
  197. claude_mpm/services/agents/deployment/facade/async_deployment_executor.py +159 -0
  198. claude_mpm/services/agents/deployment/facade/deployment_executor.py +73 -0
  199. claude_mpm/services/agents/deployment/facade/deployment_facade.py +270 -0
  200. claude_mpm/services/agents/deployment/facade/sync_deployment_executor.py +178 -0
  201. claude_mpm/services/agents/deployment/interface_adapter.py +227 -0
  202. claude_mpm/services/agents/deployment/lifecycle_health_checker.py +85 -0
  203. claude_mpm/services/agents/deployment/lifecycle_performance_tracker.py +100 -0
  204. claude_mpm/services/agents/deployment/pipeline/__init__.py +32 -0
  205. claude_mpm/services/agents/deployment/pipeline/pipeline_builder.py +158 -0
  206. claude_mpm/services/agents/deployment/pipeline/pipeline_context.py +159 -0
  207. claude_mpm/services/agents/deployment/pipeline/pipeline_executor.py +169 -0
  208. claude_mpm/services/agents/deployment/pipeline/steps/__init__.py +19 -0
  209. claude_mpm/services/agents/deployment/pipeline/steps/agent_processing_step.py +195 -0
  210. claude_mpm/services/agents/deployment/pipeline/steps/base_step.py +119 -0
  211. claude_mpm/services/agents/deployment/pipeline/steps/configuration_step.py +79 -0
  212. claude_mpm/services/agents/deployment/pipeline/steps/target_directory_step.py +90 -0
  213. claude_mpm/services/agents/deployment/pipeline/steps/validation_step.py +100 -0
  214. claude_mpm/services/agents/deployment/processors/__init__.py +15 -0
  215. claude_mpm/services/agents/deployment/processors/agent_deployment_context.py +98 -0
  216. claude_mpm/services/agents/deployment/processors/agent_deployment_result.py +235 -0
  217. claude_mpm/services/agents/deployment/processors/agent_processor.py +258 -0
  218. claude_mpm/services/agents/deployment/refactored_agent_deployment_service.py +318 -0
  219. claude_mpm/services/agents/deployment/results/__init__.py +13 -0
  220. claude_mpm/services/agents/deployment/results/deployment_metrics.py +200 -0
  221. claude_mpm/services/agents/deployment/results/deployment_result_builder.py +249 -0
  222. claude_mpm/services/agents/deployment/strategies/__init__.py +25 -0
  223. claude_mpm/services/agents/deployment/strategies/base_strategy.py +119 -0
  224. claude_mpm/services/agents/deployment/strategies/project_strategy.py +150 -0
  225. claude_mpm/services/agents/deployment/strategies/strategy_selector.py +117 -0
  226. claude_mpm/services/agents/deployment/strategies/system_strategy.py +116 -0
  227. claude_mpm/services/agents/deployment/strategies/user_strategy.py +137 -0
  228. claude_mpm/services/agents/deployment/system_instructions_deployer.py +108 -0
  229. claude_mpm/services/agents/deployment/validation/__init__.py +19 -0
  230. claude_mpm/services/agents/deployment/validation/agent_validator.py +323 -0
  231. claude_mpm/services/agents/deployment/validation/deployment_validator.py +238 -0
  232. claude_mpm/services/agents/deployment/validation/template_validator.py +299 -0
  233. claude_mpm/services/agents/deployment/validation/validation_result.py +226 -0
  234. claude_mpm/services/agents/loading/__init__.py +2 -2
  235. claude_mpm/services/agents/loading/agent_profile_loader.py +259 -229
  236. claude_mpm/services/agents/loading/base_agent_manager.py +90 -81
  237. claude_mpm/services/agents/loading/framework_agent_loader.py +154 -129
  238. claude_mpm/services/agents/management/__init__.py +2 -2
  239. claude_mpm/services/agents/management/agent_capabilities_generator.py +72 -58
  240. claude_mpm/services/agents/management/agent_management_service.py +209 -156
  241. claude_mpm/services/agents/memory/__init__.py +9 -6
  242. claude_mpm/services/agents/memory/agent_memory_manager.py +218 -1152
  243. claude_mpm/services/agents/memory/agent_persistence_service.py +20 -16
  244. claude_mpm/services/agents/memory/analyzer.py +430 -0
  245. claude_mpm/services/agents/memory/content_manager.py +376 -0
  246. claude_mpm/services/agents/memory/template_generator.py +468 -0
  247. claude_mpm/services/agents/registry/__init__.py +7 -10
  248. claude_mpm/services/agents/registry/deployed_agent_discovery.py +122 -97
  249. claude_mpm/services/agents/registry/modification_tracker.py +351 -285
  250. claude_mpm/services/async_session_logger.py +187 -153
  251. claude_mpm/services/claude_session_logger.py +87 -72
  252. claude_mpm/services/command_handler_service.py +217 -0
  253. claude_mpm/services/communication/__init__.py +3 -2
  254. claude_mpm/services/core/__init__.py +50 -97
  255. claude_mpm/services/core/base.py +60 -53
  256. claude_mpm/services/core/interfaces/__init__.py +188 -0
  257. claude_mpm/services/core/interfaces/agent.py +351 -0
  258. claude_mpm/services/core/interfaces/communication.py +343 -0
  259. claude_mpm/services/core/interfaces/infrastructure.py +413 -0
  260. claude_mpm/services/core/interfaces/service.py +434 -0
  261. claude_mpm/services/core/interfaces.py +19 -944
  262. claude_mpm/services/event_aggregator.py +208 -170
  263. claude_mpm/services/exceptions.py +387 -308
  264. claude_mpm/services/framework_claude_md_generator/__init__.py +75 -79
  265. claude_mpm/services/framework_claude_md_generator/content_assembler.py +69 -60
  266. claude_mpm/services/framework_claude_md_generator/content_validator.py +65 -61
  267. claude_mpm/services/framework_claude_md_generator/deployment_manager.py +68 -49
  268. claude_mpm/services/framework_claude_md_generator/section_generators/__init__.py +34 -34
  269. claude_mpm/services/framework_claude_md_generator/section_generators/agents.py +25 -22
  270. claude_mpm/services/framework_claude_md_generator/section_generators/claude_pm_init.py +10 -10
  271. claude_mpm/services/framework_claude_md_generator/section_generators/core_responsibilities.py +4 -3
  272. claude_mpm/services/framework_claude_md_generator/section_generators/delegation_constraints.py +4 -3
  273. claude_mpm/services/framework_claude_md_generator/section_generators/environment_config.py +4 -3
  274. claude_mpm/services/framework_claude_md_generator/section_generators/footer.py +6 -5
  275. claude_mpm/services/framework_claude_md_generator/section_generators/header.py +8 -7
  276. claude_mpm/services/framework_claude_md_generator/section_generators/orchestration_principles.py +4 -3
  277. claude_mpm/services/framework_claude_md_generator/section_generators/role_designation.py +6 -5
  278. claude_mpm/services/framework_claude_md_generator/section_generators/subprocess_validation.py +9 -8
  279. claude_mpm/services/framework_claude_md_generator/section_generators/todo_task_tools.py +4 -3
  280. claude_mpm/services/framework_claude_md_generator/section_generators/troubleshooting.py +5 -4
  281. claude_mpm/services/framework_claude_md_generator/section_manager.py +28 -27
  282. claude_mpm/services/framework_claude_md_generator/version_manager.py +30 -28
  283. claude_mpm/services/hook_service.py +106 -114
  284. claude_mpm/services/infrastructure/__init__.py +7 -5
  285. claude_mpm/services/infrastructure/context_preservation.py +233 -199
  286. claude_mpm/services/infrastructure/daemon_manager.py +279 -0
  287. claude_mpm/services/infrastructure/logging.py +83 -76
  288. claude_mpm/services/infrastructure/monitoring.py +547 -404
  289. claude_mpm/services/mcp_gateway/__init__.py +30 -13
  290. claude_mpm/services/mcp_gateway/config/__init__.py +2 -2
  291. claude_mpm/services/mcp_gateway/config/config_loader.py +61 -56
  292. claude_mpm/services/mcp_gateway/config/config_schema.py +50 -41
  293. claude_mpm/services/mcp_gateway/config/configuration.py +82 -75
  294. claude_mpm/services/mcp_gateway/core/__init__.py +13 -20
  295. claude_mpm/services/mcp_gateway/core/base.py +80 -67
  296. claude_mpm/services/mcp_gateway/core/exceptions.py +60 -46
  297. claude_mpm/services/mcp_gateway/core/interfaces.py +87 -84
  298. claude_mpm/services/mcp_gateway/main.py +287 -137
  299. claude_mpm/services/mcp_gateway/registry/__init__.py +1 -1
  300. claude_mpm/services/mcp_gateway/registry/service_registry.py +97 -94
  301. claude_mpm/services/mcp_gateway/registry/tool_registry.py +135 -126
  302. claude_mpm/services/mcp_gateway/server/__init__.py +2 -2
  303. claude_mpm/services/mcp_gateway/server/mcp_gateway.py +105 -110
  304. claude_mpm/services/mcp_gateway/server/stdio_handler.py +105 -107
  305. claude_mpm/services/mcp_gateway/server/stdio_server.py +691 -0
  306. claude_mpm/services/mcp_gateway/tools/__init__.py +4 -2
  307. claude_mpm/services/mcp_gateway/tools/base_adapter.py +109 -119
  308. claude_mpm/services/mcp_gateway/tools/document_summarizer.py +283 -215
  309. claude_mpm/services/mcp_gateway/tools/hello_world.py +122 -120
  310. claude_mpm/services/mcp_gateway/tools/ticket_tools.py +652 -0
  311. claude_mpm/services/mcp_gateway/tools/unified_ticket_tool.py +606 -0
  312. claude_mpm/services/memory/__init__.py +2 -2
  313. claude_mpm/services/memory/builder.py +451 -362
  314. claude_mpm/services/memory/cache/__init__.py +2 -2
  315. claude_mpm/services/memory/cache/shared_prompt_cache.py +232 -194
  316. claude_mpm/services/memory/cache/simple_cache.py +107 -93
  317. claude_mpm/services/memory/indexed_memory.py +195 -193
  318. claude_mpm/services/memory/optimizer.py +267 -234
  319. claude_mpm/services/memory/router.py +571 -263
  320. claude_mpm/services/memory_hook_service.py +237 -0
  321. claude_mpm/services/port_manager.py +223 -0
  322. claude_mpm/services/project/__init__.py +3 -3
  323. claude_mpm/services/project/analyzer.py +451 -305
  324. claude_mpm/services/project/registry.py +262 -240
  325. claude_mpm/services/recovery_manager.py +287 -231
  326. claude_mpm/services/response_tracker.py +87 -67
  327. claude_mpm/services/runner_configuration_service.py +587 -0
  328. claude_mpm/services/session_management_service.py +304 -0
  329. claude_mpm/services/socketio/__init__.py +4 -4
  330. claude_mpm/services/socketio/client_proxy.py +174 -0
  331. claude_mpm/services/socketio/handlers/__init__.py +3 -3
  332. claude_mpm/services/socketio/handlers/base.py +44 -30
  333. claude_mpm/services/socketio/handlers/connection.py +145 -65
  334. claude_mpm/services/socketio/handlers/file.py +123 -108
  335. claude_mpm/services/socketio/handlers/git.py +607 -373
  336. claude_mpm/services/socketio/handlers/hook.py +170 -0
  337. claude_mpm/services/socketio/handlers/memory.py +4 -4
  338. claude_mpm/services/socketio/handlers/project.py +4 -4
  339. claude_mpm/services/socketio/handlers/registry.py +53 -38
  340. claude_mpm/services/socketio/server/__init__.py +18 -0
  341. claude_mpm/services/socketio/server/broadcaster.py +252 -0
  342. claude_mpm/services/socketio/server/core.py +399 -0
  343. claude_mpm/services/socketio/server/main.py +323 -0
  344. claude_mpm/services/socketio_client_manager.py +160 -133
  345. claude_mpm/services/socketio_server.py +36 -1885
  346. claude_mpm/services/subprocess_launcher_service.py +316 -0
  347. claude_mpm/services/system_instructions_service.py +258 -0
  348. claude_mpm/services/ticket_manager.py +19 -533
  349. claude_mpm/services/utility_service.py +285 -0
  350. claude_mpm/services/version_control/__init__.py +18 -21
  351. claude_mpm/services/version_control/branch_strategy.py +20 -10
  352. claude_mpm/services/version_control/conflict_resolution.py +37 -13
  353. claude_mpm/services/version_control/git_operations.py +52 -21
  354. claude_mpm/services/version_control/semantic_versioning.py +92 -53
  355. claude_mpm/services/version_control/version_parser.py +145 -125
  356. claude_mpm/services/version_service.py +270 -0
  357. claude_mpm/storage/__init__.py +2 -2
  358. claude_mpm/storage/state_storage.py +177 -181
  359. claude_mpm/ticket_wrapper.py +2 -2
  360. claude_mpm/utils/__init__.py +2 -2
  361. claude_mpm/utils/agent_dependency_loader.py +453 -243
  362. claude_mpm/utils/config_manager.py +157 -118
  363. claude_mpm/utils/console.py +1 -1
  364. claude_mpm/utils/dependency_cache.py +102 -107
  365. claude_mpm/utils/dependency_manager.py +52 -47
  366. claude_mpm/utils/dependency_strategies.py +131 -96
  367. claude_mpm/utils/environment_context.py +110 -102
  368. claude_mpm/utils/error_handler.py +75 -55
  369. claude_mpm/utils/file_utils.py +80 -67
  370. claude_mpm/utils/framework_detection.py +12 -11
  371. claude_mpm/utils/import_migration_example.py +12 -60
  372. claude_mpm/utils/imports.py +48 -45
  373. claude_mpm/utils/path_operations.py +100 -93
  374. claude_mpm/utils/robust_installer.py +172 -164
  375. claude_mpm/utils/session_logging.py +30 -23
  376. claude_mpm/utils/subprocess_utils.py +99 -61
  377. claude_mpm/validation/__init__.py +1 -1
  378. claude_mpm/validation/agent_validator.py +151 -111
  379. claude_mpm/validation/frontmatter_validator.py +92 -71
  380. {claude_mpm-3.9.11.dist-info → claude_mpm-4.0.3.dist-info}/METADATA +27 -1
  381. claude_mpm-4.0.3.dist-info/RECORD +402 -0
  382. {claude_mpm-3.9.11.dist-info → claude_mpm-4.0.3.dist-info}/entry_points.txt +1 -0
  383. {claude_mpm-3.9.11.dist-info → claude_mpm-4.0.3.dist-info}/licenses/LICENSE +1 -1
  384. claude_mpm/cli/commands/run_guarded.py +0 -511
  385. claude_mpm/config/memory_guardian_config.py +0 -325
  386. claude_mpm/config/memory_guardian_yaml.py +0 -335
  387. claude_mpm/core/config_paths.py +0 -150
  388. claude_mpm/core/memory_aware_runner.py +0 -353
  389. claude_mpm/dashboard/static/js/dashboard-original.js +0 -4134
  390. claude_mpm/deployment_paths.py +0 -261
  391. claude_mpm/hooks/claude_hooks/hook_handler_fixed.py +0 -454
  392. claude_mpm/models/state_models.py +0 -433
  393. claude_mpm/services/agent/__init__.py +0 -24
  394. claude_mpm/services/agent/deployment.py +0 -2548
  395. claude_mpm/services/agent/management.py +0 -598
  396. claude_mpm/services/agent/registry.py +0 -813
  397. claude_mpm/services/agents/registry/agent_registry.py +0 -813
  398. claude_mpm/services/communication/socketio.py +0 -1935
  399. claude_mpm/services/communication/websocket.py +0 -479
  400. claude_mpm/services/framework_claude_md_generator.py +0 -624
  401. claude_mpm/services/health_monitor.py +0 -893
  402. claude_mpm/services/infrastructure/graceful_degradation.py +0 -616
  403. claude_mpm/services/infrastructure/health_monitor.py +0 -775
  404. claude_mpm/services/infrastructure/memory_dashboard.py +0 -479
  405. claude_mpm/services/infrastructure/memory_guardian.py +0 -944
  406. claude_mpm/services/infrastructure/restart_protection.py +0 -642
  407. claude_mpm/services/infrastructure/state_manager.py +0 -774
  408. claude_mpm/services/mcp_gateway/manager.py +0 -334
  409. claude_mpm/services/optimized_hook_service.py +0 -542
  410. claude_mpm/services/project_analyzer.py +0 -864
  411. claude_mpm/services/project_registry.py +0 -608
  412. claude_mpm/services/standalone_socketio_server.py +0 -1300
  413. claude_mpm/services/ticket_manager_di.py +0 -318
  414. claude_mpm/services/ticketing_service_original.py +0 -510
  415. claude_mpm/utils/paths.py +0 -395
  416. claude_mpm/utils/platform_memory.py +0 -524
  417. claude_mpm-3.9.11.dist-info/RECORD +0 -306
  418. {claude_mpm-3.9.11.dist-info → claude_mpm-4.0.3.dist-info}/WHEEL +0 -0
  419. {claude_mpm-3.9.11.dist-info → claude_mpm-4.0.3.dist-info}/top_level.txt +0 -0
@@ -1,11 +1,10 @@
1
1
  """
2
2
  Consolidated Agent Registry for Claude MPM.
3
3
 
4
- This module combines functionality from:
5
- - agent_registry.py (current working implementation)
6
- - agent_registry_original.py (legacy convenience functions)
4
+ This module provides the primary interface for agent discovery and management.
5
+ All functionality has been consolidated into the unified agent registry system.
7
6
 
8
- Provides:
7
+ This module provides:
9
8
  - Agent discovery from the framework
10
9
  - Agent listing and selection
11
10
  - Compatibility with both sync and async interfaces
@@ -14,11 +13,25 @@ Provides:
14
13
 
15
14
  import os
16
15
  import sys
17
- from pathlib import Path
18
- from typing import Optional, Dict, Any, List, Set
19
- import importlib.util
20
- from datetime import datetime
21
16
  from dataclasses import dataclass
17
+ from datetime import datetime
18
+ from pathlib import Path
19
+ from typing import Any, Dict, List, Optional, Set
20
+
21
+ # Import from the unified agent registry system
22
+ from .unified_agent_registry import AgentMetadata as UnifiedAgentMetadata
23
+ from .unified_agent_registry import AgentTier, AgentType
24
+ from .unified_agent_registry import discover_agents as unified_discover_agents
25
+ from .unified_agent_registry import get_agent as unified_get_agent
26
+ from .unified_agent_registry import get_agent_names as unified_get_agent_names
27
+ from .unified_agent_registry import get_agent_registry
28
+ from .unified_agent_registry import get_core_agents as unified_get_core_agents
29
+ from .unified_agent_registry import get_project_agents as unified_get_project_agents
30
+ from .unified_agent_registry import get_registry_stats as unified_get_registry_stats
31
+ from .unified_agent_registry import (
32
+ get_specialized_agents as unified_get_specialized_agents,
33
+ )
34
+ from .unified_agent_registry import list_agents as unified_list_agents
22
35
 
23
36
  try:
24
37
  from ..core.logger import get_logger
@@ -26,9 +39,19 @@ except ImportError:
26
39
  from core.logger import get_logger
27
40
 
28
41
 
42
+ # ============================================================================
43
+ # Compatibility Classes - Delegate to Unified Agent Registry
44
+ # ============================================================================
45
+
46
+
29
47
  @dataclass
30
48
  class AgentMetadata:
31
- """Metadata for an agent."""
49
+ """
50
+ COMPATIBILITY WRAPPER for agent metadata.
51
+
52
+ This class now delegates to the UnifiedAgentRegistry system.
53
+ """
54
+
32
55
  name: str
33
56
  type: str
34
57
  path: str
@@ -36,454 +59,331 @@ class AgentMetadata:
36
59
  last_modified: float = 0.0
37
60
  specializations: List[str] = None
38
61
  description: str = ""
39
-
62
+
40
63
  def __post_init__(self):
41
64
  if self.specializations is None:
42
65
  self.specializations = []
43
66
 
67
+ @classmethod
68
+ def from_unified(cls, unified_metadata: UnifiedAgentMetadata) -> "AgentMetadata":
69
+ """Create compatibility metadata from unified metadata."""
70
+ return cls(
71
+ name=unified_metadata.name,
72
+ type=unified_metadata.agent_type.value,
73
+ path=unified_metadata.path,
74
+ tier=unified_metadata.tier.value,
75
+ last_modified=unified_metadata.last_modified,
76
+ specializations=unified_metadata.specializations,
77
+ description=unified_metadata.description,
78
+ )
79
+
44
80
 
45
81
  class SimpleAgentRegistry:
46
- """Simple agent registry implementation."""
47
-
48
- def __init__(self, framework_path: Path):
82
+ """
83
+ COMPATIBILITY WRAPPER for simple agent registry.
84
+
85
+ This class now delegates to the UnifiedAgentRegistry system.
86
+ """
87
+
88
+ def __init__(self, framework_path: Optional[Path] = None):
89
+ """Initialize with optional framework path (ignored in new implementation)."""
49
90
  self.framework_path = framework_path
91
+ self._unified_registry = get_agent_registry()
50
92
  self.agents = {}
51
93
  self._discover_agents()
52
-
94
+
53
95
  def _discover_agents(self):
54
- """Discover agents from the framework and project."""
55
- # Check multiple possible locations, including project-level
56
- agent_locations = [
57
- # Project-level agents (highest priority)
58
- # Project-level deployed agents (highest priority - what Claude Code uses)
59
- Path.cwd() / ".claude" / "agents",
60
- # Project-level source agents (fallback)
61
- Path.cwd() / ".claude-mpm" / "agents",
62
- # Framework/system agents
63
- self.framework_path / "src" / "claude_mpm" / "agents" / "templates",
64
- self.framework_path / "src" / "claude_mpm" / "agents",
65
- self.framework_path / "agents",
66
- ]
67
-
68
- # Track discovered agents to handle precedence
69
- discovered_agents = {}
70
-
71
- for agents_dir in agent_locations:
72
- if agents_dir.exists():
73
- # Look for both .md and .json files
74
- for pattern in ["*.md", "*.json"]:
75
- for agent_file in agents_dir.glob(pattern):
76
- agent_id = agent_file.stem
77
- tier = self._determine_tier(agent_file)
78
-
79
- # Check if we already have this agent
80
- if agent_id in discovered_agents:
81
- existing_tier = discovered_agents[agent_id]['tier']
82
- # Skip if existing has higher precedence
83
- # Precedence: project > user > system
84
- tier_precedence = {'project': 3, 'user': 2, 'system': 1}
85
- if tier_precedence.get(existing_tier, 0) >= tier_precedence.get(tier, 0):
86
- continue
87
-
88
- discovered_agents[agent_id] = {
89
- 'name': agent_id,
90
- 'type': agent_id,
91
- 'path': str(agent_file),
92
- 'last_modified': agent_file.stat().st_mtime,
93
- 'tier': tier,
94
- 'specializations': self._extract_specializations(agent_id),
95
- 'description': self._extract_description(agent_id)
96
- }
97
-
98
- # Store the final agents
99
- self.agents = discovered_agents
100
-
96
+ """Discover agents using the unified registry."""
97
+ unified_agents = self._unified_registry.discover_agents()
98
+
99
+ # Convert to old format for compatibility
100
+ self.agents = {}
101
+ for name, unified_metadata in unified_agents.items():
102
+ self.agents[name] = {
103
+ "name": unified_metadata.name,
104
+ "type": unified_metadata.agent_type.value,
105
+ "path": unified_metadata.path,
106
+ "last_modified": unified_metadata.last_modified,
107
+ "tier": unified_metadata.tier.value,
108
+ "specializations": unified_metadata.specializations,
109
+ "description": unified_metadata.description,
110
+ }
111
+
101
112
  def _determine_tier(self, agent_path: Path) -> str:
102
- """Determine agent tier based on path."""
103
- path_str = str(agent_path)
104
- if 'project' in path_str or '.claude-mpm' in path_str or '.claude/agents' in path_str:
105
- return 'project'
106
- elif 'user' in path_str or str(Path.home()) in path_str:
107
- return 'user'
113
+ """Determine agent tier based on path (compatibility method)."""
114
+ # Delegate to unified registry logic
115
+ if (
116
+ "project" in str(agent_path)
117
+ or ".claude-mpm" in str(agent_path)
118
+ or ".claude/agents" in str(agent_path)
119
+ ):
120
+ return "project"
121
+ elif "user" in str(agent_path) or str(Path.home()) in str(agent_path):
122
+ return "user"
108
123
  else:
109
- return 'system'
110
-
124
+ return "system"
125
+
111
126
  def _extract_specializations(self, agent_id: str) -> List[str]:
112
- """Extract specializations based on agent type."""
127
+ """Extract specializations based on agent type (compatibility method)."""
113
128
  specialization_map = {
114
- 'engineer': ['coding', 'architecture', 'implementation'],
115
- 'documentation': ['docs', 'api', 'guides'],
116
- 'qa': ['testing', 'quality', 'validation'],
117
- 'research': ['analysis', 'investigation', 'exploration'],
118
- 'ops': ['deployment', 'monitoring', 'infrastructure'],
119
- 'security': ['security', 'audit', 'compliance'],
120
- 'version_control': ['git', 'versioning', 'releases'],
121
- 'data_engineer': ['data', 'etl', 'analytics']
129
+ "engineer": ["coding", "architecture", "implementation"],
130
+ "documentation": ["docs", "api", "guides"],
131
+ "qa": ["testing", "quality", "validation"],
132
+ "research": ["analysis", "investigation", "exploration"],
133
+ "ops": ["deployment", "monitoring", "infrastructure"],
134
+ "security": ["security", "audit", "compliance"],
135
+ "version_control": ["git", "versioning", "releases"],
136
+ "data_engineer": ["data", "etl", "analytics"],
122
137
  }
123
138
  return specialization_map.get(agent_id, [])
124
-
139
+
125
140
  def _extract_description(self, agent_id: str) -> str:
126
- """Extract description for agent."""
141
+ """Extract description for agent (compatibility method)."""
127
142
  descriptions = {
128
- 'engineer': 'Software engineering and implementation',
129
- 'documentation': 'Documentation creation and maintenance',
130
- 'qa': 'Quality assurance and testing',
131
- 'research': 'Research and investigation',
132
- 'ops': 'Operations and deployment',
133
- 'security': 'Security analysis and compliance',
134
- 'version_control': 'Version control and release management',
135
- 'data_engineer': 'Data engineering and analytics'
143
+ "engineer": "Software engineering and implementation",
144
+ "documentation": "Documentation creation and maintenance",
145
+ "qa": "Quality assurance and testing",
146
+ "research": "Research and investigation",
147
+ "ops": "Operations and deployment",
148
+ "security": "Security analysis and compliance",
149
+ "version_control": "Version control and release management",
150
+ "data_engineer": "Data engineering and analytics",
136
151
  }
137
- return descriptions.get(agent_id, f'{agent_id.title()} agent')
138
-
152
+ return descriptions.get(agent_id, f"{agent_id.title()} agent")
153
+
139
154
  def list_agents(self, **kwargs) -> Dict[str, Any]:
140
- """List all agents."""
155
+ """List all agents (compatibility method)."""
141
156
  return self.agents
142
-
157
+
143
158
  def listAgents(self, **kwargs) -> Dict[str, Any]:
144
159
  """DEPRECATED: Use list_agents() instead. Kept for backward compatibility."""
145
- import warnings
146
160
  warnings.warn(
147
161
  "listAgents() is deprecated, use list_agents() instead",
148
162
  DeprecationWarning,
149
- stacklevel=2
163
+ stacklevel=2,
150
164
  )
151
165
  return self.list_agents(**kwargs)
152
-
153
- def list_agents_filtered(self, agent_type: Optional[str] = None, tier: Optional[str] = None) -> List[AgentMetadata]:
154
- """List agents with optional filtering."""
155
- results = []
156
- for agent_id, metadata in self.agents.items():
157
- if agent_type and metadata.get('type') != agent_type:
158
- continue
159
- if tier and metadata.get('tier') != tier:
160
- continue
161
-
162
- results.append(AgentMetadata(
163
- name=metadata['name'],
164
- type=metadata['type'],
165
- path=metadata['path'],
166
- tier=metadata.get('tier', 'system'),
167
- last_modified=metadata.get('last_modified', 0),
168
- specializations=metadata.get('specializations', []),
169
- description=metadata.get('description', '')
170
- ))
171
- return results
172
-
166
+
167
+ def list_agents_filtered(
168
+ self, agent_type: Optional[str] = None, tier: Optional[str] = None
169
+ ) -> List[AgentMetadata]:
170
+ """List agents with optional filtering (compatibility method)."""
171
+ # Use unified registry for filtering
172
+ unified_tier = None
173
+ unified_agent_type = None
174
+
175
+ if tier:
176
+ unified_tier = AgentTier(tier)
177
+ if agent_type:
178
+ try:
179
+ unified_agent_type = AgentType(agent_type)
180
+ except ValueError:
181
+ # Handle legacy agent types
182
+ unified_agent_type = None
183
+
184
+ unified_agents = self._unified_registry.list_agents(
185
+ tier=unified_tier, agent_type=unified_agent_type
186
+ )
187
+
188
+ return [AgentMetadata.from_unified(agent) for agent in unified_agents]
189
+
173
190
  def get_agent(self, agent_name: str) -> Optional[AgentMetadata]:
174
- """Get a specific agent."""
175
- metadata = self.agents.get(agent_name)
176
- if metadata:
177
- return AgentMetadata(
178
- name=metadata['name'],
179
- type=metadata['type'],
180
- path=metadata['path'],
181
- tier=metadata.get('tier', 'system'),
182
- last_modified=metadata.get('last_modified', 0),
183
- specializations=metadata.get('specializations', []),
184
- description=metadata.get('description', '')
185
- )
191
+ """Get a specific agent (compatibility method)."""
192
+ unified_agent = self._unified_registry.get_agent(agent_name)
193
+ if unified_agent:
194
+ return AgentMetadata.from_unified(unified_agent)
186
195
  return None
187
-
196
+
188
197
  def discover_agents(self, force_refresh: bool = False) -> Dict[str, AgentMetadata]:
189
- """Discover agents (optionally refresh)."""
190
- if force_refresh:
191
- self.agents.clear()
192
- self._discover_agents()
193
-
198
+ """Discover agents (compatibility method)."""
199
+ unified_agents = self._unified_registry.discover_agents(
200
+ force_refresh=force_refresh
201
+ )
202
+
203
+ # Update internal agents dict for compatibility
204
+ self.agents = {}
205
+ for name, unified_metadata in unified_agents.items():
206
+ self.agents[name] = {
207
+ "name": unified_metadata.name,
208
+ "type": unified_metadata.agent_type.value,
209
+ "path": unified_metadata.path,
210
+ "last_modified": unified_metadata.last_modified,
211
+ "tier": unified_metadata.tier.value,
212
+ "specializations": unified_metadata.specializations,
213
+ "description": unified_metadata.description,
214
+ }
215
+
216
+ # Return compatibility format
194
217
  return {
195
- agent_id: AgentMetadata(
196
- name=metadata['name'],
197
- type=metadata['type'],
198
- path=metadata['path'],
199
- tier=metadata.get('tier', 'system'),
200
- last_modified=metadata.get('last_modified', 0),
201
- specializations=metadata.get('specializations', []),
202
- description=metadata.get('description', '')
203
- )
204
- for agent_id, metadata in self.agents.items()
218
+ name: AgentMetadata.from_unified(unified_metadata)
219
+ for name, unified_metadata in unified_agents.items()
205
220
  }
206
-
221
+
207
222
  @property
208
223
  def core_agent_types(self) -> Set[str]:
209
- """Get core agent types."""
224
+ """Get core agent types (compatibility property)."""
210
225
  return {
211
- 'documentation',
212
- 'engineer',
213
- 'qa',
214
- 'research',
215
- 'ops',
216
- 'security',
217
- 'version_control',
218
- 'data_engineer'
226
+ "documentation",
227
+ "engineer",
228
+ "qa",
229
+ "research",
230
+ "ops",
231
+ "security",
232
+ "version_control",
233
+ "data_engineer",
219
234
  }
220
-
235
+
221
236
  @property
222
237
  def specialized_agent_types(self) -> Set[str]:
223
- """Get specialized agent types beyond core."""
224
- all_types = set(metadata['type'] for metadata in self.agents.values())
238
+ """Get specialized agent types beyond core (compatibility property)."""
239
+ all_types = set(metadata["type"] for metadata in self.agents.values())
225
240
  return all_types - self.core_agent_types
226
241
 
227
242
 
228
243
  class AgentRegistryAdapter:
229
244
  """
230
- Adapter to integrate agent registry functionality.
231
-
232
- This adapter:
233
- 1. Locates the claude-mpm installation
234
- 2. Provides a clean interface for agent operations
235
- 3. Maintains backwards compatibility
245
+ COMPATIBILITY WRAPPER for agent registry adapter.
246
+
247
+ This adapter now delegates to the UnifiedAgentRegistry system.
236
248
  """
237
-
249
+
238
250
  def __init__(self, framework_path: Optional[Path] = None):
239
- """
240
- Initialize the agent registry adapter.
241
-
242
- Args:
243
- framework_path: Path to claude-mpm (auto-detected if None)
244
- """
251
+ """Initialize the agent registry adapter (framework_path ignored in new implementation)."""
245
252
  self.logger = get_logger("agent_registry")
246
- self.framework_path = framework_path or self._find_framework()
247
- self.registry = None
248
- self._initialize_registry()
249
-
253
+ self.framework_path = framework_path # Kept for compatibility
254
+ self._unified_registry = get_agent_registry()
255
+ self.registry = SimpleAgentRegistry(framework_path)
256
+
250
257
  def _find_framework(self) -> Optional[Path]:
251
- """Find claude-mpm installation.
252
-
253
- Search order:
254
- 1. CLAUDE_MPM_PATH environment variable
255
- 2. Current working directory (if it's claude-mpm)
256
- 3. Walk up from current file location
257
- 4. Common development locations
258
- """
259
- # Check environment variable first
260
- env_path = os.environ.get("CLAUDE_MPM_PATH")
261
- if env_path:
262
- candidate = Path(env_path)
263
- if self._is_valid_framework_path(candidate):
264
- self.logger.info(f"Using claude-mpm from CLAUDE_MPM_PATH: {candidate}")
265
- return candidate
266
- else:
267
- self.logger.warning(f"CLAUDE_MPM_PATH is set but invalid: {env_path}")
268
-
269
- # Check current working directory
270
- cwd = Path.cwd()
271
- if self._is_valid_framework_path(cwd):
272
- return cwd
273
-
274
- # Check if we're running from within the installed package
275
- current_file = Path(__file__).resolve()
276
- for parent in current_file.parents:
277
- if self._is_valid_framework_path(parent):
278
- return parent
279
- # Stop at site-packages or similar
280
- if parent.name in ("site-packages", "dist-packages", "lib"):
281
- break
282
-
283
- # Check common development locations
284
- candidates = [
285
- Path.home() / "Projects" / "claude-mpm",
286
- Path.home() / "claude-mpm",
287
- ]
288
-
289
- for candidate in candidates:
290
- if self._is_valid_framework_path(candidate):
291
- self.logger.info(f"Found claude-mpm at: {candidate}")
292
- return candidate
293
-
294
- return None
295
-
258
+ """Find claude-mpm installation (compatibility method)."""
259
+ # Delegate to unified path manager
260
+ from .unified_paths import get_path_manager
261
+
262
+ return get_path_manager().framework_root
263
+
296
264
  def _is_valid_framework_path(self, path: Path) -> bool:
297
- """Check if a path is a valid claude-mpm installation."""
298
- return (
299
- path.exists() and
300
- (path / "src" / "claude_mpm").exists()
301
- )
302
-
265
+ """Check if a path is a valid claude-mpm installation (compatibility method)."""
266
+ return path.exists() and (path / "src" / "claude_mpm").exists()
267
+
303
268
  def _initialize_registry(self):
304
- """Initialize the agent registry."""
305
- if not self.framework_path:
306
- self.logger.warning("No framework path, registry unavailable")
307
- return
308
-
309
- try:
310
- self.registry = SimpleAgentRegistry(self.framework_path)
311
- self.logger.info("Agent registry initialized successfully")
312
-
313
- except Exception as e:
314
- self.logger.error(f"Failed to initialize registry: {e}")
315
-
269
+ """Initialize the agent registry (compatibility method)."""
270
+ # Registry is already initialized in __init__
271
+ pass
272
+
316
273
  def list_agents(self, **kwargs) -> Dict[str, Any]:
317
- """
318
- List available agents.
319
-
320
- Args:
321
- **kwargs: Arguments to pass to registry
322
-
323
- Returns:
324
- Dictionary of agents with metadata
325
- """
326
- if not self.registry:
327
- return {}
328
-
274
+ """List available agents (compatibility method)."""
329
275
  try:
330
276
  return self.registry.list_agents(**kwargs)
331
277
  except Exception as e:
332
278
  self.logger.error(f"Error listing agents: {e}")
333
279
  return {}
334
-
280
+
335
281
  def get_agent_definition(self, agent_name: str) -> Optional[str]:
336
- """
337
- Get agent definition by name.
338
-
339
- Args:
340
- agent_name: Name of the agent
341
-
342
- Returns:
343
- Agent definition content or None
344
- """
345
- if not self.registry:
346
- return None
347
-
282
+ """Get agent definition by name (compatibility method)."""
348
283
  try:
349
- # Try to load agent definition
350
- agents = self.registry.list_agents()
351
- for agent_id, metadata in agents.items():
352
- if agent_name in agent_id or agent_name == metadata.get('type'):
353
- # Load the agent file
354
- agent_path = Path(metadata['path'])
355
- if agent_path.exists():
356
- return agent_path.read_text()
357
-
284
+ unified_agent = self._unified_registry.get_agent(agent_name)
285
+ if unified_agent:
286
+ agent_path = Path(unified_agent.path)
287
+ if agent_path.exists():
288
+ return agent_path.read_text()
358
289
  return None
359
-
360
290
  except Exception as e:
361
291
  self.logger.error(f"Error getting agent definition: {e}")
362
292
  return None
363
-
364
- def select_agent_for_task(self, task_description: str, required_specializations: Optional[List[str]] = None) -> Optional[Dict[str, Any]]:
365
- """
366
- Select optimal agent for a task.
367
-
368
- Args:
369
- task_description: Description of the task
370
- required_specializations: Required agent specializations
371
-
372
- Returns:
373
- Agent metadata or None
374
- """
375
- if not self.registry:
376
- return None
377
-
293
+
294
+ def select_agent_for_task(
295
+ self,
296
+ task_description: str,
297
+ required_specializations: Optional[List[str]] = None,
298
+ ) -> Optional[Dict[str, Any]]:
299
+ """Select optimal agent for a task (compatibility method)."""
378
300
  try:
379
- # Get agents with required specializations
380
- agents = self.registry.list_agents()
381
-
301
+ # Get all agents from unified registry
302
+ unified_agents = self._unified_registry.list_agents()
303
+
382
304
  if required_specializations:
383
305
  # Filter by specializations
384
- filtered = {}
385
- for agent_id, metadata in agents.items():
386
- agent_specs = set(metadata.get('specializations', []))
306
+ filtered = []
307
+ for agent in unified_agents:
308
+ agent_specs = set(agent.specializations)
387
309
  if any(spec in agent_specs for spec in required_specializations):
388
- filtered[agent_id] = metadata
389
- agents = filtered
390
-
391
- if not agents:
310
+ filtered.append(agent)
311
+ unified_agents = filtered
312
+
313
+ if not unified_agents:
392
314
  return None
393
-
394
- # For now, return the first matching agent
395
- # In future, could implement more sophisticated selection
396
- agent_id = next(iter(agents))
315
+
316
+ # Return the first matching agent in compatibility format
317
+ agent = unified_agents[0]
397
318
  return {
398
- 'id': agent_id,
399
- 'metadata': agents[agent_id]
319
+ "id": agent.name,
320
+ "metadata": {
321
+ "name": agent.name,
322
+ "type": agent.agent_type.value,
323
+ "path": agent.path,
324
+ "tier": agent.tier.value,
325
+ "specializations": agent.specializations,
326
+ "description": agent.description,
327
+ },
400
328
  }
401
-
329
+
402
330
  except Exception as e:
403
331
  self.logger.error(f"Error selecting agent: {e}")
404
332
  return None
405
-
333
+
406
334
  def get_agent_hierarchy(self) -> Dict[str, List[str]]:
407
- """
408
- Get agent hierarchy (project → user → system).
409
-
410
- Returns:
411
- Dictionary with hierarchy levels and agent names
412
- """
413
- if not self.registry:
414
- return {
415
- 'project': [],
416
- 'user': [],
417
- 'system': []
418
- }
419
-
335
+ """Get agent hierarchy (compatibility method)."""
420
336
  try:
421
- # Get all agents
422
- all_agents = self.registry.list_agents()
423
-
424
- hierarchy = {
425
- 'project': [],
426
- 'user': [],
427
- 'system': []
428
- }
429
-
430
- # Categorize by tier
431
- for agent_id, metadata in all_agents.items():
432
- tier = metadata.get('tier', 'system')
433
- hierarchy[tier].append(agent_id)
434
-
337
+ hierarchy = {"project": [], "user": [], "system": []}
338
+
339
+ # Get agents by tier from unified registry
340
+ for tier in [AgentTier.PROJECT, AgentTier.USER, AgentTier.SYSTEM]:
341
+ agents = self._unified_registry.list_agents(tier=tier)
342
+ hierarchy[tier.value] = [agent.name for agent in agents]
343
+
435
344
  return hierarchy
436
-
345
+
437
346
  except Exception as e:
438
347
  self.logger.error(f"Error getting hierarchy: {e}")
439
- return {'project': [], 'user': [], 'system': []}
440
-
348
+ return {"project": [], "user": [], "system": []}
349
+
441
350
  def get_core_agents(self) -> List[str]:
442
- """
443
- Get list of core system agents.
444
-
445
- Returns:
446
- List of core agent names
447
- """
448
- return [
449
- 'documentation',
450
- 'engineer',
451
- 'qa',
452
- 'research',
453
- 'ops',
454
- 'security',
455
- 'version_control',
456
- 'data_engineer'
457
- ]
458
-
459
- def format_agent_for_task_tool(self, agent_name: str, task: str, context: str = "") -> str:
460
- """
461
- Format agent delegation for Task Tool.
462
-
463
- Args:
464
- agent_name: Name of the agent
465
- task: Task description
466
- context: Additional context
467
-
468
- Returns:
469
- Formatted Task Tool prompt
470
- """
351
+ """Get list of core system agents (compatibility method)."""
352
+ try:
353
+ core_agents = self._unified_registry.get_core_agents()
354
+ return [agent.name for agent in core_agents]
355
+ except Exception as e:
356
+ self.logger.error(f"Error getting core agents: {e}")
357
+ return [
358
+ "documentation",
359
+ "engineer",
360
+ "qa",
361
+ "research",
362
+ "ops",
363
+ "security",
364
+ "version_control",
365
+ "data_engineer",
366
+ ]
367
+
368
+ def format_agent_for_task_tool(
369
+ self, agent_name: str, task: str, context: str = ""
370
+ ) -> str:
371
+ """Format agent delegation for Task Tool (compatibility method)."""
471
372
  # Map agent names to nicknames
472
373
  nicknames = {
473
- 'documentation': 'Documenter',
474
- 'engineer': 'Engineer',
475
- 'qa': 'QA',
476
- 'research': 'Researcher',
477
- 'ops': 'Ops',
478
- 'security': 'Security',
479
- 'version_control': 'Versioner',
480
- 'data_engineer': 'Data Engineer'
374
+ "documentation": "Documenter",
375
+ "engineer": "Engineer",
376
+ "qa": "QA",
377
+ "research": "Researcher",
378
+ "ops": "Ops",
379
+ "security": "Security",
380
+ "version_control": "Versioner",
381
+ "data_engineer": "Data Engineer",
481
382
  }
482
-
383
+
483
384
  nickname = nicknames.get(agent_name, agent_name.title())
484
-
485
385
  today = datetime.now().strftime("%Y-%m-%d")
486
-
386
+
487
387
  return f"""**{nickname}**: {task}
488
388
 
489
389
  TEMPORAL CONTEXT: Today is {today}. Apply date awareness to task execution.
@@ -496,181 +396,132 @@ TEMPORAL CONTEXT: Today is {today}. Apply date awareness to task execution.
496
396
  **Expected Results**: Completed task with operational insights"""
497
397
 
498
398
 
399
+ # ============================================================================
400
+ # Compatibility Functions - Delegate to Unified Agent Registry
401
+ # ============================================================================
402
+
499
403
  # Export main class as AgentRegistry for compatibility
500
404
  AgentRegistry = SimpleAgentRegistry
501
405
 
502
- # Convenience functions for backwards compatibility
503
- def create_agent_registry(cache_service: Any = None, framework_path: Optional[Path] = None) -> AgentRegistry:
504
- """
505
- Create a new AgentRegistry instance
506
-
507
- Args:
508
- cache_service: Ignored for compatibility
509
- framework_path: Path to framework (auto-detected if None)
510
-
511
- Returns:
512
- AgentRegistry instance
513
- """
514
- if not framework_path:
515
- adapter = AgentRegistryAdapter()
516
- framework_path = adapter.framework_path
517
-
518
- if framework_path:
519
- return AgentRegistry(framework_path)
520
- else:
521
- raise ValueError("Could not find claude-mpm framework path")
406
+
407
+ def create_agent_registry(
408
+ cache_service: Any = None, framework_path: Optional[Path] = None
409
+ ) -> AgentRegistry:
410
+ """Create a new AgentRegistry instance (compatibility function)."""
411
+ # Ignore parameters and use unified registry
412
+ return AgentRegistry(framework_path)
413
+
522
414
 
523
415
  def discover_agents(force_refresh: bool = False) -> Dict[str, AgentMetadata]:
524
- """
525
- Convenience function for synchronous agent discovery
526
-
527
- Args:
528
- force_refresh: Force cache refresh
529
-
530
- Returns:
531
- Dictionary of discovered agents
532
- """
533
- adapter = AgentRegistryAdapter()
534
- if adapter.registry:
535
- return adapter.registry.discover_agents(force_refresh=force_refresh)
536
- return {}
416
+ """Convenience function for synchronous agent discovery (compatibility function)."""
417
+ return unified_discover_agents()
418
+
537
419
 
538
420
  def get_core_agent_types() -> Set[str]:
539
- """
540
- Get the set of core agent types
541
-
542
- Returns:
543
- Set of core agent type names
544
- """
545
- adapter = AgentRegistryAdapter()
546
- if adapter.registry:
547
- return adapter.registry.core_agent_types
548
- return set()
421
+ """Get the set of core agent types (compatibility function)."""
422
+ core_agents = unified_get_core_agents()
423
+ return {agent.name for agent in core_agents}
424
+
549
425
 
550
426
  def get_specialized_agent_types() -> Set[str]:
551
- """
552
- Get the set of specialized agent types beyond core 9
553
-
554
- Returns:
555
- Set of specialized agent type names
556
- """
557
- adapter = AgentRegistryAdapter()
558
- if adapter.registry:
559
- return adapter.registry.specialized_agent_types
560
- return set()
427
+ """Get the set of specialized agent types (compatibility function)."""
428
+ specialized_agents = unified_get_specialized_agents()
429
+ return {agent.name for agent in specialized_agents}
430
+
561
431
 
562
432
  def list_agents_all() -> Dict[str, Dict[str, Any]]:
563
- """
564
- Synchronous function for listing all agents
565
-
566
- Returns:
567
- Dictionary of agent name -> agent metadata
568
- """
569
- adapter = AgentRegistryAdapter()
570
- if adapter.registry:
571
- return adapter.registry.list_agents()
572
- return {}
433
+ """Synchronous function for listing all agents (compatibility function)."""
434
+ unified_agents = unified_discover_agents()
435
+ return {
436
+ name: {
437
+ "name": metadata.name,
438
+ "type": metadata.agent_type.value,
439
+ "path": metadata.path,
440
+ "tier": metadata.tier.value,
441
+ "last_modified": metadata.last_modified,
442
+ "specializations": metadata.specializations,
443
+ "description": metadata.description,
444
+ }
445
+ for name, metadata in unified_agents.items()
446
+ }
447
+
573
448
 
574
449
  def listAgents() -> Dict[str, Dict[str, Any]]:
575
- """
576
- DEPRECATED: Use list_agents_all() instead. Kept for backward compatibility.
577
-
578
- Returns:
579
- Dictionary of agent name -> agent metadata
580
- """
581
- import warnings
450
+ """DEPRECATED: Use list_agents_all() instead (compatibility function)."""
582
451
  warnings.warn(
583
452
  "listAgents() is deprecated, use list_agents_all() instead",
584
453
  DeprecationWarning,
585
- stacklevel=2
454
+ stacklevel=2,
586
455
  )
587
456
  return list_agents_all()
588
457
 
589
- def list_agents(agent_type: Optional[str] = None, tier: Optional[str] = None) -> List[AgentMetadata]:
590
- """
591
- Synchronous function to list agents with optional filtering
592
-
593
- Args:
594
- agent_type: Filter by agent type
595
- tier: Filter by hierarchy tier
596
-
597
- Returns:
598
- List of agent metadata dictionaries
599
- """
600
- adapter = AgentRegistryAdapter()
601
- if adapter.registry:
602
- return adapter.registry.list_agents_filtered(agent_type=agent_type, tier=tier)
603
- return []
458
+
459
+ def list_agents(
460
+ agent_type: Optional[str] = None, tier: Optional[str] = None
461
+ ) -> List[AgentMetadata]:
462
+ """Synchronous function to list agents with optional filtering (compatibility function)."""
463
+ # Convert parameters to unified types
464
+ unified_tier = None
465
+ unified_agent_type = None
466
+
467
+ if tier:
468
+ try:
469
+ unified_tier = AgentTier(tier)
470
+ except ValueError:
471
+ pass
472
+
473
+ if agent_type:
474
+ try:
475
+ unified_agent_type = AgentType(agent_type)
476
+ except ValueError:
477
+ pass
478
+
479
+ unified_agents = unified_list_agents(
480
+ tier=unified_tier, agent_type=unified_agent_type
481
+ )
482
+ return [AgentMetadata.from_unified(agent) for agent in unified_agents]
483
+
604
484
 
605
485
  def discover_agents_sync(force_refresh: bool = False) -> Dict[str, AgentMetadata]:
606
- """
607
- Synchronous function for agent discovery
608
-
609
- Args:
610
- force_refresh: Force cache refresh
611
-
612
- Returns:
613
- Dictionary of discovered agents
614
- """
486
+ """Synchronous function for agent discovery (compatibility function)."""
615
487
  return discover_agents(force_refresh)
616
488
 
489
+
617
490
  def get_agent(agent_name: str) -> Optional[Dict[str, Any]]:
618
- """
619
- Synchronous function to get a specific agent
620
-
621
- Args:
622
- agent_name: Name of agent to retrieve
623
-
624
- Returns:
625
- Agent metadata or None
626
- """
627
- adapter = AgentRegistryAdapter()
628
- if adapter.registry:
629
- agent = adapter.registry.get_agent(agent_name)
630
- if agent:
631
- return {
632
- 'name': agent.name,
633
- 'type': agent.type,
634
- 'path': agent.path,
635
- 'tier': agent.tier,
636
- 'last_modified': agent.last_modified,
637
- 'specializations': agent.specializations,
638
- 'description': agent.description
639
- }
491
+ """Synchronous function to get a specific agent (compatibility function)."""
492
+ unified_agent = unified_get_agent(agent_name)
493
+ if unified_agent:
494
+ return {
495
+ "name": unified_agent.name,
496
+ "type": unified_agent.agent_type.value,
497
+ "path": unified_agent.path,
498
+ "tier": unified_agent.tier.value,
499
+ "last_modified": unified_agent.last_modified,
500
+ "specializations": unified_agent.specializations,
501
+ "description": unified_agent.description,
502
+ }
640
503
  return None
641
504
 
505
+
642
506
  def get_registry_stats() -> Dict[str, Any]:
643
- """
644
- Synchronous function to get registry statistics
645
-
646
- Returns:
647
- Dictionary of registry statistics
648
- """
649
- adapter = AgentRegistryAdapter()
650
- if adapter.registry:
651
- agents = adapter.registry.list_agents_filtered()
652
- return {
653
- 'total_agents': len(agents),
654
- 'agent_types': len(set(a.type for a in agents)),
655
- 'tiers': list(set(a.tier for a in agents))
656
- }
657
- return {'total_agents': 0, 'agent_types': 0, 'tiers': []}
507
+ """Synchronous function to get registry statistics (compatibility function)."""
508
+ return unified_get_registry_stats()
658
509
 
659
510
 
660
511
  # Export all public symbols
661
512
  __all__ = [
662
- 'AgentRegistry',
663
- 'AgentRegistryAdapter',
664
- 'AgentMetadata',
665
- 'SimpleAgentRegistry',
666
- 'create_agent_registry',
667
- 'discover_agents',
668
- 'get_core_agent_types',
669
- 'get_specialized_agent_types',
670
- 'list_agents_all',
671
- 'list_agents',
672
- 'listAgents', # Deprecated
673
- 'discover_agents_sync',
674
- 'get_agent',
675
- 'get_registry_stats'
676
- ]
513
+ "AgentRegistry",
514
+ "AgentRegistryAdapter",
515
+ "AgentMetadata",
516
+ "SimpleAgentRegistry",
517
+ "create_agent_registry",
518
+ "discover_agents",
519
+ "get_core_agent_types",
520
+ "get_specialized_agent_types",
521
+ "list_agents_all",
522
+ "list_agents",
523
+ "listAgents", # Deprecated
524
+ "discover_agents_sync",
525
+ "get_agent",
526
+ "get_registry_stats",
527
+ ]