claude-mpm 4.7.4__py3-none-any.whl → 4.18.2__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 (308) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/agents/BASE_AGENT_TEMPLATE.md +118 -0
  3. claude_mpm/agents/BASE_ENGINEER.md +286 -0
  4. claude_mpm/agents/BASE_PM.md +106 -1
  5. claude_mpm/agents/OUTPUT_STYLE.md +329 -11
  6. claude_mpm/agents/PM_INSTRUCTIONS.md +397 -459
  7. claude_mpm/agents/agent_loader.py +17 -5
  8. claude_mpm/agents/frontmatter_validator.py +284 -253
  9. claude_mpm/agents/templates/README.md +465 -0
  10. claude_mpm/agents/templates/agent-manager.json +4 -1
  11. claude_mpm/agents/templates/agentic-coder-optimizer.json +13 -3
  12. claude_mpm/agents/templates/api_qa.json +11 -2
  13. claude_mpm/agents/templates/circuit_breakers.md +638 -0
  14. claude_mpm/agents/templates/clerk-ops.json +12 -2
  15. claude_mpm/agents/templates/code_analyzer.json +8 -2
  16. claude_mpm/agents/templates/content-agent.json +358 -0
  17. claude_mpm/agents/templates/dart_engineer.json +15 -2
  18. claude_mpm/agents/templates/data_engineer.json +15 -2
  19. claude_mpm/agents/templates/documentation.json +10 -2
  20. claude_mpm/agents/templates/engineer.json +21 -1
  21. claude_mpm/agents/templates/gcp_ops_agent.json +12 -2
  22. claude_mpm/agents/templates/git_file_tracking.md +584 -0
  23. claude_mpm/agents/templates/golang_engineer.json +270 -0
  24. claude_mpm/agents/templates/imagemagick.json +4 -1
  25. claude_mpm/agents/templates/java_engineer.json +346 -0
  26. claude_mpm/agents/templates/local_ops_agent.json +1227 -6
  27. claude_mpm/agents/templates/memory_manager.json +4 -1
  28. claude_mpm/agents/templates/nextjs_engineer.json +141 -133
  29. claude_mpm/agents/templates/ops.json +12 -2
  30. claude_mpm/agents/templates/php-engineer.json +270 -174
  31. claude_mpm/agents/templates/pm_examples.md +474 -0
  32. claude_mpm/agents/templates/pm_red_flags.md +240 -0
  33. claude_mpm/agents/templates/product_owner.json +338 -0
  34. claude_mpm/agents/templates/project_organizer.json +14 -4
  35. claude_mpm/agents/templates/prompt-engineer.json +13 -2
  36. claude_mpm/agents/templates/python_engineer.json +174 -81
  37. claude_mpm/agents/templates/qa.json +11 -2
  38. claude_mpm/agents/templates/react_engineer.json +16 -3
  39. claude_mpm/agents/templates/refactoring_engineer.json +12 -2
  40. claude_mpm/agents/templates/research.json +34 -21
  41. claude_mpm/agents/templates/response_format.md +583 -0
  42. claude_mpm/agents/templates/ruby-engineer.json +129 -192
  43. claude_mpm/agents/templates/rust_engineer.json +270 -0
  44. claude_mpm/agents/templates/security.json +10 -2
  45. claude_mpm/agents/templates/svelte-engineer.json +225 -0
  46. claude_mpm/agents/templates/ticketing.json +10 -2
  47. claude_mpm/agents/templates/typescript_engineer.json +116 -125
  48. claude_mpm/agents/templates/validation_templates.md +312 -0
  49. claude_mpm/agents/templates/vercel_ops_agent.json +12 -2
  50. claude_mpm/agents/templates/version_control.json +12 -2
  51. claude_mpm/agents/templates/web_qa.json +11 -2
  52. claude_mpm/agents/templates/web_ui.json +15 -2
  53. claude_mpm/cli/__init__.py +34 -614
  54. claude_mpm/cli/commands/agent_manager.py +25 -12
  55. claude_mpm/cli/commands/agent_state_manager.py +186 -0
  56. claude_mpm/cli/commands/agents.py +235 -148
  57. claude_mpm/cli/commands/agents_detect.py +380 -0
  58. claude_mpm/cli/commands/agents_recommend.py +309 -0
  59. claude_mpm/cli/commands/aggregate.py +7 -3
  60. claude_mpm/cli/commands/analyze.py +9 -4
  61. claude_mpm/cli/commands/analyze_code.py +7 -2
  62. claude_mpm/cli/commands/auto_configure.py +570 -0
  63. claude_mpm/cli/commands/config.py +47 -13
  64. claude_mpm/cli/commands/configure.py +419 -1571
  65. claude_mpm/cli/commands/configure_agent_display.py +261 -0
  66. claude_mpm/cli/commands/configure_behavior_manager.py +204 -0
  67. claude_mpm/cli/commands/configure_hook_manager.py +225 -0
  68. claude_mpm/cli/commands/configure_models.py +18 -0
  69. claude_mpm/cli/commands/configure_navigation.py +167 -0
  70. claude_mpm/cli/commands/configure_paths.py +104 -0
  71. claude_mpm/cli/commands/configure_persistence.py +254 -0
  72. claude_mpm/cli/commands/configure_startup_manager.py +646 -0
  73. claude_mpm/cli/commands/configure_template_editor.py +497 -0
  74. claude_mpm/cli/commands/configure_validators.py +73 -0
  75. claude_mpm/cli/commands/local_deploy.py +537 -0
  76. claude_mpm/cli/commands/memory.py +54 -20
  77. claude_mpm/cli/commands/mpm_init.py +585 -196
  78. claude_mpm/cli/commands/mpm_init_handler.py +37 -3
  79. claude_mpm/cli/commands/search.py +170 -4
  80. claude_mpm/cli/commands/upgrade.py +152 -0
  81. claude_mpm/cli/executor.py +202 -0
  82. claude_mpm/cli/helpers.py +105 -0
  83. claude_mpm/cli/interactive/__init__.py +3 -0
  84. claude_mpm/cli/interactive/skills_wizard.py +491 -0
  85. claude_mpm/cli/parsers/__init__.py +7 -1
  86. claude_mpm/cli/parsers/agents_parser.py +9 -0
  87. claude_mpm/cli/parsers/auto_configure_parser.py +245 -0
  88. claude_mpm/cli/parsers/base_parser.py +110 -3
  89. claude_mpm/cli/parsers/local_deploy_parser.py +227 -0
  90. claude_mpm/cli/parsers/mpm_init_parser.py +65 -5
  91. claude_mpm/cli/shared/output_formatters.py +28 -19
  92. claude_mpm/cli/startup.py +481 -0
  93. claude_mpm/cli/utils.py +52 -1
  94. claude_mpm/commands/mpm-agents-detect.md +168 -0
  95. claude_mpm/commands/mpm-agents-recommend.md +214 -0
  96. claude_mpm/commands/mpm-agents.md +75 -1
  97. claude_mpm/commands/mpm-auto-configure.md +217 -0
  98. claude_mpm/commands/mpm-help.md +163 -0
  99. claude_mpm/commands/mpm-init.md +148 -3
  100. claude_mpm/commands/mpm-version.md +113 -0
  101. claude_mpm/commands/mpm.md +1 -0
  102. claude_mpm/config/agent_config.py +2 -2
  103. claude_mpm/config/model_config.py +428 -0
  104. claude_mpm/constants.py +1 -0
  105. claude_mpm/core/base_service.py +13 -12
  106. claude_mpm/core/enums.py +452 -0
  107. claude_mpm/core/factories.py +1 -1
  108. claude_mpm/core/instruction_reinforcement_hook.py +2 -1
  109. claude_mpm/core/interactive_session.py +9 -3
  110. claude_mpm/core/log_manager.py +2 -0
  111. claude_mpm/core/logging_config.py +6 -2
  112. claude_mpm/core/oneshot_session.py +8 -4
  113. claude_mpm/core/optimized_agent_loader.py +3 -3
  114. claude_mpm/core/output_style_manager.py +12 -192
  115. claude_mpm/core/service_registry.py +5 -1
  116. claude_mpm/core/types.py +2 -9
  117. claude_mpm/core/typing_utils.py +7 -6
  118. claude_mpm/dashboard/static/js/dashboard.js +0 -14
  119. claude_mpm/dashboard/templates/index.html +3 -41
  120. claude_mpm/hooks/__init__.py +20 -0
  121. claude_mpm/hooks/claude_hooks/event_handlers.py +4 -2
  122. claude_mpm/hooks/claude_hooks/response_tracking.py +35 -1
  123. claude_mpm/hooks/claude_hooks/services/connection_manager_http.py +23 -2
  124. claude_mpm/hooks/failure_learning/__init__.py +60 -0
  125. claude_mpm/hooks/failure_learning/failure_detection_hook.py +235 -0
  126. claude_mpm/hooks/failure_learning/fix_detection_hook.py +217 -0
  127. claude_mpm/hooks/failure_learning/learning_extraction_hook.py +286 -0
  128. claude_mpm/hooks/instruction_reinforcement.py +7 -2
  129. claude_mpm/hooks/kuzu_enrichment_hook.py +263 -0
  130. claude_mpm/hooks/kuzu_memory_hook.py +37 -12
  131. claude_mpm/hooks/kuzu_response_hook.py +183 -0
  132. claude_mpm/models/resume_log.py +340 -0
  133. claude_mpm/services/agents/__init__.py +18 -5
  134. claude_mpm/services/agents/auto_config_manager.py +796 -0
  135. claude_mpm/services/agents/deployment/agent_configuration_manager.py +1 -1
  136. claude_mpm/services/agents/deployment/agent_record_service.py +1 -1
  137. claude_mpm/services/agents/deployment/agent_validator.py +17 -1
  138. claude_mpm/services/agents/deployment/async_agent_deployment.py +1 -1
  139. claude_mpm/services/agents/deployment/interface_adapter.py +3 -2
  140. claude_mpm/services/agents/deployment/local_template_deployment.py +1 -1
  141. claude_mpm/services/agents/deployment/pipeline/steps/agent_processing_step.py +7 -6
  142. claude_mpm/services/agents/deployment/pipeline/steps/base_step.py +7 -16
  143. claude_mpm/services/agents/deployment/pipeline/steps/configuration_step.py +4 -3
  144. claude_mpm/services/agents/deployment/pipeline/steps/target_directory_step.py +5 -3
  145. claude_mpm/services/agents/deployment/pipeline/steps/validation_step.py +6 -5
  146. claude_mpm/services/agents/deployment/refactored_agent_deployment_service.py +9 -6
  147. claude_mpm/services/agents/deployment/validation/__init__.py +3 -1
  148. claude_mpm/services/agents/deployment/validation/validation_result.py +1 -9
  149. claude_mpm/services/agents/local_template_manager.py +1 -1
  150. claude_mpm/services/agents/memory/agent_memory_manager.py +5 -2
  151. claude_mpm/services/agents/observers.py +547 -0
  152. claude_mpm/services/agents/recommender.py +568 -0
  153. claude_mpm/services/agents/registry/modification_tracker.py +5 -2
  154. claude_mpm/services/command_handler_service.py +11 -5
  155. claude_mpm/services/core/__init__.py +33 -1
  156. claude_mpm/services/core/interfaces/__init__.py +90 -3
  157. claude_mpm/services/core/interfaces/agent.py +184 -0
  158. claude_mpm/services/core/interfaces/health.py +172 -0
  159. claude_mpm/services/core/interfaces/model.py +281 -0
  160. claude_mpm/services/core/interfaces/process.py +372 -0
  161. claude_mpm/services/core/interfaces/project.py +121 -0
  162. claude_mpm/services/core/interfaces/restart.py +307 -0
  163. claude_mpm/services/core/interfaces/stability.py +260 -0
  164. claude_mpm/services/core/memory_manager.py +11 -24
  165. claude_mpm/services/core/models/__init__.py +79 -0
  166. claude_mpm/services/core/models/agent_config.py +381 -0
  167. claude_mpm/services/core/models/health.py +162 -0
  168. claude_mpm/services/core/models/process.py +235 -0
  169. claude_mpm/services/core/models/restart.py +302 -0
  170. claude_mpm/services/core/models/stability.py +264 -0
  171. claude_mpm/services/core/models/toolchain.py +306 -0
  172. claude_mpm/services/core/path_resolver.py +23 -7
  173. claude_mpm/services/diagnostics/__init__.py +2 -2
  174. claude_mpm/services/diagnostics/checks/agent_check.py +25 -24
  175. claude_mpm/services/diagnostics/checks/claude_code_check.py +24 -23
  176. claude_mpm/services/diagnostics/checks/common_issues_check.py +25 -24
  177. claude_mpm/services/diagnostics/checks/configuration_check.py +24 -23
  178. claude_mpm/services/diagnostics/checks/filesystem_check.py +18 -17
  179. claude_mpm/services/diagnostics/checks/installation_check.py +30 -29
  180. claude_mpm/services/diagnostics/checks/instructions_check.py +20 -19
  181. claude_mpm/services/diagnostics/checks/mcp_check.py +50 -36
  182. claude_mpm/services/diagnostics/checks/mcp_services_check.py +38 -33
  183. claude_mpm/services/diagnostics/checks/monitor_check.py +23 -22
  184. claude_mpm/services/diagnostics/checks/startup_log_check.py +9 -8
  185. claude_mpm/services/diagnostics/diagnostic_runner.py +6 -5
  186. claude_mpm/services/diagnostics/doctor_reporter.py +28 -25
  187. claude_mpm/services/diagnostics/models.py +19 -24
  188. claude_mpm/services/infrastructure/monitoring/__init__.py +1 -1
  189. claude_mpm/services/infrastructure/monitoring/aggregator.py +12 -12
  190. claude_mpm/services/infrastructure/monitoring/base.py +5 -13
  191. claude_mpm/services/infrastructure/monitoring/network.py +7 -6
  192. claude_mpm/services/infrastructure/monitoring/process.py +13 -12
  193. claude_mpm/services/infrastructure/monitoring/resources.py +7 -6
  194. claude_mpm/services/infrastructure/monitoring/service.py +16 -15
  195. claude_mpm/services/infrastructure/resume_log_generator.py +439 -0
  196. claude_mpm/services/local_ops/__init__.py +163 -0
  197. claude_mpm/services/local_ops/crash_detector.py +257 -0
  198. claude_mpm/services/local_ops/health_checks/__init__.py +28 -0
  199. claude_mpm/services/local_ops/health_checks/http_check.py +224 -0
  200. claude_mpm/services/local_ops/health_checks/process_check.py +236 -0
  201. claude_mpm/services/local_ops/health_checks/resource_check.py +255 -0
  202. claude_mpm/services/local_ops/health_manager.py +430 -0
  203. claude_mpm/services/local_ops/log_monitor.py +396 -0
  204. claude_mpm/services/local_ops/memory_leak_detector.py +294 -0
  205. claude_mpm/services/local_ops/process_manager.py +595 -0
  206. claude_mpm/services/local_ops/resource_monitor.py +331 -0
  207. claude_mpm/services/local_ops/restart_manager.py +401 -0
  208. claude_mpm/services/local_ops/restart_policy.py +387 -0
  209. claude_mpm/services/local_ops/state_manager.py +372 -0
  210. claude_mpm/services/local_ops/unified_manager.py +600 -0
  211. claude_mpm/services/mcp_config_manager.py +9 -4
  212. claude_mpm/services/mcp_gateway/core/__init__.py +1 -2
  213. claude_mpm/services/mcp_gateway/core/base.py +18 -31
  214. claude_mpm/services/mcp_gateway/main.py +30 -0
  215. claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +206 -32
  216. claude_mpm/services/mcp_gateway/tools/health_check_tool.py +30 -28
  217. claude_mpm/services/mcp_gateway/tools/kuzu_memory_service.py +25 -5
  218. claude_mpm/services/mcp_service_verifier.py +1 -1
  219. claude_mpm/services/memory/failure_tracker.py +563 -0
  220. claude_mpm/services/memory_hook_service.py +165 -4
  221. claude_mpm/services/model/__init__.py +147 -0
  222. claude_mpm/services/model/base_provider.py +365 -0
  223. claude_mpm/services/model/claude_provider.py +412 -0
  224. claude_mpm/services/model/model_router.py +453 -0
  225. claude_mpm/services/model/ollama_provider.py +415 -0
  226. claude_mpm/services/monitor/daemon_manager.py +3 -2
  227. claude_mpm/services/monitor/handlers/dashboard.py +2 -1
  228. claude_mpm/services/monitor/handlers/hooks.py +2 -1
  229. claude_mpm/services/monitor/management/lifecycle.py +3 -2
  230. claude_mpm/services/monitor/server.py +2 -1
  231. claude_mpm/services/project/__init__.py +23 -0
  232. claude_mpm/services/project/detection_strategies.py +719 -0
  233. claude_mpm/services/project/toolchain_analyzer.py +581 -0
  234. claude_mpm/services/self_upgrade_service.py +342 -0
  235. claude_mpm/services/session_management_service.py +3 -2
  236. claude_mpm/services/session_manager.py +205 -1
  237. claude_mpm/services/shared/async_service_base.py +16 -27
  238. claude_mpm/services/shared/lifecycle_service_base.py +1 -14
  239. claude_mpm/services/socketio/handlers/__init__.py +5 -2
  240. claude_mpm/services/socketio/handlers/hook.py +13 -2
  241. claude_mpm/services/socketio/handlers/registry.py +4 -2
  242. claude_mpm/services/socketio/server/main.py +10 -8
  243. claude_mpm/services/subprocess_launcher_service.py +14 -5
  244. claude_mpm/services/unified/analyzer_strategies/code_analyzer.py +8 -7
  245. claude_mpm/services/unified/analyzer_strategies/dependency_analyzer.py +6 -5
  246. claude_mpm/services/unified/analyzer_strategies/performance_analyzer.py +8 -7
  247. claude_mpm/services/unified/analyzer_strategies/security_analyzer.py +7 -6
  248. claude_mpm/services/unified/analyzer_strategies/structure_analyzer.py +5 -4
  249. claude_mpm/services/unified/config_strategies/validation_strategy.py +13 -9
  250. claude_mpm/services/unified/deployment_strategies/cloud_strategies.py +10 -3
  251. claude_mpm/services/unified/deployment_strategies/local.py +6 -5
  252. claude_mpm/services/unified/deployment_strategies/utils.py +6 -5
  253. claude_mpm/services/unified/deployment_strategies/vercel.py +7 -6
  254. claude_mpm/services/unified/interfaces.py +3 -1
  255. claude_mpm/services/unified/unified_analyzer.py +14 -10
  256. claude_mpm/services/unified/unified_config.py +2 -1
  257. claude_mpm/services/unified/unified_deployment.py +9 -4
  258. claude_mpm/services/version_service.py +104 -1
  259. claude_mpm/skills/__init__.py +21 -0
  260. claude_mpm/skills/bundled/__init__.py +6 -0
  261. claude_mpm/skills/bundled/api-documentation.md +393 -0
  262. claude_mpm/skills/bundled/async-testing.md +571 -0
  263. claude_mpm/skills/bundled/code-review.md +143 -0
  264. claude_mpm/skills/bundled/database-migration.md +199 -0
  265. claude_mpm/skills/bundled/docker-containerization.md +194 -0
  266. claude_mpm/skills/bundled/express-local-dev.md +1429 -0
  267. claude_mpm/skills/bundled/fastapi-local-dev.md +1199 -0
  268. claude_mpm/skills/bundled/git-workflow.md +414 -0
  269. claude_mpm/skills/bundled/imagemagick.md +204 -0
  270. claude_mpm/skills/bundled/json-data-handling.md +223 -0
  271. claude_mpm/skills/bundled/nextjs-local-dev.md +807 -0
  272. claude_mpm/skills/bundled/pdf.md +141 -0
  273. claude_mpm/skills/bundled/performance-profiling.md +567 -0
  274. claude_mpm/skills/bundled/refactoring-patterns.md +180 -0
  275. claude_mpm/skills/bundled/security-scanning.md +327 -0
  276. claude_mpm/skills/bundled/systematic-debugging.md +473 -0
  277. claude_mpm/skills/bundled/test-driven-development.md +378 -0
  278. claude_mpm/skills/bundled/vite-local-dev.md +1061 -0
  279. claude_mpm/skills/bundled/web-performance-optimization.md +2305 -0
  280. claude_mpm/skills/bundled/xlsx.md +157 -0
  281. claude_mpm/skills/registry.py +286 -0
  282. claude_mpm/skills/skill_manager.py +310 -0
  283. claude_mpm/storage/state_storage.py +15 -15
  284. claude_mpm/tools/code_tree_analyzer.py +177 -141
  285. claude_mpm/tools/code_tree_events.py +4 -2
  286. claude_mpm/utils/agent_dependency_loader.py +40 -20
  287. claude_mpm/utils/display_helper.py +260 -0
  288. claude_mpm/utils/git_analyzer.py +407 -0
  289. claude_mpm/utils/robust_installer.py +73 -19
  290. {claude_mpm-4.7.4.dist-info → claude_mpm-4.18.2.dist-info}/METADATA +129 -12
  291. {claude_mpm-4.7.4.dist-info → claude_mpm-4.18.2.dist-info}/RECORD +295 -193
  292. claude_mpm/dashboard/static/css/code-tree.css +0 -1639
  293. claude_mpm/dashboard/static/index-hub-backup.html +0 -713
  294. claude_mpm/dashboard/static/js/components/code-tree/tree-breadcrumb.js +0 -353
  295. claude_mpm/dashboard/static/js/components/code-tree/tree-constants.js +0 -235
  296. claude_mpm/dashboard/static/js/components/code-tree/tree-search.js +0 -409
  297. claude_mpm/dashboard/static/js/components/code-tree/tree-utils.js +0 -435
  298. claude_mpm/dashboard/static/js/components/code-tree.js +0 -5869
  299. claude_mpm/dashboard/static/js/components/code-viewer.js +0 -1386
  300. claude_mpm/hooks/claude_hooks/hook_handler_eventbus.py +0 -425
  301. claude_mpm/hooks/claude_hooks/hook_handler_original.py +0 -1041
  302. claude_mpm/hooks/claude_hooks/hook_handler_refactored.py +0 -347
  303. claude_mpm/services/agents/deployment/agent_lifecycle_manager_refactored.py +0 -575
  304. claude_mpm/services/project/analyzer_refactored.py +0 -450
  305. {claude_mpm-4.7.4.dist-info → claude_mpm-4.18.2.dist-info}/WHEEL +0 -0
  306. {claude_mpm-4.7.4.dist-info → claude_mpm-4.18.2.dist-info}/entry_points.txt +0 -0
  307. {claude_mpm-4.7.4.dist-info → claude_mpm-4.18.2.dist-info}/licenses/LICENSE +0 -0
  308. {claude_mpm-4.7.4.dist-info → claude_mpm-4.18.2.dist-info}/top_level.txt +0 -0
