claude-mpm 3.9.9__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.
- claude_mpm/VERSION +1 -1
- claude_mpm/__init__.py +2 -2
- claude_mpm/__main__.py +3 -2
- claude_mpm/agents/__init__.py +85 -79
- claude_mpm/agents/agent_loader.py +464 -1003
- claude_mpm/agents/agent_loader_integration.py +45 -45
- claude_mpm/agents/agents_metadata.py +29 -30
- claude_mpm/agents/async_agent_loader.py +156 -138
- claude_mpm/agents/base_agent.json +1 -1
- claude_mpm/agents/base_agent_loader.py +179 -151
- claude_mpm/agents/frontmatter_validator.py +229 -130
- claude_mpm/agents/schema/agent_schema.json +1 -1
- claude_mpm/agents/system_agent_config.py +213 -147
- claude_mpm/agents/templates/__init__.py +13 -13
- claude_mpm/agents/templates/code_analyzer.json +2 -2
- claude_mpm/agents/templates/data_engineer.json +1 -1
- claude_mpm/agents/templates/documentation.json +23 -11
- claude_mpm/agents/templates/engineer.json +22 -6
- claude_mpm/agents/templates/memory_manager.json +155 -0
- claude_mpm/agents/templates/ops.json +2 -2
- claude_mpm/agents/templates/project_organizer.json +1 -1
- claude_mpm/agents/templates/qa.json +1 -1
- claude_mpm/agents/templates/refactoring_engineer.json +222 -0
- claude_mpm/agents/templates/research.json +20 -14
- claude_mpm/agents/templates/security.json +1 -1
- claude_mpm/agents/templates/ticketing.json +1 -1
- claude_mpm/agents/templates/version_control.json +1 -1
- claude_mpm/agents/templates/web_qa.json +3 -1
- claude_mpm/agents/templates/web_ui.json +2 -2
- claude_mpm/cli/__init__.py +90 -49
- claude_mpm/cli/__main__.py +3 -2
- claude_mpm/cli/commands/__init__.py +21 -18
- claude_mpm/cli/commands/agents.py +279 -247
- claude_mpm/cli/commands/aggregate.py +138 -157
- claude_mpm/cli/commands/cleanup.py +147 -147
- claude_mpm/cli/commands/config.py +93 -76
- claude_mpm/cli/commands/info.py +17 -16
- claude_mpm/cli/commands/mcp.py +143 -762
- claude_mpm/cli/commands/mcp_command_router.py +139 -0
- claude_mpm/cli/commands/mcp_config_commands.py +20 -0
- claude_mpm/cli/commands/mcp_install_commands.py +20 -0
- claude_mpm/cli/commands/mcp_server_commands.py +175 -0
- claude_mpm/cli/commands/mcp_tool_commands.py +34 -0
- claude_mpm/cli/commands/memory.py +239 -203
- claude_mpm/cli/commands/monitor.py +203 -81
- claude_mpm/cli/commands/run.py +380 -429
- claude_mpm/cli/commands/run_config_checker.py +160 -0
- claude_mpm/cli/commands/socketio_monitor.py +235 -0
- claude_mpm/cli/commands/tickets.py +305 -197
- claude_mpm/cli/parser.py +24 -1150
- claude_mpm/cli/parsers/__init__.py +29 -0
- claude_mpm/cli/parsers/agents_parser.py +136 -0
- claude_mpm/cli/parsers/base_parser.py +331 -0
- claude_mpm/cli/parsers/config_parser.py +85 -0
- claude_mpm/cli/parsers/mcp_parser.py +152 -0
- claude_mpm/cli/parsers/memory_parser.py +138 -0
- claude_mpm/cli/parsers/monitor_parser.py +104 -0
- claude_mpm/cli/parsers/run_parser.py +147 -0
- claude_mpm/cli/parsers/tickets_parser.py +203 -0
- claude_mpm/cli/ticket_cli.py +7 -3
- claude_mpm/cli/utils.py +55 -37
- claude_mpm/cli_module/__init__.py +6 -6
- claude_mpm/cli_module/args.py +188 -140
- claude_mpm/cli_module/commands.py +79 -70
- claude_mpm/cli_module/migration_example.py +38 -60
- claude_mpm/config/__init__.py +32 -25
- claude_mpm/config/agent_config.py +151 -119
- claude_mpm/config/experimental_features.py +217 -0
- claude_mpm/config/paths.py +94 -208
- claude_mpm/config/socketio_config.py +84 -73
- claude_mpm/constants.py +36 -18
- claude_mpm/core/__init__.py +9 -6
- claude_mpm/core/agent_name_normalizer.py +68 -71
- claude_mpm/core/agent_registry.py +372 -521
- claude_mpm/core/agent_session_manager.py +74 -63
- claude_mpm/core/base_service.py +116 -87
- claude_mpm/core/cache.py +119 -153
- claude_mpm/core/claude_runner.py +425 -1120
- claude_mpm/core/config.py +263 -168
- claude_mpm/core/config_aliases.py +69 -61
- claude_mpm/core/config_constants.py +292 -0
- claude_mpm/core/constants.py +57 -99
- claude_mpm/core/container.py +211 -178
- claude_mpm/core/exceptions.py +233 -89
- claude_mpm/core/factories.py +92 -54
- claude_mpm/core/framework_loader.py +378 -220
- claude_mpm/core/hook_manager.py +198 -83
- claude_mpm/core/hook_performance_config.py +136 -0
- claude_mpm/core/injectable_service.py +61 -55
- claude_mpm/core/interactive_session.py +165 -155
- claude_mpm/core/interfaces.py +221 -195
- claude_mpm/core/lazy.py +96 -96
- claude_mpm/core/logger.py +133 -107
- claude_mpm/core/logging_config.py +185 -157
- claude_mpm/core/minimal_framework_loader.py +20 -15
- claude_mpm/core/mixins.py +30 -29
- claude_mpm/core/oneshot_session.py +215 -181
- claude_mpm/core/optimized_agent_loader.py +134 -138
- claude_mpm/core/optimized_startup.py +159 -157
- claude_mpm/core/pm_hook_interceptor.py +85 -72
- claude_mpm/core/service_registry.py +103 -101
- claude_mpm/core/session_manager.py +97 -87
- claude_mpm/core/socketio_pool.py +212 -158
- claude_mpm/core/tool_access_control.py +58 -51
- claude_mpm/core/types.py +46 -24
- claude_mpm/core/typing_utils.py +166 -82
- claude_mpm/core/unified_agent_registry.py +721 -0
- claude_mpm/core/unified_config.py +550 -0
- claude_mpm/core/unified_paths.py +549 -0
- claude_mpm/dashboard/index.html +1 -1
- claude_mpm/dashboard/open_dashboard.py +51 -17
- claude_mpm/dashboard/static/css/dashboard.css +27 -8
- claude_mpm/dashboard/static/dist/components/agent-inference.js +2 -0
- claude_mpm/dashboard/static/dist/components/event-processor.js +2 -0
- claude_mpm/dashboard/static/dist/components/event-viewer.js +2 -0
- claude_mpm/dashboard/static/dist/components/export-manager.js +2 -0
- claude_mpm/dashboard/static/dist/components/file-tool-tracker.js +2 -0
- claude_mpm/dashboard/static/dist/components/hud-library-loader.js +2 -0
- claude_mpm/dashboard/static/dist/components/hud-manager.js +2 -0
- claude_mpm/dashboard/static/dist/components/hud-visualizer.js +2 -0
- claude_mpm/dashboard/static/dist/components/module-viewer.js +2 -0
- claude_mpm/dashboard/static/dist/components/session-manager.js +2 -0
- claude_mpm/dashboard/static/dist/components/socket-manager.js +2 -0
- claude_mpm/dashboard/static/dist/components/ui-state-manager.js +2 -0
- claude_mpm/dashboard/static/dist/components/working-directory.js +2 -0
- claude_mpm/dashboard/static/dist/dashboard.js +2 -0
- claude_mpm/dashboard/static/dist/socket-client.js +2 -0
- claude_mpm/dashboard/static/js/components/agent-inference.js +80 -76
- claude_mpm/dashboard/static/js/components/event-processor.js +71 -67
- claude_mpm/dashboard/static/js/components/event-viewer.js +74 -70
- claude_mpm/dashboard/static/js/components/export-manager.js +31 -28
- claude_mpm/dashboard/static/js/components/file-tool-tracker.js +106 -92
- claude_mpm/dashboard/static/js/components/hud-library-loader.js +11 -11
- claude_mpm/dashboard/static/js/components/hud-manager.js +73 -73
- claude_mpm/dashboard/static/js/components/hud-visualizer.js +163 -163
- claude_mpm/dashboard/static/js/components/module-viewer.js +305 -233
- claude_mpm/dashboard/static/js/components/session-manager.js +32 -29
- claude_mpm/dashboard/static/js/components/socket-manager.js +27 -20
- claude_mpm/dashboard/static/js/components/ui-state-manager.js +21 -18
- claude_mpm/dashboard/static/js/components/working-directory.js +74 -71
- claude_mpm/dashboard/static/js/dashboard.js +178 -453
- claude_mpm/dashboard/static/js/extension-error-handler.js +164 -0
- claude_mpm/dashboard/static/js/socket-client.js +120 -54
- claude_mpm/dashboard/templates/index.html +40 -50
- claude_mpm/experimental/cli_enhancements.py +60 -58
- claude_mpm/generators/__init__.py +1 -1
- claude_mpm/generators/agent_profile_generator.py +75 -65
- claude_mpm/hooks/__init__.py +1 -1
- claude_mpm/hooks/base_hook.py +33 -28
- claude_mpm/hooks/claude_hooks/__init__.py +1 -1
- claude_mpm/hooks/claude_hooks/connection_pool.py +120 -0
- claude_mpm/hooks/claude_hooks/event_handlers.py +743 -0
- claude_mpm/hooks/claude_hooks/hook_handler.py +415 -1331
- claude_mpm/hooks/claude_hooks/hook_wrapper.sh +4 -4
- claude_mpm/hooks/claude_hooks/memory_integration.py +221 -0
- claude_mpm/hooks/claude_hooks/response_tracking.py +348 -0
- claude_mpm/hooks/claude_hooks/tool_analysis.py +230 -0
- claude_mpm/hooks/memory_integration_hook.py +140 -100
- claude_mpm/hooks/tool_call_interceptor.py +89 -76
- claude_mpm/hooks/validation_hooks.py +57 -49
- claude_mpm/init.py +145 -121
- claude_mpm/models/__init__.py +9 -9
- claude_mpm/models/agent_definition.py +33 -23
- claude_mpm/models/agent_session.py +228 -200
- claude_mpm/scripts/__init__.py +1 -1
- claude_mpm/scripts/socketio_daemon.py +192 -75
- claude_mpm/scripts/socketio_server_manager.py +328 -0
- claude_mpm/scripts/start_activity_logging.py +25 -22
- claude_mpm/services/__init__.py +68 -43
- claude_mpm/services/agent_capabilities_service.py +271 -0
- claude_mpm/services/agents/__init__.py +23 -32
- claude_mpm/services/agents/deployment/__init__.py +3 -3
- claude_mpm/services/agents/deployment/agent_config_provider.py +310 -0
- claude_mpm/services/agents/deployment/agent_configuration_manager.py +359 -0
- claude_mpm/services/agents/deployment/agent_definition_factory.py +84 -0
- claude_mpm/services/agents/deployment/agent_deployment.py +415 -2113
- claude_mpm/services/agents/deployment/agent_discovery_service.py +387 -0
- claude_mpm/services/agents/deployment/agent_environment_manager.py +293 -0
- claude_mpm/services/agents/deployment/agent_filesystem_manager.py +387 -0
- claude_mpm/services/agents/deployment/agent_format_converter.py +453 -0
- claude_mpm/services/agents/deployment/agent_frontmatter_validator.py +161 -0
- claude_mpm/services/agents/deployment/agent_lifecycle_manager.py +345 -495
- claude_mpm/services/agents/deployment/agent_metrics_collector.py +279 -0
- claude_mpm/services/agents/deployment/agent_restore_handler.py +88 -0
- claude_mpm/services/agents/deployment/agent_template_builder.py +406 -0
- claude_mpm/services/agents/deployment/agent_validator.py +352 -0
- claude_mpm/services/agents/deployment/agent_version_manager.py +313 -0
- claude_mpm/services/agents/deployment/agent_versioning.py +6 -9
- claude_mpm/services/agents/deployment/agents_directory_resolver.py +79 -0
- claude_mpm/services/agents/deployment/async_agent_deployment.py +298 -234
- claude_mpm/services/agents/deployment/config/__init__.py +13 -0
- claude_mpm/services/agents/deployment/config/deployment_config.py +182 -0
- claude_mpm/services/agents/deployment/config/deployment_config_manager.py +200 -0
- claude_mpm/services/agents/deployment/deployment_config_loader.py +54 -0
- claude_mpm/services/agents/deployment/deployment_type_detector.py +124 -0
- claude_mpm/services/agents/deployment/facade/__init__.py +18 -0
- claude_mpm/services/agents/deployment/facade/async_deployment_executor.py +159 -0
- claude_mpm/services/agents/deployment/facade/deployment_executor.py +73 -0
- claude_mpm/services/agents/deployment/facade/deployment_facade.py +270 -0
- claude_mpm/services/agents/deployment/facade/sync_deployment_executor.py +178 -0
- claude_mpm/services/agents/deployment/interface_adapter.py +227 -0
- claude_mpm/services/agents/deployment/lifecycle_health_checker.py +85 -0
- claude_mpm/services/agents/deployment/lifecycle_performance_tracker.py +100 -0
- claude_mpm/services/agents/deployment/pipeline/__init__.py +32 -0
- claude_mpm/services/agents/deployment/pipeline/pipeline_builder.py +158 -0
- claude_mpm/services/agents/deployment/pipeline/pipeline_context.py +159 -0
- claude_mpm/services/agents/deployment/pipeline/pipeline_executor.py +169 -0
- claude_mpm/services/agents/deployment/pipeline/steps/__init__.py +19 -0
- claude_mpm/services/agents/deployment/pipeline/steps/agent_processing_step.py +195 -0
- claude_mpm/services/agents/deployment/pipeline/steps/base_step.py +119 -0
- claude_mpm/services/agents/deployment/pipeline/steps/configuration_step.py +79 -0
- claude_mpm/services/agents/deployment/pipeline/steps/target_directory_step.py +90 -0
- claude_mpm/services/agents/deployment/pipeline/steps/validation_step.py +100 -0
- claude_mpm/services/agents/deployment/processors/__init__.py +15 -0
- claude_mpm/services/agents/deployment/processors/agent_deployment_context.py +98 -0
- claude_mpm/services/agents/deployment/processors/agent_deployment_result.py +235 -0
- claude_mpm/services/agents/deployment/processors/agent_processor.py +258 -0
- claude_mpm/services/agents/deployment/refactored_agent_deployment_service.py +318 -0
- claude_mpm/services/agents/deployment/results/__init__.py +13 -0
- claude_mpm/services/agents/deployment/results/deployment_metrics.py +200 -0
- claude_mpm/services/agents/deployment/results/deployment_result_builder.py +249 -0
- claude_mpm/services/agents/deployment/strategies/__init__.py +25 -0
- claude_mpm/services/agents/deployment/strategies/base_strategy.py +119 -0
- claude_mpm/services/agents/deployment/strategies/project_strategy.py +150 -0
- claude_mpm/services/agents/deployment/strategies/strategy_selector.py +117 -0
- claude_mpm/services/agents/deployment/strategies/system_strategy.py +116 -0
- claude_mpm/services/agents/deployment/strategies/user_strategy.py +137 -0
- claude_mpm/services/agents/deployment/system_instructions_deployer.py +108 -0
- claude_mpm/services/agents/deployment/validation/__init__.py +19 -0
- claude_mpm/services/agents/deployment/validation/agent_validator.py +323 -0
- claude_mpm/services/agents/deployment/validation/deployment_validator.py +238 -0
- claude_mpm/services/agents/deployment/validation/template_validator.py +299 -0
- claude_mpm/services/agents/deployment/validation/validation_result.py +226 -0
- claude_mpm/services/agents/loading/__init__.py +2 -2
- claude_mpm/services/agents/loading/agent_profile_loader.py +259 -229
- claude_mpm/services/agents/loading/base_agent_manager.py +90 -81
- claude_mpm/services/agents/loading/framework_agent_loader.py +154 -129
- claude_mpm/services/agents/management/__init__.py +2 -2
- claude_mpm/services/agents/management/agent_capabilities_generator.py +72 -58
- claude_mpm/services/agents/management/agent_management_service.py +209 -156
- claude_mpm/services/agents/memory/__init__.py +9 -6
- claude_mpm/services/agents/memory/agent_memory_manager.py +218 -1152
- claude_mpm/services/agents/memory/agent_persistence_service.py +20 -16
- claude_mpm/services/agents/memory/analyzer.py +430 -0
- claude_mpm/services/agents/memory/content_manager.py +376 -0
- claude_mpm/services/agents/memory/template_generator.py +468 -0
- claude_mpm/services/agents/registry/__init__.py +7 -10
- claude_mpm/services/agents/registry/deployed_agent_discovery.py +122 -97
- claude_mpm/services/agents/registry/modification_tracker.py +351 -285
- claude_mpm/services/async_session_logger.py +187 -153
- claude_mpm/services/claude_session_logger.py +87 -72
- claude_mpm/services/command_handler_service.py +217 -0
- claude_mpm/services/communication/__init__.py +3 -2
- claude_mpm/services/core/__init__.py +50 -97
- claude_mpm/services/core/base.py +60 -53
- claude_mpm/services/core/interfaces/__init__.py +188 -0
- claude_mpm/services/core/interfaces/agent.py +351 -0
- claude_mpm/services/core/interfaces/communication.py +343 -0
- claude_mpm/services/core/interfaces/infrastructure.py +413 -0
- claude_mpm/services/core/interfaces/service.py +434 -0
- claude_mpm/services/core/interfaces.py +19 -944
- claude_mpm/services/event_aggregator.py +208 -170
- claude_mpm/services/exceptions.py +387 -308
- claude_mpm/services/framework_claude_md_generator/__init__.py +75 -79
- claude_mpm/services/framework_claude_md_generator/content_assembler.py +69 -60
- claude_mpm/services/framework_claude_md_generator/content_validator.py +65 -61
- claude_mpm/services/framework_claude_md_generator/deployment_manager.py +68 -49
- claude_mpm/services/framework_claude_md_generator/section_generators/__init__.py +34 -34
- claude_mpm/services/framework_claude_md_generator/section_generators/agents.py +25 -22
- claude_mpm/services/framework_claude_md_generator/section_generators/claude_pm_init.py +10 -10
- claude_mpm/services/framework_claude_md_generator/section_generators/core_responsibilities.py +4 -3
- claude_mpm/services/framework_claude_md_generator/section_generators/delegation_constraints.py +4 -3
- claude_mpm/services/framework_claude_md_generator/section_generators/environment_config.py +4 -3
- claude_mpm/services/framework_claude_md_generator/section_generators/footer.py +6 -5
- claude_mpm/services/framework_claude_md_generator/section_generators/header.py +8 -7
- claude_mpm/services/framework_claude_md_generator/section_generators/orchestration_principles.py +4 -3
- claude_mpm/services/framework_claude_md_generator/section_generators/role_designation.py +6 -5
- claude_mpm/services/framework_claude_md_generator/section_generators/subprocess_validation.py +9 -8
- claude_mpm/services/framework_claude_md_generator/section_generators/todo_task_tools.py +4 -3
- claude_mpm/services/framework_claude_md_generator/section_generators/troubleshooting.py +5 -4
- claude_mpm/services/framework_claude_md_generator/section_manager.py +28 -27
- claude_mpm/services/framework_claude_md_generator/version_manager.py +30 -28
- claude_mpm/services/hook_service.py +106 -114
- claude_mpm/services/infrastructure/__init__.py +7 -5
- claude_mpm/services/infrastructure/context_preservation.py +571 -0
- claude_mpm/services/infrastructure/daemon_manager.py +279 -0
- claude_mpm/services/infrastructure/logging.py +83 -76
- claude_mpm/services/infrastructure/monitoring.py +547 -404
- claude_mpm/services/mcp_gateway/__init__.py +40 -23
- claude_mpm/services/mcp_gateway/config/__init__.py +2 -2
- claude_mpm/services/mcp_gateway/config/config_loader.py +61 -56
- claude_mpm/services/mcp_gateway/config/config_schema.py +50 -41
- claude_mpm/services/mcp_gateway/config/configuration.py +82 -75
- claude_mpm/services/mcp_gateway/core/__init__.py +14 -21
- claude_mpm/services/mcp_gateway/core/base.py +80 -67
- claude_mpm/services/mcp_gateway/core/exceptions.py +60 -46
- claude_mpm/services/mcp_gateway/core/interfaces.py +97 -93
- claude_mpm/services/mcp_gateway/main.py +307 -127
- claude_mpm/services/mcp_gateway/registry/__init__.py +1 -1
- claude_mpm/services/mcp_gateway/registry/service_registry.py +100 -101
- claude_mpm/services/mcp_gateway/registry/tool_registry.py +135 -126
- claude_mpm/services/mcp_gateway/server/__init__.py +4 -4
- claude_mpm/services/mcp_gateway/server/{mcp_server.py → mcp_gateway.py} +149 -153
- claude_mpm/services/mcp_gateway/server/stdio_handler.py +105 -107
- claude_mpm/services/mcp_gateway/server/stdio_server.py +691 -0
- claude_mpm/services/mcp_gateway/tools/__init__.py +4 -2
- claude_mpm/services/mcp_gateway/tools/base_adapter.py +110 -121
- claude_mpm/services/mcp_gateway/tools/document_summarizer.py +283 -215
- claude_mpm/services/mcp_gateway/tools/hello_world.py +122 -120
- claude_mpm/services/mcp_gateway/tools/ticket_tools.py +652 -0
- claude_mpm/services/mcp_gateway/tools/unified_ticket_tool.py +606 -0
- claude_mpm/services/memory/__init__.py +2 -2
- claude_mpm/services/memory/builder.py +451 -362
- claude_mpm/services/memory/cache/__init__.py +2 -2
- claude_mpm/services/memory/cache/shared_prompt_cache.py +232 -194
- claude_mpm/services/memory/cache/simple_cache.py +107 -93
- claude_mpm/services/memory/indexed_memory.py +195 -193
- claude_mpm/services/memory/optimizer.py +267 -234
- claude_mpm/services/memory/router.py +571 -263
- claude_mpm/services/memory_hook_service.py +237 -0
- claude_mpm/services/port_manager.py +223 -0
- claude_mpm/services/project/__init__.py +3 -3
- claude_mpm/services/project/analyzer.py +451 -305
- claude_mpm/services/project/registry.py +262 -240
- claude_mpm/services/recovery_manager.py +287 -231
- claude_mpm/services/response_tracker.py +87 -67
- claude_mpm/services/runner_configuration_service.py +587 -0
- claude_mpm/services/session_management_service.py +304 -0
- claude_mpm/services/socketio/__init__.py +4 -4
- claude_mpm/services/socketio/client_proxy.py +174 -0
- claude_mpm/services/socketio/handlers/__init__.py +3 -3
- claude_mpm/services/socketio/handlers/base.py +44 -30
- claude_mpm/services/socketio/handlers/connection.py +145 -65
- claude_mpm/services/socketio/handlers/file.py +123 -108
- claude_mpm/services/socketio/handlers/git.py +607 -373
- claude_mpm/services/socketio/handlers/hook.py +170 -0
- claude_mpm/services/socketio/handlers/memory.py +4 -4
- claude_mpm/services/socketio/handlers/project.py +4 -4
- claude_mpm/services/socketio/handlers/registry.py +53 -38
- claude_mpm/services/socketio/server/__init__.py +18 -0
- claude_mpm/services/socketio/server/broadcaster.py +252 -0
- claude_mpm/services/socketio/server/core.py +399 -0
- claude_mpm/services/socketio/server/main.py +323 -0
- claude_mpm/services/socketio_client_manager.py +160 -133
- claude_mpm/services/socketio_server.py +36 -1885
- claude_mpm/services/subprocess_launcher_service.py +316 -0
- claude_mpm/services/system_instructions_service.py +258 -0
- claude_mpm/services/ticket_manager.py +20 -534
- claude_mpm/services/utility_service.py +285 -0
- claude_mpm/services/version_control/__init__.py +18 -21
- claude_mpm/services/version_control/branch_strategy.py +20 -10
- claude_mpm/services/version_control/conflict_resolution.py +37 -13
- claude_mpm/services/version_control/git_operations.py +52 -21
- claude_mpm/services/version_control/semantic_versioning.py +92 -53
- claude_mpm/services/version_control/version_parser.py +145 -125
- claude_mpm/services/version_service.py +270 -0
- claude_mpm/storage/__init__.py +9 -0
- claude_mpm/storage/state_storage.py +552 -0
- claude_mpm/ticket_wrapper.py +2 -2
- claude_mpm/utils/__init__.py +2 -2
- claude_mpm/utils/agent_dependency_loader.py +453 -243
- claude_mpm/utils/config_manager.py +157 -118
- claude_mpm/utils/console.py +1 -1
- claude_mpm/utils/dependency_cache.py +102 -107
- claude_mpm/utils/dependency_manager.py +52 -47
- claude_mpm/utils/dependency_strategies.py +131 -96
- claude_mpm/utils/environment_context.py +110 -102
- claude_mpm/utils/error_handler.py +75 -55
- claude_mpm/utils/file_utils.py +80 -67
- claude_mpm/utils/framework_detection.py +12 -11
- claude_mpm/utils/import_migration_example.py +12 -60
- claude_mpm/utils/imports.py +48 -45
- claude_mpm/utils/path_operations.py +100 -93
- claude_mpm/utils/robust_installer.py +172 -164
- claude_mpm/utils/session_logging.py +30 -23
- claude_mpm/utils/subprocess_utils.py +99 -61
- claude_mpm/validation/__init__.py +1 -1
- claude_mpm/validation/agent_validator.py +151 -111
- claude_mpm/validation/frontmatter_validator.py +92 -71
- {claude_mpm-3.9.9.dist-info → claude_mpm-4.0.3.dist-info}/METADATA +51 -2
- claude_mpm-4.0.3.dist-info/RECORD +402 -0
- {claude_mpm-3.9.9.dist-info → claude_mpm-4.0.3.dist-info}/entry_points.txt +1 -0
- {claude_mpm-3.9.9.dist-info → claude_mpm-4.0.3.dist-info}/licenses/LICENSE +1 -1
- claude_mpm/config/memory_guardian_config.py +0 -325
- claude_mpm/core/config_paths.py +0 -150
- claude_mpm/dashboard/static/js/dashboard-original.js +0 -4134
- claude_mpm/deployment_paths.py +0 -261
- claude_mpm/hooks/claude_hooks/hook_handler_fixed.py +0 -454
- claude_mpm/models/state_models.py +0 -433
- claude_mpm/services/agent/__init__.py +0 -24
- claude_mpm/services/agent/deployment.py +0 -2548
- claude_mpm/services/agent/management.py +0 -598
- claude_mpm/services/agent/registry.py +0 -813
- claude_mpm/services/agents/registry/agent_registry.py +0 -813
- claude_mpm/services/communication/socketio.py +0 -1935
- claude_mpm/services/communication/websocket.py +0 -479
- claude_mpm/services/framework_claude_md_generator.py +0 -624
- claude_mpm/services/health_monitor.py +0 -893
- claude_mpm/services/infrastructure/memory_guardian.py +0 -770
- claude_mpm/services/mcp_gateway/server/mcp_server_simple.py +0 -444
- claude_mpm/services/optimized_hook_service.py +0 -542
- claude_mpm/services/project_analyzer.py +0 -864
- claude_mpm/services/project_registry.py +0 -608
- claude_mpm/services/standalone_socketio_server.py +0 -1300
- claude_mpm/services/ticket_manager_di.py +0 -318
- claude_mpm/services/ticketing_service_original.py +0 -510
- claude_mpm/utils/paths.py +0 -395
- claude_mpm/utils/platform_memory.py +0 -524
- claude_mpm-3.9.9.dist-info/RECORD +0 -293
- {claude_mpm-3.9.9.dist-info → claude_mpm-4.0.3.dist-info}/WHEEL +0 -0
- {claude_mpm-3.9.9.dist-info → claude_mpm-4.0.3.dist-info}/top_level.txt +0 -0
| @@ -0,0 +1,258 @@ | |
| 1 | 
            +
            """Agent processor for individual agent deployment operations."""
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            import time
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            from claude_mpm.core.exceptions import AgentDeploymentError
         | 
| 6 | 
            +
            from claude_mpm.core.logger import get_logger
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            from .agent_deployment_context import AgentDeploymentContext
         | 
| 9 | 
            +
            from .agent_deployment_result import AgentDeploymentResult, AgentDeploymentStatus
         | 
| 10 | 
            +
             | 
| 11 | 
            +
             | 
| 12 | 
            +
            class AgentProcessor:
         | 
| 13 | 
            +
                """Processor for deploying individual agents.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                This class handles the processing and deployment of a single agent,
         | 
| 16 | 
            +
                including update checking, building, and deployment.
         | 
| 17 | 
            +
                """
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def __init__(self, template_builder, version_manager):
         | 
| 20 | 
            +
                    """Initialize the agent processor.
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    Args:
         | 
| 23 | 
            +
                        template_builder: Template builder service
         | 
| 24 | 
            +
                        version_manager: Version manager service
         | 
| 25 | 
            +
                    """
         | 
| 26 | 
            +
                    self.template_builder = template_builder
         | 
| 27 | 
            +
                    self.version_manager = version_manager
         | 
| 28 | 
            +
                    self.logger = get_logger(__name__)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def process_agent(self, context: AgentDeploymentContext) -> AgentDeploymentResult:
         | 
| 31 | 
            +
                    """Process and deploy a single agent.
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    Args:
         | 
| 34 | 
            +
                        context: Agent deployment context
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                    Returns:
         | 
| 37 | 
            +
                        AgentDeploymentResult with deployment outcome
         | 
| 38 | 
            +
                    """
         | 