@@ -160,203 +160,23 @@ class OutputStyleManager:
160
160
 
161
161
  def extract_output_style_content(self, framework_loader=None) -> str:
162
162
  """
163
- Extract output style content from framework instructions.
164
-
165
- This extracts PM delegation behavior, tone, communication standards,
166
- response formats, TodoWrite requirements, and workflow rules from:
167
- - INSTRUCTIONS.md
168
- - BASE_PM.md
163
+ Read output style content from OUTPUT_STYLE.md.
169
164
 
170
165
  Args:
171
- framework_loader: Optional FrameworkLoader instance to reuse loaded content
166
+ framework_loader: Optional framework loader (kept for compatibility, not used)
172
167
 
173
168
  Returns:
174
- Formatted output style content in YAML frontmatter + markdown format
169
+ Complete output style content from file
175
170
  """
176
- # Build the content sections
177
- sections = []
178
-
179
- # Add YAML frontmatter
180
- sections.append("---")
181
- sections.append("name: Claude MPM")
182
- sections.append(
183
- "description: Multi-Agent Project Manager orchestration mode for delegation and coordination"
184
- )
185
- sections.append("---")
186
- sections.append("")
187
-
188
- # Header
189
- sections.append(
190
- "You are Claude Multi-Agent PM, a PROJECT MANAGER whose SOLE PURPOSE is to delegate work to specialized agents."
191
- )
192
- sections.append("")
193
-
194
- # Extract from INSTRUCTIONS.md
195
- if framework_loader and framework_loader.framework_content.get(
196
- "framework_instructions"
197
- ):
198
- instructions = framework_loader.framework_content["framework_instructions"]
199
- sections.extend(self._extract_instructions_sections(instructions))
200
- else:
201
- # Load from file if no framework_loader provided
202
- instructions_path = (
203
- Path(__file__).parent.parent / "agents" / "INSTRUCTIONS.md"
204
- )
205
- if instructions_path.exists():
206
- instructions = instructions_path.read_text()
207
- sections.extend(self._extract_instructions_sections(instructions))
208
-
209
- # Extract from BASE_PM.md
210
- if framework_loader and framework_loader.framework_content.get(
211
- "base_pm_instructions"
212
- ):
213
- base_pm = framework_loader.framework_content["base_pm_instructions"]
214
- sections.extend(self._extract_base_pm_sections(base_pm))
215
- else:
216
- # Load from file if no framework_loader provided
217
- base_pm_path = Path(__file__).parent.parent / "agents" / "BASE_PM.md"
218
- if base_pm_path.exists():
219
- base_pm = base_pm_path.read_text()
220
- sections.extend(self._extract_base_pm_sections(base_pm))
221
-
222
- return "\n".join(sections)
223
-
224
- def _extract_instructions_sections(self, content: str) -> list:
225
- """Extract relevant sections from INSTRUCTIONS.md."""
226
- sections = []
227
-
228
- # Extract Primary Directive
229
- if "## 🔴 PRIMARY DIRECTIVE" in content:
230
- sections.append("## 🔴 PRIMARY DIRECTIVE - MANDATORY DELEGATION 🔴")
231
- sections.append("")
232
- sections.append(
233
- "**YOU ARE STRICTLY FORBIDDEN FROM DOING ANY WORK DIRECTLY.**"
234
- )
235
- sections.append("")
236
- sections.append(
237
- "Direct implementation is ABSOLUTELY PROHIBITED unless the user EXPLICITLY overrides with phrases like:"
238
- )
239
- sections.append('- "do this yourself"')
240
- sections.append('- "don\'t delegate"')
241
- sections.append('- "implement directly"')
242
- sections.append('- "you do it"')
243
- sections.append('- "no delegation"')
244
- sections.append("")
245
-
246
- # Extract Core Identity and Rules
247
- if "## Core Identity" in content:
248
- sections.append("## Core Operating Rules")
249
- sections.append("")
250
- sections.append("**DEFAULT BEHAVIOR - ALWAYS DELEGATE**:")
251
- sections.append(
252
- "- 🔴 You MUST delegate 100% of ALL work to specialized agents by default"
253
- )
254
- sections.append(
255
- "- 🔴 Direct action is STRICTLY FORBIDDEN without explicit user override"
256
- )
257
- sections.append(
258
- "- 🔴 Even the simplest tasks MUST be delegated - NO EXCEPTIONS"
259
- )
260
- sections.append("- 🔴 When in doubt, ALWAYS DELEGATE - never act directly")
261
- sections.append("")
262
- sections.append("**Allowed Tools**:")
263
- sections.append("- **Task** for delegation (YOUR PRIMARY FUNCTION)")
264
- sections.append("- **TodoWrite** for tracking delegation progress ONLY")
265
- sections.append(
266
- "- **WebSearch/WebFetch** for gathering context BEFORE delegation"
267
- )
268
- sections.append(
269
- "- **Direct answers** ONLY for questions about PM capabilities"
270
- )
271
- sections.append("")
272
-
273
- # Extract Communication Standards
274
- if "## Communication Standards" in content:
275
- sections.append("## Communication Standards")
276
- sections.append("")
277
- sections.append("- **Tone**: Professional, neutral by default")
278
- sections.append('- **Use**: "Understood", "Confirmed", "Noted"')
279
- sections.append("- **No simplification** without explicit user request")
280
- sections.append("- **No mocks** outside test environments")
281
- sections.append("- **Complete implementations** only - no placeholders")
282
- sections.append(
283
- '- **FORBIDDEN**: Overeager enthusiasm ("Excellent!", "Perfect!", "Amazing!")'
284
- )
285
- sections.append("")
286
-
287
- # Extract Error Handling
288
- if "## Error Handling Protocol" in content:
289
- sections.append("## Error Handling Protocol")
290
- sections.append("")
291
- sections.append("**3-Attempt Process**:")
292
- sections.append("1. **First Failure**: Re-delegate with enhanced context")
293
- sections.append(
294
- '2. **Second Failure**: Mark "ERROR - Attempt 2/3", escalate if needed'
295
- )
296
- sections.append(
297
- "3. **Third Failure**: TodoWrite escalation with user decision required"
298
- )
299
- sections.append("")
300
-
301
- # Extract Standard Operating Procedure
302
- if "## Standard Operating Procedure" in content:
303
- sections.append("## Standard Operating Procedure")
304
- sections.append("")
305
- sections.append("1. **Analysis**: Parse request, assess context (NO TOOLS)")
306
- sections.append(
307
- "2. **Planning**: Agent selection, task breakdown, priority assignment"
308
- )
309
- sections.append("3. **Delegation**: Task Tool with enhanced format")
310
- sections.append("4. **Monitoring**: Track progress via TodoWrite")
311
- sections.append("5. **Integration**: Synthesize results, validate, report")
312
- sections.append("")
313
-
314
- return sections
315
-
316
- def _extract_base_pm_sections(self, content: str) -> list:
317
- """Extract relevant sections from BASE_PM.md."""
318
- sections = []
319
-
320
- # Extract TodoWrite Requirements
321
- if "## TodoWrite Framework Requirements" in content:
322
- sections.append("## TodoWrite Requirements")
323
- sections.append("")
324
- sections.append("### Mandatory [Agent] Prefix Rules")
325
- sections.append("")
326
- sections.append("**ALWAYS use [Agent] prefix for delegated tasks**:")
327
- sections.append("- ✅ `[Research] Analyze authentication patterns`")
328
- sections.append("- ✅ `[Engineer] Implement user registration`")
329
- sections.append("- ✅ `[QA] Test payment flow`")
330
- sections.append("- ✅ `[Documentation] Update API docs`")
331
- sections.append("")
332
- sections.append("**NEVER use [PM] prefix for implementation tasks**")
333
- sections.append("")
334
- sections.append("### Task Status Management")
335
- sections.append("")
336
- sections.append("- `pending` - Task not yet started")
337
- sections.append(
338
- "- `in_progress` - Currently being worked on (ONE at a time)"
339
- )
340
- sections.append("- `completed` - Task finished successfully")
341
- sections.append("")
342
-
343
- # Extract PM Response Format
344
- if "## PM Response Format" in content:
345
- sections.append("## Response Format")
346
- sections.append("")
347
- sections.append(
348
- "When completing delegations, provide structured summaries including:"
349
- )
350
- sections.append("- Request summary")
351
- sections.append("- Agents used and task counts")
352
- sections.append("- Tasks completed with [Agent] prefixes")
353
- sections.append("- Files affected across all agents")
354
- sections.append("- Blockers encountered and resolutions")
355
- sections.append("- Next steps for user")
356
- sections.append("- Key information to remember")
357
- sections.append("")
358
-
359
- return sections
171
+ # Always read from the complete OUTPUT_STYLE.md file
172
+ if self.mpm_output_style_path.exists():
173
+ content = self.mpm_output_style_path.read_text()
174
+ self.logger.info(f"Read OUTPUT_STYLE.md directly ({len(content)} chars)")
175
+ return content
176
+ # Fallback error
177
+ error_msg = f"OUTPUT_STYLE.md not found at {self.mpm_output_style_path}"
178
+ self.logger.error(error_msg)
179
+ raise FileNotFoundError(error_msg)
360
180
 