| 39 | 
            +
                    start_time = time.time()
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                    try:
         | 
| 42 | 
            +
                        self.logger.debug(f"Processing agent: {context.agent_name}")
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                        # Check if agent needs update
         | 
| 45 | 
            +
                        needs_update, is_migration, reason = self._check_update_status(context)
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                        # Skip if exists and doesn't need update (only in update mode)
         | 
| 48 | 
            +
                        if (
         | 
| 49 | 
            +
                            context.target_file.exists()
         | 
| 50 | 
            +
                            and not needs_update
         | 
| 51 | 
            +
                            and not context.is_project_deployment()
         | 
| 52 | 
            +
                        ):
         | 
| 53 | 
            +
                            self.logger.debug(f"Skipped up-to-date agent: {context.agent_name}")
         | 
| 54 | 
            +
                            return AgentDeploymentResult.skipped(
         | 
| 55 | 
            +
                                context.agent_name,
         | 
| 56 | 
            +
                                context.template_file,
         | 
| 57 | 
            +
                                context.target_file,
         | 
| 58 | 
            +
                                reason="Agent is up-to-date",
         | 
| 59 | 
            +
                            )
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                        # Build the agent
         | 
| 62 | 
            +
                        agent_content = self._build_agent_content(context)
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                        # Deploy the agent
         | 
| 65 | 
            +
                        self._deploy_agent_content(context, agent_content)
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                        # Calculate deployment time
         | 
| 68 | 
            +
                        deployment_time_ms = (time.time() - start_time) * 1000
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                        # Determine result type
         | 
| 71 | 
            +
                        if is_migration:
         | 
| 72 | 
            +
                            self.logger.info(f"Successfully migrated agent: {context.agent_name}")
         | 
| 73 | 
            +
                            return AgentDeploymentResult.migrated(
         | 
| 74 | 
            +
                                context.agent_name,
         | 
| 75 | 
            +
                                context.template_file,
         | 
| 76 | 
            +
                                context.target_file,
         | 
| 77 | 
            +
                                deployment_time_ms,
         | 
| 78 | 
            +
                                reason,
         | 
| 79 | 
            +
                            )
         | 
| 80 | 
            +
                        elif context.is_update():
         | 
| 81 | 
            +
                            self.logger.debug(f"Updated agent: {context.agent_name}")
         | 
| 82 | 
            +
                            return AgentDeploymentResult.updated(
         | 
| 83 | 
            +
                                context.agent_name,
         | 
| 84 | 
            +
                                context.template_file,
         | 
| 85 | 
            +
                                context.target_file,
         | 
| 86 | 
            +
                                deployment_time_ms,
         | 
| 87 | 
            +
                                reason,
         | 
| 88 | 
            +
                            )
         | 