361
181
  def save_output_style(self, content: str) -> Path:
362
182
  """
@@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, Union
10
10
  from .base_service import BaseService
11
11
  from .config import Config
12
12
  from .container import DIContainer, ServiceLifetime, get_container
13
+ from .enums import OperationResult
13
14
  from .logger import get_logger
14
15
  from .shared.config_loader import ConfigLoader
15
16
 
@@ -249,7 +250,10 @@ class ServiceRegistry:
249
250
  "metrics": health.metrics,
250
251
  }
251
252
  except Exception as e:
252
- health_status[name] = {"status": "error", "message": str(e)}
253
+ health_status[name] = {
254
+ "status": OperationResult.ERROR,
255
+ "message": str(e),
256
+ }
253
257
 
254
258
  return health_status
255
259
 
claude_mpm/core/types.py CHANGED
@@ -20,6 +20,8 @@ from datetime import datetime, timezone
20
20
  from enum import Enum
21
21
  from typing import Any, Dict, List, Optional, Tuple, Union
22
22
 
23
+ from .enums import HealthStatus
24
+
23
25
 
24
26
  # Service operation results
25
27
  @dataclass
@@ -230,15 +232,6 @@ class SocketMessage:
230
232
 
231
233
 
232
234
  # Health monitoring types
233
- class HealthStatus(Enum):
234
- """Service health status levels."""
235
-
236
- HEALTHY = "healthy"
237
- DEGRADED = "degraded"
238
- UNHEALTHY = "unhealthy"
239
- UNKNOWN = "unknown"
240
-
241
-
242
235
  @dataclass
243
236
  class HealthCheck:
244
237
  """Health check result."""
@@ -32,6 +32,8 @@ from typing import (
32
32
 
33
33
  from typing_extensions import NotRequired, TypeAlias, TypedDict
34
34
 
35
+ from claude_mpm.core.enums import OperationResult, ServiceState
36
+
35
37
  # Generic type variables
36
38
  T = TypeVar("T")
37
39
  TSession = TypeVar("TSession") # Generic session type
@@ -42,15 +44,14 @@ TService = TypeVar("TService") # Generic service type
42
44
  PathLike: TypeAlias = Union[str, Path]
43
45
  JSONValue: TypeAlias = Union[str, int, float, bool, None, Dict[str, Any], List[Any]]
44
46
  JSONDict: TypeAlias = Dict[str, JSONValue]
47
+
45
48
  Headers: TypeAlias = Dict[str, str]
46
49
  ErrorCode: TypeAlias = Union[int, str]
47
50
  LogLevel: TypeAlias = Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
48
51
 
49
52
  # Session types
50
53
  SessionId: TypeAlias = str
51
- SessionStatus: TypeAlias = Literal[
52
- "initializing", "running", "stopped", "error", "completed"
53
- ]
54
+ SessionStatus: TypeAlias = ServiceState # Replaced Literal with ServiceState enum
54
55
  LaunchMethod: TypeAlias = Literal["exec", "subprocess", "oneshot"]
55
56
 
56
57
 
@@ -152,7 +153,7 @@ class WebSocketMessage(TypedDict):
152
153
  class ClaudeStatus(TypedDict):
153
154
  """Claude process status."""
154
155
 
155
- status: Literal["starting", "running", "stopped", "error"]
156
+ status: ServiceState # Replaced Literal with ServiceState enum
156
157
  message: str
157
158
  timestamp: NotRequired[datetime]
158
159
  pid: NotRequired[int]
@@ -163,7 +164,7 @@ class DelegationInfo(TypedDict):
163
164
 
164
165
  agent: AgentId
165
166
  task: str
166
- status: Literal["detected", "started", "completed", "failed"]
167
+ status: OperationResult # Replaced Literal with OperationResult enum
167
168
  timestamp: NotRequired[datetime]
168
169
  result: NotRequired[str]
169
170
 
@@ -194,7 +195,7 @@ class HookContext(TypedDict):
194
195
 
195
196
  # Service types
196
197
  ServiceName: TypeAlias = str
197
- ServiceStatus: TypeAlias = Literal["idle", "running", "stopped", "error"]
198
+ ServiceStatus: TypeAlias = ServiceState # Replaced Literal with ServiceState enum
198
199
 
199
200
 
200
201
  class ServiceConfig(TypedDict):
@@ -321,14 +321,6 @@ class Dashboard {
321
321
  // Process agent inference for new events
322
322
  this.agentInference.processAgentInference();
323
323
 
324
- // Notify CodeViewer that file operations have been updated
325
- // This ensures File Tree tab shows the same data as Files tab
326
- if (window.CodeViewer && typeof window.CodeViewer.refreshFromFileToolTracker === 'function') {
327
- setTimeout(() => {
328
- window.CodeViewer.refreshFromFileToolTracker();
329
- }, 50);
330
- }
331
-
332
324
  // Update agent hierarchy with new events
333
325
  this.agentHierarchy.updateWithNewEvents(events);
334
326
 
@@ -445,12 +437,6 @@ class Dashboard {
445
437
  case 'events':
446
438
  // Events tab is handled by EventViewer
447
439
  break;
448
- case 'claude-tree':
449
- // File Tree tab - trigger CodeViewer rendering
450
- if (window.CodeViewer && typeof window.CodeViewer.show === 'function') {
451
- window.CodeViewer.show();
452
- }
453
- break;
454
440
  case 'activity':
455
441
  // Trigger Activity tab rendering through the component
456
442
  // Check if ActivityTree class is available (from built module)
@@ -33,7 +33,6 @@
33
33
  <link rel="stylesheet" href="/static/css/dashboard.css">
34
34
  <link rel="stylesheet" href="/static/css/connection-status.css">
35
35
  <link rel="stylesheet" href="/static/css/activity.css">
36
- <link rel="stylesheet" href="/static/css/code-tree.css">
37
36
 
38
37
  <!-- Additional styles for file operations -->
39
38
  <style>
@@ -258,7 +257,6 @@
258
257
  <a href="#tools" class="tab-button" data-tab="tools">🔧 Tools</a>
259
258
  <a href="#files" class="tab-button" data-tab="files">📁 Files</a>
260
259
  <a href="#activity" class="tab-button" data-tab="activity">🌳 Activity</a>
261
- <a href="#file_tree" class="tab-button" data-tab="claude-tree">📝 File Tree</a>
262
260
  </div>
263
261
 
264
262
  <!-- Events Tab -->
@@ -397,15 +395,6 @@
397
395
  </div>
398
396
  </div>
399
397
 
400
- <!-- File Tree Tab -->
401
- <div class="tab-content" id="claude-tree-tab">
402
- <div id="claude-tree-container" style="width: 100%; height: 100%; position: relative;">
403
- <!-- File activity tree will be rendered here by code-viewer.js -->
404
- <!-- This container is ISOLATED from other tabs -->
405
- </div>
406
- </div>
407
-
408
-
409
398
  </div>
410
399
  </div>
411
400
  </div>
@@ -489,16 +478,12 @@
489
478
  });
490
479
  };
491
480
 
492
- // Load shared services first, then tree modules, then components
481
+ // Load shared services first, then components
493
482
  // Load services sequentially to ensure dependencies are available
494
483
  loadModule('/static/js/shared/tooltip-service.js')
495
484
  .then(() => loadModule('/static/js/shared/dom-helpers.js'))
496
485
  .then(() => loadModule('/static/js/shared/event-bus.js'))
497
486
  .then(() => loadModule('/static/js/shared/logger.js'))
498
- .then(() => loadModule('/static/js/components/code-tree/tree-utils.js'))
499
- .then(() => loadModule('/static/js/components/code-tree/tree-constants.js'))
500
- .then(() => loadModule('/static/js/components/code-tree/tree-search.js'))
501
- .then(() => loadModule('/static/js/components/code-tree/tree-breadcrumb.js'))
502
487
  .then(() => {
503
488
  // CRITICAL: Load socket-client.js FIRST (dependency of socket-manager)
504
489
  return loadModule('/static/js/socket-client.js');
@@ -530,29 +515,15 @@
530
515
  return Promise.all([
531
516
  loadModule('/static/dist/dashboard.js'), // Use dist version that requires above components
532
517
  loadModule('/static/dist/components/activity-tree.js'),
533
- loadModule('/static/js/components/code-tree.js'), // TEMPORARY: Direct source for debugging
534
- loadModule('/static/js/components/code-viewer.js').catch(err => {
535
- console.error('[CRITICAL] Failed to load code-viewer.js:', err);
536
- throw err;
537
- }), // Code viewer now includes file change tracking
538
518
  loadModule('/static/dist/components/file-viewer.js') // File viewer for viewing file contents
539
519
  ]);
540
520
  })
541
521
  .then(() => {
542
522
  console.log('All dashboard modules loaded successfully');
543
-
544
- // Debug: Check if CodeViewer loaded
545
- if (window.CodeViewer) {
546
- console.log('[DEBUG] CodeViewer is available on window object');
547
- } else {
548
- console.error('[ERROR] CodeViewer NOT FOUND on window object!');
549
- }
550
-
551
- // CodeViewer will auto-initialize and handle tab switching internally
552
-
523
+
553
524
  // Browser Log Viewer initialization is now handled by UIStateManager
554
525
  // This prevents duplicate event handlers and tab selection conflicts
555
-
526
+
556
527
  // Load bulletproof tab isolation fix
557
528
  loadModule('/static/js/tab-isolation-fix.js')
558
529
  .then(() => {
@@ -564,15 +535,6 @@
564
535
 
565
536
  // Hash navigation will handle default tab based on URL
566
537
  // If no hash, default will be 'events' as per hashToTab mapping
567
- // To start with File Tree, we can set hash if not present
568
- setTimeout(() => {
569
- if (!window.location.hash) {
570
- console.log('No hash present, setting default to File Tree tab...');
571
- window.location.hash = '#file_tree';
572
- } else {
573
- console.log('Hash present:', window.location.hash);
574
- }
575
- }, 500);
576
538
  })
577
539
  .catch(error => {
578
540
  console.error('[CRITICAL] Error loading dashboard modules:', error);
@@ -1,13 +1,33 @@
1
1
  """Hook system for claude-mpm."""
2
2
 
3
3
  from .base_hook import BaseHook, HookContext, HookResult, HookType
4
+ from .failure_learning import (
5
+ FailureDetectionHook,
6
+ FixDetectionHook,
7
+ LearningExtractionHook,
8
+ get_failure_detection_hook,
9
+ get_fix_detection_hook,
10
+ get_learning_extraction_hook,
11
+ )
12
+ from .kuzu_enrichment_hook import KuzuEnrichmentHook, get_kuzu_enrichment_hook
4
13
  from .kuzu_memory_hook import KuzuMemoryHook, get_kuzu_memory_hook
14
+ from .kuzu_response_hook import KuzuResponseHook, get_kuzu_response_hook
5
15
 
6
16
  __all__ = [
7
17
  "BaseHook",
18
+ "FailureDetectionHook",
19
+ "FixDetectionHook",
8
20
  "HookContext",
9
21
  "HookResult",
10
22
  "HookType",
23
+ "KuzuEnrichmentHook",
11
24
  "KuzuMemoryHook",
25
+ "KuzuResponseHook",
26
+ "LearningExtractionHook",
27
+ "get_failure_detection_hook",
28
+ "get_fix_detection_hook",
29
+ "get_kuzu_enrichment_hook",
12
30
  "get_kuzu_memory_hook",
31
+ "get_kuzu_response_hook",
32
+ "get_learning_extraction_hook",
13
33
  ]
@@ -312,14 +312,16 @@ class EventHandlers:
312
312
  if not working_dir:
313
313
  working_dir = Path.cwd()
314
314
 
315
- # Check cache first (cache for 30 seconds)
315
+ # Check cache first (cache for 300 seconds = 5 minutes)
316
+ # WHY 5 minutes: Git branches rarely change during development sessions,
317
+ # reducing subprocess overhead significantly without staleness issues
316
318
  current_time = datetime.now(timezone.utc).timestamp()
317
319
  cache_key = working_dir
318
320
 
319
321
  if (
320
322
  cache_key in self.hook_handler._git_branch_cache
321
323
  and cache_key in self.hook_handler._git_branch_cache_time
322
- and current_time - self.hook_handler._git_branch_cache_time[cache_key] < 30
324
+ and current_time - self.hook_handler._git_branch_cache_time[cache_key] < 300
323
325
  ):
324
326
  return self.hook_handler._git_branch_cache[cache_key]
325
327
 
@@ -268,7 +268,10 @@ class ResponseTrackingManager:
268
268
  def track_stop_response(
269
269
  self, event: dict, session_id: str, metadata: dict, pending_prompts: dict
270
270
  ):
271
- """Track response for stop events."""
271
+ """Track response for stop events.
272
+
273
+ Captures Claude API stop_reason and usage data for context management.
274
+ """
272
275
  if not (self.response_tracking_enabled and self.response_tracker):
273
276
  return
274
277
 
@@ -294,6 +297,37 @@ class ResponseTrackingManager:
294
297
  # Add prompt timestamp to metadata
295
298
  metadata["prompt_timestamp"] = prompt_data.get("timestamp")
296
299
 
300
+ # Capture Claude API stop_reason if available
301
+ if "stop_reason" in event:
302
+ metadata["stop_reason"] = event["stop_reason"]
303
+ if DEBUG:
304
+ print(
305
+ f" - Captured stop_reason: {event['stop_reason']}",
306
+ file=sys.stderr,
307
+ )
308
+
309
+ # Capture Claude API usage data if available
310
+ if "usage" in event:
311
+ usage_data = event["usage"]
312
+ metadata["usage"] = {
313
+ "input_tokens": usage_data.get("input_tokens", 0),
314
+ "output_tokens": usage_data.get("output_tokens", 0),
315
+ "cache_creation_input_tokens": usage_data.get(
316
+ "cache_creation_input_tokens", 0
317
+ ),
318
+ "cache_read_input_tokens": usage_data.get(
319
+ "cache_read_input_tokens", 0
320
+ ),
321
+ }
322
+ if DEBUG:
323
+ total_tokens = usage_data.get(
324
+ "input_tokens", 0
325
+ ) + usage_data.get("output_tokens", 0)
326
+ print(
327
+ f" - Captured usage: {total_tokens} total tokens",
328
+ file=sys.stderr,
329
+ )
330
+
297
331
  # Track the main Claude response
298
332
  file_path = self.response_tracker.track_response(
299
333
  agent_name="claude_main",
@@ -12,6 +12,7 @@ This eliminates disconnection issues and matches the process lifecycle.
12
12
  import asyncio
13
13
  import os
14
14
  import sys
15
+ from concurrent.futures import ThreadPoolExecutor
15
16
  from datetime import datetime, timezone
16
17
 
17
18
  # Debug mode is enabled by default for better visibility into hook processing
@@ -79,6 +80,13 @@ class ConnectionManagerService:
79
80
  # Track async emit tasks to prevent garbage collection
80
81
  self._emit_tasks: set = set()
81
82
 
83
+ # Thread pool for non-blocking HTTP requests
84
+ # WHY: Prevents HTTP POST from blocking hook processing (2s timeout → 0ms blocking)
85
+ # max_workers=2: Sufficient for low-frequency HTTP fallback events
86
+ self._http_executor = ThreadPoolExecutor(
87
+ max_workers=2, thread_name_prefix="http-emit"
88
+ )
89
+
82
90
  if DEBUG:
83
91
  print(
84
92
  f"✅ HTTP connection manager initialized - endpoint: {self.http_endpoint}",
@@ -181,7 +189,11 @@ class ConnectionManagerService:
181
189
  return False
182
190
 
183
191
  def _try_http_emit(self, namespace: str, event: str, data: dict):
184
- """Try to emit event using HTTP POST fallback."""
192
+ """Try to emit event using HTTP POST fallback (non-blocking).
193
+
194
+ WHY non-blocking: HTTP POST can take up to 2 seconds (timeout),
195
+ blocking hook processing. Thread pool makes it fire-and-forget.
196
+ """
185
197
  if not REQUESTS_AVAILABLE:
186
198
  if DEBUG:
187
199
  print(
@@ -190,6 +202,11 @@ class ConnectionManagerService:
190
202
  )
191
203
  return
192
204
 
205
+ # Submit to thread pool - don't wait for result (fire-and-forget)
206
+ self._http_executor.submit(self._http_emit_blocking, namespace, event, data)
207
+
208
+ def _http_emit_blocking(self, namespace: str, event: str, data: dict):
209
+ """HTTP emission in background thread (blocking operation isolated)."""
193
210
  try:
194
211
  # Create payload for HTTP API
195
212
  payload = {
@@ -230,4 +247,8 @@ class ConnectionManagerService:
230
247
 
231
248
  def cleanup(self):
232
249
  """Cleanup connections on service destruction."""
233
- # Nothing to cleanup for HTTP POST approach
250
+ # Shutdown HTTP executor gracefully
251
+ if hasattr(self, "_http_executor"):
252
+ self._http_executor.shutdown(wait=False)
253
+ if DEBUG:
254
+ print("✅ HTTP executor shutdown", file=sys.stderr)
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Failure-Learning Hook System
4
+ =============================
5
+
6
+ Automatic learning extraction from failure-fix cycles.
7
+
8
+ WHY: When tasks fail and agents fix them, valuable knowledge is created. This
9
+ hook system automatically captures failures, detects fixes, and extracts learnings
10
+ without requiring manual intervention.
11
+
12
+ Components:
13
+ - FailureDetectionHook (priority 85): Detects task failures from tool outputs
14
+ - FixDetectionHook (priority 87): Matches successful executions with failures
15
+ - LearningExtractionHook (priority 89): Synthesizes and persists learnings
16
+
17
+ Integration:
18
+ The hooks work together as a chain:
19
+ 1. Tool executes and fails → FailureDetectionHook records failure
20
+ 2. User or agent makes changes
21
+ 3. Tool executes and succeeds → FixDetectionHook detects fix
22
+ 4. Fix matched with failure → LearningExtractionHook creates learning
23
+ 5. Learning written to agent memory file
24
+
25
+ Usage:
26
+ from claude_mpm.hooks.failure_learning import (
27
+ get_failure_detection_hook,
28
+ get_fix_detection_hook,
29
+ get_learning_extraction_hook,
30
+ )
31
+
32
+ # Register hooks with hook service
33
+ hook_service.register_hook(get_failure_detection_hook())
34
+ hook_service.register_hook(get_fix_detection_hook())
35
+ hook_service.register_hook(get_learning_extraction_hook())
36
+ """
37
+
38
+ from .failure_detection_hook import (
39
+ FailureDetectionHook,
40
+ get_failure_detection_hook,
41
+ )
42
+ from .fix_detection_hook import (
43
+ FixDetectionHook,
44
+ get_fix_detection_hook,
45
+ )
46
+ from .learning_extraction_hook import (
47
+ LearningExtractionHook,
48
+ get_learning_extraction_hook,
49
+ )
50
+
51
+ __all__ = [
52
+ # Hooks
53
+ "FailureDetectionHook",
54
+ "FixDetectionHook",
55
+ "LearningExtractionHook",
56
+ # Factory functions
57
+ "get_failure_detection_hook",
58
+ "get_fix_detection_hook",
59
+ "get_learning_extraction_hook",
60
+ ]