| 89 | 
            +
                        else:
         | 
| 90 | 
            +
                            self.logger.debug(f"Deployed new agent: {context.agent_name}")
         | 
| 91 | 
            +
                            return AgentDeploymentResult.deployed(
         | 
| 92 | 
            +
                                context.agent_name,
         | 
| 93 | 
            +
                                context.template_file,
         | 
| 94 | 
            +
                                context.target_file,
         | 
| 95 | 
            +
                                deployment_time_ms,
         | 
| 96 | 
            +
                            )
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                    except AgentDeploymentError as e:
         | 
| 99 | 
            +
                        # Re-raise our custom exceptions
         | 
| 100 | 
            +
                        deployment_time_ms = (time.time() - start_time) * 1000
         | 
| 101 | 
            +
                        self.logger.error(
         | 
| 102 | 
            +
                            f"Agent deployment error for {context.agent_name}: {str(e)}"
         | 
| 103 | 
            +
                        )
         | 
| 104 | 
            +
                        return AgentDeploymentResult.failed(
         | 
| 105 | 
            +
                            context.agent_name,
         | 
| 106 | 
            +
                            context.template_file,
         | 
| 107 | 
            +
                            context.target_file,
         | 
| 108 | 
            +
                            str(e),
         | 
| 109 | 
            +
                            deployment_time_ms,
         | 
| 110 | 
            +
                        )
         | 
| 111 | 
            +
                    except Exception as e:
         | 
| 112 | 
            +
                        # Wrap generic exceptions with context
         | 
| 113 | 
            +
                        deployment_time_ms = (time.time() - start_time) * 1000
         | 
| 114 | 
            +
                        error_msg = f"Failed to process {context.agent_name}: {e}"
         | 
| 115 | 
            +
                        self.logger.error(error_msg, exc_info=True)
         | 
| 116 | 
            +
                        return AgentDeploymentResult.failed(
         | 
| 117 | 
            +
                            context.agent_name,
         | 
| 118 | 
            +
                            context.template_file,
         | 
| 119 | 
            +
                            context.target_file,
         | 
| 120 | 
            +
                            error_msg,
         | 
| 121 | 
            +
                            deployment_time_ms,
         | 
| 122 | 
            +
                        )
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                def _check_update_status(self, context: AgentDeploymentContext) -> tuple:
         | 
| 125 | 
            +
                    """Check if agent needs update and determine status.
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                    Args:
         | 
| 128 | 
            +
                        context: Agent deployment context
         | 
| 129 | 
            +
             | 
| 130 | 
            +
                    Returns:
         | 
| 131 | 
            +
                        Tuple of (needs_update, is_migration, reason)
         | 
| 132 | 
            +
                    """
         | 
| 133 | 
            +
                    needs_update = context.force_rebuild
         | 
| 134 | 
            +
                    is_migration = False
         | 
| 135 | 
            +
                    reason = ""
         | 
| 136 | 
            +
             | 
| 137 | 
            +
                    # In project deployment mode, always deploy regardless of version
         | 
| 138 | 
            +
                    if context.is_project_deployment():
         | 
| 139 | 
            +
                        if context.target_file.exists():
         | 
| 140 | 
            +
                            needs_update = True
         | 
| 141 | 
            +
                            reason = "Project deployment mode"
         | 
| 142 | 
            +
                            self.logger.debug(
         | 
| 143 | 
            +
                                f"Project deployment mode: will deploy {context.agent_name}"
         | 
| 144 | 
            +
                            )
         | 
| 145 | 
            +
                        else:
         | 
| 146 | 
            +
                            needs_update = True
         | 
| 147 | 
            +
                            reason = "New agent in project mode"
         | 
| 148 | 
            +
                    elif not needs_update and context.target_file.exists():
         | 
| 149 | 
            +
                        # In update mode, check version compatibility
         | 
| 150 | 
            +
                        needs_update, reason = self.version_manager.check_agent_needs_update(
         | 
| 151 | 
            +
                            context.target_file, context.template_file, context.base_agent_version
         | 
| 152 | 
            +
                        )
         | 
| 153 | 
            +
                        if needs_update:
         | 
| 154 | 
            +
                            # Check if this is a migration from old format
         | 
| 155 | 
            +
                            if "migration needed" in reason:
         | 
| 156 | 
            +
                                is_migration = True
         | 
| 157 | 
            +
                                self.logger.info(
         | 
| 158 | 
            +
                                    f"Migration needed for agent {context.agent_name}: {reason}"
         | 
| 159 | 
            +
                                )
         | 
| 160 | 
            +
                            else:
         | 
| 161 | 
            +
                                self.logger.info(
         | 
| 162 | 
            +
                                    f"Agent {context.agent_name} needs update: {reason}"
         | 
| 163 | 
            +
                                )
         | 
| 164 | 
            +
             | 
| 165 | 
            +
                    return needs_update, is_migration, reason
         | 
| 166 | 
            +
             | 
| 167 | 
            +
                def _build_agent_content(self, context: AgentDeploymentContext) -> str:
         | 
| 168 | 
            +
                    """Build agent content from template.
         | 
| 169 | 
            +
             | 
| 170 | 
            +
                    Args:
         | 
| 171 | 
            +
                        context: Agent deployment context
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                    Returns:
         | 
| 174 | 
            +
                        Built agent content as markdown with YAML frontmatter
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                    Raises:
         | 
| 177 | 
            +
                        AgentDeploymentError: If building fails
         | 
| 178 | 
            +
                    """
         | 
| 179 | 
            +
                    try:
         | 
| 180 | 
            +
                        return self.template_builder.build_agent_markdown(
         | 
| 181 | 
            +
                            context.agent_name, context.template_file, context.base_agent_data
         | 
| 182 | 
            +
                        )
         | 
| 183 | 
            +
                    except Exception as e:
         | 
| 184 | 
            +
                        raise AgentDeploymentError(
         | 
| 185 | 
            +
                            f"Failed to build agent {context.agent_name}: {e}"
         | 
| 186 | 
            +
                        ) from e
         | 
| 187 | 
            +
             | 
| 188 | 
            +
                def _deploy_agent_content(
         | 
| 189 | 
            +
                    self, context: AgentDeploymentContext, content: str
         | 
| 190 | 
            +
                ) -> None:
         | 
| 191 | 
            +
                    """Deploy agent content to target file.
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                    Args:
         | 
| 194 | 
            +
                        context: Agent deployment context
         | 
| 195 | 
            +
                        content: Agent content to deploy
         | 
| 196 | 
            +
             | 
| 197 | 
            +
                    Raises:
         | 
| 198 | 
            +
                        AgentDeploymentError: If deployment fails
         | 
| 199 | 
            +
                    """
         | 
| 200 | 
            +
                    try:
         | 
| 201 | 
            +
                        # Ensure target directory exists
         | 
| 202 | 
            +
                        context.target_file.parent.mkdir(parents=True, exist_ok=True)
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                        # Write the agent file
         | 
| 205 | 
            +
                        context.target_file.write_text(content, encoding="utf-8")
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                        self.logger.debug(f"Successfully wrote agent file: {context.target_file}")
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                    except Exception as e:
         | 
| 210 | 
            +
                        raise AgentDeploymentError(
         | 
| 211 | 
            +
                            f"Failed to write agent {context.agent_name} to {context.target_file}: {e}"
         | 
| 212 | 
            +
                        ) from e
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                def validate_agent(self, context: AgentDeploymentContext) -> bool:
         | 
| 215 | 
            +
                    """Validate agent template before processing.
         | 
| 216 | 
            +
             | 
| 217 | 
            +
                    Args:
         | 
| 218 | 
            +
                        context: Agent deployment context
         | 
| 219 | 
            +
             | 
| 220 | 
            +
                    Returns:
         | 
| 221 | 
            +
                        True if agent is valid
         | 
| 222 | 
            +
                    """
         | 
| 223 | 
            +
                    try:
         | 
| 224 | 
            +
                        # Check if template file exists and is readable
         | 
| 225 | 
            +
                        if not context.template_file.exists():
         | 
| 226 | 
            +
                            self.logger.error(
         | 
| 227 | 
            +
                                f"Template file does not exist: {context.template_file}"
         | 
| 228 | 
            +
                            )
         | 
| 229 | 
            +
                            return False
         | 
| 230 | 
            +
             | 
| 231 | 
            +
                        if not context.template_file.is_file():
         | 
| 232 | 
            +
                            self.logger.error(
         | 
| 233 | 
            +
                                f"Template path is not a file: {context.template_file}"
         | 
| 234 | 
            +
                            )
         | 
| 235 | 
            +
                            return False
         | 
| 236 | 
            +
             | 
| 237 | 
            +
                        # Check if we can read the template
         | 
| 238 | 
            +
                        try:
         | 
| 239 | 
            +
                            context.template_file.read_text(encoding="utf-8")
         | 
| 240 | 
            +
                        except Exception as e:
         | 
| 241 | 
            +
                            self.logger.error(
         | 
| 242 | 
            +
                                f"Cannot read template file {context.template_file}: {e}"
         | 
| 243 | 
            +
                            )
         | 
| 244 | 
            +
                            return False
         | 
| 245 | 
            +
             | 
| 246 | 
            +
                        # Check if target directory is writable
         | 
| 247 | 
            +
                        if context.target_file.parent.exists():
         | 
| 248 | 
            +
                            if not context.target_file.parent.is_dir():
         | 
| 249 | 
            +
                                self.logger.error(
         | 
| 250 | 
            +
                                    f"Target parent is not a directory: {context.target_file.parent}"
         | 
| 251 | 
            +
                                )
         | 
| 252 | 
            +
                                return False
         | 
| 253 | 
            +
             | 
| 254 | 
            +
                        return True
         | 
| 255 | 
            +
             | 
| 256 | 
            +
                    except Exception as e:
         | 
| 257 | 
            +
                        self.logger.error(f"Validation error for agent {context.agent_name}: {e}")
         | 
| 258 | 
            +
                        return False
         | 
| @@ -0,0 +1,318 @@ | |
| 1 | 
            +
            """Refactored Agent Deployment Service using new architecture."""
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            from pathlib import Path
         | 
| 4 | 
            +
            from typing import Any, Dict, List, Optional, Tuple
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            from claude_mpm.core.config import Config
         | 
| 7 | 
            +
            from claude_mpm.core.interfaces import AgentDeploymentInterface
         | 
| 8 | 
            +
            from claude_mpm.core.logger import get_logger
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            from .config import DeploymentConfigManager
         | 
| 11 | 
            +
            from .facade import DeploymentFacade
         | 
| 12 | 
            +
            from .pipeline import (
         | 
| 13 | 
            +
                DeploymentPipelineBuilder,
         | 
| 14 | 
            +
                DeploymentPipelineExecutor,
         | 
| 15 | 
            +
                PipelineContext,
         | 
| 16 | 
            +
            )
         | 
| 17 | 
            +
            from .processors import AgentProcessor
         | 
| 18 | 
            +
            from .results import DeploymentMetrics, DeploymentResultBuilder
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            # Import refactored components
         | 
| 21 | 
            +
            from .strategies import DeploymentContext, DeploymentStrategySelector
         | 
| 22 | 
            +
            from .validation import DeploymentValidator
         | 
| 23 | 
            +
             | 
| 24 | 
            +
             | 
| 25 | 
            +
            class RefactoredAgentDeploymentService(AgentDeploymentInterface):
         | 
| 26 | 
            +
                """Refactored Agent Deployment Service.
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                This service uses the new modular architecture with:
         | 
| 29 | 
            +
                - Strategy pattern for deployment types
         | 
| 30 | 
            +
                - Pipeline pattern for deployment flow
         | 
| 31 | 
            +
                - Facade pattern for async/sync execution
         | 
| 32 | 
            +
                - Dedicated validation and processing components
         | 
| 33 | 
            +
                """
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                def __init__(
         | 
| 36 | 
            +
                    self,
         | 
| 37 | 
            +
                    templates_dir: Optional[Path] = None,
         | 
| 38 | 
            +
                    base_agent_path: Optional[Path] = None,
         | 
| 39 | 
            +
                    working_directory: Optional[Path] = None,
         | 
| 40 | 
            +
                ):
         | 
| 41 | 
            +
                    """Initialize the refactored deployment service.
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                    Args:
         | 
| 44 | 
            +
                        templates_dir: Directory containing agent templates
         | 
| 45 | 
            +
                        base_agent_path: Path to base agent configuration
         | 
| 46 | 
            +
                        working_directory: Working directory for deployment
         | 
| 47 | 
            +
                    """
         | 
| 48 | 
            +
                    self.logger = get_logger(__name__)
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                    # Set up directories
         | 
| 51 | 
            +
                    self.working_directory = working_directory or Path.cwd()
         | 
| 52 | 
            +
                    self.templates_dir = templates_dir or self.working_directory / "agents"
         | 
| 53 | 
            +
                    self.base_agent_path = (
         | 
| 54 | 
            +
                        base_agent_path or self.working_directory / "base_agent.md"
         | 
| 55 | 
            +
                    )
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                    # Initialize components
         | 
| 58 | 
            +
                    self.strategy_selector = DeploymentStrategySelector()
         | 
| 59 | 
            +
                    self.config_manager = DeploymentConfigManager()
         | 
| 60 | 
            +
                    self.validator = DeploymentValidator()
         | 
| 61 | 
            +
                    self.result_builder = DeploymentResultBuilder()
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                    # Initialize pipeline components
         | 
| 64 | 
            +
                    self.pipeline_builder = DeploymentPipelineBuilder()
         | 
| 65 | 
            +
                    self.pipeline_executor = DeploymentPipelineExecutor()
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                    # Initialize facade for async/sync execution
         | 
| 68 | 
            +
                    self.deployment_facade = DeploymentFacade(
         | 
| 69 | 
            +
                        self.pipeline_builder, self.pipeline_executor
         | 
| 70 | 
            +
                    )
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                    self.logger.info(f"Refactored deployment service initialized")
         | 
| 73 | 
            +
                    self.logger.info(f"Templates directory: {self.templates_dir}")
         | 
| 74 | 
            +
                    self.logger.info(f"Base agent path: {self.base_agent_path}")
         | 
| 75 | 
            +
                    self.logger.info(f"Working directory: {self.working_directory}")
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                def deploy_agents(
         | 
| 78 | 
            +
                    self, force: bool = False, include_all: bool = False
         | 
| 79 | 
            +
                ) -> Dict[str, Any]:
         | 
| 80 | 
            +
                    """Deploy agents to target environment.
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                    Args:
         | 
| 83 | 
            +
                        force: Force deployment even if agents already exist
         | 
| 84 | 
            +
                        include_all: Include all agents, ignoring exclusion lists
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                    Returns:
         | 
| 87 | 
            +
                        Dictionary with deployment results and status
         | 
| 88 | 
            +
                    """
         | 
| 89 | 
            +
                    try:
         | 
| 90 | 
            +
                        self.logger.info(
         | 
| 91 | 
            +
                            f"Starting agent deployment (force={force}, include_all={include_all})"
         | 
| 92 | 
            +
                        )
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                        # Create deployment context
         | 
| 95 | 
            +
                        deployment_context = DeploymentContext(
         | 
| 96 | 
            +
                            templates_dir=self.templates_dir,
         | 
| 97 | 
            +
                            base_agent_path=self.base_agent_path,
         | 
| 98 | 
            +
                            working_directory=self.working_directory,
         | 
| 99 | 
            +
                            force_rebuild=force,
         | 
| 100 | 
            +
                            deployment_mode="project" if include_all else "update",
         | 
| 101 | 
            +
                        )
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                        # Select deployment strategy
         | 
| 104 | 
            +
                        strategy = self.strategy_selector.select_strategy(deployment_context)
         | 
| 105 | 
            +
                        self.logger.info(
         | 
| 106 | 
            +
                            f"Selected deployment strategy: {strategy.__class__.__name__}"
         | 
| 107 | 
            +
                        )
         | 
| 108 | 
            +
             | 
| 109 | 
            +
                        # Use facade to execute deployment
         | 
| 110 | 
            +
                        results = self.deployment_facade.deploy_agents(
         | 
| 111 | 
            +
                            templates_dir=self.templates_dir,
         | 
| 112 | 
            +
                            base_agent_path=self.base_agent_path,
         | 
| 113 | 
            +
                            working_directory=self.working_directory,
         | 
| 114 | 
            +
                            target_dir=strategy.determine_target_directory(deployment_context),
         | 
| 115 | 
            +
                            force_rebuild=force,
         | 
| 116 | 
            +
                            deployment_mode=deployment_context.deployment_mode,
         | 
| 117 | 
            +
                            config=None,  # Use default configuration
         | 
| 118 | 
            +
                            use_async=False,  # Default to sync for interface compliance
         | 
| 119 | 
            +
                        )
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                        # Ensure success field is present
         | 
| 122 | 
            +
                        if "success" not in results:
         | 
| 123 | 
            +
                            results["success"] = not bool(results.get("errors", []))
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                        self.logger.info(f"Deployment completed: {results.get('success', False)}")
         | 
| 126 | 
            +
                        return results
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                    except Exception as e:
         | 
| 129 | 
            +
                        self.logger.error(f"Deployment failed: {e}", exc_info=True)
         | 
| 130 | 
            +
                        return {
         | 
| 131 | 
            +
                            "success": False,
         | 
| 132 | 
            +
                            "error": str(e),
         | 
| 133 | 
            +
                            "deployed": [],
         | 
| 134 | 
            +
                            "updated": [],
         | 
| 135 | 
            +
                            "migrated": [],
         | 
| 136 | 
            +
                            "skipped": [],
         | 
| 137 | 
            +
                            "errors": [str(e)],
         | 
| 138 | 
            +
                            "metadata": {
         | 
| 139 | 
            +
                                "service_version": "refactored-1.0.0",
         | 
| 140 | 
            +
                                "error_type": type(e).__name__,
         | 
| 141 | 
            +
                            },
         | 
| 142 | 
            +
                        }
         | 
| 143 | 
            +
             | 
| 144 | 
            +
                def validate_agent(self, agent_path: Path) -> Tuple[bool, List[str]]:
         | 
| 145 | 
            +
                    """Validate agent configuration and structure.
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                    Args:
         | 
| 148 | 
            +
                        agent_path: Path to agent configuration file
         | 
| 149 | 
            +
             | 
| 150 | 
            +
                    Returns:
         | 
| 151 | 
            +
                        Tuple of (is_valid, list_of_errors)
         | 
| 152 | 
            +
                    """
         | 
| 153 | 
            +
                    try:
         | 
| 154 | 
            +
                        # Use the validation service
         | 
| 155 | 
            +
                        if agent_path.suffix == ".json":
         | 
| 156 | 
            +
                            # Template file validation
         | 
| 157 | 
            +
                            result = self.validator.template_validator.validate_template_file(
         | 
| 158 | 
            +
                                agent_path
         | 
| 159 | 
            +
                            )
         | 
| 160 | 
            +
                        else:
         | 
| 161 | 
            +
                            # Agent file validation
         | 
| 162 | 
            +
                            result = self.validator.agent_validator.validate_agent_file(agent_path)
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                        # Convert validation result to interface format
         | 
| 165 | 
            +
                        errors = [str(issue) for issue in result.errors]
         | 
| 166 | 
            +
                        return result.is_valid, errors
         | 
| 167 | 
            +
             | 
| 168 | 
            +
                    except Exception as e:
         | 
| 169 | 
            +
                        self.logger.error(f"Agent validation failed: {e}", exc_info=True)
         | 
| 170 | 
            +
                        return False, [f"Validation error: {str(e)}"]
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                def clean_deployment(self, preserve_user_agents: bool = True) -> bool:
         | 
| 173 | 
            +
                    """Clean up deployed agents.
         | 
| 174 | 
            +
             | 
| 175 | 
            +
                    Args:
         | 
| 176 | 
            +
                        preserve_user_agents: Whether to keep user-created agents
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                    Returns:
         | 
| 179 | 
            +
                        True if cleanup successful
         | 
| 180 | 
            +
                    """
         | 
| 181 | 
            +
                    try:
         | 
| 182 | 
            +
                        self.logger.info(
         | 
| 183 | 
            +
                            f"Cleaning deployment (preserve_user_agents={preserve_user_agents})"
         | 
| 184 | 
            +
                        )
         | 
| 185 | 
            +
             | 
| 186 | 
            +
                        # Find agents directory
         | 
| 187 | 
            +
                        agents_dir = self.working_directory / ".claude" / "agents"
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                        if not agents_dir.exists():
         | 
| 190 | 
            +
                            self.logger.info("No agents directory to clean")
         | 
| 191 | 
            +
                            return True
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                        cleaned_count = 0
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                        # Clean up agent files
         | 
| 196 | 
            +
                        for agent_file in agents_dir.glob("*.md"):
         | 
| 197 | 
            +
                            try:
         | 
| 198 | 
            +
                                if preserve_user_agents:
         | 
| 199 | 
            +
                                    # Check if this is a system agent (authored by claude-mpm)
         | 
| 200 | 
            +
                                    content = agent_file.read_text(encoding="utf-8")
         | 
| 201 | 
            +
                                    if (
         | 
| 202 | 
            +
                                        "author: claude-mpm" not in content
         | 
| 203 | 
            +
                                        and "author: 'claude-mpm'" not in content
         | 
| 204 | 
            +
                                    ):
         | 
| 205 | 
            +
                                        self.logger.debug(
         | 
| 206 | 
            +
                                            f"Preserving user agent: {agent_file.name}"
         | 
| 207 | 
            +
                                        )
         | 
| 208 | 
            +
                                        continue
         | 
| 209 | 
            +
             | 
| 210 | 
            +
                                # Remove the agent file
         | 
| 211 | 
            +
                                agent_file.unlink()
         | 
| 212 | 
            +
                                cleaned_count += 1
         | 
| 213 | 
            +
                                self.logger.debug(f"Cleaned agent: {agent_file.name}")
         | 
| 214 | 
            +
             | 
| 215 | 
            +
                            except Exception as e:
         | 
| 216 | 
            +
                                self.logger.warning(f"Failed to clean agent {agent_file.name}: {e}")
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                        self.logger.info(f"Cleaned {cleaned_count} agent files")
         | 
| 219 | 
            +
                        return True
         | 
| 220 | 
            +
             | 
| 221 | 
            +
                    except Exception as e:
         | 
| 222 | 
            +
                        self.logger.error(f"Deployment cleanup failed: {e}", exc_info=True)
         | 
| 223 | 
            +
                        return False
         | 
| 224 | 
            +
             | 
| 225 | 
            +
                def get_deployment_status(self) -> Dict[str, Any]:
         | 
| 226 | 
            +
                    """Get current deployment status and metrics.
         | 
| 227 | 
            +
             | 
| 228 | 
            +
                    Returns:
         | 
| 229 | 
            +
                        Dictionary with deployment status information
         | 
| 230 | 
            +
                    """
         | 
| 231 | 
            +
                    try:
         | 
| 232 | 
            +
                        # Get metrics from the result builder
         | 
| 233 | 
            +
                        metrics_data = self.result_builder.metrics.get_summary()
         | 
| 234 | 
            +
             | 
| 235 | 
            +
                        # Get available executors from facade
         | 
| 236 | 
            +
                        available_executors = self.deployment_facade.get_available_executors()
         | 
| 237 | 
            +
             | 
| 238 | 
            +
                        # Build status information
         | 
| 239 | 
            +
                        status = {
         | 
| 240 | 
            +
                            "service_version": "refactored-1.0.0",
         | 
| 241 | 
            +
                            "status": "ready",
         | 
| 242 | 
            +
                            "templates_dir": str(self.templates_dir),
         | 
| 243 | 
            +
                            "base_agent_path": str(self.base_agent_path),
         | 
| 244 | 
            +
                            "working_directory": str(self.working_directory),
         | 
| 245 | 
            +
                            "metrics": metrics_data,
         | 
| 246 | 
            +
                            "available_executors": available_executors,
         | 
| 247 | 
            +
                            "components": {
         | 
| 248 | 
            +
                                "strategy_selector": True,
         | 
| 249 | 
            +
                                "config_manager": True,
         | 
| 250 | 
            +
                                "validator": True,
         | 
| 251 | 
            +
                                "pipeline_builder": True,
         | 
| 252 | 
            +
                                "pipeline_executor": True,
         | 
| 253 | 
            +
                                "deployment_facade": True,
         | 
| 254 | 
            +
                            },
         | 
| 255 | 
            +
                        }
         | 
| 256 | 
            +
             | 
| 257 | 
            +
                        return status
         | 
| 258 | 
            +
             | 
| 259 | 
            +
                    except Exception as e:
         | 
| 260 | 
            +
                        self.logger.error(f"Failed to get deployment status: {e}", exc_info=True)
         | 
| 261 | 
            +
                        return {
         | 
| 262 | 
            +
                            "service_version": "refactored-1.0.0",
         | 
| 263 | 
            +
                            "status": "error",
         | 
| 264 | 
            +
                            "error": str(e),
         | 
| 265 | 
            +
                        }
         | 
| 266 | 
            +
             | 
| 267 | 
            +
                # Additional convenience methods for enhanced functionality
         | 
| 268 | 
            +
             | 
| 269 | 
            +
                def deploy_agents_async(
         | 
| 270 | 
            +
                    self, force: bool = False, include_all: bool = False
         | 
| 271 | 
            +
                ) -> Dict[str, Any]:
         | 
| 272 | 
            +
                    """Deploy agents using async execution if available.
         | 
| 273 | 
            +
             | 
| 274 | 
            +
                    Args:
         | 
| 275 | 
            +
                        force: Force deployment even if agents already exist
         | 
| 276 | 
            +
                        include_all: Include all agents, ignoring exclusion lists
         | 
| 277 | 
            +
             | 
| 278 | 
            +
                    Returns:
         | 
| 279 | 
            +
                        Dictionary with deployment results and status
         | 
| 280 | 
            +
                    """
         | 
| 281 | 
            +
                    try:
         | 
| 282 | 
            +
                        # Create deployment context
         | 
| 283 | 
            +
                        deployment_context = DeploymentContext(
         | 
| 284 | 
            +
                            templates_dir=self.templates_dir,
         | 
| 285 | 
            +
                            base_agent_path=self.base_agent_path,
         | 
| 286 | 
            +
                            working_directory=self.working_directory,
         | 
| 287 | 
            +
                            force_rebuild=force,
         | 
| 288 | 
            +
                            deployment_mode="project" if include_all else "update",
         | 
| 289 | 
            +
                        )
         | 
| 290 | 
            +
             | 
| 291 | 
            +
                        # Select deployment strategy
         | 
| 292 | 
            +
                        strategy = self.strategy_selector.select_strategy(deployment_context)
         | 
| 293 | 
            +
             | 
| 294 | 
            +
                        # Use facade with synchronous deployment for reliability
         | 
| 295 | 
            +
                        results = self.deployment_facade.deploy_agents(
         | 
| 296 | 
            +
                            templates_dir=self.templates_dir,
         | 
| 297 | 
            +
                            base_agent_path=self.base_agent_path,
         | 
| 298 | 
            +
                            working_directory=self.working_directory,
         | 
| 299 | 
            +
                            target_dir=strategy.determine_target_directory(deployment_context),
         | 
| 300 | 
            +
                            force_rebuild=force,
         | 
| 301 | 
            +
                            deployment_mode=deployment_context.deployment_mode,
         | 
| 302 | 
            +
                            config=None,
         | 
| 303 | 
            +
                            use_async=False,  # Use synchronous deployment to ensure agents are ready when Claude Code launches
         | 
| 304 | 
            +
                        )
         | 
| 305 | 
            +
             | 
| 306 | 
            +
                        return results
         | 
| 307 | 
            +
             | 
| 308 | 
            +
                    except Exception as e:
         | 
| 309 | 
            +
                        self.logger.error(f"Async deployment failed: {e}", exc_info=True)
         | 
| 310 | 
            +
                        return {
         | 
| 311 | 
            +
                            "success": False,
         | 
| 312 | 
            +
                            "error": str(e),
         | 
| 313 | 
            +
                            "deployed": [],
         | 
| 314 | 
            +
                            "updated": [],
         | 
| 315 | 
            +
                            "migrated": [],
         | 
| 316 | 
            +
                            "skipped": [],
         | 
| 317 | 
            +
                            "errors": [str(e)],
         | 
| 318 | 
            +
                        }
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            """Deployment results management.
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            This module provides classes for building and managing deployment results,
         | 
| 4 | 
            +
            including metrics collection and result formatting.
         | 
| 5 | 
            +
            """
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            from .deployment_metrics import DeploymentMetrics
         | 
| 8 | 
            +
            from .deployment_result_builder import DeploymentResultBuilder
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            __all__ = [
         | 
| 11 | 
            +
                "DeploymentResultBuilder",
         | 
| 12 | 
            +
                "DeploymentMetrics",
         | 
| 13 | 
            +
            ]
         |